@firecms/core 3.0.0 → 3.1.0-canary.02232f4
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 +1 -1
- package/dist/components/AIIcon.d.ts +16 -0
- package/dist/components/EntityCollectionTable/EntityCollectionRowActions.d.ts +7 -1
- package/dist/components/EntityCollectionTable/EntityCollectionTable.d.ts +1 -1
- package/dist/components/EntityCollectionTable/EntityCollectionTableProps.d.ts +14 -0
- package/dist/components/EntityCollectionTable/PropertyTableCell.d.ts +6 -0
- package/dist/components/EntityCollectionTable/internal/CollectionTableToolbar.d.ts +5 -4
- package/dist/components/EntityCollectionTable/internal/EntityTableCell.d.ts +6 -0
- package/dist/components/EntityCollectionTable/internal/popup_field/useDraggable.d.ts +2 -2
- 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/CollectionDataErrorBanner.d.ts +4 -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/EntityCollectionViewActions.d.ts +2 -2
- package/dist/components/EntityCollectionView/EntityCollectionViewStartActions.d.ts +7 -3
- 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/ErrorBoundary.d.ts +4 -2
- package/dist/components/HomePage/DefaultHomePage.d.ts +0 -1
- package/dist/components/LanguageToggle.d.ts +1 -0
- package/dist/components/SelectableTable/SelectableTable.d.ts +5 -1
- package/dist/components/SelectableTable/filters/DateTimeFilterField.d.ts +2 -1
- package/dist/components/UnsavedChangesDialog.d.ts +1 -0
- package/dist/components/VirtualTable/VirtualTable.performance.test.d.ts +1 -0
- package/dist/components/VirtualTable/VirtualTableCell.d.ts +6 -0
- package/dist/components/VirtualTable/VirtualTableHeader.d.ts +4 -1
- package/dist/components/VirtualTable/VirtualTableHeaderRow.d.ts +1 -1
- package/dist/components/VirtualTable/VirtualTableProps.d.ts +17 -1
- package/dist/components/VirtualTable/fields/VirtualTableDateField.d.ts +1 -0
- package/dist/components/VirtualTable/types.d.ts +3 -0
- package/dist/components/index.d.ts +4 -0
- package/dist/contexts/index.d.ts +10 -0
- package/dist/core/DrawerNavigationGroup.d.ts +45 -0
- package/dist/core/index.d.ts +1 -0
- package/dist/editor/components/SlashCommandMenu.d.ts +6 -0
- package/dist/editor/components/editor-bubble-item.d.ts +8 -0
- package/dist/editor/components/editor-bubble.d.ts +8 -0
- package/dist/editor/components/image-bubble.d.ts +5 -0
- package/dist/editor/components/index.d.ts +16 -0
- package/dist/editor/components/table-bubble.d.ts +5 -0
- package/dist/editor/editor.d.ts +30 -0
- package/dist/editor/extensions/HighlightDecorationExtension.d.ts +24 -0
- package/dist/editor/extensions/Image/index.d.ts +6 -0
- package/dist/editor/extensions/Image.d.ts +6 -0
- package/dist/editor/extensions/TextLoadingDecorationExtension.d.ts +16 -0
- package/dist/editor/extensions/clipboard.d.ts +7 -0
- package/dist/editor/extensions/custom-keymap.d.ts +1 -0
- package/dist/editor/extensions/drag-and-drop.d.ts +9 -0
- package/dist/editor/hooks/useProseMirror.d.ts +13 -0
- package/dist/editor/hooks/useProseMirrorContext.d.ts +9 -0
- package/dist/editor/index.d.ts +2 -0
- package/dist/editor/markdown.d.ts +5 -0
- package/dist/editor/nodeViews/ImageComponent.d.ts +3 -0
- package/dist/editor/nodeViews/ReactNodeView.d.ts +29 -0
- package/dist/editor/nodeViews/TaskItemComponent.d.ts +3 -0
- package/dist/editor/nodeViews/index.d.ts +6 -0
- package/dist/editor/plugins/index.d.ts +2 -0
- package/dist/editor/plugins/inputrules.d.ts +6 -0
- package/dist/editor/plugins/placeholderPlugin.d.ts +3 -0
- package/dist/editor/plugins/slashCommandPlugin.d.ts +12 -0
- package/dist/editor/schema.d.ts +2 -0
- package/dist/editor/selectors/ai-selector.d.ts +0 -0
- package/dist/editor/selectors/color-selector.d.ts +10 -0
- package/dist/editor/selectors/link-selector.d.ts +8 -0
- package/dist/editor/selectors/node-selector.d.ts +15 -0
- package/dist/editor/selectors/text-buttons.d.ts +1 -0
- package/dist/editor/types.d.ts +5 -0
- package/dist/editor/useProseMirror.d.ts +16 -0
- package/dist/editor/utils/prosemirror-utils.d.ts +6 -0
- package/dist/editor/utils/remove_classes.d.ts +1 -0
- package/dist/editor/utils/useDebouncedCallback.d.ts +1 -0
- package/dist/form/components/ErrorFocus.d.ts +1 -1
- package/dist/form/components/LocalChangesMenu.d.ts +2 -2
- package/dist/form/components/StorageUploadProgress.d.ts +1 -1
- package/dist/form/field_bindings/MapFieldBinding.d.ts +1 -1
- package/dist/form/field_bindings/MarkdownEditorFieldBinding.d.ts +1 -1
- package/dist/form/validation.d.ts +3 -2
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/useBreadcrumbsController.d.ts +16 -0
- package/dist/hooks/useBuildNavigationController.d.ts +0 -1
- package/dist/hooks/useCollapsedGroups.d.ts +6 -3
- package/dist/hooks/useTranslation.d.ts +17 -0
- package/dist/i18n/FireCMSi18nProvider.d.ts +33 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.es.js +31028 -16080
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +29955 -15028
- package/dist/index.umd.js.map +1 -1
- package/dist/internal/useRestoreScroll.d.ts +1 -1
- package/dist/locales/de.d.ts +2 -0
- package/dist/locales/en.d.ts +10 -0
- package/dist/locales/es.d.ts +10 -0
- package/dist/locales/fr.d.ts +2 -0
- package/dist/locales/hi.d.ts +2 -0
- package/dist/locales/it.d.ts +2 -0
- package/dist/locales/pt.d.ts +7 -0
- package/dist/preview/PropertyPreviewProps.d.ts +5 -0
- package/dist/preview/components/DatePreview.d.ts +13 -3
- package/dist/preview/components/ImagePreview.d.ts +5 -1
- package/dist/preview/components/StorageThumbnail.d.ts +2 -1
- package/dist/preview/components/UrlComponentPreview.d.ts +2 -1
- package/dist/preview/property_previews/ArrayOfStorageComponentsPreview.d.ts +1 -1
- package/dist/preview/property_previews/ArrayOfStringsPreview.d.ts +1 -1
- package/dist/preview/property_previews/SkeletonPropertyComponent.d.ts +1 -1
- package/dist/types/analytics.d.ts +1 -1
- package/dist/types/collections.d.ts +88 -2
- package/dist/types/customization_controller.d.ts +2 -1
- package/dist/types/datasource.d.ts +0 -1
- package/dist/types/entities.d.ts +1 -0
- package/dist/types/firecms.d.ts +2 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/navigation.d.ts +2 -2
- package/dist/types/plugins.d.ts +69 -1
- package/dist/types/properties.d.ts +277 -12
- package/dist/types/storage.d.ts +9 -0
- package/dist/types/translations.d.ts +669 -0
- package/dist/util/__tests__/conditions.test.d.ts +1 -0
- package/dist/util/__tests__/objects.test.d.ts +1 -0
- package/dist/util/conditions.d.ts +26 -0
- package/dist/util/entities.d.ts +2 -3
- package/dist/util/index.d.ts +3 -1
- package/dist/util/lazy_eager.d.ts +7 -0
- package/dist/util/objects.d.ts +1 -0
- package/dist/util/property_utils.d.ts +2 -1
- package/dist/util/resolutions.d.ts +3 -3
- package/dist/util/useStorageUploadController.d.ts +11 -2
- package/package.json +52 -12
- package/src/app/Scaffold.tsx +20 -19
- package/src/components/AIIcon.tsx +41 -0
- package/src/components/ArrayContainer.tsx +7 -8
- package/src/components/ClearFilterSortButton.tsx +25 -19
- package/src/components/ConfirmationDialog.tsx +4 -4
- package/src/components/DeleteEntityDialog.tsx +12 -11
- package/src/components/EntityCollectionTable/EntityCollectionRowActions.tsx +82 -43
- package/src/components/EntityCollectionTable/EntityCollectionTable.tsx +130 -79
- package/src/components/EntityCollectionTable/EntityCollectionTableProps.tsx +121 -104
- package/src/components/EntityCollectionTable/PropertyTableCell.tsx +132 -103
- package/src/components/EntityCollectionTable/fields/TableReferenceField.tsx +6 -3
- package/src/components/EntityCollectionTable/internal/CollectionTableToolbar.tsx +24 -44
- package/src/components/EntityCollectionTable/internal/EntityTableCell.tsx +90 -49
- package/src/components/EntityCollectionTable/internal/EntityTableCellActions.tsx +1 -1
- package/src/components/EntityCollectionTable/internal/popup_field/PopupFormField.tsx +3 -2
- package/src/components/EntityCollectionTable/internal/popup_field/useDraggable.tsx +11 -11
- 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 +174 -0
- package/src/components/EntityCollectionView/CollectionDataErrorBanner.tsx +43 -0
- package/src/components/EntityCollectionView/EntityBoardCard.tsx +212 -0
- package/src/components/EntityCollectionView/EntityCard.tsx +235 -0
- package/src/components/EntityCollectionView/EntityCollectionBoardView.tsx +706 -0
- package/src/components/EntityCollectionView/EntityCollectionCardView.tsx +236 -0
- package/src/components/EntityCollectionView/EntityCollectionView.tsx +531 -209
- package/src/components/EntityCollectionView/EntityCollectionViewActions.tsx +35 -22
- package/src/components/EntityCollectionView/EntityCollectionViewStartActions.tsx +86 -15
- package/src/components/EntityCollectionView/FiltersDialog.tsx +252 -0
- package/src/components/EntityCollectionView/ViewModeToggle.tsx +202 -0
- package/src/components/EntityCollectionView/board_types.ts +113 -0
- package/src/components/EntityCollectionView/useBoardDataController.tsx +490 -0
- package/src/components/EntityJsonPreview.tsx +2 -1
- package/src/components/EntityPreview.tsx +1 -1
- package/src/components/EntityView.tsx +3 -2
- package/src/components/ErrorBoundary.tsx +27 -15
- package/src/components/ErrorTooltip.tsx +2 -1
- package/src/components/HomePage/DefaultHomePage.tsx +65 -22
- package/src/components/HomePage/HomePageDnD.tsx +59 -42
- package/src/components/HomePage/NavigationCard.tsx +20 -18
- package/src/components/HomePage/NavigationGroup.tsx +20 -17
- package/src/components/HomePage/RenameGroupDialog.tsx +15 -15
- package/src/components/HomePage/SmallNavigationCard.tsx +10 -9
- package/src/components/LanguageToggle.tsx +66 -0
- package/src/components/NotFoundPage.tsx +5 -3
- package/src/components/ReferenceTable/ReferenceSelectionTable.tsx +12 -17
- package/src/components/ReferenceWidget.tsx +5 -6
- package/src/components/SearchIconsView.tsx +3 -1
- package/src/components/SelectableTable/SelectableTable.tsx +75 -67
- package/src/components/SelectableTable/filters/BooleanFilterField.tsx +7 -6
- package/src/components/SelectableTable/filters/DateTimeFilterField.tsx +50 -40
- package/src/components/SelectableTable/filters/ReferenceFilterField.tsx +53 -40
- package/src/components/SelectableTable/filters/StringNumberFilterField.tsx +60 -58
- package/src/components/UnsavedChangesDialog.tsx +6 -6
- package/src/components/UserDisplay.tsx +4 -4
- package/src/components/VirtualTable/VirtualTable.performance.test.tsx +387 -0
- package/src/components/VirtualTable/VirtualTable.tsx +277 -121
- package/src/components/VirtualTable/VirtualTableCell.tsx +18 -2
- package/src/components/VirtualTable/VirtualTableHeader.tsx +76 -64
- package/src/components/VirtualTable/VirtualTableHeaderRow.tsx +163 -42
- package/src/components/VirtualTable/VirtualTableProps.tsx +21 -2
- package/src/components/VirtualTable/VirtualTableRow.tsx +1 -1
- package/src/components/VirtualTable/fields/VirtualTableDateField.tsx +3 -0
- package/src/components/VirtualTable/fields/VirtualTableSelect.tsx +19 -6
- package/src/components/VirtualTable/types.tsx +3 -0
- package/src/components/common/default_entity_actions.tsx +4 -0
- package/src/components/common/useColumnsIds.tsx +95 -3
- package/src/components/common/useDataSourceTableController.tsx +12 -4
- package/src/components/index.tsx +5 -0
- package/src/contexts/BreacrumbsContext.tsx +15 -8
- package/src/contexts/index.ts +10 -0
- package/src/core/DefaultAppBar.tsx +49 -32
- package/src/core/DefaultDrawer.tsx +49 -57
- package/src/core/DrawerNavigationGroup.tsx +120 -0
- package/src/core/DrawerNavigationItem.tsx +4 -3
- package/src/core/EntityEditView.tsx +94 -50
- package/src/core/EntityEditViewFormActions.tsx +24 -17
- package/src/core/EntitySidePanel.tsx +34 -30
- package/src/core/FireCMS.tsx +33 -6
- package/src/core/SideDialogs.tsx +4 -2
- package/src/core/field_configs.tsx +18 -11
- package/src/core/index.tsx +1 -0
- package/src/editor/components/SlashCommandMenu.tsx +516 -0
- package/src/editor/components/editor-bubble-item.tsx +32 -0
- package/src/editor/components/editor-bubble.tsx +118 -0
- package/src/editor/components/image-bubble.tsx +156 -0
- package/src/editor/components/index.ts +14 -0
- package/src/editor/components/table-bubble.tsx +165 -0
- package/src/editor/editor.tsx +455 -0
- package/src/editor/extensions/HighlightDecorationExtension.ts +114 -0
- package/src/editor/extensions/Image/index.ts +133 -0
- package/src/editor/extensions/Image.ts +159 -0
- package/src/editor/extensions/TextLoadingDecorationExtension.tsx +107 -0
- package/src/editor/extensions/clipboard.ts +72 -0
- package/src/editor/extensions/custom-keymap.ts +24 -0
- package/src/editor/extensions/drag-and-drop.tsx +480 -0
- package/src/editor/hooks/useProseMirror.ts +124 -0
- package/src/editor/hooks/useProseMirrorContext.ts +15 -0
- package/src/editor/index.ts +2 -0
- package/src/editor/markdown.ts +172 -0
- package/src/editor/nodeViews/ImageComponent.tsx +20 -0
- package/src/editor/nodeViews/ReactNodeView.tsx +89 -0
- package/src/editor/nodeViews/TaskItemComponent.tsx +29 -0
- package/src/editor/nodeViews/index.ts +35 -0
- package/src/editor/plugins/index.ts +58 -0
- package/src/editor/plugins/inputrules.ts +82 -0
- package/src/editor/plugins/placeholderPlugin.ts +55 -0
- package/src/editor/plugins/slashCommandPlugin.ts +61 -0
- package/src/editor/schema.ts +240 -0
- package/src/editor/selectors/ai-selector.tsx +111 -0
- package/src/editor/selectors/color-selector.tsx +200 -0
- package/src/editor/selectors/link-selector.tsx +118 -0
- package/src/editor/selectors/node-selector.tsx +157 -0
- package/src/editor/selectors/text-buttons.tsx +86 -0
- package/src/editor/types.ts +6 -0
- package/src/editor/useProseMirror.ts +126 -0
- package/src/editor/utils/prosemirror-utils.ts +108 -0
- package/src/editor/utils/remove_classes.ts +17 -0
- package/src/editor/utils/useDebouncedCallback.ts +25 -0
- package/src/form/EntityForm.tsx +150 -75
- package/src/form/EntityFormActions.tsx +19 -12
- package/src/form/PropertyFieldBinding.tsx +68 -51
- package/src/form/components/ErrorFocus.tsx +3 -3
- package/src/form/components/LocalChangesMenu.tsx +19 -19
- package/src/form/components/StorageItemPreview.tsx +5 -3
- package/src/form/components/StorageUploadProgress.tsx +22 -6
- package/src/form/field_bindings/ArrayCustomShapedFieldBinding.tsx +18 -5
- package/src/form/field_bindings/ArrayOfReferencesFieldBinding.tsx +22 -10
- package/src/form/field_bindings/BlockFieldBinding.tsx +26 -9
- package/src/form/field_bindings/DateTimeFieldBinding.tsx +18 -17
- package/src/form/field_bindings/KeyValueFieldBinding.tsx +46 -25
- package/src/form/field_bindings/MapFieldBinding.tsx +88 -70
- package/src/form/field_bindings/MarkdownEditorFieldBinding.tsx +93 -52
- package/src/form/field_bindings/MultiSelectFieldBinding.tsx +15 -1
- package/src/form/field_bindings/ReferenceAsStringFieldBinding.tsx +25 -11
- package/src/form/field_bindings/ReferenceFieldBinding.tsx +25 -11
- package/src/form/field_bindings/RepeatFieldBinding.tsx +21 -6
- package/src/form/field_bindings/SelectFieldBinding.tsx +7 -5
- package/src/form/field_bindings/StorageUploadFieldBinding.tsx +110 -92
- package/src/form/field_bindings/SwitchFieldBinding.tsx +31 -14
- package/src/form/field_bindings/TextFieldBinding.tsx +77 -38
- package/src/form/field_bindings/UserSelectFieldBinding.tsx +7 -5
- package/src/form/validation.ts +245 -160
- package/src/hooks/index.tsx +1 -0
- package/src/hooks/useBreadcrumbsController.tsx +18 -0
- package/src/hooks/useBuildNavigationController.tsx +91 -41
- package/src/hooks/useCollapsedGroups.ts +18 -9
- package/src/hooks/useTranslation.ts +31 -0
- package/src/hooks/useValidateAuthenticator.tsx +1 -1
- package/src/i18n/FireCMSi18nProvider.tsx +160 -0
- package/src/index.ts +5 -0
- package/src/internal/useBuildDataSource.ts +68 -34
- package/src/internal/useBuildSideDialogsController.tsx +11 -8
- package/src/internal/useBuildSideEntityController.tsx +24 -24
- package/src/internal/useRestoreScroll.tsx +26 -14
- package/src/locales/de.ts +718 -0
- package/src/locales/en.ts +730 -0
- package/src/locales/es.ts +730 -0
- package/src/locales/fr.ts +718 -0
- package/src/locales/hi.ts +718 -0
- package/src/locales/it.ts +718 -0
- package/src/locales/pt.ts +727 -0
- package/src/preview/PropertyPreview.tsx +43 -33
- package/src/preview/PropertyPreviewProps.tsx +6 -0
- package/src/preview/components/DatePreview.tsx +72 -4
- package/src/preview/components/EmptyValue.tsx +1 -1
- package/src/preview/components/ImagePreview.tsx +37 -21
- package/src/preview/components/ReferencePreview.tsx +8 -2
- package/src/preview/components/StorageThumbnail.tsx +16 -12
- package/src/preview/components/UrlComponentPreview.tsx +32 -27
- package/src/preview/components/UserPreview.tsx +3 -1
- package/src/preview/property_previews/ArrayOfStorageComponentsPreview.tsx +9 -7
- package/src/preview/property_previews/ArrayOfStringsPreview.tsx +11 -9
- package/src/preview/property_previews/ArrayPropertyPreview.tsx +26 -24
- package/src/preview/property_previews/MapPropertyPreview.tsx +49 -27
- package/src/preview/property_previews/SkeletonPropertyComponent.tsx +61 -56
- package/src/routes/CustomCMSRoute.tsx +1 -0
- package/src/routes/FireCMSRoute.tsx +87 -65
- package/src/types/analytics.ts +10 -0
- package/src/types/collections.ts +97 -3
- package/src/types/customization_controller.tsx +2 -1
- package/src/types/datasource.ts +54 -56
- package/src/types/entities.ts +10 -0
- package/src/types/firecms.tsx +2 -1
- package/src/types/index.ts +1 -0
- package/src/types/navigation.ts +2 -2
- package/src/types/plugins.tsx +77 -1
- package/src/types/properties.ts +369 -37
- package/src/types/storage.ts +11 -1
- package/src/types/translations.ts +752 -0
- package/src/util/__tests__/conditions.test.ts +506 -0
- package/src/util/__tests__/objects.test.ts +196 -0
- package/src/util/callbacks.ts +6 -3
- package/src/util/collections.ts +51 -6
- package/src/util/conditions.ts +339 -0
- package/src/util/entities.ts +29 -30
- package/src/util/entity_cache.ts +2 -1
- package/src/util/index.ts +3 -1
- package/src/util/join_collections.ts +10 -8
- package/src/util/lazy_eager.tsx +33 -0
- package/src/util/objects.ts +46 -13
- package/src/util/{references.ts → previews.ts} +16 -2
- package/src/util/property_utils.tsx +37 -11
- package/src/util/resolutions.ts +62 -58
- package/src/util/useStorageUploadController.tsx +34 -30
- /package/dist/util/{references.d.ts → previews.d.ts} +0 -0
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
import React, { memo, useEffect, useMemo, useRef } from "react";
|
|
2
|
+
import { useDroppable } from "@dnd-kit/core";
|
|
3
|
+
import { useSortable } from "@dnd-kit/sortable";
|
|
4
|
+
import { CSS } from "@dnd-kit/utilities";
|
|
5
|
+
import { CircularProgress, cls } from "@firecms/ui";
|
|
6
|
+
import { BoardItem, BoardItemViewProps } from "./board_types";
|
|
7
|
+
import { useTranslation } from "../../hooks";
|
|
8
|
+
|
|
9
|
+
interface BoardSortableListProps<M extends Record<string, any>> {
|
|
10
|
+
columnId: string;
|
|
11
|
+
items: BoardItem<M>[];
|
|
12
|
+
ItemComponent: React.ComponentType<BoardItemViewProps<M>>;
|
|
13
|
+
isDragging: boolean;
|
|
14
|
+
isDragOverColumn: boolean;
|
|
15
|
+
loading?: boolean;
|
|
16
|
+
hasMore?: boolean;
|
|
17
|
+
onLoadMore?: () => void;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function BoardSortableList<M extends Record<string, any>>({
|
|
21
|
+
columnId,
|
|
22
|
+
items,
|
|
23
|
+
ItemComponent,
|
|
24
|
+
isDragging,
|
|
25
|
+
isDragOverColumn,
|
|
26
|
+
loading = false,
|
|
27
|
+
hasMore = false,
|
|
28
|
+
onLoadMore,
|
|
29
|
+
}: BoardSortableListProps<M>) {
|
|
30
|
+
const { t } = useTranslation();
|
|
31
|
+
const {
|
|
32
|
+
setNodeRef,
|
|
33
|
+
} = useDroppable({
|
|
34
|
+
id: columnId,
|
|
35
|
+
data: { type: "ITEM-LIST" }
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
// Infinite scroll sentinel ref - must be inside scrollable container
|
|
39
|
+
const sentinelRef = useRef<HTMLDivElement>(null);
|
|
40
|
+
const isLoadingRef = useRef(false);
|
|
41
|
+
isLoadingRef.current = loading;
|
|
42
|
+
const lastLoadTimeRef = useRef(0);
|
|
43
|
+
|
|
44
|
+
// Set up IntersectionObserver for infinite scroll
|
|
45
|
+
useEffect(() => {
|
|
46
|
+
if (!sentinelRef.current || !hasMore || !onLoadMore) return;
|
|
47
|
+
|
|
48
|
+
const sentinel = sentinelRef.current;
|
|
49
|
+
|
|
50
|
+
const observer = new IntersectionObserver(
|
|
51
|
+
(entries) => {
|
|
52
|
+
const now = Date.now();
|
|
53
|
+
if (
|
|
54
|
+
entries[0].isIntersecting &&
|
|
55
|
+
hasMore &&
|
|
56
|
+
!isLoadingRef.current &&
|
|
57
|
+
now - lastLoadTimeRef.current > 500
|
|
58
|
+
) {
|
|
59
|
+
lastLoadTimeRef.current = now;
|
|
60
|
+
onLoadMore();
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
{ threshold: 0.1 }
|
|
64
|
+
);
|
|
65
|
+
|
|
66
|
+
observer.observe(sentinel);
|
|
67
|
+
|
|
68
|
+
// Check if sentinel is already visible when effect runs
|
|
69
|
+
// This handles the case where the sentinel was visible before the observer was created
|
|
70
|
+
const rect = sentinel.getBoundingClientRect();
|
|
71
|
+
const containerRect = sentinel.parentElement?.getBoundingClientRect();
|
|
72
|
+
if (containerRect && rect.top < containerRect.bottom && rect.bottom > containerRect.top) {
|
|
73
|
+
const now = Date.now();
|
|
74
|
+
if (hasMore && !isLoadingRef.current && now - lastLoadTimeRef.current > 500) {
|
|
75
|
+
lastLoadTimeRef.current = now;
|
|
76
|
+
onLoadMore();
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
return () => observer.disconnect();
|
|
81
|
+
}, [hasMore, onLoadMore]);
|
|
82
|
+
|
|
83
|
+
// Memoize className to avoid recomputation on every render
|
|
84
|
+
const containerClassName = useMemo(() => cls(
|
|
85
|
+
"flex flex-col p-2 transition-opacity duration-100 transition-bg ease-linear w-full overflow-y-auto no-scrollbar flex-1 rounded-md",
|
|
86
|
+
isDragging && isDragOverColumn
|
|
87
|
+
? "bg-surface-accent-200 dark:bg-surface-800"
|
|
88
|
+
: isDragging
|
|
89
|
+
? "bg-surface-50 dark:bg-surface-950 hover:bg-surface-accent-100 dark:hover:bg-surface-800"
|
|
90
|
+
: "bg-surface-50 dark:bg-surface-950"
|
|
91
|
+
), [isDragging, isDragOverColumn]);
|
|
92
|
+
|
|
93
|
+
return (
|
|
94
|
+
<div
|
|
95
|
+
ref={setNodeRef}
|
|
96
|
+
className={containerClassName}
|
|
97
|
+
style={{ minHeight: 80 }}
|
|
98
|
+
>
|
|
99
|
+
{items.length === 0 && !loading ? (
|
|
100
|
+
<div className="flex-1 flex items-center justify-center">
|
|
101
|
+
<span className="text-xs text-surface-400 dark:text-surface-500">
|
|
102
|
+
{t("no_items")}
|
|
103
|
+
</span>
|
|
104
|
+
</div>
|
|
105
|
+
) : (
|
|
106
|
+
<>
|
|
107
|
+
{items.map((item, index) => (
|
|
108
|
+
<SortableItem
|
|
109
|
+
key={item.id}
|
|
110
|
+
item={item}
|
|
111
|
+
index={index}
|
|
112
|
+
columnId={columnId}
|
|
113
|
+
ItemComponent={ItemComponent}
|
|
114
|
+
/>
|
|
115
|
+
))}
|
|
116
|
+
{/* Infinite scroll sentinel - inside scrollable container */}
|
|
117
|
+
{(loading || hasMore) && (
|
|
118
|
+
<div ref={sentinelRef} className="flex items-center justify-center py-2 min-h-6">
|
|
119
|
+
{loading && <CircularProgress size="smallest" />}
|
|
120
|
+
</div>
|
|
121
|
+
)}
|
|
122
|
+
</>
|
|
123
|
+
)}
|
|
124
|
+
</div>
|
|
125
|
+
);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
interface SortableItemProps<M extends Record<string, any>> {
|
|
129
|
+
item: BoardItem<M>;
|
|
130
|
+
index: number;
|
|
131
|
+
columnId: string;
|
|
132
|
+
ItemComponent: React.ComponentType<BoardItemViewProps<M>>;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
// Memoized to prevent unnecessary re-renders when other items in the list change
|
|
136
|
+
const SortableItem = memo(function SortableItem<M extends Record<string, any>>({
|
|
137
|
+
item,
|
|
138
|
+
index,
|
|
139
|
+
columnId,
|
|
140
|
+
ItemComponent,
|
|
141
|
+
}: SortableItemProps<M>) {
|
|
142
|
+
const {
|
|
143
|
+
setNodeRef,
|
|
144
|
+
attributes,
|
|
145
|
+
listeners,
|
|
146
|
+
isDragging: isItemBeingDragged,
|
|
147
|
+
transform,
|
|
148
|
+
transition,
|
|
149
|
+
} = useSortable({
|
|
150
|
+
id: item.id,
|
|
151
|
+
data: {
|
|
152
|
+
type: "ITEM",
|
|
153
|
+
columnId
|
|
154
|
+
}
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
// Memoize style object to prevent object recreation on each render
|
|
158
|
+
const sortableStyle = useMemo(() => ({
|
|
159
|
+
transform: CSS.Transform.toString(transform),
|
|
160
|
+
transition,
|
|
161
|
+
zIndex: isItemBeingDragged ? 2 : 1,
|
|
162
|
+
opacity: isItemBeingDragged ? 0 : 1,
|
|
163
|
+
}), [transform, transition, isItemBeingDragged]);
|
|
164
|
+
|
|
165
|
+
return (
|
|
166
|
+
<div ref={setNodeRef} style={sortableStyle} {...attributes} {...listeners}>
|
|
167
|
+
<ItemComponent
|
|
168
|
+
item={item}
|
|
169
|
+
isDragging={isItemBeingDragged}
|
|
170
|
+
index={index}
|
|
171
|
+
/>
|
|
172
|
+
</div>
|
|
173
|
+
);
|
|
174
|
+
}) as <M extends Record<string, any>>(props: SortableItemProps<M>) => React.ReactElement;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Typography, IconButton, RefreshIcon, Button, Tooltip } from "@firecms/ui";
|
|
3
|
+
import { useTranslation } from "../../hooks";
|
|
4
|
+
|
|
5
|
+
export function CollectionDataErrorBanner({ error, onRetry }: { error?: Error, onRetry?: () => void }) {
|
|
6
|
+
const { t } = useTranslation();
|
|
7
|
+
if (!error) return null;
|
|
8
|
+
|
|
9
|
+
const errorMessage = error.message || "";
|
|
10
|
+
// Only extract standard Firestore index errors using the standard matching pattern
|
|
11
|
+
const indexUrl = errorMessage.match(/https:\/\/console\.firebase\.google\.com[^\s]+/)?.[0];
|
|
12
|
+
|
|
13
|
+
return (
|
|
14
|
+
<div className="flex w-full items-center gap-4 px-4 py-3 bg-red-50 dark:bg-red-900/20 border-b border-red-200 dark:border-red-800">
|
|
15
|
+
<Typography variant="body2" className="text-red-700 dark:text-red-300 flex-1 break-words">
|
|
16
|
+
<strong>{t("error")}:</strong>{" "}
|
|
17
|
+
{indexUrl
|
|
18
|
+
? t("error_firestore_index")
|
|
19
|
+
: errorMessage}
|
|
20
|
+
</Typography>
|
|
21
|
+
{onRetry && (
|
|
22
|
+
<Tooltip title={t("refresh_data")}>
|
|
23
|
+
<IconButton
|
|
24
|
+
size="small"
|
|
25
|
+
onClick={onRetry}
|
|
26
|
+
>
|
|
27
|
+
<RefreshIcon size="small" />
|
|
28
|
+
</IconButton>
|
|
29
|
+
</Tooltip>
|
|
30
|
+
)}
|
|
31
|
+
{indexUrl && (
|
|
32
|
+
<Button
|
|
33
|
+
size="small"
|
|
34
|
+
variant="outlined"
|
|
35
|
+
color="error"
|
|
36
|
+
onClick={() => window.open(indexUrl, "_blank")}
|
|
37
|
+
>
|
|
38
|
+
{t("create_index")}
|
|
39
|
+
</Button>
|
|
40
|
+
)}
|
|
41
|
+
</div>
|
|
42
|
+
);
|
|
43
|
+
}
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
import React, { memo, useCallback, useMemo } from "react";
|
|
2
|
+
import { Entity, EntityCollection, ResolvedProperty } from "../../types";
|
|
3
|
+
import {
|
|
4
|
+
getEntityImagePreviewPropertyKey,
|
|
5
|
+
getEntityTitlePropertyKey,
|
|
6
|
+
getValueInPath,
|
|
7
|
+
IconForView,
|
|
8
|
+
resolveCollection
|
|
9
|
+
} from "../../util";
|
|
10
|
+
import { Checkbox, cls, defaultBorderMixin } from "@firecms/ui";
|
|
11
|
+
import { PropertyPreview } from "../../preview";
|
|
12
|
+
import { useAuthController, useCustomizationController } from "../../hooks";
|
|
13
|
+
import { BoardItemViewProps } from "./board_types";
|
|
14
|
+
|
|
15
|
+
export type EntityBoardCardProps<M extends Record<string, any> = any> = BoardItemViewProps<M> & {
|
|
16
|
+
collection: EntityCollection<M>;
|
|
17
|
+
onClick?: (entity: Entity<M>) => void;
|
|
18
|
+
selected?: boolean;
|
|
19
|
+
onSelectionChange?: (entity: Entity<M>, selected: boolean) => void;
|
|
20
|
+
selectionEnabled?: boolean;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Compact card component for displaying an entity in a Kanban board.
|
|
25
|
+
* Shows thumbnail, title, and optional selection checkbox.
|
|
26
|
+
*/
|
|
27
|
+
function EntityBoardCardInner<M extends Record<string, any> = any>({
|
|
28
|
+
item,
|
|
29
|
+
isDragging,
|
|
30
|
+
isGroupedOver,
|
|
31
|
+
style,
|
|
32
|
+
collection,
|
|
33
|
+
onClick,
|
|
34
|
+
selected,
|
|
35
|
+
onSelectionChange,
|
|
36
|
+
selectionEnabled = false
|
|
37
|
+
}: EntityBoardCardProps<M>) {
|
|
38
|
+
const entity = item.entity;
|
|
39
|
+
const authController = useAuthController();
|
|
40
|
+
const customizationController = useCustomizationController();
|
|
41
|
+
|
|
42
|
+
const resolvedCollection = useMemo(() => resolveCollection({
|
|
43
|
+
collection,
|
|
44
|
+
path: entity.path,
|
|
45
|
+
values: entity.values,
|
|
46
|
+
propertyConfigs: customizationController.propertyConfigs,
|
|
47
|
+
authController
|
|
48
|
+
}), [collection, entity.path, entity.values, customizationController.propertyConfigs, authController]);
|
|
49
|
+
|
|
50
|
+
const titlePropertyKey = useMemo(
|
|
51
|
+
() => getEntityTitlePropertyKey(resolvedCollection, customizationController.propertyConfigs),
|
|
52
|
+
[resolvedCollection, customizationController.propertyConfigs]
|
|
53
|
+
);
|
|
54
|
+
|
|
55
|
+
const imagePropertyKey = useMemo(
|
|
56
|
+
() => getEntityImagePreviewPropertyKey(resolvedCollection),
|
|
57
|
+
[resolvedCollection]
|
|
58
|
+
);
|
|
59
|
+
|
|
60
|
+
const imageProperty = imagePropertyKey ? resolvedCollection.properties[imagePropertyKey] : undefined;
|
|
61
|
+
const usedImageProperty = imageProperty && "of" in imageProperty ? imageProperty.of : imageProperty;
|
|
62
|
+
|
|
63
|
+
const imageValue = imagePropertyKey ? getValueInPath(entity.values, imagePropertyKey) : undefined;
|
|
64
|
+
const usedImageValue = imageProperty !== undefined
|
|
65
|
+
? ("of" in imageProperty
|
|
66
|
+
? ((imageValue ?? []).length > 0 ? imageValue[0] : undefined)
|
|
67
|
+
: imageValue)
|
|
68
|
+
: undefined;
|
|
69
|
+
|
|
70
|
+
const titleValue = titlePropertyKey ? getValueInPath(entity.values, titlePropertyKey) : undefined;
|
|
71
|
+
const titleProperty = titlePropertyKey ? resolvedCollection.properties[titlePropertyKey] as ResolvedProperty : undefined;
|
|
72
|
+
|
|
73
|
+
const handleClick = useCallback((e: React.MouseEvent) => {
|
|
74
|
+
// Cmd+click (Mac) or Ctrl+click (Windows) toggles selection
|
|
75
|
+
if ((e.metaKey || e.ctrlKey) && selectionEnabled) {
|
|
76
|
+
e.preventDefault();
|
|
77
|
+
e.stopPropagation();
|
|
78
|
+
onSelectionChange?.(entity, !selected);
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
if (onClick) {
|
|
82
|
+
e.stopPropagation();
|
|
83
|
+
onClick(entity);
|
|
84
|
+
}
|
|
85
|
+
}, [entity, onClick, onSelectionChange, selected, selectionEnabled]);
|
|
86
|
+
|
|
87
|
+
const handleCheckboxClick = useCallback((e: React.MouseEvent) => {
|
|
88
|
+
e.stopPropagation();
|
|
89
|
+
}, []);
|
|
90
|
+
|
|
91
|
+
const handleSelectionChange = useCallback((checked: boolean) => {
|
|
92
|
+
onSelectionChange?.(entity, checked);
|
|
93
|
+
}, [entity, onSelectionChange]);
|
|
94
|
+
|
|
95
|
+
// Memoize className computations
|
|
96
|
+
const backgroundColor = useMemo((): string => {
|
|
97
|
+
if (isDragging) {
|
|
98
|
+
return "bg-surface-100 dark:bg-surface-800";
|
|
99
|
+
}
|
|
100
|
+
if (isGroupedOver) {
|
|
101
|
+
return "bg-surface-200";
|
|
102
|
+
}
|
|
103
|
+
return "bg-white dark:bg-surface-900 hover:bg-surface-100 dark:hover:bg-surface-800";
|
|
104
|
+
}, [isDragging, isGroupedOver]);
|
|
105
|
+
|
|
106
|
+
const borderColor = useMemo((): string =>
|
|
107
|
+
isDragging ? "ring-2 ring-primary" : "", [isDragging]);
|
|
108
|
+
|
|
109
|
+
// Memoize the card className
|
|
110
|
+
const cardClassName = useMemo(() => cls(
|
|
111
|
+
"p-2 flex items-start border rounded-lg cursor-pointer transition-colors",
|
|
112
|
+
defaultBorderMixin,
|
|
113
|
+
borderColor,
|
|
114
|
+
backgroundColor,
|
|
115
|
+
selected && "ring-2 ring-primary"
|
|
116
|
+
), [borderColor, backgroundColor, selected]);
|
|
117
|
+
|
|
118
|
+
return (
|
|
119
|
+
<div
|
|
120
|
+
style={style}
|
|
121
|
+
className="py-1"
|
|
122
|
+
data-is-dragging={isDragging}
|
|
123
|
+
data-testid={item.id}
|
|
124
|
+
onClick={handleClick}
|
|
125
|
+
>
|
|
126
|
+
<div className={cardClassName}>
|
|
127
|
+
{/* Thumbnail */}
|
|
128
|
+
{usedImageProperty && usedImageValue ? (
|
|
129
|
+
<div className="w-10 h-10 rounded-md overflow-hidden shrink-0 mr-2">
|
|
130
|
+
<PropertyPreview
|
|
131
|
+
property={usedImageProperty}
|
|
132
|
+
propertyKey={imagePropertyKey as string}
|
|
133
|
+
size="small"
|
|
134
|
+
value={usedImageValue}
|
|
135
|
+
fill={true}
|
|
136
|
+
/>
|
|
137
|
+
</div>
|
|
138
|
+
) : (
|
|
139
|
+
<div
|
|
140
|
+
className="w-10 h-10 rounded-md bg-surface-100 dark:bg-surface-800 shrink-0 mr-2 flex items-center justify-center">
|
|
141
|
+
<IconForView
|
|
142
|
+
collectionOrView={collection}
|
|
143
|
+
color="disabled"
|
|
144
|
+
size="small"
|
|
145
|
+
/>
|
|
146
|
+
</div>
|
|
147
|
+
)}
|
|
148
|
+
|
|
149
|
+
{/* Content */}
|
|
150
|
+
<div className="flex-1 min-w-0">
|
|
151
|
+
{/* Title */}
|
|
152
|
+
<div className="line-clamp-2 text-sm font-medium">
|
|
153
|
+
{titleProperty && titleValue ? (
|
|
154
|
+
<PropertyPreview
|
|
155
|
+
propertyKey={titlePropertyKey as string}
|
|
156
|
+
value={titleValue}
|
|
157
|
+
property={titleProperty}
|
|
158
|
+
size="small"
|
|
159
|
+
/>
|
|
160
|
+
) : (
|
|
161
|
+
<span className="text-surface-500">{entity.id}</span>
|
|
162
|
+
)}
|
|
163
|
+
</div>
|
|
164
|
+
{/* ID */}
|
|
165
|
+
<div className="text-xs text-surface-500 font-mono truncate">
|
|
166
|
+
{entity.id}
|
|
167
|
+
</div>
|
|
168
|
+
</div>
|
|
169
|
+
|
|
170
|
+
{/* Selection checkbox */}
|
|
171
|
+
{selectionEnabled && (
|
|
172
|
+
<div className="ml-2 shrink-0" onClick={handleCheckboxClick}>
|
|
173
|
+
<Checkbox
|
|
174
|
+
checked={selected ?? false}
|
|
175
|
+
onCheckedChange={handleSelectionChange}
|
|
176
|
+
size="smallest"
|
|
177
|
+
/>
|
|
178
|
+
</div>
|
|
179
|
+
)}
|
|
180
|
+
</div>
|
|
181
|
+
</div>
|
|
182
|
+
);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
// Memoized to prevent unnecessary re-renders when other cards in the board change
|
|
186
|
+
export const EntityBoardCard = memo(EntityBoardCardInner) as typeof EntityBoardCardInner;
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* Wrapper component that adapts EntityBoardCard to BoardItemViewProps interface
|
|
190
|
+
*/
|
|
191
|
+
export function createEntityBoardCardComponent<M extends Record<string, any>>(
|
|
192
|
+
collection: EntityCollection<M>,
|
|
193
|
+
options: {
|
|
194
|
+
onClick?: (entity: Entity<M>) => void;
|
|
195
|
+
isEntitySelected?: (entity: Entity<M>) => boolean;
|
|
196
|
+
onSelectionChange?: (entity: Entity<M>, selected: boolean) => void;
|
|
197
|
+
selectionEnabled?: boolean;
|
|
198
|
+
}
|
|
199
|
+
): React.ComponentType<BoardItemViewProps<M>> {
|
|
200
|
+
return function EntityBoardCardWrapper(props: BoardItemViewProps<M>) {
|
|
201
|
+
return (
|
|
202
|
+
<EntityBoardCard
|
|
203
|
+
{...props}
|
|
204
|
+
collection={collection}
|
|
205
|
+
onClick={options.onClick}
|
|
206
|
+
selected={options.isEntitySelected?.(props.item.entity)}
|
|
207
|
+
onSelectionChange={options.onSelectionChange}
|
|
208
|
+
selectionEnabled={options.selectionEnabled}
|
|
209
|
+
/>
|
|
210
|
+
);
|
|
211
|
+
};
|
|
212
|
+
}
|
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
import React, { useMemo } from "react";
|
|
2
|
+
import {
|
|
3
|
+
CollectionSize,
|
|
4
|
+
Entity,
|
|
5
|
+
EntityCollection,
|
|
6
|
+
ResolvedProperty
|
|
7
|
+
} from "../../types";
|
|
8
|
+
import {
|
|
9
|
+
getEntityImagePreviewPropertyKey,
|
|
10
|
+
getEntityPreviewKeys,
|
|
11
|
+
getEntityTitlePropertyKey,
|
|
12
|
+
getValueInPath,
|
|
13
|
+
IconForView,
|
|
14
|
+
resolveCollection
|
|
15
|
+
} from "../../util";
|
|
16
|
+
import {
|
|
17
|
+
Card,
|
|
18
|
+
Checkbox,
|
|
19
|
+
cls,
|
|
20
|
+
KeyboardTabIcon,
|
|
21
|
+
IconButton,
|
|
22
|
+
Skeleton,
|
|
23
|
+
Tooltip,
|
|
24
|
+
Typography
|
|
25
|
+
} from "@firecms/ui";
|
|
26
|
+
import { PropertyPreview, SkeletonPropertyComponent } from "../../preview";
|
|
27
|
+
import {
|
|
28
|
+
useAuthController,
|
|
29
|
+
useCustomizationController,
|
|
30
|
+
useNavigationController,
|
|
31
|
+
useSideEntityController
|
|
32
|
+
} from "../../hooks";
|
|
33
|
+
import { useAnalyticsController } from "../../hooks/useAnalyticsController";
|
|
34
|
+
|
|
35
|
+
export type EntityCardProps<M extends Record<string, any> = any> = {
|
|
36
|
+
entity: Entity<M>;
|
|
37
|
+
collection: EntityCollection<M>;
|
|
38
|
+
onClick?: (entity: Entity<M>) => void;
|
|
39
|
+
selected?: boolean;
|
|
40
|
+
highlighted?: boolean;
|
|
41
|
+
onSelectionChange?: (entity: Entity<M>, selected: boolean) => void;
|
|
42
|
+
selectionEnabled?: boolean;
|
|
43
|
+
/**
|
|
44
|
+
* Size of the card - affects checkbox styling
|
|
45
|
+
*/
|
|
46
|
+
size?: CollectionSize;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Card component for displaying an entity in a grid view.
|
|
51
|
+
* Shows thumbnail, title, and preview properties.
|
|
52
|
+
*/
|
|
53
|
+
export function EntityCard<M extends Record<string, any> = any>({
|
|
54
|
+
entity,
|
|
55
|
+
collection,
|
|
56
|
+
onClick,
|
|
57
|
+
selected,
|
|
58
|
+
highlighted,
|
|
59
|
+
onSelectionChange,
|
|
60
|
+
selectionEnabled,
|
|
61
|
+
size = "m"
|
|
62
|
+
}: EntityCardProps<M>) {
|
|
63
|
+
const authController = useAuthController();
|
|
64
|
+
const analyticsController = useAnalyticsController();
|
|
65
|
+
const sideEntityController = useSideEntityController();
|
|
66
|
+
const customizationController = useCustomizationController();
|
|
67
|
+
const navigationController = useNavigationController();
|
|
68
|
+
|
|
69
|
+
const resolvedCollection = useMemo(() => resolveCollection({
|
|
70
|
+
collection,
|
|
71
|
+
path: entity.path,
|
|
72
|
+
values: entity.values,
|
|
73
|
+
propertyConfigs: customizationController.propertyConfigs,
|
|
74
|
+
authController
|
|
75
|
+
}), [collection, entity.path, entity.values]);
|
|
76
|
+
|
|
77
|
+
const titlePropertyKey = useMemo(
|
|
78
|
+
() => getEntityTitlePropertyKey(resolvedCollection, customizationController.propertyConfigs),
|
|
79
|
+
[resolvedCollection, customizationController.propertyConfigs]
|
|
80
|
+
);
|
|
81
|
+
|
|
82
|
+
const imagePropertyKey = useMemo(
|
|
83
|
+
() => getEntityImagePreviewPropertyKey(resolvedCollection),
|
|
84
|
+
[resolvedCollection]
|
|
85
|
+
);
|
|
86
|
+
|
|
87
|
+
const previewKeys = useMemo(
|
|
88
|
+
() => getEntityPreviewKeys(authController, resolvedCollection, customizationController.propertyConfigs, undefined, 2)
|
|
89
|
+
.filter(key => key !== titlePropertyKey && key !== imagePropertyKey),
|
|
90
|
+
[authController, resolvedCollection, customizationController.propertyConfigs, titlePropertyKey, imagePropertyKey]
|
|
91
|
+
);
|
|
92
|
+
|
|
93
|
+
const imageProperty = imagePropertyKey ? resolvedCollection.properties[imagePropertyKey] : undefined;
|
|
94
|
+
const usedImageProperty = imageProperty && "of" in imageProperty ? imageProperty.of : imageProperty;
|
|
95
|
+
|
|
96
|
+
const imageValue = imagePropertyKey ? getValueInPath(entity.values, imagePropertyKey) : undefined;
|
|
97
|
+
const usedImageValue = imageProperty !== undefined
|
|
98
|
+
? ("of" in imageProperty
|
|
99
|
+
? ((imageValue ?? []).length > 0 ? imageValue[0] : undefined)
|
|
100
|
+
: imageValue)
|
|
101
|
+
: undefined;
|
|
102
|
+
|
|
103
|
+
const titleValue = titlePropertyKey ? getValueInPath(entity.values, titlePropertyKey) : undefined;
|
|
104
|
+
const titleProperty = titlePropertyKey ? resolvedCollection.properties[titlePropertyKey] as ResolvedProperty : undefined;
|
|
105
|
+
|
|
106
|
+
const handleClick = (e?: React.MouseEvent) => {
|
|
107
|
+
// Cmd+click (Mac) or Ctrl+click (Windows) toggles selection
|
|
108
|
+
if (e && (e.metaKey || e.ctrlKey) && selectionEnabled) {
|
|
109
|
+
e.preventDefault();
|
|
110
|
+
onSelectionChange?.(entity, !selected);
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
if (onClick) {
|
|
114
|
+
analyticsController.onAnalyticsEvent?.("card_view_entity_click", {
|
|
115
|
+
path: entity.path,
|
|
116
|
+
entityId: entity.id
|
|
117
|
+
});
|
|
118
|
+
onClick(entity);
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
const handleCheckboxClick = (e: React.MouseEvent) => {
|
|
123
|
+
e.stopPropagation();
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
const handleSelectionChange = (checked: boolean) => {
|
|
127
|
+
onSelectionChange?.(entity, checked);
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
return (
|
|
132
|
+
<Card
|
|
133
|
+
className={cls(
|
|
134
|
+
"cursor-pointer overflow-hidden group relative",
|
|
135
|
+
"transition-all duration-200",
|
|
136
|
+
"hover:shadow-lg hover:-translate-y-0.5",
|
|
137
|
+
selected && "ring-2 ring-primary",
|
|
138
|
+
highlighted && !selected && "ring-2 ring-primary ring-opacity-50"
|
|
139
|
+
)}
|
|
140
|
+
onClick={handleClick}
|
|
141
|
+
>
|
|
142
|
+
{/* Thumbnail area */}
|
|
143
|
+
<div className="aspect-[4/3] relative overflow-hidden bg-surface-100 dark:bg-surface-800">
|
|
144
|
+
{usedImageProperty && usedImageValue ? (
|
|
145
|
+
<div className="w-full h-full">
|
|
146
|
+
<PropertyPreview
|
|
147
|
+
property={usedImageProperty}
|
|
148
|
+
propertyKey={imagePropertyKey as string}
|
|
149
|
+
size="medium"
|
|
150
|
+
value={usedImageValue}
|
|
151
|
+
fill={true}
|
|
152
|
+
/>
|
|
153
|
+
</div>
|
|
154
|
+
) : (
|
|
155
|
+
<div className="w-full h-full flex items-center justify-center">
|
|
156
|
+
<IconForView
|
|
157
|
+
collectionOrView={collection}
|
|
158
|
+
color="disabled"
|
|
159
|
+
size="large"
|
|
160
|
+
/>
|
|
161
|
+
</div>
|
|
162
|
+
)}
|
|
163
|
+
|
|
164
|
+
{/* Hover overlay */}
|
|
165
|
+
<div className={cls(
|
|
166
|
+
"absolute inset-0 bg-black/0 group-hover:bg-black/10",
|
|
167
|
+
"transition-colors duration-200"
|
|
168
|
+
)} />
|
|
169
|
+
|
|
170
|
+
{/* Selection checkbox */}
|
|
171
|
+
{selectionEnabled && (
|
|
172
|
+
<div
|
|
173
|
+
className={cls(
|
|
174
|
+
"absolute",
|
|
175
|
+
size === "xs" || size === "s" ? "top-1 left-1" : "top-2 left-2"
|
|
176
|
+
)}
|
|
177
|
+
onClick={handleCheckboxClick}
|
|
178
|
+
>
|
|
179
|
+
<Checkbox
|
|
180
|
+
checked={selected ?? false}
|
|
181
|
+
onCheckedChange={handleSelectionChange}
|
|
182
|
+
size={size === "xs" ? "smallest" : "small"}
|
|
183
|
+
/>
|
|
184
|
+
</div>
|
|
185
|
+
)}
|
|
186
|
+
|
|
187
|
+
</div>
|
|
188
|
+
|
|
189
|
+
{/* Content area */}
|
|
190
|
+
<div className="p-3">
|
|
191
|
+
{/* Entity ID */}
|
|
192
|
+
<Typography
|
|
193
|
+
variant="caption"
|
|
194
|
+
color="disabled"
|
|
195
|
+
className="font-mono truncate block"
|
|
196
|
+
>
|
|
197
|
+
{entity.id}
|
|
198
|
+
</Typography>
|
|
199
|
+
|
|
200
|
+
{/* Title */}
|
|
201
|
+
<div className="truncate my-1 text-sm font-medium min-h-[20px]">
|
|
202
|
+
{titleProperty && titleValue ? (
|
|
203
|
+
<PropertyPreview
|
|
204
|
+
propertyKey={titlePropertyKey as string}
|
|
205
|
+
value={titleValue}
|
|
206
|
+
property={titleProperty}
|
|
207
|
+
size="small"
|
|
208
|
+
/>
|
|
209
|
+
) : (
|
|
210
|
+
<Typography variant="body2" className="text-surface-500">
|
|
211
|
+
{entity.id}
|
|
212
|
+
</Typography>
|
|
213
|
+
)}
|
|
214
|
+
</div>
|
|
215
|
+
|
|
216
|
+
{/* Preview properties */}
|
|
217
|
+
{previewKeys.slice(0, 2).map((key) => {
|
|
218
|
+
const property = resolvedCollection.properties[key] as ResolvedProperty;
|
|
219
|
+
if (!property) return null;
|
|
220
|
+
const value = getValueInPath(entity.values, key);
|
|
221
|
+
return (
|
|
222
|
+
<div key={key} className="truncate text-xs text-surface-600 dark:text-surface-400">
|
|
223
|
+
<PropertyPreview
|
|
224
|
+
propertyKey={key}
|
|
225
|
+
value={value}
|
|
226
|
+
property={property}
|
|
227
|
+
size="small"
|
|
228
|
+
/>
|
|
229
|
+
</div>
|
|
230
|
+
);
|
|
231
|
+
})}
|
|
232
|
+
</div>
|
|
233
|
+
</Card>
|
|
234
|
+
);
|
|
235
|
+
}
|