es-grid-template 1.4.3 → 1.4.5

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.
@@ -26,9 +26,9 @@ exports.isContinuous = exports.isColor = exports.isBottomMostInRegion = void 0;
26
26
  exports.isDateString = isDateString;
27
27
  exports.isEmpty = exports.isEditable = exports.isDisable = void 0;
28
28
  exports.isEqualSet = isEqualSet;
29
- exports.isObjEmpty = exports.isNullOrUndefined = exports.isNameColor = void 0;
29
+ exports.isRangeCell = exports.isObjEmpty = exports.isNullOrUndefined = exports.isNameColor = void 0;
30
30
  exports.isRightMostInRegion = isRightMostInRegion;
31
- exports.updateData = exports.updateColumnsByGroup = exports.updateColumns = exports.updateArrayByKey = exports.transformColumns1 = exports.transformColumns = exports.totalFixedWidth = exports.sumDataByField = exports.sortedSetDSC = exports.sortedSetASC = exports.showDraggingPoint = exports.shouldInclude = exports.removeFieldRecursive = exports.removeColumns = exports.removeClassCellIndexSelected = exports.removeClassBorderPasteCell = exports.removeBorderClass2 = exports.removeBorderClass = exports.parseCells = exports.parseBooleanToValue = exports.onRemoveBorderSelectedCell = exports.onRemoveBgSelectedCell = exports.onAddBorderSelectedCell = exports.onAddBgSelectedCell = exports.newGuid = exports.mergedSets = exports.isTopMostInRegion = void 0;
31
+ exports.updateData = exports.updateColumnsByGroup = exports.updateColumns = exports.updateArrayByKey = exports.transformColumns1 = exports.transformColumns = exports.totalFixedWidth = exports.sumDataByField = exports.sortedSetDSC = exports.sortedSetASC = exports.showDraggingPoint = exports.shouldInclude = exports.removeFieldRecursive = exports.removeColumns = exports.removeClassCellIndexSelected = exports.removeClassBorderPasteCell = exports.removeBorderClass2 = exports.removeBorderClass = exports.parseCells = exports.parseBooleanToValue = exports.onRemoveBorderSelectedCell = exports.onRemoveBgSelectedCell = exports.onRemoveBgCellIndex = exports.onAddBorderSelectedCell = exports.onAddBgSelectedCell = exports.onAddBgCellIndex = exports.newGuid = exports.mergedSets = exports.isTopMostInRegion = exports.isSelectedCell = void 0;
32
32
  var _dayjs = _interopRequireDefault(require("dayjs"));
33
33
  var _moment = _interopRequireDefault(require("moment/moment"));
34
34
  var _uuid = require("uuid");
