@firecms/core 3.0.0-alpha.72 → 3.0.0-alpha.73

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.
@@ -109,7 +109,11 @@ export function getYupMapObjectSchema<M extends Record<string, any>>({
109
109
  });
110
110
  });
111
111
 
112
- return yup.object().shape(objectSchema);
112
+ const shape = yup.object().shape(objectSchema);
113
+ if (validation?.required) {
114
+ return shape.required(validation?.requiredMessage ? validation.requiredMessage : "Required").nullable(true);
115
+ }
116
+ return shape.nullable(true);
113
117
  // const object: ObjectSchema<any> = yup.object().shape(objectSchema);
114
118
  // return validation?.required
115
119
  // ? object.required(validation?.requiredMessage ? validation.requiredMessage : "Required").nullable(true)
@@ -68,7 +68,6 @@ export function EntityView<M extends Record<string, any>, UserType extends User>
68
68
  onClose
69
69
  }: EntityViewProps<M>) {
70
70
 
71
-
72
71
  if (collection.customId && collection.formAutoSave) {
73
72
  console.warn(`The collection ${collection.path} has customId and formAutoSave enabled. This is not supported and formAutoSave will be ignored`);
74
73
  }
@@ -502,11 +501,12 @@ export function EntityView<M extends Record<string, any>, UserType extends User>
502
501
 
503
502
  <div
504
503
  className="pb-1 self-center">
505
- <IconButton onClick={() => {
506
- onClose?.();
507
- return sideDialogContext.close(false);
508
- }}
509
- size="large">
504
+ <IconButton
505
+ onClick={() => {
506
+ onClose?.();
507
+ return sideDialogContext.close(false);
508
+ }}
509
+ size="large">
510
510
  <CloseIcon/>
511
511
  </IconButton>
512
512
  </div>
@@ -225,8 +225,6 @@ export function useBuildDataSource({
225
225
  })
226
226
  : firestoreValues;
227
227
 
228
- console.debug("Saving entity", path, entityId, updatedFirestoreValues);
229
-
230
228
  return delegate.saveEntity({
231
229
  path,
232
230
  entityId,
@@ -61,6 +61,7 @@ export const useBuildSideEntityController = (navigation: NavigationController,
61
61
  if (props.copy && !props.entityId) {
62
62
  throw Error("If you want to copy an entity you need to provide an entityId");
63
63
  }
64
+
64
65
  const defaultSelectedView = resolveDefaultSelectedView(
65
66
  props.collection ? props.collection.defaultSelectedView : undefined,
66
67
  {
@@ -69,7 +70,10 @@ export const useBuildSideEntityController = (navigation: NavigationController,
69
70
  }
70
71
  );
71
72
 
72
- sideDialogsController.open(propsToSidePanel({ selectedSubPath: defaultSelectedView, ...props }, navigation, smallLayout));
73
+ sideDialogsController.open(propsToSidePanel({
74
+ selectedSubPath: defaultSelectedView,
75
+ ...props,
76
+ }, navigation, smallLayout));
73
77
 
74
78
  }, [sideDialogsController, navigation, smallLayout]);
75
79
 
@@ -144,17 +148,24 @@ export function buildSidePanelsFromUrl(path: string, collections: EntityCollecti
144
148
 
145
149
  const propsToSidePanel = (props: EntitySidePanelProps<any>, navigation: NavigationController, smallLayout: boolean): SideDialogPanelProps => {
146
150
 
147
- const collectionPath = removeInitialAndTrailingSlashes(props.path);
148
- const newPath = props.entityId
149
- ? navigation.buildUrlCollectionPath(`${collectionPath}/${props.entityId}/${props.selectedSubPath || ""}`)
150
- : navigation.buildUrlCollectionPath(`${collectionPath}#${NEW_URL_HASH}`);
151
-
152
- return ({
153
- key: `${props.path}/${props.entityId}`,
154
- component: <EntitySidePanel {...props}/>,
155
- urlPath: newPath,
156
- parentUrlPath: navigation.buildUrlCollectionPath(collectionPath),
157
- width: getEntityViewWidth(props, smallLayout),
158
- onClose: props.onClose
159
- });
160
- };
151
+ const collectionPath = removeInitialAndTrailingSlashes(props.path);
152
+ const newPath = props.entityId
153
+ ? navigation.buildUrlCollectionPath(`${collectionPath}/${props.entityId}/${props.selectedSubPath || ""}`)
154
+ : navigation.buildUrlCollectionPath(`${collectionPath}#${NEW_URL_HASH}`);
155
+ const resolvedPath = navigation.resolveAliasesFrom(props.path);
156
+
157
+ const resolvedPanelProps: EntitySidePanelProps<any> = {
158
+ ...props,
159
+ path: resolvedPath
160
+ };
161
+
162
+ return ({
163
+ key: `${props.path}/${props.entityId}`,
164
+ component: <EntitySidePanel {...resolvedPanelProps}/>,
165
+ urlPath: newPath,
166
+ parentUrlPath: navigation.buildUrlCollectionPath(collectionPath),
167
+ width: getEntityViewWidth(props, smallLayout),
168
+ onClose: props.onClose
169
+ });
170
+ }
171
+ ;
@@ -5,6 +5,7 @@ import { PropertyPreviewProps } from "../PropertyPreviewProps";
5
5
  import { PropertyPreview } from "../PropertyPreview";
6
6
  import { cn, defaultBorderMixin, Typography } from "@firecms/ui";
7
7
  import { ErrorBoundary } from "../../components";
8
+ import { EmptyValue } from "../components/EmptyValue";
8
9
 
9
10
  /**
10
11
  * @group Preview components
@@ -43,7 +44,7 @@ export function MapPropertyPreview<T extends Record<string, any> = Record<string
43
44
  <PropertyPreview propertyKey={key}
44
45
  value={(value)[key]}
45
46
  property={mapProperty.properties![key]}
46
- // entity={entity}
47
+ // entity={entity}
47
48
  size={size}/>
48
49
  </ErrorBoundary>
49
50
  </div>
@@ -105,6 +106,7 @@ export function MapPropertyPreview<T extends Record<string, any> = Record<string
105
106
 
106
107
  export function KeyValuePreview({ value }: { value: any }) {
107
108
  if (typeof value !== "object") return null;
109
+ if (!value) return <EmptyValue/>;
108
110
  return <div
109
111
  className="flex flex-col gap-1 w-full">
110
112
  {
@@ -2,12 +2,11 @@ import React from "react";
2
2
 
3
3
  import { resolvePropertyEnum } from "../../util";
4
4
  import { EnumValuesChip } from "../components/EnumValuesChip";
5
- import { getColorSchemeForSeed } from "../../util/chip_utils";
6
5
  import { PreviewType } from "../../types";
7
6
  import { UrlComponentPreview } from "../components/UrlComponentPreview";
8
7
  import { PropertyPreviewProps } from "../PropertyPreviewProps";
9
8
  import { ErrorBoundary } from "../../components";
10
- import { Chip } from "@firecms/ui";
9
+ import { Chip, getColorSchemeForSeed } from "@firecms/ui";
11
10
 
12
11
  /**
13
12
  * @group Preview components
package/src/util/enums.ts CHANGED
@@ -1,6 +1,5 @@
1
1
  import { EnumValueConfig, EnumValues } from "../types";
2
- import { CHIP_COLORS, ChipColorScheme } from "@firecms/ui";
3
- import { getColorSchemeForSeed } from "./chip_utils";
2
+ import { CHIP_COLORS, ChipColorScheme, getColorSchemeForSeed } from "@firecms/ui";
4
3
 
5
4
  export function enumToObjectEntries(enumValues: EnumValues): EnumValueConfig[] {
6
5
  if (Array.isArray(enumValues)) {
@@ -1,3 +0,0 @@
1
- import { ChipColorKey, ChipColorScheme } from "@firecms/ui";
2
- export declare function getColorSchemeForSeed(seed: string): ChipColorScheme;
3
- export declare function getColorSchemeForKey(key: ChipColorKey): ChipColorScheme;
@@ -1,13 +0,0 @@
1
- import { hashString } from "./hash";
2
- import { CHIP_COLORS, ChipColorKey, ChipColorScheme } from "@firecms/ui";
3
-
4
- export function getColorSchemeForSeed(seed: string): ChipColorScheme {
5
- const hash: number = hashString(seed);
6
- const colorKeys = Object.keys(CHIP_COLORS);
7
- const index = hash % colorKeys.length;
8
- return CHIP_COLORS[colorKeys[index]];
9
- }
10
-
11
- export function getColorSchemeForKey(key: ChipColorKey): ChipColorScheme {
12
- return CHIP_COLORS[key];
13
- }