@neovici/cosmoz-omnitable 13.1.0 → 13.2.1

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.
@@ -127,7 +127,6 @@ class OmnitableColumnListData extends translatable(mixin(Template, PolymerElemen
127
127
  this._expanded = !this._expanded;
128
128
  event.stopPropagation();
129
129
  event.preventDefault();
130
- this.dispatchEvent(new CustomEvent('expand', { bubbles: true }));
131
130
  }
132
131
  }
133
132
 
@@ -14,7 +14,6 @@ import {
14
14
  onText,
15
15
  } from './cosmoz-omnitable-column-list-mixin';
16
16
  import '@neovici/cosmoz-autocomplete';
17
- import { notifyResize } from './lib/utils';
18
17
  import { columnSymbol } from './lib/use-dom-columns';
19
18
 
20
19
  /**
@@ -41,10 +40,9 @@ class OmnitableColumnList extends listColumnMixin(columnMixin(PolymerElement)) {
41
40
  };
42
41
  }
43
42
 
44
- renderCell({ valuePath, textProperty }, { item, index }) {
43
+ renderCell({ valuePath, textProperty }, { item }) {
45
44
  return html`<cosmoz-omnitable-column-list-data
46
45
  .items=${getTexts(item, valuePath, textProperty)}
47
- @expand=${(event) => notifyResize(event.target, index)}
48
46
  ></cosmoz-omnitable-column-list-data>`;
49
47
  }
50
48
 
@@ -2,7 +2,6 @@
2
2
  import { component, useEffect } from '@pionjs/pion';
3
3
  import { html, nothing } from 'lit-html';
4
4
  import './cosmoz-omnitable-item-expand-line';
5
- import { notifyResize } from './lib/utils';
6
5
 
7
6
  const renderExpandList = ({
8
7
  columns,
@@ -24,7 +23,7 @@ const renderExpandList = ({
24
23
  >`
25
24
  ),
26
25
  ExpandList = (host) => {
27
- const { expanded, index, columns } = host;
26
+ const { columns } = host;
28
27
 
29
28
  useEffect(() => {
30
29
  if (columns?.length > 0) {
@@ -35,11 +34,6 @@ const renderExpandList = ({
35
34
  return () => host.removeAttribute('hidden');
36
35
  }, [columns?.length]);
37
36
 
38
- useEffect(
39
- () => expanded && requestAnimationFrame(() => notifyResize(host, index)),
40
- [expanded]
41
- );
42
-
43
37
  return Array.isArray(columns) && columns.length > 0 && host.expanded
44
38
  ? renderExpandList(host)
45
39
  : nothing;
@@ -36,7 +36,6 @@ const Omnitable = (host) => {
36
36
  <style>
37
37
  ${guard([], () => shimCSS(styles))}
38
38
  </style>
39
- <div id="layoutStyle"></div>
40
39
 
41
40
  <div class="mainContainer">
42
41
  ${renderHeader(header)}
@@ -1,20 +1,19 @@
1
- import { html } from '@pionjs/pion';
2
1
  import { layout } from './layout';
3
2
 
4
- const
5
- _toCss = (layout, config) =>
6
- config
7
- .map((item, index) => {
8
- const width = layout[index];
9
- return width == null || width === 0
10
- ? `cosmoz-omnitable-resize-nub[name="${ item.name }"], .cell[name="${ item.name }"]{display:none}`
11
- : `.cell[name="${ item.name }"]{width: ${ width }px;padding: 0 min(3px, ${ width / 2 }px)}`;
12
- })
13
- .join('\n');
3
+ const _toCss = (layout, config) =>
4
+ config
5
+ .map((item, index) => {
6
+ const width = layout[index];
7
+ return width == null || width === 0
8
+ ? `cosmoz-omnitable-resize-nub[name="${item.name}"], .cell[name="${item.name}"]{display:none}`
9
+ : `.cell[name="${item.name}"]{width: ${Math.floor(
10
+ width,
11
+ )}px;padding: 0 min(3px, ${width / 2}px)}`;
12
+ })
13
+ .join('\n');
14
14
 
15
- export const
16
- computeLayout = (_columnConfigs, canvasWidth, numColumns) => {
17
- const columnConfigs = _columnConfigs.filter(c => !c.hidden),
15
+ export const computeLayout = (_columnConfigs, canvasWidth, numColumns) => {
16
+ const columnConfigs = _columnConfigs.filter((c) => !c.hidden),
18
17
  totalWidths = columnConfigs.reduce((sum, { width }) => sum + width, 0);
19
18
 
20
19
  if (columnConfigs.length > 1 && totalWidths > canvasWidth) {
@@ -26,8 +25,11 @@ export const
26
25
  // as the column configs might now be in a different order than displayed
27
26
  // due to priority settings
28
27
  const lastColumnIndex = columnConfigs.reduce(
29
- ([max, maxIndex], column, index) => [Math.max(max, column.index), column.index > max ? index : maxIndex],
30
- [-1, -1]
28
+ ([max, maxIndex], column, index) => [
29
+ Math.max(max, column.index),
30
+ column.index > max ? index : maxIndex,
31
+ ],
32
+ [-1, -1],
31
33
  )[1];
32
34
 
33
35
  // force the last visible column to flex
@@ -43,6 +45,4 @@ export const
43
45
  }, new Array(numColumns).fill(undefined));
44
46
  },
45
47
  toCss = (layout, config) =>
46
- layout.length === 0
47
- ? html`<style>.cell {display: none;}</style>`
48
- : html`<style>${ _toCss(layout, config) }</style>`;
48
+ layout.length === 0 ? '.cell {display: none;}' : _toCss(layout, config);
@@ -1,10 +1,10 @@
1
- import { useLayoutEffect, useMemo } from '@pionjs/pion';
1
+ import { useMemo } from '@pionjs/pion';
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
- import { render } from 'lit-html';
7
+ import { useStyleSheet } from '@neovici/cosmoz-utils/hooks/use-stylesheet';
8
8
 
9
9
  export const useFastLayout = ({
10
10
  host,
@@ -24,7 +24,7 @@ export const useFastLayout = ({
24
24
  tweenedlayout = useTweenArray(layout, resizeSpeedFactor),
25
25
  layoutCss = useMemo(
26
26
  () => toCss(tweenedlayout, settings.columns),
27
- [tweenedlayout]
27
+ [tweenedlayout],
28
28
  ),
29
29
  collapsedColumns = useMemo(
30
30
  () =>
@@ -35,9 +35,9 @@ export const useFastLayout = ({
35
35
  column.disabled
36
36
  ? acc
37
37
  : [...acc, columns.find((c) => c.name === column.name)],
38
- []
38
+ [],
39
39
  ),
40
- [columns, settings, layout]
40
+ [columns, settings, layout],
41
41
  );
42
42
 
43
43
  useResizableColumns({
@@ -47,10 +47,7 @@ export const useFastLayout = ({
47
47
  setSettings: (update) => setSettings(update(settings)),
48
48
  });
49
49
 
50
- useLayoutEffect(
51
- () => render(layoutCss, host.shadowRoot.querySelector('#layoutStyle')),
52
- [layoutCss]
53
- );
50
+ useStyleSheet(layoutCss);
54
51
 
55
52
  return { collapsedColumns };
56
53
  };
package/lib/use-list.js CHANGED
@@ -165,11 +165,6 @@ export const useList = ({
165
165
  );
166
166
  }, []);
167
167
 
168
- useEffect(() => {
169
- host.shadowRoot.querySelector('#groupedList').scrollTarget =
170
- host.shadowRoot.querySelector('#scroller');
171
- }, []);
172
-
173
168
  const { groupOnColumn } = sortAndGroupOptions,
174
169
  onItemChange = useCallback(
175
170
  (column, item) => (value) => _onItemChange(host, column, item, value),
package/lib/utils.js CHANGED
@@ -1,10 +1,3 @@
1
- const notifyResize = (target, index) =>
2
- target.dispatchEvent(
3
- new CustomEvent('update-item-size', {
4
- bubbles: true,
5
- detail: { index },
6
- })
7
- ),
8
- indexSymbol = Symbol('index');
1
+ const indexSymbol = Symbol('index');
9
2
 
10
- export { notifyResize, indexSymbol };
3
+ export { indexSymbol };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@neovici/cosmoz-omnitable",
3
- "version": "13.1.0",
3
+ "version": "13.2.1",
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"
@@ -64,11 +64,11 @@
64
64
  "@neovici/cosmoz-collapse": "^1.1.0",
65
65
  "@neovici/cosmoz-datetime-input": "^4.0.0",
66
66
  "@neovici/cosmoz-dropdown": "^4.0.0",
67
- "@neovici/cosmoz-grouped-list": "^7.0.0",
67
+ "@neovici/cosmoz-grouped-list": "^8.0.0",
68
68
  "@neovici/cosmoz-i18next": "^3.1.1",
69
69
  "@neovici/cosmoz-input": "^4.0.0",
70
70
  "@neovici/cosmoz-router": "^11.0.0",
71
- "@neovici/cosmoz-utils": "^6.0.0",
71
+ "@neovici/cosmoz-utils": "^6.5.0",
72
72
  "@neovici/nullxlsx": "^3.0.0",
73
73
  "@pionjs/pion": "^2.0.0",
74
74
  "@polymer/iron-icon": "^3.0.0",