@visactor/vtable-calendar 1.26.0 → 1.26.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.
@@ -1789,6 +1789,20 @@
1789
1789
  function crossProduct(dir1, dir2) {
1790
1790
  return dir1[0] * dir2[1] - dir1[1] * dir2[0];
1791
1791
  }
1792
+ function fixPrecision$1(num, precision = 10) {
1793
+ return Math.round(num * precision) / precision;
1794
+ }
1795
+ function getDecimalPlaces(n) {
1796
+ const dStr = n.toString().split(/[eE]/),
1797
+ s = (dStr[0].split(".")[1] || "").length - (+dStr[1] || 0);
1798
+ return s > 0 ? s : 0;
1799
+ }
1800
+ function precisionAdd(a, b) {
1801
+ return fixPrecision$1(a + b, 10 ** Math.max(getDecimalPlaces(a), getDecimalPlaces(b)));
1802
+ }
1803
+ function precisionSub(a, b) {
1804
+ return fixPrecision$1(a - b, 10 ** Math.max(getDecimalPlaces(a), getDecimalPlaces(b)));
1805
+ }
1792
1806
 
1793
1807
  class Point {
1794
1808
  constructor(x = 0, y = 0, x1, y1) {
@@ -33714,42 +33728,54 @@
33714
33728
  if (record) if (this.isRecord && this.records && (record.isAggregator ? this.records.push(...record.records) : this.records.push(record)), record.isAggregator && this.children) {
33715
33729
  this.children.push(record);
33716
33730
  const value = record.value();
33717
- this.sum += null != value ? value : 0, this.needSplitPositiveAndNegativeForSum && (value > 0 ? this.positiveSum += value : value < 0 && (this.nagetiveSum += value));
33731
+ this.sum = precisionAdd(this.sum, null != value ? value : 0), this.needSplitPositiveAndNegativeForSum && (value > 0 ? this.positiveSum = precisionAdd(this.positiveSum, value) : value < 0 && (this.nagetiveSum = precisionAdd(this.nagetiveSum, value)));
33718
33732
  } else if (this.field && !isNaN(parseFloat(record[this.field]))) {
33719
33733
  const value = parseFloat(record[this.field]);
33720
- this.sum += value, this.needSplitPositiveAndNegativeForSum && (value > 0 ? this.positiveSum += value : value < 0 && (this.nagetiveSum += value));
33734
+ this.sum = precisionAdd(this.sum, value), this.needSplitPositiveAndNegativeForSum && (value > 0 ? this.positiveSum = precisionAdd(this.positiveSum, value) : value < 0 && (this.nagetiveSum = precisionAdd(this.nagetiveSum, value)));
33721
33735
  }
33722
33736
  this.clearCacheValue();
33723
33737
  }
33724
33738
  deleteRecord(record) {
33725
- if (record) if (this.isRecord && this.records && (this.records = this.records.filter(item => item !== record)), record.isAggregator && this.children) {
33726
- this.children = this.children.filter(item => item !== record);
33727
- const value = record.value();
33728
- this.sum -= null != value ? value : 0, this.needSplitPositiveAndNegativeForSum && (value > 0 ? this.positiveSum -= value : value < 0 && (this.nagetiveSum -= value));
33729
- } else if (this.field && !isNaN(parseFloat(record[this.field]))) {
33730
- const value = parseFloat(record[this.field]);
33731
- this.sum -= value, this.needSplitPositiveAndNegativeForSum && (value > 0 ? this.positiveSum -= value : value < 0 && (this.nagetiveSum -= value));
33739
+ if (record) {
33740
+ if (this.isRecord && this.records) {
33741
+ const index = this.records.indexOf(record);
33742
+ -1 !== index && this.records.splice(index, 1);
33743
+ }
33744
+ if (record.isAggregator && this.children) {
33745
+ const index = this.children.indexOf(record);
33746
+ -1 !== index && this.children.splice(index, 1);
33747
+ const value = record.value();
33748
+ this.sum = precisionSub(this.sum, null != value ? value : 0), this.needSplitPositiveAndNegativeForSum && (value > 0 ? this.positiveSum = precisionSub(this.positiveSum, value) : value < 0 && (this.nagetiveSum = precisionSub(this.nagetiveSum, value)));
33749
+ } else if (this.field && !isNaN(parseFloat(record[this.field]))) {
33750
+ const value = parseFloat(record[this.field]);
33751
+ this.sum = precisionSub(this.sum, value), this.needSplitPositiveAndNegativeForSum && (value > 0 ? this.positiveSum = precisionSub(this.positiveSum, value) : value < 0 && (this.nagetiveSum = precisionSub(this.nagetiveSum, value)));
33752
+ }
33732
33753
  }
33733
33754
  this.clearCacheValue();
33734
33755
  }
33735
33756
  updateRecord(oldRecord, newRecord) {
33736
33757
  if (oldRecord && newRecord) {
33737
- if (this.isRecord && this.records && (this.records = this.records.map(item => item === oldRecord ? newRecord : item)), oldRecord.isAggregator && this.children) {
33738
- const oldValue = oldRecord.value();
33739
- this.children = this.children.filter(item => item !== oldRecord);
33758
+ if (this.isRecord && this.records) {
33759
+ const index = this.records.indexOf(oldRecord);
33760
+ -1 !== index && (this.records[index] = newRecord);
33761
+ }
33762
+ if (oldRecord.isAggregator && this.children) {
33763
+ const oldValue = oldRecord.value(),
33764
+ index = this.children.indexOf(oldRecord);
33765
+ -1 !== index && (this.children[index] = newRecord);
33740
33766
  const newValue = newRecord.value();
33741
- this.children.push(newRecord), this.sum += newValue - oldValue, this.needSplitPositiveAndNegativeForSum && (oldValue > 0 ? this.positiveSum -= oldValue : oldValue < 0 && (this.nagetiveSum -= oldValue), newValue > 0 ? this.positiveSum += newValue : newValue < 0 && (this.nagetiveSum += newValue));
33767
+ this.sum = precisionAdd(this.sum, precisionSub(newValue, oldValue)), this.needSplitPositiveAndNegativeForSum && (oldValue > 0 ? this.positiveSum = precisionSub(this.positiveSum, oldValue) : oldValue < 0 && (this.nagetiveSum = precisionSub(this.nagetiveSum, oldValue)), newValue > 0 ? this.positiveSum = precisionAdd(this.positiveSum, newValue) : newValue < 0 && (this.nagetiveSum = precisionAdd(this.nagetiveSum, newValue)));
33742
33768
  } else if (this.field && !isNaN(parseFloat(oldRecord[this.field]))) {
33743
33769
  const oldValue = parseFloat(oldRecord[this.field]),
33744
33770
  newValue = parseFloat(newRecord[this.field]);
33745
- this.sum += newValue - oldValue, this.needSplitPositiveAndNegativeForSum && (oldValue > 0 ? this.positiveSum -= oldValue : oldValue < 0 && (this.nagetiveSum -= oldValue), newValue > 0 ? this.positiveSum += newValue : newValue < 0 && (this.nagetiveSum += newValue));
33771
+ this.sum = precisionAdd(this.sum, precisionSub(newValue, oldValue)), this.needSplitPositiveAndNegativeForSum && (oldValue > 0 ? this.positiveSum = precisionSub(this.positiveSum, oldValue) : oldValue < 0 && (this.nagetiveSum = precisionSub(this.nagetiveSum, oldValue)), newValue > 0 ? this.positiveSum = precisionAdd(this.positiveSum, newValue) : newValue < 0 && (this.nagetiveSum = precisionAdd(this.nagetiveSum, newValue)));
33746
33772
  }
33747
33773
  this.clearCacheValue();
33748
33774
  }
33749
33775
  }
33750
33776
  value() {
33751
- var _a, _b;
33752
- return null !== (_a = this.changedValue) && void 0 !== _a ? _a : (null === (_b = this.records) || void 0 === _b ? void 0 : _b.length) >= 1 ? this.sum : void 0;
33777
+ var _a;
33778
+ return null !== (_a = this.changedValue) && void 0 !== _a ? _a : this.records && this.records.length >= 1 || !1 === this.isRecord ? this.sum : void 0;
33753
33779
  }
33754
33780
  positiveValue() {
33755
33781
  return this.positiveSum;
@@ -33765,16 +33791,16 @@
33765
33791
  const child = this.children[i];
33766
33792
  if (child.isAggregator) {
33767
33793
  const value = child.value();
33768
- this.sum += null != value ? value : 0, this.needSplitPositiveAndNegativeForSum && (value > 0 ? this.positiveSum += value : value < 0 && (this.nagetiveSum += value));
33794
+ this.sum = precisionAdd(this.sum, null != value ? value : 0), this.needSplitPositiveAndNegativeForSum && (value > 0 ? this.positiveSum = precisionAdd(this.positiveSum, value) : value < 0 && (this.nagetiveSum = precisionAdd(this.nagetiveSum, value)));
33769
33795
  }
33770
33796
  } else if (this.records) for (let i = 0; i < this.records.length; i++) {
33771
33797
  const record = this.records[i];
33772
33798
  if (record.isAggregator) {
33773
33799
  const value = record.value();
33774
- this.sum += null != value ? value : 0, this.needSplitPositiveAndNegativeForSum && (value > 0 ? this.positiveSum += value : value < 0 && (this.nagetiveSum += value));
33800
+ this.sum = precisionAdd(this.sum, null != value ? value : 0), this.needSplitPositiveAndNegativeForSum && (value > 0 ? this.positiveSum = precisionAdd(this.positiveSum, value) : value < 0 && (this.nagetiveSum = precisionAdd(this.nagetiveSum, value)));
33775
33801
  } else if (this.field && !isNaN(parseFloat(record[this.field]))) {
33776
33802
  const value = parseFloat(record[this.field]);
33777
- this.sum += value, this.needSplitPositiveAndNegativeForSum && (value > 0 ? this.positiveSum += value : value < 0 && (this.nagetiveSum += value));
33803
+ this.sum = precisionAdd(this.sum, value), this.needSplitPositiveAndNegativeForSum && (value > 0 ? this.positiveSum = precisionAdd(this.positiveSum, value) : value < 0 && (this.nagetiveSum = precisionAdd(this.nagetiveSum, value)));
33778
33804
  }
33779
33805
  }
33780
33806
  }
@@ -33817,17 +33843,43 @@
33817
33843
  super(...arguments), this.type = AggregationType.AVG, this.sum = 0, this.count = 0;
33818
33844
  }
33819
33845
  push(record) {
33820
- record && (this.isRecord && this.records && (record.isAggregator ? this.records.push(...record.records) : this.records.push(record)), record.isAggregator && record.type === AggregationType.AVG ? (this.children && this.children.push(record), this.sum += record.sum, this.count += record.count) : this.field && !isNaN(parseFloat(record[this.field])) && (this.sum += parseFloat(record[this.field]), this.count++)), this.clearCacheValue();
33846
+ record && (this.isRecord && this.records && (record.isAggregator ? this.records.push(...record.records) : this.records.push(record)), record.isAggregator && record.type === AggregationType.AVG ? (this.children && this.children.push(record), this.sum = precisionAdd(this.sum, record.sum), this.count += record.count) : this.field && !isNaN(parseFloat(record[this.field])) && (this.sum = precisionAdd(this.sum, parseFloat(record[this.field])), this.count++)), this.clearCacheValue();
33821
33847
  }
33822
33848
  deleteRecord(record) {
33823
- record && (this.isRecord && this.records && (this.records = this.records.filter(item => item !== record)), record.isAggregator && record.type === AggregationType.AVG ? (this.children && (this.children = this.children.filter(item => item !== record)), this.sum -= record.sum, this.count -= record.count) : this.field && !isNaN(parseFloat(record[this.field])) && (this.sum -= parseFloat(record[this.field]), this.count--)), this.clearCacheValue();
33849
+ if (record) {
33850
+ if (this.isRecord && this.records) {
33851
+ const index = this.records.indexOf(record);
33852
+ -1 !== index && this.records.splice(index, 1);
33853
+ }
33854
+ if (record.isAggregator && record.type === AggregationType.AVG) {
33855
+ if (this.children) {
33856
+ const index = this.children.indexOf(record);
33857
+ -1 !== index && this.children.splice(index, 1);
33858
+ }
33859
+ this.sum = precisionSub(this.sum, record.sum), this.count -= record.count;
33860
+ } else this.field && !isNaN(parseFloat(record[this.field])) && (this.sum = precisionSub(this.sum, parseFloat(record[this.field])), this.count--);
33861
+ }
33862
+ this.clearCacheValue();
33824
33863
  }
33825
33864
  updateRecord(oldRecord, newRecord) {
33826
- oldRecord && newRecord && (this.isRecord && this.records && (this.records = this.records.map(item => item === oldRecord ? newRecord : item)), oldRecord.isAggregator && oldRecord.type === AggregationType.AVG ? (this.children && newRecord.isAggregator && (this.children = this.children.map(item => item === oldRecord ? newRecord : item)), this.sum += newRecord.sum - oldRecord.sum, this.count += newRecord.count - oldRecord.count) : this.field && !isNaN(parseFloat(oldRecord[this.field])) && (this.sum += parseFloat(newRecord[this.field]) - parseFloat(oldRecord[this.field])), this.clearCacheValue());
33865
+ if (oldRecord && newRecord) {
33866
+ if (this.isRecord && this.records) {
33867
+ const index = this.records.indexOf(oldRecord);
33868
+ -1 !== index && (this.records[index] = newRecord);
33869
+ }
33870
+ if (oldRecord.isAggregator && oldRecord.type === AggregationType.AVG) {
33871
+ if (this.children && newRecord.isAggregator) {
33872
+ const index = this.children.indexOf(oldRecord);
33873
+ -1 !== index && (this.children[index] = newRecord);
33874
+ }
33875
+ this.sum = precisionAdd(this.sum, precisionSub(newRecord.sum, oldRecord.sum)), this.count += newRecord.count - oldRecord.count;
33876
+ } else this.field && !isNaN(parseFloat(oldRecord[this.field])) && (this.sum = precisionAdd(this.sum, precisionSub(parseFloat(newRecord[this.field]), parseFloat(oldRecord[this.field]))));
33877
+ this.clearCacheValue();
33878
+ }
33827
33879
  }
33828
33880
  value() {
33829
- var _a, _b;
33830
- return null !== (_a = this.changedValue) && void 0 !== _a ? _a : (null === (_b = this.records) || void 0 === _b ? void 0 : _b.length) >= 1 ? this.sum / this.count : void 0;
33881
+ var _a;
33882
+ return null !== (_a = this.changedValue) && void 0 !== _a ? _a : this.records && this.records.length >= 1 || !1 === this.isRecord && this.count > 0 ? this.sum / this.count : void 0;
33831
33883
  }
33832
33884
  reset() {
33833
33885
  this.changedValue = void 0, this.children = [], this.records = [], this.sum = 0, this.count = 0;
@@ -33837,11 +33889,11 @@
33837
33889
  const child = this.children[i];
33838
33890
  if (child.isAggregator && child.type === AggregationType.AVG) {
33839
33891
  const childValue = child.value();
33840
- this.sum += childValue * child.count, this.count += child.count;
33892
+ this.sum = precisionAdd(this.sum, childValue * child.count), this.count += child.count;
33841
33893
  }
33842
33894
  } else if (this.records) for (let i = 0; i < this.records.length; i++) {
33843
33895
  const record = this.records[i];
33844
- record.isAggregator && record.type === AggregationType.AVG ? (this.sum += record.sum, this.count += record.count) : this.field && !isNaN(parseFloat(record[this.field])) && (this.sum += parseFloat(record[this.field]), this.count++);
33896
+ record.isAggregator && record.type === AggregationType.AVG ? (this.sum = precisionAdd(this.sum, record.sum), this.count += record.count) : this.field && !isNaN(parseFloat(record[this.field])) && (this.sum = precisionAdd(this.sum, parseFloat(record[this.field])), this.count++);
33845
33897
  }
33846
33898
  }
