@visactor/vtable 1.3.2-alpha.0 → 1.3.2-alpha.2

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.
Files changed (107) hide show
  1. package/cjs/PivotChart.d.ts +1 -0
  2. package/cjs/PivotChart.js +4 -0
  3. package/cjs/PivotChart.js.map +1 -1
  4. package/cjs/components/axis/axis.js +3 -2
  5. package/cjs/components/axis/axis.js.map +1 -1
  6. package/cjs/components/empty-tip/empty-tip.js +2 -2
  7. package/cjs/components/empty-tip/empty-tip.js.map +1 -1
  8. package/cjs/components/legend/discrete-legend/discrete-legend.js +2 -1
  9. package/cjs/components/legend/discrete-legend/discrete-legend.js.map +1 -1
  10. package/cjs/core/BaseTable.d.ts +4 -2
  11. package/cjs/core/BaseTable.js +54 -170
  12. package/cjs/core/BaseTable.js.map +1 -1
  13. package/cjs/core/FouseInput.d.ts +1 -0
  14. package/cjs/core/FouseInput.js +5 -2
  15. package/cjs/core/FouseInput.js.map +1 -1
  16. package/cjs/core/utils/get-cell-position.d.ts +42 -0
  17. package/cjs/core/utils/get-cell-position.js +206 -0
  18. package/cjs/core/utils/get-cell-position.js.map +1 -0
  19. package/cjs/dataset/dataset.d.ts +0 -2
  20. package/cjs/dataset/dataset.js +7 -8
  21. package/cjs/dataset/dataset.js.map +1 -1
  22. package/cjs/event/event.js +2 -1
  23. package/cjs/event/event.js.map +1 -1
  24. package/cjs/event/listener/container-dom.js +1 -1
  25. package/cjs/event/listener/container-dom.js.map +1 -1
  26. package/cjs/event/util.js +2 -2
  27. package/cjs/event/util.js.map +1 -1
  28. package/cjs/index.d.ts +1 -1
  29. package/cjs/index.js +1 -1
  30. package/cjs/index.js.map +1 -1
  31. package/cjs/layout/pivot-header-layout.js +37 -57
  32. package/cjs/layout/pivot-header-layout.js.map +1 -1
  33. package/cjs/scenegraph/debug-tool/debug-tool.js +4 -1
  34. package/cjs/scenegraph/debug-tool/debug-tool.js.map +1 -1
  35. package/cjs/scenegraph/graphic/chart.d.ts +1 -0
  36. package/cjs/scenegraph/graphic/chart.js +34 -20
  37. package/cjs/scenegraph/graphic/chart.js.map +1 -1
  38. package/cjs/scenegraph/graphic/contributions/chart-render-helper.js +20 -8
  39. package/cjs/scenegraph/graphic/contributions/chart-render-helper.js.map +1 -1
  40. package/cjs/scenegraph/graphic/contributions/chart-render.d.ts +2 -1
  41. package/cjs/scenegraph/graphic/contributions/chart-render.js +40 -24
  42. package/cjs/scenegraph/graphic/contributions/chart-render.js.map +1 -1
  43. package/cjs/scenegraph/group-creater/cell-type/chart-cell.js +2 -1
  44. package/cjs/scenegraph/group-creater/cell-type/chart-cell.js.map +1 -1
  45. package/cjs/scenegraph/refresh-node/update-chart.d.ts +1 -0
  46. package/cjs/scenegraph/refresh-node/update-chart.js +9 -2
  47. package/cjs/scenegraph/refresh-node/update-chart.js.map +1 -1
  48. package/cjs/scenegraph/scenegraph.js +10 -4
  49. package/cjs/scenegraph/scenegraph.js.map +1 -1
  50. package/cjs/ts-types/base-table.d.ts +14 -1
  51. package/cjs/ts-types/base-table.js.map +1 -1
  52. package/cjs/vrender.js.map +1 -1
  53. package/dist/vtable.js +511 -443
  54. package/dist/vtable.min.js +2 -2
  55. package/es/PivotChart.d.ts +1 -0
  56. package/es/PivotChart.js +5 -2
  57. package/es/PivotChart.js.map +1 -1
  58. package/es/components/axis/axis.js +3 -1
  59. package/es/components/axis/axis.js.map +1 -1
  60. package/es/components/empty-tip/empty-tip.js +2 -2
  61. package/es/components/empty-tip/empty-tip.js.map +1 -1
  62. package/es/components/legend/discrete-legend/discrete-legend.js +2 -1
  63. package/es/components/legend/discrete-legend/discrete-legend.js.map +1 -1
  64. package/es/core/BaseTable.d.ts +4 -2
  65. package/es/core/BaseTable.js +55 -169
  66. package/es/core/BaseTable.js.map +1 -1
  67. package/es/core/FouseInput.d.ts +1 -0
  68. package/es/core/FouseInput.js +5 -2
  69. package/es/core/FouseInput.js.map +1 -1
  70. package/es/core/utils/get-cell-position.d.ts +42 -0
  71. package/es/core/utils/get-cell-position.js +194 -0
  72. package/es/core/utils/get-cell-position.js.map +1 -0
  73. package/es/dataset/dataset.d.ts +0 -2
  74. package/es/dataset/dataset.js +7 -8
  75. package/es/dataset/dataset.js.map +1 -1
  76. package/es/event/event.js +2 -1
  77. package/es/event/event.js.map +1 -1
  78. package/es/event/listener/container-dom.js +1 -1
  79. package/es/event/listener/container-dom.js.map +1 -1
  80. package/es/event/util.js +2 -2
  81. package/es/event/util.js.map +1 -1
  82. package/es/index.d.ts +1 -1
  83. package/es/index.js +1 -1
  84. package/es/index.js.map +1 -1
  85. package/es/layout/pivot-header-layout.js +36 -56
  86. package/es/layout/pivot-header-layout.js.map +1 -1
  87. package/es/scenegraph/debug-tool/debug-tool.js +4 -1
  88. package/es/scenegraph/debug-tool/debug-tool.js.map +1 -1
  89. package/es/scenegraph/graphic/chart.d.ts +1 -0
  90. package/es/scenegraph/graphic/chart.js +33 -21
  91. package/es/scenegraph/graphic/chart.js.map +1 -1
  92. package/es/scenegraph/graphic/contributions/chart-render-helper.js +20 -8
  93. package/es/scenegraph/graphic/contributions/chart-render-helper.js.map +1 -1
  94. package/es/scenegraph/graphic/contributions/chart-render.d.ts +2 -1
  95. package/es/scenegraph/graphic/contributions/chart-render.js +41 -25
  96. package/es/scenegraph/graphic/contributions/chart-render.js.map +1 -1
  97. package/es/scenegraph/group-creater/cell-type/chart-cell.js +2 -1
  98. package/es/scenegraph/group-creater/cell-type/chart-cell.js.map +1 -1
  99. package/es/scenegraph/refresh-node/update-chart.d.ts +1 -0
  100. package/es/scenegraph/refresh-node/update-chart.js +6 -0
  101. package/es/scenegraph/refresh-node/update-chart.js.map +1 -1
  102. package/es/scenegraph/scenegraph.js +10 -4
  103. package/es/scenegraph/scenegraph.js.map +1 -1
  104. package/es/ts-types/base-table.d.ts +14 -1
  105. package/es/ts-types/base-table.js.map +1 -1
  106. package/es/vrender.js.map +1 -1
  107. package/package.json +2 -2
