@firecms/core 3.0.0-canary.7 → 3.0.0-canary.70
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 +2 -2
- package/dist/app/AppBar.d.ts +12 -0
- package/dist/app/Drawer.d.ts +17 -0
- package/dist/app/Scaffold.d.ts +30 -0
- package/dist/app/index.d.ts +4 -0
- package/dist/app/useApp.d.ts +16 -0
- package/dist/components/ClearFilterSortButton.d.ts +5 -0
- package/dist/components/EntityCollectionTable/EntityCollectionRowActions.d.ts +11 -11
- package/dist/components/EntityCollectionTable/EntityCollectionTable.d.ts +2 -2
- package/dist/components/EntityCollectionTable/EntityCollectionTableProps.d.ts +5 -3
- package/dist/components/EntityCollectionTable/PropertyTableCell.d.ts +3 -2
- package/dist/components/EntityCollectionTable/column_utils.d.ts +1 -2
- package/dist/components/EntityCollectionTable/fields/TableReferenceField.d.ts +2 -0
- package/dist/components/EntityCollectionTable/internal/CollectionTableToolbar.d.ts +1 -4
- package/dist/components/EntityCollectionTable/internal/EntityTableCell.d.ts +2 -2
- package/dist/components/EntityCollectionTable/internal/popup_field/PopupFormField.d.ts +1 -1
- package/dist/components/EntityCollectionView/EntityCollectionView.d.ts +12 -3
- package/dist/components/EntityCollectionView/EntityCollectionViewStartActions.d.ts +11 -0
- package/dist/components/EntityCollectionView/useSelectionController.d.ts +2 -0
- package/dist/components/EntityPreview.d.ts +26 -7
- package/dist/components/EntityView.d.ts +11 -0
- package/dist/components/FieldCaption.d.ts +5 -0
- package/dist/components/HomePage/NavigationCard.d.ts +8 -0
- package/dist/components/HomePage/{NavigationCollectionCard.d.ts → NavigationCardBinding.d.ts} +2 -2
- package/dist/components/HomePage/SmallNavigationCard.d.ts +6 -0
- package/dist/components/HomePage/index.d.ts +3 -1
- package/dist/components/ReferenceWidget.d.ts +3 -1
- package/dist/components/SelectableTable/SelectableTable.d.ts +1 -1
- package/dist/components/SelectableTable/filters/ReferenceFilterField.d.ts +2 -1
- package/dist/components/VirtualTable/VirtualTableProps.d.ts +6 -7
- package/dist/components/VirtualTable/types.d.ts +3 -3
- package/dist/components/{EntityCollectionTable/internal → common}/default_entity_actions.d.ts +1 -1
- package/dist/components/common/index.d.ts +1 -0
- package/dist/components/common/table_height.d.ts +5 -0
- package/dist/components/common/types.d.ts +4 -6
- package/dist/components/common/useDataSourceEntityCollectionTableController.d.ts +3 -0
- package/dist/components/index.d.ts +6 -3
- package/dist/contexts/AuthControllerContext.d.ts +1 -1
- package/dist/{components/FireCMSAppBar.d.ts → core/DefaultAppBar.d.ts} +5 -8
- package/dist/core/DefaultDrawer.d.ts +19 -0
- package/dist/core/DrawerNavigationItem.d.ts +9 -0
- package/dist/core/EntityEditView.d.ts +36 -0
- package/dist/core/NavigationRoutes.d.ts +2 -2
- package/dist/core/index.d.ts +3 -4
- package/dist/form/PropertiesForm.d.ts +8 -0
- package/dist/form/components/ErrorFocus.d.ts +1 -1
- package/dist/form/components/FieldHelperText.d.ts +3 -3
- package/dist/form/components/StorageItemPreview.d.ts +2 -3
- package/dist/form/components/StorageUploadProgress.d.ts +1 -1
- package/dist/form/field_bindings/KeyValueFieldBinding.d.ts +1 -1
- package/dist/form/field_bindings/MapFieldBinding.d.ts +1 -1
- package/dist/form/field_bindings/StorageUploadFieldBinding.d.ts +3 -4
- package/dist/form/field_bindings/TextFieldBinding.d.ts +2 -2
- package/dist/form/index.d.ts +0 -2
- package/dist/form/validation.d.ts +1 -1
- package/dist/hooks/data/delete.d.ts +2 -2
- package/dist/hooks/data/save.d.ts +2 -3
- package/dist/hooks/data/useDataSource.d.ts +2 -2
- package/dist/hooks/data/useEntityFetch.d.ts +3 -3
- package/dist/hooks/index.d.ts +2 -0
- package/dist/hooks/useBuildNavigationController.d.ts +6 -4
- package/dist/hooks/useProjectLog.d.ts +6 -2
- package/dist/hooks/useStorageSource.d.ts +2 -2
- package/dist/hooks/useValidateAuthenticator.d.ts +21 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.es.js +10512 -9997
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +5 -5
- package/dist/index.umd.js.map +1 -1
- package/dist/internal/useBuildDataSource.d.ts +1 -16
- package/dist/preview/PropertyPreview.d.ts +1 -1
- package/dist/preview/PropertyPreviewProps.d.ts +1 -4
- package/dist/preview/components/BooleanPreview.d.ts +5 -1
- package/dist/preview/components/EnumValuesChip.d.ts +1 -1
- package/dist/preview/components/ReferencePreview.d.ts +3 -8
- package/dist/types/analytics.d.ts +1 -1
- package/dist/types/auth.d.ts +37 -1
- package/dist/types/collections.d.ts +44 -6
- package/dist/types/datasource.d.ts +21 -14
- package/dist/types/entities.d.ts +5 -1
- package/dist/types/entity_actions.d.ts +14 -0
- package/dist/types/entity_callbacks.d.ts +2 -2
- package/dist/types/entity_overrides.d.ts +6 -0
- package/dist/types/fields.d.ts +31 -30
- package/dist/types/index.d.ts +2 -1
- package/dist/types/navigation.d.ts +15 -14
- package/dist/types/permissions.d.ts +5 -1
- package/dist/types/plugins.d.ts +22 -22
- package/dist/types/properties.d.ts +13 -5
- package/dist/types/property_config.d.ts +2 -2
- package/dist/types/roles.d.ts +31 -0
- package/dist/types/storage.d.ts +11 -3
- package/dist/types/user.d.ts +5 -0
- package/dist/util/collections.d.ts +9 -1
- package/dist/util/entities.d.ts +1 -1
- package/dist/util/icon_synonyms.d.ts +1 -97
- package/dist/util/icons.d.ts +8 -2
- package/dist/util/navigation_utils.d.ts +2 -2
- package/dist/util/objects.d.ts +1 -1
- package/dist/util/permissions.d.ts +4 -4
- package/dist/util/references.d.ts +4 -2
- package/dist/util/resolutions.d.ts +14 -14
- package/dist/util/storage.d.ts +23 -2
- package/dist/util/useStorageUploadController.d.ts +1 -1
- package/dist/util/useTraceUpdate.d.ts +1 -0
- package/package.json +139 -119
- package/src/app/AppBar.tsx +18 -0
- package/src/app/Drawer.tsx +25 -0
- package/src/app/Scaffold.tsx +249 -0
- package/src/app/index.ts +4 -0
- package/src/app/useApp.tsx +32 -0
- package/src/components/ClearFilterSortButton.tsx +41 -0
- package/src/components/DeleteEntityDialog.tsx +4 -4
- package/src/components/EntityCollectionTable/EntityCollectionRowActions.tsx +4 -4
- package/src/components/EntityCollectionTable/EntityCollectionTable.tsx +276 -279
- package/src/components/EntityCollectionTable/EntityCollectionTableProps.tsx +9 -5
- package/src/components/EntityCollectionTable/PropertyTableCell.tsx +48 -45
- package/src/components/EntityCollectionTable/column_utils.tsx +3 -3
- package/src/components/EntityCollectionTable/fields/TableReferenceField.tsx +18 -17
- package/src/components/EntityCollectionTable/fields/TableStorageUpload.tsx +5 -5
- package/src/components/EntityCollectionTable/internal/CollectionTableToolbar.tsx +29 -34
- package/src/components/EntityCollectionTable/internal/EntityTableCell.tsx +16 -12
- package/src/components/EntityCollectionTable/internal/popup_field/PopupFormField.tsx +4 -5
- package/src/components/EntityCollectionView/EntityCollectionView.tsx +73 -72
- package/src/components/EntityCollectionView/EntityCollectionViewActions.tsx +5 -6
- package/src/components/EntityCollectionView/EntityCollectionViewStartActions.tsx +68 -0
- package/src/components/EntityCollectionView/useSelectionController.tsx +30 -0
- package/src/components/EntityPreview.tsx +209 -70
- package/src/components/EntityView.tsx +84 -0
- package/src/components/FieldCaption.tsx +14 -0
- package/src/components/HomePage/DefaultHomePage.tsx +15 -11
- package/src/components/HomePage/NavigationCard.tsx +69 -0
- package/src/components/HomePage/NavigationCardBinding.tsx +116 -0
- package/src/components/HomePage/SmallNavigationCard.tsx +45 -0
- package/src/components/HomePage/index.tsx +3 -1
- package/src/components/PropertyIdCopyTooltipContent.tsx +2 -3
- package/src/components/ReferenceTable/ReferenceSelectionTable.tsx +4 -4
- package/src/components/ReferenceWidget.tsx +22 -12
- package/src/components/SearchIconsView.tsx +5 -5
- package/src/components/SelectableTable/SelectableTable.tsx +5 -3
- package/src/components/SelectableTable/filters/BooleanFilterField.tsx +2 -3
- package/src/components/SelectableTable/filters/DateTimeFilterField.tsx +23 -8
- package/src/components/SelectableTable/filters/ReferenceFilterField.tsx +38 -24
- package/src/components/SelectableTable/filters/StringNumberFilterField.tsx +35 -15
- package/src/components/VirtualTable/VirtualTable.tsx +38 -29
- package/src/components/VirtualTable/VirtualTableHeader.tsx +4 -4
- package/src/components/VirtualTable/VirtualTableHeaderRow.tsx +2 -2
- package/src/components/VirtualTable/VirtualTableProps.tsx +7 -7
- package/src/components/VirtualTable/VirtualTableRow.tsx +4 -5
- package/src/components/VirtualTable/fields/VirtualTableDateField.tsx +1 -1
- package/src/components/VirtualTable/types.tsx +2 -3
- package/src/components/{EntityCollectionTable/internal → common}/default_entity_actions.tsx +11 -7
- package/src/components/common/index.ts +1 -0
- package/src/components/{VirtualTable/common.tsx → common/table_height.tsx} +5 -2
- package/src/components/common/types.tsx +4 -6
- package/src/components/common/useColumnsIds.tsx +10 -2
- package/src/components/common/useDataSourceEntityCollectionTableController.tsx +12 -1
- package/src/components/common/useTableSearchHelper.ts +39 -9
- package/src/components/index.tsx +6 -3
- package/src/contexts/AuthControllerContext.tsx +1 -1
- package/src/{components/FireCMSAppBar.tsx → core/DefaultAppBar.tsx} +51 -34
- package/src/core/DefaultDrawer.tsx +177 -0
- package/src/core/DrawerNavigationItem.tsx +62 -0
- package/src/core/EntityEditView.tsx +1101 -0
- package/src/core/EntitySidePanel.tsx +3 -4
- package/src/core/FireCMS.tsx +54 -43
- package/src/core/NavigationRoutes.tsx +14 -7
- package/src/core/field_configs.tsx +2 -3
- package/src/core/index.tsx +3 -4
- package/src/form/PropertiesForm.tsx +81 -0
- package/src/form/PropertyFieldBinding.tsx +29 -7
- package/src/form/components/FieldHelperText.tsx +3 -3
- package/src/form/components/StorageItemPreview.tsx +5 -7
- package/src/form/components/StorageUploadProgress.tsx +9 -8
- package/src/form/field_bindings/ArrayOfReferencesFieldBinding.tsx +10 -12
- package/src/form/field_bindings/BlockFieldBinding.tsx +2 -2
- package/src/form/field_bindings/DateTimeFieldBinding.tsx +1 -1
- package/src/form/field_bindings/KeyValueFieldBinding.tsx +19 -19
- package/src/form/field_bindings/MapFieldBinding.tsx +25 -17
- package/src/form/field_bindings/MarkdownFieldBinding.tsx +2 -2
- package/src/form/field_bindings/ReadOnlyFieldBinding.tsx +2 -9
- package/src/form/field_bindings/ReferenceFieldBinding.tsx +16 -13
- package/src/form/field_bindings/SelectFieldBinding.tsx +3 -3
- package/src/form/field_bindings/StorageUploadFieldBinding.tsx +14 -35
- package/src/form/field_bindings/TextFieldBinding.tsx +7 -5
- package/src/form/index.tsx +4 -4
- package/src/form/validation.ts +4 -21
- package/src/hooks/data/delete.ts +3 -3
- package/src/hooks/data/save.ts +4 -2
- package/src/hooks/data/useCollectionFetch.tsx +1 -1
- package/src/hooks/data/useDataSource.tsx +8 -3
- package/src/hooks/data/useEntityFetch.tsx +4 -4
- package/src/hooks/index.tsx +3 -0
- package/src/hooks/useBuildLocalConfigurationPersistence.tsx +8 -10
- package/src/hooks/useBuildModeController.tsx +11 -5
- package/src/hooks/useBuildNavigationController.tsx +200 -83
- package/src/hooks/useProjectLog.tsx +17 -7
- package/src/hooks/useReferenceDialog.tsx +2 -2
- package/src/hooks/useResolvedNavigationFrom.tsx +1 -1
- package/src/hooks/useStorageSource.tsx +7 -2
- package/src/hooks/useValidateAuthenticator.tsx +115 -0
- package/src/index.ts +1 -0
- package/src/internal/useBuildDataSource.ts +54 -47
- package/src/internal/useBuildSideEntityController.tsx +88 -21
- package/src/preview/PropertyPreview.tsx +5 -15
- package/src/preview/PropertyPreviewProps.tsx +1 -11
- package/src/preview/components/BooleanPreview.tsx +19 -4
- package/src/preview/components/EnumValuesChip.tsx +2 -2
- package/src/preview/components/ReferencePreview.tsx +72 -165
- package/src/preview/property_previews/ArrayOfMapsPreview.tsx +0 -1
- package/src/preview/property_previews/ArrayOfReferencesPreview.tsx +2 -1
- package/src/preview/property_previews/ArrayOfStorageComponentsPreview.tsx +0 -1
- package/src/preview/property_previews/ArrayOfStringsPreview.tsx +0 -1
- package/src/preview/property_previews/ArrayOneOfPreview.tsx +2 -3
- package/src/preview/property_previews/ArrayPropertyPreview.tsx +2 -3
- package/src/preview/property_previews/MapPropertyPreview.tsx +5 -5
- package/src/preview/property_previews/StringPropertyPreview.tsx +8 -7
- package/src/types/analytics.ts +1 -0
- package/src/types/auth.tsx +50 -1
- package/src/types/collections.ts +51 -6
- package/src/types/customization_controller.tsx +0 -1
- package/src/types/datasource.ts +24 -17
- package/src/types/entities.ts +9 -1
- package/src/types/entity_actions.tsx +17 -0
- package/src/types/entity_callbacks.ts +2 -2
- package/src/types/entity_overrides.tsx +7 -0
- package/src/types/fields.tsx +33 -33
- package/src/types/firecms.tsx +0 -1
- package/src/types/index.ts +2 -1
- package/src/types/navigation.ts +17 -17
- package/src/types/permissions.ts +6 -1
- package/src/types/plugins.tsx +28 -30
- package/src/types/properties.ts +19 -7
- package/src/types/property_config.tsx +2 -2
- package/src/types/roles.ts +41 -0
- package/src/types/side_entity_controller.tsx +1 -0
- package/src/types/storage.ts +12 -3
- package/src/types/user.ts +7 -0
- package/src/util/collections.ts +22 -0
- package/src/util/entities.ts +2 -1
- package/src/util/enums.ts +1 -1
- package/src/util/icon_list.ts +2 -2
- package/src/util/icon_synonyms.ts +3 -99
- package/src/util/icons.tsx +11 -3
- package/src/util/navigation_utils.ts +6 -6
- package/src/util/objects.ts +8 -21
- package/src/util/permissions.ts +12 -8
- package/src/util/references.ts +36 -5
- package/src/util/resolutions.ts +32 -31
- package/src/util/storage.ts +75 -21
- package/src/util/strings.ts +2 -2
- package/src/util/useStorageUploadController.tsx +21 -3
- package/src/util/useTraceUpdate.tsx +2 -1
- package/dist/components/VirtualTable/common.d.ts +0 -2
- package/dist/core/Drawer.d.ts +0 -23
- package/dist/core/EntityView.d.ts +0 -22
- package/dist/core/Scaffold.d.ts +0 -55
- package/dist/core/SideEntityView.d.ts +0 -7
- package/dist/form/EntityForm.d.ts +0 -77
- package/dist/internal/useBuildCustomizationController.d.ts +0 -2
- package/dist/internal/useLocaleConfig.d.ts +0 -1
- package/dist/types/appcheck.d.ts +0 -26
- package/src/components/HomePage/NavigationCollectionCard.tsx +0 -146
- package/src/core/Drawer.tsx +0 -164
- package/src/core/EntityView.tsx +0 -578
- package/src/core/Scaffold.tsx +0 -281
- package/src/core/SideEntityView.tsx +0 -38
- package/src/form/EntityForm.tsx +0 -720
- package/src/internal/useBuildCustomizationController.tsx +0 -5
- package/src/internal/useLocaleConfig.tsx +0 -18
- package/src/types/appcheck.ts +0 -29
|
@@ -1,21 +1,11 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import { useMemo } from "react";
|
|
3
2
|
|
|
4
|
-
import { Entity, EntityCollection, EntityReference
|
|
5
|
-
|
|
6
|
-
import { getReferencePreviewKeys, getValueInPath, resolveCollection } from "../../util";
|
|
7
|
-
import {
|
|
8
|
-
useCustomizationController,
|
|
9
|
-
useEntityFetch,
|
|
10
|
-
useNavigationController,
|
|
11
|
-
useSideEntityController
|
|
12
|
-
} from "../../hooks";
|
|
13
|
-
import { PropertyPreview } from "../PropertyPreview";
|
|
3
|
+
import { Entity, EntityCollection, EntityReference } from "../../types";
|
|
4
|
+
import { useCustomizationController, useEntityFetch, useNavigationController } from "../../hooks";
|
|
14
5
|
import { PreviewSize } from "../PropertyPreviewProps";
|
|
15
|
-
import {
|
|
16
|
-
import { cn, IconButton, KeyboardTabIcon, Skeleton, Tooltip, Typography } from "@firecms/ui";
|
|
6
|
+
import { Skeleton } from "@firecms/ui";
|
|
17
7
|
import { ErrorView } from "../../components";
|
|
18
|
-
import {
|
|
8
|
+
import { EntityPreview, EntityPreviewContainer } from "../../components/EntityPreview";
|
|
19
9
|
|
|
20
10
|
export type ReferencePreviewProps = {
|
|
21
11
|
disabled?: boolean;
|
|
@@ -23,8 +13,9 @@ export type ReferencePreviewProps = {
|
|
|
23
13
|
size: PreviewSize;
|
|
24
14
|
previewProperties?: string[];
|
|
25
15
|
onClick?: (e: React.SyntheticEvent) => void;
|
|
26
|
-
|
|
27
|
-
|
|
16
|
+
hover?: boolean;
|
|
17
|
+
includeEntityLink?: boolean;
|
|
18
|
+
includeId?: boolean;
|
|
28
19
|
};
|
|
29
20
|
|
|
30
21
|
/**
|
|
@@ -34,12 +25,12 @@ export const ReferencePreview = React.memo<ReferencePreviewProps>(function Refer
|
|
|
34
25
|
const reference = props.reference;
|
|
35
26
|
if (!(typeof reference === "object" && "isEntityReference" in reference && reference.isEntityReference())) {
|
|
36
27
|
console.warn("Reference preview received value of type", typeof reference);
|
|
37
|
-
return <
|
|
28
|
+
return <EntityPreviewContainer
|
|
38
29
|
onClick={props.onClick}
|
|
39
30
|
size={props.size}>
|
|
40
31
|
<ErrorView error={"Unexpected value. Click to edit"}
|
|
41
32
|
tooltip={JSON.stringify(reference)}/>
|
|
42
|
-
</
|
|
33
|
+
</EntityPreviewContainer>;
|
|
43
34
|
}
|
|
44
35
|
return <ReferencePreviewInternal {...props} />;
|
|
45
36
|
}, areEqual) as React.FunctionComponent<ReferencePreviewProps>;
|
|
@@ -47,28 +38,29 @@ export const ReferencePreview = React.memo<ReferencePreviewProps>(function Refer
|
|
|
47
38
|
function areEqual(prevProps: ReferencePreviewProps, nextProps: ReferencePreviewProps) {
|
|
48
39
|
return prevProps.disabled === nextProps.disabled &&
|
|
49
40
|
prevProps.size === nextProps.size &&
|
|
50
|
-
prevProps.
|
|
41
|
+
prevProps.hover === nextProps.hover &&
|
|
51
42
|
prevProps.reference?.id === nextProps.reference?.id &&
|
|
52
43
|
prevProps.reference?.path === nextProps.reference?.path &&
|
|
53
|
-
prevProps.
|
|
44
|
+
prevProps.includeEntityLink === nextProps.includeEntityLink
|
|
54
45
|
;
|
|
55
46
|
}
|
|
56
47
|
|
|
57
|
-
function ReferencePreviewInternal
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
48
|
+
function ReferencePreviewInternal({
|
|
49
|
+
disabled,
|
|
50
|
+
reference,
|
|
51
|
+
previewProperties,
|
|
52
|
+
size,
|
|
53
|
+
hover,
|
|
54
|
+
onClick,
|
|
55
|
+
includeEntityLink = true,
|
|
56
|
+
includeId = true
|
|
57
|
+
}: ReferencePreviewProps) {
|
|
66
58
|
|
|
67
59
|
const customizationController = useCustomizationController();
|
|
68
60
|
|
|
69
61
|
const navigationController = useNavigationController();
|
|
70
62
|
|
|
71
|
-
const collection = navigationController.getCollection
|
|
63
|
+
const collection = navigationController.getCollection(reference.path);
|
|
72
64
|
if (!collection) {
|
|
73
65
|
if (customizationController.components?.missingReference) {
|
|
74
66
|
return <customizationController.components.missingReference path={reference.path}/>;
|
|
@@ -83,20 +75,26 @@ function ReferencePreviewInternal<M extends Record<string, any>>({
|
|
|
83
75
|
previewProperties={previewProperties}
|
|
84
76
|
size={size}
|
|
85
77
|
disabled={disabled}
|
|
86
|
-
|
|
78
|
+
includeEntityLink={includeEntityLink}
|
|
79
|
+
includeId={includeId}
|
|
87
80
|
onClick={onClick}
|
|
88
|
-
|
|
81
|
+
hover={hover}/>
|
|
89
82
|
}
|
|
90
83
|
|
|
91
|
-
function ReferencePreviewExisting<M extends Record<string, any> = any>({
|
|
84
|
+
function ReferencePreviewExisting<M extends Record<string, any> = any>({
|
|
85
|
+
reference,
|
|
86
|
+
collection,
|
|
87
|
+
previewProperties,
|
|
88
|
+
size,
|
|
89
|
+
disabled,
|
|
90
|
+
includeEntityLink,
|
|
91
|
+
includeId,
|
|
92
|
+
onClick,
|
|
93
|
+
hover
|
|
94
|
+
}: ReferencePreviewProps & {
|
|
92
95
|
collection: EntityCollection<M>
|
|
93
96
|
}) {
|
|
94
97
|
|
|
95
|
-
const customizationController = useCustomizationController();
|
|
96
|
-
|
|
97
|
-
const analyticsController = useAnalyticsController();
|
|
98
|
-
const sideEntityController = useSideEntityController();
|
|
99
|
-
|
|
100
98
|
const {
|
|
101
99
|
entity,
|
|
102
100
|
dataLoading,
|
|
@@ -114,145 +112,54 @@ function ReferencePreviewExisting<M extends Record<string, any> = any>({ referen
|
|
|
114
112
|
|
|
115
113
|
const usedEntity = entity ?? referencesCache.get(reference.pathWithId);
|
|
116
114
|
|
|
117
|
-
const resolvedCollection = useMemo(() => resolveCollection({
|
|
118
|
-
collection,
|
|
119
|
-
path: reference.path,
|
|
120
|
-
values: usedEntity?.values,
|
|
121
|
-
fields: customizationController.propertyConfigs
|
|
122
|
-
}), [collection]);
|
|
123
|
-
|
|
124
|
-
const listProperties = useMemo(() => getReferencePreviewKeys(resolvedCollection, customizationController.propertyConfigs, previewProperties, size === "small" || size === "medium" ? 3 : 1),
|
|
125
|
-
[previewProperties, resolvedCollection, size]);
|
|
126
|
-
|
|
127
115
|
let body: React.ReactNode;
|
|
128
116
|
|
|
129
|
-
if (!resolvedCollection) {
|
|
130
|
-
return <ErrorView
|
|
131
|
-
error={"Could not find collection with id " + resolvedCollection}/>
|
|
132
|
-
}
|
|
133
|
-
|
|
134
117
|
if (!reference) {
|
|
135
118
|
body = <ErrorView error={"Reference not set"}/>;
|
|
136
119
|
} else if (usedEntity && !usedEntity.values) {
|
|
137
120
|
body = <ErrorView error={"Reference does not exist"}
|
|
138
121
|
tooltip={reference.path}/>;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
size !== "medium"
|
|
149
|
-
? "block whitespace-nowrap overflow-hidden truncate"
|
|
150
|
-
: ""
|
|
151
|
-
}`}>
|
|
152
|
-
<Typography variant={"caption"}
|
|
153
|
-
className={"font-mono"}>
|
|
154
|
-
{reference.id}
|
|
155
|
-
</Typography>
|
|
156
|
-
</div>
|
|
157
|
-
: <Skeleton/>)}
|
|
158
|
-
|
|
159
|
-
{listProperties && listProperties.map((key) => {
|
|
160
|
-
const childProperty = resolvedCollection.properties[key as string];
|
|
161
|
-
if (!childProperty) return null;
|
|
162
|
-
|
|
163
|
-
return (
|
|
164
|
-
<div key={"ref_prev_" + (key as string)}
|
|
165
|
-
className={listProperties.length > 1 ? "my-0.5" : "my-0"}>
|
|
166
|
-
{
|
|
167
|
-
usedEntity
|
|
168
|
-
? <PropertyPreview
|
|
169
|
-
propertyKey={key as string}
|
|
170
|
-
value={getValueInPath(usedEntity.values, key)}
|
|
171
|
-
property={childProperty as ResolvedProperty}
|
|
172
|
-
// entity={usedEntity}
|
|
173
|
-
size={"tiny"}/>
|
|
174
|
-
: <SkeletonPropertyComponent
|
|
175
|
-
property={childProperty as ResolvedProperty}
|
|
176
|
-
size={"tiny"}/>
|
|
177
|
-
}
|
|
178
|
-
</div>
|
|
179
|
-
);
|
|
180
|
-
})}
|
|
181
|
-
|
|
182
|
-
</div>
|
|
183
|
-
<div className={`my-${size === "tiny" ? 2 : 4}`}>
|
|
184
|
-
{!disabled && usedEntity && allowEntityNavigation &&
|
|
185
|
-
<Tooltip title={`See details for ${usedEntity.id}`}>
|
|
186
|
-
<IconButton
|
|
187
|
-
color={"inherit"}
|
|
188
|
-
size={"small"}
|
|
189
|
-
onClick={(e) => {
|
|
190
|
-
e.stopPropagation();
|
|
191
|
-
analyticsController.onAnalyticsEvent?.("entity_click_from_reference", {
|
|
192
|
-
path: usedEntity.path,
|
|
193
|
-
entityId: usedEntity.id
|
|
194
|
-
});
|
|
195
|
-
sideEntityController.open({
|
|
196
|
-
entityId: usedEntity.id,
|
|
197
|
-
path: usedEntity.path,
|
|
198
|
-
collection: resolvedCollection,
|
|
199
|
-
updateUrl: true
|
|
200
|
-
});
|
|
201
|
-
}}>
|
|
202
|
-
<KeyboardTabIcon size={"small"}/>
|
|
203
|
-
</IconButton>
|
|
204
|
-
</Tooltip>}
|
|
205
|
-
</div>
|
|
206
|
-
</>
|
|
122
|
+
}
|
|
123
|
+
if (body) {
|
|
124
|
+
|
|
125
|
+
return (
|
|
126
|
+
<EntityPreviewContainer onClick={disabled ? undefined : onClick}
|
|
127
|
+
hover={disabled ? undefined : hover}
|
|
128
|
+
size={size}>
|
|
129
|
+
{body}
|
|
130
|
+
</EntityPreviewContainer>
|
|
207
131
|
);
|
|
208
132
|
}
|
|
209
133
|
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
export function ReferencePreviewContainer({
|
|
220
|
-
children,
|
|
221
|
-
onHover,
|
|
222
|
-
size,
|
|
223
|
-
onClick
|
|
224
|
-
}: {
|
|
225
|
-
children: React.ReactNode;
|
|
226
|
-
onHover?: boolean;
|
|
227
|
-
size: PreviewSize;
|
|
228
|
-
onClick?: (e: React.SyntheticEvent) => void;
|
|
229
|
-
}) {
|
|
230
|
-
return <Typography variant={"label"}
|
|
231
|
-
className={cn("bg-opacity-70 bg-gray-100 dark:bg-gray-800 dark:bg-opacity-60",
|
|
232
|
-
"w-full",
|
|
233
|
-
"flex",
|
|
234
|
-
"rounded-md",
|
|
235
|
-
"overflow-hidden",
|
|
236
|
-
onHover ? "hover:bg-opacity-90 dark:hover:bg-opacity-90" : "",
|
|
237
|
-
size === "medium" ? "p-2" : "p-1",
|
|
238
|
-
size === "tiny" ? "items-center" : "",
|
|
239
|
-
"transition-colors duration-300 ease-in-out ",
|
|
240
|
-
// onHover ? "shadow-outline" : "",
|
|
241
|
-
onClick ? "cursor-pointer" : "")}
|
|
242
|
-
style={{
|
|
243
|
-
// @ts-ignore
|
|
244
|
-
tabindex: 0
|
|
245
|
-
}}
|
|
246
|
-
onClick={(event) => {
|
|
247
|
-
if (onClick) {
|
|
248
|
-
event.preventDefault();
|
|
249
|
-
onClick(event);
|
|
250
|
-
}
|
|
251
|
-
}}>
|
|
134
|
+
if (dataLoading && !usedEntity) {
|
|
135
|
+
return (
|
|
136
|
+
<EntityPreviewContainer onClick={disabled ? undefined : onClick}
|
|
137
|
+
hover={disabled ? undefined : hover}
|
|
138
|
+
size={size}>
|
|
139
|
+
<Skeleton/>
|
|
140
|
+
</EntityPreviewContainer>
|
|
141
|
+
);
|
|
142
|
+
}
|
|
252
143
|
|
|
253
|
-
|
|
144
|
+
if (!usedEntity) {
|
|
145
|
+
return (
|
|
146
|
+
<EntityPreviewContainer onClick={disabled ? undefined : onClick}
|
|
147
|
+
hover={disabled ? undefined : hover}
|
|
148
|
+
size={size}>
|
|
149
|
+
<ErrorView error={"Entity not found"}/>
|
|
150
|
+
</EntityPreviewContainer>
|
|
151
|
+
);
|
|
152
|
+
}
|
|
153
|
+
return <EntityPreview size={size}
|
|
154
|
+
previewProperties={previewProperties}
|
|
155
|
+
disabled={disabled}
|
|
156
|
+
entity={usedEntity}
|
|
157
|
+
collection={collection}
|
|
158
|
+
onClick={onClick}
|
|
159
|
+
includeEntityLink={includeEntityLink}
|
|
160
|
+
includeId={includeId}
|
|
161
|
+
hover={hover}/>;
|
|
254
162
|
|
|
255
|
-
</Typography>
|
|
256
163
|
}
|
|
257
164
|
|
|
258
165
|
const referencesCache = new Map<string, Entity<any>>();
|
|
@@ -18,7 +18,6 @@ export function ArrayOfReferencesPreview({
|
|
|
18
18
|
const property = resolveArrayProperty({
|
|
19
19
|
propertyKey,
|
|
20
20
|
property: inputProperty,
|
|
21
|
-
propertyValue: value,
|
|
22
21
|
fields: customizationController.propertyConfigs
|
|
23
22
|
});
|
|
24
23
|
|
|
@@ -43,6 +42,8 @@ export function ArrayOfReferencesPreview({
|
|
|
43
42
|
previewProperties={ofProperty.previewProperties}
|
|
44
43
|
size={childSize}
|
|
45
44
|
reference={reference}
|
|
45
|
+
includeId={ofProperty.includeId}
|
|
46
|
+
includeEntityLink={ofProperty.includeEntityLink}
|
|
46
47
|
/>
|
|
47
48
|
</div>;
|
|
48
49
|
}
|
|
@@ -4,7 +4,7 @@ import { ResolvedProperty } from "../../types";
|
|
|
4
4
|
import { useCustomizationController } from "../../hooks";
|
|
5
5
|
import { PreviewSize, PropertyPreviewProps } from "../PropertyPreviewProps";
|
|
6
6
|
import { PropertyPreview } from "../PropertyPreview";
|
|
7
|
-
import {
|
|
7
|
+
import { cls, defaultBorderMixin } from "@firecms/ui";
|
|
8
8
|
import { DEFAULT_ONE_OF_TYPE, DEFAULT_ONE_OF_VALUE } from "../../util/common";
|
|
9
9
|
import { ErrorBoundary } from "../../components";
|
|
10
10
|
|
|
@@ -23,7 +23,6 @@ export function ArrayOneOfPreview({
|
|
|
23
23
|
const property = resolveArrayProperty({
|
|
24
24
|
propertyKey,
|
|
25
25
|
property: inputProperty,
|
|
26
|
-
propertyValue: value,
|
|
27
26
|
fields: customizationController.propertyConfigs
|
|
28
27
|
});
|
|
29
28
|
|
|
@@ -50,7 +49,7 @@ export function ArrayOneOfPreview({
|
|
|
50
49
|
values.map((value, index) =>
|
|
51
50
|
<React.Fragment
|
|
52
51
|
key={"preview_array_" + value + "_" + index}>
|
|
53
|
-
<div className={
|
|
52
|
+
<div className={cls(defaultBorderMixin, "m-1 border-b last:border-b-0")}>
|
|
54
53
|
<ErrorBoundary>
|
|
55
54
|
{value && <PropertyPreview
|
|
56
55
|
propertyKey={propertyKey}
|
|
@@ -5,7 +5,7 @@ import { ResolvedProperty } from "../../types";
|
|
|
5
5
|
import { useCustomizationController } from "../../hooks";
|
|
6
6
|
import { PreviewSize, PropertyPreviewProps } from "../PropertyPreviewProps";
|
|
7
7
|
import { PropertyPreview } from "../PropertyPreview";
|
|
8
|
-
import {
|
|
8
|
+
import { cls, defaultBorderMixin } from "@firecms/ui";
|
|
9
9
|
import { ErrorBoundary } from "../../components";
|
|
10
10
|
|
|
11
11
|
/**
|
|
@@ -23,7 +23,6 @@ export function ArrayPropertyPreview({
|
|
|
23
23
|
const property = resolveArrayProperty({
|
|
24
24
|
propertyKey,
|
|
25
25
|
property: inputProperty,
|
|
26
|
-
propertyValue: value,
|
|
27
26
|
fields: customizationController.propertyConfigs
|
|
28
27
|
});
|
|
29
28
|
|
|
@@ -49,7 +48,7 @@ export function ArrayPropertyPreview({
|
|
|
49
48
|
return of
|
|
50
49
|
? <React.Fragment
|
|
51
50
|
key={"preview_array_" + index}>
|
|
52
|
-
<div className={
|
|
51
|
+
<div className={cls(defaultBorderMixin, "m-1 border-b last:border-b-0")}>
|
|
53
52
|
<ErrorBoundary>
|
|
54
53
|
<PropertyPreview
|
|
55
54
|
propertyKey={propertyKey}
|
|
@@ -3,7 +3,7 @@ import React from "react";
|
|
|
3
3
|
import { ResolvedMapProperty } from "../../types";
|
|
4
4
|
import { PropertyPreviewProps } from "../PropertyPreviewProps";
|
|
5
5
|
import { PropertyPreview } from "../PropertyPreview";
|
|
6
|
-
import {
|
|
6
|
+
import { cls, defaultBorderMixin, Typography } from "@firecms/ui";
|
|
7
7
|
import { ErrorBoundary } from "../../components";
|
|
8
8
|
import { EmptyValue } from "../components/EmptyValue";
|
|
9
9
|
|
|
@@ -61,7 +61,7 @@ export function MapPropertyPreview<T extends Record<string, any> = Record<string
|
|
|
61
61
|
return (
|
|
62
62
|
<div
|
|
63
63
|
key={`map_preview_table_${key}}`}
|
|
64
|
-
className={
|
|
64
|
+
className={cls(defaultBorderMixin, "last:border-b-0 border-b")}>
|
|
65
65
|
<div
|
|
66
66
|
className={"flex flex-row pt-0.5 pb-0.5 gap-2"}>
|
|
67
67
|
<div
|
|
@@ -87,7 +87,7 @@ export function MapPropertyPreview<T extends Record<string, any> = Record<string
|
|
|
87
87
|
</div>
|
|
88
88
|
|
|
89
89
|
{(childProperty.dataType === "map" || childProperty === "array") &&
|
|
90
|
-
<div className={
|
|
90
|
+
<div className={cls(defaultBorderMixin, "border-l pl-4 ml-2 my-2")}>
|
|
91
91
|
<PropertyPreview
|
|
92
92
|
propertyKey={key}
|
|
93
93
|
value={(value)[key]}
|
|
@@ -113,7 +113,7 @@ export function KeyValuePreview({ value }: { value: any }) {
|
|
|
113
113
|
Object.entries(value).map(([key, childValue]) => (
|
|
114
114
|
<div
|
|
115
115
|
key={`map_preview_table_${key}}`}
|
|
116
|
-
className={
|
|
116
|
+
className={cls(defaultBorderMixin, "last:border-b-0 border-b")}>
|
|
117
117
|
<div
|
|
118
118
|
className={"flex flex-row pt-0.5 pb-0.5 gap-2"}>
|
|
119
119
|
<div
|
|
@@ -135,7 +135,7 @@ export function KeyValuePreview({ value }: { value: any }) {
|
|
|
135
135
|
</div>
|
|
136
136
|
</div>
|
|
137
137
|
{typeof childValue === "object" &&
|
|
138
|
-
<div className={
|
|
138
|
+
<div className={cls(defaultBorderMixin, "border-l pl-4")}>
|
|
139
139
|
<KeyValuePreview value={childValue}/>
|
|
140
140
|
</div>
|
|
141
141
|
}
|
|
@@ -6,7 +6,7 @@ import { PreviewType } from "../../types";
|
|
|
6
6
|
import { UrlComponentPreview } from "../components/UrlComponentPreview";
|
|
7
7
|
import { PropertyPreviewProps } from "../PropertyPreviewProps";
|
|
8
8
|
import { ErrorBoundary } from "../../components";
|
|
9
|
-
import { Chip, getColorSchemeForSeed } from "@firecms/ui";
|
|
9
|
+
import { Chip, cls, getColorSchemeForSeed } from "@firecms/ui";
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* @group Preview components
|
|
@@ -24,14 +24,14 @@ export function StringPropertyPreview({
|
|
|
24
24
|
return <EnumValuesChip
|
|
25
25
|
enumKey={enumKey}
|
|
26
26
|
enumValues={resolvedProperty.enumValues}
|
|
27
|
-
size={size
|
|
27
|
+
size={size}/>;
|
|
28
28
|
} else if (property.previewAsTag) {
|
|
29
29
|
const colorScheme = getColorSchemeForSeed(propertyKey ?? "");
|
|
30
30
|
return (
|
|
31
31
|
<ErrorBoundary>
|
|
32
32
|
<Chip
|
|
33
33
|
colorScheme={colorScheme}
|
|
34
|
-
size={size
|
|
34
|
+
size={size}>
|
|
35
35
|
{value}
|
|
36
36
|
</Chip>
|
|
37
37
|
</ErrorBoundary>);
|
|
@@ -45,15 +45,16 @@ export function StringPropertyPreview({
|
|
|
45
45
|
if (!value) return <></>;
|
|
46
46
|
const lines = value.split("\n");
|
|
47
47
|
return value && value.includes("\n")
|
|
48
|
-
? <div className={"overflow-x-scroll"}>
|
|
48
|
+
? <div className={cls("overflow-x-scroll", size === "tiny" ? "text-sm" : "")}>
|
|
49
49
|
{lines.map((str, index) =>
|
|
50
50
|
<React.Fragment key={`string_preview_${index}`}>
|
|
51
51
|
<span>{str}</span>
|
|
52
52
|
{index !== lines.length - 1 && <br/>}
|
|
53
53
|
</React.Fragment>)}
|
|
54
54
|
</div>
|
|
55
|
-
:
|
|
56
|
-
|
|
57
|
-
|
|
55
|
+
: (size === "tiny"
|
|
56
|
+
? <span className={"text-sm"}>{value}</span>
|
|
57
|
+
: <>{value}</>
|
|
58
|
+
);
|
|
58
59
|
}
|
|
59
60
|
}
|
package/src/types/analytics.ts
CHANGED
package/src/types/auth.tsx
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import { User } from "./user";
|
|
2
|
+
import { Role } from "./roles";
|
|
3
|
+
import { DataSourceDelegate } from "./datasource";
|
|
4
|
+
import { StorageSource } from "./storage";
|
|
2
5
|
|
|
3
6
|
/**
|
|
4
7
|
* Controller for retrieving the logged user or performing auth related operations.
|
|
@@ -6,7 +9,7 @@ import { User } from "./user";
|
|
|
6
9
|
* to do it as the result of a hook.
|
|
7
10
|
* @group Hooks and utilities
|
|
8
11
|
*/
|
|
9
|
-
export type AuthController<UserType extends User =
|
|
12
|
+
export type AuthController<UserType extends User = any, ExtraData extends any = any> = {
|
|
10
13
|
|
|
11
14
|
/**
|
|
12
15
|
* The user currently logged in
|
|
@@ -14,6 +17,11 @@ export type AuthController<UserType extends User = User> = {
|
|
|
14
17
|
*/
|
|
15
18
|
user: UserType | null;
|
|
16
19
|
|
|
20
|
+
/**
|
|
21
|
+
* Roles related to the logged user
|
|
22
|
+
*/
|
|
23
|
+
roles?: Role[];
|
|
24
|
+
|
|
17
25
|
/**
|
|
18
26
|
* Initial loading flag. It is used not to display the login screen
|
|
19
27
|
* when the app first loads, and it has not been checked whether the user
|
|
@@ -21,6 +29,12 @@ export type AuthController<UserType extends User = User> = {
|
|
|
21
29
|
*/
|
|
22
30
|
initialLoading?: boolean;
|
|
23
31
|
|
|
32
|
+
/**
|
|
33
|
+
* Loading flag. It is used to display a loading screen when the user is
|
|
34
|
+
* logging in or out.
|
|
35
|
+
*/
|
|
36
|
+
authLoading: boolean;
|
|
37
|
+
|
|
24
38
|
/**
|
|
25
39
|
* Sign out
|
|
26
40
|
*/
|
|
@@ -46,4 +60,39 @@ export type AuthController<UserType extends User = User> = {
|
|
|
46
60
|
*/
|
|
47
61
|
loginSkipped: boolean;
|
|
48
62
|
|
|
63
|
+
extra: ExtraData;
|
|
64
|
+
|
|
65
|
+
setExtra: (extra: ExtraData) => void;
|
|
66
|
+
|
|
67
|
+
// setUser?: (user: UserType | null) => void;
|
|
68
|
+
|
|
69
|
+
// setRoles?: (roles: Role[]) => void;
|
|
49
70
|
};
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Implement this function to allow access to specific users.
|
|
74
|
+
* @group Hooks and utilities
|
|
75
|
+
*/
|
|
76
|
+
export type Authenticator<UserType extends User = User, Controller extends AuthController<UserType> = AuthController<UserType>> = (props: {
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Logged-in user or null
|
|
80
|
+
*/
|
|
81
|
+
user: UserType | null;
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* AuthController
|
|
85
|
+
*/
|
|
86
|
+
authController: Controller;
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Connector to your database, e.g. your Firestore database
|
|
90
|
+
*/
|
|
91
|
+
dataSourceDelegate: DataSourceDelegate;
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Used storage implementation
|
|
95
|
+
*/
|
|
96
|
+
storageSource: StorageSource;
|
|
97
|
+
|
|
98
|
+
}) => boolean | Promise<boolean>;
|