es-grid-template 1.7.27 → 1.7.29
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 -1
- package/es/table-component/TableContainer.js +82 -74
- package/es/table-component/TableContainerEdit.d.ts +4 -0
- package/es/table-component/TableContainerEdit.js +370 -85
- 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 -12
- package/es/table-component/body/TableBodyCellEdit.d.ts +1 -1
- package/es/table-component/body/TableBodyCellEdit.js +44 -19
- 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 +11 -9
- package/es/table-component/header/TableHeadRow.d.ts +6 -6
- package/es/table-component/header/TableHeadRow.js +10 -32
- package/es/table-component/hook/utils.js +1 -1
- package/es/table-component/style.scss +26 -2
- package/es/table-component/table/Grid.d.ts +1 -0
- package/es/table-component/table/Grid.js +12 -6
- package/es/table-component/table/TableWrapper.d.ts +33 -0
- package/es/table-component/table/TableWrapper.js +245 -0
- package/es/table-component/type.d.ts +5 -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 -1
- package/lib/table-component/TableContainer.js +84 -74
- package/lib/table-component/TableContainerEdit.d.ts +4 -0
- package/lib/table-component/TableContainerEdit.js +366 -83
- 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 -12
- package/lib/table-component/body/TableBodyCellEdit.d.ts +1 -1
- package/lib/table-component/body/TableBodyCellEdit.js +43 -19
- 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 +11 -8
- package/lib/table-component/header/TableHeadRow.d.ts +6 -6
- package/lib/table-component/header/TableHeadRow.js +10 -32
- package/lib/table-component/hook/utils.js +1 -1
- package/lib/table-component/style.scss +26 -2
- package/lib/table-component/table/Grid.d.ts +1 -0
- package/lib/table-component/table/Grid.js +12 -6
- package/lib/table-component/table/TableWrapper.d.ts +33 -0
- package/lib/table-component/table/TableWrapper.js +254 -0
- package/lib/table-component/type.d.ts +5 -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;
|
|
@@ -16,7 +16,10 @@ type TableContainerProps<T> = Omit<TableProps<T>, 'columns'> & {
|
|
|
16
16
|
setSorterChange: Dispatch<SetStateAction<boolean>>;
|
|
17
17
|
setFilterChange: Dispatch<SetStateAction<boolean>>;
|
|
18
18
|
onContextMenu?: (data: T) => (event: any) => void;
|
|
19
|
-
|
|
19
|
+
windowSize: {
|
|
20
|
+
innerHeight: number;
|
|
21
|
+
innerWidth: number;
|
|
22
|
+
};
|
|
20
23
|
triggerPaste?: (pastedRows: T[], pastedColumnsArray: string[], newData: T[], copyRows: T[]) => void;
|
|
21
24
|
mergedFilterKeys?: any;
|
|
22
25
|
setMergedFilterKeys?: any;
|
|
@@ -26,6 +29,8 @@ type TableContainerProps<T> = Omit<TableProps<T>, 'columns'> & {
|
|
|
26
29
|
propsColumns: ColumnsTable;
|
|
27
30
|
triggerChangeColumns: any;
|
|
28
31
|
columnHidden: any;
|
|
32
|
+
isFullScreen: boolean;
|
|
33
|
+
setIsFullScreen: Dispatch<SetStateAction<boolean>>;
|
|
29
34
|
};
|
|
30
35
|
declare const TableContainer: <RecordType extends object>(props: TableContainerProps<RecordType>) => React.JSX.Element;
|
|
31
36
|
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,
|
|
@@ -38,6 +44,7 @@ const TableContainer = props => {
|
|
|
38
44
|
setSorterChange,
|
|
39
45
|
setFilterChange,
|
|
40
46
|
height,
|
|
47
|
+
minHeight,
|
|
41
48
|
showToolbar,
|
|
42
49
|
toolbarItems,
|
|
43
50
|
actionTemplate,
|
|
@@ -53,30 +60,48 @@ const TableContainer = props => {
|
|
|
53
60
|
columnHidden,
|
|
54
61
|
expanded,
|
|
55
62
|
setExpanded,
|
|
56
|
-
showEmptyText
|
|
63
|
+
showEmptyText,
|
|
64
|
+
infiniteScroll,
|
|
65
|
+
next,
|
|
66
|
+
loading,
|
|
67
|
+
windowSize,
|
|
68
|
+
contextMenuOpen,
|
|
69
|
+
contextMenuClick,
|
|
70
|
+
contextMenuHidden,
|
|
71
|
+
isFullScreen,
|
|
72
|
+
setIsFullScreen
|
|
57
73
|
} = props;
|
|
58
74
|
const tableContainerRef = React.useRef(null);
|
|
59
75
|
const containerRef = React.useRef(null);
|
|
60
76
|
const bottomToolbarRef = React.useRef(null);
|
|
61
77
|
const topToolbarRef = React.useRef(null);
|
|
62
|
-
const visibleColumns = table.getVisibleLeafColumns();
|
|
63
|
-
const [isFullScreen] = React.useState(false);
|
|
64
78
|
const [tableHeight, settableHeight] = React.useState(0);
|
|
65
79
|
React.useEffect(() => {
|
|
66
|
-
const totalHeight = height;
|
|
67
|
-
if (totalHeight
|
|
68
|
-
|
|
80
|
+
const totalHeight = minHeight ?? height;
|
|
81
|
+
if (totalHeight) {
|
|
82
|
+
const topHeight = topToolbarRef.current ? topToolbarRef.current.offsetHeight : 0;
|
|
83
|
+
const bottomHeight = bottomToolbarRef.current ? bottomToolbarRef.current.offsetHeight : 0;
|
|
84
|
+
settableHeight(totalHeight - topHeight - bottomHeight);
|
|
69
85
|
}
|
|
70
|
-
}, [id, height, editAble]);
|
|
86
|
+
}, [id, height, editAble, minHeight]);
|
|
87
|
+
const visibleColumns = table.getVisibleLeafColumns();
|
|
71
88
|
const fixedLeftColumns = table.getState().columnPinning.left ? visibleColumns.filter(vc => table.getState().columnPinning.left?.includes(vc.id)) : [];
|
|
72
89
|
const fixedRightColumns = table.getState().columnPinning.right ? visibleColumns.filter(vc => table.getState().columnPinning.right?.includes(vc.id)) : [];
|
|
90
|
+
|
|
91
|
+
//we are using a slightly different virtualization strategy for columns (compared to virtual rows) in order to support dynamic row heights
|
|
73
92
|
const columnVirtualizer = useVirtualizer({
|
|
74
93
|
count: visibleColumns.length,
|
|
75
94
|
estimateSize: index => visibleColumns[index].getSize(),
|
|
95
|
+
//estimate width of each column for accurate scrollbar dragging
|
|
76
96
|
getScrollElement: () => tableContainerRef.current,
|
|
77
97
|
horizontal: true,
|
|
98
|
+
// measureElement(element) {
|
|
99
|
+
|
|
100
|
+
// return element?.getBoundingClientRect().width;
|
|
101
|
+
// },
|
|
102
|
+
|
|
78
103
|
measureElement: typeof window !== 'undefined' && navigator.userAgent.indexOf('Firefox') === -1 ? element => element?.getBoundingClientRect().height : undefined,
|
|
79
|
-
overscan:
|
|
104
|
+
overscan: 1 //how many columns to render on each side off screen each way (adjust this for performance)
|
|
80
105
|
});
|
|
81
106
|
const virtualColumns = columnVirtualizer.getVirtualItems();
|
|
82
107
|
const cacheColumns = columnVirtualizer.measurementsCache;
|
|
@@ -91,8 +116,13 @@ const TableContainer = props => {
|
|
|
91
116
|
const pdRight = columnVirtualizer.getTotalSize() - (virtualColumns[virtualColumns.length - 1]?.end ?? 0);
|
|
92
117
|
if (columnVirtualizer && virtualColumns?.length) {
|
|
93
118
|
virtualPaddingLeft = fixedLeftColumns && fixedLeftColumns.length > 0 ? (virtualColumns[0]?.start ?? 0) - leftWidth > 0 ? (virtualColumns[0]?.start ?? 0) - leftWidth : 0 : virtualColumns[0]?.start ?? 0;
|
|
119
|
+
|
|
120
|
+
// virtualPaddingLeft = leftCols.length === rss.length ? (virtualColumns[0]?.start ?? 0) : 0;
|
|
121
|
+
// columnVirtualizer.getTotalSize() - (virtualColumns[virtualColumns.length - 1]?.end ?? 0) - rightWidth > 0 ? columnVirtualizer.getTotalSize() - (virtualColumns[virtualColumns.length - 1]?.end ?? 0) - rightWidth : 0;
|
|
94
122
|
virtualPaddingRight = fixedRightColumns && fixedRightColumns.length > 0 ? pdRight - rightWidth > 0 ? pdRight - rightWidth : 0 : pdRight;
|
|
123
|
+
// virtualPaddingRight = columnVirtualizer.getTotalSize() - (virtualColumns[virtualColumns.length - 1]?.end ?? 0)
|
|
95
124
|
}
|
|
125
|
+
const triggerCommandClick = () => {};
|
|
96
126
|
return /*#__PURE__*/React.createElement("div", {
|
|
97
127
|
ref: containerRef,
|
|
98
128
|
id: id
|
|
@@ -115,16 +145,18 @@ const TableContainer = props => {
|
|
|
115
145
|
items: (toolbarItems ?? []).filter(it => it.position !== 'Bottom'),
|
|
116
146
|
mode: 'scroll'
|
|
117
147
|
})), fullScreen !== false && (isFullScreen ? /*#__PURE__*/React.createElement(Minimize, {
|
|
118
|
-
fontSize: 16
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
148
|
+
fontSize: 16,
|
|
149
|
+
onClick: () => {
|
|
150
|
+
setIsFullScreen(!isFullScreen);
|
|
151
|
+
},
|
|
152
|
+
"data-tooltip-id": `${id}-tooltip-content`,
|
|
122
153
|
"data-tooltip-content": t ? t('Minimized') : 'Minimized'
|
|
123
154
|
}) : /*#__PURE__*/React.createElement(Maximize, {
|
|
124
|
-
fontSize: 16
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
155
|
+
fontSize: 16,
|
|
156
|
+
onClick: () => {
|
|
157
|
+
setIsFullScreen(!isFullScreen);
|
|
158
|
+
},
|
|
159
|
+
"data-tooltip-id": `${id}-tooltip-content`,
|
|
128
160
|
"data-tooltip-content": t ? t('Full screen') : 'Full screen'
|
|
129
161
|
})), /*#__PURE__*/React.createElement("div", {
|
|
130
162
|
style: {
|
|
@@ -138,9 +170,9 @@ const TableContainer = props => {
|
|
|
138
170
|
responsive: true,
|
|
139
171
|
size: 'small',
|
|
140
172
|
rootClassName: 'top-pagination',
|
|
141
|
-
showTotal: (
|
|
173
|
+
showTotal: (totalItems, range) =>
|
|
142
174
|
// @ts-ignore
|
|
143
|
-
`${range[0]}-${range[1]} / ${
|
|
175
|
+
`${range[0]}-${range[1]} / ${totalItems} ${t ? t(pagination?.locale?.items ?? 'items') : 'items'}`
|
|
144
176
|
}, pagination)), typeof actionTemplate === 'function' ? actionTemplate() : actionTemplate, showColumnChoose && /*#__PURE__*/React.createElement(ColumnsChoose, {
|
|
145
177
|
columnHidden: columnHidden,
|
|
146
178
|
columns: columns,
|
|
@@ -148,23 +180,7 @@ const TableContainer = props => {
|
|
|
148
180
|
t: t,
|
|
149
181
|
columnsGroup: groupColumns,
|
|
150
182
|
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, {
|
|
183
|
+
})))), /*#__PURE__*/React.createElement(TableContext.Provider, {
|
|
168
184
|
value: {
|
|
169
185
|
locale,
|
|
170
186
|
prefix,
|
|
@@ -183,44 +199,36 @@ const TableContainer = props => {
|
|
|
183
199
|
setIsSelectionChange,
|
|
184
200
|
onContextMenu,
|
|
185
201
|
setSorterChange,
|
|
186
|
-
setFilterChange
|
|
187
|
-
|
|
188
|
-
}, /*#__PURE__*/React.createElement("table", {
|
|
189
|
-
style: {
|
|
190
|
-
display: 'grid',
|
|
191
|
-
minWidth: table.getTotalSize()
|
|
202
|
+
setFilterChange,
|
|
203
|
+
windowSize
|
|
192
204
|
}
|
|
193
|
-
}, /*#__PURE__*/React.createElement(
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
fixedLeftColumns: fixedLeftColumns,
|
|
200
|
-
fixedRightColumns: fixedRightColumns
|
|
201
|
-
}), /*#__PURE__*/React.createElement(TableBody, {
|
|
202
|
-
tableId: id,
|
|
203
|
-
columnVirtualizer: columnVirtualizer,
|
|
205
|
+
}, /*#__PURE__*/React.createElement(TableWrapper, {
|
|
206
|
+
contextMenuItems: contextMenuItems,
|
|
207
|
+
height: tableHeight,
|
|
208
|
+
minHeight: minHeight,
|
|
209
|
+
id: id,
|
|
210
|
+
prefix: prefix,
|
|
204
211
|
table: table,
|
|
205
212
|
tableContainerRef: tableContainerRef,
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
commandClick: commandClick,
|
|
213
|
+
commandClick: triggerCommandClick,
|
|
214
|
+
contextMenuClick: contextMenuClick,
|
|
215
|
+
contextMenuHidden: contextMenuHidden,
|
|
216
|
+
contextMenuOpen: contextMenuOpen,
|
|
211
217
|
editAble: editAble,
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
218
|
+
showEmptyText: showEmptyText,
|
|
219
|
+
summary: summary,
|
|
220
|
+
dataSource: dataSource,
|
|
221
|
+
infiniteScroll: infiniteScroll,
|
|
222
|
+
next: next,
|
|
223
|
+
loading: loading,
|
|
215
224
|
columnVirtualizer: columnVirtualizer,
|
|
216
|
-
table: table,
|
|
217
225
|
virtualPaddingLeft: virtualPaddingLeft,
|
|
218
226
|
virtualPaddingRight: virtualPaddingRight,
|
|
219
227
|
fixedLeftColumns: fixedLeftColumns,
|
|
220
228
|
fixedRightColumns: fixedRightColumns
|
|
221
|
-
}))
|
|
229
|
+
})), /*#__PURE__*/React.createElement("div", {
|
|
222
230
|
ref: bottomToolbarRef
|
|
223
|
-
}, pagination && /*#__PURE__*/React.createElement(Pagination
|
|
231
|
+
}, pagination && !infiniteScroll && /*#__PURE__*/React.createElement(Pagination
|
|
224
232
|
// style={{padding: '0.75rem 1rem'}}
|
|
225
233
|
, _extends({}, pagination, {
|
|
226
234
|
rootClassName: 'pagination-template',
|
|
@@ -229,20 +237,20 @@ const TableContainer = props => {
|
|
|
229
237
|
size: 'small',
|
|
230
238
|
total: pagination.total,
|
|
231
239
|
pageSize: pagination.onChange ? pagination.pageSize : table.getState().pagination.pageSize,
|
|
232
|
-
showTotal: (
|
|
240
|
+
showTotal: (totalItems, range) => `${numericFormatter((range[0] ?? 0).toString(), {
|
|
233
241
|
thousandSeparator: '.'
|
|
234
242
|
})}-${numericFormatter((range[1] ?? 0).toString(), {
|
|
235
243
|
thousandSeparator: '.'
|
|
236
|
-
})} / ${numericFormatter((
|
|
244
|
+
})} / ${numericFormatter((totalItems ?? 0).toString(), {
|
|
237
245
|
thousandSeparator: '.'
|
|
238
246
|
})} items`,
|
|
239
247
|
pageSizeOptions: [20, 50, 100, 1000, 10000],
|
|
240
|
-
onChange: (page,
|
|
248
|
+
onChange: (page, pageSize1) => {
|
|
241
249
|
if (pagination.onChange) {
|
|
242
|
-
pagination.onChange(page,
|
|
250
|
+
pagination.onChange(page, pageSize1);
|
|
243
251
|
} else {
|
|
244
252
|
table.setPageIndex(page - 1);
|
|
245
|
-
table.setPageSize(
|
|
253
|
+
table.setPageSize(pageSize1);
|
|
246
254
|
}
|
|
247
255
|
}
|
|
248
256
|
}))));
|
|
@@ -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;
|