@firecms/core 3.0.0-alpha.72 → 3.0.0-alpha.74
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/components/{EntityCollectionTable/internal/DeleteEntityDialog.d.ts → DeleteEntityDialog.d.ts} +1 -1
- package/dist/components/EntityCollectionTable/{internal/EntityCollectionRowActions.d.ts → EntityCollectionRowActions.d.ts} +3 -3
- package/dist/components/EntityCollectionTable/EntityCollectionTable.d.ts +1 -1
- package/dist/components/EntityCollectionTable/EntityCollectionTableProps.d.ts +3 -3
- package/dist/components/EntityCollectionTable/{internal/PropertyTableCell.d.ts → PropertyTableCell.d.ts} +2 -2
- package/dist/components/EntityCollectionTable/SimpleEntityCollectionTable.d.ts +95 -0
- package/dist/components/EntityCollectionTable/column_utils.d.ts +16 -0
- package/dist/components/EntityCollectionTable/index.d.ts +4 -0
- package/dist/components/EntityCollectionTable/internal/CollectionTableToolbar.d.ts +1 -1
- package/dist/components/EntityCollectionTable/internal/popup_field/PopupFormField.d.ts +1 -1
- package/dist/components/EntityCollectionTable/types.d.ts +2 -2
- package/dist/components/EntityCollectionTable/useDataSourceEntityCollectionTableController.d.ts +3 -3
- package/dist/components/EntityCollectionView/EntityCollectionViewActions.d.ts +2 -2
- package/dist/components/VirtualTable/VirtualTableCell.d.ts +1 -1
- package/dist/components/VirtualTable/VirtualTableProps.d.ts +2 -3
- package/dist/components/VirtualTable/types.d.ts +1 -1
- package/dist/form/components/FieldHelperText.d.ts +1 -1
- package/dist/index.es.js +5004 -4214
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +587 -4
- package/dist/index.umd.js.map +1 -1
- package/dist/types/collections.d.ts +2 -2
- package/dist/types/plugins.d.ts +2 -0
- package/package.json +3 -3
- package/src/components/{EntityCollectionTable/internal/DeleteEntityDialog.tsx → DeleteEntityDialog.tsx} +4 -4
- package/src/components/EntityCollectionTable/{internal/EntityCollectionRowActions.tsx → EntityCollectionRowActions.tsx} +4 -4
- package/src/components/EntityCollectionTable/EntityCollectionTable.tsx +13 -48
- package/src/components/EntityCollectionTable/EntityCollectionTableProps.tsx +3 -3
- package/src/components/EntityCollectionTable/{internal/PropertyTableCell.tsx → PropertyTableCell.tsx} +19 -18
- package/src/components/EntityCollectionTable/SimpleEntityCollectionTable.tsx +369 -0
- package/src/components/EntityCollectionTable/column_utils.tsx +74 -0
- package/src/components/EntityCollectionTable/index.tsx +4 -0
- package/src/components/EntityCollectionTable/internal/CollectionTableToolbar.tsx +3 -3
- package/src/components/EntityCollectionTable/internal/EntityTableCell.tsx +1 -2
- package/src/components/EntityCollectionTable/internal/default_entity_actions.tsx +1 -1
- package/src/components/EntityCollectionTable/internal/popup_field/PopupFormField.tsx +18 -18
- package/src/components/EntityCollectionTable/types.tsx +2 -2
- package/src/components/EntityCollectionTable/useDataSourceEntityCollectionTableController.tsx +3 -3
- package/src/components/EntityCollectionView/EntityCollectionView.tsx +4 -4
- package/src/components/EntityCollectionView/EntityCollectionViewActions.tsx +2 -2
- package/src/components/ReferenceSelectionInner.tsx +1 -1
- package/src/components/VirtualTable/VirtualTableCell.tsx +9 -13
- package/src/components/VirtualTable/VirtualTableProps.tsx +3 -4
- package/src/components/VirtualTable/VirtualTableRow.tsx +0 -1
- package/src/components/VirtualTable/types.tsx +1 -1
- package/src/core/EntitySidePanel.tsx +0 -1
- package/src/core/FireCMS.tsx +2 -2
- package/src/form/EntityForm.tsx +7 -8
- package/src/form/PropertyFieldBinding.tsx +3 -1
- package/src/form/components/FieldHelperText.tsx +2 -2
- package/src/form/field_bindings/DateTimeFieldBinding.tsx +2 -1
- package/src/form/field_bindings/MapFieldBinding.tsx +3 -9
- 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 +27 -15
- package/src/preview/components/BooleanPreview.tsx +1 -1
- package/src/preview/property_previews/MapPropertyPreview.tsx +3 -1
- package/src/preview/property_previews/StringPropertyPreview.tsx +1 -2
- package/src/types/collections.ts +2 -2
- package/src/types/plugins.tsx +4 -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,25 @@ 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
|
+
|
|
153
|
+
const newPath = props.entityId
|
|
154
|
+
? navigation.buildUrlCollectionPath(`${collectionPath}/${props.entityId}/${props.selectedSubPath || ""}`)
|
|
155
|
+
: navigation.buildUrlCollectionPath(`${collectionPath}#${NEW_URL_HASH}`);
|
|
156
|
+
const resolvedPath = navigation.resolveAliasesFrom(props.path);
|
|
157
|
+
|
|
158
|
+
const resolvedPanelProps: EntitySidePanelProps<any> = {
|
|
159
|
+
...props,
|
|
160
|
+
path: resolvedPath
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
return ({
|
|
164
|
+
key: `${props.path}/${props.entityId}`,
|
|
165
|
+
component: <EntitySidePanel {...resolvedPanelProps}/>,
|
|
166
|
+
urlPath: newPath,
|
|
167
|
+
parentUrlPath: navigation.buildUrlCollectionPath(collectionPath),
|
|
168
|
+
width: getEntityViewWidth(props, smallLayout),
|
|
169
|
+
onClose: props.onClose
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
;
|
|
@@ -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/types/collections.ts
CHANGED
|
@@ -317,7 +317,7 @@ export interface CollectionActionsProps<M extends Record<string, any> = any, Use
|
|
|
317
317
|
* Use this controller to get the table controller and to update the
|
|
318
318
|
* table controller state.
|
|
319
319
|
*/
|
|
320
|
-
tableController:
|
|
320
|
+
tableController: EntityTableController<M>;
|
|
321
321
|
|
|
322
322
|
/**
|
|
323
323
|
* Context of the app status
|
|
@@ -497,7 +497,7 @@ export type DefaultSelectedViewParams = {
|
|
|
497
497
|
/**
|
|
498
498
|
* You can use this controller to control the table view of a collection.
|
|
499
499
|
*/
|
|
500
|
-
export type
|
|
500
|
+
export type EntityTableController<M extends Record<string, any> = any> = {
|
|
501
501
|
data: Entity<M>[];
|
|
502
502
|
dataLoading: boolean;
|
|
503
503
|
noMoreToLoad: boolean;
|
package/src/types/plugins.tsx
CHANGED
|
@@ -125,13 +125,15 @@ export type FireCMSPlugin<PROPS = any, FORM_PROPS = any, EC extends EntityCollec
|
|
|
125
125
|
showTextSearchBar?: (props: {
|
|
126
126
|
context: FireCMSContext,
|
|
127
127
|
path: string,
|
|
128
|
-
collection: EC
|
|
128
|
+
collection: EC,
|
|
129
|
+
parentCollectionIds?: string[]
|
|
129
130
|
}) => boolean;
|
|
130
131
|
|
|
131
132
|
onTextSearchClick?: (props: {
|
|
132
133
|
context: FireCMSContext,
|
|
133
134
|
path: string,
|
|
134
|
-
collection: EC
|
|
135
|
+
collection: EC,
|
|
136
|
+
parentCollectionIds?: string[]
|
|
135
137
|
}) => Promise<boolean>;
|
|
136
138
|
|
|
137
139
|
/**
|
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
|
-
}
|