@firecms/core 3.0.0-beta.8 → 3.0.0-beta.9
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/app/Drawer.d.ts +1 -1
- package/dist/app/Scaffold.d.ts +1 -1
- package/dist/components/ArrayContainer.d.ts +2 -1
- package/dist/components/CircularProgressCenter.d.ts +1 -1
- package/dist/components/EntityCollectionTable/EntityCollectionRowActions.d.ts +0 -1
- package/dist/components/EntityCollectionTable/fields/TableReferenceField.d.ts +1 -1
- package/dist/components/EntityCollectionTable/internal/popup_field/PopupFormField.d.ts +1 -1
- package/dist/components/EntityCollectionView/EntityCollectionView.d.ts +1 -1
- package/dist/components/EntityPreview.d.ts +1 -1
- package/dist/components/ErrorView.d.ts +1 -1
- package/dist/components/HomePage/DefaultHomePage.d.ts +1 -1
- package/dist/components/HomePage/NavigationCardBinding.d.ts +1 -1
- package/dist/components/PropertyIdCopyTooltip.d.ts +8 -0
- package/dist/components/VirtualTable/VirtualTableProps.d.ts +10 -6
- package/dist/components/common/useColumnsIds.d.ts +2 -1
- package/dist/components/index.d.ts +1 -0
- package/dist/core/DefaultAppBar.d.ts +1 -1
- package/dist/core/DefaultDrawer.d.ts +1 -1
- package/dist/core/DrawerNavigationItem.d.ts +2 -1
- package/dist/core/EntityEditView.d.ts +3 -3
- package/dist/core/FireCMS.d.ts +1 -1
- package/dist/core/NavigationRoutes.d.ts +1 -1
- package/dist/form/PropertyFieldBinding.d.ts +1 -1
- package/dist/form/components/FormikArrayContainer.d.ts +2 -1
- package/dist/form/components/LabelWithIcon.d.ts +1 -1
- package/dist/form/components/LabelWithIconAndTooltip.d.ts +15 -0
- package/dist/form/components/index.d.ts +1 -0
- package/dist/form/field_bindings/ArrayCustomShapedFieldBinding.d.ts +1 -1
- package/dist/form/field_bindings/ArrayOfReferencesFieldBinding.d.ts +1 -1
- package/dist/form/field_bindings/BlockFieldBinding.d.ts +1 -1
- package/dist/form/field_bindings/KeyValueFieldBinding.d.ts +1 -1
- package/dist/form/field_bindings/MapFieldBinding.d.ts +1 -1
- package/dist/form/field_bindings/MarkdownEditorFieldBinding.d.ts +11 -0
- package/dist/form/field_bindings/{MultiSelectBinding.d.ts → MultiSelectFieldBinding.d.ts} +1 -1
- package/dist/form/field_bindings/ReadOnlyFieldBinding.d.ts +1 -1
- package/dist/form/field_bindings/RepeatFieldBinding.d.ts +1 -1
- package/dist/form/field_bindings/SelectFieldBinding.d.ts +1 -1
- package/dist/form/field_bindings/StorageUploadFieldBinding.d.ts +1 -1
- package/dist/form/field_bindings/TextFieldBinding.d.ts +1 -1
- package/dist/form/index.d.ts +3 -3
- package/dist/form/useClearRestoreValue.d.ts +2 -2
- package/dist/hooks/useProjectLog.d.ts +2 -2
- package/dist/index.es.js +14127 -11014
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +19987 -587
- package/dist/index.umd.js.map +1 -1
- package/dist/preview/PropertyPreviewProps.d.ts +1 -1
- package/dist/preview/components/EnumValuesChip.d.ts +1 -1
- package/dist/preview/components/ReferencePreview.d.ts +1 -1
- package/dist/types/auth.d.ts +1 -1
- package/dist/types/collections.d.ts +12 -3
- package/dist/types/datasource.d.ts +35 -22
- package/dist/types/entities.d.ts +1 -0
- package/dist/types/entity_overrides.d.ts +2 -2
- package/dist/types/fields.d.ts +20 -15
- package/dist/types/navigation.d.ts +1 -0
- package/dist/types/properties.d.ts +18 -18
- package/dist/types/side_dialogs_controller.d.ts +10 -0
- package/dist/types/storage.d.ts +75 -0
- package/dist/util/entities.d.ts +1 -1
- package/dist/util/icon_list.d.ts +5 -1
- package/dist/util/icons.d.ts +1 -0
- package/dist/util/index.d.ts +1 -0
- package/dist/util/plurals.d.ts +0 -2
- package/dist/util/property_utils.d.ts +1 -1
- package/dist/util/resolutions.d.ts +15 -1
- package/dist/util/storage.d.ts +1 -1
- package/dist/util/useStorageUploadController.d.ts +2 -2
- package/package.json +15 -17
- package/src/app/Drawer.tsx +1 -1
- package/src/app/Scaffold.tsx +22 -27
- package/src/components/ArrayContainer.tsx +15 -10
- package/src/components/CircularProgressCenter.tsx +1 -1
- package/src/components/EntityCollectionTable/EntityCollectionRowActions.tsx +4 -9
- package/src/components/EntityCollectionTable/EntityCollectionTable.tsx +2 -2
- package/src/components/EntityCollectionTable/PropertyTableCell.tsx +4 -2
- package/src/components/EntityCollectionTable/fields/TableReferenceField.tsx +21 -14
- package/src/components/EntityCollectionTable/fields/TableStorageUpload.tsx +12 -4
- package/src/components/EntityCollectionTable/internal/EntityTableCell.tsx +17 -19
- package/src/components/EntityCollectionTable/internal/EntityTableCellActions.tsx +19 -7
- package/src/components/EntityCollectionTable/internal/popup_field/PopupFormField.tsx +3 -5
- package/src/components/EntityCollectionView/EntityCollectionView.tsx +26 -25
- package/src/components/EntityCollectionView/useSelectionController.tsx +19 -7
- package/src/components/EntityPreview.tsx +30 -31
- package/src/components/ErrorView.tsx +1 -1
- package/src/components/HomePage/DefaultHomePage.tsx +24 -18
- package/src/components/HomePage/NavigationCardBinding.tsx +1 -1
- package/src/components/HomePage/SmallNavigationCard.tsx +1 -2
- package/src/components/PropertyIdCopyTooltip.tsx +48 -0
- package/src/components/ReferenceTable/ReferenceSelectionTable.tsx +7 -6
- package/src/components/SearchIconsView.tsx +5 -2
- package/src/components/SelectableTable/SelectableTable.tsx +2 -4
- package/src/components/SelectableTable/filters/DateTimeFilterField.tsx +1 -1
- package/src/components/SelectableTable/filters/StringNumberFilterField.tsx +54 -7
- package/src/components/VirtualTable/VirtualTable.tsx +33 -9
- package/src/components/VirtualTable/VirtualTableCell.tsx +1 -9
- package/src/components/VirtualTable/VirtualTableProps.tsx +12 -8
- package/src/components/VirtualTable/fields/VirtualTableDateField.tsx +3 -3
- package/src/components/VirtualTable/fields/VirtualTableInput.tsx +2 -1
- package/src/components/VirtualTable/fields/VirtualTableNumberInput.tsx +2 -1
- package/src/components/VirtualTable/fields/VirtualTableSelect.tsx +14 -28
- package/src/components/common/useColumnsIds.tsx +13 -0
- package/src/components/common/useDataSourceEntityCollectionTableController.tsx +12 -12
- package/src/components/common/useTableSearchHelper.ts +1 -0
- package/src/components/index.tsx +1 -0
- package/src/core/DefaultAppBar.tsx +3 -3
- package/src/core/DefaultDrawer.tsx +18 -12
- package/src/core/DrawerNavigationItem.tsx +31 -27
- package/src/core/EntityEditView.tsx +136 -109
- package/src/core/FireCMS.tsx +2 -2
- package/src/core/NavigationRoutes.tsx +1 -1
- package/src/core/SideDialogs.tsx +1 -0
- package/src/core/field_configs.tsx +5 -5
- package/src/form/PropertyFieldBinding.tsx +24 -14
- package/src/form/components/CustomIdField.tsx +4 -2
- package/src/form/components/FieldHelperText.tsx +1 -1
- package/src/form/components/FormikArrayContainer.tsx +4 -1
- package/src/form/components/LabelWithIcon.tsx +27 -19
- package/src/form/components/LabelWithIconAndTooltip.tsx +28 -0
- package/src/form/components/StorageItemPreview.tsx +1 -0
- package/src/form/components/StorageUploadProgress.tsx +0 -1
- package/src/form/components/index.tsx +1 -0
- package/src/form/field_bindings/ArrayCustomShapedFieldBinding.tsx +22 -14
- package/src/form/field_bindings/ArrayOfReferencesFieldBinding.tsx +24 -22
- package/src/form/field_bindings/BlockFieldBinding.tsx +13 -11
- package/src/form/field_bindings/DateTimeFieldBinding.tsx +17 -14
- package/src/form/field_bindings/KeyValueFieldBinding.tsx +8 -7
- package/src/form/field_bindings/MapFieldBinding.tsx +16 -24
- package/src/form/field_bindings/MarkdownEditorFieldBinding.tsx +150 -0
- package/src/form/field_bindings/{MultiSelectBinding.tsx → MultiSelectFieldBinding.tsx} +25 -20
- package/src/form/field_bindings/ReadOnlyFieldBinding.tsx +9 -7
- package/src/form/field_bindings/ReferenceFieldBinding.tsx +27 -18
- package/src/form/field_bindings/RepeatFieldBinding.tsx +27 -17
- package/src/form/field_bindings/SelectFieldBinding.tsx +17 -10
- package/src/form/field_bindings/StorageUploadFieldBinding.tsx +36 -17
- package/src/form/field_bindings/SwitchFieldBinding.tsx +9 -5
- package/src/form/field_bindings/TextFieldBinding.tsx +26 -23
- package/src/form/index.tsx +4 -9
- package/src/form/useClearRestoreValue.tsx +2 -2
- package/src/hooks/data/delete.ts +2 -1
- package/src/hooks/data/save.ts +5 -2
- package/src/hooks/data/useDataSource.tsx +11 -3
- package/src/hooks/useBuildNavigationController.tsx +10 -3
- package/src/hooks/useProjectLog.tsx +18 -7
- package/src/internal/useBuildDataSource.ts +59 -76
- package/src/internal/useBuildSideDialogsController.tsx +1 -0
- package/src/internal/useBuildSideEntityController.tsx +17 -4
- package/src/internal/useUnsavedChangesDialog.tsx +3 -1
- package/src/preview/PropertyPreview.tsx +2 -2
- package/src/preview/PropertyPreviewProps.tsx +1 -1
- package/src/preview/components/BooleanPreview.tsx +1 -1
- package/src/preview/components/EnumValuesChip.tsx +1 -1
- package/src/preview/components/ImagePreview.tsx +4 -2
- package/src/preview/components/ReferencePreview.tsx +2 -13
- package/src/preview/components/UrlComponentPreview.tsx +1 -1
- package/src/preview/property_previews/ArrayOfMapsPreview.tsx +1 -1
- package/src/preview/property_previews/ArrayOfReferencesPreview.tsx +1 -1
- package/src/preview/property_previews/ArrayOfStorageComponentsPreview.tsx +1 -1
- package/src/preview/property_previews/ArrayOneOfPreview.tsx +2 -2
- package/src/preview/property_previews/ArrayPropertyPreview.tsx +1 -1
- package/src/preview/property_previews/MapPropertyPreview.tsx +1 -1
- package/src/preview/property_previews/SkeletonPropertyComponent.tsx +2 -2
- package/src/preview/property_previews/StringPropertyPreview.tsx +2 -2
- package/src/preview/util.ts +2 -2
- package/src/types/auth.tsx +1 -1
- package/src/types/collections.ts +15 -4
- package/src/types/datasource.ts +42 -27
- package/src/types/entities.ts +2 -0
- package/src/types/entity_overrides.tsx +2 -2
- package/src/types/fields.tsx +23 -17
- package/src/types/navigation.ts +1 -0
- package/src/types/properties.ts +18 -17
- package/src/types/side_dialogs_controller.tsx +13 -0
- package/src/types/storage.ts +82 -0
- package/src/util/entities.ts +1 -1
- package/src/util/icon_list.ts +14 -9
- package/src/util/icons.tsx +8 -2
- package/src/util/index.ts +1 -0
- package/src/util/plurals.ts +0 -2
- package/src/util/property_utils.tsx +1 -1
- package/src/util/references.ts +3 -0
- package/src/util/resolutions.ts +43 -11
- package/src/util/storage.ts +6 -2
- package/src/util/useStorageUploadController.tsx +15 -7
- package/dist/components/PropertyIdCopyTooltipContent.d.ts +0 -3
- package/dist/form/PropertiesForm.d.ts +0 -8
- package/dist/form/field_bindings/MarkdownFieldBinding.d.ts +0 -9
- package/src/components/PropertyIdCopyTooltipContent.tsx +0 -27
- package/src/form/PropertiesForm.tsx +0 -81
- package/src/form/field_bindings/MarkdownFieldBinding.tsx +0 -695
|
@@ -1,17 +1,9 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import {
|
|
3
|
-
CMSType,
|
|
4
|
-
FieldProps,
|
|
5
|
-
FormContext,
|
|
6
|
-
MapProperty,
|
|
7
|
-
Properties,
|
|
8
|
-
ResolvedProperties,
|
|
9
|
-
ResolvedProperty
|
|
10
|
-
} from "../../types";
|
|
2
|
+
import { FieldProps, Properties, ResolvedProperties } from "../../types";
|
|
11
3
|
|
|
12
4
|
import { ErrorBoundary } from "../../components";
|
|
13
5
|
import { getIconForProperty, isHidden, pick } from "../../util";
|
|
14
|
-
import { FieldHelperText,
|
|
6
|
+
import { FieldHelperText, LabelWithIconAndTooltip } from "../components";
|
|
15
7
|
import { PropertyFieldBinding } from "../PropertyFieldBinding";
|
|
16
8
|
import { ExpandablePanel, InputLabel, Select, SelectItem } from "@firecms/ui";
|
|
17
9
|
|
|
@@ -29,8 +21,7 @@ export function MapFieldBinding({
|
|
|
29
21
|
error,
|
|
30
22
|
disabled,
|
|
31
23
|
property,
|
|
32
|
-
|
|
33
|
-
tableMode,
|
|
24
|
+
minimalistView,
|
|
34
25
|
includeDescription,
|
|
35
26
|
underlyingValueHasChanged,
|
|
36
27
|
autoFocus,
|
|
@@ -63,16 +54,15 @@ export function MapFieldBinding({
|
|
|
63
54
|
{Object.entries(mapProperties)
|
|
64
55
|
.filter(([_, property]) => !isHidden(property))
|
|
65
56
|
.map(([entryKey, childProperty], index) => {
|
|
66
|
-
const
|
|
57
|
+
const fieldBindingProps = {
|
|
67
58
|
propertyKey: `${propertyKey}.${entryKey}`,
|
|
68
59
|
disabled,
|
|
69
60
|
property: childProperty,
|
|
70
61
|
includeDescription,
|
|
71
62
|
underlyingValueHasChanged,
|
|
72
63
|
context,
|
|
73
|
-
tableMode: false,
|
|
74
64
|
partOfArray: false,
|
|
75
|
-
|
|
65
|
+
minimalistView: false,
|
|
76
66
|
autoFocus: autoFocus && index === 0
|
|
77
67
|
};
|
|
78
68
|
|
|
@@ -80,7 +70,7 @@ export function MapFieldBinding({
|
|
|
80
70
|
<div key={`map-${propertyKey}-${index}`}>
|
|
81
71
|
<ErrorBoundary>
|
|
82
72
|
<PropertyFieldBinding
|
|
83
|
-
{...
|
|
73
|
+
{...fieldBindingProps}/>
|
|
84
74
|
</ErrorBoundary>
|
|
85
75
|
</div>
|
|
86
76
|
);
|
|
@@ -93,20 +83,22 @@ export function MapFieldBinding({
|
|
|
93
83
|
</>;
|
|
94
84
|
|
|
95
85
|
const title = (
|
|
96
|
-
<
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
86
|
+
<LabelWithIconAndTooltip
|
|
87
|
+
propertyKey={propertyKey}
|
|
88
|
+
icon={getIconForProperty(property, "small")}
|
|
89
|
+
required={property.validation?.required}
|
|
90
|
+
title={property.name}
|
|
91
|
+
className={"text-text-secondary dark:text-text-secondary-dark"}/>
|
|
100
92
|
);
|
|
101
93
|
|
|
102
94
|
return (
|
|
103
95
|
<ErrorBoundary>
|
|
104
96
|
|
|
105
|
-
{!
|
|
106
|
-
|
|
107
|
-
|
|
97
|
+
{!minimalistView && !minimalistView && <ExpandablePanel initiallyExpanded={expanded}
|
|
98
|
+
className={"px-2 md:px-4 pb-2 md:pb-4 pt-1 md:pt-2 bg-slate-50 bg-opacity-50 dark:bg-gray-900"}
|
|
99
|
+
title={title}>{mapFormView}</ExpandablePanel>}
|
|
108
100
|
|
|
109
|
-
{(
|
|
101
|
+
{(minimalistView || minimalistView) && mapFormView}
|
|
110
102
|
|
|
111
103
|
<FieldHelperText includeDescription={includeDescription}
|
|
112
104
|
showError={showError ?? false}
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import React, { useCallback, useEffect, useRef, useState } from "react";
|
|
2
|
+
import {
|
|
3
|
+
FieldHelperText,
|
|
4
|
+
FieldProps,
|
|
5
|
+
getIconForProperty,
|
|
6
|
+
LabelWithIconAndTooltip, PropertyOrBuilder,
|
|
7
|
+
randomString,
|
|
8
|
+
ResolvedArrayProperty,
|
|
9
|
+
ResolvedStringProperty,
|
|
10
|
+
useStorageSource
|
|
11
|
+
} from "../../index";
|
|
12
|
+
import { cls, fieldBackgroundHoverMixin, fieldBackgroundMixin } from "@firecms/ui";
|
|
13
|
+
import { FireCMSEditor, FireCMSEditorProps } from "@firecms/editor";
|
|
14
|
+
import { resolveProperty, resolveStorageFilenameString, resolveStoragePathString } from "../../util";
|
|
15
|
+
|
|
16
|
+
interface MarkdownEditorFieldProps {
|
|
17
|
+
highlight?: { from: number, to: number };
|
|
18
|
+
editorProps?: Partial<FireCMSEditorProps>
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function MarkdownEditorFieldBinding({
|
|
22
|
+
property,
|
|
23
|
+
propertyKey,
|
|
24
|
+
value,
|
|
25
|
+
setValue,
|
|
26
|
+
includeDescription,
|
|
27
|
+
showError,
|
|
28
|
+
error,
|
|
29
|
+
minimalistView,
|
|
30
|
+
isSubmitting,
|
|
31
|
+
context,
|
|
32
|
+
customProps,
|
|
33
|
+
}: FieldProps<string, MarkdownEditorFieldProps>) {
|
|
34
|
+
|
|
35
|
+
const highlight = customProps?.highlight;
|
|
36
|
+
const editorProps = customProps?.editorProps;
|
|
37
|
+
const storageSource = useStorageSource();
|
|
38
|
+
const storage = property.storage;
|
|
39
|
+
|
|
40
|
+
const entityValues = context.values;
|
|
41
|
+
const entityId = context.entityId;
|
|
42
|
+
const path = context.path;
|
|
43
|
+
|
|
44
|
+
// const fieldVersion = useRef(0);
|
|
45
|
+
const [fieldVersion, setFieldVersion] = useState(0);
|
|
46
|
+
const internalValue = useRef(value);
|
|
47
|
+
|
|
48
|
+
const onContentChange = useCallback((content: string) => {
|
|
49
|
+
internalValue.current = content;
|
|
50
|
+
setValue(content);
|
|
51
|
+
}, [setValue]);
|
|
52
|
+
|
|
53
|
+
useEffect(() => {
|
|
54
|
+
if (internalValue.current !== value) {
|
|
55
|
+
internalValue.current = value;
|
|
56
|
+
setFieldVersion(fieldVersion + 1);
|
|
57
|
+
// fieldVersion.current = fieldVersion.current + 1;
|
|
58
|
+
}
|
|
59
|
+
}, [value]);
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
const resolvedProperty = resolveProperty({
|
|
63
|
+
propertyOrBuilder: property as PropertyOrBuilder,
|
|
64
|
+
values: entityValues
|
|
65
|
+
}) as ResolvedStringProperty | ResolvedArrayProperty<string[]>;
|
|
66
|
+
|
|
67
|
+
const fileNameBuilder = useCallback(async (file: File) => {
|
|
68
|
+
if (storage?.fileName) {
|
|
69
|
+
const fileName = await resolveStorageFilenameString({
|
|
70
|
+
input: storage.fileName,
|
|
71
|
+
storage,
|
|
72
|
+
values: entityValues,
|
|
73
|
+
entityId,
|
|
74
|
+
path,
|
|
75
|
+
property: resolvedProperty,
|
|
76
|
+
file,
|
|
77
|
+
propertyKey
|
|
78
|
+
});
|
|
79
|
+
if (!fileName || fileName.length === 0) {
|
|
80
|
+
throw Error("You need to return a valid filename");
|
|
81
|
+
}
|
|
82
|
+
return fileName;
|
|
83
|
+
}
|
|
84
|
+
return randomString() + "_" + file.name;
|
|
85
|
+
}, [entityId, entityValues, path, resolvedProperty, propertyKey, storage]);
|
|
86
|
+
|
|
87
|
+
const storagePathBuilder = useCallback((file: File) => {
|
|
88
|
+
if (!storage) return "/";
|
|
89
|
+
const resolvedProperty = resolveProperty({
|
|
90
|
+
propertyOrBuilder: property,
|
|
91
|
+
values: entityValues
|
|
92
|
+
}) as ResolvedStringProperty | ResolvedArrayProperty<string[]>;
|
|
93
|
+
return resolveStoragePathString({
|
|
94
|
+
input: storage.storagePath,
|
|
95
|
+
storage,
|
|
96
|
+
values: entityValues,
|
|
97
|
+
entityId,
|
|
98
|
+
path,
|
|
99
|
+
property: resolvedProperty,
|
|
100
|
+
file,
|
|
101
|
+
propertyKey
|
|
102
|
+
}) ?? "/";
|
|
103
|
+
}, [entityId, entityValues, path, property, propertyKey, storage]);
|
|
104
|
+
|
|
105
|
+
const editor = <FireCMSEditor
|
|
106
|
+
content={value}
|
|
107
|
+
onMarkdownContentChange={onContentChange}
|
|
108
|
+
version={context.formex.version + fieldVersion}
|
|
109
|
+
highlight={highlight}
|
|
110
|
+
handleImageUpload={async (file: File) => {
|
|
111
|
+
const storagePath = storagePathBuilder(file);
|
|
112
|
+
const fileName = await fileNameBuilder(file);
|
|
113
|
+
const result = await storageSource.uploadFile({
|
|
114
|
+
file,
|
|
115
|
+
fileName,
|
|
116
|
+
path: storagePath,
|
|
117
|
+
});
|
|
118
|
+
const downloadConfig = await storageSource.getDownloadURL(result.path);
|
|
119
|
+
const url = downloadConfig.url;
|
|
120
|
+
if (!url) {
|
|
121
|
+
throw new Error("Error uploading image");
|
|
122
|
+
}
|
|
123
|
+
return url;
|
|
124
|
+
}}
|
|
125
|
+
{...editorProps}
|
|
126
|
+
/>;
|
|
127
|
+
|
|
128
|
+
if (minimalistView)
|
|
129
|
+
return editor;
|
|
130
|
+
|
|
131
|
+
return (
|
|
132
|
+
<>
|
|
133
|
+
<LabelWithIconAndTooltip
|
|
134
|
+
propertyKey={propertyKey}
|
|
135
|
+
icon={getIconForProperty(property, "small")}
|
|
136
|
+
required={property.validation?.required}
|
|
137
|
+
title={property.name}
|
|
138
|
+
className={"text-text-secondary dark:text-text-secondary-dark ml-3.5"}/>
|
|
139
|
+
<div className={cls("rounded-md", fieldBackgroundMixin, fieldBackgroundHoverMixin)}>
|
|
140
|
+
{editor}
|
|
141
|
+
</div>
|
|
142
|
+
<FieldHelperText includeDescription={includeDescription}
|
|
143
|
+
showError={showError}
|
|
144
|
+
error={error}
|
|
145
|
+
property={property}/>
|
|
146
|
+
</>
|
|
147
|
+
|
|
148
|
+
);
|
|
149
|
+
|
|
150
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { useCallback } from "react";
|
|
2
2
|
|
|
3
3
|
import { EnumType, FieldProps, ResolvedProperty } from "../../types";
|
|
4
|
-
import { FieldHelperText,
|
|
4
|
+
import { FieldHelperText, LabelWithIconAndTooltip } from "../components";
|
|
5
5
|
import { EnumValuesChip } from "../../preview";
|
|
6
6
|
import { enumToObjectEntries, getIconForProperty, getLabelOrConfigFrom } from "../../util";
|
|
7
7
|
import { CloseIcon, MultiSelect, MultiSelectItem } from "@firecms/ui";
|
|
@@ -14,17 +14,18 @@ import { useClearRestoreValue } from "../useClearRestoreValue";
|
|
|
14
14
|
* and tables to the specified properties.
|
|
15
15
|
* @group Form fields
|
|
16
16
|
*/
|
|
17
|
-
export function
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
17
|
+
export function MultiSelectFieldBinding({
|
|
18
|
+
propertyKey,
|
|
19
|
+
value,
|
|
20
|
+
setValue,
|
|
21
|
+
error,
|
|
22
|
+
showError,
|
|
23
|
+
disabled,
|
|
24
|
+
property,
|
|
25
|
+
includeDescription,
|
|
26
|
+
size = "medium",
|
|
27
|
+
autoFocus
|
|
28
|
+
}: FieldProps<EnumType[], any, any>) {
|
|
28
29
|
|
|
29
30
|
const of: ResolvedProperty<any> | ResolvedProperty<any>[] = property.of;
|
|
30
31
|
if (!of) {
|
|
@@ -79,16 +80,20 @@ export function MultiSelectBinding({
|
|
|
79
80
|
}, [enumValues, setValue, value]);
|
|
80
81
|
|
|
81
82
|
return (
|
|
82
|
-
|
|
83
|
+
<>
|
|
83
84
|
<MultiSelect
|
|
85
|
+
className={"w-full mt-2"}
|
|
86
|
+
size={size === "medium" ? "medium" : "small"}
|
|
84
87
|
value={validValue ? value.map((v) => v.toString()) : []}
|
|
85
88
|
disabled={disabled}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
89
|
+
modalPopover={true}
|
|
90
|
+
label={<LabelWithIconAndTooltip
|
|
91
|
+
propertyKey={propertyKey}
|
|
92
|
+
icon={getIconForProperty(property, "small")}
|
|
93
|
+
required={property.validation?.required}
|
|
94
|
+
title={property.name}
|
|
95
|
+
className={"text-text-secondary dark:text-text-secondary-dark ml-3.5"}/>}
|
|
96
|
+
onValueChange={(updatedValue: string[]) => {
|
|
92
97
|
let newValue: EnumType[] | null;
|
|
93
98
|
if (of && (of as ResolvedProperty)?.dataType === "number") {
|
|
94
99
|
newValue = updatedValue ? (updatedValue as string[]).map((e) => parseFloat(e)) : [];
|
|
@@ -109,6 +114,6 @@ export function MultiSelectBinding({
|
|
|
109
114
|
disabled={disabled}
|
|
110
115
|
property={property}/>
|
|
111
116
|
|
|
112
|
-
|
|
117
|
+
</>
|
|
113
118
|
);
|
|
114
119
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { FieldProps } from "../../types";
|
|
4
4
|
|
|
5
5
|
import { PropertyPreview } from "../../preview";
|
|
6
|
-
import { FieldHelperText,
|
|
6
|
+
import { FieldHelperText, LabelWithIconAndTooltip } from "../components";
|
|
7
7
|
import { ErrorBoundary } from "../../components";
|
|
8
8
|
import { getIconForProperty } from "../../util";
|
|
9
9
|
import { cls, paperMixin } from "@firecms/ui";
|
|
@@ -21,7 +21,7 @@ export function ReadOnlyFieldBinding({
|
|
|
21
21
|
value,
|
|
22
22
|
error,
|
|
23
23
|
showError,
|
|
24
|
-
|
|
24
|
+
minimalistView,
|
|
25
25
|
property,
|
|
26
26
|
includeDescription,
|
|
27
27
|
context
|
|
@@ -34,10 +34,12 @@ export function ReadOnlyFieldBinding({
|
|
|
34
34
|
|
|
35
35
|
<>
|
|
36
36
|
|
|
37
|
-
{!
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
37
|
+
{!minimalistView && <LabelWithIconAndTooltip
|
|
38
|
+
propertyKey={propertyKey}
|
|
39
|
+
icon={getIconForProperty(property, "small")}
|
|
40
|
+
required={property.validation?.required}
|
|
41
|
+
title={property.name}
|
|
42
|
+
className={"text-text-secondary dark:text-text-secondary-dark ml-3.5"}/>
|
|
41
43
|
}
|
|
42
44
|
|
|
43
45
|
<div
|
|
@@ -3,12 +3,13 @@ import React, { useCallback, useMemo } from "react";
|
|
|
3
3
|
import { Entity, EntityCollection, EntityReference, FieldProps } from "../../types";
|
|
4
4
|
import { useNavigationController, useReferenceDialog } from "../../hooks";
|
|
5
5
|
import { ReadOnlyFieldBinding } from "./ReadOnlyFieldBinding";
|
|
6
|
-
import { FieldHelperText,
|
|
6
|
+
import { FieldHelperText, LabelWithIconAndTooltip } from "../components";
|
|
7
7
|
import { ErrorView } from "../../components";
|
|
8
|
-
import { ReferencePreview } from "../../preview";
|
|
9
|
-
import { getIconForProperty, getReferenceFrom } from "../../util";
|
|
10
|
-
import { Button } from "@firecms/ui";
|
|
8
|
+
import { EmptyValue, ReferencePreview } from "../../preview";
|
|
9
|
+
import { getIconForProperty, getReferenceFrom, IconForView } from "../../util";
|
|
11
10
|
import { useClearRestoreValue } from "../useClearRestoreValue";
|
|
11
|
+
import { EntityPreviewContainer } from "../../components/EntityPreview";
|
|
12
|
+
import { cls } from "@firecms/ui";
|
|
12
13
|
|
|
13
14
|
/**
|
|
14
15
|
* Field that opens a reference selection dialog.
|
|
@@ -28,17 +29,19 @@ export function ReferenceFieldBinding<M extends Record<string, any>>(props: Fiel
|
|
|
28
29
|
}
|
|
29
30
|
|
|
30
31
|
function ReferenceFieldBindingInternal({
|
|
32
|
+
propertyKey,
|
|
31
33
|
value,
|
|
32
34
|
setValue,
|
|
33
35
|
error,
|
|
34
36
|
showError,
|
|
35
37
|
isSubmitting,
|
|
36
38
|
disabled,
|
|
39
|
+
minimalistView,
|
|
37
40
|
touched,
|
|
38
41
|
autoFocus,
|
|
39
42
|
property,
|
|
40
43
|
includeDescription,
|
|
41
|
-
|
|
44
|
+
size = "medium"
|
|
42
45
|
}: FieldProps<EntityReference>) {
|
|
43
46
|
if (!property.path) {
|
|
44
47
|
throw new Error("Property path is required for ReferenceFieldBinding");
|
|
@@ -75,17 +78,19 @@ function ReferenceFieldBindingInternal({
|
|
|
75
78
|
}
|
|
76
79
|
);
|
|
77
80
|
|
|
78
|
-
const onEntryClick =
|
|
81
|
+
const onEntryClick = (e: React.SyntheticEvent) => {
|
|
79
82
|
e.preventDefault();
|
|
80
83
|
referenceDialogController.open();
|
|
81
|
-
}
|
|
84
|
+
};
|
|
82
85
|
|
|
83
86
|
return (
|
|
84
87
|
<>
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
88
|
+
{!minimalistView && <LabelWithIconAndTooltip
|
|
89
|
+
propertyKey={propertyKey}
|
|
90
|
+
icon={getIconForProperty(property, "small")}
|
|
91
|
+
required={property.validation?.required}
|
|
92
|
+
title={property.name}
|
|
93
|
+
className={"text-text-secondary dark:text-text-secondary-dark ml-3.5"}/>}
|
|
89
94
|
|
|
90
95
|
{!collection && <ErrorView
|
|
91
96
|
error={"The specified collection does not exist. Check console"}/>}
|
|
@@ -96,7 +101,7 @@ function ReferenceFieldBindingInternal({
|
|
|
96
101
|
disabled={!property.path}
|
|
97
102
|
previewProperties={property.previewProperties}
|
|
98
103
|
hover={!disabled}
|
|
99
|
-
size={
|
|
104
|
+
size={size}
|
|
100
105
|
onClick={disabled || isSubmitting ? undefined : onEntryClick}
|
|
101
106
|
reference={value}
|
|
102
107
|
includeEntityLink={property.includeEntityLink}
|
|
@@ -104,12 +109,16 @@ function ReferenceFieldBindingInternal({
|
|
|
104
109
|
/>}
|
|
105
110
|
|
|
106
111
|
{!value && <div className="justify-center text-left">
|
|
107
|
-
<
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
112
|
+
<EntityPreviewContainer className={cls("px-6 h-16 text-sm font-medium flex items-center gap-6",
|
|
113
|
+
disabled || isSubmitting
|
|
114
|
+
? "text-slate-500"
|
|
115
|
+
: "cursor-pointer text-slate-700 dark:text-slate-300 hover:bg-slate-50 dark:hover:bg-gray-800 group-hover:bg-slate-50 dark:group-hover:bg-gray-800")}
|
|
116
|
+
onClick={onEntryClick}
|
|
117
|
+
size={"medium"}>
|
|
118
|
+
<IconForView collectionOrView={collection}
|
|
119
|
+
className={"text-gray-300 dark:text-gray-600"}/>
|
|
120
|
+
{`Edit ${property.name}`.toUpperCase()}
|
|
121
|
+
</EntityPreviewContainer>
|
|
113
122
|
</div>}
|
|
114
123
|
</>}
|
|
115
124
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import React, { useState } from "react";
|
|
2
2
|
import { CMSType, FieldProps, ResolvedProperty } from "../../types";
|
|
3
|
-
import { FieldHelperText, FormikArrayContainer,
|
|
3
|
+
import { FieldHelperText, FormikArrayContainer, LabelWithIconAndTooltip } from "../components";
|
|
4
4
|
import { ErrorBoundary } from "../../components";
|
|
5
|
-
import { getDefaultValueFor, getIconForProperty } from "../../util";
|
|
5
|
+
import { getArrayResolvedProperties, getDefaultValueFor, getIconForProperty } from "../../util";
|
|
6
6
|
import { PropertyFieldBinding } from "../PropertyFieldBinding";
|
|
7
7
|
import { ExpandablePanel, Typography } from "@firecms/ui";
|
|
8
8
|
import { useClearRestoreValue } from "../useClearRestoreValue";
|
|
@@ -23,7 +23,7 @@ export function RepeatFieldBinding<T extends Array<any>>({
|
|
|
23
23
|
isSubmitting,
|
|
24
24
|
setValue,
|
|
25
25
|
setFieldValue,
|
|
26
|
-
|
|
26
|
+
minimalistView,
|
|
27
27
|
property,
|
|
28
28
|
includeDescription,
|
|
29
29
|
underlyingValueHasChanged,
|
|
@@ -34,8 +34,17 @@ export function RepeatFieldBinding<T extends Array<any>>({
|
|
|
34
34
|
if (!property.of)
|
|
35
35
|
throw Error("RepeatFieldBinding misconfiguration. Property `of` not set");
|
|
36
36
|
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
let resolvedProperties = "resolvedProperties" in property ? property.resolvedProperties : undefined;
|
|
38
|
+
if (!resolvedProperties) {
|
|
39
|
+
resolvedProperties = getArrayResolvedProperties({
|
|
40
|
+
propertyValue: value,
|
|
41
|
+
propertyKey,
|
|
42
|
+
property,
|
|
43
|
+
ignoreMissingFields: false
|
|
44
|
+
})
|
|
45
|
+
}
|
|
46
|
+
// if (!resolvedProperties || !Array.isArray(resolvedProperties))
|
|
47
|
+
// throw Error("RepeatFieldBinding - Internal error: Expected array in 'property.resolvedProperties'");
|
|
39
48
|
|
|
40
49
|
const expanded = property.expanded === undefined ? true : property.expanded;
|
|
41
50
|
const ofProperty: ResolvedProperty<CMSType[]> = property.of as ResolvedProperty<CMSType[]>;
|
|
@@ -49,7 +58,7 @@ export function RepeatFieldBinding<T extends Array<any>>({
|
|
|
49
58
|
});
|
|
50
59
|
|
|
51
60
|
const buildEntry = (index: number, internalId: number) => {
|
|
52
|
-
const childProperty =
|
|
61
|
+
const childProperty = resolvedProperties[index] ?? ofProperty;
|
|
53
62
|
const fieldProps = {
|
|
54
63
|
propertyKey: `${propertyKey}.${index}`,
|
|
55
64
|
disabled,
|
|
@@ -57,13 +66,12 @@ export function RepeatFieldBinding<T extends Array<any>>({
|
|
|
57
66
|
includeDescription,
|
|
58
67
|
underlyingValueHasChanged,
|
|
59
68
|
context,
|
|
60
|
-
tableMode: false,
|
|
61
69
|
partOfArray: true,
|
|
62
|
-
|
|
70
|
+
minimalistView: false,
|
|
63
71
|
autoFocus: internalId === lastAddedId
|
|
64
72
|
};
|
|
65
73
|
return <ErrorBoundary>
|
|
66
|
-
<PropertyFieldBinding {...fieldProps}/>
|
|
74
|
+
<PropertyFieldBinding {...fieldProps} index={index}/>
|
|
67
75
|
</ErrorBoundary>;
|
|
68
76
|
};
|
|
69
77
|
|
|
@@ -78,10 +86,12 @@ export function RepeatFieldBinding<T extends Array<any>>({
|
|
|
78
86
|
newDefaultEntry={getDefaultValueFor(property.of)}/>;
|
|
79
87
|
|
|
80
88
|
const title = (<>
|
|
81
|
-
<
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
89
|
+
<LabelWithIconAndTooltip
|
|
90
|
+
propertyKey={propertyKey}
|
|
91
|
+
icon={getIconForProperty(property, "small")}
|
|
92
|
+
required={property.validation?.required}
|
|
93
|
+
title={property.name}
|
|
94
|
+
className={"flex flex-grow text-text-secondary dark:text-text-secondary-dark"}/>
|
|
85
95
|
{Array.isArray(value) && <Typography variant={"caption"} className={"px-4"}>({value.length})</Typography>}
|
|
86
96
|
</>);
|
|
87
97
|
|
|
@@ -89,13 +99,13 @@ export function RepeatFieldBinding<T extends Array<any>>({
|
|
|
89
99
|
|
|
90
100
|
<>
|
|
91
101
|
|
|
92
|
-
{!
|
|
93
|
-
|
|
94
|
-
|
|
102
|
+
{!minimalistView && <ExpandablePanel initiallyExpanded={expanded}
|
|
103
|
+
className={"px-2 md:px-4 pb-2 md:pb-4 pt-1 md:pt-2"}
|
|
104
|
+
title={title}>
|
|
95
105
|
{arrayContainer}
|
|
96
106
|
</ExpandablePanel>}
|
|
97
107
|
|
|
98
|
-
{
|
|
108
|
+
{minimalistView && arrayContainer}
|
|
99
109
|
|
|
100
110
|
<FieldHelperText includeDescription={includeDescription}
|
|
101
111
|
showError={showError}
|
|
@@ -3,9 +3,10 @@ import React, { useCallback } from "react";
|
|
|
3
3
|
import { EnumType, FieldProps } from "../../types";
|
|
4
4
|
import { FieldHelperText, LabelWithIcon } from "../components";
|
|
5
5
|
import { EnumValuesChip } from "../../preview";
|
|
6
|
-
import { getIconForProperty } from "../../util";
|
|
6
|
+
import { getIconForProperty, resolveEnumValues } from "../../util";
|
|
7
7
|
import { ClearIcon, cls, IconButton, Select, SelectItem } from "@firecms/ui";
|
|
8
8
|
import { useClearRestoreValue } from "../useClearRestoreValue";
|
|
9
|
+
import { PropertyIdCopyTooltip } from "../../components";
|
|
9
10
|
|
|
10
11
|
type SelectProps<T extends EnumType> = FieldProps<T>;
|
|
11
12
|
|
|
@@ -27,10 +28,11 @@ export function SelectFieldBinding<T extends EnumType>({
|
|
|
27
28
|
autoFocus,
|
|
28
29
|
touched,
|
|
29
30
|
property,
|
|
30
|
-
includeDescription
|
|
31
|
+
includeDescription,
|
|
32
|
+
size = "medium"
|
|
31
33
|
}: SelectProps<T>) {
|
|
32
34
|
|
|
33
|
-
const enumValues = property.enumValues;
|
|
35
|
+
const enumValues = resolveEnumValues(property.enumValues ?? []);
|
|
34
36
|
|
|
35
37
|
useClearRestoreValue({
|
|
36
38
|
property,
|
|
@@ -48,15 +50,20 @@ export function SelectFieldBinding<T extends EnumType>({
|
|
|
48
50
|
<>
|
|
49
51
|
|
|
50
52
|
<Select
|
|
53
|
+
size={size === "medium" ? "medium" : "small"}
|
|
51
54
|
value={value !== undefined && value != null ? value.toString() : ""}
|
|
52
55
|
disabled={disabled}
|
|
53
56
|
position="item-aligned"
|
|
54
57
|
inputClassName={cls("w-full")}
|
|
55
|
-
label={
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
58
|
+
label={
|
|
59
|
+
<PropertyIdCopyTooltip propertyKey={propertyKey}>
|
|
60
|
+
<LabelWithIcon
|
|
61
|
+
icon={getIconForProperty(property, "small")}
|
|
62
|
+
required={property.validation?.required}
|
|
63
|
+
title={property.name}
|
|
64
|
+
className={"text-text-secondary dark:text-text-secondary-dark ml-3.5"}
|
|
65
|
+
/>
|
|
66
|
+
</PropertyIdCopyTooltip>}
|
|
60
67
|
endAdornment={
|
|
61
68
|
property.clearable && <IconButton
|
|
62
69
|
onClick={handleClearClick}>
|
|
@@ -73,7 +80,7 @@ export function SelectFieldBinding<T extends EnumType>({
|
|
|
73
80
|
return <EnumValuesChip
|
|
74
81
|
enumKey={enumKey}
|
|
75
82
|
enumValues={enumValues}
|
|
76
|
-
size={
|
|
83
|
+
size={size}/>;
|
|
77
84
|
}}
|
|
78
85
|
>
|
|
79
86
|
{enumValues && enumValues.map((option) => {
|
|
@@ -83,7 +90,7 @@ export function SelectFieldBinding<T extends EnumType>({
|
|
|
83
90
|
<EnumValuesChip
|
|
84
91
|
enumKey={String(option.id)}
|
|
85
92
|
enumValues={enumValues}
|
|
86
|
-
size={
|
|
93
|
+
size={size}/>
|
|
87
94
|
</SelectItem>
|
|
88
95
|
})}
|
|
89
96
|
</Select>
|