@rebasepro/cms 0.30.0 → 0.31.0-canary.g59cd6fd
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":"CollectionTableBinding.js","names":[],"sources":["../../../src/components/CollectionTableBinding/CollectionTableBinding.tsx"],"sourcesContent":["import type { AdditionalFieldDelegate, AdminCollection } from \"@rebasepro/cms-types\";\nimport { AdditionalFieldValue } from \"../AdditionalFieldValue\";\nimport { rowOfEntity } from \"@rebasepro/app\";\nimport React, { useCallback, useContext, useMemo, useRef } from \"react\";\nimport { Entity, User, Property } from \"@rebasepro/types\";\nimport { CollectionSize, RebaseContext } from \"@rebasepro/cms-types\";\nimport { PropertyTableCell } from \"./PropertyTableCell\";\nimport { ErrorBoundary } from \"@rebasepro/ui\";\nimport { useRebaseContext, useCollectionScope, useCustomizationController } from \"@rebasepro/app\";\nimport { useCollectionLargeLayout } from \"../CollectionViewBinding/useCollectionLargeLayout\";\nimport { CellRendererParams, VirtualTableColumn } from \"@rebasepro/ui\";\nimport { CollectionRowActions } from \"./CollectionRowActions\";\nimport { CollectionTableToolbar } from \"./internal/CollectionTableToolbar\";\nimport { CollectionTableBindingProps } from \"./CollectionTableBindingProps\";\nimport { EntityTableCell } from \"./internal/EntityTableCell\";\nimport { CustomFieldValidator } from \"../../form/validation\";\nimport { renderSkeletonText, useDateFnsLocale } from \"../../preview\";\nimport { propertiesToColumns } from \"./column_utils\";\nimport { ErrorView } from \"@rebasepro/app\";\nimport { SelectableTable } from \"../SelectableTable/SelectableTable\";\nimport { cls } from \"@rebasepro/ui\";\nimport { getRowHeight, isDisabled } from \"@rebasepro/app\";\nimport { getValueInPath } from \"@rebasepro/utils\";\nimport { deepEqual as equal } from \"fast-equals\";\n\n/**\n * This component is in charge of rendering a collection table with a high\n * degree of customization.\n *\n * This component is used internally by {@link CollectionViewBinding} and\n * {@link useReferenceDialog}\n *\n * Please note that you only need to use this component if you are building\n * a custom view. If you just need to create a default view you can do it\n * exclusively with config options.\n *\n * If you want to bind a {@link AdminCollection} to a table with the default\n * options you see in collections in the top level navigation, you can\n * check {@link CollectionViewBinding}.\n *\n * The data displayed in the table is managed by a {@link EntityTableController}.\n * You can build the default, bound to a path in the driver, by using the hook\n * {@link useDataTableController}\n *\n * @see CollectionTableBindingProps\n * @see CollectionViewBinding\n * @see VirtualTable\n * @group Components\n */\nexport const CollectionTableBinding = function CollectionTableBinding<M extends Record<string, unknown> = Record<string, unknown>, USER extends User = User>\n ({\n className,\n style,\n fixedFilter,\n actionsStart,\n actions,\n viewModeToggle,\n title,\n tableRowActionsBuilder,\n uniqueFieldValidator,\n getPropertyFor,\n onValueChange,\n selectionController,\n highlightedEntities,\n onEntityClick,\n onColumnResize,\n initialScroll,\n onScroll,\n onSizeChanged,\n\n hoverRow = true,\n inlineEditing = false,\n additionalFields,\n displayedColumnIds,\n defaultSize,\n properties,\n tableController,\n filterable = true,\n sortable = true,\n endAdornment,\n AddColumnComponent,\n AdditionalHeaderWidget,\n additionalIDHeaderWidget,\n emptyComponent,\n getIdColumnWidth,\n enablePopupIcon,\n openEntityMode = \"side_panel\",\n onColumnsOrderChange,\n hideToolbar = false\n }: CollectionTableBindingProps<M>) {\n\n const ref = useRef<HTMLDivElement>(null);\n\n const largeLayout = useCollectionLargeLayout();\n // Asked per row rather than held as a list: a query selection has no list,\n // and the one this replaced would have answered with whatever the view had\n // scrolled. `highlightedEntities` is the fallback the table has always had\n // — the row you navigated to, shown lit when nothing is selected.\n const hasSelection = Boolean(selectionController?.hasSelection);\n const isRowHighlighted = useCallback((entity: Entity<M>) => {\n if (hasSelection) return selectionController!.isEntitySelected(entity);\n return Boolean(highlightedEntities?.some(e => e && e.id === entity.id && e.path === entity.path));\n }, [hasSelection, selectionController, highlightedEntities]);\n\n // What the row actions are drawn from besides their row. Handed down by\n // context rather than through the cell renderer, so that a change here\n // draws the id column of each row and nothing else: it used to be the\n // cells' memo key, and ticking one checkbox re-ran the renderer of every\n // cell on screen (~460) to redraw the one column that shows a selection.\n //\n // The selection and the highlighted rows are dependencies, not fields: a\n // builder may read either from its closure, and a change to them has to\n // reach the actions it built. The highlighted rows by identity, not by\n // array: a caller passing a new `[]` each render changes nothing.\n const highlightedKey = JSON.stringify(highlightedEntities?.map(e => e ? [e.path, e.id] : null) ?? []);\n const rowActionsContext: RowActionsContextValue<M> = useMemo(() => ({\n tableRowActionsBuilder,\n openEntityMode\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }), [tableRowActionsBuilder, openEntityMode, selectionController?.selection, highlightedKey]);\n\n const context: RebaseContext<USER> = useRebaseContext<USER>();\n\n const [size, setSize] = React.useState<CollectionSize>(defaultSize ?? \"m\");\n\n // Sync internal size with defaultSize prop when it changes\n React.useEffect(() => {\n if (defaultSize) {\n setSize(defaultSize);\n }\n }, [defaultSize]);\n\n const updateSize = useCallback((size: CollectionSize) => {\n if (onSizeChanged)\n onSizeChanged(size);\n setSize(size);\n }, []);\n\n const onTextSearch = useCallback((newSearchString?: string) => tableController.setSearchString?.(newSearchString), []);\n\n const additionalFieldsMap: Record<string, AdditionalFieldDelegate<M, USER>> = useMemo(() => {\n return (additionalFields\n ? additionalFields\n .map((aC) => ({ [aC.key]: aC as AdditionalFieldDelegate<M, USER> }))\n .reduce((a, b) => ({ ...a,\n...b }), {})\n : {}) as Record<string, AdditionalFieldDelegate<M, USER>>;\n }, [additionalFields]);\n\n const customFieldValidator: CustomFieldValidator | undefined = uniqueFieldValidator;\n\n const propertyCellRenderer = useCallback(({\n column,\n columnIndex,\n rowData,\n rowIndex,\n sortableNodeRef,\n sortableStyle,\n sortableAttributes,\n isDragging,\n isDraggable,\n frozen\n }: CellRendererParams<Entity<M>>) => {\n\n const entity: Entity<M> | undefined = rowData;\n if (!entity) return null;\n\n const propertyKey = column.key;\n\n const columnCustom = column.custom as { disabled?: boolean; resolvedProperty?: Property } | undefined;\n let disabled: boolean = columnCustom?.disabled ?? false;\n const property = getPropertyFor?.({\n propertyKey,\n entity\n }) ?? columnCustom?.resolvedProperty;\n if (!property || !isDisabled(property)) {\n disabled = false;\n }\n\n if (!property) {\n return null;\n }\n\n return (\n <ErrorBoundary>\n {entity\n ? <PropertyTableCell\n key={`property_table_cell_${entity.id}_${propertyKey}`}\n readonly={!inlineEditing}\n align={column.align ?? \"left\"}\n propertyKey={propertyKey as string}\n property={property}\n value={entity?.values ? getValueInPath(entity.values, propertyKey) : undefined}\n customFieldValidator={customFieldValidator}\n columnIndex={columnIndex}\n width={column.width}\n height={getRowHeight(size)}\n entity={entity}\n disabled={disabled}\n enablePopupIcon={enablePopupIcon}\n path={entity.path}\n sortableNodeRef={sortableNodeRef}\n sortableStyle={sortableStyle}\n sortableAttributes={sortableAttributes}\n isDragging={isDragging}\n isDraggable={isDraggable}\n frozen={frozen}/>\n : renderSkeletonText()\n }\n </ErrorBoundary>);\n\n }, [getPropertyFor, customFieldValidator, inlineEditing, enablePopupIcon, size]);\n\n // The collection the rows are converted by when an additional field is\n // handed one: the table itself is given only its properties.\n const scopedCollection = useCollectionScope();\n // Same source the filter fields read their engine from, so the header's\n // filter control and the field it opens cannot disagree about what the\n // collection's driver can answer.\n const engine = scopedCollection?.engine;\n\n const additionalCellRenderer = useCallback(({\n column,\n rowData,\n width,\n sortableNodeRef,\n sortableStyle,\n sortableAttributes,\n isDragging,\n isDraggable,\n frozen\n }: CellRendererParams<Entity<M>>) => {\n\n const entity: Entity<M> | undefined = rowData;\n if (!entity) return null;\n\n const additionalField = additionalFieldsMap[column.key as string];\n const value = additionalField.dependencies\n ? Object.entries(entity.values)\n .filter(([key, value]) => additionalField.dependencies!.includes(key as Extract<keyof M, string>))\n .reduce((a, b) => ({ ...a,\n...b }), {})\n : entity;\n\n const Builder = additionalField.Builder;\n if (!Builder && !additionalField.value) {\n throw new Error(\"When using additional fields you need to provide a Builder or a value\");\n }\n\n const row = rowOfEntity(entity, scopedCollection);\n const id = String(entity.id);\n const child: React.ReactNode = Builder\n ? <Builder row={row} id={id} context={context}/>\n : <AdditionalFieldValue\n field={additionalField}\n row={row}\n id={id}\n context={context as RebaseContext}/>;\n\n return (\n <EntityTableCell\n key={`additional_table_cell_${entity.id}_${column.key}`}\n width={width}\n size={size}\n value={value}\n selected={false}\n disabled={true}\n align={\"left\"}\n allowScroll={false}\n showExpandIcon={false}\n disabledTooltip={\"This column can't be edited directly\"}\n sortableNodeRef={sortableNodeRef}\n sortableStyle={sortableStyle}\n sortableAttributes={sortableAttributes as Record<string, string | number | undefined>}\n isDragging={isDragging}\n isDraggable={isDraggable}\n frozen={frozen}\n >\n <ErrorBoundary>\n {child}\n </ErrorBoundary>\n </EntityTableCell>\n );\n\n }, [size, additionalFieldsMap, context, scopedCollection]);\n\n // Date columns are sized from the dates they will show, which depends on\n // how the admin formats them.\n const customizationController = useCustomizationController();\n const dateFnsLocale = useDateFnsLocale();\n const locale = customizationController?.locale;\n const dateTimeFormat = customizationController?.dateTimeFormat;\n const dateFormatting = useMemo(\n () => ({ locale, dateTimeFormat, dateFnsLocale }),\n [locale, dateTimeFormat, dateFnsLocale]\n );\n\n const collectionColumns: VirtualTableColumn[] = useMemo(() => {\n const columnsResult: VirtualTableColumn[] = propertiesToColumns({\n properties,\n sortable,\n fixedFilter,\n engine,\n dateFormatting,\n inlineEditing,\n AdditionalHeaderWidget\n });\n\n // Get keys from property columns to filter out duplicate additional fields\n const propertyColumnKeys = new Set(columnsResult.map(col => col.key));\n\n const additionalTableColumns: VirtualTableColumn[] = additionalFields\n // Filter out additional fields whose key already exists in property columns\n ? additionalFields\n .filter((additionalField) => !propertyColumnKeys.has(additionalField.key))\n .map((additionalField) =>\n ({\n key: additionalField.key,\n align: \"left\",\n sortable: false,\n title: additionalField.name,\n width: additionalField.width ?? 200\n }))\n : [];\n return [...columnsResult, ...additionalTableColumns];\n }, [properties, sortable, fixedFilter, engine, dateFormatting, inlineEditing, AdditionalHeaderWidget, additionalFields]);\n\n // Held by value: the widget is an element, and a caller that builds it\n // inline hands over a new one on every render. Each new one rebuilt the\n // id column, so the table's columns, so every cell on screen.\n const idHeaderWidgetRef = useRef(additionalIDHeaderWidget);\n if (idHeaderWidgetRef.current !== additionalIDHeaderWidget && !equal(idHeaderWidgetRef.current, additionalIDHeaderWidget)) {\n idHeaderWidgetRef.current = additionalIDHeaderWidget;\n }\n const stableIdHeaderWidget = idHeaderWidgetRef.current;\n\n const idColumn: VirtualTableColumn = useMemo(() => ({\n key: \"id_ewcfedcswdf3\",\n width: getIdColumnWidth?.(largeLayout) ?? (largeLayout ? 140 : 120),\n title: \"ID\",\n resizable: false,\n frozen: largeLayout,\n headerAlign: \"center\",\n align: \"center\",\n AdditionalHeaderWidget: () => stableIdHeaderWidget\n }), [getIdColumnWidth, largeLayout, stableIdHeaderWidget]);\n\n const columns: VirtualTableColumn[] = useMemo(() => [\n idColumn,\n ...(displayedColumnIds\n ? displayedColumnIds\n .map((p) => {\n return collectionColumns.find(c => c.key === p.key);\n }).filter(Boolean)\n : collectionColumns) as VirtualTableColumn[]\n ], [idColumn, displayedColumnIds, collectionColumns]);\n\n const cellRenderer = useCallback((props: CellRendererParams<Entity<M>>) => {\n const column = props.column;\n const columns = props.columns;\n const columnKey = column.key;\n\n // A row that exists but has not been read: above a scroll position\n // the view came back to, until it is scrolled to.\n if (!props.rowData) {\n return <div className=\"w-full h-full flex items-center px-4\" style={{ width: column.width }} aria-busy={true}>\n {renderSkeletonText(undefined, Math.min(120, Math.max(24, column.width - 32)))}\n </div>;\n }\n\n try {\n if (props.columnIndex === 0) {\n return <TableRowActions entity={props.rowData!}\n size={size}\n width={column.width}\n frozen={column.frozen}\n sortableNodeRef={props.sortableNodeRef}\n sortableStyle={props.sortableStyle}\n sortableAttributes={props.sortableAttributes}\n isDragging={props.isDragging}\n isDraggable={props.isDraggable}/>;\n } else if (additionalFieldsMap[columnKey]) {\n return additionalCellRenderer(props);\n } else if (props.columnIndex < columns.length + 1) {\n return propertyCellRenderer(props);\n } else {\n throw Error(\"Internal: columns not mapped properly\");\n }\n } catch (e: unknown) {\n console.error(\"Error rendering cell\", e);\n return <EntityTableCell\n size={size}\n width={column.width}\n savedTimestamp={undefined}\n value={null}\n align={\"left\"}\n fullHeight={false}\n disabled={true}\n sortableNodeRef={props.sortableNodeRef}\n sortableStyle={props.sortableStyle}\n sortableAttributes={props.sortableAttributes as Record<string, string | number | undefined>}\n isDragging={props.isDragging}\n isDraggable={props.isDraggable}\n frozen={props.frozen}>\n <ErrorView error={e instanceof Error ? e : new Error(String(e))}/>\n </EntityTableCell>;\n }\n }, [additionalFieldsMap, additionalCellRenderer, propertyCellRenderer, size]);\n\n return (\n\n <div ref={ref}\n style={style}\n className={cls(\"h-full min-h-0 w-full flex flex-col bg-surface-card\", className)}>\n\n {!hideToolbar && <CollectionTableToolbar\n onTextSearch={onTextSearch}\n title={title}\n actionsStart={actionsStart}\n actions={actions}\n viewModeToggle={viewModeToggle}\n loading={tableController.dataLoading}/>}\n\n <RowActionsContext.Provider value={rowActionsContext as RowActionsContextValue<Record<string, unknown>>}>\n <SelectableTable columns={columns}\n size={size}\n inlineEditing={inlineEditing}\n cellRenderer={cellRenderer}\n onEntityClick={onEntityClick}\n highlightedRow={isRowHighlighted}\n tableController={tableController}\n onValueChange={onValueChange}\n initialScroll={initialScroll}\n onScroll={onScroll}\n onColumnResize={onColumnResize}\n hoverRow={hoverRow}\n filterable={filterable}\n emptyComponent={emptyComponent}\n endAdornment={endAdornment}\n AddColumnComponent={AddColumnComponent}\n onColumnsOrderChange={onColumnsOrderChange}/>\n </RowActionsContext.Provider>\n\n </div>\n );\n\n};\n\ntype RowActionsContextValue<M extends Record<string, unknown>> = {\n tableRowActionsBuilder: CollectionTableBindingProps<M>[\"tableRowActionsBuilder\"];\n openEntityMode: NonNullable<CollectionTableBindingProps<M>[\"openEntityMode\"]>;\n};\n\nconst RowActionsContext = React.createContext<RowActionsContextValue<Record<string, unknown>>>({\n tableRowActionsBuilder: undefined,\n openEntityMode: \"side_panel\"\n});\n\n/**\n * The first cell of a row: its actions, from the table's builder or the\n * default ones. Reads the builder from context, so a new builder or a new\n * selection redraws this cell in every row and leaves the property cells\n * alone.\n */\nfunction TableRowActions<M extends Record<string, unknown>>({\n entity,\n size,\n width,\n frozen,\n sortableNodeRef,\n sortableStyle,\n sortableAttributes,\n isDragging,\n isDraggable\n}: {\n entity: Entity<M>;\n size: CollectionSize;\n width: number;\n frozen?: boolean;\n sortableNodeRef?: (node: HTMLElement | null) => void;\n sortableStyle?: React.CSSProperties;\n sortableAttributes?: Record<string, unknown>;\n isDragging?: boolean;\n isDraggable?: boolean;\n}) {\n const { tableRowActionsBuilder, openEntityMode } = useContext(RowActionsContext) as RowActionsContextValue<M>;\n if (tableRowActionsBuilder)\n return <>{tableRowActionsBuilder({\n entity,\n size,\n width,\n frozen\n })}</>;\n return <CollectionRowActions entity={entity}\n width={width}\n frozen={frozen}\n isSelected={false}\n size={size}\n openEntityMode={openEntityMode}\n sortableNodeRef={sortableNodeRef}\n sortableStyle={sortableStyle}\n sortableAttributes={sortableAttributes}\n isDragging={isDragging}\n isDraggable={isDraggable}/>;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiDA,IAAa,yBAAyB,SAAS,uBAC1C,EACG,WACA,OACA,aACA,cACA,SACA,gBACA,OACA,wBACA,sBACA,gBACA,eACA,qBACA,qBACA,eACA,gBACA,eACA,UACA,eAEA,WAAW,MACX,gBAAgB,OAChB,kBACA,oBACA,aACA,YACA,iBACA,aAAa,MACb,WAAW,MACX,cACA,oBACA,wBACA,0BACA,gBACA,kBACA,iBACA,iBAAiB,cACjB,sBACA,cAAc,SACiB;CAEnC,MAAM,MAAM,OAAuB,IAAI;CAEvC,MAAM,cAAc,yBAAyB;CAK7C,MAAM,eAAe,QAAQ,qBAAqB,YAAY;CAC9D,MAAM,mBAAmB,aAAa,WAAsB;EACxD,IAAI,cAAc,OAAO,oBAAqB,iBAAiB,MAAM;EACrE,OAAO,QAAQ,qBAAqB,MAAK,MAAK,KAAK,EAAE,OAAO,OAAO,MAAM,EAAE,SAAS,OAAO,IAAI,CAAC;CACpG,GAAG;EAAC;EAAc;EAAqB;CAAmB,CAAC;CAY3D,MAAM,iBAAiB,KAAK,UAAU,qBAAqB,KAAI,MAAK,IAAI,CAAC,EAAE,MAAM,EAAE,EAAE,IAAI,IAAI,KAAK,CAAC,CAAC;CACpG,MAAM,oBAA+C,eAAe;EAChE;EACA;CAEJ,IAAI;EAAC;EAAwB;EAAgB,qBAAqB;EAAW;CAAc,CAAC;CAE5F,MAAM,UAA+B,iBAAuB;CAE5D,MAAM,CAAC,MAAM,WAAW,MAAM,SAAyB,eAAe,GAAG;CAGzE,MAAM,gBAAgB;EAClB,IAAI,aACA,QAAQ,WAAW;CAE3B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AAgB;IACC;IACF;IACA;IACL;IACM;IACN;IACE;IACI;IACF;IACM;IACE;GAAsB,CAAA;EACpB,CAAA,CAE3B;;AAGb;AAOA,IAAM,oBAAoB,MAAM,cAA+D;CAC3F,wBAAwB,KAAA;CACxB,gBAAgB;AACpB,CAAC;;;;;;;AAQD,SAAS,gBAAmD,EACxD,QACA,MACA,OACA,QACA,iBACA,eACA,oBACA,YACA,eAWD;CACC,MAAM,EAAE,wBAAwB,mBAAmB,WAAW,iBAAiB;CAC/E,IAAI,wBACA,OAAO,oBAAA,UAAA,EAAA,UAAG,uBAAuB;EAC7B;EACA;EACA;EACA;CACJ,CAAC,EAAI,CAAA;CACT,OAAO,oBAAC,sBAAD;EAA8B;EAC1B;EACC;EACR,YAAY;EACN;EACU;EACC;EACF;EACK;EACR;EACC;CAAa,CAAA;AAClC"}
|
|
1
|
+
{"version":3,"file":"CollectionTableBinding.js","names":[],"sources":["../../../src/components/CollectionTableBinding/CollectionTableBinding.tsx"],"sourcesContent":["import type { AdditionalFieldDelegate, AdminCollection } from \"@rebasepro/cms-types\";\nimport { AdditionalFieldValue } from \"../AdditionalFieldValue\";\nimport { rowOfEntity } from \"@rebasepro/app\";\nimport React, { useCallback, useContext, useMemo, useRef } from \"react\";\nimport { User } from \"@rebasepro/types\";\nimport { CollectionSize, RebaseContext, Property, Entity } from \"@rebasepro/cms-types\";\nimport { PropertyTableCell } from \"./PropertyTableCell\";\nimport { ErrorBoundary } from \"@rebasepro/ui\";\nimport { useRebaseContext, useCollectionScope, useCustomizationController } from \"@rebasepro/app\";\nimport { useCollectionLargeLayout } from \"../CollectionViewBinding/useCollectionLargeLayout\";\nimport { CellRendererParams, VirtualTableColumn } from \"@rebasepro/ui\";\nimport { CollectionRowActions } from \"./CollectionRowActions\";\nimport { CollectionTableToolbar } from \"./internal/CollectionTableToolbar\";\nimport { CollectionTableBindingProps } from \"./CollectionTableBindingProps\";\nimport { EntityTableCell } from \"./internal/EntityTableCell\";\nimport { CustomFieldValidator } from \"../../form/validation\";\nimport { renderSkeletonText, useDateFnsLocale } from \"../../preview\";\nimport { propertiesToColumns } from \"./column_utils\";\nimport { ErrorView } from \"@rebasepro/app\";\nimport { SelectableTable } from \"../SelectableTable/SelectableTable\";\nimport { cls } from \"@rebasepro/ui\";\nimport { getRowHeight, isDisabled } from \"@rebasepro/app\";\nimport { getValueInPath } from \"@rebasepro/utils\";\nimport { deepEqual as equal } from \"fast-equals\";\n\n/**\n * This component is in charge of rendering a collection table with a high\n * degree of customization.\n *\n * This component is used internally by {@link CollectionViewBinding} and\n * {@link useReferenceDialog}\n *\n * Please note that you only need to use this component if you are building\n * a custom view. If you just need to create a default view you can do it\n * exclusively with config options.\n *\n * If you want to bind a {@link AdminCollection} to a table with the default\n * options you see in collections in the top level navigation, you can\n * check {@link CollectionViewBinding}.\n *\n * The data displayed in the table is managed by a {@link EntityTableController}.\n * You can build the default, bound to a path in the driver, by using the hook\n * {@link useDataTableController}\n *\n * @see CollectionTableBindingProps\n * @see CollectionViewBinding\n * @see VirtualTable\n * @group Components\n */\nexport const CollectionTableBinding = function CollectionTableBinding<M extends Record<string, unknown> = Record<string, unknown>, USER extends User = User>\n ({\n className,\n style,\n fixedFilter,\n actionsStart,\n actions,\n viewModeToggle,\n title,\n tableRowActionsBuilder,\n uniqueFieldValidator,\n getPropertyFor,\n onValueChange,\n selectionController,\n highlightedEntities,\n onEntityClick,\n onColumnResize,\n initialScroll,\n onScroll,\n onSizeChanged,\n\n hoverRow = true,\n inlineEditing = false,\n additionalFields,\n displayedColumnIds,\n defaultSize,\n properties,\n tableController,\n filterable = true,\n sortable = true,\n endAdornment,\n AddColumnComponent,\n AdditionalHeaderWidget,\n additionalIDHeaderWidget,\n emptyComponent,\n getIdColumnWidth,\n enablePopupIcon,\n openEntityMode = \"side_panel\",\n onColumnsOrderChange,\n hideToolbar = false\n }: CollectionTableBindingProps<M>) {\n\n const ref = useRef<HTMLDivElement>(null);\n\n const largeLayout = useCollectionLargeLayout();\n // Asked per row rather than held as a list: a query selection has no list,\n // and the one this replaced would have answered with whatever the view had\n // scrolled. `highlightedEntities` is the fallback the table has always had\n // — the row you navigated to, shown lit when nothing is selected.\n const hasSelection = Boolean(selectionController?.hasSelection);\n const isRowHighlighted = useCallback((entity: Entity<M>) => {\n if (hasSelection) return selectionController!.isEntitySelected(entity);\n return Boolean(highlightedEntities?.some(e => e && e.id === entity.id && e.path === entity.path));\n }, [hasSelection, selectionController, highlightedEntities]);\n\n // What the row actions are drawn from besides their row. Handed down by\n // context rather than through the cell renderer, so that a change here\n // draws the id column of each row and nothing else: it used to be the\n // cells' memo key, and ticking one checkbox re-ran the renderer of every\n // cell on screen (~460) to redraw the one column that shows a selection.\n //\n // The selection and the highlighted rows are dependencies, not fields: a\n // builder may read either from its closure, and a change to them has to\n // reach the actions it built. The highlighted rows by identity, not by\n // array: a caller passing a new `[]` each render changes nothing.\n const highlightedKey = JSON.stringify(highlightedEntities?.map(e => e ? [e.path, e.id] : null) ?? []);\n const rowActionsContext: RowActionsContextValue<M> = useMemo(() => ({\n tableRowActionsBuilder,\n openEntityMode\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }), [tableRowActionsBuilder, openEntityMode, selectionController?.selection, highlightedKey]);\n\n const context: RebaseContext<USER> = useRebaseContext<USER>();\n\n const [size, setSize] = React.useState<CollectionSize>(defaultSize ?? \"m\");\n\n // Sync internal size with defaultSize prop when it changes\n React.useEffect(() => {\n if (defaultSize) {\n setSize(defaultSize);\n }\n }, [defaultSize]);\n\n const updateSize = useCallback((size: CollectionSize) => {\n if (onSizeChanged)\n onSizeChanged(size);\n setSize(size);\n }, []);\n\n const onTextSearch = useCallback((newSearchString?: string) => tableController.setSearchString?.(newSearchString), []);\n\n const additionalFieldsMap: Record<string, AdditionalFieldDelegate<M, USER>> = useMemo(() => {\n return (additionalFields\n ? additionalFields\n .map((aC) => ({ [aC.key]: aC as AdditionalFieldDelegate<M, USER> }))\n .reduce((a, b) => ({ ...a,\n...b }), {})\n : {}) as Record<string, AdditionalFieldDelegate<M, USER>>;\n }, [additionalFields]);\n\n const customFieldValidator: CustomFieldValidator | undefined = uniqueFieldValidator;\n\n const propertyCellRenderer = useCallback(({\n column,\n columnIndex,\n rowData,\n rowIndex,\n sortableNodeRef,\n sortableStyle,\n sortableAttributes,\n isDragging,\n isDraggable,\n frozen\n }: CellRendererParams<Entity<M>>) => {\n\n const entity: Entity<M> | undefined = rowData;\n if (!entity) return null;\n\n const propertyKey = column.key;\n\n const columnCustom = column.custom as { disabled?: boolean; resolvedProperty?: Property } | undefined;\n let disabled: boolean = columnCustom?.disabled ?? false;\n const property = getPropertyFor?.({\n propertyKey,\n entity\n }) ?? columnCustom?.resolvedProperty;\n if (!property || !isDisabled(property)) {\n disabled = false;\n }\n\n if (!property) {\n return null;\n }\n\n return (\n <ErrorBoundary>\n {entity\n ? <PropertyTableCell\n key={`property_table_cell_${entity.id}_${propertyKey}`}\n readonly={!inlineEditing}\n align={column.align ?? \"left\"}\n propertyKey={propertyKey as string}\n property={property}\n value={entity?.values ? getValueInPath(entity.values, propertyKey) : undefined}\n customFieldValidator={customFieldValidator}\n columnIndex={columnIndex}\n width={column.width}\n height={getRowHeight(size)}\n entity={entity}\n disabled={disabled}\n enablePopupIcon={enablePopupIcon}\n path={entity.path}\n sortableNodeRef={sortableNodeRef}\n sortableStyle={sortableStyle}\n sortableAttributes={sortableAttributes}\n isDragging={isDragging}\n isDraggable={isDraggable}\n frozen={frozen}/>\n : renderSkeletonText()\n }\n </ErrorBoundary>);\n\n }, [getPropertyFor, customFieldValidator, inlineEditing, enablePopupIcon, size]);\n\n // The collection the rows are converted by when an additional field is\n // handed one: the table itself is given only its properties.\n const scopedCollection = useCollectionScope();\n // Same source the filter fields read their engine from, so the header's\n // filter control and the field it opens cannot disagree about what the\n // collection's driver can answer.\n const engine = scopedCollection?.engine;\n\n const additionalCellRenderer = useCallback(({\n column,\n rowData,\n width,\n sortableNodeRef,\n sortableStyle,\n sortableAttributes,\n isDragging,\n isDraggable,\n frozen\n }: CellRendererParams<Entity<M>>) => {\n\n const entity: Entity<M> | undefined = rowData;\n if (!entity) return null;\n\n const additionalField = additionalFieldsMap[column.key as string];\n const value = additionalField.dependencies\n ? Object.entries(entity.values)\n .filter(([key, value]) => additionalField.dependencies!.includes(key as Extract<keyof M, string>))\n .reduce((a, b) => ({ ...a,\n...b }), {})\n : entity;\n\n const Builder = additionalField.Builder;\n if (!Builder && !additionalField.value) {\n throw new Error(\"When using additional fields you need to provide a Builder or a value\");\n }\n\n const row = rowOfEntity(entity, scopedCollection);\n const id = String(entity.id);\n const child: React.ReactNode = Builder\n ? <Builder row={row} id={id} context={context}/>\n : <AdditionalFieldValue\n field={additionalField}\n row={row}\n id={id}\n context={context as RebaseContext}/>;\n\n return (\n <EntityTableCell\n key={`additional_table_cell_${entity.id}_${column.key}`}\n width={width}\n size={size}\n value={value}\n selected={false}\n disabled={true}\n align={\"left\"}\n allowScroll={false}\n showExpandIcon={false}\n disabledTooltip={\"This column can't be edited directly\"}\n sortableNodeRef={sortableNodeRef}\n sortableStyle={sortableStyle}\n sortableAttributes={sortableAttributes as Record<string, string | number | undefined>}\n isDragging={isDragging}\n isDraggable={isDraggable}\n frozen={frozen}\n >\n <ErrorBoundary>\n {child}\n </ErrorBoundary>\n </EntityTableCell>\n );\n\n }, [size, additionalFieldsMap, context, scopedCollection]);\n\n // Date columns are sized from the dates they will show, which depends on\n // how the admin formats them.\n const customizationController = useCustomizationController();\n const dateFnsLocale = useDateFnsLocale();\n const locale = customizationController?.locale;\n const dateTimeFormat = customizationController?.dateTimeFormat;\n const dateFormatting = useMemo(\n () => ({ locale, dateTimeFormat, dateFnsLocale }),\n [locale, dateTimeFormat, dateFnsLocale]\n );\n\n const collectionColumns: VirtualTableColumn[] = useMemo(() => {\n const columnsResult: VirtualTableColumn[] = propertiesToColumns({\n properties,\n sortable,\n fixedFilter,\n engine,\n dateFormatting,\n inlineEditing,\n AdditionalHeaderWidget\n });\n\n // Get keys from property columns to filter out duplicate additional fields\n const propertyColumnKeys = new Set(columnsResult.map(col => col.key));\n\n const additionalTableColumns: VirtualTableColumn[] = additionalFields\n // Filter out additional fields whose key already exists in property columns\n ? additionalFields\n .filter((additionalField) => !propertyColumnKeys.has(additionalField.key))\n .map((additionalField) =>\n ({\n key: additionalField.key,\n align: \"left\",\n sortable: false,\n title: additionalField.name,\n width: additionalField.width ?? 200\n }))\n : [];\n return [...columnsResult, ...additionalTableColumns];\n }, [properties, sortable, fixedFilter, engine, dateFormatting, inlineEditing, AdditionalHeaderWidget, additionalFields]);\n\n // Held by value: the widget is an element, and a caller that builds it\n // inline hands over a new one on every render. Each new one rebuilt the\n // id column, so the table's columns, so every cell on screen.\n const idHeaderWidgetRef = useRef(additionalIDHeaderWidget);\n if (idHeaderWidgetRef.current !== additionalIDHeaderWidget && !equal(idHeaderWidgetRef.current, additionalIDHeaderWidget)) {\n idHeaderWidgetRef.current = additionalIDHeaderWidget;\n }\n const stableIdHeaderWidget = idHeaderWidgetRef.current;\n\n const idColumn: VirtualTableColumn = useMemo(() => ({\n key: \"id_ewcfedcswdf3\",\n width: getIdColumnWidth?.(largeLayout) ?? (largeLayout ? 140 : 120),\n title: \"ID\",\n resizable: false,\n frozen: largeLayout,\n headerAlign: \"center\",\n align: \"center\",\n AdditionalHeaderWidget: () => stableIdHeaderWidget\n }), [getIdColumnWidth, largeLayout, stableIdHeaderWidget]);\n\n const columns: VirtualTableColumn[] = useMemo(() => [\n idColumn,\n ...(displayedColumnIds\n ? displayedColumnIds\n .map((p) => {\n return collectionColumns.find(c => c.key === p.key);\n }).filter(Boolean)\n : collectionColumns) as VirtualTableColumn[]\n ], [idColumn, displayedColumnIds, collectionColumns]);\n\n const cellRenderer = useCallback((props: CellRendererParams<Entity<M>>) => {\n const column = props.column;\n const columns = props.columns;\n const columnKey = column.key;\n\n // A row that exists but has not been read: above a scroll position\n // the view came back to, until it is scrolled to.\n if (!props.rowData) {\n return <div className=\"w-full h-full flex items-center px-4\" style={{ width: column.width }} aria-busy={true}>\n {renderSkeletonText(undefined, Math.min(120, Math.max(24, column.width - 32)))}\n </div>;\n }\n\n try {\n if (props.columnIndex === 0) {\n return <TableRowActions entity={props.rowData!}\n size={size}\n width={column.width}\n frozen={column.frozen}\n sortableNodeRef={props.sortableNodeRef}\n sortableStyle={props.sortableStyle}\n sortableAttributes={props.sortableAttributes}\n isDragging={props.isDragging}\n isDraggable={props.isDraggable}/>;\n } else if (additionalFieldsMap[columnKey]) {\n return additionalCellRenderer(props);\n } else if (props.columnIndex < columns.length + 1) {\n return propertyCellRenderer(props);\n } else {\n throw Error(\"Internal: columns not mapped properly\");\n }\n } catch (e: unknown) {\n console.error(\"Error rendering cell\", e);\n return <EntityTableCell\n size={size}\n width={column.width}\n savedTimestamp={undefined}\n value={null}\n align={\"left\"}\n fullHeight={false}\n disabled={true}\n sortableNodeRef={props.sortableNodeRef}\n sortableStyle={props.sortableStyle}\n sortableAttributes={props.sortableAttributes as Record<string, string | number | undefined>}\n isDragging={props.isDragging}\n isDraggable={props.isDraggable}\n frozen={props.frozen}>\n <ErrorView error={e instanceof Error ? e : new Error(String(e))}/>\n </EntityTableCell>;\n }\n }, [additionalFieldsMap, additionalCellRenderer, propertyCellRenderer, size]);\n\n return (\n\n <div ref={ref}\n style={style}\n className={cls(\"h-full min-h-0 w-full flex flex-col bg-surface-card\", className)}>\n\n {!hideToolbar && <CollectionTableToolbar\n onTextSearch={onTextSearch}\n title={title}\n actionsStart={actionsStart}\n actions={actions}\n viewModeToggle={viewModeToggle}\n loading={tableController.dataLoading}/>}\n\n <RowActionsContext.Provider value={rowActionsContext as RowActionsContextValue<Record<string, unknown>>}>\n <SelectableTable columns={columns}\n size={size}\n inlineEditing={inlineEditing}\n cellRenderer={cellRenderer}\n onEntityClick={onEntityClick}\n highlightedRow={isRowHighlighted}\n tableController={tableController}\n onValueChange={onValueChange}\n initialScroll={initialScroll}\n onScroll={onScroll}\n onColumnResize={onColumnResize}\n hoverRow={hoverRow}\n filterable={filterable}\n emptyComponent={emptyComponent}\n endAdornment={endAdornment}\n AddColumnComponent={AddColumnComponent}\n onColumnsOrderChange={onColumnsOrderChange}/>\n </RowActionsContext.Provider>\n\n </div>\n );\n\n};\n\ntype RowActionsContextValue<M extends Record<string, unknown>> = {\n tableRowActionsBuilder: CollectionTableBindingProps<M>[\"tableRowActionsBuilder\"];\n openEntityMode: NonNullable<CollectionTableBindingProps<M>[\"openEntityMode\"]>;\n};\n\nconst RowActionsContext = React.createContext<RowActionsContextValue<Record<string, unknown>>>({\n tableRowActionsBuilder: undefined,\n openEntityMode: \"side_panel\"\n});\n\n/**\n * The first cell of a row: its actions, from the table's builder or the\n * default ones. Reads the builder from context, so a new builder or a new\n * selection redraws this cell in every row and leaves the property cells\n * alone.\n */\nfunction TableRowActions<M extends Record<string, unknown>>({\n entity,\n size,\n width,\n frozen,\n sortableNodeRef,\n sortableStyle,\n sortableAttributes,\n isDragging,\n isDraggable\n}: {\n entity: Entity<M>;\n size: CollectionSize;\n width: number;\n frozen?: boolean;\n sortableNodeRef?: (node: HTMLElement | null) => void;\n sortableStyle?: React.CSSProperties;\n sortableAttributes?: Record<string, unknown>;\n isDragging?: boolean;\n isDraggable?: boolean;\n}) {\n const { tableRowActionsBuilder, openEntityMode } = useContext(RowActionsContext) as RowActionsContextValue<M>;\n if (tableRowActionsBuilder)\n return <>{tableRowActionsBuilder({\n entity,\n size,\n width,\n frozen\n })}</>;\n return <CollectionRowActions entity={entity}\n width={width}\n frozen={frozen}\n isSelected={false}\n size={size}\n openEntityMode={openEntityMode}\n sortableNodeRef={sortableNodeRef}\n sortableStyle={sortableStyle}\n sortableAttributes={sortableAttributes}\n isDragging={isDragging}\n isDraggable={isDraggable}/>;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiDA,IAAa,yBAAyB,SAAS,uBAC1C,EACG,WACA,OACA,aACA,cACA,SACA,gBACA,OACA,wBACA,sBACA,gBACA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A,UAAG,uBAAuB;EAC7B;EACA;EACA;EACA;CACJ,CAAC,EAAI,CAAA;CACT,OAAO,oBAAC,sBAAD;EAA8B;EAC1B;EACC;EACR,YAAY;EACN;EACU;EACC;EACF;EACK;EACR;EACC;CAAa,CAAA;AAClC"}
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import type { Properties } from "@rebasepro/types";
|
|
2
|
-
import type { AdditionalFieldDelegate } from "@rebasepro/cms-types";
|
|
3
|
-
import type { Property } from "@rebasepro/types";
|
|
1
|
+
import type { AdditionalFieldDelegate, Properties, Property } from "@rebasepro/cms-types";
|
|
4
2
|
import React from "react";
|
|
5
|
-
import {
|
|
6
|
-
import { CollectionSize, EntityTableController, EntitySelectionController } from "@rebasepro/cms-types";
|
|
3
|
+
import { FilterValues, User } from "@rebasepro/types";
|
|
4
|
+
import { CollectionSize, EntityTableController, EntitySelectionController, Entity } from "@rebasepro/cms-types";
|
|
7
5
|
import { OnCellValueChange, OnColumnResizeParams, UniqueFieldValidator } from "@rebasepro/app";
|
|
8
6
|
import { VirtualTableColumn } from "@rebasepro/ui";
|
|
9
7
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { Property } from "@rebasepro/types";
|
|
1
|
+
import type { Property } from "@rebasepro/cms-types";
|
|
2
2
|
import React from "react";
|
|
3
|
-
import { Entity } from "@rebasepro/types";
|
|
3
|
+
import { Entity } from "@rebasepro/cms-types";
|
|
4
4
|
import { CustomFieldValidator } from "../../form/validation.js";
|
|
5
5
|
export interface PropertyTableCellProps<T> {
|
|
6
6
|
propertyKey: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PropertyTableCell.js","names":[],"sources":["../../../src/components/CollectionTableBinding/PropertyTableCell.tsx"],"sourcesContent":["import { useCellSelected, createSelectionStore } from \"../SelectableTable/SelectionStore\";\nimport type { ArrayProperty, NumberProperty, Property, ReferenceProperty, StringProperty } from \"@rebasepro/types\";\nimport React, { useCallback, useEffect, useMemo, useRef, useState } from \"react\";\nimport { deepEqual as equal, shallowEqual } from \"fast-equals\"\n\nimport { Entity, EntityReference, EntityRelation } from \"@rebasepro/types\";\n\nimport { getTableBindingForProperty } from \"./table_bindings\";\n\nimport { PropertyPreview } from \"../../preview\";\nimport { getPreviewSizeFrom } from \"../../preview/util\";\n\nimport type { ZodTypeAny } from \"zod\";\nimport { applyValueTransforms, CustomFieldValidator, mapPropertyToZod } from \"../../form/validation\";\n\nimport { EntityTableCell } from \"./internal/EntityTableCell\";\nimport { EntityTableCellActions } from \"./internal/EntityTableCellActions\";\n\nimport { useSelectableTableController } from \"../SelectableTable/SelectableTableContext\";\nimport { getRowHeight, useTranslation } from \"@rebasepro/app\";\nimport { isDisabled, isReadOnly } from \"@rebasepro/app\";\nimport { EntityTableCellOpener } from \"./internal/EntityTableCell\";\nimport { TableCellOpenerKind } from \"./internal/TableCellOpener\";\n\nexport interface PropertyTableCellProps<T> {\n propertyKey: string;\n columnIndex: number;\n align: \"right\" | \"left\" | \"center\";\n customFieldValidator?: CustomFieldValidator;\n value: T;\n readonly: boolean;\n property: Property;\n height: number;\n width: number;\n entity: Entity<any>;\n path: string;\n disabled: boolean;\n enablePopupIcon?: boolean;\n // Sortable props for dnd-kit integration\n sortableNodeRef?: (node: HTMLElement | null) => void;\n sortableStyle?: React.CSSProperties;\n sortableAttributes?: Record<string, any>;\n isDragging?: boolean;\n isDraggable?: boolean;\n frozen?: boolean;\n}\n\n\n/**\n * One validation schema per column: keyed by the property object, the\n * property key and the field validator, and held as long as the property\n * object is (a WeakMap — a collection that changes brings new property objects\n * and so new schemas; nothing outlives the collection it was built for).\n *\n * The row id is deliberately not part of the key: `mapPropertyToZod` only\n * threads `entityId` through to nested properties and reads it nowhere, so the\n * schema built for one row is the schema of every row. It was built per cell\n * — 600 schemas, 15-28 ms, for a 30-row screen of 20 columns. A rule that\n * needs the row would have to read it at validation time, not at build time.\n */\nconst columnSchemas = new WeakMap<Property, Map<string, Map<CustomFieldValidator | undefined, ZodTypeAny>>>();\n\nfunction getColumnSchema(property: Property, propertyKey: string, customFieldValidator?: CustomFieldValidator): ZodTypeAny {\n let byKey = columnSchemas.get(property);\n if (!byKey) {\n byKey = new Map();\n columnSchemas.set(property, byKey);\n }\n let byValidator = byKey.get(propertyKey);\n if (!byValidator) {\n byValidator = new Map();\n byKey.set(propertyKey, byValidator);\n }\n let schema = byValidator.get(customFieldValidator);\n if (!schema) {\n schema = mapPropertyToZod({\n property,\n customFieldValidator,\n name: propertyKey\n });\n byValidator.set(customFieldValidator, schema);\n }\n return schema;\n}\n\nexport const PropertyTableCell = React.memo<PropertyTableCellProps<any>>(\n function PropertyTableCell<T, M extends Record<string, any>>({\n propertyKey,\n customFieldValidator,\n value,\n property,\n align,\n width,\n height,\n path,\n entity,\n readonly,\n disabled: disabledProp,\n enablePopupIcon = true,\n sortableNodeRef,\n sortableStyle,\n sortableAttributes,\n isDragging,\n isDraggable,\n frozen\n }: PropertyTableCellProps<T>) {\n\n const {\n onValueChange,\n size,\n selectionStore,\n select,\n setPopupCell\n } = useSelectableTableController();\n const { t } = useTranslation();\n\n const dummySelectionStore = useMemo(() => createSelectionStore(), []);\n const activeSelectionStore = selectionStore || dummySelectionStore;\n const selected = useCellSelected(activeSelectionStore, propertyKey, entity.path, entity.id);\n\n const [internalValue, setInternalValue] = useState<any | null>(value);\n const internalValueRef = useRef(value);\n\n const [error, setError] = useState<Error | undefined>();\n const [validationError, setValidationError] = useState<Error | undefined>();\n const [savedTimestamp, setSavedTimestamp] = useState<number>(0);\n // Whether the user has edited what the cell holds. Only an edited value\n // is judged: a stored value that fails a rule added later is the\n // record's state, not something the user did, and drawing it red on\n // every row as the table renders said otherwise.\n const [edited, setEdited] = useState(false);\n\n const onValueUpdated = useCallback(() => {\n setSavedTimestamp(Date.now());\n }, []);\n\n const customField = Boolean(property.admin?.Field);\n const customPreview = Boolean(property.admin?.Preview);\n const readOnlyProperty = isReadOnly(property);\n const disabledTooltip: string | undefined = typeof property.admin?.disabled === \"object\" ? property.admin?.disabled.disabledMessage : undefined;\n const disabled = readonly || disabledProp || isDisabled(property);\n\n const validation = useMemo(\n () => getColumnSchema(property, propertyKey, customFieldValidator),\n [property, propertyKey, customFieldValidator]);\n\n useEffect(\n () => {\n if (!equal(value, internalValueRef.current)) {\n setValidationError(undefined);\n setEdited(false);\n setInternalValue(value);\n internalValueRef.current = value;\n onValueUpdated();\n }\n },\n [onValueUpdated, value]\n );\n\n // What a save writes: the value with the string transforms the\n // property declares (`trim`, `lowercase`, `uppercase`) applied, as the\n // form writes it. Validation judges the same transformed value.\n const toWrittenValue = useCallback((typed: unknown): unknown =>\n applyValueTransforms({ value: typed }, { value: property }).value, [property]);\n\n // The editor keeps what was typed while the cell is edited — trimming\n // under the cursor would eat the space before the next word — and the\n // cell shows what was written once it is left.\n const [transformedWrite, setTransformedWrite] = useState<{ value: unknown }>();\n useEffect(() => {\n if (selected || !transformedWrite) return;\n if (equal(toWrittenValue(internalValue), transformedWrite.value))\n setInternalValue(transformedWrite.value);\n setTransformedWrite(undefined);\n }, [selected, transformedWrite, internalValue, toWrittenValue]);\n\n const saveValues = async (value: unknown) => {\n const writtenValue = toWrittenValue(value);\n if (equal(writtenValue, internalValueRef.current))\n return;\n const result = await validation.safeParseAsync(value);\n if (result.success) {\n setValidationError(undefined);\n internalValueRef.current = writtenValue as T;\n if (!equal(writtenValue, value))\n setTransformedWrite({ value: writtenValue });\n if (onValueChange) {\n try {\n onValueChange({\n value: writtenValue,\n propertyKey,\n setError,\n onValueUpdated,\n data: entity\n });\n } catch (e: unknown) {\n console.error(\"onValueChange error\", e);\n setError(e instanceof Error ? e : new Error(String(e)));\n }\n\n }\n } else {\n setValidationError(result.error);\n }\n };\n\n // What the cell holds, judged by its column's schema — the only two\n // things the result depends on. It also re-ran for every new row\n // object a realtime frame brought, changed or not. Only once edited.\n useEffect(() => {\n if (!edited) return;\n let current = true;\n validation\n .safeParseAsync(internalValue)\n .then((result) => {\n if (!current) return;\n if (result.success) {\n setValidationError(undefined);\n } else {\n setValidationError(result.error);\n }\n });\n return () => { current = false; };\n }, [edited, internalValue, validation]);\n\n // Saves the row at once, so only an edit may call it. The table shows\n // what is stored: a disabled property's `clearOnDisabled` belongs to\n // the form, whose values are written only when the user saves.\n const updateValue = (newValue: unknown | null) => {\n\n let updatedValue: unknown;\n if (newValue === undefined) {\n updatedValue = null;\n } else {\n updatedValue = newValue;\n }\n setEdited(true);\n setInternalValue(updatedValue);\n saveValues(updatedValue);\n };\n\n const onSelect = useCallback((cellRect: DOMRect | undefined) => {\n if (!cellRect) {\n select(undefined);\n } else {\n select({\n width,\n height,\n entityPath: entity.path,\n id: String(entity.id),\n cellRect,\n propertyKey: propertyKey as Extract<keyof M, string>\n });\n }\n }, [entity, height, propertyKey, select, width]);\n\n const openPopup = (cellRect: DOMRect | undefined) => {\n if (!setPopupCell)\n return;\n if (!cellRect) {\n setPopupCell(undefined);\n } else {\n setPopupCell({\n width,\n height,\n entityPath: entity.path,\n id: String(entity.id),\n cellRect,\n propertyKey: propertyKey as Extract<keyof M, string>\n });\n }\n };\n\n // `getTableBindingForProperty` builds its `Component` as a fresh inline\n // arrow function on every call. Calling it during render therefore gave\n // React a new component *type* each pass, so the cell was unmounted and\n // remounted instead of updated — which is why a BooleanSwitch in the\n // table never animated (a replaced element cannot run a CSS transition)\n // and why every cell re-created its subtree on unrelated renders.\n const tableBinding = useMemo(\n () => getTableBindingForProperty(property, selected),\n [property, selected]);\n\n // The editor the cell opens, whether or not it is mounted yet. A picker\n // is only mounted once its cell is selected (see table_bindings), but\n // the opener that reveals it is there from rest.\n const editorBinding = useMemo(\n () => getTableBindingForProperty(property, true),\n [property]);\n\n // Whether the cell's floating editor is open: the dropdown, the picker\n // dialog, the date picker. Held here rather than inside the editor so\n // the opener can open it in the same click that selects the cell —\n // before the editor exists.\n const [editorOpen, setEditorOpen] = useState(false);\n useEffect(() => {\n if (!selected) setEditorOpen(false);\n }, [selected]);\n\n // What a floating editor is positioned against: the cell, not the\n // editor's own trigger, which the cell may clip.\n const cellRef = useRef<HTMLDivElement>(null);\n\n // What the cell shows at rest. A picker renders the same node as its\n // trigger, so selecting the cell changes its frame and nothing else.\n const preview = <PropertyPreview width={width}\n height={height}\n propertyKey={propertyKey as string}\n value={internalValue}\n property={property}\n size={getPreviewSizeFrom(size)}\n />;\n\n let openerKind: TableCellOpenerKind | undefined;\n if (!disabled && !readOnlyProperty) {\n if (!customField && editorBinding)\n openerKind = editorBinding.opener;\n else if (enablePopupIcon && setPopupCell)\n openerKind = \"expand\";\n }\n\n const onOpenerToggleRef = useRef<(open: boolean, cellRect: DOMRect | undefined) => void>(() => undefined);\n onOpenerToggleRef.current = (open, cellRect) => {\n if (openerKind === \"expand\") {\n if (open) openPopup(cellRect);\n } else {\n setEditorOpen(open);\n }\n };\n // Stable: `EntityTableCell` compares its props field by field and would\n // otherwise hold on to the first one it was given.\n const onOpenerToggle = useCallback((open: boolean, cellRect: DOMRect | undefined) =>\n onOpenerToggleRef.current(open, cellRect), []);\n\n const opener: EntityTableCellOpener | undefined = openerKind\n ? {\n kind: openerKind,\n open: editorOpen,\n // A dropdown's own trigger takes the focus, and Enter opens it.\n // The rest have no trigger in the cell; the opener stands in.\n focusOnSelect: openerKind !== \"dropdown\",\n label: openerKind === \"expand\"\n ? t(\"expand\")\n : t(\"edit_name\", { name: property.name ?? propertyKey }),\n onToggle: onOpenerToggle\n }\n : undefined;\n\n let innerComponent: React.ReactNode | undefined;\n let allowScroll = false;\n let showExpandIcon = false;\n let hideOverflow = true;\n let removePadding = false;\n let fullHeight = false;\n let includeActions = true;\n const showError = !disabled && error;\n\n if (readonly || readOnlyProperty) {\n return <EntityTableCell\n size={size}\n width={width}\n savedTimestamp={savedTimestamp}\n key={`${propertyKey}_${entity.path}_${entity.id}`}\n value={internalValue}\n align={align ?? \"left\"}\n fullHeight={false}\n disabledTooltip={disabledTooltip ?? (readOnlyProperty ? \"Read only\" : undefined)}\n disabled={true}\n sortableNodeRef={sortableNodeRef}\n sortableStyle={sortableStyle}\n sortableAttributes={sortableAttributes}\n isDragging={isDragging}\n isDraggable={isDraggable}\n frozen={frozen}>\n <PropertyPreview\n width={width}\n height={getRowHeight(size)}\n propertyKey={propertyKey}\n property={property}\n value={internalValue}\n size={getPreviewSizeFrom(size)}\n />\n </EntityTableCell>;\n }\n\n if (!customField && (!customPreview || selected)) {\n if (tableBinding) {\n const Component = tableBinding.Component;\n innerComponent = <Component\n propertyKey={propertyKey}\n property={property}\n internalValue={internalValue}\n updateValue={updateValue}\n error={error}\n validationError={validationError}\n disabled={disabled}\n selected={selected}\n size={size}\n align={align}\n entity={entity}\n path={path}\n openPopup={setPopupCell ? openPopup : undefined}\n open={editorOpen}\n onOpenChange={setEditorOpen}\n preview={preview}\n anchorRef={cellRef}\n />;\n\n allowScroll = tableBinding.allowScroll ?? false;\n includeActions = tableBinding.includeActions ?? true;\n showExpandIcon = tableBinding.showExpandIcon ?? false;\n fullHeight = tableBinding.fullHeight ?? false;\n removePadding = tableBinding.removePadding ?? false;\n if (tableBinding.hideOverflow !== undefined) hideOverflow = tableBinding.hideOverflow;\n }\n }\n\n if (!innerComponent) {\n allowScroll = false;\n innerComponent = preview;\n }\n\n return (\n <EntityTableCell\n key={`cell_${propertyKey}_${entity.path}_${entity.id}`}\n size={size}\n width={width}\n onSelect={onSelect}\n selected={selected}\n disabled={disabled || readOnlyProperty}\n disabledTooltip={disabledTooltip ?? \"Disabled\"}\n removePadding={removePadding}\n fullHeight={fullHeight}\n savedTimestamp={savedTimestamp}\n error={validationError ?? error}\n align={align}\n allowScroll={allowScroll}\n showExpandIcon={showExpandIcon}\n value={internalValue}\n hideOverflow={hideOverflow}\n opener={opener}\n cellRef={cellRef}\n sortableNodeRef={sortableNodeRef}\n sortableStyle={sortableStyle}\n sortableAttributes={sortableAttributes}\n isDragging={isDragging}\n isDraggable={isDraggable}\n frozen={frozen}\n actions={includeActions && <EntityTableCellActions\n showError={showError}\n disabled={disabled}\n showExpandIcon={showExpandIcon}\n selected={selected}\n openPopup={!disabled ? openPopup : undefined}/>}\n >\n\n {innerComponent}\n\n </EntityTableCell>\n );\n\n },\n areEqual) as React.FunctionComponent<PropertyTableCellProps<any>>;\n\n// The row is compared as well as the cell's own value: a save is built from\n// `entity.values` — a key inside a map is written as the whole map — and hands\n// them to `beforeSave` as the previous values, so a cell must not hold on to a\n// row that has since changed in another column or in a sibling key.\n//\n// Every prop is compared. Leaving `readonly`, `disabled` and `enablePopupIcon`\n// out meant switching inline editing off, or a permission changing, did not\n// reach a cell already drawn until its row changed.\nfunction areEqual(prevProps: PropertyTableCellProps<any>, nextProps: PropertyTableCellProps<any>) {\n return prevProps.height === nextProps.height &&\n prevProps.propertyKey === nextProps.propertyKey &&\n prevProps.columnIndex === nextProps.columnIndex &&\n prevProps.align === nextProps.align &&\n prevProps.width === nextProps.width &&\n prevProps.readonly === nextProps.readonly &&\n prevProps.disabled === nextProps.disabled &&\n prevProps.enablePopupIcon === nextProps.enablePopupIcon &&\n prevProps.customFieldValidator === nextProps.customFieldValidator &&\n prevProps.path === nextProps.path &&\n equal(prevProps.property, nextProps.property) &&\n equal(prevProps.value, nextProps.value) &&\n prevProps.entity.id === nextProps.entity.id &&\n prevProps.entity.path === nextProps.entity.path &&\n (prevProps.entity === nextProps.entity || equal(prevProps.entity.values, nextProps.entity.values)) &&\n prevProps.isDragging === nextProps.isDragging &&\n prevProps.isDraggable === nextProps.isDraggable &&\n prevProps.frozen === nextProps.frozen &&\n prevProps.sortableNodeRef === nextProps.sortableNodeRef &&\n shallowEqual(prevProps.sortableStyle ?? NO_STYLE, nextProps.sortableStyle ?? NO_STYLE) &&\n shallowEqual(prevProps.sortableAttributes ?? NO_ATTRIBUTES, nextProps.sortableAttributes ?? NO_ATTRIBUTES)\n ;\n}\n\nconst NO_STYLE: React.CSSProperties = {};\nconst NO_ATTRIBUTES: Record<string, unknown> = {};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AA4DA,IAAM,gC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UAAU,UAAU,UAAU,QAAQ,KAC5C,UAAM,UAAU,OAAO,UAAU,KAAK,KACtC,UAAU,OAAO,OAAO,UAAU,OAAO,MACzC,UAAU,OAAO,SAAS,UAAU,OAAO,SAC1C,UAAU,WAAW,UAAU,UAAU,UAAM,UAAU,OAAO,QAAQ,UAAU,OAAO,MAAM,MAChG,UAAU,eAAe,UAAU,cACnC,UAAU,gBAAgB,UAAU,eACpC,UAAU,WAAW,UAAU,UAC/B,UAAU,oBAAoB,UAAU,mBACxC,aAAa,UAAU,iBAAiB,UAAU,UAAU,iBAAiB,QAAQ,KACrF,aAAa,UAAU,sBAAsB,eAAe,UAAU,sBAAsB,aAAa;AAEjH;AAEA,IAAM,WAAgC,CAAC;AACvC,IAAM,gBAAyC,CAAC"}
|
|
1
|
+
{"version":3,"file":"PropertyTableCell.js","names":[],"sources":["../../../src/components/CollectionTableBinding/PropertyTableCell.tsx"],"sourcesContent":["import { useCellSelected, createSelectionStore } from \"../SelectableTable/SelectionStore\";\nimport type { ArrayProperty, NumberProperty, Property, ReferenceProperty, StringProperty } from \"@rebasepro/cms-types\";\nimport React, { useCallback, useEffect, useMemo, useRef, useState } from \"react\";\nimport { deepEqual as equal, shallowEqual } from \"fast-equals\"\n\nimport { EntityReference, EntityRelation, Entity } from \"@rebasepro/cms-types\";\n\nimport { getTableBindingForProperty } from \"./table_bindings\";\n\nimport { PropertyPreview } from \"../../preview\";\nimport { getPreviewSizeFrom } from \"../../preview/util\";\n\nimport type { ZodTypeAny } from \"zod\";\nimport { applyValueTransforms, CustomFieldValidator, mapPropertyToZod } from \"../../form/validation\";\n\nimport { EntityTableCell } from \"./internal/EntityTableCell\";\nimport { EntityTableCellActions } from \"./internal/EntityTableCellActions\";\n\nimport { useSelectableTableController } from \"../SelectableTable/SelectableTableContext\";\nimport { getRowHeight, useTranslation } from \"@rebasepro/app\";\nimport { isDisabled, isReadOnly } from \"@rebasepro/app\";\nimport { EntityTableCellOpener } from \"./internal/EntityTableCell\";\nimport { TableCellOpenerKind } from \"./internal/TableCellOpener\";\n\nexport interface PropertyTableCellProps<T> {\n propertyKey: string;\n columnIndex: number;\n align: \"right\" | \"left\" | \"center\";\n customFieldValidator?: CustomFieldValidator;\n value: T;\n readonly: boolean;\n property: Property;\n height: number;\n width: number;\n entity: Entity<any>;\n path: string;\n disabled: boolean;\n enablePopupIcon?: boolean;\n // Sortable props for dnd-kit integration\n sortableNodeRef?: (node: HTMLElement | null) => void;\n sortableStyle?: React.CSSProperties;\n sortableAttributes?: Record<string, any>;\n isDragging?: boolean;\n isDraggable?: boolean;\n frozen?: boolean;\n}\n\n\n/**\n * One validation schema per column: keyed by the property object, the\n * property key and the field validator, and held as long as the property\n * object is (a WeakMap — a collection that changes brings new property objects\n * and so new schemas; nothing outlives the collection it was built for).\n *\n * The row id is deliberately not part of the key: `mapPropertyToZod` only\n * threads `entityId` through to nested properties and reads it nowhere, so the\n * schema built for one row is the schema of every row. It was built per cell\n * — 600 schemas, 15-28 ms, for a 30-row screen of 20 columns. A rule that\n * needs the row would have to read it at validation time, not at build time.\n */\nconst columnSchemas = new WeakMap<Property, Map<string, Map<CustomFieldValidator | undefined, ZodTypeAny>>>();\n\nfunction getColumnSchema(property: Property, propertyKey: string, customFieldValidator?: CustomFieldValidator): ZodTypeAny {\n let byKey = columnSchemas.get(property);\n if (!byKey) {\n byKey = new Map();\n columnSchemas.set(property, byKey);\n }\n let byValidator = byKey.get(propertyKey);\n if (!byValidator) {\n byValidator = new Map();\n byKey.set(propertyKey, byValidator);\n }\n let schema = byValidator.get(customFieldValidator);\n if (!schema) {\n schema = mapPropertyToZod({\n property,\n customFieldValidator,\n name: propertyKey\n });\n byValidator.set(customFieldValidator, schema);\n }\n return schema;\n}\n\nexport const PropertyTableCell = React.memo<PropertyTableCellProps<any>>(\n function PropertyTableCell<T, M extends Record<string, any>>({\n propertyKey,\n customFieldValidator,\n value,\n property,\n align,\n width,\n height,\n path,\n entity,\n readonly,\n disabled: disabledProp,\n enablePopupIcon = true,\n sortableNodeRef,\n sortableStyle,\n sortableAttributes,\n isDragging,\n isDraggable,\n frozen\n }: PropertyTableCellProps<T>) {\n\n const {\n onValueChange,\n size,\n selectionStore,\n select,\n setPopupCell\n } = useSelectableTableController();\n const { t } = useTranslation();\n\n const dummySelectionStore = useMemo(() => createSelectionStore(), []);\n const activeSelectionStore = selectionStore || dummySelectionStore;\n const selected = useCellSelected(activeSelectionStore, propertyKey, entity.path, entity.id);\n\n const [internalValue, setInternalValue] = useState<any | null>(value);\n const internalValueRef = useRef(value);\n\n const [error, setError] = useState<Error | undefined>();\n const [validationError, setValidationError] = useState<Error | undefined>();\n const [savedTimestamp, setSavedTimestamp] = useState<number>(0);\n // Whether the user has edited what the cell holds. Only an edited value\n // is judged: a stored value that fails a rule added later is the\n // record's state, not something the user did, and drawing it red on\n // every row as the table renders said otherwise.\n const [edited, setEdited] = useState(false);\n\n const onValueUpdated = useCallback(() => {\n setSavedTimestamp(Date.now());\n }, []);\n\n const customField = Boolean(property.admin?.Field);\n const customPreview = Boolean(property.admin?.Preview);\n const readOnlyProperty = isReadOnly(property);\n const disabledTooltip: string | undefined = typeof property.admin?.disabled === \"object\" ? property.admin?.disabled.disabledMessage : undefined;\n const disabled = readonly || disabledProp || isDisabled(property);\n\n const validation = useMemo(\n () => getColumnSchema(property, propertyKey, customFieldValidator),\n [property, propertyKey, customFieldValidator]);\n\n useEffect(\n () => {\n if (!equal(value, internalValueRef.current)) {\n setValidationError(undefined);\n setEdited(false);\n setInternalValue(value);\n internalValueRef.current = value;\n onValueUpdated();\n }\n },\n [onValueUpdated, value]\n );\n\n // What a save writes: the value with the string transforms the\n // property declares (`trim`, `lowercase`, `uppercase`) applied, as the\n // form writes it. Validation judges the same transformed value.\n const toWrittenValue = useCallback((typed: unknown): unknown =>\n applyValueTransforms({ value: typed }, { value: property }).value, [property]);\n\n // The editor keeps what was typed while the cell is edited — trimming\n // under the cursor would eat the space before the next word — and the\n // cell shows what was written once it is left.\n const [transformedWrite, setTransformedWrite] = useState<{ value: unknown }>();\n useEffect(() => {\n if (selected || !transformedWrite) return;\n if (equal(toWrittenValue(internalValue), transformedWrite.value))\n setInternalValue(transformedWrite.value);\n setTransformedWrite(undefined);\n }, [selected, transformedWrite, internalValue, toWrittenValue]);\n\n const saveValues = async (value: unknown) => {\n const writtenValue = toWrittenValue(value);\n if (equal(writtenValue, internalValueRef.current))\n return;\n const result = await validation.safeParseAsync(value);\n if (result.success) {\n setValidationError(undefined);\n internalValueRef.current = writtenValue as T;\n if (!equal(writtenValue, value))\n setTransformedWrite({ value: writtenValue });\n if (onValueChange) {\n try {\n onValueChange({\n value: writtenValue,\n propertyKey,\n setError,\n onValueUpdated,\n data: entity\n });\n } catch (e: unknown) {\n console.error(\"onValueChange error\", e);\n setError(e instanceof Error ? e : new Error(String(e)));\n }\n\n }\n } else {\n setValidationError(result.error);\n }\n };\n\n // What the cell holds, judged by its column's schema — the only two\n // things the result depends on. It also re-ran for every new row\n // object a realtime frame brought, changed or not. Only once edited.\n useEffect(() => {\n if (!edited) return;\n let current = true;\n validation\n .safeParseAsync(internalValue)\n .then((result) => {\n if (!current) return;\n if (result.success) {\n setValidationError(undefined);\n } else {\n setValidationError(result.error);\n }\n });\n return () => { current = false; };\n }, [edited, internalValue, validation]);\n\n // Saves the row at once, so only an edit may call it. The table shows\n // what is stored: a disabled property's `clearOnDisabled` belongs to\n // the form, whose values are written only when the user saves.\n const updateValue = (newValue: unknown | null) => {\n\n let updatedValue: unknown;\n if (newValue === undefined) {\n updatedValue = null;\n } else {\n updatedValue = newValue;\n }\n setEdited(true);\n setInternalValue(updatedValue);\n saveValues(updatedValue);\n };\n\n const onSelect = useCallback((cellRect: DOMRect | undefined) => {\n if (!cellRect) {\n select(undefined);\n } else {\n select({\n width,\n height,\n entityPath: entity.path,\n id: String(entity.id),\n cellRect,\n propertyKey: propertyKey as Extract<keyof M, string>\n });\n }\n }, [entity, height, propertyKey, select, width]);\n\n const openPopup = (cellRect: DOMRect | undefined) => {\n if (!setPopupCell)\n return;\n if (!cellRect) {\n setPopupCell(undefined);\n } else {\n setPopupCell({\n width,\n height,\n entityPath: entity.path,\n id: String(entity.id),\n cellRect,\n propertyKey: propertyKey as Extract<keyof M, string>\n });\n }\n };\n\n // `getTableBindingForProperty` builds its `Component` as a fresh inline\n // arrow function on every call. Calling it during render therefore gave\n // React a new component *type* each pass, so the cell was unmounted and\n // remounted instead of updated — which is why a BooleanSwitch in the\n // table never animated (a replaced element cannot run a CSS transition)\n // and why every cell re-created its subtree on unrelated renders.\n const tableBinding = useMemo(\n () => getTableBindingForProperty(property, selected),\n [property, selected]);\n\n // The editor the cell opens, whether or not it is mounted yet. A picker\n // is only mounted once its cell is selected (see table_bindings), but\n // the opener that reveals it is there from rest.\n const editorBinding = useMemo(\n () => getTableBindingForProperty(property, true),\n [property]);\n\n // Whether the cell's floating editor is open: the dropdown, the picker\n // dialog, the date picker. Held here rather than inside the editor so\n // the opener can open it in the same click that selects the cell —\n // before the editor exists.\n const [editorOpen, setEditorOpen] = useState(false);\n useEffect(() => {\n if (!selected) setEditorOpen(false);\n }, [selected]);\n\n // What a floating editor is positioned against: the cell, not the\n // editor's own trigger, which the cell may clip.\n const cellRef = useRef<HTMLDivElement>(null);\n\n // What the cell shows at rest. A picker renders the same node as its\n // trigger, so selecting the cell changes its frame and nothing else.\n const preview = <PropertyPreview width={width}\n height={height}\n propertyKey={propertyKey as string}\n value={internalValue}\n property={property}\n size={getPreviewSizeFrom(size)}\n />;\n\n let openerKind: TableCellOpenerKind | undefined;\n if (!disabled && !readOnlyProperty) {\n if (!customField && editorBinding)\n openerKind = editorBinding.opener;\n else if (enablePopupIcon && setPopupCell)\n openerKind = \"expand\";\n }\n\n const onOpenerToggleRef = useRef<(open: boolean, cellRect: DOMRect | undefined) => void>(() => undefined);\n onOpenerToggleRef.current = (open, cellRect) => {\n if (openerKind === \"expand\") {\n if (open) openPopup(cellRect);\n } else {\n setEditorOpen(open);\n }\n };\n // Stable: `EntityTableCell` compares its props field by field and would\n // otherwise hold on to the first one it was given.\n const onOpenerToggle = useCallback((open: boolean, cellRect: DOMRect | undefined) =>\n onOpenerToggleRef.current(open, cellRect), []);\n\n const opener: EntityTableCellOpener | undefined = openerKind\n ? {\n kind: openerKind,\n open: editorOpen,\n // A dropdown's own trigger takes the focus, and Enter opens it.\n // The rest have no trigger in the cell; the opener stands in.\n focusOnSelect: openerKind !== \"dropdown\",\n label: openerKind === \"expand\"\n ? t(\"expand\")\n : t(\"edit_name\", { name: property.name ?? propertyKey }),\n onToggle: onOpenerToggle\n }\n : undefined;\n\n let innerComponent: React.ReactNode | undefined;\n let allowScroll = false;\n let showExpandIcon = false;\n let hideOverflow = true;\n let removePadding = false;\n let fullHeight = false;\n let includeActions = true;\n const showError = !disabled && error;\n\n if (readonly || readOnlyProperty) {\n return <EntityTableCell\n size={size}\n width={width}\n savedTimestamp={savedTimestamp}\n key={`${propertyKey}_${entity.path}_${entity.id}`}\n value={internalValue}\n align={align ?? \"left\"}\n fullHeight={false}\n disabledTooltip={disabledTooltip ?? (readOnlyProperty ? \"Read only\" : undefined)}\n disabled={true}\n sortableNodeRef={sortableNodeRef}\n sortableStyle={sortableStyle}\n sortableAttributes={sortableAttributes}\n isDragging={isDragging}\n isDraggable={isDraggable}\n frozen={frozen}>\n <PropertyPreview\n width={width}\n height={getRowHeight(size)}\n propertyKey={propertyKey}\n property={property}\n value={internalValue}\n size={getPreviewSizeFrom(size)}\n />\n </EntityTableCell>;\n }\n\n if (!customField && (!customPreview || selected)) {\n if (tableBinding) {\n const Component = tableBinding.Component;\n innerComponent = <Component\n propertyKey={propertyKey}\n property={property}\n internalValue={internalValue}\n updateValue={updateValue}\n error={error}\n validationError={validationError}\n disabled={disabled}\n selected={selected}\n size={size}\n align={align}\n entity={entity}\n path={path}\n openPopup={setPopupCell ? openPopup : undefined}\n open={editorOpen}\n onOpenChange={setEditorOpen}\n preview={preview}\n anchorRef={cellRef}\n />;\n\n allowScroll = tableBinding.allowScroll ?? false;\n includeActions = tableBinding.includeActions ?? true;\n showExpandIcon = tableBinding.showExpandIcon ?? false;\n fullHeight = tableBinding.fullHeight ?? false;\n removePadding = tableBinding.removePadding ?? false;\n if (tableBinding.hideOverflow !== undefined) hideOverflow = tableBinding.hideOverflow;\n }\n }\n\n if (!innerComponent) {\n allowScroll = false;\n innerComponent = preview;\n }\n\n return (\n <EntityTableCell\n key={`cell_${propertyKey}_${entity.path}_${entity.id}`}\n size={size}\n width={width}\n onSelect={onSelect}\n selected={selected}\n disabled={disabled || readOnlyProperty}\n disabledTooltip={disabledTooltip ?? \"Disabled\"}\n removePadding={removePadding}\n fullHeight={fullHeight}\n savedTimestamp={savedTimestamp}\n error={validationError ?? error}\n align={align}\n allowScroll={allowScroll}\n showExpandIcon={showExpandIcon}\n value={internalValue}\n hideOverflow={hideOverflow}\n opener={opener}\n cellRef={cellRef}\n sortableNodeRef={sortableNodeRef}\n sortableStyle={sortableStyle}\n sortableAttributes={sortableAttributes}\n isDragging={isDragging}\n isDraggable={isDraggable}\n frozen={frozen}\n actions={includeActions && <EntityTableCellActions\n showError={showError}\n disabled={disabled}\n showExpandIcon={showExpandIcon}\n selected={selected}\n openPopup={!disabled ? openPopup : undefined}/>}\n >\n\n {innerComponent}\n\n </EntityTableCell>\n );\n\n },\n areEqual) as React.FunctionComponent<PropertyTableCellProps<any>>;\n\n// The row is compared as well as the cell's own value: a save is built from\n// `entity.values` — a key inside a map is written as the whole map — and hands\n// them to `beforeSave` as the previous values, so a cell must not hold on to a\n// row that has since changed in another column or in a sibling key.\n//\n// Every prop is compared. Leaving `readonly`, `disabled` and `enablePopupIcon`\n// out meant switching inline editing off, or a permission changing, did not\n// reach a cell already drawn until its row changed.\nfunction areEqual(prevProps: PropertyTableCellProps<any>, nextProps: PropertyTableCellProps<any>) {\n return prevProps.height === nextProps.height &&\n prevProps.propertyKey === nextProps.propertyKey &&\n prevProps.columnIndex === nextProps.columnIndex &&\n prevProps.align === nextProps.align &&\n prevProps.width === nextProps.width &&\n prevProps.readonly === nextProps.readonly &&\n prevProps.disabled === nextProps.disabled &&\n prevProps.enablePopupIcon === nextProps.enablePopupIcon &&\n prevProps.customFieldValidator === nextProps.customFieldValidator &&\n prevProps.path === nextProps.path &&\n equal(prevProps.property, nextProps.property) &&\n equal(prevProps.value, nextProps.value) &&\n prevProps.entity.id === nextProps.entity.id &&\n prevProps.entity.path === nextProps.entity.path &&\n (prevProps.entity === nextProps.entity || equal(prevProps.entity.values, nextProps.entity.values)) &&\n prevProps.isDragging === nextProps.isDragging &&\n prevProps.isDraggable === nextProps.isDraggable &&\n prevProps.frozen === nextProps.frozen &&\n prevProps.sortableNodeRef === nextProps.sortableNodeRef &&\n shallowEqual(prevProps.sortableStyle ?? NO_STYLE, nextProps.sortableStyle ?? NO_STYLE) &&\n shallowEqual(prevProps.sortableAttributes ?? NO_ATTRIBUTES, nextProps.sortableAttributes ?? NO_ATTRIBUTES)\n ;\n}\n\nconst NO_STYLE: React.CSSProperties = {};\nconst NO_ATTRIBUTES: Record<string, unknown> = {};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AA4DA,IAAM,gCAAgB,IAAI,QAAkF;AAE5G,SAAS,gBAAgB,UAAoB,aAAqB,sBAAyD;CACvH,IAAI,QAAQ,cAAc,IAAI,QAAQ;CACtC,IAAI,CAAC,OAAO;EACR,wBAAQ,IAAI,IAAI;EAChB,cAAc,IAAI,UAAU,KAAK;CACrC;CACA,IAAI,cAAc,MAAM,IAAI,WAAW;CACvC,IAAI,CAAC,aAAa;EACd,8BAAc,IAAI,IAAI;EACtB,MAAM,IAAI,aAAa,WAAW;CACtC;CACA,IAAI,SAAS,YAAY,IAAI,oBAAoB;CACjD,IAAI,CAAC,QAAQ;EACT,SAAS,iBAAiB;GACtB;GACA;GACA,MAAM;EACV,CAAC;EACD,YAAY,IAAI,sBAAsB,MAAM;CAChD;CACA,OAAO;AACX;AAEA,IAAa,oBAAoB,MAAM,KACnC,SAAS,kBAA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-
import type { Properties, Property } from "@rebasepro/types";
|
|
1
|
+
import type { Properties, Property } from "@rebasepro/cms-types";
|
|
2
2
|
import React from "react";
|
|
3
3
|
import { DateColumnFormatting } from "./internal/common.js";
|
|
4
4
|
import { FilterValues } from "@rebasepro/types";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"column_utils.js","names":[],"sources":["../../../src/components/CollectionTableBinding/column_utils.tsx"],"sourcesContent":["import type { Properties, Property, RelationProperty } from \"@rebasepro/types\";\nimport React from \"react\";\nimport { DateColumnFormatting, getTableCellAlignment, getTablePropertyColumnWidth } from \"./internal/common\";\nimport { FilterValues } from \"@rebasepro/types\";\nimport { VirtualTableColumn } from \"@rebasepro/ui\";\nimport { getResolvedPropertyInPath } from \"../../util/property_utils\";\nimport { getColumnKeysForProperty, isPropertyFilterable, isReadOnly } from \"@rebasepro/app\";\n\nexport function buildIdColumn(largeLayout?: boolean): VirtualTableColumn {\n return {\n key: \"id_ewcfedcswdf3\",\n width: (largeLayout ? 160 : 130),\n title: \"ID\",\n resizable: false,\n frozen: largeLayout ?? false,\n headerAlign: \"center\",\n align: \"center\"\n };\n}\n\nexport interface PropertiesToColumnsParams<M extends Record<string, unknown>> {\n properties: Properties;\n sortable?: boolean;\n fixedFilter?: FilterValues<keyof M extends string ? keyof M : never>;\n /**\n * The engine backing the collection (`collection.engine`). Decides which\n * relation kinds can be filtered — see `isFilterableRelation`. Omitted\n * falls back to the default engine's capabilities.\n */\n engine?: string;\n /**\n * The admin's locale and date format, which decide how wide a date\n * column must be to keep its dates on one line.\n */\n dateFormatting?: DateColumnFormatting;\n /** Whether cells are edited in place: an editable date is an input, not the preview. */\n inlineEditing?: boolean;\n AdditionalHeaderWidget?: React.ComponentType<{\n property: Property,\n propertyKey: string,\n onHover: boolean,\n }>;\n}\n\nexport function propertiesToColumns<M extends Record<string, unknown>>({ properties, sortable, fixedFilter, engine, dateFormatting, inlineEditing, AdditionalHeaderWidget }: PropertiesToColumnsParams<M>): VirtualTableColumn[] {\n // A fixed filter locks its own fields, not the table: the user's filters\n // on every other column combine with it. It used to switch every header\n // filter off, while the filters dialog went on offering the same fields.\n const isFixed = (key: string) => Boolean(fixedFilter && key in fixedFilter);\n return Object.entries<Property>(properties)\n .flatMap(([key, property]) => getColumnKeysForProperty(property, key))\n .flatMap(({\n key,\n disabled\n }) => {\n const property = getResolvedPropertyInPath(properties, key) as Property | undefined;\n // One unresolvable key used to throw, and this runs inside the\n // memo that builds the table's columns — so a single bad column\n // took down the header, the rows and the empty state together,\n // leaving a blank pane with nothing to attribute it to. A column\n // that cannot be resolved is one column the table cannot offer;\n // say so and carry the rest. Same choice, and now the same\n // behaviour, as `getSortablePropertyOptions` below.\n if (!property) {\n console.warn(`No property found in path \"${key}\" — skipping that column.`);\n return [];\n }\n const filterable = filterableProperty(property, engine);\n return [{\n key: key as string,\n align: getTableCellAlignment(property),\n title: property.name ?? key as string,\n sortable: sortable && sortableProperty(property),\n filter: !isFixed(key) && filterable,\n width: getTablePropertyColumnWidth(property, {\n ...dateFormatting,\n editable: Boolean(inlineEditing) && !isReadOnly(property)\n }),\n resizable: true,\n custom: {\n resolvedProperty: property,\n disabled\n },\n AdditionalHeaderWidget: AdditionalHeaderWidget\n ? ({ onHover }: { onHover: boolean }) => <AdditionalHeaderWidget property={property} propertyKey={key} onHover={onHover}/>\n : undefined\n } satisfies VirtualTableColumn];\n });\n}\n\nexport type SortablePropertyOption = {\n key: string;\n title: string;\n property: Property;\n};\n\n/**\n * The properties a sort can be applied to, as keys and titles.\n *\n * Only the table renders headers, so the list, card and split views had no way\n * to order anything — the controller has carried `sortBy` all along, with no\n * control bound to it outside the table. This is the same walk\n * `propertiesToColumns` makes, under the same keys and the same\n * `sortableProperty` authority, so a sort picked from the toolbar means exactly\n * what clicking the header would have meant, and the two cannot drift into\n * offering different columns.\n */\nexport function getSortablePropertyOptions(properties: Properties): SortablePropertyOption[] {\n return Object.entries<Property>(properties)\n .flatMap(([key, property]) => getColumnKeysForProperty(property, key))\n .flatMap(({ key }) => {\n // Unlike the table, a missing property here is not worth throwing\n // over: the sort control simply has one fewer option to offer.\n const property = getResolvedPropertyInPath(properties, key) as Property | undefined;\n if (!property || !sortableProperty(property)) return [];\n return [{\n key: key as string,\n title: property.name ?? key as string,\n property\n }];\n });\n}\n\n/**\n * Whether this column can be ordered by.\n *\n * `sortable` arrived as one flag for the whole table while `filter` was\n * computed per property, so every column advertised a sort — including the ones\n * no `ORDER BY` can be written for. A to-many relation is a *set* per row\n * (`posts.tags`), and there is no single value to order on; the driver used to\n * answer by silently dropping the sort and returning rows in whatever order\n * Postgres pleased, which is how a header that did nothing went unnoticed.\n *\n * Now that the driver refuses instead, offering the control would turn a\n * useless header into a failed request. Same authority as the filter side: ask\n * the property, not the table.\n */\nfunction sortableProperty(property: Property): boolean {\n if (property.type !== \"relation\") return true;\n const relationProperty = property as RelationProperty;\n const kind = relationProperty.relation?.kind ?? relationProperty.resolvedRelation?.kind;\n // An unresolved relation keeps the benefit of the doubt — the same choice\n // `isFilterableRelation` makes for a kind it cannot see.\n if (!kind) return true;\n return kind === \"belongsTo\";\n}\n\nfunction filterableProperty(property: Property, engine?: string): boolean {\n // The same question the filters dialog asks, answered in one place — see\n // `isPropertyFilterable`. It used to be answered here by a second\n // predicate, and the two disagreed on arrays, on `filterOperators: []`\n // and on a custom `admin.Filter`. A relation this engine's driver cannot\n // compile into a `WHERE` is not filterable either way: before the driver\n // started failing closed, sending one silently returned every row.\n return isPropertyFilterable(property, engine);\n}\n"],"mappings":";;;;;;AA4CA,SAAgB,oBAAuD,EAAE,YAAY,UAAU,aAAa,QAAQ,gBAAgB,eAAe,0BAA8E;CAI7N,MAAM,WAAW,QAAgB,QAAQ,eAAe,OAAO,WAAW;CAC1E,OAAO,OAAO,QAAkB,UAAU,CAAC,CACtC,SAAS,CAAC,KAAK,cAAc,yBAAyB,UAAU,GAAG,CAAC,CAAC,CACrE,SAAS,EACN,KACA,eACE;EACF,MAAM,WAAW,0BA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,"file":"column_utils.js","names":[],"sources":["../../../src/components/CollectionTableBinding/column_utils.tsx"],"sourcesContent":["import type { Properties, Property, RelationProperty } from \"@rebasepro/cms-types\";\nimport React from \"react\";\nimport { DateColumnFormatting, getTableCellAlignment, getTablePropertyColumnWidth } from \"./internal/common\";\nimport { FilterValues } from \"@rebasepro/types\";\nimport { VirtualTableColumn } from \"@rebasepro/ui\";\nimport { getResolvedPropertyInPath } from \"../../util/property_utils\";\nimport { getColumnKeysForProperty, isPropertyFilterable, isReadOnly } from \"@rebasepro/app\";\n\nexport function buildIdColumn(largeLayout?: boolean): VirtualTableColumn {\n return {\n key: \"id_ewcfedcswdf3\",\n width: (largeLayout ? 160 : 130),\n title: \"ID\",\n resizable: false,\n frozen: largeLayout ?? false,\n headerAlign: \"center\",\n align: \"center\"\n };\n}\n\nexport interface PropertiesToColumnsParams<M extends Record<string, unknown>> {\n properties: Properties;\n sortable?: boolean;\n fixedFilter?: FilterValues<keyof M extends string ? keyof M : never>;\n /**\n * The engine backing the collection (`collection.engine`). Decides which\n * relation kinds can be filtered — see `isFilterableRelation`. Omitted\n * falls back to the default engine's capabilities.\n */\n engine?: string;\n /**\n * The admin's locale and date format, which decide how wide a date\n * column must be to keep its dates on one line.\n */\n dateFormatting?: DateColumnFormatting;\n /** Whether cells are edited in place: an editable date is an input, not the preview. */\n inlineEditing?: boolean;\n AdditionalHeaderWidget?: React.ComponentType<{\n property: Property,\n propertyKey: string,\n onHover: boolean,\n }>;\n}\n\nexport function propertiesToColumns<M extends Record<string, unknown>>({ properties, sortable, fixedFilter, engine, dateFormatting, inlineEditing, AdditionalHeaderWidget }: PropertiesToColumnsParams<M>): VirtualTableColumn[] {\n // A fixed filter locks its own fields, not the table: the user's filters\n // on every other column combine with it. It used to switch every header\n // filter off, while the filters dialog went on offering the same fields.\n const isFixed = (key: string) => Boolean(fixedFilter && key in fixedFilter);\n return Object.entries<Property>(properties)\n .flatMap(([key, property]) => getColumnKeysForProperty(property, key))\n .flatMap(({\n key,\n disabled\n }) => {\n const property = getResolvedPropertyInPath(properties, key) as Property | undefined;\n // One unresolvable key used to throw, and this runs inside the\n // memo that builds the table's columns — so a single bad column\n // took down the header, the rows and the empty state together,\n // leaving a blank pane with nothing to attribute it to. A column\n // that cannot be resolved is one column the table cannot offer;\n // say so and carry the rest. Same choice, and now the same\n // behaviour, as `getSortablePropertyOptions` below.\n if (!property) {\n console.warn(`No property found in path \"${key}\" — skipping that column.`);\n return [];\n }\n const filterable = filterableProperty(property, engine);\n return [{\n key: key as string,\n align: getTableCellAlignment(property),\n title: property.name ?? key as string,\n sortable: sortable && sortableProperty(property),\n filter: !isFixed(key) && filterable,\n width: getTablePropertyColumnWidth(property, {\n ...dateFormatting,\n editable: Boolean(inlineEditing) && !isReadOnly(property)\n }),\n resizable: true,\n custom: {\n resolvedProperty: property,\n disabled\n },\n AdditionalHeaderWidget: AdditionalHeaderWidget\n ? ({ onHover }: { onHover: boolean }) => <AdditionalHeaderWidget property={property} propertyKey={key} onHover={onHover}/>\n : undefined\n } satisfies VirtualTableColumn];\n });\n}\n\nexport type SortablePropertyOption = {\n key: string;\n title: string;\n property: Property;\n};\n\n/**\n * The properties a sort can be applied to, as keys and titles.\n *\n * Only the table renders headers, so the list, card and split views had no way\n * to order anything — the controller has carried `sortBy` all along, with no\n * control bound to it outside the table. This is the same walk\n * `propertiesToColumns` makes, under the same keys and the same\n * `sortableProperty` authority, so a sort picked from the toolbar means exactly\n * what clicking the header would have meant, and the two cannot drift into\n * offering different columns.\n */\nexport function getSortablePropertyOptions(properties: Properties): SortablePropertyOption[] {\n return Object.entries<Property>(properties)\n .flatMap(([key, property]) => getColumnKeysForProperty(property, key))\n .flatMap(({ key }) => {\n // Unlike the table, a missing property here is not worth throwing\n // over: the sort control simply has one fewer option to offer.\n const property = getResolvedPropertyInPath(properties, key) as Property | undefined;\n if (!property || !sortableProperty(property)) return [];\n return [{\n key: key as string,\n title: property.name ?? key as string,\n property\n }];\n });\n}\n\n/**\n * Whether this column can be ordered by.\n *\n * `sortable` arrived as one flag for the whole table while `filter` was\n * computed per property, so every column advertised a sort — including the ones\n * no `ORDER BY` can be written for. A to-many relation is a *set* per row\n * (`posts.tags`), and there is no single value to order on; the driver used to\n * answer by silently dropping the sort and returning rows in whatever order\n * Postgres pleased, which is how a header that did nothing went unnoticed.\n *\n * Now that the driver refuses instead, offering the control would turn a\n * useless header into a failed request. Same authority as the filter side: ask\n * the property, not the table.\n */\nfunction sortableProperty(property: Property): boolean {\n if (property.type !== \"relation\") return true;\n const relationProperty = property as RelationProperty;\n const kind = relationProperty.relation?.kind ?? relationProperty.resolvedRelation?.kind;\n // An unresolved relation keeps the benefit of the doubt — the same choice\n // `isFilterableRelation` makes for a kind it cannot see.\n if (!kind) return true;\n return kind === \"belongsTo\";\n}\n\nfunction filterableProperty(property: Property, engine?: string): boolean {\n // The same question the filters dialog asks, answered in one place — see\n // `isPropertyFilterable`. It used to be answered here by a second\n // predicate, and the two disagreed on arrays, on `filterOperators: []`\n // and on a custom `admin.Filter`. A relation this engine's driver cannot\n // compile into a `WHERE` is not filterable either way: before the driver\n // started failing closed, sending one silently returned every row.\n return isPropertyFilterable(property, engine);\n}\n"],"mappings":";;;;;;AA4CA,SAAgB,oBAAuD,EAAE,YAAY,UAAU,aAAa,QAAQ,gBAAgB,eAAe,0BAA8E;CAI7N,MAAM,WAAW,QAAgB,QAAQ,eAAe,OAAO,WAAW;CAC1E,OAAO,OAAO,QAAkB,UAAU,CAAC,CACtC,SAAS,CAAC,KAAK,cAAc,yBAAyB,UAAU,GAAG,CAAC,CAAC,CACrE,SAAS,EACN,KACA,eACE;EACF,MAAM,WAAW,0BAA0B,YAAY,GAAG;EAQ1D,IAAI,CAAC,UAAU;GACX,QAAQ,KAAK,8BAA8B,IAAI,0BAA0B;GACzE,OAAO,CAAC;EACZ;EACA,MAAM,aAAa,mBAAmB,UAAU,MAAM;EACtD,OAAO,CAAC;GACC;GACL,OAAO,sBAAsB,QAAQ;GACrC,OAAO,SAAS,QAAQ;GACxB,UAAU,YAAY,iBAAiB,QAAQ;GAC/C,QAAQ,CAAC,QAAQ,GAAG,KAAK;GACzB,OAAO,4BAA4B,UAAU;IACzC,GAAG;IACH,UAAU,QAAQ,aAAa,KAAK,CAAC,WAAW,QAAQ;GAC5D,CAAC;GACD,WAAW;GACX,QAAQ;IACJ,kBAAkB;IAClB;GACJ;GACA,wBAAwB,0BACjB,EAAE,cAAoC,oBAAC,wBAAD;IAAkC;IAAU,aAAa;IAAc;GAAS,CAAA,IACvH,KAAA;EACV,CAA8B;CAClC,CAAC;AACT;;;;;;;;;;;;AAmBA,SAAgB,2BAA2B,YAAkD;CACzF,OAAO,OAAO,QAAkB,UAAU,CAAC,CACtC,SAAS,CAAC,KAAK,cAAc,yBAAyB,UAAU,GAAG,CAAC,CAAC,CACrE,SAAS,EAAE,UAAU;EAGlB,MAAM,WAAW,0BAA0B,YAAY,GAAG;EAC1D,IAAI,CAAC,YAAY,CAAC,iBAAiB,QAAQ,GAAG,OAAO,CAAC;EACtD,OAAO,CAAC;GACC;GACL,OAAO,SAAS,QAAQ;GACxB;EACJ,CAAC;CACL,CAAC;AACT;;;;;;;;;;;;;;;AAgBA,SAAS,iBAAiB,UAA6B;CACnD,IAAI,SAAS,SAAS,YAAY,OAAO;CACzC,MAAM,mBAAmB;CACzB,MAAM,OAAO,iBAAiB,UAAU,QAAQ,iBAAiB,kBAAkB;CAGnF,IAAI,CAAC,MAAM,OAAO;CAClB,OAAO,SAAS;AACpB;AAEA,SAAS,mBAAmB,UAAoB,QAA0B;CAOtE,OAAO,qBAAqB,UAAU,MAAM;AAChD"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import {
|
|
3
|
-
import { AdminCollection } from "@rebasepro/cms-types";
|
|
2
|
+
import { FilterValues } from "@rebasepro/types";
|
|
3
|
+
import { AdminCollection, Relation, EntityRelation } from "@rebasepro/cms-types";
|
|
4
4
|
type TableMultipleRelationFieldProps = {
|
|
5
5
|
name: string;
|
|
6
6
|
disabled: boolean;
|
|
@@ -4,9 +4,8 @@ import { useEntitySelectionDialog } from "../../../hooks/useSelectionDialog.js";
|
|
|
4
4
|
import React, { useCallback, useEffect } from "react";
|
|
5
5
|
import { jsx } from "react/jsx-runtime";
|
|
6
6
|
import { deepEqual } from "fast-equals";
|
|
7
|
-
import { getRelationFrom, normalizeToEntityRelation } from "@rebasepro/
|
|
7
|
+
import { getCollectionDataPath, getRelationFrom, normalizeToEntityRelation } from "@rebasepro/cms-types";
|
|
8
8
|
import { ErrorView } from "@rebasepro/app";
|
|
9
|
-
import { getCollectionDataPath } from "@rebasepro/types";
|
|
10
9
|
//#region src/components/CollectionTableBinding/fields/TableMultipleRelationField.tsx
|
|
11
10
|
function TableMultipleRelationField(props) {
|
|
12
11
|
const collection = props.relation.target();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TableMultipleRelationField.js","names":[],"sources":["../../../../src/components/CollectionTableBinding/fields/TableMultipleRelationField.tsx"],"sourcesContent":["import { useEntitySelectionDialog } from \"../../../hooks/useSelectionDialog\";\n\nimport
|
|
1
|
+
{"version":3,"file":"TableMultipleRelationField.js","names":[],"sources":["../../../../src/components/CollectionTableBinding/fields/TableMultipleRelationField.tsx"],"sourcesContent":["import { useEntitySelectionDialog } from \"../../../hooks/useSelectionDialog\";\n\nimport React, { useCallback, useEffect } from \"react\";\nimport { deepEqual as equal } from \"fast-equals\";\n\n\nimport { RelationPreview } from \"../../../preview\";\nimport { FilterValues } from \"@rebasepro/types\";\nimport { AdminCollection, getRelationFrom, getCollectionDataPath, Relation, normalizeToEntityRelation, EntityRelation, Entity } from \"@rebasepro/cms-types\";\nimport { } from \"@rebasepro/app\";\nimport { ErrorView } from \"@rebasepro/app\";\nimport { CompactEntityCellField } from \"./CompactEntityCellField\";\n\ntype TableMultipleRelationFieldProps = {\n name: string;\n disabled: boolean;\n internalValue: EntityRelation[] | undefined | null;\n updateValue: (newValue: EntityRelation[] | null) => void;\n previewProperties?: string[];\n relation: Relation;\n fixedFilter?: FilterValues<string>;\n includeId?: boolean;\n includeEntityLink?: boolean;\n /** The cell is selected. */\n selected?: boolean;\n /** See `TableRelationField`. */\n open?: boolean;\n onOpenChange?: (open: boolean) => void;\n};\n\nexport function TableMultipleRelationField(props: TableMultipleRelationFieldProps) {\n const collection = props.relation.target();\n return <TableMultipleRelationFieldInternal {...props} collection={collection}/>;\n}\n\nexport const TableMultipleRelationFieldInternal = React.memo(\n function TableMultipleRelationFieldInternal(props: TableMultipleRelationFieldProps & {\n collection: AdminCollection;\n }) {\n const {\n name,\n internalValue,\n updateValue,\n previewProperties,\n disabled,\n fixedFilter,\n collection,\n includeId,\n includeEntityLink,\n selected,\n open,\n onOpenChange\n } = props;\n\n const value = Array.isArray(internalValue) ? internalValue : [];\n\n const onMultipleEntitiesSelected = useCallback((entities: Entity<any>[]) => {\n updateValue(entities.map(e => getRelationFrom(e)));\n }, [updateValue]);\n\n const selectedEntityIds = value.map((ref) => ref.id);\n\n const relationDialogController = useEntitySelectionDialog({\n multiselect: true,\n path: getCollectionDataPath(collection),\n collection,\n onMultipleEntitiesSelected,\n selectedEntityIds,\n fixedFilter\n }\n );\n\n const handleOpen = () => {\n if (disabled)\n return;\n relationDialogController.open();\n };\n\n // The cell's opener asks for the dialog. It is a request, not a state:\n // the dialog closes itself, so the request is handed straight back.\n useEffect(() => {\n if (!open) return;\n onOpenChange?.(false);\n handleOpen();\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [open]);\n\n const valueNotSet = !internalValue || (Array.isArray(internalValue) && internalValue.length === 0);\n\n if (!collection)\n return <ErrorView error={\"The specified collection does not exist\"}/>;\n\n // One line at every row size: see CompactEntityCellField.\n return <CompactEntityCellField empty={valueNotSet}\n disabled={disabled}\n selected={selected}\n onClear={() => updateValue([])}>\n {value.map((item, index) => {\n const relationItem = normalizeToEntityRelation(item);\n if (!relationItem) return null;\n return <RelationPreview key={`compact_rel_${name}_${index}`}\n size={\"small\"}\n relation={relationItem}\n hover={false}\n previewProperties={previewProperties}\n includeId={includeId}\n includeEntityLink={includeEntityLink}/>;\n })}\n </CompactEntityCellField>;\n }, equal);\n"],"mappings":";;;;;;;;;AA8BA,SAAgB,2BAA2B,OAAwC;CAC/E,MAAM,aAAa,MAAM,SAAS,OAAO;CACzC,OAAO,oBAAC,oCAAD;EAAoC,GAAI;EAAmB;CAAY,CAAA;AAClF;AAEA,IAAa,qCAAqC,MAAM,KACpD,SAAS,mCAAmC,OAEzC;CACC,MAAM,EACF,MACA,eACA,aACA,mBACA,UACA,aACA,YACA,WACA,mBACA,UACA,MACA,iBACA;CAEJ,MAAM,QAAQ,MAAM,QAAQ,aAAa,IAAI,gBAAgB,CAAC;CAE9D,MAAM,6BAA6B,aAAa,aAA4B;EACxE,YAAY,SAAS,KAAI,MAAK,gBAAgB,CAAC,CAAC,CAAC;CACrD,GAAG,CAAC,WAAW,CAAC;CAEhB,MAAM,oBAAoB,MAAM,KAAK,QAAQ,IAAI,EAAE;CAEnD,MAAM,2BAA2B,yBAAyB;EACtD,aAAa;EACb,MAAM,sBAAsB,UAAU;EACtC;EACA;EACA;EACA;CACJ,CACA;CAEA,MAAM,mBAAmB;EACrB,IAAI,UACA;EACJ,yBAAyB,KAAK;CAClC;CAIA,gBAAgB;EACZ,IAAI,CAAC,MAAM;EACX,eAAe,KAAK;EACpB,WAAW;CAEf,GAAG,CAAC,IAAI,CAAC;CAET,MAAM,cAAc,CAAC,iBAAkB,MAAM,QAAQ,aAAa,KAAK,cAAc,WAAW;CAEhG,IAAI,CAAC,YACD,OAAO,oBAAC,WAAD,EAAW,OAAO,0CAA2C,CAAA;CAGxE,OAAO,oBAAC,wBAAD;EAAwB,OAAO;EACxB;EACA;EACV,eAAe,YAAY,CAAC,CAAC;YAC5B,MAAM,KAAK,MAAM,UAAU;GACxB,MAAM,eAAe,0BAA0B,IAAI;GACnD,IAAI,CAAC,cAAc,OAAO;GAC1B,OAAO,oBAAC,iBAAD;IACH,MAAM;IACN,UAAU;IACV,OAAO;IACY;IACR;IACQ;GAAmB,GANb,eAAe,KAAK,GAAG,OAMV;EAC9C,CAAC;CACmB,CAAA;AAC5B,GAAG,SAAK"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import {
|
|
3
|
-
import { CollectionSize, AdminCollection } from "@rebasepro/cms-types";
|
|
2
|
+
import { FilterValues } from "@rebasepro/types";
|
|
3
|
+
import { CollectionSize, AdminCollection, EntityReference } from "@rebasepro/cms-types";
|
|
4
4
|
type TableReferenceFieldProps = {
|
|
5
5
|
name: string;
|
|
6
6
|
disabled: boolean;
|
|
@@ -22,8 +22,8 @@ function TableReferenceFieldResolver(props) {
|
|
|
22
22
|
}
|
|
23
23
|
function TableReferenceField(props) {
|
|
24
24
|
const collectionRegistryController = useCollectionRegistryController();
|
|
25
|
-
const {
|
|
26
|
-
const path =
|
|
25
|
+
const { targetPath } = useReferencePaths();
|
|
26
|
+
const path = targetPath(props.path);
|
|
27
27
|
const collection = collectionRegistryController.getCollection(path);
|
|
28
28
|
const content = /* @__PURE__ */ jsx(TableReferenceFieldResolver, {
|
|
29
29
|
...props,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TableReferenceField.js","names":[],"sources":["../../../../src/components/CollectionTableBinding/fields/TableReferenceField.tsx"],"sourcesContent":["import { useEntitySelectionDialog } from \"../../../hooks/useSelectionDialog\";\n\nimport React, { useCallback, useEffect } from \"react\";\nimport { deepEqual as equal } from \"fast-equals\"\n\nimport { ReferencePreview } from \"../../../preview\";\nimport {
|
|
1
|
+
{"version":3,"file":"TableReferenceField.js","names":[],"sources":["../../../../src/components/CollectionTableBinding/fields/TableReferenceField.tsx"],"sourcesContent":["import { useEntitySelectionDialog } from \"../../../hooks/useSelectionDialog\";\n\nimport React, { useCallback, useEffect } from \"react\";\nimport { deepEqual as equal } from \"fast-equals\"\n\nimport { ReferencePreview } from \"../../../preview\";\nimport { FilterValues } from \"@rebasepro/types\";\nimport { CollectionSize, AdminCollection, EntityReference, Entity } from \"@rebasepro/cms-types\";\n\nimport { getPreviewSizeFrom } from \"../../../preview/util\";\nimport { useComponentOverride, ErrorView, CollectionScopeProvider } from \"@rebasepro/app\";\nimport { useCollectionRegistryController } from \"../../../hooks/navigation/contexts/CollectionRegistryContext\";\nimport { useReferencePaths } from \"../../../hooks/useReferencePaths\";\nimport { CompactEntityCellField } from \"./CompactEntityCellField\";\nimport { DefaultMissingReference } from \"../../DefaultMissingReference\";\n\ntype TableReferenceFieldProps = {\n name: string;\n disabled: boolean;\n internalValue: EntityReference | EntityReference[] | undefined | null;\n updateValue: (newValue: (EntityReference | EntityReference[] | null)) => void;\n size: CollectionSize;\n multiselect: boolean;\n previewProperties?: string[];\n path: string;\n fixedFilter?: FilterValues<string>;\n includeId?: boolean;\n includeEntityLink?: boolean;\n /** The cell is selected. */\n selected?: boolean;\n /**\n * Set by the cell's opener: opens the selection dialog, and is handed\n * back as closed at once — the dialog keeps its own state from there.\n */\n open?: boolean;\n onOpenChange?: (open: boolean) => void;\n};\n\n\nfunction TableReferenceFieldResolver(props: TableReferenceFieldProps & { collection: AdminCollection | undefined }) {\n const ResolvedMissingReference = useComponentOverride(\"Entity.MissingReference\", DefaultMissingReference);\n const { path, collection } = props;\n\n if (!collection) {\n if (ResolvedMissingReference !== DefaultMissingReference) {\n return <ResolvedMissingReference path={path}/>;\n } else {\n return <ErrorView error={`Collection not found: ${path}`}/>;\n }\n }\n return <TableReferenceFieldInternal {...props} collection={collection}/>;\n}\n\nexport function TableReferenceField(props: TableReferenceFieldProps) {\n const collectionRegistryController = useCollectionRegistryController();\n const { targetPath } = useReferencePaths();\n const path = targetPath(props.path);\n const collection = collectionRegistryController.getCollection(path);\n\n const content = (\n <TableReferenceFieldResolver\n {...props}\n path={path}\n collection={collection}\n />\n );\n\n if (collection) {\n return (\n <CollectionScopeProvider collection={collection}>\n {content}\n </CollectionScopeProvider>\n );\n }\n return content;\n}\n\nexport const TableReferenceFieldInternal = React.memo(\n function TableReferenceFieldInternal(props: TableReferenceFieldProps & {\n collection: AdminCollection;\n }) {\n const {\n name,\n internalValue,\n updateValue,\n multiselect,\n path,\n size,\n previewProperties,\n disabled,\n fixedFilter,\n collection,\n includeId,\n includeEntityLink,\n selected,\n open,\n onOpenChange\n } = props;\n\n const { referenceTo } = useReferencePaths();\n\n const onSingleEntitySelected = useCallback((entity: Entity<any>) => {\n updateValue(entity ? referenceTo(entity) : null);\n }, [updateValue, referenceTo]);\n\n const onMultipleEntitiesSelected = useCallback((entities: Entity<any>[]) => {\n updateValue(entities.map((e) => referenceTo(e)));\n }, [updateValue, referenceTo]);\n\n const selectedEntityIds = internalValue\n ? (Array.isArray(internalValue)\n ? internalValue.map((ref) => ref.id)\n : internalValue.id ? [internalValue.id] : [])\n : [];\n\n const referenceDialogController = useEntitySelectionDialog({\n multiselect,\n path,\n collection,\n onMultipleEntitiesSelected,\n onSingleEntitySelected,\n selectedEntityIds,\n fixedFilter\n }\n );\n\n const handleOpen = () => {\n if (disabled)\n return;\n referenceDialogController.open();\n };\n\n // The cell's opener asks for the dialog. It is a request, not a state:\n // the dialog closes itself, so the request is handed straight back.\n useEffect(() => {\n if (!open) return;\n onOpenChange?.(false);\n handleOpen();\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [open]);\n\n const valueNotSet = !internalValue || (Array.isArray(internalValue) && internalValue.length === 0);\n\n if (!collection)\n return <ErrorView error={\"The specified collection does not exist\"}/>;\n\n // One line at every row size: the inline previews (each title opens\n // its record), the cell's opener to pick and a cross to clear. A single\n // record takes the row's preview size; a list stays lines.\n const refs: EntityReference[] = !internalValue ? [] : (Array.isArray(internalValue) ? internalValue : [internalValue]);\n return <CompactEntityCellField empty={valueNotSet}\n disabled={disabled}\n selected={selected}\n onClear={() => updateValue(multiselect ? [] : null)}>\n {refs.map((reference, index) =>\n reference && reference.isEntityReference && reference.isEntityReference()\n ? <ReferencePreview key={`compact_ref_${name}_${index}`}\n size={multiselect ? \"small\" : getPreviewSizeFrom(size)}\n reference={reference}\n hover={false}\n disabled={!path}\n previewProperties={previewProperties}\n includeId={includeId}\n includeEntityLink={includeEntityLink}/>\n : <ErrorView key={`compact_ref_${name}_${index}`} error={\"Value is not a reference\"}/>)}\n </CompactEntityCellField>;\n }, equal);\n"],"mappings":";;;;;;;;;;;;AAuCA,SAAS,4BAA4B,OAA+E;CAChH,MAAM,2BAA2B,qBAAqB,2BAA2B,uBAAuB;CACxG,MAAM,EAAE,MAAM,eAAe;CAE7B,IAAI,CAAC,YACD,IAAI,6BAA6B,yBAC7B,OAAO,oBAAC,0BAAD,EAAgC,KAAM,CAAA;MAE7C,OAAO,oBAAC,WAAD,EAAW,OAAO,yBAAyB,OAAQ,CAAA;CAGlE,OAAO,oBAAC,6BAAD;EAA6B,GAAI;EAAmB;CAAY,CAAA;AAC3E;AAEA,SAAgB,oBAAoB,OAAiC;CACjE,MAAM,+BAA+B,gCAAgC;CACrE,MAAM,EAAE,eAAe,kBAAkB;CACzC,MAAM,OAAO,WAAW,MAAM,IAAI;CAClC,MAAM,aAAa,6BAA6B,cAAc,IAAI;CAElE,MAAM,UACF,oBAAC,6BAAD;EACI,GAAI;EACE;EACM;CACf,CAAA;CAGL,IAAI,YACA,OACI,oBAAC,yBAAD;EAAqC;YAChC;CACoB,CAAA;CAGjC,OAAO;AACX;AAEA,IAAa,8BAA8B,MAAM,KAC7C,SAAS,4BAA4B,OAElC;CACC,MAAM,EACF,MACA,eACA,aACA,aACA,MACA,MACA,mBACA,UACA,aACA,YACA,WACA,mBACA,UACA,MACA,iBACA;CAEJ,MAAM,EAAE,gBAAgB,kBAAkB;CAE1C,MAAM,yBAAyB,aAAa,WAAwB;EAChE,YAAY,SAAS,YAAY,MAAM,IAAI,IAAI;CACnD,GAAG,CAAC,aAAa,WAAW,CAAC;CAY7B,MAAM,4BAA4B,yBAAyB;EACvD;EACA;EACA;EACA,4BAd+B,aAAa,aAA4B;GACxE,YAAY,SAAS,KAAK,MAAM,YAAY,CAAC,CAAC,CAAC;EACnD,GAAG,CAAC,aAAa,WAAW,CAYxB;EACA;EACA,mBAZsB,gBACnB,MAAM,QAAQ,aAAa,IACxB,cAAc,KAAK,QAAQ,IAAI,EAAE,IACjC,cAAc,KAAK,CAAC,cAAc,EAAE,IAAI,CAAC,IAC7C,CAAC;EASH;CACJ,CACA;CAEA,MAAM,mBAAmB;EACrB,IAAI,UACA;EACJ,0BAA0B,KAAK;CACnC;CAIA,gBAAgB;EACZ,IAAI,CAAC,MAAM;EACX,eAAe,KAAK;EACpB,WAAW;CAEf,GAAG,CAAC,IAAI,CAAC;CAET,MAAM,cAAc,CAAC,iBAAkB,MAAM,QAAQ,aAAa,KAAK,cAAc,WAAW;CAEhG,IAAI,CAAC,YACD,OAAO,oBAAC,WAAD,EAAW,OAAO,0CAA2C,CAAA;CAMxE,OAAO,oBAAC,wBAAD;EAAwB,OAAO;EACxB;EACA;EACV,eAAe,YAAY,cAAc,CAAC,IAAI,IAAI;aAJtB,CAAC,gBAAgB,CAAC,IAAK,MAAM,QAAQ,aAAa,IAAI,gBAAgB,CAAC,aAAa,EAAA,CAK1G,KAAK,WAAW,UAClB,aAAa,UAAU,qBAAqB,UAAU,kBAAkB,IAClE,oBAAC,kBAAD;GACE,MAAM,cAAc,UAAU,mBAAmB,IAAI;GAC1C;GACX,OAAO;GACP,UAAU,CAAC;GACQ;GACR;GACQ;EAAmB,GAPjB,eAAe,KAAK,GAAG,OAON,IACxC,oBAAC,WAAD,EAAgD,OAAO,2BAA4B,GAAnE,eAAe,KAAK,GAAG,OAA4C,CAAC;CAC1E,CAAA;AAC5B,GAAG,SAAK"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import {
|
|
3
|
-
import { CollectionSize, AdminCollection } from "@rebasepro/cms-types";
|
|
2
|
+
import { FilterValues } from "@rebasepro/types";
|
|
3
|
+
import { CollectionSize, AdminCollection, Relation, EntityRelation } from "@rebasepro/cms-types";
|
|
4
4
|
type TableRelationFieldProps = {
|
|
5
5
|
name: string;
|
|
6
6
|
disabled: boolean;
|
|
@@ -6,9 +6,8 @@ import { useEntitySelectionDialog } from "../../../hooks/useSelectionDialog.js";
|
|
|
6
6
|
import React, { useCallback, useEffect } from "react";
|
|
7
7
|
import { jsx } from "react/jsx-runtime";
|
|
8
8
|
import { deepEqual } from "fast-equals";
|
|
9
|
-
import { getRelationFrom, normalizeToEntityRelation } from "@rebasepro/
|
|
9
|
+
import { getCollectionDataPath, getRelationFrom, normalizeToEntityRelation } from "@rebasepro/cms-types";
|
|
10
10
|
import { ErrorView } from "@rebasepro/app";
|
|
11
|
-
import { getCollectionDataPath } from "@rebasepro/types";
|
|
12
11
|
//#region src/components/CollectionTableBinding/fields/TableRelationField.tsx
|
|
13
12
|
/** Whether an authored relation yields many rows. Derived from its kind. */
|
|
14
13
|
function relationCardinality(relation) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TableRelationField.js","names":[],"sources":["../../../../src/components/CollectionTableBinding/fields/TableRelationField.tsx"],"sourcesContent":["import { useEntitySelectionDialog } from \"../../../hooks/useSelectionDialog\";\n\nimport
|
|
1
|
+
{"version":3,"file":"TableRelationField.js","names":[],"sources":["../../../../src/components/CollectionTableBinding/fields/TableRelationField.tsx"],"sourcesContent":["import { useEntitySelectionDialog } from \"../../../hooks/useSelectionDialog\";\n\nimport React, { useCallback, useEffect } from \"react\";\nimport { deepEqual as equal } from \"fast-equals\"\n\nimport { RelationPreview } from \"../../../preview\";\nimport { FilterValues } from \"@rebasepro/types\";\nimport { CollectionSize, AdminCollection, getRelationFrom, getCollectionDataPath, Relation, EntityRelation, normalizeToEntityRelation, Entity } from \"@rebasepro/cms-types\";\n\nimport { getPreviewSizeFrom } from \"../../../preview/util\";\nimport { } from \"@rebasepro/app\";\nimport { ErrorView } from \"@rebasepro/app\";\nimport { TableMultipleRelationField } from \"./TableMultipleRelationField\";\nimport { CompactEntityCellField } from \"./CompactEntityCellField\";\n\n/** Whether an authored relation yields many rows. Derived from its kind. */\nfunction 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\ntype TableRelationFieldProps = {\n name: string;\n disabled: boolean;\n internalValue: EntityRelation | EntityRelation[] | undefined | null;\n updateValue: (newValue: (EntityRelation | EntityRelation[] | null)) => void;\n size: CollectionSize;\n multiselect: boolean;\n previewProperties?: string[];\n relation: Relation;\n fixedFilter?: FilterValues<string>;\n includeId?: boolean;\n includeEntityLink?: boolean;\n /** The cell is selected. */\n selected?: boolean;\n /**\n * Set by the cell's opener: opens the selection dialog, and is handed\n * back as closed at once — the dialog keeps its own state from there.\n */\n open?: boolean;\n onOpenChange?: (open: boolean) => void;\n};\n\nexport function TableRelationField(props: TableRelationFieldProps) {\n const collection = props.relation.target();\n\n // Check if this is a many-to-many relation\n const manyRelation = relationCardinality(props.relation) === \"many\";\n\n if (manyRelation) {\n return <TableMultipleRelationField\n name={props.name}\n disabled={props.disabled}\n internalValue={Array.isArray(props.internalValue) ? props.internalValue : []}\n updateValue={(newValue) => props.updateValue(newValue)}\n previewProperties={props.previewProperties}\n relation={props.relation}\n fixedFilter={props.fixedFilter}\n includeId={props.includeId}\n includeEntityLink={props.includeEntityLink}\n selected={props.selected}\n open={props.open}\n onOpenChange={props.onOpenChange}\n />;\n }\n\n return <TableRelationFieldInternal {...props} collection={collection}/>;\n}\n\nexport const TableRelationFieldInternal = React.memo(\n function TableRelationFieldInternal(props: TableRelationFieldProps & {\n collection: AdminCollection;\n }) {\n const {\n name,\n internalValue,\n updateValue,\n multiselect,\n relation,\n size,\n previewProperties,\n disabled,\n fixedFilter,\n collection,\n includeId,\n includeEntityLink,\n selected,\n open,\n onOpenChange\n } = props;\n\n const onSingleEntitySelected = useCallback((entity: Entity<any>) => {\n updateValue(entity ? getRelationFrom(entity) : null);\n }, [updateValue]);\n\n const onMultipleEntitiesSelected = useCallback((entities: Entity<any>[]) => {\n updateValue(entities.map((e) => getRelationFrom(e)));\n }, [updateValue]);\n\n const selectedEntityIds = internalValue\n ? (Array.isArray(internalValue)\n ? internalValue.map((ref) => ref.id)\n : internalValue.id ? [internalValue.id] : [])\n : [];\n\n const relationDialogController = useEntitySelectionDialog({\n multiselect,\n path: getCollectionDataPath(collection),\n collection,\n onMultipleEntitiesSelected,\n onSingleEntitySelected,\n selectedEntityIds,\n fixedFilter\n }\n );\n\n const handleOpen = () => {\n if (disabled)\n return;\n relationDialogController.open();\n };\n\n // The cell's opener asks for the dialog. It is a request, not a state:\n // the dialog closes itself, so the request is handed straight back.\n useEffect(() => {\n if (!open) return;\n onOpenChange?.(false);\n handleOpen();\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [open]);\n\n const valueNotSet = !internalValue || (Array.isArray(internalValue) && internalValue.length === 0);\n\n if (!collection)\n return <ErrorView error={\"The specified collection does not exist\"}/>;\n\n // One line at every row size: see CompactEntityCellField. A single\n // record takes the row's preview size — a line of text in a text row,\n // a row with its image in a taller one — and a list stays lines.\n const items = !internalValue ? [] : (Array.isArray(internalValue) ? internalValue : [internalValue]);\n return <CompactEntityCellField empty={valueNotSet}\n disabled={disabled}\n selected={selected}\n onClear={() => updateValue(multiselect ? [] : null)}>\n {items.map((item, index) => {\n const relationItem = normalizeToEntityRelation(item);\n if (!relationItem) return null;\n return <RelationPreview key={`compact_rel_${name}_${index}`}\n size={multiselect ? \"small\" : getPreviewSizeFrom(size)}\n relation={relationItem}\n hover={false}\n previewProperties={previewProperties}\n includeId={includeId}\n includeEntityLink={includeEntityLink}/>;\n })}\n </CompactEntityCellField>;\n }, equal);\n"],"mappings":";;;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AK,CAAC,cAAc,EAAE,IAAI,CAAC,IAC7C,CAAC;CAEP,MAAM,2BAA2B,yBAAyB;EACtD;EACA,MAAM,sBAAsB,UAAU;EACtC;EACA;EACA;EACA;EACA;CACJ,CACA;CAEA,MAAM,mBAAmB;EACrB,IAAI,UACA;EACJ,yBAAyB,KAAK;CAClC;CAIA,gBAAgB;EACZ,IAAI,CAAC,MAAM;EACX,eAAe,KAAK;EACpB,WAAW;CAEf,GAAG,CAAC,IAAI,CAAC;CAET,MAAM,cAAc,CAAC,iBAAkB,MAAM,QAAQ,aAAa,KAAK,cAAc,WAAW;CAEhG,IAAI,CAAC,YACD,OAAO,oBAAC,WAAD,EAAW,OAAO,0CAA2C,CAAA;CAMxE,OAAO,oBAAC,wBAAD;EAAwB,OAAO;EACxB;EACA;EACV,eAAe,YAAY,cAAc,CAAC,IAAI,IAAI;aAJxC,CAAC,gBAAgB,CAAC,IAAK,MAAM,QAAQ,aAAa,IAAI,gBAAgB,CAAC,aAAa,EAAA,CAKvF,KAAK,MAAM,UAAU;GACxB,MAAM,eAAe,0BAA0B,IAAI;GACnD,IAAI,CAAC,cAAc,OAAO;GAC1B,OAAO,oBAAC,iBAAD;IACH,MAAM,cAAc,UAAU,mBAAmB,IAAI;IACrD,UAAU;IACV,OAAO;IACY;IACR;IACQ;GAAmB,GANb,eAAe,KAAK,GAAG,OAMV;EAC9C,CAAC;CACmB,CAAA;AAC5B,GAAG,SAAK"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import {
|
|
2
|
+
import { FilterValues } from "@rebasepro/types";
|
|
3
|
+
import { Relation, EntityRelation } from "@rebasepro/cms-types";
|
|
3
4
|
interface RelationSelectorFieldProps {
|
|
4
5
|
/** Field name */
|
|
5
6
|
name: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TableRelationSelectorField.js","names":[],"sources":["../../../../src/components/CollectionTableBinding/fields/TableRelationSelectorField.tsx"],"sourcesContent":["import React, { useEffect, useRef } from \"react\";\nimport {
|
|
1
|
+
{"version":3,"file":"TableRelationSelectorField.js","names":[],"sources":["../../../../src/components/CollectionTableBinding/fields/TableRelationSelectorField.tsx"],"sourcesContent":["import React, { useEffect, useRef } from \"react\";\nimport { FilterValues } from \"@rebasepro/types\";\nimport { Relation, EntityRelation } from \"@rebasepro/cms-types\";\nimport { RelationSelector } from \"../../RelationSelector\";\n\ninterface RelationSelectorFieldProps {\n /** Field name */\n name: string;\n /** Whether the field is disabled */\n disabled?: boolean;\n /** Current value - can be single EntityRelation or array for multiple selection */\n internalValue: EntityRelation | EntityRelation[] | undefined | null;\n /** Callback when value changes */\n updateValue: (newValue: EntityRelation | EntityRelation[] | null) => void;\n /** The relation configuration */\n relation: Relation;\n /** Force filter to be applied to the relation search */\n fixedFilter?: FilterValues<string>;\n /** The cell is selected: the trigger takes the focus, so Enter opens the list. */\n focused?: boolean;\n /** Whether the list is open. Set by the cell's opener as well as the trigger. */\n open?: boolean;\n onOpenChange?: (open: boolean) => void;\n /**\n * What the cell shows at rest. The trigger shows the same node, so a\n * selected cell looks like an unselected one.\n */\n preview?: React.ReactNode;\n /** The cell: the list opens against it rather than against the trigger. */\n anchorRef?: React.RefObject<HTMLElement | null>;\n}\n\n/** Thin wrapper around RelationSelector for table cells */\nexport function TableRelationSelectorField({\n disabled = false,\n internalValue,\n updateValue,\n relation,\n fixedFilter,\n focused,\n open,\n onOpenChange,\n preview,\n anchorRef\n}: RelationSelectorFieldProps) {\n\n const ref = useRef<HTMLElement>(null);\n useEffect(() => {\n if (focused) ref.current?.focus({ preventScroll: true });\n }, [focused]);\n\n // Closing the list hands the focus back to the trigger, so the next Escape\n // clears the cell and Enter opens it again — unless the focus has already\n // gone somewhere of its own, like another cell that was clicked.\n const handleOpenChange = (nextOpen: boolean) => {\n onOpenChange?.(nextOpen);\n if (!nextOpen) {\n setTimeout(() => {\n if (!document.activeElement || document.activeElement === document.body)\n ref.current?.focus({ preventScroll: true });\n }, 0);\n }\n };\n\n return (\n <RelationSelector\n ref={ref}\n disabled={disabled}\n value={internalValue || null}\n onValueChange={(newVal) => updateValue(newVal ?? null)}\n relation={relation}\n fixedFilter={fixedFilter}\n open={open}\n onOpenChange={handleOpenChange}\n triggerContent={preview}\n anchorRef={anchorRef}\n />\n );\n}\n"],"mappings":";;;;;AAiCA,SAAgB,2BAA2B,EACvC,WAAW,OACX,eACA,aACA,UACA,aACA,SACA,MACA,cACA,SACA,aAC2B;CAE3B,MAAM,MAAM,OAAoB,IAAI;CACpC,gBAAgB;EACZ,IAAI,SAAS,IAAI,SAAS,MAAM,EAAE,eAAe,KAAK,CAAC;CAC3D,GAAG,CAAC,OAAO,CAAC;CAKZ,MAAM,oBAAoB,aAAsB;EAC5C,eAAe,QAAQ;EACvB,IAAI,CAAC,UACD,iBAAiB;GACb,IAAI,CAAC,SAAS,iBAAiB,SAAS,kBAAkB,SAAS,MAC/D,IAAI,SAAS,MAAM,EAAE,eAAe,KAAK,CAAC;EAClD,GAAG,CAAC;CAEZ;CAEA,OACI,oBAAC,kBAAD;EACS;EACK;EACV,OAAO,iBAAiB;EACxB,gBAAgB,WAAW,YAAY,UAAU,IAAI;EAC3C;EACG;EACP;EACN,cAAc;EACd,gBAAgB;EACL;CACd,CAAA;AAET"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { ArrayProperty, StringProperty } from "@rebasepro/types";
|
|
1
|
+
import type { ArrayProperty, StringProperty } from "@rebasepro/cms-types";
|
|
2
2
|
import * as React from "react";
|
|
3
|
-
import { Entity } from "@rebasepro/types";
|
|
3
|
+
import { Entity } from "@rebasepro/cms-types";
|
|
4
4
|
import { PreviewSize } from "../../../types/index.js";
|
|
5
5
|
/**
|
|
6
6
|
* Field that allows to upload files to Google Cloud Storage.
|