e-virt-table 1.0.6 → 1.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.es.js CHANGED
@@ -2248,7 +2248,7 @@ class li {
2248
2248
  this.ctx = t, this.init();
2249
2249
  }
2250
2250
  init() {
2251
- this.bind(window, "resize", this.handleResize.bind(this)), this.bind(window, "mouseup", this.handleMouseUp.bind(this)), this.bind(window, "mousemove", this.handleMousemove.bind(this)), this.bind(this.ctx.stageElement, "click", this.handleClick.bind(this)), this.bind(window, "keydown", this.handleKeydown.bind(this)), this.bind(this.ctx.stageElement, "wheel", this.handleWheel.bind(this)), this.bind(this.ctx.stageElement, "touchstart", this.handleTouchstart.bind(this)), this.bind(this.ctx.stageElement, "touchend", this.handleTouchend.bind(this)), this.bind(this.ctx.stageElement, "touchmove", this.handleTouchmove.bind(this)), this.bind(this.ctx.stageElement, "contextmenu", this.handleContextMenu.bind(this)), this.bind(this.ctx.stageElement, "mousedown", this.handleMouseDown.bind(this)), this.bind(this.ctx.stageElement, "dblclick", this.handleDblclick.bind(this)), this.bind(this.ctx.stageElement, "mouseover", this.handleMouseover.bind(this)), this.bind(this.ctx.stageElement, "mouseout", this.handleMouseout.bind(this));
2251
+ this.bind(window, "resize", this.handleResize.bind(this)), this.bind(window, "mouseup", this.handleMouseUp.bind(this)), this.bind(window, "mousemove", this.handleMousemove.bind(this)), this.bind(this.ctx.stageElement, "click", this.handleClick.bind(this)), this.bind(window, "keydown", this.handleKeydown.bind(this)), this.bind(this.ctx.stageElement, "wheel", this.handleWheel.bind(this)), this.bind(this.ctx.stageElement, "touchstart", this.handleTouchstart.bind(this)), this.bind(this.ctx.stageElement, "touchend", this.handleTouchend.bind(this)), this.bind(this.ctx.stageElement, "touchmove", this.handleTouchmove.bind(this)), this.bind(this.ctx.stageElement, "contextmenu", this.handleContextMenu.bind(this)), this.bind(this.ctx.stageElement, "mousedown", this.handleMouseDown.bind(this)), this.bind(this.ctx.stageElement, "dblclick", this.handleDblclick.bind(this)), this.bind(this.ctx.stageElement, "mouseover", this.handleMouseover.bind(this)), this.bind(this.ctx.stageElement, "mouseout", this.handleMouseout.bind(this)), this.bind(this.ctx.containerElement, "focusin", this.handleFocusin.bind(this)), this.bind(this.ctx.containerElement, "focusout", this.handleFocusout.bind(this));
2252
2252
  }
