@neovici/cosmoz-omnitable 8.14.2 → 9.0.1
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-list-data.js +9 -4
- package/cosmoz-omnitable-column-list.js +37 -24
- package/cosmoz-omnitable-item-expand.js +37 -20
- package/cosmoz-omnitable-item-row.js +2 -2
- package/cosmoz-omnitable-styles.js +2 -1
- package/cosmoz-omnitable.js +346 -234
- package/lib/settings/cosmoz-omnitable-settings.js +8 -1
- package/lib/settings/style.css.js +5 -2
- package/lib/use-dom-columns.js +1 -4
- package/lib/use-fast-layout.js +24 -24
- package/lib/use-omnitable.js +4 -0
- package/lib/use-processed-items.js +163 -59
- package/lib/use-tween-array.js +23 -21
- package/lib/utils.js +10 -0
- package/package.json +2 -2
|
@@ -67,9 +67,6 @@ class OmnitableColumnListData extends translatable(mixin(Template, PolymerElemen
|
|
|
67
67
|
return {
|
|
68
68
|
items: {
|
|
69
69
|
type: Array,
|
|
70
|
-
observer() {
|
|
71
|
-
this.dispatchEvent(new CustomEvent('iron-resize', { bubbles: true }));
|
|
72
|
-
}
|
|
73
70
|
},
|
|
74
71
|
|
|
75
72
|
_expanded: {
|
|
@@ -84,6 +81,14 @@ class OmnitableColumnListData extends translatable(mixin(Template, PolymerElemen
|
|
|
84
81
|
};
|
|
85
82
|
}
|
|
86
83
|
|
|
84
|
+
static get observers() {
|
|
85
|
+
return ['_itemsLengthChanged(items.length)']
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
_itemsLengthChanged() {
|
|
89
|
+
requestAnimationFrame(() => this.dispatchEvent(new CustomEvent('expand', { bubbles: true })));
|
|
90
|
+
}
|
|
91
|
+
|
|
87
92
|
_firstItem(items) {
|
|
88
93
|
if (items !== undefined && items !== null && items.length > 0) {
|
|
89
94
|
return items[0];
|
|
@@ -122,7 +127,7 @@ class OmnitableColumnListData extends translatable(mixin(Template, PolymerElemen
|
|
|
122
127
|
this._expanded = !this._expanded;
|
|
123
128
|
event.stopPropagation();
|
|
124
129
|
event.preventDefault();
|
|
125
|
-
this.dispatchEvent(new CustomEvent('
|
|
130
|
+
this.dispatchEvent(new CustomEvent('expand', { bubbles: true }));
|
|
126
131
|
}
|
|
127
132
|
}
|
|
128
133
|
|
|
@@ -1,13 +1,19 @@
|
|
|
1
1
|
import './cosmoz-omnitable-column-list-data';
|
|
2
2
|
|
|
3
3
|
import { PolymerElement } from '@polymer/polymer/polymer-element';
|
|
4
|
-
import {
|
|
5
|
-
html, nothing
|
|
6
|
-
} from 'lit-html';
|
|
4
|
+
import { html, nothing } from 'lit-html';
|
|
7
5
|
|
|
8
6
|
import { columnMixin } from './cosmoz-omnitable-column-mixin';
|
|
9
|
-
import {
|
|
7
|
+
import {
|
|
8
|
+
getString,
|
|
9
|
+
getTexts,
|
|
10
|
+
listColumnMixin,
|
|
11
|
+
onChange,
|
|
12
|
+
onFocus,
|
|
13
|
+
onText,
|
|
14
|
+
} from './cosmoz-omnitable-column-list-mixin';
|
|
10
15
|
import '@neovici/cosmoz-autocomplete';
|
|
16
|
+
import { notifyResize } from './lib/utils';
|
|
11
17
|
|
|
12
18
|
/**
|
|
13
19
|
* @polymer
|
|
@@ -16,41 +22,48 @@ import '@neovici/cosmoz-autocomplete';
|
|
|
16
22
|
* @appliesMixin columnMixin
|
|
17
23
|
*/
|
|
18
24
|
class OmnitableColumnList extends listColumnMixin(columnMixin(PolymerElement)) {
|
|
19
|
-
renderCell({ valuePath, textProperty }, { item }) {
|
|
25
|
+
renderCell({ valuePath, textProperty }, { item, index }) {
|
|
20
26
|
return html`<cosmoz-omnitable-column-list-data
|
|
21
|
-
.items=${
|
|
27
|
+
.items=${getTexts(item, valuePath, textProperty)}
|
|
28
|
+
@expand=${(event) => notifyResize(event.target, index)}
|
|
22
29
|
></cosmoz-omnitable-column-list-data>`;
|
|
23
30
|
}
|
|
24
31
|
|
|
25
32
|
renderEditCell(column, { item }, onItemChange) {
|
|
26
|
-
const onChange = event =>
|
|
33
|
+
const onChange = (event) =>
|
|
34
|
+
onItemChange(event.target.value.split(/,\s*/gu));
|
|
27
35
|
|
|
28
36
|
return html`<paper-input
|
|
29
37
|
no-label-float
|
|
30
38
|
type="text"
|
|
31
|
-
@change=${
|
|
32
|
-
.value=${
|
|
39
|
+
@change=${onChange}
|
|
40
|
+
.value=${getString(column, item)}
|
|
33
41
|
></paper-input>`;
|
|
34
42
|
}
|
|
35
43
|
|
|
36
44
|
renderHeader(column, { filter, query }, setState, source) {
|
|
37
|
-
const
|
|
38
|
-
spinner
|
|
39
|
-
|
|
40
|
-
|
|
45
|
+
const spinner = column.loading
|
|
46
|
+
? html`<paper-spinner-lite
|
|
47
|
+
style="width: 20px; height: 20px; flex:none;"
|
|
48
|
+
suffix
|
|
49
|
+
slot="suffix"
|
|
50
|
+
active
|
|
51
|
+
></paper-spinner-lite>`
|
|
52
|
+
: nothing;
|
|
41
53
|
|
|
42
54
|
return html`<cosmoz-autocomplete-ui
|
|
43
|
-
class="external-values-${
|
|
44
|
-
.label=${
|
|
45
|
-
.source=${
|
|
46
|
-
.textProperty=${
|
|
47
|
-
.valueProperty=${
|
|
48
|
-
.value=${
|
|
49
|
-
.text=${
|
|
50
|
-
.onChange=${
|
|
51
|
-
.onFocus=${
|
|
52
|
-
.onText=${
|
|
53
|
-
|
|
55
|
+
class="external-values-${column.externalValues}"
|
|
56
|
+
.label=${column.title}
|
|
57
|
+
.source=${source}
|
|
58
|
+
.textProperty=${column.textProperty}
|
|
59
|
+
.valueProperty=${column.valueProperty}
|
|
60
|
+
.value=${filter}
|
|
61
|
+
.text=${query}
|
|
62
|
+
.onChange=${onChange(setState)}
|
|
63
|
+
.onFocus=${onFocus(setState)}
|
|
64
|
+
.onText=${onText(setState)}
|
|
65
|
+
>${spinner}</cosmoz-autocomplete-ui
|
|
66
|
+
>`;
|
|
54
67
|
}
|
|
55
68
|
}
|
|
56
69
|
|
|
@@ -1,37 +1,54 @@
|
|
|
1
1
|
/* eslint-disable object-curly-newline */
|
|
2
2
|
import { component, useEffect } from 'haunted';
|
|
3
|
-
import {
|
|
4
|
-
html, nothing
|
|
5
|
-
} from 'lit-html';
|
|
3
|
+
import { html, nothing } from 'lit-html';
|
|
6
4
|
import './cosmoz-omnitable-item-expand-line';
|
|
5
|
+
import { notifyResize } from './lib/utils';
|
|
7
6
|
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
7
|
+
const renderExpandList = ({
|
|
8
|
+
columns,
|
|
9
|
+
item,
|
|
10
|
+
selected,
|
|
11
|
+
expanded,
|
|
12
|
+
groupOnColumn,
|
|
13
|
+
}) =>
|
|
14
|
+
columns.map(
|
|
15
|
+
(column) => html`<cosmoz-omnitable-item-expand-line
|
|
16
|
+
.column=${column}
|
|
17
|
+
?hidden=${column === groupOnColumn}
|
|
18
|
+
exportparts="item-expand-label,item-expand-value"
|
|
19
|
+
>${column.renderCell(column, {
|
|
20
|
+
item,
|
|
21
|
+
selected,
|
|
22
|
+
expanded,
|
|
23
|
+
})}</cosmoz-omnitable-item-expand-line
|
|
24
|
+
>`
|
|
25
|
+
),
|
|
26
|
+
ExpandList = (host) => {
|
|
27
|
+
const { expanded, index, columns } = host;
|
|
15
28
|
|
|
16
|
-
ExpandList = host => {
|
|
17
29
|
useEffect(() => {
|
|
18
|
-
if (
|
|
30
|
+
if (columns?.length > 0) {
|
|
19
31
|
return;
|
|
20
32
|
}
|
|
21
33
|
|
|
22
34
|
host.setAttribute('hidden', '');
|
|
23
35
|
return () => host.removeAttribute('hidden');
|
|
24
|
-
}, [
|
|
36
|
+
}, [columns?.length]);
|
|
25
37
|
|
|
26
|
-
useEffect(
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}, [host.columns, host.expanded]);
|
|
38
|
+
useEffect(
|
|
39
|
+
() => expanded && requestAnimationFrame(() => notifyResize(host, index)),
|
|
40
|
+
[expanded]
|
|
41
|
+
);
|
|
31
42
|
|
|
32
|
-
return Array.isArray(
|
|
43
|
+
return Array.isArray(columns) && columns.length > 0 && host.expanded
|
|
33
44
|
? renderExpandList(host)
|
|
34
45
|
: nothing;
|
|
35
46
|
};
|
|
36
47
|
|
|
37
|
-
customElements.define(
|
|
48
|
+
customElements.define(
|
|
49
|
+
'cosmoz-omnitable-item-expand',
|
|
50
|
+
component(ExpandList, {
|
|
51
|
+
useShadowDOM: false,
|
|
52
|
+
observedAttributes: ['expanded'],
|
|
53
|
+
})
|
|
54
|
+
);
|
|
@@ -5,7 +5,7 @@ const
|
|
|
5
5
|
renderCell = (column, data, onItemChange) => column.editable
|
|
6
6
|
? column.renderEditCell(column, data, onItemChange(column, data.item))
|
|
7
7
|
: column.renderCell(column, data),
|
|
8
|
-
ItemRow = ({ columns, groupOnColumn, item, selected, expanded, onItemChange }) => {
|
|
8
|
+
ItemRow = ({ columns, groupOnColumn, item, index, selected, expanded, onItemChange }) => {
|
|
9
9
|
return repeat(columns, column => column.name, column => {
|
|
10
10
|
return html`<div
|
|
11
11
|
class="cell itemRow-cell ${ column.cellClass ?? '' }"
|
|
@@ -13,7 +13,7 @@ const
|
|
|
13
13
|
?editable=${ column.editable }
|
|
14
14
|
title=${ column.cellTitleFn(column, item) }
|
|
15
15
|
name=${ column.name }
|
|
16
|
-
>${ renderCell(column, { item, selected, expanded }, onItemChange) }</div>`;
|
|
16
|
+
>${ renderCell(column, { item, index, selected, expanded }, onItemChange) }</div>`;
|
|
17
17
|
});
|
|
18
18
|
};
|
|
19
19
|
|
|
@@ -273,11 +273,12 @@ export default `<style>
|
|
|
273
273
|
flex: auto;
|
|
274
274
|
position: relative;
|
|
275
275
|
overflow: auto;
|
|
276
|
+
overflow-x: hidden;
|
|
276
277
|
will-change: transform;
|
|
277
278
|
}
|
|
278
279
|
|
|
279
280
|
#groupedList {
|
|
280
|
-
position: absolute;
|
|
281
|
+
position: absolute !important;
|
|
281
282
|
top: 0;
|
|
282
283
|
right: 0;
|
|
283
284
|
bottom: 0;
|