es-grid-template 1.7.26 → 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 +160 -122
- package/es/table-component/TableContainer.d.ts +6 -0
- package/es/table-component/TableContainer.js +74 -70
- package/es/table-component/TableContainerEdit.d.ts +6 -0
- package/es/table-component/TableContainerEdit.js +372 -92
- package/es/table-component/body/TableBody.d.ts +2 -8
- package/es/table-component/body/TableBody.js +28 -0
- package/es/table-component/body/TableBodyCell.d.ts +1 -1
- package/es/table-component/body/TableBodyCell.js +28 -14
- package/es/table-component/body/TableBodyCellEdit.d.ts +1 -1
- package/es/table-component/body/TableBodyCellEdit.js +44 -28
- 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 +14 -11
- 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 +6 -28
- package/es/table-component/header/TableHeadCell.d.ts +2 -3
- package/es/table-component/header/TableHeadCell.js +25 -55
- package/es/table-component/header/TableHeadRow.d.ts +6 -7
- package/es/table-component/header/TableHeadRow.js +37 -62
- package/es/table-component/hook/convert.d.ts +1 -0
- package/es/table-component/hook/convert.js +28 -0
- package/es/table-component/hook/useColumns.js +1 -0
- package/es/table-component/hook/utils.js +3 -0
- package/es/table-component/style.scss +61 -50
- package/es/table-component/table/Grid.d.ts +3 -0
- package/es/table-component/table/Grid.js +9 -5
- 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 +9 -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 +161 -122
- package/lib/table-component/TableContainer.d.ts +6 -0
- package/lib/table-component/TableContainer.js +76 -70
- package/lib/table-component/TableContainerEdit.d.ts +6 -0
- package/lib/table-component/TableContainerEdit.js +368 -90
- package/lib/table-component/body/TableBody.d.ts +2 -8
- package/lib/table-component/body/TableBody.js +29 -0
- package/lib/table-component/body/TableBodyCell.d.ts +1 -1
- package/lib/table-component/body/TableBodyCell.js +28 -14
- package/lib/table-component/body/TableBodyCellEdit.d.ts +1 -1
- package/lib/table-component/body/TableBodyCellEdit.js +44 -28
- 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 +15 -11
- 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 +6 -28
- package/lib/table-component/header/TableHeadCell.d.ts +2 -3
- package/lib/table-component/header/TableHeadCell.js +25 -54
- package/lib/table-component/header/TableHeadRow.d.ts +6 -7
- package/lib/table-component/header/TableHeadRow.js +37 -62
- package/lib/table-component/hook/convert.d.ts +1 -0
- package/lib/table-component/hook/convert.js +34 -0
- package/lib/table-component/hook/useColumns.js +1 -0
- package/lib/table-component/hook/utils.js +3 -0
- package/lib/table-component/style.scss +61 -50
- package/lib/table-component/table/Grid.d.ts +3 -0
- package/lib/table-component/table/Grid.js +9 -5
- 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 +9 -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,
|
|
@@ -36,6 +36,8 @@ filterDataByColumns, flatColumns2,
|
|
|
36
36
|
getAllRowKey, getDiffent2Array, getFixedFields, getInvisibleColumns, groupArrayByColumns } from "./hook/utils";
|
|
37
37
|
// import GridEdit from './table/GridEdit'
|
|
38
38
|
import { convertToTanStackColumns } from "./hook/useColumns";
|
|
39
|
+
import { convertColumns } from "./hook/convert";
|
|
40
|
+
import { Modal } from 'antd';
|
|
39
41
|
// import { columns111 } from '../test-2/columns'
|
|
40
42
|
|
|
41
43
|
dayjs.extend(customParseFormat);
|
|
@@ -59,14 +61,15 @@ const InternalTable = props => {
|
|
|
59
61
|
groupAble,
|
|
60
62
|
groupSetting,
|
|
61
63
|
groupColumns,
|
|
62
|
-
infiniteScroll,
|
|
64
|
+
// infiniteScroll,
|
|
63
65
|
// wrapSettings,
|
|
64
66
|
// onFilter,
|
|
65
67
|
// expandable,
|
|
66
|
-
contextMenuItems: propContextMenuItems,
|
|
67
|
-
contextMenuHidden,
|
|
68
|
+
// contextMenuItems: propContextMenuItems,
|
|
69
|
+
// contextMenuHidden,
|
|
68
70
|
contextMenuClick,
|
|
69
71
|
contextMenuOpen,
|
|
72
|
+
height,
|
|
70
73
|
...rest
|
|
71
74
|
} = props;
|
|
72
75
|
const id = React.useMemo(() => {
|
|
@@ -105,22 +108,24 @@ const InternalTable = props => {
|
|
|
105
108
|
// }
|
|
106
109
|
// }
|
|
107
110
|
|
|
108
|
-
const menuRef = React.useRef(null)
|
|
109
|
-
const viewportWidth = windowSize.innerWidth
|
|
110
|
-
const viewportHeight = windowSize.innerHeight
|
|
111
|
-
|
|
112
|
-
const [
|
|
113
|
-
const [
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
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 })
|
|
119
123
|
|
|
120
124
|
// const [tooltipContent, setTooltipContent] = useState<any>('')
|
|
121
125
|
|
|
122
126
|
const [filterStates, setFilterState] = React.useState(null);
|
|
123
127
|
const [sorterStates, setSorterStates] = React.useState([]);
|
|
128
|
+
const [isFullScreen, setIsFullScreen] = React.useState(false);
|
|
124
129
|
const [expanded, setExpanded] = React.useState({});
|
|
125
130
|
const convertData = React.useMemo(() => {
|
|
126
131
|
if (groupAble && groupSetting && groupSetting.client !== false) {
|
|
@@ -141,7 +146,6 @@ const InternalTable = props => {
|
|
|
141
146
|
|
|
142
147
|
// return convertToTanStackColumns<RecordType>(columns, expanded, setExpanded, expandable)
|
|
143
148
|
}, [t, columns, format, editAble]);
|
|
144
|
-
console.log('mergedColumns', mergedColumns);
|
|
145
149
|
const columnPinning = React.useMemo(() => {
|
|
146
150
|
return {
|
|
147
151
|
left: getFixedFields(columns, 'left'),
|
|
@@ -167,101 +171,81 @@ const InternalTable = props => {
|
|
|
167
171
|
const rsss = getDiffent2Array(aa, keys);
|
|
168
172
|
setColumnsHiddenKeys(rsss);
|
|
169
173
|
};
|
|
170
|
-
const contextMenuItems = React.useMemo(() => {
|
|
171
|
-
if (typeof contextMenuHidden === 'function' && propContextMenuItems && selectedRowData) {
|
|
172
|
-
const hiddenItems = contextMenuHidden({
|
|
173
|
-
rowInfo: {
|
|
174
|
-
rowData: selectedRowData
|
|
175
|
-
}
|
|
176
|
-
});
|
|
177
|
-
return propContextMenuItems.filter(item => !hiddenItems.includes(item?.key));
|
|
178
|
-
}
|
|
179
|
-
if (contextMenuHidden && typeof contextMenuHidden !== 'function' && propContextMenuItems) {
|
|
180
|
-
return propContextMenuItems.filter(item => !contextMenuHidden.includes(item?.key));
|
|
181
|
-
}
|
|
182
|
-
return propContextMenuItems;
|
|
183
|
-
}, [propContextMenuItems, contextMenuHidden, selectedRowData]);
|
|
184
|
-
|
|
185
|
-
// const [columns, setColumns] = React.useState<any[]>([])
|
|
186
|
-
|
|
187
|
-
// React.useEffect(() => {
|
|
188
|
-
// setColumns(propsColumns)
|
|
189
|
-
// }, [propsColumns])
|
|
190
174
|
|
|
191
|
-
// const
|
|
175
|
+
// const contextMenuItems = React.useMemo(() => {
|
|
176
|
+
// if (typeof contextMenuHidden === 'function' && propContextMenuItems && selectedRowData) {
|
|
177
|
+
// const hiddenItems = contextMenuHidden({
|
|
178
|
+
// rowInfo: {
|
|
179
|
+
// rowData: selectedRowData
|
|
180
|
+
// }
|
|
181
|
+
// })
|
|
192
182
|
|
|
193
|
-
//
|
|
194
|
-
//
|
|
195
|
-
// } else {
|
|
196
|
-
|
|
197
|
-
// setFilterState(convertFilters(queries))
|
|
198
|
-
|
|
199
|
-
// const b = filterDataByColumns(convertData, convertFilters(queries), [], [])
|
|
183
|
+
// return propContextMenuItems.filter(item => !(hiddenItems as string[]).includes(item?.key as string))
|
|
184
|
+
// }
|
|
200
185
|
|
|
201
|
-
//
|
|
186
|
+
// if (contextMenuHidden && typeof contextMenuHidden !== 'function' && propContextMenuItems) {
|
|
187
|
+
// return propContextMenuItems.filter(item => !(contextMenuHidden as string[]).includes(item?.key as string))
|
|
188
|
+
// }
|
|
202
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
|
+
// })
|
|
203
246
|
// }
|
|
204
247
|
// }
|
|
205
248
|
|
|
206
|
-
const onContextMenu = data => event => {
|
|
207
|
-
event.preventDefault(); // Ngăn chặn menu mặc định của trình duyệt
|
|
208
|
-
|
|
209
|
-
setSelectedRowData(data);
|
|
210
|
-
contextMenuOpen?.({
|
|
211
|
-
rowInfo: {
|
|
212
|
-
rowData: data
|
|
213
|
-
},
|
|
214
|
-
event
|
|
215
|
-
});
|
|
216
|
-
setMenuVisible(true);
|
|
217
|
-
|
|
218
|
-
// Đợi DOM cập nhật và lấy kích thước menu
|
|
219
|
-
setTimeout(() => {
|
|
220
|
-
const menuElement = menuRef.current; // Lấy menu từ DOM
|
|
221
|
-
const menuWidth = menuElement?.offsetWidth || 200; // Mặc định 200px nếu chưa render
|
|
222
|
-
const menuHeight = menuElement?.offsetHeight; // Mặc định 450px nếu chưa render
|
|
223
|
-
|
|
224
|
-
// Điều chỉnh vị trí menu
|
|
225
|
-
let x = event.clientX;
|
|
226
|
-
let y = event.clientY;
|
|
227
|
-
if (x + menuWidth > viewportWidth) {
|
|
228
|
-
x = x - menuWidth - 10; // Cách cạnh phải 10px
|
|
229
|
-
}
|
|
230
|
-
if (y + menuHeight > viewportHeight) {
|
|
231
|
-
if (y < menuHeight) {
|
|
232
|
-
y = 10;
|
|
233
|
-
} else {
|
|
234
|
-
y = y - 10 - menuHeight; // Cách cạnh dưới 10px
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
setPosition(prevState => ({
|
|
238
|
-
...prevState,
|
|
239
|
-
x,
|
|
240
|
-
y
|
|
241
|
-
}));
|
|
242
|
-
}, 100);
|
|
243
|
-
if (!menuVisible) {
|
|
244
|
-
document.addEventListener(`click`, function onClickOutside(e) {
|
|
245
|
-
const element = e.target;
|
|
246
|
-
const menuContainer = document.querySelector('.popup-context-menu');
|
|
247
|
-
const isInsideContainer = element.closest('.popup-context-menu') && menuContainer;
|
|
248
|
-
if (isInsideContainer) {
|
|
249
|
-
return;
|
|
250
|
-
}
|
|
251
|
-
setMenuVisible(false);
|
|
252
|
-
setPosition(prevState => ({
|
|
253
|
-
...prevState,
|
|
254
|
-
x: undefined,
|
|
255
|
-
y: undefined
|
|
256
|
-
}));
|
|
257
|
-
document.removeEventListener(`click`, onClickOutside);
|
|
258
|
-
});
|
|
259
|
-
}
|
|
260
|
-
};
|
|
261
|
-
|
|
262
|
-
// const TableComponent = infiniteScroll ? InfiniteTable : (groupAble ? Group : editAble ? GridEdit : Grid)
|
|
263
|
-
// const TableComponent = Grid
|
|
264
|
-
|
|
265
249
|
return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement(Grid, _extends({}, rest, {
|
|
266
250
|
t: t,
|
|
267
251
|
id: id,
|
|
@@ -272,7 +256,7 @@ const InternalTable = props => {
|
|
|
272
256
|
format: format
|
|
273
257
|
// columns={columns111 as any}
|
|
274
258
|
,
|
|
275
|
-
columns: mergedColumns,
|
|
259
|
+
columns: convertColumns(mergedColumns),
|
|
276
260
|
propsColumns: columns,
|
|
277
261
|
rowKey: rowKey,
|
|
278
262
|
groupSetting: groupSetting,
|
|
@@ -284,25 +268,79 @@ const InternalTable = props => {
|
|
|
284
268
|
triggerSorter: setSorterStates,
|
|
285
269
|
setMergedFilterKeys: setMergedFilterKeys,
|
|
286
270
|
mergedFilterKeys: mergedFilterKeys,
|
|
287
|
-
expanded: expanded
|
|
288
|
-
|
|
289
|
-
|
|
271
|
+
expanded: expanded
|
|
272
|
+
// onContextMenu={onContextMenu}
|
|
273
|
+
// contextMenuItems={contextMenuItems}
|
|
274
|
+
,
|
|
290
275
|
editAble: editAble,
|
|
291
276
|
triggerChangeColumns: triggerChangeColumns,
|
|
292
|
-
setExpanded: setExpanded
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
id: `${id}-tooltip-content`,
|
|
277
|
+
setExpanded: setExpanded,
|
|
278
|
+
isFullScreen: isFullScreen,
|
|
279
|
+
setIsFullScreen: setIsFullScreen,
|
|
280
|
+
windowSize: windowSize
|
|
281
|
+
})), /*#__PURE__*/React.createElement(Modal, {
|
|
282
|
+
open: isFullScreen,
|
|
283
|
+
footer: null,
|
|
284
|
+
centered: true,
|
|
285
|
+
closable: true,
|
|
286
|
+
width: '100%',
|
|
303
287
|
style: {
|
|
304
|
-
|
|
288
|
+
maxWidth: '100%',
|
|
289
|
+
height: '100%'
|
|
290
|
+
},
|
|
291
|
+
onClose: () => setIsFullScreen(false),
|
|
292
|
+
onCancel: () => setIsFullScreen(false)
|
|
293
|
+
|
|
294
|
+
// destroyOnClose
|
|
295
|
+
,
|
|
296
|
+
styles: {
|
|
297
|
+
content: {
|
|
298
|
+
height: '100vh',
|
|
299
|
+
borderRadius: 0,
|
|
300
|
+
padding: '15px 10px'
|
|
301
|
+
},
|
|
302
|
+
wrapper: {
|
|
303
|
+
zIndex: 1050
|
|
304
|
+
}
|
|
305
|
+
},
|
|
306
|
+
destroyOnClose: true
|
|
307
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
308
|
+
style: {
|
|
309
|
+
paddingTop: 40
|
|
305
310
|
}
|
|
306
|
-
}
|
|
311
|
+
}, /*#__PURE__*/React.createElement(Grid, _extends({}, rest, {
|
|
312
|
+
t: t,
|
|
313
|
+
id: isFullScreen ? faker.string.alpha(20) : id,
|
|
314
|
+
prefix: prefix,
|
|
315
|
+
originData: convertData,
|
|
316
|
+
dataSource: mergedData,
|
|
317
|
+
locale: locale,
|
|
318
|
+
format: format
|
|
319
|
+
// columns={columns111 as any}
|
|
320
|
+
,
|
|
321
|
+
columns: convertColumns(mergedColumns),
|
|
322
|
+
propsColumns: columns,
|
|
323
|
+
rowKey: rowKey,
|
|
324
|
+
groupSetting: groupSetting,
|
|
325
|
+
groupAble: groupAble,
|
|
326
|
+
groupColumns: groupColumns,
|
|
327
|
+
columnPinning: columnPinning,
|
|
328
|
+
columnHidden: columnsHiddenKeys ? convertToObj(columnsHiddenKeys) : columnVisibility,
|
|
329
|
+
triggerFilter: setFilterState,
|
|
330
|
+
triggerSorter: setSorterStates,
|
|
331
|
+
setMergedFilterKeys: setMergedFilterKeys,
|
|
332
|
+
mergedFilterKeys: mergedFilterKeys,
|
|
333
|
+
expanded: expanded
|
|
334
|
+
// onContextMenu={onContextMenu}
|
|
335
|
+
// contextMenuItems={contextMenuItems}
|
|
336
|
+
,
|
|
337
|
+
editAble: editAble,
|
|
338
|
+
triggerChangeColumns: triggerChangeColumns,
|
|
339
|
+
setExpanded: setExpanded,
|
|
340
|
+
isFullScreen: isFullScreen,
|
|
341
|
+
setIsFullScreen: setIsFullScreen,
|
|
342
|
+
height: windowSize.innerHeight - 70,
|
|
343
|
+
windowSize: windowSize
|
|
344
|
+
})))));
|
|
307
345
|
};
|
|
308
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;
|
|
@@ -26,6 +30,8 @@ type TableContainerProps<T> = Omit<TableProps<T>, 'columns'> & {
|
|
|
26
30
|
columns: ColumnDef<T>[];
|
|
27
31
|
triggerChangeColumns: any;
|
|
28
32
|
columnHidden: any;
|
|
33
|
+
isFullScreen: boolean;
|
|
34
|
+
setIsFullScreen: Dispatch<SetStateAction<boolean>>;
|
|
29
35
|
};
|
|
30
36
|
declare const TableContainerEdit: <RecordType extends object>(props: TableContainerProps<RecordType>) => React.JSX.Element;
|
|
31
37
|
export default TableContainerEdit;
|