33847
33899
  }
@@ -46969,7 +47021,7 @@
46969
47021
  };
46970
47022
  function dynamicSetX(x, screenLeft, isEnd, proxy) {
46971
47023
  return __awaiter$7(this, void 0, void 0, function* () {
46972
- if (!screenLeft) return;
47024
+ if (!screenLeft) return proxy.updateDeltaX(x), proxy.table.scenegraph.setBodyAndColHeaderX(-x + proxy.deltaX), void proxy.table.scenegraph.updateNextFrame();
46973
47025
  const screenLeftCol = screenLeft.col,
46974
47026
  screenLeftX = screenLeft.left;
46975
47027
  let deltaCol;
@@ -47145,7 +47197,7 @@
47145
47197
  };
47146
47198
  function dynamicSetY(y, screenTop, isEnd, proxy) {
47147
47199
  return __awaiter$6(this, void 0, void 0, function* () {
47148
- if (!screenTop) return;
47200
+ if (!screenTop) return proxy.updateDeltaY(y), proxy.updateBody(y - proxy.deltaY), void proxy.table.scenegraph.updateNextFrame();
47149
47201
  const screenTopRow = screenTop.row,
47150
47202
  screenTopY = screenTop.top;
47151
47203
  let deltaRow;
@@ -47750,7 +47802,7 @@
47750
47802
  return __awaiter$3(this, void 0, void 0, function* () {
47751
47803
  const yLimitTop = this.table.getRowsHeight(this.bodyTopRow, this.bodyTopRow + (this.rowEnd - this.rowStart + 1)) / 2,
47752
47804
  yLimitBottom = this.table.getAllRowsHeight() - yLimitTop,
47753
- screenTop = this.table.getTargetRowAt(y + this.table.scenegraph.colHeaderGroup.attribute.height);
47805
+ screenTop = this.resolveTargetRowInfo(y + this.table.scenegraph.colHeaderGroup.attribute.height);
47754
47806
  screenTop && (this.screenTopRow = screenTop.row), y < yLimitTop && this.rowStart === this.bodyTopRow || y > yLimitBottom && this.rowEnd === this.bodyBottomRow ? (this.updateDeltaY(y), this.updateBody(y - this.deltaY)) : this.table.scenegraph.bodyGroup.firstChild && "group" === this.table.scenegraph.bodyGroup.firstChild.type && 0 !== this.table.scenegraph.bodyGroup.firstChild.childrenCount || this.table.scenegraph.rowHeaderGroup.firstChild && "group" === this.table.scenegraph.rowHeaderGroup.firstChild.type && 0 !== this.table.scenegraph.rowHeaderGroup.firstChild.childrenCount ? this.dynamicSetY(y, screenTop, isEnd) : (this.updateDeltaY(y), this.updateBody(y - this.deltaY));
47755
47807
  });
47756
47808
  }
@@ -47759,7 +47811,7 @@
47759
47811
  return __awaiter$3(this, void 0, void 0, function* () {
47760
47812
  const xLimitLeft = this.table.getColsWidth(this.bodyLeftCol, this.bodyLeftCol + (this.colEnd - this.colStart + 1)) / 2,
47761
47813
  xLimitRight = this.table.getAllColsWidth() - xLimitLeft,
47762
- screenLeft = this.table.getTargetColAt(x + this.table.scenegraph.rowHeaderGroup.attribute.width + (null !== (_c = null === (_b = (_a = this.table).getFrozenColsOffset) || void 0 === _b ? void 0 : _b.call(_a)) && void 0 !== _c ? _c : 0));
47814
+ screenLeft = this.resolveTargetColInfo(x + this.table.scenegraph.rowHeaderGroup.attribute.width + (null !== (_c = null === (_b = (_a = this.table).getFrozenColsOffset) || void 0 === _b ? void 0 : _b.call(_a)) && void 0 !== _c ? _c : 0));
47763
47815
  screenLeft && (this.screenLeftCol = screenLeft.col), x < xLimitLeft && this.colStart === this.bodyLeftCol || x > xLimitRight && this.colEnd === this.bodyRightCol || this.table.scenegraph.bodyGroup.firstChild && "group" === this.table.scenegraph.bodyGroup.firstChild.type && 0 === this.table.scenegraph.bodyGroup.firstChild.childrenCount ? (this.updateDeltaX(x), this.table.scenegraph.setBodyAndColHeaderX(-x + this.deltaX)) : this.dynamicSetX(x, screenLeft, isEnd);
47764
47816
  });
47765
47817
  }
@@ -47773,6 +47825,22 @@
47773
47825
  dynamicSetX(x, screenLeft, isEnd, this);
47774
47826
  });
47775
47827
  }
