e-virt-table 1.3.26 → 1.4.1
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/dist/index.cjs.js +16 -5
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.js +2993 -2520
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +16 -5
- package/dist/index.umd.js.map +1 -1
- package/dist/lib/Autofill.js +3 -2
- package/dist/lib/Autofill.js.map +1 -1
- package/dist/lib/BaseCell.d.ts +15 -2
- package/dist/lib/BaseCell.js +55 -15
- package/dist/lib/BaseCell.js.map +1 -1
- package/dist/lib/Body.d.ts +8 -0
- package/dist/lib/Body.js +230 -0
- package/dist/lib/Body.js.map +1 -1
- package/dist/lib/Cell.d.ts +9 -18
- package/dist/lib/Cell.js +143 -181
- package/dist/lib/Cell.js.map +1 -1
- package/dist/lib/CellHeader.d.ts +9 -2
- package/dist/lib/CellHeader.js +80 -44
- package/dist/lib/CellHeader.js.map +1 -1
- package/dist/lib/CellImage.d.ts +15 -0
- package/dist/lib/CellImage.js +72 -0
- package/dist/lib/CellImage.js.map +1 -0
- package/dist/lib/Config.d.ts +18 -3
- package/dist/lib/Config.js +72 -25
- package/dist/lib/Config.js.map +1 -1
- package/dist/lib/Context.d.ts +5 -1
- package/dist/lib/Context.js +22 -3
- package/dist/lib/Context.js.map +1 -1
- package/dist/lib/ContextMenu.js +10 -2
- package/dist/lib/ContextMenu.js.map +1 -1
- package/dist/lib/DOMTreeMenu.js +1 -1
- package/dist/lib/DOMTreeMenu.js.map +1 -1
- package/dist/lib/Database.d.ts +1 -0
- package/dist/lib/Database.js +105 -94
- package/dist/lib/Database.js.map +1 -1
- package/dist/lib/EVirtTable.d.ts +5 -0
- package/dist/lib/EVirtTable.js +24 -0
- package/dist/lib/EVirtTable.js.map +1 -1
- package/dist/lib/Editor.d.ts +1 -0
- package/dist/lib/Editor.js +10 -3
- package/dist/lib/Editor.js.map +1 -1
- package/dist/lib/Empty.d.ts +2 -0
- package/dist/lib/Empty.js +11 -2
- package/dist/lib/Empty.js.map +1 -1
- package/dist/lib/EventTable.d.ts +0 -13
- package/dist/lib/EventTable.js +33 -221
- package/dist/lib/EventTable.js.map +1 -1
- package/dist/lib/Header.d.ts +2 -0
- package/dist/lib/Header.js +46 -2
- package/dist/lib/Header.js.map +1 -1
- package/dist/lib/Icons.d.ts +8 -7
- package/dist/lib/Icons.js +22 -10
- package/dist/lib/Icons.js.map +1 -1
- package/dist/lib/Loading.d.ts +3 -0
- package/dist/lib/Loading.js +18 -4
- package/dist/lib/Loading.js.map +1 -1
- package/dist/lib/Locale.d.ts +7 -0
- package/dist/lib/Locale.js +26 -0
- package/dist/lib/Locale.js.map +1 -0
- package/dist/lib/Paint.d.ts +7 -0
- package/dist/lib/Paint.js +220 -67
- package/dist/lib/Paint.js.map +1 -1
- package/dist/lib/Selector.js +16 -12
- package/dist/lib/Selector.js.map +1 -1
- package/dist/lib/TextSelector.d.ts +95 -0
- package/dist/lib/TextSelector.js +250 -0
- package/dist/lib/TextSelector.js.map +1 -0
- package/dist/lib/TreeUtil.d.ts +6 -8
- package/dist/lib/TreeUtil.js +49 -40
- package/dist/lib/TreeUtil.js.map +1 -1
- package/dist/lib/lang/en-US.d.ts +25 -0
- package/dist/lib/lang/en-US.js +25 -0
- package/dist/lib/lang/en-US.js.map +1 -0
- package/dist/lib/lang/zh-CN.d.ts +25 -0
- package/dist/lib/lang/zh-CN.js +25 -0
- package/dist/lib/lang/zh-CN.js.map +1 -0
- package/dist/lib/types.d.ts +25 -3
- package/dist/lib/util.d.ts +2 -1
- package/dist/lib/util.js +5 -1
- package/dist/lib/util.js.map +1 -1
- package/package.json +1 -1
package/dist/lib/Cell.js
CHANGED
|
@@ -1,7 +1,20 @@
|
|
|
1
1
|
import BaseCell from './BaseCell';
|
|
2
|
+
import CellImage from './CellImage';
|
|
2
3
|
export default class Cell extends BaseCell {
|
|
3
4
|
constructor(ctx, rowIndex, colIndex, x, y, width, height, column, row, cellType = 'body', isUpdate = true) {
|
|
4
5
|
super(ctx, x, y, width, height, cellType, column.fixed);
|
|
6
|
+
Object.defineProperty(this, "parentRowKey", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
configurable: true,
|
|
9
|
+
writable: true,
|
|
10
|
+
value: ''
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(this, "parentRowKeys", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
configurable: true,
|
|
15
|
+
writable: true,
|
|
16
|
+
value: []
|
|
17
|
+
});
|
|
5
18
|
Object.defineProperty(this, "formatter", {
|
|
6
19
|
enumerable: true,
|
|
7
20
|
configurable: true,
|
|
@@ -278,117 +291,6 @@ export default class Cell extends BaseCell {
|
|
|
278
291
|
writable: true,
|
|
279
292
|
value: 0
|
|
280
293
|
});
|
|
281
|
-
// 画tree图标
|
|
282
|
-
Object.defineProperty(this, "drawTreeImageX", {
|
|
283
|
-
enumerable: true,
|
|
284
|
-
configurable: true,
|
|
285
|
-
writable: true,
|
|
286
|
-
value: 0
|
|
287
|
-
});
|
|
288
|
-
Object.defineProperty(this, "drawTreeImageY", {
|
|
289
|
-
enumerable: true,
|
|
290
|
-
configurable: true,
|
|
291
|
-
writable: true,
|
|
292
|
-
value: 0
|
|
293
|
-
});
|
|
294
|
-
Object.defineProperty(this, "drawTreeImageWidth", {
|
|
295
|
-
enumerable: true,
|
|
296
|
-
configurable: true,
|
|
297
|
-
writable: true,
|
|
298
|
-
value: 0
|
|
299
|
-
});
|
|
300
|
-
Object.defineProperty(this, "drawTreeImageHeight", {
|
|
301
|
-
enumerable: true,
|
|
302
|
-
configurable: true,
|
|
303
|
-
writable: true,
|
|
304
|
-
value: 0
|
|
305
|
-
});
|
|
306
|
-
Object.defineProperty(this, "drawTreeImageName", {
|
|
307
|
-
enumerable: true,
|
|
308
|
-
configurable: true,
|
|
309
|
-
writable: true,
|
|
310
|
-
value: ''
|
|
311
|
-
});
|
|
312
|
-
Object.defineProperty(this, "drawTreeImageSource", {
|
|
313
|
-
enumerable: true,
|
|
314
|
-
configurable: true,
|
|
315
|
-
writable: true,
|
|
316
|
-
value: void 0
|
|
317
|
-
});
|
|
318
|
-
// 画selection图标
|
|
319
|
-
Object.defineProperty(this, "drawSelectionImageX", {
|
|
320
|
-
enumerable: true,
|
|
321
|
-
configurable: true,
|
|
322
|
-
writable: true,
|
|
323
|
-
value: 0
|
|
324
|
-
});
|
|
325
|
-
Object.defineProperty(this, "drawSelectionImageY", {
|
|
326
|
-
enumerable: true,
|
|
327
|
-
configurable: true,
|
|
328
|
-
writable: true,
|
|
329
|
-
value: 0
|
|
330
|
-
});
|
|
331
|
-
Object.defineProperty(this, "drawSelectionImageWidth", {
|
|
332
|
-
enumerable: true,
|
|
333
|
-
configurable: true,
|
|
334
|
-
writable: true,
|
|
335
|
-
value: 0
|
|
336
|
-
});
|
|
337
|
-
Object.defineProperty(this, "drawSelectionImageHeight", {
|
|
338
|
-
enumerable: true,
|
|
339
|
-
configurable: true,
|
|
340
|
-
writable: true,
|
|
341
|
-
value: 0
|
|
342
|
-
});
|
|
343
|
-
Object.defineProperty(this, "drawSelectionImageName", {
|
|
344
|
-
enumerable: true,
|
|
345
|
-
configurable: true,
|
|
346
|
-
writable: true,
|
|
347
|
-
value: ''
|
|
348
|
-
});
|
|
349
|
-
Object.defineProperty(this, "drawSelectionImageSource", {
|
|
350
|
-
enumerable: true,
|
|
351
|
-
configurable: true,
|
|
352
|
-
writable: true,
|
|
353
|
-
value: void 0
|
|
354
|
-
});
|
|
355
|
-
// 画hover图标
|
|
356
|
-
Object.defineProperty(this, "drawHoverImageX", {
|
|
357
|
-
enumerable: true,
|
|
358
|
-
configurable: true,
|
|
359
|
-
writable: true,
|
|
360
|
-
value: 0
|
|
361
|
-
});
|
|
362
|
-
Object.defineProperty(this, "drawHoverImageY", {
|
|
363
|
-
enumerable: true,
|
|
364
|
-
configurable: true,
|
|
365
|
-
writable: true,
|
|
366
|
-
value: 0
|
|
367
|
-
});
|
|
368
|
-
Object.defineProperty(this, "drawHoverImageWidth", {
|
|
369
|
-
enumerable: true,
|
|
370
|
-
configurable: true,
|
|
371
|
-
writable: true,
|
|
372
|
-
value: 0
|
|
373
|
-
});
|
|
374
|
-
Object.defineProperty(this, "drawHoverImageHeight", {
|
|
375
|
-
enumerable: true,
|
|
376
|
-
configurable: true,
|
|
377
|
-
writable: true,
|
|
378
|
-
value: 0
|
|
379
|
-
});
|
|
380
|
-
Object.defineProperty(this, "drawHoverImageName", {
|
|
381
|
-
enumerable: true,
|
|
382
|
-
configurable: true,
|
|
383
|
-
writable: true,
|
|
384
|
-
value: ''
|
|
385
|
-
});
|
|
386
|
-
Object.defineProperty(this, "drawHoverImageSource", {
|
|
387
|
-
enumerable: true,
|
|
388
|
-
configurable: true,
|
|
389
|
-
writable: true,
|
|
390
|
-
value: void 0
|
|
391
|
-
});
|
|
392
294
|
Object.defineProperty(this, "autoRowHeight", {
|
|
393
295
|
enumerable: true,
|
|
394
296
|
configurable: true,
|
|
@@ -449,6 +351,36 @@ export default class Cell extends BaseCell {
|
|
|
449
351
|
writable: true,
|
|
450
352
|
value: 'auto'
|
|
451
353
|
});
|
|
354
|
+
Object.defineProperty(this, "precision", {
|
|
355
|
+
enumerable: true,
|
|
356
|
+
configurable: true,
|
|
357
|
+
writable: true,
|
|
358
|
+
value: undefined
|
|
359
|
+
});
|
|
360
|
+
Object.defineProperty(this, "min", {
|
|
361
|
+
enumerable: true,
|
|
362
|
+
configurable: true,
|
|
363
|
+
writable: true,
|
|
364
|
+
value: undefined
|
|
365
|
+
});
|
|
366
|
+
Object.defineProperty(this, "max", {
|
|
367
|
+
enumerable: true,
|
|
368
|
+
configurable: true,
|
|
369
|
+
writable: true,
|
|
370
|
+
value: undefined
|
|
371
|
+
});
|
|
372
|
+
Object.defineProperty(this, "maxlength", {
|
|
373
|
+
enumerable: true,
|
|
374
|
+
configurable: true,
|
|
375
|
+
writable: true,
|
|
376
|
+
value: undefined
|
|
377
|
+
});
|
|
378
|
+
Object.defineProperty(this, "mixedRender", {
|
|
379
|
+
enumerable: true,
|
|
380
|
+
configurable: true,
|
|
381
|
+
writable: true,
|
|
382
|
+
value: false
|
|
383
|
+
});
|
|
452
384
|
Object.defineProperty(this, "renderType", {
|
|
453
385
|
enumerable: true,
|
|
454
386
|
configurable: true,
|
|
@@ -496,8 +428,18 @@ export default class Cell extends BaseCell {
|
|
|
496
428
|
this.formatter = column.formatter;
|
|
497
429
|
this.formatterFooter = column.formatterFooter;
|
|
498
430
|
this.maxLineClamp = column.maxLineClamp || 'auto';
|
|
431
|
+
this.precision = column.precision;
|
|
432
|
+
this.min = column.min;
|
|
433
|
+
this.max = column.max;
|
|
434
|
+
this.maxlength = column.maxlength;
|
|
435
|
+
this.mixedRender = column.mixedRender || false;
|
|
499
436
|
this.renderType = column.renderType || 'default';
|
|
500
437
|
this.renderFooterType = column.renderFooterType || 'default';
|
|
438
|
+
const rowItem = this.ctx.database.getRowForRowKey(this.rowKey);
|
|
439
|
+
if (this.cellType === 'body' && rowItem) {
|
|
440
|
+
this.parentRowKey = rowItem.parentRowKey;
|
|
441
|
+
this.parentRowKeys = rowItem.parentRowKeys;
|
|
442
|
+
}
|
|
501
443
|
if (isUpdate) {
|
|
502
444
|
this.update();
|
|
503
445
|
}
|
|
@@ -517,11 +459,14 @@ export default class Cell extends BaseCell {
|
|
|
517
459
|
update() {
|
|
518
460
|
this.drawX = this.getDrawX();
|
|
519
461
|
this.drawY = this.getDrawY();
|
|
520
|
-
this.
|
|
462
|
+
this.updateSpan();
|
|
463
|
+
this.updateDragImage();
|
|
464
|
+
const dragImage = this.getImage('drag');
|
|
465
|
+
const drawDragImageWidth = dragImage ? dragImage.width : 0;
|
|
466
|
+
this.drawTextX = this.drawX + drawDragImageWidth;
|
|
521
467
|
this.drawTextY = this.drawY;
|
|
522
468
|
this.isHasChanged = this.ctx.database.isHasChangedData(this.rowKey, this.key);
|
|
523
|
-
this.
|
|
524
|
-
this.drawTextWidth = this.visibleWidth;
|
|
469
|
+
this.drawTextWidth = this.visibleWidth - drawDragImageWidth;
|
|
525
470
|
this.drawTextHeight = this.visibleHeight;
|
|
526
471
|
this.updateStyle();
|
|
527
472
|
this.updateType();
|
|
@@ -674,6 +619,9 @@ export default class Cell extends BaseCell {
|
|
|
674
619
|
}
|
|
675
620
|
this.style = this.getOverlayerViewsStyle();
|
|
676
621
|
}
|
|
622
|
+
isInsideVisible(x, y) {
|
|
623
|
+
return x >= this.drawX && x <= this.drawX + this.visibleWidth && y >= this.drawY && y <= this.drawY + this.visibleHeight;
|
|
624
|
+
}
|
|
677
625
|
updateTree() {
|
|
678
626
|
const { CELL_PADDING = 0 } = this.ctx.config;
|
|
679
627
|
const { rowKey, cellType } = this;
|
|
@@ -712,17 +660,24 @@ export default class Cell extends BaseCell {
|
|
|
712
660
|
let iconX = drawX + iconOffsetX + CELL_PADDING;
|
|
713
661
|
let iconY = this.drawY + (this.visibleHeight - iconHeight) / 2;
|
|
714
662
|
let drawTextX = iconOffsetX + this.drawX + iconWidth - 0.5;
|
|
715
|
-
|
|
663
|
+
const selectionImage = this.getImage('selection');
|
|
664
|
+
const dragImage = this.getImage('drag');
|
|
665
|
+
const dragImageWidth = dragImage ? dragImage.width : 0;
|
|
666
|
+
if (this.type === 'selection-tree' && selectionImage) {
|
|
667
|
+
const selectionImageX = selectionImage.x;
|
|
668
|
+
const selectionImageWidth = selectionImage.width;
|
|
716
669
|
// 树形图标在左侧,checkbox 在树形图标右侧
|
|
717
|
-
iconX = iconOffsetX +
|
|
670
|
+
iconX = iconOffsetX + selectionImageX + selectionImageWidth;
|
|
718
671
|
drawTextX = iconX + iconWidth - CELL_PADDING / 2;
|
|
719
672
|
}
|
|
720
673
|
else if (this.type === 'tree-selection') {
|
|
721
674
|
// 树形选择,两个图标宽度,文本已经有CELL_PADDING间距,/2看起来好看些
|
|
675
|
+
iconX += dragImageWidth;
|
|
722
676
|
drawTextX = iconX + CHECKBOX_SIZE + iconWidth - CELL_PADDING / 2;
|
|
723
677
|
}
|
|
724
678
|
else {
|
|
725
679
|
// 普通tree,文本已经有CELL_PADDING间距,/2看起来好看些
|
|
680
|
+
iconX += dragImageWidth;
|
|
726
681
|
drawTextX = iconX + iconWidth - CELL_PADDING / 2;
|
|
727
682
|
}
|
|
728
683
|
// 更改文本距离
|
|
@@ -736,20 +691,21 @@ export default class Cell extends BaseCell {
|
|
|
736
691
|
return;
|
|
737
692
|
}
|
|
738
693
|
// 不论是否需要绘制图标,都更新图标的“基准位置”,供树线使用
|
|
739
|
-
this.
|
|
740
|
-
this.drawTreeImageY = iconY;
|
|
741
|
-
this.drawTreeImageWidth = iconWidth;
|
|
742
|
-
this.drawTreeImageHeight = iconHeight;
|
|
743
|
-
if (icon) {
|
|
744
|
-
this.drawTreeImageName = iconName;
|
|
745
|
-
this.drawTreeImageSource = icon;
|
|
746
|
-
}
|
|
747
|
-
else {
|
|
748
|
-
this.drawTreeImageName = '';
|
|
749
|
-
this.drawTreeImageSource = undefined;
|
|
750
|
-
}
|
|
694
|
+
this.setImage('tree', new CellImage(iconName, iconX, iconY, iconWidth, iconHeight, icon));
|
|
751
695
|
// 树连线仅在绘制阶段调用,避免在 update 阶段被清屏
|
|
752
696
|
}
|
|
697
|
+
updateDragImage() {
|
|
698
|
+
if (this.cellType === 'body' && this.column.dragRow) {
|
|
699
|
+
const { DRAG_ROW_ICON_SIZE, CELL_PADDING } = this.ctx.config;
|
|
700
|
+
const dragImageX = this.drawX + CELL_PADDING / 2;
|
|
701
|
+
const dragImageY = this.drawY + (this.visibleHeight - DRAG_ROW_ICON_SIZE) / 2;
|
|
702
|
+
const dragImage = new CellImage('drag', dragImageX, dragImageY, DRAG_ROW_ICON_SIZE, DRAG_ROW_ICON_SIZE, this.ctx.icons.get('drag'));
|
|
703
|
+
if (this.rowspan === 0) {
|
|
704
|
+
dragImage.setVisible(false);
|
|
705
|
+
}
|
|
706
|
+
this.setImage('drag', dragImage);
|
|
707
|
+
}
|
|
708
|
+
}
|
|
753
709
|
drawTreeLine() {
|
|
754
710
|
const { TREE_LINE, TREE_INDENT = 16, TREE_ICON_SIZE = 16, TREE_LINE_COLOR = '#e1e6eb' } = this.ctx.config;
|
|
755
711
|
// 仅 body 且树类型才绘制
|
|
@@ -762,11 +718,18 @@ export default class Cell extends BaseCell {
|
|
|
762
718
|
const row = this.ctx.database.getRowForRowKey(this.rowKey) || {};
|
|
763
719
|
const level = row.level ?? 0;
|
|
764
720
|
// 以当前树图标为中心点
|
|
765
|
-
const
|
|
766
|
-
|
|
721
|
+
const treeImage = this.getImage('tree');
|
|
722
|
+
if (!treeImage)
|
|
723
|
+
return;
|
|
724
|
+
const treeImageX = treeImage.x;
|
|
725
|
+
const treeImageY = treeImage.y;
|
|
726
|
+
const treeImageWidth = treeImage.width;
|
|
727
|
+
const treeImageHeight = treeImage.height;
|
|
728
|
+
const iconCenterX = treeImageX + treeImageWidth / 2;
|
|
729
|
+
const iconCenterY = treeImageY + treeImageHeight / 2;
|
|
767
730
|
// 基于已计算的树图标位置反推基准点:当前图标左侧减去 level * TREE_INDENT
|
|
768
731
|
// 这样无论对齐方式如何(left/center/right),都以实际图标为基准定位所有竖线
|
|
769
|
-
let baseX =
|
|
732
|
+
let baseX = treeImageX - level * TREE_INDENT;
|
|
770
733
|
// 逐层画竖线(仅当 level > 0 才需要祖先连线)
|
|
771
734
|
const parentRowKeys = Array.isArray(row.parentRowKeys) ? row.parentRowKeys : [];
|
|
772
735
|
if (level > 0) {
|
|
@@ -781,7 +744,7 @@ export default class Cell extends BaseCell {
|
|
|
781
744
|
if (nextIsLast)
|
|
782
745
|
continue;
|
|
783
746
|
// 以当前树图标 X 为基准向左回推
|
|
784
|
-
const vx = Math.round(
|
|
747
|
+
const vx = Math.round(treeImageX - (level - i) * TREE_INDENT + TREE_ICON_SIZE / 2);
|
|
785
748
|
this.ctx.paint.drawLine([vx, this.drawY, vx, this.drawY + this.visibleHeight], {
|
|
786
749
|
borderColor: TREE_LINE_COLOR,
|
|
787
750
|
borderWidth: 1,
|
|
@@ -790,7 +753,7 @@ export default class Cell extends BaseCell {
|
|
|
790
753
|
});
|
|
791
754
|
}
|
|
792
755
|
// 父层(level-1):无论父是不是末尾,都需要连接当前节点形成 L 型
|
|
793
|
-
const vxParent = Math.round(
|
|
756
|
+
const vxParent = Math.round(treeImageX - TREE_INDENT + TREE_ICON_SIZE / 2);
|
|
794
757
|
const toCenter = !!row.isLastChild;
|
|
795
758
|
const y2 = toCenter ? iconCenterY : this.drawY + this.visibleHeight;
|
|
796
759
|
this.ctx.paint.drawLine([vxParent, this.drawY, vxParent, y2], {
|
|
@@ -810,7 +773,7 @@ export default class Cell extends BaseCell {
|
|
|
810
773
|
}
|
|
811
774
|
// 1) 父节点行:在图标正下画一段短竖线(展开时绘制,符合视觉预期)
|
|
812
775
|
if (row.hasChildren && row.expand) {
|
|
813
|
-
const shortTop =
|
|
776
|
+
const shortTop = treeImageY + treeImageHeight;
|
|
814
777
|
const shortBottom = this.drawY + this.visibleHeight;
|
|
815
778
|
this.ctx.paint.drawLine([iconCenterX, shortTop, iconCenterX, shortBottom], {
|
|
816
779
|
borderColor: TREE_LINE_COLOR,
|
|
@@ -865,7 +828,7 @@ export default class Cell extends BaseCell {
|
|
|
865
828
|
minY = yArr[0];
|
|
866
829
|
maxY = yArr[1];
|
|
867
830
|
}
|
|
868
|
-
if (HIGHLIGHT_HOVER_ROW && hoverCell) {
|
|
831
|
+
if (HIGHLIGHT_HOVER_ROW && hoverCell && !this.ctx.dragRowIng) {
|
|
869
832
|
if (hoverCell.rowKey === this.rowKey) {
|
|
870
833
|
drawCellSkyBgColor = HIGHLIGHT_HOVER_ROW_COLOR;
|
|
871
834
|
}
|
|
@@ -873,7 +836,7 @@ export default class Cell extends BaseCell {
|
|
|
873
836
|
drawCellSkyBgColor = HIGHLIGHT_HOVER_ROW_COLOR;
|
|
874
837
|
}
|
|
875
838
|
}
|
|
876
|
-
if (HIGHLIGHT_SELECTED_ROW && currentCell) {
|
|
839
|
+
if (HIGHLIGHT_SELECTED_ROW && currentCell && !this.ctx.dragRowIng) {
|
|
877
840
|
if (currentCell.rowKey === this.rowKey) {
|
|
878
841
|
drawCellSkyBgColor = HIGHLIGHT_SELECTED_ROW_COLOR;
|
|
879
842
|
}
|
|
@@ -1002,6 +965,9 @@ export default class Cell extends BaseCell {
|
|
|
1002
965
|
checkboxName = 'checkbox-disabled';
|
|
1003
966
|
}
|
|
1004
967
|
}
|
|
968
|
+
const dragImage = this.getImage('drag');
|
|
969
|
+
const drawDragImageWidth = dragImage ? dragImage.width : 0;
|
|
970
|
+
iconX += drawDragImageWidth;
|
|
1005
971
|
// 判断是否溢出格子
|
|
1006
972
|
if (iconX + CHECKBOX_SIZE + CELL_PADDING > this.drawX + this.visibleWidth) {
|
|
1007
973
|
return;
|
|
@@ -1009,25 +975,25 @@ export default class Cell extends BaseCell {
|
|
|
1009
975
|
if (iconY + CHECKBOX_SIZE + CELL_PADDING > this.drawY + this.visibleHeight) {
|
|
1010
976
|
return;
|
|
1011
977
|
}
|
|
978
|
+
const selectionImage = new CellImage(checkboxName, iconX, iconY, CHECKBOX_SIZE, CHECKBOX_SIZE, checkboxImage);
|
|
1012
979
|
if (type === 'index-selection') {
|
|
980
|
+
selectionImage.setVisible(false);
|
|
1013
981
|
if ((this.ctx.hoverCell && this.ctx.hoverCell.rowIndex === rowIndex) ||
|
|
1014
982
|
['checkbox-disabled', 'checkbox-check'].includes(checkboxName)) {
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
983
|
+
selectionImage.setVisible(true);
|
|
984
|
+
}
|
|
985
|
+
let minY = this.rowIndex;
|
|
986
|
+
let maxY = this.rowIndex;
|
|
987
|
+
const hoverCell = this.ctx.hoverCell;
|
|
988
|
+
const spanInfo = this.getSpanInfo();
|
|
989
|
+
const { yArr } = spanInfo;
|
|
990
|
+
minY = yArr[0];
|
|
991
|
+
maxY = yArr[1];
|
|
992
|
+
if (hoverCell && hoverCell.rowIndex >= minY && hoverCell.rowIndex <= maxY) {
|
|
993
|
+
selectionImage.setVisible(true);
|
|
1021
994
|
}
|
|
1022
995
|
}
|
|
1023
|
-
|
|
1024
|
-
this.drawSelectionImageX = iconX;
|
|
1025
|
-
this.drawSelectionImageY = iconY;
|
|
1026
|
-
this.drawSelectionImageWidth = CHECKBOX_SIZE;
|
|
1027
|
-
this.drawSelectionImageHeight = CHECKBOX_SIZE;
|
|
1028
|
-
this.drawSelectionImageName = checkboxName;
|
|
1029
|
-
this.drawSelectionImageSource = checkboxImage;
|
|
1030
|
-
}
|
|
996
|
+
this.setImage('selection', selectionImage);
|
|
1031
997
|
}
|
|
1032
998
|
updateHoverIcon() {
|
|
1033
999
|
const readonly = this.ctx.database.getReadonly(this.rowKey, this.key);
|
|
@@ -1051,7 +1017,7 @@ export default class Cell extends BaseCell {
|
|
|
1051
1017
|
}
|
|
1052
1018
|
// 永远放在右边
|
|
1053
1019
|
const { hoverCell } = this.ctx;
|
|
1054
|
-
if (this.hoverIconName && !this.ctx.editing && hoverCell) {
|
|
1020
|
+
if (this.hoverIconName && !this.ctx.editing && !this.ctx.dragRowIng && hoverCell) {
|
|
1055
1021
|
let _x = 0;
|
|
1056
1022
|
let _y = 0;
|
|
1057
1023
|
if (hoverCell.rowKey === this.rowKey) {
|
|
@@ -1071,12 +1037,11 @@ export default class Cell extends BaseCell {
|
|
|
1071
1037
|
}
|
|
1072
1038
|
}
|
|
1073
1039
|
const drawImageSource = this.ctx.icons.get(this.hoverIconName);
|
|
1074
|
-
this.
|
|
1075
|
-
this.
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
this.
|
|
1079
|
-
this.drawHoverImageSource = drawImageSource;
|
|
1040
|
+
const hoverImage = new CellImage(this.hoverIconName, _x, _y, CELL_HOVER_ICON_SIZE, CELL_HOVER_ICON_SIZE, drawImageSource);
|
|
1041
|
+
if (this.rowspan === 0 || this.colspan === 0) {
|
|
1042
|
+
hoverImage.setVisible(false);
|
|
1043
|
+
}
|
|
1044
|
+
this.setImage('hover', hoverImage);
|
|
1080
1045
|
}
|
|
1081
1046
|
}
|
|
1082
1047
|
/**
|
|
@@ -1157,14 +1122,12 @@ export default class Cell extends BaseCell {
|
|
|
1157
1122
|
if (this.rowspan === 0 || this.colspan === 0) {
|
|
1158
1123
|
return '';
|
|
1159
1124
|
}
|
|
1160
|
-
//
|
|
1161
|
-
if (this.render && this.renderType === 'default') {
|
|
1125
|
+
// 自定义渲染为 default 且非混合渲染时不显示 canvas 文本
|
|
1126
|
+
if (this.render && this.renderType === 'default' && !this.mixedRender) {
|
|
1162
1127
|
return '';
|
|
1163
1128
|
}
|
|
1164
|
-
|
|
1165
|
-
if (this.type === 'index-selection' &&
|
|
1166
|
-
((this.ctx.hoverCell && this.ctx.hoverCell.rowIndex === this.rowIndex) ||
|
|
1167
|
-
['checkbox-disabled', 'checkbox-check'].includes(this.drawSelectionImageName))) {
|
|
1129
|
+
const selectionImage = this.getImage('selection');
|
|
1130
|
+
if (this.type === 'index-selection' && selectionImage && selectionImage.visible) {
|
|
1168
1131
|
return '';
|
|
1169
1132
|
}
|
|
1170
1133
|
if (this.text === null || this.text === undefined) {
|
|
@@ -1191,7 +1154,6 @@ export default class Cell extends BaseCell {
|
|
|
1191
1154
|
}
|
|
1192
1155
|
return this.row[this.key];
|
|
1193
1156
|
}
|
|
1194
|
-
// cellType === "body"
|
|
1195
1157
|
// formatter优先等级比较高
|
|
1196
1158
|
if (typeof this.formatter === 'function') {
|
|
1197
1159
|
const _text = this.formatter({
|
|
@@ -1392,27 +1354,27 @@ export default class Cell extends BaseCell {
|
|
|
1392
1354
|
lineHeight: CELL_LINE_HEIGHT,
|
|
1393
1355
|
maxLineClamp: this.maxLineClamp,
|
|
1394
1356
|
cacheTextKey,
|
|
1357
|
+
layoutCallback: (layout) => {
|
|
1358
|
+
this.ctx.emit('registerTextLayout', `${this.cellType}-${this.rowIndex}-${this.colIndex}`, layout);
|
|
1359
|
+
},
|
|
1395
1360
|
});
|
|
1396
1361
|
return this.ellipsis;
|
|
1397
1362
|
}
|
|
1398
1363
|
drawImage() {
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
});
|
|
1414
|
-
this.ctx.paint.drawImage(this.drawHoverImageSource, this.drawHoverImageX, this.drawHoverImageY, this.drawHoverImageWidth, this.drawHoverImageHeight);
|
|
1415
|
-
}
|
|
1364
|
+
// 遍历cellImages
|
|
1365
|
+
this.getImages().forEach((image, key) => {
|
|
1366
|
+
if (image.visible && image.source) {
|
|
1367
|
+
if (key === 'hover') {
|
|
1368
|
+
// 绘制hover图标背景
|
|
1369
|
+
const { CELL_HOVER_ICON_BG_COLOR, CELL_HOVER_ICON_BORDER_COLOR } = this.ctx.config;
|
|
1370
|
+
image.drawWrapper(this.ctx, {
|
|
1371
|
+
borderColor: CELL_HOVER_ICON_BORDER_COLOR,
|
|
1372
|
+
fillColor: CELL_HOVER_ICON_BG_COLOR,
|
|
1373
|
+
});
|
|
1374
|
+
}
|
|
1375
|
+
this.ctx.paint.drawImage(image.source, image.x, image.y, image.width, image.height);
|
|
1376
|
+
}
|
|
1377
|
+
});
|
|
1416
1378
|
}
|
|
1417
1379
|
drawSelector() {
|
|
1418
1380
|
if (this.cellType === 'footer') {
|