es-grid-template 1.2.0 → 1.2.2

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 (69) hide show
  1. package/assets/index.css +695 -0
  2. package/assets/index.scss +1063 -0
  3. package/es/grid-component/ColumnsChoose.d.ts +1 -0
  4. package/es/grid-component/ColumnsChoose.js +63 -28
  5. package/es/grid-component/ColumnsGroup/ColumnsGroup.d.ts +12 -0
  6. package/es/grid-component/ColumnsGroup/ColumnsGroup.js +223 -0
  7. package/es/grid-component/ColumnsGroup/index.d.ts +1 -0
  8. package/es/grid-component/ColumnsGroup/index.js +1 -0
  9. package/es/grid-component/ConvertColumnTable.d.ts +7 -0
  10. package/es/grid-component/ConvertColumnTable.js +143 -0
  11. package/es/grid-component/EditableCell.js +1 -1
  12. package/es/grid-component/GridStyle.js +1 -1
  13. package/es/grid-component/InternalTable.d.ts +1 -0
  14. package/es/grid-component/InternalTable.js +150 -249
  15. package/es/grid-component/TableGrid.d.ts +4 -1
  16. package/es/grid-component/TableGrid.js +31 -70
  17. package/es/grid-component/hooks/{useColumns → columns}/index.d.ts +2 -2
  18. package/es/grid-component/hooks/{useColumns → columns}/index.js +20 -16
  19. package/es/grid-component/hooks/content/HeaderContent.d.ts +11 -0
  20. package/es/grid-component/hooks/content/HeaderContent.js +79 -0
  21. package/es/grid-component/hooks/content/TooltipContent.d.ts +13 -0
  22. package/es/grid-component/hooks/content/TooltipContent.js +74 -0
  23. package/es/grid-component/hooks/useColumns.d.ts +16 -0
  24. package/es/grid-component/hooks/useColumns.js +280 -0
  25. package/es/grid-component/hooks/utils.d.ts +26 -1
  26. package/es/grid-component/hooks/utils.js +331 -1
  27. package/es/grid-component/index.js +3 -1
  28. package/es/grid-component/styles.scss +365 -68
  29. package/es/grid-component/table/Grid.d.ts +2 -0
  30. package/es/grid-component/table/Grid.js +18 -6
  31. package/es/grid-component/table/GridEdit.d.ts +4 -1
  32. package/es/grid-component/table/GridEdit.js +941 -307
  33. package/es/grid-component/table/Group.d.ts +13 -0
  34. package/es/grid-component/table/Group.js +154 -0
  35. package/es/grid-component/type.d.ts +39 -2
  36. package/lib/grid-component/ColumnsChoose.d.ts +1 -0
  37. package/lib/grid-component/ColumnsChoose.js +62 -27
  38. package/lib/grid-component/ColumnsGroup/ColumnsGroup.d.ts +12 -0
  39. package/lib/grid-component/ColumnsGroup/ColumnsGroup.js +234 -0
  40. package/lib/grid-component/ColumnsGroup/index.d.ts +1 -0
  41. package/lib/grid-component/ColumnsGroup/index.js +16 -0
  42. package/lib/grid-component/ConvertColumnTable.d.ts +7 -0
  43. package/lib/grid-component/ConvertColumnTable.js +152 -0
  44. package/lib/grid-component/EditableCell.js +1 -1
  45. package/lib/grid-component/GridStyle.js +1 -1
  46. package/lib/grid-component/InternalTable.d.ts +1 -0
  47. package/lib/grid-component/InternalTable.js +144 -249
  48. package/lib/grid-component/TableGrid.d.ts +4 -1
  49. package/lib/grid-component/TableGrid.js +26 -68
  50. package/lib/grid-component/hooks/{useColumns → columns}/index.d.ts +2 -2
  51. package/lib/grid-component/hooks/{useColumns → columns}/index.js +20 -16
  52. package/lib/grid-component/hooks/content/HeaderContent.d.ts +11 -0
  53. package/lib/grid-component/hooks/content/HeaderContent.js +86 -0
  54. package/lib/grid-component/hooks/content/TooltipContent.d.ts +13 -0
  55. package/lib/grid-component/hooks/content/TooltipContent.js +81 -0
  56. package/lib/grid-component/hooks/useColumns.d.ts +16 -0
  57. package/lib/grid-component/hooks/useColumns.js +291 -0
  58. package/lib/grid-component/hooks/utils.d.ts +26 -1
  59. package/lib/grid-component/hooks/utils.js +347 -5
  60. package/lib/grid-component/index.js +2 -1
  61. package/lib/grid-component/styles.scss +365 -68
  62. package/lib/grid-component/table/Grid.d.ts +2 -0
  63. package/lib/grid-component/table/Grid.js +18 -6
  64. package/lib/grid-component/table/GridEdit.d.ts +4 -1
  65. package/lib/grid-component/table/GridEdit.js +939 -305
  66. package/lib/grid-component/table/Group.d.ts +13 -0
  67. package/lib/grid-component/table/Group.js +163 -0
  68. package/lib/grid-component/type.d.ts +39 -2
  69. package/package.json +106 -105
@@ -5,7 +5,7 @@ import classNames from "classnames";
5
5
  import { Button, Dropdown, Form } from "antd";
6
6
  import { useForm } from 'react-hook-form';
7
7
  import { Toaster } from "react-hot-toast";
8
- import { flatColumns, renderContent } from "../hooks/useColumns";
8
+ import { flatColumns2, getValueCell, renderContent } from "../hooks/columns";
9
9
  import EditableCell from "../EditableCell";
10
10
  import { GridStyle } from "../GridStyle";
11
11
  import { TableContext } from "../useContext";
@@ -13,13 +13,16 @@ import dayjs from "dayjs";
13
13
  import 'dayjs/locale/es';
14
14
  import 'dayjs/locale/vi';
15
15
  import TableGrid from "../TableGrid";
16
- import { getEditType, getRowNumber, isObjEmpty, totalFixedWidth } from "../hooks";
16
+ import { addRows8, findAllChildrenKeys, findItemByKey, flattenArray, flattenData, getDefaultValue, getEditType, getFirstSelectCell, getLastSelectCell, getRowNumber, getRowsPasteIndex, isObjEmpty, newGuid, totalFixedWidth, updateArrayByKey } from "../hooks";
17
17
  import Message from "../../Message/Message";
18
18
 
19
19
  // import Command from "../Command";
20
20
 
21
- import { Toolbar } from "rc-master-ui";
21
+ import { Toolbar, ConfigProvider } from "rc-master-ui";
22
22
  import classnames from "classnames";
23
+ import useMergedState from "rc-util/es/hooks/useMergedState";
24
+ // import useLazyKVMap from "rc-master-ui/es/table/hooks/useLazyKVMap";
25
+
23
26
  dayjs.extend(customParseFormat);
24
27
  const toast = 'top-right';
