@firecms/core 3.0.0-canary.90 → 3.0.0-canary.92
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/common/useColumnsIds.d.ts +2 -1
- package/dist/index.es.js +79 -38
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +78 -37
- package/dist/index.umd.js.map +1 -1
- package/package.json +4 -4
- package/src/components/common/useColumnsIds.tsx +13 -0
- package/src/core/EntityEditView.tsx +74 -45
- package/src/hooks/useBuildNavigationController.tsx +1 -1
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.
|
|
4
|
+
"version": "3.0.0-canary.92",
|
|
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.
|
|
50
|
-
"@firecms/ui": "^3.0.0-canary.
|
|
49
|
+
"@firecms/formex": "^3.0.0-canary.92",
|
|
50
|
+
"@firecms/ui": "^3.0.0-canary.92",
|
|
51
51
|
"@fontsource/jetbrains-mono": "^5.0.20",
|
|
52
52
|
"@hello-pangea/dnd": "^16.6.0",
|
|
53
53
|
"@radix-ui/react-portal": "^1.1.1",
|
|
@@ -102,7 +102,7 @@
|
|
|
102
102
|
"dist",
|
|
103
103
|
"src"
|
|
104
104
|
],
|
|
105
|
-
"gitHead": "
|
|
105
|
+
"gitHead": "9c6fcb4a58bcb8118ad47f6ab8c77536f7efc3ed",
|
|
106
106
|
"publishConfig": {
|
|
107
107
|
"access": "public"
|
|
108
108
|
},
|
|
@@ -106,3 +106,16 @@ export function getColumnKeysForProperty(property: ResolvedProperty, key: string
|
|
|
106
106
|
disabled: disabled || Boolean(property.disabled) || Boolean(property.readOnly)
|
|
107
107
|
}];
|
|
108
108
|
}
|
|
109
|
+
|
|
110
|
+
export function getFormFieldKeys(collection: EntityCollection): string[] {
|
|
111
|
+
const propertyKeys = Object.keys(collection.properties);
|
|
112
|
+
const additionalFields = collection.additionalFields ?? [];
|
|
113
|
+
const allKeys = [
|
|
114
|
+
...propertyKeys,
|
|
115
|
+
...additionalFields.map((field) => field.key)
|
|
116
|
+
];
|
|
117
|
+
if (collection.propertiesOrder) {
|
|
118
|
+
return collection.propertiesOrder.filter(key => allKeys.includes(key));
|
|
119
|
+
}
|
|
120
|
+
return allKeys;
|
|
121
|
+
}
|
|
@@ -23,6 +23,7 @@ import {
|
|
|
23
23
|
EntityCollectionView,
|
|
24
24
|
EntityView,
|
|
25
25
|
ErrorBoundary,
|
|
26
|
+
getFormFieldKeys,
|
|
26
27
|
} from "../components";
|
|
27
28
|
import {
|
|
28
29
|
canCreateEntity,
|
|
@@ -59,6 +60,8 @@ import {
|
|
|
59
60
|
defaultBorderMixin,
|
|
60
61
|
DialogActions,
|
|
61
62
|
IconButton,
|
|
63
|
+
NotesIcon,
|
|
64
|
+
paperMixin,
|
|
62
65
|
Tab,
|
|
63
66
|
Tabs,
|
|
64
67
|
Tooltip,
|
|
@@ -71,7 +74,7 @@ import { CustomIdField } from "../form/components/CustomIdField";
|
|
|
71
74
|
import { CustomFieldValidator, getYupEntitySchema } from "../form/validation";
|
|
72
75
|
import { ErrorFocus } from "../form/components/ErrorFocus";
|
|
73
76
|
import { PropertyIdCopyTooltipContent } from "../components/PropertyIdCopyTooltipContent";
|
|
74
|
-
import { PropertyFieldBinding } from "../form";
|
|
77
|
+
import { LabelWithIcon, PropertyFieldBinding } from "../form";
|
|
75
78
|
import { ValidationError } from "yup";
|
|
76
79
|
|
|
77
80
|
const MAIN_TAB_VALUE = "main_##Q$SC^#S6";
|
|
@@ -580,11 +583,6 @@ export function EntityEditViewInner<M extends Record<string, any>>({
|
|
|
580
583
|
});
|
|
581
584
|
};
|
|
582
585
|
|
|
583
|
-
// const onValuesChanged = useCallback((values?: EntityValues<M>) => {
|
|
584
|
-
// modifiedValuesRef.current = values;
|
|
585
|
-
// }, []);
|
|
586
|
-
|
|
587
|
-
// eslint-disable-next-line n/handle-callback-err
|
|
588
586
|
const onIdUpdateError = useCallback((error: any) => {
|
|
589
587
|
snackbarController.open({
|
|
590
588
|
type: "error",
|
|
@@ -739,50 +737,81 @@ export function EntityEditViewInner<M extends Record<string, any>>({
|
|
|
739
737
|
|
|
740
738
|
const formFields = (
|
|
741
739
|
<>
|
|
742
|
-
{(
|
|
740
|
+
{(getFormFieldKeys(resolvedCollection))
|
|
743
741
|
.map((key) => {
|
|
744
742
|
|
|
745
743
|
const property = resolvedCollection.properties[key];
|
|
746
|
-
if (
|
|
747
|
-
|
|
748
|
-
|
|
744
|
+
if (property) {
|
|
745
|
+
|
|
746
|
+
const underlyingValueHasChanged: boolean =
|
|
747
|
+
!!underlyingChanges &&
|
|
748
|
+
Object.keys(underlyingChanges).includes(key) &&
|
|
749
|
+
!!formex.touched[key];
|
|
750
|
+
|
|
751
|
+
const disabled = (!autoSave && formex.isSubmitting) || isReadOnly(property) || Boolean(property.disabled);
|
|
752
|
+
const hidden = isHidden(property);
|
|
753
|
+
if (hidden) return null;
|
|
754
|
+
const cmsFormFieldProps: PropertyFieldBindingProps<any, M> = {
|
|
755
|
+
propertyKey: key,
|
|
756
|
+
disabled,
|
|
757
|
+
property,
|
|
758
|
+
includeDescription: property.description || property.longDescription,
|
|
759
|
+
underlyingValueHasChanged: underlyingValueHasChanged && !autoSave,
|
|
760
|
+
context: formContext,
|
|
761
|
+
tableMode: false,
|
|
762
|
+
partOfArray: false,
|
|
763
|
+
partOfBlock: false,
|
|
764
|
+
autoFocus: false
|
|
765
|
+
};
|
|
766
|
+
|
|
767
|
+
return (
|
|
768
|
+
<div id={`form_field_${key}`}
|
|
769
|
+
key={`field_${resolvedCollection.name}_${key}`}>
|
|
770
|
+
<ErrorBoundary>
|
|
771
|
+
<Tooltip title={<PropertyIdCopyTooltipContent propertyId={key}/>}
|
|
772
|
+
delayDuration={800}
|
|
773
|
+
side={"left"}
|
|
774
|
+
align={"start"}
|
|
775
|
+
sideOffset={16}>
|
|
776
|
+
<PropertyFieldBinding {...cmsFormFieldProps}/>
|
|
777
|
+
</Tooltip>
|
|
778
|
+
</ErrorBoundary>
|
|
779
|
+
</div>
|
|
780
|
+
);
|
|
749
781
|
}
|
|
750
782
|
|
|
751
|
-
const
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
</ErrorBoundary>
|
|
784
|
-
</div>
|
|
785
|
-
);
|
|
783
|
+
const additionalField = resolvedCollection.additionalFields?.find(f => f.key === key);
|
|
784
|
+
if (additionalField && entity) {
|
|
785
|
+
const Builder = additionalField.Builder;
|
|
786
|
+
if (!Builder && !additionalField.value) {
|
|
787
|
+
throw new Error("When using additional fields you need to provide a Builder or a value");
|
|
788
|
+
}
|
|
789
|
+
|
|
790
|
+
const child = Builder
|
|
791
|
+
? <Builder entity={entity} context={context}/>
|
|
792
|
+
: <>{additionalField.value?.({
|
|
793
|
+
entity,
|
|
794
|
+
context
|
|
795
|
+
})}</>;
|
|
796
|
+
return (
|
|
797
|
+
<div>
|
|
798
|
+
<LabelWithIcon icon={<NotesIcon size={"small"}/>}
|
|
799
|
+
title={additionalField.name}
|
|
800
|
+
className={"text-text-secondary dark:text-text-secondary-dark ml-3.5"}/>
|
|
801
|
+
<div
|
|
802
|
+
className={cls(paperMixin, "min-h-14 p-4 md:p-6 overflow-x-scroll no-scrollbar")}>
|
|
803
|
+
|
|
804
|
+
<ErrorBoundary>
|
|
805
|
+
{child}
|
|
806
|
+
</ErrorBoundary>
|
|
807
|
+
|
|
808
|
+
</div>
|
|
809
|
+
</div>
|
|
810
|
+
);
|
|
811
|
+
}
|
|
812
|
+
|
|
813
|
+
console.warn(`Property ${key} not found in collection ${resolvedCollection.name} in properties or additional fields. Skipping.`);
|
|
814
|
+
return null;
|
|
786
815
|
})
|
|
787
816
|
.filter(Boolean)}
|
|
788
817
|
|
|
@@ -199,7 +199,7 @@ export function useBuildNavigationController<EC extends EntityCollection, UserTy
|
|
|
199
199
|
);
|
|
200
200
|
|
|
201
201
|
let shouldUpdateTopLevelNav = false;
|
|
202
|
-
if (!areCollectionListsEqual(collectionsRef.current ?? [], resolvedCollections)) {
|
|
202
|
+
if (!areCollectionListsEqual(collectionsRef.current ?? [], resolvedCollections) || resolvedCollections.length === 0) {
|
|
203
203
|
collectionsRef.current = resolvedCollections;
|
|
204
204
|
shouldUpdateTopLevelNav = true;
|
|
205
205
|
}
|