47828
+ resolveTargetColInfo(absoluteX) {
47829
+ const offsets = [0, -1, 1, -2, 2];
47830
+ for (let i = 0; i < offsets.length; i++) {
47831
+ const screenLeft = this.table.getTargetColAt(absoluteX + offsets[i]);
47832
+ if (screenLeft) return screenLeft;
47833
+ }
47834
+ return null;
47835
+ }
47836
+ resolveTargetRowInfo(absoluteY) {
47837
+ const offsets = [0, -1, 1, -2, 2];
47838
+ for (let i = 0; i < offsets.length; i++) {
47839
+ const screenTop = this.table.getTargetRowAt(absoluteY + offsets[i]);
47840
+ if (screenTop) return screenTop;
47841
+ }
47842
+ return null;
47843
+ }
47776
47844
  updateBody(y) {
47777
47845
  this.table.scenegraph.setBodyAndRowHeaderY(-y);
47778
47846
  }
@@ -50093,15 +50161,17 @@
50093
50161
  this.table.scenegraph.proxy.setY(-y, isEnd);
50094
50162
  }
50095
50163
  setBodyAndRowHeaderY(y) {
50096
- var _a, _b, _c, _d, _e, _f;
50097
- const firstBodyCell = null !== (_b = null === (_a = this.bodyGroup.firstChild) || void 0 === _a ? void 0 : _a.firstChild) && void 0 !== _b ? _b : null === (_c = this.rowHeaderGroup.firstChild) || void 0 === _c ? void 0 : _c.firstChild,
50098
- lastBodyCell = null !== (_e = null === (_d = this.bodyGroup.firstChild) || void 0 === _d ? void 0 : _d.lastChild) && void 0 !== _e ? _e : null === (_f = this.rowHeaderGroup.firstChild) || void 0 === _f ? void 0 : _f.lastChild;
50099
- 0 === y && firstBodyCell && firstBodyCell.row === this.table.frozenRowCount && firstBodyCell.attribute.y + y < 0 ? y = -firstBodyCell.attribute.y : lastBodyCell && this.table.tableNoFrameHeight < this.table.getAllRowsHeight() && lastBodyCell.row === this.table.rowCount - this.table.bottomFrozenRowCount - 1 && lastBodyCell.attribute.y + this.table.getRowHeight(lastBodyCell.row) + y < this.table.tableNoFrameHeight - this.table.getFrozenRowsHeight() - this.table.getBottomFrozenRowsHeight() && (y = this.table.tableNoFrameHeight - this.table.getFrozenRowsHeight() - this.table.getBottomFrozenRowsHeight() - lastBodyCell.attribute.y - this.table.getRowHeight(lastBodyCell.row)), this.colHeaderGroup.attribute.height + y !== this.bodyGroup.attribute.y && (this.bodyGroup.setAttribute("y", this.colHeaderGroup.attribute.height + y), this.rowHeaderGroup.setAttribute("y", this.cornerHeaderGroup.attribute.height + y), this.bodySelectGroup.setAttribute("y", this.bodyGroup.attribute.y), this.rowHeaderSelectGroup.setAttribute("y", this.rowHeaderGroup.attribute.y), this.colHeaderSelectGroup.setAttribute("y", this.colHeaderGroup.attribute.y), this.cornerHeaderSelectGroup.setAttribute("y", this.cornerHeaderGroup.attribute.y), this.table.rightFrozenColCount > 0 && (this.rightFrozenGroup.setAttribute("y", this.rightTopCornerGroup.attribute.height + y), this.rightFrozenSelectGroup.setAttribute("y", this.rightFrozenGroup.attribute.y), this.rightTopCornerSelectGroup.setAttribute("y", this.rightTopCornerGroup.attribute.y)), this.table.bottomFrozenRowCount > 0 && (this.bottomFrozenSelectGroup.setAttribute("y", this.bottomFrozenGroup.attribute.y), this.leftBottomCornerSelectGroup.setAttribute("y", this.leftBottomCornerGroup.attribute.y)), this.table.rightFrozenColCount > 0 && this.table.bottomFrozenRowCount > 0 && this.rightBottomCornerSelectGroup.setAttribute("y", this.rightBottomCornerGroup.attribute.y), this.updateNextFrame());
50164
+ var _a, _b;
50165
+ const firstBodyColGroup = this.bodyGroup.firstChild,
50166
+ firstRowHeaderColGroup = this.rowHeaderGroup.firstChild,
50167
+ firstBodyCell = null !== (_a = null == firstBodyColGroup ? void 0 : firstBodyColGroup.firstChild) && void 0 !== _a ? _a : null == firstRowHeaderColGroup ? void 0 : firstRowHeaderColGroup.firstChild;
50168
+ let lastBodyCell = null !== (_b = null == firstBodyColGroup ? void 0 : firstBodyColGroup.lastChild) && void 0 !== _b ? _b : null == firstRowHeaderColGroup ? void 0 : firstRowHeaderColGroup.lastChild;
50169
+ lastBodyCell && "group" !== lastBodyCell.type && (lastBodyCell = lastBodyCell._prev), 0 === y && firstBodyCell && firstBodyCell.row === this.table.frozenRowCount && firstBodyCell.attribute.y + y < 0 ? y = -firstBodyCell.attribute.y : lastBodyCell && this.table.tableNoFrameHeight < this.table.getAllRowsHeight() && lastBodyCell.row === this.table.rowCount - this.table.bottomFrozenRowCount - 1 && lastBodyCell.attribute.y + this.table.getRowHeight(lastBodyCell.row) + y < this.table.tableNoFrameHeight - this.table.getFrozenRowsHeight() - this.table.getBottomFrozenRowsHeight() && (y = this.table.tableNoFrameHeight - this.table.getFrozenRowsHeight() - this.table.getBottomFrozenRowsHeight() - lastBodyCell.attribute.y - this.table.getRowHeight(lastBodyCell.row)), this.colHeaderGroup.attribute.height + y !== this.bodyGroup.attribute.y && (this.bodyGroup.setAttribute("y", this.colHeaderGroup.attribute.height + y), this.rowHeaderGroup.setAttribute("y", this.cornerHeaderGroup.attribute.height + y), this.bodySelectGroup.setAttribute("y", this.bodyGroup.attribute.y), this.rowHeaderSelectGroup.setAttribute("y", this.rowHeaderGroup.attribute.y), this.colHeaderSelectGroup.setAttribute("y", this.colHeaderGroup.attribute.y), this.cornerHeaderSelectGroup.setAttribute("y", this.cornerHeaderGroup.attribute.y), this.table.rightFrozenColCount > 0 && (this.rightFrozenGroup.setAttribute("y", this.rightTopCornerGroup.attribute.height + y), this.rightFrozenSelectGroup.setAttribute("y", this.rightFrozenGroup.attribute.y), this.rightTopCornerSelectGroup.setAttribute("y", this.rightTopCornerGroup.attribute.y)), this.table.bottomFrozenRowCount > 0 && (this.bottomFrozenSelectGroup.setAttribute("y", this.bottomFrozenGroup.attribute.y), this.leftBottomCornerSelectGroup.setAttribute("y", this.leftBottomCornerGroup.attribute.y)), this.table.rightFrozenColCount > 0 && this.table.bottomFrozenRowCount > 0 && this.rightBottomCornerSelectGroup.setAttribute("y", this.rightBottomCornerGroup.attribute.y), this.updateNextFrame());
50100
50170
  }
