@neovici/cosmoz-omnitable 8.0.0-beta.3 → 8.0.0-beta.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.
@@ -23,7 +23,7 @@ import styles from './cosmoz-omnitable-styles';
23
23
 
24
24
  import { PolymerElement } from '@polymer/polymer/polymer-element';
25
25
  import { html } from '@polymer/polymer/lib/utils/html-tag';
26
- import { html as litHtml, render } from 'lit-html';
26
+ import { html as litHtml } from 'lit-html';
27
27
 
28
28
  import { translatable } from '@neovici/cosmoz-i18next';
29
29
  import { mixin, hauntedPolymer } from '@neovici/cosmoz-utils';
@@ -275,8 +275,7 @@ class Omnitable extends hauntedPolymer(useOmnitable)(mixin({ isEmpty }, translat
275
275
 
276
276
  static get observers() {
277
277
  return [
278
- '_selectedItemsChanged(selectedItems.*)',
279
- 'renderFastLayoutCss(layoutCss, $.layoutStyle)'
278
+ '_selectedItemsChanged(selectedItems.*)'
280
279
  ];
281
280
  }
282
281
 
@@ -516,10 +515,6 @@ class Omnitable extends hauntedPolymer(useOmnitable)(mixin({ isEmpty }, translat
516
515
  return this.ngettext('{0} row', '{0} rows', numRows);
517
516
  }
518
517
 
519
- renderFastLayoutCss(layoutCss, outlet) {
520
- render(layoutCss, outlet);
521
- }
522
-
523
518
  _onCompleteValues(columns, type, value) { /* eslint-disable-next-line no-bitwise */
524
519
  return columns?.filter?.(c => c[type]).sort((a, b) => ((b === value) >> 0) - ((a === value) >> 0));
525
520
  }
@@ -1,10 +1,11 @@
1
- import { useMemo } from 'haunted';
1
+ import { useEffect, useLayoutEffect, useMemo } from 'haunted';
2
2
  import { toCss } from './compute-layout';
3
3
  import { useResizableColumns } from './use-resizable-columns';
4
4
  import { useCanvasWidth } from './use-canvas-width';
5
5
  import { useTweenArray } from './use-tween-array';
6
6
  import { useLayout } from './use-layout';
7
7
  import { columnSymbol } from './normalize-settings';
8
+ import { render } from 'lit-html';
8
9
 
9
10
  export const useFastLayout = ({ host, settings, setSettings, groupOnColumn, resizeSpeedFactor }) => {
10
11
  const
@@ -26,8 +27,26 @@ export const useFastLayout = ({ host, settings, setSettings, groupOnColumn, resi
26
27
 
27
28
  useResizableColumns({ host, canvasWidth, layout, setSettings: update => setSettings(update(settings)) });
28
29
 
30
+ useLayoutEffect(() => render(layoutCss, host.$.layoutStyle), [layoutCss]);
31
+
32
+ // force iron-list to render when the omnitable becomes visible
33
+ useEffect(() => {
34
+ let lastWidth = 0;
35
+
36
+ const
37
+ onResize = ([entry]) => {
38
+ if (lastWidth === 0) {
39
+ requestAnimationFrame(() => host.$.groupedList.$.list._render());
40
+ }
41
+ lastWidth = entry.contentRect?.width;
42
+ },
43
+ observer = new ResizeObserver(onResize);
44
+
45
+ observer.observe(host);
46
+ return () => observer.unobserve(host);
47
+ }, []);
48
+
29
49
  return {
30
- layoutCss,
31
50
  collapsedColumns
32
51
  };
33
52
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@neovici/cosmoz-omnitable",
3
- "version": "8.0.0-beta.3",
3
+ "version": "8.0.0-beta.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"