@neovici/cosmoz-omnitable 12.26.4 → 12.28.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-amount.js +46 -38
- package/cosmoz-omnitable-column-autocomplete.js +12 -11
- package/cosmoz-omnitable-column-date.js +3 -3
- package/cosmoz-omnitable-column-datetime.js +1 -1
- package/cosmoz-omnitable-column-list.js +10 -9
- package/cosmoz-omnitable-column-number.js +41 -25
- package/cosmoz-omnitable-column-time.js +33 -23
- package/cosmoz-omnitable-column.js +53 -41
- package/cosmoz-omnitable-styles.js +3 -12
- package/lib/cosmoz-omnitable-amount-range-input.js +82 -53
- package/lib/cosmoz-omnitable-date-range-input.js +44 -28
- package/lib/cosmoz-omnitable-datetime-range-input.js +46 -27
- package/lib/cosmoz-omnitable-number-range-input.js +51 -63
- package/lib/cosmoz-omnitable-range-input-mixin.js +2 -2
- package/lib/cosmoz-omnitable-time-range-input.js +5 -4
- package/package.json +6 -8
- package/ui-helpers/cosmoz-clear-button.js +66 -59
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/* eslint-disable no-return-assign */
|
|
2
|
-
import '@
|
|
2
|
+
import '@neovici/cosmoz-input';
|
|
3
3
|
import '@polymer/paper-dropdown-menu/paper-dropdown-menu';
|
|
4
4
|
import './ui-helpers/cosmoz-clear-button';
|
|
5
5
|
|
|
@@ -9,7 +9,16 @@ import { html } from 'lit-html';
|
|
|
9
9
|
import { columnMixin } from './cosmoz-omnitable-column-mixin';
|
|
10
10
|
import { defaultComputeSource } from './lib/utils-data';
|
|
11
11
|
import './lib/cosmoz-omnitable-amount-range-input';
|
|
12
|
-
import {
|
|
12
|
+
import {
|
|
13
|
+
getComparableValue,
|
|
14
|
+
getCurrency,
|
|
15
|
+
applySingleFilter,
|
|
16
|
+
getString,
|
|
17
|
+
getInputString,
|
|
18
|
+
toAmount,
|
|
19
|
+
toHashString,
|
|
20
|
+
fromHashString,
|
|
21
|
+
} from './lib/utils-amount';
|
|
13
22
|
import { get } from '@polymer/polymer/lib/utils/path';
|
|
14
23
|
|
|
15
24
|
/**
|
|
@@ -29,13 +38,12 @@ class OmnitableColumnAmount extends columnMixin(PolymerElement) {
|
|
|
29
38
|
rates: { type: Object, notify: true },
|
|
30
39
|
width: { type: String, value: '70px' },
|
|
31
40
|
cellClass: { type: String, value: 'amount-cell align-right' },
|
|
32
|
-
headerCellClass: { type: String, value: 'amount-header-cell' }
|
|
41
|
+
headerCellClass: { type: String, value: 'amount-header-cell' },
|
|
33
42
|
};
|
|
34
43
|
}
|
|
35
44
|
|
|
36
45
|
getFilterFn(column, filter) {
|
|
37
|
-
const
|
|
38
|
-
min = getComparableValue({ ...column, valuePath: 'min' }, filter),
|
|
46
|
+
const min = getComparableValue({ ...column, valuePath: 'min' }, filter),
|
|
39
47
|
max = getComparableValue({ ...column, valuePath: 'max' }, filter);
|
|
40
48
|
|
|
41
49
|
if (min == null && max == null) {
|
|
@@ -64,8 +72,7 @@ class OmnitableColumnAmount extends columnMixin(PolymerElement) {
|
|
|
64
72
|
if (filter == null) {
|
|
65
73
|
return;
|
|
66
74
|
}
|
|
67
|
-
const
|
|
68
|
-
min = toAmount(rates, filter.min),
|
|
75
|
+
const min = toAmount(rates, filter.min),
|
|
69
76
|
max = toAmount(rates, filter.max);
|
|
70
77
|
|
|
71
78
|
if (min == null && max == null) {
|
|
@@ -86,51 +93,52 @@ class OmnitableColumnAmount extends columnMixin(PolymerElement) {
|
|
|
86
93
|
|
|
87
94
|
return {
|
|
88
95
|
min: fromHashString(matches[1]),
|
|
89
|
-
max: fromHashString(matches[2])
|
|
96
|
+
max: fromHashString(matches[2]),
|
|
90
97
|
};
|
|
91
98
|
}
|
|
92
99
|
|
|
93
100
|
renderCell(column, { item }) {
|
|
94
|
-
return html`<span>${
|
|
101
|
+
return html`<span>${column.getString(column, item)}</span>`;
|
|
95
102
|
}
|
|
96
103
|
|
|
97
104
|
renderEditCell(column, { item }, onItemChange) {
|
|
98
|
-
const onChange = event =>
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
105
|
+
const onChange = (event) =>
|
|
106
|
+
onItemChange({
|
|
107
|
+
amount: event.target.value,
|
|
108
|
+
currency: get(item, column.valuePath)?.currency,
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
return html`<cosmoz-input
|
|
112
|
+
no-label-float
|
|
113
|
+
type="number"
|
|
114
|
+
@change=${onChange}
|
|
115
|
+
.value=${getInputString(column, item)}
|
|
116
|
+
>
|
|
117
|
+
<div slot="suffix">${getCurrency(column, item)}</div>
|
|
118
|
+
</cosmoz-input>`;
|
|
106
119
|
}
|
|
107
120
|
|
|
108
121
|
renderHeader(
|
|
109
|
-
{ title,
|
|
110
|
-
min,
|
|
111
|
-
max,
|
|
112
|
-
locale,
|
|
113
|
-
rates,
|
|
114
|
-
currency,
|
|
115
|
-
autoupdate,
|
|
116
|
-
autodetect },
|
|
122
|
+
{ title, min, max, locale, rates, currency, autoupdate, autodetect },
|
|
117
123
|
{ filter },
|
|
118
124
|
setState,
|
|
119
|
-
source
|
|
125
|
+
source,
|
|
120
126
|
) {
|
|
121
127
|
return html`<cosmoz-omnitable-amount-range-input
|
|
122
|
-
.title=${
|
|
123
|
-
.filter=${
|
|
124
|
-
.values=${
|
|
125
|
-
.rates=${
|
|
126
|
-
.min=${
|
|
127
|
-
.max=${
|
|
128
|
-
.locale=${
|
|
129
|
-
.currency=${
|
|
130
|
-
.autoupdate=${
|
|
131
|
-
.autodetect=${
|
|
132
|
-
@filter-changed=${
|
|
133
|
-
|
|
128
|
+
.title=${title}
|
|
129
|
+
.filter=${filter}
|
|
130
|
+
.values=${source}
|
|
131
|
+
.rates=${rates}
|
|
132
|
+
.min=${min}
|
|
133
|
+
.max=${max}
|
|
134
|
+
.locale=${locale}
|
|
135
|
+
.currency=${currency}
|
|
136
|
+
.autoupdate=${autoupdate}
|
|
137
|
+
.autodetect=${autodetect}
|
|
138
|
+
@filter-changed=${({ detail: { value } }) =>
|
|
139
|
+
setState((state) => ({ ...state, filter: value }))}
|
|
140
|
+
@header-focused-changed=${({ detail: { value } }) =>
|
|
141
|
+
setState((state) => ({ ...state, headerFocused: value }))}
|
|
134
142
|
></cosmoz-omnitable-amount-range-input>`;
|
|
135
143
|
}
|
|
136
144
|
|
|
@@ -20,7 +20,7 @@ import { get } from '@polymer/polymer/lib/utils/path';
|
|
|
20
20
|
|
|
21
21
|
export const getComparableValue = (
|
|
22
22
|
{ valuePath, textProperty, valueProperty },
|
|
23
|
-
item
|
|
23
|
+
item,
|
|
24
24
|
) => {
|
|
25
25
|
const property = textProperty ? strProp(textProperty) : prop(valueProperty),
|
|
26
26
|
values = array(valuePath && get(item, valuePath)).map(property);
|
|
@@ -33,7 +33,7 @@ export const getComparableValue = (
|
|
|
33
33
|
* @appliesMixin columnMixin
|
|
34
34
|
*/
|
|
35
35
|
class OmnitableColumnAutocomplete extends listColumnMixin(
|
|
36
|
-
columnMixin(PolymerElement)
|
|
36
|
+
columnMixin(PolymerElement),
|
|
37
37
|
) {
|
|
38
38
|
static get properties() {
|
|
39
39
|
return {
|
|
@@ -63,12 +63,12 @@ class OmnitableColumnAutocomplete extends listColumnMixin(
|
|
|
63
63
|
|
|
64
64
|
renderEditCell(column, { item }, onItemChange) {
|
|
65
65
|
const onChange = (event) => onItemChange(event.target.value);
|
|
66
|
-
return html`<
|
|
66
|
+
return html`<cosmoz-input
|
|
67
67
|
no-label-float
|
|
68
68
|
type="text"
|
|
69
69
|
@change=${onChange}
|
|
70
70
|
.value=${getString(column, item)}
|
|
71
|
-
></
|
|
71
|
+
></cosmoz-input>`;
|
|
72
72
|
}
|
|
73
73
|
|
|
74
74
|
renderHeader(column, { filter, query }, setState, source) {
|
|
@@ -89,12 +89,13 @@ class OmnitableColumnAutocomplete extends listColumnMixin(
|
|
|
89
89
|
.onText=${onText(setState)}
|
|
90
90
|
>${when(
|
|
91
91
|
column.loading,
|
|
92
|
-
() =>
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
92
|
+
() =>
|
|
93
|
+
html`<paper-spinner-lite
|
|
94
|
+
style="width: 20px; height: 20px; flex:none;"
|
|
95
|
+
suffix
|
|
96
|
+
slot="suffix"
|
|
97
|
+
active
|
|
98
|
+
></paper-spinner-lite>`,
|
|
98
99
|
)}</cosmoz-autocomplete-ui
|
|
99
100
|
>`;
|
|
100
101
|
}
|
|
@@ -105,5 +106,5 @@ class OmnitableColumnAutocomplete extends listColumnMixin(
|
|
|
105
106
|
}
|
|
106
107
|
customElements.define(
|
|
107
108
|
'cosmoz-omnitable-column-autocomplete',
|
|
108
|
-
OmnitableColumnAutocomplete
|
|
109
|
+
OmnitableColumnAutocomplete,
|
|
109
110
|
);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/* eslint-disable no-return-assign */
|
|
2
|
-
import '@
|
|
2
|
+
import '@neovici/cosmoz-input';
|
|
3
3
|
import '@polymer/paper-dropdown-menu/paper-dropdown-menu';
|
|
4
4
|
|
|
5
5
|
import './ui-helpers/cosmoz-clear-button';
|
|
@@ -88,12 +88,12 @@ class OmnitableColumnDate extends columnMixin(PolymerElement) {
|
|
|
88
88
|
renderEditCell(column, { item }, onItemChange) {
|
|
89
89
|
const onChange = event => onItemChange(fromInputString(event.target.value));
|
|
90
90
|
|
|
91
|
-
return html`<
|
|
91
|
+
return html`<cosmoz-input
|
|
92
92
|
no-label-float
|
|
93
93
|
type="date"
|
|
94
94
|
@change=${ onChange }
|
|
95
95
|
.value=${ getInputString(column, item) }
|
|
96
|
-
></
|
|
96
|
+
></cosmoz-input>`;
|
|
97
97
|
}
|
|
98
98
|
|
|
99
99
|
renderHeader(
|
|
@@ -96,7 +96,7 @@ class OmnitableColumnDatetime extends columnMixin(PolymerElement) {
|
|
|
96
96
|
|
|
97
97
|
renderEditCell(column, { item }, onItemChange) {
|
|
98
98
|
const onChange = event => onItemChange(fromInputString(event.target.value));
|
|
99
|
-
return html`<
|
|
99
|
+
return html`<cosmoz-input no-label-float type="text" @change=${ onChange } .value=${ getString(column, item) }></cosmoz-input>`;
|
|
100
100
|
}
|
|
101
101
|
|
|
102
102
|
// eslint-disable-next-line max-lines-per-function
|
|
@@ -52,12 +52,12 @@ class OmnitableColumnList extends listColumnMixin(columnMixin(PolymerElement)) {
|
|
|
52
52
|
const onChange = (event) =>
|
|
53
53
|
onItemChange(event.target.value.split(/,\s*/gu));
|
|
54
54
|
|
|
55
|
-
return html`<
|
|
55
|
+
return html`<cosmoz-input
|
|
56
56
|
no-label-float
|
|
57
57
|
type="text"
|
|
58
|
-
@change=${onChange}
|
|
59
58
|
.value=${getString(column, item)}
|
|
60
|
-
|
|
59
|
+
@change=${onChange}
|
|
60
|
+
></cosmoz-input>`;
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
renderHeader(column, { filter, query }, setState, source) {
|
|
@@ -79,12 +79,13 @@ class OmnitableColumnList extends listColumnMixin(columnMixin(PolymerElement)) {
|
|
|
79
79
|
.onText=${onText(setState)}
|
|
80
80
|
>${when(
|
|
81
81
|
column.loading,
|
|
82
|
-
() =>
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
82
|
+
() =>
|
|
83
|
+
html`<paper-spinner-lite
|
|
84
|
+
style="width: 20px; height: 20px; flex:none;"
|
|
85
|
+
suffix
|
|
86
|
+
slot="suffix"
|
|
87
|
+
active
|
|
88
|
+
></paper-spinner-lite>`,
|
|
88
89
|
)}</cosmoz-autocomplete-ui
|
|
89
90
|
>`;
|
|
90
91
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import '@
|
|
1
|
+
import '@neovici/cosmoz-input';
|
|
2
2
|
import '@polymer/paper-dropdown-menu/paper-dropdown-menu';
|
|
3
3
|
import './ui-helpers/cosmoz-clear-button';
|
|
4
4
|
|
|
@@ -9,10 +9,16 @@ import { columnMixin } from './cosmoz-omnitable-column-mixin';
|
|
|
9
9
|
|
|
10
10
|
import './lib/cosmoz-omnitable-number-range-input';
|
|
11
11
|
import { defaultComputeSource } from './lib/utils-data';
|
|
12
|
-
import {
|
|
12
|
+
import {
|
|
13
|
+
applySingleFilter,
|
|
14
|
+
getComparableValue,
|
|
15
|
+
getInputString,
|
|
16
|
+
getString,
|
|
17
|
+
toHashString,
|
|
18
|
+
toNumber,
|
|
19
|
+
} from './lib/utils-number';
|
|
13
20
|
import { get } from '@polymer/polymer/lib/utils/path';
|
|
14
21
|
|
|
15
|
-
|
|
16
22
|
/**
|
|
17
23
|
* @polymer
|
|
18
24
|
* @customElement
|
|
@@ -30,13 +36,12 @@ class OmnitableColumnNumber extends columnMixin(PolymerElement) {
|
|
|
30
36
|
minWidth: { type: String, value: '30px' },
|
|
31
37
|
headerCellClass: { type: String, value: 'number-header-cell' },
|
|
32
38
|
maximumFractionDigits: { type: Number, value: null },
|
|
33
|
-
minimumFractionDigits: { type: Number, value: null } // browser default 0 for numbers, currency-specific or 2 for currency
|
|
39
|
+
minimumFractionDigits: { type: Number, value: null }, // browser default 0 for numbers, currency-specific or 2 for currency
|
|
34
40
|
};
|
|
35
41
|
}
|
|
36
42
|
|
|
37
43
|
getFilterFn(column, filter) {
|
|
38
|
-
const
|
|
39
|
-
min = getComparableValue({ ...column, valuePath: 'min' }, filter),
|
|
44
|
+
const min = getComparableValue({ ...column, valuePath: 'min' }, filter),
|
|
40
45
|
max = getComparableValue({ ...column, valuePath: 'max' }, filter);
|
|
41
46
|
|
|
42
47
|
if (min == null && max == null) {
|
|
@@ -86,44 +91,55 @@ class OmnitableColumnNumber extends columnMixin(PolymerElement) {
|
|
|
86
91
|
|
|
87
92
|
return {
|
|
88
93
|
min: toNumber(matches[1]),
|
|
89
|
-
max: toNumber(matches[2])
|
|
94
|
+
max: toNumber(matches[2]),
|
|
90
95
|
};
|
|
91
96
|
}
|
|
92
97
|
|
|
93
98
|
renderCell(column, { item }) {
|
|
94
|
-
return html`<div class="omnitable-cell-number"
|
|
99
|
+
return html`<div class="omnitable-cell-number">
|
|
100
|
+
${getString(column, item)}
|
|
101
|
+
</div>`;
|
|
95
102
|
}
|
|
96
103
|
|
|
97
104
|
renderEditCell(column, { item }, onItemChange) {
|
|
98
|
-
const onChange = event => onItemChange(event.target.value);
|
|
99
|
-
|
|
100
|
-
return html`<
|
|
105
|
+
const onChange = (event) => onItemChange(event.target.value);
|
|
106
|
+
|
|
107
|
+
return html`<cosmoz-input
|
|
108
|
+
no-label-float
|
|
109
|
+
type="number"
|
|
110
|
+
@change=${onChange}
|
|
111
|
+
.value=${getInputString(column, item)}
|
|
112
|
+
></cosmoz-input>`;
|
|
101
113
|
}
|
|
102
114
|
|
|
103
115
|
renderHeader(
|
|
104
|
-
{
|
|
116
|
+
{
|
|
117
|
+
title,
|
|
105
118
|
min,
|
|
106
119
|
max,
|
|
107
120
|
locale,
|
|
108
121
|
maximumFractionDigits,
|
|
109
122
|
minimumFractionDigits,
|
|
110
|
-
autoupdate
|
|
123
|
+
autoupdate,
|
|
124
|
+
},
|
|
111
125
|
{ filter },
|
|
112
126
|
setState,
|
|
113
|
-
source
|
|
127
|
+
source,
|
|
114
128
|
) {
|
|
115
129
|
return html`<cosmoz-omnitable-number-range-input
|
|
116
|
-
.title=${
|
|
117
|
-
.filter=${
|
|
118
|
-
.values=${
|
|
119
|
-
.min=${
|
|
120
|
-
.max=${
|
|
121
|
-
.locale=${
|
|
122
|
-
.maximumFractionDigits=${
|
|
123
|
-
.minimumFractionDigsits=${
|
|
124
|
-
.autoupdate=${
|
|
125
|
-
@filter-changed=${
|
|
126
|
-
|
|
130
|
+
.title=${title}
|
|
131
|
+
.filter=${filter}
|
|
132
|
+
.values=${source}
|
|
133
|
+
.min=${min}
|
|
134
|
+
.max=${max}
|
|
135
|
+
.locale=${locale}
|
|
136
|
+
.maximumFractionDigits=${maximumFractionDigits}
|
|
137
|
+
.minimumFractionDigsits=${minimumFractionDigits}
|
|
138
|
+
.autoupdate=${autoupdate}
|
|
139
|
+
@filter-changed=${({ detail: { value } }) =>
|
|
140
|
+
setState((state) => ({ ...state, filter: value }))}
|
|
141
|
+
@header-focused-changed=${({ detail: { value } }) =>
|
|
142
|
+
setState((state) => ({ ...state, headerFocused: value }))}
|
|
127
143
|
></cosmoz-omnitable-number-range-input>`;
|
|
128
144
|
}
|
|
129
145
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/* eslint-disable no-return-assign */
|
|
2
2
|
import '@polymer/paper-dropdown-menu/paper-dropdown-menu';
|
|
3
|
-
import '@
|
|
3
|
+
import '@neovici/cosmoz-input';
|
|
4
4
|
|
|
5
5
|
import './ui-helpers/cosmoz-clear-button';
|
|
6
6
|
|
|
@@ -8,7 +8,15 @@ import { PolymerElement } from '@polymer/polymer/polymer-element';
|
|
|
8
8
|
import { html } from 'lit-html';
|
|
9
9
|
|
|
10
10
|
import { columnMixin } from './cosmoz-omnitable-column-mixin';
|
|
11
|
-
import {
|
|
11
|
+
import {
|
|
12
|
+
getComparableValue,
|
|
13
|
+
getString,
|
|
14
|
+
toXlsxValue,
|
|
15
|
+
applySingleFilter,
|
|
16
|
+
toDate,
|
|
17
|
+
toHashString,
|
|
18
|
+
fromHashString,
|
|
19
|
+
} from './lib/utils-time';
|
|
12
20
|
import './lib/cosmoz-omnitable-time-range-input';
|
|
13
21
|
import { defaultComputeSource } from './lib/utils-data';
|
|
14
22
|
|
|
@@ -32,13 +40,12 @@ class OmnitableColumnTime extends columnMixin(PolymerElement) {
|
|
|
32
40
|
* 1 => full seconds
|
|
33
41
|
* 0.1 => milliseconds
|
|
34
42
|
*/
|
|
35
|
-
filterStep: { type: String, value: '1' }
|
|
43
|
+
filterStep: { type: String, value: '1' },
|
|
36
44
|
};
|
|
37
45
|
}
|
|
38
46
|
|
|
39
47
|
getFilterFn(column, filter) {
|
|
40
|
-
const
|
|
41
|
-
min = getComparableValue({ ...column, valuePath: 'min' }, filter),
|
|
48
|
+
const min = getComparableValue({ ...column, valuePath: 'min' }, filter),
|
|
42
49
|
max = getComparableValue({ ...column, valuePath: 'max' }, filter);
|
|
43
50
|
|
|
44
51
|
if (min == null && max == null) {
|
|
@@ -88,7 +95,7 @@ class OmnitableColumnTime extends columnMixin(PolymerElement) {
|
|
|
88
95
|
|
|
89
96
|
return {
|
|
90
97
|
min: fromHashString(matches[1]),
|
|
91
|
-
max: fromHashString(matches[2])
|
|
98
|
+
max: fromHashString(matches[2]),
|
|
92
99
|
};
|
|
93
100
|
}
|
|
94
101
|
|
|
@@ -97,30 +104,33 @@ class OmnitableColumnTime extends columnMixin(PolymerElement) {
|
|
|
97
104
|
}
|
|
98
105
|
|
|
99
106
|
renderEditCell(column, { item }, onItemChange) {
|
|
100
|
-
const onChange = event => onItemChange(event.target.value);
|
|
101
|
-
return html`<
|
|
107
|
+
const onChange = (event) => onItemChange(event.target.value);
|
|
108
|
+
return html`<cosmoz-input
|
|
109
|
+
no-label-float
|
|
110
|
+
type="text"
|
|
111
|
+
@change=${onChange}
|
|
112
|
+
.value=${getString(column, item)}
|
|
113
|
+
></cosmoz-input>`;
|
|
102
114
|
}
|
|
103
115
|
|
|
104
116
|
renderHeader(
|
|
105
|
-
{ title,
|
|
106
|
-
min,
|
|
107
|
-
max,
|
|
108
|
-
locale,
|
|
109
|
-
filterStep },
|
|
117
|
+
{ title, min, max, locale, filterStep },
|
|
110
118
|
{ filter },
|
|
111
119
|
setState,
|
|
112
|
-
source
|
|
120
|
+
source,
|
|
113
121
|
) {
|
|
114
122
|
return html`<cosmoz-omnitable-time-range-input
|
|
115
|
-
.title=${
|
|
116
|
-
.filter=${
|
|
117
|
-
.values=${
|
|
118
|
-
.min=${
|
|
119
|
-
.max=${
|
|
120
|
-
.locale=${
|
|
121
|
-
.filterStep=${
|
|
122
|
-
@filter-changed=${
|
|
123
|
-
|
|
123
|
+
.title=${title}
|
|
124
|
+
.filter=${filter}
|
|
125
|
+
.values=${source}
|
|
126
|
+
.min=${min}
|
|
127
|
+
.max=${max}
|
|
128
|
+
.locale=${locale}
|
|
129
|
+
.filterStep=${filterStep}
|
|
130
|
+
@filter-changed=${({ detail: { value } }) =>
|
|
131
|
+
setState((state) => ({ ...state, filter: value }))}
|
|
132
|
+
@header-focused-changed=${({ detail: { value } }) =>
|
|
133
|
+
setState((state) => ({ ...state, headerFocused: value }))}
|
|
124
134
|
></cosmoz-omnitable-time-range-input>`;
|
|
125
135
|
}
|
|
126
136
|
|
|
@@ -1,41 +1,42 @@
|
|
|
1
1
|
/* eslint-disable no-return-assign */
|
|
2
|
-
import '@
|
|
3
|
-
import '@polymer/paper-input/paper-input';
|
|
2
|
+
import '@neovici/cosmoz-input';
|
|
4
3
|
import './ui-helpers/cosmoz-clear-button';
|
|
5
4
|
|
|
6
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
applySingleFilter,
|
|
7
|
+
columnMixin,
|
|
8
|
+
getString,
|
|
9
|
+
} from './cosmoz-omnitable-column-mixin';
|
|
7
10
|
import { PolymerElement } from '@polymer/polymer/polymer-element';
|
|
8
11
|
import { html } from 'lit-html';
|
|
9
12
|
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
clearTimeout(state.t);
|
|
18
|
-
const t = setTimeout(() => setState(state => ({ ...state, filter: state.inputValue })), 1000);
|
|
19
|
-
return { ...state, inputValue: event.target.value, t };
|
|
20
|
-
}),
|
|
21
|
-
|
|
22
|
-
onBlur = setState => () =>
|
|
23
|
-
setState(state => ({ ...state, filter: state.inputValue })),
|
|
13
|
+
const onChange = (setState) => (event) =>
|
|
14
|
+
setState((state) => {
|
|
15
|
+
// skip the event emitted during cosmoz-input initialization
|
|
16
|
+
if (state.inputValue === undefined && event.target.value === '') {
|
|
17
|
+
return state;
|
|
18
|
+
}
|
|
24
19
|
|
|
25
|
-
|
|
20
|
+
clearTimeout(state.t);
|
|
21
|
+
const t = setTimeout(
|
|
22
|
+
() => setState((state) => ({ ...state, filter: state.inputValue })),
|
|
23
|
+
1000,
|
|
24
|
+
);
|
|
25
|
+
return { ...state, inputValue: event.target.value, t };
|
|
26
|
+
}),
|
|
27
|
+
onBlur = (setState) => () =>
|
|
28
|
+
setState((state) => ({ ...state, filter: state.inputValue })),
|
|
29
|
+
onKeyDown = (setState) => (event) => {
|
|
26
30
|
if (event.keyCode === 13) {
|
|
27
31
|
event.preventDefault();
|
|
28
|
-
setState(state => ({ ...state, filter: state.inputValue }));
|
|
32
|
+
setState((state) => ({ ...state, filter: state.inputValue }));
|
|
29
33
|
}
|
|
30
34
|
},
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
setState(state => ({ ...state, filter: null, inputValue: null })),
|
|
37
|
-
|
|
38
|
-
hasFilter = filter => filter != null && filter !== '';
|
|
35
|
+
onFocus = (setState) => (event) =>
|
|
36
|
+
setState((state) => ({ ...state, headerFocused: event.detail.value })),
|
|
37
|
+
resetFilter = (setState) => () =>
|
|
38
|
+
setState((state) => ({ ...state, filter: null, inputValue: null })),
|
|
39
|
+
hasFilter = (filter) => filter != null && filter !== '';
|
|
39
40
|
|
|
40
41
|
/**
|
|
41
42
|
* @polymer
|
|
@@ -47,7 +48,7 @@ class OmnitableColumn extends columnMixin(PolymerElement) {
|
|
|
47
48
|
return {
|
|
48
49
|
minWidth: { type: String, value: '55px' },
|
|
49
50
|
editMinWidth: { type: String, value: '55px' },
|
|
50
|
-
inputValue: { type: Object, notify: true }
|
|
51
|
+
inputValue: { type: Object, notify: true },
|
|
51
52
|
};
|
|
52
53
|
}
|
|
53
54
|
|
|
@@ -59,26 +60,37 @@ class OmnitableColumn extends columnMixin(PolymerElement) {
|
|
|
59
60
|
}
|
|
60
61
|
|
|
61
62
|
renderCell(column, { item }) {
|
|
62
|
-
return html`<span class="default-column">${
|
|
63
|
+
return html`<span class="default-column">${getString(column, item)}</span>`;
|
|
63
64
|
}
|
|
64
65
|
|
|
65
66
|
renderEditCell(column, { item }, onItemChange) {
|
|
66
|
-
const onChange = event => onItemChange(event.target.value);
|
|
67
|
-
return html`<
|
|
67
|
+
const onChange = (event) => onItemChange(event.target.value);
|
|
68
|
+
return html`<cosmoz-input
|
|
69
|
+
no-label-float
|
|
70
|
+
type="text"
|
|
71
|
+
@change=${onChange}
|
|
72
|
+
.value=${getString(column, item)}
|
|
73
|
+
></cosmoz-input>`;
|
|
68
74
|
}
|
|
69
75
|
|
|
70
76
|
renderHeader(column, { filter, inputValue, headerFocused }, setState) {
|
|
71
|
-
return html`<
|
|
72
|
-
label=${
|
|
73
|
-
.value=${
|
|
74
|
-
@value-changed=${
|
|
75
|
-
focused=${
|
|
76
|
-
@focused-changed=${
|
|
77
|
-
@keydown=${
|
|
78
|
-
@blur=${
|
|
77
|
+
return html`<cosmoz-input
|
|
78
|
+
label=${column.title}
|
|
79
|
+
.value=${inputValue ?? filter}
|
|
80
|
+
@value-changed=${onChange(setState)}
|
|
81
|
+
focused=${headerFocused}
|
|
82
|
+
@focused-changed=${onFocus(setState)}
|
|
83
|
+
@keydown=${onKeyDown(setState)}
|
|
84
|
+
@blur=${onBlur(setState)}
|
|
79
85
|
>
|
|
80
|
-
<cosmoz-clear-button
|
|
81
|
-
|
|
86
|
+
<cosmoz-clear-button
|
|
87
|
+
suffix
|
|
88
|
+
slot="suffix"
|
|
89
|
+
?visible=${hasFilter(filter)}
|
|
90
|
+
light
|
|
91
|
+
@click=${resetFilter(setState)}
|
|
92
|
+
></cosmoz-clear-button>
|
|
93
|
+
</cosmoz-input>`;
|
|
82
94
|
}
|
|
83
95
|
|
|
84
96
|
legacyFilterToState(filter) {
|
|
@@ -155,19 +155,10 @@ export default css`
|
|
|
155
155
|
--cosmoz-omnitable-header-font-size,
|
|
156
156
|
16px
|
|
157
157
|
);
|
|
158
|
+
--cosmoz-input-label-text-transform: var(--cosmoz-omnitable-header-text-transform, none);
|
|
159
|
+
--cosmoz-input-label-font-weight: var(--cosmoz-omnitable-header-font-weight, normal);
|
|
158
160
|
}
|
|
159
161
|
|
|
160
|
-
cosmoz-autocomplete-ui::part(input-label) {
|
|
161
|
-
text-transform: var(--cosmoz-omnitable-header-text-transform, none);
|
|
162
|
-
font-weight: var(--cosmoz-omnitable-header-font-weight, normal);
|
|
163
|
-
font-family: var(
|
|
164
|
-
--cosmoz-omnitable-header-font-family,
|
|
165
|
-
'Roboto',
|
|
166
|
-
'Noto',
|
|
167
|
-
sans-serif
|
|
168
|
-
);
|
|
169
|
-
font-size: var(--cosmoz-omnitable-header-font-size, 16px);
|
|
170
|
-
}
|
|
171
162
|
cosmoz-omnitable-header-row {
|
|
172
163
|
white-space: nowrap;
|
|
173
164
|
}
|
|
@@ -518,7 +509,7 @@ export default css`
|
|
|
518
509
|
display: inline-flex;
|
|
519
510
|
position: relative;
|
|
520
511
|
}
|
|
521
|
-
.header-cell :not(.sg) {
|
|
512
|
+
.header-cell :not(.sg,cosmoz-clear-button) {
|
|
522
513
|
min-width: 0;
|
|
523
514
|
flex: auto;
|
|
524
515
|
}
|