es-grid-template 1.2.1 → 1.2.3

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.
@@ -90,7 +90,7 @@ const GridEdit = props => {
90
90
  const [selectedCells, setSelectedCells] = (0, _react.useState)(new Set());
91
91
  const [pasteCells, setPasteCells] = (0, _react.useState)(new Set());
92
92
  const [isSelectDragging, setSelectIsDragging] = (0, _react.useState)(false);
93
- const [isPasteDragging, setIsPasteDragging] = (0, _react.useState)(false);
93
+ const [isPasteDragging, setIsPasteDragging] = (0, _react.useState)(false); // isPasteDragging == tiếp tục hiển thị con trỏ crosshair
94
94
 
95
95
  // const [showDraggingPoint, setShowDraggingPoint] = useState(false);
96
96
 
@@ -165,7 +165,21 @@ const GridEdit = props => {
165
165
  }
166
166
  };
167
167
  const handleDuplicate = () => {
168
- console.log('rowsFocus', rowsFocus);
168
+ // không tính tree
169
+
170
+ // Cập nhật data mới
171
+ const newData = [...dataSource];
172
+ const duplicatedItems = rowsFocus.map(index => ({
173
+ ...newData[index],
174
+ rowId: (0, _hooks.newGuid)(),
175
+ id: undefined,
176
+ isDuplicate: true
177
+ }));
178
+
179
+ // Vị trí chèn là ngay sau phần tử lớn nhất trong rowsFocus
180
+ const insertAfter = Math.max(...rowsFocus);
181
+ const rs = [...newData.slice(0, insertAfter + 1), ...duplicatedItems, ...newData.slice(insertAfter + 1)];
182
+ triggerChangeData?.(rs, 'DUPLICATE');
169
183
  };