25
28
  const GridEdit = props => {
@@ -34,24 +37,37 @@ const GridEdit = props => {
34
37
  selectionSettings,
35
38
  height,
36
39
  format,
37
- // onDataChange,
38
40
  triggerChangeData,
41
+ triggerChangeColumns,
39
42
  onCellPaste,
40
43
  onCellChange,
44
+ triggerPaste,
41
45
  style,
42
46
  getRowKey,
43
47
  className,
44
48
  toolbarItems,
49
+ defaultValue,
50
+ expandable,
51
+ onCellClick,
45
52
  ...rest
46
53
  } = props;
47
-
48
- // const forceUpdate = useForceUpdate();
49
- // const [updateKey, setUpdateKey] = useState(0);
50
-
54
+ const {
55
+ mode,
56
+ type,
57
+ // checkboxOnly,
58
+ // hideSelectAll,
59
+ columnWidth
60
+ // selectedRowKeys,
61
+ // defaultSelectedRowKeys
62
+ } = selectionSettings || {};
51
63
  const isSelecting = useRef(false);
52
64
  const startCell = useRef(null);
65
+ const childrenColumnName = 'children';
53
66
  const isSelectingRow = useRef(false);
54
67
  const rowStart = useRef(null);
68
+
69
+ // const [getRecordByKey] = useLazyKVMap(dataSource, childrenColumnName, getRowKey);
70
+
55
71
  const itemsAdd = [{
56
72
  key: '10',
57
73
  label: '10 rows'
@@ -65,71 +81,346 @@ const GridEdit = props => {
65
81
  const [form] = Form.useForm();
66
82
  const [editingKey, setEditingKey] = useState('');
67
83
  const [selectedCells, setSelectedCells] = useState(new Set());
84
+ const [pasteCells, setPasteCells] = useState(new Set());
85
+ const [isSelectDragging, setSelectIsDragging] = useState(false);
86
+ const [isPasteDragging, setIsPasteDragging] = useState(false); // isPasteDragging == tiếp tục hiển thị con trỏ crosshair
87
+
88
+ // const [showDraggingPoint, setShowDraggingPoint] = useState(false);
89
+
68
90
  const [rowsSelected, setRowsSelected] = useState(new Set());
69
- const [selectedCell, setSelectedCell] = useState(null);
70
- const handleAdd = item => {
71
- console.log(item);
91
+ const [startSelectedCells, setStartSelectedCell] = useState(null);
92
+ const [innerExpandedKeys, setInnerExpandedKeys] = React.useState(() => {
93
+ // if (defaultExpandedRowKeys) {
94
+ // return defaultExpandedRowKeys;
95
+ // }
96
+ // if (defaultExpandAllRows) {
97
+ return findAllChildrenKeys(dataSource, getRowKey, childrenColumnName) ?? [];
98
+ // }
99
+ // return [];
100
+ });
101
+ const mergedExpandedKeys = React.useMemo(() => new Set(innerExpandedKeys || []), [innerExpandedKeys]);
102
+ const [mergedSelectedKeys, setMergedSelectedKeys] = useMergedState([], {
103
+ value: []
104
+ });
105
+ const rowsFocus = React.useMemo(() => {
106
+ return [...new Set(Array.from(selectedCells).map(item => parseInt(item.split('-')[0])))] ?? [];
107
+ }, [selectedCells]);
108
+ const onTriggerExpand = React.useCallback(record => {
109
+ const key = getRowKey(record, dataSource.indexOf(record));
110
+ let newExpandedKeys;
111
+ const hasKey = mergedExpandedKeys.has(key);
112
+ if (hasKey) {
113
+ mergedExpandedKeys.delete(key);
114
+ newExpandedKeys = [...mergedExpandedKeys];
115
+ } else {
116
+ newExpandedKeys = [...mergedExpandedKeys, key];
117
+ }
118
+ setInnerExpandedKeys(newExpandedKeys);
119
+ }, [getRowKey, mergedExpandedKeys, dataSource]);
120
+ const handleAddSingle = item => {
121
+ const defaultRowValue = getDefaultValue(defaultValue);
122
+ const rowId = defaultRowValue && defaultRowValue.id ? defaultRowValue.id : newGuid();
123
+ if (item.onClick) {
124
+ item.onClick({
125
+ toolbar: item
126
+ });
127
+ } else {
128
+ const newData = [...dataSource, defaultValue ? {
129
+ ...defaultRowValue,
130
+ id: undefined,
131
+ rowId
132
+ } : {
133
+ id: undefined,
134
+ rowId
135
+ }];
136
+ triggerChangeData?.(newData, 'Add');
137
+ }
138
+ };
139
+ const handleAddMulti = (item, e) => {
140
+ if (item.onClick) {
141
+ item.onClick({
142
+ toolbar: item
143
+ });
144
+ } else {
145
+ const defaultRowValue = getDefaultValue(defaultValue);
146
+ const newRows = Array.from({
147
+ length: Number(e.key)
148
+ }).map(() => defaultRowValue ? {
149
+ ...defaultRowValue,
150
+ id: undefined,
151
+ rowId: newGuid()
152
+ } : {
153
+ id: undefined,
154
+ rowId: newGuid()
155
+ });
156
+ const newData = dataSource.concat(newRows);
157
+ triggerChangeData?.(newData, 'Add');
158
+ }
159
+ };
160
+ const handleDuplicate = () => {
161
+ // không tính tree
162
+
163
+ // Cập nhật data mới
164
+ const newData = [...dataSource];
165
+ const duplicatedItems = rowsFocus.map(index => ({
166
+ ...newData[index],
167
+ rowId: newGuid(),
168
+ id: undefined,
169
+ isDuplicate: true
170
+ }));
171
+
172
+ // Vị trí chèn là ngay sau phần tử lớn nhất trong rowsFocus
173
+ const insertAfter = Math.max(...rowsFocus);
174
+ const rs = [...newData.slice(0, insertAfter + 1), ...duplicatedItems, ...newData.slice(insertAfter + 1)];
175
+ triggerChangeData?.(rs, 'DUPLICATE');
176
+ };
177
+ const handleInsertBefore = item => {
178
+ const defaultRowValue = getDefaultValue(defaultValue);
179
+ const rowId = defaultRowValue && defaultRowValue.id ? defaultRowValue.id : newGuid();
180
+ const record = flattenData(childrenColumnName, dataSource)[rowsFocus[rowsFocus.length - 1]];
181
+ if (item.onClick) {
182
+ item.onClick({
183
+ toolbar: item
184
+ });
185
+ } else {
186
+ if (!record.parentId) {
187
+ // Cập nhật data mới
188
+ const newData = [...dataSource];
189
+ const index = newData.findIndex(obj => obj[rowKey] === record[rowKey]);
190
+ newData.splice(index, 0, {
191
+ ...defaultRowValue,
192
+ rowId,
193
+ parentId: null,
194
+ id: undefined
195
+ });
196
+ triggerChangeData?.(newData, 'INSERT_BEFORE');
197
+ } else {
198
+ const newData = [...dataSource];
199
+ const parent = findItemByKey(newData, rowKey, record.parentId);
200
+
201
+ // Cập nhật childData mới
202
+ const childData = parent?.children ? [...parent.children] : [];
203
+ const index = childData.findIndex(obj => obj[rowKey] === record[rowKey]);
204
+ childData.splice(index, 0, {
205
+ ...defaultRowValue,
206
+ rowId,
207
+ parentId: record.parentId,
208
+ id: undefined
209
+ });
210
+ const newRowData = {
211
+ ...parent,
212
+ children: childData
213
+ };
214
+ const newDataSource = updateArrayByKey(newData, newRowData, rowKey);
215
+ triggerChangeData?.(newDataSource, 'INSERT_BEFORE');
216
+ }
217
+ }
218
+ };
219
+ const handleInsertAfter = item => {
220
+ const defaultRowValue = getDefaultValue(defaultValue);
221
+ const rowId = defaultRowValue && defaultRowValue.id ? defaultRowValue.id : newGuid();
222
+ const record = flattenData(childrenColumnName, dataSource)[rowsFocus[rowsFocus.length - 1]];
223
+
224
+ // const record = getRecordByKey()
225
+
72
226
  if (item.onClick) {
73
- console.log('cccccccccccccccc');
227
+ item.onClick({
228
+ toolbar: item
229
+ });
74
230
  } else {
75
- console.log('bbbbbbbbbbbbb');
231
+ if (!record.parentId) {
232
+ // Cập nhật data mới
233
+ const newData = [...dataSource];
234
+ const index = newData.findIndex(obj => obj[rowKey] === record[rowKey]);
235
+ newData.splice(index + 1, 0, {
236
+ ...defaultRowValue,
237
+ rowId,
238
+ parentId: null
239
+ });
240
+ triggerChangeData?.(newData, 'INSERT_AFTER');
241
+ } else {
242
+ const newData = [...dataSource];
243
+ const parent = findItemByKey(newData, rowKey, record.parentId);
244
+
245
+ // Cập nhật childData mới
246
+ const childData = parent?.children ? [...parent.children] : [];
247
+ const index = childData.findIndex(obj => obj[rowKey] === record[rowKey]);
248
+ childData.splice(index + 1, 0, {
249
+ ...defaultRowValue,
250
+ rowId,
251
+ parentId: record.parentId
252
+ });
253
+ const newRowData = {
254
+ ...parent,
255
+ children: childData
256
+ };
257
+ const newDataSource = updateArrayByKey(newData, newRowData, rowKey);
258
+ triggerChangeData?.(newDataSource, 'INSERT_BEFORE');
259
+ }
76
260
  }
77
261
  };
78
- const handleDuplicate = () => {};
79
- const handleInsertBefore = () => {};
80
- const handleInsertAfter = () => {};
81
262
  const handleDeleteAll = () => {};
82
263
  const toolbarItemsBottom = useMemo(() => {
83
- return toolbarItems?.filter(it => it.position === 'Bottom').map(item => {
84
- return {
85
- ...item,
86
- template: () => {
87
- return /*#__PURE__*/React.createElement(Fragment, null, item.key === 'ADD' && /*#__PURE__*/React.createElement("div", {
88
- className: classnames(`be-toolbar-item ${item.className}`)
89
- }, /*#__PURE__*/React.createElement(Dropdown.Button, {
90
- menu: {
91
- items: itemsAdd,
92
- onClick: () => handleAdd(item)
264
+ if (!rowsFocus || rowsFocus.length === 0) {
265
+ return toolbarItems?.filter(it => it.position === 'Bottom' && it.visible !== false && it.key !== 'DUPLICATE' && it.key !== 'INSERT_BEFORE' && it.key !== 'INSERT_AFTER').map(item => {
266
+ if (item.key === 'ADD') {
267
+ return {
268
+ ...item,
269
+ template: () => {
270
+ return /*#__PURE__*/React.createElement(Fragment, null, item.key === 'ADD' && /*#__PURE__*/React.createElement("div", {
271
+ className: classnames(`be-toolbar-item`, item?.className)
272
+ }, /*#__PURE__*/React.createElement(Dropdown.Button, {
273
+ style: {
274
+ color: '#28c76f',
275
+ borderColor: '#28c76f'
276
+ },
277
+ className: 'toolbar-button toolbar-dropdown-button',
278
+ menu: {
279
+ items: itemsAdd,
280
+ onClick: e => handleAddMulti(item, e)
281
+ }
282
+ }, /*#__PURE__*/React.createElement("span", {
283
+ style: {
284
+ color: '#28c76f'
285
+ },
286
+ onClick: () => handleAddSingle(item)
287
+ }, item.title ? t ? t(item.title) : item.title : t ? t('Add item') : 'Add item'))));
93
288
  }
94
- }, item.title ? t ? t(item.title) : item.title : t ? t('Add item') : 'Add item')), item.key === 'DUPLICATE' && item.visible !== false && editingKey && /*#__PURE__*/React.createElement("div", {
95
- className: classnames(`be-toolbar-item ${item.className}`)
96
- }, /*#__PURE__*/React.createElement(Button, {
97
- color: "green",
98
- variant: 'outlined',
99
- onClick: handleDuplicate,
100
- className: "d-flex be-button"
101
- }, item.title ? t ? t(item.title) : item.title : t ? t('Duplicate') : 'Duplicate')), item.key === 'INSERT_BEFORE' && item.visible !== false && editingKey && /*#__PURE__*/React.createElement("div", {
102
- className: classnames(`be-toolbar-item ${item.className}`)
103
- }, /*#__PURE__*/React.createElement(Button, {
104
- color: "green",
105
- variant: 'outlined',
106
- onClick: handleInsertBefore,
107
- className: "d-flex be-button"
108
- }, item.title ? t ? t(item.title) : item.title : t ? t('Insert item before') : 'Insert item before')), item.key === 'INSERT_AFTER' && item.visible !== false && editingKey && /*#__PURE__*/React.createElement("div", {
109
- className: classnames(`be-toolbar-item ${item.className}`)
110
- }, /*#__PURE__*/React.createElement(Button, {
111
- color: "green",
112
- variant: 'outlined',
113
- onClick: handleInsertAfter,
114
- className: "d-flex be-button"
115
- }, item.title ? t ? t(item.title) : item.title : t ? t('Insert item after') : 'Insert item after')), item.key === 'DELETE' && item.visible !== false && /*#__PURE__*/React.createElement("div", {
116
- className: classnames(`be-toolbar-item ${item.className}`)
117
- }, /*#__PURE__*/React.createElement(Button, {
118
- color: "primary",
119
- variant: 'outlined',
120
- onClick: handleDeleteAll,
121
- className: "d-flex be-button"
122
- }, item.title ? t ? t(item.title) : item.title : t ? t('Delete all item') : 'Delete all item')));
289
+ };
123
290
  }
291
+ if (item.key === 'DELETE') {
292
+ return {
293
+ ...item,
294
+ template: () => {
295
+ return /*#__PURE__*/React.createElement("div", {
296
+ className: classnames(`be-toolbar-item`, item?.className)
297
+ }, /*#__PURE__*/React.createElement(Button, {
298
+ style: {
299
+ color: '#eb4619',
300
+ borderColor: '#eb4619'
301
+ },
302
+ variant: 'outlined',
303
+ onClick: handleDeleteAll,
304
+ className: "d-flex toolbar-button"
305
+ }, item.title ? t ? t(item.title) : item.title : t ? t('Delete all item') : 'Delete all item'));
306
+ }
307
+ };
308
+ }
309
+ return {
310
+ ...item
311
+ };
312
+ });
313
+ }
314
+ return toolbarItems?.filter(it => it.position === 'Bottom' && it.visible !== false).map(item => {
315
+ if (item.key === 'ADD') {
316
+ return {
317
+ ...item,
318
+ template: () => {
319
+ return /*#__PURE__*/React.createElement(Fragment, null, item.key === 'ADD' && /*#__PURE__*/React.createElement("div", {
320
+ className: classnames(`be-toolbar-item`, item?.className)
321
+ }, /*#__PURE__*/React.createElement(Dropdown.Button, {
322
+ style: {
323
+ color: '#28c76f',
324
+ borderColor: '#28c76f'
325
+ },
326
+ className: 'toolbar-button toolbar-dropdown-button',
327
+ menu: {
328
+ items: itemsAdd,
329
+ onClick: e => handleAddMulti(item, e)
330
+ }
331
+ }, /*#__PURE__*/React.createElement("span", {
332
+ style: {
333
+ color: '#28c76f'
334
+ },
335
+ onClick: () => handleAddSingle(item)
336
+ }, item.title ? t ? t(item.title) : item.title : t ? t('Add item') : 'Add item'))));
337
+ }
338
+ };
339
+ }
340
+ if (item.key === 'DUPLICATE') {
341
+ return {
342
+ ...item,
343
+ template: () => {
344
+ return /*#__PURE__*/React.createElement(Fragment, null, item.key === 'DUPLICATE' && item.visible !== false && rowsFocus.length > 0 && /*#__PURE__*/React.createElement("div", {
345
+ className: classnames(`be-toolbar-item`, item?.className)
346
+ }, /*#__PURE__*/React.createElement(Button, {
347
+ style: {
348
+ color: '#28c76f',
349
+ borderColor: '#28c76f'
350
+ },
351
+ variant: 'outlined',
352
+ onClick: handleDuplicate,
353
+ className: "d-flex toolbar-button"
354
+ }, item.title ? t ? t(item.title) : item.title : t ? t('Duplicate') : 'Duplicate')));
355
+ }
356
+ };
357
+ }
358
+ if (item.key === 'INSERT_BEFORE') {
359
+ return {
360
+ ...item,
361
+ template: () => {
362
+ return /*#__PURE__*/React.createElement(Fragment, null, item.key === 'INSERT_BEFORE' && item.visible !== false && rowsFocus.length > 0 && /*#__PURE__*/React.createElement("div", {
363
+ className: classnames(`be-toolbar-item`, item?.className)
364
+ }, /*#__PURE__*/React.createElement(Button, {
365
+ style: {
366
+ color: '#28c76f',
367
+ borderColor: '#28c76f'
368
+ },
369
+ variant: 'outlined',
370
+ onClick: () => handleInsertBefore(item),
371
+ className: "d-flex toolbar-button"
372
+ }, item.title ? t ? t(item.title) : item.title : t ? t('Insert item before') : 'Insert item before')));
373
+ }
374
+ };
375
+ }
376
+ if (item.key === 'INSERT_AFTER') {
377
+ return {
378
+ ...item,
379
+ template: () => {
380
+ return /*#__PURE__*/React.createElement(Fragment, null, item.key === 'INSERT_AFTER' && item.visible !== false && rowsFocus.length > 0 && /*#__PURE__*/React.createElement("div", {
381
+ className: classnames(`be-toolbar-item`, item?.className)
382
+ }, /*#__PURE__*/React.createElement(Button, {
383
+ style: {
384
+ color: '#28c76f',
385
+ borderColor: '#28c76f'
386
+ },
387
+ variant: 'outlined',
388
+ onClick: () => handleInsertAfter(item),
389
+ className: "d-flex toolbar-button"
390
+ }, item.title ? t ? t(item.title) : item.title : t ? t('Insert item after') : 'Insert item after')));
391
+ }
392
+ };
393
+ }
394
+ if (item.key === 'DELETE') {
395
+ return {
396
+ ...item,
397
+ template: () => {
398
+ return /*#__PURE__*/React.createElement("div", {
399
+ className: classnames(`be-toolbar-item`, item?.className)
400
+ }, /*#__PURE__*/React.createElement(Button, {
401
+ style: {
402
+ color: '#eb4619',
403
+ borderColor: '#eb4619'
404
+ },
405
+ variant: 'outlined',
406
+ onClick: handleDeleteAll,
407
+ className: "d-flex toolbar-button"
408
+ }, item.title ? t ? t(item.title) : item.title : t ? t('Delete all item') : 'Delete all item'));
409
+ }
410
+ };
411
+ }
412
+ return {
413
+ ...item
124
414
  };
125
415
  });
126
- }, [toolbarItems]);
416
+ }, [handleAddMulti, handleAddSingle, itemsAdd, rowsFocus.length, t, toolbarItems]);
127
417
  const {
128
418
  control,
129
419
  handleSubmit,
130
420
  setValue,
131
421
  trigger,
132
- getValues
422
+ getValues,
423
+ reset
133
424
  // formState: { errors }
134
425
  } = useForm({
135
426
  mode: 'onChange'
@@ -141,13 +432,16 @@ const GridEdit = props => {
141
432
  const isEditing = record => record[rowKey] === editingKey;
142
433
  useEffect(() => {
143
434
  const handleClickOutside = event => {
144
- const tableBodies = document.getElementsByClassName("ui-rc-table-tbody");
145
435
  const element = event.target;
436
+ const tableBodies = document.getElementsByClassName("ui-rc-table-tbody");
146
437
  const container = document.querySelector(".be-popup-container");
147
438
  // const containerHidden = document.querySelector(".be-popup-container.ant-picker-dropdown-hidden")
148
439
 
440
+ // const toolbarContainer = document.getElementsByClassName("ui-rc-toolbar");
441
+ const itemContainer = document.querySelector(".ui-rc-toolbar-selection-overflow-item");
149
442
  const isInsideContainer = element.closest(".be-popup-container") && container;
150
- if (isInsideContainer) {
443
+ const isInsideToolbar = element.closest(".ui-rc-toolbar-selection-overflow-item") && itemContainer;
444
+ if (isInsideContainer || isInsideToolbar) {
151
445
  return;
152
446
  }
153
447
  if (tableBodies.length > 0) {
@@ -167,36 +461,237 @@ const GridEdit = props => {
167
461
  document.removeEventListener("click", handleClickOutside);
168
462
  };
169
463
  }, []);
170
- const handleMouseDown = (row, col, e) => {
464
+ const handleMouseDown = (record, row, col, e) => {
171
465
  if (e.button === 2) {
172
466
  e.stopPropagation();
173
467
  return;
174
468
  }
175
- setSelectedCell({
176
- row,
177
- col
178
- });
179
469
  isSelecting.current = true;
180
470
  startCell.current = {
181
471
  row,
182
472
  col
183
473
  };
184
- setSelectedCells(new Set([`${row}-${col}`]));
185
- setRowsSelected(new Set());
474
+ if (e.target.className === 'dragging-point') {
475
+ // e.stopPropagation()
476
+ // e.preventDefault()
477
+ } else {
478
+ // isSelecting.current = true;
479
+ // startCell.current = { row, col };
480
+
481
+ // if (!isPasteDragging) {
482
+ setStartSelectedCell({
483
+ row,
484
+ col
485
+ });
486
+ setSelectedCells(new Set([`${row}-${col}`]));
487
+ setRowsSelected(new Set());
488
+ // }
489
+ }
490
+
491
+ // setSelectIsDragging(true)
492
+
493
+ // isSelecting.current = true;
494
+ // startCell.current = { row, col };
495
+ //
496
+ // if (!isPasteDragging) {
497
+ // setStartSelectedCell({ row, col })
498
+ // setSelectedCells(new Set([`${row}-${col}`]));
499
+ // setRowsSelected(new Set())
500
+ // }
501
+ };
502
+
503
+ // const handlePointEnter = (e: any) => {
504
+ //
505
+ // if (e.button === 2) {
506
+ // e.stopPropagation()
507
+ // return
508
+ // }
509
+ //
510
+ // // setIsPasteDragging(true);
511
+ //
512
+ // };
513
+
514
+ // const handlePointLeave = () => {
515
+ //
516
+ // if (isPasteDragging && !isSelectDragging) {
517
+ // // setIsPasteDragging(false);
518
+ // }
519
+ //
520
+ // };
521
+
522
+ const triggerDragPaste = pastesArray => {
523
+ const mergedSet = new Set([...selectedCells, ...pastesArray]);
524
+ setSelectedCells(mergedSet);
525
+ setPasteCells(new Set());
526
+ const selectedArray = Array.from(selectedCells).map(key => {
527
+ const [row, col] = key.split("-").map(Number);
528
+ // @ts-ignore
529
+ const columnKey = columns[col].field;
530
+
531
+ // @ts-ignore
532
+ return {
533
+ row,
534
+ col,
535
+ value: flattenData(childrenColumnName, dataSource)[row][columnKey]
536
+ };
537
+ // return { row, col, value: '' };
538
+ });
539
+
540
+ // Xác định min/max row và col để sắp xếp dữ liệu
541
+ const minRow = Math.min(...selectedArray.map(cell => cell.row));
542
+ const maxRow = Math.max(...selectedArray.map(cell => cell.row));
543
+ const minCol = Math.min(...selectedArray.map(cell => cell.col));
544
+ const maxCol = Math.max(...selectedArray.map(cell => cell.col));
545
+
546
+ // Tạo dữ liệu dạng bảng (mảng 2D)
547
+ const table = Array.from({
548
+ length: maxRow - minRow + 1
549
+ }, () => Array(maxCol - minCol + 1).fill(""));
550
+
551
+ // Gán giá trị vào bảng
552
+ selectedArray.forEach(({
553
+ row,
554
+ col,
555
+ value
556
+ }) => {
557
+ table[row - minRow][col - minCol] = value;
558
+ });
559
+ const newRange = addRows8(table, getRowsPasteIndex(pastesArray).length);
560
+ const record = flattenData(childrenColumnName, dataSource)[getFirstSelectCell(pastesArray).row];
561
+ if (!record.parentId) {
562
+ // Cập nhật data mới
563
+ const newData = [...dataSource];
564
+
565
+ // Lấy vị trí bắt đầu
566
+ // const { row: startRow, col: startCol } = selectedCell;
567
+ const startRow = getFirstSelectCell(pastesArray).row;
568
+ const startCol = getFirstSelectCell(selectedCells).col;
569
+ const pastedRows = [];
570
+ const pastedColumns = new Set();
571
+ newRange.addedRows.forEach((rowValues, rowIndex) => {
572
+ const targetRow = startRow + rowIndex;
573
+
574
+ // Nếu vượt quá số dòng hiện có, thêm dòng mới
575
+ if (targetRow >= newData.length) {
576
+ // @ts-ignore
577
+ newData.push({
578
+ id: undefined,
579
+ rowId: newGuid()
580
+ });
581
+ }
582
+ rowValues.forEach((cellValue, colIndex) => {
583
+ const targetCol = startCol + colIndex;
584
+ if (targetCol >= columns.length) {
585
+ // Không vượt quá số cột
586
+ return;
587
+ }
588
+
589
+ // @ts-ignore
590
+ const columnKey = columns[targetCol].field;
591
+
592
+ // @ts-ignore
593
+ newData[targetRow] = {
594
+ ...newData[targetRow],
595
+ [columnKey]: typeof cellValue === 'string' ? cellValue.trim() : cellValue
596
+ };
597
+ pastedColumns.add(columnKey);
598
+ });
599
+
600
+ // Lưu dòng được paste
601
+ pastedRows.push(newData[targetRow]);
602
+ });
603
+ const pastedColumnsArray = Array.from(pastedColumns) ?? [];
604
+ triggerPaste?.(pastedRows, pastedColumnsArray, newData);
605
+ }
606
+ };
607
+ const handlePointDoubleClick = e => {
608
+ e.preventDefault();
609
+ e.stopPropagation();
610
+ const colStart = getFirstSelectCell(selectedCells).col;
611
+ const colEnd = getLastSelectCell(selectedCells).col;
612
+ const startPasteRow = getLastSelectCell(selectedCells).row;
613
+ const newPasteCells = new Set();
614
+ for (let r = Math.min(startPasteRow, dataSource.length - 1) + 1; r <= Math.max(startPasteRow, dataSource.length - 1); r++) {
615
+ for (let c = Math.min(colStart, colStart); c <= Math.max(colStart, colEnd); c++) {
616
+ newPasteCells.add(`${r}-${c}`);
617
+ }
618
+ }
619
+ triggerDragPaste(newPasteCells);
620
+ };
621
+ const handleMouseUp = () => {
622
+ isSelecting.current = false;
623
+ startCell.current = null;
624
+ isSelectingRow.current = false;
625
+ rowStart.current = null;
626
+ setIsPasteDragging(false);
627
+ setSelectIsDragging(false);
628
+ if (pasteCells.size > 0) {
629
+ triggerDragPaste(pasteCells);
630
+ }
186
631
  };
187
632
  const handleMouseEnter = (row, col) => {
188
- if (!isSelecting.current || !startCell.current) return;
633
+ if (!isSelecting.current || !startCell.current) {
634
+ return;
635
+ }
189
636
  const {
190
637
  row: startRow,
191
638
  col: startCol
192
639
  } = startCell.current;
193
- const newSelectedCells = new Set();
194
- for (let r = Math.min(startRow, row); r <= Math.max(startRow, row); r++) {
195
- for (let c = Math.min(startCol, col); c <= Math.max(startCol, col); c++) {
196
- newSelectedCells.add(`${r}-${c}`);
640
+ if (!isPasteDragging) {
641
+ // chọn vùng copy
642
+
643
+ setSelectIsDragging(true);
644
+ setIsPasteDragging(false);
645
+ const newSelectedCells = new Set();
646
+ for (let r = Math.min(startRow, row); r <= Math.max(startRow, row); r++) {
647
+ for (let c = Math.min(startCol, col); c <= Math.max(startCol, col); c++) {
648
+ newSelectedCells.add(`${r}-${c}`);
649
+ }
650
+ }
651
+ setSelectedCells(newSelectedCells);
652
+ } else {
653
+ // chọn vùng paste
654
+
655
+ setSelectIsDragging(false);
656
+ setIsPasteDragging(true);
657
+ const newSelectedCells = new Set();
658
+ for (let r = Math.min(startRow, row); r <= Math.max(startRow, row); r++) {
659
+ for (let c = Math.min(startCol, col); c <= Math.max(startCol, col); c++) {
660
+ newSelectedCells.add(`${r}-${c}`);
661
+ }
662
+ }
663
+ const colStart = getFirstSelectCell(selectedCells).col;
664
+ const colEnd = getLastSelectCell(selectedCells).col;
665
+ const rowSelectedEnd = getLastSelectCell(selectedCells).row;
666
+ if (row >= rowSelectedEnd) {
667
+ // kéo xuống dưới
668
+
669
+ const newPasteCells = new Set();
670
+ for (let r = Math.min(startRow, row) + 1; r <= Math.max(startRow, row); r++) {
671
+ for (let c = Math.min(colStart, col); c <= Math.max(colStart, colEnd); c++) {
672
+ newPasteCells.add(`${r}-${c}`);
673
+ }
674
+ }
675
+ setPasteCells(newPasteCells);
676
+ }
677
+ if (row < rowSelectedEnd) {
678
+ // kéo lên trên
679
+ }
680
+ if (col > colEnd) {
681
+ // kéo sang phải
197
682
  }
683
+ if (row < colStart) {
684
+ // kéo sang trái
685
+ }
686
+
687
+ // const newPasteCells = new Set()
688
+ // for (let r = Math.min(startRow, row) + 1; r <= Math.max(startRow, row); r++) {
689
+ // for (let c = Math.min(colStart, col); c <= Math.max(colStart, colEnd); c++) {
690
+ // newPasteCells.add(`${r}-${c}`);
691
+ // }
692
+ // }
693
+ // setPasteCells(newPasteCells)
198
694
  }
199
- setSelectedCells(newSelectedCells);
200
695
  };
201
696
  const handleClickRowHeader = (row, col) => {
202
697
  const newSelectedCells = new Set();
@@ -265,23 +760,46 @@ const GridEdit = props => {
265
760
  setRowsSelected(newSelectedRows);
266
761
  setSelectedCells(newSelectedCells);
267
762
  };
268
- const handleMouseUp = () => {
269
- isSelecting.current = false;
270
- startCell.current = null;
271
- isSelectingRow.current = false;
272
- rowStart.current = null;
763
+ const handleCellClick = (indexRow, record, column) => {
764
+ const cellClickCallback = newOptions => {
765
+ if (newOptions) {
766
+ const newElem = {
767
+ ...column,
768
+ editSelectSettings: {
769
+ ...(column?.editSelectSettings ? {
770
+ ...column?.editSelectSettings
771
+ } : {}),
772
+ options: newOptions
773
+ }
774
+ };
775
+ const rrr = updateArrayByKey([...columns], newElem, 'field');
776
+ triggerChangeColumns?.(rrr, 'click');
777
+ }
778
+ };
779
+ if (onCellClick) {
780
+ onCellClick({
781
+ index: indexRow,
782
+ rowId: record.rowId,
783
+ cellValue: record[record.field],
784
+ type: "Editing",
785
+ field: column.field,
786
+ rowData: record
787
+ }, cellClickCallback);
788
+ }
273
789
  };
274
790
  const handleCopy = e => {
275
791
  const selectedArray = Array.from(selectedCells).map(key => {
276
792
  const [row, col] = key.split("-").map(Number);
277
793
  // @ts-ignore
278
- const columnKey = columns[col].dataIndex;
794
+ const columnKey = columns[col].field;
795
+
279
796
  // @ts-ignore
280
797
  return {
281
798
  row,
282
799
  col,
283
- value: dataSource[row][columnKey]
800
+ value: flattenData(childrenColumnName, dataSource)[row][columnKey]
284
801
  };
802
+ // return { row, col, value: '' };
285
803
  });
286
804
 
287
805
  // Xác định min/max row và col để sắp xếp dữ liệu
@@ -312,133 +830,131 @@ const GridEdit = props => {
312
830
  e.clipboardData.setData("text/plain", copyText);
313
831
  Message(t ? t('CopySuccessful') : 'Copy Successful');
314
832
  };
315
- const handlePaste = (e, indexCol, indexRow) => {
833
+ const handlePaste = (record, indexCol, rowNumber, e) => {
316
834
  // const clipboard: any = (e.clipboardData || (window && window?.Clipboard)).getData("text")
317
835
  const pasteData = e.clipboardData.getData("text/plain").trim();
318
836
 
319
837
  // Chuyển đổi dữ liệu từ clipboard thành mảng
320
838
  const rows = pasteData.split("\n").map(row => row.replace(/\r/g, "").split("\t"));
839
+ if (!record.parentId) {
840
+ // Cập nhật data mới
841
+ const newData = [...dataSource];
321
842
 
322
- // Lấy vị trí bắt đầu
323
- // const { row: startRow, col: startCol } = selectedCell;
324
- const startRow = indexRow;
325
- const startCol = indexCol;
843
+ // @ts-ignore
844
+ const indexRows = newData.findIndex(it => it[rowKey] === record[rowKey]);
326
845
 
327
- // Cập nhật data mới
328
- const newData = [...dataSource];
329
- const pastedRows = [];
330
- const pastedColumns = new Set();
331
- rows.forEach((rowValues, rowIndex) => {
332
- const targetRow = startRow + rowIndex;
846
+ // Lấy vị trí bắt đầu
847
+ // const { row: startRow, col: startCol } = selectedCell;
848
+ const startRow = indexRows;
849
+ const startCol = indexCol;
333
850
 
334
- // Nếu vượt quá số dòng hiện có, thêm dòng mới
335
- if (targetRow >= newData.length) {
336
- // @ts-ignore
337
- // newData.push({ id: newGuid()});
338
- newData.push({
339
- id: newGuid()
851
+ // const flattData = flattenArray(newData);
852
+
853
+ const pastedRows = [];
854
+ const pastedColumns = new Set();
855
+ rows.forEach((rowValues, rowIndex) => {
856
+ const targetRow = startRow + rowIndex;
857
+
858
+ // Nếu vượt quá số dòng hiện có, thêm dòng mới
859
+ if (targetRow >= newData.length) {
860
+ // @ts-ignore
861
+ // newData.push({ id: newGuid()});
862
+ newData.push({
863
+ id: undefined,
864
+ rowId: newGuid()
865
+ });
866
+ }
867
+ rowValues.forEach((cellValue, colIndex) => {
868
+ const targetCol = startCol + colIndex;
869
+ if (targetCol >= columns.length) {
870
+ // Không vượt quá số cột
871
+ return;
872
+ }
873
+
874
+ // @ts-ignore
875
+ const columnKey = columns[targetCol].field;
876
+
877
+ // @ts-ignore
878
+ newData[targetRow] = {
879
+ ...newData[targetRow],
880
+ [columnKey]: cellValue.trim()
881
+ };
882
+ pastedColumns.add(columnKey);
340
883
  });
341
- }
342
- rowValues.forEach((cellValue, colIndex) => {
343
- const targetCol = startCol + colIndex;
344
- if (targetCol >= columns.length) return; // Không vượt quá số cột
345
884
 
346
- // @ts-ignore
347
- const columnKey = columns[targetCol].dataIndex;
348
- // @ts-ignore
349
- newData[targetRow] = {
350
- ...newData[targetRow],
351
- [columnKey]: cellValue.trim()
352
- };
353
- pastedColumns.add(columnKey);
885
+ // Lưu dòng được paste
886
+ pastedRows.push(newData[targetRow]);
354
887
  });
888
+ const pastedColumnsArray = Array.from(pastedColumns) ?? [];
889
+ triggerPaste?.(pastedRows, pastedColumnsArray, newData);
890
+ } else {
891
+ // Cập nhật data mới
892
+ const newData = [...dataSource];
893
+ const parent = findItemByKey(newData, rowKey, record.parentId);
355
894
 
356
- // Lưu dòng được paste
357
- pastedRows.push(newData[targetRow]);
358
- });
359
- const pastedColumnsArray = Array.from(pastedColumns) ?? [];
360
- console.log(pastedColumnsArray);
361
- console.log(pastedRows);
895
+ // Cập nhật childData mới
896
+ const childData = parent?.children ? [...parent.children] : [];
362
897
 
363
- // // trigger DataChange + trigger paste
898
+ // Lấy vị trí bắt đầu
899
+ // const { row: startRow, col: startCol } = selectedCell;
900
+ const startRow = childData.findIndex(it => it[rowKey] === record[rowKey]);
901
+ const startCol = indexCol;
902
+ const pastedRows = [];
903
+ const pastedColumns = new Set();
904
+ rows.forEach((rowValues, rowIndex) => {
905
+ const targetRow = startRow + rowIndex;
364
906
 
365
- // const handlePasteCallback = (callbackData: RecordType[]) => {
366
- //
367
- // const newDataUpdate = updateData(dataSource, callbackData, rowKey as any)
368
- //
369
- // // setData(newDataUpdate)
370
- // // onDataChange?.(newData)
371
- // onCellPaste?.dataChange?.(newDataUpdate)
372
- // }
373
- //
374
- //
375
- // if (onCellPaste && onCellPaste.onPasted) {
376
- //
377
- // if (onCellPaste.onPasted.length > 1) {
378
- // onCellPaste.onPasted({
379
- // pasteData: pastedRows,
380
- // type: 'onPaste',
381
- // data: dataSource,
382
- // pastedColumns: pastedColumnsArray as string[]
383
- // }, handlePasteCallback)
384
- //
385
- // } else {
386
- // onCellPaste.onPasted({
387
- // pasteData: pastedRows,
388
- // type: 'onPaste',
389
- // data: dataSource,
390
- // pastedColumns: ['']
391
- // }, handlePasteCallback)
392
- //
393
- // onCellPaste.dataChange?.(newData)
394
- //
395
- // // setData(newData);
396
- // // onDataChange?.(newData)
397
- // }
398
- //
399
- // }
907
+ // Nếu vượt quá số dòng hiện có, thêm dòng mới
908
+ if (targetRow >= childData.length) {
909
+ childData.push({
910
+ id: undefined,
911
+ rowId: newGuid(),
912
+ parentId: parent[rowKey ?? 'id']
913
+ });
914
+ }
915
+ rowValues.forEach((cellValue, colIndex) => {
916
+ const targetCol = startCol + colIndex;
917
+ if (targetCol >= columns.length) {
918
+ // Không vượt quá số cột
919
+ return;
920
+ }
921
+
922
+ // @ts-ignore
923
+ const columnKey = columns[targetCol].field;
924
+
925
+ // @ts-ignore
926
+ childData[targetRow] = {
927
+ ...childData[targetRow],
928
+ [columnKey]: cellValue.trim()
929
+ };
930
+ pastedColumns.add(columnKey);
931
+ });
932
+
933
+ // Lưu dòng được paste
934
+ pastedRows.push(childData[targetRow]);
935
+ });
936
+ const pastedColumnsArray = Array.from(pastedColumns) ?? [];
937
+ const newRowData = {
938
+ ...parent,
939
+ children: childData
940
+ };
941
+ const newDataSource = updateArrayByKey(newData, newRowData, rowKey);
942
+ triggerPaste?.(pastedRows, pastedColumnsArray, newDataSource);
943
+ }
400
944
  };
401
945
  const onSubmit = formData => {
402
- console.log('onSubmit', formData);
403
946
  try {
404
947
  // const record = (await form.validateFields()) as RecordType;
405
948
  const row = {
406
949
  ...formData
407
950
  };
408
- // const rowData = { ...record };
409
-
410
- // columns.forEach(column => {
411
- //
412
- // // @ts-ignore
413
- // if (column.editType === 'date' && rowData[column.dataIndex]) {
414
- // // @ts-ignore
415
- // rowData[column.dataIndex] = !isEmpty(record[column.dataIndex]) ? moment(row[column.dataIndex]).format() : null
416
- // }
417
- // });
418
-
419
951
  const newData = [...dataSource];
952
+
420
953
  // @ts-ignore
421
954
  const index = newData.findIndex(item => formData[rowKey] === item[rowKey]);
422
-
423
- // setIsManualUpdate(true);
424
-
955
+ const rs = updateArrayByKey(dataSource, row, rowKey);
425
956
  if (index > -1) {
426
- const item = newData[index];
427
- newData.splice(index, 1, {
428
- ...item,
429
- ...row
430
- });
431
- triggerChangeData?.(newData, 'onChange');
432
-
433
- // trigger DataChange
434
- // setData(newData);
435
- // onDataChange?.(newData)
436
- } else {
437
- newData.push(row);
438
- // trigger DataChange
439
-
440
- // setData(newData);
441
- // onDataChange?.(newData)
957
+ triggerChangeData?.(rs, 'onChange');
442
958
  }
443
959
  } catch (errInfo) {
444
960
  console.log('Validate Failed:', errInfo);
@@ -447,29 +963,18 @@ const GridEdit = props => {
447
963
  const handleCellChange = args => {
448
964
  const {
449
965
  record,
450
- type,
966
+ type: changeType,
451
967
  newState,
452
968
  prevState,
453
969
  option,
454
970
  field
455
971
  } = args;
456
972
 
457
- // console.log('newState', newState)
458
- //
459
- // console.log('getValues()', getValues())
460
-
461
973
  // const newRecord = getValues()
462
974
 
463
- if (type === 'enter') {
464
- console.log('aaaaaa enter');
465
- }
466
- if (type === 'blur') {
467
- // onCellChange
468
-
975
+ if (changeType === 'enter') {}
976
+ if (changeType === 'blur') {
469
977
  const handleChangeCallback = callbackData => {
470
- // const newDataUpdate = updateData(data, callbackData, rowKey as any)
471
-
472
- console.log('callbackData', callbackData);
473
978
  const callbackRecord = callbackData;
474
979
  Object.entries(callbackRecord).forEach(([name, value]) => {
475
980
  setValue(name, value);
@@ -478,7 +983,6 @@ const GridEdit = props => {
478
983
  };
479
984
  if (onCellChange) {
480
985
  if (onCellChange.length > 1) {
481
- console.log('onCellChange Callback');
482
986
  onCellChange({
483
987
  field,
484
988
  indexCol: 1,
@@ -492,7 +996,6 @@ const GridEdit = props => {
492
996
  sumValue: []
493
997
  }, handleChangeCallback);
494
998
  } else {
495
- console.log('onCellChange');
496
999
  onCellChange({
497
1000
  field,
498
1001
  indexCol: 1,
@@ -508,16 +1011,15 @@ const GridEdit = props => {
508
1011
  onSubmit(record);
509
1012
  }
510
1013
  }
511
- console.log('aaaaaa blur');
512
1014
  }
513
- if (prevState && newState && prevState !== newState && type === 'enter') {
514
- console.log('enter');
1015
+ if (prevState && newState && prevState !== newState && changeType === 'enter') {
515
1016
  onSubmit(record);
516
1017
  }
517
1018
  };
518
1019
  const handleEdit = (record, col, editType, e) => {
519
1020
  // @ts-ignore
520
1021
  setEditingKey(record[rowKey]);
1022
+ reset();
521
1023
 
522
1024
  // const formattedRecord = { ...record };
523
1025
 
@@ -547,19 +1049,20 @@ const GridEdit = props => {
547
1049
  // });
548
1050
 
549
1051
  if (e.key === 'Enter' || editType === 'date' || e.type === 'dblclick') {} else {
550
- setValue(col.dataIndex, e.key);
1052
+ setValue(col.dataIndex, editType === 'numeric' ? !isNaN(Number(e.key)) ? Number(e.key) : '' : e.key);
1053
+ // setValue(col.dataIndex, e.key)
551
1054
  }
552
1055
  if (editType === 'select') {
553
1056
  // setSearchValue(e.key)
554
1057
  // setOpen(true)
555
1058
  }
556
- if (selectedCell?.row !== undefined && selectedCell?.col !== undefined) {
1059
+ if (startSelectedCells?.row !== undefined && startSelectedCells?.col !== undefined) {
557
1060
  setTimeout(() => {
558
1061
  // const input = document.querySelector(`.ui-rc-table-row[data-row-key="${selectedCell.row}"] .cell-editing[data-col-index="${selectedCell.col}"] input`) as HTMLInputElement;
559
- const input = document.querySelector(`.ui-rc-table-row .cell-editing[data-row-index="${selectedCell.row}"].cell-editing[data-col-index="${selectedCell.col}"] input`);
1062
+ const input = document.querySelector(`.ui-rc-table-row .cell-editing[data-row-index="${startSelectedCells.row}"].cell-editing[data-col-index="${startSelectedCells.col}"] input`);
560
1063
  // const input = document.getElementById(`col${selectedCell.col}-record${selectedCell.row}`) as HTMLInputElement;
561
1064
 
562
- const select = document.querySelector(`div.cell-editing[tabindex="${selectedCell?.col}"] .ant-select-selection-search input`);
1065
+ const select = document.querySelector(`div.cell-editing[tabindex="${startSelectedCells?.col}"] .ant-select-selection-search input`);
563
1066
  if (input) {
564
1067
  input.focus();
565
1068
  }
@@ -572,18 +1075,21 @@ const GridEdit = props => {
572
1075
  }, 0);
573
1076
  }
574
1077
  };
575
- useEffect(() => {
576
- const tableBody = document.querySelector(".ui-rc-table-tbody");
577
- const tableHeader = document.querySelector(".ui-rc-table-header");
578
- if (tableBody && tableHeader) {
579
- tableBody.addEventListener("scroll", () => {
580
- tableHeader.scrollLeft = tableBody.scrollLeft;
581
- });
582
- }
583
- }, []);
584
- const scrollToCell = (rowIndex, colIndex, cell, type) => {
1078
+
1079
+ // useEffect(() => {
1080
+ // const tableBody = document.querySelector(".ui-rc-table-tbody");
1081
+ // const tableHeader = document.querySelector(".ui-rc-table-header");
1082
+ //
1083
+ // if (tableBody && tableHeader) {
1084
+ // tableBody.addEventListener("scroll", () => {
1085
+ // tableHeader.scrollLeft = tableBody.scrollLeft;
1086
+ // });
1087
+ // }
1088
+ // }, []);
1089
+
1090
+ const scrollToCell = (rowIndex, colIndex, cell, scrollType) => {
585
1091
  const fixedWidth = totalFixedWidth(columns, 'left', selectionSettings);
586
- if (type === 'horizontal') {
1092
+ if (scrollType === 'horizontal') {
587
1093
  if (tableRef.current) {
588
1094
  tableRef.current.scrollTo({
589
1095
  left: cell.offsetLeft - fixedWidth,
@@ -603,15 +1109,12 @@ const GridEdit = props => {
603
1109
  });
604
1110
  }
605
1111
  };
606
- const handleFocusCell = (rowIndex, colIndex, col, type, e) => {
1112
+ const handleFocusCell = (rowIndex, colIndex, col, scrollType, e) => {
607
1113
  const isEdit = editingKey !== '';
608
- // const cellEdit: any = document.querySelector(`.ui-rc-table-row[data-row-key="${rowIndex}"] .cell-editing[data-col-index="${colIndex}"]`);
609
- // const cell: any = document.querySelector(`.ui-rc-table-row[data-row-key="${rowIndex}"] .cell-editable[data-col-index="${colIndex}"]`);
610
-
611
1114
  const cellEdit = document.querySelector(`.ui-rc-table-row .cell-editing[data-row-index="${rowIndex}"].cell-editing[data-col-index="${colIndex}"]`);
612
1115
  const cell = document.querySelector(`.ui-rc-table-row .cell-editable[data-row-index="${rowIndex}"].cell-editable[data-col-index="${colIndex}"]`);
613
1116
  const updateSelection = () => {
614
- setSelectedCell({
1117
+ setStartSelectedCell({
615
1118
  row: rowIndex,
616
1119
  col: colIndex
617
1120
  });
@@ -624,10 +1127,10 @@ const GridEdit = props => {
624
1127
  cellEdit.focus();
625
1128
  }
626
1129
  }
627
- if (type === 'horizontal' && cellEdit) {
1130
+ if (scrollType === 'horizontal' && cellEdit) {
628
1131
  scrollToCell(rowIndex, colIndex, cellEdit, 'horizontal');
629
1132
  }
630
- if (type === 'vertical' && cell) {
1133
+ if (scrollType === 'vertical' && cell) {
631
1134
  setEditingKey('');
632
1135
  updateSelection();
633
1136
  scrollToCell(rowIndex, colIndex, cellEdit, 'vertical');
@@ -643,11 +1146,52 @@ const GridEdit = props => {
643
1146
  }
644
1147
  }
645
1148
  if (cell) {
646
- scrollToCell(rowIndex, colIndex, cell, type);
1149
+ scrollToCell(rowIndex, colIndex, cell, scrollType);
647
1150
  }
648
1151
  }
649
1152
  };
650
- const convertColumns = flatColumns(columns).map((column, colIndex) => {
1153
+ const getCellClass = (record, rowIndex, colIndex) => {
1154
+ const cellKey = `${rowIndex}-${colIndex}`;
1155
+ const topCellKey = `${rowIndex + 1}-${colIndex}`;
1156
+ const leftCellKey = `${rowIndex}-${colIndex + 1}`;
1157
+ const rightCellKey = `${rowIndex}-${colIndex - 1}`;
1158
+ const isSelected = selectedCells.has(cellKey);
1159
+ const isTopSelected = selectedCells.has(topCellKey);
1160
+ const isLeftSelected = selectedCells.has(leftCellKey);
1161
+ const isRightSelected = selectedCells.has(rightCellKey);
1162
+ const isPasteSelected = pasteCells.has(cellKey);
1163
+ const isPasteLeftSelected = pasteCells.has(leftCellKey);
1164
+ const isPasteRightSelected = pasteCells.has(rightCellKey);
1165
+ const cellClass = isEditing(record) ? 'rc-ui-cell-editable cell-editing' : 'rc-ui-cell-editable cell-editable';
1166
+ const prevRecordEditing = flattenData(childrenColumnName, dataSource)[rowIndex + 1];
1167
+ const cellStart = getFirstSelectCell(selectedCells);
1168
+ const cellEnd = getLastSelectCell(selectedCells);
1169
+ const cellPasteStart = getFirstSelectCell(pasteCells);
1170
+ const cellPasteSEnd = getLastSelectCell(pasteCells);
1171
+ const isPasteBottom = pasteCells.size && cellPasteSEnd && rowIndex === Math.max(cellPasteStart.row, cellPasteSEnd.row);
1172
+ if (!isSelected && !isPasteSelected) {
1173
+ const isTop = prevRecordEditing && !isEditing(prevRecordEditing) && rowIndex === Math.min(cellStart.row - 1, cellEnd?.row);
1174
+ const isLeft = colIndex + 1 === Math.min(cellStart.col, cellEnd?.col);
1175
+ const isRight = colIndex - 1 === Math.max(cellStart.col, cellEnd?.col);
1176
+ const isPasteLeft = colIndex + 1 === Math.min(cellPasteStart.col, cellPasteSEnd?.col);
1177
+ const isPasteRight = colIndex - 1 === Math.max(cellPasteStart.col, cellPasteSEnd?.col);
1178
+ return isTopSelected || isLeftSelected || isRightSelected ? `${cellClass} ${isTop ? `cell-border-top` : ''} ${isLeft ? `cell-border-left` : ''} ${isPasteBottom ? `cell-paste-border-bottom` : ''} ${isRight ? `next-cell-border-left` : ''}` : isPasteLeftSelected || isPasteRightSelected ? `${cellClass} ${isPasteLeft ? `cell-paste-border-left` : ''} ${isPasteRight ? `next-cell-paste-border-left` : ''}` :
1179
+ // (isPasteLeftSelected || isPasteRightSelected) ? `${cellClass} ${isPasteLeft ? `cell-paste-border-left` : ''}` :
1180
+
1181
+ cellClass;
1182
+ }
1183
+ const isBottom = cellEnd && rowIndex === Math.max(cellStart.row, cellEnd.row);
1184
+ const isRight = cellEnd && colIndex === Math.max(cellStart.col, cellEnd.col);
1185
+ const isLeft = colIndex === Math.min(cellStart.col, cellEnd?.col);
1186
+ const isPasteRight = cellPasteSEnd && colIndex === Math.max(cellPasteStart.col, cellPasteSEnd.col);
1187
+ const isPasteLeft = colIndex === Math.min(cellPasteStart.col, cellPasteSEnd?.col);
1188
+
1189
+ // return `${cellClass} ${isBottom ? `cell-border-bottom` : ''} ${isRight ? `cell-border-right` : '' } ${isBottom && isRight ? `cell-border-end` : '' }
1190
+ // return `${cellClass} ${isPasteBottom ? `cell-paste-border-bottom` : ''} ${isBottom ? `cell-border-bottom` : ''} ${isRight ? `cell-border-right` : '' } ${isLeft ? `fixed-cell-border-left` : '' } ${isBottom && isRight ? `cell-border-end` : '' }`
1191
+
1192
+ return `${cellClass} ${isPasteBottom ? `cell-paste-border-bottom` : ''} ${isPasteSelected && isPasteRight ? `cell-paste-border-right` : ''} ${isPasteSelected && isPasteLeft ? `fixed-cell-paste-border-left` : ''} ${isBottom ? `cell-border-bottom` : ''} ${isRight ? `cell-border-right` : ''} ${isLeft ? `fixed-cell-border-left` : ''} ${isBottom && isRight ? `cell-border-end` : ''}`;
1193
+ };
1194
+ const convertColumns = flatColumns2(columns).map((column, colIndex) => {
651
1195
  if (!column?.field && !column?.key) {
652
1196
  return column;
653
1197
  }
@@ -678,83 +1222,96 @@ const GridEdit = props => {
678
1222
  }
679
1223
  return {
680
1224
  ...column,
681
- // editType: getEditType(column, record),
682
- onCell: (record, rowIndex) => ({
683
- onKeyDown: event => {
684
- if (event.key.length === 1 && !event.ctrlKey && !event.metaKey || event.key === 'Enter') {
685
- if (!isEditing(record) && record[rowKey] !== editingKey) {
686
- handleEdit(record, column, column.editType, event);
1225
+ onCell: (record, rowIndex) => {
1226
+ const rowNumber = getRowNumber(dataSource, record[rowKey], rowKey);
1227
+ return {
1228
+ onKeyDown: event => {
1229
+ const key = getRowKey(record, dataSource.indexOf(record));
1230
+ if (event.key.length === 1 && !event.ctrlKey && !event.metaKey || event.key === 'Enter') {
1231
+ if (!isEditing(record) && record[rowKey] !== editingKey) {
1232
+ handleEdit(record, column, column.editType, event);
1233
+ handleCellClick(rowNumber, record, column);
1234
+ const hasKey = mergedExpandedKeys.has(key);
1235
+ if (hasKey) {
1236
+ // mergedExpandedKeys.delete(key);
1237
+ // newExpandedKeys = [...mergedExpandedKeys];
1238
+ } else {
1239
+ onTriggerExpand(record);
1240
+ }
1241
+ }
1242
+ if (editingKey && editingKey !== '' && (rowNumber ?? 0) + 1 < flattenArray(dataSource).length && event.key === 'Enter') {
1243
+ handleFocusCell((rowNumber ?? 0) + 1, colIndex, column, 'vertical', event);
1244
+ }
687
1245
  }
688
- if (editingKey && editingKey !== '' && (rowIndex ?? 0) + 1 < dataSource.length && event.key === 'Enter') {
689
- handleFocusCell((rowIndex ?? 0) + 1, colIndex, column, 'vertical', event);
1246
+ if (event.key === 'Tab') {
1247
+ if (colIndex + 1 !== columns.length) {
1248
+ handleFocusCell(rowNumber, colIndex + 1, column, 'horizontal', event);
1249
+ } else {
1250
+ event.stopPropagation();
1251
+ event.preventDefault();
1252
+ }
690
1253
  }
691
- }
692
- if (event.key === 'Tab') {
693
- if (colIndex + 1 !== columns.length) {
694
- handleFocusCell(rowIndex, colIndex + 1, column, 'horizontal', event);
695
- } else {
696
- event.stopPropagation();
697
- event.preventDefault();
1254
+ if (event.key === 'ArrowRight' && colIndex + 1 !== columns.length) {
1255
+ if (editingKey !== '') {} else {
1256
+ handleFocusCell(rowNumber, colIndex + 1, column, 'horizontal', event);
1257
+ }
698
1258
  }
699
- }
700
- if (event.key === 'ArrowRight' && colIndex + 1 !== columns.length) {
701
- if (editingKey !== '') {} else {
702
- handleFocusCell(rowIndex, colIndex + 1, column, 'horizontal', event);
1259
+ if (event.key === 'ArrowLeft' && colIndex > 0) {
1260
+ if (!column.dataIndex && !column.key || column.field === 'index' || column.field === '#' || column.dataIndex === 'index' || column.dataIndex === '#') {
1261
+ event.stopPropagation();
1262
+ event.preventDefault();
1263
+ } else {
1264
+ if (editingKey !== '') {} else {
1265
+ handleFocusCell(rowNumber, colIndex - 1, column, 'horizontal', event);
1266
+ }
1267
+ }
703
1268
  }
704
- }
705
- if (event.key === 'ArrowLeft' && colIndex > 0) {
706
- if (!column.dataIndex && !column.key || column.field === 'index' || column.field === '#' || column.dataIndex === 'index' || column.dataIndex === '#') {
707
- event.stopPropagation();
1269
+ if (event.key === 'ArrowDown' && (rowNumber ?? 0) + 1 < flattenArray(dataSource).length) {
1270
+ handleFocusCell((rowNumber ?? 0) + 1, colIndex, column, 'vertical', event);
1271
+ }
1272
+ if (event.key === 'ArrowUp' && (rowNumber ?? 0) > 0) {
1273
+ handleFocusCell((rowNumber ?? 0) - 1, colIndex, column, 'vertical', event);
1274
+ }
1275
+ },
1276
+ onPaste: event => {
1277
+ if (editingKey === '') {
1278
+ handlePaste(record, colIndex, rowNumber, event);
708
1279
  event.preventDefault();
709
- } else {
710
- if (editingKey !== '') {} else {
711
- handleFocusCell(rowIndex, colIndex - 1, column, 'horizontal', event);
712
- }
713
1280
  }
714
- }
715
- if (event.key === 'ArrowDown' && (rowIndex ?? 0) + 1 < dataSource.length) {
716
- handleFocusCell((rowIndex ?? 0) + 1, colIndex, column, 'vertical', event);
717
- }
718
- if (event.key === 'ArrowUp' && (rowIndex ?? 0) > 0) {
719
- handleFocusCell((rowIndex ?? 0) - 1, colIndex, column, 'vertical', event);
720
- }
721
- },
722
- onPaste: event => {
723
- if (editingKey === '') {
724
- handlePaste(event, colIndex, rowIndex);
725
- event.preventDefault();
726
- }
727
- },
728
- onCopy: e => {
729
- if (editingKey === '') {
730
- handleCopy(e);
731
- e.preventDefault();
732
- }
733
- },
734
- onDoubleClick: event => {
735
- if (!isEditing(record) && record[rowKey] !== editingKey) {
736
- handleEdit(record, column, getEditType(column, record), event);
737
- }
738
- },
739
- onClick: () => {
740
- if (record[rowKey] !== editingKey && editingKey !== '') {
741
- setEditingKey('');
742
- }
743
- },
744
- className: isEditing(record) ? 'rc-ui-cell-editable cell-editing' : 'rc-ui-cell-editable cell-editable',
745
- record,
746
- column: column,
747
- editType: getEditType(column, record),
748
- dataIndex: column.dataIndex,
749
- title: column.title,
750
- 'data-col-index': colIndex,
751
- 'data-row-index': rowIndex,
752
- // colIndex: colIndex,
753
- indexCol: colIndex,
754
- indexRow: rowIndex,
755
- editing: isEditing(record),
756
- tabIndex: (rowIndex ?? 0) * columns.length + colIndex
757
- }),
1281
+ },
1282
+ onCopy: e => {
1283
+ if (editingKey === '') {
1284
+ handleCopy(e);
1285
+ e.preventDefault();
1286
+ }
1287
+ },
1288
+ onDoubleClick: event => {
1289
+ if (!isEditing(record) && record[rowKey] !== editingKey) {
1290
+ handleEdit(record, column, getEditType(column, record), event);
1291
+ handleCellClick(rowNumber, record, column);
1292
+ }
1293
+ },
1294
+ onClick: () => {
1295
+ if (record[rowKey] !== editingKey && editingKey !== '') {
1296
+ setEditingKey('');
1297
+ }
1298
+ },
1299
+ // className: isEditing(record) ? 'rc-ui-cell-editable cell-editing' : 'rc-ui-cell-editable cell-editable',
1300
+ className: getCellClass(record, rowNumber, colIndex),
1301
+ record,
1302
+ column: column,
1303
+ editType: getEditType(column, record),
1304
+ dataIndex: column.dataIndex,
1305
+ title: getValueCell(column, record[column.field], format),
1306
+ 'data-col-index': colIndex,
1307
+ 'data-row-index': rowNumber,
1308
+ editing: isEditing(record),
1309
+ tabIndex: (rowIndex ?? 0) * columns.length + colIndex,
1310
+ style: isPasteDragging ? {
1311
+ cursor: "crosshair"
1312
+ } : {}
1313
+ };
1314
+ },
758
1315
  render: (value, record, rowIndex) => {
759
1316
  const rowNumber = getRowNumber(dataSource, record[rowKey], rowKey);
760
1317
  return /*#__PURE__*/React.createElement("div", {
@@ -762,13 +1319,26 @@ const GridEdit = props => {
762
1319
  // selected: selectedCells.has(`${record[rowKey]}-${colIndex}`)
763
1320
  selected: selectedCells.has(`${rowNumber}-${colIndex}`)
764
1321
  }),
765
- onMouseDown: event => handleMouseDown(rowNumber, colIndex, event)
766
- // onMouseEnter={() => handleMouseEnter(record[rowKey], colIndex)}
767
- ,
768
- onMouseEnter: () => handleMouseEnter(rowNumber, colIndex)
1322
+ onMouseDown: event => handleMouseDown(record, rowNumber, colIndex, event),
1323
+ onMouseEnter: () => handleMouseEnter(rowNumber, colIndex),
1324
+ onMouseUp: handleMouseUp
769
1325
  }, /*#__PURE__*/React.createElement("div", {
770
1326
  className: 'ui-rc_content'
771
- }, renderContent(column, value, record, rowIndex, format)));
1327
+ }, renderContent(column, value, record, rowIndex, format)), getLastSelectCell(selectedCells).row === rowNumber && getLastSelectCell(selectedCells).col === colIndex && !isSelectDragging &&
1328
+ /*#__PURE__*/
1329
+ // showDraggingPoint &&
1330
+ React.createElement("div", {
1331
+ className: 'dragging-point'
1332
+ // onMouseEnter={(event) => handlePointEnter(event)}
1333
+ // onMouseLeave={() => handlePointLeave()}
1334
+ ,
1335
+ onMouseDown: () => {
1336
+ setIsPasteDragging(true);
1337
+ },
1338
+ onDoubleClick: handlePointDoubleClick
1339
+ }, /*#__PURE__*/React.createElement("span", {
1340
+ className: 'dot-point'
1341
+ })));
772
1342
  }
773
1343
  };
774
1344
  });
@@ -796,7 +1366,12 @@ const GridEdit = props => {
796
1366
  }, [convertColumns]);
797
1367
  const mergedColumns = React.useMemo(() => transformColumns(columns ?? []), [transformColumns, columns]);
798
1368
  const bottomToolbar = () => {
799
- return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(Toolbar, {
1369
+ return /*#__PURE__*/React.createElement("div", {
1370
+ className: 'ui-rc-toolbar-bottom',
1371
+ style: {
1372
+ borderBottom: '1px solid #e0e0e0'
1373
+ }
1374
+ }, /*#__PURE__*/React.createElement(Toolbar, {
800
1375
  style: {
801
1376
  width: '100%'
802
1377
  },
@@ -807,6 +1382,9 @@ const GridEdit = props => {
807
1382
  // }}
808
1383
  }));
809
1384
  };
1385
+ const onSelectChange = keys => {
1386
+ setMergedSelectedKeys(keys);
1387
+ };
810
1388
  return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement(GridStyle, {
811
1389
  heightTable: height,
812
1390
  style: {
@@ -826,6 +1404,23 @@ const GridEdit = props => {
826
1404
  }
827
1405
  }, /*#__PURE__*/React.createElement("form", {
828
1406
  onSubmit: handleSubmit(onSubmit)
1407
+ }, /*#__PURE__*/React.createElement(ConfigProvider, {
1408
+ theme: {
1409
+ components: {
1410
+ Table: {
1411
+ rowHoverBg: '#eb461912',
1412
+ rowSelectedBg: '#eb4619',
1413
+ rowSelectedHoverBg: '#eb4619',
1414
+ cellFontSize: 12,
1415
+ cellFontSizeSM: 13,
1416
+ headerBg: '#ffffff'
1417
+ // cellPaddingBlock: 0,
1418
+ // cellPaddingBlockSM: 0,
1419
+ // cellPaddingInlineSM: 0,
1420
+ // cellPaddingInline: 0
1421
+ }
1422
+ }
1423
+ }
829
1424
  }, /*#__PURE__*/React.createElement(TableGrid, _extends({}, rest, {
830
1425
  t: t,
831
1426
  tableRef: tableRef,
@@ -838,6 +1433,7 @@ const GridEdit = props => {
838
1433
  },
839
1434
  className: classNames(className, 'grid-editable'),
840
1435
  rowKey: rowKey,
1436
+ getRowKey: getRowKey,
841
1437
  columns: mergedColumns,
842
1438
  showSorterTooltip: {
843
1439
  target: 'sorter-icon'
@@ -848,13 +1444,51 @@ const GridEdit = props => {
848
1444
  ...selectionSettings,
849
1445
  checkboxOnly: true
850
1446
  } : undefined,
851
- style: {
852
- ...style,
853
- minHeight: height
854
- },
855
1447
  rowHoverable: false,
856
- bottomToolbar: bottomToolbar
857
- }))))), /*#__PURE__*/React.createElement(Toaster, {
1448
+ bottomToolbar: bottomToolbar,
1449
+ expandable: {
1450
+ ...expandable,
1451
+ expandedRowKeys: innerExpandedKeys,
1452
+ expandIcon: args => {
1453
+ const {
1454
+ record,
1455
+ expanded
1456
+ } = args;
1457
+
1458
+ // @ts-ignore
1459
+ if (record?.children?.length > 0 || record?.isChildren) {
1460
+ return expanded ? /*#__PURE__*/React.createElement("button", {
1461
+ onClick: e => {
1462
+ e.preventDefault();
1463
+ e.stopPropagation();
1464
+ onTriggerExpand(record);
1465
+ // onExpand(record, e)
1466
+ },
1467
+ className: 'ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-expanded'
1468
+ }) : /*#__PURE__*/React.createElement("button", {
1469
+ onClick: e => {
1470
+ e.preventDefault();
1471
+ e.stopPropagation();
1472
+ onTriggerExpand(record);
1473
+ // onExpand(record, e)
1474
+ },
1475
+ className: 'ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-collapsed'
1476
+ });
1477
+ } else {
1478
+ return /*#__PURE__*/React.createElement("button", {
1479
+ className: 'ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-spaced'
1480
+ });
1481
+ }
1482
+ }
1483
+ },
1484
+ rowSelection: columns && columns.length === 0 ? undefined : {
1485
+ type: mode === 'checkbox' || type === 'multiple' ? 'checkbox' : "radio",
1486
+ columnWidth: !mode ? 0.0000001 : columnWidth ?? 50,
1487
+ onChange: onSelectChange,
1488
+ selectedRowKeys: mergedSelectedKeys,
1489
+ preserveSelectedRowKeys: true
1490
+ }
1491
+ })))))), /*#__PURE__*/React.createElement(Toaster, {
858
1492
  position: toast,
859
1493
  toastOptions: {
860
1494
  className: 'react-hot-toast'