@firecms/core 3.0.0-canary.139 → 3.0.0-canary.140
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/ArrayContainer.d.ts +3 -3
- package/dist/form/PropertyFieldBinding.d.ts +1 -1
- package/dist/index.es.js +17 -14
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +17 -14
- package/dist/index.umd.js.map +1 -1
- package/package.json +5 -5
- package/src/components/ArrayContainer.tsx +4 -5
- package/src/core/EntityEditView.tsx +29 -32
- package/src/form/PropertyFieldBinding.tsx +3 -1
- package/src/form/field_bindings/ArrayCustomShapedFieldBinding.tsx +3 -2
- package/src/form/field_bindings/BlockFieldBinding.tsx +17 -16
- package/src/form/field_bindings/MapFieldBinding.tsx +4 -3
- package/src/hooks/data/save.ts +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.140",
|
|
5
5
|
"description": "Awesome Firebase/Firestore-based headless open-source CMS",
|
|
6
6
|
"funding": {
|
|
7
7
|
"url": "https://github.com/sponsors/firecmsco"
|
|
@@ -46,9 +46,9 @@
|
|
|
46
46
|
"./package.json": "./package.json"
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"@firecms/editor": "^3.0.0-canary.
|
|
50
|
-
"@firecms/formex": "^3.0.0-canary.
|
|
51
|
-
"@firecms/ui": "^3.0.0-canary.
|
|
49
|
+
"@firecms/editor": "^3.0.0-canary.140",
|
|
50
|
+
"@firecms/formex": "^3.0.0-canary.140",
|
|
51
|
+
"@firecms/ui": "^3.0.0-canary.140",
|
|
52
52
|
"@hello-pangea/dnd": "^17.0.0",
|
|
53
53
|
"@radix-ui/react-portal": "^1.1.2",
|
|
54
54
|
"clsx": "^2.1.1",
|
|
@@ -100,7 +100,7 @@
|
|
|
100
100
|
"dist",
|
|
101
101
|
"src"
|
|
102
102
|
],
|
|
103
|
-
"gitHead": "
|
|
103
|
+
"gitHead": "112132e315d1ae63babf9f53500c00bc37a2d8e4",
|
|
104
104
|
"publishConfig": {
|
|
105
105
|
"access": "public"
|
|
106
106
|
},
|
|
@@ -7,7 +7,6 @@ import {
|
|
|
7
7
|
AddIcon,
|
|
8
8
|
Button,
|
|
9
9
|
ContentCopyIcon,
|
|
10
|
-
fieldBackgroundHoverMixin,
|
|
11
10
|
HandleIcon,
|
|
12
11
|
IconButton,
|
|
13
12
|
Menu,
|
|
@@ -17,11 +16,11 @@ import {
|
|
|
17
16
|
useOutsideAlerter
|
|
18
17
|
} from "@firecms/ui";
|
|
19
18
|
|
|
20
|
-
interface ArrayContainerProps<T> {
|
|
19
|
+
export interface ArrayContainerProps<T> {
|
|
21
20
|
droppableId: string;
|
|
22
21
|
value: T[];
|
|
23
22
|
addLabel: string;
|
|
24
|
-
buildEntry: (index: number, internalId: number) => React.ReactNode;
|
|
23
|
+
buildEntry: (index: number, internalId: number, isDragging:boolean) => React.ReactNode;
|
|
25
24
|
disabled?: boolean;
|
|
26
25
|
size?: "small" | "medium";
|
|
27
26
|
onInternalIdAdded?: (id: number) => void;
|
|
@@ -209,7 +208,7 @@ type ArrayContainerItemProps = {
|
|
|
209
208
|
internalId: number,
|
|
210
209
|
size?: "small" | "medium",
|
|
211
210
|
disabled: boolean,
|
|
212
|
-
buildEntry: (index: number, internalId: number) => React.ReactNode,
|
|
211
|
+
buildEntry: (index: number, internalId: number, isDragging: boolean) => React.ReactNode,
|
|
213
212
|
remove: (index: number) => void,
|
|
214
213
|
copy: (index: number) => void,
|
|
215
214
|
isDragging: boolean,
|
|
@@ -246,7 +245,7 @@ export function ArrayContainerItem({
|
|
|
246
245
|
className="flex items-start">
|
|
247
246
|
<div
|
|
248
247
|
className="flex-grow w-[calc(100%-48px)] text-text-primary dark:text-text-primary-dark">
|
|
249
|
-
{buildEntry(index, internalId)}
|
|
248
|
+
{buildEntry(index, internalId, isDragging)}
|
|
250
249
|
</div>
|
|
251
250
|
<ArrayItemOptions direction={size === "small" ? "row" : "column"}
|
|
252
251
|
disabled={disabled}
|
|
@@ -892,45 +892,42 @@ export function EntityEditViewInner<M extends Record<string, any>>({
|
|
|
892
892
|
{pluginActions}
|
|
893
893
|
</div>}
|
|
894
894
|
|
|
895
|
-
<div className="
|
|
895
|
+
<div className="pt-12 pb-16 pl-4 sm:px-8 md:px-10">
|
|
896
|
+
<div
|
|
897
|
+
className={`w-full py-2 flex flex-col items-start mt-${4 + (pluginActions ? 8 : 0)} lg:mt-${8 + (pluginActions ? 8 : 0)} mb-8`}>
|
|
896
898
|
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
<Alert color={"base"} className={"w-full"} size={"small"}>
|
|
906
|
-
<code className={"text-xs select-all"}>{path}/{entityId}</code>
|
|
907
|
-
</Alert>
|
|
908
|
-
</div>
|
|
899
|
+
<Typography
|
|
900
|
+
className={"mt-4 flex-grow line-clamp-1 " + inputCollection.hideIdFromForm ? "mb-2" : "mb-0"}
|
|
901
|
+
variant={"h4"}>{title ?? inputCollection.singularName ?? inputCollection.name}
|
|
902
|
+
</Typography>
|
|
903
|
+
<Alert color={"base"} className={"w-full"} size={"small"}>
|
|
904
|
+
<code className={"text-xs select-all"}>{path}/{entityId}</code>
|
|
905
|
+
</Alert>
|
|
906
|
+
</div>
|
|
909
907
|
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
908
|
+
{!collection.hideIdFromForm &&
|
|
909
|
+
<CustomIdField customId={inputCollection.customId}
|
|
910
|
+
entityId={entityId}
|
|
911
|
+
status={status}
|
|
912
|
+
onChange={setEntityId}
|
|
913
|
+
error={entityIdError}
|
|
914
|
+
loading={customIdLoading}
|
|
915
|
+
entity={entity}/>}
|
|
918
916
|
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
917
|
+
{entityId && formContext && <>
|
|
918
|
+
<div className="mt-12 flex flex-col gap-8"
|
|
919
|
+
ref={formRef}>
|
|
922
920
|
|
|
923
|
-
|
|
921
|
+
{formFields}
|
|
924
922
|
|
|
925
|
-
|
|
923
|
+
<ErrorFocus containerRef={formRef}/>
|
|
926
924
|
|
|
927
|
-
|
|
925
|
+
</div>
|
|
928
926
|
|
|
929
|
-
|
|
927
|
+
<div className="h-14"/>
|
|
930
928
|
|
|
931
|
-
|
|
929
|
+
</>}
|
|
932
930
|
|
|
933
|
-
</div>
|
|
934
931
|
</div>
|
|
935
932
|
</>;
|
|
936
933
|
|
|
@@ -1004,10 +1001,10 @@ export function EntityEditViewInner<M extends Record<string, any>>({
|
|
|
1004
1001
|
return (
|
|
1005
1002
|
<Formex value={formex}>
|
|
1006
1003
|
|
|
1007
|
-
<div className="flex flex-col h-full w-full
|
|
1004
|
+
<div className="flex flex-col h-full w-full">
|
|
1008
1005
|
|
|
1009
1006
|
<div
|
|
1010
|
-
className={cls(defaultBorderMixin, "no-scrollbar border-b pl-2 pr-2 pt-1 flex items-end overflow-scroll bg-gray-50 dark:bg-gray-950")}>
|
|
1007
|
+
className={cls(defaultBorderMixin, "no-scrollbar h-16 border-b pl-2 pr-2 pt-1 flex items-end overflow-scroll bg-gray-50 dark:bg-gray-950")}>
|
|
1011
1008
|
|
|
1012
1009
|
<div
|
|
1013
1010
|
className="pb-1 self-center">
|
|
@@ -81,7 +81,7 @@ function PropertyFieldBindingInternal<T extends CMSType = CMSType, M extends Rec
|
|
|
81
81
|
context,
|
|
82
82
|
includeDescription,
|
|
83
83
|
underlyingValueHasChanged,
|
|
84
|
-
disabled,
|
|
84
|
+
disabled: disabledProp,
|
|
85
85
|
partOfArray,
|
|
86
86
|
minimalistView,
|
|
87
87
|
autoFocus,
|
|
@@ -109,6 +109,8 @@ function PropertyFieldBindingInternal<T extends CMSType = CMSType, M extends Rec
|
|
|
109
109
|
index
|
|
110
110
|
});
|
|
111
111
|
|
|
112
|
+
const disabled = disabledProp || isReadOnly(resolvedProperty) || Boolean(resolvedProperty?.disabled);
|
|
113
|
+
|
|
112
114
|
if (resolvedProperty === null || isHidden(resolvedProperty)) {
|
|
113
115
|
return <></>;
|
|
114
116
|
} else if (isReadOnly(resolvedProperty)) {
|
|
@@ -3,7 +3,7 @@ import { FieldProps } from "../../types";
|
|
|
3
3
|
import { FieldHelperText, LabelWithIconAndTooltip } from "../components";
|
|
4
4
|
import { PropertyFieldBinding } from "../PropertyFieldBinding";
|
|
5
5
|
import { ExpandablePanel, Typography } from "@firecms/ui";
|
|
6
|
-
import { getArrayResolvedProperties, getIconForProperty } from "../../util";
|
|
6
|
+
import { getArrayResolvedProperties, getIconForProperty, isReadOnly } from "../../util";
|
|
7
7
|
import { useClearRestoreValue } from "../useClearRestoreValue";
|
|
8
8
|
|
|
9
9
|
/**
|
|
@@ -57,9 +57,10 @@ export function ArrayCustomShapedFieldBinding<T extends Array<any>>({
|
|
|
57
57
|
</>);
|
|
58
58
|
|
|
59
59
|
const body = resolvedProperties.map((childProperty, index) => {
|
|
60
|
+
const thisDisabled = isReadOnly(childProperty) || Boolean(childProperty.disabled);
|
|
60
61
|
const fieldProps = {
|
|
61
62
|
propertyKey: `${propertyKey}[${index}]`,
|
|
62
|
-
disabled,
|
|
63
|
+
disabled: disabled || thisDisabled,
|
|
63
64
|
property: childProperty,
|
|
64
65
|
includeDescription,
|
|
65
66
|
underlyingValueHasChanged,
|
|
@@ -2,7 +2,7 @@ import React, { useCallback, useEffect, useState } from "react";
|
|
|
2
2
|
|
|
3
3
|
import { Field, useFormex } from "@firecms/formex";
|
|
4
4
|
|
|
5
|
-
import { FieldHelperText,
|
|
5
|
+
import { FieldHelperText, LabelWithIconAndTooltip } from "../components";
|
|
6
6
|
import { PropertyFieldBinding } from "../PropertyFieldBinding";
|
|
7
7
|
import { EnumValuesChip } from "../../preview";
|
|
8
8
|
import { FieldProps, FormContext, PropertyFieldBindingProps, PropertyOrBuilder } from "../../types";
|
|
@@ -10,6 +10,7 @@ import { getDefaultValueFor, getIconForProperty, } from "../../util";
|
|
|
10
10
|
import { DEFAULT_ONE_OF_TYPE, DEFAULT_ONE_OF_VALUE } from "../../util/common";
|
|
11
11
|
import { cls, ExpandablePanel, paperMixin, Select, SelectItem, Typography } from "@firecms/ui";
|
|
12
12
|
import { useClearRestoreValue } from "../useClearRestoreValue";
|
|
13
|
+
import { ArrayContainer } from "../../components";
|
|
13
14
|
|
|
14
15
|
/**
|
|
15
16
|
* If the `oneOf` property is specified, this fields render each array entry as
|
|
@@ -47,9 +48,9 @@ export function BlockFieldBinding<T extends Array<any>>({
|
|
|
47
48
|
|
|
48
49
|
const [lastAddedId, setLastAddedId] = useState<number | undefined>();
|
|
49
50
|
|
|
50
|
-
const buildEntry = useCallback((index: number, internalId: number) => {
|
|
51
|
+
const buildEntry = useCallback((index: number, internalId: number, isDragging:boolean) => {
|
|
51
52
|
return <BlockEntry
|
|
52
|
-
key={`array_one_of_${
|
|
53
|
+
key={`array_one_of_${internalId}`}
|
|
53
54
|
name={`${propertyKey}.${index}`}
|
|
54
55
|
index={index}
|
|
55
56
|
value={value[index]}
|
|
@@ -70,19 +71,19 @@ export function BlockFieldBinding<T extends Array<any>>({
|
|
|
70
71
|
);
|
|
71
72
|
|
|
72
73
|
const firstOneOfKey = Object.keys(property.oneOf.properties)[0];
|
|
73
|
-
const body = <
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
74
|
+
const body = <ArrayContainer value={value}
|
|
75
|
+
className={"flex flex-col gap-3"}
|
|
76
|
+
droppableId={propertyKey}
|
|
77
|
+
addLabel={property.name ? "Add entry to " + property.name : "Add entry"}
|
|
78
|
+
buildEntry={buildEntry}
|
|
79
|
+
onInternalIdAdded={setLastAddedId}
|
|
80
|
+
disabled={isSubmitting || Boolean(property.disabled)}
|
|
81
|
+
includeAddButton={!property.disabled}
|
|
82
|
+
onValueChange={(value) => setFieldValue(propertyKey, value)}
|
|
83
|
+
newDefaultEntry={{
|
|
84
|
+
[property.oneOf!.typeField ?? DEFAULT_ONE_OF_TYPE]: firstOneOfKey,
|
|
85
|
+
[property.oneOf!.valueField ?? DEFAULT_ONE_OF_VALUE]: getDefaultValueFor(property.oneOf.properties[firstOneOfKey])
|
|
86
|
+
}}/>;
|
|
86
87
|
return (
|
|
87
88
|
|
|
88
89
|
<>
|
|
@@ -2,7 +2,7 @@ import React from "react";
|
|
|
2
2
|
import { FieldProps, Properties, ResolvedProperties } from "../../types";
|
|
3
3
|
|
|
4
4
|
import { ErrorBoundary } from "../../components";
|
|
5
|
-
import { getIconForProperty, isHidden, pick } from "../../util";
|
|
5
|
+
import { getIconForProperty, isHidden, isReadOnly, pick } from "../../util";
|
|
6
6
|
import { FieldHelperText, LabelWithIconAndTooltip } from "../components";
|
|
7
7
|
import { PropertyFieldBinding } from "../PropertyFieldBinding";
|
|
8
8
|
import { ExpandablePanel, InputLabel, Select, SelectItem } from "@firecms/ui";
|
|
@@ -54,9 +54,10 @@ export function MapFieldBinding({
|
|
|
54
54
|
{Object.entries(mapProperties)
|
|
55
55
|
.filter(([_, property]) => !isHidden(property))
|
|
56
56
|
.map(([entryKey, childProperty], index) => {
|
|
57
|
-
|
|
57
|
+
const thisDisabled = isReadOnly(childProperty) || Boolean(childProperty.disabled);
|
|
58
|
+
const fieldBindingProps = {
|
|
58
59
|
propertyKey: `${propertyKey}.${entryKey}`,
|
|
59
|
-
disabled,
|
|
60
|
+
disabled: disabled || thisDisabled,
|
|
60
61
|
property: childProperty,
|
|
61
62
|
includeDescription,
|
|
62
63
|
underlyingValueHasChanged,
|
package/src/hooks/data/save.ts
CHANGED