@firecms/core 3.0.0-canary.103 → 3.0.0-canary.105

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.
@@ -58,7 +58,8 @@ export interface EntityCollection<M extends Record<string, any> = any, UserType
58
58
  * Icon key to use in this collection.
59
59
  * You can use any of the icons in the Material specs:
60
60
  * https://fonts.google.com/icons
61
- * e.g. 'account_tree' or 'person'
61
+ * e.g. 'account_tree' or 'person'.
62
+ * Find all the icons in https://firecms.co/docs/icons
62
63
  */
63
64
  icon?: string;
64
65
  /**
@@ -270,6 +271,10 @@ export interface EntityCollection<M extends Record<string, any> = any, UserType
270
271
  * Width of the side dialog (in pixels) when opening an entity in this collection.
271
272
  */
272
273
  sideDialogWidth?: number | string;
274
+ /**
275
+ * Default preview properties displayed when this collection is referenced to.
276
+ */
277
+ previewProperties?: string[];
273
278
  }
274
279
  /**
275
280
  * Parameter passed to the `Actions` prop in the collection configuration.
@@ -144,6 +144,7 @@ export interface CMSView {
144
144
  * You can use any of the icons in the Material specs:
145
145
  * https://fonts.google.com/icons
146
146
  * e.g. 'account_tree' or 'person'
147
+ * Find all the icons in https://firecms.co/docs/icons
147
148
  */
148
149
  icon?: string;
149
150
  /**
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.103",
4
+ "version": "3.0.0-canary.105",
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.103",
50
- "@firecms/formex": "^3.0.0-canary.103",
51
- "@firecms/ui": "^3.0.0-canary.103",
49
+ "@firecms/editor": "^3.0.0-canary.105",
50
+ "@firecms/formex": "^3.0.0-canary.105",
51
+ "@firecms/ui": "^3.0.0-canary.105",
52
52
  "@hello-pangea/dnd": "^16.6.0",
53
53
  "@radix-ui/react-portal": "^1.1.1",
54
54
  "clsx": "^2.1.1",
@@ -100,7 +100,7 @@
100
100
  "dist",
101
101
  "src"
102
102
  ],
103
- "gitHead": "c33fe736fee99aaf30789aed66e4385563011783",
103
+ "gitHead": "e5b79b1a4af2fd750b9e8c8f73052322aa3e86ab",
104
104
  "publishConfig": {
105
105
  "access": "public"
106
106
  },
@@ -1,14 +1,14 @@
1
- import React, { useCallback, useState } from "react";
1
+ import React, { useCallback } from "react";
2
2
  import equal from "react-fast-compare"
3
3
 
4
- import { ReferencePreview } from "../../../preview";
4
+ import { EmptyValue, ReferencePreview } from "../../../preview";
5
5
  import { CollectionSize, Entity, EntityCollection, EntityReference, FilterValues } from "../../../types";
6
6
 
7
7
  import { getPreviewSizeFrom } from "../../../preview/util";
8
8
  import { getReferenceFrom } from "../../../util";
9
9
  import { useCustomizationController, useNavigationController, useReferenceDialog } from "../../../hooks";
10
10
  import { ErrorView } from "../../ErrorView";
11
- import { Button } from "@firecms/ui";
11
+ import { cls } from "@firecms/ui";
12
12
  import { EntityPreviewContainer } from "../../EntityPreview";
13
13
 
14
14
  type TableReferenceFieldProps = {
@@ -151,13 +151,14 @@ export const TableReferenceFieldSuccess = React.memo(
151
151
  {internalValue && multiselect && buildMultipleReferenceField()}
152
152
 
153
153
  {valueNotSet &&
154
- <Button
155
- onClick={handleOpen}
156
- size={"small"}
157
- variant="outlined"
158
- color="primary">
154
+ <EntityPreviewContainer className={cls("p-4 text-sm font-medium flex items-center gap-4 uppercase",
155
+ disabled
156
+ ? "text-slate-500"
157
+ : "cursor-pointer text-slate-700 dark:text-slate-300 hover:bg-slate-50 dark:hover:bg-gray-800 group-hover:bg-slate-50 dark:group-hover:bg-gray-800")}
158
+ onClick={handleOpen}
159
+ size={"medium"}>
159
160
  Edit {title}
160
- </Button>}
161
+ </EntityPreviewContainer>}
161
162
 
162
163
  </div>
163
164
  );
@@ -16,7 +16,7 @@ import {
16
16
  } from "../../hooks";
17
17
  import { ErrorView } from "../ErrorView";
18
18
  import { AddIcon, Button, DialogActions, Typography } from "@firecms/ui";
19
- import { canCreateEntity, fullPathToCollectionSegments, resolveCollection } from "../../util";
19
+ import { canCreateEntity, resolveCollection } from "../../util";
20
20
  import { useSelectionController } from "../EntityCollectionView/useSelectionController";
21
21
  import { useColumnIds, useTableSearchHelper } from "../common";
22
22
  import { useSideDialogContext } from "../../core";
@@ -247,7 +247,6 @@ export function ReferenceSelectionTable<M extends Record<string, any>>(
247
247
  error={"Could not find collection with id " + collection}/>
248
248
  }
249
249
 
250
- // eslint-disable-next-line react-hooks/rules-of-hooks
251
250
  const resolvedCollection = useMemo(() => resolveCollection({
252
251
  collection: collection,
253
252
  path: fullPath,
@@ -255,10 +254,8 @@ export function ReferenceSelectionTable<M extends Record<string, any>>(
255
254
  fields: customizationController.propertyConfigs
256
255
  }), [collection, customizationController.propertyConfigs, fullPath]);
257
256
 
258
- // eslint-disable-next-line react-hooks/rules-of-hooks
259
257
  const displayedColumnIds = useColumnIds(resolvedCollection, false);
260
258
 
261
- // eslint-disable-next-line react-hooks/rules-of-hooks
262
259
  const tableController = useDataSourceEntityCollectionTableController<M>({
263
260
  fullPath,
264
261
  collection,
@@ -272,7 +269,6 @@ export function ReferenceSelectionTable<M extends Record<string, any>>(
272
269
  onTextSearchClick,
273
270
  textSearchEnabled
274
271
  } =
275
- // eslint-disable-next-line react-hooks/rules-of-hooks
276
272
  useTableSearchHelper({
277
273
  collection,
278
274
  fullPath,
@@ -5,10 +5,11 @@ import { useNavigationController, useReferenceDialog } from "../../hooks";
5
5
  import { ReadOnlyFieldBinding } from "./ReadOnlyFieldBinding";
6
6
  import { FieldHelperText, LabelWithIcon } from "../components";
7
7
  import { ErrorView } from "../../components";
8
- import { ReferencePreview } from "../../preview";
8
+ import { EmptyValue, ReferencePreview } from "../../preview";
9
9
  import { getIconForProperty, getReferenceFrom } from "../../util";
10
- import { Button } from "@firecms/ui";
11
10
  import { useClearRestoreValue } from "../useClearRestoreValue";
11
+ import { EntityPreviewContainer } from "../../components/EntityPreview";
12
+ import { cls } from "@firecms/ui";
12
13
 
13
14
  /**
14
15
  * Field that opens a reference selection dialog.
@@ -34,6 +35,7 @@ function ReferenceFieldBindingInternal({
34
35
  showError,
35
36
  isSubmitting,
36
37
  disabled,
38
+ minimalistView,
37
39
  touched,
38
40
  autoFocus,
39
41
  property,
@@ -82,10 +84,10 @@ function ReferenceFieldBindingInternal({
82
84
 
83
85
  return (
84
86
  <>
85
- <LabelWithIcon icon={getIconForProperty(property, "small")}
86
- required={property.validation?.required}
87
- title={property.name}
88
- className={"text-text-secondary dark:text-text-secondary-dark ml-3.5"}/>
87
+ {!minimalistView && <LabelWithIcon icon={getIconForProperty(property, "small")}
88
+ required={property.validation?.required}
89
+ title={property.name}
90
+ className={"text-text-secondary dark:text-text-secondary-dark ml-3.5"}/>}
89
91
 
90
92
  {!collection && <ErrorView
91
93
  error={"The specified collection does not exist. Check console"}/>}
@@ -104,12 +106,15 @@ function ReferenceFieldBindingInternal({
104
106
  />}
105
107
 
106
108
  {!value && <div className="justify-center text-left">
107
- <Button variant="outlined"
108
- color="primary"
109
- disabled={disabled || isSubmitting}
110
- onClick={onEntryClick}>
111
- Edit {property.name}
112
- </Button>
109
+ <EntityPreviewContainer className={cls("p-6 text-sm font-medium flex items-center gap-6",
110
+ disabled || isSubmitting
111
+ ? "text-slate-500"
112
+ : "cursor-pointer text-slate-700 dark:text-slate-300 hover:bg-slate-50 dark:hover:bg-gray-800 group-hover:bg-slate-50 dark:group-hover:bg-gray-800")}
113
+ onClick={onEntryClick}
114
+ size={"medium"}>
115
+ <EmptyValue/>
116
+ {`Edit ${property.name}`.toUpperCase()}
117
+ </EntityPreviewContainer>
113
118
  </div>}
114
119
  </>}
115
120
 
@@ -67,7 +67,8 @@ export interface EntityCollection<M extends Record<string, any> = any, UserType
67
67
  * Icon key to use in this collection.
68
68
  * You can use any of the icons in the Material specs:
69
69
  * https://fonts.google.com/icons
70
- * e.g. 'account_tree' or 'person'
70
+ * e.g. 'account_tree' or 'person'.
71
+ * Find all the icons in https://firecms.co/docs/icons
71
72
  */
