@neovici/cosmoz-omnitable 8.0.0-beta.2 → 8.0.0-beta.6

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/README.md CHANGED
@@ -28,3 +28,5 @@ views/administration/periods/list.js
28
28
  BUGS:
29
29
  * when navigating the queue, filters are not reset when view-core is reused
30
30
  * autocomplete columns without valueProperty might not work
31
+ * treenode cells have show-max-nodes="undefined"
32
+ * treenode source has empty texts
@@ -35,8 +35,8 @@ class OmnitableColumnAmount extends columnMixin(PolymerElement) {
35
35
 
36
36
  getFilterFn(column, filter) {
37
37
  const
38
- min = getComparableValue(filter, 'min', column),
39
- max = getComparableValue(filter, 'max', column);
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(item, valuePath, column) {
60
- return getComparableValue(item, valuePath, column);
59
+ getComparableValue(column, item) {
60
+ return getComparableValue(column, item);
61
61
  }
62
62
 
63
63
  serializeFilter({ rates }, filter) {
@@ -14,7 +14,7 @@ import {
14
14
  import { get } from '@polymer/polymer/lib/utils/path';
15
15
 
16
16
  export const
17
- getComparableValue = (item, valuePath, { textProperty, valueProperty } = {}) => {
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,8 +63,8 @@ class OmnitableColumnAutocomplete extends listColumnMixin(columnMixin(PolymerEle
63
63
  >${ spinner }</cosmoz-autocomplete-ui>`;
64
64
  }
65
65
 
66
- getComparableValue(item, valuePath, column) {
67
- return getComparableValue(item, valuePath, column);
66
+ getComparableValue(column, item) {
67
+ return getComparableValue(column, item);
68
68
  }
69
69
 
70
70
  computeSource(column, data) {
@@ -27,8 +27,8 @@ class OmnitableColumnDate extends columnMixin(PolymerElement) {
27
27
 
28
28
  getFilterFn(column, filter) {
29
29
  const
30
- min = getComparableValue(filter, 'min', column),
31
- max = getComparableValue(filter, 'max', column);
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(item, valuePath, column) {
52
- return getComparableValue(item, valuePath, column);
51
+ getComparableValue(column, item) {
52
+ return getComparableValue(column, item);
53
53
  }
54
54
 
55
55
  serializeFilter(column, filter) {
@@ -36,8 +36,8 @@ class OmnitableColumnDatetime extends columnMixin(PolymerElement) {
36
36
 
37
37
  getFilterFn(column, filter) {
38
38
  const
39
- min = getComparableValue(filter, 'min', column),
40
- max = getComparableValue(filter, 'max', column);
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(item, valuePath, column) {
61
- return getComparableValue(item, valuePath, column);
60
+ getComparableValue(column, item) {
61
+ return getComparableValue(column, item);
62
62
  }
63
63
 
64
64
  serializeFilter(column, filter) {
@@ -130,7 +130,7 @@ const
130
130
  return getString(column, item);
131
131
  }
132
132
 
133
- getComparableValue(item, valuePath, { valueProperty }) {
133
+ getComparableValue({ valuePath, valueProperty }, item) {
134
134
  const value = get(item, valuePath);
135
135
  if (valueProperty == null) {
136
136
  return value;
@@ -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(item, valuePath) {
91
- return get(item, valuePath);
91
+ getComparableValue(column, item) {
92
+ return getComparableValue(column, item);
92
93
  }
93
94
 
94
- computeSource() {
95
- return null;
95
+ computeSource(column, data) {
96
+ return data;
96
97
  }
97
98
 
98
99
  _propertiesChanged(currentProps, changedProps, oldProps) {
@@ -36,8 +36,8 @@ class OmnitableColumnNumber extends columnMixin(PolymerElement) {
36
36
 
37
37
  getFilterFn(column, filter) {
38
38
  const
39
- min = getComparableValue(filter, 'min', column),
40
- max = getComparableValue(filter, 'max', column);
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(item, valuePath, column) {
61
- return getComparableValue(item, valuePath, column);
60
+ getComparableValue(column, item) {
61
+ return getComparableValue(column, item);
62
62
  }
63
63
 
64
64
  serializeFilter(column, filter) {
@@ -38,8 +38,8 @@ class OmnitableColumnTime extends columnMixin(PolymerElement) {
38
38
 
39
39
  getFilterFn(column, filter) {
40
40
  const
41
- min = getComparableValue(filter, 'min', column),
42
- max = getComparableValue(filter, 'max', column);
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(item, valuePath, column) {
63
- return getComparableValue(item, valuePath, column);
62
+ getComparableValue(column, item) {
63
+ return getComparableValue(column, item);
64
64
  }
65
65
 
66
66
  serializeFilter(column, filter) {
@@ -22,7 +22,7 @@ const checkbox = `
22
22
  }
23
23
 
24
24
  .checkbox:checked {
25
- background-color: var(--paper-checkbox-checked-color, var(--primary-color));
25
+ background-color: var(--cosmoz-omnitable-checkbox-checked-color, var(--primary-color));
26
26
  box-shadow: none;
27
27
  }
28
28
 
@@ -63,7 +63,7 @@ const checkbox = `
63
63
  height: 2px;
64
64
  left: 4px;
65
65
  top: 8px;
66
- background-color: var(--paper-checkbox-checked-color, var(--primary-color));
66
+ background-color: var(--cosmoz-omnitable-checkbox-checked-color, var(--primary-color));
67
67
  }
68
68
  `;
69
69
 
@@ -282,7 +282,7 @@ export default `<style>
282
282
  display: flex;
283
283
  align-items: center;
284
284
  border-top: solid 1px #e8e8e8;
285
- background-color: #f5f5f5;
285
+ background-color: var(--cosmoz-omnitable-footer-bg-color, #f5f5f5);
286
286
  min-height: 25px;
287
287
  height: 63px;
288
288
  margin-bottom: 1px; /* Chrome overflow rendering bug? When only component in a view */
@@ -3,7 +3,6 @@ import '@polymer/iron-icons/iron-icons';
3
3
  import '@polymer/iron-icon/iron-icon';
4
4
  import '@polymer/iron-label/iron-label';
5
5
  import '@polymer/paper-button/paper-button';
6
- import '@polymer/paper-checkbox/paper-checkbox';
7
6
  import '@polymer/paper-dropdown-menu/paper-dropdown-menu';
8
7
  import '@polymer/paper-icon-button/paper-icon-button';
9
8
  import '@polymer/paper-item/paper-item';
@@ -24,7 +23,7 @@ import styles from './cosmoz-omnitable-styles';
24
23
 
25
24
  import { PolymerElement } from '@polymer/polymer/polymer-element';
26
25
  import { html } from '@polymer/polymer/lib/utils/html-tag';
27
- import { html as litHtml, render } from 'lit-html';
26
+ import { html as litHtml } from 'lit-html';
28
27
 
29
28
  import { translatable } from '@neovici/cosmoz-i18next';
30
29
  import { mixin, hauntedPolymer } from '@neovici/cosmoz-utils';
@@ -276,8 +275,7 @@ class Omnitable extends hauntedPolymer(useOmnitable)(mixin({ isEmpty }, translat
276
275
 
277
276
  static get observers() {
278
277
  return [
279
- '_selectedItemsChanged(selectedItems.*)',
280
- 'renderFastLayoutCss(layoutCss, $.layoutStyle)'
278
+ '_selectedItemsChanged(selectedItems.*)'
281
279
  ];
282
280
  }
283
281
 
@@ -517,10 +515,6 @@ class Omnitable extends hauntedPolymer(useOmnitable)(mixin({ isEmpty }, translat
517
515
  return this.ngettext('{0} row', '{0} rows', numRows);
518
516
  }
519
517
 
520
- renderFastLayoutCss(layoutCss, outlet) {
521
- render(layoutCss, outlet);
522
- }
523
-
524
518
  _onCompleteValues(columns, type, value) { /* eslint-disable-next-line no-bitwise */
525
519
  return columns?.filter?.(c => c[type]).sort((a, b) => ((b === value) >> 0) - ((a === value) >> 0));
526
520
  }
@@ -232,7 +232,7 @@ const settingsStyles = `
232
232
  position: absolute;
233
233
  top: 1px;
234
234
  right: -4px;
235
- background-color: var(--paper-checkbox-checked-color, var(--primary-color));
235
+ background-color: var(--cosmoz-omnitable-checkbox-checked-color, var(--primary-color));
236
236
  width: 8px;
237
237
  height: 8px;
238
238
  border-radius: 100%;
@@ -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(a, sortOnColumn.sortOn, sortOnColumn), descending));
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(item, groupOnColumn.groupOn, groupOnColumn);
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(a => groupOnColumn.getComparableValue(a.items[0], groupOnColumn.groupOn, groupOnColumn), groupOnDescending));
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(a, sortOnColumn.sortOn, sortOnColumn), descending));
117
+ group.items.sort(sortBy(a => sortOnColumn.getComparableValue({ ...sortOnColumn, valuePath: sortOnColumn.sortOn }, a), descending));
117
118
  return group;
118
119
  });
