e-virt-table 0.0.12 → 0.0.13

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
@@ -378,7 +378,7 @@ var Ut = function(t, e, i, s, o, r) {
378
378
  v.required(t, e, s, r, o), e !== void 0 && (v.type(t, e, s, r, o), v.range(t, e, s, r, o));
379
379
  }
380
380
  i(r);
381
- }, Ve = function(t, e, i, s, o) {
381
+ }, ze = function(t, e, i, s, o) {
382
382
  var r = [], n = t.required || !t.required && s.hasOwnProperty(t.field);
383
383
  if (n) {
384
384
  if (e == null && !t.required)
@@ -386,7 +386,7 @@ var Ut = function(t, e, i, s, o, r) {
386
386
  v.required(t, e, s, r, o, "array"), e != null && (v.type(t, e, s, r, o), v.range(t, e, s, r, o));
387
387
  }
388
388
  i(r);
389
- }, ze = function(t, e, i, s, o) {
389
+ }, Ve = function(t, e, i, s, o) {
390
390
  var r = [], n = t.required || !t.required && s.hasOwnProperty(t.field);
391
391
  if (n) {
392
392
  if (I(e) && !t.required)
@@ -448,8 +448,8 @@ var Ut = function(t, e, i, s, o, r) {
448
448
  regexp: Be,
449
449
  integer: We,
450
450
  float: Pe,
451
- array: Ve,
452
- object: ze,
451
+ array: ze,
452
+ object: Ve,
453
453
  enum: qe,
454
454
  pattern: Ge,
455
455
  date: je,
@@ -2816,7 +2816,7 @@ class li {
2816
2816
  this.eventTable.destroy(), this.eventBrowser.destroy(), this.eventBus.destroy();
2817
2817
  }
2818
2818
  }
2819
- class Vt {
2819
+ class zt {
2820
2820
  constructor(t, e) {
2821
2821
  c(this, "ctx");
2822
2822
  c(this, "type");
@@ -2849,6 +2849,8 @@ class Vt {
2849
2849
  onMouseDown(t) {
2850
2850
  if (!(t.target instanceof HTMLCanvasElement) || !this.ctx.isTarget(t.target))
2851
2851
  return;
2852
+ if (this.ctx.target.style.cursor === "row-resize" || this.ctx.target.style.cursor === "col-resize")
2853
+ return !0;
2852
2854
  const { offsetX: e, offsetY: i, clientX: s, clientY: o } = t;
2853
2855
  if (!(s == this.clientX && o == this.clientY)) {
2854
2856
  if (this.isOnScrollbar(e, i))
@@ -2928,7 +2930,7 @@ class hi {
2928
2930
  c(this, "ctx");
2929
2931
  c(this, "verticalScrollbar");
2930
2932
  c(this, "horizontalScrollbar");
2931
- this.ctx = t, this.verticalScrollbar = new Vt(t, "vertical"), this.horizontalScrollbar = new Vt(t, "horizontal"), this.ctx.on("wheel", (e) => this.onWheel(e)), this.ctx.on("mousedown", (e) => this.onMouseDown(e)), this.ctx.on("mousemove", (e) => this.onMouseMove(e)), this.ctx.on("mouseup", () => this.onMouseUp()), this.ctx.on("setScroll", (e, i) => {
2933
+ this.ctx = t, this.verticalScrollbar = new zt(t, "vertical"), this.horizontalScrollbar = new zt(t, "horizontal"), this.ctx.on("wheel", (e) => this.onWheel(e)), this.ctx.on("mousedown", (e) => this.onMouseDown(e)), this.ctx.on("mousemove", (e) => this.onMouseMove(e)), this.ctx.on("mouseup", () => this.onMouseUp()), this.ctx.on("setScroll", (e, i) => {
2932
2934
  this.setScroll(e, i);
2933
2935
  }), this.ctx.on("setScrollX", (e) => {
2934
2936
  this.setScrollX(e);
@@ -2997,7 +2999,7 @@ class di {
2997
2999
  // 调整列的数量
2998
3000
  c(this, "isResizing", !1);
2999
3001
  // 是否移动中
3000
- c(this, "offsetX", 0);
3002
+ c(this, "clientX", 0);
3001
3003
  // 鼠标按下时的x轴位置
3002
3004
  c(this, "resizeDiff", 0);
3003
3005
  // 是否移动中
@@ -3050,9 +3052,9 @@ class di {
3050
3052
  config: { ENABLE_RESIZE_COLUMN: t }
3051
3053
  } = this.ctx;
3052
3054
  t && (this.ctx.on("mousedown", (e) => {
3053
- this.ctx.isTarget(e.target) && (this.offsetX = e.offsetX, this.resizeTarget ? (this.isResizing = !0, this.ctx.columnResizing = !0) : this.isResizing = !1, this.isMouseDown = !0);
3055
+ this.ctx.isTarget(e.target) && (this.clientX = e.clientX, this.resizeTarget ? (this.isResizing = !0, this.ctx.columnResizing = !0) : this.isResizing = !1, this.isMouseDown = !0);
3054
3056
  }), this.ctx.on("mouseup", () => {
3055
- this.isMouseDown = !1, this.resizeDiff !== 0 && this.resizeTarget && this.resizeColumn(this.resizeTarget, this.resizeDiff), this.resizeTarget = null, this.isResizing = !1, this.ctx.columnResizing = !1, this.offsetX = 0;
3057
+ this.isMouseDown = !1, this.resizeDiff !== 0 && this.resizeTarget && this.resizeColumn(this.resizeTarget, this.resizeDiff), this.resizeTarget = null, this.isResizing = !1, this.ctx.columnResizing = !1, this.clientX = 0;
3056
3058
  }), this.ctx.on("mousemove", (e) => {
3057
3059
  if (this.ctx.editing) return;
3058
3060
  const {
@@ -3061,7 +3063,7 @@ class di {
3061
3063
  } = this.ctx;
3062
3064
  if (this.isResizing && this.resizeTarget) {
3063
3065
  const o = this.resizeTarget.width;
3064
- let r = e.offsetX - this.offsetX;
3066
+ let r = e.clientX - this.clientX;
3065
3067
  r + o < s && (r = -(o - s)), this.resizeDiff = r, this.ctx.emit("draw");
3066
3068
  } else {
3067
3069
  if (this.resizeTarget = null, this.isMouseDown)
@@ -3248,7 +3250,7 @@ class fi {
3248
3250
  // 是否按下
3249
3251
  c(this, "resizeDiff", 0);
3250
3252
  // 是否移动中
3251
- c(this, "offsetY", 0);
3253
+ c(this, "clientY", 0);
3252
3254
  // 鼠标按下时的y轴位置
3253
3255
  c(this, "ctx");
3254
3256
  c(this, "x", 0);
@@ -3322,30 +3324,30 @@ class fi {
3322
3324
  t && (this.ctx.on("mouseup", () => {
3323
3325
  this.isMouseDown = !1, this.resizeDiff !== 0 && this.resizeTarget && this.resizeRow(this.resizeTarget, this.resizeDiff), this.resizeTarget = null, this.resizeDiff = 0, this.isResizing = !1, setTimeout(() => {
3324
3326
  this.ctx.rowResizing = !1;
3325
- }, 0), this.offsetY = 0;
3327
+ }, 0), this.clientY = 0;
3326
3328
  }), this.ctx.on("mousedown", (e) => {
3327
- this.ctx.isTarget(e.target) && (this.offsetY = e.offsetY, this.resizeTarget ? (this.isResizing = !0, this.ctx.rowResizing = !0) : (this.isResizing = !1, this.ctx.rowResizing = !1), this.isMouseDown = !0);
3329
+ this.ctx.isTarget(e.target) && (this.clientY = e.clientY, this.resizeTarget ? (this.isResizing = !0, this.ctx.rowResizing = !0) : (this.isResizing = !1, this.ctx.rowResizing = !1), this.isMouseDown = !0);
3328
3330
  }), this.ctx.on("mousemove", (e) => {
3329
3331
  if (this.ctx.editing) return;
3330
- const i = e.offsetY, s = e.offsetX, {
3331
- target: o,
3332
- scrollY: r,
3333
- config: { RESIZE_ROW_MIN_HEIGHT: n = 0 }
3332
+ const i = e.offsetY, s = e.offsetX, o = e.clientY, {
3333
+ target: r,
3334
+ scrollY: n,
3335
+ config: { RESIZE_ROW_MIN_HEIGHT: l = 0 }
3334
3336
  } = this.ctx;
3335
3337
  if (this.isResizing && this.resizeTarget) {
3336
- const l = this.resizeTarget.height;
3337
- let h = i - this.offsetY;
3338
- h + l < n && (h = -(l - n)), this.resizeDiff = h, this.ctx.emit("draw");
3338
+ const h = this.resizeTarget.height;
3339
+ let f = o - this.clientY;
3340
+ f + h < l && (f = -(h - l)), this.resizeDiff = f, this.ctx.emit("draw");
3339
3341
  } else {
3340
3342
  if (this.resizeTarget = null, this.isMouseDown || this.ctx.target.style.cursor === "crosshair")
3341
3343
  return;
3342
3344
  this.ctx.target.style.cursor === "row-resize" && (this.ctx.target.style.cursor = "default");
3343
- for (let l = 0; l < this.renderRows.length; l++) {
3344
- const h = this.renderRows[l];
3345
- if (i > h.y - r + h.height - 1.5 && i < h.y - r + h.height + 1.5 && i < o.height - 4)
3346
- for (let d = 0; d < h.cells.length; d++) {
3347
- const x = h.cells[d];
3348
- s > x.drawX + 10 && s < x.drawX + x.width - 10 && x.rowspan === 1 && (this.ctx.target.style.cursor = "row-resize", this.resizeTarget = h);
3345
+ for (let h = 0; h < this.renderRows.length; h++) {
3346
+ const f = this.renderRows[h];
3347
+ if (i > f.y - n + f.height - 1.5 && i < f.y - n + f.height + 1.5 && i < r.height - 4)
3348
+ for (let x = 0; x < f.cells.length; x++) {
3349
+ const u = f.cells[x];
3350
+ s > u.drawX + 10 && s < u.drawX + u.width - 10 && u.rowspan === 1 && (this.ctx.target.style.cursor = "row-resize", this.resizeTarget = f);
3349
3351
  }
3350
3352
  }
3351
3353
  }
@@ -3620,7 +3622,7 @@ class ui {
3620
3622
  }
3621
3623
  }
3622
3624
  selectCols(t) {
3623
- if (this.ctx.config.ENABLE_SELECTOR_SINGLE || !this.ctx.config.ENABLE_SELECTOR_ALL_ROWS || this.ctx.autofillMove || this.ctx.columnResizing)
3625
+ if (this.ctx.config.ENABLE_SELECTOR_SINGLE || !this.ctx.config.ENABLE_SELECTOR_ALL_ROWS || this.ctx.autofillMove || this.ctx.columnResizing || this.ctx.editing)
3624
3626
  return;
3625
3627
  if (t.operation) {
3626
3628
  this.selectAll();
@@ -3642,7 +3644,7 @@ class ui {
3642
3644
  }
3643
3645
  }
3644
3646
  selectAll() {
3645
- if (this.ctx.autofillMove)
3647
+ if (this.ctx.autofillMove || this.ctx.editing)
3646
3648
  return;
3647
3649
  const { ENABLE_SELECTOR_ALL_ROWS: t, ENABLE_SELECTOR_ALL_COLS: e } = this.ctx.config;
3648
3650
  if (t && e) {
@@ -3651,7 +3653,7 @@ class ui {
3651
3653
  }
3652
3654
  }
3653
3655
  selectRows(t, e = !0) {
3654
- if (this.ctx.config.ENABLE_SELECTOR_SINGLE || !this.ctx.config.ENABLE_SELECTOR_ALL_COLS || this.ctx.autofillMove)
3656
+ if (this.ctx.config.ENABLE_SELECTOR_SINGLE || !this.ctx.config.ENABLE_SELECTOR_ALL_COLS || this.ctx.autofillMove || this.ctx.editing)
3655
3657
  return;
3656
3658
  const { SELECTOR_AREA_MIN_X: i, SELECTOR_AREA_MAX_X: s } = this.ctx.config, o = s || this.ctx.maxColIndex, r = i;
3657
3659
  if (e) {
@@ -3671,7 +3673,7 @@ class ui {
3671
3673
  }
3672
3674
  }
3673
3675
  mouseenter() {
3674
- if (this.ctx.config.ENABLE_SELECTOR_SINGLE)
3676
+ if (this.ctx.config.ENABLE_SELECTOR_SINGLE || this.ctx.editing)
3675
3677
  return;
3676
3678
  const { mousedown: t, focusCell: e, hoverCell: i } = this.ctx;
3677
3679
  if (t && e && i) {
@@ -3975,7 +3977,7 @@ class gi {
3975
3977
  destroy() {
3976
3978
  }
3977
3979
  }
3978
- const rt = Math.min, U = Math.max, ft = Math.round, V = (a) => ({
3980
+ const rt = Math.min, U = Math.max, ft = Math.round, z = (a) => ({
3979
3981
  x: a,
3980
3982
  y: a
3981
3983
  }), wi = {
@@ -4080,7 +4082,7 @@ function ut(a) {
4080
4082
  y: e
4081
4083
  };
4082
4084
  }
4083
- function zt(a, t, e) {
4085
+ function Vt(a, t, e) {
4084
4086
  let {
4085
4087
  reference: i,
4086
4088
  floating: s
@@ -4142,7 +4144,7 @@ const vi = async (a, t, e) => {
4142
4144
  }), {
4143
4145
  x: f,
4144
4146
  y: d
4145
- } = zt(h, i, l), x = i, u = {}, y = 0;
4147
+ } = Vt(h, i, l), x = i, u = {}, y = 0;
4146
4148
  for (let g = 0; g < n.length; g++) {
4147
4149
  const {
4148
4150
  name: w,
@@ -4179,7 +4181,7 @@ const vi = async (a, t, e) => {
4179
4181
  }) : C.rects), {
4180
4182
  x: f,
4181
4183
  y: d
4182
- } = zt(h, x, l)), g = -1);
4184
+ } = Vt(h, x, l)), g = -1);
4183
4185
  }
4184
4186
  return {
4185
4187
  x: f,
@@ -4509,13 +4511,13 @@ function Dt(a) {
4509
4511
  return e.transform !== "none" || e.perspective !== "none" || (e.containerType ? e.containerType !== "normal" : !1) || !t && (e.backdropFilter ? e.backdropFilter !== "none" : !1) || !t && (e.filter ? e.filter !== "none" : !1) || ["transform", "perspective", "filter"].some((i) => (e.willChange || "").includes(i)) || ["paint", "layout", "strict", "content"].some((i) => (e.contain || "").includes(i));
4510
4512
  }
4511
4513
  function Li(a) {
4512
- let t = z(a);
4514
+ let t = V(a);
4513
4515
  for (; N(t) && !Q(t); ) {
4514
4516
  if (Dt(t))
4515
4517
  return t;
4516
4518
  if (wt(t))
4517
4519
  return null;
4518
- t = z(t);
4520
+ t = V(t);
4519
4521
  }
4520
4522
  return null;
4521
4523
  }
@@ -4537,7 +4539,7 @@ function pt(a) {
4537
4539
  scrollTop: a.scrollY
4538
4540
  };
4539
4541
  }
4540
- function z(a) {
4542
+ function V(a) {
4541
4543
  if (tt(a) === "html")
4542
4544
  return a;
4543
4545
  const t = (
@@ -4550,7 +4552,7 @@ function z(a) {
4550
4552
  return $t(t) ? t.host : t;
4551
4553
  }
4552
4554
  function ce(a) {
4553
- const t = z(a);
4555
+ const t = V(a);
4554
4556
  return Q(t) ? a.ownerDocument ? a.ownerDocument.body : a.body : N(t) && lt(t) ? t : ce(t);
4555
4557
  }
4556
4558
  function St(a, t, e) {
@@ -4582,7 +4584,7 @@ function he(a) {
4582
4584
  function Z(a) {
4583
4585
  const t = he(a);
4584
4586
  if (!N(t))
4585
- return V(1);
4587
+ return z(1);
4586
4588
  const e = t.getBoundingClientRect(), {
4587
4589
  width: i,
4588
4590
  height: s,
@@ -4594,7 +4596,7 @@ function Z(a) {
4594
4596
  y: n
4595
4597
  };
4596
4598
  }
4597
- const Ai = /* @__PURE__ */ V(0);
4599
+ const Ai = /* @__PURE__ */ z(0);
4598
4600
  function de(a) {
4599
4601
  const t = H(a);
4600
4602
  return !Xt() || !t.visualViewport ? Ai : {
@@ -4608,9 +4610,9 @@ function Mi(a, t, e) {
4608
4610
  function ot(a, t, e, i) {
4609
4611
  t === void 0 && (t = !1), e === void 0 && (e = !1);
4610
4612
  const s = a.getBoundingClientRect(), o = he(a);
4611
- let r = V(1);
4613
+ let r = z(1);
4612
4614
  t && (i ? X(i) && (r = Z(i)) : r = Z(a));
4613
- const n = Mi(o, e, i) ? de(o) : V(0);
4615
+ const n = Mi(o, e, i) ? de(o) : z(0);
4614
4616
  let l = (s.left + n.x) / r.x, h = (s.top + n.y) / r.y, f = s.width / r.x, d = s.height / r.y;
4615
4617
  if (o) {
4616
4618
  const x = H(o), u = i && X(i) ? H(i) : i;
@@ -4640,8 +4642,8 @@ function Hi(a) {
4640
4642
  let l = {
4641
4643
  scrollLeft: 0,
4642
4644
  scrollTop: 0
4643
- }, h = V(1);
4644
- const f = V(0), d = N(i);
4645
+ }, h = z(1);
4646
+ const f = z(0), d = N(i);
4645
4647
  if ((d || !d && !o) && ((tt(i) !== "body" || lt(r)) && (l = pt(i)), N(i))) {
4646
4648
  const x = ot(i);
4647
4649
  h = Z(i), f.x = x.x + i.clientLeft, f.y = x.y + i.clientTop;
@@ -4687,7 +4689,7 @@ function ki(a, t) {
4687
4689
  };
4688
4690
  }
4689
4691
  function Fi(a, t) {
4690
- const e = ot(a, !0, t === "fixed"), i = e.top + a.clientTop, s = e.left + a.clientLeft, o = N(a) ? Z(a) : V(1), r = a.clientWidth * o.x, n = a.clientHeight * o.y, l = s * o.x, h = i * o.y;
4692
+ const e = ot(a, !0, t === "fixed"), i = e.top + a.clientTop, s = e.left + a.clientLeft, o = N(a) ? Z(a) : z(1), r = a.clientWidth * o.x, n = a.clientHeight * o.y, l = s * o.x, h = i * o.y;
4691
4693
  return {
4692
4694
  width: r,
4693
4695
  height: n,
@@ -4714,7 +4716,7 @@ function qt(a, t, e) {
4714
4716
  return ut(i);
4715
4717
  }
4716
4718
  function fe(a, t) {
4717
- const e = z(a);
4719
+ const e = V(a);
4718
4720
  return e === t || !X(e) || Q(e) ? !1 : k(e).position === "fixed" || fe(e, t);
4719
4721
  }
4720
4722
  function Ni(a, t) {
@@ -4723,10 +4725,10 @@ function Ni(a, t) {
4723
4725
  return e;
4724
4726
  let i = St(a, [], !1).filter((n) => X(n) && tt(n) !== "body"), s = null;
4725
4727
  const o = k(a).position === "fixed";
4726
- let r = o ? z(a) : a;
4728
+ let r = o ? V(a) : a;
4727
4729
  for (; X(r) && !Q(r); ) {
4728
4730
  const n = k(r), l = Dt(r);
4729
- !l && n.position === "fixed" && (s = null), (o ? !l && !s : !l && n.position === "static" && !!s && ["absolute", "fixed"].includes(s.position) || lt(r) && !l && fe(a, r)) ? i = i.filter((f) => f !== r) : s = n, r = z(r);
4731
+ !l && n.position === "fixed" && (s = null), (o ? !l && !s : !l && n.position === "static" && !!s && ["absolute", "fixed"].includes(s.position) || lt(r) && !l && fe(a, r)) ? i = i.filter((f) => f !== r) : s = n, r = V(r);
4730
4732
  }
4731
4733
  return t.set(a, i), i;
4732
4734
  }
@@ -4764,7 +4766,7 @@ function Bi(a, t, e) {
4764
4766
  scrollLeft: 0,
4765
4767
  scrollTop: 0
4766
4768
  };
4767
- const l = V(0);
4769
+ const l = z(0);
4768
4770
  if (i || !i && !o)
4769
4771
  if ((tt(t) !== "body" || lt(s)) && (n = pt(t)), i) {
4770
4772
  const u = ot(t, !0, o, t);
@@ -4800,11 +4802,11 @@ function xe(a, t) {
4800
4802
  if (wt(a))
4801
4803
  return e;
4802
4804
  if (!N(a)) {
4803
- let s = z(a);
4805
+ let s = V(a);
4804
4806
  for (; s && !Q(s); ) {
4805
4807
  if (X(s) && !mt(s))
4806
4808
  return s;
4807
- s = z(s);
4809
+ s = V(s);
4808
4810
  }
4809
4811
  return e;
4810
4812
  }
@@ -4828,7 +4830,7 @@ const Wi = async function(a) {
4828
4830
  function Pi(a) {
4829
4831
  return k(a).direction === "rtl";
4830
4832
  }
4831
- const Vi = {
4833
+ const zi = {
4832
4834
  convertOffsetParentRelativeRectToViewportRelativeRect: Hi,
4833
4835
  getDocumentElement: K,
4834
4836
  getClippingRect: Yi,
@@ -4839,9 +4841,9 @@ const Vi = {
4839
4841
  getScale: Z,
4840
4842
  isElement: X,
4841
4843
  isRTL: Pi
4842
- }, ue = Oi, ge = Si, we = Ii, zi = Ri, pe = (a, t, e) => {
4844
+ }, ue = Oi, ge = Si, we = Ii, Vi = Ri, pe = (a, t, e) => {
4843
4845
  const i = /* @__PURE__ */ new Map(), s = {
4844
- platform: Vi,
4846
+ platform: zi,
4845
4847
  ...e
4846
4848
  }, o = {
4847
4849
  ...s.platform,
@@ -4922,7 +4924,7 @@ let $i = class {
4922
4924
  }
4923
4925
  }, this.floatingEl, {
4924
4926
  placement: t.overflowTooltipPlacement,
4925
- middleware: [ge(), we(), ue(6), zi({ element: this.arrowEl })]
4927
+ middleware: [ge(), we(), ue(6), Vi({ element: this.arrowEl })]
4926
4928
  }).then((n) => {
4927
4929
  const { x: l, y: h, placement: f, middlewareData: d } = n;
4928
4930
  if (Object.assign(this.floatingEl.style, {