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
|
@@ -42,7 +42,8 @@ export const getCommonPinningStyles = column => {
|
|
|
42
42
|
// opacity: isPinned ? 0.5 : 1,
|
|
43
43
|
opacity: 1,
|
|
44
44
|
position: isPinned ? "sticky" : "relative",
|
|
45
|
-
width: column.getSize(),
|
|
45
|
+
// width: column.getSize(),
|
|
46
|
+
width: 'auto',
|
|
46
47
|
zIndex: isPinned ? 2 : 0
|
|
47
48
|
// border: '1px solid #e5e7eb',
|
|
48
49
|
// borderTop: 0,
|
|
@@ -203,9 +204,11 @@ export const addRowIdArray = inputArray => {
|
|
|
203
204
|
if (typeof item.children !== "string" && item.children && item.children.length > 0) {
|
|
204
205
|
item.children = addRowIdArray(item.children);
|
|
205
206
|
}
|
|
207
|
+
|
|
208
|
+
// return { ...item, rowId: item.rowId ?? item.id ?? newGuid() }
|
|
206
209
|
return {
|
|
207
210
|
...item,
|
|
208
|
-
rowId: item.
|
|
211
|
+
rowId: item.id ?? item.rowId ?? newGuid()
|
|
209
212
|
};
|
|
210
213
|
});
|
|
211
214
|
} else {
|
|
@@ -121,7 +121,7 @@ $fontFamily: "Montserrat", Helvetica, Arial, serif !default;
|
|
|
121
121
|
white-space: normal;
|
|
122
122
|
// overflow: hidden;
|
|
123
123
|
text-overflow: ellipsis;
|
|
124
|
-
word-break:
|
|
124
|
+
word-break: break-word;
|
|
125
125
|
}
|
|
126
126
|
|
|
127
127
|
|
|
@@ -129,7 +129,7 @@ $fontFamily: "Montserrat", Helvetica, Arial, serif !default;
|
|
|
129
129
|
white-space: normal;
|
|
130
130
|
overflow: hidden;
|
|
131
131
|
text-overflow: ellipsis;
|
|
132
|
-
word-break:
|
|
132
|
+
word-break: break-word;
|
|
133
133
|
}
|
|
134
134
|
|
|
135
135
|
}
|
|
@@ -176,7 +176,7 @@ $fontFamily: "Montserrat", Helvetica, Arial, serif !default;
|
|
|
176
176
|
.#{$prefix}-grid-cell-text-wrap {
|
|
177
177
|
white-space: normal;
|
|
178
178
|
// text-overflow: ellipsis;
|
|
179
|
-
word-break:
|
|
179
|
+
word-break: break-word;
|
|
180
180
|
overflow: hidden;
|
|
181
181
|
}
|
|
182
182
|
|
|
@@ -257,7 +257,7 @@ $fontFamily: "Montserrat", Helvetica, Arial, serif !default;
|
|
|
257
257
|
|
|
258
258
|
.#{$prefix}-grid-tbody {
|
|
259
259
|
|
|
260
|
-
|
|
260
|
+
.#{$prefix}-grid-row {
|
|
261
261
|
border-bottom: 1px solid lightgray;
|
|
262
262
|
}
|
|
263
263
|
|
|
@@ -266,6 +266,20 @@ $fontFamily: "Montserrat", Helvetica, Arial, serif !default;
|
|
|
266
266
|
position: absolute;
|
|
267
267
|
width: 100%;
|
|
268
268
|
|
|
269
|
+
&:hover {
|
|
270
|
+
.#{$prefix}-grid-cell:not(.editable) {
|
|
271
|
+
background-color: $rowHoverBg;
|
|
272
|
+
|
|
273
|
+
&.cell-editable, &.#{$prefix}-grid-cell-index, &.#{$prefix}-grid-cell-selection {
|
|
274
|
+
// background-color: transparent;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
// &.ui-rc-grid-cell-index {
|
|
278
|
+
// background-color: #ffffff;
|
|
279
|
+
// }
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
|
|
269
283
|
&.#{$prefix}-grid-row-selected {
|
|
270
284
|
|
|
271
285
|
.#{$prefix}-grid-cell {
|
|
@@ -274,6 +288,14 @@ $fontFamily: "Montserrat", Helvetica, Arial, serif !default;
|
|
|
274
288
|
|
|
275
289
|
}
|
|
276
290
|
|
|
291
|
+
&.#{$prefix}-grid-row-focus {
|
|
292
|
+
|
|
293
|
+
.#{$prefix}-grid-cell {
|
|
294
|
+
background-color: $rowHoverBg;
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
}
|
|
298
|
+
|
|
277
299
|
}
|
|
278
300
|
|
|
279
301
|
.#{$prefix}-grid-cell {
|
|
@@ -141,18 +141,16 @@ const Grid = props => {
|
|
|
141
141
|
|
|
142
142
|
// debugTable: true
|
|
143
143
|
});
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
// }, [columnHidden, columnSizingInfo])
|
|
144
|
+
React.useEffect(() => {
|
|
145
|
+
if (columnHidden) {
|
|
146
|
+
const abb = table.getVisibleLeafColumns()?.[0];
|
|
147
|
+
if (abb && Object.keys(columnSizingInfo).length === 0) {
|
|
148
|
+
setColumnSizing({
|
|
149
|
+
"#": abb.getSize()
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}, [columnHidden, columnSizingInfo]);
|
|
156
154
|
|
|
157
155
|
// React.useEffect(() => {
|
|
158
156
|
// if (columnSizingInfo.isResizingColumn === false) {
|
|
@@ -167,12 +165,12 @@ const Grid = props => {
|
|
|
167
165
|
|
|
168
166
|
React.useEffect(() => {
|
|
169
167
|
// if (!manualUpdate) {
|
|
170
|
-
if (Object.keys(rowSelection) !== Object.keys(mergedSelectedKeys)) {
|
|
168
|
+
if (Object.keys(rowSelection) !== Object.keys(mergedSelectedKeys) && !isSelectionChange.isChange) {
|
|
171
169
|
setRowSelection(convertToObjTrue(mergedSelectedKeys));
|
|
172
170
|
}
|
|
173
171
|
|
|
174
172
|
// }
|
|
175
|
-
}, [mergedSelectedKeys]);
|
|
173
|
+
}, [mergedSelectedKeys, isSelectionChange]);
|
|
176
174
|
React.useEffect(() => {
|
|
177
175
|
if (isSelectionChange.isChange) {
|
|
178
176
|
// setManualUpdate(true)
|
|
@@ -186,12 +184,14 @@ const Grid = props => {
|
|
|
186
184
|
rowData: isSelectionChange.rowData,
|
|
187
185
|
selected: rs
|
|
188
186
|
});
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
187
|
+
|
|
188
|
+
// setIsSelectionChange((prev) => ({
|
|
189
|
+
// ...prev,
|
|
190
|
+
// isChange: false
|
|
191
|
+
|
|
192
|
+
// }))
|
|
193
193
|
}
|
|
194
|
-
}, [isSelectionChange,
|
|
194
|
+
}, [isSelectionChange, rowSelection, table.getState().rowSelection]);
|
|
195
195
|
React.useEffect(() => {
|
|
196
196
|
if (sorterChange) {
|
|
197
197
|
const aa = table.getState().sorting;
|
|
@@ -189,7 +189,7 @@ const TableWrapper = props => {
|
|
|
189
189
|
// onScroll={infiniteScroll ? handleScroll : undefined}
|
|
190
190
|
,
|
|
191
191
|
onScroll: handleScroll
|
|
192
|
-
}, /*#__PURE__*/React.createElement("
|
|
192
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
193
193
|
style: {
|
|
194
194
|
display: 'grid',
|
|
195
195
|
minWidth: table.getTotalSize()
|
|
@@ -13,18 +13,16 @@ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return
|
|
|
13
13
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
14
14
|
const TempTable = props => {
|
|
15
15
|
const {
|
|
16
|
-
infiniteScroll,
|
|
17
16
|
groupAble,
|
|
18
17
|
editAble,
|
|
19
18
|
...rest
|
|
20
19
|
} = props;
|
|
21
20
|
|
|
22
21
|
// const TabComponent = groupAble ? InternalTable : Table
|
|
23
|
-
const TabComponent =
|
|
22
|
+
const TabComponent = groupAble ? _InternalTable.default : _tableComponent.default;
|
|
24
23
|
// const TabComponent = InternalTable
|
|
25
24
|
|
|
26
25
|
return /*#__PURE__*/_react.default.createElement(_react.Fragment, null, /*#__PURE__*/_react.default.createElement(TabComponent, (0, _extends2.default)({}, rest, {
|
|
27
|
-
infiniteScroll: infiniteScroll,
|
|
28
26
|
groupAble: groupAble,
|
|
29
27
|
editAble: editAble
|
|
30
28
|
})));
|
|
@@ -9,12 +9,14 @@ var _useMergedState = _interopRequireDefault(require("rc-util/lib/hooks/useMerge
|
|
|
9
9
|
var _react = _interopRequireWildcard(require("react"));
|
|
10
10
|
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
11
11
|
var _antd = require("antd");
|
|
12
|
-
var _icons = require("@ant-design/icons");
|
|
13
12
|
var _tree = _interopRequireDefault(require("rc-master-ui/es/tree"));
|
|
14
13
|
var _SearchOutlined = _interopRequireDefault(require("@ant-design/icons/SearchOutlined"));
|
|
15
14
|
var _utils = require("./hook/utils");
|
|
15
|
+
var _becoxyIcons = require("becoxy-icons");
|
|
16
16
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
17
17
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
18
|
+
// import { SettingOutlined } from "@ant-design/icons"
|
|
19
|
+
|
|
18
20
|
const BoxAction = _styledComponents.default.div.withConfig({
|
|
19
21
|
displayName: "BoxAction",
|
|
20
22
|
componentId: "es-grid-template__sc-jfujqh-0"
|
|
@@ -211,6 +213,11 @@ const ColumnsChoose = props => {
|
|
|
211
213
|
}, /*#__PURE__*/_react.default.createElement(_antd.Tooltip, {
|
|
212
214
|
arrow: false,
|
|
213
215
|
title: 'Cài đặt'
|
|
214
|
-
}, /*#__PURE__*/_react.default.createElement(
|
|
216
|
+
}, /*#__PURE__*/_react.default.createElement(_becoxyIcons.Settings, {
|
|
217
|
+
fontSize: 16,
|
|
218
|
+
style: {
|
|
219
|
+
cursor: 'pointer'
|
|
220
|
+
}
|
|
221
|
+
}))));
|
|
215
222
|
};
|
|
216
223
|
exports.ColumnsChoose = ColumnsChoose;
|
|
@@ -110,6 +110,7 @@ const InternalTable = props => {
|
|
|
110
110
|
const [columns, setColumns] = _react.default.useState([]);
|
|
111
111
|
_react.default.useEffect(() => {
|
|
112
112
|
// setColumns(propsColumns as any)
|
|
113
|
+
|
|
113
114
|
setColumns((0, _utils.updateWidthsByOther)(propsColumns, columns));
|
|
114
115
|
}, [propsColumns]);
|
|
115
116
|
const [expanded, setExpanded] = _react.default.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;
|
|
@@ -80,13 +80,17 @@ const TableContainer = props => {
|
|
|
80
80
|
contextMenuHidden,
|
|
81
81
|
isFullScreen,
|
|
82
82
|
setIsFullScreen,
|
|
83
|
-
isDataTree
|
|
83
|
+
isDataTree,
|
|
84
|
+
setColumns,
|
|
85
|
+
columnSizing,
|
|
86
|
+
columnSizingInfo
|
|
84
87
|
} = props;
|
|
85
88
|
const tableContainerRef = _react.default.useRef(null);
|
|
86
89
|
const containerRef = _react.default.useRef(null);
|
|
87
90
|
const bottomToolbarRef = _react.default.useRef(null);
|
|
88
91
|
const topToolbarRef = _react.default.useRef(null);
|
|
89
92
|
const [tableHeight, settableHeight] = _react.default.useState(0);
|
|
93
|
+
const [focusedCell, setFocusedCell] = _react.default.useState(undefined);
|
|
90
94
|
_react.default.useEffect(() => {
|
|
91
95
|
const totalHeight = minHeight ?? height;
|
|
92
96
|
if (totalHeight) {
|
|
@@ -139,6 +143,30 @@ const TableContainer = props => {
|
|
|
139
143
|
columnVirtualizer.measure();
|
|
140
144
|
});
|
|
141
145
|
}, [columnSizingState, columnVirtualizer]);
|
|
146
|
+
_react.default.useEffect(() => {
|
|
147
|
+
if (!tableContainerRef.current) {
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
// const containerWidth = tableContainerRef.current.offsetWidth
|
|
152
|
+
// const totalWidth = table.getTotalSize()
|
|
153
|
+
|
|
154
|
+
// if (totalWidth && totalWidth <= containerWidth) {
|
|
155
|
+
|
|
156
|
+
// return
|
|
157
|
+
|
|
158
|
+
// }
|
|
159
|
+
|
|
160
|
+
if (columnSizingInfo.isResizingColumn === false) {
|
|
161
|
+
const aa = (0, _utils.updateColumnWidthsRecursive)(propsColumns, columnSizing);
|
|
162
|
+
setColumns(aa);
|
|
163
|
+
|
|
164
|
+
// requestAnimationFrame(() => {
|
|
165
|
+
|
|
166
|
+
// columnVirtualizer.measure()
|
|
167
|
+
// })
|
|
168
|
+
}
|
|
169
|
+
}, [columnSizingInfo]);
|
|
142
170
|
const triggerCommandClick = () => {};
|
|
143
171
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
144
172
|
ref: containerRef,
|
|
@@ -219,7 +247,9 @@ const TableContainer = props => {
|
|
|
219
247
|
setSorterChange,
|
|
220
248
|
setFilterChange,
|
|
221
249
|
windowSize,
|
|
222
|
-
isDataTree
|
|
250
|
+
isDataTree,
|
|
251
|
+
focusedCell,
|
|
252
|
+
setFocusedCell
|
|
223
253
|
}
|
|
224
254
|
}, /*#__PURE__*/_react.default.createElement(_TableWrapper.default, {
|
|
225
255
|
contextMenuItems: contextMenuItems,
|
|
@@ -674,80 +674,105 @@ const TableContainerEdit = props => {
|
|
|
674
674
|
}, [dataSource, editingKey, id, onBlur]);
|
|
675
675
|
const columnSizingState = table.getState().columnSizing;
|
|
676
676
|
_react.default.useEffect(() => {
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
// columnVirtualizer.measure()
|
|
681
|
-
// })
|
|
677
|
+
requestAnimationFrame(() => {
|
|
678
|
+
columnVirtualizer.measure();
|
|
679
|
+
});
|
|
682
680
|
}, [columnSizingState, columnVirtualizer]);
|
|
683
681
|
_react.default.useEffect(() => {
|
|
684
682
|
if (!tableContainerRef.current) {
|
|
685
683
|
return;
|
|
686
684
|
}
|
|
687
|
-
|
|
688
|
-
const
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
685
|
+
|
|
686
|
+
// const containerWidth = tableContainerRef.current.offsetWidth
|
|
687
|
+
// const totalWidth = table.getTotalSize()
|
|
688
|
+
|
|
689
|
+
// if (totalWidth && totalWidth <= containerWidth) {
|
|
690
|
+
|
|
691
|
+
// return
|
|
692
|
+
|
|
693
|
+
// }
|
|
694
|
+
|
|
692
695
|
if (columnSizingInfo.isResizingColumn === false) {
|
|
693
696
|
const aa = (0, _utils.updateColumnWidthsRecursive)(propsColumns, columnSizing);
|
|
694
697
|
setColumns(aa);
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
+
|
|
699
|
+
// requestAnimationFrame(() => {
|
|
700
|
+
|
|
701
|
+
// columnVirtualizer.measure()
|
|
702
|
+
// })
|
|
698
703
|
}
|
|
699
704
|
}, [columnSizingInfo]);
|
|
700
|
-
_react.default.useEffect(() => {
|
|
701
|
-
// if (!containerRef.current || !tableContainerRef.current) {
|
|
702
|
-
if (!tableContainerRef.current) {
|
|
703
|
-
return;
|
|
704
|
-
}
|
|
705
705
|
|
|
706
|
-
|
|
707
|
-
// const containerWidth = tableContainerRef.current.offsetWidth
|
|
708
|
-
const containerWidth = tableContainerRef.current.offsetWidth - (tableContainerRef.current.scrollHeight > tableContainerRef.current.offsetHeight ? 15 : 0);
|
|
709
|
-
const totalWidth = table.getTotalSize() - (tableContainerRef.current.scrollHeight > tableContainerRef.current.offsetHeight ? 15 : 0);
|
|
710
|
-
if (totalWidth && totalWidth > 0 && totalWidth < containerWidth) {
|
|
711
|
-
const factor = containerWidth / totalWidth;
|
|
712
|
-
const visibleCols = table.getVisibleLeafColumns();
|
|
713
|
-
const baseSizes = visibleCols.map(col => col.getSize() || col.columnDef.size || 150);
|
|
714
|
-
const scaledSizes = baseSizes.map(size => size * factor);
|
|
715
|
-
const roundedSizes = scaledSizes.map(size => Math.floor(size));
|
|
716
|
-
let diff = containerWidth - roundedSizes.reduce((a, b) => a + b, 0);
|
|
717
|
-
|
|
718
|
-
// phân bổ diff cho các cột từ trái qua phải
|
|
719
|
-
for (let i = 0; diff > 0; i = (i + 1) % roundedSizes.length) {
|
|
720
|
-
roundedSizes[i]++;
|
|
721
|
-
diff--;
|
|
722
|
-
}
|
|
723
|
-
const aaa = visibleCols.reduce((acc, col, idx) => {
|
|
724
|
-
acc[col.id] = roundedSizes[idx];
|
|
725
|
-
return acc;
|
|
726
|
-
}, {});
|
|
727
|
-
const aa = (0, _utils.updateColumnWidthsRecursive)(propsColumns, aaa);
|
|
728
|
-
setColumns(aa);
|
|
729
|
-
table.setColumnSizing(aaa);
|
|
730
|
-
requestAnimationFrame(() => {
|
|
731
|
-
columnVirtualizer.measure();
|
|
732
|
-
});
|
|
706
|
+
// React.useEffect(() => {
|
|
733
707
|
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
708
|
+
// // if (!containerRef.current || !tableContainerRef.current) {
|
|
709
|
+
// if (!tableContainerRef.current) {
|
|
710
|
+
// return
|
|
711
|
+
// }
|
|
712
|
+
|
|
713
|
+
// // const containerWidth = containerRef.current.offsetWidth - 1
|
|
714
|
+
// // const containerWidth = tableContainerRef.current.offsetWidth
|
|
715
|
+
// const containerWidth = tableContainerRef.current.offsetWidth - (tableContainerRef.current.scrollHeight > tableContainerRef.current.offsetHeight ? 15 : 0)
|
|
716
|
+
|
|
717
|
+
// const totalWidth = table.getTotalSize() - (tableContainerRef.current.scrollHeight > tableContainerRef.current.offsetHeight ? 15 : 0)
|
|
718
|
+
|
|
719
|
+
// if (totalWidth && totalWidth > 0 && totalWidth < containerWidth) {
|
|
720
|
+
|
|
721
|
+
// const factor = containerWidth / totalWidth
|
|
722
|
+
|
|
723
|
+
// const visibleCols = table.getVisibleLeafColumns()
|
|
724
|
+
|
|
725
|
+
// const baseSizes = visibleCols.map(
|
|
726
|
+
// (col) => col.getSize() || col.columnDef.size || 150
|
|
727
|
+
// )
|
|
728
|
+
|
|
729
|
+
// const scaledSizes = baseSizes.map((size) => size * factor)
|
|
730
|
+
// const roundedSizes = scaledSizes.map((size) => Math.floor(size))
|
|
731
|
+
|
|
732
|
+
// let diff = containerWidth - roundedSizes.reduce((a, b) => a + b, 0)
|
|
733
|
+
|
|
734
|
+
// // phân bổ diff cho các cột từ trái qua phải
|
|
735
|
+
// for (let i = 0; diff > 0; i = (i + 1) % roundedSizes.length) {
|
|
736
|
+
// roundedSizes[i]++
|
|
737
|
+
// diff--
|
|
738
|
+
// }
|
|
739
|
+
|
|
740
|
+
// const aaa = visibleCols.reduce((acc, col, idx) => {
|
|
741
|
+
// acc[col.id] = roundedSizes[idx]
|
|
742
|
+
// return acc
|
|
743
|
+
// }, {} as Record<string, number>)
|
|
744
|
+
|
|
745
|
+
// const aa = updateColumnWidthsRecursive(propsColumns, aaa)
|
|
746
|
+
|
|
747
|
+
// // setColumns(aa)
|
|
748
|
+
|
|
749
|
+
// // table.setColumnSizing(aaa)
|
|
750
|
+
|
|
751
|
+
// requestAnimationFrame(() => {
|
|
752
|
+
|
|
753
|
+
// columnVirtualizer.measure()
|
|
754
|
+
// })
|
|
755
|
+
|
|
756
|
+
// // setColumnSizing?.(aaa)
|
|
757
|
+
// } else {
|
|
758
|
+
// if (columnHidden) {
|
|
759
|
+
// const abb = table.getVisibleLeafColumns()?.[0]
|
|
760
|
+
|
|
761
|
+
// if (abb && Object.keys(columnSizingInfo).length === 0
|
|
762
|
+
// ) {
|
|
763
|
+
// // setColumnSizing({ "#": abb.getSize() })
|
|
764
|
+
// table.setColumnSizing({ "#": abb.getSize() })
|
|
765
|
+
|
|
766
|
+
// requestAnimationFrame(() => {
|
|
767
|
+
|
|
768
|
+
// columnVirtualizer.measure()
|
|
769
|
+
// })
|
|
770
|
+
// }
|
|
771
|
+
// }
|
|
772
|
+
|
|
773
|
+
// }
|
|
774
|
+
|
|
775
|
+
// }, [table.getTotalSize(), dataSource.length, windowSize.innerWidth, columnVirtualizer])
|
|
751
776
|
|
|
752
777
|
// React.useEffect(() => {
|
|
753
778
|
|
|
@@ -49,7 +49,7 @@ const TableBody = ({
|
|
|
49
49
|
overscan: 1
|
|
50
50
|
});
|
|
51
51
|
const virtualRows = rowVirtualizer.getVirtualItems();
|
|
52
|
-
return /*#__PURE__*/_react.default.createElement("
|
|
52
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
53
53
|
className: `${prefix}-grid-tbody`,
|
|
54
54
|
style: {
|
|
55
55
|
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;
|