@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,4 +1,5 @@
1
1
  import { ArrowForwardIcon, Card, cls, Markdown, Typography, } from "@firecms/ui";
2
+ import React from "react"; // Import React
2
3
 
3
4
  export type NavigationCardProps = {
4
5
  name: string,
@@ -6,64 +7,72 @@ export type NavigationCardProps = {
6
7
  actions: React.ReactNode;
7
8
  icon: React.ReactNode;
8
9
  onClick?: () => void,
10
+ shrink?: boolean
9
11
  };
10
12
 
11
- export function NavigationCard({
13
+ // Wrap the component with React.memo
14
+ export const NavigationCard = React.memo(function NavigationCard({
12
15
  name,
13
16
  description,
14
17
  icon,
15
18
  actions,
16
19
  onClick,
20
+ shrink
17
21
  }: NavigationCardProps) {
18
22
 
19
- return (<Card
20
- className={cls("h-full p-4 cursor-pointer min-h-[230px]")}
21
- onClick={() => {
22
- onClick?.();
23
- }}>
23
+ return (
24
+ <Card
25
+ className={cls(
26
+ "h-full p-4 cursor-pointer min-h-[230px] transition-all duration-200 ease-in-out",
27
+ shrink && "w-full max-w-full min-h-0 scale-75"
28
+ )}
29
+ onClick={() => {
30
+ onClick?.();
31
+ }}
32
+ >
33
+
34
+ <div className="flex flex-col items-start h-full">
35
+ <div
36
+ className="flex-grow w-full">
24
37
 
25
- <div className="flex flex-col items-start h-full">
26
- <div
27
- className="flex-grow w-full">
38
+ <div
39
+ className="h-10 flex items-center w-full justify-between text-surface-300 dark:text-surface-600">
28
40
 
29
- <div
30
- className="h-10 flex items-center w-full justify-between text-surface-300 dark:text-surface-600">
41
+ {icon}
31
42
 
32
- {icon}
43
+ <div
44
+ className="flex items-center gap-1"
45
+ onClick={(event: React.MouseEvent) => {
46
+ event.preventDefault();
47
+ event.stopPropagation();
48
+ }}>
33
49
 
34
- <div
35
- className="flex items-center gap-1"
36
- onClick={(event: React.MouseEvent) => {
37
- event.preventDefault();
38
- event.stopPropagation();
39
- }}>
50
+ {actions}
40
51
 
41
- {actions}
52
+ </div>
42
53
 
43
54
  </div>
44
55
 
45
- </div>
46
-
47
- <Typography gutterBottom variant="h5"
48
- component="h2">
49
- {name}
50
- </Typography>
56
+ <Typography gutterBottom variant="h5"
57
+ component="h2">
58
+ {name}
59
+ </Typography>
51
60
 
52
- {description && <Typography variant="body2"
53
- color="secondary"
54
- component="div">
55
- <Markdown source={description} size={"small"}/>
56
- </Typography>}
57
- </div>
61
+ {description && <Typography variant="body2"
62
+ color="secondary"
63
+ component="div">
64
+ <Markdown source={description} size={"small"}/>
65
+ </Typography>}
66
+ </div>
58
67
 
59
- <div style={{ alignSelf: "flex-end" }}>
68
+ <div style={{ alignSelf: "flex-end" }}>
60
69
 
61
- <div className={"p-4"}>
62
- <ArrowForwardIcon className="text-primary"/>
70
+ <div className={"p-4"}>
71
+ <ArrowForwardIcon className="text-primary"/>
72
+ </div>
63
73
  </div>
64
- </div>
65
74
 
66
- </div>
75
+ </div>
67
76
 
68
- </Card>)
69
- }
77
+ </Card>)
78
+ });
@@ -1,7 +1,7 @@
1
1
  import { useNavigate } from "react-router-dom";
2
2
 
3
3
  import { useCustomizationController, useFireCMSContext } from "../../hooks";
4
- import { PluginHomePageActionsProps, TopNavigationEntry } from "../../types";
4
+ import { PluginHomePageActionsProps, NavigationEntry } from "../../types";
5
5
  import { IconForView } from "../../util";
6
6
  import { useUserConfigurationPersistence } from "../../hooks/useUserConfigurationPersistence";
7
7
  import { IconButton, StarIcon } from "@firecms/ui";
@@ -30,9 +30,11 @@ export function NavigationCardBinding({
30
30
  name,
31
31
  description,
32
32
  onClick,
33
- type
34
- }: TopNavigationEntry & {
35
- onClick?: () => void
33
+ type,
34
+ shrink // <-- add shrink prop
35
+ }: NavigationEntry & {
36
+ onClick?: () => void,
37
+ shrink?: boolean // <-- add shrink prop type
36
38
  }) {
37
39
 
38
40
  const userConfigurationPersistence = useUserConfigurationPersistence();
@@ -93,7 +95,7 @@ export function NavigationCardBinding({
93
95
  if (type === "admin") {
94
96
  return <SmallNavigationCard icon={collectionIcon}
95
97
  name={name}
96
- url={url}/>
98
+ url={url}/>;
97
99
  }
98
100
 
99
101
  return <NavigationCard
@@ -109,5 +111,7 @@ export function NavigationCardBinding({
109
111
  [path, ...(userConfigurationPersistence.recentlyVisitedPaths ?? []).filter(p => p !== path)]
110
112
  );
111
113
  }
112
- }}/>;
114
+ }}
115
+ shrink={shrink}
116
+ />;
113
117
  }
