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.
Files changed (93) hide show
  1. package/es/grid-component/InternalTable.js +31 -36
  2. package/es/grid-component/TempTable.d.ts +4 -0
  3. package/es/grid-component/TempTable.js +21 -0
  4. package/es/grid-component/hooks/columns/index.js +3 -1
  5. package/es/grid-component/index.d.ts +2 -2
  6. package/es/grid-component/index.js +6 -4
  7. package/es/grid-component/styles.scss +0 -1
  8. package/es/grid-component/table/GridEdit.js +112 -96
  9. package/es/grid-component/type.d.ts +7 -1
  10. package/es/table-component/InternalTable.js +160 -122
  11. package/es/table-component/TableContainer.d.ts +6 -0
  12. package/es/table-component/TableContainer.js +74 -70
  13. package/es/table-component/TableContainerEdit.d.ts +6 -0
  14. package/es/table-component/TableContainerEdit.js +372 -92
  15. package/es/table-component/body/TableBody.d.ts +2 -8
  16. package/es/table-component/body/TableBody.js +28 -0
  17. package/es/table-component/body/TableBodyCell.d.ts +1 -1
  18. package/es/table-component/body/TableBodyCell.js +28 -14
  19. package/es/table-component/body/TableBodyCellEdit.d.ts +1 -1
  20. package/es/table-component/body/TableBodyCellEdit.js +44 -28
  21. package/es/table-component/body/TableBodyRow.d.ts +3 -3
  22. package/es/table-component/body/TableBodyRow.js +4 -6
  23. package/es/table-component/footer/TableFooter.d.ts +2 -8
  24. package/es/table-component/footer/TableFooter.js +14 -13
  25. package/es/table-component/footer/TableFooterCell.d.ts +3 -6
  26. package/es/table-component/footer/TableFooterCell.js +14 -11
  27. package/es/table-component/footer/TableFooterRow.d.ts +2 -8
  28. package/es/table-component/footer/TableFooterRow.js +23 -48
  29. package/es/table-component/header/TableHead.d.ts +4 -3
  30. package/es/table-component/header/TableHead.js +6 -28
  31. package/es/table-component/header/TableHeadCell.d.ts +2 -3
  32. package/es/table-component/header/TableHeadCell.js +25 -55
  33. package/es/table-component/header/TableHeadRow.d.ts +6 -7
  34. package/es/table-component/header/TableHeadRow.js +37 -62
  35. package/es/table-component/hook/convert.d.ts +1 -0
  36. package/es/table-component/hook/convert.js +28 -0
  37. package/es/table-component/hook/useColumns.js +1 -0
  38. package/es/table-component/hook/utils.js +3 -0
  39. package/es/table-component/style.scss +61 -50
  40. package/es/table-component/table/Grid.d.ts +3 -0
  41. package/es/table-component/table/Grid.js +9 -5
  42. package/es/table-component/table/TableWrapper.d.ts +32 -0
  43. package/es/table-component/table/TableWrapper.js +242 -0
  44. package/es/table-component/type.d.ts +9 -4
  45. package/es/table-component/useContext.d.ts +4 -0
  46. package/es/table-component/useContext.js +4 -0
  47. package/lib/grid-component/InternalTable.js +30 -35
  48. package/lib/grid-component/TempTable.d.ts +4 -0
  49. package/lib/grid-component/TempTable.js +30 -0
  50. package/lib/grid-component/hooks/columns/index.js +3 -1
  51. package/lib/grid-component/index.d.ts +2 -2
  52. package/lib/grid-component/index.js +5 -3
  53. package/lib/grid-component/styles.scss +0 -1
  54. package/lib/grid-component/table/GridEdit.js +112 -96
  55. package/lib/grid-component/type.d.ts +7 -1
  56. package/lib/table-component/InternalTable.js +161 -122
  57. package/lib/table-component/TableContainer.d.ts +6 -0
  58. package/lib/table-component/TableContainer.js +76 -70
  59. package/lib/table-component/TableContainerEdit.d.ts +6 -0
  60. package/lib/table-component/TableContainerEdit.js +368 -90
  61. package/lib/table-component/body/TableBody.d.ts +2 -8
  62. package/lib/table-component/body/TableBody.js +29 -0
  63. package/lib/table-component/body/TableBodyCell.d.ts +1 -1
  64. package/lib/table-component/body/TableBodyCell.js +28 -14
  65. package/lib/table-component/body/TableBodyCellEdit.d.ts +1 -1
  66. package/lib/table-component/body/TableBodyCellEdit.js +44 -28
  67. package/lib/table-component/body/TableBodyRow.d.ts +3 -3
  68. package/lib/table-component/body/TableBodyRow.js +4 -6
  69. package/lib/table-component/footer/TableFooter.d.ts +2 -8
  70. package/lib/table-component/footer/TableFooter.js +15 -13
  71. package/lib/table-component/footer/TableFooterCell.d.ts +3 -6
  72. package/lib/table-component/footer/TableFooterCell.js +15 -11
  73. package/lib/table-component/footer/TableFooterRow.d.ts +2 -8
  74. package/lib/table-component/footer/TableFooterRow.js +23 -48
  75. package/lib/table-component/header/TableHead.d.ts +4 -3
  76. package/lib/table-component/header/TableHead.js +6 -28
  77. package/lib/table-component/header/TableHeadCell.d.ts +2 -3
  78. package/lib/table-component/header/TableHeadCell.js +25 -54
  79. package/lib/table-component/header/TableHeadRow.d.ts +6 -7
  80. package/lib/table-component/header/TableHeadRow.js +37 -62
  81. package/lib/table-component/hook/convert.d.ts +1 -0
  82. package/lib/table-component/hook/convert.js +34 -0
  83. package/lib/table-component/hook/useColumns.js +1 -0
  84. package/lib/table-component/hook/utils.js +3 -0
  85. package/lib/table-component/style.scss +61 -50
  86. package/lib/table-component/table/Grid.d.ts +3 -0
  87. package/lib/table-component/table/Grid.js +9 -5
  88. package/lib/table-component/table/TableWrapper.d.ts +32 -0
  89. package/lib/table-component/table/TableWrapper.js +251 -0
  90. package/lib/table-component/type.d.ts +9 -4
  91. package/lib/table-component/useContext.d.ts +4 -0
  92. package/lib/table-component/useContext.js +4 -0
  93. package/package.json +1 -1
