@neovici/cosmoz-omnitable 8.0.0-beta.3 → 8.0.0-beta.7
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-column-amount.js +7 -7
- package/cosmoz-omnitable-column-autocomplete.js +6 -4
- package/cosmoz-omnitable-column-date.js +7 -7
- package/cosmoz-omnitable-column-datetime.js +7 -7
- package/cosmoz-omnitable-column-list-mixin.js +4 -2
- package/cosmoz-omnitable-column-mixin.js +5 -4
- package/cosmoz-omnitable-column-number.js +7 -7
- package/cosmoz-omnitable-column-time.js +7 -7
- package/cosmoz-omnitable.js +2 -7
- package/lib/use-dom-columns.js +3 -4
- package/lib/use-fast-layout.js +21 -2
- package/lib/use-processed-items.js +6 -5
- package/lib/utils-amount.js +4 -4
- package/lib/utils-data.js +5 -0
- package/lib/utils-date.js +7 -7
- package/lib/utils-number.js +4 -4
- package/lib/utils-time.js +4 -4
- package/package.json +1 -1
|
@@ -7,7 +7,7 @@ import { PolymerElement } from '@polymer/polymer/polymer-element';
|
|
|
7
7
|
import { html } from 'lit-html';
|
|
8
8
|
|
|
9
9
|
import { columnMixin } from './cosmoz-omnitable-column-mixin';
|
|
10
|
-
import {
|
|
10
|
+
import { defaultComputeSource } from './lib/utils-data';
|
|
11
11
|
import './lib/cosmoz-omnitable-amount-range-input';
|
|
12
12
|
import { getComparableValue, getCurrency, applySingleFilter, getString, getInputString, toAmount, toHashString, fromHashString } from './lib/utils-amount';
|
|
13
13
|
import { get } from '@polymer/polymer/lib/utils/path';
|
|
@@ -35,8 +35,8 @@ class OmnitableColumnAmount extends columnMixin(PolymerElement) {
|
|
|
35
35
|
|
|
36
36
|
getFilterFn(column, filter) {
|
|
37
37
|
const
|
|
38
|
-
min = getComparableValue(
|
|
39
|
-
max = getComparableValue(
|
|
38
|
+
min = getComparableValue({ ...column, valuePath: 'min' }, filter),
|
|
39
|
+
max = getComparableValue({ ...column, valuePath: 'max' }, filter);
|
|
40
40
|
|
|
41
41
|
if (min == null && max == null) {
|
|
42
42
|
return;
|
|
@@ -56,8 +56,8 @@ class OmnitableColumnAmount extends columnMixin(PolymerElement) {
|
|
|
56
56
|
return getString(column, item);
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
-
getComparableValue(
|
|
60
|
-
return getComparableValue(
|
|
59
|
+
getComparableValue(column, item) {
|
|
60
|
+
return getComparableValue(column, item);
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
serializeFilter({ rates }, filter) {
|
|
@@ -134,8 +134,8 @@ class OmnitableColumnAmount extends columnMixin(PolymerElement) {
|
|
|
134
134
|
></cosmoz-omnitable-amount-range-input>`;
|
|
135
135
|
}
|
|
136
136
|
|
|
137
|
-
computeSource(
|
|
138
|
-
return
|
|
137
|
+
computeSource(column, data) {
|
|
138
|
+
return defaultComputeSource(column, data);
|
|
139
139
|
}
|
|
140
140
|
}
|
|
141
141
|
|
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
import { get } from '@polymer/polymer/lib/utils/path';
|
|
15
15
|
|
|
16
16
|
export const
|
|
17
|
-
getComparableValue = (
|
|
17
|
+
getComparableValue = ({ valuePath, textProperty, valueProperty }, item) => {
|
|
18
18
|
const property = textProperty ? strProp(textProperty) : prop(valueProperty),
|
|
19
19
|
values = array(valuePath && get(item, valuePath)).map(property);
|
|
20
20
|
return values.length > 1 ? values.filter(Boolean).join(',') : values[0];
|
|
@@ -63,12 +63,14 @@ class OmnitableColumnAutocomplete extends listColumnMixin(columnMixin(PolymerEle
|
|
|
63
63
|
>${ spinner }</cosmoz-autocomplete-ui>`;
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
-
getComparableValue(
|
|
67
|
-
return getComparableValue(
|
|
66
|
+
getComparableValue(column, item) {
|
|
67
|
+
return getComparableValue(column, item);
|
|
68
68
|
}
|
|
69
69
|
|
|
70
70
|
computeSource(column, data) {
|
|
71
|
-
return
|
|
71
|
+
return column.externalValues || typeof column.values === 'function'
|
|
72
|
+
? column.values
|
|
73
|
+
: computeSource(column, data);
|
|
72
74
|
}
|
|
73
75
|
|
|
74
76
|
}
|
|
@@ -9,7 +9,7 @@ import { html } from 'lit-html';
|
|
|
9
9
|
|
|
10
10
|
import { columnMixin } from './cosmoz-omnitable-column-mixin';
|
|
11
11
|
import './lib/cosmoz-omnitable-date-range-input';
|
|
12
|
-
import {
|
|
12
|
+
import { defaultComputeSource } from './lib/utils-data';
|
|
13
13
|
import { getString, getComparableValue, toDate, toHashString, toXlsxValue, applySingleFilter, getInputString, fromInputString } from './lib/utils-date';
|
|
14
14
|
|
|
15
15
|
class OmnitableColumnDate extends columnMixin(PolymerElement) {
|
|
@@ -27,8 +27,8 @@ class OmnitableColumnDate extends columnMixin(PolymerElement) {
|
|
|
27
27
|
|
|
28
28
|
getFilterFn(column, filter) {
|
|
29
29
|
const
|
|
30
|
-
min = getComparableValue(
|
|
31
|
-
max = getComparableValue(
|
|
30
|
+
min = getComparableValue({ ...column, valuePath: 'min' }, filter),
|
|
31
|
+
max = getComparableValue({ ...column, valuePath: 'max' }, filter);
|
|
32
32
|
|
|
33
33
|
if (min == null && max == null) {
|
|
34
34
|
return;
|
|
@@ -48,8 +48,8 @@ class OmnitableColumnDate extends columnMixin(PolymerElement) {
|
|
|
48
48
|
return getString(column, item);
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
getComparableValue(
|
|
52
|
-
return getComparableValue(
|
|
51
|
+
getComparableValue(column, item) {
|
|
52
|
+
return getComparableValue(column, item);
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
serializeFilter(column, filter) {
|
|
@@ -117,8 +117,8 @@ class OmnitableColumnDate extends columnMixin(PolymerElement) {
|
|
|
117
117
|
></cosmoz-omnitable-date-range-input>`;
|
|
118
118
|
}
|
|
119
119
|
|
|
120
|
-
computeSource(
|
|
121
|
-
return
|
|
120
|
+
computeSource(column, data) {
|
|
121
|
+
return defaultComputeSource(column, data);
|
|
122
122
|
}
|
|
123
123
|
}
|
|
124
124
|
customElements.define('cosmoz-omnitable-column-date', OmnitableColumnDate);
|
|
@@ -8,7 +8,7 @@ import { PolymerElement } from '@polymer/polymer/polymer-element';
|
|
|
8
8
|
import { html } from 'lit-html';
|
|
9
9
|
import { fromHashString, getString, toHashString, toXlsxValue } from './lib/utils-datetime';
|
|
10
10
|
import { applySingleFilter, fromInputString, getComparableValue, toDate } from './lib/utils-date';
|
|
11
|
-
import {
|
|
11
|
+
import { defaultComputeSource } from './lib/utils-data';
|
|
12
12
|
import './lib/cosmoz-omnitable-datetime-range-input';
|
|
13
13
|
|
|
14
14
|
/**
|
|
@@ -36,8 +36,8 @@ class OmnitableColumnDatetime extends columnMixin(PolymerElement) {
|
|
|
36
36
|
|
|
37
37
|
getFilterFn(column, filter) {
|
|
38
38
|
const
|
|
39
|
-
min = getComparableValue(
|
|
40
|
-
max = getComparableValue(
|
|
39
|
+
min = getComparableValue({ ...column, valuePath: 'min' }, filter),
|
|
40
|
+
max = getComparableValue({ ...column, valuePath: 'max' }, filter);
|
|
41
41
|
|
|
42
42
|
if (min == null && max == null) {
|
|
43
43
|
return;
|
|
@@ -57,8 +57,8 @@ class OmnitableColumnDatetime extends columnMixin(PolymerElement) {
|
|
|
57
57
|
return getString(column, item);
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
-
getComparableValue(
|
|
61
|
-
return getComparableValue(
|
|
60
|
+
getComparableValue(column, item) {
|
|
61
|
+
return getComparableValue(column, item);
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
serializeFilter(column, filter) {
|
|
@@ -123,8 +123,8 @@ class OmnitableColumnDatetime extends columnMixin(PolymerElement) {
|
|
|
123
123
|
></cosmoz-omnitable-datetime-range-input>`;
|
|
124
124
|
}
|
|
125
125
|
|
|
126
|
-
computeSource(
|
|
127
|
-
return
|
|
126
|
+
computeSource(column, data) {
|
|
127
|
+
return defaultComputeSource(column, data);
|
|
128
128
|
}
|
|
129
129
|
}
|
|
130
130
|
|
|
@@ -130,7 +130,7 @@ const
|
|
|
130
130
|
return getString(column, item);
|
|
131
131
|
}
|
|
132
132
|
|
|
133
|
-
getComparableValue(
|
|
133
|
+
getComparableValue({ valuePath, valueProperty }, item) {
|
|
134
134
|
const value = get(item, valuePath);
|
|
135
135
|
if (valueProperty == null) {
|
|
136
136
|
return value;
|
|
@@ -160,7 +160,9 @@ const
|
|
|
160
160
|
}
|
|
161
161
|
|
|
162
162
|
computeSource(column, data) {
|
|
163
|
-
return
|
|
163
|
+
return column.externalValues || typeof column.values === 'function'
|
|
164
|
+
? column.values
|
|
165
|
+
: computeSource(column, data);
|
|
164
166
|
}
|
|
165
167
|
};
|
|
166
168
|
|
|
@@ -3,6 +3,7 @@ import { get } from '@polymer/polymer/lib/utils/path';
|
|
|
3
3
|
export const
|
|
4
4
|
getString = ({ valuePath }, item) => get(item, valuePath),
|
|
5
5
|
toXlsxValue = getString,
|
|
6
|
+
getComparableValue = getString,
|
|
6
7
|
|
|
7
8
|
applySingleFilter = ({ valuePath }, filter) => item => {
|
|
8
9
|
const value = get(item, valuePath);
|
|
@@ -87,12 +88,12 @@ export const
|
|
|
87
88
|
return filter;
|
|
88
89
|
}
|
|
89
90
|
|
|
90
|
-
getComparableValue(
|
|
91
|
-
return
|
|
91
|
+
getComparableValue(column, item) {
|
|
92
|
+
return getComparableValue(column, item);
|
|
92
93
|
}
|
|
93
94
|
|
|
94
|
-
computeSource() {
|
|
95
|
-
return
|
|
95
|
+
computeSource(column, data) {
|
|
96
|
+
return data;
|
|
96
97
|
}
|
|
97
98
|
|
|
98
99
|
_propertiesChanged(currentProps, changedProps, oldProps) {
|
|
@@ -8,7 +8,7 @@ import { html } from 'lit-html';
|
|
|
8
8
|
import { columnMixin } from './cosmoz-omnitable-column-mixin';
|
|
9
9
|
|
|
10
10
|
import './lib/cosmoz-omnitable-number-range-input';
|
|
11
|
-
import {
|
|
11
|
+
import { defaultComputeSource } from './lib/utils-data';
|
|
12
12
|
import { applySingleFilter, getComparableValue, getInputString, getString, toHashString, toNumber } from './lib/utils-number';
|
|
13
13
|
import { get } from '@polymer/polymer/lib/utils/path';
|
|
14
14
|
|
|
@@ -36,8 +36,8 @@ class OmnitableColumnNumber extends columnMixin(PolymerElement) {
|
|
|
36
36
|
|
|
37
37
|
getFilterFn(column, filter) {
|
|
38
38
|
const
|
|
39
|
-
min = getComparableValue(
|
|
40
|
-
max = getComparableValue(
|
|
39
|
+
min = getComparableValue({ ...column, valuePath: 'min' }, filter),
|
|
40
|
+
max = getComparableValue({ ...column, valuePath: 'max' }, filter);
|
|
41
41
|
|
|
42
42
|
if (min == null && max == null) {
|
|
43
43
|
return;
|
|
@@ -57,8 +57,8 @@ class OmnitableColumnNumber extends columnMixin(PolymerElement) {
|
|
|
57
57
|
return getString(column, item);
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
-
getComparableValue(
|
|
61
|
-
return getComparableValue(
|
|
60
|
+
getComparableValue(column, item) {
|
|
61
|
+
return getComparableValue(column, item);
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
serializeFilter(column, filter) {
|
|
@@ -127,8 +127,8 @@ class OmnitableColumnNumber extends columnMixin(PolymerElement) {
|
|
|
127
127
|
></cosmoz-omnitable-number-range-input>`;
|
|
128
128
|
}
|
|
129
129
|
|
|
130
|
-
computeSource(
|
|
131
|
-
return
|
|
130
|
+
computeSource(column, data) {
|
|
131
|
+
return defaultComputeSource(column, data);
|
|
132
132
|
}
|
|
133
133
|
}
|
|
134
134
|
customElements.define('cosmoz-omnitable-column-number', OmnitableColumnNumber);
|
|
@@ -10,7 +10,7 @@ import { html } from 'lit-html';
|
|
|
10
10
|
import { columnMixin } from './cosmoz-omnitable-column-mixin';
|
|
11
11
|
import { getComparableValue, getString, toXlsxValue, applySingleFilter, toDate, toHashString, fromHashString } from './lib/utils-time';
|
|
12
12
|
import './lib/cosmoz-omnitable-time-range-input';
|
|
13
|
-
import {
|
|
13
|
+
import { defaultComputeSource } from './lib/utils-data';
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
16
|
* @polymer
|
|
@@ -38,8 +38,8 @@ class OmnitableColumnTime extends columnMixin(PolymerElement) {
|
|
|
38
38
|
|
|
39
39
|
getFilterFn(column, filter) {
|
|
40
40
|
const
|
|
41
|
-
min = getComparableValue(
|
|
42
|
-
max = getComparableValue(
|
|
41
|
+
min = getComparableValue({ ...column, valuePath: 'min' }, filter),
|
|
42
|
+
max = getComparableValue({ ...column, valuePath: 'max' }, filter);
|
|
43
43
|
|
|
44
44
|
if (min == null && max == null) {
|
|
45
45
|
return;
|
|
@@ -59,8 +59,8 @@ class OmnitableColumnTime extends columnMixin(PolymerElement) {
|
|
|
59
59
|
return getString(column, item);
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
-
getComparableValue(
|
|
63
|
-
return getComparableValue(
|
|
62
|
+
getComparableValue(column, item) {
|
|
63
|
+
return getComparableValue(column, item);
|
|
64
64
|
}
|
|
65
65
|
|
|
66
66
|
serializeFilter(column, filter) {
|
|
@@ -124,8 +124,8 @@ class OmnitableColumnTime extends columnMixin(PolymerElement) {
|
|
|
124
124
|
></cosmoz-omnitable-time-range-input>`;
|
|
125
125
|
}
|
|
126
126
|
|
|
127
|
-
computeSource(
|
|
128
|
-
return
|
|
127
|
+
computeSource(column, data) {
|
|
128
|
+
return defaultComputeSource(column, data);
|
|
129
129
|
}
|
|
130
130
|
}
|
|
131
131
|
customElements.define('cosmoz-omnitable-column-time', OmnitableColumnTime);
|
package/cosmoz-omnitable.js
CHANGED
|
@@ -23,7 +23,7 @@ import styles from './cosmoz-omnitable-styles';
|
|
|
23
23
|
|
|
24
24
|
import { PolymerElement } from '@polymer/polymer/polymer-element';
|
|
25
25
|
import { html } from '@polymer/polymer/lib/utils/html-tag';
|
|
26
|
-
import { html as litHtml
|
|
26
|
+
import { html as litHtml } from 'lit-html';
|
|
27
27
|
|
|
28
28
|
import { translatable } from '@neovici/cosmoz-i18next';
|
|
29
29
|
import { mixin, hauntedPolymer } from '@neovici/cosmoz-utils';
|
|
@@ -275,8 +275,7 @@ class Omnitable extends hauntedPolymer(useOmnitable)(mixin({ isEmpty }, translat
|
|
|
275
275
|
|
|
276
276
|
static get observers() {
|
|
277
277
|
return [
|
|
278
|
-
'_selectedItemsChanged(selectedItems.*)'
|
|
279
|
-
'renderFastLayoutCss(layoutCss, $.layoutStyle)'
|
|
278
|
+
'_selectedItemsChanged(selectedItems.*)'
|
|
280
279
|
];
|
|
281
280
|
}
|
|
282
281
|
|
|
@@ -516,10 +515,6 @@ class Omnitable extends hauntedPolymer(useOmnitable)(mixin({ isEmpty }, translat
|
|
|
516
515
|
return this.ngettext('{0} row', '{0} rows', numRows);
|
|
517
516
|
}
|
|
518
517
|
|
|
519
|
-
renderFastLayoutCss(layoutCss, outlet) {
|
|
520
|
-
render(layoutCss, outlet);
|
|
521
|
-
}
|
|
522
|
-
|
|
523
518
|
_onCompleteValues(columns, type, value) { /* eslint-disable-next-line no-bitwise */
|
|
524
519
|
return columns?.filter?.(c => c[type]).sort((a, b) => ((b === value) >> 0) - ((a === value) >> 0));
|
|
525
520
|
}
|
package/lib/use-dom-columns.js
CHANGED
|
@@ -41,6 +41,7 @@ const
|
|
|
41
41
|
? domColumns.filter(column => enabledColumns.includes(column.name))
|
|
42
42
|
: domColumns.filter(column => !column.disabled);
|
|
43
43
|
|
|
44
|
+
// eslint-disable-next-line max-lines-per-function
|
|
44
45
|
return columns.map(column => ({
|
|
45
46
|
name: column.name,
|
|
46
47
|
title: column.title,
|
|
@@ -66,14 +67,13 @@ const
|
|
|
66
67
|
renderGroup: column.renderGroup,
|
|
67
68
|
cellTitleFn: column.cellTitleFn,
|
|
68
69
|
getFilterFn: column.getFilterFn,
|
|
70
|
+
headerCellClass: column.headerCellClass,
|
|
69
71
|
cellClass: column.cellClass,
|
|
70
72
|
|
|
71
73
|
editable: column.editable,
|
|
72
74
|
|
|
73
75
|
values: column.values,
|
|
74
|
-
source: memooize(
|
|
75
|
-
? column.values
|
|
76
|
-
: column.computeSource(column, data)),
|
|
76
|
+
source: memooize(column.computeSource),
|
|
77
77
|
|
|
78
78
|
// @deprecated
|
|
79
79
|
loading: column.loading,
|
|
@@ -107,7 +107,6 @@ const
|
|
|
107
107
|
|
|
108
108
|
// treenode columns
|
|
109
109
|
ownerTree: column.ownerTree,
|
|
110
|
-
showMaxNodes: column.showMaxNodes,
|
|
111
110
|
keyProperty: column.keyProperty,
|
|
112
111
|
|
|
113
112
|
[columnSymbol]: column
|
package/lib/use-fast-layout.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { useMemo } from 'haunted';
|
|
1
|
+
import { useEffect, useLayoutEffect, useMemo } from 'haunted';
|
|
2
2
|
import { toCss } from './compute-layout';
|
|
3
3
|
import { useResizableColumns } from './use-resizable-columns';
|
|
4
4
|
import { useCanvasWidth } from './use-canvas-width';
|
|
5
5
|
import { useTweenArray } from './use-tween-array';
|
|
6
6
|
import { useLayout } from './use-layout';
|
|
7
7
|
import { columnSymbol } from './normalize-settings';
|
|
8
|
+
import { render } from 'lit-html';
|
|
8
9
|
|
|
9
10
|
export const useFastLayout = ({ host, settings, setSettings, groupOnColumn, resizeSpeedFactor }) => {
|
|
10
11
|
const
|
|
@@ -26,8 +27,26 @@ export const useFastLayout = ({ host, settings, setSettings, groupOnColumn, resi
|
|
|
26
27
|
|
|
27
28
|
useResizableColumns({ host, canvasWidth, layout, setSettings: update => setSettings(update(settings)) });
|
|
28
29
|
|
|
30
|
+
useLayoutEffect(() => render(layoutCss, host.$.layoutStyle), [layoutCss]);
|
|
31
|
+
|
|
32
|
+
// force iron-list to render when the omnitable becomes visible
|
|
33
|
+
useEffect(() => {
|
|
34
|
+
let lastWidth = 0;
|
|
35
|
+
|
|
36
|
+
const
|
|
37
|
+
onResize = ([entry]) => {
|
|
38
|
+
if (lastWidth === 0) {
|
|
39
|
+
requestAnimationFrame(() => host.$.groupedList.$.list._render());
|
|
40
|
+
}
|
|
41
|
+
lastWidth = entry.contentRect?.width;
|
|
42
|
+
},
|
|
43
|
+
observer = new ResizeObserver(onResize);
|
|
44
|
+
|
|
45
|
+
observer.observe(host);
|
|
46
|
+
return () => observer.unobserve(host);
|
|
47
|
+
}, []);
|
|
48
|
+
|
|
29
49
|
return {
|
|
30
|
-
layoutCss,
|
|
31
50
|
collapsedColumns
|
|
32
51
|
};
|
|
33
52
|
};
|
|
@@ -14,7 +14,7 @@ const
|
|
|
14
14
|
|
|
15
15
|
Object.entries(changes).forEach(([key, value]) => {
|
|
16
16
|
column[columnSymbol][key] = value;
|
|
17
|
-
column[columnSymbol].dispatchEvent(new CustomEvent(`${ kebab(key) }-changed`, { bubbles: true, value }));
|
|
17
|
+
column[columnSymbol].dispatchEvent(new CustomEvent(`${ kebab(key) }-changed`, { bubbles: true, detail: { value }}));
|
|
18
18
|
});
|
|
19
19
|
};
|
|
20
20
|
|
|
@@ -78,12 +78,12 @@ export const useProcessedItems = ({ data, columns, groupOnColumn, groupOnDescend
|
|
|
78
78
|
// todo: extract function
|
|
79
79
|
processedItems = useMemo(() => {
|
|
80
80
|
if (!groupOnColumn && sortOnColumn != null && sortOnColumn.sortOn != null) {
|
|
81
|
-
return filteredItems.slice().sort(sortBy(a => sortOnColumn.getComparableValue(
|
|
81
|
+
return filteredItems.slice().sort(sortBy(a => sortOnColumn.getComparableValue({ ...sortOnColumn, valuePath: sortOnColumn.sortOn }, a), descending));
|
|
82
82
|
}
|
|
83
83
|
|
|
84
84
|
if (groupOnColumn != null && groupOnColumn.groupOn != null) {
|
|
85
85
|
const groupedResults = filteredItems.reduce((acc, item) => {
|
|
86
|
-
const gval = groupOnColumn.getComparableValue(
|
|
86
|
+
const gval = groupOnColumn.getComparableValue({ ...groupOnColumn, valuePath: groupOnColumn.groupOn }, item);
|
|
87
87
|
|
|
88
88
|
if (gval === undefined) {
|
|
89
89
|
return acc;
|
|
@@ -104,7 +104,8 @@ export const useProcessedItems = ({ data, columns, groupOnColumn, groupOnDescend
|
|
|
104
104
|
return acc;
|
|
105
105
|
}, []);
|
|
106
106
|
|
|
107
|
-
groupedResults.sort(sortBy(
|
|
107
|
+
groupedResults.sort(sortBy(
|
|
108
|
+
a => groupOnColumn.getComparableValue({ ...groupOnColumn, valuePath: groupOnColumn.groupOn }, a.items[0]), groupOnDescending));
|
|
108
109
|
|
|
109
110
|
if (!sortOnColumn) {
|
|
110
111
|
return groupedResults;
|
|
@@ -113,7 +114,7 @@ export const useProcessedItems = ({ data, columns, groupOnColumn, groupOnDescend
|
|
|
113
114
|
return groupedResults
|
|
114
115
|
.filter(group => Array.isArray(group.items))
|
|
115
116
|
.map(group => {
|
|
116
|
-
group.items.sort(sortBy(a => sortOnColumn.getComparableValue(
|
|
117
|
+
group.items.sort(sortBy(a => sortOnColumn.getComparableValue({ ...sortOnColumn, valuePath: sortOnColumn.sortOn }, a), descending));
|
|
117
118
|
return group;
|
|
118
119
|
});
|
|
119
120
|
}
|
package/lib/utils-amount.js
CHANGED
|
@@ -45,7 +45,7 @@ export const
|
|
|
45
45
|
return lNumber === valAmount ? amount : lAmount;
|
|
46
46
|
},
|
|
47
47
|
|
|
48
|
-
getComparableValue = (
|
|
48
|
+
getComparableValue = ({ valuePath, rates }, item) => {
|
|
49
49
|
if (item == null) {
|
|
50
50
|
return;
|
|
51
51
|
}
|
|
@@ -70,15 +70,15 @@ export const
|
|
|
70
70
|
},
|
|
71
71
|
|
|
72
72
|
applySingleFilter = (column, filter) => item => {
|
|
73
|
-
const value = getComparableValue(
|
|
73
|
+
const value = getComparableValue(column, item);
|
|
74
74
|
|
|
75
75
|
if (value == null) {
|
|
76
76
|
return false;
|
|
77
77
|
}
|
|
78
78
|
|
|
79
79
|
const
|
|
80
|
-
min = getComparableValue(
|
|
81
|
-
max = getComparableValue(
|
|
80
|
+
min = getComparableValue({ ...column, valuePath: 'min' }, filter),
|
|
81
|
+
max = getComparableValue({ ...column, valuePath: 'max' }, filter);
|
|
82
82
|
|
|
83
83
|
return !(value < min || value > max);
|
|
84
84
|
},
|
package/lib/utils-data.js
CHANGED
|
@@ -8,6 +8,11 @@ export const
|
|
|
8
8
|
value != null && self.indexOf(value) === index
|
|
9
9
|
),
|
|
10
10
|
|
|
11
|
+
defaultComputeSource = ({ externalValues, values, valuePath }, data) =>
|
|
12
|
+
externalValues || typeof values === 'function'
|
|
13
|
+
? values
|
|
14
|
+
: valuesFrom(data, valuePath),
|
|
15
|
+
|
|
11
16
|
onItemChange = (host, column, item, value) => {
|
|
12
17
|
const
|
|
13
18
|
{ valuePath } = column,
|
package/lib/utils-date.js
CHANGED
|
@@ -56,11 +56,11 @@ export const
|
|
|
56
56
|
/**
|
|
57
57
|
* Get comparable number from date
|
|
58
58
|
*
|
|
59
|
-
* @param {Object} item Item to be processed
|
|
60
59
|
* @param {String} valuePath Property path
|
|
60
|
+
* @param {Object} item Item to be processed
|
|
61
61
|
* @returns {Number|void} Valid value or void
|
|
62
62
|
*/
|
|
63
|
-
getComparableValue = (
|
|
63
|
+
getComparableValue = ({ valuePath }, item) => {
|
|
64
64
|
if (item == null) {
|
|
65
65
|
return;
|
|
66
66
|
}
|
|
@@ -100,8 +100,8 @@ export const
|
|
|
100
100
|
return date;
|
|
101
101
|
}
|
|
102
102
|
|
|
103
|
-
const comparableDate = getComparableValue(date),
|
|
104
|
-
comparableLDate = getComparableValue(lDate),
|
|
103
|
+
const comparableDate = getComparableValue({}, date),
|
|
104
|
+
comparableLDate = getComparableValue({}, lDate),
|
|
105
105
|
limitedValue = limitFunc(comparableDate, comparableLDate);
|
|
106
106
|
return limitedValue === comparableDate ? date : lDate;
|
|
107
107
|
},
|
|
@@ -188,15 +188,15 @@ export const
|
|
|
188
188
|
},
|
|
189
189
|
|
|
190
190
|
applySingleFilter = (column, filter) => item => {
|
|
191
|
-
const value = getComparableValue(
|
|
191
|
+
const value = getComparableValue(column, item);
|
|
192
192
|
|
|
193
193
|
if (value == null) {
|
|
194
194
|
return false;
|
|
195
195
|
}
|
|
196
196
|
|
|
197
197
|
const
|
|
198
|
-
min = getComparableValue(
|
|
199
|
-
max = getComparableValue(
|
|
198
|
+
min = getComparableValue({ ...column, valuePath: 'min' }, filter),
|
|
199
|
+
max = getComparableValue({ ...column, valuePath: 'max' }, filter);
|
|
200
200
|
|
|
201
201
|
return !(value < min || value > max);
|
|
202
202
|
};
|
package/lib/utils-number.js
CHANGED
|
@@ -50,7 +50,7 @@ export const
|
|
|
50
50
|
return string;
|
|
51
51
|
},
|
|
52
52
|
|
|
53
|
-
getComparableValue = (
|
|
53
|
+
getComparableValue = ({ valuePath, maximumFractionDigits }, item) => {
|
|
54
54
|
if (item == null) {
|
|
55
55
|
return;
|
|
56
56
|
}
|
|
@@ -98,15 +98,15 @@ export const
|
|
|
98
98
|
},
|
|
99
99
|
|
|
100
100
|
applySingleFilter = (column, filter) => item => {
|
|
101
|
-
const value = getComparableValue(
|
|
101
|
+
const value = getComparableValue(column, item);
|
|
102
102
|
|
|
103
103
|
if (value == null) {
|
|
104
104
|
return false;
|
|
105
105
|
}
|
|
106
106
|
|
|
107
107
|
const
|
|
108
|
-
min = getComparableValue(
|
|
109
|
-
max = getComparableValue(
|
|
108
|
+
min = getComparableValue({ ...column, valuePath: 'min' }, filter),
|
|
109
|
+
max = getComparableValue({ ...column, valuePath: 'max' }, filter);
|
|
110
110
|
|
|
111
111
|
return !(value < min || value > max);
|
|
112
112
|
};
|
package/lib/utils-time.js
CHANGED
|
@@ -67,7 +67,7 @@ export const
|
|
|
67
67
|
return toLocalISOString(date).slice(11, 19);
|
|
68
68
|
},
|
|
69
69
|
|
|
70
|
-
getComparableValue = (
|
|
70
|
+
getComparableValue = ({ valuePath }, item) => {
|
|
71
71
|
if (item == null) {
|
|
72
72
|
return;
|
|
73
73
|
}
|
|
@@ -83,15 +83,15 @@ export const
|
|
|
83
83
|
},
|
|
84
84
|
|
|
85
85
|
applySingleFilter = (column, filter) => item => {
|
|
86
|
-
const value = getComparableValue(
|
|
86
|
+
const value = getComparableValue(column, item);
|
|
87
87
|
|
|
88
88
|
if (value == null) {
|
|
89
89
|
return false;
|
|
90
90
|
}
|
|
91
91
|
|
|
92
92
|
const
|
|
93
|
-
min = getComparableValue(
|
|
94
|
-
max = getComparableValue(
|
|
93
|
+
min = getComparableValue({ ...column, valuePath: 'min' }, filter),
|
|
94
|
+
max = getComparableValue({ ...column, valuePath: 'max' }, filter);
|
|
95
95
|
|
|
96
96
|
return !(value < min || value > max);
|
|
97
97
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@neovici/cosmoz-omnitable",
|
|
3
|
-
"version": "8.0.0-beta.
|
|
3
|
+
"version": "8.0.0-beta.7",
|
|
4
4
|
"description": "[](https://travis-ci.org/Neovici/cosmoz-omnitable)",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"web-components"
|