@neovici/cosmoz-omnitable 9.0.1 → 10.0.0-beta.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-header-row.js +1 -1
- package/cosmoz-omnitable-item-row.js +1 -1
- package/cosmoz-omnitable.js +7 -11
- package/lib/cosmoz-omnitable-amount-range-input.js +1 -1
- package/lib/cosmoz-omnitable-date-range-input.js +1 -1
- package/lib/cosmoz-omnitable-datetime-range-input.js +1 -1
- package/lib/cosmoz-omnitable-number-range-input.js +1 -1
- package/lib/cosmoz-omnitable-time-range-input.js +1 -1
- package/lib/settings/cosmoz-omnitable-group.js +1 -1
- package/lib/settings/normalize.js +1 -1
- package/lib/settings/use-saved-settings.js +15 -11
- package/lib/settings/use-settings.js +16 -5
- package/lib/use-hash-state.js +2 -2
- package/lib/use-omnitable.js +9 -3
- package/lib/use-sort-and-group-options.js +13 -3
- package/package.json +17 -18
package/cosmoz-omnitable.js
CHANGED
|
@@ -44,7 +44,7 @@ class Omnitable extends hauntedPolymer(useOmnitable)(
|
|
|
44
44
|
/* eslint-disable-next-line max-lines-per-function */
|
|
45
45
|
static get template() {
|
|
46
46
|
const template = html`
|
|
47
|
-
${html([styles])}
|
|
47
|
+
${html(Object.assign([styles], { raw: [styles] }))}
|
|
48
48
|
<div id="layoutStyle"></div>
|
|
49
49
|
|
|
50
50
|
<div class="mainContainer">
|
|
@@ -230,18 +230,14 @@ class Omnitable extends hauntedPolymer(useOmnitable)(
|
|
|
230
230
|
}
|
|
231
231
|
|
|
232
232
|
renderItem(collapsedColumns) {
|
|
233
|
-
return (
|
|
234
|
-
item,
|
|
235
|
-
index,
|
|
236
|
-
{ selected, expanded, toggleCollapse }
|
|
237
|
-
) => {
|
|
233
|
+
return (item, index, { selected, expanded, toggleCollapse }) => {
|
|
238
234
|
return litHtml`
|
|
239
235
|
<div class="item-row-wrapper">
|
|
240
236
|
<div ?selected=${selected}
|
|
241
237
|
part="itemRow itemRow-${item[indexSymbol]}"
|
|
242
238
|
.dataIndex=${item[indexSymbol]}
|
|
243
239
|
.dataItem=${item}
|
|
244
|
-
class="itemRow"
|
|
240
|
+
class="itemRow"
|
|
245
241
|
@click=${this.onItemClick}
|
|
246
242
|
>
|
|
247
243
|
<input class="checkbox"
|
|
@@ -268,7 +264,7 @@ class Omnitable extends hauntedPolymer(useOmnitable)(
|
|
|
268
264
|
</div>
|
|
269
265
|
<cosmoz-omnitable-item-expand .columns=${collapsedColumns}
|
|
270
266
|
.item=${item}
|
|
271
|
-
.index=${index}
|
|
267
|
+
.index=${index}
|
|
272
268
|
?selected=${selected}
|
|
273
269
|
?expanded=${expanded}
|
|
274
270
|
.groupOnColumn=${this.groupOnColumn}
|
|
@@ -280,7 +276,7 @@ class Omnitable extends hauntedPolymer(useOmnitable)(
|
|
|
280
276
|
|
|
281
277
|
renderGroup(item, index, { selected, folded, toggleFold }) {
|
|
282
278
|
return litHtml`
|
|
283
|
-
<div class="${this._getGroupRowClasses(folded)}"
|
|
279
|
+
<div class="${this._getGroupRowClasses(folded)}"
|
|
284
280
|
part="groupRow groupRow-${item[indexSymbol]}">
|
|
285
281
|
<input class="checkbox"
|
|
286
282
|
type="checkbox"
|
|
@@ -688,5 +684,5 @@ const tmplt = `
|
|
|
688
684
|
<slot name="bottom-bar-menu" slot="bottom-bar-menu"></slot>
|
|
689
685
|
`;
|
|
690
686
|
|
|
691
|
-
export const actionSlots = litHtml([tmplt]),
|
|
692
|
-
actionSlotsPolymer = html([tmplt]);
|
|
687
|
+
export const actionSlots = litHtml(Object.assign([tmplt], { raw: [tmplt] })),
|
|
688
|
+
actionSlotsPolymer = html(Object.assign([tmplt], { raw: [tmplt] }));
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { _ } from '@neovici/cosmoz-i18next';
|
|
2
2
|
import { PolymerElement } from '@polymer/polymer';
|
|
3
3
|
import { html } from 'lit-html';
|
|
4
|
-
import { ifDefined } from 'lit-html/directives/if-defined';
|
|
4
|
+
import { ifDefined } from 'lit-html/directives/if-defined.js';
|
|
5
5
|
import { rangeInputMixin } from './cosmoz-omnitable-range-input-mixin';
|
|
6
6
|
import { polymerHauntedRender } from './polymer-haunted-render-mixin';
|
|
7
7
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { _ } from '@neovici/cosmoz-i18next';
|
|
2
2
|
import { PolymerElement } from '@polymer/polymer';
|
|
3
3
|
import { html } from 'lit-html';
|
|
4
|
-
import { ifDefined } from 'lit-html/directives/if-defined';
|
|
4
|
+
import { ifDefined } from 'lit-html/directives/if-defined.js';
|
|
5
5
|
import { dateInputMixin } from './cosmoz-omnitable-date-input-mixin';
|
|
6
6
|
import { polymerHauntedRender } from './polymer-haunted-render-mixin';
|
|
7
7
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { _ } from '@neovici/cosmoz-i18next';
|
|
2
2
|
import { PolymerElement } from '@polymer/polymer';
|
|
3
3
|
import { html } from 'lit-html';
|
|
4
|
-
import { ifDefined } from 'lit-html/directives/if-defined';
|
|
4
|
+
import { ifDefined } from 'lit-html/directives/if-defined.js';
|
|
5
5
|
import { dateInputMixin } from './cosmoz-omnitable-date-input-mixin';
|
|
6
6
|
import { polymerHauntedRender } from './polymer-haunted-render-mixin';
|
|
7
7
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { _ } from '@neovici/cosmoz-i18next';
|
|
2
2
|
import { PolymerElement } from '@polymer/polymer';
|
|
3
3
|
import { html } from 'lit-html';
|
|
4
|
-
import { ifDefined } from 'lit-html/directives/if-defined';
|
|
4
|
+
import { ifDefined } from 'lit-html/directives/if-defined.js';
|
|
5
5
|
import { rangeInputMixin } from './cosmoz-omnitable-range-input-mixin';
|
|
6
6
|
import { polymerHauntedRender } from './polymer-haunted-render-mixin';
|
|
7
7
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { _ } from '@neovici/cosmoz-i18next';
|
|
2
2
|
import { PolymerElement } from '@polymer/polymer';
|
|
3
3
|
import { html } from 'lit-html';
|
|
4
|
-
import { ifDefined } from 'lit-html/directives/if-defined';
|
|
4
|
+
import { ifDefined } from 'lit-html/directives/if-defined.js';
|
|
5
5
|
import { dateInputMixin } from './cosmoz-omnitable-date-input-mixin';
|
|
6
6
|
import { polymerHauntedRender } from './polymer-haunted-render-mixin';
|
|
7
7
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { html } from 'haunted';
|
|
2
|
-
import { ifDefined } from 'lit-html/directives/if-defined';
|
|
2
|
+
import { ifDefined } from 'lit-html/directives/if-defined.js';
|
|
3
3
|
import { triangle } from '../icons';
|
|
4
4
|
|
|
5
5
|
export const render = ({ columns, on, descending, setOn, setDescending }) =>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* eslint-disable import/group-exports */
|
|
2
2
|
import { props } from '@neovici/cosmoz-utils/lib/object';
|
|
3
3
|
|
|
4
|
-
export const sgProps = ['sortOn', 'descending', 'groupOn', '
|
|
4
|
+
export const sgProps = ['sortOn', 'descending', 'groupOn', 'groupOnDescending'];
|
|
5
5
|
|
|
6
6
|
const byName = (name) => (item) => item.name === name;
|
|
7
7
|
|
|
@@ -13,7 +13,7 @@ const storagePrefix = 'omnitable-',
|
|
|
13
13
|
}
|
|
14
14
|
};
|
|
15
15
|
// eslint-disable-next-line max-lines-per-function
|
|
16
|
-
export default (settingsId, settings, setSettings) => {
|
|
16
|
+
export default (settingsId, settings, setSettings, onReset) => {
|
|
17
17
|
const [counter, setCounter] = useState(0),
|
|
18
18
|
savedSettings = useMemo(() => read(settingsId), [settingsId, counter]);
|
|
19
19
|
|
|
@@ -40,18 +40,22 @@ export default (settingsId, settings, setSettings) => {
|
|
|
40
40
|
}
|
|
41
41
|
}, [settings]),
|
|
42
42
|
|
|
43
|
-
onReset: (
|
|
44
|
-
|
|
43
|
+
onReset: useCallback(
|
|
44
|
+
(e) => {
|
|
45
|
+
setSettings();
|
|
45
46
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
47
|
+
if (e.shiftKey) {
|
|
48
|
+
try {
|
|
49
|
+
localStorage.removeItem(storagePrefix + settingsId);
|
|
50
|
+
setCounter((counter) => counter + 1);
|
|
51
|
+
} catch (err) {
|
|
52
|
+
// ignore error
|
|
53
|
+
}
|
|
52
54
|
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
+
onReset?.();
|
|
56
|
+
},
|
|
57
|
+
[onReset]
|
|
58
|
+
),
|
|
55
59
|
|
|
56
60
|
hasChanges: settings != null,
|
|
57
61
|
};
|
|
@@ -1,15 +1,24 @@
|
|
|
1
|
-
import { useMemo, useState } from 'haunted';
|
|
1
|
+
import { useMemo, useState, useRef, useCallback } from 'haunted';
|
|
2
2
|
|
|
3
3
|
import useSavedSettings from './use-saved-settings';
|
|
4
|
-
import normalize from './normalize';
|
|
4
|
+
import normalize, { sgProps } from './normalize';
|
|
5
5
|
|
|
6
|
-
export default ({ settingsId, ...thru }) => {
|
|
7
|
-
const
|
|
6
|
+
export default ({ settingsId, initial: ini, ...thru }) => {
|
|
7
|
+
const initial = useMemo(
|
|
8
|
+
() => Object.fromEntries(sgProps.map((k) => [k, ini[k]])),
|
|
9
|
+
[]
|
|
10
|
+
),
|
|
11
|
+
resetRef = useRef(),
|
|
12
|
+
onReset = useCallback(() => {
|
|
13
|
+
resetRef.current?.(initial);
|
|
14
|
+
}, [initial]),
|
|
15
|
+
[settings, setSettings] = useState(),
|
|
8
16
|
[opened, setOpened] = useState({ columns: true, sort: true }),
|
|
9
17
|
{ savedSettings, ...rest } = useSavedSettings(
|
|
10
18
|
settingsId,
|
|
11
19
|
settings,
|
|
12
|
-
setSettings
|
|
20
|
+
setSettings,
|
|
21
|
+
onReset
|
|
13
22
|
),
|
|
14
23
|
{ columns } = thru,
|
|
15
24
|
normalizedSettings = useMemo(
|
|
@@ -17,6 +26,7 @@ export default ({ settingsId, ...thru }) => {
|
|
|
17
26
|
normalize({
|
|
18
27
|
settings,
|
|
19
28
|
savedSettings,
|
|
29
|
+
initial,
|
|
20
30
|
...thru,
|
|
21
31
|
}),
|
|
22
32
|
[settings, savedSettings, ...Object.values(thru)]
|
|
@@ -36,5 +46,6 @@ export default ({ settingsId, ...thru }) => {
|
|
|
36
46
|
settings: normalizedSettings,
|
|
37
47
|
columns: normalizedColumns,
|
|
38
48
|
setSettings,
|
|
49
|
+
resetRef,
|
|
39
50
|
};
|
|
40
51
|
};
|
package/lib/use-hash-state.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useCallback, useState } from 'haunted';
|
|
2
|
-
import { navigate } from '@neovici/cosmoz-page-router
|
|
3
|
-
import { invoke } from './invoke';
|
|
2
|
+
import { navigate } from '@neovici/cosmoz-page-router';
|
|
4
3
|
import { identity } from '@neovici/cosmoz-utils/lib/function';
|
|
4
|
+
import { invoke } from './invoke';
|
|
5
5
|
|
|
6
6
|
const
|
|
7
7
|
hashUrl = () => new URL(location.hash.replace(/^#!?/iu, '').replace('%23', '#'), location.origin),
|
package/lib/use-omnitable.js
CHANGED
|
@@ -5,15 +5,21 @@ import { useSettings } from './settings';
|
|
|
5
5
|
import { useDOMColumns } from './use-dom-columns';
|
|
6
6
|
import { useSortAndGroupOptions } from './use-sort-and-group-options';
|
|
7
7
|
import { onItemChange } from './utils-data';
|
|
8
|
-
import { useNotifyProperty } from '@neovici/cosmoz-utils/lib/hooks/use-notify-property'
|
|
8
|
+
import { useNotifyProperty } from '@neovici/cosmoz-utils/lib/hooks/use-notify-property';
|
|
9
9
|
|
|
10
10
|
// eslint-disable-next-line max-lines-per-function
|
|
11
11
|
export const useOmnitable = (host) => {
|
|
12
12
|
const { enabledColumns, hashParam, settingsId } = host,
|
|
13
13
|
_columns = useDOMColumns(host, { enabledColumns }),
|
|
14
14
|
settingS = useSettings({ columns: _columns, settingsId, initial: host }),
|
|
15
|
-
{ settings, setSettings, columns } = settingS,
|
|
16
|
-
sortAndGroupOptions = useSortAndGroupOptions(
|
|
15
|
+
{ settings, setSettings, columns, resetRef } = settingS,
|
|
16
|
+
sortAndGroupOptions = useSortAndGroupOptions(
|
|
17
|
+
columns,
|
|
18
|
+
hashParam,
|
|
19
|
+
settings,
|
|
20
|
+
setSettings,
|
|
21
|
+
resetRef
|
|
22
|
+
),
|
|
17
23
|
{ groupOnColumn, groupOnDescending, sortOnColumn, descending } =
|
|
18
24
|
sortAndGroupOptions,
|
|
19
25
|
{ data, resizeSpeedFactor } = host,
|
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
component,
|
|
5
5
|
useContext,
|
|
6
6
|
useCallback,
|
|
7
|
+
useEffect,
|
|
7
8
|
} from 'haunted';
|
|
8
9
|
import { useHashState } from './use-hash-state';
|
|
9
10
|
|
|
@@ -23,7 +24,8 @@ export const useSortAndGroupOptions = (
|
|
|
23
24
|
columns,
|
|
24
25
|
hashParam,
|
|
25
26
|
settings,
|
|
26
|
-
setSettings
|
|
27
|
+
setSettings,
|
|
28
|
+
resetRef
|
|
27
29
|
) => {
|
|
28
30
|
const [sortOn, setSortOn] = useHashState(settings.sortOn, hashParam, {
|
|
29
31
|
suffix: '-sortOn',
|
|
@@ -73,7 +75,16 @@ export const useSortAndGroupOptions = (
|
|
|
73
75
|
|
|
74
76
|
columns,
|
|
75
77
|
},
|
|
76
|
-
sortAndGroup = useMemo(() => sortAndGroup_, Object.values(sortAndGroup_))
|
|
78
|
+
sortAndGroup = useMemo(() => sortAndGroup_, Object.values(sortAndGroup_)),
|
|
79
|
+
setSG = useCallback((c) => {
|
|
80
|
+
setSortOn(c.sortOn);
|
|
81
|
+
setGroupOn(c.groupOn);
|
|
82
|
+
setDescending(c.descending);
|
|
83
|
+
setGroupOnDescending(c.groupOnDescending);
|
|
84
|
+
}, []);
|
|
85
|
+
|
|
86
|
+
// eslint-disable-next-line no-void
|
|
87
|
+
useEffect(() => void (resetRef.current = setSG), []);
|
|
77
88
|
|
|
78
89
|
return {
|
|
79
90
|
...sortAndGroup,
|
|
@@ -84,7 +95,6 @@ export const useSortAndGroupOptions = (
|
|
|
84
95
|
},
|
|
85
96
|
SortAndGroupContext = createContext();
|
|
86
97
|
|
|
87
|
-
|
|
88
98
|
customElements.define('sort-and-group-provider', SortAndGroupContext.Provider);
|
|
89
99
|
customElements.define(
|
|
90
100
|
'sort-and-group-consumer',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@neovici/cosmoz-omnitable",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "10.0.0-beta.1",
|
|
4
4
|
"description": "[](https://travis-ci.org/Neovici/cosmoz-omnitable)",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"web-components"
|
|
@@ -52,15 +52,15 @@
|
|
|
52
52
|
]
|
|
53
53
|
},
|
|
54
54
|
"dependencies": {
|
|
55
|
-
"@neovici/cosmoz-autocomplete": "^
|
|
56
|
-
"@neovici/cosmoz-bottom-bar": "^
|
|
55
|
+
"@neovici/cosmoz-autocomplete": "^4.0.0-beta.1",
|
|
56
|
+
"@neovici/cosmoz-bottom-bar": "^6.0.0-beta.1",
|
|
57
57
|
"@neovici/cosmoz-collapse": "^1.1.0",
|
|
58
58
|
"@neovici/cosmoz-datetime-input": "^3.0.3",
|
|
59
|
-
"@neovici/cosmoz-dropdown": "^
|
|
60
|
-
"@neovici/cosmoz-grouped-list": "^
|
|
59
|
+
"@neovici/cosmoz-dropdown": "^2.0.0-beta.1",
|
|
60
|
+
"@neovici/cosmoz-grouped-list": "^5.0.0-beta.1",
|
|
61
61
|
"@neovici/cosmoz-i18next": "^3.1.1",
|
|
62
|
-
"@neovici/cosmoz-page-router": "^
|
|
63
|
-
"@neovici/cosmoz-utils": "^
|
|
62
|
+
"@neovici/cosmoz-page-router": "^9.0.0-beta.3",
|
|
63
|
+
"@neovici/cosmoz-utils": "^4.0.0-beta.2",
|
|
64
64
|
"@neovici/nullxlsx": "^3.0.0",
|
|
65
65
|
"@polymer/iron-icon": "^3.0.0",
|
|
66
66
|
"@polymer/iron-icons": "^3.0.0",
|
|
@@ -70,28 +70,27 @@
|
|
|
70
70
|
"@polymer/paper-spinner": "^3.0.0",
|
|
71
71
|
"@polymer/polymer": "^3.3.0",
|
|
72
72
|
"@webcomponents/shadycss": "^1.10.0",
|
|
73
|
-
"file-saver-es": "^2.0.
|
|
74
|
-
"haunted": "^
|
|
75
|
-
"lit-html": "^
|
|
73
|
+
"file-saver-es": "^2.0.0",
|
|
74
|
+
"haunted": "^5.0.0",
|
|
75
|
+
"lit-html": "^2.0.0"
|
|
76
76
|
},
|
|
77
77
|
"devDependencies": {
|
|
78
78
|
"@commitlint/cli": "^17.0.0",
|
|
79
79
|
"@commitlint/config-conventional": "^17.0.0",
|
|
80
80
|
"@neovici/cfg": "^1.13.0",
|
|
81
|
-
"@neovici/cosmoz-viewinfo": "^3.1.
|
|
82
|
-
"@
|
|
83
|
-
"@open-wc/testing": "^2.5.28",
|
|
81
|
+
"@neovici/cosmoz-viewinfo": "^3.1.0",
|
|
82
|
+
"@open-wc/testing": "^3.0.0",
|
|
84
83
|
"@polymer/iron-test-helpers": "^3.0.0",
|
|
85
|
-
"@polymer/paper-button": "^3.0.
|
|
86
|
-
"@polymer/paper-item": "^3.0.
|
|
87
|
-
"@polymer/paper-listbox": "^3.0.
|
|
84
|
+
"@polymer/paper-button": "^3.0.0",
|
|
85
|
+
"@polymer/paper-item": "^3.0.0",
|
|
86
|
+
"@polymer/paper-listbox": "^3.0.0",
|
|
88
87
|
"@polymer/paper-toggle-button": "^3.0.0",
|
|
89
88
|
"@semantic-release/changelog": "^6.0.0",
|
|
90
89
|
"@semantic-release/git": "^10.0.0",
|
|
91
90
|
"@web/dev-server": "^0.1.10",
|
|
92
91
|
"husky": "^8.0.0",
|
|
93
92
|
"semantic-release": "^19.0.0",
|
|
94
|
-
"sinon": "^
|
|
95
|
-
"web-animations-js": "^2.3.
|
|
93
|
+
"sinon": "^14.0.0",
|
|
94
|
+
"web-animations-js": "^2.3.0"
|
|
96
95
|
}
|
|
97
96
|
}
|