119
120
  }
@@ -45,7 +45,7 @@ export const
45
45
  return lNumber === valAmount ? amount : lAmount;
46
46
  },
47
47
 
48
- getComparableValue = (item, valuePath, { rates } = {}) => {
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(item, column.valuePath, column);
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(filter, 'min', column),
81
- max = getComparableValue(filter, 'max', column);
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-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 = (item, valuePath) => {
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(item, column.valuePath, column);
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(filter, 'min', column),
199
- max = getComparableValue(filter, 'max', column);
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
  };
@@ -50,7 +50,7 @@ export const
50
50
  return string;
51
51
  },
52
52
 
53
- getComparableValue = (item, valuePath, { maximumFractionDigits } = {}) => {
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(item, column.valuePath, column);
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(filter, 'min', column),
109
- max = getComparableValue(filter, 'max', column);
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 = (item, valuePath) => {
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(item, column.valuePath, column);
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(filter, 'min', column),
94
- max = getComparableValue(filter, 'max', column);
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.2",
3
+ "version": "8.0.0-beta.6",
4
4
  "description": "[![Build Status](https://travis-ci.org/Neovici/cosmoz-omnitable.svg?branch=master)](https://travis-ci.org/Neovici/cosmoz-omnitable)",
5
5
  "keywords": [
6
6
  "web-components"
@@ -64,7 +64,6 @@
64
64
  "@polymer/iron-icons": "^3.0.0",
65
65
  "@polymer/iron-label": "^3.0.0",
66
66
  "@polymer/paper-button": "^3.0.0",
67
- "@polymer/paper-checkbox": "^3.0.0",
68
67
  "@polymer/paper-dropdown-menu": "^3.2.0",
69
68
  "@polymer/paper-icon-button": "^3.0.0",
70
69
  "@polymer/paper-input": "^3.2.0",