@@ -46,7 +46,7 @@ import { getProp } from "../scenegraph/utils/get-prop";
46
46
 
47
47
  import { IconCache } from "../plugins/icons";
48
48
 
49
- import { _applyColWidthLimits, _getScrollableVisibleRect, _getTargetFrozenColAt, _getTargetFrozenRowAt, _setDataSource, _toPxWidth, createRootElement, getStyleTheme, updateRootElementPadding } from "./tableHelper";
49
+ import { _applyColWidthLimits, _getScrollableVisibleRect, _setDataSource, _toPxWidth, createRootElement, getStyleTheme, updateRootElementPadding } from "./tableHelper";
50
50
 
51
51
  import { MenuHandler } from "../components/menu/dom/MenuHandler";
52
52
 
@@ -72,6 +72,8 @@ import { hideCellSelectBorder, restoreCellSelectBorder } from "../scenegraph/sel
72
72
 
73
73
  import { hasAutoImageColumn } from "../layout/layout-helper";
74
74
 
75
+ import { getCellAt, getCellAtRelativePosition, getColAt, getRowAt, getTargetColAt, getTargetColAtConsiderRightFrozen, getTargetRowAt, getTargetRowAtConsiderBottomFrozen } from "./utils/get-cell-position";
76
+
75
77
  const {toBoxArray: toBoxArray} = utilStyle, {isTouchEvent: isTouchEvent} = event, rangeReg = /^\$(\d+)\$(\d+)$/;
