@firecms/core 3.0.0-canary.37 → 3.0.0-canary.39
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/ClearFilterSortButton.d.ts +5 -0
- package/dist/components/EntityCollectionTable/internal/CollectionTableToolbar.d.ts +1 -4
- package/dist/components/EntityCollectionView/EntityCollectionViewStartActions.d.ts +11 -0
- package/dist/index.es.js +3476 -3349
- 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/types/collections.d.ts +5 -1
- package/dist/types/plugins.d.ts +3 -1
- package/package.json +5 -5
- package/src/components/ClearFilterSortButton.tsx +41 -0
- package/src/components/EntityCollectionTable/EntityCollectionTable.tsx +0 -5
- package/src/components/EntityCollectionTable/internal/CollectionTableToolbar.tsx +27 -32
- package/src/components/EntityCollectionView/EntityCollectionView.tsx +12 -1
- package/src/components/EntityCollectionView/EntityCollectionViewStartActions.tsx +68 -0
- package/src/components/SelectableTable/filters/DateTimeFilterField.tsx +22 -7
- package/src/components/SelectableTable/filters/ReferenceFilterField.tsx +24 -5
- package/src/components/SelectableTable/filters/StringNumberFilterField.tsx +35 -15
- package/src/core/field_configs.tsx +1 -2
- package/src/hooks/useBuildLocalConfigurationPersistence.tsx +9 -10
- package/src/hooks/useBuildNavigationController.tsx +24 -0
- package/src/types/collections.ts +5 -1
- package/src/types/plugins.tsx +4 -3
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { useCallback, useEffect, useState } from "react";
|
|
1
|
+
import { useCallback, useEffect, useRef, useState } from "react";
|
|
2
2
|
import { PartialEntityCollection, UserConfigurationPersistence } from "../types";
|
|
3
3
|
import { mergeDeep, stripCollectionPath } from "../util";
|
|
4
4
|
|
|
5
5
|
export function useBuildLocalConfigurationPersistence(): UserConfigurationPersistence {
|
|
6
6
|
|
|
7
|
-
const
|
|
7
|
+
const configCache = useRef<Record<string, PartialEntityCollection>>({});
|
|
8
8
|
|
|
9
9
|
const getCollectionFromStorage = useCallback((storageKey: string) => {
|
|
10
10
|
const item = localStorage.getItem(storageKey);
|
|
@@ -13,20 +13,19 @@ export function useBuildLocalConfigurationPersistence(): UserConfigurationPersis
|
|
|
13
13
|
|
|
14
14
|
const getCollectionConfig = useCallback(<M extends Record<string, any>>(path: string): PartialEntityCollection<M> => {
|
|
15
15
|
const storageKey = `collection_config::${stripCollectionPath(path)}`;
|
|
16
|
-
if (configCache[storageKey]) {
|
|
17
|
-
return configCache[storageKey] as PartialEntityCollection<M>;
|
|
16
|
+
if (configCache.current[storageKey]) {
|
|
17
|
+
return configCache.current[storageKey] as PartialEntityCollection<M>;
|
|
18
18
|
}
|
|
19
19
|
return getCollectionFromStorage(storageKey);
|
|
20
|
-
}, [
|
|
20
|
+
}, [getCollectionFromStorage]);
|
|
21
21
|
|
|
22
22
|
const onCollectionModified = useCallback(<M extends Record<string, any>>(path: string, data: PartialEntityCollection<M>) => {
|
|
23
23
|
const storageKey = `collection_config::${stripCollectionPath(path)}`;
|
|
24
24
|
localStorage.setItem(storageKey, JSON.stringify(data));
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
});
|
|
25
|
+
const currentCache = configCache.current;
|
|
26
|
+
const cachedConfig = currentCache[storageKey];
|
|
27
|
+
const newConfig = mergeDeep(cachedConfig ?? getCollectionFromStorage(path), data);
|
|
28
|
+
configCache.current = mergeDeep(currentCache, newConfig);
|
|
30
29
|
}, [getCollectionFromStorage]);
|
|
31
30
|
|
|
32
31
|
const [recentlyVisitedPaths, _setRecentlyVisitedPaths] = useState<string[]>([]);
|
|
@@ -130,6 +130,30 @@ export function useBuildNavigationController<EC extends EntityCollection, UserTy
|
|
|
130
130
|
.filter(Boolean) as TopNavigationEntry[]
|
|
131
131
|
];
|
|
132
132
|
|
|
133
|
+
// Sort by group, entries with group "Admin" will go last, and second to last will be the group "Views"
|
|
134
|
+
navigationEntries = navigationEntries.sort((a, b) => {
|
|
135
|
+
if (a.group !== "Views" && a.group !== "Admin" && (b.group === "Views" || b.group === "Admin")) {
|
|
136
|
+
return -1;
|
|
137
|
+
}
|
|
138
|
+
if (b.group !== "Views" && b.group !== "Admin" && (a.group === "Views" || a.group === "Admin")) {
|
|
139
|
+
return 1;
|
|
140
|
+
}
|
|
141
|
+
if (a.group === "Admin" && b.group !== "Admin") {
|
|
142
|
+
return 1;
|
|
143
|
+
}
|
|
144
|
+
if (a.group !== "Admin" && b.group === "Admin") {
|
|
145
|
+
return -1;
|
|
146
|
+
}
|
|
147
|
+
if (a.group === "Views" && b.group !== "Views") {
|
|
148
|
+
return -1;
|
|
149
|
+
}
|
|
150
|
+
if (a.group !== "Views" && b.group === "Views") {
|
|
151
|
+
return 1;
|
|
152
|
+
}
|
|
153
|
+
return 0;
|
|
154
|
+
|
|
155
|
+
});
|
|
156
|
+
|
|
133
157
|
if (viewsOrder) {
|
|
134
158
|
navigationEntries = navigationEntries.sort((a, b) => {
|
|
135
159
|
const aIndex = viewsOrder.indexOf(a.path);
|
package/src/types/collections.ts
CHANGED
|
@@ -107,6 +107,10 @@ export interface EntityCollection<M extends Record<string, any> = any, UserType
|
|
|
107
107
|
* `subcollection:`. e.g. `subcollection:orders`.
|
|
108
108
|
* - If you are using a collection group, you will also have an
|
|
109
109
|
* additional `collectionGroupParent` column.
|
|
110
|
+
* You can use this prop to hide some properties from the table view.
|
|
111
|
+
* Note that if you set this prop, other ways to hide fields, like
|
|
112
|
+
* `hidden` in the property definition,will be ignored.
|
|
113
|
+
* `propertiesOrder` has precedence over `hidden`.
|
|
110
114
|
*/
|
|
111
115
|
propertiesOrder?: Extract<keyof M, string>[];
|
|
112
116
|
|
|
@@ -523,7 +527,7 @@ export type EntityTableController<M extends Record<string, any> = any> = {
|
|
|
523
527
|
filterValues?: FilterValues<Extract<keyof M, string>>;
|
|
524
528
|
setFilterValues?: (filterValues: FilterValues<Extract<keyof M, string>>) => void;
|
|
525
529
|
sortBy?: [Extract<keyof M, string>, "asc" | "desc"];
|
|
526
|
-
setSortBy?: (sortBy
|
|
530
|
+
setSortBy?: (sortBy?: [Extract<keyof M, string>, "asc" | "desc"]) => void;
|
|
527
531
|
searchString?: string;
|
|
528
532
|
setSearchString?: (searchString?: string) => void;
|
|
529
533
|
clearFilter?: () => void;
|
package/src/types/plugins.tsx
CHANGED
|
@@ -7,14 +7,13 @@ import { FieldProps, FormContext } from "./fields";
|
|
|
7
7
|
import { CMSType, Property } from "./properties";
|
|
8
8
|
import { EntityStatus } from "./entities";
|
|
9
9
|
import { ResolvedProperty } from "./resolved_entities";
|
|
10
|
-
import { CMSView } from "./navigation";
|
|
11
10
|
|
|
12
11
|
/**
|
|
13
12
|
* Interface used to define plugins for FireCMS.
|
|
14
13
|
* NOTE: This is a work in progress and the API is not stable yet.
|
|
15
14
|
* @group Core
|
|
16
15
|
*/
|
|
17
|
-
export type FireCMSPlugin<PROPS = any, FORM_PROPS = any, EC extends EntityCollection = EntityCollection, COL_ACTIONS_PROPS = any> = {
|
|
16
|
+
export type FireCMSPlugin<PROPS = any, FORM_PROPS = any, EC extends EntityCollection = EntityCollection, COL_ACTIONS_PROPS = any, COL_ACTIONS_START__PROPS = any> = {
|
|
18
17
|
|
|
19
18
|
/**
|
|
20
19
|
* Key of the plugin. This is used to identify the plugin in the CMS.
|
|
@@ -94,9 +93,11 @@ export type FireCMSPlugin<PROPS = any, FORM_PROPS = any, EC extends EntityCollec
|
|
|
94
93
|
* toolbar.
|
|
95
94
|
*/
|
|
96
95
|
CollectionActions?: React.ComponentType<CollectionActionsProps<any, any, EC> & COL_ACTIONS_PROPS> | React.ComponentType<CollectionActionsProps<any, any, EC> & COL_ACTIONS_PROPS>[];
|
|
97
|
-
|
|
98
96
|
collectionActionsProps?: COL_ACTIONS_PROPS;
|
|
99
97
|
|
|
98
|
+
CollectionActionsStart?: React.ComponentType<CollectionActionsProps<any, any, EC> & COL_ACTIONS_START__PROPS> | React.ComponentType<CollectionActionsProps<any, any, EC> & COL_ACTIONS_START__PROPS>[];
|
|
99
|
+
collectionActionsStartProps?: COL_ACTIONS_START__PROPS;
|
|
100
|
+
|
|
100
101
|
showTextSearchBar?: (props: {
|
|
101
102
|
context: FireCMSContext,
|
|
102
103
|
path: string,
|