@@ -511,12 +511,9 @@ exports.getDefaultValue = getDefaultValue;
511
511
  const addRowIdArray = inputArray => {
512
512
  if (inputArray) {
513
513
  return inputArray.map(item => {
514
- if (item.children && item.children.length > 0) {
515
- // item.children = convertArrayWithIndent(item.children)
514
+ if (typeof item.children !== "string" && item.children && item.children.length > 0) {
516
515
  item.children = addRowIdArray(item.children);
517
516
  }
518
-
519
- // return { ...item, rowId: item.rowId ? item.rowId : (item.id ? item.id : newGuid())}
520
517
  return {
521
518
  ...item,
522
519
  rowId: item.rowId ?? item.id ?? newGuid()
@@ -1590,7 +1587,7 @@ function getCellsByPosition(cellSet, position = "bottom") {
1590
1587
  const minRow = Math.min(...cells.map(c => c.row));
1591
1588
  if (minRow === 0) return []; // Bỏ qua nếu rowIndex = 0
1592
1589
 
1593
- return cells.filter(c => c.row === minRow).map(c => `${c.row - 1}-${c.col}`);
1590
+ return cells.filter(c => c.row === minRow).map(c => `${c.row}-${c.col}`);
1594
1591
  }
1595
1592
  case "bottom":
1596
1593
  {
@@ -1611,7 +1608,7 @@ function getCellsByPosition(cellSet, position = "bottom") {
1611
1608
  if (minCol === 0) return []; // Bỏ qua nếu colIndex = 0
1612
1609
 
1613
1610
  // Trả về các ô cùng row, nhưng ở cột bên trái
1614
- return cells.filter(c => c.col === minCol).map(c => `${c.row}-${c.col - 1}`);
1611
+ return cells.filter(c => c.col === minCol).map(c => `${c.row}-${c.col}`);
1615
1612
  }
1616
1613
  case "right":
1617
1614
  {
@@ -1622,7 +1619,7 @@ function getCellsByPosition(cellSet, position = "bottom") {
1622
1619
  return [];
1623
1620
  }
1624
1621
  }
1625
- const addBorderClass = (selectedCells, type, className, id) => {
1622
+ const addBorderClass = (selectedCells, type, className, id, nextCellRight) => {
1626
1623
  const table = document.querySelector(`#${id}`);
1627
1624
  const typeCells = getCellsByPosition(selectedCells, type);
1628
1625
  const selectorsCells = typeCells.map(pos => {
@@ -1633,8 +1630,34 @@ const addBorderClass = (selectedCells, type, className, id) => {
1633
1630
  if (cellsFilter && cellsFilter.length > 0) {
1634
1631
  cellsFilter.forEach(cell => {
1635
1632
  cell.classList.add(className);
1633
+ if (nextCellRight) {
1634
+ cell.style.zIndex = 1;
1635
+ }
1636
1636
  });
1637
1637
  }
1638
+
1639
+ // ui-rc-table-tbody-virtual-scrollbar ui-rc-table-tbody-virtual-scrollbar-horizontal ui-rc-table-tbody-virtual-scrollbar-visible
1640
+
1641
+ // if (type === 'left') {
1642
+ //
1643
+ // const selectorsCells2 = typeCells.map((pos: any) => {
1644
+ // const [row, col] = pos.split('-');
1645
+ // return `[data-row-index="${row}"][data-col-index="${Number(col) + 1}"]`;
1646
+ // });
1647
+ //
1648
+ // const fullSelector = selectorsCells2.map(s => `.ui-rc-table-cell-fix-right-first${s}`).join(', ');
1649
+ //
1650
+ // const cellsFilter2 = typeCells.length > 0 ? table?.querySelectorAll(fullSelector) : null
1651
+ //
1652
+ // if (cellsFilter2 && cellsFilter2.length > 0) {
1653
+ //
1654
+ // cellsFilter2.forEach(cell => {
1655
+ // // cell.classList.add('has-before');
1656
+ // cell.classList.add('cell-border-left');
1657
+ // });
1658
+ // }
1659
+ //
1660
+ // }
1638
1661
  };
1639
1662
  exports.addBorderClass = addBorderClass;
1640
1663
  const removeBorderClass = (selectedCells, type, className, id) => {
@@ -1668,10 +1691,20 @@ const onAddBgSelectedCell = (selectedCells, id, isFocusCellIndex) => {
1668
1691
  return `[data-row-index="${row1}"][data-col-index="${col1}"]`;
1669
1692
  });
1670
1693
  const table = document.querySelector(`#${id}`);
1694
+
1695
+ //// xóa class các ô đã chọn trước đó
1696
+ const cellsSelected = table ? table?.querySelectorAll('.ui-rc-table-cell.selected-bg') : null;
1697
+ if (cellsSelected) {
1698
+ cellsSelected.forEach(cell => {
1699
+ cell.classList.remove('selected-bg');
1700
+ });
1701
+ }
1702
+
1703
+ /// thêm class
1671
1704
  const cells = table && selectors.length > 0 ? table?.querySelectorAll(selectors.join(',')) : null;
1672
1705
  if (cells) {
1673
1706
  cells.forEach(cell => {
1674
- cell.classList.add('selected');
1707
+ cell.classList.add('selected-bg');
1675
1708
  });
1676
1709
  }
1677
1710
  const rowsArray = [...new Set([...selectedCells].map(item => item.split("-")[0]))];
@@ -1704,36 +1737,49 @@ const onAddBgSelectedCell = (selectedCells, id, isFocusCellIndex) => {
1704
1737
  // addBorderClass(selectedCells, 'left', 'cell-border-left', id)
1705
1738
  };
1706
1739
  exports.onAddBgSelectedCell = onAddBgSelectedCell;
1707
- const onAddBorderSelectedCell = (selectedCells, id) => {
1740
+ const onRemoveBgSelectedCell = (selectedCells, id, rowsSelected) => {
1708
1741
  const table = document.querySelector(`#${id}`);
1709
-
1710
- // tăng z-index để hiển thị round point paste
1711
- const row = getLastSelectCell(selectedCells).row;
1712
- const col = getLastSelectCell(selectedCells).col;
1713
- const cell = table?.querySelector(`.ui-rc-table-cell[data-row-index="${row}"][data-col-index="${col}"]`);
1714
- if (cell) {
1715
- cell.style.zIndex = 1;
1742
+ const cells = table ? table?.querySelectorAll('.ui-rc-table-cell.selected-bg') : null;
1743
+ if (cells) {
1744
+ cells.forEach(cell => {
1745
+ cell.classList.remove('selected-bg');
1746
+ });
1716
1747
  }
1717
- if (cell && (cell.classList.contains('ui-rc-table-cell-fix-left') || cell.classList.contains('ui-rc-table-cell-fix-right'))) {
1718
- cell.style.zIndex = 3;
1748
+ const cellsIndex = table ? table?.querySelectorAll('.ui-rc-table-cell.focus') : null;
1749
+ if (cellsIndex) {
1750
+ cellsIndex.forEach(cell => {
1751
+ cell.classList.remove('focus');
1752
+ });
1719
1753
  }
1720
1754
 
1721
- // thêm class border selected
1755
+ // xóa class selected ô STT
1722
1756
 
1723
- addBorderClass(selectedCells, 'bottom', 'cell-border-bottom', id);
1724
- addBorderClass(selectedCells, 'right', 'cell-border-right', id);
1725
- addBorderClass(selectedCells, 'top', 'cell-border-top', id);
1726
- addBorderClass(selectedCells, 'left', 'cell-border-left', id);
1757
+ if (rowsSelected && rowsSelected.size > 0) {
1758
+ const rowsSelectedArray = [...new Set([...rowsSelected].map(item => item.split("-")[0]))];
1759
+ const rowsSelectedSelectors = rowsSelectedArray.map(r => `.rc-ui-cell-index[data-row-index="${r}"]`).join(", ");
1760
+ const cellsSelectedIndex = table && rowsSelectedSelectors.length > 0 ? table?.querySelectorAll(rowsSelectedSelectors) : null;
1761
+ if (cellsSelectedIndex) {
1762
+ cellsSelectedIndex.forEach(cell => {
1763
+ cell.classList.remove('selected');
1764
+ });
1765
+ }
1766
+ }
1727
1767
  };
1728
- exports.onAddBorderSelectedCell = onAddBorderSelectedCell;
1729
- const onRemoveBgSelectedCell = (selectedCells, id, rowsSelected) => {
1768
+ exports.onRemoveBgSelectedCell = onRemoveBgSelectedCell;
1769
+ const onAddBgCellIndex = (selectedCells, id, isFocusCellIndex) => {
1730
1770
  const table = document.querySelector(`#${id}`);
1731
- const cells = table ? table?.querySelectorAll('.ui-rc-table-cell.selected') : null;
1732
- if (cells) {
1733
- cells.forEach(cell => {
1734
- cell.classList.remove('selected');
1771
+ const rowsArray = [...new Set([...selectedCells].map(item => item.split("-")[0]))];
1772
+ const rowsSelectors = rowsArray.map(r => `.rc-ui-cell-index[data-row-index="${r}"]`).join(", ");
1773
+ const cellsIndex = table && rowsSelectors.length > 0 ? table?.querySelectorAll(rowsSelectors) : null;
1774
+ if (cellsIndex && isFocusCellIndex !== false) {
1775
+ cellsIndex.forEach(cell => {
1776
+ cell.classList.add('focus');
1735
1777
  });
1736
1778
  }
1779
+ };
1780
+ exports.onAddBgCellIndex = onAddBgCellIndex;
1781
+ const onRemoveBgCellIndex = (selectedCells, id, rowsSelected) => {
1782
+ const table = document.querySelector(`#${id}`);
1737
1783
  const cellsIndex = table ? table?.querySelectorAll('.ui-rc-table-cell.focus') : null;
1738
1784
  if (cellsIndex) {
1739
1785
  cellsIndex.forEach(cell => {
@@ -1754,7 +1800,35 @@ const onRemoveBgSelectedCell = (selectedCells, id, rowsSelected) => {
1754
1800
  }
1755
1801
  }
1756
1802
  };
1757
- exports.onRemoveBgSelectedCell = onRemoveBgSelectedCell;
1803
+ exports.onRemoveBgCellIndex = onRemoveBgCellIndex;
1804
+ const onAddBorderSelectedCell = (selectedCells, id) => {
1805
+ const table = document.querySelector(`#${id}`);
1806
+
1807
+ // tăng z-index để hiển thị round point paste
1808
+ const row = getLastSelectCell(selectedCells).row;
1809
+ const col = getLastSelectCell(selectedCells).col;
1810
+ const cell = table?.querySelector(`.ui-rc-table-cell[data-row-index="${row}"][data-col-index="${col}"]`);
1811
+ const nextCellLeft = table?.querySelector(`.ui-rc-table-cell.ui-rc-table-cell-fix-left[data-row-index="${row}"][data-col-index="${col + 1}"]`);
1812
+ const nextCellRight = table?.querySelector(`.ui-rc-table-cell.ui-rc-table-cell-fix-right[data-row-index="${row}"][data-col-index="${col + 1}"]`);
1813
+ if (cell) {
1814
+ cell.style.zIndex = nextCellLeft ? 3 : 1;
1815
+ }
1816
+ if (cell && (cell.classList.contains('ui-rc-table-cell-fix-left') || cell.classList.contains('ui-rc-table-cell-fix-right'))) {
1817
+ cell.style.zIndex = 3;
1818
+ }
1819
+ removeBorderClass2('cell-border-bottom', id);
1820
+ removeBorderClass2('cell-border-top', id);
1821
+ removeBorderClass2('cell-border-right', id);
1822
+ removeBorderClass2('cell-border-left', id);
1823
+
1824
+ // thêm class border selected
1825
+
1826
+ addBorderClass(selectedCells, 'bottom', 'cell-border-bottom', id);
1827
+ addBorderClass(selectedCells, 'right', 'cell-border-right', id, !!nextCellRight);
1828
+ addBorderClass(selectedCells, 'top', 'cell-border-top', id);
1829
+ addBorderClass(selectedCells, 'left', 'cell-border-left', id);
1830
+ };
1831
+ exports.onAddBorderSelectedCell = onAddBorderSelectedCell;
1758
1832
  const onRemoveBorderSelectedCell = (selectedCells, id) => {
1759
1833
  const table = document.querySelector(`#${id}`);
1760
1834
 
@@ -1762,13 +1836,11 @@ const onRemoveBorderSelectedCell = (selectedCells, id) => {
1762
1836
 
1763
1837
  const row = getLastSelectCell(selectedCells).row;
1764
1838
  const col = getLastSelectCell(selectedCells).col;
1765
-
1766
- // const cell: any = table?.querySelector(`.ui-rc-table-cell[data-row-index="${row}"][data-col-index="${col}"]`)
1767
1839
  const cell = table?.querySelector(`.ui-rc-table-cell[data-row-index="${row}"][data-col-index="${col}"]`);
1768
1840
  if (cell) {
1769
1841
  cell.style.zIndex = 0;
1770
1842
  }
1771
- if (cell && cell.classList.contains('ui-rc-table-cell-fix-left')) {
1843
+ if (cell && (cell.classList.contains('ui-rc-table-cell-fix-left') || cell.classList.contains('ui-rc-table-cell-fix-right'))) {
1772
1844
  cell.style.zIndex = 2;
1773
1845
  }
1774
1846
 
@@ -1778,10 +1850,6 @@ const onRemoveBorderSelectedCell = (selectedCells, id) => {
1778
1850
  removeBorderClass2('cell-border-top', id);
1779
1851
  removeBorderClass2('cell-border-right', id);
1780
1852
  removeBorderClass2('cell-border-left', id);
1781
-
1782
- // removeBorderClass(selectedCells, 'right', 'cell-border-right', id)
1783
- // removeBorderClass(selectedCells, 'top', 'cell-border-top', id)
1784
- // removeBorderClass(selectedCells, 'left', 'cell-border-left', id)
1785
1853
  };
1786
1854
  exports.onRemoveBorderSelectedCell = onRemoveBorderSelectedCell;
1787
1855
  const addClassBorderPasteCell = (pasteCells, type, id) => {
@@ -1805,6 +1873,8 @@ const removeClassBorderPasteCell = (pasteCells, type, id) => {
1805
1873
  removeBorderClass(pasteCells, 'top', 'cell-paste-border-top', id);
1806
1874
  removeBorderClass(pasteCells, 'left', 'cell-paste-border-left', id);
1807
1875
  };
1876
+
1877
+ ///////////////////////////////
1808
1878
  exports.removeClassBorderPasteCell = removeClassBorderPasteCell;
1809
1879
  const addClassCellIndexSelected = (rowsSelected, id) => {
1810
1880
  // thêm class selected vào ô STT
@@ -1815,7 +1885,7 @@ const addClassCellIndexSelected = (rowsSelected, id) => {
1815
1885
  const cellsSelectedIndex = table && rowsSelectedSelectors.length > 0 ? table?.querySelectorAll(rowsSelectedSelectors) : null;
1816
1886
  if (cellsSelectedIndex) {
1817
1887
  cellsSelectedIndex.forEach(cell => {
1818
- cell.classList.add('selected');
1888
+ cell.classList.add('selected-index');
1819
1889
  });
1820
1890
  }
1821
1891
  }
@@ -1830,7 +1900,7 @@ const removeClassCellIndexSelected = (rowsSelected, id) => {
1830
1900
  const cellsSelectedIndex = table && rowsSelectedSelectors.length > 0 ? table?.querySelectorAll(rowsSelectedSelectors) : null;
1831
1901
  if (cellsSelectedIndex) {
1832
1902
  cellsSelectedIndex.forEach(cell => {
1833
- cell.classList.remove('selected');
1903
+ cell.classList.remove('selected-index');
1834
1904
  });
1835
1905
  }
1836
1906
  }
@@ -1840,7 +1910,19 @@ const showDraggingPoint = (selectedCells, id) => {
1840
1910
  const row = getLastSelectCell(selectedCells).row;
1841
1911
  const col = getLastSelectCell(selectedCells).col;
1842
1912
  const table = document.querySelector(`#${id}`);
1913
+
1914
+ // tăng z-index để hiển thị round point paste
1915
+
1843
1916
  const cell = table?.querySelector(`.ui-rc-table-cell[data-row-index="${row}"][data-col-index="${col}"]`);
1917
+
1918
+ // if (cell) {
1919
+ // cell.style.zIndex = 1
1920
+ // }
1921
+ //
1922
+ // if (cell && (cell.classList.contains('ui-rc-table-cell-fix-left') || cell.classList.contains('ui-rc-table-cell-fix-right'))) {
1923
+ // cell.style.zIndex = 3;
1924
+ // }
1925
+
1844
1926
  const point = cell?.querySelector('.dragging-point');
1845
1927
  if (point) {
1846
1928
  point.classList.add('show');
@@ -1851,20 +1933,40 @@ exports.showDraggingPoint = showDraggingPoint;
1851
1933
  const hideDraggingPoint = (selectedCells, id) => {
1852
1934
  const table = document.querySelector(`#${id}`);
1853
1935
 
1854
- // const point = table?.querySelector('.dragging-point.show')
1855
- // const points = document.querySelectorAll('.dragging-point.show')
1856
- const points = table?.querySelectorAll('.dragging-point.show');
1936
+ // xóa z-index về mặc định
1857
1937
 
1858
- // if (point) {
1859
- // point.classList.add('hidden')
1860
- // point.classList.remove('show')
1861
- // }
1938
+ const row = getLastSelectCell(selectedCells).row;
1939
+ const col = getLastSelectCell(selectedCells).col;
1940
+ const cell = table?.querySelector(`.ui-rc-table-cell[data-row-index="${row}"][data-col-index="${col}"]`);
1941
+ // const cellRight: any = table?.querySelector(`.ui-rc-table.ui-rc-table-ping-left:not(.ui-rc-table.ui-rc-table-ping-right) .ui-rc-table-tbody .rc-ui-cell-editable.cell-editable.ui-rc-table-cell-fix-right.ui-rc-table-cell[data-row-index="${row}"][data-col-index="${col + 1}"]`)
1862
1942
 
1943
+ if (cell) {
1944
+ cell.style.zIndex = 0;
1945
+ }
1946
+ if (cell && (cell.classList.contains('ui-rc-table-cell-fix-left') || cell.classList.contains('ui-rc-table-cell-fix-right'))) {
1947
+ // cell.style.zIndex = cellRight ? 1 : 2
1948
+ cell.style.zIndex = 2;
1949
+ }
1950
+ const points = table?.querySelectorAll('.dragging-point.show');
1863
1951
  if (points && points.length > 0) {
1864
- points.forEach(cell => {
1865
- cell.classList.add('hidden');
1866
- cell.classList.remove('show');
1952
+ points.forEach(c => {
1953
+ c.classList.add('hidden');
1954
+ c.classList.remove('show');
1867
1955
  });
1868
1956
  }
1869
1957
  };
1870
- exports.hideDraggingPoint = hideDraggingPoint;
1958
+ exports.hideDraggingPoint = hideDraggingPoint;
1959
+ const isRangeCell = (selectedCells, type, rowIndex, colIndex) => {
1960
+ const typeCells = getCellsByPosition(selectedCells, type);
1961
+ const key = `${rowIndex}-${colIndex}`;
1962
+ return typeCells.includes(key);
1963
+ };
1964
+ exports.isRangeCell = isRangeCell;
1965
+ const isSelectedCell = (selectedCells, rowIndex, colIndex) => {
1966
+ if (selectedCells.size === 1) {
1967
+ return false;
1968
+ }
1969
+ const key = `${rowIndex}-${colIndex}`;
1970
+ return selectedCells.has(key);
1971
+ };
1972
+ exports.isSelectedCell = isSelectedCell;