@rebasepro/cms 0.30.1 → 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":"PropertyPreview.js","names":[],"sources":["../../src/preview/PropertyPreview.tsx"],"sourcesContent":["import type { ArrayProperty, MapProperty, NumberProperty, Property, StringProperty } from \"@rebasepro/types\";\nimport React, { createElement, Suspense } from \"react\";\nimport { deepEqual as equal } from \"fast-equals\"\n\nimport { resourceKeyOf } from \"@rebasepro/types\";\nimport { EntityReference, EntityRelation } from \"@rebasepro/types\";\nimport type { PropertyPreviewProps } from \"../types/components/PropertyPreviewProps\";\nimport { resolveProperty, normalizeToEntityRelation, getRelationTargetPath } from \"@rebasepro/common\";\nimport { useAuthController, useCustomizationController, resolveComponentRef } from \"@rebasepro/app\";\nimport { EmptyValue } from \"./components/EmptyValue\";\nimport { UrlComponentPreview } from \"./components/UrlComponentPreview\";\nimport { StorageThumbnail } from \"./components/StorageThumbnail\";\nimport { StorageMarkdown } from \"./components/StorageMarkdown\";\nimport { StringPropertyPreview } from \"./property_previews/StringPropertyPreview\";\nimport { ArrayPropertyPreview } from \"./property_previews/ArrayPropertyPreview\";\nimport { ArrayOfReferencesPreview } from \"./property_previews/ArrayOfReferencesPreview\";\nimport { ArrayOfRelationsPreview } from \"./property_previews/ArrayOfRelationsPreview\";\nimport { ArrayOfStorageComponentsPreview } from \"./property_previews/ArrayOfStorageComponentsPreview\";\nimport { ArrayPropertyEnumPreview } from \"./property_previews/ArrayPropertyEnumPreview\";\nimport { ArrayOfStringsPreview } from \"./property_previews/ArrayOfStringsPreview\";\nimport { ArrayOneOfPreview } from \"./property_previews/ArrayOneOfPreview\";\nimport { MapPropertyPreview } from \"./property_previews/MapPropertyPreview\";\nimport { ReferencePreview } from \"./components/ReferencePreview\";\nimport { DatePreview } from \"./components/DatePreview\";\nimport { BooleanPreview } from \"./components/BooleanPreview\";\nimport { NumberPropertyPreview } from \"./property_previews/NumberPropertyPreview\";\nimport { ErrorView } from \"@rebasepro/app\";\nimport { RelationPreview } from \"./components/RelationPreview\";\nimport { InlineEntityListPreview } from \"./components/InlineEntityListPreview\";\nimport { useIsNestedEntityPreview } from \"../components/EntityPreviewNesting\";\nimport { markdownToPlainText } from \"./compact_text\";\nimport { getDatePropertyMode, getDatePropertyTimezone } from \"./util\";\nimport { UserPreview } from \"./components/UserPreview\";\n\n/**\n * @group Preview components\n */\nexport const PropertyPreview = React.memo(function PropertyPreview<P extends Property>(props: PropertyPreviewProps<P>) {\n\n const authController = useAuthController();\n const customizationController = useCustomizationController();\n const nested = useIsNestedEntityPreview();\n\n let content: React.ReactNode | any;\n const {\n property: inputProperty,\n propertyKey,\n value,\n size,\n height,\n width,\n interactive,\n fill\n } = props;\n\n // A preview rendered inside an entity preview fills one line of a card and\n // has no room to grow — see {@link PropertyPreviewProps.compact}. The card\n // is the thing that knows this, and it says so by opening a nesting\n // boundary, so the depth is the signal rather than a prop every caller\n // between here and there would have to forward.\n const compact = props.compact ?? (nested || Boolean(props.textOnly));\n\n const property = resolveProperty({\n propertyKey,\n property: inputProperty,\n propertyConfigs: customizationController.propertyConfigs,\n authController\n }) as Property | null;\n\n if (property === null) {\n content = <EmptyValue/>;\n } else if (property.admin?.Preview) {\n const ResolvedPreview = resolveComponentRef(property.admin.Preview) as React.ComponentType<PropertyPreviewProps<Property>> | undefined;\n if (ResolvedPreview) {\n content = <Suspense fallback={null}>\n {createElement(ResolvedPreview,\n {\n propertyKey,\n value,\n property,\n size,\n height,\n width,\n customProps: property.admin?.customProps\n })}\n </Suspense>;\n }\n } else if (value === undefined || value === null) {\n content = <EmptyValue/>;\n } else if (property.type === \"string\") {\n const stringProperty = property as StringProperty;\n if (typeof value === \"string\") {\n if (stringProperty.storage) {\n const filePath = stringProperty.storage.previewUrl ? stringProperty.storage.previewUrl(value) : value;\n content = <StorageThumbnail\n interactive={interactive}\n storeUrl={property.storage?.storeUrl ?? false}\n storageSourceKey={stringProperty.storage.storageSource === undefined ? undefined : resourceKeyOf(stringProperty.storage.storageSource)}\n size={props.size}\n fill={fill}\n storagePathOrDownloadUrl={filePath}/>;\n } else if (stringProperty.admin?.urlPreview) {\n if (typeof stringProperty.admin?.urlPreview === \"boolean\")\n content =\n <UrlComponentPreview size={props.size}\n url={value}\n fill={fill}/>;\n else if (typeof stringProperty.admin?.urlPreview === \"string\")\n content =\n <UrlComponentPreview size={props.size}\n url={value}\n interactive={interactive}\n fill={fill}\n previewType={stringProperty.admin?.urlPreview}/>;\n } else if (stringProperty.admin?.markdown) {\n content = compact\n ? <span className={\"text-sm\"}>{markdownToPlainText(value)}</span>\n // Images stored by reference get a fresh URL here, each\n // time — the editor writes no URLs into the text.\n : <StorageMarkdown source={value} size={\"small\"}/>;\n } else if (stringProperty.userSelect) {\n content = <UserPreview\n value={value}\n property={stringProperty}\n propertyKey={propertyKey}\n size={props.size}\n />;\n } else {\n content = <StringPropertyPreview {...props}\n compact={compact}\n property={stringProperty}\n value={value}/>;\n }\n } else {\n content = buildWrongValueType(propertyKey, property.type, value);\n }\n } else if (property.type === \"array\") {\n if (Array.isArray(value)) {\n const arrayProperty = property as ArrayProperty;\n if (!arrayProperty.of && !arrayProperty.oneOf) {\n throw Error(`You need to specify an 'of' or 'oneOf' prop (or specify a custom field) in your array property ${propertyKey}`);\n }\n\n if (arrayProperty.of) {\n if (Array.isArray(arrayProperty.of)) {\n content = <ArrayPropertyPreview {...props}\n compact={compact}\n value={value}\n property={arrayProperty}/>;\n } else if (arrayProperty.of.type === \"reference\") {\n content = <ArrayOfReferencesPreview {...props}\n value={value}\n property={property}/>;\n } else if (arrayProperty.of.type === \"relation\") {\n content = <ArrayOfRelationsPreview {...props}\n value={value}\n property={property}/>;\n } else if (arrayProperty.of.type === \"string\") {\n if (arrayProperty.of.enum) {\n content = <ArrayPropertyEnumPreview\n {...props}\n value={value}\n property={property}/>;\n } else if (arrayProperty.of.storage) {\n content = <ArrayOfStorageComponentsPreview\n {...props}\n value={value}\n property={property as ArrayProperty}/>;\n } else {\n content = <ArrayOfStringsPreview\n {...props}\n compact={compact}\n property={property as ArrayProperty}\n value={value as string[]}/>;\n }\n } else if (arrayProperty.of.type === \"number\" && arrayProperty.of.enum) {\n content = <ArrayPropertyEnumPreview\n {...props}\n value={value as number[]}\n property={property as ArrayProperty}/>;\n } else {\n content = <ArrayPropertyPreview {...props}\n compact={compact}\n value={value}\n property={property as ArrayProperty}/>;\n }\n } else if (arrayProperty.oneOf) {\n content = <ArrayOneOfPreview {...props}\n compact={compact}\n value={value}\n property={property as ArrayProperty}/>;\n }\n } else {\n content = buildWrongValueType(propertyKey, property.type, value);\n }\n } else if (property.type === \"map\") {\n if (typeof value === \"object\") {\n content =\n <MapPropertyPreview {...props}\n compact={compact}\n value={value as Record<string, any>}\n property={property as MapProperty}/>;\n } else {\n content = buildWrongValueType(propertyKey, property.type, value);\n }\n } else if (property.type === \"date\") {\n // Not every caller comes through the data layer's Date coercion: the\n // revision history renders raw API payloads, where a timestamp is still\n // the string Postgres sent (`2026-06-19 17:20:33.032+02`). Requiring a\n // `Date` instance turned every audit column in every history entry into\n // a red \"Unexpected value\" box.\n const date = asDate(value);\n if (date) {\n content = <DatePreview\n date={date}\n mode={getDatePropertyMode(property)}\n timezone={getDatePropertyTimezone(property)}\n />;\n } else {\n content = buildWrongValueType(propertyKey, property.type, value);\n }\n } else if (property.type === \"reference\") {\n if (typeof property.path === \"string\") {\n if (typeof value === \"object\" && value !== null && \"isEntityReference\" in value && (value as EntityReference).isEntityReference()) {\n content = <ReferencePreview\n disabled={!property.path}\n previewProperties={property.admin?.previewProperties}\n includeId={property.admin?.includeId}\n includeEntityLink={property.admin?.includeEntityLink}\n size={props.size}\n reference={value as EntityReference}\n textOnly={props.textOnly}\n />;\n } else {\n content = buildWrongValueType(propertyKey, property.type, value);\n }\n } else {\n content = <EmptyValue/>;\n }\n\n } else if (property.type === \"relation\") {\n // A relation column arrives either hydrated or as the bare foreign key,\n // depending on the fetch path. The declared target resolves the latter;\n // see `normalizeToEntityRelation`.\n const relationTargetPath = getRelationTargetPath(property);\n if (!value) {\n content = <EmptyValue/>;\n } else if (Array.isArray(value)) {\n // Many-cardinality relation: value is an array of EntityRelation (or plain objects)\n const relations = (value as unknown[])\n .map(item => normalizeToEntityRelation(item, \"relation\", relationTargetPath))\n .filter(Boolean) as EntityRelation[];\n const renderRelation = (entityRelation: EntityRelation, index: number) => <RelationPreview\n key={`preview_rel_${propertyKey}_${index}`}\n disabled={!property.relation}\n previewProperties={property.admin?.previewProperties}\n includeId={property.admin?.includeId}\n includeEntityLink={property.admin?.includeEntityLink}\n size={\"small\"}\n relation={entityRelation}\n textOnly={props.textOnly}\n />;\n\n content = nested || props.textOnly || size === \"small\"\n // See ArrayOfReferencesPreview: nested lists stay on one line.\n ? <InlineEntityListPreview items={relations}\n renderItem={renderRelation}/>\n : (\n <div className=\"flex flex-col w-full gap-0.5\">\n {relations.map((entityRelation, index) => (\n <div className=\"w-full\"\n key={`preview_rel_wrapper_${propertyKey}_${index}`}>\n {renderRelation(entityRelation, index)}\n </div>\n ))}\n </div>\n );\n } else {\n // Single-cardinality relation\n const relationValue = normalizeToEntityRelation(value, \"relation\", relationTargetPath);\n if (relationValue) {\n content = <RelationPreview\n disabled={!property.relation}\n previewProperties={property.admin?.previewProperties}\n includeId={property.admin?.includeId}\n includeEntityLink={property.admin?.includeEntityLink}\n size={props.size}\n relation={relationValue}\n textOnly={props.textOnly}\n />;\n } else {\n content = buildWrongValueType(propertyKey, property.type, value);\n }\n }\n\n } else if (property.type === \"boolean\") {\n if (typeof value === \"boolean\") {\n content = <BooleanPreview value={value} size={size} property={property} hideLabel={props.hideLabel}/>;\n } else {\n content = buildWrongValueType(propertyKey, property.type, value);\n }\n } else if (property.type === \"number\") {\n if (typeof value === \"number\") {\n content = <NumberPropertyPreview {...props}\n value={value}\n property={property as NumberProperty}/>;\n } else {\n content = buildWrongValueType(propertyKey, property.type, value);\n }\n } else {\n content = JSON.stringify(value);\n }\n\n return content === undefined || content === null || (Array.isArray(content) && content.length === 0)\n ? <EmptyValue/>\n : content;\n}, equal);\n\n/**\n * A `Date`, or a string/number that unambiguously names one. Returns null for\n * anything else, so an actual type mismatch still reports as one.\n */\nfunction asDate(value: unknown): Date | null {\n if (value instanceof Date) return isNaN(value.getTime()) ? null : value;\n if (typeof value !== \"string\" && typeof value !== \"number\") return null;\n const parsed = new Date(value);\n return isNaN(parsed.getTime()) ? null : parsed;\n}\n\nfunction buildWrongValueType(name: string | undefined, type: string, value: any) {\n console.warn(`Unexpected value for property ${name}, of type ${type}`, value);\n return (\n <ErrorView title={\"Unexpected value\"}\n error={`${JSON.stringify(value)}`}/>\n );\n}\n"],"mappings":";;;;;;;;;;;;;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EAC1B;EACG;CAA4B,CAAA;MAE1C,UAAU,oBAAoB,aAAa,SAAS,MAAM,KAAK;MAGnE,UAAU,KAAK,UAAU,KAAK;CAGlC,OAAO,YAAY,KAAA,KAAa,YAAY,QAAS,MAAM,QAAQ,OAAO,KAAK,QAAQ,WAAW,IAC5F,oBAAC,YAAD,CAAY,CAAA,IACZ;AACV,GAAG,SAAK;;;;;AAMR,SAAS,OAAO,OAA6B;CACzC,IAAI,iBAAiB,MAAM,OAAO,MAAM,MAAM,QAAQ,CAAC,IAAI,OAAO;CAClE,IAAI,OAAO,UAAU,YAAY,OAAO,UAAU,UAAU,OAAO;CACnE,MAAM,SAAS,IAAI,KAAK,KAAK;CAC7B,OAAO,MAAM,OAAO,QAAQ,CAAC,IAAI,OAAO;AAC5C;AAEA,SAAS,oBAAoB,MAA0B,MAAc,OAAY;CAC7E,QAAQ,KAAK,iCAAiC,KAAK,YAAY,QAAQ,KAAK;CAC5E,OACI,oBAAC,WAAD;EAAW,OAAO;EACd,OAAO,GAAG,KAAK,UAAU,KAAK;CAAK,CAAA;AAE/C"}
|
|
1
|
+
{"version":3,"file":"PropertyPreview.js","names":[],"sources":["../../src/preview/PropertyPreview.tsx"],"sourcesContent":["import type { ArrayProperty, MapProperty, NumberProperty, Property, StringProperty } from \"@rebasepro/cms-types\";\nimport React, { createElement, Suspense } from \"react\";\nimport { deepEqual as equal } from \"fast-equals\"\n\nimport { resourceKeyOf } from \"@rebasepro/types\";\nimport type { PropertyPreviewProps } from \"../types/components/PropertyPreviewProps\";\nimport { resolveProperty, EntityReference, EntityRelation, normalizeToEntityRelation } from \"@rebasepro/cms-types\";\nimport { getRelationTargetPath } from \"../util/relations\";\nimport { useAuthController, useCustomizationController } from \"@rebasepro/app\";\nimport { EmptyValue } from \"./components/EmptyValue\";\nimport { UrlComponentPreview } from \"./components/UrlComponentPreview\";\nimport { StorageThumbnail } from \"./components/StorageThumbnail\";\nimport { StorageMarkdown } from \"./components/StorageMarkdown\";\nimport { StringPropertyPreview } from \"./property_previews/StringPropertyPreview\";\nimport { ArrayPropertyPreview } from \"./property_previews/ArrayPropertyPreview\";\nimport { ArrayOfReferencesPreview } from \"./property_previews/ArrayOfReferencesPreview\";\nimport { ArrayOfRelationsPreview } from \"./property_previews/ArrayOfRelationsPreview\";\nimport { ArrayOfStorageComponentsPreview } from \"./property_previews/ArrayOfStorageComponentsPreview\";\nimport { ArrayPropertyEnumPreview } from \"./property_previews/ArrayPropertyEnumPreview\";\nimport { ArrayOfStringsPreview } from \"./property_previews/ArrayOfStringsPreview\";\nimport { ArrayOneOfPreview } from \"./property_previews/ArrayOneOfPreview\";\nimport { MapPropertyPreview } from \"./property_previews/MapPropertyPreview\";\nimport { ReferencePreview } from \"./components/ReferencePreview\";\nimport { DatePreview } from \"./components/DatePreview\";\nimport { BooleanPreview } from \"./components/BooleanPreview\";\nimport { NumberPropertyPreview } from \"./property_previews/NumberPropertyPreview\";\nimport { ErrorView } from \"@rebasepro/app\";\nimport { RelationPreview } from \"./components/RelationPreview\";\nimport { InlineEntityListPreview } from \"./components/InlineEntityListPreview\";\nimport { useIsNestedEntityPreview } from \"../components/EntityPreviewNesting\";\nimport { markdownToPlainText } from \"./compact_text\";\nimport { getDatePropertyMode, getDatePropertyTimezone } from \"./util\";\nimport { UserPreview } from \"./components/UserPreview\";\n\n/**\n * @group Preview components\n */\nexport const PropertyPreview = React.memo(function PropertyPreview<P extends Property>(props: PropertyPreviewProps<P>) {\n\n const authController = useAuthController();\n const customizationController = useCustomizationController();\n const nested = useIsNestedEntityPreview();\n\n let content: React.ReactNode | any;\n const {\n property: inputProperty,\n propertyKey,\n value,\n size,\n height,\n width,\n interactive,\n fill\n } = props;\n\n // A preview rendered inside an entity preview fills one line of a card and\n // has no room to grow — see {@link PropertyPreviewProps.compact}. The card\n // is the thing that knows this, and it says so by opening a nesting\n // boundary, so the depth is the signal rather than a prop every caller\n // between here and there would have to forward.\n const compact = props.compact ?? (nested || Boolean(props.textOnly));\n\n const property = resolveProperty({\n propertyKey,\n property: inputProperty,\n propertyConfigs: customizationController.propertyConfigs,\n authController\n }) as Property | null;\n\n if (property === null) {\n content = <EmptyValue/>;\n } else if (property.admin?.Preview) {\n const ResolvedPreview: React.ComponentType<PropertyPreviewProps<Property>> = property.admin.Preview;\n if (ResolvedPreview) {\n content = <Suspense fallback={null}>\n {createElement(ResolvedPreview,\n {\n propertyKey,\n value,\n property,\n size,\n height,\n width,\n customProps: property.admin?.customProps\n })}\n </Suspense>;\n }\n } else if (value === undefined || value === null) {\n content = <EmptyValue/>;\n } else if (property.type === \"string\") {\n const stringProperty = property as StringProperty;\n if (typeof value === \"string\") {\n if (stringProperty.storage) {\n const filePath = stringProperty.storage.previewUrl ? stringProperty.storage.previewUrl(value) : value;\n content = <StorageThumbnail\n interactive={interactive}\n storeUrl={property.storage?.storeUrl ?? false}\n storageSourceKey={stringProperty.storage.storageSource === undefined ? undefined : resourceKeyOf(stringProperty.storage.storageSource)}\n size={props.size}\n fill={fill}\n storagePathOrDownloadUrl={filePath}/>;\n } else if (stringProperty.admin?.urlPreview) {\n if (typeof stringProperty.admin?.urlPreview === \"boolean\")\n content =\n <UrlComponentPreview size={props.size}\n url={value}\n fill={fill}/>;\n else if (typeof stringProperty.admin?.urlPreview === \"string\")\n content =\n <UrlComponentPreview size={props.size}\n url={value}\n interactive={interactive}\n fill={fill}\n previewType={stringProperty.admin?.urlPreview}/>;\n } else if (stringProperty.admin?.markdown) {\n content = compact\n ? <span className={\"text-sm\"}>{markdownToPlainText(value)}</span>\n // Images stored by reference get a fresh URL here, each\n // time — the editor writes no URLs into the text.\n : <StorageMarkdown source={value} size={\"small\"}/>;\n } else if (stringProperty.userSelect) {\n content = <UserPreview\n value={value}\n property={stringProperty}\n propertyKey={propertyKey}\n size={props.size}\n />;\n } else {\n content = <StringPropertyPreview {...props}\n compact={compact}\n property={stringProperty}\n value={value}/>;\n }\n } else {\n content = buildWrongValueType(propertyKey, property.type, value);\n }\n } else if (property.type === \"array\") {\n if (Array.isArray(value)) {\n const arrayProperty = property as ArrayProperty;\n if (!arrayProperty.of && !arrayProperty.oneOf) {\n throw Error(`You need to specify an 'of' or 'oneOf' prop (or specify a custom field) in your array property ${propertyKey}`);\n }\n\n if (arrayProperty.of) {\n if (Array.isArray(arrayProperty.of)) {\n content = <ArrayPropertyPreview {...props}\n compact={compact}\n value={value}\n property={arrayProperty}/>;\n } else if (arrayProperty.of.type === \"reference\") {\n content = <ArrayOfReferencesPreview {...props}\n value={value}\n property={property}/>;\n } else if (arrayProperty.of.type === \"relation\") {\n content = <ArrayOfRelationsPreview {...props}\n value={value}\n property={property}/>;\n } else if (arrayProperty.of.type === \"string\") {\n if (arrayProperty.of.enum) {\n content = <ArrayPropertyEnumPreview\n {...props}\n value={value}\n property={property}/>;\n } else if (arrayProperty.of.storage) {\n content = <ArrayOfStorageComponentsPreview\n {...props}\n value={value}\n property={property as ArrayProperty}/>;\n } else {\n content = <ArrayOfStringsPreview\n {...props}\n compact={compact}\n property={property as ArrayProperty}\n value={value as string[]}/>;\n }\n } else if (arrayProperty.of.type === \"number\" && arrayProperty.of.enum) {\n content = <ArrayPropertyEnumPreview\n {...props}\n value={value as number[]}\n property={property as ArrayProperty}/>;\n } else {\n content = <ArrayPropertyPreview {...props}\n compact={compact}\n value={value}\n property={property as ArrayProperty}/>;\n }\n } else if (arrayProperty.oneOf) {\n content = <ArrayOneOfPreview {...props}\n compact={compact}\n value={value}\n property={property as ArrayProperty}/>;\n }\n } else {\n content = buildWrongValueType(propertyKey, property.type, value);\n }\n } else if (property.type === \"map\") {\n if (typeof value === \"object\") {\n content =\n <MapPropertyPreview {...props}\n compact={compact}\n value={value as Record<string, any>}\n property={property as MapProperty}/>;\n } else {\n content = buildWrongValueType(propertyKey, property.type, value);\n }\n } else if (property.type === \"date\") {\n // Not every caller comes through the data layer's Date coercion: the\n // revision history renders raw API payloads, where a timestamp is still\n // the string Postgres sent (`2026-06-19 17:20:33.032+02`). Requiring a\n // `Date` instance turned every audit column in every history entry into\n // a red \"Unexpected value\" box.\n const date = asDate(value);\n if (date) {\n content = <DatePreview\n date={date}\n mode={getDatePropertyMode(property)}\n timezone={getDatePropertyTimezone(property)}\n />;\n } else {\n content = buildWrongValueType(propertyKey, property.type, value);\n }\n } else if (property.type === \"reference\") {\n if (typeof property.path === \"string\") {\n if (typeof value === \"object\" && value !== null && \"isEntityReference\" in value && (value as EntityReference).isEntityReference()) {\n content = <ReferencePreview\n disabled={!property.path}\n previewProperties={property.admin?.previewProperties}\n includeId={property.admin?.includeId}\n includeEntityLink={property.admin?.includeEntityLink}\n size={props.size}\n reference={value as EntityReference}\n textOnly={props.textOnly}\n />;\n } else {\n content = buildWrongValueType(propertyKey, property.type, value);\n }\n } else {\n content = <EmptyValue/>;\n }\n\n } else if (property.type === \"relation\") {\n // A relation column arrives either hydrated or as the bare foreign key,\n // depending on the fetch path. The declared target resolves the latter;\n // see `normalizeToEntityRelation`.\n const relationTargetPath = getRelationTargetPath(property);\n if (!value) {\n content = <EmptyValue/>;\n } else if (Array.isArray(value)) {\n // Many-cardinality relation: value is an array of EntityRelation (or plain objects)\n const relations = (value as unknown[])\n .map(item => normalizeToEntityRelation(item, \"relation\", relationTargetPath))\n .filter(Boolean) as EntityRelation[];\n const renderRelation = (entityRelation: EntityRelation, index: number) => <RelationPreview\n key={`preview_rel_${propertyKey}_${index}`}\n disabled={!property.relation}\n previewProperties={property.admin?.previewProperties}\n includeId={property.admin?.includeId}\n includeEntityLink={property.admin?.includeEntityLink}\n size={\"small\"}\n relation={entityRelation}\n textOnly={props.textOnly}\n />;\n\n content = nested || props.textOnly || size === \"small\"\n // See ArrayOfReferencesPreview: nested lists stay on one line.\n ? <InlineEntityListPreview items={relations}\n renderItem={renderRelation}/>\n : (\n <div className=\"flex flex-col w-full gap-0.5\">\n {relations.map((entityRelation, index) => (\n <div className=\"w-full\"\n key={`preview_rel_wrapper_${propertyKey}_${index}`}>\n {renderRelation(entityRelation, index)}\n </div>\n ))}\n </div>\n );\n } else {\n // Single-cardinality relation\n const relationValue = normalizeToEntityRelation(value, \"relation\", relationTargetPath);\n if (relationValue) {\n content = <RelationPreview\n disabled={!property.relation}\n previewProperties={property.admin?.previewProperties}\n includeId={property.admin?.includeId}\n includeEntityLink={property.admin?.includeEntityLink}\n size={props.size}\n relation={relationValue}\n textOnly={props.textOnly}\n />;\n } else {\n content = buildWrongValueType(propertyKey, property.type, value);\n }\n }\n\n } else if (property.type === \"boolean\") {\n if (typeof value === \"boolean\") {\n content = <BooleanPreview value={value} size={size} property={property} hideLabel={props.hideLabel}/>;\n } else {\n content = buildWrongValueType(propertyKey, property.type, value);\n }\n } else if (property.type === \"number\") {\n if (typeof value === \"number\") {\n content = <NumberPropertyPreview {...props}\n value={value}\n property={property as NumberProperty}/>;\n } else {\n content = buildWrongValueType(propertyKey, property.type, value);\n }\n } else {\n content = JSON.stringify(value);\n }\n\n return content === undefined || content === null || (Array.isArray(content) && content.length === 0)\n ? <EmptyValue/>\n : content;\n}, equal);\n\n/**\n * A `Date`, or a string/number that unambiguously names one. Returns null for\n * anything else, so an actual type mismatch still reports as one.\n */\nfunction asDate(value: unknown): Date | null {\n if (value instanceof Date) return isNaN(value.getTime()) ? null : value;\n if (typeof value !== \"string\" && typeof value !== \"number\") return null;\n const parsed = new Date(value);\n return isNaN(parsed.getTime()) ? null : parsed;\n}\n\nfunction buildWrongValueType(name: string | undefined, type: string, value: any) {\n console.warn(`Unexpected value for property ${name}, of type ${type}`, value);\n return (\n <ErrorView title={\"Unexpected value\"}\n error={`${JSON.stringify(value)}`}/>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqCA,IAAa,kBAAkB,MAAM,KAAK,SAAS,gBAAoC,OAAgC;CAEnH,MAAM,iBAAiB,kBAAkB;CACzC,MAAM,0BAA0B,2BAA2B;CAC3D,MAAM,SAAS,yBAAyB;CAExC,IAAI;CACJ,MAAM,EACF,UAAU,eACV,aACA,OACA,MACA,QAC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AK;;;;;AAMR,SAAS,OAAO,OAA6B;CACzC,IAAI,iBAAiB,MAAM,OAAO,MAAM,MAAM,QAAQ,CAAC,IAAI,OAAO;CAClE,IAAI,OAAO,UAAU,YAAY,OAAO,UAAU,UAAU,OAAO;CACnE,MAAM,SAAS,IAAI,KAAK,KAAK;CAC7B,OAAO,MAAM,OAAO,QAAQ,CAAC,IAAI,OAAO;AAC5C;AAEA,SAAS,oBAAoB,MAA0B,MAAc,OAAY;CAC7E,QAAQ,KAAK,iCAAiC,KAAK,YAAY,QAAQ,KAAK;CAC5E,OACI,oBAAC,WAAD;EAAW,OAAO;EACd,OAAO,GAAG,KAAK,UAAU,KAAK;CAAK,CAAA;AAE/C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ArrayEnumPreview.js","names":[],"sources":["../../../src/preview/components/ArrayEnumPreview.tsx"],"sourcesContent":["import React from \"react\";\n\nimport { EnumValueConfig } from \"@rebasepro/types\";\nimport type { PreviewSize } from \"../../types/components/PropertyPreviewProps\";\nimport { EnumValuesChip } from \"./EnumValuesChip\";\nimport { ErrorBoundary } from \"@rebasepro/ui\";\n\n/**\n * @group Preview components\n */\nexport function ArrayEnumPreview({\n name,\n value,\n enumValues,\n size\n}: {\n value: string[] | number[],\n name: string | undefined,\n enumValues: EnumValueConfig[],\n size: PreviewSize\n}) {\n\n return (\n <div className=\"flex flex-wrap gap-1.5\">\n {value && value.map((enumKey, index) => {\n return (\n <ErrorBoundary\n key={`preview_array_ref_${name}_${index}`}>\n <EnumValuesChip\n enumKey={enumKey}\n enumValues={enumValues}\n size={size !== \"medium\" ? \"small\" : \"medium\"}/>\n </ErrorBoundary>\n );\n }\n )}\n </div>\n );\n}\n"],"mappings":";;;;;;;;AAUA,SAAgB,iBAAiB,EAC7B,MACA,OACA,YACA,QAMD;CAEC,OACI,oBAAC,OAAD;EAAK,WAAU;YACV,SAAS,MAAM,KAAK,SAAS,UAAU;GACpC,OACI,oBAAC,eAAD,EAAA,UAEI,oBAAC,gBAAD;IACa;IACG;IACZ,MAAM,SAAS,WAAW,UAAU;GAAU,CAAA,EACvC,GALN,qBAAqB,KAAK,GAAG,OAKvB;EAEvB,CACA;CACC,CAAA;AAEb"}
|
|
1
|
+
{"version":3,"file":"ArrayEnumPreview.js","names":[],"sources":["../../../src/preview/components/ArrayEnumPreview.tsx"],"sourcesContent":["import React from \"react\";\n\nimport { EnumValueConfig } from \"@rebasepro/cms-types\";\nimport type { PreviewSize } from \"../../types/components/PropertyPreviewProps\";\nimport { EnumValuesChip } from \"./EnumValuesChip\";\nimport { ErrorBoundary } from \"@rebasepro/ui\";\n\n/**\n * @group Preview components\n */\nexport function ArrayEnumPreview({\n name,\n value,\n enumValues,\n size\n}: {\n value: string[] | number[],\n name: string | undefined,\n enumValues: EnumValueConfig[],\n size: PreviewSize\n}) {\n\n return (\n <div className=\"flex flex-wrap gap-1.5\">\n {value && value.map((enumKey, index) => {\n return (\n <ErrorBoundary\n key={`preview_array_ref_${name}_${index}`}>\n <EnumValuesChip\n enumKey={enumKey}\n enumValues={enumValues}\n size={size !== \"medium\" ? \"small\" : \"medium\"}/>\n </ErrorBoundary>\n );\n }\n )}\n </div>\n );\n}\n"],"mappings":";;;;;;;;AAUA,SAAgB,iBAAiB,EAC7B,MACA,OACA,YACA,QAMD;CAEC,OACI,oBAAC,OAAD;EAAK,WAAU;YACV,SAAS,MAAM,KAAK,SAAS,UAAU;GACpC,OACI,oBAAC,eAAD,EAAA,UAEI,oBAAC,gBAAD;IACa;IACG;IACZ,MAAM,SAAS,WAAW,UAAU;GAAU,CAAA,EACvC,GALN,qBAAqB,KAAK,GAAG,OAKvB;EAEvB,CACA;CACC,CAAA;AAEb"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BooleanPreview.js","names":[],"sources":["../../../src/preview/components/BooleanPreview.tsx"],"sourcesContent":["import type { Property } from \"@rebasepro/types\";\nimport React from \"react\";\nimport { Checkbox, cls } from \"@rebasepro/ui\";\nimport { PreviewSize } from \"../../types/components/PropertyPreviewProps\";\n/**\n * @group Preview components\n */\nexport function BooleanPreview({\n value,\n size,\n property,\n hideLabel\n}: {\n value: boolean,\n size: PreviewSize,\n property: Property,\n /** The caller already shows the name — see `PropertyPreviewProps.hideLabel`. */\n hideLabel?: boolean,\n}): React.ReactElement {\n return <div className={\"flex flex-row gap-2 items-center\"}>\n <Checkbox checked={value}\n padding={false}\n size={size}\n color={\"primary\"}/>\n {!hideLabel && property.name && <span\n className={cls(\"text-text-secondary dark:text-text-secondary-dark\", size === \"small\" ? \"text-sm\" : \"\")}>{property.name}</span>}\n </div>;\n}\n"],"mappings":";;;;;;;AAOA,SAAgB,eAAe,EAC3B,OACA,MACA,UACA,aAOmB;CACnB,OAAO,qBAAC,OAAD;EAAK,WAAW;YAAhB,CACH,oBAAC,UAAD;GAAU,SAAS;GACf,SAAS;GACH;GACN,OAAO;EAAW,CAAA,GACrB,CAAC,aAAa,SAAS,QAAQ,oBAAC,QAAD;GAC5B,WAAW,IAAI,qDAAqD,SAAS,UAAU,YAAY,EAAE;aAAI,SAAS;EAAW,CAAA,CAChI;;AACT"}
|
|
1
|
+
{"version":3,"file":"BooleanPreview.js","names":[],"sources":["../../../src/preview/components/BooleanPreview.tsx"],"sourcesContent":["import type { Property } from \"@rebasepro/cms-types\";\nimport React from \"react\";\nimport { Checkbox, cls } from \"@rebasepro/ui\";\nimport { PreviewSize } from \"../../types/components/PropertyPreviewProps\";\n/**\n * @group Preview components\n */\nexport function BooleanPreview({\n value,\n size,\n property,\n hideLabel\n}: {\n value: boolean,\n size: PreviewSize,\n property: Property,\n /** The caller already shows the name — see `PropertyPreviewProps.hideLabel`. */\n hideLabel?: boolean,\n}): React.ReactElement {\n return <div className={\"flex flex-row gap-2 items-center\"}>\n <Checkbox checked={value}\n padding={false}\n size={size}\n color={\"primary\"}/>\n {!hideLabel && property.name && <span\n className={cls(\"text-text-secondary dark:text-text-secondary-dark\", size === \"small\" ? \"text-sm\" : \"\")}>{property.name}</span>}\n </div>;\n}\n"],"mappings":";;;;;;;AAOA,SAAgB,eAAe,EAC3B,OACA,MACA,UACA,aAOmB;CACnB,OAAO,qBAAC,OAAD;EAAK,WAAW;YAAhB,CACH,oBAAC,UAAD;GAAU,SAAS;GACf,SAAS;GACH;GACN,OAAO;EAAW,CAAA,GACrB,CAAC,aAAa,SAAS,QAAQ,oBAAC,QAAD;GAC5B,WAAW,IAAI,qDAAqD,SAAS,UAAU,YAAY,EAAE;aAAI,SAAS;EAAW,CAAA,CAChI;;AACT"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import "react";
|
|
2
2
|
import { jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { Chip } from "@rebasepro/ui";
|
|
4
|
-
import { enumToObjectEntries, getLabelOrConfigFrom } from "@rebasepro/
|
|
4
|
+
import { enumToObjectEntries, getLabelOrConfigFrom } from "@rebasepro/cms-types";
|
|
5
5
|
import { buildEnumLabel, getColorScheme } from "@rebasepro/app";
|
|
6
6
|
//#region src/preview/components/EnumValuesChip.tsx
|
|
7
7
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EnumValuesChip.js","names":[],"sources":["../../../src/preview/components/EnumValuesChip.tsx"],"sourcesContent":["import React from \"react\";\nimport { Chip } from \"@rebasepro/ui\";\nimport {
|
|
1
|
+
{"version":3,"file":"EnumValuesChip.js","names":[],"sources":["../../../src/preview/components/EnumValuesChip.tsx"],"sourcesContent":["import React from \"react\";\nimport { Chip } from \"@rebasepro/ui\";\nimport { getLabelOrConfigFrom, enumToObjectEntries, EnumValues } from \"@rebasepro/cms-types\";\nimport { buildEnumLabel, getColorScheme } from \"@rebasepro/app\";\n\nexport interface EnumValuesChipProps {\n enumValues?: EnumValues;\n enumKey: string | number;\n size: \"small\" | \"medium\" | \"large\";\n className?: string;\n children?: React.ReactNode;\n}\n\n/**\n * @group Preview components\n */\nexport function EnumValuesChip({\n enumValues,\n enumKey,\n size,\n className,\n children\n}: EnumValuesChipProps) {\n if (!enumValues) return null;\n const enumValuesConfig = enumToObjectEntries(enumValues);\n const enumValue = enumKey !== undefined ? getLabelOrConfigFrom(enumValuesConfig, enumKey) : undefined;\n const label = buildEnumLabel(enumValue);\n const colorScheme = getColorScheme(enumValuesConfig, enumKey);\n return <Chip\n className={className}\n colorScheme={colorScheme}\n error={!label}\n outlined={false}\n size={size}>\n {children}\n {!children && (label !== undefined ? label : String(enumKey))}\n </Chip>;\n}\n"],"mappings":";;;;;;;;;AAgBA,SAAgB,eAAe,EAC3B,YACA,SACA,MACA,WACA,YACoB;CACpB,IAAI,CAAC,YAAY,OAAO;CACxB,MAAM,mBAAmB,oBAAoB,UAAU;CAEvD,MAAM,QAAQ,eADI,YAAY,KAAA,IAAY,qBAAqB,kBAAkB,OAAO,IAAI,KAAA,CACtD;CAEtC,OAAO,qBAAC,MAAD;EACQ;EACE,aAHG,eAAe,kBAAkB,OAGpC;EACb,OAAO,CAAC;EACR,UAAU;EACJ;YALH,CAMF,UACA,CAAC,aAAa,UAAU,KAAA,IAAY,QAAQ,OAAO,OAAO,EACzD;;AACV"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import { EntityReference } from "@rebasepro/types";
|
|
2
|
+
import { EntityReference } from "@rebasepro/cms-types";
|
|
3
3
|
import type { PreviewSize } from "../../types/components/PropertyPreviewProps.js";
|
|
4
4
|
export type ReferencePreviewProps = {
|
|
5
5
|
disabled?: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ReferencePreview.js","names":[],"sources":["../../../src/preview/components/ReferencePreview.tsx"],"sourcesContent":["\nimport * as React from \"react\";\nimport { DefaultMissingReference } from \"../../components/DefaultMissingReference\";\n\nimport { EntityReference } from \"@rebasepro/types\";\nimport type { PreviewSize } from \"../../types/components/PropertyPreviewProps\";\nimport { useCustomizationController, useBatchedFetch, useComponentOverride, CollectionScopeProvider } from \"@rebasepro/app\";\nimport { Skeleton } from \"@rebasepro/ui\";\nimport { ErrorBoundary } from \"@rebasepro/ui\";\nimport { ErrorView } from \"@rebasepro/app\";\nimport { EntityPreviewBinding, EntityPreviewBindingData, EntityPreviewContainer } from \"../../components/EntityPreviewBinding\";\nimport {\n InlineEntityPreview,\n InlineEntityPreviewMissing,\n InlineEntityPreviewSkeleton\n} from \"../../components/InlineEntityPreview\";\nimport { useEntityPreviewLayout, useIsNestedEntityPreview } from \"../../components/EntityPreviewNesting\";\nimport { useCollectionRegistryController } from \"../../hooks/navigation/contexts/CollectionRegistryContext\";\nimport { useReferencePaths } from \"../../hooks/useReferencePaths\";\nimport type { AdminCollection } from \"@rebasepro/cms-types\";\n\nexport type ReferencePreviewProps = {\n disabled?: boolean;\n reference: EntityReference,\n size?: PreviewSize;\n previewProperties?: string[];\n onClick?: (e: React.SyntheticEvent) => void;\n hover?: boolean;\n includeEntityLink?: boolean;\n includeId?: boolean;\n textOnly?: boolean;\n};\n\n/**\n * @group Preview components\n */\nexport const ReferencePreview = function ReferencePreview(props: ReferencePreviewProps) {\n const reference = props.reference;\n const nested = useIsNestedEntityPreview();\n if (!(typeof reference === \"object\" && \"isEntityReference\" in reference && reference.isEntityReference())) {\n console.warn(\"Reference preview received value of type\", typeof reference);\n if (props.textOnly || nested) {\n return <span>{String(reference)}</span>;\n }\n return <EntityPreviewContainer\n onClick={props.onClick}\n size={props.size ?? \"medium\"}>\n <ErrorView error={\"Unexpected value. Click to edit\"}\n tooltip={JSON.stringify(reference)}/>\n </EntityPreviewContainer>;\n }\n return <ErrorBoundary>\n <ReferencePreviewInternal {...props}/>\n </ErrorBoundary>;\n};\n\n\nfunction ReferencePreviewInternalInner({\n disabled,\n reference,\n previewProperties,\n size,\n hover,\n onClick,\n includeEntityLink = true,\n includeId = true,\n textOnly,\n path,\n collection\n}: ReferencePreviewProps & { path: string, collection?: AdminCollection }) {\n const ResolvedMissingReference = useComponentOverride(\"Entity.MissingReference\", DefaultMissingReference);\n const nested = useIsNestedEntityPreview();\n\n if (!collection) {\n if (ResolvedMissingReference !== DefaultMissingReference) {\n return <ResolvedMissingReference path={reference.path}/>;\n } else {\n if (textOnly) {\n return <span>{reference.path}</span>;\n }\n if (nested) {\n return <InlineEntityPreviewMissing label={String(reference.id)}\n tooltip={`Collection not found: ${reference.path}`}/>;\n }\n return <EntityPreviewContainer\n onClick={onClick}\n size={size ?? \"medium\"}>\n <ErrorView error={\"Unexpected reference value. Click to edit\"}\n tooltip={reference.pathWithId}/>\n </EntityPreviewContainer>;\n }\n }\n\n return <ReferencePreviewExisting\n reference={reference}\n path={path}\n collection={collection}\n previewProperties={previewProperties}\n size={size}\n disabled={disabled}\n includeEntityLink={includeEntityLink}\n includeId={includeId}\n onClick={onClick}\n textOnly={textOnly}\n hover={hover}/>\n}\n\nfunction ReferencePreviewInternal(props: ReferencePreviewProps) {\n const collectionRegistryController = useCollectionRegistryController();\n // The reference carries the path its record is stored under; the\n // collection is looked up, and the record fetched, by the admin's.\n const { toCollectionPath } = useReferencePaths();\n const path = toCollectionPath(props.reference.path, props.reference.driver);\n const collection = collectionRegistryController.getCollection(path);\n\n const content = (\n <ReferencePreviewInternalInner\n {...props}\n path={path}\n collection={collection}\n />\n );\n\n if (collection) {\n return (\n <CollectionScopeProvider collection={collection}>\n {content}\n </CollectionScopeProvider>\n );\n }\n return content;\n}\n\nfunction ReferencePreviewExisting<M extends Record<string, unknown> = Record<string, unknown>>({\n reference,\n path,\n collection,\n previewProperties,\n size,\n disabled,\n includeEntityLink,\n includeId,\n onClick,\n hover,\n textOnly\n}: ReferencePreviewProps & {\n path: string,\n collection: AdminCollection<M>\n}) {\n\n const ResolvedEntityPreview = useComponentOverride(\"EntityPreview\", EntityPreviewBinding);\n const customizationController = useCustomizationController();\n const nested = useIsNestedEntityPreview();\n const layout = useEntityPreviewLayout();\n\n // Nested inside another preview, filling a title slot, or rendered small\n // (a table cell, a list row): one line of text, not a second card. The\n // card only makes sense where there is room for it. See {@link InlineEntityPreview}.\n const inline = nested || Boolean(textOnly) || size === \"small\";\n\n // Batched with every other reference shown in the same tick: one read and\n // one live subscription for a column of 23 distinct targets, where each\n // preview used to open its own `listenById` (23 subscriptions, and 23\n // server refetches per write to the target collection). An array of\n // references in a form is one batch for the whole array.\n const {\n entity,\n dataLoading,\n dataLoadingError\n } = useBatchedFetch({\n path,\n entityId: reference.id,\n collection\n });\n\n // Only what the fetch currently reports — see the note in RelationPreview:\n // the module-level Map that used to back this kept a deleted row on screen\n // for the rest of the session, and across a sign-out.\n const usedEntity = entity;\n\n let body: React.ReactNode;\n\n if (!reference) {\n body = <ErrorView error={\"Reference not set\"}/>;\n } else if (usedEntity && !usedEntity.values) {\n body = <ErrorView error={\"Reference does not exist\"}\n tooltip={reference.path}/>;\n }\n if (body) {\n if (inline) {\n return <InlineEntityPreviewMissing label={String(reference.id)}\n tooltip={reference.pathWithId}/>;\n }\n\n return (\n <EntityPreviewContainer onClick={disabled ? undefined : onClick}\n hover={disabled ? undefined : hover}\n size={size}>\n {body}\n </EntityPreviewContainer>\n );\n }\n\n if (dataLoading && !usedEntity) {\n if (inline) {\n return <InlineEntityPreviewSkeleton/>;\n }\n return (\n <EntityPreviewContainer onClick={disabled ? undefined : onClick}\n hover={disabled ? undefined : hover}\n size={size}>\n <Skeleton/>\n </EntityPreviewContainer>\n );\n }\n\n if (!usedEntity) {\n if (inline) {\n return <InlineEntityPreviewMissing label={String(reference.id)}\n tooltip={\"Entity not found\"}/>;\n }\n return (\n <EntityPreviewContainer onClick={disabled ? undefined : onClick}\n hover={disabled ? undefined : hover}\n size={size}>\n <ErrorView error={\"Entity not found\"}/>\n </EntityPreviewContainer>\n );\n }\n\n if (inline) {\n return <InlineEntityPreview entity={usedEntity}\n collection={collection}\n disabled={disabled}\n onClick={onClick}\n // In a title slot the row itself is the click target; only a\n // preview nested inside a card opens its own side panel.\n includeEntityLink={!textOnly && includeEntityLink !== false}/>;\n }\n\n // See RelationPreview: a row of a table cell, not a card taller than it.\n if (layout === \"row\" && ResolvedEntityPreview === EntityPreviewBinding) {\n return <EntityPreviewBindingData layout={\"row\"}\n size={size}\n entity={usedEntity}\n collection={collection}\n previewKeys={previewProperties}\n includeEntityLink={!disabled && includeEntityLink !== false}/>;\n }\n\n return <ResolvedEntityPreview size={size}\n previewKeys={previewProperties}\n disabled={disabled}\n entity={usedEntity}\n collection={collection}\n onClick={onClick}\n includeEntityLink={includeEntityLink}\n includeId={includeId}\n hover={hover}/>;\n\n}\n"],"mappings":";;;;;;;;;;;;;;AAoCA,IAAa,mBAAmB,SAAS,iBAAiB,OAA8B;CACpF,MAAM,YAAY,MAAM;CACxB,MAAM,SAAS,yBAAyB;CACxC,IAAI,EAAE,OAAO,cAAc,YAAY,uBAAuB,aAAa,UAAU,kBAAkB,IAAI;EACvG,QAAQ,KAAK,4CAA4C,OAAO,SAAS;EACzE,IAAI,MAAM,YAAY,QAClB,OAAO,oBAAC,QAAD,EAAA,UAAO,OAAO,SAAS,EAAQ,CAAA;EAE1C,OAAO,oBAAC,wBAAD;GACH,SAAS,MAAM;GACf,MAAM,MAAM,QAAQ;aACpB,oBAAC,WAAD;IAAW,OAAO;IACd,SAAS,KAAK,UAAU,SAAS;GAAG,CAAA;EACpB,CAAA;CAC5B;CACA,OAAO,oBAAC,eAAD,EAAA,UACH,oBAAC,0BAAD,EAA0B,GAAI,MAAO,CAAA,EAC1B,CAAA;AACnB;AAGA,SAAS,8BAA8B,EACnC,UACA,WACA,mBACA,MACA,OACA,SACA,oBAAoB,MACpB,YAAY,MACZ,UACA,MACA,cACuE;CACvE,MAAM,2BAA2B,qBAAqB,2BAA2B,uBAAuB;CACxG,MAAM,SAAS,yBAAyB;CAExC,IAAI,CAAC,YACD,IAAI,6BAA6B,yBAC7B,OAAO,oBAAC,0BAAD,EAA0B,MAAM,UAAU,KAAM,CAAA;MACpD;EACH,IAAI,UACA,OAAO,oBAAC,QAAD,EAAA,UAAO,UAAU,KAAW,CAAA;EAEvC,IAAI,QACA,OAAO,oBAA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D;GAA4B,OAAO,OAAO,UAAU,EAAE;GACzD,SAAS,UAAU;EAAY,CAAA;EAGvC,OACI,oBAAC,wBAAD;GAAwB,SAAS,WAAW,KAAA,IAAY;GACpD,OAAO,WAAW,KAAA,IAAY;GACxB;aACL;EACmB,CAAA;CAEhC;CAEA,IAAI,eAAe,CAAC,YAAY;EAC5B,IAAI,QACA,OAAO,oBAAC,6BAAD,CAA6B,CAAA;EAExC,OACI,oBAAC,wBAAD;GAAwB,SAAS,WAAW,KAAA,IAAY;GACpD,OAAO,WAAW,KAAA,IAAY;GACxB;aACN,oBAAC,UAAD,CAAU,CAAA;EACU,CAAA;CAEhC;CAEA,IAAI,CAAC,YAAY;EACb,IAAI,QACA,OAAO,oBAAC,4BAAD;GAA4B,OAAO,OAAO,UAAU,EAAE;GACzD,SAAS;EAAoB,CAAA;EAErC,OACI,oBAAC,wBAAD;GAAwB,SAAS,WAAW,KAAA,IAAY;GACpD,OAAO,WAAW,KAAA,IAAY;GACxB;aACN,oBAAC,WAAD,EAAW,OAAO,mBAAoB,CAAA;EAClB,CAAA;CAEhC;CAEA,IAAI,QACA,OAAO,oBAAC,qBAAD;EAAqB,QAAQ;EACpB;EACF;EACD;EAGT,mBAAmB,CAAC,YAAY,sBAAsB;CAAO,CAAA;CAIrE,IAAI,WAAW,SAAS,0BAA0B,sBAC9C,OAAO,oBAAC,0BAAD;EAA0B,QAAQ;EAC/B;EACN,QAAQ;EACI;EACZ,aAAa;EACb,mBAAmB,CAAC,YAAY,sBAAsB;CAAO,CAAA;CAGrE,OAAO,oBAAC,uBAAD;EAA6B;EAChC,aAAa;EACH;EACV,QAAQ;EACI;EACH;EACU;EACR;EACJ;CAAO,CAAA;AAEtB"}
|
|
1
|
+
{"version":3,"file":"ReferencePreview.js","names":[],"sources":["../../../src/preview/components/ReferencePreview.tsx"],"sourcesContent":["\nimport * as React from \"react\";\nimport { DefaultMissingReference } from \"../../components/DefaultMissingReference\";\n\nimport { EntityReference } from \"@rebasepro/cms-types\";\nimport type { PreviewSize } from \"../../types/components/PropertyPreviewProps\";\nimport { useCustomizationController, useBatchedFetch, useComponentOverride, CollectionScopeProvider } from \"@rebasepro/app\";\nimport { Skeleton } from \"@rebasepro/ui\";\nimport { ErrorBoundary } from \"@rebasepro/ui\";\nimport { ErrorView } from \"@rebasepro/app\";\nimport { EntityPreviewBinding, EntityPreviewBindingData, EntityPreviewContainer } from \"../../components/EntityPreviewBinding\";\nimport {\n InlineEntityPreview,\n InlineEntityPreviewMissing,\n InlineEntityPreviewSkeleton\n} from \"../../components/InlineEntityPreview\";\nimport { useEntityPreviewLayout, useIsNestedEntityPreview } from \"../../components/EntityPreviewNesting\";\nimport { useCollectionRegistryController } from \"../../hooks/navigation/contexts/CollectionRegistryContext\";\nimport { useReferencePaths } from \"../../hooks/useReferencePaths\";\nimport type { AdminCollection } from \"@rebasepro/cms-types\";\n\nexport type ReferencePreviewProps = {\n disabled?: boolean;\n reference: EntityReference,\n size?: PreviewSize;\n previewProperties?: string[];\n onClick?: (e: React.SyntheticEvent) => void;\n hover?: boolean;\n includeEntityLink?: boolean;\n includeId?: boolean;\n textOnly?: boolean;\n};\n\n/**\n * @group Preview components\n */\nexport const ReferencePreview = function ReferencePreview(props: ReferencePreviewProps) {\n const reference = props.reference;\n const nested = useIsNestedEntityPreview();\n if (!(typeof reference === \"object\" && \"isEntityReference\" in reference && reference.isEntityReference())) {\n console.warn(\"Reference preview received value of type\", typeof reference);\n if (props.textOnly || nested) {\n return <span>{String(reference)}</span>;\n }\n return <EntityPreviewContainer\n onClick={props.onClick}\n size={props.size ?? \"medium\"}>\n <ErrorView error={\"Unexpected value. Click to edit\"}\n tooltip={JSON.stringify(reference)}/>\n </EntityPreviewContainer>;\n }\n return <ErrorBoundary>\n <ReferencePreviewInternal {...props}/>\n </ErrorBoundary>;\n};\n\n\nfunction ReferencePreviewInternalInner({\n disabled,\n reference,\n previewProperties,\n size,\n hover,\n onClick,\n includeEntityLink = true,\n includeId = true,\n textOnly,\n path,\n collection\n}: ReferencePreviewProps & { path: string, collection?: AdminCollection }) {\n const ResolvedMissingReference = useComponentOverride(\"Entity.MissingReference\", DefaultMissingReference);\n const nested = useIsNestedEntityPreview();\n\n if (!collection) {\n if (ResolvedMissingReference !== DefaultMissingReference) {\n return <ResolvedMissingReference path={reference.path}/>;\n } else {\n if (textOnly) {\n return <span>{reference.path}</span>;\n }\n if (nested) {\n return <InlineEntityPreviewMissing label={String(reference.id)}\n tooltip={`Collection not found: ${reference.path}`}/>;\n }\n return <EntityPreviewContainer\n onClick={onClick}\n size={size ?? \"medium\"}>\n <ErrorView error={\"Unexpected reference value. Click to edit\"}\n tooltip={reference.pathWithId}/>\n </EntityPreviewContainer>;\n }\n }\n\n return <ReferencePreviewExisting\n reference={reference}\n path={path}\n collection={collection}\n previewProperties={previewProperties}\n size={size}\n disabled={disabled}\n includeEntityLink={includeEntityLink}\n includeId={includeId}\n onClick={onClick}\n textOnly={textOnly}\n hover={hover}/>\n}\n\nfunction ReferencePreviewInternal(props: ReferencePreviewProps) {\n const collectionRegistryController = useCollectionRegistryController();\n // The reference carries the path its record is stored under; the\n // collection is looked up, and the record fetched, by the admin's.\n const { toCollectionPath } = useReferencePaths();\n const path = toCollectionPath(props.reference.path, props.reference.driver);\n const collection = collectionRegistryController.getCollection(path);\n\n const content = (\n <ReferencePreviewInternalInner\n {...props}\n path={path}\n collection={collection}\n />\n );\n\n if (collection) {\n return (\n <CollectionScopeProvider collection={collection}>\n {content}\n </CollectionScopeProvider>\n );\n }\n return content;\n}\n\nfunction ReferencePreviewExisting<M extends Record<string, unknown> = Record<string, unknown>>({\n reference,\n path,\n collection,\n previewProperties,\n size,\n disabled,\n includeEntityLink,\n includeId,\n onClick,\n hover,\n textOnly\n}: ReferencePreviewProps & {\n path: string,\n collection: AdminCollection<M>\n}) {\n\n const ResolvedEntityPreview = useComponentOverride(\"EntityPreview\", EntityPreviewBinding);\n const customizationController = useCustomizationController();\n const nested = useIsNestedEntityPreview();\n const layout = useEntityPreviewLayout();\n\n // Nested inside another preview, filling a title slot, or rendered small\n // (a table cell, a list row): one line of text, not a second card. The\n // card only makes sense where there is room for it. See {@link InlineEntityPreview}.\n const inline = nested || Boolean(textOnly) || size === \"small\";\n\n // Batched with every other reference shown in the same tick: one read and\n // one live subscription for a column of 23 distinct targets, where each\n // preview used to open its own `listenById` (23 subscriptions, and 23\n // server refetches per write to the target collection). An array of\n // references in a form is one batch for the whole array.\n const {\n entity,\n dataLoading,\n dataLoadingError\n } = useBatchedFetch({\n path,\n entityId: reference.id,\n collection\n });\n\n // Only what the fetch currently reports — see the note in RelationPreview:\n // the module-level Map that used to back this kept a deleted row on screen\n // for the rest of the session, and across a sign-out.\n const usedEntity = entity;\n\n let body: React.ReactNode;\n\n if (!reference) {\n body = <ErrorView error={\"Reference not set\"}/>;\n } else if (usedEntity && !usedEntity.values) {\n body = <ErrorView error={\"Reference does not exist\"}\n tooltip={reference.path}/>;\n }\n if (body) {\n if (inline) {\n return <InlineEntityPreviewMissing label={String(reference.id)}\n tooltip={reference.pathWithId}/>;\n }\n\n return (\n <EntityPreviewContainer onClick={disabled ? undefined : onClick}\n hover={disabled ? undefined : hover}\n size={size}>\n {body}\n </EntityPreviewContainer>\n );\n }\n\n if (dataLoading && !usedEntity) {\n if (inline) {\n return <InlineEntityPreviewSkeleton/>;\n }\n return (\n <EntityPreviewContainer onClick={disabled ? undefined : onClick}\n hover={disabled ? undefined : hover}\n size={size}>\n <Skeleton/>\n </EntityPreviewContainer>\n );\n }\n\n if (!usedEntity) {\n if (inline) {\n return <InlineEntityPreviewMissing label={String(reference.id)}\n tooltip={\"Entity not found\"}/>;\n }\n return (\n <EntityPreviewContainer onClick={disabled ? undefined : onClick}\n hover={disabled ? undefined : hover}\n size={size}>\n <ErrorView error={\"Entity not found\"}/>\n </EntityPreviewContainer>\n );\n }\n\n if (inline) {\n return <InlineEntityPreview entity={usedEntity}\n collection={collection}\n disabled={disabled}\n onClick={onClick}\n // In a title slot the row itself is the click target; only a\n // preview nested inside a card opens its own side panel.\n includeEntityLink={!textOnly && includeEntityLink !== false}/>;\n }\n\n // See RelationPreview: a row of a table cell, not a card taller than it.\n if (layout === \"row\" && ResolvedEntityPreview === EntityPreviewBinding) {\n return <EntityPreviewBindingData layout={\"row\"}\n size={size}\n entity={usedEntity}\n collection={collection}\n previewKeys={previewProperties}\n includeEntityLink={!disabled && includeEntityLink !== false}/>;\n }\n\n return <ResolvedEntityPreview size={size}\n previewKeys={previewProperties}\n disabled={disabled}\n entity={usedEntity}\n collection={collection}\n onClick={onClick}\n includeEntityLink={includeEntityLink}\n includeId={includeId}\n hover={hover}/>;\n\n}\n"],"mappings":";;;;;;;;;;;;;;AAoCA,IAAa,mBAAmB,SAAS,iBAAiB,OAA8B;CACpF,MAAM,YAAY,MAAM;CACxB,MAAM,SAAS,yBAAyB;CACxC,IAAI,EAAE,OAAO,cAAc,YAAY,uBAAuB,aAAa,UAAU,kBAAkB,IAAI;EACvG,QAAQ,KAAK,4CAA4C,OAAO,SAAS;EACzE,IAAI,MAAM,YAAY,QAClB,OAAO,oBAAC,QAAD,EAAA,UAAO,OAAO,SAAS,EAAQ,CAAA;EAE1C,OAAO,oBAAC,wBAAD;GACH,SAAS,MAAM;GACf,MAAM,MAAM,QAAQ;aACpB,oBAAC,WAAD;IAAW,OAAO;IACd,SAAS,KAAK,UAAU,SAAS;GAAG,CAAA;EACpB,CAAA;CAC5B;CACA,OAAO,oBAAC,eAAD,EAAA,UACH,oBAAC,0BAAD,EAA0B,GAAI,MAAO,CAAA,EAC1B,CAAA;AACnB;AAGA,SAAS,8BAA8B,EACnC,UACA,WACA,mBACA,MACA,OACA,SACA,oBAAoB,MACpB,YAAY,MACZ,UACA,MACA,cACuE;CACvE,MAAM,2BAA2B,qBAAqB,2BAA2B,uBAAuB;CACxG,MAAM,SAAS,yBAAyB;CAExC,IAAI,CAAC,YACD,IAAI,6BAA6B,yBAC7B,OAAO,oBAAC,0BAAD,EAA0B,MAAM,UA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
|
-
import { EntityRelation } from "@rebasepro/types";
|
|
2
|
+
import { EntityRelation } from "@rebasepro/cms-types";
|
|
3
3
|
import type { PreviewSize } from "../../types/components/PropertyPreviewProps.js";
|
|
4
4
|
export type RelationPreviewProps = {
|
|
5
5
|
disabled?: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RelationPreview.js","names":[],"sources":["../../../src/preview/components/RelationPreview.tsx"],"sourcesContent":["\nimport * as React from \"react\";\nimport { DefaultMissingReference } from \"../../components/DefaultMissingReference\";\n\nimport { Entity, EntityRelation } from \"@rebasepro/types\";\nimport type { PreviewSize } from \"../../types/components/PropertyPreviewProps\";\nimport { useCustomizationController, useFetch, ErrorView, useComponentOverride, CollectionScopeProvider } from \"@rebasepro/app\";\nimport { Skeleton } from \"@rebasepro/ui\";\nimport { EntityPreviewBinding, EntityPreviewBindingData, EntityPreviewBindingSkeleton, EntityPreviewContainer } from \"../../components/EntityPreviewBinding\";\nimport {\n InlineEntityPreview,\n InlineEntityPreviewMissing,\n InlineEntityPreviewSkeleton\n} from \"../../components/InlineEntityPreview\";\nimport { useEntityPreviewLayout, useIsNestedEntityPreview } from \"../../components/EntityPreviewNesting\";\nimport { useCollectionRegistryController } from \"../../hooks/navigation/contexts/CollectionRegistryContext\";\nimport type { AdminCollection } from \"@rebasepro/cms-types\";\n\nexport type RelationPreviewProps = {\n disabled?: boolean;\n relation: EntityRelation,\n size?: PreviewSize;\n previewProperties?: string[];\n onClick?: (e: React.SyntheticEvent) => void;\n hover?: boolean;\n includeEntityLink?: boolean;\n includeId?: boolean;\n textOnly?: boolean;\n};\n\n/**\n * Extract a display name from a plain relation-shaped object that isn't\n * a proper EntityRelation instance. Tries common name fields in the\n * entity's values, then falls back to the id.\n */\nfunction extractDisplayFromPlainObject(obj: unknown): string {\n if (!obj || typeof obj !== \"object\") return \"—\";\n const record = obj as Record<string, unknown>;\n\n // Try data.values.{name,title,...} (EntityRelation.data is a Entity with .values)\n const data = record.data;\n if (data && typeof data === \"object\") {\n const dataRecord = data as Record<string, unknown>;\n const values = (dataRecord.values && typeof dataRecord.values === \"object\")\n ? dataRecord.values as Record<string, unknown>\n : dataRecord;\n const nameFields = [\"name\", \"title\", \"label\", \"display_name\", \"displayName\", \"email\", \"username\"];\n for (const field of nameFields) {\n const v = values[field];\n if (v && typeof v === \"string\") return v;\n }\n }\n\n // Try direct fields on the object itself (some serialization paths flatten the data)\n const directFields = [\"name\", \"title\", \"label\", \"display_name\", \"displayName\", \"email\"];\n for (const field of directFields) {\n const v = record[field];\n if (v && typeof v === \"string\") return v;\n }\n\n // Last resort: show the id\n if (\"id\" in record && record.id != null) return String(record.id);\n\n return \"—\";\n}\n\n/**\n * @group Preview components\n */\nexport const RelationPreview = function RelationPreview(props: RelationPreviewProps) {\n const relation = props.relation;\n const nested = useIsNestedEntityPreview();\n if (!(typeof relation === \"object\" && \"isEntityRelation\" in relation && relation.isEntityRelation())) {\n console.warn(\"Relation preview received value of type\", typeof relation);\n if (props.textOnly || nested) {\n const display = extractDisplayFromPlainObject(relation);\n return <span className=\"truncate\">{display}</span>;\n }\n return <EntityPreviewContainer\n onClick={props.onClick}\n size={props.size}>\n <ErrorView error={\"Unexpected value. Click to edit\"}\n tooltip={JSON.stringify(relation)}/>\n </EntityPreviewContainer>;\n }\n return <RelationPreviewInternal {...props}/>;\n};\n\n\nfunction RelationPreviewInternalInner({\n disabled,\n relation,\n previewProperties,\n size,\n hover,\n onClick,\n includeEntityLink = true,\n includeId = true,\n textOnly,\n collection\n}: RelationPreviewProps & { collection?: AdminCollection }) {\n const ResolvedMissingReference = useComponentOverride(\"Entity.MissingReference\", DefaultMissingReference);\n const nested = useIsNestedEntityPreview();\n\n if (!collection) {\n if (ResolvedMissingReference !== DefaultMissingReference) {\n return <ResolvedMissingReference path={relation.path}/>;\n } else {\n if (textOnly) {\n return <span>{relation.path}</span>;\n }\n if (nested) {\n return <InlineEntityPreviewMissing label={String(relation.id)}\n tooltip={`Collection not found: ${relation.path}`}/>;\n }\n return <EntityPreviewContainer size={size}>\n <ErrorView error={`Collection not found: ${relation.path}`}/>\n </EntityPreviewContainer>;\n }\n }\n\n return <RelationPreviewExisting\n relation={relation}\n collection={collection}\n previewProperties={previewProperties}\n size={size}\n disabled={disabled}\n includeEntityLink={includeEntityLink}\n includeId={includeId}\n onClick={onClick}\n textOnly={textOnly}\n hover={hover}/>\n}\n\nfunction RelationPreviewInternal(props: RelationPreviewProps) {\n const collectionRegistryController = useCollectionRegistryController();\n const collection = collectionRegistryController.getCollection(props.relation.path);\n\n const content = (\n <RelationPreviewInternalInner\n {...props}\n collection={collection}\n />\n );\n\n if (collection) {\n return (\n <CollectionScopeProvider collection={collection}>\n {content}\n </CollectionScopeProvider>\n );\n }\n return content;\n}\n\nfunction RelationPreviewExisting<M extends Record<string, unknown> = Record<string, unknown>>({\n relation,\n collection,\n previewProperties,\n size,\n disabled,\n includeEntityLink,\n includeId,\n onClick,\n hover,\n textOnly\n}: RelationPreviewProps & {\n collection: AdminCollection<M>\n}) {\n\n // admin wire format embeds relation data as { id, path, values }\n const passedEntity = relation.data as Entity<M> | undefined;\n const ResolvedEntityPreview = useComponentOverride(\"EntityPreview\", EntityPreviewBinding);\n const customizationController = useCustomizationController();\n const nested = useIsNestedEntityPreview();\n const layout = useEntityPreviewLayout();\n\n // Nested inside another preview, filling a title slot, or rendered small\n // (a table cell, a list row): one line of text, not a second card. The\n // card only makes sense where there is room for it. See {@link InlineEntityPreview}.\n const inline = nested || Boolean(textOnly) || size === \"small\";\n\n const {\n entity,\n dataLoading,\n dataLoadingError\n } = useFetch({\n path: relation.path,\n entityId: passedEntity ? undefined : relation.id,\n collection,\n useCache: true\n });\n\n // Only what the fetch currently reports. There used to be a module-level\n // Map behind this, written on every successful fetch and never invalidated:\n // when the target row was deleted `useFetch` correctly reported it gone and\n // the card carried on rendering the copy in the Map, so the \"missing\"\n // branches below were unreachable for anything previewed this session — and\n // the Map outlived a sign-out. `useFetch` keeps its own cache, seeds the\n // first render from it, and clears the entry when the row disappears.\n const usedEntity = passedEntity ?? entity;\n\n let body: React.ReactNode;\n\n if (!relation) {\n body = <ErrorView error={\"Relation not set\"}/>;\n } else if (usedEntity && !usedEntity.values) {\n body = <ErrorView error={\"Relation does not exist\"}\n tooltip={relation.path}/>;\n }\n\n if (body) {\n if (inline) {\n return <InlineEntityPreviewMissing label={String(relation.id)}\n tooltip={relation.pathWithId}/>;\n }\n return (\n <EntityPreviewContainer onClick={disabled ? undefined : onClick}\n hover={disabled ? undefined : hover}\n size={size}>\n {body}\n </EntityPreviewContainer>\n );\n }\n\n if (dataLoading && !usedEntity) {\n if (inline) {\n return <InlineEntityPreviewSkeleton/>;\n }\n // The card it will be, so it does not grow when the record arrives;\n // an overridden preview or a table row is the developer's own shape,\n // and the bar stands in for it as before.\n const asCard = layout !== \"row\" && ResolvedEntityPreview === EntityPreviewBinding;\n return (\n <EntityPreviewContainer onClick={disabled ? undefined : onClick}\n hover={disabled ? undefined : hover}\n size={size}>\n {asCard\n ? <EntityPreviewBindingSkeleton collection={collection}\n previewKeys={previewProperties}\n size={size}\n includeEntityLink={includeEntityLink}/>\n : <Skeleton/>}\n </EntityPreviewContainer>\n );\n }\n\n if (!usedEntity) {\n if (inline) {\n return <InlineEntityPreviewMissing label={String(relation.id)}\n tooltip={\"Entity not found\"}/>;\n }\n return (\n <EntityPreviewContainer onClick={disabled ? undefined : onClick}\n hover={disabled ? undefined : hover}\n size={size}>\n <ErrorView error={\"Entity not found\"}/>\n </EntityPreviewContainer>\n );\n }\n\n if (inline) {\n return <InlineEntityPreview entity={usedEntity}\n collection={collection}\n disabled={disabled}\n onClick={onClick}\n // In a title slot the row itself is the click target; only a\n // preview nested inside a card opens its own side panel.\n includeEntityLink={!textOnly && includeEntityLink !== false}/>;\n }\n\n // A table cell tall enough for more than a line: the record as a row of\n // it, not a card taller than the row. An overridden preview is the\n // developer's own and is drawn as given.\n if (layout === \"row\" && ResolvedEntityPreview === EntityPreviewBinding) {\n return <EntityPreviewBindingData layout={\"row\"}\n size={size}\n entity={usedEntity}\n collection={collection}\n previewKeys={previewProperties}\n includeEntityLink={!disabled && includeEntityLink !== false}/>;\n }\n\n return <ResolvedEntityPreview size={size}\n previewKeys={previewProperties}\n disabled={disabled}\n entity={usedEntity}\n collection={collection}\n onClick={onClick}\n includeEntityLink={includeEntityLink}\n includeId={false}\n hover={hover}/>;\n\n}\n"],"mappings":";;;;;;;;;;;;;;;AAmCA,SAAS,8BAA8B,KAAsB;CACzD,IAAI,CAAC,OAAO,OAAO,QAAQ,UAAU,OAAO;CAC5C,MAAM,SAAS;CAGf,MAAM,OAAO,OAAO;CACpB,IAAI,QAAQ,OAAO,SAAS,UAAU;EAClC,MAAM,aAAa;EACnB,MAAM,SAAU,WAAW,UAAU,OAAO,WAAW,WAAW,WAC5D,WAAW,SACX;EAEN,KAAK,MAAM,SAAS;GADA;GAAQ;GAAS;GAAS;GAAgB;GAAe;GAAS;EAClE,GAAY;GAC5B,MAAM,IAAI,OAAO;GACjB,IAAI,KAAK,OAAO,MAAM,UAAU,OAAO;EAC3C;CACJ;CAIA,KAAK,MAAM,SAAS;EADE;EAAQ;EAAS;EAAS;EAAgB;EAAe;CAC3D,GAAc;EAC9B,MAAM,IAAI,OAAO;EACjB,IAAI,KAAK,OAAO,MAAM,UAAU,OAAO;CAC3C;CAGA,IAAI,QAAQ,UAAU,OAAO,MAAM,MAAM,OAAO,OAAO,OAAO,EAAE;CAEhE,OAAO;AACX;;;;AAKA,IAAa,kBAAkB,SAAS,gBAAgB,OAA6B;CACjF,MAAM,WAAW,MAAM;CACvB,MAAM,SAAS,yBAAyB;CACxC,IAAI,EAAE,OAAO,aAAa,YAAY,sBAAsB,YAAY,SAAS,iBAAiB,IAAI;EAClG,QAAQ,KAAK,2CAA2C,OAAO,QAAQ;EACvE,IAAI,MAAM,YAAY,QAElB,OAAO,oBAAC,QAAD;GAAM,WAAU;aADP,8BAA8B,QACX;EAAc,CAAA;EAErD,OAAO,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OAAO,mBAAoB,CAAA;EAClB,CAAA;CAEhC;CAEA,IAAI,QACA,OAAO,oBAAC,qBAAD;EAAqB,QAAQ;EACpB;EACF;EACD;EAGT,mBAAmB,CAAC,YAAY,sBAAsB;CAAO,CAAA;CAMrE,IAAI,WAAW,SAAS,0BAA0B,sBAC9C,OAAO,oBAAC,0BAAD;EAA0B,QAAQ;EAC/B;EACN,QAAQ;EACI;EACZ,aAAa;EACb,mBAAmB,CAAC,YAAY,sBAAsB;CAAO,CAAA;CAGrE,OAAO,oBAAC,uBAAD;EAA6B;EAChC,aAAa;EACH;EACV,QAAQ;EACI;EACH;EACU;EACnB,WAAW;EACJ;CAAO,CAAA;AAEtB"}
|
|
1
|
+
{"version":3,"file":"RelationPreview.js","names":[],"sources":["../../../src/preview/components/RelationPreview.tsx"],"sourcesContent":["\nimport * as React from \"react\";\nimport { DefaultMissingReference } from \"../../components/DefaultMissingReference\";\n\nimport { EntityRelation, Entity } from \"@rebasepro/cms-types\";\nimport type { PreviewSize } from \"../../types/components/PropertyPreviewProps\";\nimport { useCustomizationController, useFetch, ErrorView, useComponentOverride, CollectionScopeProvider } from \"@rebasepro/app\";\nimport { Skeleton } from \"@rebasepro/ui\";\nimport { EntityPreviewBinding, EntityPreviewBindingData, EntityPreviewBindingSkeleton, EntityPreviewContainer } from \"../../components/EntityPreviewBinding\";\nimport {\n InlineEntityPreview,\n InlineEntityPreviewMissing,\n InlineEntityPreviewSkeleton\n} from \"../../components/InlineEntityPreview\";\nimport { useEntityPreviewLayout, useIsNestedEntityPreview } from \"../../components/EntityPreviewNesting\";\nimport { useCollectionRegistryController } from \"../../hooks/navigation/contexts/CollectionRegistryContext\";\nimport type { AdminCollection } from \"@rebasepro/cms-types\";\n\nexport type RelationPreviewProps = {\n disabled?: boolean;\n relation: EntityRelation,\n size?: PreviewSize;\n previewProperties?: string[];\n onClick?: (e: React.SyntheticEvent) => void;\n hover?: boolean;\n includeEntityLink?: boolean;\n includeId?: boolean;\n textOnly?: boolean;\n};\n\n/**\n * Extract a display name from a plain relation-shaped object that isn't\n * a proper EntityRelation instance. Tries common name fields in the\n * entity's values, then falls back to the id.\n */\nfunction extractDisplayFromPlainObject(obj: unknown): string {\n if (!obj || typeof obj !== \"object\") return \"—\";\n const record = obj as Record<string, unknown>;\n\n // Try data.values.{name,title,...} (EntityRelation.data is a Entity with .values)\n const data = record.data;\n if (data && typeof data === \"object\") {\n const dataRecord = data as Record<string, unknown>;\n const values = (dataRecord.values && typeof dataRecord.values === \"object\")\n ? dataRecord.values as Record<string, unknown>\n : dataRecord;\n const nameFields = [\"name\", \"title\", \"label\", \"display_name\", \"displayName\", \"email\", \"username\"];\n for (const field of nameFields) {\n const v = values[field];\n if (v && typeof v === \"string\") return v;\n }\n }\n\n // Try direct fields on the object itself (some serialization paths flatten the data)\n const directFields = [\"name\", \"title\", \"label\", \"display_name\", \"displayName\", \"email\"];\n for (const field of directFields) {\n const v = record[field];\n if (v && typeof v === \"string\") return v;\n }\n\n // Last resort: show the id\n if (\"id\" in record && record.id != null) return String(record.id);\n\n return \"—\";\n}\n\n/**\n * @group Preview components\n */\nexport const RelationPreview = function RelationPreview(props: RelationPreviewProps) {\n const relation = props.relation;\n const nested = useIsNestedEntityPreview();\n if (!(typeof relation === \"object\" && \"isEntityRelation\" in relation && relation.isEntityRelation())) {\n console.warn(\"Relation preview received value of type\", typeof relation);\n if (props.textOnly || nested) {\n const display = extractDisplayFromPlainObject(relation);\n return <span className=\"truncate\">{display}</span>;\n }\n return <EntityPreviewContainer\n onClick={props.onClick}\n size={props.size}>\n <ErrorView error={\"Unexpected value. Click to edit\"}\n tooltip={JSON.stringify(relation)}/>\n </EntityPreviewContainer>;\n }\n return <RelationPreviewInternal {...props}/>;\n};\n\n\nfunction RelationPreviewInternalInner({\n disabled,\n relation,\n previewProperties,\n size,\n hover,\n onClick,\n includeEntityLink = true,\n includeId = true,\n textOnly,\n collection\n}: RelationPreviewProps & { collection?: AdminCollection }) {\n const ResolvedMissingReference = useComponentOverride(\"Entity.MissingReference\", DefaultMissingReference);\n const nested = useIsNestedEntityPreview();\n\n if (!collection) {\n if (ResolvedMissingReference !== DefaultMissingReference) {\n return <ResolvedMissingReference path={relation.path}/>;\n } else {\n if (textOnly) {\n return <span>{relation.path}</span>;\n }\n if (nested) {\n return <InlineEntityPreviewMissing label={String(relation.id)}\n tooltip={`Collection not found: ${relation.path}`}/>;\n }\n return <EntityPreviewContainer size={size}>\n <ErrorView error={`Collection not found: ${relation.path}`}/>\n </EntityPreviewContainer>;\n }\n }\n\n return <RelationPreviewExisting\n relation={relation}\n collection={collection}\n previewProperties={previewProperties}\n size={size}\n disabled={disabled}\n includeEntityLink={includeEntityLink}\n includeId={includeId}\n onClick={onClick}\n textOnly={textOnly}\n hover={hover}/>\n}\n\nfunction RelationPreviewInternal(props: RelationPreviewProps) {\n const collectionRegistryController = useCollectionRegistryController();\n const collection = collectionRegistryController.getCollection(props.relation.path);\n\n const content = (\n <RelationPreviewInternalInner\n {...props}\n collection={collection}\n />\n );\n\n if (collection) {\n return (\n <CollectionScopeProvider collection={collection}>\n {content}\n </CollectionScopeProvider>\n );\n }\n return content;\n}\n\nfunction RelationPreviewExisting<M extends Record<string, unknown> = Record<string, unknown>>({\n relation,\n collection,\n previewProperties,\n size,\n disabled,\n includeEntityLink,\n includeId,\n onClick,\n hover,\n textOnly\n}: RelationPreviewProps & {\n collection: AdminCollection<M>\n}) {\n\n // admin wire format embeds relation data as { id, path, values }\n const passedEntity = relation.data as Entity<M> | undefined;\n const ResolvedEntityPreview = useComponentOverride(\"EntityPreview\", EntityPreviewBinding);\n const customizationController = useCustomizationController();\n const nested = useIsNestedEntityPreview();\n const layout = useEntityPreviewLayout();\n\n // Nested inside another preview, filling a title slot, or rendered small\n // (a table cell, a list row): one line of text, not a second card. The\n // card only makes sense where there is room for it. See {@link InlineEntityPreview}.\n const inline = nested || Boolean(textOnly) || size === \"small\";\n\n const {\n entity,\n dataLoading,\n dataLoadingError\n } = useFetch({\n path: relation.path,\n entityId: passedEntity ? undefined : relation.id,\n collection,\n useCache: true\n });\n\n // Only what the fetch currently reports. There used to be a module-level\n // Map behind this, written on every successful fetch and never invalidated:\n // when the target row was deleted `useFetch` correctly reported it gone and\n // the card carried on rendering the copy in the Map, so the \"missing\"\n // branches below were unreachable for anything previewed this session — and\n // the Map outlived a sign-out. `useFetch` keeps its own cache, seeds the\n // first render from it, and clears the entry when the row disappears.\n const usedEntity = passedEntity ?? entity;\n\n let body: React.ReactNode;\n\n if (!relation) {\n body = <ErrorView error={\"Relation not set\"}/>;\n } else if (usedEntity && !usedEntity.values) {\n body = <ErrorView error={\"Relation does not exist\"}\n tooltip={relation.path}/>;\n }\n\n if (body) {\n if (inline) {\n return <InlineEntityPreviewMissing label={String(relation.id)}\n tooltip={relation.pathWithId}/>;\n }\n return (\n <EntityPreviewContainer onClick={disabled ? undefined : onClick}\n hover={disabled ? undefined : hover}\n size={size}>\n {body}\n </EntityPreviewContainer>\n );\n }\n\n if (dataLoading && !usedEntity) {\n if (inline) {\n return <InlineEntityPreviewSkeleton/>;\n }\n // The card it will be, so it does not grow when the record arrives;\n // an overridden preview or a table row is the developer's own shape,\n // and the bar stands in for it as before.\n const asCard = layout !== \"row\" && ResolvedEntityPreview === EntityPreviewBinding;\n return (\n <EntityPreviewContainer onClick={disabled ? undefined : onClick}\n hover={disabled ? undefined : hover}\n size={size}>\n {asCard\n ? <EntityPreviewBindingSkeleton collection={collection}\n previewKeys={previewProperties}\n size={size}\n includeEntityLink={includeEntityLink}/>\n : <Skeleton/>}\n </EntityPreviewContainer>\n );\n }\n\n if (!usedEntity) {\n if (inline) {\n return <InlineEntityPreviewMissing label={String(relation.id)}\n tooltip={\"Entity not found\"}/>;\n }\n return (\n <EntityPreviewContainer onClick={disabled ? undefined : onClick}\n hover={disabled ? undefined : hover}\n size={size}>\n <ErrorView error={\"Entity not found\"}/>\n </EntityPreviewContainer>\n );\n }\n\n if (inline) {\n return <InlineEntityPreview entity={usedEntity}\n collection={collection}\n disabled={disabled}\n onClick={onClick}\n // In a title slot the row itself is the click target; only a\n // preview nested inside a card opens its own side panel.\n includeEntityLink={!textOnly && includeEntityLink !== false}/>;\n }\n\n // A table cell tall enough for more than a line: the record as a row of\n // it, not a card taller than the row. An overridden preview is the\n // developer's own and is drawn as given.\n if (layout === \"row\" && ResolvedEntityPreview === EntityPreviewBinding) {\n return <EntityPreviewBindingData layout={\"row\"}\n size={size}\n entity={usedEntity}\n collection={collection}\n previewKeys={previewProperties}\n includeEntityLink={!disabled && includeEntityLink !== false}/>;\n }\n\n return <ResolvedEntityPreview size={size}\n previewKeys={previewProperties}\n disabled={disabled}\n entity={usedEntity}\n collection={collection}\n onClick={onClick}\n includeEntityLink={includeEntityLink}\n includeId={false}\n hover={hover}/>;\n\n}\n"],"mappings":";;;;;;;;;;;;;;;AAmCA,SAAS,8BAA8B,KAAsB;CACzD,IAAI,CAAC,OAAO,OAAO,QAAQ,UAAU,OAAO;CAC5C,MAAM,SAAS;CAGf,MAAM,OAAO,OAAO;CACpB,IAAI,QAAQ,OAAO,SAAS,UAAU;EAClC,MAAM,aAAa;EACnB,MAAM,SAAU,WAAW,UAAU,OAAO,WAAW,WAAW,WAC5D,WAAW,SACX;EAEN,KAAK,MAAM,SAAS;GADA;GAAQ;GAAS;GAAS;GAAgB;GAAe;GAAS;EAClE,GAAY;GAC5B,MAAM,IAAI,OAAO;GACjB,IAAI,KAAK,OAAO,MAAM,UAAU,OAAO;EAC3C;CACJ;CAIA,KAAK,MAAM,SAAS;EADE;EAAQ;EAAS;EAAS;EAAgB;EAAe;CAC3D,GAAc;EAC9B,MAAM,IAAI,OAAO;EACjB,IAAI,KAAK,OAAO,MAAM,UAAU,OAAO;CAC3C;CAGA,IAAI,QAAQ,UAAU,OAAO,MAAM,MAAM,OAAO,OAAO,OAAO,EAAE;CAEhE,OAAO;AACX;;;;AAKA,IAAa,kBAAkB,SAAS,gBAAgB,OAA6B;CACjF,MAAM,WAAW,MAAM;CACvB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hC;CAEA,IAAI,CAAC,YAAY;EACb,IAAI,QACA,OAAO,oBAAC,4BAAD;GAA4B,OAAO,OAAO,SAAS,EAAE;GACxD,SAAS;EAAoB,CAAA;EAErC,OACI,oBAAC,wBAAD;GAAwB,SAAS,WAAW,KAAA,IAAY;GACpD,OAAO,WAAW,KAAA,IAAY;GACxB;aACN,oBAAC,WAAD,EAAW,OAAO,mBAAoB,CAAA;EAClB,CAAA;CAEhC;CAEA,IAAI,QACA,OAAO,oBAAC,qBAAD;EAAqB,QAAQ;EACpB;EACF;EACD;EAGT,mBAAmB,CAAC,YAAY,sBAAsB;CAAO,CAAA;CAMrE,IAAI,WAAW,SAAS,0BAA0B,sBAC9C,OAAO,oBAAC,0BAAD;EAA0B,QAAQ;EAC/B;EACN,QAAQ;EACI;EACZ,aAAa;EACb,mBAAmB,CAAC,YAAY,sBAAsB;CAAO,CAAA;CAGrE,OAAO,oBAAC,uBAAD;EAA6B;EAChC,aAAa;EACH;EACV,QAAQ;EACI;EACH;EACU;EACnB,WAAW;EACJ;CAAO,CAAA;AAEtB"}
|
|
@@ -5,8 +5,9 @@ import { knownStorageRenditionUrl, storageRenditionUrl } from "./storageRenditio
|
|
|
5
5
|
import React, { useEffect } from "react";
|
|
6
6
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
7
|
import { ImageOffIcon, Skeleton, Tooltip, Typography, cls, iconSize } from "@rebasepro/ui";
|
|
8
|
-
import {
|
|
8
|
+
import { resolveStorageSource } from "@rebasepro/cms-types";
|
|
9
9
|
import { AuthControllerContext, useStorageSource, useStorageSources, useTranslation } from "@rebasepro/app";
|
|
10
|
+
import { createDownloadUrlCache } from "@rebasepro/common";
|
|
10
11
|
//#region src/preview/components/StorageThumbnail.tsx
|
|
11
12
|
/**
|
|
12
13
|
* @group Preview components
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StorageThumbnail.js","names":[],"sources":["../../../src/preview/components/StorageThumbnail.tsx"],"sourcesContent":["import React, { useEffect } from \"react\";\n\nimport { renderSkeletonImageThumbnail } from \"../property_previews/SkeletonPropertyComponent\";\nimport { UrlComponentPreview } from \"./UrlComponentPreview\";\nimport { knownStorageRenditionUrl, storageRenditionUrl } from \"./storageRenditions\";\nimport { AuthControllerContext, useStorageSource, useStorageSources, useTranslation } from \"@rebasepro/app\";\nimport { createDownloadUrlCache, resolveStorageSource } from \"@rebasepro/common\";\nimport { DownloadConfig, FileType } from \"@rebasepro/types\";\nimport type { PreviewSize } from \"../../types/components/PropertyPreviewProps\";\nimport { cls, ImageOffIcon, iconSize, Skeleton, Tooltip, Typography } from \"@rebasepro/ui\";\nimport { getThumbnailMeasure } from \"../util\";\ntype StorageThumbnailProps = {\n storagePathOrDownloadUrl: string;\n storeUrl: boolean;\n size: PreviewSize;\n interactive?: boolean;\n fill?: boolean;\n /** Key of the storage source backing this property (`StorageConfig.storageSource`). */\n storageSourceKey?: string;\n};\n\n/**\n * @group Preview components\n */\nexport const StorageThumbnail = React.memo<StorageThumbnailProps>(StorageThumbnailInternal, areEqual) as React.FunctionComponent<StorageThumbnailProps>;\n\nfunction areEqual(prevProps: StorageThumbnailProps, nextProps: StorageThumbnailProps) {\n return prevProps.size === nextProps.size &&\n prevProps.storagePathOrDownloadUrl === nextProps.storagePathOrDownloadUrl &&\n prevProps.storeUrl === nextProps.storeUrl &&\n prevProps.interactive === nextProps.interactive &&\n prevProps.fill === nextProps.fill &&\n prevProps.storageSourceKey === nextProps.storageSourceKey;\n}\n\n/**\n * The config each thumbnail last resolved, keyed by `<sourceKey>::<path>`, so a\n * remount draws at once instead of a skeleton; the effect still asks the\n * source again, which owns validity. Bounded (least recently used dropped past\n * 2,000), so a long session browsing thousands of files does not keep them all.\n *\n * Owned by the signed-in user ({@link claimThumbnailCaches}): a private URL\n * carries a download token minted for whoever asked, and this module outlives\n * them — after a sign-out and another user's sign-in in the same tab, the next\n * user's thumbnail of the same path drew the previous user's URL on mount.\n */\nconst URL_CACHE = createDownloadUrlCache();\n\n/**\n * The signed-URL request currently in flight for a given cache key.\n *\n * A collection view draws one thumbnail per row and rows share images far more\n * often than not — the demo's 200 blog posts are illustrated by 20 hero images.\n * Every one of those thumbnails mounts in the same tick, and each used to call\n * `getSignedUrl` on its own: {@link URL_CACHE} is only written when a response\n * *lands*, so it is still empty while the burst goes out and dedupes nothing.\n * The result was five or more identical requests per distinct file, and minting\n * a download token is a real request — `/api/storage/metadata/<path>` — against\n * a rate-limited surface. One page view was enough to exhaust the budget and\n * every thumbnail on the screen then failed with a 429.\n *\n * Sharing the promise collapses that burst to one request per file. It\n * deliberately does not extend how long anything is cached: `DownloadConfig.url`\n * is temporal, so a later mount still refetches exactly as it did before.\n */\nconst IN_FLIGHT = new Map<string, Promise<DownloadConfig>>();\n\n/**\n * Make `owner` the user the thumbnail caches answer for. Another user empties\n * both, the requests in flight included, so the next user's thumbnails neither\n * draw a remembered URL of the previous user's nor wait on one of their\n * requests. Called on every render, before anything is read from them.\n */\nfunction claimThumbnailCaches(owner: string): void {\n if (URL_CACHE.claim(owner)) IN_FLIGHT.clear();\n}\n\nfunction getSignedUrlOnce(\n storage: { getSignedUrl: (path: string) => Promise<DownloadConfig> },\n path: string,\n cacheKey: string\n): Promise<DownloadConfig> {\n const existing = IN_FLIGHT.get(cacheKey);\n if (existing) return existing;\n\n const request: Promise<DownloadConfig> = storage.getSignedUrl(path).finally(() => {\n if (IN_FLIGHT.get(cacheKey) === request) IN_FLIGHT.delete(cacheKey);\n });\n IN_FLIGHT.set(cacheKey, request);\n return request;\n}\n\nexport function StorageThumbnailInternal({\n storeUrl,\n interactive,\n storagePathOrDownloadUrl,\n size,\n fill,\n storageSourceKey\n}: StorageThumbnailProps) {\n\n const { t } = useTranslation();\n // Not `useAuthController`: a thumbnail may render outside <Rebase>, where\n // there is no signed-in user to own anything.\n const owner = React.useContext(AuthControllerContext)?.user?.uid ?? \"\";\n claimThumbnailCaches(owner);\n const [error, setError] = React.useState<Error | undefined>(undefined);\n const defaultStorage = useStorageSource();\n const storageSources = useStorageSources();\n // Resolve the per-property backend so previews of `storeUrl: false`\n // properties pointing at a named source hit the right backend.\n const storage = resolveStorageSource({\n sourceKey: storageSourceKey,\n sources: storageSources.sources,\n defaultSource: defaultStorage,\n createSource: storageSources.createSource\n });\n\n // Cache key is namespaced by source so the same path on two backends\n // does not collide.\n const cacheKey = `${storageSourceKey ?? \"\"}::${storagePathOrDownloadUrl}`;\n\n // What is drawn: the signed config, and the resized rendition to show in\n // its place when the server makes them (see `storageRenditions`).\n const [shown, setShown] = React.useState<{ config: DownloadConfig; previewUrl?: string } | undefined>(() => {\n const cached = URL_CACHE.peek(cacheKey);\n if (!cached) return undefined;\n const previewUrl = knownStorageRenditionUrl(cached, size, fill);\n // Not yet known whether this server resizes: wait for the effect\n // rather than start downloading the original.\n return previewUrl === null ? undefined : { config: cached, previewUrl };\n });\n const downloadConfig = shown?.config;\n\n useEffect(() => {\n if (!storagePathOrDownloadUrl)\n return;\n let unmounted = false;\n getSignedUrlOnce(storage, storagePathOrDownloadUrl, cacheKey)\n .then(async function (downloadConfig) {\n const previewUrl = await storageRenditionUrl(downloadConfig, size, fill);\n if (!unmounted) {\n setShown({ config: downloadConfig, previewUrl });\n // Not for whoever signed in while this was in flight.\n if (URL_CACHE.owner === owner) URL_CACHE.set(cacheKey, { config: downloadConfig });\n }\n }).catch(setError);\n return () => {\n unmounted = true;\n };\n }, [storagePathOrDownloadUrl, cacheKey, size, fill, owner]);\n\n if (!storagePathOrDownloadUrl) return null;\n\n const filetype = downloadConfig?.metadata ? getFiletype(downloadConfig?.metadata.contentType) : undefined;\n const previewType = filetype?.startsWith(\"image\")\n ? \"image\"\n : (filetype?.startsWith(\"video\")\n ? \"video\"\n : (filetype?.startsWith(\"audio\") ? \"audio\" : \"file\"));\n\n if (downloadConfig?.fileNotFound)\n // `file_not_found` is translated into seven locales and this rendered\n // the English literal, so a German panel said \"File not found\".\n return <FileNotFoundThumbnail message={t(\"file_not_found\")}\n size={size}\n fill={fill}/>;\n\n return downloadConfig?.url\n ? <UrlComponentPreview previewType={previewType}\n url={downloadConfig.url}\n previewUrl={shown?.previewUrl}\n interactive={interactive}\n size={size}\n fill={fill}\n hint={storagePathOrDownloadUrl}/>\n : fill\n ? <Skeleton className=\"w-full h-full\"/>\n : renderSkeletonImageThumbnail(size);\n}\n\n/**\n * The placeholder for a path the storage source answered 404 for.\n *\n * It occupies the box the image would have — the card's whole 4:3 thumbnail\n * when `fill`, otherwise the same measure as the skeleton it replaces — and\n * centres its contents in it. This was `ErrorView`, which is a\n * left-aligned block with a red triangle and `m-2` around it: laid over a card\n * thumbnail it sat in the top-left corner with the icon colliding with the\n * text, and a grid of them read as a page of errors rather than as missing\n * pictures. A file that is not there is the same absence `ImagePreview`\n * already draws for an image that fails to load, so it is drawn the same way.\n *\n * At `small` the box is 40px and no label fits, so the message becomes the\n * tooltip instead of being clipped.\n */\nfunction FileNotFoundThumbnail({\n message,\n size,\n fill\n}: { message: string, size: PreviewSize, fill?: boolean }) {\n\n const measure = fill ? undefined : getThumbnailMeasure(size);\n const labelled = fill || size !== \"small\";\n\n const body = (\n <div\n className={cls(\n \"flex flex-col items-center justify-center gap-1 text-center overflow-hidden\",\n \"bg-surface-raised rounded-md p-2\",\n fill ? \"w-full h-full\" : \"\"\n )}\n style={measure === undefined ? undefined : { width: measure, height: measure, maxHeight: \"100%\" }}>\n <ImageOffIcon\n size={labelled ? iconSize.small : iconSize.smallest}\n className=\"shrink-0 text-surface-400 dark:text-surface-500\"/>\n {labelled && (\n <Typography variant=\"caption\"\n color=\"secondary\"\n className=\"max-w-full line-clamp-2 leading-tight\">\n {message}\n </Typography>\n )}\n </div>\n );\n\n return labelled ? body : <Tooltip title={message}>{body}</Tooltip>;\n}\n\nfunction getFiletype(input: string): FileType {\n if (input.startsWith(\"image\")) return \"image/*\";\n else if (input.startsWith(\"video\")) return \"video/*\";\n else if (input.startsWith(\"audio\")) return \"audio/*\";\n else if (input.startsWith(\"application\")) return \"application/*\";\n else if (input.startsWith(\"text\")) return \"text/*\";\n else if (input.startsWith(\"font\")) return \"font/*\";\n else return input;\n}\n"],"mappings":";;;;;;;;;;;;;AAwBA,IAAa,mBAAmB,MAAM,KAA4B,0BAA0B,QAAQ;AAEpG,SAAS,SAAS,WAAkC,WAAkC;CAClF,OAAO,UAAU,SAAS,UAAU,QAChC,UAAU,6BAA6B,UAAU,4BACjD,UAAU,aAAa,UAAU,YACjC,UAAU,gBAAgB,UAAU,eACpC,UAAU,SAAS,UAAU,QAC7B,UAAU,qBAAqB,UAAU;AACjD;;;;;;;;;;;;AAaA,IAAM,YAAY,uBAAuB;;;;;;;;;;;;;;;;;;AAmBzC,IAAM,4BAAY,IAAI,IAAqC;;;;;;;AAQ3D,SAAS,qBAAqB,OAAqB;CAC/C,IAAI,UAAU,MAAM,KAAK,GAAG,UAAU,MAAM;AAChD;AAEA,SAAS,iBACL,SACA,MACA,UACuB;CACvB,MAAM,WAAW,UAAU,IAAI,QAAQ;CACvC,IAAI,UAAU,OAAO;CAErB,MAAM,UAAmC,QAAQ,aAAa,IAAI,CAAC,CAAC,cAAc;EAC9E,IAAI,UAAU,IAAI,QAAQ,MAAM,SAAS,UAAU,OAAO,QAAQ;CACtE,CAAC;CACD,UAAU,IAAI,UAAU,OAAO;CAC/B,OAAO;AACX;AAEA,SAAgB,yBAAyB,EACrC,UACA,aACA,0BACA,MACA,MACA,oBACsB;CAEtB,MAAM,EAAE,MAAM,eAAe;CAG7B,MAAM,QAAQ,MAAM,WAAW,qBAAqB,CAAC,EAAE,MAAM,OAAO;CACpE,qBAAqB,KAAK;CAC1B,MAAM,CAAC,OAAO,YAAY,MAAM,SAA4B,KAAA,CAAS;CACrE,MAAM,iBAAiB,iBAAiB;CACxC,MAAM,iBAAiB,kBAAkB;CAGzC,MAAM,UAAU,qBAAqB;EACjC,WAAW;EACX,SAAS,eAAe;EACxB,eAAe;EACf,cAAc,eAAe;CACjC,CAAC;CAID,MAAM,WAAW,GAAG,oBAAoB,GAA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I;AAC/C;;;;;;;;;;;;;;;;AAiBA,SAAS,sBAAsB,EAC3B,SACA,MACA,QACuD;CAEvD,MAAM,UAAU,OAAO,KAAA,IAAY,oBAAoB,IAAI;CAC3D,MAAM,WAAW,QAAQ,SAAS;CAElC,MAAM,OACF,qBAAC,OAAD;EACI,WAAW,IACP,+EACA,oCACA,OAAO,kBAAkB,EAC7B;EACA,OAAO,YAAY,KAAA,IAAY,KAAA,IAAY;GAAE,OAAO;GAAS,QAAQ;GAAS,WAAW;EAAO;YANpG,CAOI,oBAAC,cAAD;GACI,MAAM,WAAW,SAAS,QAAQ,SAAS;GAC3C,WAAU;EAAkD,CAAA,GAC/D,YACG,oBAAC,YAAD;GAAY,SAAQ;GAChB,OAAM;GACN,WAAU;aACT;EACO,CAAA,CAEf;;CAGT,OAAO,WAAW,OAAO,oBAAC,SAAD;EAAS,OAAO;YAAU;CAAc,CAAA;AACrE;AAEA,SAAS,YAAY,OAAyB;CAC1C,IAAI,MAAM,WAAW,OAAO,GAAG,OAAO;MACjC,IAAI,MAAM,WAAW,OAAO,GAAG,OAAO;MACtC,IAAI,MAAM,WAAW,OAAO,GAAG,OAAO;MACtC,IAAI,MAAM,WAAW,aAAa,GAAG,OAAO;MAC5C,IAAI,MAAM,WAAW,MAAM,GAAG,OAAO;MACrC,IAAI,MAAM,WAAW,MAAM,GAAG,OAAO;MACrC,OAAO;AAChB"}
|
|
1
|
+
{"version":3,"file":"StorageThumbnail.js","names":[],"sources":["../../../src/preview/components/StorageThumbnail.tsx"],"sourcesContent":["import React, { useEffect } from \"react\";\n\nimport { renderSkeletonImageThumbnail } from \"../property_previews/SkeletonPropertyComponent\";\nimport { UrlComponentPreview } from \"./UrlComponentPreview\";\nimport { knownStorageRenditionUrl, storageRenditionUrl } from \"./storageRenditions\";\nimport { AuthControllerContext, useStorageSource, useStorageSources, useTranslation } from \"@rebasepro/app\";\nimport { createDownloadUrlCache } from \"@rebasepro/common\";\nimport { resolveStorageSource, FileType } from \"@rebasepro/cms-types\";\nimport { DownloadConfig } from \"@rebasepro/types\";\nimport type { PreviewSize } from \"../../types/components/PropertyPreviewProps\";\nimport { cls, ImageOffIcon, iconSize, Skeleton, Tooltip, Typography } from \"@rebasepro/ui\";\nimport { getThumbnailMeasure } from \"../util\";\ntype StorageThumbnailProps = {\n storagePathOrDownloadUrl: string;\n storeUrl: boolean;\n size: PreviewSize;\n interactive?: boolean;\n fill?: boolean;\n /** Key of the storage source backing this property (`StorageConfig.storageSource`). */\n storageSourceKey?: string;\n};\n\n/**\n * @group Preview components\n */\nexport const StorageThumbnail = React.memo<StorageThumbnailProps>(StorageThumbnailInternal, areEqual) as React.FunctionComponent<StorageThumbnailProps>;\n\nfunction areEqual(prevProps: StorageThumbnailProps, nextProps: StorageThumbnailProps) {\n return prevProps.size === nextProps.size &&\n prevProps.storagePathOrDownloadUrl === nextProps.storagePathOrDownloadUrl &&\n prevProps.storeUrl === nextProps.storeUrl &&\n prevProps.interactive === nextProps.interactive &&\n prevProps.fill === nextProps.fill &&\n prevProps.storageSourceKey === nextProps.storageSourceKey;\n}\n\n/**\n * The config each thumbnail last resolved, keyed by `<sourceKey>::<path>`, so a\n * remount draws at once instead of a skeleton; the effect still asks the\n * source again, which owns validity. Bounded (least recently used dropped past\n * 2,000), so a long session browsing thousands of files does not keep them all.\n *\n * Owned by the signed-in user ({@link claimThumbnailCaches}): a private URL\n * carries a download token minted for whoever asked, and this module outlives\n * them — after a sign-out and another user's sign-in in the same tab, the next\n * user's thumbnail of the same path drew the previous user's URL on mount.\n */\nconst URL_CACHE = createDownloadUrlCache();\n\n/**\n * The signed-URL request currently in flight for a given cache key.\n *\n * A collection view draws one thumbnail per row and rows share images far more\n * often than not — the demo's 200 blog posts are illustrated by 20 hero images.\n * Every one of those thumbnails mounts in the same tick, and each used to call\n * `getSignedUrl` on its own: {@link URL_CACHE} is only written when a response\n * *lands*, so it is still empty while the burst goes out and dedupes nothing.\n * The result was five or more identical requests per distinct file, and minting\n * a download token is a real request — `/api/storage/metadata/<path>` — against\n * a rate-limited surface. One page view was enough to exhaust the budget and\n * every thumbnail on the screen then failed with a 429.\n *\n * Sharing the promise collapses that burst to one request per file. It\n * deliberately does not extend how long anything is cached: `DownloadConfig.url`\n * is temporal, so a later mount still refetches exactly as it did before.\n */\nconst IN_FLIGHT = new Map<string, Promise<DownloadConfig>>();\n\n/**\n * Make `owner` the user the thumbnail caches answer for. Another user empties\n * both, the requests in flight included, so the next user's thumbnails neither\n * draw a remembered URL of the previous user's nor wait on one of their\n * requests. Called on every render, before anything is read from them.\n */\nfunction claimThumbnailCaches(owner: string): void {\n if (URL_CACHE.claim(owner)) IN_FLIGHT.clear();\n}\n\nfunction getSignedUrlOnce(\n storage: { getSignedUrl: (path: string) => Promise<DownloadConfig> },\n path: string,\n cacheKey: string\n): Promise<DownloadConfig> {\n const existing = IN_FLIGHT.get(cacheKey);\n if (existing) return existing;\n\n const request: Promise<DownloadConfig> = storage.getSignedUrl(path).finally(() => {\n if (IN_FLIGHT.get(cacheKey) === request) IN_FLIGHT.delete(cacheKey);\n });\n IN_FLIGHT.set(cacheKey, request);\n return request;\n}\n\nexport function StorageThumbnailInternal({\n storeUrl,\n interactive,\n storagePathOrDownloadUrl,\n size,\n fill,\n storageSourceKey\n}: StorageThumbnailProps) {\n\n const { t } = useTranslation();\n // Not `useAuthController`: a thumbnail may render outside <Rebase>, where\n // there is no signed-in user to own anything.\n const owner = React.useContext(AuthControllerContext)?.user?.uid ?? \"\";\n claimThumbnailCaches(owner);\n const [error, setError] = React.useState<Error | undefined>(undefined);\n const defaultStorage = useStorageSource();\n const storageSources = useStorageSources();\n // Resolve the per-property backend so previews of `storeUrl: false`\n // properties pointing at a named source hit the right backend.\n const storage = resolveStorageSource({\n sourceKey: storageSourceKey,\n sources: storageSources.sources,\n defaultSource: defaultStorage,\n createSource: storageSources.createSource\n });\n\n // Cache key is namespaced by source so the same path on two backends\n // does not collide.\n const cacheKey = `${storageSourceKey ?? \"\"}::${storagePathOrDownloadUrl}`;\n\n // What is drawn: the signed config, and the resized rendition to show in\n // its place when the server makes them (see `storageRenditions`).\n const [shown, setShown] = React.useState<{ config: DownloadConfig; previewUrl?: string } | undefined>(() => {\n const cached = URL_CACHE.peek(cacheKey);\n if (!cached) return undefined;\n const previewUrl = knownStorageRenditionUrl(cached, size, fill);\n // Not yet known whether this server resizes: wait for the effect\n // rather than start downloading the original.\n return previewUrl === null ? undefined : { config: cached, previewUrl };\n });\n const downloadConfig = shown?.config;\n\n useEffect(() => {\n if (!storagePathOrDownloadUrl)\n return;\n let unmounted = false;\n getSignedUrlOnce(storage, storagePathOrDownloadUrl, cacheKey)\n .then(async function (downloadConfig) {\n const previewUrl = await storageRenditionUrl(downloadConfig, size, fill);\n if (!unmounted) {\n setShown({ config: downloadConfig, previewUrl });\n // Not for whoever signed in while this was in flight.\n if (URL_CACHE.owner === owner) URL_CACHE.set(cacheKey, { config: downloadConfig });\n }\n }).catch(setError);\n return () => {\n unmounted = true;\n };\n }, [storagePathOrDownloadUrl, cacheKey, size, fill, owner]);\n\n if (!storagePathOrDownloadUrl) return null;\n\n const filetype = downloadConfig?.metadata ? getFiletype(downloadConfig?.metadata.contentType) : undefined;\n const previewType = filetype?.startsWith(\"image\")\n ? \"image\"\n : (filetype?.startsWith(\"video\")\n ? \"video\"\n : (filetype?.startsWith(\"audio\") ? \"audio\" : \"file\"));\n\n if (downloadConfig?.fileNotFound)\n // `file_not_found` is translated into seven locales and this rendered\n // the English literal, so a German panel said \"File not found\".\n return <FileNotFoundThumbnail message={t(\"file_not_found\")}\n size={size}\n fill={fill}/>;\n\n return downloadConfig?.url\n ? <UrlComponentPreview previewType={previewType}\n url={downloadConfig.url}\n previewUrl={shown?.previewUrl}\n interactive={interactive}\n size={size}\n fill={fill}\n hint={storagePathOrDownloadUrl}/>\n : fill\n ? <Skeleton className=\"w-full h-full\"/>\n : renderSkeletonImageThumbnail(size);\n}\n\n/**\n * The placeholder for a path the storage source answered 404 for.\n *\n * It occupies the box the image would have — the card's whole 4:3 thumbnail\n * when `fill`, otherwise the same measure as the skeleton it replaces — and\n * centres its contents in it. This was `ErrorView`, which is a\n * left-aligned block with a red triangle and `m-2` around it: laid over a card\n * thumbnail it sat in the top-left corner with the icon colliding with the\n * text, and a grid of them read as a page of errors rather than as missing\n * pictures. A file that is not there is the same absence `ImagePreview`\n * already draws for an image that fails to load, so it is drawn the same way.\n *\n * At `small` the box is 40px and no label fits, so the message becomes the\n * tooltip instead of being clipped.\n */\nfunction FileNotFoundThumbnail({\n message,\n size,\n fill\n}: { message: string, size: PreviewSize, fill?: boolean }) {\n\n const measure = fill ? undefined : getThumbnailMeasure(size);\n const labelled = fill || size !== \"small\";\n\n const body = (\n <div\n className={cls(\n \"flex flex-col items-center justify-center gap-1 text-center overflow-hidden\",\n \"bg-surface-raised rounded-md p-2\",\n fill ? \"w-full h-full\" : \"\"\n )}\n style={measure === undefined ? undefined : { width: measure, height: measure, maxHeight: \"100%\" }}>\n <ImageOffIcon\n size={labelled ? iconSize.small : iconSize.smallest}\n className=\"shrink-0 text-surface-400 dark:text-surface-500\"/>\n {labelled && (\n <Typography variant=\"caption\"\n color=\"secondary\"\n className=\"max-w-full line-clamp-2 leading-tight\">\n {message}\n </Typography>\n )}\n </div>\n );\n\n return labelled ? body : <Tooltip title={message}>{body}</Tooltip>;\n}\n\nfunction getFiletype(input: string): FileType {\n if (input.startsWith(\"image\")) return \"image/*\";\n else if (input.startsWith(\"video\")) return \"video/*\";\n else if (input.startsWith(\"audio\")) return \"audio/*\";\n else if (input.startsWith(\"application\")) return \"application/*\";\n else if (input.startsWith(\"text\")) return \"text/*\";\n else if (input.startsWith(\"font\")) return \"font/*\";\n else return input;\n}\n"],"mappings":";;;;;;;;;;;;;;AAyBA,IAAa,mBAAmB,MAAM,KAA4B,0BAA0B,QAAQ;AAEpG,SAAS,SAAS,WAAkC,WAAkC;CAClF,OAAO,UAAU,SAAS,UAAU,QAChC,UAAU,6BAA6B,UAAU,4BACjD,UA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YAAY,KAAA,IAAY,KAAA,IAAY;GAAE,OAAO;GAAS,QAAQ;GAAS,WAAW;EAAO;YANpG,CAOI,oBAAC,cAAD;GACI,MAAM,WAAW,SAAS,QAAQ,SAAS;GAC3C,WAAU;EAAkD,CAAA,GAC/D,YACG,oBAAC,YAAD;GAAY,SAAQ;GAChB,OAAM;GACN,WAAU;aACT;EACO,CAAA,CAEf;;CAGT,OAAO,WAAW,OAAO,oBAAC,SAAD;EAAS,OAAO;YAAU;CAAc,CAAA;AACrE;AAEA,SAAS,YAAY,OAAyB;CAC1C,IAAI,MAAM,WAAW,OAAO,GAAG,OAAO;MACjC,IAAI,MAAM,WAAW,OAAO,GAAG,OAAO;MACtC,IAAI,MAAM,WAAW,OAAO,GAAG,OAAO;MACtC,IAAI,MAAM,WAAW,aAAa,GAAG,OAAO;MAC5C,IAAI,MAAM,WAAW,MAAM,GAAG,OAAO;MACrC,IAAI,MAAM,WAAW,MAAM,GAAG,OAAO;MACrC,OAAO;AAChB"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { PropertyPreviewProps } from "../../types/components/PropertyPreviewProps.js";
|
|
2
|
-
import type { StringProperty } from "@rebasepro/types";
|
|
2
|
+
import type { StringProperty } from "@rebasepro/cms-types";
|
|
3
3
|
import React from "react";
|
|
4
4
|
/**
|
|
5
5
|
* Preview component for displaying a user reference value.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UserPreview.js","names":[],"sources":["../../../src/preview/components/UserPreview.tsx"],"sourcesContent":["import type { PropertyPreviewProps } from \"../../types/components/PropertyPreviewProps\";\nimport type { StringProperty } from \"@rebasepro/types\";\nimport React from \"react\";\nimport { EmptyValue } from \"./EmptyValue\";\nimport { Typography } from \"@rebasepro/ui\";\nimport { getUserLabel, useResolvedUser } from \"../../hooks/useResolvedUsers\";\n\n/**\n * Preview component for displaying a user reference value.\n *\n * Resolves the stored auth user id to a name (or email) the same way a\n * relation resolves its target, and falls back to the raw id only while the\n * lookup is in flight or when the user cannot be resolved.\n *\n * @group Preview components\n */\nexport function UserPreview({ value }: PropertyPreviewProps<StringProperty>) {\n const uid = typeof value === \"string\" && value ? value : undefined;\n const user = useResolvedUser(uid);\n\n if (!uid) {\n return <EmptyValue/>;\n }\n\n return <Typography variant={\"caption\"}\n color={\"secondary\"}\n className={\"truncate\"}>\n {user ? getUserLabel(user) : uid}\n </Typography>;\n}\n"],"mappings":";;;;;;;;;;;;;;;AAgBA,SAAgB,YAAY,EAAE,SAA+C;CACzE,MAAM,MAAM,OAAO,UAAU,YAAY,QAAQ,QAAQ,KAAA;CACzD,MAAM,OAAO,gBAAgB,GAAG;CAEhC,IAAI,CAAC,KACD,OAAO,oBAAC,YAAD,CAAY,CAAA;CAGvB,OAAO,oBAAC,YAAD;EAAY,SAAS;EACxB,OAAO;EACP,WAAW;YACV,OAAO,aAAa,IAAI,IAAI;CACrB,CAAA;AAChB"}
|
|
1
|
+
{"version":3,"file":"UserPreview.js","names":[],"sources":["../../../src/preview/components/UserPreview.tsx"],"sourcesContent":["import type { PropertyPreviewProps } from \"../../types/components/PropertyPreviewProps\";\nimport type { StringProperty } from \"@rebasepro/cms-types\";\nimport React from \"react\";\nimport { EmptyValue } from \"./EmptyValue\";\nimport { Typography } from \"@rebasepro/ui\";\nimport { getUserLabel, useResolvedUser } from \"../../hooks/useResolvedUsers\";\n\n/**\n * Preview component for displaying a user reference value.\n *\n * Resolves the stored auth user id to a name (or email) the same way a\n * relation resolves its target, and falls back to the raw id only while the\n * lookup is in flight or when the user cannot be resolved.\n *\n * @group Preview components\n */\nexport function UserPreview({ value }: PropertyPreviewProps<StringProperty>) {\n const uid = typeof value === \"string\" && value ? value : undefined;\n const user = useResolvedUser(uid);\n\n if (!uid) {\n return <EmptyValue/>;\n }\n\n return <Typography variant={\"caption\"}\n color={\"secondary\"}\n className={\"truncate\"}>\n {user ? getUserLabel(user) : uid}\n </Typography>;\n}\n"],"mappings":";;;;;;;;;;;;;;;AAgBA,SAAgB,YAAY,EAAE,SAA+C;CACzE,MAAM,MAAM,OAAO,UAAU,YAAY,QAAQ,QAAQ,KAAA;CACzD,MAAM,OAAO,gBAAgB,GAAG;CAEhC,IAAI,CAAC,KACD,OAAO,oBAAC,YAAD,CAAY,CAAA;CAGvB,OAAO,oBAAC,YAAD;EAAY,SAAS;EACxB,OAAO;EACP,WAAW;YACV,OAAO,aAAa,IAAI,IAAI;CACrB,CAAA;AAChB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ArrayOfMapsPreview.js","names":[],"sources":["../../../src/preview/property_previews/ArrayOfMapsPreview.tsx"],"sourcesContent":["import type { ArrayProperty, MapProperty, Property } from \"@rebasepro/types\";\nimport React from \"react\";\nimport { ErrorBoundary } from \"@rebasepro/ui\";\nimport type { PropertyPreviewProps } from \"../../types/components/PropertyPreviewProps\";\nimport { PropertyPreview } from \"../PropertyPreview\";\n\n/**\n * @group Preview components\n */\nexport function ArrayOfMapsPreview({\n propertyKey,\n value,\n property,\n size\n // entity\n}: PropertyPreviewProps<ArrayProperty>) {\n\n if (Array.isArray(property?.of)) {\n throw Error(\"Using array properties instead of single one in `of` in ArrayProperty\");\n }\n\n if (property?.type !== \"array\" || !property.of || property.of.type !== \"map\")\n throw Error(\"Picked wrong preview component ArrayOfMapsPreview\");\n\n const mapProperty = property.of;\n const properties = mapProperty.properties;\n if (!properties) {\n throw Error(`You need to specify a 'properties' prop (or specify a custom field) in your map property '${propertyKey}'${mapProperty.name ? ` (\"${mapProperty.name}\")` : \"\"}`);\n }\n const values = value as Record<string, unknown>[];\n const previewProperties: string[] | undefined = (mapProperty as MapProperty).admin?.previewProperties;\n\n if (!values) return null;\n\n let mapProperties = previewProperties;\n if (!mapProperties || !mapProperties.length) {\n mapProperties = Object.keys(properties);\n if (size)\n mapProperties = mapProperties.slice(0, 3);\n }\n\n return (\n <div className=\"table-auto text-xs\">\n <div>\n {values &&\n values.map((v, index: number) => {\n return (\n <div key={`table_${v}_${index}`}\n className=\"border-b last:border-b-0 py-2\">\n {mapProperties && mapProperties.map(\n (key) => (\n <div\n key={`table-cell-${key as string}`}\n className=\"table-cell\"\n >\n <ErrorBoundary>\n <PropertyPreview\n propertyKey={key as string}\n value={(v)[key]}\n property={properties[key as string] as Property}\n // entity={entity}\n size={\"small\"}/>\n </ErrorBoundary>\n </div>\n )\n )}\n </div>\n );\n })}\n </div>\n </div>\n );\n}\n"],"mappings":";;;;;;;;AASA,SAAgB,mBAAmB,EAC/B,aACA,OACA,UACA,QAEoC;CAEpC,IAAI,MAAM,QAAQ,UAAU,EAAE,GAC1B,MAAM,MAAM,uEAAuE;CAGvF,IAAI,UAAU,SAAS,WAAW,CAAC,SAAS,MAAM,SAAS,GAAG,SAAS,OACnE,MAAM,MAAM,mDAAmD;CAEnE,MAAM,cAAc,SAAS;CAC7B,MAAM,aAAa,YAAY;CAC/B,IAAI,CAAC,YACD,MAAM,MAAM,6FAA6F,YAAY,GAAG,YAAY,OAAO,MAAM,YAAY,KAAK,MAAM,IAAI;CAEhL,MAAM,SAAS;CACf,MAAM,oBAA2C,YAA4B,OAAO;CAEpF,IAAI,CAAC,QAAQ,OAAO;CAEpB,IAAI,gBAAgB;CACpB,IAAI,CAAC,iBAAiB,CAAC,cAAc,QAAQ;EACzC,gBAAgB,OAAO,KAAK,UAAU;EACtC,IAAI,MACA,gBAAgB,cAAc,MAAM,GAAG,CAAC;CAChD;CAEA,OACI,oBAAC,OAAD;EAAK,WAAU;YACX,oBAAC,OAAD,EAAA,UACK,UACG,OAAO,KAAK,GAAG,UAAkB;GAC7B,OACI,oBAAC,OAAD;IACI,WAAU;cACT,iBAAiB,cAAc,KAC3B,QACG,oBAAC,OAAD;KAEI,WAAU;eAEV,oBAAC,eAAD,EAAA,UACI,oBAAC,iBAAD;MACI,aAAa;MACb,OAAQ,EAAG;MACX,UAAU,WAAW;MAErB,MAAM;KAAS,CAAA,EACR,CAAA;IACd,GAXI,cAAc,KAWlB,CAEb;GACC,GAnBK,SAAS,EAAE,GAAG,OAmBnB;EAEb,CAAC,EACJ,CAAA;CACJ,CAAA;AAEb"}
|
|
1
|
+
{"version":3,"file":"ArrayOfMapsPreview.js","names":[],"sources":["../../../src/preview/property_previews/ArrayOfMapsPreview.tsx"],"sourcesContent":["import type { ArrayProperty, MapProperty, Property } from \"@rebasepro/cms-types\";\nimport React from \"react\";\nimport { ErrorBoundary } from \"@rebasepro/ui\";\nimport type { PropertyPreviewProps } from \"../../types/components/PropertyPreviewProps\";\nimport { PropertyPreview } from \"../PropertyPreview\";\n\n/**\n * @group Preview components\n */\nexport function ArrayOfMapsPreview({\n propertyKey,\n value,\n property,\n size\n // entity\n}: PropertyPreviewProps<ArrayProperty>) {\n\n if (Array.isArray(property?.of)) {\n throw Error(\"Using array properties instead of single one in `of` in ArrayProperty\");\n }\n\n if (property?.type !== \"array\" || !property.of || property.of.type !== \"map\")\n throw Error(\"Picked wrong preview component ArrayOfMapsPreview\");\n\n const mapProperty = property.of;\n const properties = mapProperty.properties;\n if (!properties) {\n throw Error(`You need to specify a 'properties' prop (or specify a custom field) in your map property '${propertyKey}'${mapProperty.name ? ` (\"${mapProperty.name}\")` : \"\"}`);\n }\n const values = value as Record<string, unknown>[];\n const previewProperties: string[] | undefined = (mapProperty as MapProperty).admin?.previewProperties;\n\n if (!values) return null;\n\n let mapProperties = previewProperties;\n if (!mapProperties || !mapProperties.length) {\n mapProperties = Object.keys(properties);\n if (size)\n mapProperties = mapProperties.slice(0, 3);\n }\n\n return (\n <div className=\"table-auto text-xs\">\n <div>\n {values &&\n values.map((v, index: number) => {\n return (\n <div key={`table_${v}_${index}`}\n className=\"border-b last:border-b-0 py-2\">\n {mapProperties && mapProperties.map(\n (key) => (\n <div\n key={`table-cell-${key as string}`}\n className=\"table-cell\"\n >\n <ErrorBoundary>\n <PropertyPreview\n propertyKey={key as string}\n value={(v)[key]}\n property={properties[key as string] as Property}\n // entity={entity}\n size={\"small\"}/>\n </ErrorBoundary>\n </div>\n )\n )}\n </div>\n );\n })}\n </div>\n </div>\n );\n}\n"],"mappings":";;;;;;;;AASA,SAAgB,mBAAmB,EAC/B,aACA,OACA,UACA,QAEoC;CAEpC,IAAI,MAAM,QAAQ,UAAU,EAAE,GAC1B,MAAM,MAAM,uEAAuE;CAGvF,IAAI,UAAU,SAAS,WAAW,CAAC,SAAS,MAAM,SAAS,GAAG,SAAS,OACnE,MAAM,MAAM,mDAAmD;CAEnE,MAAM,cAAc,SAAS;CAC7B,MAAM,aAAa,YAAY;CAC/B,IAAI,CAAC,YACD,MAAM,MAAM,6FAA6F,YAAY,GAAG,YAAY,OAAO,MAAM,YAAY,KAAK,MAAM,IAAI;CAEhL,MAAM,SAAS;CACf,MAAM,oBAA2C,YAA4B,OAAO;CAEpF,IAAI,CAAC,QAAQ,OAAO;CAEpB,IAAI,gBAAgB;CACpB,IAAI,CAAC,iBAAiB,CAAC,cAAc,QAAQ;EACzC,gBAAgB,OAAO,KAAK,UAAU;EACtC,IAAI,MACA,gBAAgB,cAAc,MAAM,GAAG,CAAC;CAChD;CAEA,OACI,oBAAC,OAAD;EAAK,WAAU;YACX,oBAAC,OAAD,EAAA,UACK,UACG,OAAO,KAAK,GAAG,UAAkB;GAC7B,OACI,oBAAC,OAAD;IACI,WAAU;cACT,iBAAiB,cAAc,KAC3B,QACG,oBAAC,OAAD;KAEI,WAAU;eAEV,oBAAC,eAAD,EAAA,UACI,oBAAC,iBAAD;MACI,aAAa;MACb,OAAQ,EAAG;MACX,UAAU,WAAW;MAErB,MAAM;KAAS,CAAA,EACR,CAAA;IACd,GAXI,cAAc,KAWlB,CAEb;GACC,GAnBK,SAAS,EAAE,GAAG,OAmBnB;EAEb,CAAC,EACJ,CAAA;CACJ,CAAA;AAEb"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ArrayOfReferencesPreview.js","names":[],"sources":["../../../src/preview/property_previews/ArrayOfReferencesPreview.tsx"],"sourcesContent":["import type { ArrayProperty, ReferenceProperty, EntityReference } from \"@rebasepro/types\";\nimport type { PropertyPreviewProps, PreviewSize } from \"../../types/components/PropertyPreviewProps\";\nimport { ReferencePreview } from \"../components/ReferencePreview\";\nimport { useIsNestedEntityPreview } from \"../../components/EntityPreviewNesting\";\nimport { InlineEntityListPreview } from \"../components/InlineEntityListPreview\";\n\n/**\n * @group Preview components\n */\nexport function ArrayOfReferencesPreview({\n propertyKey,\n value,\n property: property,\n size,\n textOnly\n}: PropertyPreviewProps<ArrayProperty>) {\n\n const nested = useIsNestedEntityPreview();\n\n if (Array.isArray(property?.of)) {\n throw Error(\"Using array properties instead of single one in `of` in ArrayProperty\");\n }\n\n if (property?.type !== \"array\" || !property.of || property.of.type !== \"reference\")\n throw Error(\"Picked wrong preview component ArrayOfReferencesPreview\");\n\n const childSize: PreviewSize = size === \"medium\" ? \"medium\" : \"small\";\n const ofProperty = property.of as ReferenceProperty;\n\n // Stacked cards inside another preview (or a title slot) turn a list into a\n // wall of boxes: keep it to one wrapping line of links. So does a small\n // preview — a table's text row — where a stacked list showed its first\n // item and the top half of the second.\n if (nested || textOnly || size === \"small\") {\n return <InlineEntityListPreview\n items={(value ?? []) as EntityReference[]}\n renderItem={(reference, index) => <ReferencePreview\n key={`preview_array_ref_${propertyKey}_${index}`}\n disabled={!ofProperty.path}\n previewProperties={ofProperty.admin?.previewProperties}\n size={childSize}\n reference={reference}\n textOnly={textOnly}\n includeId={ofProperty.admin?.includeId}\n includeEntityLink={ofProperty.admin?.includeEntityLink}\n />}/>;\n }\n\n return (\n <div className=\"flex flex-col w-full\">\n {value ?\n (value as EntityReference[]).map((reference, index: number) => {\n const ofProperty = property.of as ReferenceProperty;\n return <div className=\"mt-1 mb-1 w-full\"\n key={`preview_array_ref_${propertyKey}_${index}`}>\n <ReferencePreview\n disabled={!ofProperty.path}\n previewProperties={ofProperty.admin?.previewProperties}\n size={childSize}\n reference={reference}\n includeId={ofProperty.admin?.includeId}\n includeEntityLink={ofProperty.admin?.includeEntityLink}\n />\n </div>;\n }\n ) : null}\n </div>\n );\n}\n"],"mappings":";;;;;;;;AASA,SAAgB,yBAAyB,EACrC,aACA,OACU,UACV,MACA,YACoC;CAEpC,MAAM,SAAS,yBAAyB;CAExC,IAAI,MAAM,QAAQ,UAAU,EAAE,GAC1B,MAAM,MAAM,uEAAuE;CAGvF,IAAI,UAAU,SAAS,WAAW,CAAC,SAAS,MAAM,SAAS,GAAG,SAAS,aACnE,MAAM,MAAM,yDAAyD;CAEzE,MAAM,YAAyB,SAAS,WAAW,WAAW;CAC9D,MAAM,aAAa,SAAS;CAM5B,IAAI,UAAU,YAAY,SAAS,SAC/B,OAAO,oBAAC,yBAAD;EACH,OAAQ,SAAS,CAAC;EAClB,aAAa,WAAW,UAAU,oBAAC,kBAAD;GAE9B,UAAU,CAAC,WAAW;GACtB,mBAAmB,WAAW,OAAO;GACrC,MAAM;GACK;GACD;GACV,WAAW,WAAW,OAAO;GAC7B,mBAAmB,WAAW,OAAO;EACxC,GARQ,qBAAqB,YAAY,GAAG,OAQ5C;CAAG,CAAA;CAGZ,OACI,oBAAC,OAAD;EAAK,WAAU;YACV,QACI,MAA4B,KAAK,WAAW,UAAkB;GAC3D,MAAM,aAAa,SAAS;GAC5B,OAAO,oBAAC,OAAD;IAAK,WAAU;cAElB,oBAAC,kBAAD;KACI,UAAU,CAAC,WAAW;KACtB,mBAAmB,WAAW,OAAO;KACrC,MAAM;KACK;KACX,WAAW,WAAW,OAAO;KAC7B,mBAAmB,WAAW,OAAO;IACxC,CAAA;GACA,GATI,qBAAqB,YAAY,GAAG,OASxC;EACT,CACA,IAAI;CACP,CAAA;AAEb"}
|
|
1
|
+
{"version":3,"file":"ArrayOfReferencesPreview.js","names":[],"sources":["../../../src/preview/property_previews/ArrayOfReferencesPreview.tsx"],"sourcesContent":["import type { ArrayProperty, ReferenceProperty, EntityReference } from \"@rebasepro/cms-types\";\nimport type { PropertyPreviewProps, PreviewSize } from \"../../types/components/PropertyPreviewProps\";\nimport { ReferencePreview } from \"../components/ReferencePreview\";\nimport { useIsNestedEntityPreview } from \"../../components/EntityPreviewNesting\";\nimport { InlineEntityListPreview } from \"../components/InlineEntityListPreview\";\n\n/**\n * @group Preview components\n */\nexport function ArrayOfReferencesPreview({\n propertyKey,\n value,\n property: property,\n size,\n textOnly\n}: PropertyPreviewProps<ArrayProperty>) {\n\n const nested = useIsNestedEntityPreview();\n\n if (Array.isArray(property?.of)) {\n throw Error(\"Using array properties instead of single one in `of` in ArrayProperty\");\n }\n\n if (property?.type !== \"array\" || !property.of || property.of.type !== \"reference\")\n throw Error(\"Picked wrong preview component ArrayOfReferencesPreview\");\n\n const childSize: PreviewSize = size === \"medium\" ? \"medium\" : \"small\";\n const ofProperty = property.of as ReferenceProperty;\n\n // Stacked cards inside another preview (or a title slot) turn a list into a\n // wall of boxes: keep it to one wrapping line of links. So does a small\n // preview — a table's text row — where a stacked list showed its first\n // item and the top half of the second.\n if (nested || textOnly || size === \"small\") {\n return <InlineEntityListPreview\n items={(value ?? []) as EntityReference[]}\n renderItem={(reference, index) => <ReferencePreview\n key={`preview_array_ref_${propertyKey}_${index}`}\n disabled={!ofProperty.path}\n previewProperties={ofProperty.admin?.previewProperties}\n size={childSize}\n reference={reference}\n textOnly={textOnly}\n includeId={ofProperty.admin?.includeId}\n includeEntityLink={ofProperty.admin?.includeEntityLink}\n />}/>;\n }\n\n return (\n <div className=\"flex flex-col w-full\">\n {value ?\n (value as EntityReference[]).map((reference, index: number) => {\n const ofProperty = property.of as ReferenceProperty;\n return <div className=\"mt-1 mb-1 w-full\"\n key={`preview_array_ref_${propertyKey}_${index}`}>\n <ReferencePreview\n disabled={!ofProperty.path}\n previewProperties={ofProperty.admin?.previewProperties}\n size={childSize}\n reference={reference}\n includeId={ofProperty.admin?.includeId}\n includeEntityLink={ofProperty.admin?.includeEntityLink}\n />\n </div>;\n }\n ) : null}\n </div>\n );\n}\n"],"mappings":";;;;;;;;AASA,SAAgB,yBAAyB,EACrC,aACA,OACU,UACV,MACA,YACoC;CAEpC,MAAM,SAAS,yBAAyB;CAExC,IAAI,MAAM,QAAQ,UAAU,EAAE,GAC1B,MAAM,MAAM,uEAAuE;CAGvF,IAAI,UAAU,SAAS,WAAW,CAAC,SAAS,MAAM,SAAS,GAAG,SAAS,aACnE,MAAM,MAAM,yDAAyD;CAEzE,MAAM,YAAyB,SAAS,WAAW,WAAW;CAC9D,MAAM,aAAa,SAAS;CAM5B,IAAI,UAAU,YAAY,SAAS,SAC/B,OAAO,oBAAC,yBAAD;EACH,OAAQ,SAAS,CAAC;EAClB,aAAa,WAAW,UAAU,oBAAC,kBAAD;GAE9B,UAAU,CAAC,WAAW;GACtB,mBAAmB,WAAW,OAAO;GACrC,MAAM;GACK;GACD;GACV,WAAW,WAAW,OAAO;GAC7B,mBAAmB,WAAW,OAAO;EACxC,GARQ,qBAAqB,YAAY,GAAG,OAQ5C;CAAG,CAAA;CAGZ,OACI,oBAAC,OAAD;EAAK,WAAU;YACV,QACI,MAA4B,KAAK,WAAW,UAAkB;GAC3D,MAAM,aAAa,SAAS;GAC5B,OAAO,oBAAC,OAAD;IAAK,WAAU;cAElB,oBAAC,kBAAD;KACI,UAAU,CAAC,WAAW;KACtB,mBAAmB,WAAW,OAAO;KACrC,MAAM;KACK;KACX,WAAW,WAAW,OAAO;KAC7B,mBAAmB,WAAW,OAAO;IACxC,CAAA;GACA,GATI,qBAAqB,YAAY,GAAG,OASxC;EACT,CACA,IAAI;CACP,CAAA;AAEb"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import { getRelationTargetPath } from "../../util/relations.js";
|
|
1
2
|
import { useIsNestedEntityPreview } from "../../components/EntityPreviewNesting.js";
|
|
2
3
|
import { InlineEntityListPreview } from "../components/InlineEntityListPreview.js";
|
|
3
4
|
import { RelationPreview } from "../components/RelationPreview.js";
|
|
4
5
|
import { jsx } from "react/jsx-runtime";
|
|
5
|
-
import {
|
|
6
|
+
import { normalizeToEntityRelation } from "@rebasepro/cms-types";
|
|
6
7
|
//#region src/preview/property_previews/ArrayOfRelationsPreview.tsx
|
|
7
8
|
/**
|
|
8
9
|
* @group Preview components
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ArrayOfRelationsPreview.js","names":[],"sources":["../../../src/preview/property_previews/ArrayOfRelationsPreview.tsx"],"sourcesContent":["import type { ArrayProperty, RelationProperty } from \"@rebasepro/types\";\nimport { EntityRelation } from \"@rebasepro/types\";\nimport type { PropertyPreviewProps } from \"../../types/components/PropertyPreviewProps\";\nimport { normalizeToEntityRelation
|
|
1
|
+
{"version":3,"file":"ArrayOfRelationsPreview.js","names":[],"sources":["../../../src/preview/property_previews/ArrayOfRelationsPreview.tsx"],"sourcesContent":["import type { ArrayProperty, RelationProperty } from \"@rebasepro/cms-types\";\nimport { EntityRelation } from \"@rebasepro/cms-types\";\nimport type { PropertyPreviewProps } from \"../../types/components/PropertyPreviewProps\";\nimport { normalizeToEntityRelation } from \"@rebasepro/cms-types\";\nimport { getRelationTargetPath } from \"../../util/relations\";\nimport { RelationPreview } from \"../components/RelationPreview\";\nimport { useIsNestedEntityPreview } from \"../../components/EntityPreviewNesting\";\nimport { InlineEntityListPreview } from \"../components/InlineEntityListPreview\";\n\n/**\n * @group Preview components\n */\nexport function ArrayOfRelationsPreview({\n propertyKey,\n value,\n property,\n size,\n textOnly\n}: PropertyPreviewProps<ArrayProperty>) {\n\n const nested = useIsNestedEntityPreview();\n\n if (Array.isArray(property?.of)) {\n throw Error(\"Using array properties instead of single one in `of` in ArrayProperty\");\n }\n\n if (property?.type !== \"array\" || !property.of || property.of.type !== \"relation\")\n throw Error(\"Picked wrong preview component ArrayOfRelationsPreview\");\n\n const ofProperty = property.of as RelationProperty;\n // Elements arrive hydrated or as bare foreign keys depending on the fetch\n // path; the declared target resolves the latter rather than dropping them.\n const relationTargetPath = getRelationTargetPath(ofProperty);\n\n // See ArrayOfReferencesPreview: nested lists stay on one wrapping line.\n if (nested || textOnly || size === \"small\") {\n const relations = ((value ?? []) as unknown[])\n .map(relation => normalizeToEntityRelation(relation, \"relation\", relationTargetPath))\n .filter((relation): relation is EntityRelation => Boolean(relation));\n return <InlineEntityListPreview\n items={relations}\n renderItem={(relation, index) => <RelationPreview\n key={`preview_array_rel_${propertyKey}_${index}`}\n disabled={!ofProperty.relation}\n previewProperties={ofProperty.admin?.previewProperties}\n size={\"small\"}\n relation={relation}\n textOnly={textOnly}\n includeId={ofProperty.admin?.includeId}\n includeEntityLink={ofProperty.admin?.includeEntityLink}\n />}/>;\n }\n\n return (\n <div className=\"flex flex-col w-full gap-0.5\">\n {value ?\n (value as unknown[]).map((relation: unknown, index: number) => {\n const entityRelation = normalizeToEntityRelation(relation, \"relation\", relationTargetPath);\n\n if (!entityRelation) return null;\n\n return (\n <div className=\"w-full\"\n key={`preview_array_rel_${propertyKey}_${index}`}>\n <RelationPreview\n disabled={!ofProperty.relation}\n previewProperties={ofProperty.admin?.previewProperties}\n size={\"small\"}\n relation={entityRelation}\n includeId={ofProperty.admin?.includeId}\n includeEntityLink={ofProperty.admin?.includeEntityLink}\n />\n </div>\n );\n }) : null}\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;AAYA,SAAgB,wBAAwB,EACpC,aACA,OACA,UACA,MACA,YACoC;CAEpC,MAAM,SAAS,yBAAyB;CAExC,IAAI,MAAM,QAAQ,UAAU,EAAE,GAC1B,MAAM,MAAM,uEAAuE;CAGvF,IAAI,UAAU,SAAS,WAAW,CAAC,SAAS,MAAM,SAAS,GAAG,SAAS,YACnE,MAAM,MAAM,wDAAwD;CAExE,MAAM,aAAa,SAAS;CAG5B,MAAM,qBAAqB,sBAAsB,UAAU;CAG3D,IAAI,UAAU,YAAY,SAAS,SAI/B,OAAO,oBAAC,yBAAD;EACH,QAJgB,SAAS,CAAC,EAAA,CACzB,KAAI,aAAY,0BAA0B,UAAU,YAAY,kBAAkB,CAAC,CAAC,CACpF,QAAQ,aAAyC,QAAQ,QAAQ,CAE3D;EACP,aAAa,UAAU,UAAU,oBAAC,iBAAD;GAE7B,UAAU,CAAC,WAAW;GACtB,mBAAmB,WAAW,OAAO;GACrC,MAAM;GACI;GACA;GACV,WAAW,WAAW,OAAO;GAC7B,mBAAmB,WAAW,OAAO;EACxC,GARQ,qBAAqB,YAAY,GAAG,OAQ5C;CAAG,CAAA;CAGZ,OACI,oBAAC,OAAD;EAAK,WAAU;YACV,QACI,MAAoB,KAAK,UAAmB,UAAkB;GAC3D,MAAM,iBAAiB,0BAA0B,UAAU,YAAY,kBAAkB;GAEzF,IAAI,CAAC,gBAAgB,OAAO;GAE5B,OACI,oBAAC,OAAD;IAAK,WAAU;cAEX,oBAAC,iBAAD;KACI,UAAU,CAAC,WAAW;KACtB,mBAAmB,WAAW,OAAO;KACrC,MAAM;KACN,UAAU;KACV,WAAW,WAAW,OAAO;KAC7B,mBAAmB,WAAW,OAAO;IACxC,CAAA;GACA,GATI,qBAAqB,YAAY,GAAG,OASxC;EAEb,CAAC,IAAI;CACR,CAAA;AAEb"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ArrayOfStorageComponentsPreview.js","names":[],"sources":["../../../src/preview/property_previews/ArrayOfStorageComponentsPreview.tsx"],"sourcesContent":["import type { ArrayProperty, Property } from \"@rebasepro/types\";\nimport React from \"react\";\n\nimport type { PropertyPreviewProps, PreviewSize } from \"../../types/components/PropertyPreviewProps\";\nimport { useAuthController, useCustomizationController } from \"@rebasepro/app\";\nimport { PropertyPreview } from \"../PropertyPreview\";\nimport { ErrorBoundary } from \"@rebasepro/ui\";\n\n/**\n * @group Preview components\n */\nexport function ArrayOfStorageComponentsPreview({\n propertyKey,\n // entity,\n value,\n property: property,\n size\n}: PropertyPreviewProps<ArrayProperty>) {\n\n const authController = useAuthController();\n const customizationController = useCustomizationController();\n\n if (Array.isArray(property.of)) {\n throw Error(\"Using array properties instead of single one in `of` in ArrayProperty\");\n }\n\n if (property.type !== \"array\" || !property.of || property.of.type !== \"string\")\n throw Error(\"Picked wrong preview component ArrayOfStorageComponentsPreview\");\n\n const childSize: PreviewSize = size === \"medium\" ? \"medium\" : \"small\";\n\n if (!property.of) {\n throw Error(`You need to specify an 'of' prop (or specify a custom field) in your array property ${propertyKey}`);\n }\n return (\n <div className={\"flex flex-wrap gap-2\"}>\n {value ?\n (value as string[]).map((v, index: number) =>\n <ErrorBoundary key={`preview_array_storage_${propertyKey}_${index}`}>\n <PropertyPreview\n propertyKey={propertyKey}\n value={v}\n property={property.of as Property}\n size={childSize}/>\n </ErrorBoundary>\n ) : null}\n </div>\n );\n}\n"],"mappings":";;;;;;;;;AAWA,SAAgB,gCAAgC,EAC5C,aAEA,OACU,UACV,QACoC;CAEb,kBAAkB;CACT,2BAA2B;CAE3D,IAAI,MAAM,QAAQ,SAAS,EAAE,GACzB,MAAM,MAAM,uEAAuE;CAGvF,IAAI,SAAS,SAAS,WAAW,CAAC,SAAS,MAAM,SAAS,GAAG,SAAS,UAClE,MAAM,MAAM,gEAAgE;CAEhF,MAAM,YAAyB,SAAS,WAAW,WAAW;CAE9D,IAAI,CAAC,SAAS,IACV,MAAM,MAAM,uFAAuF,aAAa;CAEpH,OACI,oBAAC,OAAD;EAAK,WAAW;YACX,QACI,MAAmB,KAAK,GAAG,UACxB,oBAAC,eAAD,EAAA,UACI,oBAAC,iBAAD;GACiB;GACb,OAAO;GACP,UAAU,SAAS;GACnB,MAAM;EAAW,CAAA,EACV,GANK,yBAAyB,YAAY,GAAG,OAM7C,CACnB,IAAI;CACP,CAAA;AAEb"}
|
|
1
|
+
{"version":3,"file":"ArrayOfStorageComponentsPreview.js","names":[],"sources":["../../../src/preview/property_previews/ArrayOfStorageComponentsPreview.tsx"],"sourcesContent":["import type { ArrayProperty, Property } from \"@rebasepro/cms-types\";\nimport React from \"react\";\n\nimport type { PropertyPreviewProps, PreviewSize } from \"../../types/components/PropertyPreviewProps\";\nimport { useAuthController, useCustomizationController } from \"@rebasepro/app\";\nimport { PropertyPreview } from \"../PropertyPreview\";\nimport { ErrorBoundary } from \"@rebasepro/ui\";\n\n/**\n * @group Preview components\n */\nexport function ArrayOfStorageComponentsPreview({\n propertyKey,\n // entity,\n value,\n property: property,\n size\n}: PropertyPreviewProps<ArrayProperty>) {\n\n const authController = useAuthController();\n const customizationController = useCustomizationController();\n\n if (Array.isArray(property.of)) {\n throw Error(\"Using array properties instead of single one in `of` in ArrayProperty\");\n }\n\n if (property.type !== \"array\" || !property.of || property.of.type !== \"string\")\n throw Error(\"Picked wrong preview component ArrayOfStorageComponentsPreview\");\n\n const childSize: PreviewSize = size === \"medium\" ? \"medium\" : \"small\";\n\n if (!property.of) {\n throw Error(`You need to specify an 'of' prop (or specify a custom field) in your array property ${propertyKey}`);\n }\n return (\n <div className={\"flex flex-wrap gap-2\"}>\n {value ?\n (value as string[]).map((v, index: number) =>\n <ErrorBoundary key={`preview_array_storage_${propertyKey}_${index}`}>\n <PropertyPreview\n propertyKey={propertyKey}\n value={v}\n property={property.of as Property}\n size={childSize}/>\n </ErrorBoundary>\n ) : null}\n </div>\n );\n}\n"],"mappings":";;;;;;;;;AAWA,SAAgB,gCAAgC,EAC5C,aAEA,OACU,UACV,QACoC;CAEb,kBAAkB;CACT,2BAA2B;CAE3D,IAAI,MAAM,QAAQ,SAAS,EAAE,GACzB,MAAM,MAAM,uEAAuE;CAGvF,IAAI,SAAS,SAAS,WAAW,CAAC,SAAS,MAAM,SAAS,GAAG,SAAS,UAClE,MAAM,MAAM,gEAAgE;CAEhF,MAAM,YAAyB,SAAS,WAAW,WAAW;CAE9D,IAAI,CAAC,SAAS,IACV,MAAM,MAAM,uFAAuF,aAAa;CAEpH,OACI,oBAAC,OAAD;EAAK,WAAW;YACX,QACI,MAAmB,KAAK,GAAG,UACxB,oBAAC,eAAD,EAAA,UACI,oBAAC,iBAAD;GACiB;GACb,OAAO;GACP,UAAU,SAAS;GACnB,MAAM;EAAW,CAAA,EACV,GANK,yBAAyB,YAAY,GAAG,OAM7C,CACnB,IAAI;CACP,CAAA;AAEb"}
|