@visactor/vtable-plugins 1.17.7-alpha.1 → 1.18.0
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/cjs/add-row-column.d.ts +40 -0
- package/cjs/add-row-column.js +217 -0
- package/cjs/add-row-column.js.map +1 -0
- package/cjs/carousel-animation.js +2 -1
- package/cjs/column-series.d.ts +29 -0
- package/cjs/column-series.js +76 -0
- package/cjs/column-series.js.map +1 -0
- package/cjs/excel-edit-cell-keyboard.d.ts +16 -0
- package/cjs/excel-edit-cell-keyboard.js +79 -0
- package/cjs/excel-edit-cell-keyboard.js.map +1 -0
- package/cjs/focus-highlight.d.ts +23 -0
- package/cjs/focus-highlight.js +93 -0
- package/cjs/focus-highlight.js.map +1 -0
- package/cjs/header-highlight.js.map +1 -1
- package/cjs/highlight-header-when-select-cell.d.ts +25 -0
- package/cjs/highlight-header-when-select-cell.js +111 -0
- package/cjs/highlight-header-when-select-cell.js.map +1 -0
- package/cjs/index.d.ts +8 -0
- package/cjs/index.js +5 -1
- package/cjs/index.js.map +1 -1
- package/cjs/invert-highlight.js.map +1 -1
- package/cjs/row-series.d.ts +15 -0
- package/cjs/row-series.js +35 -0
- package/cjs/row-series.js.map +1 -0
- package/cjs/table-carousel-animation.d.ts +53 -0
- package/cjs/table-carousel-animation.js +73 -0
- package/cjs/table-carousel-animation.js.map +1 -0
- package/cjs/types.d.ts +3 -0
- package/cjs/types.js +6 -0
- package/cjs/types.js.map +1 -0
- package/dist/vtable-plugins.js +1042 -23
- package/dist/vtable-plugins.min.js +1 -1
- package/es/add-row-column.d.ts +40 -0
- package/es/add-row-column.js +184 -0
- package/es/add-row-column.js.map +1 -0
- package/es/carousel-animation.js +2 -1
- package/es/column-series.d.ts +29 -0
- package/es/column-series.js +43 -0
- package/es/column-series.js.map +1 -0
- package/es/excel-edit-cell-keyboard.d.ts +16 -0
- package/es/excel-edit-cell-keyboard.js +46 -0
- package/es/excel-edit-cell-keyboard.js.map +1 -0
- package/es/focus-highlight.d.ts +23 -0
- package/es/focus-highlight.js +91 -0
- package/es/focus-highlight.js.map +1 -0
- package/es/header-highlight.js.map +1 -1
- package/es/highlight-header-when-select-cell.d.ts +25 -0
- package/es/highlight-header-when-select-cell.js +103 -0
- package/es/highlight-header-when-select-cell.js.map +1 -0
- package/es/index.d.ts +8 -0
- package/es/index.js +16 -0
- package/es/index.js.map +1 -1
- package/es/invert-highlight.js.map +1 -1
- package/es/row-series.d.ts +15 -0
- package/es/row-series.js +27 -0
- package/es/row-series.js.map +1 -0
- package/es/table-carousel-animation.d.ts +53 -0
- package/es/table-carousel-animation.js +65 -0
- package/es/table-carousel-animation.js.map +1 -0
- package/es/types.d.ts +3 -0
- package/es/types.js +2 -0
- package/es/types.js.map +1 -0
- package/package.json +7 -7
package/dist/vtable-plugins.js
CHANGED
|
@@ -1,10 +1,29 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
|
|
3
|
-
typeof define === 'function' && define.amd ? define(['exports'], factory) :
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.VTable = global.VTable || {}, global.VTable.plugins = {})));
|
|
5
|
-
})(this, (function (exports) { 'use strict';
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@visactor/vtable')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports', '@visactor/vtable'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.VTable = global.VTable || {}, global.VTable.plugins = {}), global.VTable));
|
|
5
|
+
})(this, (function (exports, VTable) { 'use strict';
|
|
6
|
+
|
|
7
|
+
function _interopNamespaceDefault(e) {
|
|
8
|
+
var n = Object.create(null);
|
|
9
|
+
if (e) {
|
|
10
|
+
Object.keys(e).forEach(function (k) {
|
|
11
|
+
if (k !== 'default') {
|
|
12
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
13
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
14
|
+
enumerable: true,
|
|
15
|
+
get: function () { return e[k]; }
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
n.default = e;
|
|
21
|
+
return Object.freeze(n);
|
|
22
|
+
}
|
|
6
23
|
|
|
7
|
-
|
|
24
|
+
var VTable__namespace = /*#__PURE__*/_interopNamespaceDefault(VTable);
|
|
25
|
+
|
|
26
|
+
function isInteger$1(value) {
|
|
8
27
|
return Math.floor(value) === value;
|
|
9
28
|
}
|
|
10
29
|
class CarouselAnimationPlugin {
|
|
@@ -92,11 +111,11 @@
|
|
|
92
111
|
this.row = customRow.distRow;
|
|
93
112
|
animation = customRow.animation ?? true;
|
|
94
113
|
}
|
|
95
|
-
else if (isInteger(this.row) && this.table.scenegraph.proxy.screenTopRow !== this.row) {
|
|
114
|
+
else if (isInteger$1(this.row) && this.table.scenegraph.proxy.screenTopRow !== this.row) {
|
|
96
115
|
this.row = this.table.frozenRowCount;
|
|
97
116
|
animation = false;
|
|
98
117
|
}
|
|
99
|
-
else if (!isInteger(this.row) && this.table.scenegraph.proxy.screenTopRow !== Math.floor(this.row)) {
|
|
118
|
+
else if (!isInteger$1(this.row) && this.table.scenegraph.proxy.screenTopRow !== Math.floor(this.row)) {
|
|
100
119
|
this.row = this.table.frozenRowCount;
|
|
101
120
|
animation = false;
|
|
102
121
|
}
|
|
@@ -120,11 +139,11 @@
|
|
|
120
139
|
this.col = customCol.distCol;
|
|
121
140
|
animation = customCol.animation ?? true;
|
|
122
141
|
}
|
|
123
|
-
else if (isInteger(this.col) && this.table.scenegraph.proxy.screenLeftCol !== this.col) {
|
|
142
|
+
else if (isInteger$1(this.col) && this.table.scenegraph.proxy.screenLeftCol !== this.col) {
|
|
124
143
|
this.col = this.table.frozenColCount;
|
|
125
144
|
animation = false;
|
|
126
145
|
}
|
|
127
|
-
else if (!isInteger(this.col) && this.table.scenegraph.proxy.screenLeftCol !== Math.floor(this.col)) {
|
|
146
|
+
else if (!isInteger$1(this.col) && this.table.scenegraph.proxy.screenLeftCol !== Math.floor(this.col)) {
|
|
128
147
|
this.col = this.table.frozenColCount;
|
|
129
148
|
animation = false;
|
|
130
149
|
}
|
|
@@ -902,6 +921,25 @@
|
|
|
902
921
|
clone() {
|
|
903
922
|
return new OBBBounds(this);
|
|
904
923
|
}
|
|
924
|
+
getRotatedCorners() {
|
|
925
|
+
const originPoint = {
|
|
926
|
+
x: (this.x1 + this.x2) / 2,
|
|
927
|
+
y: (this.y1 + this.y2) / 2
|
|
928
|
+
};
|
|
929
|
+
return [rotatePoint({
|
|
930
|
+
x: this.x1,
|
|
931
|
+
y: this.y1
|
|
932
|
+
}, this.angle, originPoint), rotatePoint({
|
|
933
|
+
x: this.x2,
|
|
934
|
+
y: this.y1
|
|
935
|
+
}, this.angle, originPoint), rotatePoint({
|
|
936
|
+
x: this.x1,
|
|
937
|
+
y: this.y2
|
|
938
|
+
}, this.angle, originPoint), rotatePoint({
|
|
939
|
+
x: this.x2,
|
|
940
|
+
y: this.y2
|
|
941
|
+
}, this.angle, originPoint)];
|
|
942
|
+
}
|
|
905
943
|
}
|
|
906
944
|
|
|
907
945
|
class Matrix {
|
|
@@ -2954,7 +2992,8 @@
|
|
|
2954
2992
|
filter: "",
|
|
2955
2993
|
cursor: null,
|
|
2956
2994
|
html: null,
|
|
2957
|
-
react: null
|
|
2995
|
+
react: null,
|
|
2996
|
+
vue: null
|
|
2958
2997
|
}, DefaultFillStyle), DefaultStrokeStyle), DefaultLayout), DefaultPickStyle);
|
|
2959
2998
|
const DefaultConnectAttribute = {
|
|
2960
2999
|
connectedType: "none",
|
|
@@ -3062,6 +3101,12 @@
|
|
|
3062
3101
|
cornerRadius: 0,
|
|
3063
3102
|
closePath: !0
|
|
3064
3103
|
});
|
|
3104
|
+
const DefaultStarAttribute = Object.assign(Object.assign({}, DefaultAttribute), {
|
|
3105
|
+
width: 100,
|
|
3106
|
+
height: 100,
|
|
3107
|
+
spikes: 5,
|
|
3108
|
+
thickness: .5
|
|
3109
|
+
});
|
|
3065
3110
|
const DefaultRectAttribute = Object.assign(Object.assign({}, DefaultAttribute), {
|
|
3066
3111
|
width: 0,
|
|
3067
3112
|
height: 0,
|
|
@@ -3154,6 +3199,7 @@
|
|
|
3154
3199
|
text: DefaultTextAttribute,
|
|
3155
3200
|
rect: DefaultRectAttribute,
|
|
3156
3201
|
polygon: DefaultPolygonAttribute,
|
|
3202
|
+
star: DefaultStarAttribute,
|
|
3157
3203
|
richtext: DefaultRichTextAttribute,
|
|
3158
3204
|
richtextIcon: DefaultRichTextIconAttribute,
|
|
3159
3205
|
image: DefaultImageAttribute,
|
|
@@ -3172,6 +3218,7 @@
|
|
|
3172
3218
|
text: Object.assign({}, defaultThemeObj.text),
|
|
3173
3219
|
rect: Object.assign({}, defaultThemeObj.rect),
|
|
3174
3220
|
polygon: Object.assign({}, defaultThemeObj.polygon),
|
|
3221
|
+
star: Object.assign({}, defaultThemeObj.star),
|
|
3175
3222
|
richtext: Object.assign({}, defaultThemeObj.richtext),
|
|
3176
3223
|
richtextIcon: Object.assign({}, defaultThemeObj.richtextIcon),
|
|
3177
3224
|
image: Object.assign({}, defaultThemeObj.image),
|
|
@@ -3651,7 +3698,7 @@
|
|
|
3651
3698
|
}
|
|
3652
3699
|
_composedDetailPath(params) {
|
|
3653
3700
|
if (params && params.graphic) {
|
|
3654
|
-
const g =
|
|
3701
|
+
const g = params.graphic;
|
|
3655
3702
|
if (g.stage) {
|
|
3656
3703
|
const path = g.stage.eventSystem.manager.propagationPath(g);
|
|
3657
3704
|
this.detailPath.push(path), this._composedDetailPath(params.params);
|
|
@@ -5237,6 +5284,7 @@
|
|
|
5237
5284
|
genNumberType();
|
|
5238
5285
|
genNumberType();
|
|
5239
5286
|
genNumberType();
|
|
5287
|
+
genNumberType();
|
|
5240
5288
|
const SVG_PARSE_ATTRIBUTE_MAP = {
|
|
5241
5289
|
"stroke-linecap": "lineCap",
|
|
5242
5290
|
"stroke-linejoin": "lineJoin",
|
|
@@ -5487,6 +5535,9 @@
|
|
|
5487
5535
|
y: y
|
|
5488
5536
|
});
|
|
5489
5537
|
}
|
|
5538
|
+
setWidthHeightWithoutTransform(aabbBounds) {
|
|
5539
|
+
this.widthWithoutTransform = aabbBounds.x2 - aabbBounds.x1, this.heightWithoutTransform = aabbBounds.y2 - aabbBounds.y1;
|
|
5540
|
+
}
|
|
5490
5541
|
setAttributes(params) {
|
|
5491
5542
|
let forceUpdateTag = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : !1;
|
|
5492
5543
|
let context = arguments.length > 2 ? arguments[2] : undefined;
|
|
@@ -5775,16 +5826,17 @@
|
|
|
5775
5826
|
const {
|
|
5776
5827
|
scaleX: scaleX,
|
|
5777
5828
|
scaleY: scaleY,
|
|
5778
|
-
angle: angle
|
|
5829
|
+
angle: angle,
|
|
5830
|
+
scaleCenter: scaleCenter
|
|
5779
5831
|
} = this.attribute;
|
|
5780
5832
|
return tempBounds.copy(this._AABBBounds), this.setAttributes({
|
|
5781
|
-
|
|
5782
|
-
|
|
5783
|
-
angle: 0
|
|
5833
|
+
angle: 0,
|
|
5834
|
+
scaleCenter: null
|
|
5784
5835
|
}), params.b = this.AABBBounds.clone(), this._AABBBounds.copy(tempBounds), this.setAttributes({
|
|
5785
5836
|
scaleX: scaleX,
|
|
5786
5837
|
scaleY: scaleY,
|
|
5787
|
-
angle: angle
|
|
5838
|
+
angle: angle,
|
|
5839
|
+
scaleCenter: scaleCenter
|
|
5788
5840
|
}), params.b;
|
|
5789
5841
|
};
|
|
5790
5842
|
if ("string" == typeof anchor[0]) {
|
|
@@ -5812,7 +5864,7 @@
|
|
|
5812
5864
|
} = this.attribute;
|
|
5813
5865
|
let _anchor = [0, 0];
|
|
5814
5866
|
const params = {};
|
|
5815
|
-
if (anchor && (_anchor = this.getAnchor(anchor, params)), !scaleCenter || 1 === scaleX && 1 === scaleY) normalTransform(this._transMatrix, this._transMatrix.reset(), x, y, scaleX, scaleY, angle, anchor && _anchor);else {
|
|
5867
|
+
if (anchor && angle && (_anchor = this.getAnchor(anchor, params)), !scaleCenter || 1 === scaleX && 1 === scaleY) normalTransform(this._transMatrix, this._transMatrix.reset(), x, y, scaleX, scaleY, angle, anchor && _anchor);else {
|
|
5816
5868
|
const m = this._transMatrix;
|
|
5817
5869
|
m.reset(), m.translate(_anchor[0], _anchor[1]), m.rotate(angle), m.translate(-_anchor[0], -_anchor[1]), m.translate(x, y), _anchor = this.getAnchor(scaleCenter, params), application.transformUtil.fromMatrix(m, m).scale(scaleX, scaleY, {
|
|
5818
5870
|
x: _anchor[0],
|
|
@@ -6060,7 +6112,7 @@
|
|
|
6060
6112
|
tb1: tb1,
|
|
6061
6113
|
tb2: tb2
|
|
6062
6114
|
} = application.graphicService.updateTempAABBBounds(aabbBounds);
|
|
6063
|
-
return updateBoundsOfCommonOuterBorder(attribute, rectTheme, tb1), aabbBounds.union(tb1), tb1.setValue(tb2.x1, tb2.y1, tb2.x2, tb2.y2), application.graphicService.transformAABBBounds(attribute, aabbBounds, rectTheme, !1, this), aabbBounds;
|
|
6115
|
+
return updateBoundsOfCommonOuterBorder(attribute, rectTheme, tb1), aabbBounds.union(tb1), tb1.setValue(tb2.x1, tb2.y1, tb2.x2, tb2.y2), this.widthWithoutTransform = aabbBounds.x2 - aabbBounds.x1, this.heightWithoutTransform = aabbBounds.y2 - aabbBounds.y1, application.graphicService.transformAABBBounds(attribute, aabbBounds, rectTheme, !1, this), aabbBounds;
|
|
6064
6116
|
}
|
|
6065
6117
|
needUpdateTags(keys) {
|
|
6066
6118
|
return super.needUpdateTags(keys, RECT_UPDATE_TAG_KEY);
|
|
@@ -6091,8 +6143,9 @@
|
|
|
6091
6143
|
return new Rect(attributes);
|
|
6092
6144
|
}
|
|
6093
6145
|
|
|
6094
|
-
function isSameRange$
|
|
6095
|
-
|
|
6146
|
+
function isSameRange$2(range1, range2) {
|
|
6147
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
6148
|
+
return !range1 && !range2 || !(!range1 || !range2) && (null === (_a = range1.start) || void 0 === _a ? void 0 : _a.col) === (null === (_b = range2.start) || void 0 === _b ? void 0 : _b.col) && (null === (_c = range1.start) || void 0 === _c ? void 0 : _c.row) === (null === (_d = range2.start) || void 0 === _d ? void 0 : _d.row) && (null === (_e = range1.end) || void 0 === _e ? void 0 : _e.col) === (null === (_f = range2.end) || void 0 === _f ? void 0 : _f.col) && (null === (_g = range1.end) || void 0 === _g ? void 0 : _g.row) === (null === (_h = range2.end) || void 0 === _h ? void 0 : _h.row);
|
|
6096
6149
|
}
|
|
6097
6150
|
|
|
6098
6151
|
const isNode = "undefined" == typeof window || void 0 === window.window;
|
|
@@ -6129,7 +6182,7 @@
|
|
|
6129
6182
|
this._opacity = options?.opacity ?? 0.5;
|
|
6130
6183
|
}
|
|
6131
6184
|
setInvertHighlightRange(range) {
|
|
6132
|
-
if (isSameRange$
|
|
6185
|
+
if (isSameRange$2(this.range, range)) {
|
|
6133
6186
|
return;
|
|
6134
6187
|
}
|
|
6135
6188
|
this.range = range;
|
|
@@ -6310,18 +6363,629 @@
|
|
|
6310
6363
|
};
|
|
6311
6364
|
}
|
|
6312
6365
|
}
|
|
6313
|
-
if (this.options?.colHighlight !== false && !isSameRange(this.colHeaderRange, colHeaderRange)) {
|
|
6366
|
+
if (this.options?.colHighlight !== false && !isSameRange$1(this.colHeaderRange, colHeaderRange)) {
|
|
6314
6367
|
this.colHeaderRange && this.table.arrangeCustomCellStyle({ range: this.colHeaderRange }, undefined);
|
|
6315
6368
|
colHeaderRange && this.table.arrangeCustomCellStyle({ range: colHeaderRange }, 'col-highlight');
|
|
6316
6369
|
this.colHeaderRange = colHeaderRange;
|
|
6317
6370
|
}
|
|
6318
|
-
if (this.options?.rowHighlight !== false && !isSameRange(this.rowHeaderRange, rowHeaderRange)) {
|
|
6371
|
+
if (this.options?.rowHighlight !== false && !isSameRange$1(this.rowHeaderRange, rowHeaderRange)) {
|
|
6319
6372
|
this.rowHeaderRange && this.table.arrangeCustomCellStyle({ range: this.rowHeaderRange }, undefined);
|
|
6320
6373
|
rowHeaderRange && this.table.arrangeCustomCellStyle({ range: rowHeaderRange }, 'row-highlight');
|
|
6321
6374
|
this.rowHeaderRange = rowHeaderRange;
|
|
6322
6375
|
}
|
|
6323
6376
|
}
|
|
6324
6377
|
}
|
|
6378
|
+
function isSameRange$1(a, b) {
|
|
6379
|
+
if (a === undefined && b === undefined) {
|
|
6380
|
+
return true;
|
|
6381
|
+
}
|
|
6382
|
+
if (a === undefined || b === undefined) {
|
|
6383
|
+
return false;
|
|
6384
|
+
}
|
|
6385
|
+
return (a.start.col === b.start.col && a.start.row === b.start.row && a.end.col === b.end.col && a.end.row === b.end.row);
|
|
6386
|
+
}
|
|
6387
|
+
|
|
6388
|
+
class AddRowColumnPlugin {
|
|
6389
|
+
id = 'add-row-column';
|
|
6390
|
+
runTime = [
|
|
6391
|
+
VTable__namespace.TABLE_EVENT_TYPE.MOUSEENTER_CELL,
|
|
6392
|
+
VTable__namespace.TABLE_EVENT_TYPE.MOUSELEAVE_CELL,
|
|
6393
|
+
VTable__namespace.TABLE_EVENT_TYPE.MOUSELEAVE_TABLE
|
|
6394
|
+
];
|
|
6395
|
+
pluginOptions;
|
|
6396
|
+
table;
|
|
6397
|
+
hoverCell;
|
|
6398
|
+
hideAllTimeoutId_addColumn;
|
|
6399
|
+
hideAllTimeoutId_addRow;
|
|
6400
|
+
leftDotForAddColumn;
|
|
6401
|
+
rightDotForAddColumn;
|
|
6402
|
+
addIconForAddColumn;
|
|
6403
|
+
addLineForAddColumn;
|
|
6404
|
+
topDotForAddRow;
|
|
6405
|
+
bottomDotForAddRow;
|
|
6406
|
+
addIconForAddRow;
|
|
6407
|
+
addLineForAddRow;
|
|
6408
|
+
constructor(pluginOptions = {
|
|
6409
|
+
addColumnEnable: true,
|
|
6410
|
+
addRowEnable: true
|
|
6411
|
+
}) {
|
|
6412
|
+
this.pluginOptions = pluginOptions;
|
|
6413
|
+
this.pluginOptions.addColumnEnable = this.pluginOptions.addColumnEnable ?? true;
|
|
6414
|
+
this.pluginOptions.addRowEnable = this.pluginOptions.addRowEnable ?? true;
|
|
6415
|
+
if (this.pluginOptions.addColumnEnable) {
|
|
6416
|
+
this.initAddColumnDomElement();
|
|
6417
|
+
this.bindEventForAddColumn();
|
|
6418
|
+
}
|
|
6419
|
+
if (this.pluginOptions.addRowEnable) {
|
|
6420
|
+
this.initAddRowDomElement();
|
|
6421
|
+
this.bindEventForAddRow();
|
|
6422
|
+
}
|
|
6423
|
+
}
|
|
6424
|
+
run(...args) {
|
|
6425
|
+
const eventArgs = args[0];
|
|
6426
|
+
const runTime = args[1];
|
|
6427
|
+
const table = args[2];
|
|
6428
|
+
this.table = table;
|
|
6429
|
+
if (runTime === VTable__namespace.TABLE_EVENT_TYPE.MOUSEENTER_CELL) {
|
|
6430
|
+
clearTimeout(this.hideAllTimeoutId_addColumn);
|
|
6431
|
+
clearTimeout(this.hideAllTimeoutId_addRow);
|
|
6432
|
+
const canvasBounds = table.canvas.getBoundingClientRect();
|
|
6433
|
+
const cell = table.getCellAtRelativePosition(eventArgs.event.clientX - canvasBounds.left, eventArgs.event.clientY - canvasBounds.top);
|
|
6434
|
+
this.hoverCell = cell;
|
|
6435
|
+
const cellRect = table.getCellRelativeRect(cell.col, cell.row);
|
|
6436
|
+
if (this.pluginOptions.addColumnEnable) {
|
|
6437
|
+
const isRowSerierNumberCol = table.isSeriesNumber(cell.col, 0);
|
|
6438
|
+
this.showDotForAddColumn(canvasBounds.top - 6, cellRect.left + canvasBounds.left, cellRect.right + canvasBounds.left, !isRowSerierNumberCol);
|
|
6439
|
+
}
|
|
6440
|
+
if (this.pluginOptions.addRowEnable) {
|
|
6441
|
+
const isHeader = table.isHeader(cell.col, cell.row);
|
|
6442
|
+
this.showDotForAddRow(cellRect.top + canvasBounds.top, canvasBounds.left - 6, cellRect.bottom + canvasBounds.top, !isHeader, !isHeader);
|
|
6443
|
+
}
|
|
6444
|
+
}
|
|
6445
|
+
else if (runTime === VTable__namespace.TABLE_EVENT_TYPE.MOUSELEAVE_CELL) ;
|
|
6446
|
+
else if (runTime === VTable__namespace.TABLE_EVENT_TYPE.MOUSELEAVE_TABLE) {
|
|
6447
|
+
if (this.pluginOptions.addColumnEnable) {
|
|
6448
|
+
this.delayHideAllForAddColumn();
|
|
6449
|
+
}
|
|
6450
|
+
if (this.pluginOptions.addRowEnable) {
|
|
6451
|
+
this.delayHideAllForAddRow();
|
|
6452
|
+
}
|
|
6453
|
+
}
|
|
6454
|
+
}
|
|
6455
|
+
initAddColumnDomElement() {
|
|
6456
|
+
this.leftDotForAddColumn = document.createElement('div');
|
|
6457
|
+
this.leftDotForAddColumn.style.width = '6px';
|
|
6458
|
+
this.leftDotForAddColumn.style.height = '6px';
|
|
6459
|
+
this.leftDotForAddColumn.style.backgroundColor = '#4A90E2';
|
|
6460
|
+
this.leftDotForAddColumn.style.position = 'absolute';
|
|
6461
|
+
this.leftDotForAddColumn.style.cursor = 'pointer';
|
|
6462
|
+
this.leftDotForAddColumn.style.zIndex = '1000';
|
|
6463
|
+
this.leftDotForAddColumn.style.borderRadius = '50%';
|
|
6464
|
+
this.leftDotForAddColumn.style.border = '1px solid white';
|
|
6465
|
+
this.leftDotForAddColumn.style.boxShadow = '0 1px 3px rgba(0,0,0,0.2)';
|
|
6466
|
+
document.body.appendChild(this.leftDotForAddColumn);
|
|
6467
|
+
this.rightDotForAddColumn = document.createElement('div');
|
|
6468
|
+
this.rightDotForAddColumn.style.width = '6px';
|
|
6469
|
+
this.rightDotForAddColumn.style.height = '6px';
|
|
6470
|
+
this.rightDotForAddColumn.style.backgroundColor = '#4A90E2';
|
|
6471
|
+
this.rightDotForAddColumn.style.position = 'absolute';
|
|
6472
|
+
this.rightDotForAddColumn.style.cursor = 'pointer';
|
|
6473
|
+
this.rightDotForAddColumn.style.zIndex = '1000';
|
|
6474
|
+
this.rightDotForAddColumn.style.borderRadius = '50%';
|
|
6475
|
+
this.rightDotForAddColumn.style.border = '1px solid white';
|
|
6476
|
+
this.rightDotForAddColumn.style.boxShadow = '0 1px 3px rgba(0,0,0,0.2)';
|
|
6477
|
+
document.body.appendChild(this.rightDotForAddColumn);
|
|
6478
|
+
this.addIconForAddColumn = document.createElement('div');
|
|
6479
|
+
this.addIconForAddColumn.style.width = '18px';
|
|
6480
|
+
this.addIconForAddColumn.style.height = '18px';
|
|
6481
|
+
this.addIconForAddColumn.style.backgroundColor = '#4A90E2';
|
|
6482
|
+
this.addIconForAddColumn.style.position = 'absolute';
|
|
6483
|
+
this.addIconForAddColumn.style.zIndex = '1001';
|
|
6484
|
+
this.addIconForAddColumn.style.display = 'none';
|
|
6485
|
+
this.addIconForAddColumn.style.borderRadius = '50%';
|
|
6486
|
+
this.addIconForAddColumn.style.boxShadow = '0 2px 5px rgba(0,0,0,0.2)';
|
|
6487
|
+
this.addIconForAddColumn.style.display = 'flex';
|
|
6488
|
+
this.addIconForAddColumn.style.justifyContent = 'center';
|
|
6489
|
+
this.addIconForAddColumn.style.alignItems = 'center';
|
|
6490
|
+
this.addIconForAddColumn.style.border = '1px solid white';
|
|
6491
|
+
document.body.appendChild(this.addIconForAddColumn);
|
|
6492
|
+
const addIconText = document.createElement('div');
|
|
6493
|
+
addIconText.textContent = '+';
|
|
6494
|
+
addIconText.style.color = 'white';
|
|
6495
|
+
addIconText.style.fontSize = '18px';
|
|
6496
|
+
addIconText.style.fontWeight = 'bold';
|
|
6497
|
+
addIconText.style.lineHeight = '15px';
|
|
6498
|
+
addIconText.style.userSelect = 'none';
|
|
6499
|
+
addIconText.style.cursor = 'pointer';
|
|
6500
|
+
addIconText.style.verticalAlign = 'top';
|
|
6501
|
+
addIconText.style.textAlign = 'center';
|
|
6502
|
+
this.addIconForAddColumn.appendChild(addIconText);
|
|
6503
|
+
this.addLineForAddColumn = document.createElement('div');
|
|
6504
|
+
this.addLineForAddColumn.style.width = '2px';
|
|
6505
|
+
this.addLineForAddColumn.style.height = '10px';
|
|
6506
|
+
this.addLineForAddColumn.style.backgroundColor = '#4A90E2';
|
|
6507
|
+
this.addLineForAddColumn.style.position = 'absolute';
|
|
6508
|
+
this.addLineForAddColumn.style.zIndex = '1001';
|
|
6509
|
+
this.addLineForAddColumn.style.display = 'none';
|
|
6510
|
+
document.body.appendChild(this.addLineForAddColumn);
|
|
6511
|
+
}
|
|
6512
|
+
bindEventForAddColumn() {
|
|
6513
|
+
this.leftDotForAddColumn.addEventListener('mouseenter', () => {
|
|
6514
|
+
clearTimeout(this.hideAllTimeoutId_addColumn);
|
|
6515
|
+
this.addIconForAddColumn.style.display = 'block';
|
|
6516
|
+
const dotWidth = this.leftDotForAddColumn.offsetWidth;
|
|
6517
|
+
const dotHeight = this.leftDotForAddColumn.offsetHeight;
|
|
6518
|
+
this.showAddIconForAddColumn(this.leftDotForAddColumn.offsetLeft + dotWidth / 2, this.leftDotForAddColumn.offsetTop + dotHeight / 2, true);
|
|
6519
|
+
this.showSplitLineForAddColumn(this.leftDotForAddColumn.offsetLeft + dotWidth / 2 - 1, this.leftDotForAddColumn.offsetTop + dotHeight / 2 + 2, this.table.getDrawRange().height);
|
|
6520
|
+
});
|
|
6521
|
+
this.rightDotForAddColumn.addEventListener('mouseenter', () => {
|
|
6522
|
+
clearTimeout(this.hideAllTimeoutId_addColumn);
|
|
6523
|
+
this.addIconForAddColumn.style.display = 'block';
|
|
6524
|
+
const dotWidth = this.rightDotForAddColumn.offsetWidth;
|
|
6525
|
+
const dotHeight = this.rightDotForAddColumn.offsetHeight;
|
|
6526
|
+
this.showAddIconForAddColumn(this.rightDotForAddColumn.offsetLeft + dotWidth / 2, this.rightDotForAddColumn.offsetTop + dotHeight / 2, false);
|
|
6527
|
+
this.showSplitLineForAddColumn(this.rightDotForAddColumn.offsetLeft + dotWidth / 2 - 1, this.rightDotForAddColumn.offsetTop + dotHeight / 2 + 2, this.table.getDrawRange().height);
|
|
6528
|
+
});
|
|
6529
|
+
this.addIconForAddColumn.addEventListener('mouseleave', () => {
|
|
6530
|
+
this.addIconForAddColumn.style.display = 'none';
|
|
6531
|
+
this.addLineForAddColumn.style.display = 'none';
|
|
6532
|
+
this.delayHideAllForAddColumn();
|
|
6533
|
+
});
|
|
6534
|
+
this.addIconForAddColumn.addEventListener('click', (e) => {
|
|
6535
|
+
const isLeft = this.addIconForAddColumn.dataset.addIconType === 'left';
|
|
6536
|
+
const columns = this.table.options.columns;
|
|
6537
|
+
const col = this.hoverCell.col;
|
|
6538
|
+
const addColIndex = isLeft ? col : col + 1;
|
|
6539
|
+
if (this.pluginOptions.addColumnCallback) {
|
|
6540
|
+
this.pluginOptions.addColumnCallback(addColIndex);
|
|
6541
|
+
}
|
|
6542
|
+
else {
|
|
6543
|
+
columns.splice(addColIndex, 0, {
|
|
6544
|
+
field: ``,
|
|
6545
|
+
title: `New Column ${col}`,
|
|
6546
|
+
width: 100
|
|
6547
|
+
});
|
|
6548
|
+
this.table.updateColumns(columns);
|
|
6549
|
+
}
|
|
6550
|
+
this.delayHideAllForAddColumn(0);
|
|
6551
|
+
});
|
|
6552
|
+
}
|
|
6553
|
+
showDotForAddColumn(top, left, right, isShowLeft = true, isShowRight = true) {
|
|
6554
|
+
const dotWidth = this.leftDotForAddColumn.offsetWidth;
|
|
6555
|
+
const dotHeight = this.leftDotForAddColumn.offsetHeight;
|
|
6556
|
+
this.leftDotForAddColumn.style.left = `${left - dotWidth / 2}px`;
|
|
6557
|
+
this.leftDotForAddColumn.style.top = `${top - dotHeight / 2}px`;
|
|
6558
|
+
this.rightDotForAddColumn.style.left = `${right - dotWidth / 2}px`;
|
|
6559
|
+
this.rightDotForAddColumn.style.top = `${top - dotHeight / 2}px`;
|
|
6560
|
+
this.leftDotForAddColumn.style.display = isShowLeft ? 'block' : 'none';
|
|
6561
|
+
this.rightDotForAddColumn.style.display = isShowRight ? 'block' : 'none';
|
|
6562
|
+
}
|
|
6563
|
+
showAddIconForAddColumn(left, top, isLeft) {
|
|
6564
|
+
const iconWidth = this.addIconForAddColumn.offsetWidth;
|
|
6565
|
+
const iconHeight = this.addIconForAddColumn.offsetHeight;
|
|
6566
|
+
const dotHeight = this.leftDotForAddColumn.offsetHeight;
|
|
6567
|
+
this.addIconForAddColumn.style.left = `${left - iconWidth / 2}px`;
|
|
6568
|
+
this.addIconForAddColumn.style.top = `${top - iconHeight / 2 - dotHeight / 2}px`;
|
|
6569
|
+
if (isLeft) {
|
|
6570
|
+
this.addIconForAddColumn.dataset.addIconType = 'left';
|
|
6571
|
+
}
|
|
6572
|
+
else {
|
|
6573
|
+
this.addIconForAddColumn.dataset.addIconType = 'right';
|
|
6574
|
+
}
|
|
6575
|
+
}
|
|
6576
|
+
showSplitLineForAddColumn(left, top, height) {
|
|
6577
|
+
this.addLineForAddColumn.style.left = `${left}px`;
|
|
6578
|
+
this.addLineForAddColumn.style.top = `${top}px`;
|
|
6579
|
+
this.addLineForAddColumn.style.height = `${height}px`;
|
|
6580
|
+
this.addLineForAddColumn.style.display = 'block';
|
|
6581
|
+
}
|
|
6582
|
+
delayHideAllForAddColumn(delay = 1000) {
|
|
6583
|
+
this.hideAllTimeoutId_addColumn = setTimeout(() => {
|
|
6584
|
+
this.addIconForAddColumn.style.display = 'none';
|
|
6585
|
+
this.addLineForAddColumn.style.display = 'none';
|
|
6586
|
+
this.leftDotForAddColumn.style.display = 'none';
|
|
6587
|
+
this.rightDotForAddColumn.style.display = 'none';
|
|
6588
|
+
}, delay);
|
|
6589
|
+
}
|
|
6590
|
+
initAddRowDomElement() {
|
|
6591
|
+
this.topDotForAddRow = document.createElement('div');
|
|
6592
|
+
this.topDotForAddRow.style.width = '6px';
|
|
6593
|
+
this.topDotForAddRow.style.height = '6px';
|
|
6594
|
+
this.topDotForAddRow.style.backgroundColor = '#4A90E2';
|
|
6595
|
+
this.topDotForAddRow.style.position = 'absolute';
|
|
6596
|
+
this.topDotForAddRow.style.cursor = 'pointer';
|
|
6597
|
+
this.topDotForAddRow.style.zIndex = '1000';
|
|
6598
|
+
this.topDotForAddRow.style.borderRadius = '50%';
|
|
6599
|
+
this.topDotForAddRow.style.border = '1px solid white';
|
|
6600
|
+
this.topDotForAddRow.style.boxShadow = '0 1px 3px rgba(0,0,0,0.2)';
|
|
6601
|
+
document.body.appendChild(this.topDotForAddRow);
|
|
6602
|
+
this.bottomDotForAddRow = document.createElement('div');
|
|
6603
|
+
this.bottomDotForAddRow.style.width = '6px';
|
|
6604
|
+
this.bottomDotForAddRow.style.height = '6px';
|
|
6605
|
+
this.bottomDotForAddRow.style.backgroundColor = '#4A90E2';
|
|
6606
|
+
this.bottomDotForAddRow.style.position = 'absolute';
|
|
6607
|
+
this.bottomDotForAddRow.style.cursor = 'pointer';
|
|
6608
|
+
this.bottomDotForAddRow.style.zIndex = '1000';
|
|
6609
|
+
this.bottomDotForAddRow.style.borderRadius = '50%';
|
|
6610
|
+
this.bottomDotForAddRow.style.border = '1px solid white';
|
|
6611
|
+
this.bottomDotForAddRow.style.boxShadow = '0 1px 3px rgba(0,0,0,0.2)';
|
|
6612
|
+
document.body.appendChild(this.bottomDotForAddRow);
|
|
6613
|
+
this.addIconForAddRow = document.createElement('div');
|
|
6614
|
+
this.addIconForAddRow.style.width = '18px';
|
|
6615
|
+
this.addIconForAddRow.style.height = '18px';
|
|
6616
|
+
this.addIconForAddRow.style.backgroundColor = '#4A90E2';
|
|
6617
|
+
this.addIconForAddRow.style.position = 'absolute';
|
|
6618
|
+
this.addIconForAddRow.style.zIndex = '1001';
|
|
6619
|
+
this.addIconForAddRow.style.display = 'none';
|
|
6620
|
+
this.addIconForAddRow.style.borderRadius = '50%';
|
|
6621
|
+
this.addIconForAddRow.style.boxShadow = '0 2px 5px rgba(0,0,0,0.2)';
|
|
6622
|
+
this.addIconForAddRow.style.display = 'flex';
|
|
6623
|
+
this.addIconForAddRow.style.justifyContent = 'center';
|
|
6624
|
+
this.addIconForAddRow.style.alignItems = 'center';
|
|
6625
|
+
this.addIconForAddRow.style.border = '1px solid white';
|
|
6626
|
+
document.body.appendChild(this.addIconForAddRow);
|
|
6627
|
+
const addIconText = document.createElement('div');
|
|
6628
|
+
addIconText.textContent = '+';
|
|
6629
|
+
addIconText.style.color = 'white';
|
|
6630
|
+
addIconText.style.fontSize = '18px';
|
|
6631
|
+
addIconText.style.fontWeight = 'bold';
|
|
6632
|
+
addIconText.style.lineHeight = '15px';
|
|
6633
|
+
addIconText.style.userSelect = 'none';
|
|
6634
|
+
addIconText.style.cursor = 'pointer';
|
|
6635
|
+
addIconText.style.verticalAlign = 'top';
|
|
6636
|
+
addIconText.style.textAlign = 'center';
|
|
6637
|
+
this.addIconForAddRow.appendChild(addIconText);
|
|
6638
|
+
this.addLineForAddRow = document.createElement('div');
|
|
6639
|
+
this.addLineForAddRow.style.width = '10px';
|
|
6640
|
+
this.addLineForAddRow.style.height = '2px';
|
|
6641
|
+
this.addLineForAddRow.style.backgroundColor = '#4A90E2';
|
|
6642
|
+
this.addLineForAddRow.style.position = 'absolute';
|
|
6643
|
+
this.addLineForAddRow.style.zIndex = '1001';
|
|
6644
|
+
this.addLineForAddRow.style.display = 'none';
|
|
6645
|
+
document.body.appendChild(this.addLineForAddRow);
|
|
6646
|
+
}
|
|
6647
|
+
bindEventForAddRow() {
|
|
6648
|
+
this.topDotForAddRow.addEventListener('mouseenter', () => {
|
|
6649
|
+
clearTimeout(this.hideAllTimeoutId_addRow);
|
|
6650
|
+
this.addIconForAddRow.style.display = 'block';
|
|
6651
|
+
const dotWidth = this.topDotForAddRow.offsetWidth;
|
|
6652
|
+
const dotHeight = this.topDotForAddRow.offsetHeight;
|
|
6653
|
+
this.showAddIconForAddRow(this.topDotForAddRow.offsetLeft + dotWidth / 2, this.topDotForAddRow.offsetTop + dotHeight / 2, true);
|
|
6654
|
+
this.showSplitLineForAddRow(this.topDotForAddRow.offsetLeft + dotWidth + 2, this.topDotForAddRow.offsetTop + dotHeight / 2 - 1, this.table.getDrawRange().width);
|
|
6655
|
+
});
|
|
6656
|
+
this.bottomDotForAddRow.addEventListener('mouseenter', () => {
|
|
6657
|
+
clearTimeout(this.hideAllTimeoutId_addRow);
|
|
6658
|
+
this.addIconForAddRow.style.display = 'block';
|
|
6659
|
+
const dotWidth = this.bottomDotForAddRow.offsetWidth;
|
|
6660
|
+
const dotHeight = this.bottomDotForAddRow.offsetHeight;
|
|
6661
|
+
this.showAddIconForAddRow(this.bottomDotForAddRow.offsetLeft + dotWidth / 2, this.bottomDotForAddRow.offsetTop + dotHeight / 2, false);
|
|
6662
|
+
this.showSplitLineForAddRow(this.bottomDotForAddRow.offsetLeft + dotWidth + 2, this.bottomDotForAddRow.offsetTop + dotHeight / 2 - 1, this.table.getDrawRange().height);
|
|
6663
|
+
});
|
|
6664
|
+
this.addIconForAddRow.addEventListener('mouseleave', () => {
|
|
6665
|
+
this.addIconForAddRow.style.display = 'none';
|
|
6666
|
+
this.addLineForAddRow.style.display = 'none';
|
|
6667
|
+
this.delayHideAllForAddRow();
|
|
6668
|
+
});
|
|
6669
|
+
this.addIconForAddRow.addEventListener('click', (e) => {
|
|
6670
|
+
const isTop = this.addIconForAddRow.dataset.addIconType === 'top';
|
|
6671
|
+
const row = this.hoverCell.row;
|
|
6672
|
+
const addRowIndex = isTop ? row : row + 1;
|
|
6673
|
+
if (this.pluginOptions.addRowCallback) {
|
|
6674
|
+
this.pluginOptions.addRowCallback(addRowIndex);
|
|
6675
|
+
}
|
|
6676
|
+
else {
|
|
6677
|
+
const recordIndex = this.table.getRecordIndexByCell(0, addRowIndex);
|
|
6678
|
+
this.table.addRecord({}, recordIndex);
|
|
6679
|
+
}
|
|
6680
|
+
this.delayHideAllForAddRow(0);
|
|
6681
|
+
});
|
|
6682
|
+
}
|
|
6683
|
+
showDotForAddRow(top, left, bottom, isShowTop = true, isShowBottom = true) {
|
|
6684
|
+
const dotWidth = this.topDotForAddRow.offsetWidth;
|
|
6685
|
+
const dotHeight = this.topDotForAddRow.offsetHeight;
|
|
6686
|
+
this.topDotForAddRow.style.left = `${left - dotWidth / 2}px`;
|
|
6687
|
+
this.topDotForAddRow.style.top = `${top - dotHeight / 2}px`;
|
|
6688
|
+
this.bottomDotForAddRow.style.left = `${left - dotWidth / 2}px`;
|
|
6689
|
+
this.bottomDotForAddRow.style.top = `${bottom - dotHeight / 2}px`;
|
|
6690
|
+
this.topDotForAddRow.style.display = isShowTop ? 'block' : 'none';
|
|
6691
|
+
this.bottomDotForAddRow.style.display = isShowBottom ? 'block' : 'none';
|
|
6692
|
+
}
|
|
6693
|
+
showAddIconForAddRow(left, top, isTop) {
|
|
6694
|
+
const iconWidth = this.addIconForAddRow.offsetWidth;
|
|
6695
|
+
const iconHeight = this.addIconForAddRow.offsetHeight;
|
|
6696
|
+
const dotWidth = this.topDotForAddRow.offsetWidth;
|
|
6697
|
+
this.addIconForAddRow.style.left = `${left - iconWidth / 2 - dotWidth / 2}px`;
|
|
6698
|
+
this.addIconForAddRow.style.top = `${top - iconHeight / 2}px`;
|
|
6699
|
+
if (isTop) {
|
|
6700
|
+
this.addIconForAddRow.dataset.addIconType = 'top';
|
|
6701
|
+
}
|
|
6702
|
+
else {
|
|
6703
|
+
this.addIconForAddRow.dataset.addIconType = 'bottom';
|
|
6704
|
+
}
|
|
6705
|
+
}
|
|
6706
|
+
showSplitLineForAddRow(left, top, width) {
|
|
6707
|
+
this.addLineForAddRow.style.left = `${left}px`;
|
|
6708
|
+
this.addLineForAddRow.style.top = `${top}px`;
|
|
6709
|
+
this.addLineForAddRow.style.width = `${width}px`;
|
|
6710
|
+
this.addLineForAddRow.style.display = 'block';
|
|
6711
|
+
}
|
|
6712
|
+
delayHideAllForAddRow(delay = 1000) {
|
|
6713
|
+
this.hideAllTimeoutId_addRow = setTimeout(() => {
|
|
6714
|
+
this.addIconForAddRow.style.display = 'none';
|
|
6715
|
+
this.addLineForAddRow.style.display = 'none';
|
|
6716
|
+
this.topDotForAddRow.style.display = 'none';
|
|
6717
|
+
this.bottomDotForAddRow.style.display = 'none';
|
|
6718
|
+
}, delay);
|
|
6719
|
+
}
|
|
6720
|
+
release() {
|
|
6721
|
+
this.leftDotForAddColumn.remove();
|
|
6722
|
+
this.rightDotForAddColumn.remove();
|
|
6723
|
+
this.addIconForAddColumn.remove();
|
|
6724
|
+
this.addLineForAddColumn.remove();
|
|
6725
|
+
this.topDotForAddRow.remove();
|
|
6726
|
+
this.bottomDotForAddRow.remove();
|
|
6727
|
+
this.addIconForAddRow.remove();
|
|
6728
|
+
this.addLineForAddRow.remove();
|
|
6729
|
+
}
|
|
6730
|
+
}
|
|
6731
|
+
|
|
6732
|
+
class ColumnSeriesPlugin {
|
|
6733
|
+
id = 'column-series';
|
|
6734
|
+
runTime = [VTable__namespace.TABLE_EVENT_TYPE.BEFORE_INIT, VTable__namespace.TABLE_EVENT_TYPE.BEFORE_KEYDOWN];
|
|
6735
|
+
pluginOptions;
|
|
6736
|
+
table;
|
|
6737
|
+
columns = [];
|
|
6738
|
+
constructor(pluginOptions) {
|
|
6739
|
+
this.pluginOptions = Object.assign({ columnCount: 100, autoExtendColumn: true }, pluginOptions);
|
|
6740
|
+
}
|
|
6741
|
+
run(...args) {
|
|
6742
|
+
if (args[1] === VTable__namespace.TABLE_EVENT_TYPE.BEFORE_INIT) {
|
|
6743
|
+
const eventArgs = args[0];
|
|
6744
|
+
const table = args[2];
|
|
6745
|
+
this.table = table;
|
|
6746
|
+
const options = eventArgs.options;
|
|
6747
|
+
this.columns = this.generateColumns(this.pluginOptions.columnCount);
|
|
6748
|
+
options.columns = this.columns;
|
|
6749
|
+
}
|
|
6750
|
+
else if (args[1] === VTable__namespace.TABLE_EVENT_TYPE.BEFORE_KEYDOWN) {
|
|
6751
|
+
const eventArgs = args[0];
|
|
6752
|
+
const e = eventArgs.event;
|
|
6753
|
+
if (e.key === 'ArrowRight') {
|
|
6754
|
+
if (this.pluginOptions.autoExtendColumn &&
|
|
6755
|
+
this.table.stateManager.select.cellPos.col === this.table.colCount - 1) {
|
|
6756
|
+
this.table.addColumn(this.generateColumn(this.table.colCount - 1));
|
|
6757
|
+
}
|
|
6758
|
+
}
|
|
6759
|
+
}
|
|
6760
|
+
}
|
|
6761
|
+
generateColumns(columnCount) {
|
|
6762
|
+
const columnFields = [];
|
|
6763
|
+
for (let i = 0; i < columnCount; i++) {
|
|
6764
|
+
columnFields.push(this.generateColumn(i));
|
|
6765
|
+
}
|
|
6766
|
+
return columnFields;
|
|
6767
|
+
}
|
|
6768
|
+
generateColumn(index) {
|
|
6769
|
+
const column = {
|
|
6770
|
+
title: this.pluginOptions.generateColumnTitle
|
|
6771
|
+
? this.pluginOptions.generateColumnTitle(index)
|
|
6772
|
+
: this.generateColumnField(index)
|
|
6773
|
+
};
|
|
6774
|
+
return column;
|
|
6775
|
+
}
|
|
6776
|
+
generateColumnField(index) {
|
|
6777
|
+
if (index < 26) {
|
|
6778
|
+
return String.fromCharCode(65 + index);
|
|
6779
|
+
}
|
|
6780
|
+
const title = [];
|
|
6781
|
+
index++;
|
|
6782
|
+
while (index > 0) {
|
|
6783
|
+
index--;
|
|
6784
|
+
title.unshift(String.fromCharCode(65 + (index % 26)));
|
|
6785
|
+
index = Math.floor(index / 26);
|
|
6786
|
+
}
|
|
6787
|
+
return title.join('');
|
|
6788
|
+
}
|
|
6789
|
+
resetColumnCount(columnCount) {
|
|
6790
|
+
this.pluginOptions.columnCount = columnCount;
|
|
6791
|
+
this.columns = this.generateColumns(columnCount);
|
|
6792
|
+
this.table.updateColumns(this.columns);
|
|
6793
|
+
}
|
|
6794
|
+
}
|
|
6795
|
+
|
|
6796
|
+
class RowSeriesPlugin {
|
|
6797
|
+
id = 'row-series';
|
|
6798
|
+
runTime = [VTable.TABLE_EVENT_TYPE.BEFORE_INIT, VTable.TABLE_EVENT_TYPE.BEFORE_KEYDOWN];
|
|
6799
|
+
pluginOptions;
|
|
6800
|
+
table;
|
|
6801
|
+
constructor(pluginOptions) {
|
|
6802
|
+
this.pluginOptions = Object.assign({ rowCount: 100, autoExtendRow: true }, pluginOptions);
|
|
6803
|
+
}
|
|
6804
|
+
run(...args) {
|
|
6805
|
+
if (args[1] === VTable.TABLE_EVENT_TYPE.BEFORE_INIT) {
|
|
6806
|
+
const eventArgs = args[0];
|
|
6807
|
+
const table = args[2];
|
|
6808
|
+
this.table = table;
|
|
6809
|
+
const options = eventArgs.options;
|
|
6810
|
+
const records = options.records ?? [];
|
|
6811
|
+
for (let i = records.length; i < this.pluginOptions.rowCount; i++) {
|
|
6812
|
+
records.push(this.pluginOptions.fillRowRecord ? this.pluginOptions.fillRowRecord(i) : {});
|
|
6813
|
+
}
|
|
6814
|
+
options.records = records;
|
|
6815
|
+
if (this.pluginOptions.rowSeriesNumber) {
|
|
6816
|
+
options.rowSeriesNumber = this.pluginOptions.rowSeriesNumber;
|
|
6817
|
+
if (!this.pluginOptions.rowSeriesNumber.width) {
|
|
6818
|
+
options.rowSeriesNumber.width = 'auto';
|
|
6819
|
+
}
|
|
6820
|
+
}
|
|
6821
|
+
else if (!options.rowSeriesNumber) {
|
|
6822
|
+
options.rowSeriesNumber = {
|
|
6823
|
+
width: 'auto'
|
|
6824
|
+
};
|
|
6825
|
+
}
|
|
6826
|
+
}
|
|
6827
|
+
else if (args[1] === VTable.TABLE_EVENT_TYPE.BEFORE_KEYDOWN) {
|
|
6828
|
+
const eventArgs = args[0];
|
|
6829
|
+
const e = eventArgs.event;
|
|
6830
|
+
if (e.key === 'ArrowDown') {
|
|
6831
|
+
if (this.pluginOptions.autoExtendRow &&
|
|
6832
|
+
this.table.stateManager.select.cellPos.row === this.table.rowCount - 1) {
|
|
6833
|
+
this.table.addRecord(this.pluginOptions.fillRowRecord
|
|
6834
|
+
? this.pluginOptions.fillRowRecord(this.table.rowCount - this.table.columnHeaderLevelCount)
|
|
6835
|
+
: {});
|
|
6836
|
+
}
|
|
6837
|
+
}
|
|
6838
|
+
}
|
|
6839
|
+
}
|
|
6840
|
+
}
|
|
6841
|
+
|
|
6842
|
+
class HighlightHeaderWhenSelectCellPlugin {
|
|
6843
|
+
id = 'highlight-header-when-select-cell';
|
|
6844
|
+
runTime = [
|
|
6845
|
+
VTable.TABLE_EVENT_TYPE.INITIALIZED,
|
|
6846
|
+
VTable.TABLE_EVENT_TYPE.SELECTED_CLEAR,
|
|
6847
|
+
VTable.TABLE_EVENT_TYPE.SELECTED_CELL,
|
|
6848
|
+
VTable.TABLE_EVENT_TYPE.MOUSEMOVE_TABLE
|
|
6849
|
+
];
|
|
6850
|
+
table;
|
|
6851
|
+
pluginOptions;
|
|
6852
|
+
colHeaderRanges = [];
|
|
6853
|
+
rowHeaderRanges = [];
|
|
6854
|
+
constructor(pluginOptions) {
|
|
6855
|
+
this.pluginOptions = pluginOptions;
|
|
6856
|
+
}
|
|
6857
|
+
run(...args) {
|
|
6858
|
+
const runTime = args[1];
|
|
6859
|
+
const table = args[2];
|
|
6860
|
+
this.table = table;
|
|
6861
|
+
if (runTime === VTable.TABLE_EVENT_TYPE.SELECTED_CLEAR) {
|
|
6862
|
+
this.clearHighlight();
|
|
6863
|
+
}
|
|
6864
|
+
else if (runTime === VTable.TABLE_EVENT_TYPE.SELECTED_CELL) {
|
|
6865
|
+
this.updateHighlight();
|
|
6866
|
+
}
|
|
6867
|
+
else if (runTime === VTable.TABLE_EVENT_TYPE.MOUSEMOVE_TABLE) {
|
|
6868
|
+
this.updateHighlight();
|
|
6869
|
+
}
|
|
6870
|
+
else if (runTime === VTable.TABLE_EVENT_TYPE.INITIALIZED) {
|
|
6871
|
+
this.registerStyle();
|
|
6872
|
+
}
|
|
6873
|
+
}
|
|
6874
|
+
registerStyle() {
|
|
6875
|
+
this.table.registerCustomCellStyle('col-highlight', {
|
|
6876
|
+
bgColor: this.pluginOptions?.colHighlightBGColor ?? '#82b2f5',
|
|
6877
|
+
color: this.pluginOptions?.colHighlightColor ?? '#FFF'
|
|
6878
|
+
});
|
|
6879
|
+
this.table.registerCustomCellStyle('row-highlight', {
|
|
6880
|
+
bgColor: this.pluginOptions?.rowHighlightBGColor ?? '#82b2f5',
|
|
6881
|
+
color: this.pluginOptions?.rowHighlightColor ?? 'yellow'
|
|
6882
|
+
});
|
|
6883
|
+
}
|
|
6884
|
+
clearHighlight() {
|
|
6885
|
+
if (this.colHeaderRanges) {
|
|
6886
|
+
this.colHeaderRanges.forEach(range => {
|
|
6887
|
+
this.table.arrangeCustomCellStyle({ range }, undefined);
|
|
6888
|
+
});
|
|
6889
|
+
}
|
|
6890
|
+
if (this.rowHeaderRanges) {
|
|
6891
|
+
this.rowHeaderRanges.forEach(range => {
|
|
6892
|
+
this.table.arrangeCustomCellStyle({ range }, undefined);
|
|
6893
|
+
});
|
|
6894
|
+
}
|
|
6895
|
+
this.colHeaderRanges = [];
|
|
6896
|
+
this.rowHeaderRanges = [];
|
|
6897
|
+
}
|
|
6898
|
+
updateHighlight() {
|
|
6899
|
+
if (this.pluginOptions?.colHighlight === false && this.pluginOptions?.rowHighlight === false) {
|
|
6900
|
+
return;
|
|
6901
|
+
}
|
|
6902
|
+
const selectRanges = this.table.getSelectedCellRanges();
|
|
6903
|
+
if (selectRanges.length < 2) {
|
|
6904
|
+
this.clearHighlight();
|
|
6905
|
+
}
|
|
6906
|
+
for (let i = 0; i < selectRanges.length; i++) {
|
|
6907
|
+
const selectRange = selectRanges[i];
|
|
6908
|
+
const rowSelectRange = [selectRange.start.row, selectRange.end.row];
|
|
6909
|
+
rowSelectRange.sort((a, b) => a - b);
|
|
6910
|
+
const colSelectRange = [selectRange.start.col, selectRange.end.col];
|
|
6911
|
+
colSelectRange.sort((a, b) => a - b);
|
|
6912
|
+
let colHeaderRange;
|
|
6913
|
+
let rowHeaderRange;
|
|
6914
|
+
if (this.table.isPivotTable()) {
|
|
6915
|
+
colHeaderRange = {
|
|
6916
|
+
start: {
|
|
6917
|
+
col: colSelectRange[0],
|
|
6918
|
+
row: 0
|
|
6919
|
+
},
|
|
6920
|
+
end: {
|
|
6921
|
+
col: colSelectRange[1],
|
|
6922
|
+
row: this.table.columnHeaderLevelCount - 1
|
|
6923
|
+
}
|
|
6924
|
+
};
|
|
6925
|
+
rowHeaderRange = {
|
|
6926
|
+
start: {
|
|
6927
|
+
col: 0,
|
|
6928
|
+
row: rowSelectRange[0]
|
|
6929
|
+
},
|
|
6930
|
+
end: {
|
|
6931
|
+
col: this.table.rowHeaderLevelCount - 1,
|
|
6932
|
+
row: rowSelectRange[1]
|
|
6933
|
+
}
|
|
6934
|
+
};
|
|
6935
|
+
}
|
|
6936
|
+
else if (this.table.internalProps.transpose) {
|
|
6937
|
+
rowHeaderRange = {
|
|
6938
|
+
start: {
|
|
6939
|
+
col: 0,
|
|
6940
|
+
row: rowSelectRange[0]
|
|
6941
|
+
},
|
|
6942
|
+
end: {
|
|
6943
|
+
col: this.table.rowHeaderLevelCount - 1,
|
|
6944
|
+
row: rowSelectRange[1]
|
|
6945
|
+
}
|
|
6946
|
+
};
|
|
6947
|
+
}
|
|
6948
|
+
else {
|
|
6949
|
+
colHeaderRange = {
|
|
6950
|
+
start: {
|
|
6951
|
+
col: colSelectRange[0],
|
|
6952
|
+
row: 0
|
|
6953
|
+
},
|
|
6954
|
+
end: {
|
|
6955
|
+
col: colSelectRange[1],
|
|
6956
|
+
row: this.table.columnHeaderLevelCount - 1
|
|
6957
|
+
}
|
|
6958
|
+
};
|
|
6959
|
+
if (this.table.internalProps.rowSeriesNumber) {
|
|
6960
|
+
rowHeaderRange = {
|
|
6961
|
+
start: {
|
|
6962
|
+
col: 0,
|
|
6963
|
+
row: rowSelectRange[0]
|
|
6964
|
+
},
|
|
6965
|
+
end: {
|
|
6966
|
+
col: 0,
|
|
6967
|
+
row: rowSelectRange[1]
|
|
6968
|
+
}
|
|
6969
|
+
};
|
|
6970
|
+
}
|
|
6971
|
+
}
|
|
6972
|
+
if (this.pluginOptions?.colHighlight !== false &&
|
|
6973
|
+
!this.colHeaderRanges.find(range => isSameRange(range, colHeaderRange))) {
|
|
6974
|
+
colHeaderRange && this.table.arrangeCustomCellStyle({ range: colHeaderRange }, 'col-highlight');
|
|
6975
|
+
this.colHeaderRanges.push(colHeaderRange);
|
|
6976
|
+
}
|
|
6977
|
+
if (this.pluginOptions?.rowHighlight !== false &&
|
|
6978
|
+
!this.rowHeaderRanges.find(range => isSameRange(range, rowHeaderRange))) {
|
|
6979
|
+
rowHeaderRange && this.table.arrangeCustomCellStyle({ range: rowHeaderRange }, 'row-highlight');
|
|
6980
|
+
this.rowHeaderRanges.push(rowHeaderRange);
|
|
6981
|
+
}
|
|
6982
|
+
}
|
|
6983
|
+
}
|
|
6984
|
+
release() {
|
|
6985
|
+
this.rowHeaderRanges = [];
|
|
6986
|
+
this.colHeaderRanges = [];
|
|
6987
|
+
}
|
|
6988
|
+
}
|
|
6325
6989
|
function isSameRange(a, b) {
|
|
6326
6990
|
if (a === undefined && b === undefined) {
|
|
6327
6991
|
return true;
|
|
@@ -6332,8 +6996,363 @@
|
|
|
6332
6996
|
return (a.start.col === b.start.col && a.start.row === b.start.row && a.end.col === b.end.col && a.end.row === b.end.row);
|
|
6333
6997
|
}
|
|
6334
6998
|
|
|
6999
|
+
class ExcelEditCellKeyboardPlugin {
|
|
7000
|
+
id = 'excel-edit-cell-keyboard';
|
|
7001
|
+
runTime = [VTable__namespace.TABLE_EVENT_TYPE.INITIALIZED];
|
|
7002
|
+
table;
|
|
7003
|
+
pluginOptions;
|
|
7004
|
+
constructor(pluginOptions) {
|
|
7005
|
+
this.pluginOptions = pluginOptions;
|
|
7006
|
+
this.bindEvent();
|
|
7007
|
+
}
|
|
7008
|
+
run(...args) {
|
|
7009
|
+
const table = args[2];
|
|
7010
|
+
this.table = table;
|
|
7011
|
+
}
|
|
7012
|
+
bindEvent() {
|
|
7013
|
+
document.addEventListener('keydown', this.handleKeyDown.bind(this), true);
|
|
7014
|
+
}
|
|
7015
|
+
handleKeyDown(event) {
|
|
7016
|
+
if (this.table.editorManager) {
|
|
7017
|
+
if (this.table.editorManager.beginTriggerEditCellMode === 'keydown') {
|
|
7018
|
+
if (this.table.editorManager.editingEditor && this.isExcelShortcutKey(event)) {
|
|
7019
|
+
const { col, row } = this.table.editorManager.editCell;
|
|
7020
|
+
this.table.editorManager.completeEdit();
|
|
7021
|
+
this.table.getElement().focus();
|
|
7022
|
+
if (!event.shiftKey && !event.ctrlKey && !event.metaKey) {
|
|
7023
|
+
if (event.key === 'Enter') {
|
|
7024
|
+
this.table.selectCell(col, row + 1);
|
|
7025
|
+
}
|
|
7026
|
+
else if (event.key === 'Tab') {
|
|
7027
|
+
this.table.selectCell(col + 1, row);
|
|
7028
|
+
}
|
|
7029
|
+
else if (event.key === 'ArrowLeft') {
|
|
7030
|
+
this.table.selectCell(col - 1, row);
|
|
7031
|
+
}
|
|
7032
|
+
else if (event.key === 'ArrowRight') {
|
|
7033
|
+
this.table.selectCell(col + 1, row);
|
|
7034
|
+
}
|
|
7035
|
+
else if (event.key === 'ArrowDown') {
|
|
7036
|
+
this.table.selectCell(col, row + 1);
|
|
7037
|
+
}
|
|
7038
|
+
else if (event.key === 'ArrowUp') {
|
|
7039
|
+
this.table.selectCell(col, row - 1);
|
|
7040
|
+
}
|
|
7041
|
+
event.stopPropagation();
|
|
7042
|
+
event.preventDefault();
|
|
7043
|
+
}
|
|
7044
|
+
}
|
|
7045
|
+
}
|
|
7046
|
+
else {
|
|
7047
|
+
const { col, row } = this.table.stateManager.select.cellPos;
|
|
7048
|
+
if (this.table.editorManager.editingEditor && (event.key === 'Enter' || event.key === 'Tab')) {
|
|
7049
|
+
this.table.editorManager.completeEdit();
|
|
7050
|
+
this.table.getElement().focus();
|
|
7051
|
+
if (event.key === 'Enter') {
|
|
7052
|
+
this.table.selectCell(col, row + 1);
|
|
7053
|
+
}
|
|
7054
|
+
else if (event.key === 'Tab') {
|
|
7055
|
+
this.table.selectCell(col + 1, row);
|
|
7056
|
+
}
|
|
7057
|
+
event.stopPropagation();
|
|
7058
|
+
event.preventDefault();
|
|
7059
|
+
}
|
|
7060
|
+
else if (event.key === 'Delete') {
|
|
7061
|
+
const selectCells = this.table.getSelectedCellInfos();
|
|
7062
|
+
if (selectCells?.length > 0) {
|
|
7063
|
+
deleteSelectRange(selectCells, this.table);
|
|
7064
|
+
}
|
|
7065
|
+
event.stopPropagation();
|
|
7066
|
+
event.preventDefault();
|
|
7067
|
+
}
|
|
7068
|
+
}
|
|
7069
|
+
}
|
|
7070
|
+
}
|
|
7071
|
+
isExcelShortcutKey(event) {
|
|
7072
|
+
return (event.key === 'Enter' ||
|
|
7073
|
+
event.key === 'Tab' ||
|
|
7074
|
+
event.key === 'ArrowLeft' ||
|
|
7075
|
+
event.key === 'ArrowRight' ||
|
|
7076
|
+
event.key === 'ArrowDown' ||
|
|
7077
|
+
event.key === 'ArrowUp');
|
|
7078
|
+
}
|
|
7079
|
+
release() {
|
|
7080
|
+
document.removeEventListener('keydown', this.handleKeyDown, true);
|
|
7081
|
+
}
|
|
7082
|
+
}
|
|
7083
|
+
function deleteSelectRange(selectCells, tableInstance) {
|
|
7084
|
+
for (let i = 0; i < selectCells.length; i++) {
|
|
7085
|
+
for (let j = 0; j < selectCells[i].length; j++) {
|
|
7086
|
+
tableInstance.changeCellValue(selectCells[i][j].col, selectCells[i][j].row, '');
|
|
7087
|
+
}
|
|
7088
|
+
}
|
|
7089
|
+
}
|
|
7090
|
+
|
|
7091
|
+
class FocusHighlightPlugin {
|
|
7092
|
+
id = 'focus-highlight';
|
|
7093
|
+
name = 'Focus Highlight';
|
|
7094
|
+
runTime = [VTable.TABLE_EVENT_TYPE.INITIALIZED, VTable.TABLE_EVENT_TYPE.SELECTED_CELL, VTable.TABLE_EVENT_TYPE.SELECTED_CLEAR];
|
|
7095
|
+
table;
|
|
7096
|
+
range;
|
|
7097
|
+
pluginOptions;
|
|
7098
|
+
constructor(options = {
|
|
7099
|
+
fill: '#000',
|
|
7100
|
+
opacity: 0.5,
|
|
7101
|
+
highlightRange: undefined
|
|
7102
|
+
}) {
|
|
7103
|
+
this.pluginOptions = Object.assign({
|
|
7104
|
+
fill: '#000',
|
|
7105
|
+
opacity: 0.5
|
|
7106
|
+
}, options);
|
|
7107
|
+
}
|
|
7108
|
+
run(...args) {
|
|
7109
|
+
if (!this.table) {
|
|
7110
|
+
this.table = args[2];
|
|
7111
|
+
}
|
|
7112
|
+
if (args[1] === VTable.TABLE_EVENT_TYPE.INITIALIZED) {
|
|
7113
|
+
this.pluginOptions.highlightRange && this.setFocusHighlightRange(this.pluginOptions.highlightRange);
|
|
7114
|
+
}
|
|
7115
|
+
else if (args[1] === VTable.TABLE_EVENT_TYPE.SELECTED_CELL) {
|
|
7116
|
+
const posCell = this.table.stateManager.select.cellPos;
|
|
7117
|
+
if (this.table.isHeader(posCell.col, posCell.row)) {
|
|
7118
|
+
this.setFocusHighlightRange(undefined);
|
|
7119
|
+
}
|
|
7120
|
+
else {
|
|
7121
|
+
const ranges = this.table.stateManager.select.ranges;
|
|
7122
|
+
const min_col = 0;
|
|
7123
|
+
const max_col = this.table.colCount - 1;
|
|
7124
|
+
const min_row = Math.min(ranges[0].start.row, ranges[0].end.row);
|
|
7125
|
+
const max_row = Math.max(ranges[0].start.row, ranges[0].end.row);
|
|
7126
|
+
this.setFocusHighlightRange({
|
|
7127
|
+
start: { col: min_col, row: min_row },
|
|
7128
|
+
end: { col: max_col, row: max_row }
|
|
7129
|
+
});
|
|
7130
|
+
}
|
|
7131
|
+
}
|
|
7132
|
+
else if (args[1] === VTable.TABLE_EVENT_TYPE.SELECTED_CLEAR) {
|
|
7133
|
+
this.setFocusHighlightRange(undefined);
|
|
7134
|
+
}
|
|
7135
|
+
}
|
|
7136
|
+
setFocusHighlightRange(range) {
|
|
7137
|
+
let cellRange;
|
|
7138
|
+
if (range && 'start' in range && 'end' in range) {
|
|
7139
|
+
cellRange = range;
|
|
7140
|
+
}
|
|
7141
|
+
else if (range) {
|
|
7142
|
+
cellRange = {
|
|
7143
|
+
start: range,
|
|
7144
|
+
end: range
|
|
7145
|
+
};
|
|
7146
|
+
}
|
|
7147
|
+
if (isSameRange$2(this.range, cellRange)) {
|
|
7148
|
+
return;
|
|
7149
|
+
}
|
|
7150
|
+
this.range = cellRange;
|
|
7151
|
+
if (!range) {
|
|
7152
|
+
this.deleteAllCellGroupShadow();
|
|
7153
|
+
}
|
|
7154
|
+
else {
|
|
7155
|
+
this.updateCellGroupShadow();
|
|
7156
|
+
}
|
|
7157
|
+
this.table.scenegraph.updateNextFrame();
|
|
7158
|
+
}
|
|
7159
|
+
deleteAllCellGroupShadow() {
|
|
7160
|
+
if (!this.table.isPivotTable()) {
|
|
7161
|
+
this.updateCellGroupShadowInContainer(this.table.scenegraph.rowHeaderGroup);
|
|
7162
|
+
this.updateCellGroupShadowInContainer(this.table.scenegraph.leftBottomCornerGroup);
|
|
7163
|
+
}
|
|
7164
|
+
this.updateCellGroupShadowInContainer(this.table.scenegraph.bodyGroup);
|
|
7165
|
+
this.updateCellGroupShadowInContainer(this.table.scenegraph.rightFrozenGroup);
|
|
7166
|
+
this.updateCellGroupShadowInContainer(this.table.scenegraph.bottomFrozenGroup);
|
|
7167
|
+
this.updateCellGroupShadowInContainer(this.table.scenegraph.rightBottomCornerGroup);
|
|
7168
|
+
}
|
|
7169
|
+
updateCellGroupShadow() {
|
|
7170
|
+
if (!this.table.isPivotTable()) {
|
|
7171
|
+
this.updateCellGroupShadowInContainer(this.table.scenegraph.rowHeaderGroup, this.range);
|
|
7172
|
+
this.updateCellGroupShadowInContainer(this.table.scenegraph.leftBottomCornerGroup, this.range);
|
|
7173
|
+
}
|
|
7174
|
+
this.updateCellGroupShadowInContainer(this.table.scenegraph.bodyGroup, this.range);
|
|
7175
|
+
this.updateCellGroupShadowInContainer(this.table.scenegraph.rightFrozenGroup, this.range);
|
|
7176
|
+
this.updateCellGroupShadowInContainer(this.table.scenegraph.bottomFrozenGroup), this.range;
|
|
7177
|
+
this.updateCellGroupShadowInContainer(this.table.scenegraph.rightBottomCornerGroup, this.range);
|
|
7178
|
+
}
|
|
7179
|
+
updateCellGroupShadowInContainer(container, range) {
|
|
7180
|
+
let cellRange;
|
|
7181
|
+
if (range && 'start' in range && 'end' in range) {
|
|
7182
|
+
cellRange = range;
|
|
7183
|
+
}
|
|
7184
|
+
else if (range) {
|
|
7185
|
+
cellRange = {
|
|
7186
|
+
start: range,
|
|
7187
|
+
end: range
|
|
7188
|
+
};
|
|
7189
|
+
}
|
|
7190
|
+
container.forEachChildrenSkipChild((item) => {
|
|
7191
|
+
const column = item;
|
|
7192
|
+
if (column.role === 'column') {
|
|
7193
|
+
column.forEachChildrenSkipChild((item) => {
|
|
7194
|
+
const cell = item;
|
|
7195
|
+
if (cell.role !== 'cell') {
|
|
7196
|
+
return;
|
|
7197
|
+
}
|
|
7198
|
+
cell.attachShadow(cell.shadowRoot);
|
|
7199
|
+
const shadowGroup = cell.shadowRoot;
|
|
7200
|
+
if (!cellRange) {
|
|
7201
|
+
shadowGroup.removeAllChild();
|
|
7202
|
+
}
|
|
7203
|
+
else if (cellInRange(cellRange, cell.col, cell.row)) {
|
|
7204
|
+
shadowGroup.removeAllChild();
|
|
7205
|
+
}
|
|
7206
|
+
else if (!shadowGroup.firstChild) {
|
|
7207
|
+
const shadowRect = createRect({
|
|
7208
|
+
x: 0,
|
|
7209
|
+
y: 0,
|
|
7210
|
+
width: cell.attribute.width,
|
|
7211
|
+
height: cell.attribute.height,
|
|
7212
|
+
fill: this.pluginOptions.fill,
|
|
7213
|
+
opacity: this.pluginOptions.opacity
|
|
7214
|
+
});
|
|
7215
|
+
shadowRect.name = 'shadow-rect';
|
|
7216
|
+
shadowGroup.appendChild(shadowRect);
|
|
7217
|
+
}
|
|
7218
|
+
});
|
|
7219
|
+
}
|
|
7220
|
+
});
|
|
7221
|
+
}
|
|
7222
|
+
}
|
|
7223
|
+
|
|
7224
|
+
function isInteger(value) {
|
|
7225
|
+
return Math.floor(value) === value;
|
|
7226
|
+
}
|
|
7227
|
+
class TableCarouselAnimationPlugin {
|
|
7228
|
+
id = 'table-carousel-animation';
|
|
7229
|
+
runTime = [VTable.TABLE_EVENT_TYPE.INITIALIZED];
|
|
7230
|
+
table;
|
|
7231
|
+
rowCount;
|
|
7232
|
+
colCount;
|
|
7233
|
+
animationDuration;
|
|
7234
|
+
animationDelay;
|
|
7235
|
+
animationEasing;
|
|
7236
|
+
playing;
|
|
7237
|
+
row;
|
|
7238
|
+
col;
|
|
7239
|
+
willUpdateRow = false;
|
|
7240
|
+
willUpdateCol = false;
|
|
7241
|
+
autoPlay;
|
|
7242
|
+
autoPlayDelay;
|
|
7243
|
+
customDistRowFunction;
|
|
7244
|
+
customDistColFunction;
|
|
7245
|
+
constructor(options = {}) {
|
|
7246
|
+
this.rowCount = options?.rowCount ?? undefined;
|
|
7247
|
+
this.colCount = options?.colCount ?? undefined;
|
|
7248
|
+
this.animationDuration = options?.animationDuration ?? 500;
|
|
7249
|
+
this.animationDelay = options?.animationDelay ?? 1000;
|
|
7250
|
+
this.animationEasing = options?.animationEasing ?? 'linear';
|
|
7251
|
+
this.autoPlay = options?.autoPlay ?? false;
|
|
7252
|
+
this.autoPlayDelay = options?.autoPlayDelay ?? 0;
|
|
7253
|
+
this.customDistColFunction = options.customDistColFunction;
|
|
7254
|
+
this.customDistRowFunction = options.customDistRowFunction;
|
|
7255
|
+
}
|
|
7256
|
+
run(...args) {
|
|
7257
|
+
if (!this.table) {
|
|
7258
|
+
this.table = args[2];
|
|
7259
|
+
}
|
|
7260
|
+
this.reset();
|
|
7261
|
+
if (this.autoPlay) {
|
|
7262
|
+
setTimeout(() => {
|
|
7263
|
+
this.play();
|
|
7264
|
+
}, this.autoPlayDelay);
|
|
7265
|
+
}
|
|
7266
|
+
}
|
|
7267
|
+
reset() {
|
|
7268
|
+
this.playing = false;
|
|
7269
|
+
this.row = this.table.frozenRowCount;
|
|
7270
|
+
this.col = this.table.frozenColCount;
|
|
7271
|
+
}
|
|
7272
|
+
play() {
|
|
7273
|
+
if (!this.table) {
|
|
7274
|
+
throw new Error('table is not initialized');
|
|
7275
|
+
}
|
|
7276
|
+
this.playing = true;
|
|
7277
|
+
if (this.rowCount && !this.willUpdateRow) {
|
|
7278
|
+
this.updateRow();
|
|
7279
|
+
}
|
|
7280
|
+
else if (this.colCount && !this.willUpdateCol) {
|
|
7281
|
+
this.updateCol();
|
|
7282
|
+
}
|
|
7283
|
+
}
|
|
7284
|
+
pause() {
|
|
7285
|
+
this.playing = false;
|
|
7286
|
+
}
|
|
7287
|
+
updateRow() {
|
|
7288
|
+
if (!this.playing || this.table.isReleased) {
|
|
7289
|
+
return;
|
|
7290
|
+
}
|
|
7291
|
+
let animation = true;
|
|
7292
|
+
const customRow = this.customDistRowFunction && this.customDistRowFunction(this.row, this.table);
|
|
7293
|
+
if (customRow) {
|
|
7294
|
+
this.row = customRow.distRow;
|
|
7295
|
+
animation = customRow.animation ?? true;
|
|
7296
|
+
}
|
|
7297
|
+
else if (isInteger(this.row) && this.table.scenegraph.proxy.screenTopRow !== this.row) {
|
|
7298
|
+
this.row = this.table.frozenRowCount;
|
|
7299
|
+
animation = false;
|
|
7300
|
+
}
|
|
7301
|
+
else if (!isInteger(this.row) && this.table.scenegraph.proxy.screenTopRow !== Math.floor(this.row)) {
|
|
7302
|
+
this.row = this.table.frozenRowCount;
|
|
7303
|
+
animation = false;
|
|
7304
|
+
}
|
|
7305
|
+
else {
|
|
7306
|
+
this.row += this.rowCount;
|
|
7307
|
+
}
|
|
7308
|
+
this.table.scrollToRow(this.row, animation ? { duration: this.animationDuration, easing: this.animationEasing } : undefined);
|
|
7309
|
+
this.willUpdateRow = true;
|
|
7310
|
+
setTimeout(() => {
|
|
7311
|
+
this.willUpdateRow = false;
|
|
7312
|
+
this.updateRow();
|
|
7313
|
+
}, this.animationDuration + this.animationDelay);
|
|
7314
|
+
}
|
|
7315
|
+
updateCol() {
|
|
7316
|
+
if (!this.playing || this.table.isReleased) {
|
|
7317
|
+
return;
|
|
7318
|
+
}
|
|
7319
|
+
let animation = true;
|
|
7320
|
+
const customCol = this.customDistColFunction && this.customDistColFunction(this.col, this.table);
|
|
7321
|
+
if (customCol) {
|
|
7322
|
+
this.col = customCol.distCol;
|
|
7323
|
+
animation = customCol.animation ?? true;
|
|
7324
|
+
}
|
|
7325
|
+
else if (isInteger(this.col) && this.table.scenegraph.proxy.screenLeftCol !== this.col) {
|
|
7326
|
+
this.col = this.table.frozenColCount;
|
|
7327
|
+
animation = false;
|
|
7328
|
+
}
|
|
7329
|
+
else if (!isInteger(this.col) && this.table.scenegraph.proxy.screenLeftCol !== Math.floor(this.col)) {
|
|
7330
|
+
this.col = this.table.frozenColCount;
|
|
7331
|
+
animation = false;
|
|
7332
|
+
}
|
|
7333
|
+
else {
|
|
7334
|
+
this.col += this.colCount;
|
|
7335
|
+
}
|
|
7336
|
+
this.table.scrollToCol(this.col, animation ? { duration: this.animationDuration, easing: this.animationEasing } : undefined);
|
|
7337
|
+
this.willUpdateCol = true;
|
|
7338
|
+
setTimeout(() => {
|
|
7339
|
+
this.willUpdateCol = false;
|
|
7340
|
+
this.updateCol();
|
|
7341
|
+
}, this.animationDuration + this.animationDelay);
|
|
7342
|
+
}
|
|
7343
|
+
release() {
|
|
7344
|
+
}
|
|
7345
|
+
}
|
|
7346
|
+
|
|
7347
|
+
exports.AddRowColumnPlugin = AddRowColumnPlugin;
|
|
6335
7348
|
exports.CarouselAnimationPlugin = CarouselAnimationPlugin;
|
|
7349
|
+
exports.ColumnSeriesPlugin = ColumnSeriesPlugin;
|
|
7350
|
+
exports.ExcelEditCellKeyboardPlugin = ExcelEditCellKeyboardPlugin;
|
|
7351
|
+
exports.FocusHighlightPlugin = FocusHighlightPlugin;
|
|
6336
7352
|
exports.HeaderHighlightPlugin = HeaderHighlightPlugin;
|
|
7353
|
+
exports.HighlightHeaderWhenSelectCellPlugin = HighlightHeaderWhenSelectCellPlugin;
|
|
6337
7354
|
exports.InvertHighlightPlugin = InvertHighlightPlugin;
|
|
7355
|
+
exports.RowSeriesPlugin = RowSeriesPlugin;
|
|
7356
|
+
exports.TableCarouselAnimationPlugin = TableCarouselAnimationPlugin;
|
|
6338
7357
|
|
|
6339
7358
|
}));
|