170
184
  const handleInsertBefore = item => {
171
185
  const defaultRowValue = (0, _hooks.getDefaultValue)(defaultValue);
@@ -183,7 +197,8 @@ const GridEdit = props => {
183
197
  newData.splice(index, 0, {
184
198
  ...defaultRowValue,
185
199
  rowId,
186
- parentId: null
200
+ parentId: null,
201
+ id: undefined
187
202
  });
188
203
  triggerChangeData?.(newData, 'INSERT_BEFORE');
189
204
  } else {
@@ -196,7 +211,8 @@ const GridEdit = props => {
196
211
  childData.splice(index, 0, {
197
212
  ...defaultRowValue,
198
213
  rowId,
199
- parentId: record.parentId
214
+ parentId: record.parentId,
215
+ id: undefined
200
216
  });
201
217
  const newRowData = {
202
218
  ...parent,
@@ -252,50 +268,156 @@ const GridEdit = props => {
252
268
  };
253
269
  const handleDeleteAll = () => {};
254
270
  const toolbarItemsBottom = (0, _react.useMemo)(() => {
255
- return toolbarItems?.filter(it => it.position === 'Bottom').map(item => {
256
- return {
257
- ...item,
258
- template: () => {
259
- return /*#__PURE__*/_react.default.createElement(_react.Fragment, null, item.key === 'ADD' && /*#__PURE__*/_react.default.createElement("div", {
260
- className: (0, _classnames.default)(`be-toolbar-item`, item?.className)
261
- }, /*#__PURE__*/_react.default.createElement(_antd.Dropdown.Button, {
262
- className: 'toolbar-button',
263
- menu: {
264
- items: itemsAdd,
265
- onClick: e => handleAddMulti(item, e)
271
+ if (!rowsFocus || rowsFocus.length === 0) {
272
+ return toolbarItems?.filter(it => it.position === 'Bottom' && it.visible !== false && it.key !== 'DUPLICATE' && it.key !== 'INSERT_BEFORE' && it.key !== 'INSERT_AFTER').map(item => {
273
+ if (item.key === 'ADD') {
274
+ return {
275
+ ...item,
276
+ template: () => {
277
+ return /*#__PURE__*/_react.default.createElement(_react.Fragment, null, item.key === 'ADD' && /*#__PURE__*/_react.default.createElement("div", {
278
+ className: (0, _classnames.default)(`be-toolbar-item`, item?.className)
279
+ }, /*#__PURE__*/_react.default.createElement(_antd.Dropdown.Button, {
280
+ style: {
281
+ color: '#28c76f',
282
+ borderColor: '#28c76f'
283
+ },
284
+ className: 'toolbar-button toolbar-dropdown-button',
285
+ menu: {
286
+ items: itemsAdd,
287
+ onClick: e => handleAddMulti(item, e)
288
+ }
289
+ }, /*#__PURE__*/_react.default.createElement("span", {
290
+ style: {
291
+ color: '#28c76f'
292
+ },
293
+ onClick: () => handleAddSingle(item)
294
+ }, item.title ? t ? t(item.title) : item.title : t ? t('Add item') : 'Add item'))));
266
295
  }
267
- }, /*#__PURE__*/_react.default.createElement("span", {
268
- onClick: () => handleAddSingle(item)
269
- }, 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.default.createElement("div", {
270
- className: (0, _classnames.default)(`be-toolbar-item`, item?.className)
271
- }, /*#__PURE__*/_react.default.createElement(_antd.Button, {
272
- color: "green",
273
- variant: 'outlined',
274
- onClick: handleDuplicate,
275
- className: "d-flex toolbar-button"
276
- }, item.title ? t ? t(item.title) : item.title : t ? t('Duplicate') : 'Duplicate')), item.key === 'INSERT_BEFORE' && item.visible !== false && rowsFocus.length > 0 && /*#__PURE__*/_react.default.createElement("div", {
277
- className: (0, _classnames.default)(`be-toolbar-item`, item?.className)
278
- }, /*#__PURE__*/_react.default.createElement(_antd.Button, {
279
- color: "green",
280
- variant: 'outlined',
281
- onClick: () => handleInsertBefore(item),
282
- className: "d-flex toolbar-button"
283
- }, 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.default.createElement("div", {
284
- className: (0, _classnames.default)(`be-toolbar-item`, item?.className)
285
- }, /*#__PURE__*/_react.default.createElement(_antd.Button, {
286
- color: "green",
287
- variant: 'outlined',
288
- onClick: () => handleInsertAfter(item),
289
- className: "d-flex toolbar-button"
290
- }, item.title ? t ? t(item.title) : item.title : t ? t('Insert item after') : 'Insert item after')), item.key === 'DELETE' && item.visible !== false && /*#__PURE__*/_react.default.createElement("div", {
291
- className: (0, _classnames.default)(`be-toolbar-item`, item?.className)
292
- }, /*#__PURE__*/_react.default.createElement(_antd.Button, {
293
- color: "primary",
294
- variant: 'outlined',
295
- onClick: handleDeleteAll,
296
- className: "d-flex toolbar-button"
297
- }, item.title ? t ? t(item.title) : item.title : t ? t('Delete all item') : 'Delete all item')));
296
+ };
297
+ }
298
+ if (item.key === 'DELETE') {
299
+ return {
300
+ ...item,
301
+ template: () => {
302
+ return /*#__PURE__*/_react.default.createElement("div", {
303
+ className: (0, _classnames.default)(`be-toolbar-item`, item?.className)
304
+ }, /*#__PURE__*/_react.default.createElement(_antd.Button, {
305
+ style: {
306
+ color: '#eb4619',
307
+ borderColor: '#eb4619'
308
+ },
309
+ variant: 'outlined',
310
+ onClick: handleDeleteAll,
311
+ className: "d-flex toolbar-button"
312
+ }, item.title ? t ? t(item.title) : item.title : t ? t('Delete all item') : 'Delete all item'));
313
+ }
314
+ };
298
315
  }
316
+ return {
317
+ ...item
318
+ };
319
+ });
320
+ }
321
+ return toolbarItems?.filter(it => it.position === 'Bottom' && it.visible !== false).map(item => {
322
+ if (item.key === 'ADD') {
323
+ return {
324
+ ...item,
325
+ template: () => {
326
+ return /*#__PURE__*/_react.default.createElement(_react.Fragment, null, item.key === 'ADD' && /*#__PURE__*/_react.default.createElement("div", {
327
+ className: (0, _classnames.default)(`be-toolbar-item`, item?.className)
328
+ }, /*#__PURE__*/_react.default.createElement(_antd.Dropdown.Button, {
329
+ style: {
330
+ color: '#28c76f',
331
+ borderColor: '#28c76f'
332
+ },
333
+ className: 'toolbar-button toolbar-dropdown-button',
334
+ menu: {
335
+ items: itemsAdd,
336
+ onClick: e => handleAddMulti(item, e)
337
+ }
338
+ }, /*#__PURE__*/_react.default.createElement("span", {
339
+ style: {
340
+ color: '#28c76f'
341
+ },
342
+ onClick: () => handleAddSingle(item)
343
+ }, item.title ? t ? t(item.title) : item.title : t ? t('Add item') : 'Add item'))));
344
+ }
345
+ };
346
+ }
347
+ if (item.key === 'DUPLICATE') {
348
+ return {
349
+ ...item,
350
+ template: () => {
351
+ return /*#__PURE__*/_react.default.createElement(_react.Fragment, null, item.key === 'DUPLICATE' && item.visible !== false && rowsFocus.length > 0 && /*#__PURE__*/_react.default.createElement("div", {
352
+ className: (0, _classnames.default)(`be-toolbar-item`, item?.className)
353
+ }, /*#__PURE__*/_react.default.createElement(_antd.Button, {
354
+ style: {
355
+ color: '#28c76f',
356
+ borderColor: '#28c76f'
357
+ },
358
+ variant: 'outlined',
359
+ onClick: handleDuplicate,
360
+ className: "d-flex toolbar-button"
361
+ }, item.title ? t ? t(item.title) : item.title : t ? t('Duplicate') : 'Duplicate')));
362
+ }
363
+ };
364
+ }
365
+ if (item.key === 'INSERT_BEFORE') {
366
+ return {
367
+ ...item,
368
+ template: () => {
369
+ return /*#__PURE__*/_react.default.createElement(_react.Fragment, null, item.key === 'INSERT_BEFORE' && item.visible !== false && rowsFocus.length > 0 && /*#__PURE__*/_react.default.createElement("div", {
370
+ className: (0, _classnames.default)(`be-toolbar-item`, item?.className)
371
+ }, /*#__PURE__*/_react.default.createElement(_antd.Button, {
372
+ style: {
373
+ color: '#28c76f',
374
+ borderColor: '#28c76f'
375
+ },
376
+ variant: 'outlined',
377
+ onClick: () => handleInsertBefore(item),
378
+ className: "d-flex toolbar-button"
379
+ }, item.title ? t ? t(item.title) : item.title : t ? t('Insert item before') : 'Insert item before')));
380
+ }
381
+ };
382
+ }
383
+ if (item.key === 'INSERT_AFTER') {
384
+ return {
385
+ ...item,
386
+ template: () => {
387
+ return /*#__PURE__*/_react.default.createElement(_react.Fragment, null, item.key === 'INSERT_AFTER' && item.visible !== false && rowsFocus.length > 0 && /*#__PURE__*/_react.default.createElement("div", {
388
+ className: (0, _classnames.default)(`be-toolbar-item`, item?.className)
389
+ }, /*#__PURE__*/_react.default.createElement(_antd.Button, {
390
+ style: {
391
+ color: '#28c76f',
392
+ borderColor: '#28c76f'
393
+ },
394
+ variant: 'outlined',
395
+ onClick: () => handleInsertAfter(item),
396
+ className: "d-flex toolbar-button"
397
+ }, item.title ? t ? t(item.title) : item.title : t ? t('Insert item after') : 'Insert item after')));
398
+ }
399
+ };
400
+ }
401
+ if (item.key === 'DELETE') {
402
+ return {
403
+ ...item,
404
+ template: () => {
405
+ return /*#__PURE__*/_react.default.createElement("div", {
406
+ className: (0, _classnames.default)(`be-toolbar-item`, item?.className)
407
+ }, /*#__PURE__*/_react.default.createElement(_antd.Button, {
408
+ style: {
409
+ color: '#eb4619',
410
+ borderColor: '#eb4619'
411
+ },
412
+ variant: 'outlined',
413
+ onClick: handleDeleteAll,
414
+ className: "d-flex toolbar-button"
415
+ }, item.title ? t ? t(item.title) : item.title : t ? t('Delete all item') : 'Delete all item'));
416
+ }
417
+ };
418
+ }
419
+ return {
420
+ ...item
299
421
  };
300
422
  });
301
423
  }, [handleAddMulti, handleAddSingle, itemsAdd, rowsFocus.length, t, toolbarItems]);
@@ -351,131 +473,168 @@ const GridEdit = props => {
351
473
  e.stopPropagation();
352
474
  return;
353
475
  }
354
- setSelectIsDragging(true);
355
476
  isSelecting.current = true;
356
477
  startCell.current = {
357
478
  row,
358
479
  col
359
480
  };
360
- if (!isPasteDragging) {
481
+ if (e.target.className === 'dragging-point') {
482
+ // e.stopPropagation()
483
+ // e.preventDefault()
484
+ } else {
485
+ // isSelecting.current = true;
486
+ // startCell.current = { row, col };
487
+
488
+ // if (!isPasteDragging) {
361
489
  setStartSelectedCell({
362
490
  row,
363
491
  col
364
492
  });
365
493
  setSelectedCells(new Set([`${row}-${col}`]));
366
494
  setRowsSelected(new Set());
367
- // setShowDraggingPoint(true)
495
+ // }
368
496
  }
369
497
 
370
- // if (record[rowKey] !== editingKey && (editingKey !== '')) {
371
- // setEditingKey('')
498
+ // setSelectIsDragging(true)
499
+
500
+ // isSelecting.current = true;
501
+ // startCell.current = { row, col };
502
+ //
503
+ // if (!isPasteDragging) {
504
+ // setStartSelectedCell({ row, col })
505
+ // setSelectedCells(new Set([`${row}-${col}`]));
506
+ // setRowsSelected(new Set())
372
507
  // }
373
508
  };
374
- const handlePointEnter = e => {
375
- if (e.button === 2) {
376
- e.stopPropagation();
377
- return;
378
- }
379
- setIsPasteDragging(true);
380
- };
381
- const handlePointLeave = () => {
382
- if (isPasteDragging && !isSelectDragging) {
383
- setIsPasteDragging(false);
384
- }
385
- };
386
- const handleMouseUp = () => {
387
- isSelecting.current = false;
388
- startCell.current = null;
389
- isSelectingRow.current = false;
390
- rowStart.current = null;
391
- setIsPasteDragging(false);
392
- setSelectIsDragging(false);
393
- if (pasteCells.size > 0) {
394
- console.log('');
395
- const mergedSet = new Set([...selectedCells, ...pasteCells]);
396
- setSelectedCells(mergedSet);
397
- setPasteCells(new Set());
398
- const selectedArray = Array.from(selectedCells).map(key => {
399
- const [row, col] = key.split("-").map(Number);
400
- // @ts-ignore
401
- const columnKey = columns[col].field;
402
509
 
403
- // @ts-ignore
404
- return {
405
- row,
406
- col,
407
- value: (0, _hooks.flattenData)(childrenColumnName, dataSource)[row][columnKey]
408
- };
409
- // return { row, col, value: '' };
410
- });
510
+ // const handlePointEnter = (e: any) => {
511
+ //
512
+ // if (e.button === 2) {
513
+ // e.stopPropagation()
514
+ // return
515
+ // }
516
+ //
517
+ // // setIsPasteDragging(true);
518
+ //
519
+ // };
411
520
 
412
- // Xác định min/max row col để sắp xếp dữ liệu
413
- const minRow = Math.min(...selectedArray.map(cell => cell.row));
414
- const maxRow = Math.max(...selectedArray.map(cell => cell.row));
415
- const minCol = Math.min(...selectedArray.map(cell => cell.col));
416
- const maxCol = Math.max(...selectedArray.map(cell => cell.col));
521
+ // const handlePointLeave = () => {
522
+ //
523
+ // if (isPasteDragging && !isSelectDragging) {
524
+ // // setIsPasteDragging(false);
525
+ // }
526
+ //
527
+ // };
417
528
 
418
- // Tạo dữ liệu dạng bảng (mảng 2D)
419
- const table = Array.from({
420
- length: maxRow - minRow + 1
421
- }, () => Array(maxCol - minCol + 1).fill(""));
529
+ const triggerDragPaste = pastesArray => {
530
+ const mergedSet = new Set([...selectedCells, ...pastesArray]);
531
+ setSelectedCells(mergedSet);
532
+ setPasteCells(new Set());
533
+ const selectedArray = Array.from(selectedCells).map(key => {
534
+ const [row, col] = key.split("-").map(Number);
535
+ // @ts-ignore
536
+ const columnKey = columns[col].field;
422
537
 
423
- // Gán giá trị vào bảng
424
- selectedArray.forEach(({
538
+ // @ts-ignore
539
+ return {
425
540
  row,
426
541
  col,
427
- value
428
- }) => {
429
- table[row - minRow][col - minCol] = value;
430
- });
431
- const aaaa = (0, _hooks.addRows8)(table, (0, _hooks.getRowsPasteIndex)(pasteCells).length);
432
- const record = (0, _hooks.flattenData)(childrenColumnName, dataSource)[(0, _hooks.getFirstSelectCell)(pasteCells).row];
433
- if (!record.parentId) {
434
- // Cập nhật data mới
435
- const newData = [...dataSource];
542
+ value: (0, _hooks.flattenData)(childrenColumnName, dataSource)[row][columnKey]
543
+ };
544
+ // return { row, col, value: '' };
545
+ });
436
546
 
437
- // Lấy vị trí bắt đầu
438
- // const { row: startRow, col: startCol } = selectedCell;
439
- const startRow = (0, _hooks.getFirstSelectCell)(pasteCells).row;
440
- const startCol = (0, _hooks.getFirstSelectCell)(selectedCells).col;
441
- const pastedRows = [];
442
- const pastedColumns = new Set();
443
- aaaa.addedRows.forEach((rowValues, rowIndex) => {
444
- const targetRow = startRow + rowIndex;
445
-
446
- // Nếu vượt quá số dòng hiện có, thêm dòng mới
447
- if (targetRow >= newData.length) {
448
- // @ts-ignore
449
- newData.push({
450
- id: undefined,
451
- rowId: (0, _hooks.newGuid)()
452
- });
453
- }
454
- rowValues.forEach((cellValue, colIndex) => {
455
- const targetCol = startCol + colIndex;
456
- if (targetCol >= columns.length) {
457
- // Không vượt quá số cột
458
- return;
459
- }
547
+ // Xác định min/max row và col để sắp xếp dữ liệu
548
+ const minRow = Math.min(...selectedArray.map(cell => cell.row));
549
+ const maxRow = Math.max(...selectedArray.map(cell => cell.row));
550
+ const minCol = Math.min(...selectedArray.map(cell => cell.col));
551
+ const maxCol = Math.max(...selectedArray.map(cell => cell.col));
552
+
553
+ // Tạo dữ liệu dạng bảng (mảng 2D)
554
+ const table = Array.from({
555
+ length: maxRow - minRow + 1
556
+ }, () => Array(maxCol - minCol + 1).fill(""));
557
+
558
+ // Gán giá trị vào bảng
559
+ selectedArray.forEach(({
560
+ row,
561
+ col,
562
+ value
563
+ }) => {
564
+ table[row - minRow][col - minCol] = value;
565
+ });
566
+ const newRange = (0, _hooks.addRows8)(table, (0, _hooks.getRowsPasteIndex)(pastesArray).length);
567
+ const record = (0, _hooks.flattenData)(childrenColumnName, dataSource)[(0, _hooks.getFirstSelectCell)(pastesArray).row];
568
+ if (!record.parentId) {
569
+ // Cập nhật data mới
570
+ const newData = [...dataSource];
460
571
 
461
- // @ts-ignore
462
- const columnKey = columns[targetCol].field;
572
+ // Lấy vị trí bắt đầu
573
+ // const { row: startRow, col: startCol } = selectedCell;
574
+ const startRow = (0, _hooks.getFirstSelectCell)(pastesArray).row;
575
+ const startCol = (0, _hooks.getFirstSelectCell)(selectedCells).col;
576
+ const pastedRows = [];
577
+ const pastedColumns = new Set();
578
+ newRange.addedRows.forEach((rowValues, rowIndex) => {
579
+ const targetRow = startRow + rowIndex;
463
580
 
464
- // @ts-ignore
465
- newData[targetRow] = {
466
- ...newData[targetRow],
467
- [columnKey]: typeof cellValue === 'string' ? cellValue.trim() : cellValue
468
- };
469
- pastedColumns.add(columnKey);
581
+ // Nếu vượt quá số dòng hiện có, thêm dòng mới
582
+ if (targetRow >= newData.length) {
583
+ // @ts-ignore
584
+ newData.push({
585
+ id: undefined,
586
+ rowId: (0, _hooks.newGuid)()
470
587
  });
588
+ }
589
+ rowValues.forEach((cellValue, colIndex) => {
590
+ const targetCol = startCol + colIndex;
591
+ if (targetCol >= columns.length) {
592
+ // Không vượt quá số cột
593
+ return;
594
+ }
471
595
 
472
- // Lưu dòng được paste
473
- pastedRows.push(newData[targetRow]);
596
+ // @ts-ignore
597
+ const columnKey = columns[targetCol].field;
598
+
599
+ // @ts-ignore
600
+ newData[targetRow] = {
601
+ ...newData[targetRow],
602
+ [columnKey]: typeof cellValue === 'string' ? cellValue.trim() : cellValue
603
+ };
604
+ pastedColumns.add(columnKey);
474
605
  });
475
- const pastedColumnsArray = Array.from(pastedColumns) ?? [];
476
- triggerPaste?.(pastedRows, pastedColumnsArray, newData);
606
+
607
+ // Lưu dòng được paste
608
+ pastedRows.push(newData[targetRow]);
609
+ });
610
+ const pastedColumnsArray = Array.from(pastedColumns) ?? [];
611
+ triggerPaste?.(pastedRows, pastedColumnsArray, newData);
612
+ }
613
+ };
614
+ const handlePointDoubleClick = e => {
615
+ e.preventDefault();
616
+ e.stopPropagation();
617
+ const colStart = (0, _hooks.getFirstSelectCell)(selectedCells).col;
618
+ const colEnd = (0, _hooks.getLastSelectCell)(selectedCells).col;
619
+ const startPasteRow = (0, _hooks.getLastSelectCell)(selectedCells).row;
620
+ const newPasteCells = new Set();
621
+ for (let r = Math.min(startPasteRow, dataSource.length - 1) + 1; r <= Math.max(startPasteRow, dataSource.length - 1); r++) {
622
+ for (let c = Math.min(colStart, colStart); c <= Math.max(colStart, colEnd); c++) {
623
+ newPasteCells.add(`${r}-${c}`);
477
624
  }
478
625
  }
626
+ triggerDragPaste(newPasteCells);
627
+ };
628
+ const handleMouseUp = () => {
629
+ isSelecting.current = false;
630
+ startCell.current = null;
631
+ isSelectingRow.current = false;
632
+ rowStart.current = null;
633
+ setIsPasteDragging(false);
634
+ setSelectIsDragging(false);
635
+ if (pasteCells.size > 0) {
636
+ triggerDragPaste(pasteCells);
637
+ }
479
638
  };
480
639
  const handleMouseEnter = (row, col) => {
481
640
  if (!isSelecting.current || !startCell.current) {
@@ -486,6 +645,10 @@ const GridEdit = props => {
486
645
  col: startCol
487
646
  } = startCell.current;
488
647
  if (!isPasteDragging) {
648
+ // chọn vùng copy
649
+
650
+ setSelectIsDragging(true);
651
+ setIsPasteDragging(false);
489
652
  const newSelectedCells = new Set();
490
653
  for (let r = Math.min(startRow, row); r <= Math.max(startRow, row); r++) {
491
654
  for (let c = Math.min(startCol, col); c <= Math.max(startCol, col); c++) {
@@ -494,6 +657,10 @@ const GridEdit = props => {
494
657
  }
495
658
  setSelectedCells(newSelectedCells);
496
659
  } else {
660
+ // chọn vùng paste
661
+
662
+ setSelectIsDragging(false);
663
+ setIsPasteDragging(true);
497
664
  const newSelectedCells = new Set();
498
665
  for (let r = Math.min(startRow, row); r <= Math.max(startRow, row); r++) {
499
666
  for (let c = Math.min(startCol, col); c <= Math.max(startCol, col); c++) {
@@ -502,13 +669,35 @@ const GridEdit = props => {
502
669
  }
503
670
  const colStart = (0, _hooks.getFirstSelectCell)(selectedCells).col;
504
671
  const colEnd = (0, _hooks.getLastSelectCell)(selectedCells).col;
505
- const newPasteCells = new Set();
506
- for (let r = Math.min(startRow, row) + 1; r <= Math.max(startRow, row); r++) {
507
- for (let c = Math.min(colStart, col); c <= Math.max(colStart, colEnd); c++) {
508
- newPasteCells.add(`${r}-${c}`);
672
+ const rowSelectedEnd = (0, _hooks.getLastSelectCell)(selectedCells).row;
673
+ if (row >= rowSelectedEnd) {
674
+ // kéo xuống dưới
675
+
676
+ const newPasteCells = new Set();
677
+ for (let r = Math.min(startRow, row) + 1; r <= Math.max(startRow, row); r++) {
678
+ for (let c = Math.min(colStart, col); c <= Math.max(colStart, colEnd); c++) {
679
+ newPasteCells.add(`${r}-${c}`);
680
+ }
509
681
  }
682
+ setPasteCells(newPasteCells);
510
683
  }
511
- setPasteCells(newPasteCells);
684
+ if (row < rowSelectedEnd) {
685
+ // kéo lên trên
686
+ }
687
+ if (col > colEnd) {
688
+ // kéo sang phải
689
+ }
690
+ if (row < colStart) {
691
+ // kéo sang trái
692
+ }
693
+
694
+ // const newPasteCells = new Set()
695
+ // for (let r = Math.min(startRow, row) + 1; r <= Math.max(startRow, row); r++) {
696
+ // for (let c = Math.min(colStart, col); c <= Math.max(colStart, colEnd); c++) {
697
+ // newPasteCells.add(`${r}-${c}`);
698
+ // }
699
+ // }
700
+ // setPasteCells(newPasteCells)
512
701
  }
513
702
  };
514
703
  const handleClickRowHeader = (row, col) => {
@@ -977,23 +1166,37 @@ const GridEdit = props => {
977
1166
  const isTopSelected = selectedCells.has(topCellKey);
978
1167
  const isLeftSelected = selectedCells.has(leftCellKey);
979
1168
  const isRightSelected = selectedCells.has(rightCellKey);
1169
+ const isPasteSelected = pasteCells.has(cellKey);
1170
+ const isPasteLeftSelected = pasteCells.has(leftCellKey);
1171
+ const isPasteRightSelected = pasteCells.has(rightCellKey);
980
1172
  const cellClass = isEditing(record) ? 'rc-ui-cell-editable cell-editing' : 'rc-ui-cell-editable cell-editable';
981
1173
  const prevRecordEditing = (0, _hooks.flattenData)(childrenColumnName, dataSource)[rowIndex + 1];
982
1174
  const cellStart = (0, _hooks.getFirstSelectCell)(selectedCells);
983
1175
  const cellEnd = (0, _hooks.getLastSelectCell)(selectedCells);
984
- if (!isSelected) {
1176
+ const cellPasteStart = (0, _hooks.getFirstSelectCell)(pasteCells);
1177
+ const cellPasteSEnd = (0, _hooks.getLastSelectCell)(pasteCells);
1178
+ const isPasteBottom = pasteCells.size && cellPasteSEnd && rowIndex === Math.max(cellPasteStart.row, cellPasteSEnd.row);
1179
+ if (!isSelected && !isPasteSelected) {
985
1180
  const isTop = prevRecordEditing && !isEditing(prevRecordEditing) && rowIndex === Math.min(cellStart.row - 1, cellEnd?.row);
986
1181
  const isLeft = colIndex + 1 === Math.min(cellStart.col, cellEnd?.col);
987
1182
  const isRight = colIndex - 1 === Math.max(cellStart.col, cellEnd?.col);
988
- return isTopSelected || isLeftSelected || isRightSelected ? `${cellClass} ${isTop ? `cell-border-top` : ''} ${isLeft ? `cell-border-left` : ''} ${isRight ? `next-cell-border-left` : ''}` : cellClass;
1183
+ const isPasteLeft = colIndex + 1 === Math.min(cellPasteStart.col, cellPasteSEnd?.col);
1184
+ const isPasteRight = colIndex - 1 === Math.max(cellPasteStart.col, cellPasteSEnd?.col);
1185
+ 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` : ''}` :
1186
+ // (isPasteLeftSelected || isPasteRightSelected) ? `${cellClass} ${isPasteLeft ? `cell-paste-border-left` : ''}` :
1187
+
1188
+ cellClass;
989
1189
  }
990
1190
  const isBottom = cellEnd && rowIndex === Math.max(cellStart.row, cellEnd.row);
991
1191
  const isRight = cellEnd && colIndex === Math.max(cellStart.col, cellEnd.col);
992
1192
  const isLeft = colIndex === Math.min(cellStart.col, cellEnd?.col);
1193
+ const isPasteRight = cellPasteSEnd && colIndex === Math.max(cellPasteStart.col, cellPasteSEnd.col);
1194
+ const isPasteLeft = colIndex === Math.min(cellPasteStart.col, cellPasteSEnd?.col);
993
1195
 
994
1196
  // return `${cellClass} ${isBottom ? `cell-border-bottom` : ''} ${isRight ? `cell-border-right` : '' } ${isBottom && isRight ? `cell-border-end` : '' }
995
- return `${cellClass} ${isBottom ? `cell-border-bottom` : ''} ${isRight ? `cell-border-right` : ''} ${isLeft ? `fixed-cell-border-left` : ''} ${isBottom && isRight ? `cell-border-end` : ''}
996
- `;
1197
+ // 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` : '' }`
1198
+
1199
+ 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` : ''}`;
997
1200
  };
998
1201
  const convertColumns = (0, _columns.flatColumns2)(columns).map((column, colIndex) => {
999
1202
  if (!column?.field && !column?.key) {
@@ -1125,16 +1328,21 @@ const GridEdit = props => {
1125
1328
  }),
1126
1329
  onMouseDown: event => handleMouseDown(record, rowNumber, colIndex, event),
1127
1330
  onMouseEnter: () => handleMouseEnter(rowNumber, colIndex),
1128
- onMouseUp: () => handleMouseUp()
1331
+ onMouseUp: handleMouseUp
1129
1332
  }, /*#__PURE__*/_react.default.createElement("div", {
1130
1333
  className: 'ui-rc_content'
1131
- }, (0, _columns.renderContent)(column, value, record, rowIndex, format)), (0, _hooks.getLastSelectCell)(selectedCells).row === rowNumber && (0, _hooks.getLastSelectCell)(selectedCells).col === colIndex && !isSelectDragging &&
1334
+ }, (0, _columns.renderContent)(column, value, record, rowIndex, format)), selectedCells && selectedCells.size > 0 && (0, _hooks.getLastSelectCell)(selectedCells).row === rowNumber && (0, _hooks.getLastSelectCell)(selectedCells).col === colIndex && !isSelectDragging &&
1132
1335
  /*#__PURE__*/
1133
1336
  // showDraggingPoint &&
1134
- _react.default.createElement("span", {
1135
- className: 'dragging-point',
1136
- onMouseEnter: event => handlePointEnter(event),
1137
- onMouseLeave: () => handlePointLeave()
1337
+ _react.default.createElement("div", {
1338
+ className: 'dragging-point'
1339
+ // onMouseEnter={(event) => handlePointEnter(event)}
1340
+ // onMouseLeave={() => handlePointLeave()}
1341
+ ,
1342
+ onMouseDown: () => {
1343
+ setIsPasteDragging(true);
1344
+ },
1345
+ onDoubleClick: handlePointDoubleClick
1138
1346
  }, /*#__PURE__*/_react.default.createElement("span", {
1139
1347
  className: 'dot-point'
1140
1348
  })));
@@ -1203,6 +1411,23 @@ const GridEdit = props => {
1203
1411
  }
1204
1412
  }, /*#__PURE__*/_react.default.createElement("form", {
1205
1413
  onSubmit: handleSubmit(onSubmit)
1414
+ }, /*#__PURE__*/_react.default.createElement(_rcMasterUi.ConfigProvider, {
1415
+ theme: {
1416
+ components: {
1417
+ Table: {
1418
+ rowHoverBg: '#eb461912',
1419
+ rowSelectedBg: '#eb4619',
1420
+ rowSelectedHoverBg: '#eb4619',
1421
+ cellFontSize: 12,
1422
+ cellFontSizeSM: 13,
1423
+ headerBg: '#ffffff'
1424
+ // cellPaddingBlock: 0,
1425
+ // cellPaddingBlockSM: 0,
1426
+ // cellPaddingInlineSM: 0,
1427
+ // cellPaddingInline: 0
1428
+ }
1429
+ }
1430
+ }
1206
1431
  }, /*#__PURE__*/_react.default.createElement(_TableGrid.default, (0, _extends2.default)({}, rest, {
1207
1432
  t: t,
1208
1433
  tableRef: tableRef,
@@ -1270,7 +1495,7 @@ const GridEdit = props => {
1270
1495
  selectedRowKeys: mergedSelectedKeys,
1271
1496
  preserveSelectedRowKeys: true
1272
1497
  }
1273
- }))))), /*#__PURE__*/_react.default.createElement(_reactHotToast.Toaster, {
1498
+ })))))), /*#__PURE__*/_react.default.createElement(_reactHotToast.Toaster, {
1274
1499
  position: toast,
1275
1500
  toastOptions: {
1276
1501
  className: 'react-hot-toast'