@neovici/cosmoz-omnitable 12.10.0 → 12.12.0
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/cosmoz-omnitable.js +3 -0
- package/lib/use-omnitable.js +19 -14
- package/lib/use-processed-items.js +8 -4
- package/lib/use-public-interface.js +13 -5
- package/package.json +2 -2
package/cosmoz-omnitable.js
CHANGED
package/lib/use-omnitable.js
CHANGED
|
@@ -10,7 +10,15 @@ import { useFooter } from './use-footer';
|
|
|
10
10
|
|
|
11
11
|
// eslint-disable-next-line max-lines-per-function
|
|
12
12
|
export const useOmnitable = (host) => {
|
|
13
|
-
const {
|
|
13
|
+
const {
|
|
14
|
+
hashParam,
|
|
15
|
+
settingsId,
|
|
16
|
+
data,
|
|
17
|
+
resizeSpeedFactor,
|
|
18
|
+
noLocal,
|
|
19
|
+
noLocalSort = noLocal,
|
|
20
|
+
noLocalFilter = noLocal,
|
|
21
|
+
} = host,
|
|
14
22
|
settingS = useSettings({ settingsId, host }),
|
|
15
23
|
{ settings, setSettings, columns, resetRef } = settingS,
|
|
16
24
|
sortAndGroupOptions = useSortAndGroupOptions(
|
|
@@ -21,18 +29,15 @@ export const useOmnitable = (host) => {
|
|
|
21
29
|
resetRef
|
|
22
30
|
),
|
|
23
31
|
// TODO: drop filterFunctions
|
|
24
|
-
{
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
hashParam,
|
|
34
|
-
sortAndGroupOptions,
|
|
35
|
-
}),
|
|
32
|
+
{ processedItems, visibleData, filters, setFilterState, filterFunctions } =
|
|
33
|
+
useProcessedItems({
|
|
34
|
+
data,
|
|
35
|
+
columns,
|
|
36
|
+
hashParam,
|
|
37
|
+
sortAndGroupOptions,
|
|
38
|
+
noLocalSort,
|
|
39
|
+
noLocalFilter,
|
|
40
|
+
}),
|
|
36
41
|
{ collapsedColumns } = useFastLayout({
|
|
37
42
|
host,
|
|
38
43
|
columns,
|
|
@@ -69,7 +74,7 @@ export const useOmnitable = (host) => {
|
|
|
69
74
|
filterFunctions,
|
|
70
75
|
settingS,
|
|
71
76
|
setFilterState,
|
|
72
|
-
hideSelectAll: host.hideSelectAll === true
|
|
77
|
+
hideSelectAll: host.hideSelectAll === true,
|
|
73
78
|
}),
|
|
74
79
|
list: useList({
|
|
75
80
|
host,
|
|
@@ -35,6 +35,8 @@ export const useProcessedItems = ({
|
|
|
35
35
|
columns,
|
|
36
36
|
hashParam,
|
|
37
37
|
sortAndGroupOptions,
|
|
38
|
+
noLocalSort,
|
|
39
|
+
noLocalFilter,
|
|
38
40
|
}) => {
|
|
39
41
|
const { groupOnColumn, groupOnDescending, sortOnColumn, descending } =
|
|
40
42
|
sortAndGroupOptions,
|
|
@@ -110,18 +112,19 @@ export const useProcessedItems = ({
|
|
|
110
112
|
return [];
|
|
111
113
|
}
|
|
112
114
|
|
|
113
|
-
if (Object.entries(filterFunctions).length === 0) {
|
|
115
|
+
if (Object.entries(filterFunctions).length === 0 || noLocalFilter) {
|
|
114
116
|
return data.slice();
|
|
115
117
|
}
|
|
116
118
|
|
|
117
119
|
return data.filter((item) =>
|
|
118
120
|
Object.values(filterFunctions).every((filterFn) => filterFn(item))
|
|
119
121
|
);
|
|
120
|
-
}, [data, filterFunctions]),
|
|
122
|
+
}, [data, filterFunctions, noLocalFilter]),
|
|
121
123
|
// todo: extract function
|
|
122
124
|
// eslint-disable-next-line max-lines-per-function
|
|
123
125
|
processedItems = useMemo(() => {
|
|
124
126
|
if (
|
|
127
|
+
!noLocalSort &&
|
|
125
128
|
!groupOnColumn &&
|
|
126
129
|
sortOnColumn != null &&
|
|
127
130
|
sortOnColumn.sortOn != null
|
|
@@ -177,7 +180,7 @@ export const useProcessedItems = ({
|
|
|
177
180
|
)
|
|
178
181
|
);
|
|
179
182
|
|
|
180
|
-
if (!sortOnColumn) {
|
|
183
|
+
if (!sortOnColumn || noLocalSort) {
|
|
181
184
|
return groupedResults;
|
|
182
185
|
}
|
|
183
186
|
|
|
@@ -205,6 +208,7 @@ export const useProcessedItems = ({
|
|
|
205
208
|
groupOnDescending,
|
|
206
209
|
sortOnColumn,
|
|
207
210
|
descending,
|
|
211
|
+
noLocalSort,
|
|
208
212
|
]),
|
|
209
213
|
visibleData = useMemo(() => {
|
|
210
214
|
let index = 0,
|
|
@@ -255,6 +259,6 @@ export const useProcessedItems = ({
|
|
|
255
259
|
visibleData,
|
|
256
260
|
filters,
|
|
257
261
|
filterFunctions,
|
|
258
|
-
setFilterState
|
|
262
|
+
setFilterState,
|
|
259
263
|
};
|
|
260
264
|
};
|
|
@@ -67,11 +67,7 @@ const mkNapi = (host) => {
|
|
|
67
67
|
};
|
|
68
68
|
};
|
|
69
69
|
|
|
70
|
-
export const usePublicInterface = ({
|
|
71
|
-
host,
|
|
72
|
-
visibleData,
|
|
73
|
-
...api
|
|
74
|
-
}) => {
|
|
70
|
+
export const usePublicInterface = ({ host, visibleData, filters, ...api }) => {
|
|
75
71
|
const { setFilterState } = api,
|
|
76
72
|
napi = useMemo(() => mkNapi(host), []);
|
|
77
73
|
|
|
@@ -96,4 +92,16 @@ export const usePublicInterface = ({
|
|
|
96
92
|
useNotifyProperty('selectedItems', api.selectedItems);
|
|
97
93
|
useNotifyProperty('sortOn', api.sortOn);
|
|
98
94
|
useNotifyProperty('descending', api.descending);
|
|
95
|
+
|
|
96
|
+
const filterValues = useMemo(
|
|
97
|
+
() =>
|
|
98
|
+
Object.fromEntries(
|
|
99
|
+
Object.entries(filters)
|
|
100
|
+
.filter(([, { filter }]) => filter !== undefined)
|
|
101
|
+
.map(([key, { filter }]) => [key, filter])
|
|
102
|
+
),
|
|
103
|
+
[filters]
|
|
104
|
+
);
|
|
105
|
+
|
|
106
|
+
useNotifyProperty('filters', filterValues, Object.values(filterValues));
|
|
99
107
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@neovici/cosmoz-omnitable",
|
|
3
|
-
"version": "12.
|
|
3
|
+
"version": "12.12.0",
|
|
4
4
|
"description": "[](https://travis-ci.org/Neovici/cosmoz-omnitable)",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"web-components"
|
|
@@ -67,7 +67,7 @@
|
|
|
67
67
|
"@neovici/cosmoz-grouped-list": "^6.0.0",
|
|
68
68
|
"@neovici/cosmoz-i18next": "^3.1.1",
|
|
69
69
|
"@neovici/cosmoz-router": "^10.0.0",
|
|
70
|
-
"@neovici/cosmoz-utils": "^5.
|
|
70
|
+
"@neovici/cosmoz-utils": "^5.16.0",
|
|
71
71
|
"@neovici/nullxlsx": "^3.0.0",
|
|
72
72
|
"@polymer/iron-icon": "^3.0.0",
|
|
73
73
|
"@polymer/iron-icons": "^3.0.0",
|