@firecms/core 3.0.0-canary.162 → 3.0.0-canary.164

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.
@@ -3,7 +3,7 @@ export declare function isReadOnly(property: Property<any> | ResolvedProperty<an
3
3
  export declare function isHidden(property: Property | ResolvedProperty): boolean;
4
4
  export declare function isPropertyBuilder<T extends CMSType, M extends Record<string, any>>(propertyOrBuilder?: PropertyOrBuilder<T, M> | Property<T> | ResolvedProperty<T>): propertyOrBuilder is PropertyBuilder<T, M>;
5
5
  export declare function getDefaultValuesFor<M extends Record<string, any>>(properties: PropertiesOrBuilders<M> | ResolvedProperties<M>): Partial<EntityValues<M>>;
6
- export declare function getDefaultValueFor(property: PropertyOrBuilder): {} | null | undefined;
6
+ export declare function getDefaultValueFor(property?: PropertyOrBuilder): {} | null | undefined;
7
7
  export declare function getDefaultValueForDataType(dataType: DataType): {} | null;
8
8
  /**
9
9
  * Update the automatic values in an entity before save
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.162",
4
+ "version": "3.0.0-canary.164",
5
5
  "description": "Awesome Firebase/Firestore-based headless open-source CMS",
6
6
  "funding": {
7
7
  "url": "https://github.com/sponsors/firecmsco"
@@ -50,9 +50,9 @@
50
50
  "./package.json": "./package.json"
51
51
  },
52
52
  "dependencies": {
53
- "@firecms/editor": "^3.0.0-canary.162",
54
- "@firecms/formex": "^3.0.0-canary.162",
55
- "@firecms/ui": "^3.0.0-canary.162",
53
+ "@firecms/editor": "^3.0.0-canary.164",
54
+ "@firecms/formex": "^3.0.0-canary.164",
55
+ "@firecms/ui": "^3.0.0-canary.164",
56
56
  "@hello-pangea/dnd": "^17.0.0",
57
57
  "@radix-ui/react-portal": "^1.1.2",
58
58
  "clsx": "^2.1.1",
@@ -106,7 +106,7 @@
106
106
  "dist",
107
107
  "src"
108
108
  ],
109
- "gitHead": "a1b322b8cdcd05a1598baefce37c89124d96cd79",
109
+ "gitHead": "9f7019e32346d4917da2e32539ac13244636493f",
110
110
  "publishConfig": {
111
111
  "access": "public"
112
112
  },
@@ -88,8 +88,6 @@ export const EntityCollectionTable = function EntityCollectionTable<M extends Re
88
88
 
89
89
  const [size, setSize] = React.useState<CollectionSize>(defaultSize ?? "m");
90
90
 
91
- const selectedEntityIds = selectedEntities?.map(e => e.id);
92
-
93
91
  const updateSize = useCallback((size: CollectionSize) => {
94
92
  if (onSizeChanged)
95
93
  onSizeChanged(size);
@@ -204,7 +202,7 @@ export const EntityCollectionTable = function EntityCollectionTable<M extends Re
204
202
  </EntityTableCell>
205
203
  );
206
204
 
207
- }, [size, selectedEntityIds]);
205
+ }, [size]);
208
206
 
209
207
  const collectionColumns: VirtualTableColumn[] = (() => {
210
208
  const columnsResult: VirtualTableColumn[] = propertiesToColumns({
@@ -312,7 +310,7 @@ export const EntityCollectionTable = function EntityCollectionTable<M extends Re
312
310
  inlineEditing={inlineEditing}
313
311
  cellRenderer={cellRenderer}
314
312
  onEntityClick={onEntityClick}
315
- highlightedRow={useCallback((entity: Entity<M>) => selectedEntityIds?.includes(entity.id) ?? false, [selectedEntityIds])}
313
+ highlightedRow={(entity: Entity<M>) => Boolean(selectedEntities?.find(e => e.id === entity.id && e.path === entity.path))}
316
314
  tableController={tableController}
317
315
  onValueChange={onValueChange}
318
316
  onColumnResize={onColumnResize}
@@ -482,7 +482,7 @@ export const EntityCollectionView = React.memo(
482
482
  frozen?: boolean
483
483
  }) => {
484
484
 
485
- const isSelected = usedSelectionController.selectedEntities.map(e => e.id).includes(entity.id);
485
+ const isSelected = Boolean(usedSelectionController.selectedEntities.find(e => e.id == entity.id && e.path == entity.path));
486
486
 
487
487
  const actions = getActionsForEntity({
488
488
  entity,
@@ -10,9 +10,10 @@ export function useSelectionController<M extends Record<string, any> = any>(
10
10
  const toggleEntitySelection = useCallback((entity: Entity<M>, newSelectedState?: boolean) => {
11
11
  let newValue;
12
12
  if (newSelectedState === undefined) {
13
- if (selectedEntities.map(e => e.id).includes(entity.id)) {
13
+ const isSelected = Boolean(selectedEntities.find(e => e.id === entity.id && e.path === entity.path));
14
+ if (isSelected) {
14
15
  onSelectionChange?.(entity, false);
15
- newValue = selectedEntities.filter((item: Entity<M>) => item.id !== entity.id);
16
+ newValue = selectedEntities.filter((item: Entity<M>) => !(item.id === entity.id && item.path === entity.path));
16
17
  } else {
17
18
  onSelectionChange?.(entity, true);
18
19
  newValue = [...selectedEntities, entity];
@@ -23,14 +24,14 @@ export function useSelectionController<M extends Record<string, any> = any>(
23
24
  newValue = [...selectedEntities, entity];
24
25
  } else {
25
26
  onSelectionChange?.(entity, false);
26
- newValue = selectedEntities.filter((item: Entity<M>) => item.id !== entity.id);
27
+ newValue = selectedEntities.filter((item: Entity<M>) => !(item.id === entity.id && item.path === entity.path));
27
28
  }
28
29
  }
29
30
  setSelectedEntities(newValue);
30
31
  }, [selectedEntities]);
31
32
 
32
33
  const isEntitySelected = useCallback((entity: Entity<M>) => {
33
- return selectedEntities.map(e => e.id).includes(entity.id);
34
+ return Boolean(selectedEntities.find(e => e.id === entity.id && e.path === entity.path));
34
35
  }, [selectedEntities]);
35
36
 
36
37
  return {
@@ -110,7 +110,7 @@ export const DefaultAppBar = function DefaultAppBar({
110
110
 
111
111
  {navigation && <div className="mr-8 hidden lg:block">
112
112
  <ReactLink
113
- className="visited:text-inherit visited:dark:text-inherit"
113
+ className="visited:text-inherit visited:dark:text-inherit block"
114
114
  to={navigation?.basePath ?? "/"}
115
115
  >
116
116
  <div className={"flex flex-row gap-4"}>
@@ -122,8 +122,7 @@ export const DefaultAppBar = function DefaultAppBar({
122
122
 
123
123
  {typeof title === "string"
124
124
  ? <Typography variant="subtitle1"
125
- noWrap
126
- className={cls("transition-all", drawerOpen ? "ml-2" : "")}>
125
+ noWrap>
127
126
  {title}
128
127
  </Typography>
129
128
  : title}
@@ -164,12 +164,13 @@ export function DrawerLogo({ logo }: {
164
164
  transition: "padding 100ms cubic-bezier(0.4, 0, 0.6, 1) 0ms",
165
165
  padding: drawerOpen ? "32px 144px 0px 24px" : "72px 12px 0px 12px"
166
166
  }}
167
- className={cls("cursor-pointer ml-3 mr-1")}>
167
+ className={cls("cursor-pointer rounded ml-3 mr-1")}>
168
168
 
169
169
  <Tooltip title={"Home"}
170
170
  sideOffset={20}
171
171
  side="right">
172
172
  <Link
173
+ className={"block"}
173
174
  to={navigation.basePath}>
174
175
  {logo
175
176
  ? <img src={logo}
@@ -40,13 +40,15 @@ export function getDefaultValuesFor<M extends Record<string, any>>(properties: P
40
40
  if (!properties) return {};
41
41
  return Object.entries(properties)
42
42
  .map(([key, property]) => {
43
+ if (!property) return {};
43
44
  const value = getDefaultValueFor(property as PropertyOrBuilder);
44
45
  return value === undefined ? {} : { [key]: value };
45
46
  })
46
47
  .reduce((a, b) => ({ ...a, ...b }), {}) as EntityValues<M>;
47
48
  }
48
49
 
49
- export function getDefaultValueFor(property: PropertyOrBuilder) {
50
+ export function getDefaultValueFor(property?: PropertyOrBuilder) {
51
+ if (!property) return undefined;
50
52
  if (isPropertyBuilder(property)) return undefined;
51
53
  if (property.defaultValue || property.defaultValue === null) {
52
54
  return property.defaultValue;