@firecms/core 3.0.0-canary.145 → 3.0.0-canary.147

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.
@@ -1,5 +1,4 @@
1
1
  import { User } from "./user";
2
- import { Role } from "./roles";
3
2
  import { DataSourceDelegate } from "./datasource";
4
3
  import { StorageSource } from "./storage";
5
4
  /**
@@ -14,10 +13,6 @@ export type AuthController<USER extends User = any, ExtraData = any> = {
14
13
  * The values can be: the user object, null if they skipped login
15
14
  */
16
15
  user: USER | null;
17
- /**
18
- * Roles related to the logged user
19
- */
20
- userRoles?: Role[];
21
16
  /**
22
17
  * Initial loading flag. It is used not to display the login screen
23
18
  * when the app first loads, and it has not been checked whether the user
@@ -52,7 +47,6 @@ export type AuthController<USER extends User = any, ExtraData = any> = {
52
47
  extra: ExtraData;
53
48
  setExtra: (extra: ExtraData) => void;
54
49
  setUser?: (user: USER | null) => void;
55
- setUserRoles?: (roles: Role[]) => void;
56
50
  };
57
51
  /**
58
52
  * Implement this function to allow access to specific users.
@@ -1,5 +1,6 @@
1
1
  import React from "react";
2
- export declare function getIcon(iconKey?: string, className?: string): React.ReactElement | undefined;
2
+ import { IconColor } from "@firecms/ui";
3
+ export declare function getIcon(iconKey?: string, className?: string, color?: IconColor): React.ReactElement | undefined;
3
4
  export type IconViewProps = {
4
5
  path: string;
5
6
  name: string;
@@ -9,6 +10,7 @@ export type IconViewProps = {
9
10
  };
10
11
  export declare const IconForView: React.NamedExoticComponent<{
11
12
  collectionOrView?: IconViewProps;
13
+ color?: IconColor;
12
14
  className?: string;
13
15
  size?: "smallest" | "small" | "medium" | "large" | number;
14
16
  }>;
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.145",
4
+ "version": "3.0.0-canary.147",
5
5
  "description": "Awesome Firebase/Firestore-based headless open-source CMS",
6
6
  "funding": {
7
7
  "url": "https://github.com/sponsors/firecmsco"
@@ -46,9 +46,9 @@
46
46
  "./package.json": "./package.json"
47
47
  },
48
48
  "dependencies": {
49
- "@firecms/editor": "^3.0.0-canary.145",
50
- "@firecms/formex": "^3.0.0-canary.145",
51
- "@firecms/ui": "^3.0.0-canary.145",
49
+ "@firecms/editor": "^3.0.0-canary.147",
50
+ "@firecms/formex": "^3.0.0-canary.147",
51
+ "@firecms/ui": "^3.0.0-canary.147",
52
52
  "@hello-pangea/dnd": "^17.0.0",
53
53
  "@radix-ui/react-portal": "^1.1.2",
54
54
  "clsx": "^2.1.1",
@@ -100,7 +100,7 @@
100
100
  "dist",
101
101
  "src"
102
102
  ],
103
- "gitHead": "e5d660f00c5806e1b63839c013af3c973f3dd47e",
103
+ "gitHead": "904db63d5e1b326111f6d4c2787b7fde84b1decf",
104
104
  "publishConfig": {
105
105
  "access": "public"
106
106
  },
@@ -8,7 +8,7 @@ import { getPreviewSizeFrom } from "../../../preview/util";
8
8
  import { getReferenceFrom, IconForView } from "../../../util";
9
9
  import { useCustomizationController, useNavigationController, useReferenceDialog } from "../../../hooks";
10
10
  import { ErrorView } from "../../ErrorView";
11
- import { cls } from "@firecms/ui";
11
+ import { cls, EditIcon } from "@firecms/ui";
12
12
  import { EntityPreviewContainer } from "../../EntityPreview";
13
13
 
14
14
  type TableReferenceFieldProps = {
@@ -151,18 +151,17 @@ export const TableReferenceFieldInternal = React.memo(
151
151
 
152
152
  {valueNotSet &&
153
153
  <EntityPreviewContainer
154
- className={cls("px-4 py-2 text-sm font-medium flex items-center uppercase",
154
+ className={cls("px-3 py-2 text-sm font-medium flex items-center",
155
155
  multiselect ? "gap-4" : "gap-6",
156
156
  disabled
157
157
  ? "text-surface-accent-500"
158
- : "cursor-pointer text-surface-accent-700 dark:text-surface-accent-300 hover:bg-surface-accent-50 dark:hover:bg-surface-800 group-hover:bg-surface-accent-50 dark:group-hover:bg-surface-800")}
158
+ : "cursor-pointer text-text-secondary dark:text-text-secondary-dark hover:bg-surface-accent-50 dark:hover:bg-surface-800 group-hover:bg-surface-accent-50 dark:group-hover:bg-surface-800")}
159
159
  onClick={handleOpen}
160
160
  size={"medium"}>
161
- <IconForView
161
+ <EditIcon
162
162
  size={"small"}
163
- collectionOrView={collection}
164
- className={"text-surface-300 dark:text-surface-600"}/>
165
- Edit {title}
163
+ className={"ml-2 mr-1 text-surface-300 dark:text-surface-600"}/>
164
+ {title}
166
165
  </EntityPreviewContainer>}
167
166
 
168
167
  </div>
@@ -77,12 +77,15 @@ export function EntityPreview({
77
77
  return <EntityPreviewContainer onClick={disabled ? undefined : onClick}
78
78
  hover={disabled ? undefined : hover}
79
79
  size={size}>
80
- <div className={cls("flex w-10 h-10 mr-2 shrink-0", size === "smallest" ? "my-0.5" : "m-2 self-start")}>
80
+ <div className={cls("flex w-10 h-10 ml-1 mr-2 shrink-0", size === "smallest" ? "my-0.5" : "m-2 self-start")}>
81
81
  {imageProperty && <PropertyPreview property={imageProperty}
82
82
  propertyKey={imagePropertyKey as string}
83
83
  size={"smallest"}
84
84
  value={getValueInPath(entity.values, imagePropertyKey as string)}/>}
85
- {!imageProperty && <IconForView collectionOrView={collection} size={size} className={"m-auto"}/>}
85
+ {!imageProperty && <IconForView collectionOrView={collection}
86
+ color={"primary"}
87
+ size={size}
88
+ className={"m-auto p-1"}/>}
86
89
  </div>
87
90
 
88
91
 
@@ -181,7 +184,6 @@ export type EntityPreviewContainerProps = {
181
184
  onClick?: (e: React.SyntheticEvent) => void;
182
185
  };
183
186
 
184
-
185
187
  export const EntityPreviewContainer = React.forwardRef<HTMLDivElement, EntityPreviewContainerProps>(({
186
188
  children,
187
189
  hover,
@@ -188,7 +188,6 @@ export function useBuildNavigationController<EC extends EntityCollection, USER e
188
188
  if (authController.initialLoading)
189
189
  return;
190
190
 
191
- console.log("refresh", authController)
192
191
  console.debug("Refreshing navigation");
193
192
 
194
193
  try {
@@ -462,9 +461,7 @@ async function resolveCollections(collections: undefined | EntityCollection[] |
462
461
  }
463
462
 
464
463
  resolvedCollections = applyPermissionsFunctionIfEmpty(resolvedCollections, collectionPermissions);
465
- console.log("resolvedCollections 2", resolvedCollections, collectionPermissions);
466
464
  resolvedCollections = filterOutNotAllowedCollections(resolvedCollections, authController);
467
- console.log("resolvedCollections 3", resolvedCollections, authController);
468
465
  return resolvedCollections;
469
466
  }
470
467
 
@@ -17,11 +17,6 @@ export type AuthController<USER extends User = any, ExtraData = any> = {
17
17
  */
