@firecms/core 3.0.0-canary.248 → 3.0.0-canary.249

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.
Files changed (45) hide show
  1. package/dist/components/HomePage/DefaultHomePage.d.ts +2 -15
  2. package/dist/components/HomePage/HomePageDnD.d.ts +76 -0
  3. package/dist/components/HomePage/NavigationCard.d.ts +3 -1
  4. package/dist/components/HomePage/NavigationCardBinding.d.ts +3 -2
  5. package/dist/components/HomePage/NavigationGroup.d.ts +7 -1
  6. package/dist/components/HomePage/RenameGroupDialog.d.ts +9 -0
  7. package/dist/core/field_configs.d.ts +1 -1
  8. package/dist/form/field_bindings/ReferenceAsStringFieldBinding.d.ts +9 -0
  9. package/dist/form/index.d.ts +1 -0
  10. package/dist/hooks/useBuildNavigationController.d.ts +51 -2
  11. package/dist/index.es.js +1726 -778
  12. package/dist/index.es.js.map +1 -1
  13. package/dist/index.umd.js +1723 -775
  14. package/dist/index.umd.js.map +1 -1
  15. package/dist/types/analytics.d.ts +1 -1
  16. package/dist/types/collections.d.ts +3 -0
  17. package/dist/types/navigation.d.ts +20 -4
  18. package/dist/types/plugins.d.ts +12 -0
  19. package/dist/types/properties.d.ts +7 -0
  20. package/dist/types/property_config.d.ts +1 -1
  21. package/dist/util/icons.d.ts +1 -1
  22. package/package.json +5 -5
  23. package/src/components/EntityCollectionTable/PropertyTableCell.tsx +25 -3
  24. package/src/components/HomePage/DefaultHomePage.tsx +476 -157
  25. package/src/components/HomePage/FavouritesView.tsx +3 -3
  26. package/src/components/HomePage/HomePageDnD.tsx +613 -0
  27. package/src/components/HomePage/NavigationCard.tsx +47 -38
  28. package/src/components/HomePage/NavigationCardBinding.tsx +10 -6
  29. package/src/components/HomePage/NavigationGroup.tsx +63 -29
  30. package/src/components/HomePage/RenameGroupDialog.tsx +113 -0
  31. package/src/core/DefaultDrawer.tsx +8 -8
  32. package/src/core/DrawerNavigationItem.tsx +1 -1
  33. package/src/core/field_configs.tsx +15 -1
  34. package/src/form/field_bindings/ReferenceAsStringFieldBinding.tsx +135 -0
  35. package/src/form/field_bindings/RepeatFieldBinding.tsx +0 -1
  36. package/src/form/index.tsx +1 -0
  37. package/src/hooks/useBuildNavigationController.tsx +273 -84
  38. package/src/preview/PropertyPreview.tsx +14 -0
  39. package/src/types/analytics.ts +3 -0
  40. package/src/types/collections.ts +3 -0
  41. package/src/types/navigation.ts +27 -5
  42. package/src/types/plugins.tsx +15 -0
  43. package/src/types/properties.ts +8 -0
  44. package/src/types/property_config.tsx +1 -0
  45. package/src/util/icons.tsx +7 -3
@@ -1 +1 @@
1
- export type CMSAnalyticsEvent = "entity_click" | "entity_click_from_reference" | "reference_selection_clear" | "reference_selection_toggle" | "reference_selected_single" | "reference_selection_new_entity" | "edit_entity_clicked" | "entity_edited" | "new_entity_click" | "new_entity_saved" | "copy_entity_click" | "entity_copied" | "single_delete_dialog_open" | "multiple_delete_dialog_open" | "single_entity_deleted" | "multiple_entities_deleted" | "drawer_navigate_to_home" | "drawer_navigate_to_collection" | "drawer_navigate_to_view" | "home_navigate_to_collection" | "home_favorite_navigate_to_collection" | "home_navigate_to_view" | "home_navigate_to_admin_view" | "home_favorite_navigate_to_view" | "collection_inline_editing" | "unmapped_event";
1
+ export type CMSAnalyticsEvent = "entity_click" | "entity_click_from_reference" | "reference_selection_clear" | "reference_selection_toggle" | "reference_selected_single" | "reference_selection_new_entity" | "edit_entity_clicked" | "entity_edited" | "new_entity_click" | "new_entity_saved" | "copy_entity_click" | "entity_copied" | "single_delete_dialog_open" | "multiple_delete_dialog_open" | "single_entity_deleted" | "multiple_entities_deleted" | "drawer_navigate_to_home" | "drawer_navigate_to_collection" | "drawer_navigate_to_view" | "home_navigate_to_collection" | "home_favorite_navigate_to_collection" | "home_navigate_to_view" | "home_navigate_to_admin_view" | "home_favorite_navigate_to_view" | "home_move_card" | "home_move_group" | "home_drop_new_group" | "collection_inline_editing" | "unmapped_event";
@@ -66,6 +66,9 @@ export interface EntityCollection<M extends Record<string, any> = any, USER exte
66
66
  * Optional field used to group top level navigation entries under a~
