e-virt-table 0.0.13 → 0.0.15

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
@@ -149,7 +149,7 @@ function Oe(a) {
149
149
  t.push.apply(t, a[e] || []);
150
150
  }), t;
151
151
  }
152
- var Ft = /* @__PURE__ */ function(a) {
152
+ var Nt = /* @__PURE__ */ function(a) {
153
153
  be(t, a);
154
154
  function t(e, i) {
155
155
  var s;
@@ -161,7 +161,7 @@ function Se(a, t, e, i, s) {
161
161
  if (t.first) {
162
162
  var o = new Promise(function(x, u) {
163
163
  var y = function(p) {
164
- return i(p), p.length ? u(new Ft(p, Ct(p))) : x(s);
164
+ return i(p), p.length ? u(new Nt(p, Ct(p))) : x(s);
165
165
  }, g = Oe(a);
166
166
  kt(g, e, y);
167
167
  });
@@ -172,7 +172,7 @@ function Se(a, t, e, i, s) {
172
172
  var r = t.firstFields === !0 ? Object.keys(a) : t.firstFields || [], n = Object.keys(a), l = n.length, h = 0, f = [], d = new Promise(function(x, u) {
173
173
  var y = function(w) {
174
174
  if (f.push.apply(f, w), h++, h === l)
175
- return i(f), f.length ? u(new Ft(f, Ct(f))) : x(s);
175
+ return i(f), f.length ? u(new Nt(f, Ct(f))) : x(s);
176
176
  };
177
177
  n.length || (i(f), x(s)), n.forEach(function(g) {
178
178
  var w = a[g];
@@ -194,7 +194,7 @@ function Le(a, t) {
194
194
  }
195
195
  return e;
196
196
  }
197
- function Nt(a, t) {
197
+ function Ft(a, t) {
198
198
  return function(e) {
199
199
  var i;
200
200
  return a.fullFields ? i = Le(t, a.fullFields) : i = t[e.field || a.fullField], Te(e) ? (e.field = e.field || a.fullField, e.fieldValue = i, e) : {
@@ -322,7 +322,7 @@ var Ut = function(t, e, i, s, o, r) {
322
322
  range: De,
323
323
  enum: Xe,
324
324
  pattern: ke
325
- }, Fe = function(t, e, i, s, o) {
325
+ }, Ne = function(t, e, i, s, o) {
326
326
  var r = [], n = t.required || !t.required && s.hasOwnProperty(t.field);
327
327
  if (n) {
328
328
  if (I(e, "string") && !t.required)
@@ -330,7 +330,7 @@ var Ut = function(t, e, i, s, o, r) {
330
330
  v.required(t, e, s, r, o, "string"), I(e, "string") || (v.type(t, e, s, r, o), v.range(t, e, s, r, o), v.pattern(t, e, s, r, o), t.whitespace === !0 && v.whitespace(t, e, s, r, o));
331
331
  }
332
332
  i(r);
333
- }, Ne = function(t, e, i, s, o) {
333
+ }, Fe = function(t, e, i, s, o) {
334
334
  var r = [], n = t.required || !t.required && s.hasOwnProperty(t.field);
335
335
  if (n) {
336
336
  if (I(e) && !t.required)
@@ -441,8 +441,8 @@ var Ut = function(t, e, i, s, o, r) {
441
441
  }
442
442
  i(r);
443
443
  }, it = {
444
- string: Fe,
445
- method: Ne,
444
+ string: Ne,
445
+ method: Fe,
446
446
  number: Ye,
447
447
  boolean: Ke,
448
448
  regexp: Be,
@@ -583,14 +583,14 @@ var Rt = vt(), nt = /* @__PURE__ */ function() {
583
583
  R === void 0 && (R = []);
584
584
  var T = Array.isArray(R) ? R : [R];
585
585
  !l.suppressWarning && T.length && a.warning("async-validator:", T), T.length && p.message !== void 0 && (T = [].concat(p.message));
586
- var L = T.map(Nt(p, n));
586
+ var L = T.map(Ft(p, n));
587
587
  if (l.first && L.length)
588
588
  return y[p.field] = 1, w(L);
589
589
  if (!E)
590
590
  w(L);
591
591
  else {
592
592
  if (p.required && !g.value)
593
- return p.message !== void 0 ? L = [].concat(p.message).map(Nt(p, n)) : l.error && (L = [l.error(p, M(l.messages.required, p.field))]), w(L);
593
+ return p.message !== void 0 ? L = [].concat(p.message).map(Ft(p, n)) : l.error && (L = [l.error(p, M(l.messages.required, p.field))]), w(L);
594
594
  var A = {};
595
595
  p.defaultField && Object.keys(g.value).map(function(_) {
596
596
  A[_] = p.defaultField;
@@ -1436,7 +1436,7 @@ class ri {
1436
1436
  this.ctx = t, this.init();
1437
1437
  }
1438
1438
  init() {
1439
- this.bind(window, "resize", this.handleResize.bind(this)), this.bind(window, "mousedown", this.handleMouseDown.bind(this)), this.bind(window, "mouseup", this.handleMouseUp.bind(this)), this.bind(window, "mousemove", this.handleMousemove.bind(this)), this.bind(this.ctx.target, "click", this.handleClick.bind(this)), this.bind(this.ctx.target, "keydown", this.handleKeydown.bind(this)), this.bind(this.ctx.target, "wheel", this.handleWheel.bind(this)), this.bind(this.ctx.target, "contextmenu", this.handleContextMenu.bind(this));
1439
+ this.bind(window, "resize", this.handleResize.bind(this)), this.bind(window, "mousedown", this.handleMouseDown.bind(this)), this.bind(window, "mouseup", this.handleMouseUp.bind(this)), this.bind(window, "mousemove", this.handleMousemove.bind(this)), this.bind(window, "scroll", this.handleScroll.bind(this)), this.bind(this.ctx.target, "click", this.handleClick.bind(this)), this.bind(this.ctx.target, "keydown", this.handleKeydown.bind(this)), this.bind(this.ctx.target, "wheel", this.handleWheel.bind(this)), this.bind(this.ctx.target, "contextmenu", this.handleContextMenu.bind(this));
1440
1440
  }
1441
1441
  destroy() {
1442
1442
  this.eventTasks.forEach((t, e) => {
@@ -1468,6 +1468,9 @@ class ri {
1468
1468
  handleContextMenu(t) {
1469
1469
  this.ctx.emit("contextMenu", t);
1470
1470
  }
1471
+ handleScroll(t) {
1472
+ this.ctx.emit("scroll", t);
1473
+ }
1471
1474
  bind(t, e, i) {
1472
1475
  t instanceof HTMLCanvasElement && e === "keydown" && (t.tabIndex = 0), t.addEventListener(e, i), this.eventTasks.set(e, i);
1473
1476
  }
@@ -1676,6 +1679,8 @@ class Pt {
1676
1679
  c(this, "ENABLE_OFFSET_HEIGHT", !1);
1677
1680
  c(this, "OFFSET_HEIGHT", 0);
1678
1681
  c(this, "HEADER_HEIGHT", 36);
1682
+ c(this, "ENABLE_HEADER_STICKY", !1);
1683
+ // 启用头部固定,需要外面实现覆盖层,或者所有表头都要是元素
1679
1684
  c(this, "HEADER_BG_COLOR", "#F8FAFF");
1680
1685
  c(this, "BODY_BG_COLOR", "#FFF");
1681
1686
  c(this, "HEADER_TEXT_COLOR", "#1D2129");
@@ -2468,7 +2473,7 @@ class ie extends te {
2468
2473
  left: e,
2469
2474
  top: `${this.drawY + 1}px`,
2470
2475
  width: `${this.width}px`,
2471
- height: `${this.height}px`,
2476
+ height: `${this.height - 2}px`,
2472
2477
  pointerEvents: "none"
2473
2478
  };
2474
2479
  }
@@ -4260,14 +4265,14 @@ const Ri = (a) => ({
4260
4265
  }, u = Ht(s), y = Mt(u), g = await r.getDimensions(h), w = u === "y", p = w ? "top" : "left", E = w ? "bottom" : "right", m = w ? "clientHeight" : "clientWidth", b = o.reference[y] + o.reference[u] - x[u] - o.floating[y], C = x[u] - o.reference[u], R = await (r.getOffsetParent == null ? void 0 : r.getOffsetParent(h));
4261
4266
  let T = R ? R[m] : 0;
4262
4267
  (!T || !await (r.isElement == null ? void 0 : r.isElement(R))) && (T = n.floating[m] || o.floating[y]);
4263
- const L = b / 2 - C / 2, A = T / 2 - g[y] / 2 - 1, D = rt(d[p], A), B = rt(d[E], A), _ = D, S = T - g[y] - B, O = T / 2 - g[y] / 2 + L, G = _t(_, O, S), Y = !l.arrow && ct(s) != null && O !== G && o.reference[y] / 2 - (O < _ ? D : B) - g[y] / 2 < 0, F = Y ? O < _ ? O - _ : O - S : 0;
4268
+ const L = b / 2 - C / 2, A = T / 2 - g[y] / 2 - 1, D = rt(d[p], A), B = rt(d[E], A), _ = D, S = T - g[y] - B, O = T / 2 - g[y] / 2 + L, G = _t(_, O, S), Y = !l.arrow && ct(s) != null && O !== G && o.reference[y] / 2 - (O < _ ? D : B) - g[y] / 2 < 0, N = Y ? O < _ ? O - _ : O - S : 0;
4264
4269
  return {
4265
- [u]: x[u] + F,
4270
+ [u]: x[u] + N,
4266
4271
  data: {
4267
4272
  [u]: G,
4268
- centerOffset: O - G - F,
4273
+ centerOffset: O - G - N,
4269
4274
  ...Y && {
4270
- alignmentOffset: F
4275
+ alignmentOffset: N
4271
4276
  }
4272
4277
  },
4273
4278
  reset: Y
@@ -4321,12 +4326,12 @@ const Ri = (a) => ({
4321
4326
  placement: G
4322
4327
  }
4323
4328
  };
4324
- let Y = (_ = D.filter((F) => F.overflows[0] <= 0).sort((F, W) => F.overflows[1] - W.overflows[1])[0]) == null ? void 0 : _.placement;
4329
+ let Y = (_ = D.filter((N) => N.overflows[0] <= 0).sort((N, W) => N.overflows[1] - W.overflows[1])[0]) == null ? void 0 : _.placement;
4325
4330
  if (!Y)
4326
4331
  switch (u) {
4327
4332
  case "bestFit": {
4328
4333
  var S;
4329
- const F = (S = D.filter((W) => {
4334
+ const N = (S = D.filter((W) => {
4330
4335
  if (R) {
4331
4336
  const P = J(W.placement);
4332
4337
  return P === E || // Create a bias to the `y` side axis due to horizontal
@@ -4335,7 +4340,7 @@ const Ri = (a) => ({
4335
4340
  }
4336
4341
  return !0;
4337
4342
  }).map((W) => [W.placement, W.overflows.filter((P) => P > 0).reduce((P, ye) => P + ye, 0)]).sort((W, P) => W[1] - P[1])[0]) == null ? void 0 : S[0];
4338
- F && (Y = F);
4343
+ N && (Y = N);
4339
4344
  break;
4340
4345
  }
4341
4346
  case "initialPlacement":
@@ -4479,7 +4484,7 @@ function ae(a) {
4479
4484
  function X(a) {
4480
4485
  return gt() ? a instanceof Element || a instanceof H(a).Element : !1;
4481
4486
  }
4482
- function N(a) {
4487
+ function F(a) {
4483
4488
  return gt() ? a instanceof HTMLElement || a instanceof H(a).HTMLElement : !1;
4484
4489
  }
4485
4490
  function $t(a) {
@@ -4512,7 +4517,7 @@ function Dt(a) {
4512
4517
  }
4513
4518
  function Li(a) {
4514
4519
  let t = V(a);
4515
- for (; N(t) && !Q(t); ) {
4520
+ for (; F(t) && !Q(t); ) {
4516
4521
  if (Dt(t))
4517
4522
  return t;
4518
4523
  if (wt(t))
@@ -4553,7 +4558,7 @@ function V(a) {
4553
4558
  }
4554
4559
  function ce(a) {
4555
4560
  const t = V(a);
4556
- return Q(t) ? a.ownerDocument ? a.ownerDocument.body : a.body : N(t) && lt(t) ? t : ce(t);
4561
+ return Q(t) ? a.ownerDocument ? a.ownerDocument.body : a.body : F(t) && lt(t) ? t : ce(t);
4557
4562
  }
4558
4563
  function St(a, t, e) {
4559
4564
  var i;
@@ -4571,7 +4576,7 @@ function Tt(a) {
4571
4576
  function le(a) {
4572
4577
  const t = k(a);
4573
4578
  let e = parseFloat(t.width) || 0, i = parseFloat(t.height) || 0;
4574
- const s = N(a), o = s ? a.offsetWidth : e, r = s ? a.offsetHeight : i, n = ft(e) !== o || ft(i) !== r;
4579
+ const s = F(a), o = s ? a.offsetWidth : e, r = s ? a.offsetHeight : i, n = ft(e) !== o || ft(i) !== r;
4575
4580
  return n && (e = o, i = r), {
4576
4581
  width: e,
4577
4582
  height: i,
@@ -4583,7 +4588,7 @@ function he(a) {
4583
4588
  }
4584
4589
  function Z(a) {
4585
4590
  const t = he(a);
4586
- if (!N(t))
4591
+ if (!F(t))
4587
4592
  return z(1);
4588
4593
  const e = t.getBoundingClientRect(), {
4589
4594
  width: i,
@@ -4643,8 +4648,8 @@ function Hi(a) {
4643
4648
  scrollLeft: 0,
4644
4649
  scrollTop: 0
4645
4650
  }, h = z(1);
4646
- const f = z(0), d = N(i);
4647
- if ((d || !d && !o) && ((tt(i) !== "body" || lt(r)) && (l = pt(i)), N(i))) {
4651
+ const f = z(0), d = F(i);
4652
+ if ((d || !d && !o) && ((tt(i) !== "body" || lt(r)) && (l = pt(i)), F(i))) {
4648
4653
  const x = ot(i);
4649
4654
  h = Z(i), f.x = x.x + i.clientLeft, f.y = x.y + i.clientTop;
4650
4655
  }
@@ -4688,8 +4693,8 @@ function ki(a, t) {
4688
4693
  y: l
4689
4694
  };
4690
4695
  }
4691
- function Fi(a, t) {
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;
4696
+ function Ni(a, t) {
4697
+ const e = ot(a, !0, t === "fixed"), i = e.top + a.clientTop, s = e.left + a.clientLeft, o = F(a) ? Z(a) : z(1), r = a.clientWidth * o.x, n = a.clientHeight * o.y, l = s * o.x, h = i * o.y;
4693
4698
  return {
4694
4699
  width: r,
4695
4700
  height: n,
@@ -4704,7 +4709,7 @@ function qt(a, t, e) {
4704
4709
  else if (t === "document")
4705
4710
  i = Xi(K(a));
4706
4711
  else if (X(t))
4707
- i = Fi(t, e);
4712
+ i = Ni(t, e);
4708
4713
  else {
4709
4714
  const s = de(a);
4710
4715
  i = {
@@ -4719,7 +4724,7 @@ function fe(a, t) {
4719
4724
  const e = V(a);
4720
4725
  return e === t || !X(e) || Q(e) ? !1 : k(e).position === "fixed" || fe(e, t);
4721
4726
  }
4722
- function Ni(a, t) {
4727
+ function Fi(a, t) {
4723
4728
  const e = t.get(a);
4724
4729
  if (e)
4725
4730
  return e;
@@ -4739,7 +4744,7 @@ function Yi(a) {
4739
4744
  rootBoundary: i,
4740
4745
  strategy: s
4741
4746
  } = a;
4742
- const r = [...e === "clippingAncestors" ? wt(t) ? [] : Ni(t, this._c) : [].concat(e), i], n = r[0], l = r.reduce((h, f) => {
4747
+ const r = [...e === "clippingAncestors" ? wt(t) ? [] : Fi(t, this._c) : [].concat(e), i], n = r[0], l = r.reduce((h, f) => {
4743
4748
  const d = qt(t, f, s);
4744
4749
  return h.top = U(d.top, h.top), h.right = rt(d.right, h.right), h.bottom = rt(d.bottom, h.bottom), h.left = U(d.left, h.left), h;
4745
4750
  }, qt(t, n, s));
@@ -4761,7 +4766,7 @@ function Ki(a) {
4761
4766
  };
4762
4767
  }
4763
4768
  function Bi(a, t, e) {
4764
- const i = N(t), s = K(t), o = e === "fixed", r = ot(a, !0, o, t);
4769
+ const i = F(t), s = K(t), o = e === "fixed", r = ot(a, !0, o, t);
4765
4770
  let n = {
4766
4771
  scrollLeft: 0,
4767
4772
  scrollTop: 0
@@ -4790,7 +4795,7 @@ function mt(a) {
4790
4795
  return k(a).position === "static";
4791
4796
  }
4792
4797
  function Gt(a, t) {
4793
- if (!N(a) || k(a).position === "fixed")
4798
+ if (!F(a) || k(a).position === "fixed")
4794
4799
  return null;
4795
4800
  if (t)
4796
4801
  return t(a);
@@ -4801,7 +4806,7 @@ function xe(a, t) {
4801
4806
  const e = H(a);
4802
4807
  if (wt(a))
4803
4808
  return e;
4804
- if (!N(a)) {
4809
+ if (!F(a)) {
4805
4810
  let s = V(a);
4806
4811
  for (; s && !Q(s); ) {
4807
4812
  if (X(s) && !mt(s))
@@ -5077,8 +5082,11 @@ class qi {
5077
5082
  startEditByInput(t) {
5078
5083
  if (t.editorType !== "text")
5079
5084
  return;
5080
- const e = t.getValue(), { width: i, height: s } = t, o = t.getDrawX(), r = t.getDrawY(), { CELL_PADDING: n } = this.ctx.config;
5081
- this.editorEl.style.left = `${o}px`, this.editorEl.style.top = `${r}px`, this.inputEl.style.minWidth = `${i - 1}px`, this.inputEl.style.minHeight = `${s - 1}px`, this.inputEl.style.padding = `${n}px`, e !== null && (this.inputEl.textContent = e), this.inputEl.focus();
5085
+ const e = t.getValue(), { width: i } = t, s = t.getDrawX();
5086
+ let o = t.getDrawY(), { height: r } = t;
5087
+ t.height > this.ctx.body.visibleHeight && (r = this.ctx.body.visibleHeight, o = this.ctx.header.visibleHeight);
5088
+ const { CELL_PADDING: n } = this.ctx.config;
5089
+ this.editorEl.style.left = `${s}px`, this.editorEl.style.top = `${o}px`, this.inputEl.style.minWidth = `${i - 1}px`, this.inputEl.style.minHeight = `${r - 1}px`, this.inputEl.style.padding = `${n}px`, e !== null && (this.inputEl.textContent = e), this.inputEl.focus();
5082
5090
  const l = window.getSelection();
5083
5091
  l == null || l.selectAllChildren(this.inputEl), l == null || l.collapseToEnd();
5084
5092
  }
@@ -5147,7 +5155,28 @@ class Gi {
5147
5155
  class ji {
5148
5156
  constructor(t) {
5149
5157
  c(this, "ctx");
5150
- this.ctx = t;
5158
+ this.ctx = t, this.ctx.on("scroll", () => {
5159
+ if (!this.ctx.config.ENABLE_HEADER_STICKY)
5160
+ return;
5161
+ const e = this.ctx.targetContainer.getBoundingClientRect();
5162
+ let i = !1, s = this.getHeader();
5163
+ e.top < 0 && e.top < -this.ctx.header.visibleHeight && e.top > -this.ctx.body.visibleHeight ? i = !0 : i = !1;
5164
+ const {
5165
+ config: { CSS_PREFIX: o }
5166
+ } = this.ctx, { visibleWidth: r } = this.ctx.body, n = {
5167
+ type: "header-sticky",
5168
+ class: `${o}-overlayer-header-sticky`,
5169
+ style: {
5170
+ position: "sticky",
5171
+ top: "0px",
5172
+ "z-index": 10,
5173
+ width: `${r}px`,
5174
+ display: i ? "block" : "none"
5175
+ },
5176
+ views: s.views
5177
+ };
5178
+ this.ctx.emit("headerStickyChange", n);
5179
+ });
5151
5180
  }
5152
5181
  draw() {
5153
5182
  const t = this.getContainer();
@@ -5193,8 +5222,8 @@ class ji {
5193
5222
  key: "left",
5194
5223
  style: {
5195
5224
  position: "absolute",
5196
- top: `${0.5}px`,
5197
- left: `${0.5}px`,
5225
+ top: "0px",
5226
+ left: "0px",
5198
5227
  overflow: "hidden",
5199
5228
  width: `${t}px`,
5200
5229
  height: `${r}px`
@@ -5204,10 +5233,10 @@ class ji {
5204
5233
  key: "center",
5205
5234
  style: {
5206
5235
  position: "absolute",
5207
- top: `${0.5}px`,
5236
+ top: "0px",
5208
5237
  left: `${t}px`,
5209
5238
  overflow: "hidden",
5210
- width: `${o - t - d}px`,
5239
+ width: `${o - t - d + 1}px`,
5211
5240
  height: `${r}px`
5212
5241
  },
5213
5242
  cells: l
@@ -5215,10 +5244,10 @@ class ji {
5215
5244
  key: "right",
5216
5245
  style: {
5217
5246
  position: "absolute",
5218
- top: `${0.5}px`,
5219
- right: `${0.5}px`,
5247
+ top: "0px",
5248
+ right: "0px",
5220
5249
  overflow: "hidden",
5221
- width: `${d}px`,
5250
+ width: `${d + 1}px`,
5222
5251
  height: `${r}px`
5223
5252
  },
5224
5253
  cells: f