@firecms/core 3.0.0-beta.2 → 3.0.0-beta.3
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/EntityCollectionTable/EntityCollectionRowActions.d.ts +2 -6
- package/dist/components/ReferenceWidget.d.ts +3 -3
- package/dist/components/index.d.ts +0 -1
- package/dist/core/SideEntityView.d.ts +7 -0
- package/dist/core/index.d.ts +0 -2
- package/dist/form/components/index.d.ts +1 -0
- package/dist/form/index.d.ts +1 -0
- package/dist/hooks/index.d.ts +2 -1
- package/dist/{core → hooks}/useBuildModeController.d.ts +1 -1
- package/dist/hooks/useBuildNavigationController.d.ts +1 -1
- package/dist/index.es.js +2682 -2663
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +5 -5
- package/dist/index.umd.js.map +1 -1
- package/dist/internal/useBuildDataSource.d.ts +4 -0
- package/dist/types/entities.d.ts +1 -0
- package/dist/util/index.d.ts +1 -0
- package/package.json +12 -4
- package/src/components/EntityCollectionTable/EntityCollectionRowActions.tsx +33 -37
- package/src/components/EntityCollectionTable/EntityCollectionTable.tsx +36 -38
- package/src/components/EntityCollectionTable/PropertyTableCell.tsx +2 -1
- package/src/components/EntityCollectionTable/fields/TableReferenceField.tsx +1 -1
- package/src/components/EntityCollectionView/EntityCollectionView.tsx +9 -9
- package/src/components/ReferenceWidget.tsx +4 -4
- package/src/components/SelectableTable/filters/ReferenceFilterField.tsx +2 -2
- package/src/components/index.tsx +0 -1
- package/src/core/EntitySidePanel.tsx +1 -1
- package/src/{internal → core}/EntityView.tsx +2 -2
- package/src/core/SideEntityView.tsx +38 -0
- package/src/core/index.tsx +0 -2
- package/src/form/components/index.tsx +1 -0
- package/src/form/field_bindings/ArrayCustomShapedFieldBinding.tsx +2 -3
- package/src/form/field_bindings/ArrayOfReferencesFieldBinding.tsx +4 -3
- package/src/form/field_bindings/BlockFieldBinding.tsx +2 -3
- package/src/form/field_bindings/DateTimeFieldBinding.tsx +3 -3
- package/src/form/field_bindings/KeyValueFieldBinding.tsx +4 -4
- package/src/form/field_bindings/MapFieldBinding.tsx +2 -2
- package/src/form/field_bindings/MarkdownFieldBinding.tsx +1 -2
- package/src/form/field_bindings/MultiSelectBinding.tsx +2 -3
- package/src/form/field_bindings/ReadOnlyFieldBinding.tsx +2 -2
- package/src/form/field_bindings/ReferenceFieldBinding.tsx +5 -4
- package/src/form/field_bindings/RepeatFieldBinding.tsx +3 -3
- package/src/form/field_bindings/SelectFieldBinding.tsx +2 -3
- package/src/form/field_bindings/StorageUploadFieldBinding.tsx +3 -3
- package/src/form/field_bindings/SwitchFieldBinding.tsx +2 -3
- package/src/form/field_bindings/TextFieldBinding.tsx +3 -4
- package/src/form/index.tsx +1 -0
- package/src/hooks/index.tsx +3 -1
- package/src/{core → hooks}/useBuildModeController.tsx +1 -1
- package/src/hooks/useBuildNavigationController.tsx +30 -15
- package/src/internal/useBuildDataSource.ts +7 -2
- package/src/preview/PropertyPreview.tsx +1 -1
- package/src/preview/components/ReferencePreview.tsx +1 -1
- package/src/types/entities.ts +4 -0
- package/src/util/index.ts +1 -0
- /package/dist/{internal → core}/EntityView.d.ts +0 -0
- /package/dist/{components → form/components}/LabelWithIcon.d.ts +0 -0
- /package/dist/{core → hooks}/useBuildLocalConfigurationPersistence.d.ts +0 -0
- /package/src/{components → form/components}/LabelWithIcon.tsx +0 -0
- /package/src/{core → hooks}/useBuildLocalConfigurationPersistence.tsx +0 -0
|
@@ -17,6 +17,10 @@ export declare function useBuildDataSource({ delegate, propertyConfigs, navigati
|
|
|
17
17
|
* bindings.
|
|
18
18
|
* Also, Firestore references are replaced with {@link EntityReference}
|
|
19
19
|
* @param data
|
|
20
|
+
* @param buildReference
|
|
21
|
+
* @param buildGeoPoint
|
|
22
|
+
* @param buildDate
|
|
23
|
+
* @param buildDelete
|
|
20
24
|
* @group Firestore
|
|
21
25
|
*/
|
|
22
26
|
export declare function cmsToDelegateModel(data: any, buildReference: (reference: EntityReference) => any, buildGeoPoint: (geoPoint: GeoPoint) => any, buildDate: (date: Date) => any, buildDelete: () => any): any;
|
package/dist/types/entities.d.ts
CHANGED
package/dist/util/index.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@firecms/core",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "3.0.0-beta.
|
|
4
|
+
"version": "3.0.0-beta.3",
|
|
5
5
|
"description": "Awesome Firebase/Firestore-based headless open-source CMS",
|
|
6
6
|
"funding": {
|
|
7
7
|
"url": "https://github.com/sponsors/firecmsco"
|
|
@@ -37,9 +37,17 @@
|
|
|
37
37
|
"clean": "rm -rf dist && find ./src -name '*.js' -type f | xargs rm -f",
|
|
38
38
|
"generateIcons": "ts-node --esm src/icons/generateIcons.ts"
|
|
39
39
|
},
|
|
40
|
+
"exports": {
|
|
41
|
+
".": {
|
|
42
|
+
"import": "./dist/index.es.js",
|
|
43
|
+
"require": "./dist/index.umd.js",
|
|
44
|
+
"types": "./dist/src/index.d.ts"
|
|
45
|
+
},
|
|
46
|
+
"./package.json": "./package.json"
|
|
47
|
+
},
|
|
40
48
|
"dependencies": {
|
|
41
|
-
"@firecms/formex": "^3.0.0-beta.
|
|
42
|
-
"@firecms/ui": "^3.0.0-beta.
|
|
49
|
+
"@firecms/formex": "^3.0.0-beta.3",
|
|
50
|
+
"@firecms/ui": "^3.0.0-beta.3",
|
|
43
51
|
"@fontsource/ibm-plex-mono": "^5.0.8",
|
|
44
52
|
"@fontsource/roboto": "^5.0.8",
|
|
45
53
|
"@hello-pangea/dnd": "^16.5.0",
|
|
@@ -107,7 +115,7 @@
|
|
|
107
115
|
"dist",
|
|
108
116
|
"src"
|
|
109
117
|
],
|
|
110
|
-
"gitHead": "
|
|
118
|
+
"gitHead": "33cceff5d5bc2a7002cc5a3904b787e70bfb9c6e",
|
|
111
119
|
"publishConfig": {
|
|
112
120
|
"access": "public"
|
|
113
121
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import React, { MouseEvent, useCallback } from "react";
|
|
2
|
-
import equal from "react-fast-compare"
|
|
3
2
|
|
|
4
3
|
import { CollectionSize, Entity, EntityAction, EntityCollection, SelectionController } from "../../types";
|
|
5
4
|
import { Checkbox, cn, IconButton, Menu, MenuItem, MoreVertIcon, Skeleton, Tooltip, Typography } from "@firecms/ui";
|
|
@@ -14,46 +13,43 @@ import { useFireCMSContext, useLargeLayout } from "../../hooks";
|
|
|
14
13
|
* @param selectionEnabled
|
|
15
14
|
* @param size
|
|
16
15
|
* @param toggleEntitySelection
|
|
17
|
-
* @param onCopyClicked
|
|
18
|
-
* @param onEditClicked
|
|
19
|
-
* @param onDeleteClicked
|
|
20
16
|
* @param hideId
|
|
21
17
|
* @constructor
|
|
22
18
|
*
|
|
23
19
|
* @group Collection components
|
|
24
20
|
*/
|
|
25
|
-
export const EntityCollectionRowActions =
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
21
|
+
export const EntityCollectionRowActions = function EntityCollectionRowActions({
|
|
22
|
+
entity,
|
|
23
|
+
collection,
|
|
24
|
+
fullPath,
|
|
25
|
+
width,
|
|
26
|
+
frozen,
|
|
27
|
+
isSelected,
|
|
28
|
+
selectionEnabled,
|
|
29
|
+
size,
|
|
30
|
+
highlightEntity,
|
|
31
|
+
onCollectionChange,
|
|
32
|
+
unhighlightEntity,
|
|
33
|
+
actions = [],
|
|
34
|
+
hideId,
|
|
35
|
+
selectionController,
|
|
36
|
+
}:
|
|
37
|
+
{
|
|
38
|
+
entity: Entity<any>,
|
|
39
|
+
collection?: EntityCollection<any>,
|
|
40
|
+
fullPath?: string,
|
|
41
|
+
width: number,
|
|
42
|
+
frozen?: boolean,
|
|
43
|
+
size: CollectionSize,
|
|
44
|
+
isSelected?: boolean,
|
|
45
|
+
selectionEnabled?: boolean,
|
|
46
|
+
actions?: EntityAction[],
|
|
47
|
+
hideId?: boolean,
|
|
48
|
+
onCollectionChange?: () => void,
|
|
49
|
+
selectionController?: SelectionController;
|
|
50
|
+
highlightEntity?: (entity: Entity<any>) => void;
|
|
51
|
+
unhighlightEntity?: (entity: Entity<any>) => void;
|
|
52
|
+
}) {
|
|
57
53
|
|
|
58
54
|
const largeLayout = useLargeLayout();
|
|
59
55
|
|
|
@@ -171,4 +167,4 @@ export const EntityCollectionRowActions = React.memo(function EntityCollectionRo
|
|
|
171
167
|
</div>
|
|
172
168
|
);
|
|
173
169
|
|
|
174
|
-
}
|
|
170
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useCallback,
|
|
1
|
+
import React, { useCallback, useMemo, useRef } from "react";
|
|
2
2
|
import equal from "react-fast-compare";
|
|
3
3
|
import { AdditionalFieldDelegate, CollectionSize, Entity, FireCMSContext, User } from "../../types";
|
|
4
4
|
import { PropertyTableCell } from "./PropertyTableCell";
|
|
@@ -8,7 +8,6 @@ import { CellRendererParams, VirtualTableColumn } from "../VirtualTable";
|
|
|
8
8
|
import { getValueInPath } from "../../util";
|
|
9
9
|
import { getRowHeight } from "../VirtualTable/common";
|
|
10
10
|
import { EntityCollectionRowActions } from "./EntityCollectionRowActions";
|
|
11
|
-
import { EntityCollectionTableController } from "../common/types";
|
|
12
11
|
import { CollectionTableToolbar } from "./internal/CollectionTableToolbar";
|
|
13
12
|
import { EntityCollectionTableProps } from "./EntityCollectionTableProps";
|
|
14
13
|
import { EntityTableCell } from "./internal/EntityTableCell";
|
|
@@ -111,12 +110,12 @@ export const EntityCollectionTable = React.memo<EntityCollectionTableProps<any>>
|
|
|
111
110
|
|
|
112
111
|
const customFieldValidator: CustomFieldValidator | undefined = uniqueFieldValidator;
|
|
113
112
|
|
|
114
|
-
const propertyCellRenderer =
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
113
|
+
const propertyCellRenderer = ({
|
|
114
|
+
column,
|
|
115
|
+
columnIndex,
|
|
116
|
+
rowData,
|
|
117
|
+
rowIndex
|
|
118
|
+
}: CellRendererParams<any>) => {
|
|
120
119
|
|
|
121
120
|
const entity: Entity<M> = rowData;
|
|
122
121
|
|
|
@@ -158,7 +157,7 @@ export const EntityCollectionTable = React.memo<EntityCollectionTableProps<any>>
|
|
|
158
157
|
}
|
|
159
158
|
</ErrorBoundary>);
|
|
160
159
|
|
|
161
|
-
}
|
|
160
|
+
};
|
|
162
161
|
|
|
163
162
|
const additionalCellRenderer = useCallback(({
|
|
164
163
|
column,
|
|
@@ -205,30 +204,29 @@ export const EntityCollectionTable = React.memo<EntityCollectionTableProps<any>>
|
|
|
205
204
|
|
|
206
205
|
}, [size, selectedEntityIds]);
|
|
207
206
|
|
|
208
|
-
const collectionColumns: VirtualTableColumn[] =
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
const idColumn: VirtualTableColumn = useMemo(() => ({
|
|
207
|
+
const collectionColumns: VirtualTableColumn[] = (() => {
|
|
208
|
+
const columnsResult: VirtualTableColumn[] = propertiesToColumns({
|
|
209
|
+
properties,
|
|
210
|
+
sortable,
|
|
211
|
+
forceFilter,
|
|
212
|
+
disabledFilter: disabledFilterChange,
|
|
213
|
+
AdditionalHeaderWidget
|
|
214
|
+
});
|
|
215
|
+
|
|
216
|
+
const additionalTableColumns: VirtualTableColumn[] = additionalFields
|
|
217
|
+
? additionalFields.map((additionalField) =>
|
|
218
|
+
({
|
|
219
|
+
key: additionalField.key,
|
|
220
|
+
align: "left",
|
|
221
|
+
sortable: false,
|
|
222
|
+
title: additionalField.name,
|
|
223
|
+
width: additionalField.width ?? 200
|
|
224
|
+
}))
|
|
225
|
+
: [];
|
|
226
|
+
return [...columnsResult, ...additionalTableColumns];
|
|
227
|
+
})();
|
|
228
|
+
|
|
229
|
+
const idColumn: VirtualTableColumn = {
|
|
232
230
|
key: "id_ewcfedcswdf3",
|
|
233
231
|
width: getIdColumnWidth?.() ?? (largeLayout ? 160 : 130),
|
|
234
232
|
title: "ID",
|
|
@@ -237,17 +235,17 @@ export const EntityCollectionTable = React.memo<EntityCollectionTableProps<any>>
|
|
|
237
235
|
headerAlign: "center",
|
|
238
236
|
align: "center",
|
|
239
237
|
AdditionalHeaderWidget: () => additionalIDHeaderWidget
|
|
240
|
-
}
|
|
238
|
+
}
|
|
241
239
|
|
|
242
|
-
const columns: VirtualTableColumn[] =
|
|
240
|
+
const columns: VirtualTableColumn[] = [
|
|
243
241
|
idColumn,
|
|
244
242
|
...displayedColumnIds
|
|
245
243
|
.map((p) => {
|
|
246
244
|
return collectionColumns.find(c => c.key === p.key);
|
|
247
245
|
}).filter(Boolean) as VirtualTableColumn[]
|
|
248
|
-
]
|
|
246
|
+
];
|
|
249
247
|
|
|
250
|
-
const cellRenderer =
|
|
248
|
+
const cellRenderer = (props: CellRendererParams<any>) => {
|
|
251
249
|
const column = props.column;
|
|
252
250
|
const columns = props.columns;
|
|
253
251
|
const columnKey = column.key;
|
|
@@ -287,7 +285,7 @@ export const EntityCollectionTable = React.memo<EntityCollectionTableProps<any>>
|
|
|
287
285
|
<ErrorView error={e}/>
|
|
288
286
|
</EntityTableCell>;
|
|
289
287
|
}
|
|
290
|
-
}
|
|
288
|
+
}
|
|
291
289
|
|
|
292
290
|
return (
|
|
293
291
|
|
|
@@ -24,13 +24,14 @@ import { getPreviewSizeFrom } from "../../preview/util";
|
|
|
24
24
|
import { isReadOnly } from "../../util";
|
|
25
25
|
|
|
26
26
|
import { CustomFieldValidator, mapPropertyToYup } from "../../form/validation";
|
|
27
|
-
import {
|
|
27
|
+
import { useFireCMSContext } from "../../hooks";
|
|
28
28
|
|
|
29
29
|
import { EntityTableCell } from "./internal/EntityTableCell";
|
|
30
30
|
import { EntityTableCellActions } from "./internal/EntityTableCellActions";
|
|
31
31
|
|
|
32
32
|
import { getRowHeight } from "../VirtualTable/common";
|
|
33
33
|
import { useSelectableTableController } from "../SelectableTable/SelectableTableContext";
|
|
34
|
+
import { useClearRestoreValue } from "../../form/useClearRestoreValue";
|
|
34
35
|
|
|
35
36
|
export interface PropertyTableCellProps<T extends CMSType, M extends Record<string, any>> {
|
|
36
37
|
propertyKey: string;
|
|
@@ -96,7 +96,7 @@ export const TableReferenceFieldSuccess = React.memo(
|
|
|
96
96
|
const valueNotSet = !internalValue || (Array.isArray(internalValue) && internalValue.length === 0);
|
|
97
97
|
|
|
98
98
|
const buildSingleReferenceField = () => {
|
|
99
|
-
if (internalValue
|
|
99
|
+
if (internalValue && !Array.isArray(internalValue) && internalValue.isEntityReference && internalValue.isEntityReference())
|
|
100
100
|
return <ReferencePreview
|
|
101
101
|
onClick={disabled ? undefined : handleOpen}
|
|
102
102
|
size={getPreviewSizeFrom(size)}
|
|
@@ -433,7 +433,7 @@ export const EntityCollectionView = React.memo(
|
|
|
433
433
|
|
|
434
434
|
const largeLayout = useLargeLayout();
|
|
435
435
|
|
|
436
|
-
const getActionsForEntity =
|
|
436
|
+
const getActionsForEntity = ({ entity, customEntityActions }: {
|
|
437
437
|
entity?: Entity<M>,
|
|
438
438
|
customEntityActions?: EntityAction[]
|
|
439
439
|
}): EntityAction[] => {
|
|
@@ -446,7 +446,7 @@ export const EntityCollectionView = React.memo(
|
|
|
446
446
|
if (customEntityActions)
|
|
447
447
|
actions.push(...customEntityActions);
|
|
448
448
|
return actions;
|
|
449
|
-
}
|
|
449
|
+
};
|
|
450
450
|
|
|
451
451
|
const getIdColumnWidth = useCallback(() => {
|
|
452
452
|
const entityActions = getActionsForEntity({});
|
|
@@ -456,12 +456,12 @@ export const EntityCollectionView = React.memo(
|
|
|
456
456
|
return (largeLayout ? (80 + actionsWidth) : (70 + actionsWidth)) + (collapsedActions.length > 0 ? (largeLayout ? 40 : 30) : 0);
|
|
457
457
|
}, [largeLayout]);
|
|
458
458
|
|
|
459
|
-
const tableRowActionsBuilder =
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
459
|
+
const tableRowActionsBuilder = ({
|
|
460
|
+
entity,
|
|
461
|
+
size,
|
|
462
|
+
width,
|
|
463
|
+
frozen
|
|
464
|
+
}: {
|
|
465
465
|
entity: Entity<any>,
|
|
466
466
|
size: CollectionSize,
|
|
467
467
|
width: number,
|
|
@@ -491,7 +491,7 @@ export const EntityCollectionView = React.memo(
|
|
|
491
491
|
/>
|
|
492
492
|
);
|
|
493
493
|
|
|
494
|
-
}
|
|
494
|
+
};
|
|
495
495
|
|
|
496
496
|
const title = <Popover
|
|
497
497
|
open={popOverOpen}
|
|
@@ -9,13 +9,13 @@ import { Button, cn } from "@firecms/ui";
|
|
|
9
9
|
export type ReferenceWidgetProps<M extends Record<string, any>> = {
|
|
10
10
|
name?: string,
|
|
11
11
|
multiselect?: boolean,
|
|
12
|
-
value: EntityReference
|
|
12
|
+
value: EntityReference | EntityReference[] | null,
|
|
13
13
|
onReferenceSelected?: (params: {
|
|
14
|
-
reference: EntityReference
|
|
14
|
+
reference: EntityReference | null,
|
|
15
15
|
entity: Entity<M> | null
|
|
16
16
|
}) => void,
|
|
17
17
|
onMultipleReferenceSelected?: (params: {
|
|
18
|
-
references: EntityReference
|
|
18
|
+
references: EntityReference[] | null,
|
|
19
19
|
entities: Entity<M>[] | null
|
|
20
20
|
}) => void,
|
|
21
21
|
path: string,
|
|
@@ -113,7 +113,7 @@ export function ReferenceWidget<M extends Record<string, any>>({
|
|
|
113
113
|
size={size}/>
|
|
114
114
|
})}
|
|
115
115
|
</div>
|
|
116
|
-
} else if (value
|
|
116
|
+
} else if (value?.isEntityReference && value?.isEntityReference()) {
|
|
117
117
|
child = <ReferencePreview
|
|
118
118
|
reference={value}
|
|
119
119
|
onClick={onEntryClick}
|
|
@@ -60,7 +60,7 @@ export function ReferenceFilterField({
|
|
|
60
60
|
|
|
61
61
|
const selectedEntityIds = internalValue
|
|
62
62
|
? (Array.isArray(internalValue) ? internalValue.map((ref) => {
|
|
63
|
-
if (!(ref
|
|
63
|
+
if (!(ref?.isEntityReference && ref?.isEntityReference())) {
|
|
64
64
|
return null;
|
|
65
65
|
}
|
|
66
66
|
return ref.id;
|
|
@@ -74,7 +74,7 @@ export function ReferenceFilterField({
|
|
|
74
74
|
let newValue = val;
|
|
75
75
|
if (prevOpIsArray !== newOpIsArray) {
|
|
76
76
|
// @ts-ignore
|
|
77
|
-
newValue = newOpIsArray ? (newValue
|
|
77
|
+
newValue = newOpIsArray ? (newValue?.isEntityReference && newValue?.isEntityReference() ? [newValue] : []) : undefined
|
|
78
78
|
}
|
|
79
79
|
|
|
80
80
|
setOperation(op);
|
package/src/components/index.tsx
CHANGED
|
@@ -4,7 +4,7 @@ import { EntitySidePanelProps } from "../types";
|
|
|
4
4
|
import { useNavigationController } from "../hooks";
|
|
5
5
|
|
|
6
6
|
import { ErrorBoundary } from "../components";
|
|
7
|
-
import { EntityView } from "
|
|
7
|
+
import { EntityView } from "./EntityView";
|
|
8
8
|
import { useSideDialogContext } from "./SideDialogs";
|
|
9
9
|
|
|
10
10
|
/**
|
|
@@ -32,8 +32,8 @@ import {
|
|
|
32
32
|
import { EntityForm } from "../form";
|
|
33
33
|
import { CircularProgress, CloseIcon, cn, defaultBorderMixin, IconButton, Tab, Tabs, Typography } from "@firecms/ui";
|
|
34
34
|
import { EntityFormSaveParams } from "../form/EntityForm";
|
|
35
|
-
import { FORM_CONTAINER_WIDTH } from "
|
|
36
|
-
import { useSideDialogContext } from "
|
|
35
|
+
import { FORM_CONTAINER_WIDTH } from "../internal/common";
|
|
36
|
+
import { useSideDialogContext } from "./index";
|
|
37
37
|
|
|
38
38
|
const MAIN_TAB_VALUE = "main_##Q$SC^#S6";
|
|
39
39
|
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { EntityViewProps } from "./EntityView";
|
|
2
|
+
import { User } from "../types";
|
|
3
|
+
import { useSideDialogContext } from "./SideDialogs";
|
|
4
|
+
import { useSideEntityController } from "../hooks";
|
|
5
|
+
import { FORM_CONTAINER_WIDTH } from "../internal/common";
|
|
6
|
+
|
|
7
|
+
export type SideEntityViewProps<M extends Record<string, any>> = EntityViewProps<M> & {
|
|
8
|
+
formWidth?: number | string;
|
|
9
|
+
onClose?: () => void;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function SideEntityView<M extends Record<string, any>, UserType extends User>({
|
|
13
|
+
path,
|
|
14
|
+
entityId,
|
|
15
|
+
selectedSubPath,
|
|
16
|
+
copy,
|
|
17
|
+
collection,
|
|
18
|
+
parentCollectionIds,
|
|
19
|
+
onValuesAreModified,
|
|
20
|
+
formWidth,
|
|
21
|
+
onUpdate,
|
|
22
|
+
onClose
|
|
23
|
+
}: SideEntityViewProps<M>) {
|
|
24
|
+
|
|
25
|
+
const sideDialogContext = useSideDialogContext();
|
|
26
|
+
const sideEntityController = useSideEntityController();
|
|
27
|
+
const resolvedFormWidth: string = typeof formWidth === "number" ? `${formWidth}px` : formWidth ?? FORM_CONTAINER_WIDTH;
|
|
28
|
+
|
|
29
|
+
const onCloseHandler = () => {
|
|
30
|
+
if (onClose) {
|
|
31
|
+
onClose();
|
|
32
|
+
} else {
|
|
33
|
+
sideDialogContext.close();
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return <></>;
|
|
38
|
+
}
|
package/src/core/index.tsx
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { FieldProps } from "../../types";
|
|
3
|
-
import { FieldHelperText } from "../components";
|
|
3
|
+
import { FieldHelperText, LabelWithIcon } from "../components";
|
|
4
4
|
import { PropertyFieldBinding } from "../PropertyFieldBinding";
|
|
5
|
-
import { useClearRestoreValue } from "../../hooks";
|
|
6
5
|
import { ExpandablePanel } from "@firecms/ui";
|
|
7
6
|
import { getIconForProperty } from "../../util";
|
|
8
|
-
import {
|
|
7
|
+
import { useClearRestoreValue } from "../useClearRestoreValue";
|
|
9
8
|
|
|
10
9
|
/**
|
|
11
10
|
* Array field used for custom
|
|
@@ -1,12 +1,13 @@
|
|
|
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, FormikArrayContainer } from "../components";
|
|
5
|
-
import { ErrorView
|
|
4
|
+
import { FieldHelperText, FormikArrayContainer, LabelWithIcon } from "../components";
|
|
5
|
+
import { ErrorView } from "../../components";
|
|
6
6
|
import { getIconForProperty, getReferenceFrom } from "../../util";
|
|
7
7
|
|
|
8
|
-
import {
|
|
8
|
+
import { useNavigationController, useReferenceDialog } from "../../hooks";
|
|
9
9
|
import { Button, ExpandablePanel } from "@firecms/ui";
|
|
10
|
+
import { useClearRestoreValue } from "../useClearRestoreValue";
|
|
10
11
|
|
|
11
12
|
type ArrayOfReferencesFieldProps = FieldProps<EntityReference[]>;
|
|
12
13
|
|
|
@@ -2,15 +2,14 @@ import React, { useCallback, useEffect, useState } from "react";
|
|
|
2
2
|
|
|
3
3
|
import { Field, useFormex } from "@firecms/formex";
|
|
4
4
|
|
|
5
|
-
import { FieldHelperText, FormikArrayContainer } from "../components";
|
|
6
|
-
import { LabelWithIcon } from "../../components";
|
|
7
|
-
import { useClearRestoreValue } from "../../hooks";
|
|
5
|
+
import { FieldHelperText, FormikArrayContainer, LabelWithIcon } from "../components";
|
|
8
6
|
import { PropertyFieldBinding } from "../PropertyFieldBinding";
|
|
9
7
|
import { EnumValuesChip } from "../../preview";
|
|
10
8
|
import { FieldProps, FormContext, PropertyFieldBindingProps, PropertyOrBuilder } from "../../types";
|
|
11
9
|
import { getDefaultValueFor, getIconForProperty, } from "../../util";
|
|
12
10
|
import { DEFAULT_ONE_OF_TYPE, DEFAULT_ONE_OF_VALUE } from "../../util/common";
|
|
13
11
|
import { cn, ExpandablePanel, paperMixin, Select, SelectItem, Typography } from "@firecms/ui";
|
|
12
|
+
import { useClearRestoreValue } from "../useClearRestoreValue";
|
|
14
13
|
|
|
15
14
|
/**
|
|
16
15
|
* If the `oneOf` property is specified, this fields render each array entry as
|
|
@@ -2,11 +2,11 @@ import React from "react";
|
|
|
2
2
|
|
|
3
3
|
import { FieldProps } from "../../types";
|
|
4
4
|
|
|
5
|
-
import { FieldHelperText } from "../components";
|
|
6
|
-
import {
|
|
7
|
-
import { useClearRestoreValue, useCustomizationController } from "../../hooks";
|
|
5
|
+
import { FieldHelperText, LabelWithIcon } from "../components";
|
|
6
|
+
import { useCustomizationController } from "../../hooks";
|
|
8
7
|
import { getIconForProperty } from "../../util";
|
|
9
8
|
import { DateTimeField } from "@firecms/ui";
|
|
9
|
+
import { useClearRestoreValue } from "../useClearRestoreValue";
|
|
10
10
|
|
|
11
11
|
type DateTimeFieldProps = FieldProps<Date>;
|
|
12
12
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import React, { useEffect, useState } from "react";
|
|
2
|
-
import { DataType,
|
|
2
|
+
import { DataType, FieldProps, GeoPoint } from "../../types";
|
|
3
3
|
|
|
4
|
-
import { ArrayContainer
|
|
5
|
-
import { FieldHelperText } from "../components";
|
|
4
|
+
import { ArrayContainer } from "../../components";
|
|
5
|
+
import { FieldHelperText, LabelWithIcon } from "../components";
|
|
6
6
|
import {
|
|
7
7
|
AddIcon,
|
|
8
8
|
ArrowDropDownIcon,
|
|
@@ -546,7 +546,7 @@ function getDataType(value: any): DataType | undefined {
|
|
|
546
546
|
return "array";
|
|
547
547
|
} else if (value instanceof Date) {
|
|
548
548
|
return "date";
|
|
549
|
-
} else if (value
|
|
549
|
+
} else if (value?.isEntityReference && value?.isEntityReference()) {
|
|
550
550
|
return "reference";
|
|
551
551
|
} else if (value instanceof GeoPoint) {
|
|
552
552
|
return "geopoint";
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { FieldProps, Properties, ResolvedProperties } from "../../types";
|
|
3
3
|
|
|
4
|
-
import { ErrorBoundary
|
|
4
|
+
import { ErrorBoundary } from "../../components";
|
|
5
5
|
import { getIconForProperty, isHidden, pick } from "../../util";
|
|
6
|
-
import { FieldHelperText } from "../components";
|
|
6
|
+
import { FieldHelperText, LabelWithIcon } from "../components";
|
|
7
7
|
import { PropertyFieldBinding } from "../PropertyFieldBinding";
|
|
8
8
|
import { ExpandablePanel, InputLabel, Select, SelectItem } from "@firecms/ui";
|
|
9
9
|
|
|
@@ -4,8 +4,7 @@ import React, { useDeferredValue, useEffect, useRef } from "react";
|
|
|
4
4
|
import MarkdownIt from "markdown-it";
|
|
5
5
|
import MdEditor, { Plugins } from "react-markdown-editor-lite";
|
|
6
6
|
|
|
7
|
-
import { FieldHelperText } from "../components";
|
|
8
|
-
import { LabelWithIcon } from "../../components";
|
|
7
|
+
import { FieldHelperText, LabelWithIcon } from "../components";
|
|
9
8
|
import { FieldProps } from "../../types";
|
|
10
9
|
import { getIconForProperty } from "../../util";
|
|
11
10
|
import {
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import React, { useCallback } from "react";
|
|
2
2
|
|
|
3
3
|
import { EnumType, FieldProps, ResolvedProperty } from "../../types";
|
|
4
|
-
import { FieldHelperText } from "../components";
|
|
5
|
-
import { LabelWithIcon } from "../../components";
|
|
6
|
-
import { useClearRestoreValue } from "../../hooks";
|
|
4
|
+
import { FieldHelperText, LabelWithIcon } from "../components";
|
|
7
5
|
import { EnumValuesChip } from "../../preview";
|
|
8
6
|
import { enumToObjectEntries, getIconForProperty, getLabelOrConfigFrom } from "../../util";
|
|
9
7
|
import { CloseIcon, MultiSelect, MultiSelectItem } from "@firecms/ui";
|
|
8
|
+
import { useClearRestoreValue } from "../useClearRestoreValue";
|
|
10
9
|
|
|
11
10
|
/**
|
|
12
11
|
* This fields renders a dropdown with multiple selection.
|
|
@@ -3,8 +3,8 @@ import React from "react";
|
|
|
3
3
|
import { Entity, FieldProps } from "../../types";
|
|
4
4
|
|
|
5
5
|
import { PropertyPreview } from "../../preview";
|
|
6
|
-
import { FieldHelperText } from "../components";
|
|
7
|
-
import { ErrorBoundary
|
|
6
|
+
import { FieldHelperText, LabelWithIcon } from "../components";
|
|
7
|
+
import { ErrorBoundary } from "../../components";
|
|
8
8
|
import { getIconForProperty } from "../../util";
|
|
9
9
|
import { cn, paperMixin } from "@firecms/ui";
|
|
10
10
|
|