50101
50171
  setBodyAndColHeaderX(x) {
50102
- const firstBodyCol = this.bodyGroup.firstChild,
50103
- lastBodyCol = this.bodyGroup.lastChild;
50104
- 0 === x && firstBodyCol && firstBodyCol.col === this.table.frozenColCount && firstBodyCol.attribute.x + x < 0 ? x = -firstBodyCol.attribute.x : lastBodyCol && this.table.tableNoFrameWidth < this.table.getAllColsWidth() && lastBodyCol.col === this.table.colCount - this.table.rightFrozenColCount - 1 && lastBodyCol.attribute.x + lastBodyCol.attribute.width + x < this.table.tableNoFrameWidth - this.table.getFrozenColsWidth() - this.table.getRightFrozenColsWidth() && (x = this.table.tableNoFrameWidth - this.table.getFrozenColsWidth() - this.table.getRightFrozenColsWidth() - lastBodyCol.attribute.x - lastBodyCol.attribute.width), this.table.getFrozenColsWidth() + x !== this.bodyGroup.attribute.x && (this.bodyGroup.setAttribute("x", this.table.getFrozenColsWidth() + x), this.colHeaderGroup.setAttribute("x", this.table.getFrozenColsWidth() + x), this.bodySelectGroup.setAttribute("x", this.bodyGroup.attribute.x), this.colHeaderSelectGroup.setAttribute("x", this.colHeaderGroup.attribute.x), this.rowHeaderSelectGroup.setAttribute("x", this.rowHeaderGroup.attribute.x), this.cornerHeaderSelectGroup.setAttribute("x", this.cornerHeaderGroup.attribute.x), this.table.bottomFrozenRowCount > 0 && (this.bottomFrozenGroup.setAttribute("x", this.table.getFrozenColsWidth() + x), this.bottomFrozenSelectGroup.setAttribute("x", this.bottomFrozenGroup.attribute.x), this.leftBottomCornerSelectGroup.setAttribute("x", this.leftBottomCornerGroup.attribute.x)), this.table.rightFrozenColCount > 0 && (this.rightFrozenSelectGroup.setAttribute("x", this.rightFrozenGroup.attribute.x), this.rightTopCornerSelectGroup.setAttribute("x", this.rightTopCornerGroup.attribute.x)), this.table.rightFrozenColCount > 0 && this.table.bottomFrozenRowCount > 0 && this.rightBottomCornerSelectGroup.setAttribute("x", this.rightBottomCornerGroup.attribute.x), this.updateNextFrame());
50172
+ const firstBodyCol = this.bodyGroup.firstChild;
50173
+ let lastBodyCol = this.bodyGroup.lastChild;
50174
+ lastBodyCol && "group" !== lastBodyCol.type && (lastBodyCol = lastBodyCol._prev), 0 === x && firstBodyCol && firstBodyCol.col === this.table.frozenColCount && firstBodyCol.attribute.x + x < 0 ? x = -firstBodyCol.attribute.x : lastBodyCol && this.table.tableNoFrameWidth < this.table.getAllColsWidth() && lastBodyCol.col === this.table.colCount - this.table.rightFrozenColCount - 1 && lastBodyCol.attribute.x + lastBodyCol.attribute.width + x < this.table.tableNoFrameWidth - this.table.getFrozenColsWidth() - this.table.getRightFrozenColsWidth() && (x = this.table.tableNoFrameWidth - this.table.getFrozenColsWidth() - this.table.getRightFrozenColsWidth() - lastBodyCol.attribute.x - lastBodyCol.attribute.width), this.table.getFrozenColsWidth() + x !== this.bodyGroup.attribute.x && (this.bodyGroup.setAttribute("x", this.table.getFrozenColsWidth() + x), this.colHeaderGroup.setAttribute("x", this.table.getFrozenColsWidth() + x), this.bodySelectGroup.setAttribute("x", this.bodyGroup.attribute.x), this.colHeaderSelectGroup.setAttribute("x", this.colHeaderGroup.attribute.x), this.rowHeaderSelectGroup.setAttribute("x", this.rowHeaderGroup.attribute.x), this.cornerHeaderSelectGroup.setAttribute("x", this.cornerHeaderGroup.attribute.x), this.table.bottomFrozenRowCount > 0 && (this.bottomFrozenGroup.setAttribute("x", this.table.getFrozenColsWidth() + x), this.bottomFrozenSelectGroup.setAttribute("x", this.bottomFrozenGroup.attribute.x), this.leftBottomCornerSelectGroup.setAttribute("x", this.leftBottomCornerGroup.attribute.x)), this.table.rightFrozenColCount > 0 && (this.rightFrozenSelectGroup.setAttribute("x", this.rightFrozenGroup.attribute.x), this.rightTopCornerSelectGroup.setAttribute("x", this.rightTopCornerGroup.attribute.x)), this.table.rightFrozenColCount > 0 && this.table.bottomFrozenRowCount > 0 && this.rightBottomCornerSelectGroup.setAttribute("x", this.rightBottomCornerGroup.attribute.x), this.updateNextFrame());
50105
50175
  }