76
78
 
77
79
  importStyle();
@@ -84,9 +86,9 @@ export class BaseTable extends EventTarget {
84
86
  }
85
87
  constructor(container, options = {}) {
86
88
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
87
- if (super(), this.showFrozenIcon = !0, this.version = "1.3.2-alpha.0", this.id = `VTable${Date.now()}`,
89
+ if (super(), this.showFrozenIcon = !0, this.version = "1.3.2-alpha.2", this.id = `VTable${Date.now()}`,
88
90
  this.isReleased = !1, this._chartEventMap = {}, this.throttleInvalidate = throttle2(this.render.bind(this), 200),
89
- !container && "node" !== options.mode) throw new Error("vtable's container is undefined");
91
+ !container && "node" !== options.mode && !options.canvas) throw new Error("vtable's container is undefined");
90
92
  const {frozenColCount: frozenColCount = 0, defaultRowHeight: defaultRowHeight = 40, defaultHeaderRowHeight: defaultHeaderRowHeight, defaultColWidth: defaultColWidth = 80, defaultHeaderColWidth: defaultHeaderColWidth, widthMode: widthMode = "standard", heightMode: heightMode = "standard", autoFillWidth: autoFillWidth = !1, autoFillHeight: autoFillHeight = !1, widthAdaptiveMode: widthAdaptiveMode = "only-body", heightAdaptiveMode: heightAdaptiveMode = "only-body", keyboardOptions: keyboardOptions, eventOptions: eventOptions, rowSeriesNumber: rowSeriesNumber, columnResizeMode: columnResizeMode, rowResizeMode: rowResizeMode = "none", dragHeaderMode: dragHeaderMode, showFrozenIcon: showFrozenIcon, allowFrozenColCount: allowFrozenColCount, padding: padding, hover: hover, menu: menu, select: click, customRender: customRender, pixelRatio: pixelRatio = defaultPixelRatio, renderChartAsync: renderChartAsync, renderChartAsyncBatchCount: renderChartAsyncBatchCount, mode: mode, modeParams: modeParams, canvasWidth: canvasWidth, canvasHeight: canvasHeight, overscrollBehavior: overscrollBehavior, limitMinWidth: limitMinWidth, limitMinHeight: limitMinHeight, clearDOM: clearDOM = !0} = options;
91
93
  this.container = container, this.options = options, this._widthMode = widthMode,
92
94
  this._heightMode = heightMode, this._widthAdaptiveMode = widthAdaptiveMode, this._heightAdaptiveMode = heightAdaptiveMode,
@@ -104,7 +106,9 @@ export class BaseTable extends EventTarget {
104
106
  this.columnWidthComputeMode = null !== (_a = options.columnWidthComputeMode) && void 0 !== _a ? _a : "normal";
105
107
  const internalProps = this.internalProps = {};
106
108
  if (void 0 !== showFrozenIcon && (this.showFrozenIcon = showFrozenIcon), "number" == typeof allowFrozenColCount && allowFrozenColCount <= 0 && (this.showFrozenIcon = !1),
107
- "node" !== Env.mode && (internalProps.element = createRootElement(this.padding),
109
+ this.options.canvas ? (internalProps.element = this.options.canvas.parentElement,
110
+ internalProps.element.style.position = "relative", internalProps.focusControl = new FocusInput(this, internalProps.element),
111
+ internalProps.canvas = this.options.canvas, internalProps.context = internalProps.canvas.getContext("2d")) : "node" !== Env.mode && (internalProps.element = createRootElement(this.padding),
108
112
  internalProps.focusControl = new FocusInput(this, internalProps.element), internalProps.canvas = document.createElement("canvas"),
109
113
  internalProps.element.appendChild(internalProps.canvas), internalProps.context = internalProps.canvas.getContext("2d")),
110
114
  internalProps.handler = new EventHandler, isNumber(this.options.resizeTime) && (internalProps.handler.resizeTime = this.options.resizeTime),
@@ -372,10 +376,11 @@ export class BaseTable extends EventTarget {
372
376
  }
373
377
  }
374
378
  _updateSize() {
375
- 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;
379
+ 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;
376
380
  const {padding: padding} = this;
377
381
  let widthP = 0, heightP = 0;
378
- if ("browser" === Env.mode) {
382
+ if (this.tableX = 0, this.tableY = 0, this.options.canvas && this.options.viewBox) widthP = this.options.viewBox.x2 - this.options.viewBox.x1,
383
+ heightP = this.options.viewBox.y2 - this.options.viewBox.y1, (null === (_a = null == this ? void 0 : this.scenegraph) || void 0 === _a ? void 0 : _a.stage) && (this.options.viewBox ? this.scenegraph.stage.setViewBox(this.options.viewBox, !1) : this.scenegraph.stage.resize(widthP, heightP)); else if ("browser" === Env.mode) {
379
384
  const element = this.getElement();
380
385
  let widthWithoutPadding = 0, heightWithoutPadding = 0;
381
386
  if (element.parentElement) {
@@ -387,23 +392,31 @@ export class BaseTable extends EventTarget {
387
392
  element.style.width = width1 && width1 - padding.left - padding.right + "px" || "0px",
388
393
  element.style.height = height1 && height1 - padding.top - padding.bottom + "px" || "0px";
389
394
  const {canvas: canvas} = this.internalProps;
390
- widthP = null !== (_b = null === (_a = canvas.parentElement) || void 0 === _a ? void 0 : _a.offsetWidth) && void 0 !== _b ? _b : 0,
391
- heightP = null !== (_d = null === (_c = canvas.parentElement) || void 0 === _c ? void 0 : _c.offsetHeight) && void 0 !== _d ? _d : 0,
392
- (null === (_e = null == this ? void 0 : this.scenegraph) || void 0 === _e ? void 0 : _e.stage) ? this.scenegraph.stage.resize(widthP, heightP) : (canvas.style.width = "",
395
+ widthP = null !== (_c = null === (_b = canvas.parentElement) || void 0 === _b ? void 0 : _b.offsetWidth) && void 0 !== _c ? _c : 0,
396
+ heightP = null !== (_e = null === (_d = canvas.parentElement) || void 0 === _d ? void 0 : _d.offsetHeight) && void 0 !== _e ? _e : 0,
397
+ (null === (_f = null == this ? void 0 : this.scenegraph) || void 0 === _f ? void 0 : _f.stage) ? this.scenegraph.stage.resize(widthP, heightP) : (canvas.style.width = "",
393
398
  canvas.style.height = "", canvas.width = widthP, canvas.height = heightP, canvas.style.width = `${widthP}px`,
394
399
  canvas.style.height = `${heightP}px`);
395
400
  } else "node" === Env.mode && (widthP = this.canvasWidth - 1, heightP = this.canvasHeight - 1);
396
401
  const width = Math.floor(widthP - style.getScrollBarSize(this.getTheme().scrollStyle)), height = Math.floor(heightP - style.getScrollBarSize(this.getTheme().scrollStyle));
397
- if (null === (_f = this.internalProps.theme) || void 0 === _f ? void 0 : _f.frameStyle) {
398
- const lineWidths = toBoxArray(null !== (_h = null === (_g = this.internalProps.theme.frameStyle) || void 0 === _g ? void 0 : _g.borderLineWidth) && void 0 !== _h ? _h : [ null ]), shadowWidths = toBoxArray(null !== (_k = null === (_j = this.internalProps.theme.frameStyle) || void 0 === _j ? void 0 : _j.shadowBlur) && void 0 !== _k ? _k : [ 0 ]);
399
- (null === (_l = this.theme.frameStyle) || void 0 === _l ? void 0 : _l.innerBorder) ? (this.tableX = 0,
400
- this.tableY = 0, this.tableNoFrameWidth = width - (null !== (_m = shadowWidths[1]) && void 0 !== _m ? _m : 0),
401
- this.tableNoFrameHeight = height - (null !== (_o = shadowWidths[2]) && void 0 !== _o ? _o : 0)) : (this.tableX = (null !== (_p = lineWidths[3]) && void 0 !== _p ? _p : 0) + (null !== (_q = shadowWidths[3]) && void 0 !== _q ? _q : 0),
402
- this.tableY = (null !== (_r = lineWidths[0]) && void 0 !== _r ? _r : 0) + (null !== (_s = shadowWidths[0]) && void 0 !== _s ? _s : 0),
403
- this.tableNoFrameWidth = width - ((null !== (_t = lineWidths[1]) && void 0 !== _t ? _t : 0) + (null !== (_u = shadowWidths[1]) && void 0 !== _u ? _u : 0)) - ((null !== (_v = lineWidths[3]) && void 0 !== _v ? _v : 0) + (null !== (_w = shadowWidths[3]) && void 0 !== _w ? _w : 0)),
404
- this.tableNoFrameHeight = height - ((null !== (_x = lineWidths[0]) && void 0 !== _x ? _x : 0) + (null !== (_y = shadowWidths[0]) && void 0 !== _y ? _y : 0)) - ((null !== (_z = lineWidths[2]) && void 0 !== _z ? _z : 0) + (null !== (_0 = shadowWidths[2]) && void 0 !== _0 ? _0 : 0)));
402
+ if (null === (_g = this.internalProps.theme) || void 0 === _g ? void 0 : _g.frameStyle) {
403
+ const lineWidths = toBoxArray(null !== (_j = null === (_h = this.internalProps.theme.frameStyle) || void 0 === _h ? void 0 : _h.borderLineWidth) && void 0 !== _j ? _j : [ null ]), shadowWidths = toBoxArray(null !== (_l = null === (_k = this.internalProps.theme.frameStyle) || void 0 === _k ? void 0 : _k.shadowBlur) && void 0 !== _l ? _l : [ 0 ]);
404
+ (null === (_m = this.theme.frameStyle) || void 0 === _m ? void 0 : _m.innerBorder) ? (this.tableX = 0,
405
+ this.tableY = 0, this.tableNoFrameWidth = width - (null !== (_o = shadowWidths[1]) && void 0 !== _o ? _o : 0),
406
+ this.tableNoFrameHeight = height - (null !== (_p = shadowWidths[2]) && void 0 !== _p ? _p : 0)) : (this.tableX = (null !== (_q = lineWidths[3]) && void 0 !== _q ? _q : 0) + (null !== (_r = shadowWidths[3]) && void 0 !== _r ? _r : 0),
407
+ this.tableY = (null !== (_s = lineWidths[0]) && void 0 !== _s ? _s : 0) + (null !== (_t = shadowWidths[0]) && void 0 !== _t ? _t : 0),
408
+ this.tableNoFrameWidth = width - ((null !== (_u = lineWidths[1]) && void 0 !== _u ? _u : 0) + (null !== (_v = shadowWidths[1]) && void 0 !== _v ? _v : 0)) - ((null !== (_w = lineWidths[3]) && void 0 !== _w ? _w : 0) + (null !== (_x = shadowWidths[3]) && void 0 !== _x ? _x : 0)),
409
+ this.tableNoFrameHeight = height - ((null !== (_y = lineWidths[0]) && void 0 !== _y ? _y : 0) + (null !== (_z = shadowWidths[0]) && void 0 !== _z ? _z : 0)) - ((null !== (_0 = lineWidths[2]) && void 0 !== _0 ? _0 : 0) + (null !== (_1 = shadowWidths[2]) && void 0 !== _1 ? _1 : 0)));
405
410
  }
406
411
  }
412
+ updateViewBox(newViewBox) {
413
+ var _a, _b, _c, _d, _e, _f, _g, _h;
414
+ const oldWidth = null !== (_d = null !== (_b = null === (_a = this.options) || void 0 === _a ? void 0 : _a.viewBox.x2) && void 0 !== _b ? _b : 0 - (null === (_c = this.options) || void 0 === _c ? void 0 : _c.viewBox.x1)) && void 0 !== _d ? _d : 0, oldHeight = null !== (_h = null !== (_f = null === (_e = this.options) || void 0 === _e ? void 0 : _e.viewBox.y2) && void 0 !== _f ? _f : 0 - (null === (_g = this.options) || void 0 === _g ? void 0 : _g.viewBox.y1)) && void 0 !== _h ? _h : 0, newWidth = newViewBox.x2 - newViewBox.x1, newHeight = newViewBox.y2 - newViewBox.y1;
415
+ this.options.viewBox = newViewBox, oldWidth !== newWidth || oldHeight !== newHeight ? this.resize() : this.scenegraph.stage.setViewBox(this.options.viewBox, !0);
416
+ }
417
+ setViewBoxTransform(a, b, c, d, e, f) {
418
+ this.internalProps.modifiedViewBoxTransform = !0, this.scenegraph.stage.window.setViewBoxTransform(a, b, c, d, e, f);
419
+ }
407
420
  get rowHierarchyType() {
408
421
  return "grid";
409
422
  }
@@ -634,41 +647,16 @@ export class BaseTable extends EventTarget {
634
647
  } : null;
635
648
  }
636
649
  getRowAt(absoluteY) {
637
- const frozen = _getTargetFrozenRowAt(this, absoluteY);
638
- if (frozen) return frozen;
639
- let row = this.getTargetRowAt(absoluteY);
640
- return row || (row = {
641
- top: -1,
642
- row: -1,
643
- bottom: -1,
644
- height: -1
645
- }), row;
650
+ return getRowAt(absoluteY, this);
646
651
  }
647
652
  getColAt(absoluteX) {
648
- const frozen = _getTargetFrozenColAt(this, absoluteX);
649
- if (frozen) return frozen;
650
- let col = this.getTargetColAt(absoluteX);
651
- return col || (col = {
652
- left: -1,
653
- col: -1,
654
- right: -1,
655
- width: 1
656
- }), col;
653
+ return getColAt(absoluteX, this);
657
654
  }
658
655
  getCellAt(absoluteX, absoluteY) {
659
- const rowInfo = this.getRowAt(absoluteY), {row: row, top: top, bottom: bottom, height: height} = rowInfo, colInfo = this.getColAt(absoluteX), {col: col, left: left, right: right, width: width} = colInfo;
660
- return {
661
- row: row,
662
- col: col,
663
- rect: {
664
- left: left,
665
- right: right,
666
- top: top,
667
- bottom: bottom,
668
- width: width,
669
- height: height
670
- }
671
- };
656
+ return getCellAt(absoluteX, absoluteY, this);
657
+ }
658
+ getCellAtRelativePosition(relativeX, relativeY) {
659
+ return getCellAtRelativePosition(relativeX, relativeY, this);
672
660
  }
673
661
  _checkRowCol(col, row) {
674
662
  return col >= 0 && col < this.colCount && row >= 0 && row < this.rowCount;
@@ -694,8 +682,11 @@ export class BaseTable extends EventTarget {
694
682
  }));
695
683
  }
696
684
  _toRelativeRect(absoluteRect, relativeX = !0, relativeY = !0) {
685
+ var _a, _b, _c, _d;
697
686
  const rect = absoluteRect.copy(), visibleRect = this.getVisibleRect();
698
687
  return rect.offsetLeft(this.tableX - (relativeX ? visibleRect.left : 0)), rect.offsetTop(this.tableY - (relativeY ? visibleRect.top : 0)),
688
+ rect.offsetLeft(null !== (_b = null === (_a = this.options.viewBox) || void 0 === _a ? void 0 : _a.x1) && void 0 !== _b ? _b : 0),
689
+ rect.offsetTop(null !== (_d = null === (_c = this.options.viewBox) || void 0 === _c ? void 0 : _c.y1) && void 0 !== _d ? _d : 0),
699
690
  rect;
700
691
  }
701
692
  getVisibleRect() {
@@ -800,9 +791,11 @@ export class BaseTable extends EventTarget {
800
791
  internalProps.layoutMap.release(), internalProps.releaseList && (internalProps.releaseList.forEach((releaseObj => {
801
792
  var _a;
802
793
  return null === (_a = null == releaseObj ? void 0 : releaseObj.release) || void 0 === _a ? void 0 : _a.call(releaseObj);
803
- })), internalProps.releaseList = null), this.scenegraph.stage.release(), this.scenegraph.proxy.release();
794
+ })), internalProps.releaseList = null), this.scenegraph.stage.release(), this.scenegraph.proxy.release(),
795
+ internalProps.focusControl.release();
804
796
  const {parentElement: parentElement} = internalProps.element;
805
- parentElement && parentElement.removeChild(internalProps.element), null === (_q = null === (_p = null === (_o = this.editorManager) || void 0 === _o ? void 0 : _o.editingEditor) || void 0 === _p ? void 0 : _p.onEnd) || void 0 === _q || _q.call(_p),
797
+ parentElement && !this.options.canvas && parentElement.removeChild(internalProps.element),
798
+ null === (_q = null === (_p = null === (_o = this.editorManager) || void 0 === _o ? void 0 : _o.editingEditor) || void 0 === _p ? void 0 : _p.onEnd) || void 0 === _q || _q.call(_p),
806
799
  this.isReleased = !0, this.scenegraph = null, this.internalProps = null;
807
800
  }
808
801
  fireListeners(type, event) {
@@ -910,6 +903,7 @@ export class BaseTable extends EventTarget {
910
903
  return new Rect(this.tableX, this.tableY, width, height);
911
904
  }
912
905
  _getMouseAbstractPoint(evt, isAddScroll = !0) {
906
+ var _a, _b, _c, _d;
913
907
  let e;
914
908
  if (!evt) return {
915
909
  inTable: !1,
@@ -920,138 +914,30 @@ export class BaseTable extends EventTarget {
920
914
  const clientX = e.clientX || e.pageX + window.scrollX, clientY = e.clientY || e.pageY + window.scrollY, rect = this.internalProps.canvas.getBoundingClientRect();
921
915
  let inTable = !0;
922
916
  rect.right <= clientX && (inTable = !1), rect.bottom <= clientY && (inTable = !1);
923
- const currentWidth = rect.width, widthRatio = currentWidth / (this.canvas.offsetWidth || currentWidth), currentHeight = rect.height, heightRatio = currentHeight / (this.canvas.offsetHeight || currentHeight);
924
- return {
925
- x: (clientX - rect.left) / widthRatio + (isAddScroll ? this.scrollLeft : 0),
926
- y: (clientY - rect.top) / heightRatio + (isAddScroll ? this.scrollTop : 0),
917
+ const currentWidth = rect.width, widthRatio = currentWidth / (this.canvas.offsetWidth || currentWidth), currentHeight = rect.height, heightRatio = currentHeight / (this.canvas.offsetHeight || currentHeight), point = {
918
+ x: (clientX - rect.left) / widthRatio + (isAddScroll ? this.scrollLeft : 0) - (null !== (_b = null === (_a = this.options.viewBox) || void 0 === _a ? void 0 : _a.x1) && void 0 !== _b ? _b : 0),
919
+ y: (clientY - rect.top) / heightRatio + (isAddScroll ? this.scrollTop : 0) - (null !== (_d = null === (_c = this.options.viewBox) || void 0 === _c ? void 0 : _c.y1) && void 0 !== _d ? _d : 0),
927
920
  inTable: inTable
928
921
  };
922
+ if (this.internalProps.modifiedViewBoxTransform && this.scenegraph.stage.window.getViewBoxTransform()) {
923
+ this.scenegraph.stage.window.getViewBoxTransform().transformPoint(point, point);
924
+ }
925
+ return point;
929
926
  }
930
927
  getTheme() {
931
928
  return this.internalProps.theme;
932
929
  }
933
930
  getTargetColAt(absoluteX) {
934
- if (0 === absoluteX) return {
935
- left: 0,
936
- col: 0,
937
- right: 0,
938
- width: 0
939
- };
940
- const findAfter = (startCol, startRight) => {
941
- let left = startRight - this.getColWidth(startCol);
942
- const {colCount: colCount} = this.internalProps;
943
- for (let col = startCol; col < colCount; col++) {
944
- const width = this.getColWidth(col), right = left + width;
945
- if (Math.round(left) <= Math.round(absoluteX) && Math.round(absoluteX) < Math.round(right)) return {
946
- left: left,
947
- col: col,
948
- right: right,
949
- width: width
950
- };
951
- left = right;
952
- }
953
- return null;
954
- }, candCol = this.computeTargetColByX(absoluteX), right = this.getColsWidth(0, candCol);
955
- return absoluteX >= right ? findAfter(candCol, right) : ((startCol, startRight) => {
956
- let right = startRight;
957
- for (let col = startCol; col >= 0; col--) {
958
- const width = this.getColWidth(col), left = right - width;
959
- if (Math.round(left) <= Math.round(absoluteX) && Math.round(absoluteX) < Math.round(right)) return {
960
- left: left,
961
- col: col,
962
- right: right,
963
- width: width
964
- };
965
- right = left;
966
- }
967
- return null;
968
- })(candCol, right);
931
+ return getTargetColAt(absoluteX, this);
969
932
  }
970
933
  getTargetRowAt(absoluteY) {
971
- if (0 === absoluteY) return {
972
- top: 0,
973
- row: 0,
974
- bottom: 0,
975
- height: 0
976
- };
977
- const findAfter = (startRow, startBottom) => {
978
- let top = startBottom - this.getRowHeight(startRow);
979
- const {rowCount: rowCount} = this.internalProps;
980
- for (let row = startRow; row < rowCount; row++) {
981
- const height = this.getRowHeight(row), bottom = top + height;
982
- if (Math.round(top) <= Math.round(absoluteY) && Math.round(absoluteY) < Math.round(bottom)) return {
983
- top: top,
984
- row: row,
985
- bottom: bottom,
986
- height: height
987
- };
988
- top = bottom;
989
- }
990
- return null;
991
- }, candRow = this.computeTargetRowByY(absoluteY), bottom = this.getRowsHeight(0, candRow);
992
- return absoluteY >= bottom ? findAfter(candRow, bottom) : ((startRow, startBottom) => {
993
- let bottom = startBottom;
994
- for (let row = startRow; row >= 0; row--) {
995
- const height = this.getRowHeight(row), top = bottom - height;
996
- if (Math.round(top) <= Math.round(absoluteY) && Math.round(absoluteY) < Math.round(bottom)) return {
997
- top: top,
998
- row: row,
999
- bottom: bottom,
1000
- height: height
1001
- };
1002
- bottom = top;
1003
- }
1004
- return null;
1005
- })(candRow, bottom);
934
+ return getTargetRowAt(absoluteY, this);
1006
935
  }
1007
936
  getTargetColAtConsiderRightFrozen(absoluteX, isConsider) {
1008
- if (0 === absoluteX) return {
1009
- left: 0,
1010
- col: 0,
1011
- right: 0,
1012
- width: 0
1013
- };
1014
- if (isConsider && absoluteX > this.tableNoFrameWidth - this.getRightFrozenColsWidth() && absoluteX < this.tableNoFrameWidth) for (let i = 0; i < this.rightFrozenColCount; i++) if (absoluteX > this.tableNoFrameWidth - this.getColsWidth(this.colCount - i - 1, this.colCount - 1)) return {
1015
- col: this.colCount - i - 1,
1016
- left: void 0,
1017
- right: void 0,
1018
- width: void 0
1019
- };
1020
- return this.getTargetColAt(absoluteX);
937
+ return getTargetColAtConsiderRightFrozen(absoluteX, isConsider, this);
1021
938
  }
1022
939
  getTargetRowAtConsiderBottomFrozen(absoluteY, isConsider) {
1023
- if (0 === absoluteY) return {
1024
- top: 0,
1025
- row: 0,
1026
- bottom: 0,
1027
- height: 0
1028
- };
1029
- if (isConsider && absoluteY > this.tableNoFrameHeight - this.getBottomFrozenRowsHeight() && absoluteY < this.tableNoFrameHeight) for (let i = 0; i < this.rightFrozenColCount; i++) if (absoluteY > this.tableNoFrameHeight - this.getRowsHeight(this.rowCount - i - 1, this.rowCount - 1)) return {
1030
- row: this.rowCount - i - 1,
1031
- top: void 0,
1032
- bottom: void 0,
1033
- height: void 0
1034
- };
1035
- return this.getTargetRowAt(absoluteY);
1036
- }
1037
- computeTargetRowByY(absoluteY) {
1038
- let defaultRowHeight = this.internalProps.defaultRowHeight;
1039
- return this._rowRangeHeightsMap.get("$0$" + (this.rowCount - 1)) && (defaultRowHeight = this._rowRangeHeightsMap.get("$0$" + (this.rowCount - 1)) / this.rowCount),
1040
- Math.min(Math.ceil(absoluteY / defaultRowHeight), this.rowCount - 1);
1041
- }
1042
- computeTargetColByX(absoluteX) {
1043
- if (this._colRangeWidthsMap.get("$0$" + (this.colCount - 1))) {
1044
- let startCol = 0, endCol = this.colCount - 1;
1045
- for (;endCol - startCol > 1; ) {
1046
- const midCol = Math.floor((startCol + endCol) / 2);
1047
- if (absoluteX < this._colRangeWidthsMap.get(`$0$${midCol}`)) endCol = midCol; else {
1048
- if (!(absoluteX > this._colRangeWidthsMap.get(`$0$${midCol}`))) return midCol;
1049
- startCol = midCol;
1050
- }
1051
- }
1052
- return endCol;
1053
- }
1054
- return Math.min(Math.ceil(absoluteX / this.internalProps.defaultColWidth), this.colCount - 1);
940
+ return getTargetRowAtConsiderBottomFrozen(absoluteY, isConsider, this);
1055
941
  }
1056
942
  clearSelected() {
1057
943
  this.stateManager.updateSelectPos(-1, -1);