@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.
- package/dist/index.es.js +4050 -3461
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +587 -4
- package/dist/index.umd.js.map +1 -1
- package/package.json +3 -3
- package/src/components/EntityCollectionTable/internal/CollectionTableToolbar.tsx +2 -2
- package/src/components/VirtualTable/VirtualTableRow.tsx +0 -1
- package/src/core/EntitySidePanel.tsx +0 -1
- package/src/form/EntityForm.tsx +6 -5
- package/src/form/PropertyFieldBinding.tsx +1 -1
- package/src/form/field_bindings/MarkdownFieldBinding.tsx +585 -585
- package/src/form/validation.ts +5 -1
- package/src/internal/EntityView.tsx +6 -6
- package/src/internal/useBuildDataSource.ts +0 -2
- package/src/internal/useBuildSideEntityController.tsx +26 -15
- package/src/preview/property_previews/MapPropertyPreview.tsx +3 -1
- package/src/preview/property_previews/StringPropertyPreview.tsx +1 -2
- package/src/util/enums.ts +1 -2
- package/dist/util/chip_utils.d.ts +0 -3
- package/src/util/chip_utils.ts +0 -13
package/src/form/validation.ts
CHANGED
|
@@ -109,7 +109,11 @@ export function getYupMapObjectSchema<M extends Record<string, any>>({
|
|
|
109
109
|
});
|
|
110
110
|
});
|
|
111
111
|
|
|
112
|
-
|
|
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
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
504
|
+
<IconButton
|
|
505
|
+
onClick={() => {
|
|
506
|
+
onClose?.();
|
|
507
|
+
return sideDialogContext.close(false);
|
|
508
|
+
}}
|
|
509
|
+
size="large">
|
|
510
510
|
<CloseIcon/>
|
|
511
511
|
</IconButton>
|
|
512
512
|
</div>
|
|
@@ -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({
|
|
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
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
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
|
-
|
|
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)) {
|
package/src/util/chip_utils.ts
DELETED
|
@@ -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
|
-
}
|