@neovici/cosmoz-omnitable 12.8.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.
- package/cosmoz-omnitable-column-mixin.js +118 -104
- package/cosmoz-omnitable-styles.js +8 -9
- package/package.json +1 -1
|
@@ -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
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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
|
-
|
|
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
|
-
*
|
|
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
|
-
|
|
66
|
-
|
|
67
|
-
}
|
|
96
|
+
// eslint-disable-next-line no-empty-function
|
|
97
|
+
getFilterFn() {}
|
|
68
98
|
|
|
69
|
-
|
|
70
|
-
|
|
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
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
getString(column, item) {
|
|
88
|
-
return getString(column, item);
|
|
89
|
-
}
|
|
103
|
+
toXlsxValue(column, item) {
|
|
104
|
+
return toXlsxValue(column, item);
|
|
105
|
+
}
|
|
90
106
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
107
|
+
cellTitleFn(column, item) {
|
|
108
|
+
return getString(column, item);
|
|
109
|
+
}
|
|
94
110
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
111
|
+
serializeFilter(column, filter) {
|
|
112
|
+
return serializeFilter(column, filter);
|
|
113
|
+
}
|
|
98
114
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
115
|
+
deserializeFilter(column, filter) {
|
|
116
|
+
if (filter == null) {
|
|
117
|
+
return null;
|
|
118
|
+
}
|
|
102
119
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
120
|
+
if (typeof filter === 'string') {
|
|
121
|
+
return window.decodeURIComponent(filter);
|
|
122
|
+
}
|
|
123
|
+
return filter;
|
|
106
124
|
}
|
|
107
125
|
|
|
108
|
-
|
|
109
|
-
return
|
|
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
|
-
|
|
119
|
-
|
|
120
|
-
|
|
130
|
+
computeSource(column, data) {
|
|
131
|
+
return data;
|
|
132
|
+
}
|
|
121
133
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
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
|
+
};
|
|
@@ -132,25 +132,24 @@ export default css`
|
|
|
132
132
|
--paper-font-caption_-_line-height: 18px;
|
|
133
133
|
}
|
|
134
134
|
--paper-font-subhead_-_font-family: var(
|
|
135
|
-
--cosmoz-omnitable-header-font-family,
|
|
136
|
-
'Inter' sans-serif
|
|
135
|
+
--cosmoz-omnitable-header-font-family, 'Roboto', 'Noto', sans-serif
|
|
137
136
|
);
|
|
138
|
-
text-transform: var(--cosmoz-omnitable-header-text-transform,
|
|
137
|
+
text-transform: var(--cosmoz-omnitable-header-text-transform, none);
|
|
139
138
|
--paper-font-subhead_-_font-weight: var(
|
|
140
139
|
--cosmoz-omnitable-header-font-weight,
|
|
141
|
-
|
|
140
|
+
normal
|
|
142
141
|
);
|
|
143
142
|
--paper-font-subhead_-_font-size: var(
|
|
144
143
|
--cosmoz-omnitable-header-font-size,
|
|
145
|
-
|
|
144
|
+
16px
|
|
146
145
|
);
|
|
147
146
|
}
|
|
148
147
|
|
|
149
148
|
cosmoz-autocomplete-ui::part(input-label) {
|
|
150
|
-
text-transform: var(--cosmoz-omnitable-header-text-transform,
|
|
151
|
-
font-weight: var(--cosmoz-omnitable-header-font-weight,
|
|
152
|
-
font-family: var(--cosmoz-omnitable-header-font-family, '
|
|
153
|
-
font-size: var(--cosmoz-omnitable-header-font-size,
|
|
149
|
+
text-transform: var(--cosmoz-omnitable-header-text-transform, none);
|
|
150
|
+
font-weight: var(--cosmoz-omnitable-header-font-weight, normal);
|
|
151
|
+
font-family: var(--cosmoz-omnitable-header-font-family, 'Roboto', 'Noto', sans-serif);
|
|
152
|
+
font-size: var(--cosmoz-omnitable-header-font-size, 16px);
|
|
154
153
|
}
|
|
155
154
|
cosmoz-omnitable-header-row {
|
|
156
155
|
white-space: nowrap;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@neovici/cosmoz-omnitable",
|
|
3
|
-
"version": "12.
|
|
3
|
+
"version": "12.10.0",
|
|
4
4
|
"description": "[](https://travis-ci.org/Neovici/cosmoz-omnitable)",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"web-components"
|