@firecms/core 3.0.0-canary.53 → 3.0.0-canary.55
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/fields/TableReferenceField.d.ts +2 -0
- package/dist/components/EntityCollectionTable/internal/EntityTableCell.d.ts +2 -2
- package/dist/components/EntityPreview.d.ts +3 -2
- package/dist/components/FireCMSAppBar.d.ts +2 -1
- package/dist/components/ReferenceWidget.d.ts +3 -1
- package/dist/components/SelectableTable/filters/ReferenceFilterField.d.ts +2 -1
- package/dist/components/VirtualTable/VirtualTableProps.d.ts +1 -6
- package/dist/components/VirtualTable/types.d.ts +3 -3
- package/dist/components/common/table_height.d.ts +5 -0
- package/dist/components/index.d.ts +1 -0
- package/dist/index.es.js +2017 -1973
- 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/preview/components/ReferencePreview.d.ts +2 -1
- package/dist/types/properties.d.ts +8 -0
- package/package.json +6 -6
- package/src/components/EntityCollectionTable/EntityCollectionTable.tsx +1 -1
- package/src/components/EntityCollectionTable/PropertyTableCell.tsx +5 -2
- package/src/components/EntityCollectionTable/fields/TableReferenceField.tsx +9 -1
- package/src/components/EntityCollectionTable/internal/EntityTableCell.tsx +2 -3
- package/src/components/EntityPreview.tsx +6 -4
- package/src/components/FireCMSAppBar.tsx +5 -2
- package/src/components/ReferenceWidget.tsx +19 -9
- package/src/components/SelectableTable/SelectableTable.tsx +4 -2
- package/src/components/SelectableTable/filters/ReferenceFilterField.tsx +4 -1
- package/src/components/VirtualTable/VirtualTable.tsx +7 -8
- package/src/components/VirtualTable/VirtualTableProps.tsx +1 -6
- package/src/components/VirtualTable/VirtualTableRow.tsx +2 -3
- package/src/components/VirtualTable/types.tsx +2 -3
- package/src/components/{VirtualTable/common.tsx → common/table_height.tsx} +5 -2
- package/src/components/index.tsx +1 -0
- package/src/core/EntityEditView.tsx +3 -2
- package/src/core/FireCMS.tsx +33 -36
- package/src/form/EntityForm.tsx +7 -10
- package/src/form/field_bindings/ArrayOfReferencesFieldBinding.tsx +2 -0
- package/src/form/field_bindings/ReferenceFieldBinding.tsx +15 -13
- package/src/form/field_bindings/SelectFieldBinding.tsx +0 -3
- package/src/hooks/data/save.ts +2 -0
- package/src/hooks/useValidateAuthenticator.tsx +15 -15
- package/src/preview/PropertyPreview.tsx +2 -1
- package/src/preview/components/ReferencePreview.tsx +21 -22
- package/src/preview/property_previews/ArrayOfReferencesPreview.tsx +2 -0
- package/src/preview/property_previews/NumberPropertyPreview.tsx +0 -1
- package/src/types/properties.ts +10 -0
- package/dist/components/VirtualTable/common.d.ts +0 -2
|
@@ -8,7 +8,8 @@ export type ReferencePreviewProps = {
|
|
|
8
8
|
previewProperties?: string[];
|
|
9
9
|
onClick?: (e: React.SyntheticEvent) => void;
|
|
10
10
|
hover?: boolean;
|
|
11
|
-
|
|
11
|
+
includeEntityLink?: boolean;
|
|
12
|
+
includeId?: boolean;
|
|
12
13
|
};
|
|
13
14
|
/**
|
|
14
15
|
* @group Preview components
|
|
@@ -474,6 +474,14 @@ export interface ReferenceProperty extends BaseProperty<EntityReference> {
|
|
|
474
474
|
* specified values are considered.
|
|
475
475
|
*/
|
|
476
476
|
previewProperties?: string[];
|
|
477
|
+
/**
|
|
478
|
+
* Should the reference include the ID of the entity. Defaults to `true`
|
|
479
|
+
*/
|
|
480
|
+
includeId?: boolean;
|
|
481
|
+
/**
|
|
482
|
+
* Should the reference include a link to the entity (open the entity details). Defaults to `true`
|
|
483
|
+
*/
|
|
484
|
+
includeEntityLink?: boolean;
|
|
477
485
|
}
|
|
478
486
|
/**
|
|
479
487
|
* Rules to validate any property. Some properties have specific rules
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@firecms/core",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "3.0.0-canary.
|
|
4
|
+
"version": "3.0.0-canary.55",
|
|
5
5
|
"description": "Awesome Firebase/Firestore-based headless open-source CMS",
|
|
6
6
|
"funding": {
|
|
7
7
|
"url": "https://github.com/sponsors/firecmsco"
|
|
@@ -46,8 +46,8 @@
|
|
|
46
46
|
"./package.json": "./package.json"
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"@firecms/formex": "^3.0.0-canary.
|
|
50
|
-
"@firecms/ui": "^3.0.0-canary.
|
|
49
|
+
"@firecms/formex": "^3.0.0-canary.55",
|
|
50
|
+
"@firecms/ui": "^3.0.0-canary.55",
|
|
51
51
|
"@fontsource/jetbrains-mono": "^5.0.20",
|
|
52
52
|
"@hello-pangea/dnd": "^16.6.0",
|
|
53
53
|
"@radix-ui/react-portal": "^1.0.4",
|
|
@@ -70,8 +70,8 @@
|
|
|
70
70
|
},
|
|
71
71
|
"peerDependencies": {
|
|
72
72
|
"firebase": "^10.5.2",
|
|
73
|
-
"react": "^18.
|
|
74
|
-
"react-dom": "^18.
|
|
73
|
+
"react": "^18.3.1",
|
|
74
|
+
"react-dom": "^18.3.1",
|
|
75
75
|
"react-router": "^6.22.0",
|
|
76
76
|
"react-router-dom": "^6.22.0"
|
|
77
77
|
},
|
|
@@ -111,7 +111,7 @@
|
|
|
111
111
|
"dist",
|
|
112
112
|
"src"
|
|
113
113
|
],
|
|
114
|
-
"gitHead": "
|
|
114
|
+
"gitHead": "504f907bf8ecf1b7ed81fa1f84d3461c06efb39a",
|
|
115
115
|
"publishConfig": {
|
|
116
116
|
"access": "public"
|
|
117
117
|
},
|
|
@@ -5,7 +5,6 @@ import { ErrorBoundary } from "../ErrorBoundary";
|
|
|
5
5
|
import { useFireCMSContext, useLargeLayout } from "../../hooks";
|
|
6
6
|
import { CellRendererParams, VirtualTableColumn } from "../VirtualTable";
|
|
7
7
|
import { getValueInPath } from "../../util";
|
|
8
|
-
import { getRowHeight } from "../VirtualTable/common";
|
|
9
8
|
import { EntityCollectionRowActions } from "./EntityCollectionRowActions";
|
|
10
9
|
import { CollectionTableToolbar } from "./internal/CollectionTableToolbar";
|
|
11
10
|
import { EntityCollectionTableProps } from "./EntityCollectionTableProps";
|
|
@@ -16,6 +15,7 @@ import { propertiesToColumns } from "./column_utils";
|
|
|
16
15
|
import { ErrorView } from "../ErrorView";
|
|
17
16
|
import { SelectableTable } from "../SelectableTable/SelectableTable";
|
|
18
17
|
import { cn } from "@firecms/ui";
|
|
18
|
+
import { getRowHeight } from "../common/table_height";
|
|
19
19
|
|
|
20
20
|
/**
|
|
21
21
|
* This component is in charge of rendering a collection table with a high
|
|
@@ -24,14 +24,13 @@ import { getPreviewSizeFrom } from "../../preview/util";
|
|
|
24
24
|
import { isReadOnly } from "../../util";
|
|
25
25
|
|
|
26
26
|
import { CustomFieldValidator, mapPropertyToYup } from "../../form/validation";
|
|
27
|
-
import { useFireCMSContext } from "../../hooks";
|
|
28
27
|
|
|
29
28
|
import { EntityTableCell } from "./internal/EntityTableCell";
|
|
30
29
|
import { EntityTableCellActions } from "./internal/EntityTableCellActions";
|
|
31
30
|
|
|
32
|
-
import { getRowHeight } from "../VirtualTable/common";
|
|
33
31
|
import { useSelectableTableController } from "../SelectableTable/SelectableTableContext";
|
|
34
32
|
import { useClearRestoreValue } from "../../form/useClearRestoreValue";
|
|
33
|
+
import { getRowHeight } from "../common/table_height";
|
|
35
34
|
|
|
36
35
|
export interface PropertyTableCellProps<T extends CMSType> {
|
|
37
36
|
propertyKey: string;
|
|
@@ -348,6 +347,8 @@ export const PropertyTableCell = React.memo<PropertyTableCellProps<any>>(
|
|
|
348
347
|
path={property.path}
|
|
349
348
|
multiselect={false}
|
|
350
349
|
previewProperties={property.previewProperties}
|
|
350
|
+
includeId={property.includeId}
|
|
351
|
+
includeEntityLink={property.includeEntityLink}
|
|
351
352
|
title={property.name}
|
|
352
353
|
forceFilter={property.forceFilter}
|
|
353
354
|
/>;
|
|
@@ -392,6 +393,8 @@ export const PropertyTableCell = React.memo<PropertyTableCellProps<any>>(
|
|
|
392
393
|
previewProperties={arrayProperty.of.previewProperties}
|
|
393
394
|
title={arrayProperty.name}
|
|
394
395
|
forceFilter={arrayProperty.of.forceFilter}
|
|
396
|
+
includeId={arrayProperty.of.includeId}
|
|
397
|
+
includeEntityLink={arrayProperty.of.includeEntityLink}
|
|
395
398
|
/>;
|
|
396
399
|
}
|
|
397
400
|
allowScroll = false;
|
|
@@ -22,6 +22,8 @@ type TableReferenceFieldProps = {
|
|
|
22
22
|
title?: string;
|
|
23
23
|
path: string;
|
|
24
24
|
forceFilter?: FilterValues<string>;
|
|
25
|
+
includeId?: boolean;
|
|
26
|
+
includeEntityLink?: boolean;
|
|
25
27
|
};
|
|
26
28
|
|
|
27
29
|
export function TableReferenceField(props: TableReferenceFieldProps) {
|
|
@@ -55,7 +57,9 @@ export const TableReferenceFieldSuccess = React.memo(
|
|
|
55
57
|
title,
|
|
56
58
|
disabled,
|
|
57
59
|
forceFilter,
|
|
58
|
-
collection
|
|
60
|
+
collection,
|
|
61
|
+
includeId,
|
|
62
|
+
includeEntityLink
|
|
59
63
|
} = props;
|
|
60
64
|
|
|
61
65
|
const onSingleEntitySelected = useCallback((entity: Entity<any>) => {
|
|
@@ -100,6 +104,8 @@ export const TableReferenceFieldSuccess = React.memo(
|
|
|
100
104
|
hover={!disabled}
|
|
101
105
|
disabled={!path}
|
|
102
106
|
previewProperties={previewProperties}
|
|
107
|
+
includeId={includeId}
|
|
108
|
+
includeEntityLink={includeEntityLink}
|
|
103
109
|
/>;
|
|
104
110
|
else
|
|
105
111
|
return <EntityPreviewContainer
|
|
@@ -122,6 +128,8 @@ export const TableReferenceFieldSuccess = React.memo(
|
|
|
122
128
|
hover={!disabled}
|
|
123
129
|
disabled={!path}
|
|
124
130
|
previewProperties={previewProperties}
|
|
131
|
+
includeId={includeId}
|
|
132
|
+
includeEntityLink={includeEntityLink}
|
|
125
133
|
/>
|
|
126
134
|
</div>
|
|
127
135
|
)
|
|
@@ -2,10 +2,9 @@ import React, { useCallback, useEffect, useMemo, useRef, useState } from "react"
|
|
|
2
2
|
|
|
3
3
|
import useMeasure from "react-use-measure";
|
|
4
4
|
|
|
5
|
-
import { VirtualTableSize } from "../../VirtualTable";
|
|
6
|
-
import { getRowHeight } from "../../VirtualTable/common";
|
|
7
5
|
import { cn, RemoveCircleIcon, Tooltip } from "@firecms/ui";
|
|
8
6
|
import { ErrorBoundary } from "../../../components";
|
|
7
|
+
import { getRowHeight, TableSize } from "../../common/table_height";
|
|
9
8
|
|
|
10
9
|
interface EntityTableCellProps {
|
|
11
10
|
children: React.ReactNode;
|
|
@@ -19,7 +18,7 @@ interface EntityTableCellProps {
|
|
|
19
18
|
error?: Error;
|
|
20
19
|
allowScroll?: boolean;
|
|
21
20
|
align: "right" | "left" | "center";
|
|
22
|
-
size:
|
|
21
|
+
size: TableSize;
|
|
23
22
|
disabledTooltip?: string;
|
|
24
23
|
width: number;
|
|
25
24
|
showExpandIcon?: boolean;
|
|
@@ -23,7 +23,8 @@ export type EntityPreviewProps = {
|
|
|
23
23
|
previewProperties?: string[],
|
|
24
24
|
disabled: undefined | boolean,
|
|
25
25
|
entity: Entity<any>,
|
|
26
|
-
|
|
26
|
+
includeId?: boolean,
|
|
27
|
+
includeEntityLink?: boolean,
|
|
27
28
|
onClick?: (e: React.SyntheticEvent) => void;
|
|
28
29
|
};
|
|
29
30
|
|
|
@@ -39,7 +40,8 @@ export function EntityPreview({
|
|
|
39
40
|
previewProperties,
|
|
40
41
|
onClick,
|
|
41
42
|
size,
|
|
42
|
-
|
|
43
|
+
includeId = true,
|
|
44
|
+
includeEntityLink = true,
|
|
43
45
|
entity
|
|
44
46
|
}: EntityPreviewProps) {
|
|
45
47
|
|
|
@@ -85,7 +87,7 @@ export function EntityPreview({
|
|
|
85
87
|
|
|
86
88
|
<div className={"flex flex-col flex-grow w-full m-1"}>
|
|
87
89
|
|
|
88
|
-
{size !== "tiny" && (
|
|
90
|
+
{size !== "tiny" && includeId && (
|
|
89
91
|
entity
|
|
90
92
|
? <div className={`${
|
|
91
93
|
size !== "medium"
|
|
@@ -140,7 +142,7 @@ export function EntityPreview({
|
|
|
140
142
|
|
|
141
143
|
</div>
|
|
142
144
|
|
|
143
|
-
{entity &&
|
|
145
|
+
{entity && includeEntityLink &&
|
|
144
146
|
<Tooltip title={`See details for ${entity.id}`}
|
|
145
147
|
className={size !== "tiny" ? "self-start" : ""}>
|
|
146
148
|
<IconButton
|
|
@@ -31,6 +31,8 @@ export type FireCMSAppBarProps<ADDITIONAL_PROPS = object> = {
|
|
|
31
31
|
|
|
32
32
|
includeDrawer?: boolean;
|
|
33
33
|
|
|
34
|
+
includeModeToggle?: boolean;
|
|
35
|
+
|
|
34
36
|
drawerOpen: boolean;
|
|
35
37
|
|
|
36
38
|
className?: string;
|
|
@@ -58,6 +60,7 @@ export const FireCMSAppBar = function FireCMSAppBar({
|
|
|
58
60
|
drawerOpen,
|
|
59
61
|
dropDownActions,
|
|
60
62
|
includeDrawer,
|
|
63
|
+
includeModeToggle = true,
|
|
61
64
|
className,
|
|
62
65
|
style,
|
|
63
66
|
logo,
|
|
@@ -144,7 +147,7 @@ export const FireCMSAppBar = function FireCMSAppBar({
|
|
|
144
147
|
{endAdornment}
|
|
145
148
|
</ErrorBoundary>}
|
|
146
149
|
|
|
147
|
-
<IconButton
|
|
150
|
+
{includeModeToggle && <IconButton
|
|
148
151
|
color="inherit"
|
|
149
152
|
aria-label="Open drawer"
|
|
150
153
|
onClick={toggleMode}
|
|
@@ -152,7 +155,7 @@ export const FireCMSAppBar = function FireCMSAppBar({
|
|
|
152
155
|
{mode === "dark"
|
|
153
156
|
? <DarkModeIcon/>
|
|
154
157
|
: <LightModeIcon/>}
|
|
155
|
-
</IconButton>
|
|
158
|
+
</IconButton>}
|
|
156
159
|
|
|
157
160
|
<Menu trigger={avatarComponent}>
|
|
158
161
|
{user && <div className={"px-4 py-2 mb-2"}>
|
|
@@ -27,6 +27,8 @@ export type ReferenceWidgetProps<M extends Record<string, any>> = {
|
|
|
27
27
|
forceFilter?: FilterValues<string>;
|
|
28
28
|
size: PreviewSize;
|
|
29
29
|
className?: string;
|
|
30
|
+
includeId?: boolean;
|
|
31
|
+
includeEntityLink?: boolean;
|
|
30
32
|
};
|
|
31
33
|
|
|
32
34
|
/**
|
|
@@ -43,7 +45,9 @@ export function ReferenceWidget<M extends Record<string, any>>({
|
|
|
43
45
|
previewProperties,
|
|
44
46
|
forceFilter,
|
|
45
47
|
size,
|
|
46
|
-
className
|
|
48
|
+
className,
|
|
49
|
+
includeId,
|
|
50
|
+
includeEntityLink
|
|
47
51
|
}: ReferenceWidgetProps<M>) {
|
|
48
52
|
|
|
49
53
|
const navigationController = useNavigationController();
|
|
@@ -52,16 +56,15 @@ export function ReferenceWidget<M extends Record<string, any>>({
|
|
|
52
56
|
return navigationController.getCollection(path);
|
|
53
57
|
}, [path, navigationController.getCollection]);
|
|
54
58
|
|
|
55
|
-
// if (!collection) {
|
|
56
|
-
// throw Error(`Couldn't find the corresponding collection for the path: ${path}`);
|
|
57
|
-
// }
|
|
58
|
-
|
|
59
59
|
const onSingleEntitySelected = useCallback((entity: Entity<M> | null) => {
|
|
60
60
|
if (disabled)
|
|
61
61
|
return;
|
|
62
62
|
if (onReferenceSelected) {
|
|
63
63
|
const reference = entity ? getReferenceFrom(entity) : null;
|
|
64
|
-
onReferenceSelected?.({
|
|
64
|
+
onReferenceSelected?.({
|
|
65
|
+
reference,
|
|
66
|
+
entity
|
|
67
|
+
});
|
|
65
68
|
}
|
|
66
69
|
}, [disabled, onReferenceSelected]);
|
|
67
70
|
|
|
@@ -70,7 +73,10 @@ export function ReferenceWidget<M extends Record<string, any>>({
|
|
|
70
73
|
return;
|
|
71
74
|
if (onMultipleReferenceSelected) {
|
|
72
75
|
const references = entities ? entities.map(e => getReferenceFrom(e)) : null;
|
|
73
|
-
onMultipleReferenceSelected({
|
|
76
|
+
onMultipleReferenceSelected({
|
|
77
|
+
references,
|
|
78
|
+
entities
|
|
79
|
+
});
|
|
74
80
|
}
|
|
75
81
|
}, [disabled, onReferenceSelected]);
|
|
76
82
|
|
|
@@ -110,7 +116,9 @@ export function ReferenceWidget<M extends Record<string, any>>({
|
|
|
110
116
|
reference={ref}
|
|
111
117
|
disabled={disabled}
|
|
112
118
|
previewProperties={previewProperties}
|
|
113
|
-
size={size}
|
|
119
|
+
size={size}
|
|
120
|
+
includeId={includeId}
|
|
121
|
+
includeEntityLink={includeEntityLink}/>
|
|
114
122
|
})}
|
|
115
123
|
</div>
|
|
116
124
|
} else if (value?.isEntityReference && value?.isEntityReference()) {
|
|
@@ -119,7 +127,9 @@ export function ReferenceWidget<M extends Record<string, any>>({
|
|
|
119
127
|
onClick={onEntryClick}
|
|
120
128
|
disabled={disabled}
|
|
121
129
|
previewProperties={previewProperties}
|
|
122
|
-
size={size}
|
|
130
|
+
size={size}
|
|
131
|
+
includeId={includeId}
|
|
132
|
+
includeEntityLink={includeEntityLink}/>
|
|
123
133
|
|
|
124
134
|
}
|
|
125
135
|
return <div className={cn("text-sm font-medium",
|
|
@@ -18,6 +18,7 @@ import { BooleanFilterField } from "./filters/BooleanFilterField";
|
|
|
18
18
|
import { DateTimeFilterField } from "./filters/DateTimeFilterField";
|
|
19
19
|
import { useOutsideAlerter } from "@firecms/ui";
|
|
20
20
|
import { SelectableTableContext } from "./SelectableTableContext";
|
|
21
|
+
import { getRowHeight } from "../common/table_height";
|
|
21
22
|
|
|
22
23
|
export type SelectableTableProps<M extends Record<string, any>> = {
|
|
23
24
|
|
|
@@ -115,7 +116,7 @@ export const SelectableTable = React.memo<SelectableTableProps<any>>(
|
|
|
115
116
|
onEntityClick,
|
|
116
117
|
onColumnResize,
|
|
117
118
|
hoverRow = true,
|
|
118
|
-
size,
|
|
119
|
+
size = "m",
|
|
119
120
|
inlineEditing = false,
|
|
120
121
|
tableController:
|
|
121
122
|
{
|
|
@@ -224,7 +225,7 @@ export const SelectableTable = React.memo<SelectableTableProps<any>>(
|
|
|
224
225
|
error={dataLoadingError}
|
|
225
226
|
paginationEnabled={paginationEnabled}
|
|
226
227
|
onColumnResize={onColumnResize}
|
|
227
|
-
|
|
228
|
+
rowHeight={getRowHeight(size)}
|
|
228
229
|
loading={dataLoading}
|
|
229
230
|
filter={filterValues}
|
|
230
231
|
onFilterUpdate={setFilterValues ? onFilterUpdate : undefined}
|
|
@@ -280,6 +281,7 @@ function createFilterField({
|
|
|
280
281
|
isArray={isArray}
|
|
281
282
|
path={baseProperty.path}
|
|
282
283
|
title={resolvedProperty?.name}
|
|
284
|
+
includeId={baseProperty.includeId}
|
|
283
285
|
previewProperties={baseProperty?.previewProperties}
|
|
284
286
|
hidden={hidden}
|
|
285
287
|
setHidden={setHidden}/>;
|
|
@@ -13,6 +13,7 @@ interface ReferenceFilterFieldProps {
|
|
|
13
13
|
isArray?: boolean;
|
|
14
14
|
path?: string;
|
|
15
15
|
title?: string;
|
|
16
|
+
includeId?: boolean;
|
|
16
17
|
previewProperties?: string[];
|
|
17
18
|
hidden: boolean;
|
|
18
19
|
setHidden: (hidden: boolean) => void;
|
|
@@ -40,6 +41,7 @@ export function ReferenceFilterField({
|
|
|
40
41
|
isArray,
|
|
41
42
|
path,
|
|
42
43
|
title,
|
|
44
|
+
includeId = true,
|
|
43
45
|
previewProperties,
|
|
44
46
|
setHidden
|
|
45
47
|
}: ReferenceFilterFieldProps) {
|
|
@@ -134,7 +136,8 @@ export function ReferenceFilterField({
|
|
|
134
136
|
onClick={doOpenDialog}
|
|
135
137
|
reference={reference}
|
|
136
138
|
hover={true}
|
|
137
|
-
|
|
139
|
+
includeId={includeId}
|
|
140
|
+
includeEntityLink={false}
|
|
138
141
|
/>
|
|
139
142
|
);
|
|
140
143
|
};
|
|
@@ -15,7 +15,6 @@ import {
|
|
|
15
15
|
VirtualTableWhereFilterOp
|
|
16
16
|
} from "./VirtualTableProps";
|
|
17
17
|
|
|
18
|
-
import { getRowHeight } from "./common";
|
|
19
18
|
import { VirtualTableContextProps } from "./types";
|
|
20
19
|
import { VirtualTableHeaderRow } from "./VirtualTableHeaderRow";
|
|
21
20
|
import { VirtualTableRow } from "./VirtualTableRow";
|
|
@@ -92,7 +91,7 @@ export const VirtualTable = React.memo<VirtualTableProps<any>>(
|
|
|
92
91
|
data,
|
|
93
92
|
onResetPagination,
|
|
94
93
|
onEndReached,
|
|
95
|
-
|
|
94
|
+
rowHeight = 54,
|
|
96
95
|
columns: columnsProp,
|
|
97
96
|
onRowClick,
|
|
98
97
|
onColumnResize,
|
|
@@ -187,7 +186,7 @@ export const VirtualTable = React.memo<VirtualTableProps<any>>(
|
|
|
187
186
|
onSortByUpdate(undefined);
|
|
188
187
|
}, [onSortByUpdate]);
|
|
189
188
|
|
|
190
|
-
const maxScroll = Math.max((data?.length ?? 0) *
|
|
189
|
+
const maxScroll = Math.max((data?.length ?? 0) * rowHeight - bounds.height, 0);
|
|
191
190
|
const onEndReachedInternal = useCallback((scrollOffset: number) => {
|
|
192
191
|
if (onEndReached && (data?.length ?? 0) > 0 && scrollOffset > endReachCallbackThreshold.current + 600) {
|
|
193
192
|
endReachCallbackThreshold.current = scrollOffset;
|
|
@@ -253,7 +252,7 @@ export const VirtualTable = React.memo<VirtualTableProps<any>>(
|
|
|
253
252
|
|
|
254
253
|
const virtualListController = {
|
|
255
254
|
data,
|
|
256
|
-
|
|
255
|
+
rowHeight: rowHeight,
|
|
257
256
|
cellRenderer,
|
|
258
257
|
columns,
|
|
259
258
|
currentSort,
|
|
@@ -282,13 +281,13 @@ export const VirtualTable = React.memo<VirtualTableProps<any>>(
|
|
|
282
281
|
|
|
283
282
|
<MemoizedList
|
|
284
283
|
outerRef={tableRef}
|
|
285
|
-
key={
|
|
284
|
+
key={rowHeight}
|
|
286
285
|
width={bounds.width}
|
|
287
286
|
height={bounds.height}
|
|
288
287
|
itemCount={(data?.length ?? 0) + (endAdornment ? 1 : 0)}
|
|
289
288
|
onScroll={onScroll}
|
|
290
289
|
includeAddColumn={Boolean(AddColumnComponent)}
|
|
291
|
-
itemSize={
|
|
290
|
+
itemSize={rowHeight}/>
|
|
292
291
|
|
|
293
292
|
</VirtualListContext.Provider>
|
|
294
293
|
</div>
|
|
@@ -328,7 +327,7 @@ function MemoizedList({
|
|
|
328
327
|
onRowClick,
|
|
329
328
|
data,
|
|
330
329
|
columns,
|
|
331
|
-
|
|
330
|
+
rowHeight = 54,
|
|
332
331
|
cellRenderer,
|
|
333
332
|
hoverRow,
|
|
334
333
|
rowClassName,
|
|
@@ -361,7 +360,7 @@ function MemoizedList({
|
|
|
361
360
|
...style,
|
|
362
361
|
top: `calc(${style.top}px + 48px)`
|
|
363
362
|
}}
|
|
364
|
-
|
|
363
|
+
rowHeight={rowHeight}>
|
|
365
364
|
|
|
366
365
|
{columns.map((column: VirtualTableColumn, columnIndex: number) => {
|
|
367
366
|
const cellData = rowData && rowData[column.key];
|
|
@@ -69,7 +69,7 @@ export interface VirtualTableProps<T extends Record<string, any>> {
|
|
|
69
69
|
/**
|
|
70
70
|
* Size of the table
|
|
71
71
|
*/
|
|
72
|
-
|
|
72
|
+
rowHeight?: number,
|
|
73
73
|
|
|
74
74
|
/**
|
|
75
75
|
* In case this table should have some filters set by default
|
|
@@ -232,11 +232,6 @@ export type OnVirtualTableColumnResizeParams = {
|
|
|
232
232
|
column: VirtualTableColumn
|
|
233
233
|
};
|
|
234
234
|
|
|
235
|
-
/**
|
|
236
|
-
* @see Table
|
|
237
|
-
* @group Components
|
|
238
|
-
*/
|
|
239
|
-
export type VirtualTableSize = "xs" | "s" | "m" | "l" | "xl";
|
|
240
235
|
|
|
241
236
|
/**
|
|
242
237
|
* @see Table
|
|
@@ -2,7 +2,6 @@ import React, { useCallback } from "react";
|
|
|
2
2
|
|
|
3
3
|
import equal from "react-fast-compare"
|
|
4
4
|
|
|
5
|
-
import { getRowHeight } from "./common";
|
|
6
5
|
import { VirtualTableRowProps } from "./types";
|
|
7
6
|
import { cn } from "@firecms/ui";
|
|
8
7
|
|
|
@@ -12,7 +11,7 @@ export const VirtualTableRow = React.memo<VirtualTableRowProps<any>>(
|
|
|
12
11
|
rowIndex,
|
|
13
12
|
children,
|
|
14
13
|
onRowClick,
|
|
15
|
-
|
|
14
|
+
rowHeight,
|
|
16
15
|
style,
|
|
17
16
|
hoverRow,
|
|
18
17
|
rowClassName
|
|
@@ -40,7 +39,7 @@ export const VirtualTableRow = React.memo<VirtualTableRowProps<any>>(
|
|
|
40
39
|
onClick={onClick}
|
|
41
40
|
style={{
|
|
42
41
|
...(style),
|
|
43
|
-
height:
|
|
42
|
+
height: rowHeight,
|
|
44
43
|
width: "fit-content"
|
|
45
44
|
}}
|
|
46
45
|
>
|
|
@@ -5,14 +5,13 @@ import {
|
|
|
5
5
|
OnVirtualTableColumnResizeParams,
|
|
6
6
|
VirtualTableColumn,
|
|
7
7
|
VirtualTableFilterValues,
|
|
8
|
-
VirtualTableSize,
|
|
9
8
|
VirtualTableWhereFilterOp
|
|
10
9
|
} from "./VirtualTableProps";
|
|
11
10
|
import { FilterFormFieldProps } from "./VirtualTableHeader";
|
|
12
11
|
|
|
13
12
|
export type VirtualTableRowProps<T> = {
|
|
14
13
|
style: any,
|
|
15
|
-
|
|
14
|
+
rowHeight: number,
|
|
16
15
|
rowData: T;
|
|
17
16
|
rowIndex: number;
|
|
18
17
|
onRowClick?: (props: OnRowClickParams<any>) => void;
|
|
@@ -24,7 +23,7 @@ export type VirtualTableRowProps<T> = {
|
|
|
24
23
|
|
|
25
24
|
export type VirtualTableContextProps<T extends any> = {
|
|
26
25
|
data?: T[];
|
|
27
|
-
|
|
26
|
+
rowHeight?: number,
|
|
28
27
|
columns: VirtualTableColumn[];
|
|
29
28
|
cellRenderer: React.ComponentType<CellRendererParams<T>>;
|
|
30
29
|
currentSort: "asc" | "desc" | undefined;
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @group Components
|
|
3
|
+
*/
|
|
4
|
+
export type TableSize = "xs" | "s" | "m" | "l" | "xl";
|
|
2
5
|
|
|
3
|
-
export function getRowHeight(size:
|
|
6
|
+
export function getRowHeight(size: TableSize): number {
|
|
4
7
|
switch (size) {
|
|
5
8
|
case "xl":
|
|
6
9
|
return 400;
|
package/src/components/index.tsx
CHANGED
|
@@ -13,6 +13,7 @@ export * from "./common";
|
|
|
13
13
|
|
|
14
14
|
export * from "./HomePage";
|
|
15
15
|
export * from "./SelectableTable/SelectableTable";
|
|
16
|
+
export * from "./SelectableTable/SelectableTableContext";
|
|
16
17
|
export * from "./EntityCollectionView/EntityCollectionView";
|
|
17
18
|
export * from "./EntityCollectionView/EntityCollectionViewActions";
|
|
18
19
|
export * from "./EntityCollectionView/useSelectionController";
|
|
@@ -193,6 +193,7 @@ export function EntityEditView<M extends Record<string, any>, UserType extends U
|
|
|
193
193
|
onUpdate({ entity: updatedEntity });
|
|
194
194
|
|
|
195
195
|
if (closeAfterSave) {
|
|
196
|
+
console.log("Closing side dialog")
|
|
196
197
|
sideDialogContext.setBlocked(false);
|
|
197
198
|
sideDialogContext.close(true);
|
|
198
199
|
onClose?.();
|
|
@@ -236,7 +237,7 @@ export function EntityEditView<M extends Record<string, any>, UserType extends U
|
|
|
236
237
|
closeAfterSave: boolean,
|
|
237
238
|
}) => {
|
|
238
239
|
setSaving(true);
|
|
239
|
-
saveEntityWithCallbacks({
|
|
240
|
+
return saveEntityWithCallbacks({
|
|
240
241
|
path,
|
|
241
242
|
entityId,
|
|
242
243
|
values,
|
|
@@ -267,7 +268,7 @@ export function EntityEditView<M extends Record<string, any>, UserType extends U
|
|
|
267
268
|
if (autoSave) {
|
|
268
269
|
setValuesToBeSaved(values);
|
|
269
270
|
} else {
|
|
270
|
-
saveEntity({
|
|
271
|
+
return saveEntity({
|
|
271
272
|
collection,
|
|
272
273
|
path,
|
|
273
274
|
entityId,
|