67
67
  * navigation view. If you set this value in a subcollection it has no
68
68
  * effect.
69
+ * @deprecated This prop is deprecated and will be removed in the future.
70
+ * You can apply grouping by using the `navigationGroupMappings` prop in the
71
+ * {@link useBuildNavigationController} hook instead.
69
72
  */
70
73
  group?: string;
71
74
  /**
@@ -31,7 +31,7 @@ export type NavigationController<EC extends EntityCollection = EntityCollection<
31
31
  * level of the navigation (e.g. in the home page or the navigation
32
32
  * drawer)
33
33
  */
34
- topLevelNavigation?: TopNavigationResult;
34
+ topLevelNavigation?: NavigationResult;
35
35
  /**
36
36
  * Is the navigation loading (the configuration persistence has not
37
37
  * loaded yet, or a specified navigation builder has not completed)
@@ -190,7 +190,21 @@ export interface CMSView {
190
190
  */
191
191
  group?: string;
192
192
  }
193
- export interface TopNavigationEntry {
193
+ /**
194
+ * Used to group navigation entries in the main navigation.
195
+ */
196
+ export interface NavigationGroupMapping {
197
+ /**
198
+ * Name of the group, used to display the group header in the UI
199
+ */
200
+ name: string;
201
+ /**
202
+ * List of collection ids or view paths that belong to this group.
203
+ */
204
+ entries: string[];
205
+ }
206
+ export interface NavigationEntry {
207
+ id: string;
194
208
  url: string;
195
209
  name: string;
196
210
  path: string;
@@ -200,7 +214,9 @@ export interface TopNavigationEntry {
200
214
  description?: string;
201
215
  group: string;
202
216
  }
203
- export type TopNavigationResult = {
204
- navigationEntries: TopNavigationEntry[];
217
+ export type NavigationResult = {
218
+ allowDragAndDrop: boolean;
219
+ navigationEntries: NavigationEntry[];
205
220
  groups: string[];
221
+ onNavigationEntriesUpdate: (entries: NavigationGroupMapping[]) => void;
206
222
  };
@@ -6,6 +6,7 @@ import { FieldProps, FormContext } from "./fields";
6
6
  import { CMSType, Property } from "./properties";
7
7
  import { EntityStatus } from "./entities";
8
8
  import { ResolvedProperty } from "./resolved_entities";
9
+ import { NavigationGroupMapping } from "./navigation";
9
10
  /**
10
11
  * Interface used to define plugins for FireCMS.
11
12
  * NOTE: This is a work in progress and the API is not stable yet.
@@ -70,6 +71,17 @@ export type FireCMSPlugin<PROPS = any, FORM_PROPS = any, EC extends EntityCollec
70
71
  title: string;
71
72
  children: React.ReactNode;
72
73
  };
74
+ /**
75
+ * Allow reordering with drag and drop of the collections in the home page.
76
+ */
77
+ allowDragAndDrop?: boolean;
78
+ navigationEntries?: NavigationGroupMapping[];
79
+ /**
80
+ * This method will be called when the entries are updated in the home page.
81
+ * group => navigationEntriesOrder (path)
82
+ * @param entries
83
+ */
84
+ onNavigationEntriesUpdate?: (entries: NavigationGroupMapping[]) => void;
73
85
  };
74
86
  collectionView?: {
75
87
  /**
@@ -312,6 +312,13 @@ export interface StringProperty extends BaseProperty<string> {
312
312
  * Add an icon to clear the value and set it to `null`. Defaults to `false`
313
313
  */
314
314
  clearable?: boolean;
315
+ /**
316
+ * You can use this property (a string) to behave as a reference to another
317
+ * collection. The stored value is the ID of the entity in the
318
+ * collection, and the `path` prop is used to
319
+ * define the collection this reference points to.
320
+ */
321
+ reference?: ReferenceProperty;
315
322
  }
316
323
  /**
317
324
  * @group Entity properties
@@ -37,4 +37,4 @@ export type PropertyConfig<T extends CMSType = any> = {
37
37
  */
38
38
  description?: string;
39
39
  };
40
- export type PropertyConfigId = "text_field" | "multiline" | "markdown" | "url" | "email" | "select" | "multi_select" | "number_input" | "number_select" | "multi_number_select" | "file_upload" | "multi_file_upload" | "group" | "key_value" | "reference" | "multi_references" | "switch" | "date_time" | "repeat" | "custom_array" | "block";
40
+ export type PropertyConfigId = "text_field" | "multiline" | "markdown" | "url" | "email" | "select" | "multi_select" | "number_input" | "number_select" | "multi_number_select" | "file_upload" | "multi_file_upload" | "group" | "key_value" | "reference" | "reference_as_string" | "multi_references" | "switch" | "date_time" | "repeat" | "custom_array" | "block";
@@ -1,6 +1,6 @@
1
1
  import React from "react";
2
2
  import { IconColor } from "@firecms/ui";
3
- export declare function getIcon(iconKey?: string, className?: string, color?: IconColor): React.ReactElement | undefined;
3
+ export declare function getIcon(iconKey?: string, className?: string, color?: IconColor, size?: "smallest" | "small" | "medium" | "large" | number): React.ReactElement | undefined;
4
4
  export type IconViewProps = {
5
5
  path: string;
6
6
  name: string;
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.248",
4
+ "version": "3.0.0-canary.249",
5
5
  "description": "Awesome Firebase/Firestore-based headless open-source CMS",
6
6
  "funding": {
7
7
  "url": "https://github.com/sponsors/firecmsco"
@@ -53,9 +53,9 @@
53
53
  "@dnd-kit/core": "^6.3.1",
54
54
  "@dnd-kit/modifiers": "^9.0.0",
55
55
  "@dnd-kit/sortable": "^10.0.0",
56
- "@firecms/editor": "^3.0.0-canary.248",
57
- "@firecms/formex": "^3.0.0-canary.248",
58
- "@firecms/ui": "^3.0.0-canary.248",
56
+ "@firecms/editor": "^3.0.0-canary.249",
57
+ "@firecms/formex": "^3.0.0-canary.249",
58
+ "@firecms/ui": "^3.0.0-canary.249",
59
59
  "@radix-ui/react-portal": "^1.1.3",
60
60
  "clsx": "^2.1.1",
61
61
  "date-fns": "^3.6.0",
@@ -107,7 +107,7 @@
107
107
  "dist",
108
108
  "src"
109
109
  ],
110
- "gitHead": "466985640b3a605bf94f53b263cab1821ff24dd0",
110
+ "gitHead": "5a61d7000af7d369373142087ee99792178a2c6f",
111
111
  "publishConfig": {
112
112
  "access": "public"
113
113
  },
@@ -4,10 +4,12 @@ import {
4
4
  CMSType,
5
5
  Entity,
6
6
  EntityReference,
7
+ ReferenceProperty,
7
8
  ResolvedArrayProperty,
8
9
  ResolvedNumberProperty,
9
10
  ResolvedProperty,
10
- ResolvedStringProperty
11
+ ResolvedStringProperty,
12
+ StringProperty
11
13
  } from "../../types";
12
14
 
13
15
  import { VirtualTableInput } from "../VirtualTable/fields/VirtualTableInput";
@@ -251,7 +253,27 @@ export const PropertyTableCell = React.memo<PropertyTableCellProps<any>>(
251
253
 
252
254
  if (!customField && (!customPreview || selected)) {
253
255
  const isAStorageProperty = isStorageProperty(property);
254
- if (isAStorageProperty) {
256
+ if (property.dataType === "string" && (property as StringProperty).reference?.path) {
257
+ const stringProperty = property as StringProperty;
258
+ const path = stringProperty.reference?.path as string;
259
+ const referenceProperty = stringProperty.reference as ReferenceProperty;
260
+ const referenceValue = internalValue ? new EntityReference(internalValue, path) : undefined;
261
+ innerComponent =
262
+ <TableReferenceField name={propertyKey as string}
263
+ internalValue={referenceValue}
264
+ updateValue={(v) => updateValue(v ? (v as EntityReference).id : null)}
265
+ disabled={disabled}
266
+ size={size}
267
+ path={path}
268
+ multiselect={false}
269
+ previewProperties={referenceProperty.previewProperties}
270
+ includeId={referenceProperty.includeId}
271
+ includeEntityLink={referenceProperty.includeEntityLink}
272
+ title={stringProperty.name}
273
+ forceFilter={referenceProperty.forceFilter}
274
+ />;
275
+ allowScroll = false;
276
+ } else if (isAStorageProperty) {
255
277
  innerComponent = <TableStorageUpload error={validationError ?? error}
256
278
  disabled={disabled}
257
279
  focused={selected}
@@ -310,7 +332,7 @@ export const PropertyTableCell = React.memo<PropertyTableCellProps<any>>(
310
332
  updateValue={updateValue}
311
333
  />;
312
334
  fullHeight = true;
313
- } else if (stringProperty.markdown || !stringProperty.storage) {
335
+ } else if (stringProperty.markdown || !stringProperty.storage || !stringProperty.reference) {
314
336
  const multiline = Boolean(stringProperty.multiline) || Boolean(stringProperty.markdown);
315
337
  innerComponent = <VirtualTableInput error={validationError ?? error}
316
338
  disabled={disabled}