@@ -1,8 +1,8 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import React, { Fragment } from "react";
3
- import TableBody from "./body/TableBody";
4
- import TableHead from "./header/TableHead";
5
- import { checkDecimalSeparator, checkThousandSeparator, detectSeparators, findItemByKey, flattenArray, flattenData, getAllRowKey, getColIdsBetween, getDefaultValue, getFormat, getRowIdsBetween, getSelectedCellMatrix, isEditable, isFormattedNumber, newGuid, sumSize, unFlattenData, updateArrayByKey, updateOrInsert } from "./hook/utils";
3
+ import { checkDecimalSeparator, checkThousandSeparator, detectSeparators, findItemByKey, flattenArray, flattenData, getAllRowKey, getColIdsBetween, getDefaultValue, getFormat, getRowIdsBetween, getSelectedCellMatrix, isEditable, isFormattedNumber, newGuid, sumSize,
4
+ // sumSize,
5
+ unFlattenData, updateArrayByKey, updateOrInsert } from "./hook/utils";
6
6
  import { useVirtualizer } from "@tanstack/react-virtual";
7
7
  import { useForm } from 'react-hook-form';
8
8
  import { Button, Modal, Typography, Dropdown } from "antd";
@@ -12,9 +12,12 @@ import { TableContext } from "./useContext";
12
12
  import { yupResolver } from "@hookform/resolvers/yup";
13
13
  import { Toolbar } from "rc-master-ui";
14
14
  import classNames from "classnames";
15
- import { Maximize, Minimize } from "becoxy-icons";
15
+ import { Maximize, Minimize, Plus, Trash2 } from "becoxy-icons";
16
16
  import { ColumnsChoose } from "./ColumnsChoose";
