es-grid-template 1.7.48 → 1.8.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.
- package/es/grid-component/TempTable.js +1 -3
- package/es/table-component/ColumnsChoose.js +9 -2
- package/es/table-component/InternalTable.js +1 -0
- package/es/table-component/TableContainer.d.ts +5 -1
- package/es/table-component/TableContainer.js +33 -3
- package/es/table-component/TableContainerEdit.js +87 -62
- package/es/table-component/body/TableBody.js +1 -1
- package/es/table-component/body/TableBodyCell.d.ts +7 -3
- package/es/table-component/body/TableBodyCell.js +268 -135
- package/es/table-component/body/TableBodyCellEdit.d.ts +2 -2
- package/es/table-component/body/TableBodyCellEdit.js +18 -13
- package/es/table-component/body/TableBodyRow.d.ts +2 -2
- package/es/table-component/body/TableBodyRow.js +45 -16
- package/es/table-component/components/command/Command.js +2 -0
- package/es/table-component/footer/TableFooter.js +1 -1
- package/es/table-component/footer/TableFooterCell.js +3 -2
- package/es/table-component/footer/TableFooterRow.js +4 -3
- package/es/table-component/header/TableHead.d.ts +1 -1
- package/es/table-component/header/TableHead.js +83 -20
- package/es/table-component/header/TableHeadCell.js +13 -8
- package/es/table-component/header/TableHeadCell2.d.ts +17 -0
- package/es/table-component/header/TableHeadCell2.js +331 -0
- package/es/table-component/header/TableHeadGroupCell.d.ts +17 -0
- package/es/table-component/header/TableHeadGroupCell.js +327 -0
- package/es/table-component/header/TableHeadRow.js +1 -1
- package/es/table-component/hook/utils.js +5 -2
- package/es/table-component/style.scss +26 -4
- package/es/table-component/table/Grid.js +19 -19
- package/es/table-component/table/TableWrapper.js +1 -1
- package/lib/grid-component/TempTable.js +1 -3
- package/lib/table-component/ColumnsChoose.js +9 -2
- package/lib/table-component/InternalTable.js +1 -0
- package/lib/table-component/TableContainer.d.ts +5 -1
- package/lib/table-component/TableContainer.js +32 -2
- package/lib/table-component/TableContainerEdit.js +87 -62
- package/lib/table-component/body/TableBody.js +1 -1
- package/lib/table-component/body/TableBodyCell.d.ts +7 -3
- package/lib/table-component/body/TableBodyCell.js +267 -136
- package/lib/table-component/body/TableBodyCellEdit.d.ts +2 -2
- package/lib/table-component/body/TableBodyCellEdit.js +18 -13
- package/lib/table-component/body/TableBodyRow.d.ts +2 -2
- package/lib/table-component/body/TableBodyRow.js +45 -16
- package/lib/table-component/components/command/Command.js +2 -0
- package/lib/table-component/footer/TableFooter.js +1 -1
- package/lib/table-component/footer/TableFooterCell.js +3 -2
- package/lib/table-component/footer/TableFooterRow.js +4 -3
- package/lib/table-component/header/TableHead.d.ts +1 -1
- package/lib/table-component/header/TableHead.js +84 -20
- package/lib/table-component/header/TableHeadCell.js +13 -8
- package/lib/table-component/header/TableHeadCell2.d.ts +17 -0
- package/lib/table-component/header/TableHeadCell2.js +340 -0
- package/lib/table-component/header/TableHeadGroupCell.d.ts +17 -0
- package/lib/table-component/header/TableHeadGroupCell.js +336 -0
- package/lib/table-component/header/TableHeadRow.js +1 -1
- package/lib/table-component/hook/utils.js +5 -2
- package/lib/table-component/style.scss +26 -4
- package/lib/table-component/table/Grid.js +19 -19
- package/lib/table-component/table/TableWrapper.js +1 -1
- package/package.json +1 -1
|
@@ -4,18 +4,16 @@ import Table from "../table-component";
|
|
|
4
4
|
import InternalTable from "./InternalTable";
|
|
5
5
|
const TempTable = props => {
|
|
6
6
|
const {
|
|
7
|
-
infiniteScroll,
|
|
8
7
|
groupAble,
|
|
9
8
|
editAble,
|
|
10
9
|
...rest
|
|
11
10
|
} = props;
|
|
12
11
|
|
|
13
12
|
// const TabComponent = groupAble ? InternalTable : Table
|
|
14
|
-
const TabComponent =
|
|
13
|
+
const TabComponent = groupAble ? InternalTable : Table;
|
|
15
14
|
// const TabComponent = InternalTable
|
|
16
15
|
|
|
17
16
|
return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement(TabComponent, _extends({}, rest, {
|
|
18
|
-
infiniteScroll: infiniteScroll,
|
|
19
17
|
groupAble: groupAble,
|
|
20
18
|
editAble: editAble
|
|
21
19
|
})));
|
|
@@ -2,10 +2,12 @@ import useMergedState from "rc-util/es/hooks/useMergedState";
|
|
|
2
2
|
import React, { Fragment, useState } from "react";
|
|
3
3
|
import styled from "styled-components";
|
|
4
4
|
import { Button, Input, Popover, Tooltip } from "antd";
|
|
5
|
-
import { SettingOutlined } from "@ant-design/icons"
|
|
5
|
+
// import { SettingOutlined } from "@ant-design/icons"
|
|
6
|
+
|
|
6
7
|
import Tree from "rc-master-ui/es/tree";
|
|
7
8
|
import SearchOutlined from "@ant-design/icons/SearchOutlined";
|
|
8
9
|
import { convertColumnsToTreeData, getVisibleColumnKeys1, updateColumns1 } from "./hook/utils";
|
|
10
|
+
import { Settings } from "becoxy-icons";
|
|
9
11
|
const BoxAction = styled.div.withConfig({
|
|
10
12
|
displayName: "BoxAction",
|
|
11
13
|
componentId: "es-grid-template__sc-jfujqh-0"
|
|
@@ -202,5 +204,10 @@ export const ColumnsChoose = props => {
|
|
|
202
204
|
}, /*#__PURE__*/React.createElement(Tooltip, {
|
|
203
205
|
arrow: false,
|
|
204
206
|
title: 'Cài đặt'
|
|
205
|
-
}, /*#__PURE__*/React.createElement(
|
|
207
|
+
}, /*#__PURE__*/React.createElement(Settings, {
|
|
208
|
+
fontSize: 16,
|
|
209
|
+
style: {
|
|
210
|
+
cursor: 'pointer'
|
|
211
|
+
}
|
|
212
|
+
}))));
|
|
206
213
|
};
|
|
@@ -104,6 +104,7 @@ const InternalTable = props => {
|
|
|
104
104
|
const [columns, setColumns] = React.useState([]);
|
|
105
105
|
React.useEffect(() => {
|
|
106
106
|
// setColumns(propsColumns as any)
|
|
107
|
+
|
|
107
108
|
setColumns(updateWidthsByOther(propsColumns, columns));
|
|
108
109
|
}, [propsColumns]);
|
|
109
110
|
const [expanded, setExpanded] = React.useState({});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Dispatch, SetStateAction } from 'react';
|
|
2
2
|
import React from 'react';
|
|
3
|
-
import type { ColumnDef, Table } from '@tanstack/react-table';
|
|
3
|
+
import type { ColumnDef, ColumnSizingInfoState, ColumnSizingState, Table } from '@tanstack/react-table';
|
|
4
4
|
import type { ColumnsTable, TableProps } from './type';
|
|
5
5
|
type TableContainerProps<T> = Omit<TableProps<T>, 'columns'> & {
|
|
6
6
|
table: Table<T>;
|
|
@@ -32,6 +32,10 @@ type TableContainerProps<T> = Omit<TableProps<T>, 'columns'> & {
|
|
|
32
32
|
isFullScreen: boolean;
|
|
33
33
|
setIsFullScreen: Dispatch<SetStateAction<boolean>>;
|
|
34
34
|
isDataTree: boolean;
|
|
35
|
+
setColumnSizing: Dispatch<SetStateAction<any>>;
|
|
36
|
+
setColumns: Dispatch<SetStateAction<any>>;
|
|
37
|
+
columnSizingInfo: ColumnSizingInfoState;
|
|
38
|
+
columnSizing: ColumnSizingState;
|
|
35
39
|
};
|
|
36
40
|
declare const TableContainer: <RecordType extends object>(props: TableContainerProps<RecordType>) => React.JSX.Element;
|
|
37
41
|
export default TableContainer;
|
|
@@ -19,7 +19,7 @@ import { ColumnsChoose } from "./ColumnsChoose";
|
|
|
19
19
|
import { numericFormatter } from 'react-numeric-component';
|
|
20
20
|
// import ComponentSpinner from '../grid-component/LoadingSpinner'
|
|
21
21
|
import TableWrapper from "./table/TableWrapper";
|
|
22
|
-
import { sumSize } from "./hook/utils";
|
|
22
|
+
import { sumSize, updateColumnWidthsRecursive } from "./hook/utils";
|
|
23
23
|
import { useVirtualizer } from '@tanstack/react-virtual';
|
|
24
24
|
const TableContainer = props => {
|
|
25
25
|
const {
|
|
@@ -70,13 +70,17 @@ const TableContainer = props => {
|
|
|
70
70
|
contextMenuHidden,
|
|
71
71
|
isFullScreen,
|
|
72
72
|
setIsFullScreen,
|
|
73
|
-
isDataTree
|
|
73
|
+
isDataTree,
|
|
74
|
+
setColumns,
|
|
75
|
+
columnSizing,
|
|
76
|
+
columnSizingInfo
|
|
74
77
|
} = props;
|
|
75
78
|
const tableContainerRef = React.useRef(null);
|
|
76
79
|
const containerRef = React.useRef(null);
|
|
77
80
|
const bottomToolbarRef = React.useRef(null);
|
|
78
81
|
const topToolbarRef = React.useRef(null);
|
|
79
82
|
const [tableHeight, settableHeight] = React.useState(0);
|
|
83
|
+
const [focusedCell, setFocusedCell] = React.useState(undefined);
|
|
80
84
|
React.useEffect(() => {
|
|
81
85
|
const totalHeight = minHeight ?? height;
|
|
82
86
|
if (totalHeight) {
|
|
@@ -129,6 +133,30 @@ const TableContainer = props => {
|
|
|
129
133
|
columnVirtualizer.measure();
|
|
130
134
|
});
|
|
131
135
|
}, [columnSizingState, columnVirtualizer]);
|
|
136
|
+
React.useEffect(() => {
|
|
137
|
+
if (!tableContainerRef.current) {
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
// const containerWidth = tableContainerRef.current.offsetWidth
|
|
142
|
+
// const totalWidth = table.getTotalSize()
|
|
143
|
+
|
|
144
|
+
// if (totalWidth && totalWidth <= containerWidth) {
|
|
145
|
+
|
|
146
|
+
// return
|
|
147
|
+
|
|
148
|
+
// }
|
|
149
|
+
|
|
150
|
+
if (columnSizingInfo.isResizingColumn === false) {
|
|
151
|
+
const aa = updateColumnWidthsRecursive(propsColumns, columnSizing);
|
|
152
|
+
setColumns(aa);
|
|
153
|
+
|
|
154
|
+
// requestAnimationFrame(() => {
|
|
155
|
+
|
|
156
|
+
// columnVirtualizer.measure()
|
|
157
|
+
// })
|
|
158
|
+
}
|
|
159
|
+
}, [columnSizingInfo]);
|
|
132
160
|
const triggerCommandClick = () => {};
|
|
133
161
|
return /*#__PURE__*/React.createElement("div", {
|
|
134
162
|
ref: containerRef,
|
|
@@ -209,7 +237,9 @@ const TableContainer = props => {
|
|
|
209
237
|
setSorterChange,
|
|
210
238
|
setFilterChange,
|
|
211
239
|
windowSize,
|
|
212
|
-
isDataTree
|
|
240
|
+
isDataTree,
|
|
241
|
+
focusedCell,
|
|
242
|
+
setFocusedCell
|
|
213
243
|
}
|
|
214
244
|
}, /*#__PURE__*/React.createElement(TableWrapper, {
|
|
215
245
|
contextMenuItems: contextMenuItems,
|
|
@@ -667,80 +667,105 @@ const TableContainerEdit = props => {
|
|
|
667
667
|
}, [dataSource, editingKey, id, onBlur]);
|
|
668
668
|
const columnSizingState = table.getState().columnSizing;
|
|
669
669
|
React.useEffect(() => {
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
// columnVirtualizer.measure()
|
|
674
|
-
// })
|
|
670
|
+
requestAnimationFrame(() => {
|
|
671
|
+
columnVirtualizer.measure();
|
|
672
|
+
});
|
|
675
673
|
}, [columnSizingState, columnVirtualizer]);
|
|
676
674
|
React.useEffect(() => {
|
|
677
675
|
if (!tableContainerRef.current) {
|
|
678
676
|
return;
|
|
679
677
|
}
|
|
680
|
-
|
|
681
|
-
const
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
678
|
+
|
|
679
|
+
// const containerWidth = tableContainerRef.current.offsetWidth
|
|
680
|
+
// const totalWidth = table.getTotalSize()
|
|
681
|
+
|
|
682
|
+
// if (totalWidth && totalWidth <= containerWidth) {
|
|
683
|
+
|
|
684
|
+
// return
|
|
685
|
+
|
|
686
|
+
// }
|
|
687
|
+
|
|
685
688
|
if (columnSizingInfo.isResizingColumn === false) {
|
|
686
689
|
const aa = updateColumnWidthsRecursive(propsColumns, columnSizing);
|
|
687
690
|
setColumns(aa);
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
+
|
|
692
|
+
// requestAnimationFrame(() => {
|
|
693
|
+
|
|
694
|
+
// columnVirtualizer.measure()
|
|
695
|
+
// })
|
|
691
696
|
}
|
|
692
697
|
}, [columnSizingInfo]);
|
|
693
|
-
React.useEffect(() => {
|
|
694
|
-
// if (!containerRef.current || !tableContainerRef.current) {
|
|
695
|
-
if (!tableContainerRef.current) {
|
|
696
|
-
return;
|
|
697
|
-
}
|
|
698
698
|
|
|
699
|
-
|
|
700
|
-
// const containerWidth = tableContainerRef.current.offsetWidth
|
|
701
|
-
const containerWidth = tableContainerRef.current.offsetWidth - (tableContainerRef.current.scrollHeight > tableContainerRef.current.offsetHeight ? 15 : 0);
|
|
702
|
-
const totalWidth = table.getTotalSize() - (tableContainerRef.current.scrollHeight > tableContainerRef.current.offsetHeight ? 15 : 0);
|
|
703
|
-
if (totalWidth && totalWidth > 0 && totalWidth < containerWidth) {
|
|
704
|
-
const factor = containerWidth / totalWidth;
|
|
705
|
-
const visibleCols = table.getVisibleLeafColumns();
|
|
706
|
-
const baseSizes = visibleCols.map(col => col.getSize() || col.columnDef.size || 150);
|
|
707
|
-
const scaledSizes = baseSizes.map(size => size * factor);
|
|
708
|
-
const roundedSizes = scaledSizes.map(size => Math.floor(size));
|
|
709
|
-
let diff = containerWidth - roundedSizes.reduce((a, b) => a + b, 0);
|
|
710
|
-
|
|
711
|
-
// phân bổ diff cho các cột từ trái qua phải
|
|
712
|
-
for (let i = 0; diff > 0; i = (i + 1) % roundedSizes.length) {
|
|
713
|
-
roundedSizes[i]++;
|
|
714
|
-
diff--;
|
|
715
|
-
}
|
|
716
|
-
const aaa = visibleCols.reduce((acc, col, idx) => {
|
|
717
|
-
acc[col.id] = roundedSizes[idx];
|
|
718
|
-
return acc;
|
|
719
|
-
}, {});
|
|
720
|
-
const aa = updateColumnWidthsRecursive(propsColumns, aaa);
|
|
721
|
-
setColumns(aa);
|
|
722
|
-
table.setColumnSizing(aaa);
|
|
723
|
-
requestAnimationFrame(() => {
|
|
724
|
-
columnVirtualizer.measure();
|
|
725
|
-
});
|
|
699
|
+
// React.useEffect(() => {
|
|
726
700
|
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
701
|
+
// // if (!containerRef.current || !tableContainerRef.current) {
|
|
702
|
+
// if (!tableContainerRef.current) {
|
|
703
|
+
// return
|
|
704
|
+
// }
|
|
705
|
+
|
|
706
|
+
// // const containerWidth = containerRef.current.offsetWidth - 1
|
|
707
|
+
// // const containerWidth = tableContainerRef.current.offsetWidth
|
|
708
|
+
// const containerWidth = tableContainerRef.current.offsetWidth - (tableContainerRef.current.scrollHeight > tableContainerRef.current.offsetHeight ? 15 : 0)
|
|
709
|
+
|
|
710
|
+
// const totalWidth = table.getTotalSize() - (tableContainerRef.current.scrollHeight > tableContainerRef.current.offsetHeight ? 15 : 0)
|
|
711
|
+
|
|
712
|
+
// if (totalWidth && totalWidth > 0 && totalWidth < containerWidth) {
|
|
713
|
+
|
|
714
|
+
// const factor = containerWidth / totalWidth
|
|
715
|
+
|
|
716
|
+
// const visibleCols = table.getVisibleLeafColumns()
|
|
717
|
+
|
|
718
|
+
// const baseSizes = visibleCols.map(
|
|
719
|
+
// (col) => col.getSize() || col.columnDef.size || 150
|
|
720
|
+
// )
|
|
721
|
+
|
|
722
|
+
// const scaledSizes = baseSizes.map((size) => size * factor)
|
|
723
|
+
// const roundedSizes = scaledSizes.map((size) => Math.floor(size))
|
|
724
|
+
|
|
725
|
+
// let diff = containerWidth - roundedSizes.reduce((a, b) => a + b, 0)
|
|
726
|
+
|
|
727
|
+
// // phân bổ diff cho các cột từ trái qua phải
|
|
728
|
+
// for (let i = 0; diff > 0; i = (i + 1) % roundedSizes.length) {
|
|
729
|
+
// roundedSizes[i]++
|
|
730
|
+
// diff--
|
|
731
|
+
// }
|
|
732
|
+
|
|
733
|
+
// const aaa = visibleCols.reduce((acc, col, idx) => {
|
|
734
|
+
// acc[col.id] = roundedSizes[idx]
|
|
735
|
+
// return acc
|
|
736
|
+
// }, {} as Record<string, number>)
|
|
737
|
+
|
|
738
|
+
// const aa = updateColumnWidthsRecursive(propsColumns, aaa)
|
|
739
|
+
|
|
740
|
+
// // setColumns(aa)
|
|
741
|
+
|
|
742
|
+
// // table.setColumnSizing(aaa)
|
|
743
|
+
|
|
744
|
+
// requestAnimationFrame(() => {
|
|
745
|
+
|
|
746
|
+
// columnVirtualizer.measure()
|
|
747
|
+
// })
|
|
748
|
+
|
|
749
|
+
// // setColumnSizing?.(aaa)
|
|
750
|
+
// } else {
|
|
751
|
+
// if (columnHidden) {
|
|
752
|
+
// const abb = table.getVisibleLeafColumns()?.[0]
|
|
753
|
+
|
|
754
|
+
// if (abb && Object.keys(columnSizingInfo).length === 0
|
|
755
|
+
// ) {
|
|
756
|
+
// // setColumnSizing({ "#": abb.getSize() })
|
|
757
|
+
// table.setColumnSizing({ "#": abb.getSize() })
|
|
758
|
+
|
|
759
|
+
// requestAnimationFrame(() => {
|
|
760
|
+
|
|
761
|
+
// columnVirtualizer.measure()
|
|
762
|
+
// })
|
|
763
|
+
// }
|
|
764
|
+
// }
|
|
765
|
+
|
|
766
|
+
// }
|
|
767
|
+
|
|
768
|
+
// }, [table.getTotalSize(), dataSource.length, windowSize.innerWidth, columnVirtualizer])
|
|
744
769
|
|
|
745
770
|
// React.useEffect(() => {
|
|
746
771
|
|
|
@@ -38,7 +38,7 @@ const TableBody = ({
|
|
|
38
38
|
overscan: 1
|
|
39
39
|
});
|
|
40
40
|
const virtualRows = rowVirtualizer.getVirtualItems();
|
|
41
|
-
return /*#__PURE__*/React.createElement("
|
|
41
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
42
42
|
className: `${prefix}-grid-tbody`,
|
|
43
43
|
style: {
|
|
44
44
|
display: 'grid',
|
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
import type { Cell, Table } from "@tanstack/react-table";
|
|
2
2
|
import type { CommandClick } from "../type";
|
|
3
3
|
import React from "react";
|
|
4
|
-
import type { VirtualItem } from "@tanstack/react-virtual";
|
|
4
|
+
import type { VirtualItem, Virtualizer } from "@tanstack/react-virtual";
|
|
5
5
|
interface TableBodyCellProps<T> {
|
|
6
|
+
table: Table<T>;
|
|
7
|
+
rowVirtualizer: Virtualizer<HTMLDivElement, HTMLDivElement>;
|
|
8
|
+
columnVirtualizer: Virtualizer<HTMLDivElement, HTMLDivElement>;
|
|
9
|
+
tableId: string;
|
|
6
10
|
cell: Cell<T, unknown>;
|
|
7
11
|
commandClick?: (args: CommandClick<T>) => void;
|
|
8
|
-
|
|
9
|
-
|
|
12
|
+
virtualRow: VirtualItem;
|
|
13
|
+
[key: string]: any;
|
|
10
14
|
}
|
|
11
15
|
declare const TableBodyCell: <RecordType extends object>(props: TableBodyCellProps<RecordType>) => React.JSX.Element;
|
|
12
16
|
export default TableBodyCell;
|