e-virt-table 0.0.11 → 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");
@@ -2847,6 +2847,10 @@ class Vt {
2847
2847
  this.updateScroll(t);
2848
2848
  }
2849
2849
  onMouseDown(t) {
2850
+ if (!(t.target instanceof HTMLCanvasElement) || !this.ctx.isTarget(t.target))
2851
+ return;
2852
+ if (this.ctx.target.style.cursor === "row-resize" || this.ctx.target.style.cursor === "col-resize")
2853
+ return !0;
2850
2854
  const { offsetX: e, offsetY: i, clientX: s, clientY: o } = t;
2851
2855
  if (!(s == this.clientX && o == this.clientY)) {
2852
2856
  if (this.isOnScrollbar(e, i))
@@ -2926,7 +2930,7 @@ class hi {
2926
2930
  c(this, "ctx");
2927
2931
  c(this, "verticalScrollbar");
2928
2932
  c(this, "horizontalScrollbar");
2929
- 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) => {
2930
2934
  this.setScroll(e, i);
2931
2935
  }), this.ctx.on("setScrollX", (e) => {
2932
2936
  this.setScrollX(e);
@@ -2995,7 +2999,7 @@ class di {
2995
2999
  // 调整列的数量
2996
3000
  c(this, "isResizing", !1);
2997
3001
  // 是否移动中
2998
- c(this, "offsetX", 0);
3002
+ c(this, "clientX", 0);
2999
3003
  // 鼠标按下时的x轴位置
3000
3004
  c(this, "resizeDiff", 0);
3001
3005
  // 是否移动中
@@ -3048,9 +3052,9 @@ class di {
3048
3052
  config: { ENABLE_RESIZE_COLUMN: t }
3049
3053
  } = this.ctx;
3050
3054
  t && (this.ctx.on("mousedown", (e) => {
3051
- 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);
3052
3056
  }), this.ctx.on("mouseup", () => {
3053
- 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;
3054
3058
  }), this.ctx.on("mousemove", (e) => {
3055
3059
  if (this.ctx.editing) return;
3056
3060
  const {
@@ -3059,7 +3063,7 @@ class di {
3059
3063
  } = this.ctx;
3060
3064
  if (this.isResizing && this.resizeTarget) {
3061
3065
  const o = this.resizeTarget.width;
3062
- let r = e.offsetX - this.offsetX;
3066
+ let r = e.clientX - this.clientX;
3063
3067
  r + o < s && (r = -(o - s)), this.resizeDiff = r, this.ctx.emit("draw");
3064
3068
  } else {
3065
3069
  if (this.resizeTarget = null, this.isMouseDown)
@@ -3246,7 +3250,7 @@ class fi {
3246
3250
  // 是否按下
3247
3251
  c(this, "resizeDiff", 0);
3248
3252
  // 是否移动中
3249
- c(this, "offsetY", 0);
3253
+ c(this, "clientY", 0);
3250
3254
  // 鼠标按下时的y轴位置
3251
3255
  c(this, "ctx");
3252
3256
  c(this, "x", 0);
@@ -3320,30 +3324,30 @@ class fi {
3320
3324
  t && (this.ctx.on("mouseup", () => {
3321
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(() => {
3322
3326
  this.ctx.rowResizing = !1;
3323
- }, 0), this.offsetY = 0;
3327
+ }, 0), this.clientY = 0;
3324
3328
  }), this.ctx.on("mousedown", (e) => {
3325
- 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);
3326
3330
  }), this.ctx.on("mousemove", (e) => {
3327
3331
  if (this.ctx.editing) return;
3328
- const i = e.offsetY, s = e.offsetX, {
3329
- target: o,
3330
- scrollY: r,
3331
- 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 }
3332
3336
  } = this.ctx;
3333
3337
  if (this.isResizing && this.resizeTarget) {
3334
- const l = this.resizeTarget.height;
3335
- let h = i - this.offsetY;
3336
- 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");
3337
3341
  } else {
3338
3342
  if (this.resizeTarget = null, this.isMouseDown || this.ctx.target.style.cursor === "crosshair")
3339
3343
  return;
3340
3344
  this.ctx.target.style.cursor === "row-resize" && (this.ctx.target.style.cursor = "default");
3341
- for (let l = 0; l < this.renderRows.length; l++) {
3342
- const h = this.renderRows[l];
3343
- if (i > h.y - r + h.height - 1.5 && i < h.y - r + h.height + 1.5 && i < o.height - 4)
3344
- for (let d = 0; d < h.cells.length; d++) {
3345
- const x = h.cells[d];
3346
- 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);
3347
3351
  }
3348
3352
  }
3349
3353
  }
@@ -3618,7 +3622,7 @@ class ui {
3618
3622
  }
3619
3623
  }
3620
3624
  selectCols(t) {
3621
- 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)
3622
3626
  return;
3623
3627
  if (t.operation) {
3624
3628
  this.selectAll();
@@ -3640,7 +3644,7 @@ class ui {
3640
3644
  }
3641
3645
  }
3642
3646
  selectAll() {
3643
- if (this.ctx.autofillMove)
3647
+ if (this.ctx.autofillMove || this.ctx.editing)
3644
3648
  return;
3645
3649
  const { ENABLE_SELECTOR_ALL_ROWS: t, ENABLE_SELECTOR_ALL_COLS: e } = this.ctx.config;
3646
3650
  if (t && e) {
@@ -3649,7 +3653,7 @@ class ui {
3649
3653
  }
3650
3654
  }
3651
3655
  selectRows(t, e = !0) {
3652
- 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)
3653
3657
  return;
3654
3658
  const { SELECTOR_AREA_MIN_X: i, SELECTOR_AREA_MAX_X: s } = this.ctx.config, o = s || this.ctx.maxColIndex, r = i;
3655
3659
  if (e) {
@@ -3669,7 +3673,7 @@ class ui {
3669
3673
  }
3670
3674
  }
3671
3675
  mouseenter() {
3672
- if (this.ctx.config.ENABLE_SELECTOR_SINGLE)
3676
+ if (this.ctx.config.ENABLE_SELECTOR_SINGLE || this.ctx.editing)
3673
3677
  return;
3674
3678
  const { mousedown: t, focusCell: e, hoverCell: i } = this.ctx;
3675
3679
  if (t && e && i) {
@@ -3973,7 +3977,7 @@ class gi {
3973
3977
  destroy() {
3974
3978
  }
3975
3979
  }
3976
- 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) => ({
3977
3981
  x: a,
3978
3982
  y: a
3979
3983
  }), wi = {
@@ -4078,7 +4082,7 @@ function ut(a) {
4078
4082
  y: e
4079
4083
  };
4080
4084
  }
4081
- function zt(a, t, e) {
4085
+ function Vt(a, t, e) {
4082
4086
  let {
4083
4087
  reference: i,
4084
4088
  floating: s
@@ -4140,7 +4144,7 @@ const vi = async (a, t, e) => {
4140
4144
  }), {
4141
4145
  x: f,
4142
4146
  y: d
4143
- } = zt(h, i, l), x = i, u = {}, y = 0;
4147
+ } = Vt(h, i, l), x = i, u = {}, y = 0;
4144
4148
  for (let g = 0; g < n.length; g++) {
4145
4149
  const {
4146
4150
  name: w,
@@ -4177,7 +4181,7 @@ const vi = async (a, t, e) => {
4177
4181
  }) : C.rects), {
4178
4182
  x: f,
4179
4183
  y: d
4180
- } = zt(h, x, l)), g = -1);
4184
+ } = Vt(h, x, l)), g = -1);
4181
4185
  }
4182
4186
  return {
4183
4187
  x: f,
@@ -4507,13 +4511,13 @@ function Dt(a) {
4507
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));
4508
4512
  }
4509
4513
  function Li(a) {
4510
- let t = z(a);
4514
+ let t = V(a);
4511
4515
  for (; N(t) && !Q(t); ) {
4512
4516
  if (Dt(t))
4513
4517
  return t;
4514
4518
  if (wt(t))
4515
4519
  return null;
4516
- t = z(t);
4520
+ t = V(t);
4517
4521
  }
4518
4522
  return null;
4519
4523
  }
@@ -4535,7 +4539,7 @@ function pt(a) {
4535
4539
  scrollTop: a.scrollY
4536
4540
  };
4537
4541
  }
4538
- function z(a) {
4542
+ function V(a) {
4539
4543
  if (tt(a) === "html")
4540
4544
  return a;
4541
4545
  const t = (
@@ -4548,7 +4552,7 @@ function z(a) {
4548
4552
  return $t(t) ? t.host : t;
4549
4553
  }
4550
4554
  function ce(a) {
4551
- const t = z(a);
4555
+ const t = V(a);
4552
4556
  return Q(t) ? a.ownerDocument ? a.ownerDocument.body : a.body : N(t) && lt(t) ? t : ce(t);
4553
4557
  }
4554
4558
  function St(a, t, e) {
@@ -4580,7 +4584,7 @@ function he(a) {
4580
4584
  function Z(a) {
4581
4585
  const t = he(a);
4582
4586
  if (!N(t))
4583
- return V(1);
4587
+ return z(1);
4584
4588
  const e = t.getBoundingClientRect(), {
4585
4589
  width: i,
4586
4590
  height: s,
@@ -4592,7 +4596,7 @@ function Z(a) {
4592
4596
  y: n
4593
4597
  };
4594
4598
  }
4595
- const Ai = /* @__PURE__ */ V(0);
4599
+ const Ai = /* @__PURE__ */ z(0);
4596
4600
  function de(a) {
4597
4601
  const t = H(a);
4598
4602
  return !Xt() || !t.visualViewport ? Ai : {
@@ -4606,9 +4610,9 @@ function Mi(a, t, e) {
4606
4610
  function ot(a, t, e, i) {
4607
4611
  t === void 0 && (t = !1), e === void 0 && (e = !1);
4608
4612
  const s = a.getBoundingClientRect(), o = he(a);
4609
- let r = V(1);
4613
+ let r = z(1);
4610
4614
  t && (i ? X(i) && (r = Z(i)) : r = Z(a));
4611
- const n = Mi(o, e, i) ? de(o) : V(0);
4615
+ const n = Mi(o, e, i) ? de(o) : z(0);
4612
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;
4613
4617
  if (o) {
4614
4618
  const x = H(o), u = i && X(i) ? H(i) : i;
@@ -4638,8 +4642,8 @@ function Hi(a) {
4638
4642
  let l = {
4639
4643
  scrollLeft: 0,
4640
4644
  scrollTop: 0
4641
- }, h = V(1);
4642
- const f = V(0), d = N(i);
4645
+ }, h = z(1);
4646
+ const f = z(0), d = N(i);
4643
4647
  if ((d || !d && !o) && ((tt(i) !== "body" || lt(r)) && (l = pt(i)), N(i))) {
4644
4648
  const x = ot(i);
4645
4649
  h = Z(i), f.x = x.x + i.clientLeft, f.y = x.y + i.clientTop;
@@ -4685,7 +4689,7 @@ function ki(a, t) {
4685
4689
  };
4686
4690
  }
4687
4691
  function Fi(a, t) {
4688
- 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;
4689
4693
  return {
4690
4694
  width: r,
4691
4695
  height: n,
@@ -4712,7 +4716,7 @@ function qt(a, t, e) {
4712
4716
  return ut(i);
4713
4717
  }
4714
4718
  function fe(a, t) {
4715
- const e = z(a);
4719
+ const e = V(a);
4716
4720
  return e === t || !X(e) || Q(e) ? !1 : k(e).position === "fixed" || fe(e, t);
4717
4721
  }
4718
4722
  function Ni(a, t) {
@@ -4721,10 +4725,10 @@ function Ni(a, t) {
4721
4725
  return e;
4722
4726
  let i = St(a, [], !1).filter((n) => X(n) && tt(n) !== "body"), s = null;
4723
4727
  const o = k(a).position === "fixed";
4724
- let r = o ? z(a) : a;
4728
+ let r = o ? V(a) : a;
4725
4729
  for (; X(r) && !Q(r); ) {
4726
4730
  const n = k(r), l = Dt(r);
4727
- !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);
4728
4732
  }
4729
4733
  return t.set(a, i), i;
4730
4734
  }
@@ -4762,7 +4766,7 @@ function Bi(a, t, e) {
4762
4766
  scrollLeft: 0,
4763
4767
  scrollTop: 0
4764
4768
  };
4765
- const l = V(0);
4769
+ const l = z(0);
4766
4770
  if (i || !i && !o)
4767
4771
  if ((tt(t) !== "body" || lt(s)) && (n = pt(t)), i) {
4768
4772
  const u = ot(t, !0, o, t);
@@ -4798,11 +4802,11 @@ function xe(a, t) {
4798
4802
  if (wt(a))
4799
4803
  return e;
4800
4804
  if (!N(a)) {
4801
- let s = z(a);
4805
+ let s = V(a);
4802
4806
  for (; s && !Q(s); ) {
4803
4807
  if (X(s) && !mt(s))
4804
4808
  return s;
4805
- s = z(s);
4809
+ s = V(s);
4806
4810
  }
4807
4811
  return e;
4808
4812
  }
@@ -4826,7 +4830,7 @@ const Wi = async function(a) {
4826
4830
  function Pi(a) {
4827
4831
  return k(a).direction === "rtl";
4828
4832
  }
4829
- const Vi = {
4833
+ const zi = {
4830
4834
  convertOffsetParentRelativeRectToViewportRelativeRect: Hi,
4831
4835
  getDocumentElement: K,
4832
4836
  getClippingRect: Yi,
@@ -4837,9 +4841,9 @@ const Vi = {
4837
4841
  getScale: Z,
4838
4842
  isElement: X,
4839
4843
  isRTL: Pi
4840
- }, 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) => {
4841
4845
  const i = /* @__PURE__ */ new Map(), s = {
4842
- platform: Vi,
4846
+ platform: zi,
4843
4847
  ...e
4844
4848
  }, o = {
4845
4849
  ...s.platform,
@@ -4920,7 +4924,7 @@ let $i = class {
4920
4924
  }
4921
4925
  }, this.floatingEl, {
4922
4926
  placement: t.overflowTooltipPlacement,
4923
- middleware: [ge(), we(), ue(6), zi({ element: this.arrowEl })]
4927
+ middleware: [ge(), we(), ue(6), Vi({ element: this.arrowEl })]
4924
4928
  }).then((n) => {
4925
4929
  const { x: l, y: h, placement: f, middlewareData: d } = n;
4926
4930
  if (Object.assign(this.floatingEl.style, {