es-grid-template 1.2.1 → 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.
@@ -18,7 +18,7 @@ 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
23
  import useMergedState from "rc-util/es/hooks/useMergedState";
24
24
  // import useLazyKVMap from "rc-master-ui/es/table/hooks/useLazyKVMap";
@@ -83,7 +83,7 @@ const GridEdit = props => {
83
83
  const [selectedCells, setSelectedCells] = useState(new Set());
84
84
  const [pasteCells, setPasteCells] = useState(new Set());
85
85
  const [isSelectDragging, setSelectIsDragging] = useState(false);
86
- const [isPasteDragging, setIsPasteDragging] = useState(false);
86
+ const [isPasteDragging, setIsPasteDragging] = useState(false); // isPasteDragging == tiếp tục hiển thị con trỏ crosshair
87
87
 
88
88
  // const [showDraggingPoint, setShowDraggingPoint] = useState(false);
89
89
 
@@ -158,7 +158,21 @@ const GridEdit = props => {
158
158
  }
159
159
  };
160
160
  const handleDuplicate = () => {
161
- console.log('rowsFocus', rowsFocus);
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');
162
176
  };
163
177
  const handleInsertBefore = item => {
164
178
  const defaultRowValue = getDefaultValue(defaultValue);
@@ -176,7 +190,8 @@ const GridEdit = props => {
176
190
  newData.splice(index, 0, {
177
191
  ...defaultRowValue,
178
192
  rowId,
179
- parentId: null
193
+ parentId: null,
194
+ id: undefined
180
195
  });
181
196
  triggerChangeData?.(newData, 'INSERT_BEFORE');
182
197
  } else {
@@ -189,7 +204,8 @@ const GridEdit = props => {
189
204
  childData.splice(index, 0, {
190
205
  ...defaultRowValue,
191
206
  rowId,
192
- parentId: record.parentId
207
+ parentId: record.parentId,
208
+ id: undefined
193
209
  });
194
210
  const newRowData = {
195
211
  ...parent,
@@ -245,50 +261,156 @@ const GridEdit = props => {
245
261
  };
246
262
  const handleDeleteAll = () => {};
247
263
  const toolbarItemsBottom = useMemo(() => {
248
- return toolbarItems?.filter(it => it.position === 'Bottom').map(item => {
249
- return {
250
- ...item,
251
- template: () => {
252
- return /*#__PURE__*/React.createElement(Fragment, null, item.key === 'ADD' && /*#__PURE__*/React.createElement("div", {
253
- className: classnames(`be-toolbar-item`, item?.className)
254
- }, /*#__PURE__*/React.createElement(Dropdown.Button, {
255
- className: 'toolbar-button',
256
- menu: {
257
- items: itemsAdd,
258
- onClick: e => handleAddMulti(item, e)
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'))));
259
288
  }
260
- }, /*#__PURE__*/React.createElement("span", {
261
- onClick: () => handleAddSingle(item)
262
- }, item.title ? t ? t(item.title) : item.title : t ? t('Add item') : 'Add item'))), item.key === 'DUPLICATE' && item.visible !== false && rowsFocus.length > 0 && /*#__PURE__*/React.createElement("div", {
263
- className: classnames(`be-toolbar-item`, item?.className)
264
- }, /*#__PURE__*/React.createElement(Button, {
265
- color: "green",
266
- variant: 'outlined',
267
- onClick: handleDuplicate,
268
- className: "d-flex toolbar-button"
269
- }, item.title ? t ? t(item.title) : item.title : t ? t('Duplicate') : 'Duplicate')), item.key === 'INSERT_BEFORE' && item.visible !== false && rowsFocus.length > 0 && /*#__PURE__*/React.createElement("div", {
270
- className: classnames(`be-toolbar-item`, item?.className)
271
- }, /*#__PURE__*/React.createElement(Button, {
272
- color: "green",
273
- variant: 'outlined',
274
- onClick: () => handleInsertBefore(item),
275
- className: "d-flex toolbar-button"
276
- }, item.title ? t ? t(item.title) : item.title : t ? t('Insert item before') : 'Insert item before')), item.key === 'INSERT_AFTER' && item.visible !== false && rowsFocus.length > 0 && /*#__PURE__*/React.createElement("div", {
277
- className: classnames(`be-toolbar-item`, item?.className)
278
- }, /*#__PURE__*/React.createElement(Button, {
279
- color: "green",
280
- variant: 'outlined',
281
- onClick: () => handleInsertAfter(item),
282
- className: "d-flex toolbar-button"
283
- }, 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", {
284
- className: classnames(`be-toolbar-item`, item?.className)
285
- }, /*#__PURE__*/React.createElement(Button, {
286
- color: "primary",
287
- variant: 'outlined',
288
- onClick: handleDeleteAll,
289
- className: "d-flex toolbar-button"
290
- }, item.title ? t ? t(item.title) : item.title : t ? t('Delete all item') : 'Delete all item')));
289
+ };
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
+ };
291
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
292
414
  };
293
415
  });
294
416
  }, [handleAddMulti, handleAddSingle, itemsAdd, rowsFocus.length, t, toolbarItems]);
@@ -344,131 +466,168 @@ const GridEdit = props => {
344
466
  e.stopPropagation();
345
467
  return;
346
468
  }
347
- setSelectIsDragging(true);
348
469
  isSelecting.current = true;
349
470
  startCell.current = {
350
471
  row,
351
472
  col
352
473
  };
353
- if (!isPasteDragging) {
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) {
354
482
  setStartSelectedCell({
355
483
  row,
356
484
  col
357
485
  });
358
486
  setSelectedCells(new Set([`${row}-${col}`]));
359
487
  setRowsSelected(new Set());
360
- // setShowDraggingPoint(true)
488
+ // }
361
489
  }
362
490
 
363
- // if (record[rowKey] !== editingKey && (editingKey !== '')) {
364
- // setEditingKey('')
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())
365
500
  // }
366
501
  };
367
- const handlePointEnter = e => {
368
- if (e.button === 2) {
369
- e.stopPropagation();
370
- return;
371
- }
372
- setIsPasteDragging(true);
373
- };
374
- const handlePointLeave = () => {
375
- if (isPasteDragging && !isSelectDragging) {
376
- setIsPasteDragging(false);
377
- }
378
- };
379
- const handleMouseUp = () => {
380
- isSelecting.current = false;
381
- startCell.current = null;
382
- isSelectingRow.current = false;
383
- rowStart.current = null;
384
- setIsPasteDragging(false);
385
- setSelectIsDragging(false);
386
- if (pasteCells.size > 0) {
387
- console.log('');
388
- const mergedSet = new Set([...selectedCells, ...pasteCells]);
389
- setSelectedCells(mergedSet);
390
- setPasteCells(new Set());
391
- const selectedArray = Array.from(selectedCells).map(key => {
392
- const [row, col] = key.split("-").map(Number);
393
- // @ts-ignore
394
- const columnKey = columns[col].field;
395
502
 
396
- // @ts-ignore
397
- return {
398
- row,
399
- col,
400
- value: flattenData(childrenColumnName, dataSource)[row][columnKey]
401
- };
402
- // return { row, col, value: '' };
403
- });
503
+ // const handlePointEnter = (e: any) => {
504
+ //
505
+ // if (e.button === 2) {
506
+ // e.stopPropagation()
507
+ // return
508
+ // }
509
+ //
510
+ // // setIsPasteDragging(true);
511
+ //
512
+ // };
404
513
 
405
- // Xác định min/max row col để sắp xếp dữ liệu
406
- const minRow = Math.min(...selectedArray.map(cell => cell.row));
407
- const maxRow = Math.max(...selectedArray.map(cell => cell.row));
408
- const minCol = Math.min(...selectedArray.map(cell => cell.col));
409
- const maxCol = Math.max(...selectedArray.map(cell => cell.col));
514
+ // const handlePointLeave = () => {
515
+ //
516
+ // if (isPasteDragging && !isSelectDragging) {
517
+ // // setIsPasteDragging(false);
518
+ // }
519
+ //
520
+ // };
410
521
 
411
- // Tạo dữ liệu dạng bảng (mảng 2D)
412
- const table = Array.from({
413
- length: maxRow - minRow + 1
414
- }, () => Array(maxCol - minCol + 1).fill(""));
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;
415
530
 
416
- // Gán giá trị vào bảng
417
- selectedArray.forEach(({
531
+ // @ts-ignore
532
+ return {
418
533
  row,
419
534
  col,
420
- value
421
- }) => {
422
- table[row - minRow][col - minCol] = value;
423
- });
424
- const aaaa = addRows8(table, getRowsPasteIndex(pasteCells).length);
425
- const record = flattenData(childrenColumnName, dataSource)[getFirstSelectCell(pasteCells).row];
426
- if (!record.parentId) {
427
- // Cập nhật data mới
428
- const newData = [...dataSource];
535
+ value: flattenData(childrenColumnName, dataSource)[row][columnKey]
536
+ };
537
+ // return { row, col, value: '' };
538
+ });
429
539
 
430
- // Lấy vị trí bắt đầu
431
- // const { row: startRow, col: startCol } = selectedCell;
432
- const startRow = getFirstSelectCell(pasteCells).row;
433
- const startCol = getFirstSelectCell(selectedCells).col;
434
- const pastedRows = [];
435
- const pastedColumns = new Set();
436
- aaaa.addedRows.forEach((rowValues, rowIndex) => {
437
- const targetRow = startRow + rowIndex;
438
-
439
- // Nếu vượt quá số dòng hiện có, thêm dòng mới
440
- if (targetRow >= newData.length) {
441
- // @ts-ignore
442
- newData.push({
443
- id: undefined,
444
- rowId: newGuid()
445
- });
446
- }
447
- rowValues.forEach((cellValue, colIndex) => {
448
- const targetCol = startCol + colIndex;
449
- if (targetCol >= columns.length) {
450
- // Không vượt quá số cột
451
- return;
452
- }
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];
453
564
 
454
- // @ts-ignore
455
- const columnKey = columns[targetCol].field;
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;
456
573
 
457
- // @ts-ignore
458
- newData[targetRow] = {
459
- ...newData[targetRow],
460
- [columnKey]: typeof cellValue === 'string' ? cellValue.trim() : cellValue
461
- };
462
- pastedColumns.add(columnKey);
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()
463
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
+ }
464
588
 
465
- // Lưu dòng được paste
466
- pastedRows.push(newData[targetRow]);
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);
467
598
  });
468
- const pastedColumnsArray = Array.from(pastedColumns) ?? [];
469
- triggerPaste?.(pastedRows, pastedColumnsArray, newData);
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}`);
470
617
  }
471
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
+ }
472
631
  };
473
632
  const handleMouseEnter = (row, col) => {
474
633
  if (!isSelecting.current || !startCell.current) {
@@ -479,6 +638,10 @@ const GridEdit = props => {
479
638
  col: startCol
480
639
  } = startCell.current;
481
640
  if (!isPasteDragging) {
641
+ // chọn vùng copy
642
+
643
+ setSelectIsDragging(true);
644
+ setIsPasteDragging(false);
482
645
  const newSelectedCells = new Set();
483
646
  for (let r = Math.min(startRow, row); r <= Math.max(startRow, row); r++) {
484
647
  for (let c = Math.min(startCol, col); c <= Math.max(startCol, col); c++) {
@@ -487,6 +650,10 @@ const GridEdit = props => {
487
650
  }
488
651
  setSelectedCells(newSelectedCells);
489
652
  } else {
653
+ // chọn vùng paste
654
+
655
+ setSelectIsDragging(false);
656
+ setIsPasteDragging(true);
490
657
  const newSelectedCells = new Set();
491
658
  for (let r = Math.min(startRow, row); r <= Math.max(startRow, row); r++) {
492
659
  for (let c = Math.min(startCol, col); c <= Math.max(startCol, col); c++) {
@@ -495,13 +662,35 @@ const GridEdit = props => {
495
662
  }
496
663
  const colStart = getFirstSelectCell(selectedCells).col;
497
664
  const colEnd = getLastSelectCell(selectedCells).col;
498
- const newPasteCells = new Set();
499
- for (let r = Math.min(startRow, row) + 1; r <= Math.max(startRow, row); r++) {
500
- for (let c = Math.min(colStart, col); c <= Math.max(colStart, colEnd); c++) {
501
- newPasteCells.add(`${r}-${c}`);
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
+ }
502
674
  }
675
+ setPasteCells(newPasteCells);
503
676
  }
504
- setPasteCells(newPasteCells);
677
+ if (row < rowSelectedEnd) {
678
+ // kéo lên trên
679
+ }
680
+ if (col > colEnd) {
681
+ // kéo sang phải
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)
505
694
  }
506
695
  };
507
696
  const handleClickRowHeader = (row, col) => {
@@ -970,23 +1159,37 @@ const GridEdit = props => {
970
1159
  const isTopSelected = selectedCells.has(topCellKey);
971
1160
  const isLeftSelected = selectedCells.has(leftCellKey);
972
1161
  const isRightSelected = selectedCells.has(rightCellKey);
1162
+ const isPasteSelected = pasteCells.has(cellKey);
1163
+ const isPasteLeftSelected = pasteCells.has(leftCellKey);
1164
+ const isPasteRightSelected = pasteCells.has(rightCellKey);
973
1165
  const cellClass = isEditing(record) ? 'rc-ui-cell-editable cell-editing' : 'rc-ui-cell-editable cell-editable';
974
1166
  const prevRecordEditing = flattenData(childrenColumnName, dataSource)[rowIndex + 1];
975
1167
  const cellStart = getFirstSelectCell(selectedCells);
976
1168
  const cellEnd = getLastSelectCell(selectedCells);
977
- if (!isSelected) {
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) {
978
1173
  const isTop = prevRecordEditing && !isEditing(prevRecordEditing) && rowIndex === Math.min(cellStart.row - 1, cellEnd?.row);
979
1174
  const isLeft = colIndex + 1 === Math.min(cellStart.col, cellEnd?.col);
980
1175
  const isRight = colIndex - 1 === Math.max(cellStart.col, cellEnd?.col);
981
- return isTopSelected || isLeftSelected || isRightSelected ? `${cellClass} ${isTop ? `cell-border-top` : ''} ${isLeft ? `cell-border-left` : ''} ${isRight ? `next-cell-border-left` : ''}` : cellClass;
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;
982
1182
  }
983
1183
  const isBottom = cellEnd && rowIndex === Math.max(cellStart.row, cellEnd.row);
984
1184
  const isRight = cellEnd && colIndex === Math.max(cellStart.col, cellEnd.col);
985
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);
986
1188
 
987
1189
  // return `${cellClass} ${isBottom ? `cell-border-bottom` : ''} ${isRight ? `cell-border-right` : '' } ${isBottom && isRight ? `cell-border-end` : '' }
