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
|
@@ -5,7 +5,7 @@ import { checkDecimalSeparator, checkThousandSeparator, checkFieldKey, convertAr
|
|
|
5
5
|
// convertDayjsToDate,
|
|
6
6
|
convertLabelToTitle,
|
|
7
7
|
// customWeekStartEndFormat,
|
|
8
|
-
getDatepickerFormat, getTemplate, isDisable, isEmpty, isNullOrUndefined, customWeekStartEndFormat, convertDayjsToDate, parseBooleanToValue, isColor, genPresets
|
|
8
|
+
getDatepickerFormat, getTemplate, isDisable, isEmpty, isNullOrUndefined, customWeekStartEndFormat, convertDayjsToDate, parseBooleanToValue, isColor, genPresets, getFormat
|
|
9
9
|
// isEditable,
|
|
10
10
|
// convertDayjsToDate
|
|
11
11
|
} from "./hooks";
|
|
@@ -67,7 +67,8 @@ const EditableCell = props => {
|
|
|
67
67
|
const dateTimePickerRef = React.useRef(null);
|
|
68
68
|
// const timePickerRef = React.useRef(null);
|
|
69
69
|
|
|
70
|
-
const
|
|
70
|
+
const colFormat = typeof column?.format === 'function' ? column?.format(record) : column?.format;
|
|
71
|
+
const cellFormat = getFormat(colFormat, format);
|
|
71
72
|
const inputNode = (value, onChange) => {
|
|
72
73
|
const dateFormat = getDatepickerFormat(editType, cellFormat);
|
|
73
74
|
const date = !isEmpty(value) ? 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;
|
|
@@ -1523,6 +1523,61 @@ export function getCellsByPosition(cellSet, position = "bottom") {
|
|
|
1523
1523
|
return [];
|
|
1524
1524
|
}
|
|
1525
1525
|
}
|
|
1526
|
+
export function getCellsByPosition2(cellSet, position = "bottom") {
|
|
1527
|
+
const cells = Array.from(cellSet).map(key => {
|
|
1528
|
+
const [row, col] = key.split("-").map(Number);
|
|
1529
|
+
return {
|
|
1530
|
+
row,
|
|
1531
|
+
col,
|
|
1532
|
+
key
|
|
1533
|
+
};
|
|
1534
|
+
});
|
|
1535
|
+
switch (position) {
|
|
1536
|
+
case "top":
|
|
1537
|
+
{
|
|
1538
|
+
// const minRow = Math.min(...cells.map(c => c.row));
|
|
1539
|
+
// return cells.filter(c => c.row === minRow).map(c => c.key);
|
|
1540
|
+
|
|
1541
|
+
// const rows = cells.map(c => c.row).filter(r => r > 0);
|
|
1542
|
+
// if (rows.length === 0) return [];
|
|
1543
|
+
// const minRow = Math.min(...rows);
|
|
1544
|
+
// return cells.filter(c => c.row === minRow).map(c => c.key);
|
|
1545
|
+
|
|
1546
|
+
const minRow = Math.min(...cells.map(c => c.row));
|
|
1547
|
+
if (minRow === 0) return []; // Bỏ qua nếu rowIndex = 0
|
|
1548
|
+
|
|
1549
|
+
return cells.filter(c => c.row === minRow).map(c => `${c.row - 1}-${c.col}`);
|
|
1550
|
+
}
|
|
1551
|
+
case "bottom":
|
|
1552
|
+
{
|
|
1553
|
+
const maxRow = Math.max(...cells.map(c => c.row));
|
|
1554
|
+
return cells.filter(c => c.row === maxRow).map(c => c.key);
|
|
1555
|
+
}
|
|
1556
|
+
case "left":
|
|
1557
|
+
{
|
|
1558
|
+
// const minCol = Math.min(...cells.map(c => c.col));
|
|
1559
|
+
// return cells.filter(c => c.col === minCol).map(c => c.key);
|
|
1560
|
+
|
|
1561
|
+
// const cols = cells.map(c => c.col).filter(c => c > 0);
|
|
1562
|
+
// if (cols.length === 0) return [];
|
|
1563
|
+
// const minCol = Math.min(...cols);
|
|
1564
|
+
// return cells.filter(c => c.col === minCol).map(c => c.key);
|
|
1565
|
+
|
|
1566
|
+
const minCol = Math.min(...cells.map(c => c.col));
|
|
1567
|
+
if (minCol === 0) return []; // Bỏ qua nếu colIndex = 0
|
|
1568
|
+
|
|
1569
|
+
// Trả về các ô cùng row, nhưng ở cột bên trái
|
|
1570
|
+
return cells.filter(c => c.col === minCol).map(c => `${c.row}-${c.col - 1}`);
|
|
1571
|
+
}
|
|
1572
|
+
case "right":
|
|
1573
|
+
{
|
|
1574
|
+
const maxCol = Math.max(...cells.map(c => c.col));
|
|
1575
|
+
return cells.filter(c => c.col === maxCol).map(c => c.key);
|
|
1576
|
+
}
|
|
1577
|
+
default:
|
|
1578
|
+
return [];
|
|
1579
|
+
}
|
|
1580
|
+
}
|
|
1526
1581
|
export const addBorderClass = (selectedCells, type, className, id, nextCellRight) => {
|
|
1527
1582
|
const table = document.querySelector(`#${id}`);
|
|
1528
1583
|
const typeCells = getCellsByPosition(selectedCells, type);
|
|
@@ -1564,6 +1619,60 @@ export const addBorderClass = (selectedCells, type, className, id, nextCellRight
|
|
|
1564
1619
|
// }
|
|
1565
1620
|
};
|
|
1566
1621
|
export const removeBorderClass = (selectedCells, type, className, id) => {
|
|
1622
|
+
const table = document.querySelector(`#${id}`);
|
|
1623
|
+
const typeCells = getCellsByPosition2(selectedCells, type);
|
|
1624
|
+
const selectorsCells = typeCells.map(pos => {
|
|
1625
|
+
const [row, col] = pos.split('-');
|
|
1626
|
+
return `[data-row-index="${row}"][data-col-index="${col}"]`;
|
|
1627
|
+
});
|
|
1628
|
+
const cellsFilter = typeCells.length > 0 ? table?.querySelectorAll(selectorsCells.join(',')) : null;
|
|
1629
|
+
if (cellsFilter && cellsFilter.length > 0) {
|
|
1630
|
+
cellsFilter.forEach(cell => {
|
|
1631
|
+
cell.classList.remove(className);
|
|
1632
|
+
});
|
|
1633
|
+
}
|
|
1634
|
+
};
|
|
1635
|
+
export const addBorderPasteClass = (selectedCells, type, className, id, nextCellRight) => {
|
|
1636
|
+
const table = document.querySelector(`#${id}`);
|
|
1637
|
+
const typeCells = getCellsByPosition2(selectedCells, type);
|
|
1638
|
+
const selectorsCells = typeCells.map(pos => {
|
|
1639
|
+
const [row, col] = pos.split('-');
|
|
1640
|
+
return `[data-row-index="${row}"][data-col-index="${col}"]`;
|
|
1641
|
+
});
|
|
1642
|
+
const cellsFilter = typeCells.length > 0 ? table?.querySelectorAll(selectorsCells.join(',')) : null;
|
|
1643
|
+
if (cellsFilter && cellsFilter.length > 0) {
|
|
1644
|
+
cellsFilter.forEach(cell => {
|
|
1645
|
+
cell.classList.add(className);
|
|
1646
|
+
if (nextCellRight) {
|
|
1647
|
+
cell.style.zIndex = 1;
|
|
1648
|
+
}
|
|
1649
|
+
});
|
|
1650
|
+
}
|
|
1651
|
+
|
|
1652
|
+
// ui-rc-table-tbody-virtual-scrollbar ui-rc-table-tbody-virtual-scrollbar-horizontal ui-rc-table-tbody-virtual-scrollbar-visible
|
|
1653
|
+
|
|
1654
|
+
// if (type === 'left') {
|
|
1655
|
+
//
|
|
1656
|
+
// const selectorsCells2 = typeCells.map((pos: any) => {
|
|
1657
|
+
// const [row, col] = pos.split('-');
|
|
1658
|
+
// return `[data-row-index="${row}"][data-col-index="${Number(col) + 1}"]`;
|
|
1659
|
+
// });
|
|
1660
|
+
//
|
|
1661
|
+
// const fullSelector = selectorsCells2.map(s => `.ui-rc-table-cell-fix-right-first${s}`).join(', ');
|
|
1662
|
+
//
|
|
1663
|
+
// const cellsFilter2 = typeCells.length > 0 ? table?.querySelectorAll(fullSelector) : null
|
|
1664
|
+
//
|
|
1665
|
+
// if (cellsFilter2 && cellsFilter2.length > 0) {
|
|
1666
|
+
//
|
|
1667
|
+
// cellsFilter2.forEach(cell => {
|
|
1668
|
+
// // cell.classList.add('has-before');
|
|
1669
|
+
// cell.classList.add('cell-border-left');
|
|
1670
|
+
// });
|
|
1671
|
+
// }
|
|
1672
|
+
//
|
|
1673
|
+
// }
|
|
1674
|
+
};
|
|
1675
|
+
export const removeBorderPasteClass = (selectedCells, type, className, id) => {
|
|
1567
1676
|
const table = document.querySelector(`#${id}`);
|
|
1568
1677
|
const typeCells = getCellsByPosition(selectedCells, type);
|
|
1569
1678
|
const selectorsCells = typeCells.map(pos => {
|
|
@@ -1750,13 +1859,13 @@ export const onRemoveBorderSelectedCell = (selectedCells, id) => {
|
|
|
1750
1859
|
export const addClassBorderPasteCell = (pasteCells, type, id) => {
|
|
1751
1860
|
// thêm class border
|
|
1752
1861
|
|
|
1753
|
-
|
|
1754
|
-
|
|
1862
|
+
addBorderPasteClass(pasteCells, 'right', 'cell-paste-border-right', id);
|
|
1863
|
+
addBorderPasteClass(pasteCells, 'left', 'cell-paste-border-left', id);
|
|
1755
1864
|
if (type === 'up') {
|
|
1756
|
-
|
|
1865
|
+
addBorderPasteClass(pasteCells, 'top', 'cell-paste-border-top', id);
|
|
1757
1866
|
}
|
|
1758
1867
|
if (type === 'down') {
|
|
1759
|
-
|
|
1868
|
+
addBorderPasteClass(pasteCells, 'bottom', 'cell-paste-border-bottom', id);
|
|
1760
1869
|
}
|
|
1761
1870
|
};
|
|
1762
1871
|
export const removeClassBorderPasteCell = (pasteCells, type, id) => {
|