es-grid-template 1.4.5 → 1.4.6
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.
- package/es/grid-component/EditableCell.js +3 -2
- package/es/grid-component/hooks/utils.d.ts +3 -0
- package/es/grid-component/hooks/utils.js +113 -4
- package/es/grid-component/table/GridEdit.js +445 -443
- package/lib/grid-component/EditableCell.js +2 -1
- package/lib/grid-component/hooks/utils.d.ts +3 -0
- package/lib/grid-component/hooks/utils.js +119 -7
- package/lib/grid-component/table/GridEdit.js +445 -443
- package/package.json +1 -1
|
@@ -69,7 +69,8 @@ const EditableCell = props => {
|
|
|
69
69
|
const dateTimePickerRef = _react.default.useRef(null);
|
|
70
70
|
// const timePickerRef = React.useRef(null);
|
|
71
71
|
|
|
72
|
-
const
|
|
72
|
+
const colFormat = typeof column?.format === 'function' ? column?.format(record) : column?.format;
|
|
73
|
+
const cellFormat = (0, _hooks.getFormat)(colFormat, format);
|
|
73
74
|
const inputNode = (value, onChange) => {
|
|
74
75
|
const dateFormat = (0, _hooks.getDatepickerFormat)(editType, cellFormat);
|
|
75
76
|
const date = !(0, _hooks.isEmpty)(value) ? (0, _hooks.convertDateToDayjs)(new Date(value), dateFormat) : null;
|
|
@@ -121,8 +121,11 @@ export declare const sortedSetASC: (setValue: any) => Set<unknown>;
|
|
|
121
121
|
export declare const sortedSetDSC: (setValue: any) => Set<unknown>;
|
|
122
122
|
export declare function getBottomRowCells(cellSet: any): any[];
|
|
123
123
|
export declare function getCellsByPosition(cellSet: any, position?: string): any[];
|
|
124
|
+
export declare function getCellsByPosition2(cellSet: any, position?: string): any[];
|
|
124
125
|
export declare const addBorderClass: (selectedCells: any, type: string, className: string, id?: string, nextCellRight?: boolean) => void;
|
|
125
126
|
export declare const removeBorderClass: (selectedCells: any, type: string, className: string, id?: string) => void;
|
|
127
|
+
export declare const addBorderPasteClass: (selectedCells: any, type: string, className: string, id?: string, nextCellRight?: boolean) => void;
|
|
128
|
+
export declare const removeBorderPasteClass: (selectedCells: any, type: string, className: string, id?: string) => void;
|
|
126
129
|
export declare const removeBorderClass2: (className: string, id?: string) => void;
|
|
127
130
|
export declare const onAddBgSelectedCell: (selectedCells: any, id?: string, isFocusCellIndex?: boolean) => void;
|
|
128
131
|
export declare const onRemoveBgSelectedCell: (selectedCells: any, id?: string, rowsSelected?: any) => void;
|
|
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.addRowIdArray = exports.addClassCellIndexSelected = exports.addClassBorderPasteCell = exports.addBorderClass = void 0;
|
|
7
|
+
exports.addRowIdArray = exports.addClassCellIndexSelected = exports.addClassBorderPasteCell = exports.addBorderPasteClass = exports.addBorderClass = void 0;
|
|
8
8
|
exports.addRows8 = addRows8;
|
|
9
9
|
exports.addRowsUp = addRowsUp;
|
|
10
10
|
exports.checkThousandSeparator = exports.checkFieldKey = exports.checkDecimalSeparator = exports.checkChild = exports.buildConnectedRegions = void 0;
|
|
@@ -16,6 +16,7 @@ exports.findAllChildrenKeys = findAllChildrenKeys;
|
|
|
16
16
|
exports.getAllVisibleKeys = exports.genPresets = exports.flattenData = exports.flattenArray = exports.findItemPath = exports.findItemByKey = void 0;
|
|
17
17
|
exports.getBottomRowCells = getBottomRowCells;
|
|
18
18
|
exports.getCellsByPosition = getCellsByPosition;
|
|
19
|
+
exports.getCellsByPosition2 = getCellsByPosition2;
|
|
19
20
|
exports.getFormat = exports.getFirstSelectCell = exports.getEditType = exports.getDefaultValue = exports.getDatepickerFormat = exports.getDateString = exports.getColumnsVisible = void 0;
|
|
20
21
|
exports.getHiddenParentKeys = getHiddenParentKeys;
|
|
21
22
|
exports.hideDraggingPoint = exports.getVisibleColumnKeys = exports.getTypeFilter = exports.getTemplate = exports.getRowsPasteIndex = exports.getRowNumber = exports.getLastSelectCell = void 0;
|
|
@@ -28,7 +29,7 @@ exports.isEmpty = exports.isEditable = exports.isDisable = void 0;
|
|
|
28
29
|
exports.isEqualSet = isEqualSet;
|
|
29
30
|
exports.isRangeCell = exports.isObjEmpty = exports.isNullOrUndefined = exports.isNameColor = void 0;
|
|
30
31
|
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.onRemoveBgCellIndex = exports.onAddBorderSelectedCell = exports.onAddBgSelectedCell = exports.onAddBgCellIndex = exports.newGuid = exports.mergedSets = exports.isTopMostInRegion = exports.isSelectedCell = void 0;
|
|
32
|
+
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.removeBorderPasteClass = 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
33
|
var _dayjs = _interopRequireDefault(require("dayjs"));
|
|
33
34
|
var _moment = _interopRequireDefault(require("moment/moment"));
|
|
34
35
|
var _uuid = require("uuid");
|
|
@@ -1619,6 +1620,61 @@ function getCellsByPosition(cellSet, position = "bottom") {
|
|
|
1619
1620
|
return [];
|
|
1620
1621
|
}
|
|
1621
1622
|
}
|
|
1623
|
+
function getCellsByPosition2(cellSet, position = "bottom") {
|
|
1624
|
+
const cells = Array.from(cellSet).map(key => {
|
|
1625
|
+
const [row, col] = key.split("-").map(Number);
|
|
1626
|
+
return {
|
|
1627
|
+
row,
|
|
1628
|
+
col,
|
|
1629
|
+
key
|
|
1630
|
+
};
|
|
1631
|
+
});
|
|
1632
|
+
switch (position) {
|
|
1633
|
+
case "top":
|
|
1634
|
+
{
|
|
1635
|
+
// const minRow = Math.min(...cells.map(c => c.row));
|
|
1636
|
+
// return cells.filter(c => c.row === minRow).map(c => c.key);
|
|
1637
|
+
|
|
1638
|
+
// const rows = cells.map(c => c.row).filter(r => r > 0);
|
|
1639
|
+
// if (rows.length === 0) return [];
|
|
1640
|
+
// const minRow = Math.min(...rows);
|
|
1641
|
+
// return cells.filter(c => c.row === minRow).map(c => c.key);
|
|
1642
|
+
|
|
1643
|
+
const minRow = Math.min(...cells.map(c => c.row));
|
|
1644
|
+
if (minRow === 0) return []; // Bỏ qua nếu rowIndex = 0
|
|
1645
|
+
|
|
1646
|
+
return cells.filter(c => c.row === minRow).map(c => `${c.row - 1}-${c.col}`);
|
|
1647
|
+
}
|
|
1648
|
+
case "bottom":
|
|
1649
|
+
{
|
|
1650
|
+
const maxRow = Math.max(...cells.map(c => c.row));
|
|
1651
|
+
return cells.filter(c => c.row === maxRow).map(c => c.key);
|
|
1652
|
+
}
|
|
1653
|
+
case "left":
|
|
1654
|
+
{
|
|
1655
|
+
// const minCol = Math.min(...cells.map(c => c.col));
|
|
1656
|
+
// return cells.filter(c => c.col === minCol).map(c => c.key);
|
|
1657
|
+
|
|
1658
|
+
// const cols = cells.map(c => c.col).filter(c => c > 0);
|
|
1659
|
+
// if (cols.length === 0) return [];
|
|
1660
|
+
// const minCol = Math.min(...cols);
|
|
1661
|
+
// return cells.filter(c => c.col === minCol).map(c => c.key);
|
|
1662
|
+
|
|
1663
|
+
const minCol = Math.min(...cells.map(c => c.col));
|
|
1664
|
+
if (minCol === 0) return []; // Bỏ qua nếu colIndex = 0
|
|
1665
|
+
|
|
1666
|
+
// Trả về các ô cùng row, nhưng ở cột bên trái
|
|
1667
|
+
return cells.filter(c => c.col === minCol).map(c => `${c.row}-${c.col - 1}`);
|
|
1668
|
+
}
|
|
1669
|
+
case "right":
|
|
1670
|
+
{
|
|
1671
|
+
const maxCol = Math.max(...cells.map(c => c.col));
|
|
1672
|
+
return cells.filter(c => c.col === maxCol).map(c => c.key);
|
|
1673
|
+
}
|
|
1674
|
+
default:
|
|
1675
|
+
return [];
|
|
1676
|
+
}
|
|
1677
|
+
}
|
|
1622
1678
|
const addBorderClass = (selectedCells, type, className, id, nextCellRight) => {
|
|
1623
1679
|
const table = document.querySelector(`#${id}`);
|
|
1624
1680
|
const typeCells = getCellsByPosition(selectedCells, type);
|
|
@@ -1662,7 +1718,7 @@ const addBorderClass = (selectedCells, type, className, id, nextCellRight) => {
|
|
|
1662
1718
|
exports.addBorderClass = addBorderClass;
|
|
1663
1719
|
const removeBorderClass = (selectedCells, type, className, id) => {
|
|
1664
1720
|
const table = document.querySelector(`#${id}`);
|
|
1665
|
-
const typeCells =
|
|
1721
|
+
const typeCells = getCellsByPosition2(selectedCells, type);
|
|
1666
1722
|
const selectorsCells = typeCells.map(pos => {
|
|
1667
1723
|
const [row, col] = pos.split('-');
|
|
1668
1724
|
return `[data-row-index="${row}"][data-col-index="${col}"]`;
|
|
@@ -1675,6 +1731,62 @@ const removeBorderClass = (selectedCells, type, className, id) => {
|
|
|
1675
1731
|
}
|
|
1676
1732
|
};
|
|
1677
1733
|
exports.removeBorderClass = removeBorderClass;
|
|
1734
|
+
const addBorderPasteClass = (selectedCells, type, className, id, nextCellRight) => {
|
|
1735
|
+
const table = document.querySelector(`#${id}`);
|
|
1736
|
+
const typeCells = getCellsByPosition2(selectedCells, type);
|
|
1737
|
+
const selectorsCells = typeCells.map(pos => {
|
|
1738
|
+
const [row, col] = pos.split('-');
|
|
1739
|
+
return `[data-row-index="${row}"][data-col-index="${col}"]`;
|
|
1740
|
+
});
|
|
1741
|
+
const cellsFilter = typeCells.length > 0 ? table?.querySelectorAll(selectorsCells.join(',')) : null;
|
|
1742
|
+
if (cellsFilter && cellsFilter.length > 0) {
|
|
1743
|
+
cellsFilter.forEach(cell => {
|
|
1744
|
+
cell.classList.add(className);
|
|
1745
|
+
if (nextCellRight) {
|
|
1746
|
+
cell.style.zIndex = 1;
|
|
1747
|
+
}
|
|
1748
|
+
});
|
|
1749
|
+
}
|
|
1750
|
+
|
|
1751
|
+
// ui-rc-table-tbody-virtual-scrollbar ui-rc-table-tbody-virtual-scrollbar-horizontal ui-rc-table-tbody-virtual-scrollbar-visible
|
|
1752
|
+
|
|
1753
|
+
// if (type === 'left') {
|
|
1754
|
+
//
|
|
1755
|
+
// const selectorsCells2 = typeCells.map((pos: any) => {
|
|
1756
|
+
// const [row, col] = pos.split('-');
|
|
1757
|
+
// return `[data-row-index="${row}"][data-col-index="${Number(col) + 1}"]`;
|
|
1758
|
+
// });
|
|
1759
|
+
//
|
|
1760
|
+
// const fullSelector = selectorsCells2.map(s => `.ui-rc-table-cell-fix-right-first${s}`).join(', ');
|
|
1761
|
+
//
|
|
1762
|
+
// const cellsFilter2 = typeCells.length > 0 ? table?.querySelectorAll(fullSelector) : null
|
|
1763
|
+
//
|
|
1764
|
+
// if (cellsFilter2 && cellsFilter2.length > 0) {
|
|
1765
|
+
//
|
|
1766
|
+
// cellsFilter2.forEach(cell => {
|
|
1767
|
+
// // cell.classList.add('has-before');
|
|
1768
|
+
// cell.classList.add('cell-border-left');
|
|
1769
|
+
// });
|
|
1770
|
+
// }
|
|
1771
|
+
//
|
|
1772
|
+
// }
|
|
1773
|
+
};
|
|
1774
|
+
exports.addBorderPasteClass = addBorderPasteClass;
|
|
1775
|
+
const removeBorderPasteClass = (selectedCells, type, className, id) => {
|
|
1776
|
+
const table = document.querySelector(`#${id}`);
|
|
1777
|
+
const typeCells = getCellsByPosition(selectedCells, type);
|
|
1778
|
+
const selectorsCells = typeCells.map(pos => {
|
|
1779
|
+
const [row, col] = pos.split('-');
|
|
1780
|
+
return `[data-row-index="${row}"][data-col-index="${col}"]`;
|
|
1781
|
+
});
|
|
1782
|
+
const cellsFilter = typeCells.length > 0 ? table?.querySelectorAll(selectorsCells.join(',')) : null;
|
|
1783
|
+
if (cellsFilter && cellsFilter.length > 0) {
|
|
1784
|
+
cellsFilter.forEach(cell => {
|
|
1785
|
+
cell.classList.remove(className);
|
|
1786
|
+
});
|
|
1787
|
+
}
|
|
1788
|
+
};
|
|
1789
|
+
exports.removeBorderPasteClass = removeBorderPasteClass;
|
|
1678
1790
|
const removeBorderClass2 = (className, id) => {
|
|
1679
1791
|
const table = document.querySelector(`#${id}`);
|
|
1680
1792
|
const cellsFilter = table ? table?.querySelectorAll(`.ui-rc-table-cell.${className}`) : null;
|
|
@@ -1855,13 +1967,13 @@ exports.onRemoveBorderSelectedCell = onRemoveBorderSelectedCell;
|
|
|
1855
1967
|
const addClassBorderPasteCell = (pasteCells, type, id) => {
|
|
1856
1968
|
// thêm class border
|
|
1857
1969
|
|
|
1858
|
-
|
|
1859
|
-
|
|
1970
|
+
addBorderPasteClass(pasteCells, 'right', 'cell-paste-border-right', id);
|
|
1971
|
+
addBorderPasteClass(pasteCells, 'left', 'cell-paste-border-left', id);
|
|
1860
1972
|
if (type === 'up') {
|
|
1861
|
-
|
|
1973
|
+
addBorderPasteClass(pasteCells, 'top', 'cell-paste-border-top', id);
|
|
1862
1974
|
}
|
|
1863
1975
|
if (type === 'down') {
|
|
1864
|
-
|
|
1976
|
+
addBorderPasteClass(pasteCells, 'bottom', 'cell-paste-border-bottom', id);
|
|
1865
1977
|
}
|
|
1866
1978
|
};
|
|
1867
1979
|
exports.addClassBorderPasteCell = addClassBorderPasteCell;
|