@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
package/src/util/resolutions.ts
CHANGED
|
@@ -217,6 +217,38 @@ export function resolveProperty<T extends CMSType = CMSType, M extends Record<st
|
|
|
217
217
|
: null;
|
|
218
218
|
}
|
|
219
219
|
|
|
220
|
+
export function getArrayResolvedProperties<M>({
|
|
221
|
+
propertyKey,
|
|
222
|
+
propertyValue,
|
|
223
|
+
property,
|
|
224
|
+
...props
|
|
225
|
+
}: {
|
|
226
|
+
propertyValue: any,
|
|
227
|
+
propertyKey?: string,
|
|
228
|
+
property: ArrayProperty<any> | ResolvedArrayProperty<any>,
|
|
229
|
+
ignoreMissingFields: boolean,
|
|
230
|
+
values?: Partial<M>;
|
|
231
|
+
previousValues?: Partial<M>;
|
|
232
|
+
path?: string;
|
|
233
|
+
entityId?: string;
|
|
234
|
+
index?: number;
|
|
235
|
+
fromBuilder?: boolean;
|
|
236
|
+
fields?: Record<string, PropertyConfig>
|
|
237
|
+
}) {
|
|
238
|
+
|
|
239
|
+
const of = property.of;
|
|
240
|
+
return Array.isArray(propertyValue)
|
|
241
|
+
? propertyValue.map((v: any, index: number) => {
|
|
242
|
+
return resolveProperty({
|
|
243
|
+
propertyKey: `${propertyKey}.${index}`,
|
|
244
|
+
propertyOrBuilder: of,
|
|
245
|
+
...props,
|
|
246
|
+
index
|
|
247
|
+
});
|
|
248
|
+
}).filter(e => Boolean(e)) as ResolvedProperty[]
|
|
249
|
+
: [];
|
|
250
|
+
}
|
|
251
|
+
|
|
220
252
|
export function resolveArrayProperty<T extends any[], M>({
|
|
221
253
|
propertyKey,
|
|
222
254
|
property,
|
|
@@ -254,17 +286,14 @@ export function resolveArrayProperty<T extends any[], M>({
|
|
|
254
286
|
} as ResolvedArrayProperty;
|
|
255
287
|
} else {
|
|
256
288
|
const of = property.of;
|
|
257
|
-
const resolvedProperties
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
})).filter(e => Boolean(e)) as ResolvedProperty[]
|
|
265
|
-
: [];
|
|
289
|
+
const resolvedProperties = getArrayResolvedProperties({
|
|
290
|
+
propertyValue,
|
|
291
|
+
propertyKey,
|
|
292
|
+
property,
|
|
293
|
+
ignoreMissingFields,
|
|
294
|
+
...props
|
|
295
|
+
});
|
|
266
296
|
const ofProperty = resolveProperty({
|
|
267
|
-
propertyKey: `${propertyKey}`,
|
|
268
297
|
propertyOrBuilder: of,
|
|
269
298
|
ignoreMissingFields,
|
|
270
299
|
...props
|
|
@@ -295,6 +324,7 @@ export function resolveArrayProperty<T extends any[], M>({
|
|
|
295
324
|
}).filter(e => Boolean(e)) as ResolvedProperty[]
|
|
296
325
|
: [];
|
|
297
326
|
const properties = resolveProperties<any>({
|
|
327
|
+
propertyKey,
|
|
298
328
|
properties: property.oneOf.properties,
|
|
299
329
|
ignoreMissingFields,
|
|
300
330
|
...props
|
|
@@ -327,10 +357,12 @@ export function resolveArrayProperty<T extends any[], M>({
|
|
|
327
357
|
* @param value
|
|
328
358
|
*/
|
|
329
359
|
export function resolveProperties<M extends Record<string, any>>({
|
|
360
|
+
propertyKey,
|
|
330
361
|
properties,
|
|
331
362
|
ignoreMissingFields,
|
|
332
363
|
...props
|
|
333
364
|
}: {
|
|
365
|
+
propertyKey?: string,
|
|
334
366
|
properties: PropertiesOrBuilders<M>,
|
|
335
367
|
values?: Partial<M>,
|
|
336
368
|
previousValues?: Partial<M>,
|
|
@@ -344,7 +376,7 @@ export function resolveProperties<M extends Record<string, any>>({
|
|
|
344
376
|
return Object.entries<PropertyOrBuilder>(properties as Record<string, PropertyOrBuilder>)
|
|
345
377
|
.map(([key, property]) => {
|
|
346
378
|
const childResolvedProperty = resolveProperty({
|
|
347
|
-
propertyKey: key,
|
|
379
|
+
propertyKey: propertyKey ? `${propertyKey}.${key}` : undefined,
|
|
348
380
|
propertyOrBuilder: property,
|
|
349
381
|
ignoreMissingFields,
|
|
350
382
|
...props
|
package/src/util/storage.ts
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
|
+
ArrayProperty,
|
|
2
3
|
EntityValues,
|
|
4
|
+
PropertyOrBuilder,
|
|
3
5
|
ResolvedArrayProperty,
|
|
4
6
|
ResolvedStringProperty,
|
|
5
7
|
StorageConfig,
|
|
8
|
+
StringProperty,
|
|
6
9
|
UploadedFileContext
|
|
7
10
|
} from "../types";
|
|
8
11
|
import { randomString } from "./strings";
|
|
@@ -13,12 +16,12 @@ interface ResolveFilenameStringParams<M extends object> {
|
|
|
13
16
|
values: EntityValues<M>;
|
|
14
17
|
entityId: string;
|
|
15
18
|
path?: string;
|
|
16
|
-
property: ResolvedStringProperty | ResolvedArrayProperty<string[]
|
|
19
|
+
property: ResolvedStringProperty | ResolvedArrayProperty<string[]>,
|
|
17
20
|
file: File;
|
|
18
21
|
propertyKey: string;
|
|
19
22
|
}
|
|
20
23
|
|
|
21
|
-
export async function
|
|
24
|
+
export async function resolveStorageFilenameString<M extends object>(
|
|
22
25
|
{
|
|
23
26
|
input,
|
|
24
27
|
storage,
|
|
@@ -30,6 +33,7 @@ export async function resolveFilenameString<M extends object>(
|
|
|
30
33
|
propertyKey
|
|
31
34
|
}: ResolveFilenameStringParams<M>): Promise<string> {
|
|
32
35
|
let result;
|
|
36
|
+
|
|
33
37
|
if (typeof input === "function") {
|
|
34
38
|
result = await input({
|
|
35
39
|
path,
|
|
@@ -2,9 +2,11 @@ import Resizer from "react-image-file-resizer";
|
|
|
2
2
|
import equal from "react-fast-compare";
|
|
3
3
|
|
|
4
4
|
import {
|
|
5
|
+
ArrayProperty,
|
|
5
6
|
EntityValues,
|
|
6
7
|
ImageCompression,
|
|
7
8
|
Property,
|
|
9
|
+
PropertyOrBuilder,
|
|
8
10
|
ResolvedArrayProperty,
|
|
9
11
|
ResolvedStringProperty,
|
|
10
12
|
StorageConfig,
|
|
@@ -14,7 +16,8 @@ import {
|
|
|
14
16
|
import { useCallback, useEffect, useState } from "react";
|
|
15
17
|
import { PreviewSize } from "../preview";
|
|
16
18
|
import { randomString } from "./strings";
|
|
17
|
-
import {
|
|
19
|
+
import { resolveStorageFilenameString, resolveStoragePathString } from "./storage";
|
|
20
|
+
import { resolveProperty } from "./resolutions";
|
|
18
21
|
|
|
19
22
|
/**
|
|
20
23
|
* Internal representation of an item in the storage
|
|
@@ -48,7 +51,7 @@ export function useStorageUploadController<M extends object>({
|
|
|
48
51
|
value: string | string[] | null;
|
|
49
52
|
path?: string,
|
|
50
53
|
propertyKey: string,
|
|
51
|
-
property: ResolvedStringProperty | ResolvedArrayProperty<string[]>,
|
|
54
|
+
property: StringProperty | ArrayProperty<string[]> | ResolvedStringProperty | ResolvedArrayProperty<string[]>,
|
|
52
55
|
storageSource: StorageSource,
|
|
53
56
|
disabled: boolean,
|
|
54
57
|
onChange: (value: string | string[] | null) => void
|
|
@@ -93,15 +96,20 @@ export function useStorageUploadController<M extends object>({
|
|
|
93
96
|
}
|
|
94
97
|
}, [internalInitialValue, value, initialValue]);
|
|
95
98
|
|
|
99
|
+
const resolvedProperty = resolveProperty({
|
|
100
|
+
propertyOrBuilder: property as PropertyOrBuilder,
|
|
101
|
+
values: entityValues
|
|
102
|
+
}) as ResolvedStringProperty | ResolvedArrayProperty<string[]>;
|
|
103
|
+
|
|
96
104
|
const fileNameBuilder = useCallback(async (file: File) => {
|
|
97
105
|
if (storage.fileName) {
|
|
98
|
-
const fileName = await
|
|
106
|
+
const fileName = await resolveStorageFilenameString({
|
|
99
107
|
input: storage.fileName,
|
|
100
108
|
storage,
|
|
101
109
|
values: entityValues,
|
|
102
110
|
entityId,
|
|
103
111
|
path,
|
|
104
|
-
property,
|
|
112
|
+
property: resolvedProperty,
|
|
105
113
|
file,
|
|
106
114
|
propertyKey
|
|
107
115
|
});
|
|
@@ -111,7 +119,7 @@ export function useStorageUploadController<M extends object>({
|
|
|
111
119
|
return fileName;
|
|
112
120
|
}
|
|
113
121
|
return randomString() + "_" + file.name;
|
|
114
|
-
}, [entityId, entityValues, path,
|
|
122
|
+
}, [entityId, entityValues, path, resolvedProperty, propertyKey, storage]);
|
|
115
123
|
|
|
116
124
|
const storagePathBuilder = useCallback((file: File) => {
|
|
117
125
|
return resolveStoragePathString({
|
|
@@ -120,11 +128,11 @@ export function useStorageUploadController<M extends object>({
|
|
|
120
128
|
values: entityValues,
|
|
121
129
|
entityId,
|
|
122
130
|
path,
|
|
123
|
-
property,
|
|
131
|
+
property: resolvedProperty,
|
|
124
132
|
file,
|
|
125
133
|
propertyKey
|
|
126
134
|
}) ?? "/";
|
|
127
|
-
}, [entityId, entityValues, path,
|
|
135
|
+
}, [entityId, entityValues, path, resolvedProperty, propertyKey, storage]);
|
|
128
136
|
|
|
129
137
|
const onFileUploadComplete = useCallback(async (uploadedPath: string,
|
|
130
138
|
entry: StorageFieldItem,
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { PropertiesOrBuilders } from "../types";
|
|
2
|
-
import { FormexController } from "@firecms/formex";
|
|
3
|
-
export type PropertiesFormProps<M extends Record<string, any> = Record<string, any>> = {
|
|
4
|
-
properties: PropertiesOrBuilders<M>;
|
|
5
|
-
propertiesOrder?: string[];
|
|
6
|
-
formex: FormexController<M>;
|
|
7
|
-
};
|
|
8
|
-
export declare function PropertiesForm<M extends Record<string, any> = Record<string, any>>({ properties, propertiesOrder, formex }: PropertiesFormProps<M>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { FieldProps } from "../../types";
|
|
2
|
-
/**
|
|
3
|
-
* Render a markdown field that allows edition and seeing the preview.
|
|
4
|
-
*
|
|
5
|
-
* This is one of the internal components that get mapped natively inside forms
|
|
6
|
-
* and tables to the specified properties.
|
|
7
|
-
* @group Form fields
|
|
8
|
-
*/
|
|
9
|
-
export declare function MarkdownFieldBinding({ propertyKey, value, setValue, error, showError, disabled, autoFocus, touched, property, tableMode, includeDescription, context }: FieldProps<string>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { ContentCopyIcon, IconButton, Typography } from "@firecms/ui";
|
|
2
|
-
import { useCallback, useState } from "react";
|
|
3
|
-
|
|
4
|
-
export function PropertyIdCopyTooltipContent({ propertyId }: { propertyId: string }) {
|
|
5
|
-
|
|
6
|
-
const [copied, setCopied] = useState(false);
|
|
7
|
-
|
|
8
|
-
return (
|
|
9
|
-
<div className={"flex flex-row gap-2 items-center justify-center text-white"}>
|
|
10
|
-
<div>
|
|
11
|
-
<Typography variant={"caption"} className={"min-w-20 text-slate-400"}
|
|
12
|
-
color={"disabled"}>{copied ? "Copied" : "Property ID"}</Typography>
|
|
13
|
-
<Typography variant={"caption"} className={"text-white"}><code>{propertyId}</code></Typography>
|
|
14
|
-
</div>
|
|
15
|
-
<IconButton size={"small"}>
|
|
16
|
-
<ContentCopyIcon size={"smallest"}
|
|
17
|
-
className={"text-white"}
|
|
18
|
-
onClick={useCallback(() => {
|
|
19
|
-
navigator.clipboard.writeText(propertyId);
|
|
20
|
-
setCopied(true);
|
|
21
|
-
setTimeout(() => setCopied(false), 2000);
|
|
22
|
-
}, [propertyId])}
|
|
23
|
-
/>
|
|
24
|
-
</IconButton>
|
|
25
|
-
</div>
|
|
26
|
-
);
|
|
27
|
-
}
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import { FormContext, PropertiesOrBuilders, PropertyFieldBindingProps } from "../types";
|
|
2
|
-
import { Tooltip } from "@firecms/ui";
|
|
3
|
-
import { PropertyIdCopyTooltipContent } from "../components/PropertyIdCopyTooltipContent";
|
|
4
|
-
import { PropertyFieldBinding } from "./PropertyFieldBinding";
|
|
5
|
-
import { ErrorBoundary } from "../components";
|
|
6
|
-
import { isHidden, isReadOnly, resolveProperties } from "../util";
|
|
7
|
-
import { FormexController } from "@firecms/formex";
|
|
8
|
-
|
|
9
|
-
export type PropertiesFormProps<M extends Record<string, any> = Record<string, any>> = {
|
|
10
|
-
properties: PropertiesOrBuilders<M>;
|
|
11
|
-
propertiesOrder?: string[];
|
|
12
|
-
formex: FormexController<M>;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export function PropertiesForm<M extends Record<string, any> = Record<string, any>>({
|
|
16
|
-
properties,
|
|
17
|
-
propertiesOrder,
|
|
18
|
-
formex
|
|
19
|
-
}: PropertiesFormProps<M>) {
|
|
20
|
-
|
|
21
|
-
const resolvedProperties = resolveProperties({ properties });
|
|
22
|
-
|
|
23
|
-
const formContext: FormContext<M> = {
|
|
24
|
-
// @ts-ignore
|
|
25
|
-
setFieldValue: useCallback(formex.setFieldValue, []),
|
|
26
|
-
values: formex.values ?? {},
|
|
27
|
-
// @ts-ignore
|
|
28
|
-
save: useCallback(() => {
|
|
29
|
-
throw new Error("Not implemented. You currently can't call save from a custom field, within a PropertiesForm (it works in standard Entity forms)");
|
|
30
|
-
}, []),
|
|
31
|
-
formex
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
const formFields = (
|
|
35
|
-
<div className={"flex flex-col gap-8"}>
|
|
36
|
-
{(propertiesOrder ?? Object.keys(resolvedProperties))
|
|
37
|
-
.map((key) => {
|
|
38
|
-
|
|
39
|
-
const property = resolvedProperties[key];
|
|
40
|
-
if (!property) {
|
|
41
|
-
console.warn(`Property ${key} not found in collection PropertiesForm`);
|
|
42
|
-
return null;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
const disabled = formex.isSubmitting || isReadOnly(property) || Boolean(property.disabled);
|
|
46
|
-
const hidden = isHidden(property);
|
|
47
|
-
if (hidden) return null;
|
|
48
|
-
const cmsFormFieldProps: PropertyFieldBindingProps<any, M> = {
|
|
49
|
-
propertyKey: key,
|
|
50
|
-
disabled,
|
|
51
|
-
property,
|
|
52
|
-
includeDescription: property.description || property.longDescription,
|
|
53
|
-
context: formContext,
|
|
54
|
-
tableMode: false,
|
|
55
|
-
partOfArray: false,
|
|
56
|
-
partOfBlock: false,
|
|
57
|
-
autoFocus: false
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
return (
|
|
61
|
-
<div id={`form_field_${key}`}
|
|
62
|
-
key={`field_${key}`}>
|
|
63
|
-
<ErrorBoundary>
|
|
64
|
-
<Tooltip title={<PropertyIdCopyTooltipContent propertyId={key}/>}
|
|
65
|
-
delayDuration={800}
|
|
66
|
-
side={"left"}
|
|
67
|
-
align={"start"}
|
|
68
|
-
sideOffset={16}>
|
|
69
|
-
<PropertyFieldBinding {...cmsFormFieldProps}/>
|
|
70
|
-
</Tooltip>
|
|
71
|
-
</ErrorBoundary>
|
|
72
|
-
</div>
|
|
73
|
-
);
|
|
74
|
-
})
|
|
75
|
-
.filter(Boolean)}
|
|
76
|
-
|
|
77
|
-
</div>
|
|
78
|
-
);
|
|
79
|
-
|
|
80
|
-
return <div></div>
|
|
81
|
-
}
|