@neovici/cosmoz-omnitable 12.6.2 → 12.7.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.
@@ -11,6 +11,7 @@ import { computeSource, listColumnMixin, onChange, onFocus, onText, toAutocomple
11
11
  import {
12
12
  prop, strProp, array
13
13
  } from '@neovici/cosmoz-autocomplete/lib/utils';
14
+ import { columnSymbol } from './lib/use-dom-columns';
14
15
  import { get } from '@polymer/polymer/lib/utils/path';
15
16
 
16
17
  export const
@@ -55,6 +56,7 @@ class OmnitableColumnAutocomplete extends listColumnMixin(columnMixin(PolymerEle
55
56
  .source=${ toAutocompleteSource(source, column.valueProperty, column.textProperty) }
56
57
  .textProperty=${ column.textProperty }
57
58
  .valueProperty=${ column.valueProperty }
59
+ .itemRenderer=${column[columnSymbol]?.itemRenderer}
58
60
  .value=${ filter }
59
61
  .text=${ query }
60
62
  .onChange=${ onChange(setState) }
@@ -14,6 +14,7 @@ import {
14
14
  } from './cosmoz-omnitable-column-list-mixin';
15
15
  import '@neovici/cosmoz-autocomplete';
16
16
  import { notifyResize } from './lib/utils';
17
+ import { columnSymbol } from './lib/use-dom-columns';
17
18
 
18
19
  /**
19
20
  * @polymer
@@ -50,13 +51,13 @@ class OmnitableColumnList extends listColumnMixin(columnMixin(PolymerElement)) {
50
51
  active
51
52
  ></paper-spinner-lite>`
52
53
  : nothing;
53
-
54
54
  return html`<cosmoz-autocomplete-ui
55
55
  class="external-values-${column.externalValues}"
56
56
  .label=${column.title}
57
57
  .source=${source}
58
58
  .textProperty=${column.textProperty}
59
59
  .valueProperty=${column.valueProperty}
60
+ .itemRenderer=${column[columnSymbol]?.itemRenderer}
60
61
  .value=${filter}
61
62
  .text=${query}
62
63
  .onChange=${onChange(setState)}
@@ -1,23 +1,10 @@
1
1
  /* eslint-disable max-lines-per-function */
2
2
  import { useImperativeApi } from '@neovici/cosmoz-utils/hooks/use-imperative-api';
3
- import { useEffect } from 'haunted';
3
+ import { useEffect, useMemo } from 'haunted';
4
4
  import { useNotifyProperty } from '@neovici/cosmoz-utils/hooks/use-notify-property';
5
5
 
6
- export const usePublicInterface = ({ host, visibleData, ...api }) => {
7
- useImperativeApi(api, Object.values(api));
8
-
9
- const removeItems = (items) => {
10
- const removedItems = [];
11
-
12
- for (let i = items.length - 1; i >= 0; i -= 1) {
13
- const removed = host.removeItem(items[i]);
14
- if (removed != null) {
15
- removedItems.push(removed);
16
- }
17
- }
18
- return removedItems;
19
- },
20
- /**
6
+ const mkNapi = (host) => {
7
+ const /**
21
8
  * Helper method to remove an item from `data`.
22
9
  * @param {Object} item Item to remove
23
10
  * @return {Object} item removed
@@ -35,32 +22,61 @@ export const usePublicInterface = ({ host, visibleData, ...api }) => {
35
22
  return removed[0];
36
23
  }
37
24
  },
38
- replaceItem = (oldItem, newItem) => {
39
- const itemIndex = host.data.indexOf(oldItem);
40
- if (itemIndex > -1) {
41
- return host.replaceItemAtIndex(itemIndex, newItem);
42
- }
43
- },
44
25
  replaceItemAtIndex = (index, newItem) => {
45
26
  host.data.splice(index, 1, newItem);
46
27
  host.data = host.data.slice();
28
+ };
29
+
30
+ return {
31
+ removeItem,
32
+ removeItems(items) {
33
+ const removedItems = [];
34
+
35
+ for (let i = items.length - 1; i >= 0; i -= 1) {
36
+ const removed = host.removeItem(items[i]);
37
+ if (removed != null) {
38
+ removedItems.push(removed);
39
+ }
40
+ }
41
+ return removedItems;
47
42
  },
48
- selectItem = (item) => {
43
+
44
+ replaceItemAtIndex,
45
+ replaceItem(oldItem, newItem) {
46
+ const itemIndex = host.data.indexOf(oldItem);
47
+ if (itemIndex > -1) {
48
+ return replaceItemAtIndex(itemIndex, newItem);
49
+ }
50
+ },
51
+
52
+ selectItem(item) {
49
53
  host.shadowRoot.querySelector('#groupedList').select(item);
50
54
  },
51
- selectAll = () => {
55
+ selectAll() {
52
56
  host.shadowRoot.querySelector('#groupedList').selectAll();
53
57
  },
54
- deselectAll = () => {
58
+ deselectAll() {
55
59
  host.shadowRoot.querySelector('#groupedList').deselectAll();
56
60
  },
57
- deselectItem = (item) => {
61
+ deselectItem(item) {
58
62
  host.shadowRoot.querySelector('#groupedList').deselect(item);
59
63
  },
60
- isItemSelected = (item) => {
64
+ isItemSelected(item) {
61
65
  return host.shadowRoot.querySelector('#groupedList').isItemSelected(item);
62
66
  },
63
- { setFilterState } = api;
67
+ };
68
+ };
69
+
70
+ export const usePublicInterface = ({
71
+ host,
72
+ visibleData,
73
+ ...api
74
+ }) => {
75
+ const { setFilterState } = api,
76
+ napi = useMemo(() => mkNapi(host), []);
77
+
78
+ useImperativeApi(api, Object.values(api));
79
+ useImperativeApi(napi, Object.values(napi));
64
80
 
65
81
  useEffect(() => {
66
82
  const handler = (ev) =>
@@ -78,31 +94,6 @@ export const usePublicInterface = ({ host, visibleData, ...api }) => {
78
94
  api.sortedFilteredGroupedItems
79
95
  );
80
96
  useNotifyProperty('selectedItems', api.selectedItems);
81
- useNotifyProperty('sortOn', api.sortOn)
82
- useNotifyProperty('descending', api.descending)
83
-
84
- useImperativeApi(
85
- {
86
- removeItems,
87
- removeItem,
88
- replaceItem,
89
- replaceItemAtIndex,
90
- selectItem,
91
- selectAll,
92
- deselectItem,
93
- deselectAll,
94
- isItemSelected,
95
- },
96
- [
97
- removeItems,
98
- removeItem,
99
- replaceItem,
100
- replaceItemAtIndex,
101
- selectItem,
102
- selectAll,
103
- deselectItem,
104
- deselectAll,
105
- isItemSelected,
106
- ]
107
- );
97
+ useNotifyProperty('sortOn', api.sortOn);
98
+ useNotifyProperty('descending', api.descending);
108
99
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@neovici/cosmoz-omnitable",
3
- "version": "12.6.2",
3
+ "version": "12.7.0",
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"
@@ -96,8 +96,8 @@
96
96
  "@semantic-release/git": "^10.0.0",
97
97
  "@web/dev-server": "^0.1.10",
98
98
  "husky": "^8.0.0",
99
- "semantic-release": "^19.0.0",
100
- "sinon": "^14.0.0",
99
+ "semantic-release": "^20.0.0",
100
+ "sinon": "^15.0.0",
101
101
  "web-animations-js": "^2.3.0"
102
102
  }
103
103
  }