@firecms/core 3.0.0-canary.3 → 3.0.0-canary.5

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 (51) hide show
  1. package/dist/components/ReferenceWidget.d.ts +3 -3
  2. package/dist/components/index.d.ts +0 -1
  3. package/dist/core/SideEntityView.d.ts +7 -0
  4. package/dist/core/index.d.ts +0 -2
  5. package/dist/form/components/index.d.ts +1 -0
  6. package/dist/form/index.d.ts +1 -0
  7. package/dist/hooks/index.d.ts +2 -1
  8. package/dist/{core → hooks}/useBuildModeController.d.ts +1 -1
  9. package/dist/index.es.js +1101 -1098
  10. package/dist/index.es.js.map +1 -1
  11. package/dist/index.umd.js +5 -5
  12. package/dist/index.umd.js.map +1 -1
  13. package/dist/types/entities.d.ts +1 -0
  14. package/package.json +4 -4
  15. package/src/components/EntityCollectionTable/PropertyTableCell.tsx +2 -1
  16. package/src/components/EntityCollectionTable/fields/TableReferenceField.tsx +1 -1
  17. package/src/components/ReferenceWidget.tsx +4 -4
  18. package/src/components/SelectableTable/filters/ReferenceFilterField.tsx +2 -2
  19. package/src/components/index.tsx +0 -1
  20. package/src/core/EntitySidePanel.tsx +1 -1
  21. package/src/{internal → core}/EntityView.tsx +2 -2
  22. package/src/core/SideEntityView.tsx +38 -0
  23. package/src/core/index.tsx +0 -2
  24. package/src/form/components/index.tsx +1 -0
  25. package/src/form/field_bindings/ArrayCustomShapedFieldBinding.tsx +2 -3
  26. package/src/form/field_bindings/ArrayOfReferencesFieldBinding.tsx +4 -3
  27. package/src/form/field_bindings/BlockFieldBinding.tsx +2 -3
  28. package/src/form/field_bindings/DateTimeFieldBinding.tsx +3 -3
  29. package/src/form/field_bindings/KeyValueFieldBinding.tsx +4 -4
  30. package/src/form/field_bindings/MapFieldBinding.tsx +2 -2
  31. package/src/form/field_bindings/MarkdownFieldBinding.tsx +1 -2
  32. package/src/form/field_bindings/MultiSelectBinding.tsx +2 -3
  33. package/src/form/field_bindings/ReadOnlyFieldBinding.tsx +2 -2
  34. package/src/form/field_bindings/ReferenceFieldBinding.tsx +5 -4
  35. package/src/form/field_bindings/RepeatFieldBinding.tsx +3 -3
  36. package/src/form/field_bindings/SelectFieldBinding.tsx +2 -3
  37. package/src/form/field_bindings/StorageUploadFieldBinding.tsx +3 -3
  38. package/src/form/field_bindings/SwitchFieldBinding.tsx +2 -3
  39. package/src/form/field_bindings/TextFieldBinding.tsx +3 -4
  40. package/src/form/index.tsx +1 -0
  41. package/src/hooks/index.tsx +3 -1
  42. package/src/{core → hooks}/useBuildModeController.tsx +1 -1
  43. package/src/internal/useBuildDataSource.ts +3 -1
  44. package/src/preview/PropertyPreview.tsx +1 -1
  45. package/src/preview/components/ReferencePreview.tsx +1 -1
  46. package/src/types/entities.ts +4 -0
  47. /package/dist/{internal → core}/EntityView.d.ts +0 -0
  48. /package/dist/{components → form/components}/LabelWithIcon.d.ts +0 -0
  49. /package/dist/{core → hooks}/useBuildLocalConfigurationPersistence.d.ts +0 -0
  50. /package/src/{components → form/components}/LabelWithIcon.tsx +0 -0
  51. /package/src/{core → hooks}/useBuildLocalConfigurationPersistence.tsx +0 -0
@@ -43,6 +43,7 @@ export declare class EntityReference<M extends Record<string, any> = any> {
43
43
  readonly path: string;
44
44
  constructor(id: string, path: string);
45
45
  get pathWithId(): string;
46
+ isEntityReference(): boolean;
46
47
  }
