@firecms/core 3.0.0-canary.161 → 3.0.0-canary.163

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@firecms/core",
3
3
  "type": "module",
4
- "version": "3.0.0-canary.161",
4
+ "version": "3.0.0-canary.163",
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.161",
54
- "@firecms/formex": "^3.0.0-canary.161",
55
- "@firecms/ui": "^3.0.0-canary.161",
53
+ "@firecms/editor": "^3.0.0-canary.163",
54
+ "@firecms/formex": "^3.0.0-canary.163",
55
+ "@firecms/ui": "^3.0.0-canary.163",
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": "5f61d5a13f1d21736aa24a767102412dbdc1173a",
109
+ "gitHead": "3bd40474a708b98361bce4170062c0021693394d",
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 {
@@ -71,11 +71,15 @@ export function EntityPreview({
71
71
  const titleProperty = getEntityTitlePropertyKey(resolvedCollection, customizationController.propertyConfigs);
72
72
  const imagePropertyKey = getEntityImagePreviewPropertyKey(resolvedCollection);
73
73
  const imageProperty = imagePropertyKey ? resolvedCollection.properties[imagePropertyKey] : undefined;
74
- const usedImageProperty = "of" in imageProperty ? imageProperty.of : imageProperty;
74
+ const usedImageProperty = imageProperty && "of" in imageProperty ? imageProperty.of : imageProperty;
75
75
  const restProperties = listProperties.filter(p => p !== titleProperty && p !== imagePropertyKey);
76
76
 
77
- const imageValue = getValueInPath(entity.values, imagePropertyKey as string);
78
- const usedImageValue = "of" in imageProperty ? ((imageValue ?? []).length > 0 ? imageValue[0] : undefined) : imageValue;
77
+ const imageValue = imagePropertyKey ? getValueInPath(entity.values, imagePropertyKey) : undefined;
78
+ const usedImageValue = imageProperty !== undefined ? ("of" in imageProperty
79
+ ? ((imageValue ?? []).length > 0
80
+ ? imageValue[0] : undefined)
81
+ : imageValue)
82
+ : undefined;
79
83
 
80
84
  return <EntityPreviewContainer onClick={disabled ? undefined : onClick}
81
85
  hover={disabled ? undefined : hover}
@@ -108,7 +112,7 @@ export function EntityPreview({
108
112
  : <Skeleton/>)}
109
113
 
110
114
  {titleProperty && (
111
- <div className={"my-0.5 text-sm font-medium"}>
115
+ <div className={"truncate my-0.5 text-sm font-medium"}>
112
116
  {
113
117
  entity
114
118
  ? <PropertyPreview
@@ -129,7 +133,7 @@ export function EntityPreview({
129
133
 
130
134
  return (
131
135
  <div key={"ref_prev_" + key}
132
- className={restProperties.length > 1 ? "my-0.5" : "my-0"}>
136
+ className={cls("truncate", restProperties.length > 1 ? "my-0.5" : "my-0")}>
133
137
  {
134
138
  entity
135
139
  ? <PropertyPreview
@@ -785,7 +785,7 @@ export function EntityEditViewInner<M extends Record<string, any>>({
785
785
  })?.toString()}
786
786
  </>;
787
787
  return (
788
- <div>
788
+ <div key={`additional_${key}`}>
789
789
  <LabelWithIconAndTooltip
790
790
  propertyKey={key}
791
791
  icon={<NotesIcon size={"small"}/>}
@@ -808,8 +808,7 @@ export function EntityEditViewInner<M extends Record<string, any>>({
808
808
  })
809
809
  .filter(Boolean)}
810
810
 
811
- </>
812
- );
811
+ </>);
813
812
 
814
813
  const disabled = formex.isSubmitting || (!modified && status === "existing");
815
814
  const formRef = React.useRef<HTMLDivElement>(null);
@@ -127,7 +127,7 @@ export function KeyValuePreview({ value }: { value: any }) {
127
127
  </div>
128
128
  <div
129
129
  className="flex-grow max-w-[75%]">
130
- {childValue && ("toString" in childValue) && <Typography>
130
+ {childValue && <Typography>
131
131
  <ErrorBoundary>
132
132
  {childValue.toString()}
133
133
  </ErrorBoundary>