17
- import TableFooter from "./footer/TableFooter";
17
+ import TableWrapper from "./table/TableWrapper";
18
+ import withReactContent from "sweetalert2-react-content";
19
+ import Swal from "sweetalert2";
20
+ const MySwal = withReactContent(Swal);
18
21
  const {
19
22
  Paragraph,
20
23
  Title
@@ -69,8 +72,8 @@ const TableContainerEdit = props => {
69
72
  // triggerFilter,
70
73
  selectionSettings,
71
74
  setIsSelectionChange,
72
- onContextMenu,
73
- contextMenuItems,
75
+ // onContextMenu,
76
+ contextMenuItems: propsContext,
74
77
  setSorterChange,
75
78
  setFilterChange,
76
79
  // tableHeight,
@@ -100,7 +103,18 @@ const TableContainerEdit = props => {
100
103
  propsColumns,
101
104
  triggerChangeColumns,
102
105
  columnHidden,
103
- showEmptyText
106
+ showEmptyText,
107
+ isFullScreen,
108
+ setIsFullScreen,
109
+ infiniteScroll,
110
+ windowSize,
111
+ next,
112
+ loading,
113
+ contextMenuOpen,
114
+ contextMenuClick,
115
+ contextMenuHidden,
116
+ showDefaultContext,
117
+ commandSettings
104
118
  } = props;
105
119
  const containerRef = React.useRef(null);
106
120
  const bottomToolbarRef = React.useRef(null);
@@ -111,26 +125,126 @@ const TableContainerEdit = props => {
111
125
 
112
126
  // //The virtualizers need to know the scrollable container element
113
127
  const tableContainerRef = React.useRef(null);
114
- const visibleColumns = table.getVisibleLeafColumns();
115
- const fixedLeftColumns = table.getState().columnPinning.left ? visibleColumns.filter(vc => table.getState().columnPinning.left?.includes(vc.id)) : [];
116
- const fixedRightColumns = table.getState().columnPinning.right ? visibleColumns.filter(vc => table.getState().columnPinning.right?.includes(vc.id)) : [];
117
128
 
118
- //we are using a slightly different virtualization strategy for columns (compared to virtual rows) in order to support dynamic row heights
119
- const columnVirtualizer = useVirtualizer({
120
- count: visibleColumns.length,
121
- estimateSize: index => visibleColumns[index].getSize(),
122
- //estimate width of each column for accurate scrollbar dragging
123
- getScrollElement: () => tableContainerRef.current,
124
- horizontal: true,
125
- // measureElement(element) {
129
+ // const columnSizingState = table.getState().columnSizing;
126
130
 
127
- // return element?.getBoundingClientRect().width;
128
- // },
129
-
130
- measureElement: typeof window !== 'undefined' && navigator.userAgent.indexOf('Firefox') === -1 ? element => element?.getBoundingClientRect().height : undefined,
131
- overscan: 1 //how many columns to render on each side off screen each way (adjust this for performance)
132
- });
133
- const columnSizingState = table.getState().columnSizing;
131
+ const defaultContext = React.useMemo(() => {
132
+ return [{
133
+ key: 'INSERT_BEFORE',
134
+ // label: 'Thêm dòng bên trên',
135
+ // label: `${t ? t(locale?.add_rows_before ?? 'Add rows before') : 'Add rows before'}`,
136
+ label: locale?.add_rows_before ?? 'Add rows before',
137
+ icon: /*#__PURE__*/React.createElement(Plus, {
138
+ fontSize: 14
139
+ }),
140
+ children: [{
141
+ parentKey: 'INSERT_BEFORE',
142
+ key: 'INSERT_BEFORE_1',
143
+ label: locale?.add_1 ?? 'Add 1 rows',
144
+ row: 1
145
+ }, {
146
+ parentKey: 'INSERT_BEFORE',
147
+ key: 'INSERT_BEFORE_10',
148
+ label: locale?.add_10 ?? 'Add 10 rows',
149
+ row: 10
150
+ }, {
151
+ parentKey: 'INSERT_BEFORE',
152
+ key: 'INSERT_BEFORE_50',
153
+ label: locale?.add_50 ?? 'Add 50 rows',
154
+ row: 50
155
+ }, {
156
+ parentKey: 'INSERT_BEFORE',
157
+ key: 'INSERT_BEFORE_100',
158
+ label: locale?.add_100 ?? 'Add 100 rows',
159
+ row: 100
160
+ }, {
161
+ parentKey: 'INSERT_BEFORE',
162
+ key: 'INSERT_BEFORE_ADV',
163
+ label: locale?.custom ?? 'Custom'
164
+ }]
165
+ }, {
166
+ key: 'INSERT_AFTER',
167
+ label: locale?.add_rows_after ?? 'Add rows after',
168
+ icon: /*#__PURE__*/React.createElement(Plus, {
169
+ fontSize: 14
170
+ }),
171
+ children: [{
172
+ parentKey: 'INSERT_AFTER',
173
+ key: 'INSERT_AFTER_1',
174
+ label: locale?.add_1 ?? 'Add 1 rows',
175
+ row: 1
176
+ }, {
177
+ parentKey: 'INSERT_AFTER',
178
+ key: 'INSERT_AFTER_10',
179
+ label: locale?.add_10 ?? 'Add 10 rows',
180
+ row: 10
181
+ }, {
182
+ parentKey: 'INSERT_AFTER',
183
+ key: 'INSERT_AFTER_50',
184
+ label: locale?.add_50 ?? 'Add 50 rows',
185
+ row: 50
186
+ }, {
187
+ parentKey: 'INSERT_AFTER',
188
+ key: 'INSERT_AFTER_100',
189
+ label: locale?.add_100 ?? 'Add 100 rows',
190
+ row: 100
191
+ }, {
192
+ parentKey: 'INSERT_AFTER',
193
+ key: 'INSERT_AFTER_ADV',
194
+ label: locale?.custom ?? 'Custom'
195
+ }]
196
+ }, {
197
+ key: 'INSERT_CHILDREN',
198
+ // label: 'Insert item children',
199
+ label: locale?.add_children ?? 'Add children',
200
+ icon: /*#__PURE__*/React.createElement(Plus, {
201
+ fontSize: 14
202
+ })
203
+ // children: [
204
+ // {
205
+ // parentKey: 'INSERT_AFTER',
206
+ // key: 'INSERT_AFTER_1',
207
+ // label: 'Thêm 1 dòng',
208
+ // row: 1
209
+ // },
210
+ // {
211
+ // parentKey: 'INSERT_AFTER',
212
+ // key: 'INSERT_AFTER_10',
213
+ // label: 'Thêm 10 dòng',
214
+ // row: 10
215
+ // },
216
+ // {
217
+ // parentKey: 'INSERT_AFTER',
218
+ // key: 'INSERT_AFTER_50',
219
+ // label: 'Thêm 50 dòng',
220
+ // row: 50
221
+ // },
222
+ // {
223
+ // parentKey: 'INSERT_AFTER',
224
+ // key: 'INSERT_AFTER_100',
225
+ // label: 'Thêm 100 dòng',
226
+ // row: 100
227
+ // },
228
+ // {
229
+ // parentKey: 'INSERT_AFTER',
230
+ // key: 'INSERT_AFTER_ADV',
231
+ // label: 'Tùy chỉnh'
232
+ // }
233
+ // ]
234
+ }, {
235
+ key: 'DELETE_CONTENT',
236
+ label: locale?.delete_content ?? 'Delete content',
237
+ icon: /*#__PURE__*/React.createElement(Trash2, {
238
+ fontSize: 14
239
+ })
240
+ }, {
241
+ key: 'DELETE_ROWS',
242
+ label: locale?.delete_rows ?? 'Delete rows',
243
+ icon: /*#__PURE__*/React.createElement(Trash2, {
244
+ fontSize: 14
245
+ })
246
+ }];
247
+ }, [locale]);
134
248
  const itemsAdd = React.useMemo(() => {
135
249
  return [{
136
250
  key: '10',
@@ -143,12 +257,14 @@ const TableContainerEdit = props => {
143
257
  label: `100 ${t ? t('rows') : 'rows'}`
144
258
  }];
145
259
  }, [t]);
260
+ const contextMenuItems = React.useMemo(() => {
261
+ const a = showDefaultContext !== false ? [...defaultContext] : [];
262
+ const b = propsContext && propsContext.length > 0 ? [...propsContext, {
263
+ type: 'divider'
264
+ }] : [];
265
+ return [...b, ...a];
266
+ }, [defaultContext, propsContext, showDefaultContext]);
146
267
  const [dataErrors, setDataErrors] = React.useState([]);
147
- React.useEffect(() => {
148
- requestAnimationFrame(() => {
149
- columnVirtualizer.measure();
150
- });
151
- }, [columnSizingState, columnVirtualizer]);
152
268
  React.useEffect(() => {
153
269
  if (validate && dataSource && dataSource.length) {
154
270
  validateData(dataSource, validate).then(error => {
@@ -159,6 +275,25 @@ const TableContainerEdit = props => {
159
275
  });
160
276
  }
161
277
  }, [validate, dataSource]);
278
+ const visibleColumns = table.getVisibleLeafColumns();
279
+ const fixedLeftColumns = table.getState().columnPinning.left ? visibleColumns.filter(vc => table.getState().columnPinning.left?.includes(vc.id)) : [];
280
+ const fixedRightColumns = table.getState().columnPinning.right ? visibleColumns.filter(vc => table.getState().columnPinning.right?.includes(vc.id)) : [];
281
+
282
+ //we are using a slightly different virtualization strategy for columns (compared to virtual rows) in order to support dynamic row heights
283
+ const columnVirtualizer = useVirtualizer({
284
+ count: visibleColumns.length,
285
+ estimateSize: index => visibleColumns[index].getSize(),
286
+ //estimate width of each column for accurate scrollbar dragging
287
+ getScrollElement: () => tableContainerRef.current,
288
+ horizontal: true,
289
+ // measureElement(element) {
290
+
291
+ // return element?.getBoundingClientRect().width;
292
+ // },
293
+
294
+ measureElement: typeof window !== 'undefined' && navigator.userAgent.indexOf('Firefox') === -1 ? element => element?.getBoundingClientRect().height : undefined,
295
+ overscan: 1 //how many columns to render on each side off screen each way (adjust this for performance)
296
+ });
162
297
  const virtualColumns = columnVirtualizer.getVirtualItems();
163
298
  const cacheColumns = columnVirtualizer.measurementsCache;
164
299
  const rightCols = table.getState().columnPinning.right?.length ? [...cacheColumns].slice(-(table.getState().columnPinning.right?.length ?? 0)) : [];
@@ -206,7 +341,7 @@ const TableContainerEdit = props => {
206
341
  const [endPasteCell, setEndPasteCell] = React.useState(undefined);
207
342
  const [isSelecting, setIsSelecting] = React.useState(false);
208
343
  const [isPasting, setIsPasting] = React.useState(false);
209
- const [isFullScreen] = React.useState(false);
344
+ // const [isFullScreen] = React.useState(false);
210
345
  const [tableHeight, settableHeight] = React.useState(0);
211
346
  const rowsFocus = React.useMemo(() => {
212
347
  return startCell && endCell ? getRowIdsBetween(table, startCell.rowId, endCell.rowId) : [];
@@ -1096,6 +1231,174 @@ const TableContainerEdit = props => {
1096
1231
  };
1097
1232
  });
1098
1233
  }, [handleAddMulti, handleDeleteAll, handleDeleteRows, handleDuplicate, handleInsertAfter, handleInsertBefore, handleInsertChild, itemsAdd, rowsFocus, t, toolbarItems]);
1234
+ const triggerCommandClick = args => {
1235
+ const {
1236
+ id: idCommand,
1237
+ rowId,
1238
+ rowData,
1239
+ index
1240
+ } = args;
1241
+ const tmpData = [...dataSource];
1242
+ if (idCommand === 'DELETE') {
1243
+ // bật modal confirm
1244
+ if (commandSettings && commandSettings.confirmDialog) {
1245
+ MySwal.fire({
1246
+ title: t ? t('Confirm') : 'Confirm',
1247
+ text: t ? t('Do you want to delete item?') : 'Do you want to delete item?',
1248
+ // icon: 'warning',
1249
+ allowOutsideClick: false,
1250
+ showCancelButton: true,
1251
+ confirmButtonText: t ? t('Delete') : 'Delete',
1252
+ cancelButtonText: t ? t('Cancel') : 'Cancel',
1253
+ customClass: {
1254
+ confirmButton: 'be-button btn-primary',
1255
+ cancelButton: 'be-button btn-danger ms-1'
1256
+ },
1257
+ buttonsStyling: false
1258
+ }).then(async result => {
1259
+ if (result.value) {
1260
+ if (!commandSettings || commandSettings && commandSettings.client !== false) {
1261
+ // client
1262
+
1263
+ // kiểm tra dòng hiện tại có parent
1264
+
1265
+ let newData = [];
1266
+ if (rowData?.parentId) {
1267
+ const parent = findItemByKey(tmpData, rowKey, rowData.parentId);
1268
+ const childData = parent?.children ? [...parent.children] : [];
1269
+ const findIndex = childData.findIndex(obj => obj[rowKey] === rowData[rowKey]);
1270
+ childData.splice(Number(findIndex), 1);
1271
+ const newRowData = {
1272
+ ...parent,
1273
+ children: childData
1274
+ };
1275
+ // const newDataSource = updateArrayByKey(tmpData, newRowData, rowKey as string)
1276
+ newData = updateArrayByKey(tmpData, newRowData, rowKey);
1277
+ } else {
1278
+ tmpData.splice(Number(index), 1);
1279
+ newData = [...tmpData];
1280
+ }
1281
+ if (commandClick) {
1282
+ commandClick({
1283
+ id: idCommand,
1284
+ rowId: rowData.rowId,
1285
+ rowData,
1286
+ index,
1287
+ rows: [...newData]
1288
+ });
1289
+ }
1290
+ } else {
1291
+ // server ~~ không làm gì
1292
+ if (commandClick) {
1293
+ commandClick({
1294
+ id: idCommand,
1295
+ rowId: rowData.rowId,
1296
+ rowData,
1297
+ index,
1298
+ rows: [...originData]
1299
+ });
1300
+ }
1301
+ }
1302
+ } else if (result.dismiss === MySwal.DismissReason.cancel) {}
1303
+ });
1304
+ } else {
1305
+ // -------------------
1306
+
1307
+ if (!commandSettings || commandSettings && commandSettings.client !== false) {
1308
+ // client
1309
+
1310
+ let newData2 = [];
1311
+ if (rowData?.parentId) {
1312
+ const parent = findItemByKey(originData, rowKey, rowData.parentId);
1313
+ const childData = parent?.children ? [...parent.children] : [];
1314
+ const findIndex = childData.findIndex(obj => obj[rowKey] === rowData[rowKey]);
1315
+ childData.splice(Number(findIndex), 1);
1316
+ const newRowData = {
1317
+ ...parent,
1318
+ children: childData
1319
+ };
1320
+ newData2 = updateArrayByKey(tmpData, newRowData, rowKey);
1321
+ } else {
1322
+ tmpData.splice(Number(index), 1);
1323
+ newData2 = [...tmpData];
1324
+ }
1325
+ if (commandClick) {
1326
+ commandClick({
1327
+ id: idCommand,
1328
+ rowId,
1329
+ rowData,
1330
+ index,
1331
+ rows: [...newData2]
1332
+ });
1333
+ }
1334
+ } else {
1335
+ // server
1336
+ if (commandClick) {
1337
+ commandClick({
1338
+ id: idCommand,
1339
+ rowId,
1340
+ rowData,
1341
+ index,
1342
+ rows: [...originData]
1343
+ });
1344
+ }
1345
+ }
1346
+ }
1347
+ } else {
1348
+ if (commandClick) {
1349
+ commandClick({
1350
+ ...args,
1351
+ rows: originData
1352
+ });
1353
+ }
1354
+ }
1355
+ };
1356
+ const triggerContextMenuClick = args => {
1357
+ if (args.item?.parentKey && args.item.parentKey === 'INSERT_BEFORE') {
1358
+ if (args.item.key === 'INSERT_BEFORE_ADV') {
1359
+ // mở Modal
1360
+
1361
+ // setOpenModalAddRow((prev) => (
1362
+ // {
1363
+ // ...prev,
1364
+ // open: true,
1365
+ // type: 'INSERT_BEFORE'
1366
+ // }
1367
+ // ))
1368
+ } else {
1369
+ handleInsertBefore(args.item, args.item.row);
1370
+ }
1371
+ return;
1372
+ }
1373
+ if (args.item?.parentKey && args.item.parentKey === 'INSERT_AFTER') {
1374
+ if (args.item.key === 'INSERT_AFTER_ADV') {
1375
+
1376
+ // setOpenModalAddRow((prev) => (
1377
+ // {
1378
+ // ...prev,
1379
+ // open: true,
1380
+ // type: 'INSERT_AFTER'
1381
+ // }
1382
+ // ))
1383
+ } else {
1384
+ handleInsertAfter(args.item, args.item.row);
1385
+ }
1386
+ return;
1387
+ }
1388
+ if (args.item.key === 'INSERT_CHILDREN') {
1389
+ handleInsertChild(args.item);
1390
+ return;
1391
+ }
1392
+ if (args.item.key === 'DELETE_ROWS') {
1393
+ handleDeleteRows(args.item);
1394
+ return;
1395
+ }
1396
+ if (args.item.key === 'DELETE_CONTENT') {
1397
+ handleDeleteContent();
1398
+ return;
1399
+ }
1400
+ contextMenuClick?.(args);
1401
+ };
1099
1402
  return /*#__PURE__*/React.createElement("div", {
1100
1403
  ref: containerRef,
1101
1404
  id: id
@@ -1109,7 +1412,7 @@ const TableContainerEdit = props => {
1109
1412
  alignItems: 'center',
1110
1413
  gap: '.75rem'
1111
1414
  }
1112
- }, toolbarItems && toolbarItems?.length > 0 && /*#__PURE__*/React.createElement("div", {
1415
+ }, /*#__PURE__*/React.createElement("div", {
1113
1416
  style: {
1114
1417
  flex: 1,
1115
1418
  overflow: 'hidden'
@@ -1117,18 +1420,6 @@ const TableContainerEdit = props => {
1117
1420
  }, /*#__PURE__*/React.createElement(Toolbar, {
1118
1421
  items: (toolbarItems ?? []).filter(it => it.position !== 'Bottom'),
1119
1422
  mode: 'scroll'
1120
- })), fullScreen !== false && (isFullScreen ? /*#__PURE__*/React.createElement(Minimize, {
1121
- fontSize: 16
1122
- // onClick={() => handleFullScreen?.()}
1123
- ,
1124
- "data-tooltip-id": "tooltip-icon",
1125
- "data-tooltip-content": t ? t('Minimized') : 'Minimized'
1126
- }) : /*#__PURE__*/React.createElement(Maximize, {
1127
- fontSize: 16
1128
- // onClick={() => handleFullScreen?.()}
1129
- ,
1130
- "data-tooltip-id": "tooltip-icon",
1131
- "data-tooltip-content": t ? t('Full screen') : 'Full screen'
1132
1423
  })), /*#__PURE__*/React.createElement("div", {
1133
1424
  style: {
1134
1425
  display: 'flex',
@@ -1144,7 +1435,21 @@ const TableContainerEdit = props => {
1144
1435
  showTotal: (total, range) =>
1145
1436
  // @ts-ignore
1146
1437
  `${range[0]}-${range[1]} / ${total} ${t ? t(pagination?.locale?.items ?? 'items') : 'items'}`
1147
- }, pagination)), typeof actionTemplate === 'function' ? actionTemplate() : actionTemplate, showColumnChoose && /*#__PURE__*/React.createElement(ColumnsChoose, {
1438
+ }, pagination)), typeof actionTemplate === 'function' ? actionTemplate() : actionTemplate, fullScreen !== false && (isFullScreen ? /*#__PURE__*/React.createElement(Minimize, {
1439
+ fontSize: 16,
1440
+ onClick: () => {
1441
+ setIsFullScreen(!isFullScreen);
1442
+ },
1443
+ "data-tooltip-id": `${id}-tooltip-content`,
1444
+ "data-tooltip-content": t ? t('Minimized') : 'Minimized'
1445
+ }) : /*#__PURE__*/React.createElement(Maximize, {
1446
+ fontSize: 16,
1447
+ onClick: () => {
1448
+ setIsFullScreen(!isFullScreen);
1449
+ },
1450
+ "data-tooltip-id": `${id}-tooltip-content`,
1451
+ "data-tooltip-content": t ? t('Full screen') : 'Full screen'
1452
+ })), showColumnChoose && /*#__PURE__*/React.createElement(ColumnsChoose, {
1148
1453
  columns: columns,
1149
1454
  originColumns: propsColumns,
1150
1455
  t: t,
@@ -1153,21 +1458,6 @@ const TableContainerEdit = props => {
1153
1458
  columnHidden: columnHidden
1154
1459
  })))), /*#__PURE__*/React.createElement("form", {
1155
1460
  onSubmit: handleSubmit(onSubmit)
1156
- }, /*#__PURE__*/React.createElement("div", {
1157
- // className="container"
1158
- className: classNames(`${prefix}-grid-container`, {
1159
- 'ui-rc-table-ping-right': tableContainerRef && (tableContainerRef.current?.scrollLeft ?? 0) >= 0 && (tableContainerRef.current?.scrollLeft ?? 0) + (tableContainerRef.current?.clientWidth ?? 0) < (tableContainerRef.current?.scrollWidth ?? 0),
1160
- 'ui-rc-table-ping-left': tableContainerRef && (tableContainerRef.current?.scrollLeft ?? 0) > 0
1161
- }),
1162
- ref: tableContainerRef,
1163
- style: {
1164
- overflow: 'auto',
1165
- //our scrollable table container
1166
- position: 'relative',
1167
- //needed for sticky header
1168
- // height: tableHeight, //should be a fixed height
1169
- maxHeight: tableHeight //should be a fixed height
1170
- }
1171
1461
  }, /*#__PURE__*/React.createElement(TableContext.Provider, {
1172
1462
  value: {
1173
1463
  locale,
@@ -1184,7 +1474,7 @@ const TableContainerEdit = props => {
1184
1474
  recordDoubleClick,
1185
1475
  selectionSettings,
1186
1476
  setIsSelectionChange,
1187
- onContextMenu,
1477
+ // onContextMenu,
1188
1478
  setSorterChange,
1189
1479
  setFilterChange,
1190
1480
  rangeState,
@@ -1218,43 +1508,33 @@ const TableContainerEdit = props => {
1218
1508
  triggerPaste,
1219
1509
  handleDeleteContent,
1220
1510
  handleAddMulti,
1221
- dataErrors
1222
- }
1223
- }, /*#__PURE__*/React.createElement("table", {
1224
- // className={`${prefix}-grid-container`}
1225
- style: {
1226
- display: 'grid'
1227
- // minWidth: table.getTotalSize()
1511
+ dataErrors,
1512
+ windowSize
1228
1513
  }
1229
- }, /*#__PURE__*/React.createElement(TableHead, {
1230
- tableContainerRef: tableContainerRef,
1231
- columnVirtualizer: columnVirtualizer,
1232
- table: table,
1233
- virtualPaddingLeft: virtualPaddingLeft,
1234
- virtualPaddingRight: virtualPaddingRight,
1235
- fixedLeftColumns: fixedLeftColumns,
1236
- fixedRightColumns: fixedRightColumns
1237
- }), /*#__PURE__*/React.createElement(TableBody, {
1238
- tableId: id,
1239
- columnVirtualizer: columnVirtualizer,
1514
+ }, /*#__PURE__*/React.createElement(TableWrapper, {
1515
+ contextMenuItems: contextMenuItems,
1516
+ height: tableHeight,
1517
+ id: id,
1518
+ prefix: prefix,
1240
1519
  table: table,
1241
1520
  tableContainerRef: tableContainerRef,
1242
- virtualPaddingLeft: virtualPaddingLeft,
1243
- virtualPaddingRight: virtualPaddingRight,
1244
- fixedLeftColumns: fixedLeftColumns,
1245
- fixedRightColumns: fixedRightColumns,
1246
- commandClick: commandClick,
1521
+ commandClick: triggerCommandClick,
1522
+ contextMenuClick: triggerContextMenuClick,
1523
+ contextMenuHidden: contextMenuHidden,
1524
+ contextMenuOpen: contextMenuOpen,
1247
1525
  editAble: editAble,
1248
- contextMenuItems: contextMenuItems,
1249
- showEmptyText: showEmptyText
1250
- }), summary && /*#__PURE__*/React.createElement(TableFooter, {
1526
+ showEmptyText: showEmptyText,
1527
+ summary: summary,
1528
+ dataSource: dataSource,
1529
+ infiniteScroll: infiniteScroll,
1530
+ next: next,
1531
+ loading: loading,
1251
1532
  columnVirtualizer: columnVirtualizer,
1252
- table: table,
1253
1533
  virtualPaddingLeft: virtualPaddingLeft,
1254
1534
  virtualPaddingRight: virtualPaddingRight,
1255
1535
  fixedLeftColumns: fixedLeftColumns,
1256
1536
  fixedRightColumns: fixedRightColumns
1257
- }))))), /*#__PURE__*/React.createElement("div", {
1537
+ }))), /*#__PURE__*/React.createElement("div", {
1258
1538
  ref: bottomToolbarRef
1259
1539
  }, toolbarItemsBottom && toolbarItemsBottom.length > 0 && /*#__PURE__*/React.createElement("div", {
1260
1540
  className: 'ui-rc-toolbar-bottom'
@@ -1274,7 +1554,7 @@ const TableContainerEdit = props => {
1274
1554
  onClick: ({}) => {
1275
1555
  setEditingKey('');
1276
1556
  }
1277
- })), pagination && /*#__PURE__*/React.createElement(Pagination
1557
+ })), pagination && !infiniteScroll && /*#__PURE__*/React.createElement(Pagination
1278
1558
  // style={{padding: '0.75rem 1rem'}}
1279
1559
  , _extends({}, pagination, {
1280
1560
  rootClassName: 'pagination-template',
@@ -1282,7 +1562,7 @@ const TableContainerEdit = props => {
1282
1562
  responsive: true,
1283
1563
  size: 'small',
1284
1564
  total: pagination.total,
1285
- pageSize: pagination.onChange ? pagination.pageSize : table.getState().pagination.pageSize,
1565
+ pageSize: pagination.onChange ? pagination?.pageSize : table.getState().pagination.pageSize,
1286
1566
  pageSizeOptions: [20, 50, 100, 1000, 10000],
1287
1567
  onChange: (page, pageSize) => {
1288
1568
  if (pagination.onChange) {
@@ -1,16 +1,10 @@
1
- import type { Column, Table } from "@tanstack/react-table";
2
- import type { Virtualizer } from "@tanstack/react-virtual";
1
+ import { type Table } from "@tanstack/react-table";
3
2
  import type { CommandClick } from "../type";
4
3
  import React from "react";
5
4
  interface TableBodyProps<T> {
6
- columnVirtualizer: Virtualizer<HTMLDivElement, HTMLTableCellElement>;
7
5
  table: Table<T>;
8
6
  tableContainerRef: React.RefObject<HTMLDivElement>;
9
- virtualPaddingLeft: number | undefined;
10
- virtualPaddingRight: number | undefined;
11
- fixedLeftColumns: Column<T, unknown>[];
12
- fixedRightColumns: Column<T, unknown>[];
13
- commandClick?: (args: CommandClick) => void;
7
+ commandClick?: (args: CommandClick<T>) => void;
14
8
  editAble?: boolean;
15
9
  tableId: string;
16
10
  showEmptyText?: boolean;
@@ -1,5 +1,6 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import TableBodyRow from "./TableBodyRow";
3
+ // import type { Virtualizer } from "@tanstack/react-virtual";
3
4
  import { useVirtualizer } from "@tanstack/react-virtual";
4
5
  // import type { Dispatch, SetStateAction } from "react";
5
6
  import React, { Fragment } from "react";
@@ -64,6 +65,33 @@ const TableBody = ({
64
65
  })))) : /*#__PURE__*/React.createElement(Fragment, null, virtualRows.map(virtualRow => {
65
66
  const row = rows[virtualRow.index];
66
67
  const isEditing = row.id === editingKey;
68
+
69
+ // return (
70
+ // <tr key={row.id}>
71
+ // {row.getVisibleCells().map((cell) => (
72
+ // <td
73
+ // key={cell.id}
74
+ // style={{
75
+ // padding: '12px',
76
+ // whiteSpace: 'nowrap',
77
+ // fontSize: '0.875rem',
78
+ // color: '#6b7280',
79
+ // border: '1px solid #e5e7eb',
80
+ // width: cell.column.getSize(),
81
+ // maxWidth: cell.column.getSize(),
82
+ // overflow: "hidden",
83
+ // ...getCommonPinningStyles(cell.column)
84
+ // }}>
85
+
86
+ // {cell.column.id}
87
+
88
+ // {/* {flexRender(cell.column.columnDef.cell, cell.getContext())} */}
89
+
90
+ // </td>
91
+ // ))}
92
+ // </tr>
93
+ // )
94
+
67
95
  return /*#__PURE__*/React.createElement(TableBodyRow, _extends({}, rest, {
68
96
  table: table,
69
97
  tableId: tableId,
@@ -4,7 +4,7 @@ import React from "react";
4
4
  import type { VirtualItem } from "@tanstack/react-virtual";
5
5
  interface TableBodyCellProps<T> {
6
6
  cell: Cell<T, unknown>;
7
- commandClick?: (args: CommandClick) => void;
7
+ commandClick?: (args: CommandClick<T>) => void;
8
8
  table: Table<T>;
9
9
  virtualRow?: VirtualItem;
10
10
  }