47
48
  export declare class GeoPoint {
48
49
  /**
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.3",
4
+ "version": "3.0.0-canary.5",
5
5
  "description": "Awesome Firebase/Firestore-based headless open-source CMS",
6
6
  "funding": {
7
7
  "url": "https://github.com/sponsors/firecmsco"
@@ -46,8 +46,8 @@
46
46
  "./package.json": "./package.json"
47
47
  },
48
48
  "dependencies": {
49
- "@firecms/formex": "^3.0.0-canary.3",
50
- "@firecms/ui": "^3.0.0-canary.3",
49
+ "@firecms/formex": "^3.0.0-canary.5",
50
+ "@firecms/ui": "^3.0.0-canary.5",
51
51
  "@fontsource/ibm-plex-mono": "^5.0.8",
52
52
  "@fontsource/roboto": "^5.0.8",
53
53
  "@hello-pangea/dnd": "^16.5.0",
@@ -115,7 +115,7 @@
115
115
  "dist",
116
116
  "src"
117
117
  ],
118
- "gitHead": "9d587b683991dfcefd28e1c13b693364b5de72b2",
118
+ "gitHead": "e3850e04c28ef87d561bdf651950c7fbac87a9ec",
119
119
  "publishConfig": {
120
120
  "access": "public"
121
121
  }
@@ -24,13 +24,14 @@ import { getPreviewSizeFrom } from "../../preview/util";
24
24
  import { isReadOnly } from "../../util";
25
25
 
26
26
  import { CustomFieldValidator, mapPropertyToYup } from "../../form/validation";
27
- import { useClearRestoreValue, useFireCMSContext } from "../../hooks";
27
+ import { useFireCMSContext } from "../../hooks";
28
28
 
29
29
  import { EntityTableCell } from "./internal/EntityTableCell";
30
30
  import { EntityTableCellActions } from "./internal/EntityTableCellActions";
31
31
 
32
32
  import { getRowHeight } from "../VirtualTable/common";
33
33
  import { useSelectableTableController } from "../SelectableTable/SelectableTableContext";
34
+ import { useClearRestoreValue } from "../../form/useClearRestoreValue";
34
35
 
35
36
  export interface PropertyTableCellProps<T extends CMSType, M extends Record<string, any>> {
36
37
  propertyKey: string;
@@ -96,7 +96,7 @@ export const TableReferenceFieldSuccess = React.memo(
96
96
  const valueNotSet = !internalValue || (Array.isArray(internalValue) && internalValue.length === 0);
97
97
 
98
98
  const buildSingleReferenceField = () => {
99
- if (internalValue instanceof EntityReference)
99
+ if (internalValue && !Array.isArray(internalValue) && internalValue.isEntityReference && internalValue.isEntityReference())
100
100
  return <ReferencePreview
101
101
  onClick={disabled ? undefined : handleOpen}
102
102
  size={getPreviewSizeFrom(size)}
@@ -9,13 +9,13 @@ import { Button, cn } from "@firecms/ui";
9
9
  export type ReferenceWidgetProps<M extends Record<string, any>> = {
10
10
  name?: string,
11
11
  multiselect?: boolean,
12
- value: EntityReference<M> | EntityReference<M>[] | null,
12
+ value: EntityReference | EntityReference[] | null,
13
13
  onReferenceSelected?: (params: {
14
- reference: EntityReference<M> | null,
14
+ reference: EntityReference | null,
15
15
  entity: Entity<M> | null
16
16
  }) => void,
17
17
  onMultipleReferenceSelected?: (params: {
18
- references: EntityReference<M>[] | null,
18
+ references: EntityReference[] | null,
19
19
  entities: Entity<M>[] | null
20
20
  }) => void,
21
21
  path: string,
@@ -113,7 +113,7 @@ export function ReferenceWidget<M extends Record<string, any>>({
113
113
  size={size}/>
114
114
  })}
115
115
  </div>
116
- } else if (value instanceof EntityReference) {
116
+ } else if (value?.isEntityReference && value?.isEntityReference()) {
117
117
  child = <ReferencePreview
118
118
  reference={value}
119
119
  onClick={onEntryClick}
@@ -60,7 +60,7 @@ export function ReferenceFilterField({
60
60
 
61
61
  const selectedEntityIds = internalValue
62
62
  ? (Array.isArray(internalValue) ? internalValue.map((ref) => {
63
- if (!(ref instanceof EntityReference)) {
63
+ if (!(ref.isEntityReference && ref.isEntityReference())) {
64
64
  return null;
65
65
  }
66
66
  return ref.id;
@@ -74,7 +74,7 @@ export function ReferenceFilterField({
74
74
  let newValue = val;
75
75
  if (prevOpIsArray !== newOpIsArray) {
76
76
  // @ts-ignore
77
- newValue = newOpIsArray ? (newValue instanceof EntityReference ? [newValue] : []) : undefined
77
+ newValue = newOpIsArray ? (newValue.isEntityReference && newValue.isEntityReference() ? [newValue] : []) : undefined
78
78
  }
79
79
 
80
80
  setOperation(op);
@@ -31,5 +31,4 @@ export * from "./FireCMSAppBar";
31
31
 
32
32
  export * from "./ArrayContainer";
33
33
  export * from "./ReferenceWidget";
34
- export * from "./LabelWithIcon";
35
34
  export * from "./SearchIconsView";
@@ -4,7 +4,7 @@ import { EntitySidePanelProps } from "../types";
4
4
  import { useNavigationController } from "../hooks";
5
5
 
6
6
  import { ErrorBoundary } from "../components";
7
- import { EntityView } from "../internal/EntityView";
7
+ import { EntityView } from "./EntityView";
8
8
  import { useSideDialogContext } from "./SideDialogs";
9
9
 
10
10
  /**
@@ -32,8 +32,8 @@ import {
32
32
  import { EntityForm } from "../form";
33
33
  import { CircularProgress, CloseIcon, cn, defaultBorderMixin, IconButton, Tab, Tabs, Typography } from "@firecms/ui";
34
34
  import { EntityFormSaveParams } from "../form/EntityForm";
35
- import { FORM_CONTAINER_WIDTH } from "./common";
36
- import { useSideDialogContext } from "../core";
35
+ import { FORM_CONTAINER_WIDTH } from "../internal/common";
36
+ import { useSideDialogContext } from "./index";
37
37
 
38
38
  const MAIN_TAB_VALUE = "main_##Q$SC^#S6";
39
39
 
@@ -0,0 +1,38 @@
1
+ import { EntityViewProps } from "./EntityView";
2
+ import { User } from "../types";
3
+ import { useSideDialogContext } from "./SideDialogs";
4
+ import { useSideEntityController } from "../hooks";
5
+ import { FORM_CONTAINER_WIDTH } from "../internal/common";
6
+
7
+ export type SideEntityViewProps<M extends Record<string, any>> = EntityViewProps<M> & {
8
+ formWidth?: number | string;
9
+ onClose?: () => void;
10
+ }
11
+
12
+ export function SideEntityView<M extends Record<string, any>, UserType extends User>({
13
+ path,
14
+ entityId,
15
+ selectedSubPath,
16
+ copy,
17
+ collection,
18
+ parentCollectionIds,
19
+ onValuesAreModified,
20
+ formWidth,
21
+ onUpdate,
22
+ onClose
23
+ }: SideEntityViewProps<M>) {
24
+
25
+ const sideDialogContext = useSideDialogContext();
26
+ const sideEntityController = useSideEntityController();
27
+ const resolvedFormWidth: string = typeof formWidth === "number" ? `${formWidth}px` : formWidth ?? FORM_CONTAINER_WIDTH;
28
+
29
+ const onCloseHandler = () => {
30
+ if (onClose) {
31
+ onClose();
32
+ } else {
33
+ sideDialogContext.close();
34
+ }
35
+ }
36
+
37
+ return <></>;
38
+ }
@@ -10,5 +10,3 @@ export * from "./field_configs";
10
10
 
11
11
  export * from "./SideDialogs";
12
12
  export * from "./NavigationRoutes";
13
- export * from "./useBuildModeController";
14
- export * from "./useBuildLocalConfigurationPersistence";
@@ -1,2 +1,3 @@
1
1
  export * from "./FormikArrayContainer";
2
2
  export * from "./FieldHelperText";
3
+ export * from "./LabelWithIcon";
@@ -1,11 +1,10 @@
1
1
  import React from "react";
2
2
  import { FieldProps } from "../../types";
3
- import { FieldHelperText } from "../components";
3
+ import { FieldHelperText, LabelWithIcon } from "../components";
4
4
  import { PropertyFieldBinding } from "../PropertyFieldBinding";
5
- import { useClearRestoreValue } from "../../hooks";
6
5
  import { ExpandablePanel } from "@firecms/ui";
7
6
  import { getIconForProperty } from "../../util";
8
- import { LabelWithIcon } from "../../components";
7
+ import { useClearRestoreValue } from "../useClearRestoreValue";
9
8
 
10
9
  /**
11
10
  * Array field used for custom
@@ -1,12 +1,13 @@
1
1
  import React, { useCallback, useMemo } from "react";
2
2
  import { Entity, EntityCollection, EntityReference, FieldProps, ResolvedProperty } from "../../types";
3
3
  import { ReferencePreview } from "../../preview";
4
- import { FieldHelperText, FormikArrayContainer } from "../components";
5
- import { ErrorView, LabelWithIcon } from "../../components";
4
+ import { FieldHelperText, FormikArrayContainer, LabelWithIcon } from "../components";
5
+ import { ErrorView } from "../../components";
6
6
  import { getIconForProperty, getReferenceFrom } from "../../util";
7
7
 
8
- import { useClearRestoreValue, useNavigationController, useReferenceDialog } from "../../hooks";
8
+ import { useNavigationController, useReferenceDialog } from "../../hooks";
9
9
  import { Button, ExpandablePanel } from "@firecms/ui";
10
+ import { useClearRestoreValue } from "../useClearRestoreValue";
10
11
 
11
12
  type ArrayOfReferencesFieldProps = FieldProps<EntityReference[]>;
12
13
 
@@ -2,15 +2,14 @@ import React, { useCallback, useEffect, useState } from "react";
2
2
 
3
3
  import { Field, useFormex } from "@firecms/formex";
4
4
 
5
- import { FieldHelperText, FormikArrayContainer } from "../components";
6
- import { LabelWithIcon } from "../../components";
7
- import { useClearRestoreValue } from "../../hooks";
5
+ import { FieldHelperText, FormikArrayContainer, LabelWithIcon } from "../components";
8
6
  import { PropertyFieldBinding } from "../PropertyFieldBinding";
9
7
  import { EnumValuesChip } from "../../preview";
10
8
  import { FieldProps, FormContext, PropertyFieldBindingProps, PropertyOrBuilder } from "../../types";
11
9
  import { getDefaultValueFor, getIconForProperty, } from "../../util";
12
10
  import { DEFAULT_ONE_OF_TYPE, DEFAULT_ONE_OF_VALUE } from "../../util/common";
13
11
  import { cn, ExpandablePanel, paperMixin, Select, SelectItem, Typography } from "@firecms/ui";
12
+ import { useClearRestoreValue } from "../useClearRestoreValue";
14
13
 
15
14
  /**
16
15
  * If the `oneOf` property is specified, this fields render each array entry as
@@ -2,11 +2,11 @@ import React from "react";
2
2
 
3
3
  import { FieldProps } from "../../types";
4
4
 
5
- import { FieldHelperText } from "../components";
6
- import { LabelWithIcon } from "../../components";
7
- import { useClearRestoreValue, useCustomizationController } from "../../hooks";
5
+ import { FieldHelperText, LabelWithIcon } from "../components";
6
+ import { useCustomizationController } from "../../hooks";
8
7
  import { getIconForProperty } from "../../util";
9
8
  import { DateTimeField } from "@firecms/ui";
9
+ import { useClearRestoreValue } from "../useClearRestoreValue";
10
10
 
11
11
  type DateTimeFieldProps = FieldProps<Date>;
12
12
 
@@ -1,8 +1,8 @@
1
1
  import React, { useEffect, useState } from "react";
2
- import { DataType, EntityReference, FieldProps, GeoPoint } from "../../types";
2
+ import { DataType, FieldProps, GeoPoint } from "../../types";
3
3
 
4
- import { ArrayContainer, LabelWithIcon } from "../../components";
5
- import { FieldHelperText } from "../components";
4
+ import { ArrayContainer } from "../../components";
5
+ import { FieldHelperText, LabelWithIcon } from "../components";
6
6
  import {
7
7
  AddIcon,
8
8
  ArrowDropDownIcon,
@@ -546,7 +546,7 @@ function getDataType(value: any): DataType | undefined {
546
546
  return "array";
547
547
  } else if (value instanceof Date) {
548
548
  return "date";
549
- } else if (value instanceof EntityReference) {
549
+ } else if (value.isEntityReference && value.isEntityReference()) {
550
550
  return "reference";
551
551
  } else if (value instanceof GeoPoint) {
552
552
  return "geopoint";
@@ -1,9 +1,9 @@
1
1
  import React from "react";
2
2
  import { FieldProps, Properties, ResolvedProperties } from "../../types";
3
3
 
4
- import { ErrorBoundary, LabelWithIcon } from "../../components";
4
+ import { ErrorBoundary } from "../../components";
5
5
  import { getIconForProperty, isHidden, pick } from "../../util";
6
- import { FieldHelperText } from "../components";
6
+ import { FieldHelperText, LabelWithIcon } from "../components";
7
7
  import { PropertyFieldBinding } from "../PropertyFieldBinding";
8
8
  import { ExpandablePanel, InputLabel, Select, SelectItem } from "@firecms/ui";
9
9
 
@@ -4,8 +4,7 @@ import React, { useDeferredValue, useEffect, useRef } from "react";
4
4
  import MarkdownIt from "markdown-it";
5
5
  import MdEditor, { Plugins } from "react-markdown-editor-lite";
6
6
 
7
- import { FieldHelperText } from "../components";
8
- import { LabelWithIcon } from "../../components";
7
+ import { FieldHelperText, LabelWithIcon } from "../components";
9
8
  import { FieldProps } from "../../types";
10
9
  import { getIconForProperty } from "../../util";
11
10
  import {
@@ -1,12 +1,11 @@
1
1
  import React, { useCallback } from "react";
2
2
 
3
3
  import { EnumType, FieldProps, ResolvedProperty } from "../../types";
4
- import { FieldHelperText } from "../components";
5
- import { LabelWithIcon } from "../../components";
6
- import { useClearRestoreValue } from "../../hooks";
4
+ import { FieldHelperText, LabelWithIcon } from "../components";
7
5
  import { EnumValuesChip } from "../../preview";
8
6
  import { enumToObjectEntries, getIconForProperty, getLabelOrConfigFrom } from "../../util";
9
7
  import { CloseIcon, MultiSelect, MultiSelectItem } from "@firecms/ui";
8
+ import { useClearRestoreValue } from "../useClearRestoreValue";
10
9
 
11
10
  /**
12
11
  * This fields renders a dropdown with multiple selection.
@@ -3,8 +3,8 @@ import React from "react";
3
3
  import { Entity, FieldProps } from "../../types";
4
4
 
5
5
  import { PropertyPreview } from "../../preview";
6
- import { FieldHelperText } from "../components";
7
- import { ErrorBoundary, LabelWithIcon } from "../../components";
6
+ import { FieldHelperText, LabelWithIcon } from "../components";
7
+ import { ErrorBoundary } from "../../components";
8
8
  import { getIconForProperty } from "../../util";
9
9
  import { cn, paperMixin } from "@firecms/ui";
10
10
 
@@ -1,13 +1,14 @@
1
1
  import React, { useCallback, useMemo } from "react";
2
2
 
3
3
  import { Entity, EntityCollection, EntityReference, FieldProps } from "../../types";
4
- import { useClearRestoreValue, useNavigationController, useReferenceDialog } from "../../hooks";
4
+ import { useNavigationController, useReferenceDialog } from "../../hooks";
5
5
  import { ReadOnlyFieldBinding } from "./ReadOnlyFieldBinding";
6
- import { FieldHelperText } from "../components";
7
- import { ErrorView, LabelWithIcon } from "../../components";
6
+ import { FieldHelperText, LabelWithIcon } from "../components";
7
+ import { ErrorView } from "../../components";
8
8
  import { ReferencePreview } from "../../preview";
9
9
  import { getIconForProperty, getReferenceFrom } from "../../util";
10
10
  import { Button } from "@firecms/ui";
11
+ import { useClearRestoreValue } from "../useClearRestoreValue";
11
12
 
12
13
  /**
13
14
  * Field that opens a reference selection dialog.
@@ -49,7 +50,7 @@ function ReferenceFieldBindingInternal<M extends Record<string, any>>({
49
50
  setValue
50
51
  });
51
52
 
52
- const validValue = value && value instanceof EntityReference;
53
+ const validValue = value && value.isEntityReference && value.isEntityReference();
53
54
 
54
55
  const navigationController = useNavigationController();
55
56
  const collection: EntityCollection | undefined = useMemo(() => {
@@ -1,11 +1,11 @@
1
1
  import React, { useState } from "react";
2
2
  import { CMSType, FieldProps, ResolvedProperty } from "../../types";
3
- import { FieldHelperText, FormikArrayContainer } from "../components";
4
- import { ErrorBoundary, LabelWithIcon } from "../../components";
5
- import { useClearRestoreValue } from "../../hooks";
3
+ import { FieldHelperText, FormikArrayContainer, LabelWithIcon } from "../components";
4
+ import { ErrorBoundary } from "../../components";
6
5
  import { getIconForProperty } from "../../util";
7
6
  import { PropertyFieldBinding } from "../PropertyFieldBinding";
8
7
  import { ExpandablePanel } from "@firecms/ui";
8
+ import { useClearRestoreValue } from "../useClearRestoreValue";
9
9
 
10
10
  /**
11
11
  * Generic array field that allows reordering and renders the child property
@@ -1,12 +1,11 @@
1
1
  import React, { useCallback } from "react";
2
2
 
3
3
  import { EnumType, FieldProps } from "../../types";
4
- import { FieldHelperText } from "../components";
5
- import { LabelWithIcon } from "../../components";
6
- import { useClearRestoreValue } from "../../hooks";
4
+ import { FieldHelperText, LabelWithIcon } from "../components";
7
5
  import { EnumValuesChip } from "../../preview";
8
6
  import { getIconForProperty } from "../../util";
9
7
  import { ClearIcon, cn, IconButton, Select, SelectItem } from "@firecms/ui";
8
+ import { useClearRestoreValue } from "../useClearRestoreValue";
10
9
 
11
10
  type SelectProps<T extends EnumType> = FieldProps<T>;
12
11
 
@@ -10,11 +10,10 @@ import {
10
10
  } from "../../types";
11
11
  import { useDropzone } from "react-dropzone";
12
12
  import { PreviewSize } from "../../preview";
13
- import { FieldHelperText } from "../components";
14
- import { LabelWithIcon } from "../../components";
13
+ import { FieldHelperText,LabelWithIcon } from "../components";
15
14
 
16
15
  import { getIconForProperty, isReadOnly } from "../../util";
17
- import { useClearRestoreValue, useSnackbarController, useStorageSource } from "../../hooks";
16
+ import { useSnackbarController, useStorageSource } from "../../hooks";
18
17
  import { DragDropContext, Draggable, Droppable } from "@hello-pangea/dnd";
19
18
  import { StorageFieldItem, useStorageUploadController } from "../../util/useStorageUploadController";
20
19
  import { StorageUploadProgress } from "../components/StorageUploadProgress";
@@ -27,6 +26,7 @@ import {
27
26
  focusedMixin,
28
27
  Typography
29
28
  } from "@firecms/ui";
29
+ import { useClearRestoreValue } from "../useClearRestoreValue";
30
30
 
31
31
  const dropZoneClasses = "box-border relative pt-[2px] items-center border border-transparent min-h-[254px] outline-none rounded-md duration-200 ease-[cubic-bezier(0.4,0,0.2,1)] focus:border-primary-solid";
32
32
  const disabledClasses = "border-dotted-gray"
@@ -1,11 +1,10 @@
1
1
  import React from "react";
2
2
 
3
3
  import { FieldProps } from "../../types";
4
- import { useClearRestoreValue } from "../../hooks";
5
4
  import { getIconForProperty } from "../../util";
6
- import { FieldHelperText } from "../components/FieldHelperText";
5
+ import { FieldHelperText, LabelWithIcon } from "../components";
7
6
  import { BooleanSwitchWithLabel } from "@firecms/ui";
8
- import { LabelWithIcon } from "../../components";
7
+ import { useClearRestoreValue } from "../useClearRestoreValue";
9
8
 
10
9
  type SwitchFieldProps = FieldProps<boolean>;
11
10
 
@@ -1,12 +1,11 @@
1
1
  import React, { useCallback } from "react";
2
2
 
3
+ import { ClearIcon, Collapse, IconButton, TextField } from "@firecms/ui";
3
4
  import { FieldProps, PreviewType } from "../../types";
4
- import { FieldHelperText } from "../components";
5
- import { useClearRestoreValue } from "../../hooks";
5
+ import { FieldHelperText, LabelWithIcon } from "../components";
6
6
  import { getIconForProperty } from "../../util";
7
- import { ClearIcon, Collapse, IconButton, TextField } from "@firecms/ui";
8
7
  import { PropertyPreview } from "../../preview";
9
- import { LabelWithIcon } from "../../components";
8
+ import { useClearRestoreValue } from "../useClearRestoreValue";
10
9
 
11
10
  interface TextFieldProps<T extends string | number> extends FieldProps<T> {
12
11
  allowInfinity?: boolean
@@ -40,3 +40,4 @@ export {
40
40
  } from "./EntityForm";
41
41
 
42
42
  export { PropertyFieldBinding } from "./PropertyFieldBinding";
43
+ export * from "./useClearRestoreValue";
@@ -4,7 +4,6 @@ export * from "./data/useEntityFetch";
4
4
  export * from "./data/save";
5
5
  export * from "./data/delete";
6
6
 
7
- export * from "../form/useClearRestoreValue";
8
7
  export * from "./useNavigationController";
9
8
 
10
9
  export * from "./useResolvedNavigationFrom";
@@ -23,3 +22,6 @@ export * from "./useReferenceDialog";
23
22
  export * from "./useBrowserTitleAndIcon";
24
23
  export * from "./useCustomizationController";
25
24
  export * from "./useBuildNavigationController";
25
+
26
+ export * from "./useBuildLocalConfigurationPersistence";
27
+ export * from "./useBuildModeController";
@@ -1,6 +1,6 @@
1
1
  import { useCallback, useEffect, useState } from "react";
2
2
 
3
- import { ModeController } from "../hooks";
3
+ import { ModeController } from "./index";
4
4
 
5
5
  /**
6
6
  * Use this hook to build a color mode controller that determines
@@ -340,9 +340,11 @@ export function cmsToDelegateModel(data: any,
340
340
  ): any {
341
341
  if (data === undefined) {
342
342
  return buildDelete();
343
+ } else if (data === null) {
344
+ return null;
343
345
  } else if (Array.isArray(data)) {
344
346
  return data.map(v => cmsToDelegateModel(v, buildReference, buildGeoPoint, buildDate, buildDelete));
345
- } else if (data instanceof EntityReference) {
347
+ } else if (data.isEntityReference && data.isEntityReference()) {
346
348
  return buildReference(data);
347
349
  } else if (data instanceof GeoPoint) {
348
350
  return buildGeoPoint(data);
@@ -178,7 +178,7 @@ export const PropertyPreview = React.memo(function PropertyPreview<T extends CMS
178
178
  }
179
179
  } else if (property.dataType === "reference") {
180
180
  if (typeof property.path === "string") {
181
- if (value instanceof EntityReference) {
181
+ if (typeof value === "object" && "isEntityReference" in value && value.isEntityReference()) {
182
182
  content = <ReferencePreview
183
183
  disabled={!property.path}
184
184
  previewProperties={property.previewProperties}
@@ -32,7 +32,7 @@ export type ReferencePreviewProps = {
32
32
  */
33
33
  export const ReferencePreview = React.memo<ReferencePreviewProps>(function ReferencePreview(props: ReferencePreviewProps) {
34
34
  const reference = props.reference;
35
- if (!((reference as unknown) instanceof EntityReference)) {
35
+ if (!(typeof reference === "object" && "isEntityReference" in reference && reference.isEntityReference())) {
36
36
  console.warn("Reference preview received value of type", typeof reference);
37
37
  return <ReferencePreviewContainer
38
38
  onClick={props.onClick}
@@ -56,6 +56,10 @@ export class EntityReference<M extends Record<string, any> = any> {
56
56
  get pathWithId() {
57
57
  return `${this.path}/${this.id}`;
58
58
  }
59
+
60
+ isEntityReference() {
61
+ return true;
62
+ }
59
63
  }
60
64
 
61
65
  export class GeoPoint {
File without changes