canvas-datagrid 0.4.1 → 0.4.4
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/CHANGELOG.md +30 -0
- package/dist/canvas-datagrid.debug.js +1120 -253
- package/dist/canvas-datagrid.debug.map +1 -1
- package/dist/canvas-datagrid.js +1 -1
- package/dist/canvas-datagrid.module.js +1 -1
- package/dist/canvas-datagrid.module.js.map +1 -1
- package/dist/types.d.ts +34 -5
- package/lib/contextMenu.js +178 -49
- package/lib/defaults.js +17 -7
- package/lib/docs.js +16 -0
- package/lib/dom.js +29 -2
- package/lib/draw.js +403 -73
- package/lib/events/index.js +207 -96
- package/lib/groups/util.js +42 -0
- package/lib/intf.js +33 -2
- package/lib/publicMethods.js +199 -41
- package/package.json +1 -1
package/lib/draw.js
CHANGED
|
@@ -110,8 +110,9 @@ export default function (self) {
|
|
|
110
110
|
}
|
|
111
111
|
/**
|
|
112
112
|
* @param {number[]} coords [x0,y0, x1,y1, x2,y2, ...]
|
|
113
|
+
* @param {boolean} [fill] fill the area that construct by these lines but not stroke
|
|
113
114
|
*/
|
|
114
|
-
function
|
|
115
|
+
function drawLines(coords, fill) {
|
|
115
116
|
if (coords.length < 4) return;
|
|
116
117
|
self.ctx.beginPath();
|
|
117
118
|
self.ctx.moveTo(
|
|
@@ -123,7 +124,8 @@ export default function (self) {
|
|
|
123
124
|
const y = coords[i + 1] + self.canvasOffsetTop;
|
|
124
125
|
self.ctx.lineTo(x, y);
|
|
125
126
|
}
|
|
126
|
-
self.ctx.
|
|
127
|
+
if (fill) self.ctx.fill();
|
|
128
|
+
else self.ctx.stroke();
|
|
127
129
|
}
|
|
128
130
|
/**
|
|
129
131
|
* @param {number} x based-X (left-top)
|
|
@@ -136,8 +138,67 @@ export default function (self) {
|
|
|
136
138
|
strokeRect(x, y, width, width);
|
|
137
139
|
const cx = x + width * 0.5;
|
|
138
140
|
const cy = y + width * 0.5;
|
|
139
|
-
|
|
140
|
-
if (collapsed)
|
|
141
|
+
drawLines([x + width * 0.2, cy, x + width * 0.78, cy]);
|
|
142
|
+
if (collapsed) drawLines([cx, y + width * 0.22, cx, y + width * 0.8]);
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* @param {number} x
|
|
146
|
+
* @param {number} y
|
|
147
|
+
* @param {number} size
|
|
148
|
+
* @param {string} dir Direction of the triangle, one of the 't','b','l' and 'r'
|
|
149
|
+
* @param {boolean} [active]
|
|
150
|
+
*/
|
|
151
|
+
function drawUnhideIndicator(x, y, size, dir, active) {
|
|
152
|
+
const minPadding = size * 0.2;
|
|
153
|
+
const maxPadding = size * 0.3;
|
|
154
|
+
/** The long edge width of the triangle */
|
|
155
|
+
const longEdge = size - 2 * minPadding;
|
|
156
|
+
/** The median width of the triangle */
|
|
157
|
+
const median = size - 2 * maxPadding;
|
|
158
|
+
const halfLongEdge = longEdge * 0.5;
|
|
159
|
+
let x0, y0;
|
|
160
|
+
let coords, borderCoords;
|
|
161
|
+
switch (dir) {
|
|
162
|
+
case 'r':
|
|
163
|
+
x0 = x + maxPadding;
|
|
164
|
+
y0 = y + minPadding;
|
|
165
|
+
borderCoords = [x, y, x + size, y, x + size, y + size, x, y + size];
|
|
166
|
+
coords = [x0, y0, x0, y0 + longEdge, x0 + median, y0 + halfLongEdge];
|
|
167
|
+
break;
|
|
168
|
+
case 'l':
|
|
169
|
+
x0 = x + size - maxPadding;
|
|
170
|
+
y0 = y + minPadding;
|
|
171
|
+
borderCoords = [x + size, y, x, y, x, y + size, x + size, y + size];
|
|
172
|
+
coords = [x0, y0, x0, y0 + longEdge, x0 - median, y0 + halfLongEdge];
|
|
173
|
+
break;
|
|
174
|
+
case 't':
|
|
175
|
+
x0 = x + minPadding;
|
|
176
|
+
y0 = y + size - maxPadding;
|
|
177
|
+
borderCoords = [x, y + size, x, y, x + size, y, x + size, y + size];
|
|
178
|
+
coords = [x0, y0, x0 + longEdge, y0, x0 + halfLongEdge, y0 - median];
|
|
179
|
+
break;
|
|
180
|
+
case 'b':
|
|
181
|
+
x0 = x + minPadding;
|
|
182
|
+
y0 = y + maxPadding;
|
|
183
|
+
borderCoords = [x, y, x, y + size, x + size, y + size, x + size, y];
|
|
184
|
+
coords = [x0, y0, x0 + longEdge, y0, x0 + halfLongEdge, y0 + median];
|
|
185
|
+
break;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
if (active) {
|
|
189
|
+
self.ctx.strokeStyle = self.style.unhideIndicatorBorderColor;
|
|
190
|
+
self.ctx.lineWidth = 2;
|
|
191
|
+
drawLines(borderCoords);
|
|
192
|
+
|
|
193
|
+
self.ctx.fillStyle = self.style.unhideIndicatorBackgroundColor;
|
|
194
|
+
let offset = dir === 'r' || dir === 'b' ? 1 : 0;
|
|
195
|
+
if (dir === 'l' || dir === 'r')
|
|
196
|
+
fillRect(x - offset, y, size + offset, size);
|
|
197
|
+
else fillRect(x, y - offset, size, size + offset);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
self.ctx.fillStyle = self.style.unhideIndicatorColor;
|
|
201
|
+
drawLines(coords, true);
|
|
141
202
|
}
|
|
142
203
|
function drawOrderByArrow(x, y) {
|
|
143
204
|
var mt = self.style.columnHeaderOrderByArrowMarginTop * self.scale,
|
|
@@ -719,7 +780,15 @@ export default function (self) {
|
|
|
719
780
|
columnGroupsRectInfo = {},
|
|
720
781
|
collapsedColumnGroups = self.getCollapsedColumnGroups(),
|
|
721
782
|
collapsedRowGroups = self.getCollapsedRowGroups(),
|
|
722
|
-
cellHeight = self.style.cellHeight
|
|
783
|
+
cellHeight = self.style.cellHeight,
|
|
784
|
+
currentRowIndexOffset = 0,
|
|
785
|
+
/** @type {Array<{from:number,plus:number}>} */
|
|
786
|
+
rowIndexOffsetByHiddenRows = self.hiddenRowRanges
|
|
787
|
+
.map((range) => ({
|
|
788
|
+
from: range[0],
|
|
789
|
+
plus: range[1] - range[0] + 1,
|
|
790
|
+
}))
|
|
791
|
+
.sort((a, b) => a.from - b.from);
|
|
723
792
|
drawCount += 1;
|
|
724
793
|
p = performance.now();
|
|
725
794
|
self.visibleRowHeights = [];
|
|
@@ -995,8 +1064,10 @@ export default function (self) {
|
|
|
995
1064
|
isGrid = header.type === 'canvas-datagrid',
|
|
996
1065
|
activeHeader =
|
|
997
1066
|
(self.orders.rows[self.activeCell.rowIndex] === rowOrderIndex ||
|
|
1067
|
+
self.selectedRows.indexOf(rowOrderIndex) >= 0 ||
|
|
998
1068
|
self.orders.columns[self.activeCell.columnIndex] ===
|
|
999
|
-
headerIndex
|
|
1069
|
+
headerIndex ||
|
|
1070
|
+
self.selectedColumns.indexOf(headerIndex) >= 0) &&
|
|
1000
1071
|
(columnOrderIndex === -1 || rowOrderIndex === -1)
|
|
1001
1072
|
? isRowHeader
|
|
1002
1073
|
? 'activeRowHeaderCell'
|
|
@@ -1369,6 +1440,19 @@ export default function (self) {
|
|
|
1369
1440
|
group.to === cell.boundRowIndex,
|
|
1370
1441
|
) >= 0;
|
|
1371
1442
|
}
|
|
1443
|
+
// We don't treat the row index difference from hidden rows as the row gap.
|
|
1444
|
+
if (hasRowGap && self.hiddenRowRanges.length > 0) {
|
|
1445
|
+
for (let i = 0; i < self.hiddenRowRanges.length; i++) {
|
|
1446
|
+
const [beginRowIndex, endRowIndex] = self.hiddenRowRanges[i];
|
|
1447
|
+
if (
|
|
1448
|
+
cell.boundRowIndex === endRowIndex + 1 &&
|
|
1449
|
+
previousRowNumber === beginRowIndex - 1
|
|
1450
|
+
) {
|
|
1451
|
+
hasRowGap = false;
|
|
1452
|
+
break;
|
|
1453
|
+
}
|
|
1454
|
+
}
|
|
1455
|
+
}
|
|
1372
1456
|
|
|
1373
1457
|
if (hasRowGap) {
|
|
1374
1458
|
const barHeight = self.style.rowHeaderCellRowNumberGapHeight;
|
|
@@ -1384,9 +1468,141 @@ export default function (self) {
|
|
|
1384
1468
|
}
|
|
1385
1469
|
}
|
|
1386
1470
|
|
|
1471
|
+
//#region draw unhide indicator for column headers
|
|
1472
|
+
if (isColumnHeader && self.attributes.showUnhideColumnsIndicator) {
|
|
1473
|
+
const hovered = self.hovers.unhideIndicator;
|
|
1474
|
+
const size = self.style.unhideIndicatorSize;
|
|
1475
|
+
const cellX = x;
|
|
1476
|
+
const topY = cell.y + Math.max(0.5 * (cell.height - size), 0);
|
|
1477
|
+
|
|
1478
|
+
const isActive = (orderIndex) =>
|
|
1479
|
+
hovered &&
|
|
1480
|
+
(hovered.dir === 'l' || hovered.dir === 'r') &&
|
|
1481
|
+
orderIndex >= hovered.orderIndex0 &&
|
|
1482
|
+
orderIndex <= hovered.orderIndex1;
|
|
1483
|
+
const isHiddenColumn = (columnIndex) =>
|
|
1484
|
+
columnIndex >= 0 &&
|
|
1485
|
+
schema[columnIndex] &&
|
|
1486
|
+
schema[columnIndex].hidden;
|
|
1487
|
+
|
|
1488
|
+
let orderIndex0, orderIndex1;
|
|
1489
|
+
const drawIndicator = (leftX, dir, active) => {
|
|
1490
|
+
self.visibleUnhideIndicators.push({
|
|
1491
|
+
x: leftX - 1,
|
|
1492
|
+
y: topY - 1,
|
|
1493
|
+
x2: leftX + size + 2,
|
|
1494
|
+
y2: topY + size + 2,
|
|
1495
|
+
orderIndex0,
|
|
1496
|
+
orderIndex1,
|
|
1497
|
+
dir,
|
|
1498
|
+
});
|
|
1499
|
+
if (!active) {
|
|
1500
|
+
const line = cell.text && cell.text.lines && cell.text.lines[0];
|
|
1501
|
+
if (line) {
|
|
1502
|
+
const iconsWidth = orderByArrowSize + treeArrowSize;
|
|
1503
|
+
const lineX0 = iconsWidth > 0 ? iconsWidth : line.x;
|
|
1504
|
+
const lineX1 = line.x + line.width;
|
|
1505
|
+
if (leftX + size >= lineX0 && leftX <= lineX1) return;
|
|
1506
|
+
}
|
|
1507
|
+
}
|
|
1508
|
+
drawUnhideIndicator(leftX, topY, size, dir, active);
|
|
1509
|
+
}; // end of drawIndicator
|
|
1510
|
+
|
|
1511
|
+
let orderIndexPtr = columnOrderIndex - 1;
|
|
1512
|
+
const prevColumnIndex = self.orders.columns[orderIndexPtr];
|
|
1513
|
+
if (isHiddenColumn(prevColumnIndex)) {
|
|
1514
|
+
const active = isActive(prevColumnIndex);
|
|
1515
|
+
orderIndex0 = orderIndexPtr;
|
|
1516
|
+
orderIndex1 = orderIndexPtr;
|
|
1517
|
+
while (--orderIndexPtr >= 0) {
|
|
1518
|
+
if (isHiddenColumn(self.orders.columns[orderIndexPtr]))
|
|
1519
|
+
orderIndex0 = orderIndexPtr;
|
|
1520
|
+
else break;
|
|
1521
|
+
}
|
|
1522
|
+
drawIndicator(cellX, 'r', active);
|
|
1523
|
+
}
|
|
1524
|
+
|
|
1525
|
+
orderIndexPtr = columnOrderIndex + 1;
|
|
1526
|
+
const nextColumnIndex = self.orders.columns[orderIndexPtr];
|
|
1527
|
+
if (isHiddenColumn(nextColumnIndex)) {
|
|
1528
|
+
const active = isActive(nextColumnIndex);
|
|
1529
|
+
orderIndex0 = orderIndexPtr;
|
|
1530
|
+
orderIndex1 = orderIndexPtr;
|
|
1531
|
+
while (++orderIndexPtr < self.orders.columns.length) {
|
|
1532
|
+
if (isHiddenColumn(self.orders.columns[orderIndexPtr]))
|
|
1533
|
+
orderIndex1 = orderIndexPtr;
|
|
1534
|
+
else break;
|
|
1535
|
+
}
|
|
1536
|
+
const indicatorX = x + cell.width - size;
|
|
1537
|
+
drawIndicator(indicatorX, 'l', active);
|
|
1538
|
+
}
|
|
1539
|
+
}
|
|
1540
|
+
//#endregion draw unhide indicator for column headers
|
|
1541
|
+
|
|
1542
|
+
//#region draw unhide indicator for row headers
|
|
1543
|
+
if (
|
|
1544
|
+
isRowHeader &&
|
|
1545
|
+
self.attributes.showUnhideRowsIndicator &&
|
|
1546
|
+
self.hiddenRowRanges.length > 0
|
|
1547
|
+
) {
|
|
1548
|
+
// Leo's comment:
|
|
1549
|
+
// from the first row to the last row, `rowIndex` is from 0 to the count of rows
|
|
1550
|
+
// but `boundRowIndex` can be disordered if there are any ordered columns or filtered columns
|
|
1551
|
+
// Like this statement:
|
|
1552
|
+
// console.log(rowIndex, cell.boundRowIndex, cell.formattedValue);
|
|
1553
|
+
// can output the result like this:
|
|
1554
|
+
// 0 1 '2'
|
|
1555
|
+
// 1 3 '4'
|
|
1556
|
+
const hovered = self.hovers.unhideIndicator;
|
|
1557
|
+
const size = self.style.unhideIndicatorSize;
|
|
1558
|
+
const leftX = cell.x + cell.width - size - 2;
|
|
1559
|
+
const cellY = y;
|
|
1560
|
+
const topIndicators = {};
|
|
1561
|
+
const bottomIndicators = {};
|
|
1562
|
+
self.hiddenRowRanges.forEach((it) => {
|
|
1563
|
+
topIndicators[it[0] - 1] = it;
|
|
1564
|
+
bottomIndicators[it[1] + 1] = it;
|
|
1565
|
+
});
|
|
1566
|
+
|
|
1567
|
+
const rowIndex = cell.rowIndex + currentRowIndexOffset;
|
|
1568
|
+
const isActive = () =>
|
|
1569
|
+
hovered &&
|
|
1570
|
+
(hovered.dir === 't' || hovered.dir === 'b') &&
|
|
1571
|
+
rowIndex >= hovered.orderIndex0 - 1 &&
|
|
1572
|
+
rowIndex <= hovered.orderIndex1 + 1;
|
|
1573
|
+
|
|
1574
|
+
let orderIndex0, orderIndex1;
|
|
1575
|
+
const drawIndicator = (topY, dir, active) => {
|
|
1576
|
+
self.visibleUnhideIndicators.push({
|
|
1577
|
+
x: leftX - 1,
|
|
1578
|
+
y: topY - 1,
|
|
1579
|
+
x2: leftX + size + 2,
|
|
1580
|
+
y2: topY + size + 2,
|
|
1581
|
+
orderIndex0,
|
|
1582
|
+
orderIndex1,
|
|
1583
|
+
dir,
|
|
1584
|
+
});
|
|
1585
|
+
drawUnhideIndicator(leftX, topY, size, dir, active);
|
|
1586
|
+
}; // end of drawIndicator
|
|
1587
|
+
|
|
1588
|
+
let matched = topIndicators[rowIndex];
|
|
1589
|
+
if (matched) {
|
|
1590
|
+
const indicatorY = cellY + cell.height - size;
|
|
1591
|
+
[orderIndex0, orderIndex1] = matched;
|
|
1592
|
+
drawIndicator(indicatorY, 't', isActive());
|
|
1593
|
+
}
|
|
1594
|
+
matched = bottomIndicators[rowIndex];
|
|
1595
|
+
if (matched) {
|
|
1596
|
+
const indicatorY = cellY;
|
|
1597
|
+
[orderIndex0, orderIndex1] = matched;
|
|
1598
|
+
drawIndicator(indicatorY, 'b', isActive());
|
|
1599
|
+
}
|
|
1600
|
+
}
|
|
1601
|
+
//#endregion draw unhide indicator for row headers
|
|
1602
|
+
|
|
1387
1603
|
x += cell.width + (bc ? 0 : self.style.cellBorderWidth);
|
|
1388
1604
|
return cell.width;
|
|
1389
|
-
};
|
|
1605
|
+
}; // end of drawEach
|
|
1390
1606
|
}
|
|
1391
1607
|
function drawFilterButton(cell, ev) {
|
|
1392
1608
|
var posX = cell.x + cell.width - self.style.filterButtonWidth - 1;
|
|
@@ -1424,17 +1640,20 @@ export default function (self) {
|
|
|
1424
1640
|
// as it is in the unfiltered data, instead of simply the viewed
|
|
1425
1641
|
// row index + 1. If rowIndex > viewData.length, it's a new row
|
|
1426
1642
|
// added to the end, and we want to render that new row's number
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1643
|
+
let filteredRowNumber;
|
|
1644
|
+
if (self.viewData && rowIndex < self.viewData.length)
|
|
1645
|
+
filteredRowNumber =
|
|
1646
|
+
self.getBoundRowIndexFromViewRowIndex(rowIndex) + 1;
|
|
1647
|
+
else
|
|
1648
|
+
filteredRowNumber = self.originalData
|
|
1431
1649
|
? self.originalData.length + 1
|
|
1432
1650
|
: rowOrderIndex + 1;
|
|
1433
1651
|
|
|
1434
|
-
|
|
1652
|
+
let rowHeaderValue =
|
|
1435
1653
|
self.hasActiveFilters() || self.hasCollapsedRowGroup()
|
|
1436
1654
|
? filteredRowNumber
|
|
1437
1655
|
: rowIndex + 1;
|
|
1656
|
+
rowHeaderValue += currentRowIndexOffset;
|
|
1438
1657
|
|
|
1439
1658
|
const rowHeaderCell = { rowHeaderCell: rowHeaderValue };
|
|
1440
1659
|
const headerDescription = {
|
|
@@ -1451,6 +1670,14 @@ export default function (self) {
|
|
|
1451
1670
|
-1,
|
|
1452
1671
|
-1,
|
|
1453
1672
|
);
|
|
1673
|
+
|
|
1674
|
+
if (
|
|
1675
|
+
rowIndexOffsetByHiddenRows[0] &&
|
|
1676
|
+
rowHeaderValue >= rowIndexOffsetByHiddenRows[0].from
|
|
1677
|
+
) {
|
|
1678
|
+
const { plus } = rowIndexOffsetByHiddenRows.shift();
|
|
1679
|
+
currentRowIndexOffset += plus;
|
|
1680
|
+
}
|
|
1454
1681
|
}
|
|
1455
1682
|
}
|
|
1456
1683
|
function drawHeaders() {
|
|
@@ -1593,7 +1820,7 @@ export default function (self) {
|
|
|
1593
1820
|
}
|
|
1594
1821
|
}
|
|
1595
1822
|
//draw frozen columns
|
|
1596
|
-
x =
|
|
1823
|
+
x = 1;
|
|
1597
1824
|
if (self.attributes.showRowHeaders) {
|
|
1598
1825
|
x += rowHeaderCellWidth;
|
|
1599
1826
|
}
|
|
@@ -1675,12 +1902,20 @@ export default function (self) {
|
|
|
1675
1902
|
schema = self.getSchema();
|
|
1676
1903
|
self.visibleCells = [];
|
|
1677
1904
|
self.visibleGroups = [];
|
|
1905
|
+
self.visibleUnhideIndicators = [];
|
|
1678
1906
|
self.canvasOffsetTop = self.isChildGrid ? self.parentNode.offsetTop : 0.5;
|
|
1679
1907
|
self.canvasOffsetLeft = self.isChildGrid
|
|
1680
1908
|
? self.parentNode.offsetLeft
|
|
1681
1909
|
: -0.5;
|
|
1682
1910
|
h = self.height;
|
|
1683
1911
|
w = self.width;
|
|
1912
|
+
|
|
1913
|
+
// patch for first row being hidden
|
|
1914
|
+
const firstRowIndexOffset = rowIndexOffsetByHiddenRows[0];
|
|
1915
|
+
if (firstRowIndexOffset && firstRowIndexOffset.from === 0) {
|
|
1916
|
+
currentRowIndexOffset = firstRowIndexOffset.plus;
|
|
1917
|
+
rowIndexOffsetByHiddenRows.shift();
|
|
1918
|
+
}
|
|
1684
1919
|
}
|
|
1685
1920
|
function drawBackground() {
|
|
1686
1921
|
radiusRect(0, 0, w, h, 0);
|
|
@@ -1876,7 +2111,7 @@ export default function (self) {
|
|
|
1876
2111
|
leftX -= toggleHandlePadding + 1;
|
|
1877
2112
|
if (containsEnd) rightX += toggleHandleSize;
|
|
1878
2113
|
}
|
|
1879
|
-
|
|
2114
|
+
drawLines(lineCoords);
|
|
1880
2115
|
ctx.restore();
|
|
1881
2116
|
pushToVisibleGroups(leftX, rightX);
|
|
1882
2117
|
}
|
|
@@ -2054,7 +2289,7 @@ export default function (self) {
|
|
|
2054
2289
|
// add more clickable area into `visibleGroups`
|
|
2055
2290
|
if (containsEnd) bottomY += toggleHandleSize;
|
|
2056
2291
|
}
|
|
2057
|
-
|
|
2292
|
+
drawLines(lineCoords);
|
|
2058
2293
|
ctx.restore();
|
|
2059
2294
|
pushToVisibleGroups(topY, bottomY);
|
|
2060
2295
|
}
|
|
@@ -2078,10 +2313,8 @@ export default function (self) {
|
|
|
2078
2313
|
if (self.attributes.allowFreezingRows) {
|
|
2079
2314
|
// HACK great, another stupid magic number.
|
|
2080
2315
|
// Background will appear as a 0.5px artifact behind the row freeze bar without this hack
|
|
2081
|
-
y +=
|
|
2082
|
-
|
|
2083
|
-
self.style.frozenMarkerWidth -
|
|
2084
|
-
0.4999999999;
|
|
2316
|
+
if (y > columnHeaderCellHeight) y += self.style.frozenMarkerWidth;
|
|
2317
|
+
y += self.style.frozenMarkerBorderWidth - 0.4999999999;
|
|
2085
2318
|
}
|
|
2086
2319
|
self.lastFrozenRowPixel = y;
|
|
2087
2320
|
}
|
|
@@ -2208,6 +2441,7 @@ export default function (self) {
|
|
|
2208
2441
|
self.ctx.lineWidth = self.style.reorderMarkerIndexBorderWidth;
|
|
2209
2442
|
self.ctx.strokeStyle = self.style.reorderMarkerIndexBorderColor;
|
|
2210
2443
|
if (
|
|
2444
|
+
self.selectedRows.indexOf(self.reorderTarget.sortRowIndex) === -1 &&
|
|
2211
2445
|
self.currentCell.rowIndex !== self.reorderObject.rowIndex &&
|
|
2212
2446
|
self.currentCell.rowIndex > -1 &&
|
|
2213
2447
|
self.currentCell.rowIndex < l
|
|
@@ -2221,10 +2455,12 @@ export default function (self) {
|
|
|
2221
2455
|
}
|
|
2222
2456
|
} else if (self.dragMode === 'column-reorder' && self.reorderObject) {
|
|
2223
2457
|
var selectedColumns = self.selections[0];
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
self.
|
|
2227
|
-
|
|
2458
|
+
if (selectedColumns) {
|
|
2459
|
+
for (var k = 1; k < selectedColumns.length; k++) {
|
|
2460
|
+
b.width += self.getColumnWidth(
|
|
2461
|
+
self.orders.columns[selectedColumns[k]],
|
|
2462
|
+
);
|
|
2463
|
+
}
|
|
2228
2464
|
}
|
|
2229
2465
|
b.height = h;
|
|
2230
2466
|
b.y = 0;
|
|
@@ -2237,8 +2473,11 @@ export default function (self) {
|
|
|
2237
2473
|
self.ctx.lineWidth = self.style.reorderMarkerIndexBorderWidth;
|
|
2238
2474
|
self.ctx.strokeStyle = self.style.reorderMarkerIndexBorderColor;
|
|
2239
2475
|
if (
|
|
2476
|
+
self.selectedColumns.indexOf(self.reorderTarget.sortColumnIndex) ===
|
|
2477
|
+
-1 &&
|
|
2240
2478
|
self.currentCell.sortColumnIndex !==
|
|
2241
2479
|
self.reorderObject.sortColumnIndex &&
|
|
2480
|
+
self.reorderTarget.columnIndex !== self.reorderObject.columnIndex &&
|
|
2242
2481
|
self.currentCell.sortColumnIndex > -1 &&
|
|
2243
2482
|
self.currentCell.sortColumnIndex < schema.length
|
|
2244
2483
|
) {
|
|
@@ -2359,81 +2598,172 @@ export default function (self) {
|
|
|
2359
2598
|
self.ctx.restore();
|
|
2360
2599
|
}
|
|
2361
2600
|
function drawFrozenMarkers() {
|
|
2362
|
-
if (self.dragStartObject !== undefined) return;
|
|
2363
2601
|
var my = self.lastFrozenRowPixel - self.style.frozenMarkerWidth,
|
|
2364
|
-
mx = self.lastFrozenColumnPixel - self.style.
|
|
2602
|
+
mx = self.lastFrozenColumnPixel - self.style.frozenMarkerWidth,
|
|
2365
2603
|
xHover =
|
|
2366
2604
|
self.currentCell && self.currentCell.style === 'frozen-row-marker',
|
|
2367
2605
|
yHover =
|
|
2368
2606
|
self.currentCell && self.currentCell.style === 'frozen-column-marker';
|
|
2607
|
+
let rowHeaderCellWidth = self.getRowHeaderCellWidth();
|
|
2369
2608
|
self.ctx.lineWidth = self.style.frozenMarkerBorderWidth;
|
|
2370
2609
|
if (self.attributes.allowFreezingColumns) {
|
|
2371
|
-
|
|
2372
|
-
|
|
2373
|
-
|
|
2374
|
-
|
|
2375
|
-
|
|
2376
|
-
|
|
2377
|
-
|
|
2378
|
-
|
|
2379
|
-
|
|
2380
|
-
|
|
2381
|
-
|
|
2382
|
-
|
|
2383
|
-
|
|
2384
|
-
|
|
2385
|
-
|
|
2386
|
-
|
|
2610
|
+
if (
|
|
2611
|
+
!self.freezeMarkerPosition ||
|
|
2612
|
+
(self.freezeMarkerPosition && self.dragMode === 'frozen-row-marker')
|
|
2613
|
+
) {
|
|
2614
|
+
if (mx > self.style.rowHeaderCellWidth) {
|
|
2615
|
+
self.ctx.fillStyle = self.style.frozenMarkerColor;
|
|
2616
|
+
self.ctx.strokeStyle = self.style.frozenMarkerBorderColor;
|
|
2617
|
+
fillRect(mx, 0, self.style.frozenMarkerWidth, self.height);
|
|
2618
|
+
strokeRect(mx, 0, self.style.frozenMarkerWidth, self.height);
|
|
2619
|
+
}
|
|
2620
|
+
self.ctx.fillStyle = yHover
|
|
2621
|
+
? self.style.frozenMarkerHoverColor
|
|
2622
|
+
: self.style.frozenMarkerHeaderColor;
|
|
2623
|
+
self.ctx.strokeStyle = yHover
|
|
2624
|
+
? self.style.frozenMarkerHoverBorderColor
|
|
2625
|
+
: self.style.frozenMarkerHeaderColor;
|
|
2626
|
+
fillRect(
|
|
2627
|
+
mx,
|
|
2628
|
+
0,
|
|
2629
|
+
self.style.frozenMarkerWidth,
|
|
2630
|
+
self.style.columnHeaderCellHeight,
|
|
2631
|
+
);
|
|
2632
|
+
strokeRect(
|
|
2633
|
+
mx,
|
|
2634
|
+
0,
|
|
2635
|
+
self.style.frozenMarkerWidth,
|
|
2636
|
+
self.style.columnHeaderCellHeight,
|
|
2637
|
+
);
|
|
2638
|
+
}
|
|
2639
|
+
|
|
2640
|
+
if (
|
|
2641
|
+
!self.dragStartObject ||
|
|
2642
|
+
(self.dragStartObject &&
|
|
2643
|
+
self.dragStartObject.style !== 'rowHeaderCell')
|
|
2644
|
+
) {
|
|
2645
|
+
self.visibleCells.unshift({
|
|
2646
|
+
x: mx,
|
|
2647
|
+
y: 0,
|
|
2648
|
+
height: self.height,
|
|
2649
|
+
width: self.style.frozenMarkerWidth, // + self.style.frozenMarkerBorderWidth,
|
|
2650
|
+
style: 'frozen-column-marker',
|
|
2651
|
+
});
|
|
2652
|
+
}
|
|
2387
2653
|
}
|
|
2388
2654
|
if (self.attributes.allowFreezingRows) {
|
|
2389
|
-
|
|
2390
|
-
|
|
2391
|
-
|
|
2392
|
-
|
|
2393
|
-
|
|
2394
|
-
|
|
2395
|
-
|
|
2396
|
-
|
|
2397
|
-
|
|
2655
|
+
if (
|
|
2656
|
+
!self.freezeMarkerPosition ||
|
|
2657
|
+
(self.freezeMarkerPosition &&
|
|
2658
|
+
self.dragMode === 'frozen-column-marker')
|
|
2659
|
+
) {
|
|
2660
|
+
if (my > rowHeaderCellWidth) {
|
|
2661
|
+
self.ctx.fillStyle = self.style.frozenMarkerColor;
|
|
2662
|
+
self.ctx.strokeStyle = self.style.frozenMarkerBorderColor;
|
|
2663
|
+
fillRect(0, my, self.width, self.style.frozenMarkerWidth);
|
|
2664
|
+
strokeRect(0, my, self.width, self.style.frozenMarkerWidth);
|
|
2665
|
+
}
|
|
2666
|
+
self.ctx.fillStyle = xHover
|
|
2667
|
+
? self.style.frozenMarkerHoverColor
|
|
2668
|
+
: self.style.frozenMarkerHeaderColor;
|
|
2669
|
+
self.ctx.strokeStyle = xHover
|
|
2670
|
+
? self.style.frozenMarkerHoverBorderColor
|
|
2671
|
+
: self.style.frozenMarkerHeaderColor;
|
|
2672
|
+
fillRect(0, my, rowHeaderCellWidth, self.style.frozenMarkerWidth);
|
|
2673
|
+
strokeRect(0, my, rowHeaderCellWidth, self.style.frozenMarkerWidth);
|
|
2674
|
+
}
|
|
2675
|
+
var height =
|
|
2398
2676
|
self.style.frozenMarkerWidth + self.style.frozenMarkerBorderWidth;
|
|
2399
|
-
|
|
2400
|
-
|
|
2401
|
-
|
|
2402
|
-
|
|
2403
|
-
|
|
2404
|
-
|
|
2405
|
-
|
|
2677
|
+
if (
|
|
2678
|
+
!self.dragStartObject ||
|
|
2679
|
+
(self.dragStartObject &&
|
|
2680
|
+
self.dragStartObject.style !== 'columnHeaderCell')
|
|
2681
|
+
) {
|
|
2682
|
+
self.visibleCells.unshift({
|
|
2683
|
+
x: 0,
|
|
2684
|
+
y: my,
|
|
2685
|
+
height: height,
|
|
2686
|
+
width: self.width,
|
|
2687
|
+
style: 'frozen-row-marker',
|
|
2688
|
+
});
|
|
2689
|
+
}
|
|
2406
2690
|
rowGroupsFrozenInfo = { y: my, h: height };
|
|
2407
2691
|
}
|
|
2408
2692
|
if (self.freezeMarkerPosition) {
|
|
2409
2693
|
self.ctx.fillStyle = self.style.frozenMarkerActiveColor;
|
|
2410
2694
|
self.ctx.strokeStyle = self.style.frozenMarkerActiveBorderColor;
|
|
2411
2695
|
if (self.dragMode === 'frozen-column-marker') {
|
|
2696
|
+
let posX = self.freezeMarkerPosition.x;
|
|
2697
|
+
let nearCell = self.getCellAt(posX, 0);
|
|
2698
|
+
if (self.freezeMarkerPosition.isGrab) posX = mx;
|
|
2699
|
+
if (posX > rowHeaderCellWidth) {
|
|
2700
|
+
let x =
|
|
2701
|
+
nearCell.x -
|
|
2702
|
+
self.style.frozenMarkerWidth -
|
|
2703
|
+
self.style.frozenMarkerBorderWidth;
|
|
2704
|
+
if (posX > x + nearCell.width / 2) x = x + nearCell.width;
|
|
2705
|
+
self.ctx.fillStyle = self.style.frozenMarkerColor;
|
|
2706
|
+
self.ctx.strokeStyle = self.style.frozenMarkerBorderColor;
|
|
2707
|
+
fillRect(x, 0, self.style.frozenMarkerWidth, self.height);
|
|
2708
|
+
strokeRect(x, 0, self.style.frozenMarkerWidth, self.height);
|
|
2709
|
+
self.ctx.fillStyle = self.style.frozenMarkerHeaderColor;
|
|
2710
|
+
self.ctx.strokeStyle = self.style.frozenMarkerHeaderColor;
|
|
2711
|
+
fillRect(
|
|
2712
|
+
x,
|
|
2713
|
+
0,
|
|
2714
|
+
self.style.frozenMarkerWidth,
|
|
2715
|
+
self.style.columnHeaderCellHeight,
|
|
2716
|
+
);
|
|
2717
|
+
strokeRect(
|
|
2718
|
+
x,
|
|
2719
|
+
0,
|
|
2720
|
+
self.style.frozenMarkerWidth,
|
|
2721
|
+
self.style.columnHeaderCellHeight,
|
|
2722
|
+
);
|
|
2723
|
+
}
|
|
2724
|
+
self.ctx.fillStyle = self.style.frozenMarkerActiveHeaderColor;
|
|
2725
|
+
self.ctx.strokeStyle = self.style.frozenMarkerActiveBorderColor;
|
|
2412
2726
|
fillRect(
|
|
2413
|
-
|
|
2727
|
+
posX,
|
|
2414
2728
|
0,
|
|
2415
2729
|
self.style.frozenMarkerWidth,
|
|
2416
|
-
self.
|
|
2730
|
+
self.style.columnHeaderCellHeight,
|
|
2417
2731
|
);
|
|
2418
2732
|
strokeRect(
|
|
2419
|
-
|
|
2733
|
+
posX,
|
|
2420
2734
|
0,
|
|
2421
2735
|
self.style.frozenMarkerWidth,
|
|
2422
|
-
self.
|
|
2736
|
+
self.style.columnHeaderCellHeight,
|
|
2423
2737
|
);
|
|
2738
|
+
self.ctx.fillStyle = self.style.frozenMarkerActiveColor;
|
|
2739
|
+
fillRect(posX, 0, self.style.frozenMarkerWidth, self.height);
|
|
2740
|
+
strokeRect(posX, 0, self.style.frozenMarkerWidth, self.height);
|
|
2424
2741
|
} else {
|
|
2425
|
-
|
|
2426
|
-
|
|
2427
|
-
|
|
2428
|
-
|
|
2429
|
-
|
|
2430
|
-
|
|
2431
|
-
|
|
2432
|
-
|
|
2433
|
-
|
|
2434
|
-
self.
|
|
2435
|
-
self.style.
|
|
2436
|
-
|
|
2742
|
+
let posY = self.freezeMarkerPosition.y;
|
|
2743
|
+
let nearCell = self.getCellAt(0, posY);
|
|
2744
|
+
if (self.freezeMarkerPosition.isGrab) posY = my;
|
|
2745
|
+
if (posY > self.style.columnHeaderCellHeight) {
|
|
2746
|
+
let y =
|
|
2747
|
+
nearCell.y -
|
|
2748
|
+
self.style.frozenMarkerWidth -
|
|
2749
|
+
self.style.frozenMarkerBorderWidth;
|
|
2750
|
+
if (posY > y + nearCell.height / 2) y = y + nearCell.height;
|
|
2751
|
+
self.ctx.fillStyle = self.style.frozenMarkerColor;
|
|
2752
|
+
self.ctx.strokeStyle = self.style.frozenMarkerBorderColor;
|
|
2753
|
+
fillRect(0, y, self.width, self.style.frozenMarkerWidth);
|
|
2754
|
+
strokeRect(0, y, self.width, self.style.frozenMarkerWidth);
|
|
2755
|
+
self.ctx.fillStyle = self.style.frozenMarkerHeaderColor;
|
|
2756
|
+
self.ctx.strokeStyle = self.style.frozenMarkerHeaderColor;
|
|
2757
|
+
fillRect(0, y, rowHeaderCellWidth, self.style.frozenMarkerWidth);
|
|
2758
|
+
strokeRect(0, y, rowHeaderCellWidth, self.style.frozenMarkerWidth);
|
|
2759
|
+
}
|
|
2760
|
+
self.ctx.fillStyle = self.style.frozenMarkerActiveHeaderColor;
|
|
2761
|
+
self.ctx.strokeStyle = self.style.frozenMarkerActiveBorderColor;
|
|
2762
|
+
fillRect(0, posY, rowHeaderCellWidth, self.style.frozenMarkerWidth);
|
|
2763
|
+
strokeRect(0, posY, rowHeaderCellWidth, self.style.frozenMarkerWidth);
|
|
2764
|
+
self.ctx.fillStyle = self.style.frozenMarkerActiveColor;
|
|
2765
|
+
fillRect(0, posY, self.width, self.style.frozenMarkerWidth);
|
|
2766
|
+
strokeRect(0, posY, self.width, self.style.frozenMarkerWidth);
|
|
2437
2767
|
}
|
|
2438
2768
|
}
|
|
2439
2769
|
}
|