@firecms/core 3.0.0-canary.71 → 3.0.0-canary.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 +498 -477
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +5 -5
- package/dist/index.umd.js.map +1 -1
- package/dist/types/properties.d.ts +1 -1
- package/package.json +4 -4
- package/src/form/field_bindings/ArrayCustomShapedFieldBinding.tsx +8 -5
- package/src/form/field_bindings/ArrayOfReferencesFieldBinding.tsx +5 -4
- package/src/form/field_bindings/RepeatFieldBinding.tsx +10 -7
- package/src/types/properties.ts +1 -1
- package/src/util/entities.ts +1 -1
|
@@ -97,7 +97,7 @@ export interface BaseProperty<T extends CMSType, CustomProps = any> {
|
|
|
97
97
|
/**
|
|
98
98
|
* This value will be set by default for new entities.
|
|
99
99
|
*/
|
|
100
|
-
defaultValue?: T;
|
|
100
|
+
defaultValue?: T | null;
|
|
101
101
|
/**
|
|
102
102
|
* Should this property be editable. If set to true, the user will be able to modify the property and
|
|
103
103
|
* save the new config. The saved config will then become the source of truth.
|
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.73",
|
|
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.73",
|
|
50
|
+
"@firecms/ui": "^3.0.0-canary.73",
|
|
51
51
|
"@fontsource/jetbrains-mono": "^5.0.20",
|
|
52
52
|
"@hello-pangea/dnd": "^16.6.0",
|
|
53
53
|
"@radix-ui/react-portal": "^1.0.4",
|
|
@@ -111,7 +111,7 @@
|
|
|
111
111
|
"dist",
|
|
112
112
|
"src"
|
|
113
113
|
],
|
|
114
|
-
"gitHead": "
|
|
114
|
+
"gitHead": "3d43eb099c5584b289cb3189c25ac3c7cbb286f1",
|
|
115
115
|
"publishConfig": {
|
|
116
116
|
"access": "public"
|
|
117
117
|
},
|
|
@@ -2,7 +2,7 @@ import React from "react";
|
|
|
2
2
|
import { FieldProps } from "../../types";
|
|
3
3
|
import { FieldHelperText, LabelWithIcon } from "../components";
|
|
4
4
|
import { PropertyFieldBinding } from "../PropertyFieldBinding";
|
|
5
|
-
import { ExpandablePanel } from "@firecms/ui";
|
|
5
|
+
import { ExpandablePanel, Typography } from "@firecms/ui";
|
|
6
6
|
import { getIconForProperty } from "../../util";
|
|
7
7
|
import { useClearRestoreValue } from "../useClearRestoreValue";
|
|
8
8
|
|
|
@@ -39,10 +39,13 @@ export function ArrayCustomShapedFieldBinding<T extends Array<any>>({
|
|
|
39
39
|
setValue
|
|
40
40
|
});
|
|
41
41
|
|
|
42
|
-
const title =
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
42
|
+
const title = (<>
|
|
43
|
+
<LabelWithIcon icon={getIconForProperty(property, "small")}
|
|
44
|
+
required={property.validation?.required}
|
|
45
|
+
title={property.name}
|
|
46
|
+
className={"flex-grow text-text-secondary dark:text-text-secondary-dark"}/>
|
|
47
|
+
{Array.isArray(value) && <Typography variant={"caption"} className={"px-4"}>({value.length})</Typography>}
|
|
48
|
+
</>);
|
|
46
49
|
|
|
47
50
|
const body = property.resolvedProperties.map((childProperty, index) => {
|
|
48
51
|
const fieldProps = {
|
|
@@ -6,7 +6,7 @@ import { ErrorView } from "../../components";
|
|
|
6
6
|
import { getIconForProperty, getReferenceFrom } from "../../util";
|
|
7
7
|
|
|
8
8
|
import { useNavigationController, useReferenceDialog } from "../../hooks";
|
|
9
|
-
import { Button, cls, ExpandablePanel, fieldBackgroundMixin } from "@firecms/ui";
|
|
9
|
+
import { Button, cls, ExpandablePanel, fieldBackgroundMixin, Typography } from "@firecms/ui";
|
|
10
10
|
import { useClearRestoreValue } from "../useClearRestoreValue";
|
|
11
11
|
|
|
12
12
|
type ArrayOfReferencesFieldProps = FieldProps<EntityReference[]>;
|
|
@@ -94,12 +94,13 @@ export function ArrayOfReferencesFieldBinding({
|
|
|
94
94
|
);
|
|
95
95
|
}, [ofProperty.path, ofProperty.previewProperties, value]);
|
|
96
96
|
|
|
97
|
-
const title = (
|
|
97
|
+
const title = (<>
|
|
98
98
|
<LabelWithIcon icon={getIconForProperty(property, "small")}
|
|
99
99
|
required={property.validation?.required}
|
|
100
100
|
title={property.name}
|
|
101
|
-
className={"text-text-secondary dark:text-text-secondary-dark"}/>
|
|
102
|
-
|
|
101
|
+
className={"flex-grow text-text-secondary dark:text-text-secondary-dark"}/>
|
|
102
|
+
{Array.isArray(value) && <Typography variant={"caption"} className={"px-4"}>({value.length})</Typography>}
|
|
103
|
+
</>);
|
|
103
104
|
|
|
104
105
|
const body = <>
|
|
105
106
|
{!collection && <ErrorView
|
|
@@ -2,9 +2,9 @@ import React, { useState } from "react";
|
|
|
2
2
|
import { CMSType, FieldProps, ResolvedProperty } from "../../types";
|
|
3
3
|
import { FieldHelperText, FormikArrayContainer, LabelWithIcon } from "../components";
|
|
4
4
|
import { ErrorBoundary } from "../../components";
|
|
5
|
-
import { getIconForProperty } from "../../util";
|
|
5
|
+
import { getDefaultValueFor, getIconForProperty } from "../../util";
|
|
6
6
|
import { PropertyFieldBinding } from "../PropertyFieldBinding";
|
|
7
|
-
import { ExpandablePanel } from "@firecms/ui";
|
|
7
|
+
import { ExpandablePanel, Typography } from "@firecms/ui";
|
|
8
8
|
import { useClearRestoreValue } from "../useClearRestoreValue";
|
|
9
9
|
|
|
10
10
|
/**
|
|
@@ -75,12 +75,15 @@ export function RepeatFieldBinding<T extends Array<any>>({
|
|
|
75
75
|
onInternalIdAdded={setLastAddedId}
|
|
76
76
|
disabled={isSubmitting || Boolean(property.disabled)}
|
|
77
77
|
includeAddButton={!property.disabled}
|
|
78
|
-
newDefaultEntry={property.of
|
|
78
|
+
newDefaultEntry={getDefaultValueFor(property.of)}/>;
|
|
79
79
|
|
|
80
|
-
const title = (
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
80
|
+
const title = (<>
|
|
81
|
+
<LabelWithIcon icon={getIconForProperty(property, "small")}
|
|
82
|
+
required={property.validation?.required}
|
|
83
|
+
title={property.name}
|
|
84
|
+
className={"flex-grow text-text-secondary dark:text-text-secondary-dark"}/>
|
|
85
|
+
{Array.isArray(value) && <Typography variant={"caption"} className={"px-4"}>({value.length})</Typography>}
|
|
86
|
+
</>);
|
|
84
87
|
|
|
85
88
|
return (
|
|
86
89
|
|
package/src/types/properties.ts
CHANGED
|
@@ -149,7 +149,7 @@ export interface BaseProperty<T extends CMSType, CustomProps = any> {
|
|
|
149
149
|
/**
|
|
150
150
|
* This value will be set by default for new entities.
|
|
151
151
|
*/
|
|
152
|
-
defaultValue?: T;
|
|
152
|
+
defaultValue?: T | null;
|
|
153
153
|
|
|
154
154
|
/**
|
|
155
155
|
* Should this property be editable. If set to true, the user will be able to modify the property and
|
package/src/util/entities.ts
CHANGED
|
@@ -52,7 +52,7 @@ export function getDefaultValueFor(property: PropertyOrBuilder) {
|
|
|
52
52
|
const defaultValuesFor = getDefaultValuesFor(property.properties as Properties);
|
|
53
53
|
if (Object.keys(defaultValuesFor).length === 0) return undefined;
|
|
54
54
|
return defaultValuesFor;
|
|
55
|
-
} else if (property.defaultValue) {
|
|
55
|
+
} else if (property.defaultValue || property.defaultValue === null) {
|
|
56
56
|
return property.defaultValue;
|
|
57
57
|
} else {
|
|
58
58
|
return getDefaultValueForDataType(property.dataType);
|