18
18
  user: USER | null;
19
19
 
20
- /**
21
- * Roles related to the logged user
22
- */
23
- userRoles?: Role[];
24
-
25
20
  /**
26
21
  * Initial loading flag. It is used not to display the login screen
27
22
  * when the app first loads, and it has not been checked whether the user
@@ -66,7 +61,6 @@ export type AuthController<USER extends User = any, ExtraData = any> = {
66
61
 
67
62
  setUser?: (user: USER | null) => void;
68
63
 
69
- setUserRoles?: (roles: Role[]) => void;
70
64
  };
71
65
 
72
66
  /**
@@ -1,16 +1,16 @@
1
1
  import React from "react";
2
2
  import { hashString } from "./hash";
3
- import { coolIconKeys, Icon, iconKeys } from "@firecms/ui";
3
+ import { coolIconKeys, Icon, IconColor, iconKeys } from "@firecms/ui";
4
4
  import { slugify } from "./strings";
5
5
  import equal from "react-fast-compare"
6
6
 
7
- export function getIcon(iconKey?: string, className?: string): React.ReactElement | undefined {
7
+ export function getIcon(iconKey?: string, className?: string, color?:IconColor): React.ReactElement | undefined {
8
8
  if (!iconKey) return undefined;
9
9
  iconKey = slugify(iconKey);
10
10
  if (!(iconKey in iconKeysMap)) {
11
11
  return undefined;
12
12
  }
13
- return iconKey in iconKeysMap ? <Icon iconKey={iconKey} size={"medium"} className={className}/> : undefined;
13
+ return iconKey in iconKeysMap ? <Icon iconKey={iconKey} size={"medium"} className={className} color={color}/> : undefined;
14
14
  }
15
15
 
16
16
  export type IconViewProps = {
@@ -25,12 +25,16 @@ export const IconForView = React.memo(
25
25
  function IconForView({
26
26
  collectionOrView,
27
27
  className,
28
- size = "medium"
28
+ color,
29
+ size = "medium",
29
30
  }: {
30
- collectionOrView?: IconViewProps, className?: string, size?: "smallest" | "small" | "medium" | "large" | number,
31
+ collectionOrView?: IconViewProps,
32
+ color?: IconColor,
33
+ className?: string,
34
+ size?: "smallest" | "small" | "medium" | "large" | number,
31
35
  }): React.ReactElement {
32
36
  if (!collectionOrView) return <></>;
33
- const icon = getIcon(collectionOrView.icon, className);
37
+ const icon = getIcon(collectionOrView.icon, className, color);
34
38
  if (collectionOrView?.icon && icon)
35
39
  return icon;
36
40
 
@@ -51,9 +55,9 @@ export const IconForView = React.memo(
51
55
  if (!key)
52
56
  key = coolIconKeys[hashString(collectionOrView.path) % iconsCount];
53
57
 
54
- return <Icon iconKey={key} size={size} className={className}/>;
58
+ return <Icon iconKey={key} size={size} className={className} color={color}/>;
55
59
  }, (prevProps, nextProps) => {
56
- return equal(prevProps.collectionOrView?.icon, nextProps.collectionOrView?.icon);
60
+ return equal(prevProps.collectionOrView?.icon, nextProps.collectionOrView?.icon) && equal(prevProps.color, nextProps.color);
57
61
  });
58
62
 
59
63
  const iconKeysMap: Record<string, string> = iconKeys.reduce((acc: Record<string, string>, key) => {