@firecms/core 3.0.0-canary.140 → 3.0.0-canary.142
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 +13 -3
- package/dist/components/EntityCollectionTable/internal/popup_field/PopupFormField.d.ts +6 -3
- package/dist/form/PropertyFieldBinding.d.ts +1 -1
- package/dist/form/components/index.d.ts +0 -1
- package/dist/form/field_bindings/MapFieldBinding.d.ts +1 -1
- package/dist/form/field_bindings/ReferenceFieldBinding.d.ts +2 -2
- package/dist/index.es.js +9433 -9358
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +9432 -9357
- package/dist/index.umd.js.map +1 -1
- package/dist/types/collections.d.ts +2 -1
- package/dist/types/fields.d.ts +16 -0
- package/dist/util/objects.d.ts +1 -0
- package/dist/util/property_utils.d.ts +2 -2
- package/package.json +14 -14
- package/src/components/ArrayContainer.tsx +36 -13
- package/src/components/EntityCollectionTable/PropertyTableCell.tsx +6 -4
- package/src/components/EntityCollectionTable/internal/popup_field/PopupFormField.tsx +66 -58
- package/src/components/EntityCollectionView/EntityCollectionView.tsx +2 -3
- package/src/form/PropertyFieldBinding.tsx +22 -17
- package/src/form/components/index.tsx +0 -1
- package/src/form/field_bindings/ArrayOfReferencesFieldBinding.tsx +16 -10
- package/src/form/field_bindings/BlockFieldBinding.tsx +24 -8
- package/src/form/field_bindings/KeyValueFieldBinding.tsx +4 -1
- package/src/form/field_bindings/MapFieldBinding.tsx +55 -39
- package/src/form/field_bindings/ReferenceFieldBinding.tsx +1 -1
- package/src/form/field_bindings/RepeatFieldBinding.tsx +25 -20
- package/src/hooks/data/save.ts +0 -1
- package/src/types/collections.ts +2 -1
- package/src/types/fields.tsx +18 -0
- package/src/util/objects.ts +20 -0
- package/src/util/property_utils.tsx +9 -2
- package/dist/form/components/FormikArrayContainer.d.ts +0 -19
- package/src/form/components/FormikArrayContainer.tsx +0 -47
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import React, { useCallback, useMemo } from "react";
|
|
2
2
|
import { Entity, EntityCollection, EntityReference, FieldProps, ResolvedProperty } from "../../types";
|
|
3
3
|
import { ReferencePreview } from "../../preview";
|
|
4
|
-
import { FieldHelperText,
|
|
5
|
-
import { ErrorView } from "../../components";
|
|
4
|
+
import { FieldHelperText, LabelWithIconAndTooltip } from "../components";
|
|
5
|
+
import { ArrayContainer, ArrayEntryParams, ErrorView } from "../../components";
|
|
6
6
|
import { getIconForProperty, getReferenceFrom } from "../../util";
|
|
7
7
|
|
|
8
8
|
import { useNavigationController, useReferenceDialog } from "../../hooks";
|
|
@@ -74,7 +74,12 @@ export function ArrayOfReferencesFieldBinding({
|
|
|
74
74
|
referenceDialogController.open();
|
|
75
75
|
};
|
|
76
76
|
|
|
77
|
-
const buildEntry = useCallback((
|
|
77
|
+
const buildEntry = useCallback(({
|
|
78
|
+
index,
|
|
79
|
+
internalId,
|
|
80
|
+
storedProps,
|
|
81
|
+
storeProps
|
|
82
|
+
}: ArrayEntryParams) => {
|
|
78
83
|
const entryValue = value && value.length > index ? value[index] : undefined;
|
|
79
84
|
if (!entryValue)
|
|
80
85
|
return <div>Internal ERROR</div>;
|
|
@@ -109,13 +114,14 @@ export function ArrayOfReferencesFieldBinding({
|
|
|
109
114
|
|
|
110
115
|
{collection && <div className={"group"}>
|
|
111
116
|
|
|
112
|
-
<
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
117
|
+
<ArrayContainer droppableId={propertyKey}
|
|
118
|
+
value={value}
|
|
119
|
+
disabled={isSubmitting}
|
|
120
|
+
buildEntry={buildEntry}
|
|
121
|
+
addLabel={property.name ? "Add reference to " + property.name : "Add reference"}
|
|
122
|
+
newDefaultEntry={property.of.defaultValue}
|
|
123
|
+
onValueChange={(value) => setFieldValue(propertyKey, value)}
|
|
124
|
+
/>
|
|
119
125
|
|
|
120
126
|
<Button
|
|
121
127
|
className="my-4 justify-center text-left"
|
|
@@ -6,11 +6,11 @@ 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";
|
|
9
|
-
import { getDefaultValueFor, getIconForProperty, } from "../../util";
|
|
9
|
+
import { getDefaultValueFor, getIconForProperty, mergeDeep, } 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
|
+
import { ArrayContainer, ArrayEntryParams } from "../../components";
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
16
|
* If the `oneOf` property is specified, this fields render each array entry as
|
|
@@ -48,7 +48,13 @@ export function BlockFieldBinding<T extends Array<any>>({
|
|
|
48
48
|
|
|
49
49
|
const [lastAddedId, setLastAddedId] = useState<number | undefined>();
|
|
50
50
|
|
|
51
|
-
const buildEntry =
|
|
51
|
+
const buildEntry = ({
|
|
52
|
+
index,
|
|
53
|
+
internalId,
|
|
54
|
+
storedProps,
|
|
55
|
+
storeProps
|
|
56
|
+
}: ArrayEntryParams) => {
|
|
57
|
+
|
|
52
58
|
return <BlockEntry
|
|
53
59
|
key={`array_one_of_${internalId}`}
|
|
54
60
|
name={`${propertyKey}.${index}`}
|
|
@@ -58,8 +64,10 @@ export function BlockFieldBinding<T extends Array<any>>({
|
|
|
58
64
|
valueField={property.oneOf!.valueField ?? DEFAULT_ONE_OF_VALUE}
|
|
59
65
|
properties={property.oneOf!.properties}
|
|
60
66
|
autoFocus={internalId === lastAddedId}
|
|
61
|
-
context={context}
|
|
62
|
-
|
|
67
|
+
context={context}
|
|
68
|
+
storeProps={storeProps}
|
|
69
|
+
storedProps={storedProps}/>;
|
|
70
|
+
};
|
|
63
71
|
|
|
64
72
|
const title = (
|
|
65
73
|
<LabelWithIconAndTooltip
|
|
@@ -135,6 +143,9 @@ interface BlockEntryProps {
|
|
|
135
143
|
*/
|
|
136
144
|
context: FormContext<any>;
|
|
137
145
|
|
|
146
|
+
storedProps?: object,
|
|
147
|
+
storeProps: (props: object) => void
|
|
148
|
+
|
|
138
149
|
}
|
|
139
150
|
|
|
140
151
|
function BlockEntry({
|
|
@@ -145,7 +156,9 @@ function BlockEntry({
|
|
|
145
156
|
valueField,
|
|
146
157
|
properties,
|
|
147
158
|
autoFocus,
|
|
148
|
-
context
|
|
159
|
+
context,
|
|
160
|
+
storedProps,
|
|
161
|
+
storeProps
|
|
149
162
|
}: BlockEntryProps) {
|
|
150
163
|
|
|
151
164
|
const type = value && value[typeField];
|
|
@@ -165,7 +178,9 @@ function BlockEntry({
|
|
|
165
178
|
}
|
|
166
179
|
}, [type]);
|
|
167
180
|
|
|
168
|
-
const
|
|
181
|
+
const propertyInternal = typeInternal ? properties[typeInternal] : undefined;
|
|
182
|
+
|
|
183
|
+
const property = storedProps && typeof propertyInternal === "object" ? mergeDeep(propertyInternal, storedProps) : propertyInternal;
|
|
169
184
|
|
|
170
185
|
const enumValuesConfigs = Object.entries(properties)
|
|
171
186
|
.map(([key, property]) => ({
|
|
@@ -183,7 +198,8 @@ function BlockEntry({
|
|
|
183
198
|
context,
|
|
184
199
|
autoFocus,
|
|
185
200
|
partOfArray: false,
|
|
186
|
-
minimalistView: true
|
|
201
|
+
minimalistView: true,
|
|
202
|
+
onPropertyChange: storeProps,
|
|
187
203
|
}
|
|
188
204
|
: undefined;
|
|
189
205
|
|
|
@@ -336,7 +336,10 @@ function MapKeyValueRow<T extends Record<string, any>>({
|
|
|
336
336
|
[fieldKey]: newValue
|
|
337
337
|
});
|
|
338
338
|
}}
|
|
339
|
-
buildEntry={(
|
|
339
|
+
buildEntry={({
|
|
340
|
+
index,
|
|
341
|
+
internalId
|
|
342
|
+
}) => {
|
|
340
343
|
return <ArrayKeyValueRow
|
|
341
344
|
index={index}
|
|
342
345
|
id={internalId}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { FieldProps, Properties, ResolvedProperties } from "../../types";
|
|
2
|
+
import { FieldProps, MapProperty, Properties, PropertyFieldBindingProps, ResolvedProperties } from "../../types";
|
|
3
3
|
|
|
4
4
|
import { ErrorBoundary } from "../../components";
|
|
5
5
|
import { getIconForProperty, isHidden, isReadOnly, pick } from "../../util";
|
|
@@ -25,11 +25,12 @@ export function MapFieldBinding({
|
|
|
25
25
|
includeDescription,
|
|
26
26
|
underlyingValueHasChanged,
|
|
27
27
|
autoFocus,
|
|
28
|
-
context
|
|
28
|
+
context,
|
|
29
|
+
onPropertyChange
|
|
29
30
|
}: FieldProps<Record<string, any>>) {
|
|
30
31
|
|
|
31
32
|
const pickOnlySomeKeys = property.pickOnlySomeKeys || false;
|
|
32
|
-
const expanded =
|
|
33
|
+
const expanded = property.expanded === undefined ? true : property.expanded;
|
|
33
34
|
|
|
34
35
|
if (!property.properties) {
|
|
35
36
|
throw Error(`You need to specify a 'properties' prop (or specify a custom field) in your map property ${propertyKey}`);
|
|
@@ -50,38 +51,48 @@ export function MapFieldBinding({
|
|
|
50
51
|
}
|
|
51
52
|
|
|
52
53
|
const mapFormView = <>
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
<
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
54
|
+
<div className="py-1 flex flex-col space-y-2">
|
|
55
|
+
{Object.entries(mapProperties)
|
|
56
|
+
.filter(([_, property]) => !isHidden(property))
|
|
57
|
+
.map(([entryKey, childProperty], index) => {
|
|
58
|
+
const thisDisabled = isReadOnly(childProperty) || Boolean(childProperty.disabled);
|
|
59
|
+
const fieldBindingProps: PropertyFieldBindingProps<any> = {
|
|
60
|
+
propertyKey: `${propertyKey}.${entryKey}`,
|
|
61
|
+
disabled: disabled || thisDisabled,
|
|
62
|
+
property: childProperty,
|
|
63
|
+
includeDescription,
|
|
64
|
+
underlyingValueHasChanged,
|
|
65
|
+
context,
|
|
66
|
+
partOfArray: false,
|
|
67
|
+
minimalistView: false,
|
|
68
|
+
autoFocus: autoFocus && index === 0,
|
|
69
|
+
onPropertyChange: function (updatedProperty) {
|
|
70
|
+
onPropertyChange?.({
|
|
71
|
+
properties: {
|
|
72
|
+
[entryKey]: updatedProperty
|
|
73
|
+
}
|
|
74
|
+
} as Partial<MapProperty>);
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
return (
|
|
79
|
+
<div key={`map-${propertyKey}-${index}`}>
|
|
80
|
+
<ErrorBoundary>
|
|
81
|
+
<PropertyFieldBinding
|
|
82
|
+
{...fieldBindingProps}/>
|
|
83
|
+
</ErrorBoundary>
|
|
84
|
+
</div>
|
|
85
|
+
)
|
|
86
|
+
;
|
|
87
|
+
}
|
|
88
|
+
)
|
|
89
|
+
}
|
|
90
|
+
</div>
|
|
91
|
+
|
|
92
|
+
{/*{pickOnlySomeKeys && buildPickKeysSelect(disabled, property.properties, setValue, value)}*/}
|
|
93
|
+
|
|
94
|
+
</>
|
|
95
|
+
;
|
|
85
96
|
|
|
86
97
|
const title = (
|
|
87
98
|
<LabelWithIconAndTooltip
|
|
@@ -95,11 +106,16 @@ export function MapFieldBinding({
|
|
|
95
106
|
return (
|
|
96
107
|
<ErrorBoundary>
|
|
97
108
|
|
|
98
|
-
{!minimalistView &&
|
|
99
|
-
|
|
100
|
-
|
|
109
|
+
{!minimalistView && <ExpandablePanel initiallyExpanded={expanded}
|
|
110
|
+
onExpandedChange={(expanded) => {
|
|
111
|
+
onPropertyChange?.({
|
|
112
|
+
expanded
|
|
113
|
+
});
|
|
114
|
+
}}
|
|
115
|
+
innerClassName={"px-2 md:px-4 pb-2 md:pb-4 pt-1 md:pt-2 bg-white dark:bg-gray-900"}
|
|
116
|
+
title={title}>{mapFormView}</ExpandablePanel>}
|
|
101
117
|
|
|
102
|
-
{
|
|
118
|
+
{minimalistView && mapFormView}
|
|
103
119
|
|
|
104
120
|
<FieldHelperText includeDescription={includeDescription}
|
|
105
121
|
showError={showError ?? false}
|
|
@@ -18,7 +18,7 @@ import { cls } from "@firecms/ui";
|
|
|
18
18
|
* and tables to the specified properties.
|
|
19
19
|
* @group Form fields
|
|
20
20
|
*/
|
|
21
|
-
export function ReferenceFieldBinding
|
|
21
|
+
export function ReferenceFieldBinding(props: FieldProps) {
|
|
22
22
|
|
|
23
23
|
if (typeof props.property.path !== "string") {
|
|
24
24
|
return <ReadOnlyFieldBinding {...props}/>
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import React, { useState } from "react";
|
|
2
|
-
import { CMSType, FieldProps, ResolvedProperty } from "../../types";
|
|
3
|
-
import { FieldHelperText,
|
|
4
|
-
import { ErrorBoundary } from "../../components";
|
|
5
|
-
import { getArrayResolvedProperties, getDefaultValueFor, getIconForProperty } from "../../util";
|
|
2
|
+
import { CMSType, FieldProps, PropertyFieldBindingProps, ResolvedProperty } from "../../types";
|
|
3
|
+
import { FieldHelperText, LabelWithIconAndTooltip } from "../components";
|
|
4
|
+
import { ArrayContainer, ArrayEntryParams, ErrorBoundary } from "../../components";
|
|
5
|
+
import { getArrayResolvedProperties, getDefaultValueFor, getIconForProperty, mergeDeep } from "../../util";
|
|
6
6
|
import { PropertyFieldBinding } from "../PropertyFieldBinding";
|
|
7
7
|
import { ExpandablePanel, Typography } from "@firecms/ui";
|
|
8
8
|
import { useClearRestoreValue } from "../useClearRestoreValue";
|
|
@@ -43,8 +43,6 @@ export function RepeatFieldBinding<T extends Array<any>>({
|
|
|
43
43
|
ignoreMissingFields: false
|
|
44
44
|
})
|
|
45
45
|
}
|
|
46
|
-
// if (!resolvedProperties || !Array.isArray(resolvedProperties))
|
|
47
|
-
// throw Error("RepeatFieldBinding - Internal error: Expected array in 'property.resolvedProperties'");
|
|
48
46
|
|
|
49
47
|
const expanded = property.expanded === undefined ? true : property.expanded;
|
|
50
48
|
const ofProperty: ResolvedProperty<CMSType[]> = property.of as ResolvedProperty<CMSType[]>;
|
|
@@ -57,33 +55,40 @@ export function RepeatFieldBinding<T extends Array<any>>({
|
|
|
57
55
|
setValue
|
|
58
56
|
});
|
|
59
57
|
|
|
60
|
-
const buildEntry = (
|
|
58
|
+
const buildEntry = ({
|
|
59
|
+
index,
|
|
60
|
+
internalId,
|
|
61
|
+
storedProps,
|
|
62
|
+
storeProps
|
|
63
|
+
}: ArrayEntryParams) => {
|
|
61
64
|
const childProperty = resolvedProperties[index] ?? ofProperty;
|
|
62
|
-
const fieldProps = {
|
|
65
|
+
const fieldProps: PropertyFieldBindingProps<any, any> = {
|
|
63
66
|
propertyKey: `${propertyKey}.${index}`,
|
|
64
67
|
disabled,
|
|
65
|
-
property: childProperty,
|
|
68
|
+
property: storedProps ? mergeDeep(childProperty, storedProps) : childProperty,
|
|
69
|
+
onPropertyChange: storeProps,
|
|
66
70
|
includeDescription,
|
|
67
71
|
underlyingValueHasChanged,
|
|
68
72
|
context,
|
|
69
73
|
partOfArray: true,
|
|
70
74
|
minimalistView: false,
|
|
71
|
-
autoFocus: internalId === lastAddedId
|
|
75
|
+
autoFocus: internalId === lastAddedId,
|
|
72
76
|
};
|
|
73
77
|
return <ErrorBoundary>
|
|
74
78
|
<PropertyFieldBinding {...fieldProps} index={index}/>
|
|
75
79
|
</ErrorBoundary>;
|
|
76
80
|
};
|
|
77
81
|
|
|
78
|
-
const arrayContainer = <
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
82
|
+
const arrayContainer = <ArrayContainer droppableId={propertyKey}
|
|
83
|
+
addLabel={property.name ? "Add entry to " + property.name : "Add entry"}
|
|
84
|
+
value={value}
|
|
85
|
+
buildEntry={buildEntry}
|
|
86
|
+
onInternalIdAdded={setLastAddedId}
|
|
87
|
+
disabled={isSubmitting || Boolean(property.disabled)}
|
|
88
|
+
includeAddButton={!property.disabled}
|
|
89
|
+
newDefaultEntry={getDefaultValueFor(property.of)}
|
|
90
|
+
onValueChange={(value) => setFieldValue(propertyKey, value)}
|
|
91
|
+
/>;
|
|
87
92
|
|
|
88
93
|
const title = (<>
|
|
89
94
|
<LabelWithIconAndTooltip
|
|
@@ -109,7 +114,7 @@ export function RepeatFieldBinding<T extends Array<any>>({
|
|
|
109
114
|
|
|
110
115
|
<FieldHelperText includeDescription={includeDescription}
|
|
111
116
|
showError={showError}
|
|
112
|
-
error={error}
|
|
117
|
+
error={error ? (typeof error === "string" ? error : "A property of this array/repeat has an error") : undefined}
|
|
113
118
|
disabled={disabled}
|
|
114
119
|
property={property}/>
|
|
115
120
|
|
package/src/hooks/data/save.ts
CHANGED
package/src/types/collections.ts
CHANGED
package/src/types/fields.tsx
CHANGED
|
@@ -110,6 +110,15 @@ export interface FieldProps<T extends CMSType = any, CustomProps = any, M extend
|
|
|
110
110
|
*/
|
|
111
111
|
size?: "smallest" | "small" | "medium";
|
|
112
112
|
|
|
113
|
+
/**
|
|
114
|
+
* Some properties might change internal state (like expanding a panel).
|
|
115
|
+
* This function should be called when the internal state changes.
|
|
116
|
+
* This is used to preserve state in array containers.
|
|
117
|
+
*
|
|
118
|
+
* @param property
|
|
119
|
+
*/
|
|
120
|
+
onPropertyChange?: (property: Partial<Property<any>>) => void;
|
|
121
|
+
|
|
113
122
|
}
|
|
114
123
|
|
|
115
124
|
/**
|
|
@@ -223,4 +232,13 @@ export interface PropertyFieldBindingProps<T extends CMSType, M extends Record<s
|
|
|
223
232
|
* The size of the field
|
|
224
233
|
*/
|
|
225
234
|
size?: "smallest" | "small" | "medium",
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* Some properties might change internal state (like expanding a panel).
|
|
238
|
+
* This function should be called when the internal state changes.
|
|
239
|
+
* This is used to preserve state in array containers.
|
|
240
|
+
*
|
|
241
|
+
* @param property
|
|
242
|
+
*/
|
|
243
|
+
onPropertyChange?: (property: Partial<Property<any>>) => void;
|
|
226
244
|
}
|
package/src/util/objects.ts
CHANGED
|
@@ -125,6 +125,26 @@ export function removeUndefined(value: any, removeEmptyStrings?: boolean): any {
|
|
|
125
125
|
return value;
|
|
126
126
|
}
|
|
127
127
|
|
|
128
|
+
export function removeNulls(value: any): any {
|
|
129
|
+
if (typeof value === "function") {
|
|
130
|
+
return value;
|
|
131
|
+
}
|
|
132
|
+
if (Array.isArray(value)) {
|
|
133
|
+
return value.map((v: any) => removeNulls(v));
|
|
134
|
+
}
|
|
135
|
+
if (typeof value === "object") {
|
|
136
|
+
const res: object = {};
|
|
137
|
+
if (value === null)
|
|
138
|
+
return value;
|
|
139
|
+
Object.keys(value).forEach((key) => {
|
|
140
|
+
if (value[key] !== null)
|
|
141
|
+
(res as any)[key] = removeNulls(value[key]);
|
|
142
|
+
});
|
|
143
|
+
return res;
|
|
144
|
+
}
|
|
145
|
+
return value;
|
|
146
|
+
}
|
|
147
|
+
|
|
128
148
|
export function isEmptyObject(obj: object) {
|
|
129
149
|
return obj &&
|
|
130
150
|
Object.getPrototypeOf(obj) === Object.prototype &&
|
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
EntityCollection,
|
|
5
|
+
PropertiesOrBuilders,
|
|
6
|
+
PropertyConfig,
|
|
7
|
+
PropertyOrBuilder,
|
|
8
|
+
ResolvedProperties,
|
|
9
|
+
ResolvedProperty
|
|
10
|
+
} from "../types";
|
|
4
11
|
import { isPropertyBuilder } from "./entities";
|
|
5
12
|
import { resolveProperty } from "./resolutions";
|
|
6
13
|
import { CircleIcon, FunctionsIcon } from "@firecms/ui";
|
|
@@ -63,7 +70,7 @@ export function getColorForProperty(property: PropertyOrBuilder, fields: Record<
|
|
|
63
70
|
* @param properties
|
|
64
71
|
* @param path
|
|
65
72
|
*/
|
|
66
|
-
export function getPropertyInPath<M extends Record<string, any>>(properties: PropertiesOrBuilders<M
|
|
73
|
+
export function getPropertyInPath<M extends Record<string, any>>(properties: PropertiesOrBuilders<M> | ResolvedProperties, path: string): PropertyOrBuilder<any, M> | undefined {
|
|
67
74
|
if (typeof properties === "object") {
|
|
68
75
|
if (path in properties) {
|
|
69
76
|
return properties[path];
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
interface ArrayContainerProps<T> {
|
|
3
|
-
value: T[];
|
|
4
|
-
name: string;
|
|
5
|
-
addLabel: string;
|
|
6
|
-
buildEntry: (index: number, internalId: number) => React.ReactNode;
|
|
7
|
-
disabled?: boolean;
|
|
8
|
-
small?: boolean;
|
|
9
|
-
onInternalIdAdded?: (id: number) => void;
|
|
10
|
-
includeAddButton?: boolean;
|
|
11
|
-
newDefaultEntry?: T | null;
|
|
12
|
-
setFieldValue: (field: string, value: any, shouldValidate?: boolean | undefined) => void;
|
|
13
|
-
className?: string;
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* @group Form custom fields
|
|
17
|
-
*/
|
|
18
|
-
export declare function FormikArrayContainer<T>({ name, addLabel, value, disabled, buildEntry, small, onInternalIdAdded, includeAddButton, newDefaultEntry, setFieldValue, className }: ArrayContainerProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
19
|
-
export {};
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { ArrayContainer } from "../../components";
|
|
2
|
-
import React from "react";
|
|
3
|
-
|
|
4
|
-
interface ArrayContainerProps<T> {
|
|
5
|
-
value: T[];
|
|
6
|
-
name: string;
|
|
7
|
-
addLabel: string;
|
|
8
|
-
buildEntry: (index: number, internalId: number) => React.ReactNode;
|
|
9
|
-
disabled?: boolean;
|
|
10
|
-
small?: boolean;
|
|
11
|
-
onInternalIdAdded?: (id: number) => void;
|
|
12
|
-
includeAddButton?: boolean;
|
|
13
|
-
newDefaultEntry?: T | null;
|
|
14
|
-
setFieldValue: (field: string, value: any, shouldValidate?: boolean | undefined) => void;
|
|
15
|
-
className?: string;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* @group Form custom fields
|
|
20
|
-
*/
|
|
21
|
-
export function FormikArrayContainer<T>({
|
|
22
|
-
name,
|
|
23
|
-
addLabel,
|
|
24
|
-
value,
|
|
25
|
-
disabled = false,
|
|
26
|
-
buildEntry,
|
|
27
|
-
small,
|
|
28
|
-
onInternalIdAdded,
|
|
29
|
-
includeAddButton,
|
|
30
|
-
newDefaultEntry = null,
|
|
31
|
-
setFieldValue,
|
|
32
|
-
className
|
|
33
|
-
}: ArrayContainerProps<T>) {
|
|
34
|
-
|
|
35
|
-
return <ArrayContainer droppableId={name}
|
|
36
|
-
addLabel={addLabel}
|
|
37
|
-
value={value}
|
|
38
|
-
disabled={disabled}
|
|
39
|
-
buildEntry={buildEntry}
|
|
40
|
-
size={small ? "small" : "medium"}
|
|
41
|
-
onInternalIdAdded={onInternalIdAdded}
|
|
42
|
-
includeAddButton={includeAddButton}
|
|
43
|
-
newDefaultEntry={newDefaultEntry}
|
|
44
|
-
className={className}
|
|
45
|
-
onValueChange={(value) => setFieldValue(name, value)}
|
|
46
|
-
/>;
|
|
47
|
-
}
|