@firecms/core 3.0.0-canary.0 → 3.0.0-canary.2

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.
@@ -20,3 +20,4 @@ export * from "./flatten_object";
20
20
  export * from "./make_properties_editable";
21
21
  export * from "./join_collections";
22
22
  export * from "./builders";
23
+ export * from "./useTraceUpdate";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@firecms/core",
3
3
  "type": "module",
4
- "version": "3.0.0-canary.0",
4
+ "version": "3.0.0-canary.2",
5
5
  "description": "Awesome Firebase/Firestore-based headless open-source CMS",
6
6
  "funding": {
7
7
  "url": "https://github.com/sponsors/firecmsco"
@@ -37,9 +37,17 @@
37
37
  "clean": "rm -rf dist && find ./src -name '*.js' -type f | xargs rm -f",
38
38
  "generateIcons": "ts-node --esm src/icons/generateIcons.ts"
39
39
  },
40
+ "exports": {
41
+ ".": {
42
+ "import": "./dist/index.es.js",
43
+ "require": "./dist/index.umd.js",
44
+ "types": "./dist/src/index.d.ts"
45
+ },
46
+ "./package.json": "./package.json"
47
+ },
40
48
  "dependencies": {
41
- "@firecms/formex": "^3.0.0-canary.0",
42
- "@firecms/ui": "^3.0.0-canary.0",
49
+ "@firecms/formex": "^3.0.0-canary.2",
50
+ "@firecms/ui": "^3.0.0-canary.2",
43
51
  "@fontsource/ibm-plex-mono": "^5.0.8",
44
52
  "@fontsource/roboto": "^5.0.8",
45
53
  "@hello-pangea/dnd": "^16.5.0",
@@ -107,7 +115,7 @@
107
115
  "dist",
108
116
  "src"
109
117
  ],
110
- "gitHead": "165080f8a46d85fef75ce4e4cd3e7f38b80d59d5",
118
+ "gitHead": "24234382207c741094a561eb4b94a416f00e6b74",
111
119
  "publishConfig": {
112
120
  "access": "public"
113
121
  }
@@ -1,5 +1,4 @@
1
1
  import React, { MouseEvent, useCallback } from "react";
2
- import equal from "react-fast-compare"
3
2
 
4
3
  import { CollectionSize, Entity, EntityAction, EntityCollection, SelectionController } from "../../types";
5
4
  import { Checkbox, cn, IconButton, Menu, MenuItem, MoreVertIcon, Skeleton, Tooltip, Typography } from "@firecms/ui";
@@ -1,5 +1,6 @@
1
- import { useCallback, useEffect, useMemo, useState } from "react";
1
+ import { useCallback, useEffect, useRef, useState } from "react";
2
2
  import { useLocation } from "react-router-dom";
3
+ import equal from "react-fast-compare"
3
4
 
4
5
  import {
5
6
  AuthController,
@@ -49,7 +50,7 @@ export function useBuildNavigationController<EC extends EntityCollection, UserTy
49
50
  basePath = DEFAULT_BASE_PATH,
50
51
  baseCollectionPath = DEFAULT_COLLECTION_PATH,
51
52
  authController,
52
- collections: baseCollections,
53
+ collections: collectionsProp,
53
54
  views: baseViews,
54
55
  userConfigPersistence,
55
56
  dataSourceDelegate,
@@ -58,6 +59,7 @@ export function useBuildNavigationController<EC extends EntityCollection, UserTy
58
59
 
59
60
  const location = useLocation();
60
61
 
62
+ const collectionsRef = useRef<EntityCollection[] | null>();
61
63
  const [collections, setCollections] = useState<EntityCollection[] | undefined>();
62
64
  const [views, setViews] = useState<CMSView[] | undefined>();
63
65
  const [initialised, setInitialised] = useState<boolean>(false);
@@ -80,7 +82,6 @@ export function useBuildNavigationController<EC extends EntityCollection, UserTy
80
82
  [baseCollectionPath]);
81
83
 
82
84
  const computeTopNavigation = useCallback((collections: EntityCollection[], views: CMSView[]): TopNavigationResult => {
83
- // return (collection.editable && resolvePermissions(collection, authController, paths).editCollection) ?? DEFAULT_PERMISSIONS.editCollection;
84
85
  const navigationEntries: TopNavigationEntry[] = [
85
86
  ...(collections ?? []).map(collection => (!collection.hideFromNavigation
86
87
  ? {
@@ -125,14 +126,16 @@ export function useBuildNavigationController<EC extends EntityCollection, UserTy
125
126
 
126
127
  try {
127
128
  const [resolvedCollections = [], resolvedViews = []] = await Promise.all([
128
- resolveCollections(baseCollections, authController, dataSourceDelegate, injectCollections),
129
+ resolveCollections(collectionsProp, authController, dataSourceDelegate, injectCollections),
129
130
  resolveCMSViews(baseViews, authController, dataSourceDelegate)
130
131
  ]
131
132
  );
132
-
133
- setCollections(resolvedCollections);
134
- setViews(resolvedViews);
135
- setTopLevelNavigation(computeTopNavigation(resolvedCollections ?? [], resolvedViews));
133
+ if (!equal(collectionsRef.current, resolvedCollections) || !equal(views, resolvedViews) || !equal(topLevelNavigation, computeTopNavigation(resolvedCollections, resolvedViews))) {
134
+ collectionsRef.current = resolvedCollections;
135
+ setCollections(resolvedCollections);
136
+ setViews(resolvedViews);
137
+ setTopLevelNavigation(computeTopNavigation(resolvedCollections ?? [], resolvedViews));
138
+ }
136
139
  } catch (e) {
137
140
  console.error(e);
138
141
  setNavigationLoadingError(e as any);
@@ -140,7 +143,7 @@ export function useBuildNavigationController<EC extends EntityCollection, UserTy
140
143
 
141
144
  setNavigationLoading(false);
142
145
  setInitialised(true);
143
- }, [baseCollections, authController.user, authController.initialLoading, baseViews, computeTopNavigation, injectCollections]);
146
+ }, [collectionsProp, authController.user, authController.initialLoading, baseViews, computeTopNavigation, injectCollections]);
144
147
 
145
148
  useEffect(() => {
146
149
  refreshNavigation();
package/src/util/index.ts CHANGED
@@ -20,3 +20,4 @@ export * from "./flatten_object";
20
20
  export * from "./make_properties_editable";
21
21
  export * from "./join_collections";
22
22
  export * from "./builders";
23
+ export * from "./useTraceUpdate";