@firecms/collection_editor 3.0.0-canary.4 → 3.0.0-canary.40
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 +525 -511
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +2 -2
- package/dist/index.umd.js.map +1 -1
- package/dist/types/persisted_collection.d.ts +1 -1
- package/dist/ui/EditorCollectionActionStart.d.ts +2 -0
- package/dist/ui/collection_editor/CollectionEditorDialog.d.ts +1 -1
- package/dist/ui/collection_editor/utils/supported_fields.d.ts +2 -2
- package/package.json +18 -18
- package/src/ConfigControllerProvider.tsx +1 -1
- package/src/types/persisted_collection.ts +1 -1
- package/src/ui/EditorCollectionAction.tsx +0 -51
- package/src/ui/EditorCollectionActionStart.tsx +87 -0
- package/src/ui/MissingReferenceWidget.tsx +2 -1
- package/src/ui/NewCollectionButton.tsx +12 -10
- package/src/ui/collection_editor/CollectionDetailsForm.tsx +17 -18
- package/src/ui/collection_editor/CollectionEditorDialog.tsx +13 -9
- package/src/ui/collection_editor/CollectionEditorWelcomeView.tsx +1 -1
- package/src/ui/collection_editor/CollectionPropertiesEditorForm.tsx +7 -6
- package/src/ui/collection_editor/EnumForm.tsx +3 -4
- package/src/ui/collection_editor/GetCodeDialog.tsx +15 -3
- package/src/ui/collection_editor/PropertyEditView.tsx +4 -4
- package/src/ui/collection_editor/import/CollectionEditorImportMapping.tsx +1 -1
- package/src/ui/collection_editor/properties/CommonPropertyFields.tsx +7 -8
- package/src/ui/collection_editor/properties/DateTimePropertyField.tsx +7 -8
- package/src/ui/collection_editor/properties/MapPropertyField.tsx +3 -4
- package/src/ui/collection_editor/properties/ReferencePropertyField.tsx +3 -4
- package/src/ui/collection_editor/properties/validation/StringPropertyValidation.tsx +3 -4
- package/src/ui/collection_editor/utils/supported_fields.tsx +3 -3
- package/src/useCollectionEditorPlugin.tsx +4 -4
- package/dist/ui/collection_editor/properties/FieldHelperView.d.ts +0 -4
- package/src/ui/collection_editor/properties/FieldHelperView.tsx +0 -13
|
@@ -5,7 +5,7 @@ import { Formex, FormexController, getIn, useCreateFormex } from "@firecms/forme
|
|
|
5
5
|
import {
|
|
6
6
|
DEFAULT_FIELD_CONFIGS,
|
|
7
7
|
DeleteConfirmationDialog,
|
|
8
|
-
|
|
8
|
+
PropertyConfigId,
|
|
9
9
|
getFieldConfig,
|
|
10
10
|
getFieldId,
|
|
11
11
|
isPropertyBuilder,
|
|
@@ -375,7 +375,7 @@ function PropertyEditFormFields({
|
|
|
375
375
|
}
|
|
376
376
|
}, [errors, onError, propertyNamespace, values?.id]);
|
|
377
377
|
|
|
378
|
-
const onWidgetSelectChanged = (newSelectedWidgetId:
|
|
378
|
+
const onWidgetSelectChanged = (newSelectedWidgetId: PropertyConfigId) => {
|
|
379
379
|
setSelectedFieldConfigId(newSelectedWidgetId);
|
|
380
380
|
setValues(updatePropertyFromWidget(values, newSelectedWidgetId, propertyConfigs));
|
|
381
381
|
// Ugly hack to autofocus the name field
|
|
@@ -495,7 +495,7 @@ function PropertyEditFormFields({
|
|
|
495
495
|
return <em>Select a property
|
|
496
496
|
widget</em>;
|
|
497
497
|
}
|
|
498
|
-
const key = value as
|
|
498
|
+
const key = value as PropertyConfigId;
|
|
499
499
|
const propertyConfig = DEFAULT_FIELD_CONFIGS[key] ?? propertyConfigs[key];
|
|
500
500
|
const baseProperty = propertyConfig.property;
|
|
501
501
|
const baseFieldConfig = baseProperty && !isPropertyBuilder(baseProperty) ? getFieldConfig(baseProperty, propertyConfigs) : undefined;
|
|
@@ -524,7 +524,7 @@ function PropertyEditFormFields({
|
|
|
524
524
|
</div>
|
|
525
525
|
}}
|
|
526
526
|
onValueChange={(value) => {
|
|
527
|
-
onWidgetSelectChanged(value as
|
|
527
|
+
onWidgetSelectChanged(value as PropertyConfigId);
|
|
528
528
|
}}>
|
|
529
529
|
{displayedWidgets.map(([key, propertyConfig]) => {
|
|
530
530
|
const baseProperty = propertyConfig.property;
|
|
@@ -149,7 +149,7 @@ export function CollectionEditorImportMapping({
|
|
|
149
149
|
idColumn={importConfig.idColumn}
|
|
150
150
|
originProperties={importConfig.originProperties}
|
|
151
151
|
destinationProperties={values.properties as Properties}
|
|
152
|
-
onIdPropertyChanged={(value) => importConfig.setIdColumn(value)}
|
|
152
|
+
onIdPropertyChanged={(value) => importConfig.setIdColumn(value ?? undefined)}
|
|
153
153
|
buildPropertyView={({
|
|
154
154
|
property,
|
|
155
155
|
propertyKey,
|
|
@@ -2,8 +2,7 @@ import { Field, getIn, useFormex } from "@firecms/formex";
|
|
|
2
2
|
import { DebouncedTextField } from "@firecms/ui";
|
|
3
3
|
import { PropertyWithId } from "../PropertyEditView";
|
|
4
4
|
import React from "react";
|
|
5
|
-
import {
|
|
6
|
-
import { toSnakeCase, unslugify } from "@firecms/core";
|
|
5
|
+
import { FieldCaption, toSnakeCase, unslugify } from "@firecms/core";
|
|
7
6
|
|
|
8
7
|
type CommonPropertyFieldsProps = {
|
|
9
8
|
showErrors: boolean,
|
|
@@ -64,9 +63,9 @@ export const CommonPropertyFields = React.forwardRef<HTMLDivElement, CommonPrope
|
|
|
64
63
|
disabled={disabled}
|
|
65
64
|
error={Boolean(nameError)}/>
|
|
66
65
|
|
|
67
|
-
<
|
|
66
|
+
<FieldCaption error={Boolean(nameError)}>
|
|
68
67
|
{nameError}
|
|
69
|
-
</
|
|
68
|
+
</FieldCaption>
|
|
70
69
|
</div>
|
|
71
70
|
|
|
72
71
|
<div>
|
|
@@ -88,9 +87,9 @@ export const CommonPropertyFields = React.forwardRef<HTMLDivElement, CommonPrope
|
|
|
88
87
|
required
|
|
89
88
|
size="small"
|
|
90
89
|
error={Boolean(idError)}/>
|
|
91
|
-
<
|
|
90
|
+
<FieldCaption error={Boolean(idError)}>
|
|
92
91
|
{idError}
|
|
93
|
-
</
|
|
92
|
+
</FieldCaption>
|
|
94
93
|
</div>
|
|
95
94
|
|
|
96
95
|
<div>
|
|
@@ -99,9 +98,9 @@ export const CommonPropertyFields = React.forwardRef<HTMLDivElement, CommonPrope
|
|
|
99
98
|
label={"Description"}
|
|
100
99
|
disabled={disabled}
|
|
101
100
|
error={Boolean(descriptionError)}/>
|
|
102
|
-
<
|
|
101
|
+
<FieldCaption error={Boolean(descriptionError)}>
|
|
103
102
|
{descriptionError}
|
|
104
|
-
</
|
|
103
|
+
</FieldCaption>
|
|
105
104
|
</div>
|
|
106
105
|
|
|
107
106
|
</div>
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { getIn, useFormex } from "@firecms/formex";
|
|
3
|
-
import { NumberProperty, StringProperty } from "@firecms/core";
|
|
3
|
+
import { FieldCaption, NumberProperty, StringProperty } from "@firecms/core";
|
|
4
4
|
import { Select, SelectItem } from "@firecms/ui";
|
|
5
5
|
import { GeneralPropertyValidation } from "./validation/GeneralPropertyValidation";
|
|
6
6
|
import { ValidationPanel } from "./validation/ValidationPanel";
|
|
7
|
-
import { FieldHelperView } from "./FieldHelperView";
|
|
8
7
|
|
|
9
8
|
export function DateTimePropertyField({ disabled }: {
|
|
10
9
|
disabled: boolean;
|
|
@@ -47,14 +46,14 @@ export function DateTimePropertyField({ disabled }: {
|
|
|
47
46
|
<SelectItem value={"date_time"}> Date/Time </SelectItem>
|
|
48
47
|
<SelectItem value={"date"}> Date </SelectItem>
|
|
49
48
|
</Select>
|
|
50
|
-
<
|
|
49
|
+
<FieldCaption error={Boolean(modeError)}>
|
|
51
50
|
{modeError}
|
|
52
|
-
</
|
|
51
|
+
</FieldCaption>
|
|
53
52
|
|
|
54
53
|
<Select name={autoValuePath}
|
|
55
54
|
disabled={disabled}
|
|
56
55
|
value={autoValueValue ?? ""}
|
|
57
|
-
onValueChange={(v) => setFieldValue(autoValuePath, v)}
|
|
56
|
+
onValueChange={(v) => setFieldValue(autoValuePath, v === "none" ? null : v)}
|
|
58
57
|
renderValue={(v) => {
|
|
59
58
|
switch (v) {
|
|
60
59
|
case "on_create":
|
|
@@ -67,13 +66,13 @@ export function DateTimePropertyField({ disabled }: {
|
|
|
67
66
|
}}
|
|
68
67
|
error={Boolean(autoValueError)}
|
|
69
68
|
label={"Automatic value"}>
|
|
70
|
-
<SelectItem value={""}> None </SelectItem>
|
|
69
|
+
<SelectItem value={"none"}> None </SelectItem>
|
|
71
70
|
<SelectItem value={"on_create"}> On create </SelectItem>
|
|
72
71
|
<SelectItem value={"on_update"}> On any update </SelectItem>
|
|
73
72
|
</Select>
|
|
74
|
-
<
|
|
73
|
+
<FieldCaption error={Boolean(autoValueError)}>
|
|
75
74
|
{autoValueError ?? "Update this field automatically when creating or updating the entity"}
|
|
76
|
-
</
|
|
75
|
+
</FieldCaption>
|
|
77
76
|
|
|
78
77
|
</div>
|
|
79
78
|
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import React, { useCallback, useState } from "react";
|
|
2
|
-
import { MapProperty, Property, PropertyConfig, } from "@firecms/core";
|
|
2
|
+
import { FieldCaption, MapProperty, Property, PropertyConfig, } from "@firecms/core";
|
|
3
3
|
import { AddIcon, BooleanSwitchWithLabel, Button, Paper, Typography } from "@firecms/ui";
|
|
4
4
|
import { PropertyFormDialog } from "../PropertyEditView";
|
|
5
5
|
import { getIn, useFormex } from "@firecms/formex";
|
|
6
6
|
import { PropertyTree } from "../PropertyTree";
|
|
7
7
|
import { getFullId, idToPropertiesPath, namespaceToPropertiesOrderPath, namespaceToPropertiesPath } from "../util";
|
|
8
|
-
import { FieldHelperView } from "./FieldHelperView";
|
|
9
8
|
|
|
10
9
|
export function MapPropertyField({ disabled, getData, allowDataInference, propertyConfigs, collectionEditable }: {
|
|
11
10
|
disabled: boolean;
|
|
@@ -113,9 +112,9 @@ export function MapPropertyField({ disabled, getData, allowDataInference, proper
|
|
|
113
112
|
onValueChange={(v) => setFieldValue("spreadChildren", v)}
|
|
114
113
|
value={values.spreadChildren ?? false}
|
|
115
114
|
/>
|
|
116
|
-
<
|
|
115
|
+
<FieldCaption>
|
|
117
116
|
Set this flag to true if you want to display the children of this group as individual columns.
|
|
118
|
-
</
|
|
117
|
+
</FieldCaption>
|
|
119
118
|
</div>
|
|
120
119
|
|
|
121
120
|
<PropertyFormDialog
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { Field, getIn, useFormex } from "@firecms/formex";
|
|
3
|
-
import { IconForView, NumberProperty, StringProperty, useNavigationController } from "@firecms/core";
|
|
3
|
+
import { FieldCaption, IconForView, NumberProperty, StringProperty, useNavigationController } from "@firecms/core";
|
|
4
4
|
import { CircularProgress, Select, SelectGroup, SelectItem, Typography, } from "@firecms/ui";
|
|
5
|
-
import { FieldHelperView } from "./FieldHelperView";
|
|
6
5
|
|
|
7
6
|
export function ReferencePropertyField({
|
|
8
7
|
existing,
|
|
@@ -152,10 +151,10 @@ export function CollectionsSelect({
|
|
|
152
151
|
|
|
153
152
|
</Select>
|
|
154
153
|
|
|
155
|
-
<
|
|
154
|
+
<FieldCaption>
|
|
156
155
|
You can only edit the reference collection upon field
|
|
157
156
|
creation.
|
|
158
|
-
</
|
|
157
|
+
</FieldCaption>
|
|
159
158
|
</>
|
|
160
159
|
);
|
|
161
160
|
}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
|
|
3
3
|
import { Field, FormexFieldProps, getIn, useFormex } from "@firecms/formex";
|
|
4
|
-
import { serializeRegExp } from "@firecms/core";
|
|
4
|
+
import { FieldCaption, serializeRegExp } from "@firecms/core";
|
|
5
5
|
import { DebouncedTextField, } from "@firecms/ui";
|
|
6
6
|
import { GeneralPropertyValidation } from "./GeneralPropertyValidation";
|
|
7
|
-
import { FieldHelperView } from "../FieldHelperView";
|
|
8
7
|
import { SwitchControl } from "../../SwitchControl";
|
|
9
8
|
|
|
10
9
|
export function StringPropertyValidation({
|
|
@@ -140,9 +139,9 @@ export function StringPropertyValidation({
|
|
|
140
139
|
disabled={disabled}
|
|
141
140
|
value={matchesStringValue}
|
|
142
141
|
error={Boolean(matchesError)}/>
|
|
143
|
-
<
|
|
142
|
+
<FieldCaption error={Boolean(matchesError)}>
|
|
144
143
|
{matchesError ? "Not a valid regexp" : "e.g. /^\\d+$/ for digits only"}
|
|
145
|
-
</
|
|
144
|
+
</FieldCaption>
|
|
146
145
|
</div>}
|
|
147
146
|
|
|
148
147
|
</div>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { DEFAULT_FIELD_CONFIGS,
|
|
1
|
+
import { DEFAULT_FIELD_CONFIGS, PropertyConfigId, PropertyConfig } from "@firecms/core";
|
|
2
2
|
|
|
3
|
-
export const supportedFieldsIds:
|
|
3
|
+
export const supportedFieldsIds: PropertyConfigId[] = [
|
|
4
4
|
"text_field",
|
|
5
5
|
"multiline",
|
|
6
6
|
"markdown",
|
|
@@ -24,6 +24,6 @@ export const supportedFieldsIds: FieldConfigId[] = [
|
|
|
24
24
|
];
|
|
25
25
|
|
|
26
26
|
export const supportedFields: Record<string, PropertyConfig> = Object.entries(DEFAULT_FIELD_CONFIGS)
|
|
27
|
-
.filter(([id]) => supportedFieldsIds.includes(id as
|
|
27
|
+
.filter(([id]) => supportedFieldsIds.includes(id as PropertyConfigId))
|
|
28
28
|
.map(([id, config]) => ({ [id]: config }))
|
|
29
29
|
.reduce((a, b) => ({ ...a, ...b }), {});
|
|
@@ -14,6 +14,7 @@ import { PropertyAddColumnComponent } from "./ui/PropertyAddColumnComponent";
|
|
|
14
14
|
import { NewCollectionButton } from "./ui/NewCollectionButton";
|
|
15
15
|
import { AddIcon, Button, Typography } from "@firecms/ui";
|
|
16
16
|
import { useCollectionEditorController } from "./useCollectionEditorController";
|
|
17
|
+
import { EditorCollectionActionStart } from "./ui/EditorCollectionActionStart";
|
|
17
18
|
|
|
18
19
|
export interface CollectionConfigControllerProps<EC extends PersistedCollection = PersistedCollection, UserType extends User = User> {
|
|
19
20
|
|
|
@@ -81,11 +82,8 @@ export function useCollectionEditorPlugin<EC extends PersistedCollection = Persi
|
|
|
81
82
|
}: CollectionConfigControllerProps<EC, UserType>): FireCMSPlugin<any, any, PersistedCollection> {
|
|
82
83
|
|
|
83
84
|
return {
|
|
84
|
-
|
|
85
|
+
key: "collection_editor",
|
|
85
86
|
loading: collectionConfigController.loading,
|
|
86
|
-
collections: {
|
|
87
|
-
CollectionActions: EditorCollectionAction
|
|
88
|
-
},
|
|
89
87
|
provider: {
|
|
90
88
|
Component: ConfigControllerProvider,
|
|
91
89
|
props: {
|
|
@@ -108,6 +106,8 @@ export function useCollectionEditorPlugin<EC extends PersistedCollection = Persi
|
|
|
108
106
|
AdditionalCards: introMode ? undefined : NewCollectionCard,
|
|
109
107
|
},
|
|
110
108
|
collectionView: {
|
|
109
|
+
CollectionActionsStart: EditorCollectionActionStart,
|
|
110
|
+
CollectionActions: EditorCollectionAction,
|
|
111
111
|
HeaderAction: CollectionViewHeaderAction,
|
|
112
112
|
AddColumnComponent: PropertyAddColumnComponent
|
|
113
113
|
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { Typography } from "@firecms/ui";
|
|
2
|
-
|
|
3
|
-
export function FieldHelperView({
|
|
4
|
-
error,
|
|
5
|
-
children
|
|
6
|
-
}: { error?: boolean, children?: React.ReactNode }) {
|
|
7
|
-
if (!children) return null;
|
|
8
|
-
return (
|
|
9
|
-
<Typography variant={"caption"} color={error ? "error" : "secondary"} className={"ml-3.5 mt-0.5"}>
|
|
10
|
-
{children}
|
|
11
|
-
</Typography>
|
|
12
|
-
);
|
|
13
|
-
}
|