@firecms/core 3.0.0-alpha.81 → 3.0.0-alpha.83
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/dist/components/EntityCollectionTable/EntityCollectionTableProps.d.ts +4 -3
- package/dist/components/EntityCollectionTable/column_utils.d.ts +2 -2
- package/dist/components/EntityCollectionTable/fields/TableReferenceField.d.ts +5 -1
- package/dist/components/EntityCollectionView/EntityCollectionView.d.ts +2 -2
- package/dist/components/EntityCollectionView/EntityCollectionViewActions.d.ts +1 -1
- package/dist/components/VirtualTable/VirtualTableProps.d.ts +1 -1
- package/dist/contexts/AnalyticsContext.d.ts +3 -0
- package/dist/contexts/CustomizationControllerContext.d.ts +3 -0
- package/dist/core/field_configs.d.ts +1 -1
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/useAnalyticsController.d.ts +5 -0
- package/dist/hooks/useCustomizationController.d.ts +11 -0
- package/dist/hooks/useFireCMSContext.d.ts +0 -1
- package/dist/index.es.js +4878 -4856
- 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/useBuildCustomizationController.d.ts +2 -0
- package/dist/types/analytics_controller.d.ts +7 -0
- package/dist/types/collections.d.ts +3 -0
- package/dist/types/customization_controller.d.ts +47 -0
- package/dist/types/entity_callbacks.d.ts +17 -3
- package/dist/types/firecms_context.d.ts +6 -46
- package/dist/types/index.d.ts +2 -0
- package/dist/util/icons.d.ts +4 -1
- package/dist/util/useTraceUpdate.d.ts +1 -1
- package/package.json +3 -3
- package/src/components/DeleteEntityDialog.tsx +9 -3
- package/src/components/EntityCollectionTable/EntityCollectionRowActions.tsx +1 -1
- package/src/components/EntityCollectionTable/EntityCollectionTable.tsx +33 -8
- package/src/components/EntityCollectionTable/EntityCollectionTableProps.tsx +5 -5
- package/src/components/EntityCollectionTable/PropertyTableCell.tsx +1 -1
- package/src/components/EntityCollectionTable/SimpleEntityCollectionTable.tsx +0 -2
- package/src/components/EntityCollectionTable/column_utils.tsx +3 -3
- package/src/components/EntityCollectionTable/fields/TableReferenceField.tsx +125 -122
- package/src/components/EntityCollectionTable/filters/DateTimeFilterField.tsx +2 -2
- package/src/components/EntityCollectionTable/internal/default_entity_actions.tsx +3 -3
- package/src/components/EntityCollectionTable/internal/popup_field/PopupFormField.tsx +4 -3
- package/src/components/EntityCollectionView/EntityCollectionView.tsx +77 -48
- package/src/components/EntityCollectionView/EntityCollectionViewActions.tsx +5 -3
- package/src/components/EntityPreview.tsx +11 -9
- package/src/components/HomePage/DefaultHomePage.tsx +9 -8
- package/src/components/HomePage/NavigationCollectionCard.tsx +6 -5
- package/src/components/ReferenceSelectionInner.tsx +38 -36
- package/src/components/VirtualTable/VirtualTable.tsx +23 -20
- package/src/components/VirtualTable/VirtualTableCell.tsx +27 -9
- package/src/components/VirtualTable/VirtualTableHeader.tsx +1 -1
- package/src/components/VirtualTable/VirtualTableProps.tsx +2 -2
- package/src/components/VirtualTable/fields/VirtualTableDateField.tsx +2 -2
- package/src/contexts/AnalyticsContext.tsx +4 -0
- package/src/contexts/CustomizationControllerContext.tsx +4 -0
- package/src/core/Drawer.tsx +7 -6
- package/src/core/FireCMS.tsx +39 -29
- package/src/form/EntityForm.tsx +16 -5
- package/src/form/PropertyFieldBinding.tsx +8 -10
- package/src/form/components/CustomIdField.tsx +7 -5
- package/src/form/field_bindings/ArrayCustomShapedFieldBinding.tsx +1 -2
- package/src/form/field_bindings/DateTimeFieldBinding.tsx +2 -2
- package/src/form/field_bindings/KeyValueFieldBinding.tsx +4 -6
- package/src/hooks/data/save.ts +8 -3
- package/src/hooks/index.tsx +1 -0
- package/src/hooks/useAnalyticsController.tsx +8 -0
- package/src/hooks/useCustomizationController.tsx +14 -0
- package/src/hooks/useFireCMSContext.tsx +8 -7
- package/src/internal/EntityView.tsx +4 -2
- package/src/internal/useBuildCustomizationController.tsx +5 -0
- package/src/internal/useBuildSideDialogsController.tsx +0 -1
- package/src/preview/PropertyPreview.tsx +7 -4
- package/src/preview/components/DatePreview.tsx +4 -5
- package/src/preview/components/ReferencePreview.tsx +17 -8
- package/src/preview/property_previews/ArrayOfMapsPreview.tsx +3 -3
- package/src/preview/property_previews/ArrayOfReferencesPreview.tsx +3 -3
- package/src/preview/property_previews/ArrayOfStorageComponentsPreview.tsx +3 -3
- package/src/preview/property_previews/ArrayOfStringsPreview.tsx +4 -4
- package/src/preview/property_previews/ArrayOneOfPreview.tsx +3 -3
- package/src/preview/property_previews/ArrayPropertyPreview.tsx +3 -3
- package/src/types/analytics_controller.tsx +10 -0
- package/src/types/collections.ts +3 -0
- package/src/types/customization_controller.tsx +58 -0
- package/src/types/entity_callbacks.ts +22 -3
- package/src/types/firecms_context.tsx +6 -51
- package/src/types/index.ts +2 -0
- package/src/util/icons.tsx +22 -19
- package/src/util/useTraceUpdate.tsx +5 -5
package/src/util/icons.tsx
CHANGED
|
@@ -3,8 +3,9 @@ import { CMSView, EntityCollection } from "../types";
|
|
|
3
3
|
import { hashString } from "./hash";
|
|
4
4
|
import { coolIconKeys, Icon, iconKeys } from "@firecms/ui";
|
|
5
5
|
import { slugify } from "./strings";
|
|
6
|
+
import equal from "react-fast-compare"
|
|
6
7
|
|
|
7
|
-
export function getIcon(iconKey?: string, className?:string): React.ReactElement | undefined {
|
|
8
|
+
export function getIcon(iconKey?: string, className?: string): React.ReactElement | undefined {
|
|
8
9
|
if (!iconKey) return undefined;
|
|
9
10
|
iconKey = slugify(iconKey);
|
|
10
11
|
if (!(iconKey in iconKeysMap)) {
|
|
@@ -13,31 +14,33 @@ export function getIcon(iconKey?: string, className?:string): React.ReactElement
|
|
|
13
14
|
return iconKey in iconKeysMap ? <Icon iconKey={iconKey} size={"medium"} className={className}/> : undefined;
|
|
14
15
|
}
|
|
15
16
|
|
|
16
|
-
export
|
|
17
|
+
export const IconForView = React.memo(
|
|
18
|
+
function IconForView({ collectionOrView, className }: { collectionOrView: EntityCollection | CMSView, className?: string }): React.ReactElement {
|
|
19
|
+
const icon = getIcon(collectionOrView.icon, className);
|
|
20
|
+
if (collectionOrView?.icon && icon)
|
|
21
|
+
return icon;
|
|
17
22
|
|
|
18
|
-
|
|
19
|
-
if (collectionOrView?.icon && icon)
|
|
20
|
-
return icon;
|
|
23
|
+
let slugName = slugify(("singularName" in collectionOrView ? collectionOrView.singularName : undefined) ?? collectionOrView.name);
|
|
21
24
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
let key: string | undefined;
|
|
25
|
-
if (slugName in iconKeysMap)
|
|
26
|
-
key = slugName;
|
|
27
|
-
|
|
28
|
-
if (!key) {
|
|
29
|
-
slugName = slugify(collectionOrView.path);
|
|
25
|
+
let key: string | undefined;
|
|
30
26
|
if (slugName in iconKeysMap)
|
|
31
27
|
key = slugName;
|
|
32
|
-
}
|
|
33
28
|
|
|
34
|
-
|
|
29
|
+
if (!key) {
|
|
30
|
+
slugName = slugify(collectionOrView.path);
|
|
31
|
+
if (slugName in iconKeysMap)
|
|
32
|
+
key = slugName;
|
|
33
|
+
}
|
|
35
34
|
|
|
36
|
-
|
|
37
|
-
key = coolIconKeys[hashString(collectionOrView.path) % iconsCount];
|
|
35
|
+
const iconsCount = coolIconKeys.length;
|
|
38
36
|
|
|
39
|
-
|
|
40
|
-
|
|
37
|
+
if (!key)
|
|
38
|
+
key = coolIconKeys[hashString(collectionOrView.path) % iconsCount];
|
|
39
|
+
|
|
40
|
+
return <Icon iconKey={key} size={"medium"} className={className}/>;
|
|
41
|
+
}, (prevProps, nextProps) => {
|
|
42
|
+
return equal(prevProps.collectionOrView.icon, nextProps.collectionOrView.icon);
|
|
43
|
+
});
|
|
41
44
|
|
|
42
45
|
const iconKeysMap: Record<string, string> = iconKeys.reduce((acc: Record<string, string>, key) => {
|
|
43
46
|
acc[key] = key;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { useEffect, useRef } from "react";
|
|
2
2
|
|
|
3
|
-
function printChanged(props: any, prev: any, path = "", depth = 0) {
|
|
4
|
-
if (depth >
|
|
3
|
+
function printChanged(props: any, prev: any, path = "", depth = 0, maxDepth: number) {
|
|
4
|
+
if (depth > maxDepth) {
|
|
5
5
|
return;
|
|
6
6
|
}
|
|
7
7
|
if (props && prev && typeof props === "object" && typeof prev === "object") {
|
|
8
8
|
Object.keys(props).forEach((key) => {
|
|
9
|
-
printChanged(props[key], prev[key], path + "." + key, depth + 1);
|
|
9
|
+
printChanged(props[key], prev[key], path + "." + key, depth + 1, maxDepth);
|
|
10
10
|
});
|
|
11
11
|
} else if (props !== prev) {
|
|
12
12
|
console.log("Changed props:", path);
|
|
@@ -14,10 +14,10 @@ function printChanged(props: any, prev: any, path = "", depth = 0) {
|
|
|
14
14
|
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
export function useTraceUpdate(props: any) {
|
|
17
|
+
export function useTraceUpdate(props: any, maxDepth = 3) {
|
|
18
18
|
const prev = useRef(props);
|
|
19
19
|
useEffect(() => {
|
|
20
|
-
printChanged(props, prev.current, "");
|
|
20
|
+
printChanged(props, prev.current, "", 0, maxDepth);
|
|
21
21
|
prev.current = props;
|
|
22
22
|
});
|
|
23
23
|
}
|