2253
2253
  destroy() {
2254
2254
  this.eventTasks.forEach((t, e) => {
@@ -2293,11 +2293,17 @@ class li {
2293
2293
  this.ctx.isInsideTargetContainer = !0, this.ctx.emit("mouseover", t);
2294
2294
  }
2295
2295
  handleMouseout(t) {
2296
- this.ctx.isInsideTargetContainer = !1, this.ctx.emit("mouseout", t);
2296
+ this.ctx.emit("mouseout", t);
2297
2297
  }
2298
2298
  handleDblclick(t) {
2299
2299
  this.ctx.emit("dblclick", t);
2300
2300
  }
2301
+ handleFocusin(t) {
2302
+ this.ctx.isInsideTargetContainer = !0, this.ctx.emit("focusin", t);
2303
+ }
2304
+ handleFocusout(t) {
2305
+ this.ctx.isInsideTargetContainer = !1, this.ctx.emit("focusout", t);
2306
+ }
2301
2307
  bind(t, e, i, s) {
2302
2308
  t.addEventListener(e, i, s), this.eventTasks.set(e, i);
2303
2309
  }
@@ -3161,13 +3167,10 @@ class xi {
3161
3167
  this.focusCell !== t && (((e = this.focusCell) == null ? void 0 : e.rowKey) !== t.rowKey && (this.focusCell = t, this.emit("rowFocusChange", t)), this.focusCell = t, this.emit("cellFocusChange", t));
3162
3168
  }
3163
3169
  clearSelector() {
3164
- this.selector = {
3165
- enable: !1,
3166
- xArr: [-1, -1],
3167
- yArr: [-1, -1],
3168
- xArrCopy: [-1, -1],
3169
- yArrCopy: [-1, -1]
3170
- };
3170
+ this.selector.enable = !1, this.selector.xArr = [-1, -1], this.selector.yArr = [-1, -1];
3171
+ }
3172
+ clearSelectorCopy() {
3173
+ this.selector.xArrCopy = [-1, -1], this.selector.yArrCopy = [-1, -1];
3171
3174
  }
3172
3175
  clearAutofill() {
3173
3176
  this.autofill = {
@@ -3388,30 +3391,30 @@ class ui {
3388
3391
  });
3389
3392
  }
3390
3393
  onWheel(t) {
3391
- this.verticalScrollbar.onWheel(t), this.horizontalScrollbar.onWheel(t), this.draw(!0);
3394
+ this.verticalScrollbar.onWheel(t), this.horizontalScrollbar.onWheel(t), this.draw();
3392
3395
  }
3393
3396
  onTouchmove(t) {
3394
- this.verticalScrollbar.onTouchmove(t), this.horizontalScrollbar.onTouchmove(t), this.draw(!0);
3397
+ this.verticalScrollbar.onTouchmove(t), this.horizontalScrollbar.onTouchmove(t), this.draw();
3395
3398
  }
3396
3399
  onTouchstart(t) {
3397
- this.verticalScrollbar.onTouchstart(t), this.horizontalScrollbar.onTouchstart(t), this.draw(!0);
3400
+ this.verticalScrollbar.onTouchstart(t), this.horizontalScrollbar.onTouchstart(t), this.draw();
3398
3401
  }
3399
3402
  onMouseDown(t) {
3400
- this.verticalScrollbar.onMouseDown(t), this.horizontalScrollbar.onMouseDown(t), this.draw(!0);
3403
+ this.verticalScrollbar.onMouseDown(t), this.horizontalScrollbar.onMouseDown(t), this.draw();
3401
3404
  }
3402
3405
  onMouseMove(t) {
3403
- this.verticalScrollbar.onMouseMove(t), this.horizontalScrollbar.onMouseMove(t), this.draw(!0);
3406
+ this.verticalScrollbar.onMouseMove(t), this.horizontalScrollbar.onMouseMove(t), this.draw();
3404
3407
  }
3405
3408
  onMouseUp() {
3406
3409
  this.verticalScrollbar.onMouseUp(), this.horizontalScrollbar.onMouseUp(), this.ctx.scrollerMove = !1;
3407
3410
  }
3408
- draw(t = !1) {
3411
+ draw() {
3409
3412
  this.verticalScrollbar.draw(), this.horizontalScrollbar.draw();
3410
- const e = Math.floor(this.horizontalScrollbar.scroll), i = Math.floor(this.verticalScrollbar.scroll);
3411
- (e !== this.ctx.scrollX || i !== this.ctx.scrollY) && (this.ctx.emit("onScroll", e, i, t), e !== this.ctx.scrollX && this.ctx.emit("onScrollX", e, t), i !== this.ctx.scrollY && this.ctx.emit("onScrollY", i, t), this.ctx.scrollX = e, this.ctx.scrollY = i, this.ctx.emit("draw"));
3413
+ const t = Math.floor(this.horizontalScrollbar.scroll), e = Math.floor(this.verticalScrollbar.scroll);
3414
+ (t !== this.ctx.scrollX || e !== this.ctx.scrollY) && (this.ctx.emit("onScroll", t, e), t !== this.ctx.scrollX && this.ctx.emit("onScrollX", t), e !== this.ctx.scrollY && this.ctx.emit("onScrollY", e), this.ctx.scrollX = t, this.ctx.scrollY = e, this.ctx.emit("draw"));
3412
3415
  }
3413
3416
  setScroll(t, e) {
3414
- this.horizontalScrollbar.scroll = t, this.verticalScrollbar.scroll = e, this.ctx.emit("draw");
3417
+ this.horizontalScrollbar.scroll = t, this.verticalScrollbar.scroll = e, this.ctx.emit("draw"), this.ctx.emit("onScroll", t, e);
3415
3418
  }
3416
3419
  setScrollX(t) {
3417
3420
  this.horizontalScrollbar.scroll = t, this.ctx.emit("draw");
@@ -3872,19 +3875,25 @@ class wi {
3872
3875
  }
3873
3876
  update() {
3874
3877
  this.init();
3875
- const { header: t, database: e, scrollY: i } = this.ctx, s = i, { data: r, positions: o } = e.getData();
3876
- this.ctx.maxRowIndex = r.length - 1;
3877
- const n = this.binarySearch(o, s);
3878
- if (n === -1)
3879
- return;
3880
- let h = this.binarySearch(o, s + this.visibleHeight);
3881
- h === -1 && (h = r.length), this.headIndex = Math.max(0, n), this.tailIndex = Math.min(this.ctx.maxRowIndex, h + 1), this.visibleRows = r.slice(this.headIndex, this.tailIndex + 1), this.ctx.body.headIndex = this.headIndex, this.ctx.body.tailIndex = this.tailIndex, this.ctx.body.visibleRows = this.visibleRows;
3882
- const c = [];
3883
- for (let d = 0; d < this.visibleRows.length; d++) {
3884
- const f = this.headIndex + d, u = this.visibleRows[d], { height: x, top: p } = this.ctx.database.getPositionForRowIndex(f), g = new oe(this.ctx, f, 0, p + this.y, t.width, x, u);
3885
- c.push(g);
3878
+ const {
3879
+ header: t,
3880
+ database: e,
3881
+ scrollY: i,
3882
+ config: { CELL_HEIGHT: s }
3883
+ } = this.ctx, r = i, { data: o, positions: n } = e.getData();
3884
+ this.ctx.maxRowIndex = o.length - 1;
3885
+ let h = this.binarySearch(n, r), c = this.binarySearch(n, r + this.visibleHeight);
3886
+ if (c === -1 && (c = this.ctx.maxRowIndex), h === -1 && c === this.ctx.maxRowIndex) {
3887
+ const f = Math.floor(this.visibleHeight / s);
3888
+ h = this.ctx.maxRowIndex - f;
3889
+ }
3890
+ this.headIndex = Math.max(0, h), this.tailIndex = Math.min(this.ctx.maxRowIndex, c + 1), this.visibleRows = o.slice(this.headIndex, this.tailIndex + 1), this.ctx.body.headIndex = this.headIndex, this.ctx.body.tailIndex = this.tailIndex, this.ctx.body.visibleRows = this.visibleRows;
3891
+ const d = [];
3892
+ for (let f = 0; f < this.visibleRows.length; f++) {
3893
+ const u = this.headIndex + f, x = this.visibleRows[f], { height: p, top: g } = this.ctx.database.getPositionForRowIndex(u), w = new oe(this.ctx, u, 0, g + this.y, t.width, p, x);
3894
+ d.push(w);
3886
3895
  }
3887
- this.renderRows = c, this.ctx.body.renderRows = c;
3896
+ this.renderRows = d, this.ctx.body.renderRows = d;
3888
3897
  }
3889
3898
  draw() {
3890
3899
  this.renderRows.forEach((t) => {
@@ -3976,7 +3985,11 @@ class yi {
3976
3985
  this.ctx = t, this.init();
3977
3986
  }
3978
3987
  init() {
3979
- this.ctx.on(
3988
+ this.ctx.on("focusout", () => {
3989
+ this.ctx.clearSelector(), this.ctx.emit("draw");
3990
+ }), this.ctx.on("setMoveFocus", (t) => {
3991
+ this.moveFocus(t);
3992
+ }), this.ctx.on(
3980
3993
  "mousemove",
3981
3994
  Jt((t) => {
3982
3995
  const { offsetY: e, offsetX: i } = this.ctx.getOffset(t), s = this.ctx.isTarget() && i > 0 && i < this.ctx.body.visibleWidth && e > this.ctx.header.visibleHeight && e < this.ctx.header.visibleHeight + this.ctx.body.visibleHeight;
@@ -4033,7 +4046,7 @@ class yi {
4033
4046
  t.preventDefault(), this.moveFocus("RIGHT");
4034
4047
  return;
4035
4048
  }
4036
- if (t.code === "ArrowDown") {
4049
+ if (t.code === "ArrowDown" || t.code === "Enter") {
4037
4050
  t.preventDefault(), this.moveFocus("BOTTOM");
4038
4051
  return;
4039
4052
  }
@@ -5619,13 +5632,17 @@ class Zi {
5619
5632
  this.ctx = t, this.initTextEditor(), this.init();
5620
5633
  }
5621
5634
  init() {
5622
- this.ctx.on("onScroll", () => {
5635
+ this.ctx.on("focusout", () => {
5636
+ this.ctx.editing || (this.cellTarget = null);
5637
+ }), this.ctx.on("onScroll", () => {
5623
5638
  this.enable && this.doneEdit();
5624
5639
  }), this.ctx.on("cellHeaderMousedown", () => {
5625
5640
  this.enable && this.doneEdit(), this.cellTarget = null;
5626
5641
  }), this.ctx.on("keydown", (t) => {
5642
+ if (!this.ctx.isTarget())
5643
+ return;
5627
5644
  const e = t.key, i = t.ctrlKey, s = t.altKey, r = t.shiftKey, o = t.metaKey;
5628
- if (!(i || s || r || o || [
5645
+ i || s || r || o || [
5629
5646
  // "Enter",
5630
5647
  "Escape",
5631
5648
  "Tab",
@@ -5651,14 +5668,9 @@ class Zi {
5651
5668
  "F9",
5652
5669
  "F10",
5653
5670
  "F11",
5654
- "F12"
5655
- ].includes(e))) {
5656
- if (t.code === "Enter" && !this.enable) {
5657
- t.preventDefault(), this.startEdit();
5658
- return;
5659
- }
5660
- this.startEdit();
5661
- }
5671
+ "F12",
5672
+ "Enter"
5673
+ ].includes(e) || this.startEdit();
5662
5674
  }), this.ctx.on("adjustBoundaryPosition", (t) => {
5663
5675
  this.cellTarget = t;
5664
5676
  const { xArr: e, yArr: i } = this.ctx.selector;
@@ -5700,7 +5712,7 @@ class Zi {
5700
5712
  ` + s, this.inputEl.selectionStart = this.inputEl.selectionEnd = e + 1, this.autoSize();
5701
5713
  return;
5702
5714
  }
5703
- (t.code === "Escape" || t.code === "Enter") && (t.preventDefault(), this.inputEl.blur());
5715
+ (t.code === "Escape" || t.code === "Enter") && (t.preventDefault(), this.inputEl.blur(), this.ctx.emit("setMoveFocus", "BOTTOM"));
5704
5716
  }
5705
5717
  }), this.inputEl.addEventListener("input", this.autoSize.bind(this)), this.inputEl.addEventListener("blur", () => {
5706
5718
  this.doneEdit();
@@ -6112,7 +6124,7 @@ class ss {
6112
6124
  createContainer(t, e, i, s, r) {
6113
6125
  t.className = "e-virt-table-container";
6114
6126
  const o = document.createElement("div"), n = document.createElement("canvas"), h = e || document.createElement("div");
6115
- o.className = "e-virt-table-stage", n.className = "e-virt-table-canvas", h.className = "e-virt-table-overlayer";
6127
+ o.className = "e-virt-table-stage", t.tabIndex = 0, n.className = "e-virt-table-canvas", h.className = "e-virt-table-overlayer";
6116
6128
  const c = i || document.createElement("div");
6117
6129
  c.className = "e-virt-table-editor";
6118
6130
  const d = s, f = r;
@@ -6227,10 +6239,10 @@ class ss {
6227
6239
  return this.ctx.database.hasValidationError();
6228
6240
  }
6229
6241
  scrollTo(t, e) {
6230
- this.scrollXTo(t), this.scrollYTo(e);
6242
+ this.scroller.setScroll(t, e);
6231
6243
  }
6232
6244
  scrollXTo(t) {
6233
- this.ctx.setScrollX(t);
6245
+ this.scroller.setScrollX(t);
6234
6246
  }
6235
6247
  scrollToColkey(t) {
6236
6248
  this.scroller.scrollToColkey(t);
@@ -6245,7 +6257,7 @@ class ss {
6245
6257
  this.scroller.scrollToRowIndex(t);
6246
6258
  }
6247
6259
  scrollYTo(t) {
6248
- this.ctx.setScrollY(t);
6260
+ this.scroller.setScrollY(t);
6249
6261
  }
6250
6262
  setExpandRowKeys(t, e = !0) {
6251
6263
  this.ctx.database.setExpandRowKeys(t, e);