72
73
  icon?: string;
73
74
 
@@ -310,6 +311,11 @@ export interface EntityCollection<M extends Record<string, any> = any, UserType
310
311
  * Width of the side dialog (in pixels) when opening an entity in this collection.
311
312
  */
312
313
  sideDialogWidth?: number | string;
314
+
315
+ /**
316
+ * Default preview properties displayed when this collection is referenced to.
317
+ */
318
+ previewProperties?: string[];
313
319
  }
314
320
 
315
321
  /**
@@ -173,6 +173,7 @@ export interface CMSView {
173
173
  * You can use any of the icons in the Material specs:
174
174
  * https://fonts.google.com/icons
175
175
  * e.g. 'account_tree' or 'person'
176
+ * Find all the icons in https://firecms.co/docs/icons
176
177
  */
177
178
  icon?: string;
178
179
 
@@ -9,6 +9,9 @@ export function getEntityPreviewKeys(targetCollection: EntityCollection<any>,
9
9
  limit = 3) {
10
10
  const allProperties = Object.keys(targetCollection.properties);
11
11
  let listProperties = previewProperties?.filter(p => allProperties.includes(p as string));
12
+ if (!listProperties && targetCollection.previewProperties) {
13
+ listProperties = targetCollection.previewProperties?.filter(p => allProperties.includes(p as string));
14
+ }
12
15
  if (listProperties && listProperties.length > 0) {
13
16
  return listProperties;
14
17
  } else {