es-grid-template 1.8.40 → 1.8.42

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.
@@ -5,6 +5,16 @@ import TableHeadCell2 from "./TableHeadCell2";
5
5
  import TableHeadGroupCell from "./TableHeadGroupCell";
6
6
  // import { getCommonPinningStyles } from '../hook/utils'
7
7
 
8
+ // const getVisibleChildCount = <T,>(column: Column<T>): number => {
9
+ // if (!column.columns?.length) return 0;
10
+
11
+ // return column.columns.reduce((count: number, col: Column<T>) => {
12
+ // const selfCount = col.getIsVisible() ? 1 : 0;
13
+ // const childrenCount = getVisibleChildCount(col);
14
+ // return count + selfCount + (childrenCount ? childrenCount - 1 : childrenCount);
15
+ // }, 0);
16
+ // }
17
+
8
18
  const TableHead = ({
9
19
  columnVirtualizer,
10
20
  table
@@ -18,6 +28,7 @@ const TableHead = ({
18
28
  } = useContext(TableContext);
19
29
  const headerGroups = table.getFlatHeaders();
20
30
  const leafColumns = table.getVisibleFlatColumns();
31
+ // const leafColumns11 = table.getIsAllColumnsVisible();
21
32
  const headerDepth = table.getHeaderGroups().length;
22
33
  return /*#__PURE__*/React.createElement("div", {
23
34
  className: `${prefix}-grid-thead`,
@@ -32,10 +43,13 @@ const TableHead = ({
32
43
  }
33
44
  }, leafColumns.map(column => {
34
45
  const depth = column.depth ?? 0;
35
- // const colSpan = col.getLeafColumns().length || 1;
36
- const colSpan = column.columns.length || 1;
46
+
47
+ // const colSpan = column.columns.length || 1;
48
+ const colSpan = column.getFlatColumns().filter(col => col.getIsVisible() && col.columns.length < 2).length;
49
+ // const colSpan = getVisibleChildCount(column);
50
+
37
51
  const rowSpan = column.columns?.length > 0 ? 1 : headerDepth - depth;
38
- const header = headerGroups.find(it => it.id === column.id || it.column.id === column.id && it.subHeaders.length >= 2);
52
+ const header = headerGroups.find(it => it.id === column.id || it.column.id === column.id && it.subHeaders.length > 0);
39
53
  // const groupHeader = headerGroups.find((it) => it.column.id === column.id && it.subHeaders.length >= 2)
40
54
 
41
55
  if (header?.subHeaders && header.subHeaders.length >= 2) {
@@ -1680,13 +1680,30 @@ export const convertFilters = filters => {
1680
1680
  });
1681
1681
  return result;
1682
1682
  };
1683
+
1684
+ // export function getInvisibleColumns(columns: ColumnTable[]): Record<string, boolean> {
1685
+ // const result: Record<string, boolean> = {};
1686
+ // for (const col of columns) {
1687
+ // if (col.visible === false || col.hidden) {
1688
+ // result[col.field ?? ''] = false;
1689
+ // }
1690
+ // }
1691
+ // return result;
1692
+ // }
1693
+
1683
1694
  export function getInvisibleColumns(columns) {
1684
1695
  const result = {};
1685
- for (const col of columns) {
1686
- if (col.visible === false || col.hidden) {
1687
- result[col.field ?? ''] = false;
1696
+ function traverse(cols) {
1697
+ for (const col of cols) {
1698
+ if (col.visible === false) {
1699
+ result[col.field ?? ''] = false;
1700
+ }
1701
+ if (col.children && col.children.length > 0) {
1702
+ traverse(col.children);
1703
+ }
1688
1704
  }
1689
1705
  }
1706
+ traverse(columns);
1690
1707
  return result;
1691
1708
  }
1692
1709
  export const getAllVisibleKeys = columns => {
@@ -15,6 +15,16 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
15
15
 
16
16
  // import { getCommonPinningStyles } from '../hook/utils'
17
17
 
18
+ // const getVisibleChildCount = <T,>(column: Column<T>): number => {
19
+ // if (!column.columns?.length) return 0;
20
+
21
+ // return column.columns.reduce((count: number, col: Column<T>) => {
22
+ // const selfCount = col.getIsVisible() ? 1 : 0;
23
+ // const childrenCount = getVisibleChildCount(col);
24
+ // return count + selfCount + (childrenCount ? childrenCount - 1 : childrenCount);
25
+ // }, 0);
26
+ // }
27
+
18
28
  const TableHead = ({
19
29
  columnVirtualizer,
20
30
  table
@@ -28,6 +38,7 @@ const TableHead = ({
28
38
  } = (0, _react.useContext)(_useContext.TableContext);
29
39
  const headerGroups = table.getFlatHeaders();
30
40
  const leafColumns = table.getVisibleFlatColumns();
41
+ // const leafColumns11 = table.getIsAllColumnsVisible();
31
42
  const headerDepth = table.getHeaderGroups().length;
32
43
  return /*#__PURE__*/_react.default.createElement("div", {
33
44
  className: `${prefix}-grid-thead`,
@@ -42,10 +53,13 @@ const TableHead = ({
42
53
  }
43
54
  }, leafColumns.map(column => {
44
55
  const depth = column.depth ?? 0;
45
- // const colSpan = col.getLeafColumns().length || 1;
46
- const colSpan = column.columns.length || 1;
56
+
57
+ // const colSpan = column.columns.length || 1;
58
+ const colSpan = column.getFlatColumns().filter(col => col.getIsVisible() && col.columns.length < 2).length;
59
+ // const colSpan = getVisibleChildCount(column);
60
+
47
61
  const rowSpan = column.columns?.length > 0 ? 1 : headerDepth - depth;
48
- const header = headerGroups.find(it => it.id === column.id || it.column.id === column.id && it.subHeaders.length >= 2);
62
+ const header = headerGroups.find(it => it.id === column.id || it.column.id === column.id && it.subHeaders.length > 0);
49
63
  // const groupHeader = headerGroups.find((it) => it.column.id === column.id && it.subHeaders.length >= 2)
50
64
 
51
65
  if (header?.subHeaders && header.subHeaders.length >= 2) {
@@ -1793,14 +1793,30 @@ const convertFilters = filters => {
1793
1793
  });
1794
1794
  return result;
1795
1795
  };
1796
+
1797
+ // export function getInvisibleColumns(columns: ColumnTable[]): Record<string, boolean> {
1798
+ // const result: Record<string, boolean> = {};
1799
+ // for (const col of columns) {
1800
+ // if (col.visible === false || col.hidden) {
1801
+ // result[col.field ?? ''] = false;
1802
+ // }
1803
+ // }
1804
+ // return result;
1805
+ // }
1796
1806
  exports.convertFilters = convertFilters;
1797
1807
  function getInvisibleColumns(columns) {
1798
1808
  const result = {};
1799
- for (const col of columns) {
1800
- if (col.visible === false || col.hidden) {
1801
- result[col.field ?? ''] = false;
1809
+ function traverse(cols) {
1810
+ for (const col of cols) {
1811
+ if (col.visible === false) {
1812
+ result[col.field ?? ''] = false;
1813
+ }
1814
+ if (col.children && col.children.length > 0) {
1815
+ traverse(col.children);
1816
+ }
1802
1817
  }
1803
1818
  }
1819
+ traverse(columns);
1804
1820
  return result;
1805
1821
  }
1806
1822
  const getAllVisibleKeys = columns => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "es-grid-template",
3
- "version": "1.8.40",
3
+ "version": "1.8.42",
4
4
  "description": "es-grid-template",
5
5
  "keywords": [
6
6
  "react",