988
- return `${cellClass} ${isBottom ? `cell-border-bottom` : ''} ${isRight ? `cell-border-right` : ''} ${isLeft ? `fixed-cell-border-left` : ''} ${isBottom && isRight ? `cell-border-end` : ''}
989
- `;
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` : ''}`;
990
1193
  };
991
1194
  const convertColumns = flatColumns2(columns).map((column, colIndex) => {
992
1195
  if (!column?.field && !column?.key) {
@@ -1118,16 +1321,21 @@ const GridEdit = props => {
1118
1321
  }),
1119
1322
  onMouseDown: event => handleMouseDown(record, rowNumber, colIndex, event),
1120
1323
  onMouseEnter: () => handleMouseEnter(rowNumber, colIndex),
1121
- onMouseUp: () => handleMouseUp()
1324
+ onMouseUp: handleMouseUp
1122
1325
  }, /*#__PURE__*/React.createElement("div", {
1123
1326
  className: 'ui-rc_content'
1124
1327
  }, renderContent(column, value, record, rowIndex, format)), getLastSelectCell(selectedCells).row === rowNumber && getLastSelectCell(selectedCells).col === colIndex && !isSelectDragging &&
1125
1328
  /*#__PURE__*/
1126
1329
  // showDraggingPoint &&
1127
- React.createElement("span", {
1128
- className: 'dragging-point',
1129
- onMouseEnter: event => handlePointEnter(event),
1130
- onMouseLeave: () => handlePointLeave()
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
1131
1339
  }, /*#__PURE__*/React.createElement("span", {
1132
1340
  className: 'dot-point'
1133
1341
  })));
@@ -1196,6 +1404,23 @@ const GridEdit = props => {
1196
1404
  }
1197
1405
  }, /*#__PURE__*/React.createElement("form", {
1198
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
+ }
1199
1424
  }, /*#__PURE__*/React.createElement(TableGrid, _extends({}, rest, {
1200
1425
  t: t,
1201
1426
  tableRef: tableRef,
@@ -1263,7 +1488,7 @@ const GridEdit = props => {
1263
1488
  selectedRowKeys: mergedSelectedKeys,
1264
1489
  preserveSelectedRowKeys: true
1265
1490
  }
1266
- }))))), /*#__PURE__*/React.createElement(Toaster, {
1491
+ })))))), /*#__PURE__*/React.createElement(Toaster, {
1267
1492
  position: toast,
1268
1493
  toastOptions: {
1269
1494
  className: 'react-hot-toast'