@@ -1,39 +1,73 @@
1
- import { PropsWithChildren } from "react";
2
- import { useUserConfigurationPersistence } from "../../hooks/useUserConfigurationPersistence";
3
- import { ExpandablePanel, Typography } from "@firecms/ui";
1
+ import React, { PropsWithChildren, useState } from "react";
2
+ import { cls, EditIcon, IconButton, Typography } from "@firecms/ui";
4
3
 
5
4
  export function NavigationGroup({
6
5
  children,
7
- group
6
+ group,
7
+ minimised,
8
+ isPreview,
9
+ isPotentialCardDropTarget,
10
+ onEditGroup, // New prop to handle editing
11
+ dndDisabled // New prop to disable editing when D&D is off
8
12
  }: PropsWithChildren<{
9
- group: string | undefined
13
+ group: string | undefined,
14
+ minimised?: boolean,
15
+ isPreview?: boolean,
16
+ isPotentialCardDropTarget?: boolean,
17
+ onEditGroup?: (groupName: string) => void; // Callback to open dialog
18
+ dndDisabled?: boolean; // Added dndDisabled prop
10
19
  }>) {
11
- const userConfigurationPersistence = useUserConfigurationPersistence();
12
- return (
13
- <ExpandablePanel
14
- invisible={true}
15
- titleClassName={"font-medium text-sm text-surface-600 dark:text-surface-400"}
16
- innerClassName={"py-4"}
17
- initiallyExpanded={!(userConfigurationPersistence?.collapsedGroups ?? []).includes(group ?? "ungrouped")}
18
- onExpandedChange={expanded => {
19
- if (userConfigurationPersistence) {
20
20
 
21
- if (!expanded) {
22
- const paths = (userConfigurationPersistence.collapsedGroups ?? []).concat(group ?? "ungrouped");
23
- userConfigurationPersistence.setCollapsedGroups(paths);
24
- } else {
25
- userConfigurationPersistence.setCollapsedGroups((userConfigurationPersistence.collapsedGroups ?? []).filter(g => g !== (group ?? "ungrouped")));
26
- }
27
- }
28
- }}
29
- title={<Typography color={"secondary"}
30
- className="font-medium ml-1">
31
- {group?.toUpperCase() ?? "Views".toUpperCase()}
32
- </Typography>}>
21
+ const [isHovered, setIsHovered] = useState(false);
22
+ const currentGroupName = group ?? "Views";
23
+
24
+ return (
25
+ <div className={cls(
26
+ !isPotentialCardDropTarget ? "my-10" : "my-6",
27
+ "transition-all duration-200 ease-in-out"
28
+ )}
29
+ >
30
+ <div className={`flex items-center ${isPreview ? "px-1 py-0.5 m-0" : "ml-3.5 mt-6"} `}
33
31
 
34
- <div className="mb-8">
35
- {children}
32
+ onMouseEnter={() => setIsHovered(true)}
33
+ onMouseLeave={() => setIsHovered(false)}>
34
+ <Typography
35
+ variant={isPreview ? "body2" : "caption"}
36
+ component={"h2"}
37
+ color="secondary"
38
+ // Minimal padding and no margin for preview title
39
+ className={`${isPreview ? "px-1 py-0.5" : "ml-3.5"} font-medium uppercase text-sm text-surface-600 dark:text-surface-400`}
40
+ >
41
+ {currentGroupName}
42
+ </Typography>
43
+ {!isPreview && onEditGroup && !dndDisabled && (
44
+ <IconButton
45
+ size="smallest"
46
+ onClick={(e) => {
47
+ e.stopPropagation(); // Prevent other click events
48
+ onEditGroup(currentGroupName);
49
+ }}
50
+ className={cls("ml-2 ", isHovered ? "opacity-100" : "opacity-0", "transition-opacity duration-100")}
51
+ >
52
+ <EditIcon size="smallest"/>
53
+ </IconButton>
54
+ )}
36
55
  </div>
37
- </ExpandablePanel>
56
+
57
+ {isPreview ? (
58
+ children
59
+ ) : minimised ? (
60
+ // For minimised view in the main list
61
+ <div className={cls("mt-4 p-8 bg-surface-accent-200 dark:bg-surface-accent-800 rounded-lg")}
62
+ style={{ minHeight: "50px" }}>
63
+ </div>
64
+ ) : (
65
+ // If highlighted, the parent div already has padding, so children (NavigationGroupDroppable) don't need extra margin top as much.
66
+ // The inner content of NavigationGroupDroppable will define its own padding if needed when active.
67
+ <div className={cls("mt-4", !minimised ? "pt-0" : "")}>
68
+ {children}
69
+ </div>
70
+ )}
71
+ </div>
38
72
  );
39
73
  }
@@ -0,0 +1,113 @@
1
+ import React, { useState, useEffect, useRef } from "react";
2
+ import { Button, Dialog, DialogActions, DialogContent, DialogTitle, TextField } from "@firecms/ui";
3
+
4
+ interface RenameGroupDialogProps {
5
+ open: boolean;
6
+ initialName: string;
7
+ existingGroupNames: string[]; // Names of other existing groups to check for duplicates
8
+ onClose: () => void;
9
+ onRename: (newName: string) => void;
10
+ }
11
+
12
+ export function RenameGroupDialog({ open, initialName, existingGroupNames, onClose, onRename }: RenameGroupDialogProps) {
13
+ const [name, setName] = useState(initialName);
14
+ const [error, setError] = useState<string | null>(null);
15
+ const inputRef = useRef<HTMLInputElement | HTMLTextAreaElement | null>(null); // Create a ref for the input
16
+
17
+ useEffect(() => {
18
+ if (open) {
19
+ setName(initialName);
20
+ setError(null);
21
+ // Focus and select text when dialog opens
22
+ setTimeout(() => { // setTimeout to ensure the input is rendered and focusable
23
+ if (inputRef.current) {
24
+ inputRef.current.focus();
25
+ inputRef.current.select();
26
+ }
27
+ }, 100);
28
+ }
29
+ }, [initialName, open]);
30
+
31
+ const handleNameChange = (event: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => {
32
+ const newName = event.target.value;
33
+ setName(newName);
34
+ if (!newName.trim()) {
35
+ setError("Group name cannot be empty.");
36
+ } else if (existingGroupNames.includes(newName.trim())) {
37
+ setError("This group name already exists.");
38
+ } else {
39
+ setError(null);
40
+ }
41
+ };
42
+
43
+ const handleSave = () => {
44
+ const trimmedName = name.trim();
45
+ if (!trimmedName) {
46
+ setError("Group name cannot be empty.");
47
+ return;
48
+ }
49
+ if (existingGroupNames.includes(trimmedName)) {
50
+ setError("This group name already exists.");
51
+ return;
52
+ }
53
+ if (!error) {
54
+ onRename(trimmedName);
55
+ onClose();
56
+ }
57
+ };
58
+
59
+ const handleKeyDown = (event: React.KeyboardEvent<HTMLInputElement | HTMLTextAreaElement>) => {
60
+ if (event.key === "Enter") {
61
+ event.preventDefault(); // Prevent default form submission behavior
62
+ const trimmedName = name.trim();
63
+ // We need to check the error state directly as well,
64
+ // because the error state might not have updated if the user types and immediately hits enter.
65
+ let currentError = null;
66
+ if (!trimmedName) {
67
+ currentError = "Group name cannot be empty.";
68
+ } else if (existingGroupNames.includes(trimmedName)) {
69
+ currentError = "This group name already exists.";
70
+ }
71
+
72
+ if (!currentError && trimmedName) {
73
+ handleSave();
74
+ } else if (currentError) {
75
+ setError(currentError); // Ensure error is displayed if trying to submit with Enter
76
+ }
77
+ }
78
+ };
79
+
80
+ const handleClose = () => {
81
+ setName(initialName);
82
+ setError(null);
83
+ onClose();
84
+ };
85
+
86
+ if (!open) return null;
87
+
88
+ return (
89
+ <Dialog open={open} onOpenChange={onClose}>
90
+ <DialogTitle>Rename Group</DialogTitle>
91
+ <DialogContent>
92
+ <TextField
93
+ inputRef={inputRef} // Pass the ref to the TextField
94
+ label="Group Name"
95
+ value={name}
96
+ onChange={handleNameChange}
97
+ onKeyDown={handleKeyDown} // Added onKeyDown handler
98
+ error={!!error}
99
+ aria-describedby={error ? "group-name-error" : undefined}
100
+ />
101
+ {error && <p id="group-name-error" style={{ display: "none" }}>{error}</p>}
102
+ </DialogContent>
103
+ <DialogActions>
104
+ <Button onClick={onClose} variant="text">
105
+ Cancel
106
+ </Button>
107
+ <Button onClick={handleSave} disabled={!!error || !name.trim()}>
108
+ Save
109
+ </Button>
110
+ </DialogActions>
111
+ </Dialog>
112
+ );
113
+ }
@@ -3,7 +3,7 @@ import React, { useCallback } from "react";
3
3
  import { useLargeLayout, useNavigationController } from "../hooks";
4
4
 
5
5
  import { Link, useNavigate } from "react-router-dom";
6
- import { CMSAnalyticsEvent, TopNavigationEntry, TopNavigationResult } from "../types";
6
+ import { CMSAnalyticsEvent, NavigationEntry, NavigationResult } from "../types";
7
7
  import { IconForView } from "../util";
8
8
  import { cls, IconButton, Menu, MenuItem, MoreVertIcon, Tooltip, Typography } from "@firecms/ui";
9
9
  import { useAnalyticsController } from "../hooks/useAnalyticsController";
@@ -45,7 +45,7 @@ export function DefaultDrawer({
45
45
  const {
46
46
  navigationEntries,
47
47
  groups
48
- }: TopNavigationResult = navigation.topLevelNavigation;
48
+ }: NavigationResult = navigation.topLevelNavigation;
49
49
 
50
50
  const adminViews = navigationEntries.filter(e => e.type === "admin") ?? [];
51
51
  const groupsWithoutAdmin = groups.filter(g => g !== "Admin");
@@ -63,7 +63,7 @@ export function DefaultDrawer({
63
63
  </div>;
64
64
  }, [drawerOpen]);
65
65
 
66
- const onClick = (view: TopNavigationEntry) => {
66
+ const onClick = (view: NavigationEntry) => {
67
67
  const eventName: CMSAnalyticsEvent = view.type === "collection"
68
68
  ? "drawer_navigate_to_collection"
69
69
  : (view.type === "view" ? "drawer_navigate_to_view" : "unmapped_event");
@@ -90,9 +90,9 @@ export function DefaultDrawer({
90
90
  {buildGroupHeader(group)}
91
91
  {Object.values(navigationEntries)
92
92
  .filter(e => e.group === group)
93
- .map((view, index) =>
93
+ .map((view) =>
94
94
  <DrawerNavigationItem
95
- key={`navigation_${index}`}
95
+ key={view.id}
96
96
  icon={<IconForView collectionOrView={view.collection ?? view.view}
97
97
  size={"small"}/>}
98
98
  tooltipsOpen={tooltipsOpen}
@@ -128,13 +128,13 @@ export function DefaultDrawer({
128
128
  </div>}
129
129
  </IconButton>}
130
130
  >
131
- {adminViews.map((entry, index) =>
131
+ {adminViews.map((entry) =>
132
132
  <MenuItem
133
133
  onClick={(event) => {
134
134
  event.preventDefault();
135
- navigate(entry.path);
135
+ navigate(entry.url); // Consistent use of entry.url for navigation
136
136
  }}
137
- key={`navigation_${index}`}>
137
+ key={entry.id}>
138
138
  {<IconForView collectionOrView={entry.view}/>}
139
139
  {entry.name}
140
140
  </MenuItem>)}
@@ -38,7 +38,7 @@ export function DrawerNavigationItem({
38
38
  "flex flex-row items-center mr-8",
39
39
  // "transition-all ease-in-out delay-100 duration-300",
40
40
  // drawerOpen ? "w-full" : "w-18",
41
- drawerOpen ? "pl-4 h-12" : "pl-4 h-11",
41
+ drawerOpen ? "pl-4 h-10" : "pl-4 h-9",
42
42
  "font-semibold text-xs",
43
43
  isActive ? "bg-surface-accent-200 bg-opacity-60 dark:bg-surface-800 dark:bg-opacity-50" : ""
44
44
  )}
@@ -10,6 +10,7 @@ import {
10
10
  MapFieldBinding,
11
11
  MarkdownEditorFieldBinding,
12
12
  MultiSelectFieldBinding,
13
+ ReferenceAsStringFieldBinding,
13
14
  ReferenceFieldBinding,
14
15
  RepeatFieldBinding,
15
16
  SelectFieldBinding,
@@ -211,10 +212,21 @@ export const DEFAULT_FIELD_CONFIGS: Record<string, PropertyConfig<any>> = {
211
212
  Field: StorageUploadFieldBinding
212
213
  }
213
214
  },
215
+ reference_as_string: {
216
+ key: "reference_as_string",
217
+ name: "Reference (as string)",
218
+ description: "The value refers to a different collection (it is saved as a string)",
219
+ Icon: LinkIcon,
220
+ color: "#154fb3",
221
+ property: {
222
+ dataType: "string",
223
+ Field: ReferenceAsStringFieldBinding
224
+ }
225
+ },
214
226
  reference: {
215
227
  key: "reference",
216
228
  name: "Reference",
217
- description: "The value refers to a different collection",
229
+ description: "The value refers to a different collection (it is saved as a reference)",
218
230
  Icon: LinkIcon,
219
231
  color: "#ff0042",
220
232
  property: {
@@ -348,6 +360,8 @@ export function getDefaultFieldId(property: Property | ResolvedProperty) {
348
360
  return "email";
349
361
  } else if (property.enumValues) {
350
362
  return "select";
363
+ } else if (property.reference) {
364
+ return "reference_as_string";
351
365
  } else {
352
366
  return "text_field";
353
367
  }
@@ -0,0 +1,135 @@
1
+ import React, { useCallback, useMemo } from "react";
2
+ import { Entity, EntityCollection, EntityReference, FieldProps } from "../../types";
3
+ import { useNavigationController, useReferenceDialog } from "../../hooks";
4
+ import { ReadOnlyFieldBinding } from "./ReadOnlyFieldBinding";
5
+ import { FieldHelperText, LabelWithIconAndTooltip } from "../components";
6
+ import { ErrorView } from "../../components";
7
+ import { ReferencePreview } from "../../preview";
8
+ import { getIconForProperty, IconForView } from "../../util";
9
+ import { useClearRestoreValue } from "../useClearRestoreValue";
10
+ import { EntityPreviewContainer } from "../../components/EntityPreview";
11
+ import { cls } from "@firecms/ui";
12
+
13
+ /**
14
+ * Field that opens a reference selection dialog and stores the entity ID as a string.
15
+ *
16
+ * This is one of the internal components that get mapped natively inside forms
17
+ * and tables to the specified properties.
18
+ * @group Form fields
19
+ */
20
+ export function ReferenceAsStringFieldBinding(props: FieldProps<string>) {
21
+ if (typeof props.property.reference?.path !== "string") {
22
+ return <ReadOnlyFieldBinding {...props}/>;
23
+ }
24
+
25
+ return <ReferenceAsStringFieldBindingInternal {...props}/>;
26
+ }
27
+
28
+ function ReferenceAsStringFieldBindingInternal({
29
+ propertyKey,
30
+ value,
31
+ setValue,
32
+ error,
33
+ showError,
34
+ isSubmitting,
35
+ disabled,
36
+ minimalistView,
37
+ property,
38
+ includeDescription,
39
+ size = "medium"
40
+ }: FieldProps<string>) {
41
+ if (!property.reference?.path) {
42
+ throw new Error("Property path is required for ReferenceAsStringFieldBinding");
43
+ }
44
+
45
+ useClearRestoreValue({
46
+ property,
47
+ value,
48
+ setValue
49
+ });
50
+
51
+ const navigationController = useNavigationController();
52
+ const path = property.reference.path;
53
+ const collection: EntityCollection | undefined = useMemo(() => {
54
+ return path ? navigationController.getCollection(path) : undefined;
55
+ }, [path]);
56
+
57
+ const referenceValue: EntityReference | undefined = useMemo(() => {
58
+ if (value && path) {
59
+ return new EntityReference(value, path);
60
+ }
61
+ return undefined;
62
+ }, [value, path]);
63
+
64
+ if (!collection) {
65
+ throw Error(`Couldn't find the corresponding collection for the path: ${path}`);
66
+ }
67
+
68
+ const onSingleEntitySelected = useCallback((e: Entity<any> | null) => {
69
+ setValue(e ? e.id : null);
70
+ }, [setValue]);
71
+
72
+ const referenceDialogController = useReferenceDialog({
73
+ multiselect: false,
74
+ path: path,
75
+ collection,
76
+ onSingleEntitySelected,
77
+ selectedEntityIds: value ? [value] : undefined,
78
+ forceFilter: property.reference.forceFilter
79
+ }
80
+ );
81
+
82
+ const onEntryClick = (e: React.SyntheticEvent) => {
83
+ e.preventDefault();
84
+ referenceDialogController.open();
85
+ };
86
+
87
+ return (
88
+ <>
89
+ {!minimalistView && <LabelWithIconAndTooltip
90
+ propertyKey={propertyKey}
91
+ icon={getIconForProperty(property, "small")}
92
+ required={property.validation?.required}
93
+ title={property.name}
94
+ className={"h-8 text-text-secondary dark:text-text-secondary-dark ml-3.5"}/>}
95
+
96
+ {!collection && <ErrorView
97
+ error={"The specified collection does not exist. Check console"}/>}
98
+
99
+ {collection && <>
100
+
101
+ {referenceValue && <ReferencePreview
102
+ disabled={!path}
103
+ previewProperties={property.reference?.previewProperties}
104
+ hover={!disabled}
105
+ size={size}
106
+ onClick={disabled || isSubmitting ? undefined : onEntryClick}
107
+ reference={referenceValue}
108
+ includeEntityLink={property.reference?.includeEntityLink}
109
+ includeId={property.reference?.includeId}
110
+ />}
111
+
112
+ {!value && <div className="justify-center text-left">
113
+ <EntityPreviewContainer
114
+ className={cls("px-6 h-16 text-sm font-medium flex items-center gap-6",
115
+ disabled || isSubmitting
116
+ ? "text-surface-accent-500"
117
+ : "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")}
118
+ onClick={onEntryClick}
119
+ size={"medium"}>
120
+ <IconForView collectionOrView={collection}
121
+ className={"text-surface-300 dark:text-surface-600"}/>
122
+ {`Edit ${property.name}`.toUpperCase()}
123
+ </EntityPreviewContainer>
124
+ </div>}
125
+ </>}
126
+
127
+ <FieldHelperText includeDescription={includeDescription}
128
+ showError={showError}
129
+ error={error}
130
+ disabled={disabled}
131
+ property={property}/>
132
+
133
+ </>
134
+ );
135
+ }
@@ -79,7 +79,6 @@ export function RepeatFieldBinding<T extends Array<any>>({
79
79
  minimalistView: false,
80
80
  autoFocus: internalId === lastAddedId,
81
81
  };
82
- console.debug("Building entry for", index, fieldProps);
83
82
  return <ErrorBoundary>
84
83
  <PropertyFieldBinding {...fieldProps} index={index}/>
85
84
  </ErrorBoundary>;
@@ -8,6 +8,7 @@ export { TextFieldBinding } from "./field_bindings/TextFieldBinding";
8
8
  export { SwitchFieldBinding } from "./field_bindings/SwitchFieldBinding";
9
9
  export { DateTimeFieldBinding } from "./field_bindings/DateTimeFieldBinding";
10
10
  export { ReferenceFieldBinding } from "./field_bindings/ReferenceFieldBinding";
11
+ export { ReferenceAsStringFieldBinding } from "./field_bindings/ReferenceAsStringFieldBinding";
11
12
  export { MapFieldBinding } from "./field_bindings/MapFieldBinding";
12
13
  export { KeyValueFieldBinding } from "./field_bindings/KeyValueFieldBinding";
13
14
  export { RepeatFieldBinding } from "./field_bindings/RepeatFieldBinding";