@neovici/cosmoz-omnitable 8.2.3 → 8.2.4

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.
@@ -27,6 +27,7 @@ export const
27
27
  title: { type: String },
28
28
  valuePath: { type: String, notify: true },
29
29
  values: { type: Array, notify: true },
30
+ filter: { type: Object },
30
31
  /**
31
32
  * If the column should be disabled until enabled with enabledColumns
32
33
  */
@@ -61,6 +62,21 @@ export const
61
62
  };
62
63
  }
63
64
 
65
+ static get observers() {
66
+ return ['notifyFilterChange(filter)'];
67
+ }
68
+
69
+ notifyFilterChange(filter) {
70
+ if (this.__ownChange) {
71
+ return;
72
+ }
73
+ this.dispatchEvent(new CustomEvent('legacy-filter-changed', { detail: { name: this.name, state: this.legacyFilterToState(filter) }, bubbles: true }));
74
+ }
75
+
76
+ legacyFilterToState(filter) {
77
+ return { filter };
78
+ }
79
+
64
80
  /**
65
81
  * Override this in column elements if you need a different default width
66
82
  */
@@ -75,5 +75,9 @@ class OmnitableColumn extends columnMixin(PolymerElement) {
75
75
  <cosmoz-clear-button suffix slot="suffix" ?visible=${ hasFilter(filter) } light @click=${ resetFilter(setState) }></cosmoz-clear-button>
76
76
  </paper-input>`;
77
77
  }
78
+
79
+ legacyFilterToState(filter) {
80
+ return { filter, inputValue: filter };
81
+ }
78
82
  }
79
83
  customElements.define('cosmoz-omnitable-column', OmnitableColumn);
@@ -1,4 +1,4 @@
1
- import { useCallback, useMemo, useState } from 'haunted';
1
+ import { useCallback, useMemo, useState, useEffect } from 'haunted';
2
2
  import { normalizeSettings } from './normalize-settings';
3
3
  import { useProcessedItems } from './use-processed-items';
4
4
  import { useFastLayout } from './use-fast-layout';
@@ -74,6 +74,12 @@ export const useOmnitable = host => {
74
74
  [filterFunctions, normalizedSettings, collapsedColumns]
75
75
  );
76
76
 
77
+ useEffect(() => {
78
+ const handler = ev => setFilterState(ev.detail.name, state => ({ ...state, ...ev.detail.state }));
79
+ host.addEventListener('legacy-filter-changed', handler);
80
+ return () => host.removeEventListener('legacy-filter-changed', handler);
81
+ }, []);
82
+
77
83
  return {
78
84
  columns,
79
85
 
@@ -13,7 +13,9 @@ const
13
13
  }
14
14
 
15
15
  Object.entries(changes).forEach(([key, value]) => {
16
+ column[columnSymbol].__ownChange = true;
16
17
  column[columnSymbol][key] = value;
18
+ column[columnSymbol].__ownChange = false;
17
19
  column[columnSymbol].dispatchEvent(new CustomEvent(`${ kebab(key) }-changed`, { bubbles: true, detail: { value }}));
18
20
  });
19
21
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@neovici/cosmoz-omnitable",
3
- "version": "8.2.3",
3
+ "version": "8.2.4",
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"