es-grid-template 1.7.27 → 1.7.28
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/InternalTable.js +31 -36
- package/es/grid-component/TempTable.d.ts +4 -0
- package/es/grid-component/TempTable.js +21 -0
- package/es/grid-component/hooks/columns/index.js +3 -1
- package/es/grid-component/index.d.ts +2 -2
- package/es/grid-component/index.js +6 -4
- package/es/grid-component/styles.scss +0 -1
- package/es/grid-component/table/GridEdit.js +112 -96
- package/es/grid-component/type.d.ts +7 -1
- package/es/table-component/InternalTable.js +100 -127
- package/es/table-component/TableContainer.d.ts +6 -0
- package/es/table-component/TableContainer.js +74 -70
- package/es/table-component/TableContainerEdit.d.ts +4 -0
- package/es/table-component/TableContainerEdit.js +353 -81
- package/es/table-component/body/TableBody.d.ts +2 -8
- package/es/table-component/body/TableBody.js +1 -0
- package/es/table-component/body/TableBodyCell.d.ts +1 -1
- package/es/table-component/body/TableBodyCell.js +25 -13
- package/es/table-component/body/TableBodyCellEdit.d.ts +1 -1
- package/es/table-component/body/TableBodyCellEdit.js +24 -10
- package/es/table-component/body/TableBodyRow.d.ts +3 -3
- package/es/table-component/body/TableBodyRow.js +4 -6
- package/es/table-component/footer/TableFooter.d.ts +2 -8
- package/es/table-component/footer/TableFooter.js +14 -13
- package/es/table-component/footer/TableFooterCell.d.ts +3 -6
- package/es/table-component/footer/TableFooterCell.js +12 -10
- package/es/table-component/footer/TableFooterRow.d.ts +2 -8
- package/es/table-component/footer/TableFooterRow.js +23 -48
- package/es/table-component/header/TableHead.d.ts +4 -3
- package/es/table-component/header/TableHead.js +3 -61
- package/es/table-component/header/TableHeadCell.d.ts +0 -3
- package/es/table-component/header/TableHeadCell.js +10 -9
- package/es/table-component/header/TableHeadRow.d.ts +6 -6
- package/es/table-component/header/TableHeadRow.js +10 -32
- package/es/table-component/style.scss +24 -2
- package/es/table-component/table/Grid.d.ts +1 -0
- package/es/table-component/table/Grid.js +6 -3
- package/es/table-component/table/TableWrapper.d.ts +32 -0
- package/es/table-component/table/TableWrapper.js +242 -0
- package/es/table-component/type.d.ts +4 -4
- package/es/table-component/useContext.d.ts +4 -0
- package/es/table-component/useContext.js +4 -0
- package/lib/grid-component/InternalTable.js +30 -35
- package/lib/grid-component/TempTable.d.ts +4 -0
- package/lib/grid-component/TempTable.js +30 -0
- package/lib/grid-component/hooks/columns/index.js +3 -1
- package/lib/grid-component/index.d.ts +2 -2
- package/lib/grid-component/index.js +5 -3
- package/lib/grid-component/styles.scss +0 -1
- package/lib/grid-component/table/GridEdit.js +112 -96
- package/lib/grid-component/type.d.ts +7 -1
- package/lib/table-component/InternalTable.js +101 -127
- package/lib/table-component/TableContainer.d.ts +6 -0
- package/lib/table-component/TableContainer.js +76 -70
- package/lib/table-component/TableContainerEdit.d.ts +4 -0
- package/lib/table-component/TableContainerEdit.js +349 -79
- package/lib/table-component/body/TableBody.d.ts +2 -8
- package/lib/table-component/body/TableBody.js +2 -0
- package/lib/table-component/body/TableBodyCell.d.ts +1 -1
- package/lib/table-component/body/TableBodyCell.js +25 -13
- package/lib/table-component/body/TableBodyCellEdit.d.ts +1 -1
- package/lib/table-component/body/TableBodyCellEdit.js +24 -10
- package/lib/table-component/body/TableBodyRow.d.ts +3 -3
- package/lib/table-component/body/TableBodyRow.js +4 -6
- package/lib/table-component/footer/TableFooter.d.ts +2 -8
- package/lib/table-component/footer/TableFooter.js +15 -13
- package/lib/table-component/footer/TableFooterCell.d.ts +3 -6
- package/lib/table-component/footer/TableFooterCell.js +13 -10
- package/lib/table-component/footer/TableFooterRow.d.ts +2 -8
- package/lib/table-component/footer/TableFooterRow.js +23 -48
- package/lib/table-component/header/TableHead.d.ts +4 -3
- package/lib/table-component/header/TableHead.js +3 -61
- package/lib/table-component/header/TableHeadCell.d.ts +0 -3
- package/lib/table-component/header/TableHeadCell.js +10 -8
- package/lib/table-component/header/TableHeadRow.d.ts +6 -6
- package/lib/table-component/header/TableHeadRow.js +10 -32
- package/lib/table-component/style.scss +24 -2
- package/lib/table-component/table/Grid.d.ts +1 -0
- package/lib/table-component/table/Grid.js +6 -3
- package/lib/table-component/table/TableWrapper.d.ts +32 -0
- package/lib/table-component/table/TableWrapper.js +251 -0
- package/lib/table-component/type.d.ts +4 -4
- package/lib/table-component/useContext.d.ts +4 -0
- package/lib/table-component/useContext.js +4 -0
- package/package.json +1 -1
|
@@ -27,8 +27,8 @@ import useMergedState from "rc-util/es/hooks/useMergedState";
|
|
|
27
27
|
import Grid from "./table/Grid";
|
|
28
28
|
// import { Group } from 'becoxy-icons'
|
|
29
29
|
|
|
30
|
-
import { Tooltip } from 'react-tooltip'
|
|
31
|
-
import ContextMenu from
|
|
30
|
+
// import { Tooltip } from 'react-tooltip'
|
|
31
|
+
// import ContextMenu from './ContextMenu'
|
|
32
32
|
import { addRowIdArray, convertToObj,
|
|
33
33
|
// convertFilters,
|
|
34
34
|
filterDataByColumns, flatColumns2,
|
|
@@ -61,12 +61,12 @@ const InternalTable = props => {
|
|
|
61
61
|
groupAble,
|
|
62
62
|
groupSetting,
|
|
63
63
|
groupColumns,
|
|
64
|
-
infiniteScroll,
|
|
64
|
+
// infiniteScroll,
|
|
65
65
|
// wrapSettings,
|
|
66
66
|
// onFilter,
|
|
67
67
|
// expandable,
|
|
68
|
-
contextMenuItems: propContextMenuItems,
|
|
69
|
-
contextMenuHidden,
|
|
68
|
+
// contextMenuItems: propContextMenuItems,
|
|
69
|
+
// contextMenuHidden,
|
|
70
70
|
contextMenuClick,
|
|
71
71
|
contextMenuOpen,
|
|
72
72
|
height,
|
|
@@ -108,17 +108,18 @@ const InternalTable = props => {
|
|
|
108
108
|
// }
|
|
109
109
|
// }
|
|
110
110
|
|
|
111
|
-
const menuRef = React.useRef(null)
|
|
112
|
-
const viewportWidth = windowSize.innerWidth
|
|
113
|
-
const viewportHeight = windowSize.innerHeight
|
|
114
|
-
|
|
115
|
-
const [
|
|
116
|
-
const [
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
111
|
+
// const menuRef = React.useRef<any>(null)
|
|
112
|
+
// const viewportWidth = windowSize.innerWidth
|
|
113
|
+
// const viewportHeight = windowSize.innerHeight
|
|
114
|
+
|
|
115
|
+
// const [menuVisible, setMenuVisible] = React.useState(false)
|
|
116
|
+
// const [selectedRowData, setSelectedRowData] = React.useState<RecordType | null>(null)
|
|
117
|
+
// const [position, setPosition] = React.useState<{
|
|
118
|
+
// x: number | undefined
|
|
119
|
+
// y: number | undefined
|
|
120
|
+
// viewportWidth: number
|
|
121
|
+
// viewportHeight: number
|
|
122
|
+
// }>({ x: 0, y: 0, viewportWidth, viewportHeight })
|
|
122
123
|
|
|
123
124
|
// const [tooltipContent, setTooltipContent] = useState<any>('')
|
|
124
125
|
|
|
@@ -170,101 +171,81 @@ const InternalTable = props => {
|
|
|
170
171
|
const rsss = getDiffent2Array(aa, keys);
|
|
171
172
|
setColumnsHiddenKeys(rsss);
|
|
172
173
|
};
|
|
173
|
-
const contextMenuItems = React.useMemo(() => {
|
|
174
|
-
if (typeof contextMenuHidden === 'function' && propContextMenuItems && selectedRowData) {
|
|
175
|
-
const hiddenItems = contextMenuHidden({
|
|
176
|
-
rowInfo: {
|
|
177
|
-
rowData: selectedRowData
|
|
178
|
-
}
|
|
179
|
-
});
|
|
180
|
-
return propContextMenuItems.filter(item => !hiddenItems.includes(item?.key));
|
|
181
|
-
}
|
|
182
|
-
if (contextMenuHidden && typeof contextMenuHidden !== 'function' && propContextMenuItems) {
|
|
183
|
-
return propContextMenuItems.filter(item => !contextMenuHidden.includes(item?.key));
|
|
184
|
-
}
|
|
185
|
-
return propContextMenuItems;
|
|
186
|
-
}, [propContextMenuItems, contextMenuHidden, selectedRowData]);
|
|
187
|
-
|
|
188
|
-
// const [columns, setColumns] = React.useState<any[]>([])
|
|
189
|
-
|
|
190
|
-
// React.useEffect(() => {
|
|
191
|
-
// setColumns(propsColumns)
|
|
192
|
-
// }, [propsColumns])
|
|
193
|
-
|
|
194
|
-
// const triggerFilter = (queries: any[]) => {
|
|
195
174
|
|
|
196
|
-
//
|
|
197
|
-
//
|
|
198
|
-
//
|
|
175
|
+
// const contextMenuItems = React.useMemo(() => {
|
|
176
|
+
// if (typeof contextMenuHidden === 'function' && propContextMenuItems && selectedRowData) {
|
|
177
|
+
// const hiddenItems = contextMenuHidden({
|
|
178
|
+
// rowInfo: {
|
|
179
|
+
// rowData: selectedRowData
|
|
180
|
+
// }
|
|
181
|
+
// })
|
|
199
182
|
|
|
200
|
-
//
|
|
201
|
-
|
|
202
|
-
// const b = filterDataByColumns(convertData, convertFilters(queries), [], [])
|
|
183
|
+
// return propContextMenuItems.filter(item => !(hiddenItems as string[]).includes(item?.key as string))
|
|
184
|
+
// }
|
|
203
185
|
|
|
204
|
-
//
|
|
186
|
+
// if (contextMenuHidden && typeof contextMenuHidden !== 'function' && propContextMenuItems) {
|
|
187
|
+
// return propContextMenuItems.filter(item => !(contextMenuHidden as string[]).includes(item?.key as string))
|
|
188
|
+
// }
|
|
205
189
|
|
|
190
|
+
// return propContextMenuItems
|
|
191
|
+
// }, [propContextMenuItems, contextMenuHidden, selectedRowData])
|
|
192
|
+
|
|
193
|
+
// const onContextMenu = (data: RecordType) => (event: any) => {
|
|
194
|
+
// event.preventDefault() // Ngăn chặn menu mặc định của trình duyệt
|
|
195
|
+
|
|
196
|
+
// setSelectedRowData(data)
|
|
197
|
+
|
|
198
|
+
// contextMenuOpen?.({
|
|
199
|
+
// rowInfo: {
|
|
200
|
+
// rowData: data
|
|
201
|
+
// },
|
|
202
|
+
// event
|
|
203
|
+
// })
|
|
204
|
+
|
|
205
|
+
// setMenuVisible(true)
|
|
206
|
+
|
|
207
|
+
// // Đợi DOM cập nhật và lấy kích thước menu
|
|
208
|
+
// setTimeout(() => {
|
|
209
|
+
// const menuElement = menuRef.current // Lấy menu từ DOM
|
|
210
|
+
// const menuWidth = menuElement?.offsetWidth || 200 // Mặc định 200px nếu chưa render
|
|
211
|
+
// const menuHeight = menuElement?.offsetHeight // Mặc định 450px nếu chưa render
|
|
212
|
+
|
|
213
|
+
// // Điều chỉnh vị trí menu
|
|
214
|
+
// let x = event.clientX
|
|
215
|
+
// let y = event.clientY
|
|
216
|
+
|
|
217
|
+
// if (x + menuWidth > viewportWidth) {
|
|
218
|
+
// x = x - menuWidth - 10 // Cách cạnh phải 10px
|
|
219
|
+
// }
|
|
220
|
+
|
|
221
|
+
// if (y + menuHeight > viewportHeight) {
|
|
222
|
+
// if (y < menuHeight) {
|
|
223
|
+
// y = 10
|
|
224
|
+
// } else {
|
|
225
|
+
// y = y - 10 - menuHeight // Cách cạnh dưới 10px
|
|
226
|
+
// }
|
|
227
|
+
// }
|
|
228
|
+
|
|
229
|
+
// setPosition(prevState => ({ ...prevState, x, y }))
|
|
230
|
+
// }, 100)
|
|
231
|
+
|
|
232
|
+
// if (!menuVisible) {
|
|
233
|
+
// document.addEventListener(`click`, function onClickOutside(e) {
|
|
234
|
+
// const element: any = e.target
|
|
235
|
+
// const menuContainer = document.querySelector('.popup-context-menu')
|
|
236
|
+
|
|
237
|
+
// const isInsideContainer = element.closest('.popup-context-menu') && menuContainer
|
|
238
|
+
|
|
239
|
+
// if (isInsideContainer) {
|
|
240
|
+
// return
|
|
241
|
+
// }
|
|
242
|
+
// setMenuVisible(false)
|
|
243
|
+
// setPosition(prevState => ({ ...prevState, x: undefined, y: undefined }))
|
|
244
|
+
// document.removeEventListener(`click`, onClickOutside)
|
|
245
|
+
// })
|
|
206
246
|
// }
|
|
207
247
|
// }
|
|
208
248
|
|
|
209
|
-
const onContextMenu = data => event => {
|
|
210
|
-
event.preventDefault(); // Ngăn chặn menu mặc định của trình duyệt
|
|
211
|
-
|
|
212
|
-
setSelectedRowData(data);
|
|
213
|
-
contextMenuOpen?.({
|
|
214
|
-
rowInfo: {
|
|
215
|
-
rowData: data
|
|
216
|
-
},
|
|
217
|
-
event
|
|
218
|
-
});
|
|
219
|
-
setMenuVisible(true);
|
|
220
|
-
|
|
221
|
-
// Đợi DOM cập nhật và lấy kích thước menu
|
|
222
|
-
setTimeout(() => {
|
|
223
|
-
const menuElement = menuRef.current; // Lấy menu từ DOM
|
|
224
|
-
const menuWidth = menuElement?.offsetWidth || 200; // Mặc định 200px nếu chưa render
|
|
225
|
-
const menuHeight = menuElement?.offsetHeight; // Mặc định 450px nếu chưa render
|
|
226
|
-
|
|
227
|
-
// Điều chỉnh vị trí menu
|
|
228
|
-
let x = event.clientX;
|
|
229
|
-
let y = event.clientY;
|
|
230
|
-
if (x + menuWidth > viewportWidth) {
|
|
231
|
-
x = x - menuWidth - 10; // Cách cạnh phải 10px
|
|
232
|
-
}
|
|
233
|
-
if (y + menuHeight > viewportHeight) {
|
|
234
|
-
if (y < menuHeight) {
|
|
235
|
-
y = 10;
|
|
236
|
-
} else {
|
|
237
|
-
y = y - 10 - menuHeight; // Cách cạnh dưới 10px
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
setPosition(prevState => ({
|
|
241
|
-
...prevState,
|
|
242
|
-
x,
|
|
243
|
-
y
|
|
244
|
-
}));
|
|
245
|
-
}, 100);
|
|
246
|
-
if (!menuVisible) {
|
|
247
|
-
document.addEventListener(`click`, function onClickOutside(e) {
|
|
248
|
-
const element = e.target;
|
|
249
|
-
const menuContainer = document.querySelector('.popup-context-menu');
|
|
250
|
-
const isInsideContainer = element.closest('.popup-context-menu') && menuContainer;
|
|
251
|
-
if (isInsideContainer) {
|
|
252
|
-
return;
|
|
253
|
-
}
|
|
254
|
-
setMenuVisible(false);
|
|
255
|
-
setPosition(prevState => ({
|
|
256
|
-
...prevState,
|
|
257
|
-
x: undefined,
|
|
258
|
-
y: undefined
|
|
259
|
-
}));
|
|
260
|
-
document.removeEventListener(`click`, onClickOutside);
|
|
261
|
-
});
|
|
262
|
-
}
|
|
263
|
-
};
|
|
264
|
-
|
|
265
|
-
// const TableComponent = infiniteScroll ? InfiniteTable : (groupAble ? Group : editAble ? GridEdit : Grid)
|
|
266
|
-
// const TableComponent = Grid
|
|
267
|
-
|
|
268
249
|
return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement(Grid, _extends({}, rest, {
|
|
269
250
|
t: t,
|
|
270
251
|
id: id,
|
|
@@ -287,14 +268,16 @@ const InternalTable = props => {
|
|
|
287
268
|
triggerSorter: setSorterStates,
|
|
288
269
|
setMergedFilterKeys: setMergedFilterKeys,
|
|
289
270
|
mergedFilterKeys: mergedFilterKeys,
|
|
290
|
-
expanded: expanded
|
|
291
|
-
|
|
292
|
-
|
|
271
|
+
expanded: expanded
|
|
272
|
+
// onContextMenu={onContextMenu}
|
|
273
|
+
// contextMenuItems={contextMenuItems}
|
|
274
|
+
,
|
|
293
275
|
editAble: editAble,
|
|
294
276
|
triggerChangeColumns: triggerChangeColumns,
|
|
295
277
|
setExpanded: setExpanded,
|
|
296
278
|
isFullScreen: isFullScreen,
|
|
297
|
-
setIsFullScreen: setIsFullScreen
|
|
279
|
+
setIsFullScreen: setIsFullScreen,
|
|
280
|
+
windowSize: windowSize
|
|
298
281
|
})), /*#__PURE__*/React.createElement(Modal, {
|
|
299
282
|
open: isFullScreen,
|
|
300
283
|
footer: null,
|
|
@@ -319,7 +302,8 @@ const InternalTable = props => {
|
|
|
319
302
|
wrapper: {
|
|
320
303
|
zIndex: 1050
|
|
321
304
|
}
|
|
322
|
-
}
|
|
305
|
+
},
|
|
306
|
+
destroyOnClose: true
|
|
323
307
|
}, /*#__PURE__*/React.createElement("div", {
|
|
324
308
|
style: {
|
|
325
309
|
paddingTop: 40
|
|
@@ -346,28 +330,17 @@ const InternalTable = props => {
|
|
|
346
330
|
triggerSorter: setSorterStates,
|
|
347
331
|
setMergedFilterKeys: setMergedFilterKeys,
|
|
348
332
|
mergedFilterKeys: mergedFilterKeys,
|
|
349
|
-
expanded: expanded
|
|
350
|
-
|
|
351
|
-
|
|
333
|
+
expanded: expanded
|
|
334
|
+
// onContextMenu={onContextMenu}
|
|
335
|
+
// contextMenuItems={contextMenuItems}
|
|
336
|
+
,
|
|
352
337
|
editAble: editAble,
|
|
353
338
|
triggerChangeColumns: triggerChangeColumns,
|
|
354
339
|
setExpanded: setExpanded,
|
|
355
340
|
isFullScreen: isFullScreen,
|
|
356
341
|
setIsFullScreen: setIsFullScreen,
|
|
357
|
-
height: windowSize.innerHeight - 70
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
pos: position,
|
|
361
|
-
setOpen: setMenuVisible,
|
|
362
|
-
menuRef: menuRef,
|
|
363
|
-
contextMenuItems: contextMenuItems,
|
|
364
|
-
contextMenuClick: contextMenuClick,
|
|
365
|
-
rowData: selectedRowData
|
|
366
|
-
}), /*#__PURE__*/React.createElement(Tooltip, {
|
|
367
|
-
id: `${id}-tooltip-content`,
|
|
368
|
-
style: {
|
|
369
|
-
zIndex: 1999
|
|
370
|
-
}
|
|
371
|
-
}));
|
|
342
|
+
height: windowSize.innerHeight - 70,
|
|
343
|
+
windowSize: windowSize
|
|
344
|
+
})))));
|
|
372
345
|
};
|
|
373
346
|
export default InternalTable;
|
|
@@ -17,6 +17,10 @@ type TableContainerProps<T> = Omit<TableProps<T>, 'columns'> & {
|
|
|
17
17
|
setFilterChange: Dispatch<SetStateAction<boolean>>;
|
|
18
18
|
onContextMenu?: (data: T) => (event: any) => void;
|
|
19
19
|
tableHeight?: number;
|
|
20
|
+
windowSize: {
|
|
21
|
+
innerHeight: number;
|
|
22
|
+
innerWidth: number;
|
|
23
|
+
};
|
|
20
24
|
triggerPaste?: (pastedRows: T[], pastedColumnsArray: string[], newData: T[], copyRows: T[]) => void;
|
|
21
25
|
mergedFilterKeys?: any;
|
|
22
26
|
setMergedFilterKeys?: any;
|
|
@@ -26,6 +30,8 @@ type TableContainerProps<T> = Omit<TableProps<T>, 'columns'> & {
|
|
|
26
30
|
propsColumns: ColumnsTable;
|
|
27
31
|
triggerChangeColumns: any;
|
|
28
32
|
columnHidden: any;
|
|
33
|
+
isFullScreen: boolean;
|
|
34
|
+
setIsFullScreen: Dispatch<SetStateAction<boolean>>;
|
|
29
35
|
};
|
|
30
36
|
declare const TableContainer: <RecordType extends object>(props: TableContainerProps<RecordType>) => React.JSX.Element;
|
|
31
37
|
export default TableContainer;
|
|
@@ -2,9 +2,11 @@ import _extends from "@babel/runtime/helpers/esm/extends";
|
|
|
2
2
|
// import type { Dispatch, SetStateAction } from "react";
|
|
3
3
|
|
|
4
4
|
import React from 'react';
|
|
5
|
-
import TableHead from
|
|
6
|
-
import { sumSize } from
|
|
7
|
-
|
|
5
|
+
// import TableHead from './header/TableHead'
|
|
6
|
+
// import { sumSize } from './hook/utils'
|
|
7
|
+
|
|
8
|
+
// import { useVirtualizer } from '@tanstack/react-virtual'
|
|
9
|
+
|
|
8
10
|
import classNames from 'classnames';
|
|
9
11
|
// import TableBody from './body/TableBody'
|
|
10
12
|
import { TableContext } from "./useContext";
|
|
@@ -12,16 +14,20 @@ import Pagination from 'rc-master-ui/es/pagination';
|
|
|
12
14
|
import { Toolbar } from 'rc-master-ui';
|
|
13
15
|
import { Maximize, Minimize } from 'becoxy-icons';
|
|
14
16
|
import { ColumnsChoose } from "./ColumnsChoose";
|
|
15
|
-
import TableFooter from
|
|
16
|
-
import TableBody from
|
|
17
|
+
// import TableFooter from './footer/TableFooter'
|
|
18
|
+
// import TableBody from './body/TableBody'
|
|
17
19
|
import { numericFormatter } from 'react-numeric-component';
|
|
20
|
+
// import ComponentSpinner from '../grid-component/LoadingSpinner'
|
|
21
|
+
import TableWrapper from "./table/TableWrapper";
|
|
22
|
+
import { sumSize } from "./hook/utils";
|
|
23
|
+
import { useVirtualizer } from '@tanstack/react-virtual';
|
|
18
24
|
const TableContainer = props => {
|
|
19
25
|
const {
|
|
20
26
|
t,
|
|
21
27
|
table,
|
|
22
28
|
id,
|
|
23
29
|
prefix,
|
|
24
|
-
commandClick,
|
|
30
|
+
// commandClick,
|
|
25
31
|
editAble,
|
|
26
32
|
rowKey,
|
|
27
33
|
format,
|
|
@@ -53,14 +59,21 @@ const TableContainer = props => {
|
|
|
53
59
|
columnHidden,
|
|
54
60
|
expanded,
|
|
55
61
|
setExpanded,
|
|
56
|
-
showEmptyText
|
|
62
|
+
showEmptyText,
|
|
63
|
+
infiniteScroll,
|
|
64
|
+
next,
|
|
65
|
+
loading,
|
|
66
|
+
windowSize,
|
|
67
|
+
contextMenuOpen,
|
|
68
|
+
contextMenuClick,
|
|
69
|
+
contextMenuHidden,
|
|
70
|
+
isFullScreen,
|
|
71
|
+
setIsFullScreen
|
|
57
72
|
} = props;
|
|
58
73
|
const tableContainerRef = React.useRef(null);
|
|
59
74
|
const containerRef = React.useRef(null);
|
|
60
75
|
const bottomToolbarRef = React.useRef(null);
|
|
61
76
|
const topToolbarRef = React.useRef(null);
|
|
62
|
-
const visibleColumns = table.getVisibleLeafColumns();
|
|
63
|
-
const [isFullScreen] = React.useState(false);
|
|
64
77
|
const [tableHeight, settableHeight] = React.useState(0);
|
|
65
78
|
React.useEffect(() => {
|
|
66
79
|
const totalHeight = height;
|
|
@@ -68,15 +81,24 @@ const TableContainer = props => {
|
|
|
68
81
|
settableHeight(totalHeight - topToolbarRef.current.offsetHeight - bottomToolbarRef.current.offsetHeight);
|
|
69
82
|
}
|
|
70
83
|
}, [id, height, editAble]);
|
|
84
|
+
const visibleColumns = table.getVisibleLeafColumns();
|
|
71
85
|
const fixedLeftColumns = table.getState().columnPinning.left ? visibleColumns.filter(vc => table.getState().columnPinning.left?.includes(vc.id)) : [];
|
|
72
86
|
const fixedRightColumns = table.getState().columnPinning.right ? visibleColumns.filter(vc => table.getState().columnPinning.right?.includes(vc.id)) : [];
|
|
87
|
+
|
|
88
|
+
//we are using a slightly different virtualization strategy for columns (compared to virtual rows) in order to support dynamic row heights
|
|
73
89
|
const columnVirtualizer = useVirtualizer({
|
|
74
90
|
count: visibleColumns.length,
|
|
75
91
|
estimateSize: index => visibleColumns[index].getSize(),
|
|
92
|
+
//estimate width of each column for accurate scrollbar dragging
|
|
76
93
|
getScrollElement: () => tableContainerRef.current,
|
|
77
94
|
horizontal: true,
|
|
95
|
+
// measureElement(element) {
|
|
96
|
+
|
|
97
|
+
// return element?.getBoundingClientRect().width;
|
|
98
|
+
// },
|
|
99
|
+
|
|
78
100
|
measureElement: typeof window !== 'undefined' && navigator.userAgent.indexOf('Firefox') === -1 ? element => element?.getBoundingClientRect().height : undefined,
|
|
79
|
-
overscan:
|
|
101
|
+
overscan: 1 //how many columns to render on each side off screen each way (adjust this for performance)
|
|
80
102
|
});
|
|
81
103
|
const virtualColumns = columnVirtualizer.getVirtualItems();
|
|
82
104
|
const cacheColumns = columnVirtualizer.measurementsCache;
|
|
@@ -91,8 +113,13 @@ const TableContainer = props => {
|
|
|
91
113
|
const pdRight = columnVirtualizer.getTotalSize() - (virtualColumns[virtualColumns.length - 1]?.end ?? 0);
|
|
92
114
|
if (columnVirtualizer && virtualColumns?.length) {
|
|
93
115
|
virtualPaddingLeft = fixedLeftColumns && fixedLeftColumns.length > 0 ? (virtualColumns[0]?.start ?? 0) - leftWidth > 0 ? (virtualColumns[0]?.start ?? 0) - leftWidth : 0 : virtualColumns[0]?.start ?? 0;
|
|
116
|
+
|
|
117
|
+
// virtualPaddingLeft = leftCols.length === rss.length ? (virtualColumns[0]?.start ?? 0) : 0;
|
|
118
|
+
// columnVirtualizer.getTotalSize() - (virtualColumns[virtualColumns.length - 1]?.end ?? 0) - rightWidth > 0 ? columnVirtualizer.getTotalSize() - (virtualColumns[virtualColumns.length - 1]?.end ?? 0) - rightWidth : 0;
|
|
94
119
|
virtualPaddingRight = fixedRightColumns && fixedRightColumns.length > 0 ? pdRight - rightWidth > 0 ? pdRight - rightWidth : 0 : pdRight;
|
|
120
|
+
// virtualPaddingRight = columnVirtualizer.getTotalSize() - (virtualColumns[virtualColumns.length - 1]?.end ?? 0)
|
|
95
121
|
}
|
|
122
|
+
const triggerCommandClick = () => {};
|
|
96
123
|
return /*#__PURE__*/React.createElement("div", {
|
|
97
124
|
ref: containerRef,
|
|
98
125
|
id: id
|
|
@@ -115,16 +142,18 @@ const TableContainer = props => {
|
|
|
115
142
|
items: (toolbarItems ?? []).filter(it => it.position !== 'Bottom'),
|
|
116
143
|
mode: 'scroll'
|
|
117
144
|
})), fullScreen !== false && (isFullScreen ? /*#__PURE__*/React.createElement(Minimize, {
|
|
118
|
-
fontSize: 16
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
145
|
+
fontSize: 16,
|
|
146
|
+
onClick: () => {
|
|
147
|
+
setIsFullScreen(!isFullScreen);
|
|
148
|
+
},
|
|
149
|
+
"data-tooltip-id": `${id}-tooltip-content`,
|
|
122
150
|
"data-tooltip-content": t ? t('Minimized') : 'Minimized'
|
|
123
151
|
}) : /*#__PURE__*/React.createElement(Maximize, {
|
|
124
|
-
fontSize: 16
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
152
|
+
fontSize: 16,
|
|
153
|
+
onClick: () => {
|
|
154
|
+
setIsFullScreen(!isFullScreen);
|
|
155
|
+
},
|
|
156
|
+
"data-tooltip-id": `${id}-tooltip-content`,
|
|
128
157
|
"data-tooltip-content": t ? t('Full screen') : 'Full screen'
|
|
129
158
|
})), /*#__PURE__*/React.createElement("div", {
|
|
130
159
|
style: {
|
|
@@ -138,9 +167,9 @@ const TableContainer = props => {
|
|
|
138
167
|
responsive: true,
|
|
139
168
|
size: 'small',
|
|
140
169
|
rootClassName: 'top-pagination',
|
|
141
|
-
showTotal: (
|
|
170
|
+
showTotal: (totalItems, range) =>
|
|
142
171
|
// @ts-ignore
|
|
143
|
-
`${range[0]}-${range[1]} / ${
|
|
172
|
+
`${range[0]}-${range[1]} / ${totalItems} ${t ? t(pagination?.locale?.items ?? 'items') : 'items'}`
|
|
144
173
|
}, pagination)), typeof actionTemplate === 'function' ? actionTemplate() : actionTemplate, showColumnChoose && /*#__PURE__*/React.createElement(ColumnsChoose, {
|
|
145
174
|
columnHidden: columnHidden,
|
|
146
175
|
columns: columns,
|
|
@@ -148,23 +177,7 @@ const TableContainer = props => {
|
|
|
148
177
|
t: t,
|
|
149
178
|
columnsGroup: groupColumns,
|
|
150
179
|
triggerChangeColumns: triggerChangeColumns
|
|
151
|
-
})))), /*#__PURE__*/React.createElement(
|
|
152
|
-
className: classNames(`${prefix}-grid-container`, {
|
|
153
|
-
'ui-rc-table-ping-right': tableContainerRef && (tableContainerRef.current?.scrollLeft ?? 0) >= 0 && (tableContainerRef.current?.scrollLeft ?? 0) + (tableContainerRef.current?.clientWidth ?? 0) < (tableContainerRef.current?.scrollWidth ?? 0),
|
|
154
|
-
'ui-rc-table-ping-left': tableContainerRef && (tableContainerRef.current?.scrollLeft ?? 0) > 0
|
|
155
|
-
}),
|
|
156
|
-
id: id,
|
|
157
|
-
ref: tableContainerRef,
|
|
158
|
-
style: {
|
|
159
|
-
overflow: 'auto',
|
|
160
|
-
//our scrollable table container
|
|
161
|
-
position: 'relative',
|
|
162
|
-
//needed for sticky header
|
|
163
|
-
// height: tableHeight ?? '500px' //should be a fixed height
|
|
164
|
-
maxHeight: tableHeight //should be a fixed height
|
|
165
|
-
// minWidth: table.getTotalSize()
|
|
166
|
-
}
|
|
167
|
-
}, /*#__PURE__*/React.createElement(TableContext.Provider, {
|
|
180
|
+
})))), /*#__PURE__*/React.createElement(TableContext.Provider, {
|
|
168
181
|
value: {
|
|
169
182
|
locale,
|
|
170
183
|
prefix,
|
|
@@ -183,44 +196,35 @@ const TableContainer = props => {
|
|
|
183
196
|
setIsSelectionChange,
|
|
184
197
|
onContextMenu,
|
|
185
198
|
setSorterChange,
|
|
186
|
-
setFilterChange
|
|
187
|
-
|
|
188
|
-
}, /*#__PURE__*/React.createElement("table", {
|
|
189
|
-
style: {
|
|
190
|
-
display: 'grid',
|
|
191
|
-
minWidth: table.getTotalSize()
|
|
199
|
+
setFilterChange,
|
|
200
|
+
windowSize
|
|
192
201
|
}
|
|
193
|
-
}, /*#__PURE__*/React.createElement(
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
virtualPaddingRight: virtualPaddingRight,
|
|
199
|
-
fixedLeftColumns: fixedLeftColumns,
|
|
200
|
-
fixedRightColumns: fixedRightColumns
|
|
201
|
-
}), /*#__PURE__*/React.createElement(TableBody, {
|
|
202
|
-
tableId: id,
|
|
203
|
-
columnVirtualizer: columnVirtualizer,
|
|
202
|
+
}, /*#__PURE__*/React.createElement(TableWrapper, {
|
|
203
|
+
contextMenuItems: contextMenuItems,
|
|
204
|
+
height: tableHeight,
|
|
205
|
+
id: id,
|
|
206
|
+
prefix: prefix,
|
|
204
207
|
table: table,
|
|
205
208
|
tableContainerRef: tableContainerRef,
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
commandClick: commandClick,
|
|
209
|
+
commandClick: triggerCommandClick,
|
|
210
|
+
contextMenuClick: contextMenuClick,
|
|
211
|
+
contextMenuHidden: contextMenuHidden,
|
|
212
|
+
contextMenuOpen: contextMenuOpen,
|
|
211
213
|
editAble: editAble,
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
214
|
+
showEmptyText: showEmptyText,
|
|
215
|
+
summary: summary,
|
|
216
|
+
dataSource: dataSource,
|
|
217
|
+
infiniteScroll: infiniteScroll,
|
|
218
|
+
next: next,
|
|
219
|
+
loading: loading,
|
|
215
220
|
columnVirtualizer: columnVirtualizer,
|
|
216
|
-
table: table,
|
|
217
221
|
virtualPaddingLeft: virtualPaddingLeft,
|
|
218
222
|
virtualPaddingRight: virtualPaddingRight,
|
|
219
223
|
fixedLeftColumns: fixedLeftColumns,
|
|
220
224
|
fixedRightColumns: fixedRightColumns
|
|
221
|
-
}))
|
|
225
|
+
})), /*#__PURE__*/React.createElement("div", {
|
|
222
226
|
ref: bottomToolbarRef
|
|
223
|
-
}, pagination && /*#__PURE__*/React.createElement(Pagination
|
|
227
|
+
}, pagination && !infiniteScroll && /*#__PURE__*/React.createElement(Pagination
|
|
224
228
|
// style={{padding: '0.75rem 1rem'}}
|
|
225
229
|
, _extends({}, pagination, {
|
|
226
230
|
rootClassName: 'pagination-template',
|
|
@@ -229,20 +233,20 @@ const TableContainer = props => {
|
|
|
229
233
|
size: 'small',
|
|
230
234
|
total: pagination.total,
|
|
231
235
|
pageSize: pagination.onChange ? pagination.pageSize : table.getState().pagination.pageSize,
|
|
232
|
-
showTotal: (
|
|
236
|
+
showTotal: (totalItems, range) => `${numericFormatter((range[0] ?? 0).toString(), {
|
|
233
237
|
thousandSeparator: '.'
|
|
234
238
|
})}-${numericFormatter((range[1] ?? 0).toString(), {
|
|
235
239
|
thousandSeparator: '.'
|
|
236
|
-
})} / ${numericFormatter((
|
|
240
|
+
})} / ${numericFormatter((totalItems ?? 0).toString(), {
|
|
237
241
|
thousandSeparator: '.'
|
|
238
242
|
})} items`,
|
|
239
243
|
pageSizeOptions: [20, 50, 100, 1000, 10000],
|
|
240
|
-
onChange: (page,
|
|
244
|
+
onChange: (page, pageSize1) => {
|
|
241
245
|
if (pagination.onChange) {
|
|
242
|
-
pagination.onChange(page,
|
|
246
|
+
pagination.onChange(page, pageSize1);
|
|
243
247
|
} else {
|
|
244
248
|
table.setPageIndex(page - 1);
|
|
245
|
-
table.setPageSize(
|
|
249
|
+
table.setPageSize(pageSize1);
|
|
246
250
|
}
|
|
247
251
|
}
|
|
248
252
|
}))));
|
|
@@ -18,6 +18,10 @@ type TableContainerProps<T> = Omit<TableProps<T>, 'columns'> & {
|
|
|
18
18
|
setFilterChange: Dispatch<SetStateAction<boolean>>;
|
|
19
19
|
onContextMenu?: (data: T) => (event: any) => void;
|
|
20
20
|
tableHeight?: number;
|
|
21
|
+
windowSize: {
|
|
22
|
+
innerHeight: number;
|
|
23
|
+
innerWidth: number;
|
|
24
|
+
};
|
|
21
25
|
triggerPaste?: (pastedRows: T[], pastedColumnsArray: string[], newData: T[], copyRows: T[]) => void;
|
|
22
26
|
mergedFilterKeys?: any;
|
|
23
27
|
setMergedFilterKeys?: any;
|