50106
50176
  afterScenegraphCreated() {
50107
50177
  var _a, _b;
@@ -53538,6 +53608,7 @@
53538
53608
  }
53539
53609
  function dblclickHandler(e, table) {
53540
53610
  var _a, _b, _c, _d, _e, _f;
53611
+ if ("number" == typeof e.button && 0 !== e.button) return;
53541
53612
  const eventArgsSet = getCellEventArgsSetWithTable(e, table);
53542
53613
  let col = -1,
53543
53614
  row = -1;
@@ -53733,7 +53804,13 @@
53733
53804
  function bindContainerDomListener(eventManager) {
53734
53805
  const table = eventManager.table,
53735
53806
  stateManager = table.stateManager,
53736
- handler = table.internalProps.handler;
53807
+ handler = table.internalProps.handler,
53808
+ afterCompleteEdit = (completeEditResult, onSuccess) => {
53809
+ getPromiseValue(completeEditResult, isCompleteEdit => {
53810
+ var _a, _b, _c, _d, _e;
53811
+ !1 !== isCompleteEdit ? onSuccess() : null === (_e = null === (_d = null === (_c = null === (_b = null === (_a = table.editorManager) || void 0 === _a ? void 0 : _a.editingEditor) || void 0 === _b ? void 0 : _b.getInputElement) || void 0 === _c ? void 0 : _c.call(_b)) || void 0 === _d ? void 0 : _d.focus) || void 0 === _e || _e.call(_d);
53812
+ });
53813
+ };
53737
53814
  function handleKeydownListener(e) {
53738
53815
  var _a;
53739
53816
  if (table.hasListeners(TABLE_EVENT_TYPE.KEYDOWN)) {
@@ -53756,7 +53833,7 @@
53756
53833
  }
53757
53834
  eventManager.dealTableHover();
53758
53835
  }), handler.on(table.getElement(), "keydown", e => {
53759
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9;
53836
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0;
53760
53837
  const beforeKeydownEvent = {
53761
53838
  keyCode: null !== (_a = e.keyCode) && void 0 !== _a ? _a : e.which,
53762
53839
  code: e.code,
@@ -53766,48 +53843,60 @@
53766
53843
  if ((null === (_d = null === (_c = table.options.keyboardOptions) || void 0 === _c ? void 0 : _c.moveEditCellOnArrowKeys) || void 0 === _d || !_d) && (null === (_e = table.editorManager) || void 0 === _e ? void 0 : _e.editingEditor) || !1 === (null === (_f = table.options.keyboardOptions) || void 0 === _f ? void 0 : _f.moveSelectedCellOnArrowKeys)) return;
53767
53844
  let targetCol, targetRow;
53768
53845
  if (e.preventDefault(), e.stopPropagation(), "ArrowUp" === e.key ? e.ctrlKey || e.metaKey ? (targetCol = stateManager.select.cellPos.col, targetRow = 0) : (e.shiftKey, targetCol = stateManager.select.cellPos.col, targetRow = Math.min(table.rowCount - 1, Math.max(0, stateManager.select.cellPos.row - 1))) : "ArrowDown" === e.key ? e.ctrlKey || e.metaKey ? (targetCol = stateManager.select.cellPos.col, targetRow = table.rowCount - 1) : (e.shiftKey, targetCol = stateManager.select.cellPos.col, targetRow = Math.min(table.rowCount - 1, Math.max(0, stateManager.select.cellPos.row + 1))) : "ArrowLeft" === e.key ? e.ctrlKey || e.metaKey ? (targetCol = 0, targetRow = stateManager.select.cellPos.row) : (e.shiftKey, targetRow = stateManager.select.cellPos.row, targetCol = Math.min(table.colCount - 1, Math.max(0, stateManager.select.cellPos.col - 1))) : "ArrowRight" === e.key && (e.ctrlKey || e.metaKey ? (targetCol = table.colCount - 1, targetRow = stateManager.select.cellPos.row) : (e.shiftKey, targetRow = stateManager.select.cellPos.row, targetCol = Math.min(table.colCount - 1, Math.max(0, stateManager.select.cellPos.col + 1)))), isCellDisableSelect(table, targetCol, targetRow)) return;
53769
- const isEditingCell = !!(null === (_g = table.editorManager) || void 0 === _g ? void 0 : _g.editingEditor);
53770
- null === (_h = table.editorManager) || void 0 === _h || _h.completeEdit(), table.getElement().focus();
53771
- const enableShiftSelectMode = null === (_k = null === (_j = table.options.keyboardOptions) || void 0 === _j ? void 0 : _j.shiftMultiSelect) || void 0 === _k || _k;
53772
- table.selectCell(targetCol, targetRow, e.shiftKey && enableShiftSelectMode), null !== (_m = null === (_l = table.options.keyboardOptions) || void 0 === _l ? void 0 : _l.moveEditCellOnArrowKeys) && void 0 !== _m && _m && isEditingCell && table.getEditor(targetCol, targetRow) && (null === (_o = table.editorManager) || void 0 === _o || _o.startEditCell(targetCol, targetRow));
53773
- } else if ("Escape" === e.key) null === (_p = table.editorManager) || void 0 === _p || _p.cancelEdit(), table.getElement().focus();else if ("Enter" === e.key) {
53774
- if (null === (_q = table.editorManager) || void 0 === _q ? void 0 : _q.editingEditor) {
53775
- if (handleKeydownListener(e), null === (_r = table.editorManager) || void 0 === _r || _r.completeEdit(), table.getElement().focus(), !0 === (null === (_s = table.options.keyboardOptions) || void 0 === _s ? void 0 : _s.moveFocusCellOnEnter)) {
53776
- const targetCol = stateManager.select.cellPos.col,
53777
- targetRow = Math.min(table.rowCount - 1, Math.max(0, stateManager.select.cellPos.row + 1));
53778
- if (isCellDisableSelect(table, targetCol, targetRow)) return;
53779
- const enableShiftSelectMode = null === (_u = null === (_t = table.options.keyboardOptions) || void 0 === _t ? void 0 : _t.shiftMultiSelect) || void 0 === _u || _u;
53780
- table.selectCell(targetCol, targetRow, e.shiftKey && enableShiftSelectMode);
53781
- }
53782
- return;
53846
+ const isEditingCell = !!(null === (_g = table.editorManager) || void 0 === _g ? void 0 : _g.editingEditor),
53847
+ completeEditResult = null === (_h = table.editorManager) || void 0 === _h ? void 0 : _h.completeEdit();
53848
+ afterCompleteEdit(completeEditResult, () => {
53849
+ var _a, _b, _c, _d, _e;
53850
+ table.getElement().focus();
53851
+ const enableShiftSelectMode = null === (_b = null === (_a = table.options.keyboardOptions) || void 0 === _a ? void 0 : _a.shiftMultiSelect) || void 0 === _b || _b;
53852
+ table.selectCell(targetCol, targetRow, e.shiftKey && enableShiftSelectMode), null !== (_d = null === (_c = table.options.keyboardOptions) || void 0 === _c ? void 0 : _c.moveEditCellOnArrowKeys) && void 0 !== _d && _d && isEditingCell && table.getEditor(targetCol, targetRow) && (null === (_e = table.editorManager) || void 0 === _e || _e.startEditCell(targetCol, targetRow));
53853
+ });
53854
+ } else if ("Escape" === e.key) null === (_j = table.editorManager) || void 0 === _j || _j.cancelEdit(), table.getElement().focus();else if ("Enter" === e.key) {
53855
+ if (null === (_k = table.editorManager) || void 0 === _k ? void 0 : _k.editingEditor) {
53856
+ handleKeydownListener(e);
53857
+ const completeEditResult = null === (_l = table.editorManager) || void 0 === _l ? void 0 : _l.completeEdit();
53858
+ return void afterCompleteEdit(completeEditResult, () => {
53859
+ var _a, _b, _c;
53860
+ if (table.getElement().focus(), !0 === (null === (_a = table.options.keyboardOptions) || void 0 === _a ? void 0 : _a.moveFocusCellOnEnter)) {
53861
+ const targetCol = stateManager.select.cellPos.col,
53862
+ targetRow = Math.min(table.rowCount - 1, Math.max(0, stateManager.select.cellPos.row + 1));
53863
+ if (isCellDisableSelect(table, targetCol, targetRow)) return;
53864
+ const enableShiftSelectMode = null === (_c = null === (_b = table.options.keyboardOptions) || void 0 === _b ? void 0 : _b.shiftMultiSelect) || void 0 === _c || _c;
53865
+ table.selectCell(targetCol, targetRow, e.shiftKey && enableShiftSelectMode);
53866
+ }
53867
+ });
53783
53868
  }
53784
- if (!0 === (null === (_v = table.options.keyboardOptions) || void 0 === _v ? void 0 : _v.moveFocusCellOnEnter)) {
53869
+ if (!0 === (null === (_m = table.options.keyboardOptions) || void 0 === _m ? void 0 : _m.moveFocusCellOnEnter)) {
53785
53870
  const targetCol = stateManager.select.cellPos.col,
53786
53871
  targetRow = Math.min(table.rowCount - 1, Math.max(0, stateManager.select.cellPos.row + 1));
53787
53872
  if (isCellDisableSelect(table, targetCol, targetRow)) return;
53788
- const enableShiftSelectMode = null === (_x = null === (_w = table.options.keyboardOptions) || void 0 === _w ? void 0 : _w.shiftMultiSelect) || void 0 === _x || _x;
53873
+ const enableShiftSelectMode = null === (_p = null === (_o = table.options.keyboardOptions) || void 0 === _o ? void 0 : _o.shiftMultiSelect) || void 0 === _p || _p;
53789
53874
  table.selectCell(targetCol, targetRow, e.shiftKey && enableShiftSelectMode);
53790
- } else if ((null === (_z = null === (_y = table.options.keyboardOptions) || void 0 === _y ? void 0 : _y.editCellOnEnter) || void 0 === _z || _z) && 1 === (null !== (_1 = null === (_0 = table.stateManager.select.ranges) || void 0 === _0 ? void 0 : _0.length) && void 0 !== _1 ? _1 : 0)) {
53875
+ } else if ((null === (_r = null === (_q = table.options.keyboardOptions) || void 0 === _q ? void 0 : _q.editCellOnEnter) || void 0 === _r || _r) && 1 === (null !== (_t = null === (_s = table.stateManager.select.ranges) || void 0 === _s ? void 0 : _s.length) && void 0 !== _t ? _t : 0)) {
53791
53876
  const startCol = table.stateManager.select.ranges[0].start.col,
53792
53877
  startRow = table.stateManager.select.ranges[0].start.row,
53793
53878
  endCol = table.stateManager.select.ranges[0].end.col,
53794
53879
  endRow = table.stateManager.select.ranges[0].end.row;
53795
- startCol === endCol && startRow === endRow && table.getEditor(startCol, startRow) && (null === (_2 = table.editorManager) || void 0 === _2 || _2.startEditCell(startCol, startRow));
53880
+ startCol === endCol && startRow === endRow && table.getEditor(startCol, startRow) && (null === (_u = table.editorManager) || void 0 === _u || _u.startEditCell(startCol, startRow));
53796
53881
  }
53797
53882
  } else if ("Tab" === e.key) {
53798
- if ((null === (_4 = null === (_3 = table.options.keyboardOptions) || void 0 === _3 ? void 0 : _3.moveFocusCellOnTab) || void 0 === _4 || _4) && stateManager.select.cellPos.col >= 0 && stateManager.select.cellPos.row >= 0) {
53883
+ if ((null === (_w = null === (_v = table.options.keyboardOptions) || void 0 === _v ? void 0 : _v.moveFocusCellOnTab) || void 0 === _w || _w) && stateManager.select.cellPos.col >= 0 && stateManager.select.cellPos.row >= 0) {
53799
53884
  if (stateManager.select.cellPos.col === table.colCount - 1 && stateManager.select.cellPos.row === table.rowCount - 1) return;
53800
53885
  let targetCol, targetRow;
53801
53886
  if (e.preventDefault(), stateManager.select.cellPos.col === table.colCount - 1 ? (targetRow = Math.min(table.rowCount - 1, stateManager.select.cellPos.row + 1), targetCol = table.rowHeaderLevelCount) : (targetRow = stateManager.select.cellPos.row, targetCol = stateManager.select.cellPos.col + 1), isCellDisableSelect(table, targetCol, targetRow)) return;
53802
- const isEditingCell = !!(null === (_5 = table.editorManager) || void 0 === _5 ? void 0 : _5.editingEditor);
53803
- null === (_6 = table.editorManager) || void 0 === _6 || _6.completeEdit(), table.getElement().focus(), table.selectCell(targetCol, targetRow), isEditingCell && table.getEditor(targetCol, targetRow) && (null === (_7 = table.editorManager) || void 0 === _7 || _7.startEditCell(targetCol, targetRow));
53887
+ const isEditingCell = !!(null === (_x = table.editorManager) || void 0 === _x ? void 0 : _x.editingEditor),
53888
+ completeEditResult = null === (_y = table.editorManager) || void 0 === _y ? void 0 : _y.completeEdit();
53889
+ afterCompleteEdit(completeEditResult, () => {
53890
+ var _a;
53891
+ table.getElement().focus(), table.selectCell(targetCol, targetRow), isEditingCell && table.getEditor(targetCol, targetRow) && (null === (_a = table.editorManager) || void 0 === _a || _a.startEditCell(targetCol, targetRow));
53892
+ });
53804
53893
  }
53805
53894
  } else if (!e.ctrlKey && !e.metaKey) {
53806
53895
  const editCellTrigger = table.options.editCellTrigger,
53807
53896
  selectedRanges = table.stateManager.select.ranges;
53808
- if (1 === selectedRanges.length && selectedRanges[0].start.col === selectedRanges[0].end.col && selectedRanges[0].start.row === selectedRanges[0].end.row && ("keydown" === editCellTrigger || Array.isArray(editCellTrigger) && editCellTrigger.includes("keydown")) && !(null === (_8 = table.editorManager) || void 0 === _8 ? void 0 : _8.editingEditor)) {
53897
+ if (1 === selectedRanges.length && selectedRanges[0].start.col === selectedRanges[0].end.col && selectedRanges[0].start.row === selectedRanges[0].end.row && ("keydown" === editCellTrigger || Array.isArray(editCellTrigger) && editCellTrigger.includes("keydown")) && !(null === (_z = table.editorManager) || void 0 === _z ? void 0 : _z.editingEditor)) {
53809
53898
  const allowedKeys = /^[a-zA-Z0-9+\-*\/%=.,\s]$/;
53810
- e.key.match(allowedKeys) && (table.editorManager && (table.editorManager.beginTriggerEditCellMode = "keydown"), null === (_9 = table.editorManager) || void 0 === _9 || _9.startEditCell(stateManager.select.cellPos.col, stateManager.select.cellPos.row, ""));
53899
+ e.key.match(allowedKeys) && (table.editorManager && (table.editorManager.beginTriggerEditCellMode = "keydown"), null === (_0 = table.editorManager) || void 0 === _0 || _0.startEditCell(stateManager.select.cellPos.col, stateManager.select.cellPos.row, ""));
53811
53900
  }
53812
53901
  }
53813
53902
  handleKeydownListener(e);
@@ -57069,7 +57158,7 @@
57069
57158
  }
57070
57159
  constructor(container, options = {}) {
57071
57160
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z;
57072
- if (super(), this.showFrozenIcon = !0, this._scrollToRowCorrectTimer = null, this._tableBorderWidth_left = 0, this._tableBorderWidth_right = 0, this._tableBorderWidth_top = 0, this._tableBorderWidth_bottom = 0, this.version = "1.26.0", this.id = `VTable${Date.now()}`, this.isReleased = !1, this._chartEventMap = {}, this.throttleInvalidate = throttle2(this.render.bind(this), 200), "undefined" != typeof window) {
57161
+ if (super(), this.showFrozenIcon = !0, this._scrollToRowCorrectTimer = null, this._tableBorderWidth_left = 0, this._tableBorderWidth_right = 0, this._tableBorderWidth_top = 0, this._tableBorderWidth_bottom = 0, this.version = "1.26.1", this.id = `VTable${Date.now()}`, this.isReleased = !1, this._chartEventMap = {}, this.throttleInvalidate = throttle2(this.render.bind(this), 200), "undefined" != typeof window) {
57073
57162
  const g = window;
57074
57163
  g[this.id] = this;
57075
57164
  const registry = g.__vtable__ || (g.__vtable__ = {