@firecms/core 3.0.0-beta.2-pre.2 → 3.0.0-beta.2-pre.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/EntityCollectionTable.d.ts +0 -3
- package/dist/components/EntityCollectionTable/EntityCollectionTableProps.d.ts +1 -8
- package/dist/components/EntityCollectionTable/index.d.ts +2 -4
- package/dist/components/EntityCollectionTable/internal/popup_field/PopupFormField.d.ts +1 -1
- package/dist/components/{ReferenceSelectionInner.d.ts → ReferenceTable/ReferenceSelectionTable.d.ts} +2 -2
- package/dist/components/{EntityCollectionTable/SimpleTable.d.ts → SelectableTable/SelectableTable.d.ts} +3 -4
- package/dist/components/SelectableTable/SelectableTableContext.d.ts +4 -0
- package/dist/components/common/index.d.ts +5 -0
- package/dist/components/{EntityCollectionTable → common}/types.d.ts +7 -0
- package/dist/components/common/useTableSearchHelper.d.ts +12 -0
- package/dist/components/index.d.ts +5 -2
- package/dist/form/components/index.d.ts +0 -1
- package/dist/hooks/useSnackbarController.d.ts +1 -0
- package/dist/index.es.js +3705 -3683
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +5 -5
- package/dist/index.umd.js.map +1 -1
- package/package.json +3 -3
- package/src/components/ArrayContainer.tsx +10 -3
- package/src/components/EntityCollectionTable/EntityCollectionTable.tsx +16 -22
- package/src/components/EntityCollectionTable/EntityCollectionTableProps.tsx +1 -5
- package/src/components/EntityCollectionTable/PropertyTableCell.tsx +2 -2
- package/src/components/EntityCollectionTable/column_utils.tsx +1 -1
- package/src/components/EntityCollectionTable/index.tsx +1 -9
- package/src/components/EntityCollectionTable/internal/popup_field/PopupFormField.tsx +2 -1
- package/src/components/EntityCollectionView/EntityCollectionView.tsx +19 -40
- package/src/components/{ReferenceSelectionInner.tsx → ReferenceTable/ReferenceSelectionTable.tsx} +31 -15
- package/src/components/{EntityCollectionTable/SimpleTable.tsx → SelectableTable/SelectableTable.tsx} +8 -9
- package/src/components/SelectableTable/SelectableTableContext.tsx +6 -0
- package/src/components/common/index.ts +5 -0
- package/src/components/{EntityCollectionTable → common}/types.tsx +5 -0
- package/src/components/common/useTableSearchHelper.ts +47 -0
- package/src/components/index.tsx +6 -2
- package/src/core/EntitySidePanel.tsx +7 -5
- package/src/form/EntityForm.tsx +1 -1
- package/src/form/components/index.tsx +0 -1
- package/src/hooks/useFireCMSContext.tsx +51 -3
- package/src/hooks/useReferenceDialog.tsx +2 -2
- package/src/hooks/useSnackbarController.tsx +1 -2
- package/dist/form/components/SwitchControl.d.ts +0 -8
- package/src/form/components/SwitchControl.tsx +0 -39
- /package/dist/components/{EntityCollectionTable → SelectableTable}/filters/BooleanFilterField.d.ts +0 -0
- /package/dist/components/{EntityCollectionTable → SelectableTable}/filters/DateTimeFilterField.d.ts +0 -0
- /package/dist/components/{EntityCollectionTable → SelectableTable}/filters/ReferenceFilterField.d.ts +0 -0
- /package/dist/components/{EntityCollectionTable → SelectableTable}/filters/StringNumberFilterField.d.ts +0 -0
- /package/dist/components/{EntityCollectionView → common}/useColumnsIds.d.ts +0 -0
- /package/dist/components/{EntityCollectionTable → common}/useDataSourceEntityCollectionTableController.d.ts +0 -0
- /package/dist/components/{EntityCollectionTable → common}/useDebouncedData.d.ts +0 -0
- /package/src/components/{EntityCollectionTable → SelectableTable}/filters/BooleanFilterField.tsx +0 -0
- /package/src/components/{EntityCollectionTable → SelectableTable}/filters/DateTimeFilterField.tsx +0 -0
- /package/src/components/{EntityCollectionTable → SelectableTable}/filters/ReferenceFilterField.tsx +0 -0
- /package/src/components/{EntityCollectionTable → SelectableTable}/filters/StringNumberFilterField.tsx +0 -0
- /package/src/components/{EntityCollectionView → common}/useColumnsIds.tsx +0 -0
- /package/src/components/{EntityCollectionTable → common}/useDataSourceEntityCollectionTableController.tsx +0 -0
- /package/src/components/{EntityCollectionTable → common}/useDebouncedData.ts +0 -0
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.2-pre.
|
|
4
|
+
"version": "3.0.0-beta.2-pre.3",
|
|
5
5
|
"description": "Awesome Firebase/Firestore-based headless open-source CMS",
|
|
6
6
|
"funding": {
|
|
7
7
|
"url": "https://github.com/sponsors/firecmsco"
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"generateIcons": "ts-node --esm src/icons/generateIcons.ts"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@firecms/ui": "^3.0.0-beta.2-pre.
|
|
41
|
+
"@firecms/ui": "^3.0.0-beta.2-pre.3",
|
|
42
42
|
"@fontsource/ibm-plex-mono": "^5.0.8",
|
|
43
43
|
"@fontsource/roboto": "^5.0.8",
|
|
44
44
|
"@hello-pangea/dnd": "^16.5.0",
|
|
@@ -107,7 +107,7 @@
|
|
|
107
107
|
"dist",
|
|
108
108
|
"src"
|
|
109
109
|
],
|
|
110
|
-
"gitHead": "
|
|
110
|
+
"gitHead": "c78c58643c73ba776dfbcb8315d1a99160bb607a",
|
|
111
111
|
"publishConfig": {
|
|
112
112
|
"access": "public"
|
|
113
113
|
}
|
|
@@ -274,7 +274,7 @@ export function ArrayItemOptions({
|
|
|
274
274
|
const iconRef = React.useRef<HTMLDivElement>(null);
|
|
275
275
|
useOutsideAlerter(iconRef, () => setMenuOpen(false));
|
|
276
276
|
|
|
277
|
-
return <div className={`
|
|
277
|
+
return <div className={`pl-2 pt-1 pb-4 flex ${direction === "row" ? "flex-row-reverse" : "flex-col"} items-center`}
|
|
278
278
|
ref={iconRef}
|
|
279
279
|
{...provided.dragHandleProps}>
|
|
280
280
|
<Tooltip
|
|
@@ -302,14 +302,21 @@ export function ArrayItemOptions({
|
|
|
302
302
|
</IconButton>
|
|
303
303
|
|
|
304
304
|
<Menu
|
|
305
|
+
portalContainer={iconRef.current}
|
|
305
306
|
open={menuOpen}
|
|
306
307
|
trigger={<div/>}>
|
|
307
308
|
|
|
308
|
-
<MenuItem dense onClick={() =>
|
|
309
|
+
<MenuItem dense onClick={(e) => {
|
|
310
|
+
setMenuOpen(false);
|
|
311
|
+
remove(index);
|
|
312
|
+
}}>
|
|
309
313
|
<RemoveIcon size={"small"}/>
|
|
310
314
|
Remove
|
|
311
315
|
</MenuItem>
|
|
312
|
-
<MenuItem dense onClick={() =>
|
|
316
|
+
<MenuItem dense onClick={() => {
|
|
317
|
+
setMenuOpen(false);
|
|
318
|
+
copy(index);
|
|
319
|
+
}}>
|
|
313
320
|
<ContentCopyIcon size={"small"}/>
|
|
314
321
|
Copy
|
|
315
322
|
</MenuItem>
|
|
@@ -8,7 +8,7 @@ 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 "
|
|
11
|
+
import { EntityCollectionTableController } from "../common/types";
|
|
12
12
|
import { CollectionTableToolbar } from "./internal/CollectionTableToolbar";
|
|
13
13
|
import { EntityCollectionTableProps } from "./EntityCollectionTableProps";
|
|
14
14
|
import { EntityTableCell } from "./internal/EntityTableCell";
|
|
@@ -16,13 +16,8 @@ import { CustomFieldValidator } from "../../form/validation";
|
|
|
16
16
|
import { renderSkeletonText } from "../../preview";
|
|
17
17
|
import { propertiesToColumns } from "./column_utils";
|
|
18
18
|
import { ErrorView } from "../ErrorView";
|
|
19
|
-
import {
|
|
19
|
+
import { SelectableTable } from "../SelectableTable/SelectableTable";
|
|
20
20
|
|
|
21
|
-
const DEFAULT_STATE = {} as any;
|
|
22
|
-
|
|
23
|
-
export const EntityCollectionTableContext = React.createContext<EntityCollectionTableController<any>>(DEFAULT_STATE);
|
|
24
|
-
|
|
25
|
-
export const useEntityCollectionTableController = () => useContext<EntityCollectionTableController<any>>(EntityCollectionTableContext);
|
|
26
21
|
|
|
27
22
|
/**
|
|
28
23
|
* This component is in charge of rendering a collection table with a high
|
|
@@ -313,21 +308,20 @@ export const EntityCollectionTable = React.memo<EntityCollectionTableProps<any>>
|
|
|
313
308
|
actions={actions}
|
|
314
309
|
loading={tableController.dataLoading}/>
|
|
315
310
|
|
|
316
|
-
<
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
311
|
+
<SelectableTable columns={columns}
|
|
312
|
+
size={size}
|
|
313
|
+
inlineEditing={inlineEditing}
|
|
314
|
+
cellRenderer={cellRenderer}
|
|
315
|
+
onEntityClick={onEntityClick}
|
|
316
|
+
highlightedRow={useCallback((entity: Entity<M>) => selectedEntityIds?.includes(entity.id) ?? false, [selectedEntityIds])}
|
|
317
|
+
tableController={tableController}
|
|
318
|
+
onValueChange={onValueChange}
|
|
319
|
+
onColumnResize={onColumnResize}
|
|
320
|
+
hoverRow={hoverRow}
|
|
321
|
+
filterable={filterable}
|
|
322
|
+
emptyComponent={emptyComponent}
|
|
323
|
+
endAdornment={endAdornment}
|
|
324
|
+
AddColumnComponent={AddColumnComponent}/>
|
|
331
325
|
|
|
332
326
|
</div>
|
|
333
327
|
);
|
|
@@ -10,12 +10,8 @@ import {
|
|
|
10
10
|
SelectionController,
|
|
11
11
|
User
|
|
12
12
|
} from "../../types";
|
|
13
|
-
import { OnCellValueChange, UniqueFieldValidator } from "
|
|
13
|
+
import { OnCellValueChange, OnColumnResizeParams, UniqueFieldValidator } from "../common/types";
|
|
14
14
|
|
|
15
|
-
/**
|
|
16
|
-
* @group Collection components
|
|
17
|
-
*/
|
|
18
|
-
export type OnColumnResizeParams = { width: number, key: string };
|
|
19
15
|
|
|
20
16
|
/**
|
|
21
17
|
* @group Collection components
|
|
@@ -24,13 +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 { useEntityCollectionTableController } from "./EntityCollectionTable";
|
|
28
27
|
import { useClearRestoreValue, useFireCMSContext } from "../../hooks";
|
|
29
28
|
|
|
30
29
|
import { EntityTableCell } from "./internal/EntityTableCell";
|
|
31
30
|
import { EntityTableCellActions } from "./internal/EntityTableCellActions";
|
|
32
31
|
|
|
33
32
|
import { getRowHeight } from "../VirtualTable/common";
|
|
33
|
+
import { useSelectableTableController } from "../SelectableTable/SelectableTableContext";
|
|
34
34
|
|
|
35
35
|
export interface PropertyTableCellProps<T extends CMSType, M extends Record<string, any>> {
|
|
36
36
|
propertyKey: string;
|
|
@@ -84,7 +84,7 @@ export const PropertyTableCell = React.memo<PropertyTableCellProps<any, any>>(
|
|
|
84
84
|
selectedCell,
|
|
85
85
|
select,
|
|
86
86
|
setPopupCell
|
|
87
|
-
} =
|
|
87
|
+
} = useSelectableTableController();
|
|
88
88
|
|
|
89
89
|
const selected = selectedCell?.propertyKey === propertyKey &&
|
|
90
90
|
selectedCell?.entity.path === entity.path &&
|
|
@@ -3,7 +3,7 @@ import { getTableCellAlignment, getTablePropertyColumnWidth } from "./internal/c
|
|
|
3
3
|
import { FilterValues, ResolvedProperties, ResolvedProperty } from "../../types";
|
|
4
4
|
import { VirtualTableColumn } from "../VirtualTable";
|
|
5
5
|
import { getIconForProperty, getResolvedPropertyInPath } from "../../util";
|
|
6
|
-
import { getColumnKeysForProperty } from "../
|
|
6
|
+
import { getColumnKeysForProperty } from "../common/useColumnsIds";
|
|
7
7
|
|
|
8
8
|
export function buildIdColumn(largeLayout?: boolean): VirtualTableColumn {
|
|
9
9
|
return {
|
|
@@ -4,17 +4,9 @@ export {
|
|
|
4
4
|
|
|
5
5
|
export type {
|
|
6
6
|
EntityCollectionTableProps,
|
|
7
|
-
OnColumnResizeParams
|
|
8
7
|
} from "./EntityCollectionTableProps";
|
|
9
8
|
|
|
10
|
-
export type {
|
|
11
|
-
UniqueFieldValidator,
|
|
12
|
-
OnCellValueChange,
|
|
13
|
-
OnCellValueChangeParams
|
|
14
|
-
} from "./types";
|
|
15
|
-
|
|
16
9
|
export * from "./PropertyTableCell";
|
|
17
|
-
export * from "./SimpleTable";
|
|
18
10
|
export * from "./EntityCollectionRowActions";
|
|
19
|
-
export * from "
|
|
11
|
+
export * from "../common/useDataSourceEntityCollectionTableController";
|
|
20
12
|
export * from "./column_utils";
|
|
@@ -19,11 +19,12 @@ import { useDraggable } from "./useDraggable";
|
|
|
19
19
|
import { CustomFieldValidator, getYupEntitySchema } from "../../../../form/validation";
|
|
20
20
|
import { useWindowSize } from "./useWindowSize";
|
|
21
21
|
import { ElementResizeListener } from "./ElementResizeListener";
|
|
22
|
-
import { ErrorView
|
|
22
|
+
import { ErrorView } from "../../../ErrorView";
|
|
23
23
|
import { getPropertyInPath, isReadOnly, resolveCollection } from "../../../../util";
|
|
24
24
|
import { Button, ClearIcon, DialogActions, IconButton, Typography } from "@firecms/ui";
|
|
25
25
|
import { PropertyFieldBinding } from "../../../../form";
|
|
26
26
|
import { useCustomizationController, useFireCMSContext } from "../../../../hooks";
|
|
27
|
+
import { OnCellValueChangeParams } from "../../../common";
|
|
27
28
|
|
|
28
29
|
interface PopupFormFieldProps<M extends Record<string, any>> {
|
|
29
30
|
entity?: Entity<M>;
|
|
@@ -16,14 +16,11 @@ import {
|
|
|
16
16
|
SelectionController
|
|
17
17
|
} from "../../types";
|
|
18
18
|
import {
|
|
19
|
+
EntityCollectionRowActions,
|
|
19
20
|
EntityCollectionTable,
|
|
20
|
-
|
|
21
|
-
OnColumnResizeParams,
|
|
22
|
-
UniqueFieldValidator
|
|
21
|
+
useDataSourceEntityCollectionTableController
|
|
23
22
|
} from "../EntityCollectionTable";
|
|
24
23
|
|
|
25
|
-
import { EntityCollectionRowActions } from "../EntityCollectionTable/EntityCollectionRowActions";
|
|
26
|
-
|
|
27
24
|
import {
|
|
28
25
|
canCreateEntity,
|
|
29
26
|
canDeleteEntity,
|
|
@@ -40,16 +37,12 @@ import {
|
|
|
40
37
|
useAuthController,
|
|
41
38
|
useCustomizationController,
|
|
42
39
|
useDataSource,
|
|
43
|
-
useFireCMSContext,
|
|
44
40
|
useLargeLayout,
|
|
45
41
|
useNavigationController,
|
|
46
42
|
useSideEntityController
|
|
47
43
|
} from "../../hooks";
|
|
48
44
|
import { useUserConfigurationPersistence } from "../../hooks/useUserConfigurationPersistence";
|
|
49
45
|
import { EntityCollectionViewActions } from "./EntityCollectionViewActions";
|
|
50
|
-
import {
|
|
51
|
-
useDataSourceEntityCollectionTableController
|
|
52
|
-
} from "../EntityCollectionTable/useDataSourceEntityCollectionTableController";
|
|
53
46
|
import {
|
|
54
47
|
AddIcon,
|
|
55
48
|
Button,
|
|
@@ -66,7 +59,13 @@ import {
|
|
|
66
59
|
} from "@firecms/ui";
|
|
67
60
|
import { setIn } from "formik";
|
|
68
61
|
import { getSubcollectionColumnId } from "../EntityCollectionTable/internal/common";
|
|
69
|
-
import {
|
|
62
|
+
import {
|
|
63
|
+
OnCellValueChange,
|
|
64
|
+
OnColumnResizeParams,
|
|
65
|
+
UniqueFieldValidator,
|
|
66
|
+
useColumnIds,
|
|
67
|
+
useTableSearchHelper
|
|
68
|
+
} from "../common";
|
|
70
69
|
import { PopupFormField } from "../EntityCollectionTable/internal/popup_field/PopupFormField";
|
|
71
70
|
import { GetPropertyForProps } from "../EntityCollectionTable/EntityCollectionTableProps";
|
|
72
71
|
import {
|
|
@@ -130,7 +129,6 @@ export const EntityCollectionView = React.memo(
|
|
|
130
129
|
const userConfigPersistence = useUserConfigurationPersistence();
|
|
131
130
|
const analyticsController = useAnalyticsController();
|
|
132
131
|
const customizationController = useCustomizationController();
|
|
133
|
-
const context = useFireCMSContext();
|
|
134
132
|
|
|
135
133
|
const containerRef = React.useRef<HTMLDivElement>(null);
|
|
136
134
|
|
|
@@ -148,7 +146,6 @@ export const EntityCollectionView = React.memo(
|
|
|
148
146
|
const [selectedNavigationEntity, setSelectedNavigationEntity] = useState<Entity<M> | undefined>(undefined);
|
|
149
147
|
const [deleteEntityClicked, setDeleteEntityClicked] = React.useState<Entity<M> | Entity<M>[] | undefined>(undefined);
|
|
150
148
|
|
|
151
|
-
const [textSearchLoading, setTextSearchLoading] = useState<boolean>(false);
|
|
152
149
|
const [lastDeleteTimestamp, setLastDeleteTimestamp] = React.useState<number>(0);
|
|
153
150
|
|
|
154
151
|
// number of entities in the collection
|
|
@@ -569,34 +566,16 @@ export const EntityCollectionView = React.memo(
|
|
|
569
566
|
}
|
|
570
567
|
: undefined;
|
|
571
568
|
|
|
572
|
-
const
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
if (p.collectionView?.onTextSearchClick)
|
|
583
|
-
return p.collectionView.onTextSearchClick({ context, path: resolvedFullPath, collection, parentCollectionIds });
|
|
584
|
-
return Promise.resolve(true);
|
|
585
|
-
}) as Promise<boolean>[])
|
|
586
|
-
.then((res) => {
|
|
587
|
-
if (res.every(Boolean)) setTextSearchInitialised(true);
|
|
588
|
-
})
|
|
589
|
-
.finally(() => setTextSearchLoading(false));
|
|
590
|
-
}
|
|
591
|
-
: undefined;
|
|
592
|
-
|
|
593
|
-
customizationController.plugins?.forEach(p => {
|
|
594
|
-
if (!textSearchEnabled)
|
|
595
|
-
if (p.collectionView?.showTextSearchBar) {
|
|
596
|
-
textSearchEnabled = p.collectionView.showTextSearchBar({ context, path: resolvedFullPath, collection, parentCollectionIds });
|
|
597
|
-
}
|
|
598
|
-
})
|
|
599
|
-
}
|
|
569
|
+
const {
|
|
570
|
+
textSearchLoading,
|
|
571
|
+
textSearchInitialised,
|
|
572
|
+
onTextSearchClick,
|
|
573
|
+
textSearchEnabled
|
|
574
|
+
} = useTableSearchHelper({
|
|
575
|
+
collection,
|
|
576
|
+
fullPath: resolvedFullPath,
|
|
577
|
+
parentCollectionIds
|
|
578
|
+
});
|
|
600
579
|
|
|
601
580
|
return (
|
|
602
581
|
<div className={cn("overflow-hidden h-full w-full", className)}
|
package/src/components/{ReferenceSelectionInner.tsx → ReferenceTable/ReferenceSelectionTable.tsx}
RENAMED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import React, { MouseEventHandler, useCallback, useEffect, useMemo, useState } from "react";
|
|
2
|
-
import { CollectionSize, Entity, EntityCollection, FilterValues } from "
|
|
2
|
+
import { CollectionSize, Entity, EntityCollection, FilterValues } from "../../types";
|
|
3
3
|
|
|
4
|
-
import {
|
|
5
|
-
|
|
4
|
+
import {
|
|
5
|
+
EntityCollectionRowActions,
|
|
6
|
+
EntityCollectionTable,
|
|
7
|
+
useDataSourceEntityCollectionTableController
|
|
8
|
+
} from "../EntityCollectionTable";
|
|
6
9
|
import {
|
|
7
10
|
useAuthController,
|
|
8
11
|
useCustomizationController,
|
|
@@ -10,17 +13,14 @@ import {
|
|
|
10
13
|
useLargeLayout,
|
|
11
14
|
useNavigationController,
|
|
12
15
|
useSideEntityController
|
|
13
|
-
} from "
|
|
14
|
-
import { ErrorView } from "
|
|
16
|
+
} from "../../hooks";
|
|
17
|
+
import { ErrorView } from "../ErrorView";
|
|
15
18
|
import { AddIcon, Button, DialogActions, Typography } from "@firecms/ui";
|
|
16
|
-
import { canCreateEntity, fullPathToCollectionSegments, resolveCollection } from "
|
|
17
|
-
import { useSelectionController } from "
|
|
18
|
-
import {
|
|
19
|
-
|
|
20
|
-
} from "
|
|
21
|
-
import { useColumnIds } from "./EntityCollectionView/useColumnsIds";
|
|
22
|
-
import { useSideDialogContext } from "../core";
|
|
23
|
-
import { useAnalyticsController } from "../hooks/useAnalyticsController";
|
|
19
|
+
import { canCreateEntity, fullPathToCollectionSegments, resolveCollection } from "../../util";
|
|
20
|
+
import { useSelectionController } from "../EntityCollectionView/EntityCollectionView";
|
|
21
|
+
import { useColumnIds, useTableSearchHelper } from "../common";
|
|
22
|
+
import { useSideDialogContext } from "../../core";
|
|
23
|
+
import { useAnalyticsController } from "../../hooks/useAnalyticsController";
|
|
24
24
|
|
|
25
25
|
/**
|
|
26
26
|
* @group Components
|
|
@@ -88,7 +88,7 @@ export interface ReferenceSelectionInnerProps<M extends Record<string, any>> {
|
|
|
88
88
|
* You probably want to open this dialog as a side view using {@link useReferenceDialog}
|
|
89
89
|
* @group Components
|
|
90
90
|
*/
|
|
91
|
-
export function
|
|
91
|
+
export function ReferenceSelectionTable<M extends Record<string, any>>(
|
|
92
92
|
{
|
|
93
93
|
onSingleEntitySelected,
|
|
94
94
|
onMultipleEntitiesSelected,
|
|
@@ -98,7 +98,7 @@ export function ReferenceSelectionInner<M extends Record<string, any>>(
|
|
|
98
98
|
selectedEntityIds: selectedEntityIdsProp,
|
|
99
99
|
description,
|
|
100
100
|
forceFilter,
|
|
101
|
-
maxSelection
|
|
101
|
+
maxSelection,
|
|
102
102
|
}: ReferenceSelectionInnerProps<M>) {
|
|
103
103
|
|
|
104
104
|
const sideDialogContext = useSideDialogContext();
|
|
@@ -266,6 +266,19 @@ export function ReferenceSelectionInner<M extends Record<string, any>>(
|
|
|
266
266
|
forceFilter
|
|
267
267
|
});
|
|
268
268
|
|
|
269
|
+
|
|
270
|
+
const {
|
|
271
|
+
textSearchLoading,
|
|
272
|
+
textSearchInitialised,
|
|
273
|
+
onTextSearchClick,
|
|
274
|
+
textSearchEnabled
|
|
275
|
+
} =
|
|
276
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
277
|
+
useTableSearchHelper({
|
|
278
|
+
collection,
|
|
279
|
+
fullPath,
|
|
280
|
+
});
|
|
281
|
+
|
|
269
282
|
return (
|
|
270
283
|
|
|
271
284
|
<div className="flex flex-col h-full">
|
|
@@ -273,6 +286,9 @@ export function ReferenceSelectionInner<M extends Record<string, any>>(
|
|
|
273
286
|
<div className="flex-grow">
|
|
274
287
|
{entitiesDisplayedFirst &&
|
|
275
288
|
<EntityCollectionTable
|
|
289
|
+
textSearchLoading={textSearchLoading}
|
|
290
|
+
onTextSearchClick={textSearchInitialised ? undefined : onTextSearchClick}
|
|
291
|
+
textSearchEnabled={textSearchEnabled}
|
|
276
292
|
displayedColumnIds={displayedColumnIds}
|
|
277
293
|
onEntityClick={onEntityClick}
|
|
278
294
|
tableController={tableController}
|
package/src/components/{EntityCollectionTable/SimpleTable.tsx → SelectableTable/SelectableTable.tsx}
RENAMED
|
@@ -10,17 +10,16 @@ import {
|
|
|
10
10
|
} from "../../types";
|
|
11
11
|
import { CellRendererParams, VirtualTable, VirtualTableColumn } from "../VirtualTable";
|
|
12
12
|
import { enumToObjectEntries } from "../../util";
|
|
13
|
-
import { OnCellValueChange } from "
|
|
14
|
-
import { OnColumnResizeParams } from "./EntityCollectionTableProps";
|
|
13
|
+
import { OnCellValueChange, OnColumnResizeParams } from "../common/types";
|
|
15
14
|
import { FilterFormFieldProps } from "../VirtualTable/VirtualTableHeader";
|
|
16
15
|
import { ReferenceFilterField } from "./filters/ReferenceFilterField";
|
|
17
16
|
import { StringNumberFilterField } from "./filters/StringNumberFilterField";
|
|
18
17
|
import { BooleanFilterField } from "./filters/BooleanFilterField";
|
|
19
18
|
import { DateTimeFilterField } from "./filters/DateTimeFilterField";
|
|
20
|
-
import { EntityCollectionTableContext } from "./EntityCollectionTable";
|
|
21
19
|
import { useOutsideAlerter } from "@firecms/ui";
|
|
20
|
+
import { SelectableTableContext } from "./SelectableTableContext";
|
|
22
21
|
|
|
23
|
-
export type
|
|
22
|
+
export type SelectableTableProps<M extends Record<string, any>> = {
|
|
24
23
|
|
|
25
24
|
/**
|
|
26
25
|
* Callback when a cell value changes.
|
|
@@ -108,8 +107,8 @@ export type SimpleTableProps<M extends Record<string, any>> = {
|
|
|
108
107
|
* @see VirtualTable
|
|
109
108
|
* @group Components
|
|
110
109
|
*/
|
|
111
|
-
export const
|
|
112
|
-
function
|
|
110
|
+
export const SelectableTable = React.memo<SelectableTableProps<any>>(
|
|
111
|
+
function SelectableTable<M extends Record<string, any>>
|
|
113
112
|
({
|
|
114
113
|
onValueChange,
|
|
115
114
|
cellRenderer,
|
|
@@ -143,7 +142,7 @@ export const SimpleTable = React.memo<SimpleTableProps<any>>(
|
|
|
143
142
|
highlightedRow,
|
|
144
143
|
endAdornment,
|
|
145
144
|
AddColumnComponent
|
|
146
|
-
}:
|
|
145
|
+
}: SelectableTableProps<M>) {
|
|
147
146
|
|
|
148
147
|
const ref = useRef<HTMLDivElement>(null);
|
|
149
148
|
const [size, setSize] = React.useState<CollectionSize>("m");
|
|
@@ -203,7 +202,7 @@ export const SimpleTable = React.memo<SimpleTableProps<any>>(
|
|
|
203
202
|
}, [forceFilter]);
|
|
204
203
|
|
|
205
204
|
return (
|
|
206
|
-
<
|
|
205
|
+
<SelectableTableContext.Provider
|
|
207
206
|
value={{
|
|
208
207
|
setPopupCell: setPopupCell as ((cell?: SelectedCellProps<M>) => void),
|
|
209
208
|
select,
|
|
@@ -244,7 +243,7 @@ export const SimpleTable = React.memo<SimpleTableProps<any>>(
|
|
|
244
243
|
/>
|
|
245
244
|
|
|
246
245
|
</div>
|
|
247
|
-
</
|
|
246
|
+
</SelectableTableContext.Provider>
|
|
248
247
|
);
|
|
249
248
|
|
|
250
249
|
},
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import React, { useContext } from "react";
|
|
2
|
+
import { EntityCollectionTableController } from "../common/types";
|
|
3
|
+
|
|
4
|
+
export const SelectableTableContext = React.createContext<EntityCollectionTableController<any>>({} as any);
|
|
5
|
+
|
|
6
|
+
export const useSelectableTableController = () => useContext<EntityCollectionTableController<any>>(SelectableTableContext);
|
|
@@ -56,3 +56,8 @@ export type UniqueFieldValidator = (props: {
|
|
|
56
56
|
* @group Collection components
|
|
57
57
|
*/
|
|
58
58
|
export type OnCellValueChange<T, M extends Record<string, any>> = (params: OnCellValueChangeParams<T, M>) => Promise<void> | void;
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* @group Collection components
|
|
62
|
+
*/
|
|
63
|
+
export type OnColumnResizeParams = { width: number, key: string };
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { useState } from "react";
|
|
2
|
+
|
|
3
|
+
import { EntityCollection } from "../../types";
|
|
4
|
+
import { useCustomizationController, useFireCMSContext } from "../../hooks";
|
|
5
|
+
|
|
6
|
+
export interface UseTableSearchHelperParams<M extends Record<string, any>> {
|
|
7
|
+
collection: EntityCollection<M>;
|
|
8
|
+
fullPath: string;
|
|
9
|
+
parentCollectionIds?: string[];
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function useTableSearchHelper<M extends Record<string, any>>({ collection, fullPath, parentCollectionIds }: UseTableSearchHelperParams<M>) {
|
|
13
|
+
|
|
14
|
+
const context = useFireCMSContext();
|
|
15
|
+
const customizationController = useCustomizationController();
|
|
16
|
+
|
|
17
|
+
const [textSearchLoading, setTextSearchLoading] = useState<boolean>(false);
|
|
18
|
+
const [textSearchInitialised, setTextSearchInitialised] = useState<boolean>(false);
|
|
19
|
+
let onTextSearchClick: (() => void) | undefined;
|
|
20
|
+
let textSearchEnabled = Boolean(collection.textSearchEnabled);
|
|
21
|
+
if (customizationController?.plugins) {
|
|
22
|
+
const addTextSearchClickListener = customizationController.plugins?.find(p => Boolean(p.collectionView?.onTextSearchClick));
|
|
23
|
+
|
|
24
|
+
onTextSearchClick = addTextSearchClickListener
|
|
25
|
+
? () => {
|
|
26
|
+
setTextSearchLoading(true);
|
|
27
|
+
Promise.all(customizationController.plugins?.map(p => {
|
|
28
|
+
if (p.collectionView?.onTextSearchClick)
|
|
29
|
+
return p.collectionView.onTextSearchClick({ context, path: fullPath, collection, parentCollectionIds });
|
|
30
|
+
return Promise.resolve(true);
|
|
31
|
+
}) as Promise<boolean>[])
|
|
32
|
+
.then((res) => {
|
|
33
|
+
if (res.every(Boolean)) setTextSearchInitialised(true);
|
|
34
|
+
})
|
|
35
|
+
.finally(() => setTextSearchLoading(false));
|
|
36
|
+
}
|
|
37
|
+
: undefined;
|
|
38
|
+
|
|
39
|
+
customizationController.plugins?.forEach(p => {
|
|
40
|
+
if (!textSearchEnabled)
|
|
41
|
+
if (p.collectionView?.showTextSearchBar) {
|
|
42
|
+
textSearchEnabled = p.collectionView.showTextSearchBar({ context, path: fullPath, collection, parentCollectionIds });
|
|
43
|
+
}
|
|
44
|
+
})
|
|
45
|
+
}
|
|
46
|
+
return { textSearchLoading, textSearchInitialised, onTextSearchClick, textSearchEnabled };
|
|
47
|
+
}
|
package/src/components/index.tsx
CHANGED
|
@@ -4,13 +4,17 @@ export { ErrorView } from "./ErrorView";
|
|
|
4
4
|
export type { EntityPreviewProps } from "./EntityPreview";
|
|
5
5
|
export { EntityPreview } from "./EntityPreview";
|
|
6
6
|
|
|
7
|
-
export type { ReferenceSelectionInnerProps } from "./
|
|
8
|
-
export {
|
|
7
|
+
export type { ReferenceSelectionInnerProps } from "./ReferenceTable/ReferenceSelectionTable";
|
|
8
|
+
export { ReferenceSelectionTable } from "./ReferenceTable/ReferenceSelectionTable";
|
|
9
9
|
|
|
10
10
|
export { CircularProgressCenter } from "./CircularProgressCenter";
|
|
11
11
|
|
|
12
|
+
export * from "./common";
|
|
13
|
+
|
|
12
14
|
export * from "./HomePage";
|
|
15
|
+
export * from "./SelectableTable/SelectableTable";
|
|
13
16
|
export * from "./EntityCollectionView/EntityCollectionView";
|
|
17
|
+
export * from "./EntityCollectionView/EntityCollectionViewActions";
|
|
14
18
|
|
|
15
19
|
export * from "./PropertyConfigBadge";
|
|
16
20
|
|
|
@@ -33,13 +33,15 @@ export function EntitySidePanel(props: EntitySidePanelProps) {
|
|
|
33
33
|
if (!props) return undefined;
|
|
34
34
|
let usedCollection = props.collection;
|
|
35
35
|
|
|
36
|
+
const registryCollection = navigationController.getCollection(props.path, props.entityId);
|
|
37
|
+
if (registryCollection) {
|
|
38
|
+
usedCollection = registryCollection;
|
|
39
|
+
}
|
|
36
40
|
if (!usedCollection) {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
console.error("ERROR: No collection found in path `", props.path, "`. Entity id: ", props.entityId);
|
|
40
|
-
throw Error("ERROR: No collection found in path `" + props.path + "`. Make sure you have defined a collection for this path in the root navigation.");
|
|
41
|
-
}
|
|
41
|
+
console.error("ERROR: No collection found in path `", props.path, "`. Entity id: ", props.entityId);
|
|
42
|
+
throw Error("ERROR: No collection found in path `" + props.path + "`. Make sure you have defined a collection for this path in the root navigation.");
|
|
42
43
|
}
|
|
44
|
+
|
|
43
45
|
return usedCollection;
|
|
44
46
|
}, [navigationController, props]);
|
|
45
47
|
|
package/src/form/EntityForm.tsx
CHANGED
|
@@ -427,7 +427,7 @@ function EntityFormInternal<M extends Record<string, any>>({
|
|
|
427
427
|
{pluginActions}
|
|
428
428
|
</div>}
|
|
429
429
|
|
|
430
|
-
<div className="
|
|
430
|
+
<div className="pt-12 pb-16 pl-8 pr-8">
|
|
431
431
|
<div
|
|
432
432
|
className={`w-full py-2 flex flex-col items-start mt-${4 + (pluginActions ? 8 : 0)} lg:mt-${8 + (pluginActions ? 8 : 0)} mb-8`}>
|
|
433
433
|
|