es-grid-template 1.4.8 → 1.4.9

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.
@@ -36,7 +36,9 @@ const convertFilters = filters => {
36
36
  filteredKeys,
37
37
  operator
38
38
  }) => {
39
- if (!filteredKeys || filteredKeys.length === 0) return;
39
+ if (!filteredKeys || filteredKeys.length === 0) {
40
+ return;
41
+ }
40
42
  if (column?.typeFilter === "DateRange" && filteredKeys.length === 2) {
41
43
  result.push({
42
44
  key,
@@ -399,7 +401,7 @@ const TableGrid = props => {
399
401
  // selectedRowKeys: mode === 'checkbox' && type === 'single' ? selectedRowKeys : undefined,
400
402
  selectedRowKeys: mergedSelectedKeys,
401
403
  // defaultSelectedRowKeys: selectionSettings?.defaultSelectedRowKeys,
402
- defaultSelectedRowKeys: defaultSelectedRowKeys,
404
+ defaultSelectedRowKeys,
403
405
  preserveSelectedRowKeys: true,
404
406
  hideSelectAll: !type || type === 'single' || mode === 'radio' ? true : hideSelectAll ?? type !== 'multiple'
405
407
  }
@@ -506,10 +506,12 @@ export const getRowsPasteIndex = pasteRows => {
506
506
  return [...new Set(result)];
507
507
  };
508
508
  export function addRows8(arr, n) {
509
- if (!Array.isArray(arr) || arr.length === 0) return {
510
- combined: arr,
511
- addedRows: []
512
- };
509
+ if (!Array.isArray(arr) || arr.length === 0) {
510
+ return {
511
+ combined: arr,
512
+ addedRows: []
513
+ };
514
+ }
513
515
  const m = arr.length;
514
516
  const numCols = arr[0].length;
515
517
  const addedRows = [];
@@ -643,10 +645,12 @@ export function addRows8(arr, n) {
643
645
  }
644
646
  export function addRowsUp(array, n) {
645
647
  const arr = array.reverse();
646
- if (!Array.isArray(arr) || arr.length === 0) return {
647
- combined: arr,
648
- addedRows: []
649
- };
648
+ if (!Array.isArray(arr) || arr.length === 0) {
649
+ return {
650
+ combined: arr,
651
+ addedRows: []
652
+ };
653
+ }
650
654
  const m = arr.length;
651
655
  const numCols = arr[0].length;
652
656
  const addedRows = [];
@@ -1368,12 +1372,16 @@ export const buildConnectedRegions = cells => {
1368
1372
  ];
1369
1373
  const regions = [];
1370
1374
  for (const cell of cells) {
1371
- if (visited.has(cell.key)) continue;
1375
+ if (visited.has(cell.key)) {
1376
+ continue;
1377
+ }
1372
1378
  const stack = [cell];
1373
1379
  const region = [];
1374
1380
  while (stack.length) {
1375
1381
  const current = stack.pop();
1376
- if (visited.has(current.key)) continue;
1382
+ if (visited.has(current.key)) {
1383
+ continue;
1384
+ }
1377
1385
  visited.add(current.key);
1378
1386
  region.push(current);
1379
1387
  for (const [dr, dc] of directions) {
@@ -1421,9 +1429,13 @@ export function isRightMostInRegion(rowIndex, colIndex, listSelectCell) {
1421
1429
  return false;
1422
1430
  }
1423
1431
  export function isEqualSet(setA, setB) {
1424
- if (setA.size !== setB.size) return false;
1432
+ if (setA.size !== setB.size) {
1433
+ return false;
1434
+ }
1425
1435
  for (const item of setA) {
1426
- if (!setB.has(item)) return false;
1436
+ if (!setB.has(item)) {
1437
+ return false;
1438
+ }
1427
1439
  }
1428
1440
  return true;
1429
1441
  }
@@ -1489,7 +1501,9 @@ export function getCellsByPosition(cellSet, position = "bottom") {
1489
1501
  // return cells.filter(c => c.row === minRow).map(c => c.key);
1490
1502
 
1491
1503
  const minRow = Math.min(...cells.map(c => c.row));
1492
- if (minRow === 0) return []; // Bỏ qua nếu rowIndex = 0
1504
+ if (minRow === 0) {
1505
+ return [];
1506
+ } // Bỏ qua nếu rowIndex = 0
1493
1507
 
1494
1508
  return cells.filter(c => c.row === minRow).map(c => `${c.row}-${c.col}`);
1495
1509
  }
@@ -1509,7 +1523,9 @@ export function getCellsByPosition(cellSet, position = "bottom") {
1509
1523
  // return cells.filter(c => c.col === minCol).map(c => c.key);
1510
1524
 
1511
1525
  const minCol = Math.min(...cells.map(c => c.col));
1512
- if (minCol === 0) return []; // Bỏ qua nếu colIndex = 0
1526
+ if (minCol === 0) {
1527
+ return [];
1528
+ } // Bỏ qua nếu colIndex = 0
1513
1529
 
1514
1530
  // Trả về các ô cùng row, nhưng ở cột bên trái
1515
1531
  return cells.filter(c => c.col === minCol).map(c => `${c.row}-${c.col}`);
@@ -1544,7 +1560,9 @@ export function getCellsByPosition2(cellSet, position = "bottom") {
1544
1560
  // return cells.filter(c => c.row === minRow).map(c => c.key);
1545
1561
 
1546
1562
  const minRow = Math.min(...cells.map(c => c.row));
1547
- if (minRow === 0) return []; // Bỏ qua nếu rowIndex = 0
1563
+ if (minRow === 0) {
1564
+ return [];
1565
+ } // Bỏ qua nếu rowIndex = 0
1548
1566
 
1549
1567
  return cells.filter(c => c.row === minRow).map(c => `${c.row - 1}-${c.col}`);
1550
1568
  }
@@ -1564,7 +1582,9 @@ export function getCellsByPosition2(cellSet, position = "bottom") {
1564
1582
  // return cells.filter(c => c.col === minCol).map(c => c.key);
1565
1583
 
1566
1584
  const minCol = Math.min(...cells.map(c => c.col));
1567
- if (minCol === 0) return []; // Bỏ qua nếu colIndex = 0
1585
+ if (minCol === 0) {
1586
+ return [];
1587
+ } // Bỏ qua nếu colIndex = 0
1568
1588
 
1569
1589
  // Trả về các ô cùng row, nhưng ở cột bên trái
1570
1590
  return cells.filter(c => c.col === minCol).map(c => `${c.row}-${c.col - 1}`);
@@ -518,12 +518,12 @@ $fontFamily: "Montserrat",Helvetica,Arial,serif !default;
518
518
  pointer-events: none; /* không ảnh hưởng đến tương tác */
519
519
  z-index: 1;
520
520
  }
521
- &.ui-rc-table-cell-fix-left {
521
+ &.ui-rc-table-cell-fix-left.ui-rc-table-cell-fix-left-last {
522
522
  &::after {
523
523
  left: -100%;
524
524
  }
525
525
  }
526
- &.ui-rc-table-cell-fix-right {
526
+ &.ui-rc-table-cell-fix-right.ui-rc-table-cell-fix-right-first {
527
527
  &::after {
528
528
  left: 100%;
529
529
  }
@@ -976,7 +976,10 @@ const GridEdit = props => {
976
976
  // if (ref.current && tableId && !tableId.contains(event.target as Node)) {
977
977
 
978
978
  if (ref.current && tableBody && !tableBody.contains(event.target)) {
979
- setEditingKey('');
979
+ // setEditingKey('')
980
+ setTimeout(() => {
981
+ setEditingKey('');
982
+ });
980
983
  isSelecting.current = false;
981
984
  startCell.current = null;
982
985
  // setSelectedCells(new Set())
@@ -990,9 +993,12 @@ const GridEdit = props => {
990
993
  setRangeCells(new Set());
991
994
  }
992
995
  };
996
+
997
+ // document.addEventListener('click', handleClickOutside)
993
998
  document.addEventListener('mousedown', handleClickOutside);
994
999
  document.addEventListener('touchstart', handleClickOutside);
995
1000
  return () => {
1001
+ // document.removeEventListener('click', handleClickOutside)
996
1002
  document.removeEventListener('mousedown', handleClickOutside);
997
1003
  document.removeEventListener('touchstart', handleClickOutside);
998
1004
  };
@@ -1437,7 +1443,7 @@ const GridEdit = props => {
1437
1443
  if (target.closest('.dragging-point')) {
1438
1444
  e.stopPropagation();
1439
1445
  e.preventDefault();
1440
- return; // Không xử lý gì cả
1446
+ // Không xử lý gì cả
1441
1447
  } else {
1442
1448
  // setStartSelectedCell({row, col})
1443
1449
 
@@ -1686,7 +1692,9 @@ const GridEdit = props => {
1686
1692
  startCell.current = null;
1687
1693
  e.stopPropagation();
1688
1694
  }
1689
- if (!isSelectingRow.current || !rowStart.current) return;
1695
+ if (!isSelectingRow.current || !rowStart.current) {
1696
+ return;
1697
+ }
1690
1698
  // const { row: startRow, col: startCol } = rowStart.current;
1691
1699
  const {
1692
1700
  row: startRow,
@@ -2227,7 +2235,7 @@ const GridEdit = props => {
2227
2235
  disable: !isEditable(column, record)
2228
2236
  }),
2229
2237
  record,
2230
- column: column,
2238
+ column,
2231
2239
  editType: getEditType(column, record),
2232
2240
  dataIndex: column.dataIndex,
2233
2241
  indexRow: rowNumber,
@@ -2441,7 +2449,6 @@ const GridEdit = props => {
2441
2449
  }
2442
2450
  if (args.item.key === 'DELETE_CONTENT') {
2443
2451
  handleDeleteContent();
2444
- return;
2445
2452
  }
2446
2453
  };
2447
2454
  const hideModalAddRow = () => {
@@ -36,7 +36,9 @@ const convertFilters = filters => {
36
36
  filteredKeys,
37
37
  operator
38
38
  }) => {
39
- if (!filteredKeys || filteredKeys.length === 0) return;
39
+ if (!filteredKeys || filteredKeys.length === 0) {
40
+ return;
41
+ }
40
42
  if (column?.typeFilter === "DateRange" && filteredKeys.length === 2) {
41
43
  result.push({
42
44
  key,
@@ -399,7 +401,7 @@ const TableGrid = props => {
399
401
  // selectedRowKeys: mode === 'checkbox' && type === 'single' ? selectedRowKeys : undefined,
400
402
  selectedRowKeys: mergedSelectedKeys,
401
403
  // defaultSelectedRowKeys: selectionSettings?.defaultSelectedRowKeys,
402
- defaultSelectedRowKeys: defaultSelectedRowKeys,
404
+ defaultSelectedRowKeys,
403
405
  preserveSelectedRowKeys: true,
404
406
  hideSelectAll: !type || type === 'single' || mode === 'radio' ? true : hideSelectAll ?? type !== 'multiple'
405
407
  }
@@ -580,10 +580,12 @@ const getRowsPasteIndex = pasteRows => {
580
580
  };
581
581
  exports.getRowsPasteIndex = getRowsPasteIndex;
582
582
  function addRows8(arr, n) {
583
- if (!Array.isArray(arr) || arr.length === 0) return {
584
- combined: arr,
585
- addedRows: []
586
- };
583
+ if (!Array.isArray(arr) || arr.length === 0) {
584
+ return {
585
+ combined: arr,
586
+ addedRows: []
587
+ };
588
+ }
587
589
  const m = arr.length;
588
590
  const numCols = arr[0].length;
589
591
  const addedRows = [];
@@ -717,10 +719,12 @@ function addRows8(arr, n) {
717
719
  }
718
720
  function addRowsUp(array, n) {
719
721
  const arr = array.reverse();
720
- if (!Array.isArray(arr) || arr.length === 0) return {
721
- combined: arr,
722
- addedRows: []
723
- };
722
+ if (!Array.isArray(arr) || arr.length === 0) {
723
+ return {
724
+ combined: arr,
725
+ addedRows: []
726
+ };
727
+ }
724
728
  const m = arr.length;
725
729
  const numCols = arr[0].length;
726
730
  const addedRows = [];
@@ -1459,12 +1463,16 @@ const buildConnectedRegions = cells => {
1459
1463
  ];
1460
1464
  const regions = [];
1461
1465
  for (const cell of cells) {
1462
- if (visited.has(cell.key)) continue;
1466
+ if (visited.has(cell.key)) {
1467
+ continue;
1468
+ }
1463
1469
  const stack = [cell];
1464
1470
  const region = [];
1465
1471
  while (stack.length) {
1466
1472
  const current = stack.pop();
1467
- if (visited.has(current.key)) continue;
1473
+ if (visited.has(current.key)) {
1474
+ continue;
1475
+ }
1468
1476
  visited.add(current.key);
1469
1477
  region.push(current);
1470
1478
  for (const [dr, dc] of directions) {
@@ -1515,9 +1523,13 @@ function isRightMostInRegion(rowIndex, colIndex, listSelectCell) {
1515
1523
  return false;
1516
1524
  }
1517
1525
  function isEqualSet(setA, setB) {
1518
- if (setA.size !== setB.size) return false;
1526
+ if (setA.size !== setB.size) {
1527
+ return false;
1528
+ }
1519
1529
  for (const item of setA) {
1520
- if (!setB.has(item)) return false;
1530
+ if (!setB.has(item)) {
1531
+ return false;
1532
+ }
1521
1533
  }
1522
1534
  return true;
1523
1535
  }
@@ -1586,7 +1598,9 @@ function getCellsByPosition(cellSet, position = "bottom") {
1586
1598
  // return cells.filter(c => c.row === minRow).map(c => c.key);
1587
1599
 
1588
1600
  const minRow = Math.min(...cells.map(c => c.row));
1589
- if (minRow === 0) return []; // Bỏ qua nếu rowIndex = 0
1601
+ if (minRow === 0) {
1602
+ return [];
1603
+ } // Bỏ qua nếu rowIndex = 0
1590
1604
 
1591
1605
  return cells.filter(c => c.row === minRow).map(c => `${c.row}-${c.col}`);
1592
1606
  }
@@ -1606,7 +1620,9 @@ function getCellsByPosition(cellSet, position = "bottom") {
1606
1620
  // return cells.filter(c => c.col === minCol).map(c => c.key);
1607
1621
 
1608
1622
  const minCol = Math.min(...cells.map(c => c.col));
1609
- if (minCol === 0) return []; // Bỏ qua nếu colIndex = 0
1623
+ if (minCol === 0) {
1624
+ return [];
1625
+ } // Bỏ qua nếu colIndex = 0
1610
1626
 
1611
1627
  // Trả về các ô cùng row, nhưng ở cột bên trái
1612
1628
  return cells.filter(c => c.col === minCol).map(c => `${c.row}-${c.col}`);
@@ -1641,7 +1657,9 @@ function getCellsByPosition2(cellSet, position = "bottom") {
1641
1657
  // return cells.filter(c => c.row === minRow).map(c => c.key);
1642
1658
 
1643
1659
  const minRow = Math.min(...cells.map(c => c.row));
1644
- if (minRow === 0) return []; // Bỏ qua nếu rowIndex = 0
1660
+ if (minRow === 0) {
1661
+ return [];
1662
+ } // Bỏ qua nếu rowIndex = 0
1645
1663
 
1646
1664
  return cells.filter(c => c.row === minRow).map(c => `${c.row - 1}-${c.col}`);
1647
1665
  }
@@ -1661,7 +1679,9 @@ function getCellsByPosition2(cellSet, position = "bottom") {
1661
1679
  // return cells.filter(c => c.col === minCol).map(c => c.key);
1662
1680
 
1663
1681
  const minCol = Math.min(...cells.map(c => c.col));
1664
- if (minCol === 0) return []; // Bỏ qua nếu colIndex = 0
1682
+ if (minCol === 0) {
1683
+ return [];
1684
+ } // Bỏ qua nếu colIndex = 0
1665
1685
 
1666
1686
  // Trả về các ô cùng row, nhưng ở cột bên trái
1667
1687
  return cells.filter(c => c.col === minCol).map(c => `${c.row}-${c.col - 1}`);
@@ -518,12 +518,12 @@ $fontFamily: "Montserrat",Helvetica,Arial,serif !default;
518
518
  pointer-events: none; /* không ảnh hưởng đến tương tác */
519
519
  z-index: 1;
520
520
  }
521
- &.ui-rc-table-cell-fix-left {
521
+ &.ui-rc-table-cell-fix-left.ui-rc-table-cell-fix-left-last {
522
522
  &::after {
523
523
  left: -100%;
524
524
  }
525
525
  }
526
- &.ui-rc-table-cell-fix-right {
526
+ &.ui-rc-table-cell-fix-right.ui-rc-table-cell-fix-right-first {
527
527
  &::after {
528
528
  left: 100%;
529
529
  }
@@ -980,7 +980,10 @@ const GridEdit = props => {
980
980
  // if (ref.current && tableId && !tableId.contains(event.target as Node)) {
981
981
 
982
982
  if (ref.current && tableBody && !tableBody.contains(event.target)) {
983
- setEditingKey('');
983
+ // setEditingKey('')
984
+ setTimeout(() => {
985
+ setEditingKey('');
986
+ });
984
987
  isSelecting.current = false;
985
988
  startCell.current = null;
986
989
  // setSelectedCells(new Set())
@@ -994,9 +997,12 @@ const GridEdit = props => {
994
997
  setRangeCells(new Set());
995
998
  }
996
999
  };
1000
+
1001
+ // document.addEventListener('click', handleClickOutside)
997
1002
  document.addEventListener('mousedown', handleClickOutside);
998
1003
  document.addEventListener('touchstart', handleClickOutside);
999
1004
  return () => {
1005
+ // document.removeEventListener('click', handleClickOutside)
1000
1006
  document.removeEventListener('mousedown', handleClickOutside);
1001
1007
  document.removeEventListener('touchstart', handleClickOutside);
1002
1008
  };
@@ -1441,7 +1447,7 @@ const GridEdit = props => {
1441
1447
  if (target.closest('.dragging-point')) {
1442
1448
  e.stopPropagation();
1443
1449
  e.preventDefault();
1444
- return; // Không xử lý gì cả
1450
+ // Không xử lý gì cả
1445
1451
  } else {
1446
1452
  // setStartSelectedCell({row, col})
1447
1453
 
@@ -1690,7 +1696,9 @@ const GridEdit = props => {
1690
1696
  startCell.current = null;
1691
1697
  e.stopPropagation();
1692
1698
  }
1693
- if (!isSelectingRow.current || !rowStart.current) return;
1699
+ if (!isSelectingRow.current || !rowStart.current) {
1700
+ return;
1701
+ }
1694
1702
  // const { row: startRow, col: startCol } = rowStart.current;
1695
1703
  const {
1696
1704
  row: startRow,
@@ -2231,7 +2239,7 @@ const GridEdit = props => {
2231
2239
  disable: !(0, _hooks.isEditable)(column, record)
2232
2240
  }),
2233
2241
  record,
2234
- column: column,
2242
+ column,
2235
2243
  editType: (0, _hooks.getEditType)(column, record),
2236
2244
  dataIndex: column.dataIndex,
2237
2245
  indexRow: rowNumber,
@@ -2445,7 +2453,6 @@ const GridEdit = props => {
2445
2453
  }
2446
2454
  if (args.item.key === 'DELETE_CONTENT') {
2447
2455
  handleDeleteContent();
2448
- return;
2449
2456
  }
2450
2457
  };
2451
2458
  const hideModalAddRow = () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "es-grid-template",
3
- "version": "1.4.8",
3
+ "version": "1.4.9",
4
4
  "description": "es-grid-template",
5
5
  "keywords": [
6
6
  "react",