canvas-datagrid 0.3.25 → 0.4.3
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 +38 -0
- package/dist/canvas-datagrid.debug.js +2913 -116
- 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 +141 -0
- package/lib/contextMenu.js +427 -10
- package/lib/defaults.js +44 -0
- package/lib/docs.js +18 -0
- package/lib/dom.js +18 -1
- package/lib/draw.js +866 -36
- package/lib/events/index.js +224 -36
- package/lib/events/util.js +1 -1
- package/lib/groups/util.js +42 -0
- package/lib/intf.js +610 -1
- package/lib/publicMethods.js +459 -4
- package/package.json +1 -1
package/lib/events/index.js
CHANGED
|
@@ -74,6 +74,43 @@ export default function (self) {
|
|
|
74
74
|
1),
|
|
75
75
|
);
|
|
76
76
|
};
|
|
77
|
+
/**
|
|
78
|
+
* @returns {number} dataWidth
|
|
79
|
+
*/
|
|
80
|
+
self.refreshScrollCacheX = function () {
|
|
81
|
+
const s = self.getSchema();
|
|
82
|
+
self.scrollCache.x = [];
|
|
83
|
+
|
|
84
|
+
/** @type {number} it will be used in `reduceSchema` only */
|
|
85
|
+
let frozenWidth = 0;
|
|
86
|
+
|
|
87
|
+
const collapsedColumnGroups = self.getCollapsedColumnGroups();
|
|
88
|
+
const isColumnCollapsed = (columnIndex) =>
|
|
89
|
+
collapsedColumnGroups.findIndex(
|
|
90
|
+
(group) => columnIndex >= group.from && columnIndex <= group.to,
|
|
91
|
+
) >= 0;
|
|
92
|
+
|
|
93
|
+
const dataWidth =
|
|
94
|
+
s.reduce(function reduceSchema(accumulator, column, columnIndex) {
|
|
95
|
+
// intentional redefintion of column. This causes scrollCache to be in the correct order
|
|
96
|
+
const schemaIndex = self.orders.columns[columnIndex];
|
|
97
|
+
const columnWidth = self.getColumnWidth(schemaIndex);
|
|
98
|
+
column = s[schemaIndex];
|
|
99
|
+
if (!column.hidden && !isColumnCollapsed(columnIndex))
|
|
100
|
+
accumulator += columnWidth;
|
|
101
|
+
if (columnIndex < self.frozenColumn) {
|
|
102
|
+
self.scrollCache.x[columnIndex] = accumulator;
|
|
103
|
+
frozenWidth = accumulator;
|
|
104
|
+
} else {
|
|
105
|
+
self.scrollCache.x[columnIndex] = Math.max(
|
|
106
|
+
frozenWidth + columnWidth,
|
|
107
|
+
accumulator,
|
|
108
|
+
);
|
|
109
|
+
}
|
|
110
|
+
return accumulator;
|
|
111
|
+
}, 0) || 0;
|
|
112
|
+
return dataWidth;
|
|
113
|
+
};
|
|
77
114
|
self.resize = function (drawAfterResize) {
|
|
78
115
|
if (!self.canvas) {
|
|
79
116
|
return;
|
|
@@ -130,8 +167,9 @@ export default function (self) {
|
|
|
130
167
|
l = (self.viewData || []).length,
|
|
131
168
|
columnHeaderCellHeight = self.getColumnHeaderCellHeight(),
|
|
132
169
|
rowHeaderCellWidth = self.getRowHeaderCellWidth(),
|
|
133
|
-
|
|
134
|
-
|
|
170
|
+
topGroupAreaHeight = self.getColumnGroupAreaHeight(),
|
|
171
|
+
leftGroupAreaWidth = self.getRowGroupAreaWidth(),
|
|
172
|
+
ch = self.style.cellHeight;
|
|
135
173
|
// sets actual DOM canvas element
|
|
136
174
|
function checkScrollBoxVisibility() {
|
|
137
175
|
self.scrollBox.horizontalBarVisible =
|
|
@@ -148,8 +186,10 @@ export default function (self) {
|
|
|
148
186
|
self.scrollBox.verticalBoxVisible = dataHeight > self.scrollBox.height;
|
|
149
187
|
}
|
|
150
188
|
function setScrollBoxSize() {
|
|
151
|
-
self.scrollBox.width =
|
|
152
|
-
|
|
189
|
+
self.scrollBox.width =
|
|
190
|
+
self.width - rowHeaderCellWidth - leftGroupAreaWidth;
|
|
191
|
+
self.scrollBox.height =
|
|
192
|
+
self.height - columnHeaderCellHeight - topGroupAreaHeight;
|
|
153
193
|
}
|
|
154
194
|
function setCanvasSize() {
|
|
155
195
|
if (self.isChildGrid) {
|
|
@@ -157,8 +197,13 @@ export default function (self) {
|
|
|
157
197
|
}
|
|
158
198
|
dims = {
|
|
159
199
|
// HACK +1 ? maybe it's a magic cell border? Required to line up properly in auto height mode.
|
|
160
|
-
height:
|
|
161
|
-
|
|
200
|
+
height:
|
|
201
|
+
columnHeaderCellHeight +
|
|
202
|
+
topGroupAreaHeight +
|
|
203
|
+
dataHeight +
|
|
204
|
+
cellBorder +
|
|
205
|
+
1,
|
|
206
|
+
width: dataWidth + rowHeaderCellWidth + cellBorder + leftGroupAreaWidth,
|
|
162
207
|
};
|
|
163
208
|
['width', 'height'].forEach(function (dim) {
|
|
164
209
|
//TODO: support inherit
|
|
@@ -178,7 +223,7 @@ export default function (self) {
|
|
|
178
223
|
}
|
|
179
224
|
});
|
|
180
225
|
}
|
|
181
|
-
|
|
226
|
+
dataWidth = self.refreshScrollCacheX();
|
|
182
227
|
self.scrollCache.y = [];
|
|
183
228
|
for (x = 0; x < l; x += 1) {
|
|
184
229
|
self.scrollCache.y[x] = dataHeight;
|
|
@@ -190,19 +235,6 @@ export default function (self) {
|
|
|
190
235
|
if (l > 1) {
|
|
191
236
|
self.scrollCache.y[x] = dataHeight;
|
|
192
237
|
}
|
|
193
|
-
dataWidth =
|
|
194
|
-
s.reduce(function reduceSchema(accumulator, column, columnIndex) {
|
|
195
|
-
// intentional redefintion of column. This causes scrollCache to be in the correct order
|
|
196
|
-
column = s[self.orders.columns[columnIndex]];
|
|
197
|
-
if (column.hidden) {
|
|
198
|
-
self.scrollCache.x[columnIndex] = accumulator;
|
|
199
|
-
return accumulator;
|
|
200
|
-
}
|
|
201
|
-
var va =
|
|
202
|
-
accumulator + self.getColumnWidth(self.orders.columns[columnIndex]);
|
|
203
|
-
self.scrollCache.x[columnIndex] = va;
|
|
204
|
-
return va;
|
|
205
|
-
}, 0) || 0;
|
|
206
238
|
if (self.attributes.showNewRow) {
|
|
207
239
|
dataHeight += ch;
|
|
208
240
|
}
|
|
@@ -224,8 +256,9 @@ export default function (self) {
|
|
|
224
256
|
}
|
|
225
257
|
/// calculate scroll bar dimensions
|
|
226
258
|
// non-controversial
|
|
227
|
-
self.scrollBox.top =
|
|
228
|
-
|
|
259
|
+
self.scrollBox.top =
|
|
260
|
+
columnHeaderCellHeight + topGroupAreaHeight + columnHeaderCellBorder;
|
|
261
|
+
self.scrollBox.left = rowHeaderCellWidth + leftGroupAreaWidth;
|
|
229
262
|
// width and height of scroll box
|
|
230
263
|
setScrollBoxSize();
|
|
231
264
|
// is the data larger than the scroll box
|
|
@@ -274,6 +307,7 @@ export default function (self) {
|
|
|
274
307
|
self.scrollBox.heightBoxRatio =
|
|
275
308
|
(self.scrollBox.height -
|
|
276
309
|
columnHeaderCellHeight -
|
|
310
|
+
topGroupAreaHeight -
|
|
277
311
|
self.scrollCache.y[self.frozenRow]) /
|
|
278
312
|
dataHeight;
|
|
279
313
|
self.scrollBox.scrollBoxHeight =
|
|
@@ -291,9 +325,14 @@ export default function (self) {
|
|
|
291
325
|
);
|
|
292
326
|
// horizontal
|
|
293
327
|
n.x += rowHeaderCellWidth;
|
|
294
|
-
n.y += self.height - self.style.scrollBarWidth - d;
|
|
328
|
+
n.y += self.height - self.style.scrollBarWidth - d - topGroupAreaHeight;
|
|
295
329
|
n.width =
|
|
296
|
-
self.width -
|
|
330
|
+
self.width -
|
|
331
|
+
self.style.scrollBarWidth -
|
|
332
|
+
rowHeaderCellWidth -
|
|
333
|
+
leftGroupAreaWidth -
|
|
334
|
+
d -
|
|
335
|
+
m;
|
|
297
336
|
n.height = self.style.scrollBarWidth + self.style.scrollBarBorderWidth + d;
|
|
298
337
|
// horizontal box
|
|
299
338
|
nb.y = n.y + self.style.scrollBarBoxMargin;
|
|
@@ -302,13 +341,19 @@ export default function (self) {
|
|
|
302
341
|
// vertical
|
|
303
342
|
v.x +=
|
|
304
343
|
self.width -
|
|
344
|
+
leftGroupAreaWidth -
|
|
305
345
|
self.style.scrollBarWidth -
|
|
306
346
|
self.style.scrollBarBorderWidth -
|
|
307
347
|
d;
|
|
308
348
|
v.y += columnHeaderCellHeight + self.scrollCache.y[self.frozenRow];
|
|
309
349
|
v.width = self.style.scrollBarWidth + self.style.scrollBarBorderWidth + d;
|
|
310
350
|
v.height =
|
|
311
|
-
self.height -
|
|
351
|
+
self.height -
|
|
352
|
+
columnHeaderCellHeight -
|
|
353
|
+
topGroupAreaHeight -
|
|
354
|
+
self.style.scrollBarWidth -
|
|
355
|
+
d -
|
|
356
|
+
m;
|
|
312
357
|
// vertical box
|
|
313
358
|
vb.x = v.x + self.style.scrollBarBoxMargin;
|
|
314
359
|
vb.y += self.scrollCache.y[self.frozenRow];
|
|
@@ -420,6 +465,14 @@ export default function (self) {
|
|
|
420
465
|
if (self.contextMenu || self.input) {
|
|
421
466
|
return;
|
|
422
467
|
}
|
|
468
|
+
|
|
469
|
+
// Cancel dragging action if user ventures outside grid
|
|
470
|
+
if (self.draggingItem && e.which === 0) {
|
|
471
|
+
self.stopFreezeMove(e);
|
|
472
|
+
self.mouseup(e);
|
|
473
|
+
return;
|
|
474
|
+
}
|
|
475
|
+
|
|
423
476
|
self.mouse = overridePos || self.getLayerPos(e);
|
|
424
477
|
var ctrl =
|
|
425
478
|
(e.ctrlKey || e.metaKey || self.attributes.persistantSelectionMode) &&
|
|
@@ -458,6 +511,20 @@ export default function (self) {
|
|
|
458
511
|
}
|
|
459
512
|
self.currentCell = cell;
|
|
460
513
|
|
|
514
|
+
if (
|
|
515
|
+
!self.draggingItem && // It is not in dragging mode (avoid changing hovers frequent)
|
|
516
|
+
cell &&
|
|
517
|
+
(cell.context === 'cell' || cell.context === self.cursorGrab)
|
|
518
|
+
) {
|
|
519
|
+
const indicator = self.getUnhideIndicator(self.mouse.x, self.mouse.y);
|
|
520
|
+
if (indicator) {
|
|
521
|
+
self.cursor = 'pointer';
|
|
522
|
+
self.hovers = { unhideIndicator: indicator };
|
|
523
|
+
self.draw();
|
|
524
|
+
return;
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
|
|
461
528
|
self.hovers = {};
|
|
462
529
|
if (!self.draggingItem && cell) {
|
|
463
530
|
self.dragItem = cell;
|
|
@@ -469,6 +536,7 @@ export default function (self) {
|
|
|
469
536
|
rowIndex: cell.rowIndex,
|
|
470
537
|
columnIndex: cell.columnIndex,
|
|
471
538
|
onFilterButton: false,
|
|
539
|
+
onCellTreeIcon: false,
|
|
472
540
|
};
|
|
473
541
|
if (
|
|
474
542
|
cell.isFilterable &&
|
|
@@ -488,6 +556,26 @@ export default function (self) {
|
|
|
488
556
|
self.hovers.onFilterButton = true;
|
|
489
557
|
self.draw();
|
|
490
558
|
}
|
|
559
|
+
if (cell.isRowTree || cell.isColumnTree) {
|
|
560
|
+
const pc = cell.isRowTree
|
|
561
|
+
? self.cellTree.rows[cell.rowIndex].parentCount
|
|
562
|
+
: 0;
|
|
563
|
+
const rc = self.style.cellTreeIconWidth * self.scale,
|
|
564
|
+
rx =
|
|
565
|
+
cell.x +
|
|
566
|
+
cell.paddingLeft +
|
|
567
|
+
self.canvasOffsetLeft +
|
|
568
|
+
self.style.cellTreeIconMarginLeft +
|
|
569
|
+
pc * (rc + cell.paddingLeft),
|
|
570
|
+
ry =
|
|
571
|
+
cell.y +
|
|
572
|
+
self.canvasOffsetTop +
|
|
573
|
+
self.style.cellTreeIconMarginTop * self.scale;
|
|
574
|
+
if (x >= rx && x <= rx + rc && y >= ry && y < ry + rc) {
|
|
575
|
+
self.hovers.onCellTreeIcon = true;
|
|
576
|
+
self.draw();
|
|
577
|
+
}
|
|
578
|
+
}
|
|
491
579
|
}
|
|
492
580
|
if (self.selecting || self.reorderObject) {
|
|
493
581
|
delta = {
|
|
@@ -512,7 +600,24 @@ export default function (self) {
|
|
|
512
600
|
dragBounds.right = s.length - 1;
|
|
513
601
|
dragBounds.top = Math.min(sBounds.top, cell.rowIndex);
|
|
514
602
|
dragBounds.bottom = Math.max(sBounds.bottom, cell.rowIndex);
|
|
603
|
+
if (dragBounds.top < 0) dragBounds.top = 0;
|
|
515
604
|
}
|
|
605
|
+
|
|
606
|
+
if (self.dragStartObject.rowIndex === -1) {
|
|
607
|
+
sBounds = self.getSelectionBounds();
|
|
608
|
+
dragBounds.left =
|
|
609
|
+
cell.columnIndex === undefined
|
|
610
|
+
? sBounds.left
|
|
611
|
+
: Math.min(sBounds.left, cell.columnIndex);
|
|
612
|
+
dragBounds.right =
|
|
613
|
+
cell.columnIndex === undefined
|
|
614
|
+
? sBounds.right
|
|
615
|
+
: Math.max(sBounds.right, cell.columnIndex);
|
|
616
|
+
dragBounds.top = -1;
|
|
617
|
+
dragBounds.bottom = self.viewData.length - 1;
|
|
618
|
+
if (dragBounds.left < 0) dragBounds.left = 0;
|
|
619
|
+
}
|
|
620
|
+
|
|
516
621
|
if (
|
|
517
622
|
self.dragStartObject.rowIndex !== cell.rowIndex ||
|
|
518
623
|
self.dragStartObject.columnIndex !== cell.columnIndex
|
|
@@ -525,11 +630,31 @@ export default function (self) {
|
|
|
525
630
|
self.attributes.selectionMode === 'row'
|
|
526
631
|
) {
|
|
527
632
|
if (
|
|
633
|
+
cell.rowIndex !== undefined &&
|
|
528
634
|
(self.attributes.selectionMode === 'row' ||
|
|
529
635
|
self.dragStartObject.columnIndex === -1) &&
|
|
530
636
|
self.rowBoundaryCrossed
|
|
531
637
|
) {
|
|
532
|
-
self.
|
|
638
|
+
if (self.dragStartObject.rowIndex < cell.rowIndex) {
|
|
639
|
+
dragBounds.top = self.dragStartObject.rowIndex;
|
|
640
|
+
dragBounds.bottom = cell.rowIndex;
|
|
641
|
+
} else {
|
|
642
|
+
dragBounds.top = cell.rowIndex;
|
|
643
|
+
dragBounds.bottom = self.dragStartObject.rowIndex;
|
|
644
|
+
}
|
|
645
|
+
} else if (
|
|
646
|
+
cell.rowIndex !== undefined &&
|
|
647
|
+
(self.attributes.selectionMode === 'column' ||
|
|
648
|
+
self.dragStartObject.rowIndex === -1) &&
|
|
649
|
+
self.columnBoundaryCrossed
|
|
650
|
+
) {
|
|
651
|
+
if (self.dragStartObject.columnIndex < cell.columnIndex) {
|
|
652
|
+
dragBounds.left = self.dragStartObject.columnIndex;
|
|
653
|
+
dragBounds.right = cell.columnIndex;
|
|
654
|
+
} else {
|
|
655
|
+
dragBounds.left = cell.columnIndex;
|
|
656
|
+
dragBounds.right = self.dragStartObject.columnIndex;
|
|
657
|
+
}
|
|
533
658
|
} else if (self.attributes.selectionMode !== 'row') {
|
|
534
659
|
if (cell.hovered && self.hovers.onFilterButton) {
|
|
535
660
|
if (cell.openedFilter) {
|
|
@@ -549,12 +674,20 @@ export default function (self) {
|
|
|
549
674
|
}
|
|
550
675
|
self.draw();
|
|
551
676
|
return;
|
|
677
|
+
} else if (
|
|
678
|
+
cell.hovered &&
|
|
679
|
+
self.hovers.onCellTreeIcon &&
|
|
680
|
+
e.type == 'mousedown'
|
|
681
|
+
) {
|
|
682
|
+
self.toggleCollapseTree(cell.rowIndex, cell.columnIndex);
|
|
683
|
+
return;
|
|
552
684
|
} else {
|
|
553
685
|
self.selectedFilterButton = {
|
|
554
686
|
columnIndex: -1,
|
|
555
687
|
rowIndex: -1,
|
|
556
688
|
};
|
|
557
689
|
if (self.hovers.onFilterButton) return;
|
|
690
|
+
if (self.hovers.onCellTreeIcon) return;
|
|
558
691
|
if (!self.dragAddToSelection && cell.rowIndex !== undefined) {
|
|
559
692
|
if (
|
|
560
693
|
self.selections[cell.rowIndex] &&
|
|
@@ -627,6 +760,12 @@ export default function (self) {
|
|
|
627
760
|
}
|
|
628
761
|
}
|
|
629
762
|
}
|
|
763
|
+
const columnGroup = self.getColumnGroupAt(self.mouse.x, self.mouse.y);
|
|
764
|
+
if (columnGroup) self.cursor = 'pointer';
|
|
765
|
+
|
|
766
|
+
const rowGroup = self.getRowGroupAt(self.mouse.x, self.mouse.y);
|
|
767
|
+
if (rowGroup) self.cursor = 'pointer';
|
|
768
|
+
|
|
630
769
|
self.cellBoundaryCrossed = false;
|
|
631
770
|
self.rowBoundaryCrossed = false;
|
|
632
771
|
self.columnBoundaryCrossed = false;
|
|
@@ -675,9 +814,34 @@ export default function (self) {
|
|
|
675
814
|
) {
|
|
676
815
|
return;
|
|
677
816
|
}
|
|
817
|
+
|
|
818
|
+
const unhideIndicator = self.getUnhideIndicator(pos.x, pos.y);
|
|
819
|
+
if (unhideIndicator) {
|
|
820
|
+
const { dir, orderIndex0, orderIndex1 } = unhideIndicator;
|
|
821
|
+
if (dir === 'l' || dir === 'r')
|
|
822
|
+
self.unhideColumns(orderIndex0, orderIndex1);
|
|
823
|
+
else self.unhideRows(orderIndex0, orderIndex1);
|
|
824
|
+
return;
|
|
825
|
+
}
|
|
826
|
+
|
|
827
|
+
let group = self.getColumnGroupAt(pos.x, pos.y);
|
|
828
|
+
if (!group) group = self.getRowGroupAt(pos.x, pos.y);
|
|
829
|
+
if (group) {
|
|
830
|
+
if (self.toggleGroup(group)) {
|
|
831
|
+
self.setStorageData();
|
|
832
|
+
self.refresh();
|
|
833
|
+
return;
|
|
834
|
+
}
|
|
835
|
+
}
|
|
836
|
+
|
|
678
837
|
if (!self.hasFocus) {
|
|
679
838
|
return;
|
|
680
839
|
}
|
|
840
|
+
|
|
841
|
+
const leftOffset = self.getRowGroupAreaWidth();
|
|
842
|
+
const topOffset = self.getColumnGroupAreaHeight();
|
|
843
|
+
const xInGrid = pos.x - leftOffset;
|
|
844
|
+
const yInGrid = pos.y - topOffset;
|
|
681
845
|
if (
|
|
682
846
|
['rowHeaderCell', 'columnHeaderCell'].indexOf(self.currentCell.style) ===
|
|
683
847
|
-1 &&
|
|
@@ -715,17 +879,17 @@ export default function (self) {
|
|
|
715
879
|
if (
|
|
716
880
|
self.currentCell.style === 'rowHeaderCell' &&
|
|
717
881
|
self.attributes.tree &&
|
|
718
|
-
|
|
719
|
-
|
|
882
|
+
xInGrid > 0 &&
|
|
883
|
+
xInGrid - self.currentCell.x <
|
|
720
884
|
self.style.treeArrowWidth +
|
|
721
885
|
self.style.treeArrowMarginLeft +
|
|
722
886
|
self.style.treeArrowMarginRight +
|
|
723
887
|
self.style.treeArrowClickRadius &&
|
|
724
|
-
|
|
888
|
+
yInGrid - self.currentCell.y <
|
|
725
889
|
self.style.treeArrowHeight +
|
|
726
890
|
self.style.treeArrowMarginTop +
|
|
727
891
|
self.style.treeArrowClickRadius &&
|
|
728
|
-
|
|
892
|
+
yInGrid > 0
|
|
729
893
|
) {
|
|
730
894
|
self.toggleTree(i.rowIndex);
|
|
731
895
|
return;
|
|
@@ -765,7 +929,6 @@ export default function (self) {
|
|
|
765
929
|
self.dragMode === 'ew-resize'
|
|
766
930
|
) {
|
|
767
931
|
self.resize(true);
|
|
768
|
-
self.scrollBox.scrollLeft += x;
|
|
769
932
|
}
|
|
770
933
|
if (self.dragMode === 'ew-resize') {
|
|
771
934
|
self.sizes.columns[
|
|
@@ -1127,6 +1290,8 @@ export default function (self) {
|
|
|
1127
1290
|
|
|
1128
1291
|
self.ignoreNextClick = true;
|
|
1129
1292
|
self.freezeMarkerPosition = pos;
|
|
1293
|
+
pos.x -= self.getRowGroupAreaWidth();
|
|
1294
|
+
pos.y -= self.getColumnGroupAreaHeight();
|
|
1130
1295
|
if (
|
|
1131
1296
|
self.currentCell &&
|
|
1132
1297
|
self.currentCell.rowIndex !== undefined &&
|
|
@@ -1162,13 +1327,14 @@ export default function (self) {
|
|
|
1162
1327
|
self.currentCell.columnIndex !== undefined &&
|
|
1163
1328
|
self.dragMode === 'frozen-column-marker'
|
|
1164
1329
|
) {
|
|
1330
|
+
const dataWidth = self.refreshScrollCacheX();
|
|
1165
1331
|
self.scrollBox.scrollLeft = 0;
|
|
1166
1332
|
self.frozenColumn = self.currentCell.columnIndex + 1;
|
|
1167
1333
|
self.scrollBox.bar.h.x =
|
|
1168
1334
|
rowHeaderCellWidth + self.scrollCache.x[self.frozenColumn - 1];
|
|
1169
1335
|
self.scrollBox.box.h.x =
|
|
1170
1336
|
rowHeaderCellWidth + self.scrollCache.x[self.frozenColumn - 1];
|
|
1171
|
-
var dataWidth = self.scrollCache.x[self.scrollCache.x.length - 1];
|
|
1337
|
+
// var dataWidth = self.scrollCache.x[self.scrollCache.x.length - 1];
|
|
1172
1338
|
self.scrollBox.widthBoxRatio =
|
|
1173
1339
|
(self.scrollBox.width - self.scrollCache.x[self.frozenColumn - 1]) /
|
|
1174
1340
|
dataWidth;
|
|
@@ -1227,6 +1393,7 @@ export default function (self) {
|
|
|
1227
1393
|
move = /-move/.test(self.dragMode),
|
|
1228
1394
|
freeze = /frozen-row-marker|frozen-column-marker/.test(self.dragMode),
|
|
1229
1395
|
resize = /-resize/.test(self.dragMode);
|
|
1396
|
+
const onUnhideIndicator = self.hovers && self.hovers.unhideIndicator;
|
|
1230
1397
|
self.dragStart = overridePos || self.getLayerPos(e);
|
|
1231
1398
|
self.scrollStart = {
|
|
1232
1399
|
left: self.scrollBox.scrollLeft,
|
|
@@ -1256,7 +1423,10 @@ export default function (self) {
|
|
|
1256
1423
|
if (self.dragStartObject.isGrid) {
|
|
1257
1424
|
return;
|
|
1258
1425
|
}
|
|
1259
|
-
if (
|
|
1426
|
+
if (
|
|
1427
|
+
self.scrollModes.indexOf(self.dragStartObject.context) !== -1 &&
|
|
1428
|
+
!onUnhideIndicator
|
|
1429
|
+
) {
|
|
1260
1430
|
self.scrollMode = self.dragStartObject.context;
|
|
1261
1431
|
self.scrollStartMode = self.dragStartObject.context;
|
|
1262
1432
|
self.scrollGrid(e);
|
|
@@ -1285,6 +1455,12 @@ export default function (self) {
|
|
|
1285
1455
|
self.dragStartObject.rowIndex > -1
|
|
1286
1456
|
) {
|
|
1287
1457
|
self.selectRow(self.dragStartObject.rowIndex, ctrl, null);
|
|
1458
|
+
} else if (
|
|
1459
|
+
(self.attributes.selectionMode === 'column' ||
|
|
1460
|
+
self.dragStartObject.rowIndex === -1) &&
|
|
1461
|
+
self.dragStartObject.columnIndex > -1
|
|
1462
|
+
) {
|
|
1463
|
+
self.selectColumn(self.currentCell.header.index, ctrl, e.shiftKey);
|
|
1288
1464
|
} else if (self.attributes.selectionMode !== 'row') {
|
|
1289
1465
|
self.mousemove(e);
|
|
1290
1466
|
}
|
|
@@ -1319,7 +1495,7 @@ export default function (self) {
|
|
|
1319
1495
|
document.body.addEventListener('mouseup', self.stopFreezeMove, false);
|
|
1320
1496
|
return self.mousemove(e);
|
|
1321
1497
|
}
|
|
1322
|
-
if (resize) {
|
|
1498
|
+
if (resize && !onUnhideIndicator) {
|
|
1323
1499
|
self.draggingItem = self.dragItem;
|
|
1324
1500
|
if (self.draggingItem.rowOpen) {
|
|
1325
1501
|
self.resizingStartingHeight =
|
|
@@ -1647,9 +1823,21 @@ export default function (self) {
|
|
|
1647
1823
|
self.autosize();
|
|
1648
1824
|
} else if (
|
|
1649
1825
|
['cell', 'activeCell'].includes(self.currentCell.style) &&
|
|
1650
|
-
!self.hovers.onFilterButton
|
|
1826
|
+
!self.hovers.onFilterButton &&
|
|
1827
|
+
!self.hovers.onCellTreeIcon
|
|
1651
1828
|
) {
|
|
1652
|
-
|
|
1829
|
+
if (self.currentCell.isRowTree || self.currentCell.isColumnTree) {
|
|
1830
|
+
self.cellTreeExpandCollapse(
|
|
1831
|
+
self.currentCell.rowIndex,
|
|
1832
|
+
self.currentCell.columnIndex,
|
|
1833
|
+
);
|
|
1834
|
+
self.draw();
|
|
1835
|
+
} else {
|
|
1836
|
+
self.beginEditAt(
|
|
1837
|
+
self.currentCell.columnIndex,
|
|
1838
|
+
self.currentCell.rowIndex,
|
|
1839
|
+
);
|
|
1840
|
+
}
|
|
1653
1841
|
}
|
|
1654
1842
|
};
|
|
1655
1843
|
self.scrollWheel = function (e) {
|
package/lib/events/util.js
CHANGED
|
@@ -112,7 +112,7 @@ const createHTMLString = function (selectedData, isNeat) {
|
|
|
112
112
|
(row) =>
|
|
113
113
|
'<tr>' +
|
|
114
114
|
Object.values(row)
|
|
115
|
-
.map((value) => '<td>'
|
|
115
|
+
.map((value) => ['<td>', htmlSafe(value), '</td>'].join(''))
|
|
116
116
|
.join('') +
|
|
117
117
|
'</tr>',
|
|
118
118
|
)
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Merge a new hidden row range into existed ranges array
|
|
5
|
+
* @param {any[]} hiddenRowRanges tuples: Array<[bgeinRowIndex, endRowIndex]>
|
|
6
|
+
* @param {number[]} newRange tuple: [beginRowIndex, endRowIndex]
|
|
7
|
+
* @returns {boolean}
|
|
8
|
+
*/
|
|
9
|
+
const mergeHiddenRowRanges = function (hiddenRowRanges, newRange) {
|
|
10
|
+
const [beginRowIndex, endRowIndex] = newRange;
|
|
11
|
+
if (endRowIndex < beginRowIndex) return false;
|
|
12
|
+
let inserted = false;
|
|
13
|
+
for (let i = 0; i < hiddenRowRanges.length; i++) {
|
|
14
|
+
const range = hiddenRowRanges[i];
|
|
15
|
+
if (beginRowIndex > range[1] + 1) continue;
|
|
16
|
+
if (beginRowIndex <= range[0] && endRowIndex >= range[0]) {
|
|
17
|
+
hiddenRowRanges[i] = [beginRowIndex, Math.max(endRowIndex, range[1])];
|
|
18
|
+
inserted = true;
|
|
19
|
+
break;
|
|
20
|
+
}
|
|
21
|
+
if (beginRowIndex >= range[0]) {
|
|
22
|
+
hiddenRowRanges[i] = [range[0], Math.max(endRowIndex, range[1])];
|
|
23
|
+
inserted = true;
|
|
24
|
+
break;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
if (!inserted) hiddenRowRanges.push([beginRowIndex, endRowIndex]);
|
|
28
|
+
// merge intersections after sorting ranges
|
|
29
|
+
hiddenRowRanges.sort((a, b) => a[0] - b[0]);
|
|
30
|
+
for (let i = 0; i < hiddenRowRanges.length - 1; i++) {
|
|
31
|
+
const range = hiddenRowRanges[i];
|
|
32
|
+
const nextRange = hiddenRowRanges[i + 1];
|
|
33
|
+
if (nextRange[0] <= range[1] + 1) {
|
|
34
|
+
hiddenRowRanges[i] = [range[0], Math.max(range[1], nextRange[1])];
|
|
35
|
+
hiddenRowRanges.splice(i + 1, 1);
|
|
36
|
+
i--;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return true;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export { mergeHiddenRowRanges };
|