@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.
Files changed (84) hide show
  1. package/dist/components/EntityCollectionTable/EntityCollectionTableProps.d.ts +4 -3
  2. package/dist/components/EntityCollectionTable/column_utils.d.ts +2 -2
  3. package/dist/components/EntityCollectionTable/fields/TableReferenceField.d.ts +5 -1
  4. package/dist/components/EntityCollectionView/EntityCollectionView.d.ts +2 -2
  5. package/dist/components/EntityCollectionView/EntityCollectionViewActions.d.ts +1 -1
  6. package/dist/components/VirtualTable/VirtualTableProps.d.ts +1 -1
  7. package/dist/contexts/AnalyticsContext.d.ts +3 -0
  8. package/dist/contexts/CustomizationControllerContext.d.ts +3 -0
  9. package/dist/core/field_configs.d.ts +1 -1
  10. package/dist/hooks/index.d.ts +1 -0
  11. package/dist/hooks/useAnalyticsController.d.ts +5 -0
  12. package/dist/hooks/useCustomizationController.d.ts +11 -0
  13. package/dist/hooks/useFireCMSContext.d.ts +0 -1
  14. package/dist/index.es.js +4878 -4856
  15. package/dist/index.es.js.map +1 -1
  16. package/dist/index.umd.js +5 -5
  17. package/dist/index.umd.js.map +1 -1
  18. package/dist/internal/useBuildCustomizationController.d.ts +2 -0
  19. package/dist/types/analytics_controller.d.ts +7 -0
  20. package/dist/types/collections.d.ts +3 -0
  21. package/dist/types/customization_controller.d.ts +47 -0
  22. package/dist/types/entity_callbacks.d.ts +17 -3
  23. package/dist/types/firecms_context.d.ts +6 -46
  24. package/dist/types/index.d.ts +2 -0
  25. package/dist/util/icons.d.ts +4 -1
  26. package/dist/util/useTraceUpdate.d.ts +1 -1
  27. package/package.json +3 -3
  28. package/src/components/DeleteEntityDialog.tsx +9 -3
  29. package/src/components/EntityCollectionTable/EntityCollectionRowActions.tsx +1 -1
  30. package/src/components/EntityCollectionTable/EntityCollectionTable.tsx +33 -8
  31. package/src/components/EntityCollectionTable/EntityCollectionTableProps.tsx +5 -5
  32. package/src/components/EntityCollectionTable/PropertyTableCell.tsx +1 -1
  33. package/src/components/EntityCollectionTable/SimpleEntityCollectionTable.tsx +0 -2
  34. package/src/components/EntityCollectionTable/column_utils.tsx +3 -3
  35. package/src/components/EntityCollectionTable/fields/TableReferenceField.tsx +125 -122
  36. package/src/components/EntityCollectionTable/filters/DateTimeFilterField.tsx +2 -2
  37. package/src/components/EntityCollectionTable/internal/default_entity_actions.tsx +3 -3
  38. package/src/components/EntityCollectionTable/internal/popup_field/PopupFormField.tsx +4 -3
  39. package/src/components/EntityCollectionView/EntityCollectionView.tsx +77 -48
  40. package/src/components/EntityCollectionView/EntityCollectionViewActions.tsx +5 -3
  41. package/src/components/EntityPreview.tsx +11 -9
  42. package/src/components/HomePage/DefaultHomePage.tsx +9 -8
  43. package/src/components/HomePage/NavigationCollectionCard.tsx +6 -5
  44. package/src/components/ReferenceSelectionInner.tsx +38 -36
  45. package/src/components/VirtualTable/VirtualTable.tsx +23 -20
  46. package/src/components/VirtualTable/VirtualTableCell.tsx +27 -9
  47. package/src/components/VirtualTable/VirtualTableHeader.tsx +1 -1
  48. package/src/components/VirtualTable/VirtualTableProps.tsx +2 -2
  49. package/src/components/VirtualTable/fields/VirtualTableDateField.tsx +2 -2
  50. package/src/contexts/AnalyticsContext.tsx +4 -0
  51. package/src/contexts/CustomizationControllerContext.tsx +4 -0
  52. package/src/core/Drawer.tsx +7 -6
  53. package/src/core/FireCMS.tsx +39 -29
  54. package/src/form/EntityForm.tsx +16 -5
  55. package/src/form/PropertyFieldBinding.tsx +8 -10
  56. package/src/form/components/CustomIdField.tsx +7 -5
  57. package/src/form/field_bindings/ArrayCustomShapedFieldBinding.tsx +1 -2
  58. package/src/form/field_bindings/DateTimeFieldBinding.tsx +2 -2
  59. package/src/form/field_bindings/KeyValueFieldBinding.tsx +4 -6
  60. package/src/hooks/data/save.ts +8 -3
  61. package/src/hooks/index.tsx +1 -0
  62. package/src/hooks/useAnalyticsController.tsx +8 -0
  63. package/src/hooks/useCustomizationController.tsx +14 -0
  64. package/src/hooks/useFireCMSContext.tsx +8 -7
  65. package/src/internal/EntityView.tsx +4 -2
  66. package/src/internal/useBuildCustomizationController.tsx +5 -0
  67. package/src/internal/useBuildSideDialogsController.tsx +0 -1
  68. package/src/preview/PropertyPreview.tsx +7 -4
  69. package/src/preview/components/DatePreview.tsx +4 -5
  70. package/src/preview/components/ReferencePreview.tsx +17 -8
  71. package/src/preview/property_previews/ArrayOfMapsPreview.tsx +3 -3
  72. package/src/preview/property_previews/ArrayOfReferencesPreview.tsx +3 -3
  73. package/src/preview/property_previews/ArrayOfStorageComponentsPreview.tsx +3 -3
  74. package/src/preview/property_previews/ArrayOfStringsPreview.tsx +4 -4
  75. package/src/preview/property_previews/ArrayOneOfPreview.tsx +3 -3
  76. package/src/preview/property_previews/ArrayPropertyPreview.tsx +3 -3
  77. package/src/types/analytics_controller.tsx +10 -0
  78. package/src/types/collections.ts +3 -0
  79. package/src/types/customization_controller.tsx +58 -0
  80. package/src/types/entity_callbacks.ts +22 -3
  81. package/src/types/firecms_context.tsx +6 -51
  82. package/src/types/index.ts +2 -0
  83. package/src/util/icons.tsx +22 -19
  84. package/src/util/useTraceUpdate.tsx +5 -5
@@ -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 function getIconForView(collectionOrView: EntityCollection | CMSView, className?:string): React.ReactElement {
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
- const icon = getIcon(collectionOrView.icon, className);
19
- if (collectionOrView?.icon && icon)
20
- return icon;
23
+ let slugName = slugify(("singularName" in collectionOrView ? collectionOrView.singularName : undefined) ?? collectionOrView.name);
21
24
 
22
- let slugName = slugify(("singularName" in collectionOrView ? collectionOrView.singularName : undefined) ?? collectionOrView.name);
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
- const iconsCount = coolIconKeys.length;
29
+ if (!key) {
30
+ slugName = slugify(collectionOrView.path);
31
+ if (slugName in iconKeysMap)
32
+ key = slugName;
33
+ }
35
34
 
36
- if (!key)
37
- key = coolIconKeys[hashString(collectionOrView.path) % iconsCount];
35
+ const iconsCount = coolIconKeys.length;
38
36
 
39
- return <Icon iconKey={key} size={"medium"} className={className}/>;
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 > 10) {
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
  }