@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":"SelectableTable.js","names":[],"sources":["../../../src/components/SelectableTable/SelectableTable.tsx"],"sourcesContent":["import { createSelectionStore, AdminSelectedCell } from \"./SelectionStore\";\nimport type { Property, WhereFilterOp } from \"@rebasepro/types\";\nimport React, { useCallback, useEffect, useMemo, useRef } from \"react\";\nimport { Entity, FilterValues } from \"@rebasepro/types\";\nimport { CollectionSize, EntityTableController, SelectedCellProps, AdminCollection } from \"@rebasepro/cms-types\";\nimport { CellRendererParams, VirtualTable, VirtualTableColumn, VirtualTableFilterValues, VirtualTableSortKey, OnRowClickParams } from \"@rebasepro/ui\";\nimport { DEFAULT_PAGE_SIZE, DataCollectionTableController, OnCellValueChange, OnColumnResizeParams } from \"@rebasepro/app\";\nimport { FilterFormFieldProps } from \"@rebasepro/ui\";\nimport { isKeyHandled, useOutsideAlerter } from \"@rebasepro/ui\";\nimport { SelectableTableContext } from \"./SelectableTableContext\";\nimport { getRowHeight } from \"@rebasepro/app\";\nimport { FilterFieldBinding } from \"./filters/FilterFieldBinding\";\n\nexport type SelectableTableProps<M extends Record<string, unknown>> = {\n\n /**\n * Callback when a cell value changes.\n */\n onValueChange?: OnCellValueChange<unknown, M>;\n\n columns: VirtualTableColumn[];\n\n cellRenderer: (props: CellRendererParams<Entity<M>>) => React.ReactNode;\n\n /**\n * Builder for creating the buttons in each row\n * @param entity\n * @param size\n */\n tableRowActionsBuilder?: (params: {\n entity: Entity<M>,\n size: CollectionSize,\n width: number,\n frozen?: boolean\n }) => React.ReactNode;\n\n /**\n * Callback when anywhere on the table is clicked\n */\n onEntityClick?(entity: Entity<M>): void;\n\n /**\n * Callback when a column is resized\n */\n onColumnResize?(params: OnColumnResizeParams): void;\n\n /**\n * Should apply a different style to a row when hovering\n */\n hoverRow?: boolean;\n\n /**\n * Controller holding the logic for the table\n * {@link useDataTableController}\n * {@link EntityTableController}\n */\n tableController: EntityTableController<M>;\n\n filterable?: boolean;\n\n sortable?: boolean;\n\n inlineEditing?: boolean;\n\n fixedFilter?: FilterValues<keyof M extends string ? keyof M : never>;\n\n highlightedRow?: (data: Entity<M>) => boolean;\n\n size?: CollectionSize;\n\n initialScroll?: number;\n\n /**\n * Callback when the table is scrolled\n * @param props\n */\n onScroll?: (props: {\n scrollDirection: \"forward\" | \"backward\",\n scrollOffset: number,\n scrollUpdateWasRequested: boolean\n }) => void;\n\n emptyComponent?: React.ReactNode;\n\n endAdornment?: React.ReactNode;\n\n AddColumnComponent?: React.ComponentType;\n\n /**\n * Callback when columns are reordered via drag-and-drop\n */\n onColumnsOrderChange?: (columns: VirtualTableColumn[]) => void;\n\n /**\n * Extra data passed to VirtualTable cells. Changes to this object\n * bust the cell memo comparator, triggering re-render of cells\n * even when rowData hasn't changed.\n */\n extraData?: unknown;\n}\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 SelectableTable = function SelectableTable<M extends Record<string, unknown>>\n ({\n onValueChange,\n cellRenderer,\n onEntityClick,\n onColumnResize,\n hoverRow = true,\n size = \"m\",\n inlineEditing = false,\n tableController:\n {\n data,\n sparseData,\n onRowsRendered,\n dataLoading,\n noMoreToLoad,\n dataLoadingError,\n filterValues,\n setFilterValues,\n sortBy,\n setSortBy,\n itemCount,\n setItemCount,\n pageSize = DEFAULT_PAGE_SIZE,\n paginationEnabled,\n checkFilterCombination,\n setPopupCell\n },\n filterable = true,\n onScroll,\n initialScroll,\n emptyComponent,\n columns,\n fixedFilter,\n highlightedRow,\n endAdornment,\n AddColumnComponent,\n onColumnsOrderChange,\n extraData\n }: SelectableTableProps<M>) {\n\n const ref = useRef<HTMLDivElement>(null);\n\n // Create the selection store once\n const selectionStore = useMemo(() => createSelectionStore(), []);\n // We still keep local state for side-effects like outside-alerter, but we don't put it in context\n const [localSelectedCell, setLocalSelectedCell] = React.useState<SelectedCellProps<M> | undefined>(undefined);\n\n const loadNextPage = useCallback(() => {\n if (!paginationEnabled || dataLoading || noMoreToLoad)\n return;\n if (itemCount !== undefined)\n setItemCount?.(itemCount + pageSize);\n }, [paginationEnabled, dataLoading, noMoreToLoad, itemCount, pageSize, setItemCount]);\n\n const resetPagination = useCallback(() => {\n setItemCount?.(pageSize);\n }, [pageSize]);\n\n const onRowClick = useCallback(({ rowData }: OnRowClickParams<Entity<M>>) => {\n if (inlineEditing)\n return;\n return onEntityClick && onEntityClick(rowData);\n }, [onEntityClick, inlineEditing]);\n\n const select = useCallback((cell?: SelectedCellProps<M>) => {\n setLocalSelectedCell(cell);\n if (cell) {\n selectionStore.select({\n ...cell,\n columnKey: cell.propertyKey\n } as AdminSelectedCell);\n } else {\n selectionStore.select(undefined);\n }\n }, [selectionStore]);\n\n const unselect = useCallback(() => {\n setLocalSelectedCell(undefined);\n selectionStore.select(undefined);\n }, [selectionStore]);\n\n useOutsideAlerter(ref,\n () => {\n if (localSelectedCell) {\n unselect();\n }\n },\n Boolean(localSelectedCell));\n\n // on ESC key press\n useEffect(() => {\n const escFunction = (event: KeyboardEvent) => {\n // A layer above the table already acted on this Escape (kit rule:\n // it called preventDefault) — closing it is the whole of the key.\n if (event.key !== \"Escape\" || isKeyHandled(event)) return;\n // A key pressed inside something the table opened — a cell's\n // dropdown, portaled out of the table — is that layer's Escape: it\n // closes the list and leaves the cell selected. The next one, from\n // the cell itself, clears the selection.\n const target = event.target;\n if (target instanceof Node && target !== document.body && ref.current && !ref.current.contains(target))\n return;\n unselect();\n };\n document.addEventListener(\"keydown\", escFunction, false);\n return () => {\n document.removeEventListener(\"keydown\", escFunction, false);\n };\n }, [unselect]);\n\n // The table stops drawing rows when it goes (another view takes over):\n // say so, so the controller keeps every row held current again.\n useEffect(() => () => onRowsRendered?.(undefined), [onRowsRendered]);\n\n const onFilterUpdate = useCallback((updatedFilterValues?: VirtualTableFilterValues<string>) => {\n if (setFilterValues) {\n setFilterValues({\n ...updatedFilterValues,\n ...fixedFilter\n } as FilterValues<Extract<keyof M, string> | (string & {})>);\n }\n }, [fixedFilter, setFilterValues]);\n\n const contextValue = useMemo(() => ({\n select,\n onValueChange,\n size: size ?? \"m\",\n selectionStore,\n setPopupCell\n } as DataCollectionTableController<Record<string, unknown>>), [setPopupCell, select, onValueChange, size, selectionStore]);\n\n const createFilterField = useCallback(({\n id,\n filterValue,\n setFilterValue,\n column,\n hidden,\n setHidden\n }: FilterFormFieldProps<unknown>): React.ReactNode => {\n if (!column.custom) return null;\n const { resolvedProperty } = column.custom as { resolvedProperty?: Property };\n if (!resolvedProperty) return null;\n // Engine-aware operator resolution happens inside FilterFieldBinding,\n // which reads the collection from the surrounding CollectionScopeProvider.\n return <FilterFieldBinding\n propertyKey={id as string}\n property={resolvedProperty}\n value={filterValue as [WhereFilterOp, unknown] | undefined}\n setValue={setFilterValue as (value?: [WhereFilterOp, unknown]) => void}\n hidden={hidden}\n setHidden={setHidden}/>;\n }, []);\n\n return (\n <SelectableTableContext.Provider\n value={contextValue}>\n <div className=\"h-full min-h-0 w-full flex flex-col bg-surface-card\"\n ref={ref}>\n\n <VirtualTable\n data={sparseData ?? data}\n onRowsRendered={onRowsRendered}\n columns={columns}\n cellRenderer={cellRenderer}\n onRowClick={inlineEditing ? undefined : (onEntityClick ? onRowClick : undefined)}\n onEndReached={loadNextPage}\n onResetPagination={resetPagination}\n error={dataLoadingError}\n onColumnResize={onColumnResize}\n rowHeight={getRowHeight(size)}\n loading={dataLoading}\n filter={filterValues}\n onFilterUpdate={setFilterValues ? onFilterUpdate : undefined}\n sortBy={sortBy}\n onSortByUpdate={setSortBy as ((sortBy?: VirtualTableSortKey[]) => void)}\n hoverRow={hoverRow}\n initialScroll={initialScroll}\n onScroll={onScroll}\n checkFilterCombination={checkFilterCombination}\n createFilterField={filterable ? createFilterField : undefined}\n rowClassName={useCallback((entity: Entity<M>) => {\n return highlightedRow?.(entity) ? \"!bg-surface-raised\" : \"\";\n }, [highlightedRow])}\n className=\"grow\"\n emptyComponent={emptyComponent}\n endAdornment={endAdornment}\n AddColumnComponent={AddColumnComponent}\n onColumnsOrderChange={onColumnsOrderChange}\n extraData={extraData}\n />\n\n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AI;IAC5B,SAAS;IACT,QAAQ;IACR,gBAAgB,kBAAkB,iBAAiB,KAAA;IAC3C;IACR,gBAAgB;IACN;IACK;IACL;IACc;IACxB,mBAAmB,aAAa,oBAAoB,KAAA;IACpD,cAAc,aAAa,WAAsB;KAC7C,OAAO,iBAAiB,MAAM,IAAI,uBAAuB;IAC7D,GAAG,CAAC,cAAc,CAAC;IACnB,WAAU;IACM;IACF;IACM;IACE;IACX;GACd,CAAA;EAEA,CAAA;CACwB,CAAA;AAGzC"}
|
|
1
|
+
{"version":3,"file":"SelectableTable.js","names":[],"sources":["../../../src/components/SelectableTable/SelectableTable.tsx"],"sourcesContent":["import { createSelectionStore, AdminSelectedCell } from \"./SelectionStore\";\nimport type { WhereFilterOp } from \"@rebasepro/types\";\nimport type { Property } from \"@rebasepro/cms-types\";\nimport React, { useCallback, useEffect, useMemo, useRef } from \"react\";\nimport { FilterValues } from \"@rebasepro/types\";\nimport { CollectionSize, EntityTableController, SelectedCellProps, AdminCollection, Entity } from \"@rebasepro/cms-types\";\nimport { CellRendererParams, VirtualTable, VirtualTableColumn, VirtualTableFilterValues, VirtualTableSortKey, OnRowClickParams } from \"@rebasepro/ui\";\nimport { DEFAULT_PAGE_SIZE, DataCollectionTableController, OnCellValueChange, OnColumnResizeParams } from \"@rebasepro/app\";\nimport { FilterFormFieldProps } from \"@rebasepro/ui\";\nimport { isKeyHandled, useOutsideAlerter } from \"@rebasepro/ui\";\nimport { SelectableTableContext } from \"./SelectableTableContext\";\nimport { getRowHeight } from \"@rebasepro/app\";\nimport { FilterFieldBinding } from \"./filters/FilterFieldBinding\";\n\nexport type SelectableTableProps<M extends Record<string, unknown>> = {\n\n /**\n * Callback when a cell value changes.\n */\n onValueChange?: OnCellValueChange<unknown, M>;\n\n columns: VirtualTableColumn[];\n\n cellRenderer: (props: CellRendererParams<Entity<M>>) => React.ReactNode;\n\n /**\n * Builder for creating the buttons in each row\n * @param entity\n * @param size\n */\n tableRowActionsBuilder?: (params: {\n entity: Entity<M>,\n size: CollectionSize,\n width: number,\n frozen?: boolean\n }) => React.ReactNode;\n\n /**\n * Callback when anywhere on the table is clicked\n */\n onEntityClick?(entity: Entity<M>): void;\n\n /**\n * Callback when a column is resized\n */\n onColumnResize?(params: OnColumnResizeParams): void;\n\n /**\n * Should apply a different style to a row when hovering\n */\n hoverRow?: boolean;\n\n /**\n * Controller holding the logic for the table\n * {@link useDataTableController}\n * {@link EntityTableController}\n */\n tableController: EntityTableController<M>;\n\n filterable?: boolean;\n\n sortable?: boolean;\n\n inlineEditing?: boolean;\n\n fixedFilter?: FilterValues<keyof M extends string ? keyof M : never>;\n\n highlightedRow?: (data: Entity<M>) => boolean;\n\n size?: CollectionSize;\n\n initialScroll?: number;\n\n /**\n * Callback when the table is scrolled\n * @param props\n */\n onScroll?: (props: {\n scrollDirection: \"forward\" | \"backward\",\n scrollOffset: number,\n scrollUpdateWasRequested: boolean\n }) => void;\n\n emptyComponent?: React.ReactNode;\n\n endAdornment?: React.ReactNode;\n\n AddColumnComponent?: React.ComponentType;\n\n /**\n * Callback when columns are reordered via drag-and-drop\n */\n onColumnsOrderChange?: (columns: VirtualTableColumn[]) => void;\n\n /**\n * Extra data passed to VirtualTable cells. Changes to this object\n * bust the cell memo comparator, triggering re-render of cells\n * even when rowData hasn't changed.\n */\n extraData?: unknown;\n}\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 SelectableTable = function SelectableTable<M extends Record<string, unknown>>\n ({\n onValueChange,\n cellRenderer,\n onEntityClick,\n onColumnResize,\n hoverRow = true,\n size = \"m\",\n inlineEditing = false,\n tableController:\n {\n data,\n sparseData,\n onRowsRendered,\n dataLoading,\n noMoreToLoad,\n dataLoadingError,\n filterValues,\n setFilterValues,\n sortBy,\n setSortBy,\n itemCount,\n setItemCount,\n pageSize = DEFAULT_PAGE_SIZE,\n paginationEnabled,\n checkFilterCombination,\n setPopupCell\n },\n filterable = true,\n onScroll,\n initialScroll,\n emptyComponent,\n columns,\n fixedFilter,\n highlightedRow,\n endAdornment,\n AddColumnComponent,\n onColumnsOrderChange,\n extraData\n }: SelectableTableProps<M>) {\n\n const ref = useRef<HTMLDivElement>(null);\n\n // Create the selection store once\n const selectionStore = useMemo(() => createSelectionStore(), []);\n // We still keep local state for side-effects like outside-alerter, but we don't put it in context\n const [localSelectedCell, setLocalSelectedCell] = React.useState<SelectedCellProps<M> | undefined>(undefined);\n\n const loadNextPage = useCallback(() => {\n if (!paginationEnabled || dataLoading || noMoreToLoad)\n return;\n if (itemCount !== undefined)\n setItemCount?.(itemCount + pageSize);\n }, [paginationEnabled, dataLoading, noMoreToLoad, itemCount, pageSize, setItemCount]);\n\n const resetPagination = useCallback(() => {\n setItemCount?.(pageSize);\n }, [pageSize]);\n\n const onRowClick = useCallback(({ rowData }: OnRowClickParams<Entity<M>>) => {\n if (inlineEditing)\n return;\n return onEntityClick && onEntityClick(rowData);\n }, [onEntityClick, inlineEditing]);\n\n const select = useCallback((cell?: SelectedCellProps<M>) => {\n setLocalSelectedCell(cell);\n if (cell) {\n selectionStore.select({\n ...cell,\n columnKey: cell.propertyKey\n } as AdminSelectedCell);\n } else {\n selectionStore.select(undefined);\n }\n }, [selectionStore]);\n\n const unselect = useCallback(() => {\n setLocalSelectedCell(undefined);\n selectionStore.select(undefined);\n }, [selectionStore]);\n\n useOutsideAlerter(ref,\n () => {\n if (localSelectedCell) {\n unselect();\n }\n },\n Boolean(localSelectedCell));\n\n // on ESC key press\n useEffect(() => {\n const escFunction = (event: KeyboardEvent) => {\n // A layer above the table already acted on this Escape (kit rule:\n // it called preventDefault) — closing it is the whole of the key.\n if (event.key !== \"Escape\" || isKeyHandled(event)) return;\n // A key pressed inside something the table opened — a cell's\n // dropdown, portaled out of the table — is that layer's Escape: it\n // closes the list and leaves the cell selected. The next one, from\n // the cell itself, clears the selection.\n const target = event.target;\n if (target instanceof Node && target !== document.body && ref.current && !ref.current.contains(target))\n return;\n unselect();\n };\n document.addEventListener(\"keydown\", escFunction, false);\n return () => {\n document.removeEventListener(\"keydown\", escFunction, false);\n };\n }, [unselect]);\n\n // The table stops drawing rows when it goes (another view takes over):\n // say so, so the controller keeps every row held current again.\n useEffect(() => () => onRowsRendered?.(undefined), [onRowsRendered]);\n\n const onFilterUpdate = useCallback((updatedFilterValues?: VirtualTableFilterValues<string>) => {\n if (setFilterValues) {\n setFilterValues({\n ...updatedFilterValues,\n ...fixedFilter\n } as FilterValues<Extract<keyof M, string> | (string & {})>);\n }\n }, [fixedFilter, setFilterValues]);\n\n const contextValue = useMemo(() => ({\n select,\n onValueChange,\n size: size ?? \"m\",\n selectionStore,\n setPopupCell\n } as DataCollectionTableController<Record<string, unknown>>), [setPopupCell, select, onValueChange, size, selectionStore]);\n\n const createFilterField = useCallback(({\n id,\n filterValue,\n setFilterValue,\n column,\n hidden,\n setHidden\n }: FilterFormFieldProps<unknown>): React.ReactNode => {\n if (!column.custom) return null;\n const { resolvedProperty } = column.custom as { resolvedProperty?: Property };\n if (!resolvedProperty) return null;\n // Engine-aware operator resolution happens inside FilterFieldBinding,\n // which reads the collection from the surrounding CollectionScopeProvider.\n return <FilterFieldBinding\n propertyKey={id as string}\n property={resolvedProperty}\n value={filterValue as [WhereFilterOp, unknown] | undefined}\n setValue={setFilterValue as (value?: [WhereFilterOp, unknown]) => void}\n hidden={hidden}\n setHidden={setHidden}/>;\n }, []);\n\n return (\n <SelectableTableContext.Provider\n value={contextValue}>\n <div className=\"h-full min-h-0 w-full flex flex-col bg-surface-card\"\n ref={ref}>\n\n <VirtualTable\n data={sparseData ?? data}\n onRowsRendered={onRowsRendered}\n columns={columns}\n cellRenderer={cellRenderer}\n onRowClick={inlineEditing ? undefined : (onEntityClick ? onRowClick : undefined)}\n onEndReached={loadNextPage}\n onResetPagination={resetPagination}\n error={dataLoadingError}\n onColumnResize={onColumnResize}\n rowHeight={getRowHeight(size)}\n loading={dataLoading}\n filter={filterValues}\n onFilterUpdate={setFilterValues ? onFilterUpdate : undefined}\n sortBy={sortBy}\n onSortByUpdate={setSortBy as ((sortBy?: VirtualTableSortKey[]) => void)}\n hoverRow={hoverRow}\n initialScroll={initialScroll}\n onScroll={onScroll}\n checkFilterCombination={checkFilterCombination}\n createFilterField={filterable ? createFilterField : undefined}\n rowClassName={useCallback((entity: Entity<M>) => {\n return highlightedRow?.(entity) ? \"!bg-surface-raised\" : \"\";\n }, [highlightedRow])}\n className=\"grow\"\n emptyComponent={emptyComponent}\n endAdornment={endAdornment}\n AddColumnComponent={AddColumnComponent}\n onColumnsOrderChange={onColumnsOrderChange}\n extraData={extraData}\n />\n\n </div>\n </SelectableTableContext.Provider>\n );\n\n};\n\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8HA,IAAa,kBAAkB,SAAS,gBACnC,EACG,eACA,cACA,eACA,gBACA,WAAW,MACX,OAAO,KACP,gBAAgB,OAChB,iBACA,EACI,MACA,YACA,gBACA,aACA,cACA,kBACA,cACA,iBACA,QACA,WACA,WACA,cACA,WAAW,mBACX,mBACA,wBACA,gBAEJ,aAAa,MACb,UACA,eACA,gBACA,SACA,aACA,gBACA,cACA,oBACA,sBACA,aACwB;CAE5B,MAAM,MAAM,OAAuB,IAAI;CAGvC,MAAM,iBAAiB,cAAc,qBAAqB,GAAG,CAAC,CAAC;CAE/D,MAAM,CAAC,mBAAmB,wBAAwB,MAAM,SAA2C,KAAA,CAAS;CAE5G,MAAM,eAAe,kBAAkB;EACn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ACP,CAA2D;CAEnE,GAAG,CAAC,aAAa,eAAe,CAAC;CAEjC,MAAM,eAAe,eAAe;EAChC;EACA;EACA,MAAM,QAAQ;EACd;EACA;CACJ,IAA8D;EAAC;EAAc;EAAQ;EAAe;EAAM;CAAc,CAAC;CAEzH,MAAM,oBAAoB,aAAa,EACnC,IACA,aACA,gBACA,QACA,QACA,gBACkD;EAClD,IAAI,CAAC,OAAO,QAAQ,OAAO;EAC3B,MAAM,EAAE,qBAAqB,OAAO;EACpC,IAAI,CAAC,kBAAkB,OAAO;EAG9B,OAAO,oBAAC,oBAAD;GACH,aAAa;GACb,UAAU;GACV,OAAO;GACP,UAAU;GACF;GACG;EAAW,CAAA;CAC9B,GAAG,CAAC,CAAC;CAEL,OACI,oBAAC,uBAAuB,UAAxB;EACI,OAAO;YACP,oBAAC,OAAD;GAAK,WAAU;GACN;aAEJ,oBAAC,cAAD;IACG,MAAM,cAAc;IACJ;IACP;IACK;IACd,YAAY,gBAAgB,KAAA,IAAa,gBAAgB,aAAa,KAAA;IACtE,cAAc;IACd,mBAAmB;IACnB,OAAO;IACS;IAChB,WAAW,aAAa,IAAI;IAC5B,SAAS;IACT,QAAQ;IACR,gBAAgB,kBAAkB,iBAAiB,KAAA;IAC3C;IACR,gBAAgB;IACN;IACK;IACL;IACc;IACxB,mBAAmB,aAAa,oBAAoB,KAAA;IACpD,cAAc,aAAa,WAAsB;KAC7C,OAAO,iBAAiB,MAAM,IAAI,uBAAuB;IAC7D,GAAG,CAAC,cAAc,CAAC;IACnB,WAAU;IACM;IACF;IACM;IACE;IACX;GACd,CAAA;EAEA,CAAA;CACwB,CAAA;AAGzC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import {
|
|
2
|
+
import { WhereFilterOp } from "@rebasepro/types";
|
|
3
|
+
import { Property, EntityRelation } from "@rebasepro/cms-types";
|
|
3
4
|
export interface FilterFieldBindingInput {
|
|
4
5
|
/** Key of the property being filtered (the column id). */
|
|
5
6
|
propertyKey: string;
|
|
@@ -6,8 +6,8 @@ import { ReferenceFilterField } from "./ReferenceFilterField.js";
|
|
|
6
6
|
import { RelationFilterField } from "./RelationFilterField.js";
|
|
7
7
|
import { Suspense } from "react";
|
|
8
8
|
import { jsx } from "react/jsx-runtime";
|
|
9
|
-
import { enumToObjectEntries, normalizeToEntityRelation } from "@rebasepro/
|
|
10
|
-
import { resolveFilterOperators, useCollectionScope, useComponentOverride
|
|
9
|
+
import { enumToObjectEntries, normalizeToEntityRelation } from "@rebasepro/cms-types";
|
|
10
|
+
import { resolveFilterOperators, useCollectionScope, useComponentOverride } from "@rebasepro/app";
|
|
11
11
|
//#region src/components/SelectableTable/filters/FilterFieldBinding.tsx
|
|
12
12
|
/**
|
|
13
13
|
* The single entry point for rendering a collection filter field.
|
|
@@ -34,7 +34,7 @@ function FilterFieldBinding({ propertyKey, property, engine, value, setValue, hi
|
|
|
34
34
|
const baseProperty = isArray ? Array.isArray(ofVal) ? ofVal[0] : ofVal : property;
|
|
35
35
|
const scopeCollection = useCollectionScope();
|
|
36
36
|
const ResolvedFilterField = useComponentOverride("Collection.FilterField", DefaultFilterField);
|
|
37
|
-
const PropertyFilter =
|
|
37
|
+
const PropertyFilter = baseProperty?.admin?.Filter;
|
|
38
38
|
if (!baseProperty) return null;
|
|
39
39
|
const operators = resolveFilterOperators({
|
|
40
40
|
property: baseProperty,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FilterFieldBinding.js","names":[],"sources":["../../../../src/components/SelectableTable/filters/FilterFieldBinding.tsx"],"sourcesContent":["import React, { Suspense } from \"react\";\nimport {\n ArrayProperty,\n Property,\n ReferenceProperty,\n EntityRelation,\n RelationProperty,\n WhereFilterOp\n} from \"@rebasepro/types\";\nimport {\n FilterFieldBindingProps\n} from \"@rebasepro/cms-types\";\nimport { enumToObjectEntries, normalizeToEntityRelation } from \"@rebasepro/common\";\nimport { resolveFilterOperators } from \"@rebasepro/app\";\nimport { useCollectionScope, useComponentOverride, useResolvedComponent } from \"@rebasepro/app\";\nimport { StringNumberFilterField } from \"./StringNumberFilterField\";\nimport { BooleanFilterField } from \"./BooleanFilterField\";\nimport { DateTimeFilterField } from \"./DateTimeFilterField\";\nimport { ReferenceFilterField } from \"./ReferenceFilterField\";\nimport { RelationFilterField } from \"./RelationFilterField\";\nimport { getDatePropertyMode, getDatePropertyTimezone } from \"../../../preview/util\";\n\nexport interface FilterFieldBindingInput {\n /** Key of the property being filtered (the column id). */\n propertyKey: string;\n /** The raw property — array properties are unwrapped internally. */\n property: Property;\n /**\n * Engine backing the collection (`collection.engine`). Drives which\n * operators the engine can execute. Usually omitted — it is read from\n * the surrounding {@link CollectionScopeProvider}; pass it explicitly\n * only when rendering outside any collection scope.\n */\n engine?: string;\n value?: [WhereFilterOp, unknown];\n setValue: (value?: [WhereFilterOp, unknown]) => void;\n /** Coordination flags for fields that open their own dialogs. */\n hidden?: boolean;\n setHidden?: (hidden: boolean) => void;\n}\n\n/**\n * The single entry point for rendering a collection filter field.\n * Used by both the table header filters ({@link SelectableTable}) and the\n * Filters dialog.\n *\n * Resolution order:\n * 1. `property.admin.Filter` — per-property replacement (rendered even when the\n * resolved operator list is empty; the component owns filterability).\n * 2. `components[\"Collection.FilterField\"]` — collection-level or app-level\n * override (wrap mode supported via `OriginalComponent`).\n * 3. Built-in field dispatched by property type.\n *\n * The operators handed to the field are the intersection of the engine's\n * capabilities, the property-type defaults, and `property.admin.filterOperators`\n * (see `resolveFilterOperators`). When that intersection is empty and no\n * per-property `Filter` is set, nothing is rendered.\n *\n * @group Components\n */\nexport function FilterFieldBinding({\n propertyKey,\n property,\n engine,\n value,\n setValue,\n hidden,\n setHidden\n}: FilterFieldBindingInput): React.ReactNode {\n\n const isArray = property.type === \"array\";\n const ofVal = isArray ? (property as ArrayProperty).of : undefined;\n const baseProperty: Property | undefined = isArray\n ? (Array.isArray(ofVal) ? ofVal[0] : ofVal) as Property | undefined\n : property;\n\n // Hooks must run unconditionally — before any early return.\n const scopeCollection = useCollectionScope();\n const ResolvedFilterField = useComponentOverride<FilterFieldBindingProps>(\"Collection.FilterField\", DefaultFilterField);\n const PropertyFilter = useResolvedComponent<FilterFieldBindingProps>(baseProperty?.admin?.Filter);\n\n if (!baseProperty) return null;\n\n const operators = resolveFilterOperators({\n property: baseProperty,\n isArray,\n engine: engine ?? scopeCollection?.engine\n });\n\n const bindingProps: FilterFieldBindingProps = {\n propertyKey,\n property: baseProperty,\n isArray,\n operators,\n value,\n setValue,\n title: property.name,\n hidden,\n setHidden\n };\n\n // 1. Per-property replacement — always rendered, the dev owns filterability.\n if (PropertyFilter) {\n return (\n <Suspense fallback={null}>\n <PropertyFilter {...bindingProps}/>\n </Suspense>\n );\n }\n\n // 2/3. Override or built-in — only when the property is filterable here.\n if (operators.length === 0) return null;\n\n return <ResolvedFilterField {...bindingProps}/>;\n}\n\n/**\n * Built-in filter field dispatch by property type. This is the\n * `OriginalComponent` received by `\"Collection.FilterField\"` overrides in\n * wrap mode.\n */\n/**\n * A relation filter's value as `EntityRelation`s. The URL decoder builds them,\n * but a saved `defaultFilter` has been through JSON and holds plain\n * `{ __type: \"relation\", id, path }` objects. Returns `undefined` for anything\n * that is not a relation, so the field shows no selection rather than a wrong one.\n */\nexport function toRelationFilterValue(value: unknown): EntityRelation | EntityRelation[] | null | undefined {\n if (value === null) return null;\n if (value === undefined) return undefined;\n if (Array.isArray(value)) {\n const relations = value.map(item => normalizeToEntityRelation(item, \"relation\"));\n return relations.every((r): r is EntityRelation => r !== null) ? relations : undefined;\n }\n return normalizeToEntityRelation(value, \"relation\") ?? undefined;\n}\n\nfunction DefaultFilterField({\n propertyKey,\n property,\n isArray,\n operators,\n value,\n setValue,\n title,\n hidden,\n setHidden\n}: FilterFieldBindingProps): React.ReactNode {\n\n if (property.type === \"reference\") {\n const referenceProperty = property as ReferenceProperty;\n return <ReferenceFilterField value={value}\n setValue={setValue}\n name={propertyKey}\n isArray={isArray}\n operators={operators}\n path={referenceProperty.path}\n title={title}\n includeId={referenceProperty.admin?.includeId}\n previewProperties={referenceProperty.admin?.previewProperties}\n hidden={hidden ?? false}\n setHidden={setHidden ?? (() => undefined)}/>;\n }\n\n if (property.type === \"relation\") {\n const relation = (property as RelationProperty).relation;\n if (!relation) return null;\n const relations = value ? toRelationFilterValue(value[1]) : undefined;\n return <RelationFilterField value={value && (relations !== undefined || value[1] === undefined) ? [value[0], relations] : undefined}\n setValue={setValue}\n name={propertyKey}\n operators={operators}\n relation={relation}\n hidden={hidden ?? false}\n setHidden={setHidden ?? (() => undefined)}/>;\n }\n\n if (property.type === \"number\" || property.type === \"string\") {\n const enumValues = property.enum ? enumToObjectEntries(property.enum) : undefined;\n return <StringNumberFilterField value={value}\n setValue={setValue}\n name={propertyKey}\n type={property.type}\n isArray={isArray}\n operators={operators}\n enumValues={enumValues}\n title={title}/>;\n }\n\n if (property.type === \"boolean\") {\n return <BooleanFilterField value={value}\n setValue={setValue}\n name={propertyKey}\n operators={operators}\n title={title}/>;\n }\n\n if (property.type === \"date\") {\n return <DateTimeFilterField value={value}\n setValue={setValue}\n name={propertyKey}\n mode={getDatePropertyMode(property)}\n timezone={getDatePropertyTimezone(property)}\n isArray={isArray}\n operators={operators}\n title={title}/>;\n }\n\n return null;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4DA,SAAgB,mBAAmB,EAC/B,aACA,UACA,QACA,OACA,UACA,QACA,aACyC;CAEzC,MAAM,UAAU,SAAS,SAAS;CAClC,MAAM,QAAQ,UAAW,SAA2B,KAAK,KAAA;CACzD,MAAM,eAAqC,UACpC,MAAM,QAAQ,KAAK,IAAI,MAAM,KAAK,QACnC;CAGN,MAAM,kBAAkB,mBAAmB;CAC3C,MAAM,sBAAsB,qBAA8C,0BAA0B,kBAAkB;CACtH,MAAM,iBAAiB,qBAA8C,cAAc,OAAO,MAAM;CAEhG,IAAI,CAAC,cAAc,OAAO;CAE1B,MAAM,YAAY,uBAAuB;EACr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AAA,KAAa,CAAC,MAAM,IAAI,SAAS,IAAI,KAAA;GAC5G;GACV,MAAM;GACK;GACD;GACV,QAAQ,UAAU;GAClB,WAAW,oBAAoB,KAAA;EAAY,CAAA;CACnD;CAEA,IAAI,SAAS,SAAS,YAAY,SAAS,SAAS,UAAU;EAC1D,MAAM,aAAa,SAAS,OAAO,oBAAoB,SAAS,IAAI,IAAI,KAAA;EACxE,OAAO,oBAAC,yBAAD;GAAgC;GACzB;GACV,MAAM;GACN,MAAM,SAAS;GACN;GACE;GACC;GACL;EAAO,CAAA;CACtB;CAEA,IAAI,SAAS,SAAS,WAClB,OAAO,oBAAC,oBAAD;EAA2B;EACpB;EACV,MAAM;EACK;EACJ;CAAO,CAAA;CAGtB,IAAI,SAAS,SAAS,QAClB,OAAO,oBAAC,qBAAD;EAA4B;EACrB;EACV,MAAM;EACN,MAAM,oBAAoB,QAAQ;EAClC,UAAU,wBAAwB,QAAQ;EACjC;EACE;EACJ;CAAO,CAAA;CAGtB,OAAO;AACX"}
|
|
1
|
+
{"version":3,"file":"FilterFieldBinding.js","names":[],"sources":["../../../../src/components/SelectableTable/filters/FilterFieldBinding.tsx"],"sourcesContent":["import React, { Suspense } from \"react\";\nimport {\n WhereFilterOp\n} from \"@rebasepro/types\";\nimport {\n FilterFieldBindingProps,\n enumToObjectEntries,\n ArrayProperty,\n Property,\n ReferenceProperty,\n RelationProperty,\n EntityRelation,\n normalizeToEntityRelation\n} from \"@rebasepro/cms-types\";\nimport { resolveFilterOperators } from \"@rebasepro/app\";\nimport { useCollectionScope, useComponentOverride } from \"@rebasepro/app\";\nimport { StringNumberFilterField } from \"./StringNumberFilterField\";\nimport { BooleanFilterField } from \"./BooleanFilterField\";\nimport { DateTimeFilterField } from \"./DateTimeFilterField\";\nimport { ReferenceFilterField } from \"./ReferenceFilterField\";\nimport { RelationFilterField } from \"./RelationFilterField\";\nimport { getDatePropertyMode, getDatePropertyTimezone } from \"../../../preview/util\";\n\nexport interface FilterFieldBindingInput {\n /** Key of the property being filtered (the column id). */\n propertyKey: string;\n /** The raw property — array properties are unwrapped internally. */\n property: Property;\n /**\n * Engine backing the collection (`collection.engine`). Drives which\n * operators the engine can execute. Usually omitted — it is read from\n * the surrounding {@link CollectionScopeProvider}; pass it explicitly\n * only when rendering outside any collection scope.\n */\n engine?: string;\n value?: [WhereFilterOp, unknown];\n setValue: (value?: [WhereFilterOp, unknown]) => void;\n /** Coordination flags for fields that open their own dialogs. */\n hidden?: boolean;\n setHidden?: (hidden: boolean) => void;\n}\n\n/**\n * The single entry point for rendering a collection filter field.\n * Used by both the table header filters ({@link SelectableTable}) and the\n * Filters dialog.\n *\n * Resolution order:\n * 1. `property.admin.Filter` — per-property replacement (rendered even when the\n * resolved operator list is empty; the component owns filterability).\n * 2. `components[\"Collection.FilterField\"]` — collection-level or app-level\n * override (wrap mode supported via `OriginalComponent`).\n * 3. Built-in field dispatched by property type.\n *\n * The operators handed to the field are the intersection of the engine's\n * capabilities, the property-type defaults, and `property.admin.filterOperators`\n * (see `resolveFilterOperators`). When that intersection is empty and no\n * per-property `Filter` is set, nothing is rendered.\n *\n * @group Components\n */\nexport function FilterFieldBinding({\n propertyKey,\n property,\n engine,\n value,\n setValue,\n hidden,\n setHidden\n}: FilterFieldBindingInput): React.ReactNode {\n\n const isArray = property.type === \"array\";\n const ofVal = isArray ? (property as ArrayProperty).of : undefined;\n const baseProperty: Property | undefined = isArray\n ? (Array.isArray(ofVal) ? ofVal[0] : ofVal) as Property | undefined\n : property;\n\n // Hooks must run unconditionally — before any early return.\n const scopeCollection = useCollectionScope();\n const ResolvedFilterField = useComponentOverride<FilterFieldBindingProps>(\"Collection.FilterField\", DefaultFilterField);\n const PropertyFilter: React.ComponentType<FilterFieldBindingProps> | undefined = baseProperty?.admin?.Filter;\n\n if (!baseProperty) return null;\n\n const operators = resolveFilterOperators({\n property: baseProperty,\n isArray,\n engine: engine ?? scopeCollection?.engine\n });\n\n const bindingProps: FilterFieldBindingProps = {\n propertyKey,\n property: baseProperty,\n isArray,\n operators,\n value,\n setValue,\n title: property.name,\n hidden,\n setHidden\n };\n\n // 1. Per-property replacement — always rendered, the dev owns filterability.\n if (PropertyFilter) {\n return (\n <Suspense fallback={null}>\n <PropertyFilter {...bindingProps}/>\n </Suspense>\n );\n }\n\n // 2/3. Override or built-in — only when the property is filterable here.\n if (operators.length === 0) return null;\n\n return <ResolvedFilterField {...bindingProps}/>;\n}\n\n/**\n * Built-in filter field dispatch by property type. This is the\n * `OriginalComponent` received by `\"Collection.FilterField\"` overrides in\n * wrap mode.\n */\n/**\n * A relation filter's value as `EntityRelation`s. The URL decoder builds them,\n * but a saved `defaultFilter` has been through JSON and holds plain\n * `{ __type: \"relation\", id, path }` objects. Returns `undefined` for anything\n * that is not a relation, so the field shows no selection rather than a wrong one.\n */\nexport function toRelationFilterValue(value: unknown): EntityRelation | EntityRelation[] | null | undefined {\n if (value === null) return null;\n if (value === undefined) return undefined;\n if (Array.isArray(value)) {\n const relations = value.map(item => normalizeToEntityRelation(item, \"relation\"));\n return relations.every((r): r is EntityRelation => r !== null) ? relations : undefined;\n }\n return normalizeToEntityRelation(value, \"relation\") ?? undefined;\n}\n\nfunction DefaultFilterField({\n propertyKey,\n property,\n isArray,\n operators,\n value,\n setValue,\n title,\n hidden,\n setHidden\n}: FilterFieldBindingProps): React.ReactNode {\n\n if (property.type === \"reference\") {\n const referenceProperty = property as ReferenceProperty;\n return <ReferenceFilterField value={value}\n setValue={setValue}\n name={propertyKey}\n isArray={isArray}\n operators={operators}\n path={referenceProperty.path}\n title={title}\n includeId={referenceProperty.admin?.includeId}\n previewProperties={referenceProperty.admin?.previewProperties}\n hidden={hidden ?? false}\n setHidden={setHidden ?? (() => undefined)}/>;\n }\n\n if (property.type === \"relation\") {\n const relation = (property as RelationProperty).relation;\n if (!relation) return null;\n const relations = value ? toRelationFilterValue(value[1]) : undefined;\n return <RelationFilterField value={value && (relations !== undefined || value[1] === undefined) ? [value[0], relations] : undefined}\n setValue={setValue}\n name={propertyKey}\n operators={operators}\n relation={relation}\n hidden={hidden ?? false}\n setHidden={setHidden ?? (() => undefined)}/>;\n }\n\n if (property.type === \"number\" || property.type === \"string\") {\n const enumValues = property.enum ? enumToObjectEntries(property.enum) : undefined;\n return <StringNumberFilterField value={value}\n setValue={setValue}\n name={propertyKey}\n type={property.type}\n isArray={isArray}\n operators={operators}\n enumValues={enumValues}\n title={title}/>;\n }\n\n if (property.type === \"boolean\") {\n return <BooleanFilterField value={value}\n setValue={setValue}\n name={propertyKey}\n operators={operators}\n title={title}/>;\n }\n\n if (property.type === \"date\") {\n return <DateTimeFilterField value={value}\n setValue={setValue}\n name={propertyKey}\n mode={getDatePropertyMode(property)}\n timezone={getDatePropertyTimezone(property)}\n isArray={isArray}\n operators={operators}\n title={title}/>;\n }\n\n return null;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6DA,SAAgB,mBAAmB,EAC/B,aACA,UACA,QACA,OACA,UACA,QACA,aACyC;CAEzC,MAAM,UAAU,SAAS,SAAS;CAClC,MAAM,QAAQ,UAAW,SAA2B,KAAK,KAAA;CACzD,MAAM,eAAqC,UACpC,MAAM,QAAQ,KAAK,IAAI,MAAM,KAAK,QACnC;CAGN,MAAM,kBAAkB,mBAAmB;CAC3C,MAAM,sBAAsB,qBAA8C,0BAA0B,kBAAkB;CACtH,MAAM,iBAA2E,cAAc,OAAO;CAEtG,IAAI,CAAC,cAAc,OAAO;CAE1B,MAAM,YAAY,uBAAuB;EACrC,UAAU;EACV;EACA,QAAQ,UAAU,iBAAiB;CACvC,CAAC;CAED,MAAM,eAAwC;EAC1C;EACA,UAAU;EACV;EACA;EACA;EACA;EACA,OAAO,SAAS;EAChB;EACA;CACJ;CAGA,IAAI,gBACA,OACI,oBAAC,UAAD;EAAU,UAAU;YAChB,oBAAC,gBAAD,EAAgB,GAAI,aAAc,CAAA;CAC5B,CAAA;CAKlB,IAAI,UAAU,WAAW,GAAG,OAAO;CAEnC,OAAO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M;GACN,MAAM,SAAS;GACN;GACE;GACC;GACL;EAAO,CAAA;CACtB;CAEA,IAAI,SAAS,SAAS,WAClB,OAAO,oBAAC,oBAAD;EAA2B;EACpB;EACV,MAAM;EACK;EACJ;CAAO,CAAA;CAGtB,IAAI,SAAS,SAAS,QAClB,OAAO,oBAAC,qBAAD;EAA4B;EACrB;EACV,MAAM;EACN,MAAM,oBAAoB,QAAQ;EAClC,UAAU,wBAAwB,QAAQ;EACjC;EACE;EACJ;CAAO,CAAA;CAGtB,OAAO;AACX"}
|
|
@@ -64,8 +64,8 @@ function ReferenceFilterField({ value, setValue, isArray, path, includeId = true
|
|
|
64
64
|
else setValue(void 0);
|
|
65
65
|
}
|
|
66
66
|
const collectionRegistryController = useCollectionRegistryController();
|
|
67
|
-
const {
|
|
68
|
-
const collectionPath = path ?
|
|
67
|
+
const { targetPath, referenceTo } = useReferencePaths();
|
|
68
|
+
const collectionPath = path ? targetPath(path) : void 0;
|
|
69
69
|
const collection = useMemo(() => {
|
|
70
70
|
return collectionPath ? collectionRegistryController.getCollection(collectionPath) : void 0;
|
|
71
71
|
}, [collectionPath]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ReferenceFilterField.js","names":[],"sources":["../../../../src/components/SelectableTable/filters/ReferenceFilterField.tsx"],"sourcesContent":["import { useEntitySelectionDialog } from \"../../../hooks/useSelectionDialog\";\n\nimport React, { useId, useMemo, useState } from \"react\";\nimport { VirtualTableWhereFilterOp } from \"@rebasepro/ui\";\nimport { Entity, EntityReference } from \"@rebasepro/types\";\nimport { ReferencePreview } from \"../../../preview\";\nimport { Button, Checkbox, Label, Select, SelectItem } from \"@rebasepro/ui\";\nimport { useTranslation } from \"@rebasepro/app\";\nimport { useCollectionRegistryController } from \"../../../hooks/navigation/contexts/CollectionRegistryContext\";\nimport { useReferencePaths } from \"../../../hooks/useReferencePaths\";\nimport type { AdminCollection } from \"@rebasepro/cms-types\";\nimport { isNullFilterOperator, nullFilterOperatorFor, valueOperatorFor } from \"./null_filter\";\n\ninterface ReferenceFilterFieldProps {\n name: string,\n value?: [op: VirtualTableWhereFilterOp, fieldValue: unknown];\n setValue: (filterValue?: [VirtualTableWhereFilterOp, unknown]) => void;\n isArray?: boolean;\n path?: string;\n title?: string;\n includeId?: boolean;\n previewProperties?: string[];\n hidden: boolean;\n setHidden: (hidden: boolean) => void;\n /**\n * Restrict the offered operators (already resolved against engine\n * capabilities and property config). When omitted, all operators this\n * field can render are offered.\n */\n operators?: readonly VirtualTableWhereFilterOp[];\n}\n\nconst operationLabels = {\n \"==\": \"==\",\n \"!=\": \"!=\",\n \">\": \">\",\n \"<\": \"<\",\n \">=\": \">=\",\n \"<=\": \"<=\",\n in: \"In\",\n \"not-in\": \"Not in\",\n \"array-contains\": \"Contains\",\n \"array-contains-any\": \"Contains Any\",\n \"is-null\": \"Is null\",\n \"is-not-null\": \"Is not null\"\n};\n\nconst multipleSelectOperations = [\"array-contains-any\", \"in\", \"not-in\"];\n\nexport function ReferenceFilterField({\n value,\n setValue,\n isArray,\n path,\n includeId = true,\n previewProperties,\n setHidden,\n operators\n}: ReferenceFilterFieldProps) {\n const { t } = useTranslation();\n\n let possibleOperations: (keyof typeof operationLabels)[] = isArray\n ? [\"array-contains\"]\n : [\"==\", \"!=\", \">\", \"<\", \">=\", \"<=\"];\n\n if (isArray) {\n possibleOperations.push(\"array-contains-any\");\n } else {\n possibleOperations.push(\"in\", \"not-in\");\n }\n\n // The null checks take no operand, so they apply either way.\n possibleOperations.push(\"is-null\", \"is-not-null\");\n\n if (operators) {\n possibleOperations = possibleOperations.filter(op => (operators as readonly string[]).includes(op));\n }\n\n const [fieldOperation, fieldValue] = value || [possibleOperations[0], undefined];\n const [operation, setOperation] = useState<VirtualTableWhereFilterOp>(fieldOperation);\n const [internalValue, setInternalValue] = useState<EntityReference | EntityReference[] | undefined | null>(fieldValue as EntityReference | EntityReference[] | undefined | null);\n\n const selectedEntityIds = internalValue\n ? (Array.isArray(internalValue) ? internalValue.map((ref) => {\n if (!(ref?.isEntityReference && ref?.isEntityReference())) {\n return null;\n }\n return ref.id;\n }).filter(Boolean) as string[] : [internalValue.id])\n : [];\n\n function updateFilter(op: VirtualTableWhereFilterOp, val?: EntityReference | EntityReference[] | null) {\n\n const prevOpIsArray = multipleSelectOperations.includes(operation);\n const newOpIsArray = multipleSelectOperations.includes(op);\n let newValue = val;\n if (prevOpIsArray !== newOpIsArray) {\n newValue = newOpIsArray\n ? (newValue && !Array.isArray(newValue) && newValue.isEntityReference?.() ? [newValue] : [])\n : undefined;\n }\n\n setOperation(op);\n setInternalValue(newValue);\n\n // A null check takes no operand, so it is complete on its own — the\n // value gate below would otherwise clear the filter the moment one is\n // chosen from the dropdown, where there is no value to accompany it.\n if (isNullFilterOperator(op)) {\n setValue([op, null]);\n return;\n }\n\n const hasNewValue = newValue !== null && Array.isArray(newValue)\n ? newValue.length > 0\n : newValue !== undefined;\n if (op && hasNewValue) {\n setValue(\n [op, newValue]\n );\n } else {\n setValue(\n undefined\n );\n }\n }\n\n const collectionRegistryController = useCollectionRegistryController();\n const { toCollectionPath, referenceTo } = useReferencePaths();\n const collectionPath = path ? toCollectionPath(path) : undefined;\n const collection: AdminCollection | undefined = useMemo(() => {\n return collectionPath ? collectionRegistryController.getCollection(collectionPath) : undefined;\n }, [collectionPath]);\n\n // The filter compares against what is stored, so it carries the stored path.\n const onSingleEntitySelected = (entity: Entity<Record<string, unknown>>) => {\n updateFilter(operation, referenceTo(entity));\n };\n\n const onMultipleEntitiesSelected = (entities: Entity<Record<string, unknown>>[]) => {\n updateFilter(operation, entities.map(e => referenceTo(e)));\n };\n\n const multiple = multipleSelectOperations.includes(operation);\n const nullFiltered = isNullFilterOperator(operation);\n\n // The filters dialog renders every filterable property at once, and this\n // id was the literal string \"null-filter\" — so clicking any label toggled\n // whichever checkbox the document matched first, never the one clicked.\n const nullFilterId = useId();\n\n const referenceDialogController = useEntitySelectionDialog({\n multiselect: multiple,\n path: collectionPath,\n collection,\n onSingleEntitySelected,\n onMultipleEntitiesSelected,\n selectedEntityIds,\n onClose: () => {\n setHidden(false);\n }\n }\n );\n\n const doOpenDialog = () => {\n setHidden(true);\n referenceDialogController.open();\n };\n\n const buildEntry = (reference: EntityReference) => {\n return (\n <ReferencePreview\n disabled={!path}\n previewProperties={previewProperties}\n size={\"medium\"}\n onClick={doOpenDialog}\n reference={reference}\n hover={true}\n includeId={includeId}\n includeEntityLink={false}\n />\n );\n };\n\n // All renderable operators were filtered out (engine/property narrowing).\n if (possibleOperations.length === 0) return null;\n\n return (\n\n <div className=\"flex w-full flex-row\">\n <div className=\"w-[100px]\">\n <Select value={operation}\n size={\"medium\"}\n fullWidth={true}\n onValueChange={(value) => {\n updateFilter(value as VirtualTableWhereFilterOp, internalValue);\n }}\n renderValue={(op) => operationLabels[op as keyof typeof operationLabels]}>\n {possibleOperations.map((op) => (\n <SelectItem key={op} value={op}>\n {operationLabels[op]}\n </SelectItem>\n ))}\n </Select>\n </div>\n\n <div className=\"grow ml-2 h-full gap-2 flex flex-col\">\n\n {internalValue && Array.isArray(internalValue) && <div>\n {internalValue.map((ref, index) => buildEntry(ref))}\n </div>}\n\n {internalValue && !Array.isArray(internalValue) && <div>\n {buildEntry(internalValue)}\n </div>}\n\n {(!internalValue || (Array.isArray(internalValue) && internalValue.length === 0)) &&\n <Button onClick={doOpenDialog}\n\n size={\"medium\"}\n className=\"h-full w-full\">\n {multiple ? t(\"select_references\") : t(\"select_reference\")}\n </Button>\n }\n\n {/*\n * Switches the operator to the matching null check rather\n * than pairing a null value with whatever operator is\n * selected. Only the operator travels to the driver, and a\n * null *operand* means different things to different ones —\n * Mongo rejects `$in: null` outright. See\n * `nullFilterOperatorFor`.\n */}\n {!isArray && <Label\n className=\"border border-hairline cursor-pointer rounded-md p-2 flex items-center gap-2 bg-surface-field hover:bg-surface-field-hover\"\n htmlFor={nullFilterId}\n >\n <Checkbox id={nullFilterId}\n checked={nullFiltered}\n size={\"small\"}\n onCheckedChange={() => {\n if (!nullFiltered) updateFilter(nullFilterOperatorFor(operation), null);\n else updateFilter(valueOperatorFor(operation, possibleOperations) ?? operation, undefined);\n }}/>\n {t(\"filter_for_null_values\")}\n </Label>}\n\n </div>\n\n </div>\n );\n\n}\n"],"mappings":";;;;;;;;;;AAgCA,IAAM,kBAAkB;CACpB,MAAM;CACN,MAAM;CACN,KAAK;CACL,KAAK;CACL,MAAM;CACN,MAAM;CACN,IAAI;CACJ,UAAU;CACV,kBAAkB;CAClB,sBAAsB;CACtB,WAAW;CACX,eAAe;AACnB;AAEA,IAAM,2BAA2B;CAAC;CAAsB;CAAM;AAAQ;AAEtE,SAAgB,qBAAqB,EACjC,OACA,UACA,SACA,MACA,YAAY,MACZ,mBACA,WACA,aAC0B;CAC1B,MAAM,EAAE,MAAM,eAAe;CAE7B,IAAI,qBAAuD,UACrD,CAAC,gBAAgB,IACjB;EAAC;EAAM;EAAM;EAAK;EAAK;EAAM;CAAI;CAEvC,IAAI,SACA,mBAAmB,KAAK,oBAAoB;MAE5C,mBAAmB,KAAK,MAAM,QAAQ;CAI1C,mBAAmB,KAAK,WAAW,aAAa;CAEhD,IAAI,WACA,qBAAqB,mBAAmB,QAAO,OAAO,UAAgC,SAAS,EAAE,CAAC;CAGtG,MAAM,CAAC,gBAAgB,cAAc,SAAS,CAAC,mBAAmB,IAAI,KAAA,CAAS;CAC/E,MAAM,CAAC,WAAW,gBAAgB,SAAoC,cAAc;CACpF,MAAM,CAAC,eAAe,oBAAoB,SAAiE,UAAoE;CAE/K,MAAM,oBAAoB,gBACnB,MAAM,QAAQ,aAAa,IAAI,cAAc,KAAK,QAAQ;EACzD,IAAI,EAAE,KAAK,qBAAqB,KAAK,kBAAkB,IACnD,OAAO;EAEX,OAAO,IAAI;CACf,CAAC,CAAC,CAAC,OAAO,OAAO,IAAgB,CAAC,cAAc,EAAE,IAChD,CAAC;CAEP,SAAS,aAAa,IAA+B,KAAkD;EAEnG,MAAM,gBAAgB,yBAAyB,SAAS,SA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ableTable/filters/ReferenceFilterField.tsx"],"sourcesContent":["import { useEntitySelectionDialog } from \"../../../hooks/useSelectionDialog\";\n\nimport React, { useId, useMemo, useState } from \"react\";\nimport { VirtualTableWhereFilterOp } from \"@rebasepro/ui\";\nimport { EntityReference, Entity } from \"@rebasepro/cms-types\";\nimport { ReferencePreview } from \"../../../preview\";\nimport { Button, Checkbox, Label, Select, SelectItem } from \"@rebasepro/ui\";\nimport { useTranslation } from \"@rebasepro/app\";\nimport { useCollectionRegistryController } from \"../../../hooks/navigation/contexts/CollectionRegistryContext\";\nimport { useReferencePaths } from \"../../../hooks/useReferencePaths\";\nimport type { AdminCollection } from \"@rebasepro/cms-types\";\nimport { isNullFilterOperator, nullFilterOperatorFor, valueOperatorFor } from \"./null_filter\";\n\ninterface ReferenceFilterFieldProps {\n name: string,\n value?: [op: VirtualTableWhereFilterOp, fieldValue: unknown];\n setValue: (filterValue?: [VirtualTableWhereFilterOp, unknown]) => void;\n isArray?: boolean;\n path?: string;\n title?: string;\n includeId?: boolean;\n previewProperties?: string[];\n hidden: boolean;\n setHidden: (hidden: boolean) => void;\n /**\n * Restrict the offered operators (already resolved against engine\n * capabilities and property config). When omitted, all operators this\n * field can render are offered.\n */\n operators?: readonly VirtualTableWhereFilterOp[];\n}\n\nconst operationLabels = {\n \"==\": \"==\",\n \"!=\": \"!=\",\n \">\": \">\",\n \"<\": \"<\",\n \">=\": \">=\",\n \"<=\": \"<=\",\n in: \"In\",\n \"not-in\": \"Not in\",\n \"array-contains\": \"Contains\",\n \"array-contains-any\": \"Contains Any\",\n \"is-null\": \"Is null\",\n \"is-not-null\": \"Is not null\"\n};\n\nconst multipleSelectOperations = [\"array-contains-any\", \"in\", \"not-in\"];\n\nexport function ReferenceFilterField({\n value,\n setValue,\n isArray,\n path,\n includeId = true,\n previewProperties,\n setHidden,\n operators\n}: ReferenceFilterFieldProps) {\n const { t } = useTranslation();\n\n let possibleOperations: (keyof typeof operationLabels)[] = isArray\n ? [\"array-contains\"]\n : [\"==\", \"!=\", \">\", \"<\", \">=\", \"<=\"];\n\n if (isArray) {\n possibleOperations.push(\"array-contains-any\");\n } else {\n possibleOperations.push(\"in\", \"not-in\");\n }\n\n // The null checks take no operand, so they apply either way.\n possibleOperations.push(\"is-null\", \"is-not-null\");\n\n if (operators) {\n possibleOperations = possibleOperations.filter(op => (operators as readonly string[]).includes(op));\n }\n\n const [fieldOperation, fieldValue] = value || [possibleOperations[0], undefined];\n const [operation, setOperation] = useState<VirtualTableWhereFilterOp>(fieldOperation);\n const [internalValue, setInternalValue] = useState<EntityReference | EntityReference[] | undefined | null>(fieldValue as EntityReference | EntityReference[] | undefined | null);\n\n const selectedEntityIds = internalValue\n ? (Array.isArray(internalValue) ? internalValue.map((ref) => {\n if (!(ref?.isEntityReference && ref?.isEntityReference())) {\n return null;\n }\n return ref.id;\n }).filter(Boolean) as string[] : [internalValue.id])\n : [];\n\n function updateFilter(op: VirtualTableWhereFilterOp, val?: EntityReference | EntityReference[] | null) {\n\n const prevOpIsArray = multipleSelectOperations.includes(operation);\n const newOpIsArray = multipleSelectOperations.includes(op);\n let newValue = val;\n if (prevOpIsArray !== newOpIsArray) {\n newValue = newOpIsArray\n ? (newValue && !Array.isArray(newValue) && newValue.isEntityReference?.() ? [newValue] : [])\n : undefined;\n }\n\n setOperation(op);\n setInternalValue(newValue);\n\n // A null check takes no operand, so it is complete on its own — the\n // value gate below would otherwise clear the filter the moment one is\n // chosen from the dropdown, where there is no value to accompany it.\n if (isNullFilterOperator(op)) {\n setValue([op, null]);\n return;\n }\n\n const hasNewValue = newValue !== null && Array.isArray(newValue)\n ? newValue.length > 0\n : newValue !== undefined;\n if (op && hasNewValue) {\n setValue(\n [op, newValue]\n );\n } else {\n setValue(\n undefined\n );\n }\n }\n\n const collectionRegistryController = useCollectionRegistryController();\n const { targetPath, referenceTo } = useReferencePaths();\n const collectionPath = path ? targetPath(path) : undefined;\n const collection: AdminCollection | undefined = useMemo(() => {\n return collectionPath ? collectionRegistryController.getCollection(collectionPath) : undefined;\n }, [collectionPath]);\n\n // The filter compares against what is stored, so it carries the stored path.\n const onSingleEntitySelected = (entity: Entity<Record<string, unknown>>) => {\n updateFilter(operation, referenceTo(entity));\n };\n\n const onMultipleEntitiesSelected = (entities: Entity<Record<string, unknown>>[]) => {\n updateFilter(operation, entities.map(e => referenceTo(e)));\n };\n\n const multiple = multipleSelectOperations.includes(operation);\n const nullFiltered = isNullFilterOperator(operation);\n\n // The filters dialog renders every filterable property at once, and this\n // id was the literal string \"null-filter\" — so clicking any label toggled\n // whichever checkbox the document matched first, never the one clicked.\n const nullFilterId = useId();\n\n const referenceDialogController = useEntitySelectionDialog({\n multiselect: multiple,\n path: collectionPath,\n collection,\n onSingleEntitySelected,\n onMultipleEntitiesSelected,\n selectedEntityIds,\n onClose: () => {\n setHidden(false);\n }\n }\n );\n\n const doOpenDialog = () => {\n setHidden(true);\n referenceDialogController.open();\n };\n\n const buildEntry = (reference: EntityReference) => {\n return (\n <ReferencePreview\n disabled={!path}\n previewProperties={previewProperties}\n size={\"medium\"}\n onClick={doOpenDialog}\n reference={reference}\n hover={true}\n includeId={includeId}\n includeEntityLink={false}\n />\n );\n };\n\n // All renderable operators were filtered out (engine/property narrowing).\n if (possibleOperations.length === 0) return null;\n\n return (\n\n <div className=\"flex w-full flex-row\">\n <div className=\"w-[100px]\">\n <Select value={operation}\n size={\"medium\"}\n fullWidth={true}\n onValueChange={(value) => {\n updateFilter(value as VirtualTableWhereFilterOp, internalValue);\n }}\n renderValue={(op) => operationLabels[op as keyof typeof operationLabels]}>\n {possibleOperations.map((op) => (\n <SelectItem key={op} value={op}>\n {operationLabels[op]}\n </SelectItem>\n ))}\n </Select>\n </div>\n\n <div className=\"grow ml-2 h-full gap-2 flex flex-col\">\n\n {internalValue && Array.isArray(internalValue) && <div>\n {internalValue.map((ref, index) => buildEntry(ref))}\n </div>}\n\n {internalValue && !Array.isArray(internalValue) && <div>\n {buildEntry(internalValue)}\n </div>}\n\n {(!internalValue || (Array.isArray(internalValue) && internalValue.length === 0)) &&\n <Button onClick={doOpenDialog}\n\n size={\"medium\"}\n className=\"h-full w-full\">\n {multiple ? t(\"select_references\") : t(\"select_reference\")}\n </Button>\n }\n\n {/*\n * Switches the operator to the matching null check rather\n * than pairing a null value with whatever operator is\n * selected. Only the operator travels to the driver, and a\n * null *operand* means different things to different ones —\n * the Firestore SDK rejects `in` with a null outright. See\n * `nullFilterOperatorFor`.\n */}\n {!isArray && <Label\n className=\"border border-hairline cursor-pointer rounded-md p-2 flex items-center gap-2 bg-surface-field hover:bg-surface-field-hover\"\n htmlFor={nullFilterId}\n >\n <Checkbox id={nullFilterId}\n checked={nullFiltered}\n size={\"small\"}\n onCheckedChange={() => {\n if (!nullFiltered) updateFilter(nullFilterOperatorFor(operation), null);\n else updateFilter(valueOperatorFor(operation, possibleOperations) ?? operation, undefined);\n }}/>\n {t(\"filter_for_null_values\")}\n </Label>}\n\n </div>\n\n </div>\n );\n\n}\n"],"mappings":";;;;;;;;;;AAgCA,IAAM,kBAAkB;CACpB,MAAM;CACN,MAAM;CACN,KAAK;CACL,KAAK;CACL,MAAM;CACN,MAAM;CACN,IAAI;CACJ,UAAU;CACV,kBAAkB;CAClB,sBAAsB;CACtB,WAAW;CACX,eAAe;AACnB;AAEA,IAAM,2BAA2B;CAAC;CAAsB;CAAM;AAAQ;AAEtE,SAAgB,qBAAqB,EACjC,OACA,UACA,SACA,MACA,YAAY,MACZ,mBACA,WACA,aAC0B;CAC1B,MAAM,EAAE,MAAM,eAAe;CAE7B,IAAI,qBAAuD,UACrD,CAAC,gBAAgB,IACjB;EAAC;EAAM;EAAM;EAAK;EAAK;EAAM;CAAI;CAEvC,IAAI,SACA,mBAAmB,KAAK,oBAAoB;MAE5C,mBAAmB,KAAK,MAAM,QAAQ;CAI1C,mBAAmB,KAAK,WAAW,aAAa;CAEhD,IAAI,WACA,qBAAqB,mBAAmB,QAAO,OAAO,UAAgC,SAAS,EAAE,CAAC;CAGtG,MA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AM;KACN,WAAU;eACT,WAAW,EAAE,mBAAmB,IAAI,EAAE,kBAAkB;IACrD,CAAA;IAWX,CAAC,WAAW,qBAAC,OAAD;KACT,WAAU;KACV,SAAS;eAFA,CAIT,oBAAC,UAAD;MAAU,IAAI;MACV,SAAS;MACT,MAAM;MACN,uBAAuB;OACnB,IAAI,CAAC,cAAc,aAAa,sBAAsB,SAAS,GAAG,IAAI;YACjE,aAAa,iBAAiB,WAAW,kBAAkB,KAAK,WAAW,KAAA,CAAS;MAC7F;KAAG,CAAA,GACN,EAAE,wBAAwB,CACxB;;GAEN;IAEJ;;AAGb"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { VirtualTableWhereFilterOp } from "@rebasepro/ui";
|
|
3
|
-
import {
|
|
3
|
+
import { Relation, EntityRelation } from "@rebasepro/cms-types";
|
|
4
4
|
interface RelationFilterFieldProps {
|
|
5
5
|
name: string;
|
|
6
6
|
value?: [VirtualTableWhereFilterOp, EntityRelation | EntityRelation[] | null | undefined];
|
|
@@ -3,7 +3,7 @@ import { isNullFilterOperator, nullFilterOperatorFor, valueOperatorFor } from ".
|
|
|
3
3
|
import { useId, useMemo, useState } from "react";
|
|
4
4
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
5
|
import { Checkbox, Label, Select, SelectItem } from "@rebasepro/ui";
|
|
6
|
-
import { EntityRelation } from "@rebasepro/types";
|
|
6
|
+
import { EntityRelation } from "@rebasepro/cms-types";
|
|
7
7
|
//#region src/components/SelectableTable/filters/RelationFilterField.tsx
|
|
8
8
|
/** Whether an authored relation yields many rows. Derived from its kind. */
|
|
9
9
|
function relationCardinality(relation) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RelationFilterField.js","names":[],"sources":["../../../../src/components/SelectableTable/filters/RelationFilterField.tsx"],"sourcesContent":["import React, { useId, useMemo, useState } from \"react\";\nimport { VirtualTableWhereFilterOp } from \"@rebasepro/ui\";\nimport { EntityRelation, Relation } from \"@rebasepro/types\";\nimport { Checkbox, Label, Select, SelectItem } from \"@rebasepro/ui\";\nimport { RelationSelector } from \"../../RelationSelector\";\nimport { isNullFilterOperator, nullFilterOperatorFor, valueOperatorFor } from \"./null_filter\";\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\ninterface RelationFilterFieldProps {\n name: string,\n value?: [VirtualTableWhereFilterOp, EntityRelation | EntityRelation[] | null | undefined];\n setValue: (value?: [VirtualTableWhereFilterOp, EntityRelation | EntityRelation[] | null]) => void;\n relation: Relation; // relation config provided externally\n hidden: boolean;\n setHidden: (value: boolean) => void;\n /**\n * Restrict the offered operators (already resolved against engine\n * capabilities and property config). When omitted, all operators this\n * field can render are offered.\n */\n operators?: readonly VirtualTableWhereFilterOp[];\n}\n\nconst operationLabels = {\n \"==\": \"==\",\n \"!=\": \"!=\",\n \">\": \">\",\n \"<\": \"<\",\n \">=\": \">=\",\n \"<=\": \"<=\",\n in: \"In\",\n \"not-in\": \"Not in\",\n \"array-contains\": \"Contains\",\n \"array-contains-any\": \"Contains Any\",\n \"is-null\": \"Is empty\",\n \"is-not-null\": \"Is not empty\"\n};\n\nconst multipleSelectOperations = [\"array-contains-any\", \"in\", \"not-in\"];\n\n/**\n * What this field can render, before `operators` narrows it.\n *\n * Every relation gets the whole set. The value selector is told how many\n * values to take by the *operator* — see the `multiple` prop passed below —\n * so a to-many relation can be asked `== <one tag>` as readily as\n * `in <several>`, and the question of what shape the relation stores never\n * enters into it.\n *\n * That is a change: this list used to be split by the value the selector\n * produced, because the selector took its multiplicity from the relation's\n * cardinality and so a to-many one could only ever emit a list. Every\n * single-value operator had to be withheld to keep an array from reaching\n * `==`. `ReferenceFilterField` never had the problem — it has always sized its\n * dialog from the operator — which is what made the split look like a\n * property of relations rather than a limitation of one component.\n *\n * The array operators are the exception, and belong only to a to-many link,\n * which is the only one that *is* a list. On a to-one relation the filter\n * compiles to a comparison on a scalar foreign key, and `@>` against one is a\n * type error rather than an empty result.\n */\nconst RELATION_OPERATIONS: (keyof typeof operationLabels)[] =\n [\"==\", \"!=\", \">\", \"<\", \">=\", \"<=\", \"in\", \"not-in\", \"is-null\", \"is-not-null\"];\nconst LIST_ONLY_OPERATIONS: (keyof typeof operationLabels)[] =\n [\"array-contains\", \"array-contains-any\"];\n\n/**\n * The operators this field will actually put on screen.\n *\n * Exported because the failure mode is silence: when the intersection of what\n * the field can render and what the engine can run comes out empty, the field\n * returns null and the filter control the table header offered opens onto\n * nothing. That is a rendering outcome no unit test of either side alone\n * catches, so the intersection itself is the thing worth pinning.\n */\nexport function renderableRelationOperators(\n relation: { kind?: string; cardinality?: string } | undefined,\n operators?: readonly VirtualTableWhereFilterOp[]\n): (keyof typeof operationLabels)[] {\n const possible = relationCardinality(relation) === \"many\"\n ? [...RELATION_OPERATIONS, ...LIST_ONLY_OPERATIONS]\n : RELATION_OPERATIONS;\n if (!operators) return possible;\n return possible.filter(op => (operators as readonly string[]).includes(op));\n}\n\nexport function RelationFilterField({\n value,\n setValue,\n relation,\n name: _name,\n hidden: _hidden,\n setHidden: _setHidden,\n operators\n}: RelationFilterFieldProps) {\n\n const manyRelation = relationCardinality(relation) === \"many\";\n\n // The filters dialog renders every filterable property at once, and the\n // checkbox's id was the literal string \"null-filter\" — so clicking any\n // label toggled whichever checkbox the document matched first. Harmless\n // while one relation per table could show it; not once every relation can.\n const nullFilterId = useId();\n\n const possibleOperations = renderableRelationOperators(relation, operators);\n\n const [fieldOperation, fieldValue] = value || [possibleOperations[0], undefined];\n const [operation, setOperation] = useState<VirtualTableWhereFilterOp>(fieldOperation);\n const [internalValue, setInternalValue] = useState<EntityRelation | EntityRelation[] | undefined | null>(fieldValue);\n\n function updateFilter(op: VirtualTableWhereFilterOp, val?: EntityRelation | EntityRelation[] | null) {\n\n const prevOpIsArray = multipleSelectOperations.includes(operation);\n const newOpIsArray = multipleSelectOperations.includes(op);\n let newValue = val;\n if (prevOpIsArray !== newOpIsArray) {\n newValue = newOpIsArray ? (newValue instanceof EntityRelation ? [newValue] : []) : undefined;\n }\n\n setOperation(op);\n setInternalValue(newValue);\n\n // A null check takes no operand, so it is complete on its own — the\n // value gate below would otherwise clear the filter the moment one is\n // chosen from the dropdown, where there is no value to accompany it.\n if (isNullFilterOperator(op)) {\n setValue([op, null]);\n return;\n }\n\n const hasNewValue = newValue !== null && Array.isArray(newValue)\n ? newValue.length > 0\n : newValue !== undefined;\n if (op && hasNewValue) {\n setValue([op, newValue ?? null]);\n } else {\n setValue(undefined);\n }\n }\n\n const multiple = multipleSelectOperations.includes(operation);\n const nullFiltered = isNullFilterOperator(operation);\n\n const relationSelectorValue = useMemo(() => {\n if (internalValue === null || internalValue === undefined) return undefined;\n if (Array.isArray(internalValue)) return internalValue.map(ref => new EntityRelation(ref.id, ref.path));\n return new EntityRelation(internalValue.id, internalValue.path);\n }, [internalValue]);\n\n const handleRelationSelectorChange = (newVal?: EntityRelation | EntityRelation[] | null) => {\n if (newVal === null) {\n updateFilter(operation, null);\n return;\n }\n if (newVal === undefined) {\n updateFilter(operation, undefined);\n return;\n }\n updateFilter(operation, newVal);\n };\n\n // All renderable operators were filtered out (engine/property narrowing).\n if (possibleOperations.length === 0) return null;\n\n return (\n <div className=\"flex flex-row\">\n <div className=\"\">\n <Select\n value={operation}\n fullWidth={true}\n onValueChange={(newOp) => {\n updateFilter(newOp as VirtualTableWhereFilterOp, internalValue);\n }}\n renderValue={(op) => operationLabels[op as keyof typeof operationLabels]}\n >\n {possibleOperations.map((op) => (\n <SelectItem key={op} value={op}>\n {operationLabels[op]}\n </SelectItem>\n ))}\n </Select>\n </div>\n\n <div className=\"grow ml-2 h-full gap-2 flex flex-col w-[340px]\">\n <RelationSelector\n relation={relation}\n // The operator, not the relation, decides how many values\n // are being asked for — `updateFilter` already coerces the\n // held value on the same test, so the two cannot disagree.\n multiple={multiple}\n value={relationSelectorValue}\n onValueChange={handleRelationSelectorChange}\n disabled={nullFiltered}\n size={\"medium\"}\n />\n\n {/*\n * Shown for a to-many relation too. It used to be hidden\n * there because the only operators offered were the array\n * ones, which have no null to ask about — but \"posts with no\n * tags\" is the question a filter on a link is most often\n * for, and the driver answers it with `NOT EXISTS`.\n *\n * It switches the operator to the matching null check rather\n * than pairing a null value with whatever operator is\n * selected. Only the operator travels to the driver, and\n * `is-null` is a thing every engine implements; a null\n * *operand* is not — see `nullFilterOperatorFor`.\n */}\n <Label\n className=\"border border-hairline cursor-pointer rounded-md p-2 flex items-center gap-2 bg-surface-field hover:bg-surface-field-hover\"\n htmlFor={nullFilterId}\n >\n <Checkbox\n id={nullFilterId}\n checked={nullFiltered}\n size={\"small\"}\n onCheckedChange={() => {\n if (!nullFiltered) updateFilter(nullFilterOperatorFor(operation), null);\n else updateFilter(valueOperatorFor(operation, possibleOperations) ?? operation, undefined);\n }}\n />\n {manyRelation ? \"Filter for empty relations\" : \"Filter for null values\"}\n </Label>\n </div>\n </div>\n );\n}\n"],"mappings":";;;;;;;;AAQA,SAAS,oBAAoB,UAA2F;CACpH,IAAI,CAAC,UAAU,OAAO,KAAA;CACtB,IAAI,SAAS,SAAS,OAAO,OAAO,SAAS;CAC7C,IAAI,SAAS,SAAS,aAAa,SAAS,SAAS,cAAc,OAAO;CAC1E,IAAI,SAAS,SAAS,eAAe,SAAS,SAAS,UAAU,OAAO;CACxE,OAAO,SAAS;AACpB;AAkBA,IAAM,kBAAkB;CACpB,MAAM;CACN,MAAM;CACN,KAAK;CACL,KAAK;CACL,MAAM;CACN,MAAM;CACN,IAAI;CACJ,UAAU;CACV,kBAAkB;CAClB,sBAAsB;CACtB,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BAAsB,SAAS,GAAG,IAAI;WACjE,aAAa,iBAAiB,WAAW,kBAAkB,KAAK,WAAW,KAAA,CAAS;KAC7F;IACH,CAAA,GACA,eAAe,+BAA+B,wBAC5C;KACN;IACJ;;AAEb"}
|
|
1
|
+
{"version":3,"file":"RelationFilterField.js","names":[],"sources":["../../../../src/components/SelectableTable/filters/RelationFilterField.tsx"],"sourcesContent":["import React, { useId, useMemo, useState } from \"react\";\nimport { VirtualTableWhereFilterOp } from \"@rebasepro/ui\";\nimport { Relation, EntityRelation } from \"@rebasepro/cms-types\";\nimport { Checkbox, Label, Select, SelectItem } from \"@rebasepro/ui\";\nimport { RelationSelector } from \"../../RelationSelector\";\nimport { isNullFilterOperator, nullFilterOperatorFor, valueOperatorFor } from \"./null_filter\";\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\ninterface RelationFilterFieldProps {\n name: string,\n value?: [VirtualTableWhereFilterOp, EntityRelation | EntityRelation[] | null | undefined];\n setValue: (value?: [VirtualTableWhereFilterOp, EntityRelation | EntityRelation[] | null]) => void;\n relation: Relation; // relation config provided externally\n hidden: boolean;\n setHidden: (value: boolean) => void;\n /**\n * Restrict the offered operators (already resolved against engine\n * capabilities and property config). When omitted, all operators this\n * field can render are offered.\n */\n operators?: readonly VirtualTableWhereFilterOp[];\n}\n\nconst operationLabels = {\n \"==\": \"==\",\n \"!=\": \"!=\",\n \">\": \">\",\n \"<\": \"<\",\n \">=\": \">=\",\n \"<=\": \"<=\",\n in: \"In\",\n \"not-in\": \"Not in\",\n \"array-contains\": \"Contains\",\n \"array-contains-any\": \"Contains Any\",\n \"is-null\": \"Is empty\",\n \"is-not-null\": \"Is not empty\"\n};\n\nconst multipleSelectOperations = [\"array-contains-any\", \"in\", \"not-in\"];\n\n/**\n * What this field can render, before `operators` narrows it.\n *\n * Every relation gets the whole set. The value selector is told how many\n * values to take by the *operator* — see the `multiple` prop passed below —\n * so a to-many relation can be asked `== <one tag>` as readily as\n * `in <several>`, and the question of what shape the relation stores never\n * enters into it.\n *\n * That is a change: this list used to be split by the value the selector\n * produced, because the selector took its multiplicity from the relation's\n * cardinality and so a to-many one could only ever emit a list. Every\n * single-value operator had to be withheld to keep an array from reaching\n * `==`. `ReferenceFilterField` never had the problem — it has always sized its\n * dialog from the operator — which is what made the split look like a\n * property of relations rather than a limitation of one component.\n *\n * The array operators are the exception, and belong only to a to-many link,\n * which is the only one that *is* a list. On a to-one relation the filter\n * compiles to a comparison on a scalar foreign key, and `@>` against one is a\n * type error rather than an empty result.\n */\nconst RELATION_OPERATIONS: (keyof typeof operationLabels)[] =\n [\"==\", \"!=\", \">\", \"<\", \">=\", \"<=\", \"in\", \"not-in\", \"is-null\", \"is-not-null\"];\nconst LIST_ONLY_OPERATIONS: (keyof typeof operationLabels)[] =\n [\"array-contains\", \"array-contains-any\"];\n\n/**\n * The operators this field will actually put on screen.\n *\n * Exported because the failure mode is silence: when the intersection of what\n * the field can render and what the engine can run comes out empty, the field\n * returns null and the filter control the table header offered opens onto\n * nothing. That is a rendering outcome no unit test of either side alone\n * catches, so the intersection itself is the thing worth pinning.\n */\nexport function renderableRelationOperators(\n relation: { kind?: string; cardinality?: string } | undefined,\n operators?: readonly VirtualTableWhereFilterOp[]\n): (keyof typeof operationLabels)[] {\n const possible = relationCardinality(relation) === \"many\"\n ? [...RELATION_OPERATIONS, ...LIST_ONLY_OPERATIONS]\n : RELATION_OPERATIONS;\n if (!operators) return possible;\n return possible.filter(op => (operators as readonly string[]).includes(op));\n}\n\nexport function RelationFilterField({\n value,\n setValue,\n relation,\n name: _name,\n hidden: _hidden,\n setHidden: _setHidden,\n operators\n}: RelationFilterFieldProps) {\n\n const manyRelation = relationCardinality(relation) === \"many\";\n\n // The filters dialog renders every filterable property at once, and the\n // checkbox's id was the literal string \"null-filter\" — so clicking any\n // label toggled whichever checkbox the document matched first. Harmless\n // while one relation per table could show it; not once every relation can.\n const nullFilterId = useId();\n\n const possibleOperations = renderableRelationOperators(relation, operators);\n\n const [fieldOperation, fieldValue] = value || [possibleOperations[0], undefined];\n const [operation, setOperation] = useState<VirtualTableWhereFilterOp>(fieldOperation);\n const [internalValue, setInternalValue] = useState<EntityRelation | EntityRelation[] | undefined | null>(fieldValue);\n\n function updateFilter(op: VirtualTableWhereFilterOp, val?: EntityRelation | EntityRelation[] | null) {\n\n const prevOpIsArray = multipleSelectOperations.includes(operation);\n const newOpIsArray = multipleSelectOperations.includes(op);\n let newValue = val;\n if (prevOpIsArray !== newOpIsArray) {\n newValue = newOpIsArray ? (newValue instanceof EntityRelation ? [newValue] : []) : undefined;\n }\n\n setOperation(op);\n setInternalValue(newValue);\n\n // A null check takes no operand, so it is complete on its own — the\n // value gate below would otherwise clear the filter the moment one is\n // chosen from the dropdown, where there is no value to accompany it.\n if (isNullFilterOperator(op)) {\n setValue([op, null]);\n return;\n }\n\n const hasNewValue = newValue !== null && Array.isArray(newValue)\n ? newValue.length > 0\n : newValue !== undefined;\n if (op && hasNewValue) {\n setValue([op, newValue ?? null]);\n } else {\n setValue(undefined);\n }\n }\n\n const multiple = multipleSelectOperations.includes(operation);\n const nullFiltered = isNullFilterOperator(operation);\n\n const relationSelectorValue = useMemo(() => {\n if (internalValue === null || internalValue === undefined) return undefined;\n if (Array.isArray(internalValue)) return internalValue.map(ref => new EntityRelation(ref.id, ref.path));\n return new EntityRelation(internalValue.id, internalValue.path);\n }, [internalValue]);\n\n const handleRelationSelectorChange = (newVal?: EntityRelation | EntityRelation[] | null) => {\n if (newVal === null) {\n updateFilter(operation, null);\n return;\n }\n if (newVal === undefined) {\n updateFilter(operation, undefined);\n return;\n }\n updateFilter(operation, newVal);\n };\n\n // All renderable operators were filtered out (engine/property narrowing).\n if (possibleOperations.length === 0) return null;\n\n return (\n <div className=\"flex flex-row\">\n <div className=\"\">\n <Select\n value={operation}\n fullWidth={true}\n onValueChange={(newOp) => {\n updateFilter(newOp as VirtualTableWhereFilterOp, internalValue);\n }}\n renderValue={(op) => operationLabels[op as keyof typeof operationLabels]}\n >\n {possibleOperations.map((op) => (\n <SelectItem key={op} value={op}>\n {operationLabels[op]}\n </SelectItem>\n ))}\n </Select>\n </div>\n\n <div className=\"grow ml-2 h-full gap-2 flex flex-col w-[340px]\">\n <RelationSelector\n relation={relation}\n // The operator, not the relation, decides how many values\n // are being asked for — `updateFilter` already coerces the\n // held value on the same test, so the two cannot disagree.\n multiple={multiple}\n value={relationSelectorValue}\n onValueChange={handleRelationSelectorChange}\n disabled={nullFiltered}\n size={\"medium\"}\n />\n\n {/*\n * Shown for a to-many relation too. It used to be hidden\n * there because the only operators offered were the array\n * ones, which have no null to ask about — but \"posts with no\n * tags\" is the question a filter on a link is most often\n * for, and the driver answers it with `NOT EXISTS`.\n *\n * It switches the operator to the matching null check rather\n * than pairing a null value with whatever operator is\n * selected. Only the operator travels to the driver, and\n * `is-null` is a thing every engine implements; a null\n * *operand* is not — see `nullFilterOperatorFor`.\n */}\n <Label\n className=\"border border-hairline cursor-pointer rounded-md p-2 flex items-center gap-2 bg-surface-field hover:bg-surface-field-hover\"\n htmlFor={nullFilterId}\n >\n <Checkbox\n id={nullFilterId}\n checked={nullFiltered}\n size={\"small\"}\n onCheckedChange={() => {\n if (!nullFiltered) updateFilter(nullFilterOperatorFor(operation), null);\n else updateFilter(valueOperatorFor(operation, possibleOperations) ?? operation, undefined);\n }}\n />\n {manyRelation ? \"Filter for empty relations\" : \"Filter for null values\"}\n </Label>\n </div>\n </div>\n );\n}\n"],"mappings":";;;;;;;;AAQA,SAAS,oBAAoB,UAA2F;CACpH,IAAI,CAAC,UAAU,OAAO,KAAA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eACvB,gBAAgB;IACT,GAFK,EAEL,CACf;GACG,CAAA;EACP,CAAA,GAEL,qBAAC,OAAD;GAAK,WAAU;aAAf,CACI,oBAAC,kBAAD;IACc;IAIA;IACV,OAAO;IACP,eAAe;IACf,UAAU;IACV,MAAM;GACT,CAAA,GAeD,qBAAC,OAAD;IACI,WAAU;IACV,SAAS;cAFb,CAII,oBAAC,UAAD;KACI,IAAI;KACJ,SAAS;KACT,MAAM;KACN,uBAAuB;MACnB,IAAI,CAAC,cAAc,aAAa,sBAAsB,SAAS,GAAG,IAAI;WACjE,aAAa,iBAAiB,WAAW,kBAAkB,KAAK,WAAW,KAAA,CAAS;KAC7F;IACH,CAAA,GACA,eAAe,+BAA+B,wBAC5C;KACN;IACJ;;AAEb"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { VirtualTableWhereFilterOp } from "@rebasepro/ui";
|
|
3
|
-
import { EnumValueConfig } from "@rebasepro/types";
|
|
3
|
+
import { EnumValueConfig } from "@rebasepro/cms-types";
|
|
4
4
|
interface StringNumberFilterFieldProps {
|
|
5
5
|
name: string;
|
|
6
6
|
type: "string" | "number";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StringNumberFilterField.js","names":[],"sources":["../../../../src/components/SelectableTable/filters/StringNumberFilterField.tsx"],"sourcesContent":["import React, { useState } from \"react\";\nimport { EnumValuesChip } from \"../../../preview\";\nimport {\n IconButton,\n MultiSelect,\n MultiSelectItem,\n Select,\n SelectItem,\n TextField,\n VirtualTableWhereFilterOp,\n XIcon\n} from \"@rebasepro/ui\";\nimport { EnumValueConfig } from \"@rebasepro/types\";\nimport { useTranslation } from \"@rebasepro/app\";\n\ninterface StringNumberFilterFieldProps {\n name: string,\n type: \"string\" | \"number\";\n value?: [op: VirtualTableWhereFilterOp, fieldValue: unknown];\n setValue: (value?: [op: VirtualTableWhereFilterOp, newValue: unknown]) => void;\n isArray?: boolean;\n enumValues?: EnumValueConfig[];\n title?: string;\n /**\n * Restrict the offered operators (already resolved against engine\n * capabilities and property config). When omitted, all operators this\n * field can render are offered.\n */\n operators?: readonly VirtualTableWhereFilterOp[];\n}\n\nconst operationLabels = {\n \"==\": \"==\",\n \"!=\": \"!=\",\n \">\": \">\",\n \"<\": \"<\",\n \">=\": \">=\",\n \"<=\": \"<=\",\n in: \"In\",\n \"not-in\": \"Not in\",\n \"array-contains\": \"Contains\",\n \"array-contains-any\": \"Any\",\n \"ilike\": \"Contains\",\n \"not-ilike\": \"Not contains\",\n \"is-null\": \"Is null\",\n \"is-not-null\": \"Is not null\"\n};\n\nconst multipleSelectOperations = [\"array-contains-any\", \"in\", \"not-in\"];\n\n/** Operators that match a substring, wrapped in SQL wildcards (`%value%`). */\nconst containsOperations = [\"ilike\", \"not-ilike\"];\n\n/** Strip the surrounding `%` wildcards a contains-filter adds, for display. */\nfunction unwrapContains(value: unknown): string {\n if (typeof value !== \"string\") return \"\";\n return value.replace(/^%/, \"\").replace(/%$/, \"\");\n}\n\nexport function StringNumberFilterField({\n name,\n value,\n setValue,\n type,\n isArray,\n enumValues,\n title,\n operators\n }: StringNumberFilterFieldProps) {\n const { t } = useTranslation();\n\n let possibleOperations: (keyof typeof operationLabels)[] = isArray\n ? [\"array-contains\"]\n : [\"==\", \"!=\", \">\", \"<\", \">=\", \"<=\", \"is-null\", \"is-not-null\"];\n\n // Case-insensitive substring matching is only meaningful for free-text\n // string columns (not numbers, arrays, or enums).\n if (!isArray && !enumValues && type === \"string\") {\n possibleOperations.push(\"ilike\", \"not-ilike\");\n }\n\n if (enumValues) {\n if (isArray) {\n possibleOperations.push(\"array-contains-any\");\n } else {\n possibleOperations.push(\"in\", \"not-in\");\n }\n }\n\n if (operators) {\n possibleOperations = possibleOperations.filter(op => (operators as readonly string[]).includes(op));\n }\n\n const [fieldOperation, fieldValue] = value || [possibleOperations[0], undefined];\n // Read back both the canonical null operators and the legacy `[\"==\", null]` /\n // `[\"!=\", null]` form saved by older filter presets.\n const [operation, setOperation] = useState<VirtualTableWhereFilterOp>(\n fieldOperation === \"==\" && fieldValue === null ? \"is-null\"\n : fieldOperation === \"!=\" && fieldValue === null ? \"is-not-null\"\n : fieldOperation\n );\n const [internalValue, setInternalValue] = useState<string | number | string[] | number[] | null | undefined>(\n containsOperations.includes(fieldOperation) ? unwrapContains(fieldValue) : (fieldValue as string | number | string[] | number[] | null | undefined)\n );\n\n const isNullOperation = operation === \"is-null\" || operation === \"is-not-null\";\n\n // A single picked value, `0` included: a truthiness check dropped a zero\n // id's clear button and rendered a stray \"0\" where it should have been.\n const hasSingleValue = internalValue !== undefined && internalValue !== null && !Array.isArray(internalValue);\n\n // All renderable operators were filtered out (engine/property narrowing).\n if (possibleOperations.length === 0) return null;\n\n function updateFilter(op: VirtualTableWhereFilterOp, val: string | number | string[] | number[] | null | undefined) {\n // Null-testing operators ignore their value.\n if (op === \"is-null\" || op === \"is-not-null\") {\n setOperation(op);\n setInternalValue(null);\n setValue([op, null]);\n return;\n }\n\n // Substring matching: keep the raw text in the field, emit it wrapped\n // in SQL wildcards so the backend runs `column ILIKE '%value%'`.\n if (op === \"ilike\" || op === \"not-ilike\") {\n const raw = typeof val === \"string\" ? val : \"\";\n setOperation(op);\n setInternalValue(raw);\n if (raw.length > 0) {\n setValue([op, `%${raw}%`]);\n } else {\n setValue(undefined);\n }\n return;\n }\n\n let newValue = val;\n const prevOpIsArray = multipleSelectOperations.includes(operation);\n const newOpIsArray = multipleSelectOperations.includes(op);\n if (prevOpIsArray !== newOpIsArray) {\n if (newOpIsArray) {\n if (typeof val === \"string\") newValue = [val];\n else if (typeof val === \"number\") newValue = [val];\n else newValue = [];\n } else {\n newValue = undefined;\n }\n }\n\n if (typeof newValue === \"number\" && isNaN(newValue))\n newValue = undefined;\n\n setOperation(op);\n setInternalValue(newValue);\n\n const hasNewValue = newValue !== null && Array.isArray(newValue)\n ? newValue.length > 0\n : newValue !== undefined;\n if (op && hasNewValue) {\n setValue(\n [op, newValue]\n );\n } else {\n setValue(\n undefined\n );\n }\n }\n\n const multiple = multipleSelectOperations.includes(operation);\n\n return (\n\n <div className=\"flex w-full\">\n <div className={\"w-[100px]\"}>\n <Select value={operation}\n size={\"medium\"}\n fullWidth={true}\n position={\"item-aligned\"}\n onValueChange={(value) => {\n updateFilter(value as VirtualTableWhereFilterOp, internalValue);\n }}\n renderValue={(op) => operationLabels[op as keyof typeof operationLabels]}>\n {possibleOperations.map((op) => (\n <SelectItem key={op} value={op}>\n {operationLabels[op]}\n </SelectItem>\n ))}\n </Select>\n </div>\n\n <div className=\"grow ml-2 flex flex-col gap-2\">\n\n {!enumValues && <TextField\n size={\"medium\"}\n aria-label={`${title ?? name} filter value`}\n type={type === \"number\" ? \"number\" : undefined}\n value={internalValue !== undefined && internalValue != null ? String(internalValue) : \"\"}\n disabled={isNullOperation}\n placeholder={isNullOperation ? \"null\" : undefined}\n onChange={(evt) => {\n // Text typed and deleted again is no filter, not a\n // filter for the empty string.\n const val = evt.target.value === \"\"\n ? undefined\n : type === \"number\"\n ? parseFloat(evt.target.value)\n : evt.target.value;\n updateFilter(operation, val);\n }}\n endAdornment={internalValue !== undefined && internalValue != null && <IconButton aria-label={t(\"clear\")}\n onClick={(e) => updateFilter(operation, undefined)}>\n <XIcon/>\n </IconButton>}\n />}\n\n {enumValues && !multiple &&\n <Select\n size={\"medium\"}\n position={\"item-aligned\"}\n fullWidth={true}\n disabled={isNullOperation}\n // As a string whatever the enum's type: a number enum\n // holds the picked id as a number, which the select\n // read as no value at all and showed blank.\n value={hasSingleValue ? String(internalValue) : \"\"}\n onValueChange={(value) => {\n if (value !== \"\")\n updateFilter(operation, type === \"number\" ? parseFloat(value as string) : value as string)\n }}\n endAdornment={hasSingleValue && <IconButton aria-label={t(\"clear\")}\n onClick={(e) => updateFilter(operation, undefined)}>\n <XIcon/>\n </IconButton>}\n renderValue={(enumKey) => {\n if (enumKey === null)\n return t(\"filter_for_null_values\");\n if (enumKey === undefined)\n return null;\n\n return <EnumValuesChip\n key={`select_value_${name}_${enumKey}`}\n enumKey={enumKey}\n enumValues={enumValues}\n size={\"small\"}/>;\n }}>\n {enumValues.map((enumConfig) => (\n <SelectItem key={`select_item_${name}_${enumConfig.id}`}\n value={String(enumConfig.id)}\n textValue={enumConfig.label}>\n <EnumValuesChip\n enumKey={String(enumConfig.id)}\n enumValues={enumValues}\n size={\"small\"}/>\n </SelectItem>\n ))}\n </Select>\n }\n\n {enumValues && multiple &&\n <MultiSelect\n size={\"medium\"}\n value={Array.isArray(internalValue) ? internalValue.map(e => String(e)) : []}\n disabled={isNullOperation}\n onValueChange={(value) => {\n updateFilter(operation, type === \"number\" ? (value ?? []).map(v => parseFloat(v)) : value)\n }}\n >\n {enumValues.map((enumConfig) => (\n <MultiSelectItem key={`select_value_${name}_${enumConfig.id}`}\n value={String(enumConfig.id)}>\n <EnumValuesChip\n enumKey={String(enumConfig.id)}\n enumValues={enumValues}\n size={\"small\"}/>\n </MultiSelectItem>\n ))}\n </MultiSelect>\n }\n\n </div>\n\n </div>\n );\n\n}\n"],"mappings":";;;;;;AA+BA,IAAM,kBAAkB;CACpB,MAAM;CACN,MAAM;CACN,KAAK;CACL,KAAK;CACL,MAAM;CACN,MAAM;CACN,IAAI;CACJ,UAAU;CACV,kBAAkB;CAClB,sBAAsB;CACtB,SAAS;CACT,aAAa;CACb,WAAW;CACX,eAAe;AACnB;AAEA,IAAM,2BAA2B;CAAC;CAAsB;CAAM;AAAQ;;AAGtE,IAAM,qBAAqB,CAAC,SAAS,WAAW;;AAGhD,SAAS,eAAe,OAAwB;CAC5C,IAAI,OAAO,UAAU,UAAU,OAAO;CACtC,OAAO,MAAM,QAAQ,MAAM,EAAE,CAAC,CAAC,QAAQ,MAAM,EAAE;AACnD;AAEA,SAAgB,wBAAwB,EACI,MACA,OACA,UACA,MACA,SACA,YACA,OACA,aAC6B;CACrE,MAAM,EAAE,MAAM,eAAe;CAE7B,IAAI,qBAAuD,UACrD,CAAC,gBAAgB,IACjB;EAA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AW,EAAE;gBACxC,oBAAC,gBAAD;OACI,SAAS,OAAO,WAAW,EAAE;OACjB;OACZ,MAAM;MAAS,CAAA;KACN,GANK,gBAAgB,KAAK,GAAG,WAAW,IAMxC,CACpB;IACQ,CAAA;GAGhB;IAEJ;;AAGb"}
|
|
1
|
+
{"version":3,"file":"StringNumberFilterField.js","names":[],"sources":["../../../../src/components/SelectableTable/filters/StringNumberFilterField.tsx"],"sourcesContent":["import React, { useState } from \"react\";\nimport { EnumValuesChip } from \"../../../preview\";\nimport {\n IconButton,\n MultiSelect,\n MultiSelectItem,\n Select,\n SelectItem,\n TextField,\n VirtualTableWhereFilterOp,\n XIcon\n} from \"@rebasepro/ui\";\nimport { EnumValueConfig } from \"@rebasepro/cms-types\";\nimport { useTranslation } from \"@rebasepro/app\";\n\ninterface StringNumberFilterFieldProps {\n name: string,\n type: \"string\" | \"number\";\n value?: [op: VirtualTableWhereFilterOp, fieldValue: unknown];\n setValue: (value?: [op: VirtualTableWhereFilterOp, newValue: unknown]) => void;\n isArray?: boolean;\n enumValues?: EnumValueConfig[];\n title?: string;\n /**\n * Restrict the offered operators (already resolved against engine\n * capabilities and property config). When omitted, all operators this\n * field can render are offered.\n */\n operators?: readonly VirtualTableWhereFilterOp[];\n}\n\nconst operationLabels = {\n \"==\": \"==\",\n \"!=\": \"!=\",\n \">\": \">\",\n \"<\": \"<\",\n \">=\": \">=\",\n \"<=\": \"<=\",\n in: \"In\",\n \"not-in\": \"Not in\",\n \"array-contains\": \"Contains\",\n \"array-contains-any\": \"Any\",\n \"ilike\": \"Contains\",\n \"not-ilike\": \"Not contains\",\n \"is-null\": \"Is null\",\n \"is-not-null\": \"Is not null\"\n};\n\nconst multipleSelectOperations = [\"array-contains-any\", \"in\", \"not-in\"];\n\n/** Operators that match a substring, wrapped in SQL wildcards (`%value%`). */\nconst containsOperations = [\"ilike\", \"not-ilike\"];\n\n/** Strip the surrounding `%` wildcards a contains-filter adds, for display. */\nfunction unwrapContains(value: unknown): string {\n if (typeof value !== \"string\") return \"\";\n return value.replace(/^%/, \"\").replace(/%$/, \"\");\n}\n\nexport function StringNumberFilterField({\n name,\n value,\n setValue,\n type,\n isArray,\n enumValues,\n title,\n operators\n }: StringNumberFilterFieldProps) {\n const { t } = useTranslation();\n\n let possibleOperations: (keyof typeof operationLabels)[] = isArray\n ? [\"array-contains\"]\n : [\"==\", \"!=\", \">\", \"<\", \">=\", \"<=\", \"is-null\", \"is-not-null\"];\n\n // Case-insensitive substring matching is only meaningful for free-text\n // string columns (not numbers, arrays, or enums).\n if (!isArray && !enumValues && type === \"string\") {\n possibleOperations.push(\"ilike\", \"not-ilike\");\n }\n\n if (enumValues) {\n if (isArray) {\n possibleOperations.push(\"array-contains-any\");\n } else {\n possibleOperations.push(\"in\", \"not-in\");\n }\n }\n\n if (operators) {\n possibleOperations = possibleOperations.filter(op => (operators as readonly string[]).includes(op));\n }\n\n const [fieldOperation, fieldValue] = value || [possibleOperations[0], undefined];\n // Read back both the canonical null operators and the legacy `[\"==\", null]` /\n // `[\"!=\", null]` form saved by older filter presets.\n const [operation, setOperation] = useState<VirtualTableWhereFilterOp>(\n fieldOperation === \"==\" && fieldValue === null ? \"is-null\"\n : fieldOperation === \"!=\" && fieldValue === null ? \"is-not-null\"\n : fieldOperation\n );\n const [internalValue, setInternalValue] = useState<string | number | string[] | number[] | null | undefined>(\n containsOperations.includes(fieldOperation) ? unwrapContains(fieldValue) : (fieldValue as string | number | string[] | number[] | null | undefined)\n );\n\n const isNullOperation = operation === \"is-null\" || operation === \"is-not-null\";\n\n // A single picked value, `0` included: a truthiness check dropped a zero\n // id's clear button and rendered a stray \"0\" where it should have been.\n const hasSingleValue = internalValue !== undefined && internalValue !== null && !Array.isArray(internalValue);\n\n // All renderable operators were filtered out (engine/property narrowing).\n if (possibleOperations.length === 0) return null;\n\n function updateFilter(op: VirtualTableWhereFilterOp, val: string | number | string[] | number[] | null | undefined) {\n // Null-testing operators ignore their value.\n if (op === \"is-null\" || op === \"is-not-null\") {\n setOperation(op);\n setInternalValue(null);\n setValue([op, null]);\n return;\n }\n\n // Substring matching: keep the raw text in the field, emit it wrapped\n // in SQL wildcards so the backend runs `column ILIKE '%value%'`.\n if (op === \"ilike\" || op === \"not-ilike\") {\n const raw = typeof val === \"string\" ? val : \"\";\n setOperation(op);\n setInternalValue(raw);\n if (raw.length > 0) {\n setValue([op, `%${raw}%`]);\n } else {\n setValue(undefined);\n }\n return;\n }\n\n let newValue = val;\n const prevOpIsArray = multipleSelectOperations.includes(operation);\n const newOpIsArray = multipleSelectOperations.includes(op);\n if (prevOpIsArray !== newOpIsArray) {\n if (newOpIsArray) {\n if (typeof val === \"string\") newValue = [val];\n else if (typeof val === \"number\") newValue = [val];\n else newValue = [];\n } else {\n newValue = undefined;\n }\n }\n\n if (typeof newValue === \"number\" && isNaN(newValue))\n newValue = undefined;\n\n setOperation(op);\n setInternalValue(newValue);\n\n const hasNewValue = newValue !== null && Array.isArray(newValue)\n ? newValue.length > 0\n : newValue !== undefined;\n if (op && hasNewValue) {\n setValue(\n [op, newValue]\n );\n } else {\n setValue(\n undefined\n );\n }\n }\n\n const multiple = multipleSelectOperations.includes(operation);\n\n return (\n\n <div className=\"flex w-full\">\n <div className={\"w-[100px]\"}>\n <Select value={operation}\n size={\"medium\"}\n fullWidth={true}\n position={\"item-aligned\"}\n onValueChange={(value) => {\n updateFilter(value as VirtualTableWhereFilterOp, internalValue);\n }}\n renderValue={(op) => operationLabels[op as keyof typeof operationLabels]}>\n {possibleOperations.map((op) => (\n <SelectItem key={op} value={op}>\n {operationLabels[op]}\n </SelectItem>\n ))}\n </Select>\n </div>\n\n <div className=\"grow ml-2 flex flex-col gap-2\">\n\n {!enumValues && <TextField\n size={\"medium\"}\n aria-label={`${title ?? name} filter value`}\n type={type === \"number\" ? \"number\" : undefined}\n value={internalValue !== undefined && internalValue != null ? String(internalValue) : \"\"}\n disabled={isNullOperation}\n placeholder={isNullOperation ? \"null\" : undefined}\n onChange={(evt) => {\n // Text typed and deleted again is no filter, not a\n // filter for the empty string.\n const val = evt.target.value === \"\"\n ? undefined\n : type === \"number\"\n ? parseFloat(evt.target.value)\n : evt.target.value;\n updateFilter(operation, val);\n }}\n endAdornment={internalValue !== undefined && internalValue != null && <IconButton aria-label={t(\"clear\")}\n onClick={(e) => updateFilter(operation, undefined)}>\n <XIcon/>\n </IconButton>}\n />}\n\n {enumValues && !multiple &&\n <Select\n size={\"medium\"}\n position={\"item-aligned\"}\n fullWidth={true}\n disabled={isNullOperation}\n // As a string whatever the enum's type: a number enum\n // holds the picked id as a number, which the select\n // read as no value at all and showed blank.\n value={hasSingleValue ? String(internalValue) : \"\"}\n onValueChange={(value) => {\n if (value !== \"\")\n updateFilter(operation, type === \"number\" ? parseFloat(value as string) : value as string)\n }}\n endAdornment={hasSingleValue && <IconButton aria-label={t(\"clear\")}\n onClick={(e) => updateFilter(operation, undefined)}>\n <XIcon/>\n </IconButton>}\n renderValue={(enumKey) => {\n if (enumKey === null)\n return t(\"filter_for_null_values\");\n if (enumKey === undefined)\n return null;\n\n return <EnumValuesChip\n key={`select_value_${name}_${enumKey}`}\n enumKey={enumKey}\n enumValues={enumValues}\n size={\"small\"}/>;\n }}>\n {enumValues.map((enumConfig) => (\n <SelectItem key={`select_item_${name}_${enumConfig.id}`}\n value={String(enumConfig.id)}\n textValue={enumConfig.label}>\n <EnumValuesChip\n enumKey={String(enumConfig.id)}\n enumValues={enumValues}\n size={\"small\"}/>\n </SelectItem>\n ))}\n </Select>\n }\n\n {enumValues && multiple &&\n <MultiSelect\n size={\"medium\"}\n value={Array.isArray(internalValue) ? internalValue.map(e => String(e)) : []}\n disabled={isNullOperation}\n onValueChange={(value) => {\n updateFilter(operation, type === \"number\" ? (value ?? []).map(v => parseFloat(v)) : value)\n }}\n >\n {enumValues.map((enumConfig) => (\n <MultiSelectItem key={`select_value_${name}_${enumConfig.id}`}\n value={String(enumConfig.id)}>\n <EnumValuesChip\n enumKey={String(enumConfig.id)}\n enumValues={enum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AAI,YAAY,KAAA,GACZ,OAAO;MAEX,OAAO,oBAAC,gBAAD;OAEM;OACG;OACZ,MAAM;MAAS,GAHV,gBAAgB,KAAK,GAAG,SAGd;KACvB;eACC,WAAW,KAAK,eACb,oBAAC,YAAD;MACY,OAAO,OAAO,WAAW,EAAE;MAC3B,WAAW,WAAW;gBAC9B,oBAAC,gBAAD;OACI,SAAS,OAAO,WAAW,EAAE;OACjB;OACZ,MAAM;MAAS,CAAA;KACX,GAPK,eAAe,KAAK,GAAG,WAAW,IAOvC,CACf;IACG,CAAA;IAGX,cAAc,YACX,oBAAC,aAAD;KACI,MAAM;KACN,OAAO,MAAM,QAAQ,aAAa,IAAI,cAAc,KAAI,MAAK,OAAO,CAAC,CAAC,IAAI,CAAC;KAC3E,UAAU;KACV,gBAAgB,UAAU;MACtB,aAAa,WAAW,SAAS,YAAY,SAAS,CAAC,EAAA,CAAG,KAAI,MAAK,WAAW,CAAC,CAAC,IAAI,KAAK;KAC7F;eAEC,WAAW,KAAK,eACb,oBAAC,iBAAD;MACiB,OAAO,OAAO,WAAW,EAAE;gBACxC,oBAAC,gBAAD;OACI,SAAS,OAAO,WAAW,EAAE;OACjB;OACZ,MAAM;MAAS,CAAA;KACN,GANK,gBAAgB,KAAK,GAAG,WAAW,IAMxC,CACpB;IACQ,CAAA;GAGhB;IAEJ;;AAGb"}
|
|
@@ -9,12 +9,10 @@ import { WhereFilterOp } from "@rebasepro/types";
|
|
|
9
9
|
* - Postgres took `["==", null]` as `IS NULL`, but dropped `["in", null]`
|
|
10
10
|
* entirely — a dropped condition widens, so ticking the box returned every
|
|
11
11
|
* row instead of the ones with no value.
|
|
12
|
-
* - MongoDB maps `in`/`not-in` straight onto `$in`/`$nin`, and Mongo rejects
|
|
13
|
-
* those with a non-array: `$in needs an array`. The read fails outright.
|
|
14
12
|
* - A Firestore driver is supplied by the developer, and the Firestore SDK
|
|
15
13
|
* likewise refuses `in` without a non-empty array.
|
|
16
14
|
*
|
|
17
|
-
* Only `==`/`!=` ever worked, and only because
|
|
15
|
+
* Only `==`/`!=` ever worked, and only because the engines independently chose
|
|
18
16
|
* to special-case a null operand. Nothing in the filter contract promises that,
|
|
19
17
|
* and a filter field is shared by every engine the admin can talk to.
|
|
20
18
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"null_filter.js","names":[],"sources":["../../../../src/components/SelectableTable/filters/null_filter.ts"],"sourcesContent":["import { WhereFilterOp } from \"@rebasepro/types\";\n\n/**\n * The \"filter for null values\" checkbox, expressed portably.\n *\n * The checkbox used to emit `[whichever operator is selected, null]` and leave\n * the driver to work out that a null value means a null check. That reads as\n * an engine-neutral convention and is not one:\n *\n * - Postgres took `[\"==\", null]` as `IS NULL`, but dropped `[\"in\", null]`\n * entirely — a dropped condition widens, so ticking the box returned every\n * row instead of the ones with no value.\n * -
|
|
1
|
+
{"version":3,"file":"null_filter.js","names":[],"sources":["../../../../src/components/SelectableTable/filters/null_filter.ts"],"sourcesContent":["import { WhereFilterOp } from \"@rebasepro/types\";\n\n/**\n * The \"filter for null values\" checkbox, expressed portably.\n *\n * The checkbox used to emit `[whichever operator is selected, null]` and leave\n * the driver to work out that a null value means a null check. That reads as\n * an engine-neutral convention and is not one:\n *\n * - Postgres took `[\"==\", null]` as `IS NULL`, but dropped `[\"in\", null]`\n * entirely — a dropped condition widens, so ticking the box returned every\n * row instead of the ones with no value.\n * - A Firestore driver is supplied by the developer, and the Firestore SDK\n * likewise refuses `in` without a non-empty array.\n *\n * Only `==`/`!=` ever worked, and only because the engines independently chose\n * to special-case a null operand. Nothing in the filter contract promises that,\n * and a filter field is shared by every engine the admin can talk to.\n *\n * `is-null`/`is-not-null` are the operators that mean this, they are in\n * {@link ALL_WHERE_FILTER_OPS}, and every driver already handles them\n * explicitly rather than by inference. So the checkbox emits those, and the\n * question of what a null operand means to a given engine stops being asked.\n */\nexport const NULL_FILTER_OPERATORS: readonly WhereFilterOp[] = [\"is-null\", \"is-not-null\"];\n\n/** Whether `op` asks about absence rather than about a value. */\nexport function isNullFilterOperator(op: WhereFilterOp | undefined): boolean {\n return op === \"is-null\" || op === \"is-not-null\";\n}\n\n/**\n * The null check carrying the same sense as `op`.\n *\n * The checkbox is a toggle, not an operator, so the operator it is ticked\n * alongside is what says which way round it means: `==`/`in` are asking for\n * a match, so their null form is \"has nothing\"; `!=`/`not-in` are asking for\n * the absence of one, so theirs is \"has something\".\n */\nexport function nullFilterOperatorFor(op: WhereFilterOp | undefined): WhereFilterOp {\n if (op === \"!=\" || op === \"not-in\" || op === \"is-not-null\") return \"is-not-null\";\n return \"is-null\";\n}\n\n/**\n * The value operator to return to when the checkbox is unticked.\n *\n * `is-null` could have been reached from `==` or from `in` — the field cannot\n * know which, and it does not matter. What matters is landing on an operator\n * the dropdown actually offers, in the same sense, so the control does not\n * come back showing something it cannot render.\n */\nexport function valueOperatorFor(\n op: WhereFilterOp | undefined,\n offered: readonly WhereFilterOp[]\n): WhereFilterOp | undefined {\n const negative = op === \"is-not-null\";\n const wanted: WhereFilterOp[] = negative ? [\"!=\", \"not-in\"] : [\"==\", \"in\", \"array-contains\"];\n return wanted.find(candidate => offered.includes(candidate))\n ?? offered.find(candidate => !isNullFilterOperator(candidate));\n}\n"],"mappings":";;AA2BA,SAAgB,qBAAqB,IAAwC;CACzE,OAAO,OAAO,aAAa,OAAO;AACtC;;;;;;;;;AAUA,SAAgB,sBAAsB,IAA8C;CAChF,IAAI,OAAO,QAAQ,OAAO,YAAY,OAAO,eAAe,OAAO;CACnE,OAAO;AACX;;;;;;;;;AAUA,SAAgB,iBACZ,IACA,SACyB;CAGzB,QAFiB,OAAO,gBACmB,CAAC,MAAM,QAAQ,IAAI;EAAC;EAAM;EAAM;CAAgB,EAAA,CAC7E,MAAK,cAAa,QAAQ,SAAS,SAAS,CAAC,KACpD,QAAQ,MAAK,cAAa,CAAC,qBAAqB,SAAS,CAAC;AACrE"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { hasEntityId } from "../util/identity.js";
|
|
1
2
|
import { useCollectionRegistryController } from "../hooks/navigation/contexts/CollectionRegistryContext.js";
|
|
2
3
|
import { useSidePanel } from "../hooks/useSidePanel.js";
|
|
3
4
|
import { useUrlController } from "../hooks/navigation/contexts/UrlContext.js";
|
|
@@ -7,7 +8,6 @@ import { DetailViewBinding } from "./DetailViewBinding.js";
|
|
|
7
8
|
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
8
9
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
9
10
|
import { ErrorBoundary, IconButton, Maximize2Icon, XIcon } from "@rebasepro/ui";
|
|
10
|
-
import { hasEntityId } from "@rebasepro/common";
|
|
11
11
|
import { resolveDefaultSelectedView, useComponentOverride, useTranslation } from "@rebasepro/app";
|
|
12
12
|
import { useNavigate } from "react-router";
|
|
13
13
|
//#region src/components/SidePanelBinding.tsx
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SidePanelBinding.js","names":[],"sources":["../../src/components/SidePanelBinding.tsx"],"sourcesContent":["\nimport type { SidePanelBindingProps, AdminCollection } from \"@rebasepro/cms-types\";\nimport { hasEntityId } from \"@rebasepro/common\";\nimport React, { useCallback, useEffect, useMemo, useRef, useState } from \"react\";\n\nimport type { OnSavedParams } from \"../types/components/EntityFormProps\";\nimport { ErrorBoundary } from \"@rebasepro/ui\";\nimport { IconButton, Maximize2Icon, XIcon } from \"@rebasepro/ui\";\nimport { EditViewBinding } from \"./EditViewBinding\";\nimport { DetailViewBinding } from \"./DetailViewBinding\";\nimport { useSideDialogContext } from \"./SideDialogs\";\nimport { useNavigate } from \"react-router\";\nimport { useComponentOverride, useTranslation } from \"@rebasepro/app\";\nimport { useCollectionRegistryController } from \"../hooks/navigation/contexts/CollectionRegistryContext\";\nimport { useSidePanel } from \"../hooks/useSidePanel\";\nimport { useUrlController } from \"../hooks/navigation/contexts/UrlContext\";\nimport { resolveDefaultSelectedView } from \"@rebasepro/app\";\n\n/**\n * This is the component in charge of rendering the side dialog used\n * for editing entities. Use the {@link useSidePanel} to open\n * and control the dialogs.\n * This component needs a parent {@link Rebase}\n * {@link useSidePanel}\n * @group Components\n */\nexport function SidePanelBinding(props: SidePanelBindingProps) {\n const { t } = useTranslation();\n\n const {\n allowFullScreen = true,\n path,\n id: entityId,\n selectedTab,\n formProps\n } = props;\n\n const ResolvedDetailView = useComponentOverride(\"DetailView\", DetailViewBinding);\n\n const {\n blocked,\n setBlocked,\n setBlockedNavigationMessage,\n close\n } = useSideDialogContext();\n\n const navigate = useNavigate();\n\n const sidePanelController = useSidePanel();\n const collectionRegistryController = useCollectionRegistryController();\n const sideDialogsController = useSideDialogContext();\n const urlController = useUrlController();\n\n /**\n * The X in the identity bar.\n *\n * Unforced, so it stops at the same unsaved-changes prompt that Escape and\n * a click outside already do. It used to clear `blocked` and force the\n * close, which made the one control actually labelled \"close\" the only way\n * out of the panel that dropped an edit without asking.\n *\n * `props.onClose` is not called here: the panel carries the same callback\n * (see `propsToSidePanel`) and {@link SideDialogs} fires it once the panel\n * really closes — which is after the prompt, not before it.\n */\n const onClose = () => {\n close();\n }\n\n /**\n * Closing because the record was just saved, which is the one case that has\n * to force. `blocked` is driven by an effect on the form's dirty flag and is\n * still true for a tick after a save; prompting about unsaved changes here\n * would be asking about values that are already on the server.\n */\n const closeAfterSave = () => {\n setBlocked(false);\n close(true);\n }\n\n /**\n * The panel's response to a save, and the one place it decides where the\n * panel goes next.\n *\n * Exactly **one** panel navigation is raised here. These branches used to\n * run independently — a `replace` onto the saved record's address *and* a\n * close — and because the last navigation is the one that survives, which\n * of them the user got was settled by statement order rather than by\n * intent. Closing wins by construction now: moving a panel to a new address\n * it is about to leave is work whose only effect is to fight the close.\n *\n * `props.onSaved` runs last for the same reason. It belongs to whoever\n * opened the panel and it is free to navigate — the reference picker's\n * selects the record and closes the picker — so the opener's intent should\n * be the final word, not something this panel overwrites on its way out.\n */\n const onSaved = (params: OnSavedParams) => {\n setEditInDialog(false);\n\n // Either \"save and close\" was clicked, or the opener asked for it when\n // it opened the panel.\n const closeRequested = sideDialogsController.pendingClose || props.closeOnSave;\n\n if (closeRequested) {\n sideDialogsController.setPendingClose(false);\n closeAfterSave();\n } else if (params.status !== \"existing\") {\n // A newly created entity replaces the panel with its own address,\n // which already leaves the edit view behind.\n sidePanelController.replace({\n path: params.path,\n id: params.id,\n selectedTab: params.selectedTab,\n updateUrl: collection?.openEntityMode !== \"dialog\",\n collection: params.collection\n });\n } else {\n closeEditView();\n }\n\n props.onSaved?.(params);\n }\n\n const parentCollectionSlugs = useMemo(() => {\n return collectionRegistryController.getParentCollectionSlugs(path);\n }, [collectionRegistryController, path]);\n\n const parentEntityIds = useMemo(() => {\n return collectionRegistryController.getParentEntityIds(path);\n }, [collectionRegistryController, path]);\n\n const collection = collectionRegistryController.getCollection(path) ?? props.collection;\n\n // Dialog mode deliberately stays out of the URL, so it is the only case that\n // needs local edit state. Everywhere else `edit` is a path segment, which\n // keeps refresh and the back button working the same way they do in split.\n const isDialogMode = collection?.openEntityMode === \"dialog\";\n const [editInDialog, setEditInDialog] = useState(false);\n const showEditInPanel = isDialogMode ? editInDialog : selectedTab === \"edit\";\n const isDetailMode = collection?.defaultEntityAction === \"view\" && !showEditInPanel && hasEntityId(entityId);\n\n // Reset edit mode when switching entities\n useEffect(() => {\n setEditInDialog(false);\n }, [entityId]);\n\n const openEditView = useCallback(() => {\n if (isDialogMode || !hasEntityId(entityId)) {\n setEditInDialog(true);\n return;\n }\n sidePanelController.replace({\n path,\n id: entityId,\n selectedTab: \"edit\",\n updateUrl: true,\n collection\n });\n }, [isDialogMode, entityId, path, collection, sidePanelController]);\n\n const closeEditView = useCallback(() => {\n if (isDialogMode || !hasEntityId(entityId)) {\n setEditInDialog(false);\n return;\n }\n sidePanelController.replace({\n path,\n id: entityId,\n selectedTab: undefined,\n updateUrl: true,\n collection\n });\n }, [isDialogMode, entityId, path, collection, sidePanelController]);\n\n // One-time correction: when the side panel opens without the correct\n // selectedTab but the resolved collection (from the registry) has a\n // defaultSelectedView, update the panel width and URL to match.\n // This handles cases where defaultSelectedView is set via the collection\n // editor / Studio and is not available on the collection object the\n // caller passed to sidePanelController.open().\n const hasCorrectedDefaultView = useRef(false);\n useEffect(() => {\n hasCorrectedDefaultView.current = false;\n }, [entityId]);\n useEffect(() => {\n if (hasCorrectedDefaultView.current) return;\n if (selectedTab) return; // Already has a tab — no correction needed\n if (!hasEntityId(entityId) || !collection?.defaultSelectedView) return;\n\n const effectiveDefault = resolveDefaultSelectedView(\n collection.defaultSelectedView,\n { status: \"existing\", id: entityId }\n );\n if (effectiveDefault && effectiveDefault !== \"edit\") {\n hasCorrectedDefaultView.current = true;\n sidePanelController.replace({\n path,\n id: entityId,\n selectedTab: effectiveDefault,\n updateUrl: collection.openEntityMode !== \"dialog\",\n collection\n });\n }\n }, [selectedTab, entityId, collection, path, sidePanelController]);\n\n // Note: beforeunload is handled by useUnsavedChangesDialog in SideDialogView,\n // which listens to the same `blocked` state via SideDialogContext.\n\n const onValuesModified = useCallback((modified: boolean) => {\n setBlockedNavigationMessage(modified\n ? <> You have unsaved changes in this <b>{collection?.singularName ?? collection?.name}</b>.</>\n : undefined)\n setBlocked(modified);\n }, [collection?.name, setBlocked, setBlockedNavigationMessage]);\n\n if (!props || !collection) {\n return <div className={\"w-full\"}/>;\n }\n\n const closeButton = (\n <IconButton aria-label={t(\"close\")}\n className=\"self-center\"\n size={\"small\"}\n onClick={onClose}>\n <XIcon/>\n </IconButton>\n );\n\n /**\n * Where the panel's own two controls sit, which is not the same question in\n * the two layouts that have them.\n *\n * A **side panel** slides in over the list from the right, and its leading\n * edge is the seam between the two. Close belongs on that seam — it points\n * back at the thing still visible behind it — and it is where the eye\n * already is, because the breadcrumb starts there.\n *\n * A **dialog** has no seam and nothing behind it to point at. It is a box\n * centred on a dimmed screen, and every box like it on every platform is\n * dismissed from its top-right corner. Close was sitting at the far left\n * of the bar, a full dialog's width from the expand button it belongs\n * beside, in the one corner that means \"back\" in a layout with no back.\n *\n * So in a dialog the two travel together at the trailing edge, expand then\n * close: the window controls, after the record's actions and its overflow\n * menu, in the corner a dialog is closed from.\n */\n const barActionsStart = isDialogMode ? undefined : closeButton;\n\n const windowControls = (expandButton: React.ReactNode) => (\n <div className=\"flex gap-1 items-center\">\n {expandButton}\n {isDialogMode && closeButton}\n </div>\n );\n\n return (\n <>\n <ErrorBoundary>\n {isDetailMode\n ? <ResolvedDetailView\n path={path}\n layout={collection?.openEntityMode === \"dialog\" ? \"dialog\" : \"side_panel\"}\n collection={collection as AdminCollection}\n entityId={entityId!}\n parentCollectionSlugs={parentCollectionSlugs}\n parentEntityIds={parentEntityIds}\n onEditClick={openEditView}\n barActionsStart={barActionsStart}\n barActions={() => windowControls(\n allowFullScreen && <IconButton aria-label={t(\"full_screen\")}\n className=\"self-center\"\n size={\"small\"}\n onClick={() => {\n if (hasEntityId(entityId)) {\n const fullScreenUrl = urlController.buildUrlCollectionPath(`${path}/${entityId}`);\n navigate(fullScreenUrl, { state: null });\n }\n }}>\n <Maximize2Icon/>\n </IconButton>\n )}\n onTabChange={({\n entityId: tabEntityId,\n selectedTab,\n collection: paramCollection\n }) => {\n if (collection?.openEntityMode === \"dialog\" || paramCollection?.openEntityMode === \"dialog\") {\n return;\n }\n if (tabEntityId) {\n sidePanelController.replace({\n path,\n id: tabEntityId,\n selectedTab,\n updateUrl: true,\n collection: paramCollection ?? collection\n });\n }\n }}\n />\n : <EditViewBinding\n {...props}\n entityId={entityId}\n layout={collection?.openEntityMode === \"dialog\" ? \"dialog\" : \"side_panel\"}\n collection={collection as AdminCollection}\n parentCollectionSlugs={parentCollectionSlugs} parentEntityIds={parentEntityIds}\n onValuesModified={onValuesModified}\n onSaved={onSaved}\n navigateBack={closeEditView}\n barActionsStart={barActionsStart}\n barActions={({ carryEdit }) => windowControls(\n allowFullScreen && <IconButton aria-label={t(\"full_screen\")}\n className=\"self-center\"\n size={\"small\"}\n onClick={() => {\n // The form's own handoff, rather than a second\n // copy of the rules for it here: only an edit in\n // progress is worth carrying (a clean record\n // stashed anyway arrived announcing unsaved\n // changes to someone who had only looked at it),\n // and only the fields that were edited (carrying\n // the whole record marked every field touched).\n carryEdit?.();\n setBlocked(false);\n setBlockedNavigationMessage(undefined);\n if (hasEntityId(entityId)) {\n const fullScreenUrl = urlController.buildUrlCollectionPath(`${path}/${entityId}`);\n navigate(fullScreenUrl, { state: null });\n } else {\n const fullScreenUrl = urlController.buildUrlCollectionPath(path);\n navigate(fullScreenUrl + \"#new\", { state: null });\n }\n }}>\n <Maximize2Icon/>\n </IconButton>\n )}\n onTabChange={({\n entityId: tabEntityId,\n selectedTab,\n collection: paramCollection\n }) => {\n if (collection?.openEntityMode === \"dialog\" || paramCollection?.openEntityMode === \"dialog\") {\n return;\n }\n if (tabEntityId) {\n sidePanelController.replace({\n path,\n id: tabEntityId,\n selectedTab,\n updateUrl: true,\n collection: paramCollection ?? collection\n });\n }\n }}\n formProps={formProps}\n />\n }\n </ErrorBoundary>\n\n </>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AA0BA,SAAgB,iBAAiB,OAA8B;CAC3D,MAAM,EAAE,MAAM,eAAe;CAE7B,MAAM,EACF,kBAAkB,MAClB,MACA,IAAI,UACJ,aACA,cACA;CAEJ,MAAM,qBAAqB,qBAAqB,cAAc,iBAAiB;CAE/E,MAAM,EACF,SACA,YACA,6BACA,UACA,qBAAqB;CAEzB,MAAM,WAAW,YAAY;CAE7B,MAAM,sBAAsB,aAAa;CACzC,MAAM,+BAA+B,gCAAgC;CACrE,MAAM,wBAAwB,qBAAqB;CACnD,MAAM,gBAAgB,iBAAiB;;;;;;;;;;;;;CAcvC,MAAM,gBAAgB;EAClB,MAAM;CACV;;;;;;;CAQA,MAAM,uBAAuB;EACzB,WAAW,KAAK;EAChB,MAAM,IAAI;CACd;;;;;;;;;;;;;;;;;CAkBA,MAAM,WAAW,WAA0B;EACvC,gBAAgB,KAAK;EAMrB,IAFuB,sBAAsB,gBAAgB,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Y,iBAAiB,mBAAmB,UAC/E;GAEJ,IAAI,aACA,oBAAoB,QAAQ;IACxB;IACA,IAAI;IACJ;IACA,WAAW;IACX,YAAY,mBAAmB;GACnC,CAAC;EAET;EACW;CACd,CAAA,EAEM,CAAA,EAEjB,CAAA;AAEV"}
|
|
1
|
+
{"version":3,"file":"SidePanelBinding.js","names":[],"sources":["../../src/components/SidePanelBinding.tsx"],"sourcesContent":["\nimport type { SidePanelBindingProps, AdminCollection } from \"@rebasepro/cms-types\";\nimport { hasEntityId } from \"../util/identity\";\nimport React, { useCallback, useEffect, useMemo, useRef, useState } from \"react\";\n\nimport type { OnSavedParams } from \"../types/components/EntityFormProps\";\nimport { ErrorBoundary } from \"@rebasepro/ui\";\nimport { IconButton, Maximize2Icon, XIcon } from \"@rebasepro/ui\";\nimport { EditViewBinding } from \"./EditViewBinding\";\nimport { DetailViewBinding } from \"./DetailViewBinding\";\nimport { useSideDialogContext } from \"./SideDialogs\";\nimport { useNavigate } from \"react-router\";\nimport { useComponentOverride, useTranslation } from \"@rebasepro/app\";\nimport { useCollectionRegistryController } from \"../hooks/navigation/contexts/CollectionRegistryContext\";\nimport { useSidePanel } from \"../hooks/useSidePanel\";\nimport { useUrlController } from \"../hooks/navigation/contexts/UrlContext\";\nimport { resolveDefaultSelectedView } from \"@rebasepro/app\";\n\n/**\n * This is the component in charge of rendering the side dialog used\n * for editing entities. Use the {@link useSidePanel} to open\n * and control the dialogs.\n * This component needs a parent {@link Rebase}\n * {@link useSidePanel}\n * @group Components\n */\nexport function SidePanelBinding(props: SidePanelBindingProps) {\n const { t } = useTranslation();\n\n const {\n allowFullScreen = true,\n path,\n id: entityId,\n selectedTab,\n formProps\n } = props;\n\n const ResolvedDetailView = useComponentOverride(\"DetailView\", DetailViewBinding);\n\n const {\n blocked,\n setBlocked,\n setBlockedNavigationMessage,\n close\n } = useSideDialogContext();\n\n const navigate = useNavigate();\n\n const sidePanelController = useSidePanel();\n const collectionRegistryController = useCollectionRegistryController();\n const sideDialogsController = useSideDialogContext();\n const urlController = useUrlController();\n\n /**\n * The X in the identity bar.\n *\n * Unforced, so it stops at the same unsaved-changes prompt that Escape and\n * a click outside already do. It used to clear `blocked` and force the\n * close, which made the one control actually labelled \"close\" the only way\n * out of the panel that dropped an edit without asking.\n *\n * `props.onClose` is not called here: the panel carries the same callback\n * (see `propsToSidePanel`) and {@link SideDialogs} fires it once the panel\n * really closes — which is after the prompt, not before it.\n */\n const onClose = () => {\n close();\n }\n\n /**\n * Closing because the record was just saved, which is the one case that has\n * to force. `blocked` is driven by an effect on the form's dirty flag and is\n * still true for a tick after a save; prompting about unsaved changes here\n * would be asking about values that are already on the server.\n */\n const closeAfterSave = () => {\n setBlocked(false);\n close(true);\n }\n\n /**\n * The panel's response to a save, and the one place it decides where the\n * panel goes next.\n *\n * Exactly **one** panel navigation is raised here. These branches used to\n * run independently — a `replace` onto the saved record's address *and* a\n * close — and because the last navigation is the one that survives, which\n * of them the user got was settled by statement order rather than by\n * intent. Closing wins by construction now: moving a panel to a new address\n * it is about to leave is work whose only effect is to fight the close.\n *\n * `props.onSaved` runs last for the same reason. It belongs to whoever\n * opened the panel and it is free to navigate — the reference picker's\n * selects the record and closes the picker — so the opener's intent should\n * be the final word, not something this panel overwrites on its way out.\n */\n const onSaved = (params: OnSavedParams) => {\n setEditInDialog(false);\n\n // Either \"save and close\" was clicked, or the opener asked for it when\n // it opened the panel.\n const closeRequested = sideDialogsController.pendingClose || props.closeOnSave;\n\n if (closeRequested) {\n sideDialogsController.setPendingClose(false);\n closeAfterSave();\n } else if (params.status !== \"existing\") {\n // A newly created entity replaces the panel with its own address,\n // which already leaves the edit view behind.\n sidePanelController.replace({\n path: params.path,\n id: params.id,\n selectedTab: params.selectedTab,\n updateUrl: collection?.openEntityMode !== \"dialog\",\n collection: params.collection\n });\n } else {\n closeEditView();\n }\n\n props.onSaved?.(params);\n }\n\n const parentCollectionSlugs = useMemo(() => {\n return collectionRegistryController.getParentCollectionSlugs(path);\n }, [collectionRegistryController, path]);\n\n const parentEntityIds = useMemo(() => {\n return collectionRegistryController.getParentEntityIds(path);\n }, [collectionRegistryController, path]);\n\n const collection = collectionRegistryController.getCollection(path) ?? props.collection;\n\n // Dialog mode deliberately stays out of the URL, so it is the only case that\n // needs local edit state. Everywhere else `edit` is a path segment, which\n // keeps refresh and the back button working the same way they do in split.\n const isDialogMode = collection?.openEntityMode === \"dialog\";\n const [editInDialog, setEditInDialog] = useState(false);\n const showEditInPanel = isDialogMode ? editInDialog : selectedTab === \"edit\";\n const isDetailMode = collection?.defaultEntityAction === \"view\" && !showEditInPanel && hasEntityId(entityId);\n\n // Reset edit mode when switching entities\n useEffect(() => {\n setEditInDialog(false);\n }, [entityId]);\n\n const openEditView = useCallback(() => {\n if (isDialogMode || !hasEntityId(entityId)) {\n setEditInDialog(true);\n return;\n }\n sidePanelController.replace({\n path,\n id: entityId,\n selectedTab: \"edit\",\n updateUrl: true,\n collection\n });\n }, [isDialogMode, entityId, path, collection, sidePanelController]);\n\n const closeEditView = useCallback(() => {\n if (isDialogMode || !hasEntityId(entityId)) {\n setEditInDialog(false);\n return;\n }\n sidePanelController.replace({\n path,\n id: entityId,\n selectedTab: undefined,\n updateUrl: true,\n collection\n });\n }, [isDialogMode, entityId, path, collection, sidePanelController]);\n\n // One-time correction: when the side panel opens without the correct\n // selectedTab but the resolved collection (from the registry) has a\n // defaultSelectedView, update the panel width and URL to match.\n // This handles cases where defaultSelectedView is set via the collection\n // editor / Studio and is not available on the collection object the\n // caller passed to sidePanelController.open().\n const hasCorrectedDefaultView = useRef(false);\n useEffect(() => {\n hasCorrectedDefaultView.current = false;\n }, [entityId]);\n useEffect(() => {\n if (hasCorrectedDefaultView.current) return;\n if (selectedTab) return; // Already has a tab — no correction needed\n if (!hasEntityId(entityId) || !collection?.defaultSelectedView) return;\n\n const effectiveDefault = resolveDefaultSelectedView(\n collection.defaultSelectedView,\n { status: \"existing\", id: entityId }\n );\n if (effectiveDefault && effectiveDefault !== \"edit\") {\n hasCorrectedDefaultView.current = true;\n sidePanelController.replace({\n path,\n id: entityId,\n selectedTab: effectiveDefault,\n updateUrl: collection.openEntityMode !== \"dialog\",\n collection\n });\n }\n }, [selectedTab, entityId, collection, path, sidePanelController]);\n\n // Note: beforeunload is handled by useUnsavedChangesDialog in SideDialogView,\n // which listens to the same `blocked` state via SideDialogContext.\n\n const onValuesModified = useCallback((modified: boolean) => {\n setBlockedNavigationMessage(modified\n ? <> You have unsaved changes in this <b>{collection?.singularName ?? collection?.name}</b>.</>\n : undefined)\n setBlocked(modified);\n }, [collection?.name, setBlocked, setBlockedNavigationMessage]);\n\n if (!props || !collection) {\n return <div className={\"w-full\"}/>;\n }\n\n const closeButton = (\n <IconButton aria-label={t(\"close\")}\n className=\"self-center\"\n size={\"small\"}\n onClick={onClose}>\n <XIcon/>\n </IconButton>\n );\n\n /**\n * Where the panel's own two controls sit, which is not the same question in\n * the two layouts that have them.\n *\n * A **side panel** slides in over the list from the right, and its leading\n * edge is the seam between the two. Close belongs on that seam — it points\n * back at the thing still visible behind it — and it is where the eye\n * already is, because the breadcrumb starts there.\n *\n * A **dialog** has no seam and nothing behind it to point at. It is a box\n * centred on a dimmed screen, and every box like it on every platform is\n * dismissed from its top-right corner. Close was sitting at the far left\n * of the bar, a full dialog's width from the expand button it belongs\n * beside, in the one corner that means \"back\" in a layout with no back.\n *\n * So in a dialog the two travel together at the trailing edge, expand then\n * close: the window controls, after the record's actions and its overflow\n * menu, in the corner a dialog is closed from.\n */\n const barActionsStart = isDialogMode ? undefined : closeButton;\n\n const windowControls = (expandButton: React.ReactNode) => (\n <div className=\"flex gap-1 items-center\">\n {expandButton}\n {isDialogMode && closeButton}\n </div>\n );\n\n return (\n <>\n <ErrorBoundary>\n {isDetailMode\n ? <ResolvedDetailView\n path={path}\n layout={collection?.openEntityMode === \"dialog\" ? \"dialog\" : \"side_panel\"}\n collection={collection as AdminCollection}\n entityId={entityId!}\n parentCollectionSlugs={parentCollectionSlugs}\n parentEntityIds={parentEntityIds}\n onEditClick={openEditView}\n barActionsStart={barActionsStart}\n barActions={() => windowControls(\n allowFullScreen && <IconButton aria-label={t(\"full_screen\")}\n className=\"self-center\"\n size={\"small\"}\n onClick={() => {\n if (hasEntityId(entityId)) {\n const fullScreenUrl = urlController.buildUrlCollectionPath(`${path}/${entityId}`);\n navigate(fullScreenUrl, { state: null });\n }\n }}>\n <Maximize2Icon/>\n </IconButton>\n )}\n onTabChange={({\n entityId: tabEntityId,\n selectedTab,\n collection: paramCollection\n }) => {\n if (collection?.openEntityMode === \"dialog\" || paramCollection?.openEntityMode === \"dialog\") {\n return;\n }\n if (tabEntityId) {\n sidePanelController.replace({\n path,\n id: tabEntityId,\n selectedTab,\n updateUrl: true,\n collection: paramCollection ?? collection\n });\n }\n }}\n />\n : <EditViewBinding\n {...props}\n entityId={entityId}\n layout={collection?.openEntityMode === \"dialog\" ? \"dialog\" : \"side_panel\"}\n collection={collection as AdminCollection}\n parentCollectionSlugs={parentCollectionSlugs} parentEntityIds={parentEntityIds}\n onValuesModified={onValuesModified}\n onSaved={onSaved}\n navigateBack={closeEditView}\n barActionsStart={barActionsStart}\n barActions={({ carryEdit }) => windowControls(\n allowFullScreen && <IconButton aria-label={t(\"full_screen\")}\n className=\"self-center\"\n size={\"small\"}\n onClick={() => {\n // The form's own handoff, rather than a second\n // copy of the rules for it here: only an edit in\n // progress is worth carrying (a clean record\n // stashed anyway arrived announcing unsaved\n // changes to someone who had only looked at it),\n // and only the fields that were edited (carrying\n // the whole record marked every field touched).\n carryEdit?.();\n setBlocked(false);\n setBlockedNavigationMessage(undefined);\n if (hasEntityId(entityId)) {\n const fullScreenUrl = urlController.buildUrlCollectionPath(`${path}/${entityId}`);\n navigate(fullScreenUrl, { state: null });\n } else {\n const fullScreenUrl = urlController.buildUrlCollectionPath(path);\n navigate(fullScreenUrl + \"#new\", { state: null });\n }\n }}>\n <Maximize2Icon/>\n </IconButton>\n )}\n onTabChange={({\n entityId: tabEntityId,\n selectedTab,\n collection: paramCollection\n }) => {\n if (collection?.openEntityMode === \"dialog\" || paramCollection?.openEntityMode === \"dialog\") {\n return;\n }\n if (tabEntityId) {\n sidePanelController.replace({\n path,\n id: tabEntityId,\n selectedTab,\n updateUrl: true,\n collection: paramCollection ?? collection\n });\n }\n }}\n formProps={formProps}\n />\n }\n </ErrorBoundary>\n\n </>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AA0BA,SAAgB,iBAAiB,OAA8B;CAC3D,MAAM,EAAE,MAAM,eAAe;CAE7B,MAAM,EACF,kBAAkB,MAClB,MACA,IAAI,UACJ,aACA,cACA;CAEJ,MAAM,qBAAqB,qBAAqB,cAAc,iBAAiB;CAE/E,MAAM,EACF,SACA,YACA,6BACA,UACA,qBAAqB;CAEzB,MAAM,WAAW,YAAY;CAE7B,MAAM,sBAAsB,aAAa;CACzC,MAAM,+BAA+B,gCAAgC;CACrE,MAAM,wBAAwB,qBAAqB;CACnD,MAAM,gBAAgB,iBAAiB;;;;;;;;;;;;;CAcvC,MAAM,gBAAgB;EAClB,MAAM;CACV;;;;;;;CAQA,MAAM,uBAAuB;EACzB,WAAW,KAAK;EAChB,MAAM,IAAI;CACd;;;;;;;;;;;;;;;;;CAkBA,MAAM,WAAW,WAA0B;EACvC,gBAAgB,KAAK;EAMrB,IAFuB,sBAAsB,gBAAgB,MAAM,aAE/C;GAChB,sBAAsB,gBAAgB,KAAK;GAC3C,eAAe;EACnB,OAAO,IAAI,OAAO,WAAW,YAGzB,oBAAoB,QAAQ;GACxB,MAAM,OAAO;GACb,IAAI,OAAO;GACX,aAAa,OAAO;GACpB,WAAW,YAAY,mBAAmB;GAC1C,YAAY,OAAO;EACvB,CAAC;OAED,cAAc;EAGlB,MAAM,UAAU,MAAM;CAC1B;CAEA,MAAM,wBAAwB,cAAc;EACxC,OAAO,6BAA6B,yBAAyB,IAAI;CACrE,GAAG,CAAC,8BAA8B,IAAI,CAAC;CAEvC,MAAM,kBAAkB,cAAc;EA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,YAAY,sBACV;GACF,IAAI,YAAY,mBAAmB,YAAY,iBAAiB,mBAAmB,UAC/E;GAEJ,IAAI,aACA,oBAAoB,QAAQ;IACxB;IACA,IAAI;IACJ;IACA,WAAW;IACX,YAAY,mBAAmB;GACnC,CAAC;EAET;CACH,CAAA,IACC,oBAAC,iBAAD;EACE,GAAI;EACM;EACV,QAAQ,YAAY,mBAAmB,WAAW,WAAW;EACjD;EACW;EAAwC;EAC7C;EACT;EACT,cAAc;EACG;EACjB,aAAa,EAAE,gBAAgB,eAC3B,mBAAmB,oBAAC,YAAD;GAAY,cAAY,EAAE,aAAa;GACtD,WAAU;GACV,MAAM;GACN,eAAe;IAQX,YAAY;IACZ,WAAW,KAAK;IAChB,4BAA4B,KAAA,CAAS;IACrC,IAAI,YAAY,QAAQ,GAAG;KACvB,MAAM,gBAAgB,cAAc,uBAAuB,GAAG,KAAK,GAAG,UAAU;KAChF,SAAS,eAAe,EAAE,OAAO,KAAK,CAAC;IAC3C,OAAO;KACH,MAAM,gBAAgB,cAAc,uBAAuB,IAAI;KAC/D,SAAS,gBAAgB,QAAQ,EAAE,OAAO,KAAK,CAAC;IACpD;GACJ;aACA,oBAAC,eAAD,CAAe,CAAA;EACP,CAAA,CAChB;EACA,cAAc,EACV,UAAU,aACV,aACA,YAAY,sBACV;GACF,IAAI,YAAY,mBAAmB,YAAY,iBAAiB,mBAAmB,UAC/E;GAEJ,IAAI,aACA,oBAAoB,QAAQ;IACxB;IACA,IAAI;IACJ;IACA,WAAW;IACX,YAAY,mBAAmB;GACnC,CAAC;EAET;EACW;CACd,CAAA,EAEM,CAAA,EAEjB,CAAA;AAEV"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { DefaultFieldConfig } from "../types/fields.js";
|
|
2
|
-
import type { Property } from "@rebasepro/types";
|
|
3
|
-
import type { PropertyConfig } from "@rebasepro/cms-types";
|
|
2
|
+
import type { PropertyConfig, Property } from "@rebasepro/cms-types";
|
|
4
3
|
import { getDefaultFieldId, getFieldId } from "./field_ids.js";
|
|
5
4
|
export { getDefaultFieldId, getFieldId };
|
|
6
5
|
/**
|