@neovici/cosmoz-omnitable 8.4.0 → 8.5.2

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.
@@ -151,8 +151,7 @@ const
151
151
  }
152
152
 
153
153
  serializeFilter(column, filter) {
154
- // TODO: drop the double-encoding
155
- return filter.length === 0 ? null : encodeURIComponent(JSON.stringify(filter));
154
+ return filter.length === 0 ? null : JSON.stringify(filter);
156
155
  }
157
156
 
158
157
  deserializeFilter(column, filter) {
@@ -134,7 +134,7 @@ class Omnitable extends hauntedPolymer(useOmnitable)(mixin({ isEmpty }, translat
134
134
  label="[[ _('Group on', t) ]] [[ _computeSortDirection(groupOnDescending, t) ]]" placeholder="[[ _('No grouping', t) ]]"
135
135
  source="[[ _onCompleteValues(columns, 'groupOn', groupOnColumn) ]]" value="[[ groupOnColumn ]]" limit="1" text-property="title"
136
136
  always-float-label item-height="48" item-limit="8"
137
- class="footer-control" on-change="[[ _onCompleteChange('groupOn') ]]" default-index="-1" show-single show-selection
137
+ class="footer-control" on-select="[[ _onCompleteChange('groupOn') ]]" default-index="-1" show-single
138
138
  >
139
139
  <svg slot="suffix" viewBox="0 0 24 24" preserveAspectRatio="xMidYMid meet" focusable="false" width="24" fill="currentColor"><path d="M7 10l5 5 5-5z"></path></svg>
140
140
  </cosmoz-autocomplete>
@@ -142,7 +142,7 @@ class Omnitable extends hauntedPolymer(useOmnitable)(mixin({ isEmpty }, translat
142
142
  label="[[ _('Sort on', t) ]] [[ _computeSortDirection(descending, t) ]]" placeholder="[[ _('No sorting', t) ]]"
143
143
  source="[[ _onCompleteValues(columns, 'sortOn', sortOnColumn) ]]" value="[[ sortOnColumn ]]" limit="1" text-property="title"
144
144
  always-float-label item-height="48" item-limit="8"
145
- class="footer-control" on-change="[[ _onCompleteChange('sortOn') ]]" default-index="-1" show-single show-selection
145
+ class="footer-control" on-select="[[ _onCompleteChange('sortOn') ]]" default-index="-1" show-single
146
146
  >
147
147
  <svg slot="suffix" viewBox="0 0 24 24" preserveAspectRatio="xMidYMid meet" focusable="false" width="24" fill="currentColor"><path d="M7 10l5 5 5-5z"></path></svg>
148
148
  </cosmoz-autocomplete>
@@ -521,7 +521,7 @@ class Omnitable extends hauntedPolymer(useOmnitable)(mixin({ isEmpty }, translat
521
521
  }
522
522
 
523
523
  _onCompleteChange(type) {
524
- return (val, close) => {
524
+ return (val, {setClosed}) => {
525
525
  const value = (val[0] ?? val)?.name ?? '',
526
526
  setter = type === 'groupOn' ? this.setGroupOn : this.setSortOn,
527
527
  directionSetter = type === 'groupOn' ? this.setGroupOnDescending : this.setDescending;
@@ -535,7 +535,7 @@ class Omnitable extends hauntedPolymer(useOmnitable)(mixin({ isEmpty }, translat
535
535
  return value;
536
536
  });
537
537
 
538
- value && close(); /* eslint-disable-line no-unused-expressions */
538
+ value && setClosed(true); /* eslint-disable-line no-unused-expressions */
539
539
  };
540
540
  }
541
541
 
@@ -40,8 +40,7 @@ const
40
40
 
41
41
  export const useHashState = (initial, param, { suffix = '', read, write, multi } = {}) => {
42
42
  const
43
- link = multi ? multiLink : singleLink,
44
- parseHash = multi ? multiParse : singleParse,
43
+ [link, parseHash] = multi ? [multiLink, multiParse] : [singleLink, singleParse],
45
44
  [state, _setState] = useState(() => param == null
46
45
  ? initial
47
46
  : parseHash(param + suffix, read) ?? initial),
@@ -14,8 +14,7 @@ export const useOmnitable = host => {
14
14
  sortAndGroupOptions = useSortAndGroupOptions(
15
15
  columns,
16
16
  hashParam,
17
- host.sortOn,
18
- host.groupOn
17
+ host
19
18
  ),
20
19
  { groupOnColumn, groupOnDescending, sortOnColumn, descending } = sortAndGroupOptions,
21
20
  { data, resizeSpeedFactor, settingsId } = host,
@@ -1,18 +1,33 @@
1
1
  import { useMemo } from 'haunted';
2
2
  import { useHashState } from './use-hash-state';
3
3
 
4
- const
5
- parseBool = bool => [true, 'true', 1, 'yes', 'on'].includes(bool),
6
- boolParam = p => p === '' || parseBool(p);
4
+ const parseBool = (bool) => [true, 'true', 1, 'yes', 'on'].includes(bool),
5
+ boolParam = (p) => p === '' || (p == null ? undefined : parseBool(p));
7
6
 
8
- export const useSortAndGroupOptions = (columns, hashParam, initialSortOn, initialGroupOn) => {
9
- const
10
- [sortOn, setSortOn] = useHashState(initialSortOn, hashParam, { suffix: '-sortOn' }),
11
- [descending, setDescending] = useHashState(false, hashParam, { suffix: '-descending', read: boolParam }),
12
- [groupOn, setGroupOn] = useHashState(initialGroupOn, hashParam, { suffix: '-groupOn' }),
13
- [groupOnDescending, setGroupOnDescending] = useHashState(false, hashParam, { suffix: '-groupOnDescending', read: boolParam }),
14
- sortOnColumn = useMemo(() => columns.find(column => column.name === sortOn), [columns, sortOn]),
15
- groupOnColumn = useMemo(() => columns.find(column => column.name === groupOn), [columns, groupOn]);
7
+ export const useSortAndGroupOptions = (columns, hashParam, initial) => {
8
+ const [sortOn, setSortOn] = useHashState(initial.sortOn, hashParam, {
9
+ suffix: '-sortOn',
10
+ }),
11
+ [descending, setDescending] = useHashState(initial.descending, hashParam, {
12
+ suffix: '-descending',
13
+ read: boolParam,
14
+ }),
15
+ [groupOn, setGroupOn] = useHashState(initial.groupOn, hashParam, {
16
+ suffix: '-groupOn',
17
+ }),
18
+ [groupOnDescending, setGroupOnDescending] = useHashState(
19
+ initial.groupOnDescending,
20
+ hashParam,
21
+ { suffix: '-groupOnDescending', read: boolParam }
22
+ ),
23
+ sortOnColumn = useMemo(
24
+ () => columns.find((column) => column.name === sortOn),
25
+ [columns, sortOn]
26
+ ),
27
+ groupOnColumn = useMemo(
28
+ () => columns.find((column) => column.name === groupOn),
29
+ [columns, groupOn]
30
+ );
16
31
 
17
32
  return {
18
33
  groupOn,
@@ -25,6 +40,6 @@ export const useSortAndGroupOptions = (columns, hashParam, initialSortOn, initia
25
40
  setSortOn,
26
41
  sortOnColumn,
27
42
  descending,
28
- setDescending
43
+ setDescending,
29
44
  };
30
45
  };
@@ -106,7 +106,7 @@ export const
106
106
  return '';
107
107
  }
108
108
  return getFormatter(amount.currency, locale)
109
- .format(value.amount);
109
+ .format(amount.amount);
110
110
  },
111
111
 
112
112
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@neovici/cosmoz-omnitable",
3
- "version": "8.4.0",
3
+ "version": "8.5.2",
4
4
  "description": "[![Build Status](https://travis-ci.org/Neovici/cosmoz-omnitable.svg?branch=master)](https://travis-ci.org/Neovici/cosmoz-omnitable)",
5
5
  "keywords": [
6
6
  "web-components"
@@ -52,7 +52,7 @@
52
52
  ]
53
53
  },
54
54
  "dependencies": {
55
- "@neovici/cosmoz-autocomplete": "^2.17.1",
55
+ "@neovici/cosmoz-autocomplete": "^3.1.0",
56
56
  "@neovici/cosmoz-bottom-bar": "^5.0.0",
57
57
  "@neovici/cosmoz-datetime-input": "^3.0.3",
58
58
  "@neovici/cosmoz-dropdown": "^1.5.0",
@@ -76,6 +76,7 @@
76
76
  "devDependencies": {
77
77
  "@commitlint/cli": "^16.0.0",
78
78
  "@commitlint/config-conventional": "^16.0.0",
79
+ "@neovici/cfg": "^1.13.0",
79
80
  "@neovici/cosmoz-viewinfo": "^3.1.3",
80
81
  "@neovici/eslint-config": "^1.3.3",
81
82
  "@open-wc/testing": "^2.5.28",
@@ -89,8 +90,6 @@
89
90
  "@semantic-release/changelog": "^6.0.0",
90
91
  "@semantic-release/git": "^10.0.0",
91
92
  "@web/dev-server": "^0.1.10",
92
- "@web/test-runner": "^0.13.0",
93
- "@web/test-runner-selenium": "^0.5.0",
94
93
  "husky": "^7.0.0",
95
94
  "semantic-release": "^19.0.0",
96
95
  "sinon": "^13.0.0",