@neovici/cosmoz-omnitable 13.3.0 → 13.4.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/lib/settings/use-settings.js +4 -4
- package/lib/use-dom-columns.js +162 -153
- package/lib/use-fast-layout.js +1 -1
- package/package.json +7 -7
|
@@ -7,7 +7,7 @@ import { useDOMColumns } from '../use-dom-columns';
|
|
|
7
7
|
export default ({ settingsId, host }) => {
|
|
8
8
|
const initial = useMemo(
|
|
9
9
|
() => Object.fromEntries(sgProps.map((k) => [k, host[k]])),
|
|
10
|
-
[]
|
|
10
|
+
[],
|
|
11
11
|
),
|
|
12
12
|
resetRef = useRef(),
|
|
13
13
|
onReset = useCallback(() => {
|
|
@@ -19,7 +19,7 @@ export default ({ settingsId, host }) => {
|
|
|
19
19
|
settingsId,
|
|
20
20
|
settings,
|
|
21
21
|
setSettings,
|
|
22
|
-
onReset
|
|
22
|
+
onReset,
|
|
23
23
|
),
|
|
24
24
|
{ enabledColumns } = host,
|
|
25
25
|
columns = useDOMColumns(host, { enabledColumns }),
|
|
@@ -31,14 +31,14 @@ export default ({ settingsId, host }) => {
|
|
|
31
31
|
savedSettings,
|
|
32
32
|
initial,
|
|
33
33
|
}),
|
|
34
|
-
[columns, settings, savedSettings]
|
|
34
|
+
[columns, settings, savedSettings],
|
|
35
35
|
),
|
|
36
36
|
normalizedColumns = useMemo(
|
|
37
37
|
() =>
|
|
38
38
|
normalizedSettings.columns
|
|
39
39
|
.map((s) => columns.find((c) => c.name === s.name))
|
|
40
40
|
.filter(Boolean),
|
|
41
|
-
[columns, ...normalizedSettings.columns.map((s) => s.name)]
|
|
41
|
+
[columns, ...normalizedSettings.columns.map((s) => s.name)],
|
|
42
42
|
);
|
|
43
43
|
|
|
44
44
|
return {
|
package/lib/use-dom-columns.js
CHANGED
|
@@ -1,158 +1,167 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useLayoutEffect, useState } from '@pionjs/pion';
|
|
2
2
|
import { memooize } from '@neovici/cosmoz-utils/memoize';
|
|
3
3
|
|
|
4
|
-
const columnSymbol = Symbol('column')
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
13
|
-
ok = false;
|
|
14
|
-
// eslint-disable-next-line no-console
|
|
15
|
-
console.error(
|
|
16
|
-
'The name attribute needs to be set on all columns! Missing on column',
|
|
17
|
-
column,
|
|
18
|
-
);
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
columns.forEach((column) => {
|
|
22
|
-
if (
|
|
23
|
-
columnNames.indexOf(column.name) ===
|
|
24
|
-
columnNames.lastIndexOf(column.name)
|
|
25
|
-
) {
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
ok = false;
|
|
29
|
-
// eslint-disable-next-line no-console
|
|
30
|
-
console.error(
|
|
31
|
-
'The name attribute needs to be unique among all columns! Not unique on column',
|
|
32
|
-
column,
|
|
33
|
-
);
|
|
34
|
-
});
|
|
35
|
-
return ok;
|
|
36
|
-
},
|
|
37
|
-
// eslint-disable-next-line max-lines-per-function
|
|
38
|
-
domColumnsToConfig = (host, { enabledColumns }) => {
|
|
39
|
-
const domColumns = host.shadowRoot
|
|
40
|
-
.querySelector('#columnsSlot')
|
|
41
|
-
.assignedElements({ flatten: true })
|
|
42
|
-
.filter((child) => child.isOmnitableColumn && !child.hidden);
|
|
43
|
-
|
|
44
|
-
if (!verifyColumnSetup(domColumns)) {
|
|
45
|
-
return [];
|
|
4
|
+
const columnSymbol = Symbol('column');
|
|
5
|
+
const verifyColumnSetup = (columns) => {
|
|
6
|
+
let ok = true;
|
|
7
|
+
const columnNames = columns.map((c) => c.name);
|
|
8
|
+
// Check if column names are set
|
|
9
|
+
columns.forEach((column) => {
|
|
10
|
+
if (column.name != null) {
|
|
11
|
+
return;
|
|
46
12
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
slot.removeEventListener('slotchange', handler);
|
|
151
|
-
host.removeEventListener('cosmoz-column-prop-changed', handler);
|
|
152
|
-
};
|
|
153
|
-
}, [enabledColumns]);
|
|
154
|
-
|
|
155
|
-
return columns;
|
|
13
|
+
ok = false;
|
|
14
|
+
// eslint-disable-next-line no-console
|
|
15
|
+
console.error(
|
|
16
|
+
'The name attribute needs to be set on all columns! Missing on column',
|
|
17
|
+
column,
|
|
18
|
+
);
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
columns.forEach((column) => {
|
|
22
|
+
if (
|
|
23
|
+
columnNames.indexOf(column.name) === columnNames.lastIndexOf(column.name)
|
|
24
|
+
) {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
ok = false;
|
|
28
|
+
// eslint-disable-next-line no-console
|
|
29
|
+
console.error(
|
|
30
|
+
'The name attribute needs to be unique among all columns! Not unique on column',
|
|
31
|
+
column,
|
|
32
|
+
);
|
|
33
|
+
});
|
|
34
|
+
return ok;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
// eslint-disable-next-line max-lines-per-function
|
|
38
|
+
const normalizeColumn = (column) => {
|
|
39
|
+
const valuePath = column.valuePath ?? column.name;
|
|
40
|
+
|
|
41
|
+
return {
|
|
42
|
+
name: column.name,
|
|
43
|
+
title: column.title,
|
|
44
|
+
|
|
45
|
+
valuePath,
|
|
46
|
+
groupOn: column.groupOn ?? valuePath,
|
|
47
|
+
sortOn: column.sortOn ?? valuePath,
|
|
48
|
+
|
|
49
|
+
minWidth: column.minWidth,
|
|
50
|
+
width: column.width,
|
|
51
|
+
flex: column.flex,
|
|
52
|
+
priority: column.priority,
|
|
53
|
+
|
|
54
|
+
getString: column.getString,
|
|
55
|
+
getComparableValue: column.getComparableValue,
|
|
56
|
+
serializeFilter: column.serializeFilter,
|
|
57
|
+
deserializeFilter: column.deserializeFilter,
|
|
58
|
+
toXlsxValue: column.toXlsxValue,
|
|
59
|
+
|
|
60
|
+
renderHeader: column.renderHeader,
|
|
61
|
+
renderCell: column.renderCell,
|
|
62
|
+
renderEditCell: column.renderEditCell,
|
|
63
|
+
renderGroup: column.renderGroup,
|
|
64
|
+
cellTitleFn: column.cellTitleFn,
|
|
65
|
+
getFilterFn: column.getFilterFn,
|
|
66
|
+
headerCellClass: column.headerCellClass,
|
|
67
|
+
cellClass: column.cellClass,
|
|
68
|
+
|
|
69
|
+
editable: column.editable,
|
|
70
|
+
|
|
71
|
+
values: column.values,
|
|
72
|
+
source: memooize(column.computeSource),
|
|
73
|
+
|
|
74
|
+
noLocalFilter: column.noLocalFilter,
|
|
75
|
+
|
|
76
|
+
mini: column.mini,
|
|
77
|
+
renderMini: column.renderMini,
|
|
78
|
+
|
|
79
|
+
// @deprecated
|
|
80
|
+
loading: column.loading,
|
|
81
|
+
externalValues: column.externalValues,
|
|
82
|
+
computeSource: column.computeSource,
|
|
83
|
+
|
|
84
|
+
// boolean columns
|
|
85
|
+
trueLabel: column.trueLabel,
|
|
86
|
+
falseLabel: column.falseLabel,
|
|
87
|
+
|
|
88
|
+
// list columns
|
|
89
|
+
valueProperty: column.valueProperty,
|
|
90
|
+
textProperty: column.textProperty,
|
|
91
|
+
emptyLabel: column.emptyLabel,
|
|
92
|
+
emptyValue: column.emptyValue,
|
|
93
|
+
|
|
94
|
+
// range columns
|
|
95
|
+
min: column.min,
|
|
96
|
+
max: column.max,
|
|
97
|
+
locale: column.locale,
|
|
98
|
+
autoupdate: column.autoupdate,
|
|
99
|
+
|
|
100
|
+
// number columns
|
|
101
|
+
maximumFractionDigits: column.maximumFractionDigits,
|
|
102
|
+
minimumFractionDigits: column.minimumFractionDigits,
|
|
103
|
+
|
|
104
|
+
// amount columns
|
|
105
|
+
currency: column.currency,
|
|
106
|
+
rates: column.rates,
|
|
107
|
+
autodetect: column.autodetect,
|
|
108
|
+
|
|
109
|
+
// treenode columns
|
|
110
|
+
ownerTree: column.ownerTree,
|
|
111
|
+
keyProperty: column.keyProperty,
|
|
112
|
+
|
|
113
|
+
...column.getConfig?.(column),
|
|
114
|
+
|
|
115
|
+
[columnSymbol]: column,
|
|
156
116
|
};
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
const isVisibleColumn = (child) => child.isOmnitableColumn && !child.hidden;
|
|
120
|
+
|
|
121
|
+
const collectDomColumns = (slot) => {
|
|
122
|
+
const domColumns = slot
|
|
123
|
+
.assignedElements({ flatten: true })
|
|
124
|
+
.filter(isVisibleColumn);
|
|
125
|
+
|
|
126
|
+
if (!verifyColumnSetup(domColumns)) return [];
|
|
127
|
+
return domColumns;
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
const normalizeColumns = (domColumns, enabledColumns) => {
|
|
131
|
+
const columns = Array.isArray(enabledColumns)
|
|
132
|
+
? domColumns.filter((column) => enabledColumns.includes(column.name))
|
|
133
|
+
: domColumns.filter((column) => !column.disabled);
|
|
134
|
+
|
|
135
|
+
return columns.map(normalizeColumn);
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
export const useDOMColumns = (host, { enabledColumns }) => {
|
|
139
|
+
const [columns, setColumns] = useState([]);
|
|
140
|
+
|
|
141
|
+
useLayoutEffect(() => {
|
|
142
|
+
let sched;
|
|
143
|
+
const slot = host.shadowRoot.querySelector('#columnsSlot');
|
|
144
|
+
const update = () => {
|
|
145
|
+
setColumns(normalizeColumns(collectDomColumns(slot), enabledColumns));
|
|
146
|
+
};
|
|
147
|
+
const scheduleUpdate = () => {
|
|
148
|
+
cancelAnimationFrame(sched);
|
|
149
|
+
sched = requestAnimationFrame(update);
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
scheduleUpdate();
|
|
153
|
+
|
|
154
|
+
slot.addEventListener('slotchange', scheduleUpdate);
|
|
155
|
+
host.addEventListener('cosmoz-column-prop-changed', scheduleUpdate);
|
|
156
|
+
|
|
157
|
+
return () => {
|
|
158
|
+
slot.removeEventListener('slotchange', scheduleUpdate);
|
|
159
|
+
host.removeEventListener('cosmoz-column-prop-changed', scheduleUpdate);
|
|
160
|
+
cancelAnimationFrame(sched);
|
|
161
|
+
};
|
|
162
|
+
}, [enabledColumns]);
|
|
163
|
+
|
|
164
|
+
return columns;
|
|
165
|
+
};
|
|
157
166
|
|
|
158
|
-
export { columnSymbol
|
|
167
|
+
export { columnSymbol };
|
package/lib/use-fast-layout.js
CHANGED
|
@@ -27,7 +27,7 @@ export const useFastLayout = ({
|
|
|
27
27
|
tweenedlayout = useTweenArray(layout, resizeSpeedFactor),
|
|
28
28
|
layoutCss = useMemo(
|
|
29
29
|
() => toCss(tweenedlayout, settings.columns),
|
|
30
|
-
[tweenedlayout],
|
|
30
|
+
[tweenedlayout, settings.columns],
|
|
31
31
|
),
|
|
32
32
|
collapsedColumns = useMemo(
|
|
33
33
|
() =>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@neovici/cosmoz-omnitable",
|
|
3
|
-
"version": "13.
|
|
3
|
+
"version": "13.4.0",
|
|
4
4
|
"description": "[](https://travis-ci.org/Neovici/cosmoz-omnitable)",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"web-components"
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"start": "wds",
|
|
31
31
|
"test": "wtr --coverage",
|
|
32
32
|
"test:watch": "wtr --watch",
|
|
33
|
-
"prepare": "husky
|
|
33
|
+
"prepare": "husky"
|
|
34
34
|
},
|
|
35
35
|
"release": {
|
|
36
36
|
"plugins": [
|
|
@@ -80,8 +80,8 @@
|
|
|
80
80
|
"lit-html": "^2.0.0 || ^3.0.0"
|
|
81
81
|
},
|
|
82
82
|
"devDependencies": {
|
|
83
|
-
"@commitlint/cli": "^
|
|
84
|
-
"@commitlint/config-conventional": "^
|
|
83
|
+
"@commitlint/cli": "^19.0.0",
|
|
84
|
+
"@commitlint/config-conventional": "^19.0.0",
|
|
85
85
|
"@neovici/cfg": "^1.18.0",
|
|
86
86
|
"@neovici/cosmoz-viewinfo": "^4.0.0",
|
|
87
87
|
"@open-wc/testing": "^4.0.0",
|
|
@@ -92,8 +92,8 @@
|
|
|
92
92
|
"@polymer/paper-toggle-button": "^3.0.0",
|
|
93
93
|
"@semantic-release/changelog": "^6.0.0",
|
|
94
94
|
"@semantic-release/git": "^10.0.0",
|
|
95
|
-
"husky": "^
|
|
96
|
-
"semantic-release": "^
|
|
97
|
-
"sinon": "^
|
|
95
|
+
"husky": "^9.0.0",
|
|
96
|
+
"semantic-release": "^23.0.0",
|
|
97
|
+
"sinon": "^18.0.0"
|
|
98
98
|
}
|
|
99
99
|
}
|