@neovici/cosmoz-omnitable 8.5.1 → 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.
@@ -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
 
@@ -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
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@neovici/cosmoz-omnitable",
3
- "version": "8.5.1",
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": "^3.0.0",
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",