@rebasepro/core 0.0.1-canary.0
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/LICENSE +21 -0
- package/README.md +174 -0
- package/dist/app/AppBar.d.ts +12 -0
- package/dist/app/Drawer.d.ts +19 -0
- package/dist/app/Scaffold.d.ts +34 -0
- package/dist/app/index.d.ts +4 -0
- package/dist/app/useApp.d.ts +17 -0
- package/dist/components/AIIcon.d.ts +16 -0
- package/dist/components/AdminModeSyncer.d.ts +17 -0
- package/dist/components/ArrayContainer.d.ts +59 -0
- package/dist/components/CircularProgressCenter.d.ts +11 -0
- package/dist/components/ClearFilterSortButton.d.ts +5 -0
- package/dist/components/ConfirmationDialog.d.ts +9 -0
- package/dist/components/Debug/UIReferenceView.d.ts +1 -0
- package/dist/components/Debug/UIStyleGuide.d.ts +1 -0
- package/dist/components/DeleteEntityDialog.d.ts +12 -0
- package/dist/components/EntityCollectionTable/EntityCollectionRowActions.d.ts +37 -0
- package/dist/components/EntityCollectionTable/EntityCollectionTable.d.ts +27 -0
- package/dist/components/EntityCollectionTable/EntityCollectionTableProps.d.ts +128 -0
- package/dist/components/EntityCollectionTable/PropertyTableCell.d.ts +25 -0
- package/dist/components/EntityCollectionTable/column_utils.d.ts +15 -0
- package/dist/components/EntityCollectionTable/fields/TableMultipleRelationField.d.ts +20 -0
- package/dist/components/EntityCollectionTable/fields/TableReferenceField.d.ts +21 -0
- package/dist/components/EntityCollectionTable/fields/TableRelationField.d.ts +21 -0
- package/dist/components/EntityCollectionTable/fields/TableRelationSelectorField.d.ts +20 -0
- package/dist/components/EntityCollectionTable/fields/TableStorageUpload.d.ts +32 -0
- package/dist/components/EntityCollectionTable/index.d.ts +6 -0
- package/dist/components/EntityCollectionTable/internal/CollectionTableToolbar.d.ts +16 -0
- package/dist/components/EntityCollectionTable/internal/EntityTableCell.d.ts +32 -0
- package/dist/components/EntityCollectionTable/internal/EntityTableCellActions.d.ts +9 -0
- package/dist/components/EntityCollectionTable/internal/common.d.ts +4 -0
- package/dist/components/EntityCollectionTable/internal/popup_field/PopupFormField.d.ts +26 -0
- package/dist/components/EntityCollectionTable/internal/popup_field/useDraggable.d.ts +13 -0
- package/dist/components/EntityCollectionTable/internal/popup_field/useWindowSize.d.ts +6 -0
- package/dist/components/EntityCollectionView/Board.d.ts +2 -0
- package/dist/components/EntityCollectionView/BoardColumn.d.ts +42 -0
- package/dist/components/EntityCollectionView/BoardColumnTitle.d.ts +9 -0
- package/dist/components/EntityCollectionView/BoardSortableList.d.ts +14 -0
- package/dist/components/EntityCollectionView/EntityBoardCard.d.ts +26 -0
- package/dist/components/EntityCollectionView/EntityCard.d.ts +19 -0
- package/dist/components/EntityCollectionView/EntityCollectionBoardView.d.ts +20 -0
- package/dist/components/EntityCollectionView/EntityCollectionCardView.d.ts +31 -0
- package/dist/components/EntityCollectionView/EntityCollectionView.d.ts +54 -0
- package/dist/components/EntityCollectionView/EntityCollectionViewActions.d.ts +14 -0
- package/dist/components/EntityCollectionView/EntityCollectionViewStartActions.d.ts +15 -0
- package/dist/components/EntityCollectionView/FiltersDialog.d.ts +14 -0
- package/dist/components/EntityCollectionView/ViewModeToggle.d.ts +44 -0
- package/dist/components/EntityCollectionView/board_types.d.ts +105 -0
- package/dist/components/EntityCollectionView/useBoardDataController.d.ts +60 -0
- package/dist/components/EntityCollectionView/useSelectionController.d.ts +2 -0
- package/dist/components/EntityCollectionView/utils.d.ts +3 -0
- package/dist/components/EntityJsonPreview.d.ts +3 -0
- package/dist/components/EntityPreview.d.ts +54 -0
- package/dist/components/EntityView.d.ts +11 -0
- package/dist/components/ErrorBoundary.d.ts +11 -0
- package/dist/components/ErrorTooltip.d.ts +2 -0
- package/dist/components/ErrorView.d.ts +21 -0
- package/dist/components/FieldCaption.d.ts +5 -0
- package/dist/components/HomePage/ContentHomePage.d.ts +11 -0
- package/dist/components/HomePage/FavouritesView.d.ts +3 -0
- package/dist/components/HomePage/HomePageDnD.d.ts +77 -0
- package/dist/components/HomePage/NavigationCard.d.ts +10 -0
- package/dist/components/HomePage/NavigationCardBinding.d.ts +18 -0
- package/dist/components/HomePage/NavigationGroup.d.ts +11 -0
- package/dist/components/HomePage/RenameGroupDialog.d.ts +9 -0
- package/dist/components/HomePage/SmallNavigationCard.d.ts +6 -0
- package/dist/components/HomePage/StudioHomePage.d.ts +9 -0
- package/dist/components/HomePage/index.d.ts +5 -0
- package/dist/components/NotFoundPage.d.ts +1 -0
- package/dist/components/PropertyCollectionView.d.ts +22 -0
- package/dist/components/PropertyConfigBadge.d.ts +6 -0
- package/dist/components/PropertyIdCopyTooltip.d.ts +8 -0
- package/dist/components/RebaseLogo.d.ts +7 -0
- package/dist/components/ReferenceTable/EntitySelectionTable.d.ts +58 -0
- package/dist/components/ReferenceWidget.d.ts +29 -0
- package/dist/components/RelationSelector.d.ts +32 -0
- package/dist/components/SearchIconsView.d.ts +5 -0
- package/dist/components/SelectableTable/SelectableTable.d.ts +89 -0
- package/dist/components/SelectableTable/SelectableTableContext.d.ts +4 -0
- package/dist/components/SelectableTable/filters/BooleanFilterField.d.ts +9 -0
- package/dist/components/SelectableTable/filters/DateTimeFilterField.d.ts +12 -0
- package/dist/components/SelectableTable/filters/ReferenceFilterField.d.ts +15 -0
- package/dist/components/SelectableTable/filters/RelationFilterField.d.ts +12 -0
- package/dist/components/SelectableTable/filters/StringNumberFilterField.d.ts +13 -0
- package/dist/components/UnsavedChangesDialog.d.ts +9 -0
- package/dist/components/UserDisplay.d.ts +7 -0
- package/dist/components/UserSettingsView.d.ts +1 -0
- package/dist/components/VirtualTable/VirtualTable.d.ts +11 -0
- package/dist/components/VirtualTable/VirtualTableCell.d.ts +20 -0
- package/dist/components/VirtualTable/VirtualTableHeader.d.ts +29 -0
- package/dist/components/VirtualTable/VirtualTableHeaderRow.d.ts +2 -0
- package/dist/components/VirtualTable/VirtualTableProps.d.ts +239 -0
- package/dist/components/VirtualTable/VirtualTableRow.d.ts +3 -0
- package/dist/components/VirtualTable/fields/VirtualTableDateField.d.ts +12 -0
- package/dist/components/VirtualTable/fields/VirtualTableInput.d.ts +9 -0
- package/dist/components/VirtualTable/fields/VirtualTableNumberInput.d.ts +8 -0
- package/dist/components/VirtualTable/fields/VirtualTableSelect.d.ts +15 -0
- package/dist/components/VirtualTable/fields/VirtualTableSwitch.d.ts +7 -0
- package/dist/components/VirtualTable/fields/VirtualTableUserSelect.d.ts +12 -0
- package/dist/components/VirtualTable/index.d.ts +3 -0
- package/dist/components/VirtualTable/types.d.ts +37 -0
- package/dist/components/admin/RoleChip.d.ts +4 -0
- package/dist/components/admin/RolesView.d.ts +4 -0
- package/dist/components/admin/UsersView.d.ts +4 -0
- package/dist/components/admin/index.d.ts +3 -0
- package/dist/components/common/default_entity_actions.d.ts +4 -0
- package/dist/components/common/index.d.ts +6 -0
- package/dist/components/common/table_height.d.ts +5 -0
- package/dist/components/common/types.d.ts +58 -0
- package/dist/components/common/useColumnsIds.d.ts +6 -0
- package/dist/components/common/useDataSourceTableController.d.ts +44 -0
- package/dist/components/common/useDebouncedCallback.d.ts +1 -0
- package/dist/components/common/useDebouncedData.d.ts +9 -0
- package/dist/components/common/useScrollRestoration.d.ts +14 -0
- package/dist/components/common/useTableSearchHelper.d.ts +11 -0
- package/dist/components/index.d.ts +35 -0
- package/dist/contexts/AdminModeController.d.ts +4 -0
- package/dist/contexts/AnalyticsContext.d.ts +3 -0
- package/dist/contexts/AuthControllerContext.d.ts +3 -0
- package/dist/contexts/BreacrumbsContext.d.ts +8 -0
- package/dist/contexts/CustomizationControllerContext.d.ts +3 -0
- package/dist/contexts/DataSourceContext.d.ts +3 -0
- package/dist/contexts/DialogsProvider.d.ts +4 -0
- package/dist/contexts/EffectiveRoleController.d.ts +4 -0
- package/dist/contexts/InternalUserManagementContext.d.ts +3 -0
- package/dist/contexts/ModeController.d.ts +4 -0
- package/dist/contexts/NavigationContext.d.ts +3 -0
- package/dist/contexts/SideDialogsControllerContext.d.ts +3 -0
- package/dist/contexts/SideEntityControllerContext.d.ts +3 -0
- package/dist/contexts/SnackbarProvider.d.ts +2 -0
- package/dist/contexts/StorageSourceContext.d.ts +3 -0
- package/dist/contexts/UserConfigurationPersistenceContext.d.ts +3 -0
- package/dist/contexts/index.d.ts +15 -0
- package/dist/core/DefaultAppBar.d.ts +29 -0
- package/dist/core/DefaultDrawer.d.ts +29 -0
- package/dist/core/DrawerNavigationGroup.d.ts +45 -0
- package/dist/core/DrawerNavigationItem.d.ts +10 -0
- package/dist/core/EntityEditView.d.ts +47 -0
- package/dist/core/EntityEditViewFormActions.d.ts +2 -0
- package/dist/core/EntitySidePanel.d.ts +10 -0
- package/dist/core/Rebase.d.ts +13 -0
- package/dist/core/RebaseRouter.d.ts +4 -0
- package/dist/core/RebaseRoutes.d.ts +17 -0
- package/dist/core/SideDialogs.d.ts +25 -0
- package/dist/core/field_configs.d.ts +6 -0
- package/dist/core/index.d.ts +9 -0
- package/dist/form/EntityForm.d.ts +7 -0
- package/dist/form/EntityFormActions.d.ts +2 -0
- package/dist/form/PropertyFieldBinding.d.ts +30 -0
- package/dist/form/components/ErrorFocus.d.ts +4 -0
- package/dist/form/components/FieldHelperText.d.ts +12 -0
- package/dist/form/components/FormEntry.d.ts +6 -0
- package/dist/form/components/FormLayout.d.ts +5 -0
- package/dist/form/components/LabelWithIcon.d.ts +14 -0
- package/dist/form/components/LabelWithIconAndTooltip.d.ts +15 -0
- package/dist/form/components/LocalChangesMenu.d.ts +11 -0
- package/dist/form/components/StorageItemPreview.d.ts +13 -0
- package/dist/form/components/StorageUploadProgress.d.ts +10 -0
- package/dist/form/components/index.d.ts +5 -0
- package/dist/form/field_bindings/ArrayCustomShapedFieldBinding.d.ts +9 -0
- package/dist/form/field_bindings/ArrayOfReferencesFieldBinding.d.ts +11 -0
- package/dist/form/field_bindings/BlockFieldBinding.d.ts +10 -0
- package/dist/form/field_bindings/DateTimeFieldBinding.d.ts +11 -0
- package/dist/form/field_bindings/KeyValueFieldBinding.d.ts +7 -0
- package/dist/form/field_bindings/MapFieldBinding.d.ts +9 -0
- package/dist/form/field_bindings/MarkdownEditorFieldBinding.d.ts +11 -0
- package/dist/form/field_bindings/MultiSelectFieldBinding.d.ts +9 -0
- package/dist/form/field_bindings/MultipleRelationFieldBinding.d.ts +9 -0
- package/dist/form/field_bindings/ReadOnlyFieldBinding.d.ts +10 -0
- package/dist/form/field_bindings/ReferenceAsStringFieldBinding.d.ts +9 -0
- package/dist/form/field_bindings/ReferenceFieldBinding.d.ts +9 -0
- package/dist/form/field_bindings/RelationFieldBinding.d.ts +2 -0
- package/dist/form/field_bindings/RepeatFieldBinding.d.ts +10 -0
- package/dist/form/field_bindings/SelectFieldBinding.d.ts +10 -0
- package/dist/form/field_bindings/StorageUploadFieldBinding.d.ts +19 -0
- package/dist/form/field_bindings/SwitchFieldBinding.d.ts +9 -0
- package/dist/form/field_bindings/TextFieldBinding.d.ts +8 -0
- package/dist/form/field_bindings/UserSelectFieldBinding.d.ts +12 -0
- package/dist/form/index.d.ts +20 -0
- package/dist/form/useClearRestoreValue.d.ts +13 -0
- package/dist/form/validation.d.ts +26 -0
- package/dist/hooks/ApiConfigContext.d.ts +24 -0
- package/dist/hooks/data/delete.d.ts +33 -0
- package/dist/hooks/data/save.d.ts +37 -0
- package/dist/hooks/data/useCollectionFetch.d.ts +50 -0
- package/dist/hooks/data/useDataOrder.d.ts +12 -0
- package/dist/hooks/data/useDataSource.d.ts +6 -0
- package/dist/hooks/data/useEntityFetch.d.ts +29 -0
- package/dist/hooks/data/useRelationSelector.d.ts +45 -0
- package/dist/hooks/index.d.ts +41 -0
- package/dist/hooks/navigation/contexts/CMSUrlContext.d.ts +4 -0
- package/dist/hooks/navigation/contexts/CollectionRegistryContext.d.ts +4 -0
- package/dist/hooks/navigation/contexts/NavigationStateContext.d.ts +4 -0
- package/dist/hooks/navigation/contexts/index.d.ts +3 -0
- package/dist/hooks/navigation/useBuildCMSUrlController.d.ts +6 -0
- package/dist/hooks/navigation/useBuildCollectionRegistryController.d.ts +7 -0
- package/dist/hooks/navigation/useBuildNavigationStateController.d.ts +32 -0
- package/dist/hooks/navigation/useNavigationRegistry.d.ts +10 -0
- package/dist/hooks/navigation/useNavigationResolution.d.ts +5 -0
- package/dist/hooks/navigation/useNavigationURLs.d.ts +11 -0
- package/dist/hooks/navigation/useResolvedCollections.d.ts +26 -0
- package/dist/hooks/navigation/useResolvedViews.d.ts +28 -0
- package/dist/hooks/navigation/useTopLevelNavigation.d.ts +26 -0
- package/dist/hooks/navigation/utils.d.ts +12 -0
- package/dist/hooks/useAdminModeController.d.ts +19 -0
- package/dist/hooks/useAnalyticsController.d.ts +5 -0
- package/dist/hooks/useAuthController.d.ts +11 -0
- package/dist/hooks/useBackendStorageSource.d.ts +30 -0
- package/dist/hooks/useBreadcrumbsController.d.ts +42 -0
- package/dist/hooks/useBrowserTitleAndIcon.d.ts +6 -0
- package/dist/hooks/useBuildAdminModeController.d.ts +6 -0
- package/dist/hooks/useBuildEffectiveRoleController.d.ts +8 -0
- package/dist/hooks/useBuildLocalConfigurationPersistence.d.ts +2 -0
- package/dist/hooks/useBuildModeController.d.ts +6 -0
- package/dist/hooks/useBuildNavigationController.d.ts +16 -0
- package/dist/hooks/useClipboard.d.ts +57 -0
- package/dist/hooks/useCollapsedGroups.d.ts +12 -0
- package/dist/hooks/useCustomizationController.d.ts +11 -0
- package/dist/hooks/useDialogsController.d.ts +11 -0
- package/dist/hooks/useEffectiveRoleController.d.ts +7 -0
- package/dist/hooks/useEntitySelectionDialog.d.ts +18 -0
- package/dist/hooks/useInternalUserManagementController.d.ts +12 -0
- package/dist/hooks/useLargeLayout.d.ts +1 -0
- package/dist/hooks/useModeController.d.ts +19 -0
- package/dist/hooks/usePermissions.d.ts +11 -0
- package/dist/hooks/useRebaseContext.d.ts +11 -0
- package/dist/hooks/useResolvedNavigationFrom.d.ts +72 -0
- package/dist/hooks/useSideDialogsController.d.ts +18 -0
- package/dist/hooks/useSideEntityController.d.ts +12 -0
- package/dist/hooks/useSnackbarController.d.ts +20 -0
- package/dist/hooks/useStorageSource.d.ts +6 -0
- package/dist/hooks/useUnsavedChangesDialog.d.ts +12 -0
- package/dist/hooks/useUserConfigurationPersistence.d.ts +8 -0
- package/dist/hooks/useValidateAuthenticator.d.ts +21 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.es.js +34745 -0
- package/dist/index.es.js.map +1 -0
- package/dist/index.umd.js +34751 -0
- package/dist/index.umd.js.map +1 -0
- package/dist/internal/common.d.ts +3 -0
- package/dist/internal/useBuildDataSource.d.ts +12 -0
- package/dist/internal/useBuildSideDialogsController.d.ts +2 -0
- package/dist/internal/useBuildSideEntityController.d.ts +4 -0
- package/dist/internal/useRestoreScroll.d.ts +6 -0
- package/dist/preview/PropertyPreview.d.ts +6 -0
- package/dist/preview/components/ArrayEnumPreview.d.ts +10 -0
- package/dist/preview/components/AsyncPreviewComponent.d.ts +11 -0
- package/dist/preview/components/BooleanPreview.d.ts +10 -0
- package/dist/preview/components/DatePreview.d.ts +17 -0
- package/dist/preview/components/EmptyValue.d.ts +6 -0
- package/dist/preview/components/EnumValuesChip.d.ts +13 -0
- package/dist/preview/components/ImagePreview.d.ts +16 -0
- package/dist/preview/components/ReferencePreview.d.ts +16 -0
- package/dist/preview/components/RelationPreview.d.ts +16 -0
- package/dist/preview/components/StorageThumbnail.d.ts +15 -0
- package/dist/preview/components/UrlComponentPreview.d.ts +13 -0
- package/dist/preview/components/UserPreview.d.ts +8 -0
- package/dist/preview/index.d.ts +24 -0
- package/dist/preview/property_previews/ArrayOfMapsPreview.d.ts +5 -0
- package/dist/preview/property_previews/ArrayOfReferencesPreview.d.ts +5 -0
- package/dist/preview/property_previews/ArrayOfRelationsPreview.d.ts +5 -0
- package/dist/preview/property_previews/ArrayOfStorageComponentsPreview.d.ts +5 -0
- package/dist/preview/property_previews/ArrayOfStringsPreview.d.ts +5 -0
- package/dist/preview/property_previews/ArrayOneOfPreview.d.ts +5 -0
- package/dist/preview/property_previews/ArrayPropertyEnumPreview.d.ts +5 -0
- package/dist/preview/property_previews/ArrayPropertyPreview.d.ts +5 -0
- package/dist/preview/property_previews/MapPropertyPreview.d.ts +8 -0
- package/dist/preview/property_previews/NumberPropertyPreview.d.ts +6 -0
- package/dist/preview/property_previews/SkeletonPropertyComponent.d.ts +13 -0
- package/dist/preview/property_previews/StringPropertyPreview.d.ts +6 -0
- package/dist/preview/util.d.ts +6 -0
- package/dist/routes/CustomCMSRoute.d.ts +4 -0
- package/dist/routes/RebaseRoute.d.ts +1 -0
- package/dist/routes/index.d.ts +2 -0
- package/dist/util/createFormexStub.d.ts +2 -0
- package/dist/util/entity_cache.d.ts +27 -0
- package/dist/util/enums.d.ts +5 -0
- package/dist/util/icon_list.d.ts +5 -0
- package/dist/util/icon_synonyms.d.ts +1853 -0
- package/dist/util/icons.d.ts +16 -0
- package/dist/util/index.d.ts +11 -0
- package/dist/util/previews.d.ts +3 -0
- package/dist/util/property_utils.d.ts +23 -0
- package/dist/util/useDebouncedCallback.d.ts +1 -0
- package/dist/util/useStorageUploadController.d.ts +36 -0
- package/dist/util/useTraceUpdate.d.ts +2 -0
- package/dist/vitePlugin.d.ts +16 -0
- package/package.json +165 -0
- package/src/app/AppBar.tsx +18 -0
- package/src/app/Drawer.tsx +30 -0
- package/src/app/Scaffold.tsx +238 -0
- package/src/app/index.ts +4 -0
- package/src/app/useApp.tsx +36 -0
- package/src/components/AIIcon.tsx +39 -0
- package/src/components/AdminModeSyncer.tsx +47 -0
- package/src/components/ArrayContainer.tsx +549 -0
- package/src/components/CircularProgressCenter.tsx +26 -0
- package/src/components/ClearFilterSortButton.tsx +44 -0
- package/src/components/ConfirmationDialog.tsx +46 -0
- package/src/components/Debug/UIReferenceView.tsx +710 -0
- package/src/components/Debug/UIStyleGuide.tsx +164 -0
- package/src/components/DeleteEntityDialog.tsx +181 -0
- package/src/components/EntityCollectionTable/EntityCollectionRowActions.tsx +225 -0
- package/src/components/EntityCollectionTable/EntityCollectionTable.tsx +383 -0
- package/src/components/EntityCollectionTable/EntityCollectionTableProps.tsx +180 -0
- package/src/components/EntityCollectionTable/PropertyTableCell.tsx +561 -0
- package/src/components/EntityCollectionTable/column_utils.tsx +74 -0
- package/src/components/EntityCollectionTable/fields/TableMultipleRelationField.tsx +122 -0
- package/src/components/EntityCollectionTable/fields/TableReferenceField.tsx +169 -0
- package/src/components/EntityCollectionTable/fields/TableRelationField.tsx +177 -0
- package/src/components/EntityCollectionTable/fields/TableRelationSelectorField.tsx +42 -0
- package/src/components/EntityCollectionTable/fields/TableStorageUpload.tsx +315 -0
- package/src/components/EntityCollectionTable/index.tsx +12 -0
- package/src/components/EntityCollectionTable/internal/CollectionTableToolbar.tsx +90 -0
- package/src/components/EntityCollectionTable/internal/EntityTableCell.tsx +311 -0
- package/src/components/EntityCollectionTable/internal/EntityTableCellActions.tsx +82 -0
- package/src/components/EntityCollectionTable/internal/common.tsx +72 -0
- package/src/components/EntityCollectionTable/internal/popup_field/PopupFormField.tsx +425 -0
- package/src/components/EntityCollectionTable/internal/popup_field/useDraggable.tsx +96 -0
- package/src/components/EntityCollectionTable/internal/popup_field/useWindowSize.tsx +20 -0
- package/src/components/EntityCollectionView/Board.tsx +324 -0
- package/src/components/EntityCollectionView/BoardColumn.tsx +158 -0
- package/src/components/EntityCollectionView/BoardColumnTitle.tsx +45 -0
- package/src/components/EntityCollectionView/BoardSortableList.tsx +172 -0
- package/src/components/EntityCollectionView/EntityBoardCard.tsx +200 -0
- package/src/components/EntityCollectionView/EntityCard.tsx +225 -0
- package/src/components/EntityCollectionView/EntityCollectionBoardView.tsx +746 -0
- package/src/components/EntityCollectionView/EntityCollectionCardView.tsx +254 -0
- package/src/components/EntityCollectionView/EntityCollectionView.tsx +1220 -0
- package/src/components/EntityCollectionView/EntityCollectionViewActions.tsx +142 -0
- package/src/components/EntityCollectionView/EntityCollectionViewStartActions.tsx +131 -0
- package/src/components/EntityCollectionView/FiltersDialog.tsx +249 -0
- package/src/components/EntityCollectionView/ViewModeToggle.tsx +194 -0
- package/src/components/EntityCollectionView/board_types.ts +113 -0
- package/src/components/EntityCollectionView/useBoardDataController.tsx +490 -0
- package/src/components/EntityCollectionView/useSelectionController.tsx +43 -0
- package/src/components/EntityCollectionView/utils.ts +19 -0
- package/src/components/EntityJsonPreview.tsx +66 -0
- package/src/components/EntityPreview.tsx +367 -0
- package/src/components/EntityView.tsx +66 -0
- package/src/components/ErrorBoundary.tsx +40 -0
- package/src/components/ErrorTooltip.tsx +12 -0
- package/src/components/ErrorView.tsx +69 -0
- package/src/components/FieldCaption.tsx +14 -0
- package/src/components/HomePage/ContentHomePage.tsx +634 -0
- package/src/components/HomePage/FavouritesView.tsx +59 -0
- package/src/components/HomePage/HomePageDnD.tsx +702 -0
- package/src/components/HomePage/NavigationCard.tsx +80 -0
- package/src/components/HomePage/NavigationCardBinding.tsx +111 -0
- package/src/components/HomePage/NavigationGroup.tsx +154 -0
- package/src/components/HomePage/RenameGroupDialog.tsx +121 -0
- package/src/components/HomePage/SmallNavigationCard.tsx +45 -0
- package/src/components/HomePage/StudioHomePage.tsx +231 -0
- package/src/components/HomePage/index.tsx +6 -0
- package/src/components/NotFoundPage.tsx +25 -0
- package/src/components/PropertyCollectionView.tsx +333 -0
- package/src/components/PropertyConfigBadge.tsx +27 -0
- package/src/components/PropertyIdCopyTooltip.tsx +47 -0
- package/src/components/RebaseLogo.tsx +29 -0
- package/src/components/ReferenceTable/EntitySelectionTable.tsx +371 -0
- package/src/components/ReferenceWidget.tsx +152 -0
- package/src/components/RelationSelector.tsx +518 -0
- package/src/components/SearchIconsView.tsx +78 -0
- package/src/components/SelectableTable/SelectableTable.tsx +344 -0
- package/src/components/SelectableTable/SelectableTableContext.tsx +6 -0
- package/src/components/SelectableTable/filters/BooleanFilterField.tsx +49 -0
- package/src/components/SelectableTable/filters/DateTimeFilterField.tsx +126 -0
- package/src/components/SelectableTable/filters/ReferenceFilterField.tsx +203 -0
- package/src/components/SelectableTable/filters/RelationFilterField.tsx +138 -0
- package/src/components/SelectableTable/filters/StringNumberFilterField.tsx +217 -0
- package/src/components/UnsavedChangesDialog.tsx +45 -0
- package/src/components/UserDisplay.tsx +55 -0
- package/src/components/UserSettingsView.tsx +220 -0
- package/src/components/VirtualTable/VirtualTable.performance.test.tsx +386 -0
- package/src/components/VirtualTable/VirtualTable.tsx +625 -0
- package/src/components/VirtualTable/VirtualTableCell.tsx +58 -0
- package/src/components/VirtualTable/VirtualTableHeader.tsx +275 -0
- package/src/components/VirtualTable/VirtualTableHeaderRow.tsx +249 -0
- package/src/components/VirtualTable/VirtualTableProps.tsx +298 -0
- package/src/components/VirtualTable/VirtualTableRow.tsx +52 -0
- package/src/components/VirtualTable/fields/VirtualTableDateField.tsx +39 -0
- package/src/components/VirtualTable/fields/VirtualTableInput.tsx +93 -0
- package/src/components/VirtualTable/fields/VirtualTableNumberInput.tsx +83 -0
- package/src/components/VirtualTable/fields/VirtualTableSelect.tsx +133 -0
- package/src/components/VirtualTable/fields/VirtualTableSwitch.tsx +32 -0
- package/src/components/VirtualTable/fields/VirtualTableUserSelect.tsx +111 -0
- package/src/components/VirtualTable/index.tsx +3 -0
- package/src/components/VirtualTable/types.tsx +46 -0
- package/src/components/admin/RoleChip.tsx +23 -0
- package/src/components/admin/RolesView.tsx +408 -0
- package/src/components/admin/UsersView.tsx +353 -0
- package/src/components/admin/index.ts +3 -0
- package/src/components/common/default_entity_actions.tsx +144 -0
- package/src/components/common/index.ts +6 -0
- package/src/components/common/table_height.tsx +21 -0
- package/src/components/common/types.tsx +61 -0
- package/src/components/common/useColumnsIds.tsx +210 -0
- package/src/components/common/useDataSourceTableController.tsx +480 -0
- package/src/components/common/useDebouncedCallback.tsx +20 -0
- package/src/components/common/useDebouncedData.ts +49 -0
- package/src/components/common/useScrollRestoration.tsx +68 -0
- package/src/components/common/useTableSearchHelper.ts +75 -0
- package/src/components/index.tsx +49 -0
- package/src/contexts/AdminModeController.tsx +11 -0
- package/src/contexts/AnalyticsContext.tsx +4 -0
- package/src/contexts/AuthControllerContext.tsx +4 -0
- package/src/contexts/BreacrumbsContext.tsx +45 -0
- package/src/contexts/CustomizationControllerContext.tsx +4 -0
- package/src/contexts/DataSourceContext.tsx +4 -0
- package/src/contexts/DialogsProvider.tsx +53 -0
- package/src/contexts/EffectiveRoleController.tsx +11 -0
- package/src/contexts/InternalUserManagementContext.tsx +4 -0
- package/src/contexts/ModeController.tsx +11 -0
- package/src/contexts/NavigationContext.tsx +4 -0
- package/src/contexts/SideDialogsControllerContext.tsx +4 -0
- package/src/contexts/SideEntityControllerContext.tsx +4 -0
- package/src/contexts/SnackbarProvider.tsx +14 -0
- package/src/contexts/StorageSourceContext.tsx +4 -0
- package/src/contexts/UserConfigurationPersistenceContext.tsx +4 -0
- package/src/contexts/index.ts +15 -0
- package/src/core/DefaultAppBar.tsx +274 -0
- package/src/core/DefaultDrawer.tsx +267 -0
- package/src/core/DrawerNavigationGroup.tsx +117 -0
- package/src/core/DrawerNavigationItem.tsx +65 -0
- package/src/core/EntityEditView.tsx +590 -0
- package/src/core/EntityEditViewFormActions.tsx +343 -0
- package/src/core/EntitySidePanel.tsx +173 -0
- package/src/core/Rebase.tsx +229 -0
- package/src/core/RebaseRouter.tsx +17 -0
- package/src/core/RebaseRoutes.tsx +47 -0
- package/src/core/SideDialogs.tsx +200 -0
- package/src/core/field_configs.tsx +443 -0
- package/src/core/index.tsx +14 -0
- package/src/form/EntityForm.tsx +820 -0
- package/src/form/EntityFormActions.tsx +201 -0
- package/src/form/PropertyFieldBinding.tsx +348 -0
- package/src/form/components/ErrorFocus.tsx +44 -0
- package/src/form/components/FieldHelperText.tsx +45 -0
- package/src/form/components/FormEntry.tsx +22 -0
- package/src/form/components/FormLayout.tsx +16 -0
- package/src/form/components/LabelWithIcon.tsx +43 -0
- package/src/form/components/LabelWithIconAndTooltip.tsx +28 -0
- package/src/form/components/LocalChangesMenu.tsx +144 -0
- package/src/form/components/StorageItemPreview.tsx +79 -0
- package/src/form/components/StorageUploadProgress.tsx +105 -0
- package/src/form/components/index.tsx +5 -0
- package/src/form/field_bindings/ArrayCustomShapedFieldBinding.tsx +105 -0
- package/src/form/field_bindings/ArrayOfReferencesFieldBinding.tsx +163 -0
- package/src/form/field_bindings/BlockFieldBinding.tsx +268 -0
- package/src/form/field_bindings/DateTimeFieldBinding.tsx +70 -0
- package/src/form/field_bindings/KeyValueFieldBinding.tsx +567 -0
- package/src/form/field_bindings/MapFieldBinding.tsx +156 -0
- package/src/form/field_bindings/MarkdownEditorFieldBinding.tsx +146 -0
- package/src/form/field_bindings/MultiSelectFieldBinding.tsx +120 -0
- package/src/form/field_bindings/MultipleRelationFieldBinding.tsx +151 -0
- package/src/form/field_bindings/ReadOnlyFieldBinding.tsx +64 -0
- package/src/form/field_bindings/ReferenceAsStringFieldBinding.tsx +135 -0
- package/src/form/field_bindings/ReferenceFieldBinding.tsx +134 -0
- package/src/form/field_bindings/RelationFieldBinding.tsx +176 -0
- package/src/form/field_bindings/RepeatFieldBinding.tsx +136 -0
- package/src/form/field_bindings/SelectFieldBinding.tsx +107 -0
- package/src/form/field_bindings/StorageUploadFieldBinding.tsx +490 -0
- package/src/form/field_bindings/SwitchFieldBinding.tsx +64 -0
- package/src/form/field_bindings/TextFieldBinding.tsx +153 -0
- package/src/form/field_bindings/UserSelectFieldBinding.tsx +96 -0
- package/src/form/index.tsx +27 -0
- package/src/form/useClearRestoreValue.tsx +35 -0
- package/src/form/validation.ts +532 -0
- package/src/hooks/ApiConfigContext.tsx +40 -0
- package/src/hooks/data/delete.ts +77 -0
- package/src/hooks/data/save.ts +75 -0
- package/src/hooks/data/useCollectionFetch.tsx +148 -0
- package/src/hooks/data/useDataOrder.ts +26 -0
- package/src/hooks/data/useDataSource.tsx +22 -0
- package/src/hooks/data/useEntityFetch.tsx +121 -0
- package/src/hooks/data/useRelationSelector.tsx +205 -0
- package/src/hooks/index.tsx +51 -0
- package/src/hooks/navigation/contexts/CMSUrlContext.tsx +24 -0
- package/src/hooks/navigation/contexts/CollectionRegistryContext.tsx +19 -0
- package/src/hooks/navigation/contexts/NavigationStateContext.tsx +15 -0
- package/src/hooks/navigation/contexts/index.ts +14 -0
- package/src/hooks/navigation/useBuildCMSUrlController.tsx +68 -0
- package/src/hooks/navigation/useBuildCollectionRegistryController.tsx +150 -0
- package/src/hooks/navigation/useBuildNavigationStateController.tsx +135 -0
- package/src/hooks/navigation/useNavigationRegistry.ts +142 -0
- package/src/hooks/navigation/useNavigationResolution.ts +98 -0
- package/src/hooks/navigation/useNavigationURLs.ts +56 -0
- package/src/hooks/navigation/useResolvedCollections.ts +139 -0
- package/src/hooks/navigation/useResolvedViews.tsx +204 -0
- package/src/hooks/navigation/useTopLevelNavigation.ts +265 -0
- package/src/hooks/navigation/utils.ts +177 -0
- package/src/hooks/useAdminModeController.tsx +23 -0
- package/src/hooks/useAnalyticsController.tsx +8 -0
- package/src/hooks/useAuthController.tsx +14 -0
- package/src/hooks/useBackendStorageSource.ts +276 -0
- package/src/hooks/useBreadcrumbsController.tsx +49 -0
- package/src/hooks/useBrowserTitleAndIcon.tsx +25 -0
- package/src/hooks/useBuildAdminModeController.tsx +24 -0
- package/src/hooks/useBuildEffectiveRoleController.tsx +30 -0
- package/src/hooks/useBuildLocalConfigurationPersistence.tsx +65 -0
- package/src/hooks/useBuildModeController.tsx +71 -0
- package/src/hooks/useBuildNavigationController.tsx +341 -0
- package/src/hooks/useClipboard.tsx +158 -0
- package/src/hooks/useCollapsedGroups.ts +72 -0
- package/src/hooks/useCustomizationController.tsx +14 -0
- package/src/hooks/useDialogsController.tsx +14 -0
- package/src/hooks/useEffectiveRoleController.tsx +10 -0
- package/src/hooks/useEntitySelectionDialog.tsx +56 -0
- package/src/hooks/useInternalUserManagementController.tsx +17 -0
- package/src/hooks/useLargeLayout.tsx +65 -0
- package/src/hooks/useModeController.tsx +23 -0
- package/src/hooks/usePermissions.ts +43 -0
- package/src/hooks/useRebaseContext.tsx +86 -0
- package/src/hooks/useResolvedNavigationFrom.tsx +158 -0
- package/src/hooks/useSideDialogsController.tsx +21 -0
- package/src/hooks/useSideEntityController.tsx +15 -0
- package/src/hooks/useSnackbarController.tsx +52 -0
- package/src/hooks/useStorageSource.tsx +14 -0
- package/src/hooks/useUnsavedChangesDialog.tsx +62 -0
- package/src/hooks/useUserConfigurationPersistence.tsx +11 -0
- package/src/hooks/useValidateAuthenticator.tsx +115 -0
- package/src/index.ts +17 -0
- package/src/internal/common.tsx +5 -0
- package/src/internal/useBuildDataSource.ts +380 -0
- package/src/internal/useBuildSideDialogsController.tsx +135 -0
- package/src/internal/useBuildSideEntityController.tsx +309 -0
- package/src/internal/useRestoreScroll.tsx +60 -0
- package/src/preview/PropertyPreview.tsx +308 -0
- package/src/preview/components/ArrayEnumPreview.tsx +38 -0
- package/src/preview/components/AsyncPreviewComponent.tsx +47 -0
- package/src/preview/components/BooleanPreview.tsx +25 -0
- package/src/preview/components/DatePreview.tsx +94 -0
- package/src/preview/components/EmptyValue.tsx +10 -0
- package/src/preview/components/EnumValuesChip.tsx +39 -0
- package/src/preview/components/ImagePreview.tsx +111 -0
- package/src/preview/components/ReferencePreview.tsx +162 -0
- package/src/preview/components/RelationPreview.tsx +153 -0
- package/src/preview/components/StorageThumbnail.tsx +91 -0
- package/src/preview/components/UrlComponentPreview.tsx +113 -0
- package/src/preview/components/UserPreview.tsx +27 -0
- package/src/preview/index.ts +26 -0
- package/src/preview/property_previews/ArrayOfMapsPreview.tsx +72 -0
- package/src/preview/property_previews/ArrayOfReferencesPreview.tsx +43 -0
- package/src/preview/property_previews/ArrayOfRelationsPreview.tsx +52 -0
- package/src/preview/property_previews/ArrayOfStorageComponentsPreview.tsx +49 -0
- package/src/preview/property_previews/ArrayOfStringsPreview.tsx +44 -0
- package/src/preview/property_previews/ArrayOneOfPreview.tsx +67 -0
- package/src/preview/property_previews/ArrayPropertyEnumPreview.tsx +34 -0
- package/src/preview/property_previews/ArrayPropertyPreview.tsx +69 -0
- package/src/preview/property_previews/MapPropertyPreview.tsx +145 -0
- package/src/preview/property_previews/NumberPropertyPreview.tsx +28 -0
- package/src/preview/property_previews/SkeletonPropertyComponent.tsx +275 -0
- package/src/preview/property_previews/StringPropertyPreview.tsx +57 -0
- package/src/preview/util.ts +30 -0
- package/src/routes/CustomCMSRoute.tsx +21 -0
- package/src/routes/RebaseRoute.tsx +255 -0
- package/src/routes/index.ts +2 -0
- package/src/util/createFormexStub.tsx +66 -0
- package/src/util/entity_cache.ts +267 -0
- package/src/util/enums.ts +32 -0
- package/src/util/icon_list.ts +23 -0
- package/src/util/icon_synonyms.ts +1853 -0
- package/src/util/icons.tsx +87 -0
- package/src/util/index.ts +11 -0
- package/src/util/previews.ts +50 -0
- package/src/util/property_utils.tsx +152 -0
- package/src/util/useDebouncedCallback.ts +25 -0
- package/src/util/useStorageUploadController.tsx +342 -0
- package/src/util/useTraceUpdate.tsx +24 -0
- package/src/vitePlugin.ts +47 -0
|
@@ -0,0 +1,309 @@
|
|
|
1
|
+
import { useCallback, useEffect, useRef } from "react";
|
|
2
|
+
import {
|
|
3
|
+
AuthController,
|
|
4
|
+
CustomizationController,
|
|
5
|
+
EntityCollection,
|
|
6
|
+
EntitySidePanelProps,
|
|
7
|
+
SideDialogPanelProps,
|
|
8
|
+
SideDialogsController,
|
|
9
|
+
SideEntityController,
|
|
10
|
+
CollectionRegistryController,
|
|
11
|
+
CMSUrlController,
|
|
12
|
+
NavigationStateController,
|
|
13
|
+
Property
|
|
14
|
+
} from "@rebasepro/types";
|
|
15
|
+
import { useLocation } from "react-router-dom";
|
|
16
|
+
import {
|
|
17
|
+
getNavigationEntriesFromPath,
|
|
18
|
+
NavigationViewInternal,
|
|
19
|
+
removeInitialAndTrailingSlashes,
|
|
20
|
+
resolveDefaultSelectedView, resolvedSelectedEntityView,
|
|
21
|
+
} from "@rebasepro/common";
|
|
22
|
+
import { ADDITIONAL_TAB_WIDTH, CONTAINER_FULL_WIDTH, FORM_CONTAINER_WIDTH } from "./common";
|
|
23
|
+
import { useCustomizationController, useLargeLayout } from "../hooks";
|
|
24
|
+
import { JSON_TAB_VALUE } from "../core/EntityEditView";
|
|
25
|
+
|
|
26
|
+
const NEW_URL_HASH = "new_side";
|
|
27
|
+
const SIDE_URL_HASH = "side";
|
|
28
|
+
|
|
29
|
+
export function getEntityViewWidth(props: EntitySidePanelProps<any>, small: boolean, customizationController: CustomizationController): string {
|
|
30
|
+
if (small) return CONTAINER_FULL_WIDTH;
|
|
31
|
+
|
|
32
|
+
const {
|
|
33
|
+
selectedSecondaryForm
|
|
34
|
+
} = resolvedSelectedEntityView(props.collection?.entityViews, customizationController, props.selectedTab);
|
|
35
|
+
|
|
36
|
+
const shouldUseSmallLayout = !props.selectedTab || props.selectedTab === JSON_TAB_VALUE || props.selectedTab === "__history" || Boolean(selectedSecondaryForm);
|
|
37
|
+
|
|
38
|
+
let resolvedWidth: string | undefined;
|
|
39
|
+
if (props.width) {
|
|
40
|
+
resolvedWidth = typeof props.width === "number" ? `${props.width}px` : props.width;
|
|
41
|
+
} else if (props.collection?.sideDialogWidth) {
|
|
42
|
+
resolvedWidth = typeof props.collection.sideDialogWidth === "number" ? `${props.collection.sideDialogWidth}px` : props.collection.sideDialogWidth;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (!shouldUseSmallLayout) {
|
|
46
|
+
return `calc(${ADDITIONAL_TAB_WIDTH} + ${resolvedWidth ?? FORM_CONTAINER_WIDTH})`
|
|
47
|
+
} else {
|
|
48
|
+
if (resolvedWidth) {
|
|
49
|
+
return resolvedWidth
|
|
50
|
+
} else if (!props.collection) {
|
|
51
|
+
return FORM_CONTAINER_WIDTH;
|
|
52
|
+
} else {
|
|
53
|
+
return calculateCollectionDesiredWidth(props.collection);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const collectionViewWidthCache: { [key: string]: string } = {};
|
|
59
|
+
|
|
60
|
+
function calculateCollectionDesiredWidth(collection: EntityCollection<any>): string {
|
|
61
|
+
if (collectionViewWidthCache[collection.slug]) {
|
|
62
|
+
return collectionViewWidthCache[collection.slug];
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
let result = FORM_CONTAINER_WIDTH
|
|
66
|
+
if (collection?.properties) {
|
|
67
|
+
const values = Object.values(collection.properties).map((p: Property) => getNestedPropertiesDepth(p));
|
|
68
|
+
const maxDepth = Math.max(...values);
|
|
69
|
+
if (maxDepth < 3) {
|
|
70
|
+
result = FORM_CONTAINER_WIDTH;
|
|
71
|
+
} else {
|
|
72
|
+
result = 768 + 32 * (maxDepth - 2) + "px";
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
collectionViewWidthCache[collection.slug] = result;
|
|
76
|
+
return result;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function getNestedPropertiesDepth(property: Property, accumulator: number = 0): number {
|
|
80
|
+
if (property.type === "map" && property.properties) {
|
|
81
|
+
const values = Object.values(property.properties).flatMap((property) => getNestedPropertiesDepth(property, accumulator + 1));
|
|
82
|
+
return Math.max(...values);
|
|
83
|
+
} else if (property.type === "array" && property.oneOf) {
|
|
84
|
+
return accumulator + 3;
|
|
85
|
+
} else if (property.type === "array" && property.of) {
|
|
86
|
+
if (Array.isArray(property.of)) {
|
|
87
|
+
return Math.max(...property.of.map((p) => getNestedPropertiesDepth(p, accumulator + 1)));
|
|
88
|
+
} else {
|
|
89
|
+
return getNestedPropertiesDepth(property.of, accumulator + 1);
|
|
90
|
+
}
|
|
91
|
+
} else {
|
|
92
|
+
return accumulator + 1;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export const useBuildSideEntityController = (collectionRegistryController: CollectionRegistryController,
|
|
97
|
+
cmsUrlController: CMSUrlController,
|
|
98
|
+
navigationStateController: NavigationStateController,
|
|
99
|
+
sideDialogsController: SideDialogsController,
|
|
100
|
+
authController: AuthController
|
|
101
|
+
): SideEntityController => {
|
|
102
|
+
|
|
103
|
+
const location = useLocation();
|
|
104
|
+
const initialised = useRef<boolean>(false);
|
|
105
|
+
const currentPanelKeysRef = useRef<string[]>([]);
|
|
106
|
+
const customizationController = useCustomizationController();
|
|
107
|
+
|
|
108
|
+
const smallLayout = !useLargeLayout();
|
|
109
|
+
|
|
110
|
+
useEffect(() => {
|
|
111
|
+
|
|
112
|
+
const newFlag = location.hash === `#${NEW_URL_HASH}`;
|
|
113
|
+
const sideFlag = location.hash === `#${SIDE_URL_HASH}`;
|
|
114
|
+
|
|
115
|
+
if (!navigationStateController.loading) {
|
|
116
|
+
if ((newFlag || sideFlag) && cmsUrlController.isUrlCollectionPath(location.pathname)) {
|
|
117
|
+
const entityOrCollectionPath = cmsUrlController.urlPathToDataPath(location.pathname);
|
|
118
|
+
const panelsFromUrl = buildSidePanelsFromUrl(entityOrCollectionPath, collectionRegistryController.collections ?? [], newFlag);
|
|
119
|
+
for (let i = 0; i < panelsFromUrl.length; i++) {
|
|
120
|
+
const props = panelsFromUrl[i];
|
|
121
|
+
if (i === 0)
|
|
122
|
+
sideDialogsController.replace(propsToSidePanel(props, cmsUrlController.buildUrlCollectionPath, cmsUrlController.resolveDatabasePathsFrom, smallLayout, customizationController, authController, location.search));
|
|
123
|
+
else
|
|
124
|
+
sideDialogsController.open(propsToSidePanel(props, cmsUrlController.buildUrlCollectionPath, cmsUrlController.resolveDatabasePathsFrom, smallLayout, customizationController, authController, location.search))
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
initialised.current = true;
|
|
128
|
+
}
|
|
129
|
+
}, [navigationStateController.loading]);
|
|
130
|
+
|
|
131
|
+
// sync panels if URL changes with #side
|
|
132
|
+
// Use a ref for currentPanelKeys so this effect only fires on URL changes,
|
|
133
|
+
// not on panel state changes. This prevents a race condition with React Router 7
|
|
134
|
+
// where close() clears panels before the URL updates, causing the effect to
|
|
135
|
+
// re-open the panel from the stale #side hash.
|
|
136
|
+
currentPanelKeysRef.current = sideDialogsController.sidePanels.map(p => p.key);
|
|
137
|
+
useEffect(() => {
|
|
138
|
+
if (initialised.current) {
|
|
139
|
+
const sideFlag = location.hash === `#${SIDE_URL_HASH}`;
|
|
140
|
+
if (sideFlag) {
|
|
141
|
+
const currentKeys = currentPanelKeysRef.current;
|
|
142
|
+
const entityOrCollectionPath = cmsUrlController.urlPathToDataPath(location.pathname);
|
|
143
|
+
const panelsFromUrl = buildSidePanelsFromUrl(entityOrCollectionPath, collectionRegistryController.collections ?? [], false);
|
|
144
|
+
// if we have more panels than determined by the url, we ignore the url. We might have references open
|
|
145
|
+
if (panelsFromUrl.length <= currentKeys.length) {
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
const lastPanel = panelsFromUrl[panelsFromUrl.length - 1];
|
|
149
|
+
const panelProps = propsToSidePanel(lastPanel, cmsUrlController.buildUrlCollectionPath, cmsUrlController.resolveDatabasePathsFrom, smallLayout, customizationController, authController, location.search);
|
|
150
|
+
const lastCurrentPanel = currentKeys.length > 0 ? currentKeys[currentKeys.length - 1] : undefined;
|
|
151
|
+
if (!lastCurrentPanel || lastCurrentPanel !== panelProps.key) {
|
|
152
|
+
sideDialogsController.replace(panelProps);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}, [location.pathname, location.hash]);
|
|
157
|
+
|
|
158
|
+
// update side panels to match browser size
|
|
159
|
+
useEffect(() => {
|
|
160
|
+
const updatedSidePanels = sideDialogsController.sidePanels.map(sidePanelProps => {
|
|
161
|
+
if (sidePanelProps.additional) {
|
|
162
|
+
return propsToSidePanel(sidePanelProps.additional as EntitySidePanelProps, cmsUrlController.buildUrlCollectionPath, cmsUrlController.resolveDatabasePathsFrom, smallLayout, customizationController, authController, location.search);
|
|
163
|
+
}
|
|
164
|
+
return sidePanelProps;
|
|
165
|
+
});
|
|
166
|
+
sideDialogsController.setSidePanels(updatedSidePanels);
|
|
167
|
+
}, [smallLayout]);
|
|
168
|
+
|
|
169
|
+
const close = useCallback(() => {
|
|
170
|
+
sideDialogsController.close();
|
|
171
|
+
}, [sideDialogsController]);
|
|
172
|
+
|
|
173
|
+
const open = useCallback((props: EntitySidePanelProps<any>) => {
|
|
174
|
+
|
|
175
|
+
if (props.copy && !props.entityId) {
|
|
176
|
+
throw Error("If you want to copy an entity you need to provide an entityId");
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
const defaultSelectedView = resolveDefaultSelectedView(
|
|
180
|
+
props.collection ? props.collection.defaultSelectedView : undefined,
|
|
181
|
+
{
|
|
182
|
+
status: props.copy ? "copy" : (props.entityId ? "existing" : "new"),
|
|
183
|
+
entityId: props.entityId
|
|
184
|
+
}
|
|
185
|
+
);
|
|
186
|
+
|
|
187
|
+
sideDialogsController.open(
|
|
188
|
+
propsToSidePanel({
|
|
189
|
+
selectedTab: defaultSelectedView,
|
|
190
|
+
...props
|
|
191
|
+
},
|
|
192
|
+
cmsUrlController.buildUrlCollectionPath,
|
|
193
|
+
cmsUrlController.resolveDatabasePathsFrom,
|
|
194
|
+
smallLayout,
|
|
195
|
+
customizationController,
|
|
196
|
+
authController,
|
|
197
|
+
location.search
|
|
198
|
+
));
|
|
199
|
+
|
|
200
|
+
}, [sideDialogsController, cmsUrlController.buildUrlCollectionPath, cmsUrlController.resolveDatabasePathsFrom, smallLayout, authController.user, location.search]);
|
|
201
|
+
|
|
202
|
+
const replace = useCallback((props: EntitySidePanelProps<any>) => {
|
|
203
|
+
|
|
204
|
+
if (props.copy && !props.entityId) {
|
|
205
|
+
throw Error("If you want to copy an entity you need to provide an entityId");
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
sideDialogsController.replace(propsToSidePanel(props, cmsUrlController.buildUrlCollectionPath, cmsUrlController.resolveDatabasePathsFrom, smallLayout, customizationController, authController, location.search));
|
|
209
|
+
|
|
210
|
+
}, [cmsUrlController.buildUrlCollectionPath, cmsUrlController.resolveDatabasePathsFrom, sideDialogsController, smallLayout, authController.user, location.search]);
|
|
211
|
+
|
|
212
|
+
return {
|
|
213
|
+
close,
|
|
214
|
+
open,
|
|
215
|
+
replace
|
|
216
|
+
};
|
|
217
|
+
};
|
|
218
|
+
|
|
219
|
+
export function buildSidePanelsFromUrl(path: string, collections: EntityCollection[], newFlag: boolean): EntitySidePanelProps<any>[] {
|
|
220
|
+
|
|
221
|
+
const navigationViewsForPath: NavigationViewInternal<any>[] = getNavigationEntriesFromPath({
|
|
222
|
+
path,
|
|
223
|
+
collections
|
|
224
|
+
});
|
|
225
|
+
|
|
226
|
+
let sidePanel: EntitySidePanelProps<any> | undefined = undefined;
|
|
227
|
+
let lastCollectionPath = "";
|
|
228
|
+
let lastCollectionId: string | undefined = undefined;
|
|
229
|
+
for (let i = 0; i < navigationViewsForPath.length; i++) {
|
|
230
|
+
const navigationEntry = navigationViewsForPath[i];
|
|
231
|
+
|
|
232
|
+
if (navigationEntry.type === "collection") {
|
|
233
|
+
lastCollectionPath = navigationEntry.slug;
|
|
234
|
+
lastCollectionId = navigationEntry.collection.slug;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
const previousEntry = navigationViewsForPath[i - 1];
|
|
238
|
+
if (navigationEntry.type === "entity") {
|
|
239
|
+
sidePanel = {
|
|
240
|
+
path: navigationEntry.slug,
|
|
241
|
+
entityId: navigationEntry.entityId,
|
|
242
|
+
copy: false,
|
|
243
|
+
width: navigationEntry.parentCollection?.sideDialogWidth
|
|
244
|
+
};
|
|
245
|
+
} else if (navigationEntry.type === "custom_view") {
|
|
246
|
+
if (previousEntry?.type === "entity") {
|
|
247
|
+
if (sidePanel)
|
|
248
|
+
sidePanel.selectedTab = navigationEntry.view.key;
|
|
249
|
+
}
|
|
250
|
+
} else if (navigationEntry.type === "collection") {
|
|
251
|
+
if (previousEntry?.type === "entity") {
|
|
252
|
+
if (sidePanel)
|
|
253
|
+
sidePanel.selectedTab = navigationEntry.collection.slug;
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
if (newFlag) {
|
|
260
|
+
sidePanel = {
|
|
261
|
+
path: lastCollectionPath,
|
|
262
|
+
copy: false
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
return sidePanel ? [sidePanel] : [];
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
const propsToSidePanel = (props: EntitySidePanelProps,
|
|
270
|
+
buildUrlCollectionPath: (path: string) => string,
|
|
271
|
+
resolveIdsFrom: (pathWithAliases: string) => string,
|
|
272
|
+
smallLayout: boolean,
|
|
273
|
+
customizationController: CustomizationController,
|
|
274
|
+
authController: AuthController,
|
|
275
|
+
locationSearch: string
|
|
276
|
+
): SideDialogPanelProps => {
|
|
277
|
+
|
|
278
|
+
const collectionPath = removeInitialAndTrailingSlashes(props.path);
|
|
279
|
+
|
|
280
|
+
// When updateUrl is explicitly false, don't generate URL paths — the dialog
|
|
281
|
+
// opens as an overlay without affecting the browser URL / router.
|
|
282
|
+
const shouldUpdateUrl = props.updateUrl !== false;
|
|
283
|
+
|
|
284
|
+
const urlPath = shouldUpdateUrl
|
|
285
|
+
? (props.entityId
|
|
286
|
+
? buildUrlCollectionPath(`${collectionPath}/${props.entityId}${props.selectedTab ? "/" + props.selectedTab : ""}${locationSearch}#${SIDE_URL_HASH}`)
|
|
287
|
+
: buildUrlCollectionPath(`${collectionPath}${locationSearch}#${NEW_URL_HASH}`))
|
|
288
|
+
: undefined;
|
|
289
|
+
|
|
290
|
+
const parentUrlPath = shouldUpdateUrl
|
|
291
|
+
? buildUrlCollectionPath(collectionPath)
|
|
292
|
+
: undefined;
|
|
293
|
+
|
|
294
|
+
const resolvedPanelProps: EntitySidePanelProps<any> = {
|
|
295
|
+
...props,
|
|
296
|
+
formProps: props.formProps
|
|
297
|
+
};
|
|
298
|
+
|
|
299
|
+
const entityViewWidth = getEntityViewWidth(props, smallLayout, customizationController);
|
|
300
|
+
return {
|
|
301
|
+
key: `${props.path}/${props.entityId}`,
|
|
302
|
+
component: undefined, // Lazy render in SideDialogs for better performance
|
|
303
|
+
urlPath: urlPath,
|
|
304
|
+
parentUrlPath: parentUrlPath,
|
|
305
|
+
width: entityViewWidth,
|
|
306
|
+
onClose: props.onClose,
|
|
307
|
+
additional: resolvedPanelProps
|
|
308
|
+
};
|
|
309
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import React, { useCallback, useEffect, useRef } from "react";
|
|
2
|
+
import { useLocation } from "react-router-dom";
|
|
3
|
+
|
|
4
|
+
const scrollsMap: Record<string, number> = {};
|
|
5
|
+
|
|
6
|
+
export function useRestoreScroll() {
|
|
7
|
+
|
|
8
|
+
const location = useLocation();
|
|
9
|
+
|
|
10
|
+
const containerRef = useRef<HTMLDivElement>(null);
|
|
11
|
+
const [scroll, setScroll] = React.useState(0);
|
|
12
|
+
const [direction, setDirection] = React.useState<"up" | "down">("down");
|
|
13
|
+
|
|
14
|
+
// Use ref to track previous scroll for direction calculation
|
|
15
|
+
// This avoids recreating handleScroll on every scroll
|
|
16
|
+
const prevScrollRef = useRef(0);
|
|
17
|
+
|
|
18
|
+
const handleScroll = useCallback(() => {
|
|
19
|
+
if (!containerRef.current || !location.key) return;
|
|
20
|
+
const scrollTop = containerRef.current.scrollTop;
|
|
21
|
+
scrollsMap[location.key] = scrollTop;
|
|
22
|
+
setScroll(scrollTop);
|
|
23
|
+
setDirection(scrollTop > prevScrollRef.current ? "down" : "up");
|
|
24
|
+
prevScrollRef.current = scrollTop;
|
|
25
|
+
}, [location.key]);
|
|
26
|
+
|
|
27
|
+
useEffect(() => {
|
|
28
|
+
const container = containerRef.current;
|
|
29
|
+
if (!container) return;
|
|
30
|
+
container.addEventListener("scroll", handleScroll, { passive: true });
|
|
31
|
+
|
|
32
|
+
return () => {
|
|
33
|
+
if (container)
|
|
34
|
+
container.removeEventListener("scroll", handleScroll);
|
|
35
|
+
};
|
|
36
|
+
}, [handleScroll]);
|
|
37
|
+
|
|
38
|
+
// Defer scroll restoration to next tick to allow async content to render
|
|
39
|
+
// This is necessary because DefaultHomePage content loads asynchronously
|
|
40
|
+
useEffect(() => {
|
|
41
|
+
const savedScroll = scrollsMap[location.key];
|
|
42
|
+
if (!containerRef.current || !savedScroll) return;
|
|
43
|
+
|
|
44
|
+
const timeoutId = setTimeout(() => {
|
|
45
|
+
if (!containerRef.current) return;
|
|
46
|
+
containerRef.current.scrollTo({
|
|
47
|
+
top: savedScroll,
|
|
48
|
+
behavior: "auto"
|
|
49
|
+
});
|
|
50
|
+
}, 0);
|
|
51
|
+
|
|
52
|
+
return () => clearTimeout(timeoutId);
|
|
53
|
+
}, [location.key]);
|
|
54
|
+
|
|
55
|
+
return {
|
|
56
|
+
containerRef,
|
|
57
|
+
scroll,
|
|
58
|
+
direction
|
|
59
|
+
};
|
|
60
|
+
}
|
|
@@ -0,0 +1,308 @@
|
|
|
1
|
+
import React, { createElement } from "react";
|
|
2
|
+
import { deepEqual as equal } from "fast-equals"
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
ArrayProperty,
|
|
6
|
+
EntityReference,
|
|
7
|
+
EntityRelation,
|
|
8
|
+
MapProperty,
|
|
9
|
+
NumberProperty,
|
|
10
|
+
Property,
|
|
11
|
+
PropertyPreviewProps,
|
|
12
|
+
StringProperty
|
|
13
|
+
} from "@rebasepro/types";
|
|
14
|
+
|
|
15
|
+
import { resolveProperty } from "@rebasepro/common";
|
|
16
|
+
import { useAuthController, useCustomizationController } from "../hooks";
|
|
17
|
+
import { EmptyValue } from "./components/EmptyValue";
|
|
18
|
+
import { UrlComponentPreview } from "./components/UrlComponentPreview";
|
|
19
|
+
import { StorageThumbnail } from "./components/StorageThumbnail";
|
|
20
|
+
import { Markdown } from "@rebasepro/ui";
|
|
21
|
+
import { StringPropertyPreview } from "./property_previews/StringPropertyPreview";
|
|
22
|
+
import { ArrayPropertyPreview } from "./property_previews/ArrayPropertyPreview";
|
|
23
|
+
import { ArrayOfReferencesPreview } from "./property_previews/ArrayOfReferencesPreview";
|
|
24
|
+
import { ArrayOfRelationsPreview } from "./property_previews/ArrayOfRelationsPreview";
|
|
25
|
+
import { ArrayOfStorageComponentsPreview } from "./property_previews/ArrayOfStorageComponentsPreview";
|
|
26
|
+
import { ArrayPropertyEnumPreview } from "./property_previews/ArrayPropertyEnumPreview";
|
|
27
|
+
import { ArrayOfStringsPreview } from "./property_previews/ArrayOfStringsPreview";
|
|
28
|
+
import { ArrayOneOfPreview } from "./property_previews/ArrayOneOfPreview";
|
|
29
|
+
import { MapPropertyPreview } from "./property_previews/MapPropertyPreview";
|
|
30
|
+
import { ReferencePreview } from "./components/ReferencePreview";
|
|
31
|
+
import { DatePreview } from "./components/DatePreview";
|
|
32
|
+
import { BooleanPreview } from "./components/BooleanPreview";
|
|
33
|
+
import { NumberPropertyPreview } from "./property_previews/NumberPropertyPreview";
|
|
34
|
+
import { ErrorView } from "../components";
|
|
35
|
+
import { RelationPreview } from "./components/RelationPreview";
|
|
36
|
+
import { UserPreview } from "./components/UserPreview";
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* @group Preview components
|
|
40
|
+
*/
|
|
41
|
+
export const PropertyPreview = React.memo(function PropertyPreview<P extends Property>(props: PropertyPreviewProps<P>) {
|
|
42
|
+
|
|
43
|
+
const authController = useAuthController();
|
|
44
|
+
const customizationController = useCustomizationController();
|
|
45
|
+
|
|
46
|
+
let content: React.ReactNode | any;
|
|
47
|
+
const {
|
|
48
|
+
property: inputProperty,
|
|
49
|
+
propertyKey,
|
|
50
|
+
value,
|
|
51
|
+
size,
|
|
52
|
+
height,
|
|
53
|
+
width,
|
|
54
|
+
interactive,
|
|
55
|
+
fill
|
|
56
|
+
} = props;
|
|
57
|
+
|
|
58
|
+
const property = resolveProperty({
|
|
59
|
+
propertyKey,
|
|
60
|
+
property: inputProperty,
|
|
61
|
+
propertyConfigs: customizationController.propertyConfigs,
|
|
62
|
+
authController
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
if (property === null) {
|
|
66
|
+
content = <EmptyValue />;
|
|
67
|
+
} else if (property.Preview) {
|
|
68
|
+
content = createElement(property.Preview,
|
|
69
|
+
{
|
|
70
|
+
propertyKey,
|
|
71
|
+
value,
|
|
72
|
+
property,
|
|
73
|
+
size,
|
|
74
|
+
height,
|
|
75
|
+
width,
|
|
76
|
+
// entity,
|
|
77
|
+
customProps: property.customProps
|
|
78
|
+
});
|
|
79
|
+
} else if (value === undefined || value === null) {
|
|
80
|
+
content = <EmptyValue />;
|
|
81
|
+
} else if (property.type === "string") {
|
|
82
|
+
const stringProperty = property as StringProperty;
|
|
83
|
+
if (typeof value === "string") {
|
|
84
|
+
if (stringProperty.storage) {
|
|
85
|
+
const filePath = stringProperty.storage.previewUrl ? stringProperty.storage.previewUrl(value) : value;
|
|
86
|
+
content = <StorageThumbnail
|
|
87
|
+
interactive={interactive}
|
|
88
|
+
storeUrl={property.storage?.storeUrl ?? false}
|
|
89
|
+
size={props.size}
|
|
90
|
+
fill={fill}
|
|
91
|
+
storagePathOrDownloadUrl={filePath} />;
|
|
92
|
+
} else if (stringProperty.url) {
|
|
93
|
+
if (typeof stringProperty.url === "boolean")
|
|
94
|
+
content =
|
|
95
|
+
<UrlComponentPreview size={props.size}
|
|
96
|
+
url={value}
|
|
97
|
+
fill={fill} />;
|
|
98
|
+
else if (typeof stringProperty.url === "string")
|
|
99
|
+
content =
|
|
100
|
+
<UrlComponentPreview size={props.size}
|
|
101
|
+
url={value}
|
|
102
|
+
interactive={interactive}
|
|
103
|
+
fill={fill}
|
|
104
|
+
previewType={stringProperty.url} />;
|
|
105
|
+
} else if (stringProperty.markdown) {
|
|
106
|
+
content = <Markdown source={value} size={"small"} />;
|
|
107
|
+
} else if (stringProperty.userSelect) {
|
|
108
|
+
content = <UserPreview
|
|
109
|
+
value={value}
|
|
110
|
+
property={stringProperty}
|
|
111
|
+
propertyKey={propertyKey}
|
|
112
|
+
size={props.size}
|
|
113
|
+
/>;
|
|
114
|
+
} else if (stringProperty.reference) {
|
|
115
|
+
if (typeof stringProperty.reference.path === "string") {
|
|
116
|
+
content = <ReferencePreview
|
|
117
|
+
disabled={!stringProperty.reference.path}
|
|
118
|
+
previewProperties={stringProperty.reference.previewProperties}
|
|
119
|
+
includeId={stringProperty.reference.includeId}
|
|
120
|
+
includeEntityLink={stringProperty.reference.includeEntityLink}
|
|
121
|
+
size={props.size}
|
|
122
|
+
reference={new EntityReference({ id: value, path: stringProperty.reference.path })}
|
|
123
|
+
/>;
|
|
124
|
+
} else {
|
|
125
|
+
content = <EmptyValue />;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
} else {
|
|
129
|
+
content = <StringPropertyPreview {...props}
|
|
130
|
+
property={stringProperty}
|
|
131
|
+
value={value} />;
|
|
132
|
+
}
|
|
133
|
+
} else {
|
|
134
|
+
content = buildWrongValueType(propertyKey, property.type, value);
|
|
135
|
+
}
|
|
136
|
+
} else if (property.type === "array") {
|
|
137
|
+
if (Array.isArray(value)) {
|
|
138
|
+
const arrayProperty = property as ArrayProperty;
|
|
139
|
+
if (!arrayProperty.of && !arrayProperty.oneOf) {
|
|
140
|
+
throw Error(`You need to specify an 'of' or 'oneOf' prop (or specify a custom field) in your array property ${propertyKey}`);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
if (arrayProperty.of) {
|
|
144
|
+
if (Array.isArray(arrayProperty.of)) {
|
|
145
|
+
content = <ArrayPropertyPreview {...props}
|
|
146
|
+
value={value}
|
|
147
|
+
property={arrayProperty} />;
|
|
148
|
+
} else if (arrayProperty.of.type === "reference") {
|
|
149
|
+
content = <ArrayOfReferencesPreview {...props}
|
|
150
|
+
value={value}
|
|
151
|
+
property={property} />;
|
|
152
|
+
} else if (arrayProperty.of.type === "relation") {
|
|
153
|
+
content = <ArrayOfRelationsPreview {...props}
|
|
154
|
+
value={value}
|
|
155
|
+
property={property} />;
|
|
156
|
+
} else if (arrayProperty.of.type === "string") {
|
|
157
|
+
if (arrayProperty.of.enum) {
|
|
158
|
+
content = <ArrayPropertyEnumPreview
|
|
159
|
+
{...props}
|
|
160
|
+
value={value}
|
|
161
|
+
property={property} />;
|
|
162
|
+
} else if (arrayProperty.of.storage) {
|
|
163
|
+
content = <ArrayOfStorageComponentsPreview
|
|
164
|
+
{...props}
|
|
165
|
+
value={value}
|
|
166
|
+
property={property as ArrayProperty} />;
|
|
167
|
+
} else {
|
|
168
|
+
content = <ArrayOfStringsPreview
|
|
169
|
+
{...props}
|
|
170
|
+
property={property as ArrayProperty}
|
|
171
|
+
value={value as string[]} />;
|
|
172
|
+
}
|
|
173
|
+
} else if (arrayProperty.of.type === "number" && arrayProperty.of.enum) {
|
|
174
|
+
content = <ArrayPropertyEnumPreview
|
|
175
|
+
{...props}
|
|
176
|
+
value={value as number[]}
|
|
177
|
+
property={property as ArrayProperty} />;
|
|
178
|
+
} else {
|
|
179
|
+
content = <ArrayPropertyPreview {...props}
|
|
180
|
+
value={value}
|
|
181
|
+
property={property as ArrayProperty} />;
|
|
182
|
+
}
|
|
183
|
+
} else if (arrayProperty.oneOf) {
|
|
184
|
+
content = <ArrayOneOfPreview {...props}
|
|
185
|
+
value={value}
|
|
186
|
+
property={property as ArrayProperty} />;
|
|
187
|
+
}
|
|
188
|
+
} else {
|
|
189
|
+
content = buildWrongValueType(propertyKey, property.type, value);
|
|
190
|
+
}
|
|
191
|
+
} else if (property.type === "map") {
|
|
192
|
+
if (typeof value === "object") {
|
|
193
|
+
content =
|
|
194
|
+
<MapPropertyPreview {...props}
|
|
195
|
+
value={value as Record<string, any>}
|
|
196
|
+
property={property as MapProperty} />;
|
|
197
|
+
} else {
|
|
198
|
+
content = buildWrongValueType(propertyKey, property.type, value);
|
|
199
|
+
}
|
|
200
|
+
} else if (property.type === "date") {
|
|
201
|
+
if (value instanceof Date) {
|
|
202
|
+
content = <DatePreview
|
|
203
|
+
date={value}
|
|
204
|
+
mode={property.mode}
|
|
205
|
+
/>;
|
|
206
|
+
} else {
|
|
207
|
+
content = buildWrongValueType(propertyKey, property.type, value);
|
|
208
|
+
}
|
|
209
|
+
} else if (property.type === "reference") {
|
|
210
|
+
if (typeof property.path === "string") {
|
|
211
|
+
if (typeof value === "object" && "isEntityReference" in value && value.isEntityReference()) {
|
|
212
|
+
content = <ReferencePreview
|
|
213
|
+
disabled={!property.path}
|
|
214
|
+
previewProperties={property.previewProperties}
|
|
215
|
+
includeId={property.includeId}
|
|
216
|
+
includeEntityLink={property.includeEntityLink}
|
|
217
|
+
size={props.size}
|
|
218
|
+
reference={value as EntityReference}
|
|
219
|
+
/>;
|
|
220
|
+
} else {
|
|
221
|
+
content = buildWrongValueType(propertyKey, property.type, value);
|
|
222
|
+
}
|
|
223
|
+
} else {
|
|
224
|
+
content = <EmptyValue />;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
} else if (property.type === "relation") {
|
|
228
|
+
if (!value) {
|
|
229
|
+
content = <EmptyValue />;
|
|
230
|
+
} else if (Array.isArray(value)) {
|
|
231
|
+
// Many-cardinality relation: value is an array of EntityRelation (or plain objects)
|
|
232
|
+
content = (
|
|
233
|
+
<div className="flex flex-col w-full gap-0.5">
|
|
234
|
+
{(value as any[]).map((item: any, index: number) => {
|
|
235
|
+
const entityRelation: EntityRelation | null = (item instanceof EntityRelation)
|
|
236
|
+
? item
|
|
237
|
+
: (item && typeof item === "object" && (item.__type === "relation" || ("isEntityRelation" in item && item.isEntityRelation())))
|
|
238
|
+
? new EntityRelation(item.id, item.path)
|
|
239
|
+
: null;
|
|
240
|
+
if (!entityRelation) return null;
|
|
241
|
+
return (
|
|
242
|
+
<div className="w-full"
|
|
243
|
+
key={`preview_rel_${propertyKey}_${index}`}>
|
|
244
|
+
<RelationPreview
|
|
245
|
+
disabled={!property.relation}
|
|
246
|
+
previewProperties={property.previewProperties}
|
|
247
|
+
includeId={property.includeId}
|
|
248
|
+
includeEntityLink={property.includeEntityLink}
|
|
249
|
+
size={"small"}
|
|
250
|
+
relation={entityRelation}
|
|
251
|
+
/>
|
|
252
|
+
</div>
|
|
253
|
+
);
|
|
254
|
+
})}
|
|
255
|
+
</div>
|
|
256
|
+
);
|
|
257
|
+
} else {
|
|
258
|
+
// Single-cardinality relation
|
|
259
|
+
const rawValue = value as any;
|
|
260
|
+
const relationValue: EntityRelation | null = (value instanceof EntityRelation)
|
|
261
|
+
? value
|
|
262
|
+
: (typeof rawValue === "object" && (rawValue.__type === "relation" || ("isEntityRelation" in rawValue && rawValue.isEntityRelation())))
|
|
263
|
+
? new EntityRelation(rawValue.id, rawValue.path)
|
|
264
|
+
: null;
|
|
265
|
+
if (relationValue) {
|
|
266
|
+
content = <RelationPreview
|
|
267
|
+
disabled={!property.relation}
|
|
268
|
+
previewProperties={property.previewProperties}
|
|
269
|
+
includeId={property.includeId}
|
|
270
|
+
includeEntityLink={property.includeEntityLink}
|
|
271
|
+
size={props.size}
|
|
272
|
+
relation={relationValue}
|
|
273
|
+
/>;
|
|
274
|
+
} else {
|
|
275
|
+
content = buildWrongValueType(propertyKey, property.type, value);
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
} else if (property.type === "boolean") {
|
|
280
|
+
if (typeof value === "boolean") {
|
|
281
|
+
content = <BooleanPreview value={value} size={size} property={property} />;
|
|
282
|
+
} else {
|
|
283
|
+
content = buildWrongValueType(propertyKey, property.type, value);
|
|
284
|
+
}
|
|
285
|
+
} else if (property.type === "number") {
|
|
286
|
+
if (typeof value === "number") {
|
|
287
|
+
content = <NumberPropertyPreview {...props}
|
|
288
|
+
value={value}
|
|
289
|
+
property={property as NumberProperty} />;
|
|
290
|
+
} else {
|
|
291
|
+
content = buildWrongValueType(propertyKey, property.type, value);
|
|
292
|
+
}
|
|
293
|
+
} else {
|
|
294
|
+
content = JSON.stringify(value);
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
return content === undefined || content === null || (Array.isArray(content) && content.length === 0)
|
|
298
|
+
? <EmptyValue />
|
|
299
|
+
: content;
|
|
300
|
+
}, equal);
|
|
301
|
+
|
|
302
|
+
function buildWrongValueType(name: string | undefined, type: string, value: any) {
|
|
303
|
+
console.warn(`Unexpected value for property ${name}, of type ${type}`, value);
|
|
304
|
+
return (
|
|
305
|
+
<ErrorView title={"Unexpected value"}
|
|
306
|
+
error={`${JSON.stringify(value)}`} />
|
|
307
|
+
);
|
|
308
|
+
}
|