@neovici/cosmoz-omnitable 12.9.0 → 12.10.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.
@@ -1,126 +1,140 @@
1
1
  import { get } from '@polymer/polymer/lib/utils/path';
2
2
 
3
- export const
4
- getString = ({ valuePath }, item) => get(item, valuePath),
3
+ export const getString = ({ valuePath }, item) => get(item, valuePath),
5
4
  toXlsxValue = getString,
6
5
  getComparableValue = getString,
6
+ applySingleFilter =
7
+ ({ valuePath }, filter) =>
8
+ (item) => {
9
+ const value = get(item, valuePath);
10
+ if (value == null) {
11
+ return false;
12
+ }
13
+ return value
14
+ .toString()
15
+ .toLowerCase()
16
+ .trim()
17
+ .includes(filter.toLowerCase().trim());
18
+ },
19
+ serializeFilter = (column, filter) =>
20
+ filter === '' || filter == null ? null : filter,
21
+ // eslint-disable-next-line max-lines-per-function
22
+ columnMixin = (base) =>
23
+ class extends base {
24
+ static get properties() {
25
+ return {
26
+ /**
27
+ * Used to indicate that an element using this behavior is a column definition that can be used
28
+ * in cosmoz-omnitable
29
+ */
30
+ isOmnitableColumn: { type: Boolean, value: true },
31
+ title: { type: String },
32
+ valuePath: { type: String, notify: true },
33
+ values: { type: Array, notify: true },
34
+ filter: { type: Object },
35
+ /**
36
+ * If the column should be disabled until enabled with enabledColumns
37
+ */
38
+ disabled: { type: Boolean, value: false, notify: true },
39
+ /**
40
+ * If true, the column will be editable by using an input element for rendering.
41
+ */
42
+ editable: { type: Boolean, notify: true },
43
+ /**
44
+ * Indicate that the column is loading/performing work
45
+ */
46
+ loading: { type: Boolean, value: false, notify: true },
47
+ externalValues: { type: Boolean, value: false, notify: true },
48
+ /**
49
+ * Column name for use with enabledColumns
50
+ */
51
+ name: { type: String },
52
+ sortOn: { type: String },
53
+ groupOn: { type: String },
54
+ width: { type: String, value: '75px' },
55
+ minWidth: { type: String, value: '40px' },
56
+ flex: { type: String, value: '1' },
57
+ cellClass: { type: String, value: 'default-cell' },
58
+ headerCellClass: { type: String, value: 'default-header-cell' },
59
+ priority: { type: Number, value: 0 },
60
+ hidden: { type: Boolean, notify: true },
61
+ preferredDropdownHorizontalAlign: { type: String, value: 'right' },
62
+ renderHeader: { type: Function },
63
+ renderCell: { type: Function },
64
+ renderEditCell: { type: Function },
65
+ renderGroup: { type: Function },
66
+ };
67
+ }
7
68
 
8
- applySingleFilter = ({ valuePath }, filter) => item => {
9
- const value = get(item, valuePath);
10
- if (value == null) {
11
- return false;
12
- }
13
- return value.toString().toLowerCase().includes(filter.toLowerCase());
14
- },
69
+ static get observers() {
70
+ return ['notifyFilterChange(filter)'];
71
+ }
15
72
 
16
- serializeFilter = (column, filter) => filter === '' || filter == null ? null : filter,
73
+ notifyFilterChange(filter) {
74
+ if (this.__ownChange) {
75
+ return;
76
+ }
77
+ this.dispatchEvent(
78
+ new CustomEvent('legacy-filter-changed', {
79
+ detail: {
80
+ name: this.name,
81
+ state: this.legacyFilterToState(filter),
82
+ },
83
+ bubbles: true,
84
+ })
85
+ );
86
+ }
87
+
88
+ legacyFilterToState(filter) {
89
+ return { filter };
90
+ }
17
91
 
18
- // eslint-disable-next-line max-lines-per-function
19
- columnMixin = base => class extends base {
20
- static get properties() {
21
- return {
22
92
  /**
23
- * Used to indicate that an element using this behavior is a column definition that can be used
24
- * in cosmoz-omnitable
25
- */
26
- isOmnitableColumn: { type: Boolean, value: true },
27
- title: { type: String },
28
- valuePath: { type: String, notify: true },
29
- values: { type: Array, notify: true },
30
- filter: { type: Object },
31
- /**
32
- * If the column should be disabled until enabled with enabledColumns
33
- */
34
- disabled: { type: Boolean, value: false, notify: true },
35
- /**
36
- * If true, the column will be editable by using an input element for rendering.
37
- */
38
- editable: { type: Boolean, notify: true },
39
- /**
40
- * Indicate that the column is loading/performing work
93
+ * Override this in column elements if you need a different default width
41
94
  */
42
- loading: { type: Boolean, value: false, notify: true },
43
- externalValues: { type: Boolean, value: false, notify: true },
44
- /**
45
- * Column name for use with enabledColumns
46
- */
47
- name: { type: String },
48
- sortOn: { type: String },
49
- groupOn: { type: String },
50
- width: { type: String, value: '75px' },
51
- minWidth: { type: String, value: '40px' },
52
- flex: { type: String, value: '1' },
53
- cellClass: { type: String, value: 'default-cell' },
54
- headerCellClass: { type: String, value: 'default-header-cell' },
55
- priority: { type: Number, value: 0 },
56
- hidden: { type: Boolean, notify: true },
57
- preferredDropdownHorizontalAlign: { type: String, value: 'right' },
58
- renderHeader: { type: Function },
59
- renderCell: { type: Function },
60
- renderEditCell: { type: Function },
61
- renderGroup: { type: Function }
62
- };
63
- }
64
95
 
65
- static get observers() {
66
- return ['notifyFilterChange(filter)'];
67
- }
96
+ // eslint-disable-next-line no-empty-function
97
+ getFilterFn() {}
68
98
 
69
- notifyFilterChange(filter) {
70
- if (this.__ownChange) {
71
- return;
99
+ getString(column, item) {
100
+ return getString(column, item);
72
101
  }
73
- this.dispatchEvent(new CustomEvent('legacy-filter-changed', { detail: { name: this.name, state: this.legacyFilterToState(filter) }, bubbles: true }));
74
- }
75
-
76
- legacyFilterToState(filter) {
77
- return { filter };
78
- }
79
-
80
- /**
81
- * Override this in column elements if you need a different default width
82
- */
83
102
 
84
- // eslint-disable-next-line no-empty-function
85
- getFilterFn() {}
86
-
87
- getString(column, item) {
88
- return getString(column, item);
89
- }
103
+ toXlsxValue(column, item) {
104
+ return toXlsxValue(column, item);
105
+ }
90
106
 
91
- toXlsxValue(column, item) {
92
- return toXlsxValue(column, item);
93
- }
107
+ cellTitleFn(column, item) {
108
+ return getString(column, item);
109
+ }
94
110
 
95
- cellTitleFn(column, item) {
96
- return getString(column, item);
97
- }
111
+ serializeFilter(column, filter) {
112
+ return serializeFilter(column, filter);
113
+ }
98
114
 
99
- serializeFilter(column, filter) {
100
- return serializeFilter(column, filter);
101
- }
115
+ deserializeFilter(column, filter) {
116
+ if (filter == null) {
117
+ return null;
118
+ }
102
119
 
103
- deserializeFilter(column, filter) {
104
- if (filter == null) {
105
- return null;
120
+ if (typeof filter === 'string') {
121
+ return window.decodeURIComponent(filter);
122
+ }
123
+ return filter;
106
124
  }
107
125
 
108
- if (typeof filter === 'string') {
109
- return window.decodeURIComponent(filter);
126
+ getComparableValue(column, item) {
127
+ return getComparableValue(column, item);
110
128
  }
111
- return filter;
112
- }
113
-
114
- getComparableValue(column, item) {
115
- return getComparableValue(column, item);
116
- }
117
129
 
118
- computeSource(column, data) {
119
- return data;
120
- }
130
+ computeSource(column, data) {
131
+ return data;
132
+ }
121
133
 
122
- _propertiesChanged(currentProps, changedProps, oldProps) {
123
- super._propertiesChanged(currentProps, changedProps, oldProps);
124
- this.dispatchEvent(new CustomEvent('cosmoz-column-prop-changed', { bubbles: true }));
125
- }
126
- };
134
+ _propertiesChanged(currentProps, changedProps, oldProps) {
135
+ super._propertiesChanged(currentProps, changedProps, oldProps);
136
+ this.dispatchEvent(
137
+ new CustomEvent('cosmoz-column-prop-changed', { bubbles: true })
138
+ );
139
+ }
140
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@neovici/cosmoz-omnitable",
3
- "version": "12.9.0",
3
+ "version": "12.10.0",
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"