e-virt-table 0.0.6 → 0.0.7

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
@@ -186,7 +186,7 @@ function Oe(a, t, e, i, s) {
186
186
  function _e(a) {
187
187
  return !!(a && a.message !== void 0);
188
188
  }
189
- function Se(a, t) {
189
+ function Te(a, t) {
190
190
  for (var e = a, i = 0; i < t.length; i++) {
191
191
  if (e == null)
192
192
  return e;
@@ -197,7 +197,7 @@ function Se(a, t) {
197
197
  function Nt(a, t) {
198
198
  return function(e) {
199
199
  var i;
200
- return a.fullFields ? i = Se(t, a.fullFields) : i = t[e.field || a.fullField], _e(e) ? (e.field = e.field || a.fullField, e.fieldValue = i, e) : {
200
+ return a.fullFields ? i = Te(t, a.fullFields) : i = t[e.field || a.fullField], _e(e) ? (e.field = e.field || a.fullField, e.fieldValue = i, e) : {
201
201
  message: typeof e == "function" ? e() : e,
202
202
  fieldValue: i,
203
203
  field: e.field || a.fullField
@@ -216,7 +216,7 @@ function Kt(a, t) {
216
216
  }
217
217
  var Gt = function(t, e, i, s, r, o) {
218
218
  t.required && (!i.hasOwnProperty(t.field) || I(e, o || t.type)) && s.push(H(r.messages.required, t.fullField));
219
- }, Te = function(t, e, i, s, r) {
219
+ }, Se = function(t, e, i, s, r) {
220
220
  (/^\s+$/.test(e) || e === "") && s.push(H(r.messages.whitespace, t.fullField));
221
221
  }, lt, Le = function() {
222
222
  if (lt)
@@ -317,7 +317,7 @@ var Gt = function(t, e, i, s, r, o) {
317
317
  }
318
318
  }, v = {
319
319
  required: Gt,
320
- whitespace: Te,
320
+ whitespace: Se,
321
321
  type: Ae,
322
322
  range: He,
323
323
  enum: Me,
@@ -573,17 +573,17 @@ var Rt = vt(), nt = /* @__PURE__ */ function() {
573
573
  return Oe(x, h, function(g, w) {
574
574
  var p = g.rule, E = (p.type === "object" || p.type === "array") && (typeof p.fields == "object" || typeof p.defaultField == "object");
575
575
  E = E && (p.required || !p.required && g.value), p.field = g.field;
576
- function m(R, T) {
577
- return $({}, T, {
576
+ function m(R, S) {
577
+ return $({}, S, {
578
578
  fullField: p.fullField + "." + R,
579
579
  fullFields: p.fullFields ? [].concat(p.fullFields, [R]) : [R]
580
580
  });
581
581
  }
582
582
  function b(R) {
583
583
  R === void 0 && (R = []);
584
- var T = Array.isArray(R) ? R : [R];
585
- !h.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));
584
+ var S = Array.isArray(R) ? R : [R];
585
+ !h.suppressWarning && S.length && a.warning("async-validator:", S), S.length && p.message !== void 0 && (S = [].concat(p.message));
586
+ var L = S.map(Nt(p, n));
587
587
  if (h.first && L.length)
588
588
  return y[p.field] = 1, w(L);
589
589
  if (!E)
@@ -597,13 +597,13 @@ var Rt = vt(), nt = /* @__PURE__ */ function() {
597
597
  }), A = $({}, A, g.rule.fields);
598
598
  var D = {};
599
599
  Object.keys(A).forEach(function(O) {
600
- var S = A[O], _ = Array.isArray(S) ? S : [S];
600
+ var T = A[O], _ = Array.isArray(T) ? T : [T];
601
601
  D[O] = _.map(m.bind(null, O));
602
602
  });
603
603
  var B = new a(D);
604
604
  B.messages(h.messages), g.rule.options && (g.rule.options.messages = h.messages, g.rule.options.error = h.error), B.validate(g.value, g.rule.options || h, function(O) {
605
- var S = [];
606
- L && L.length && S.push.apply(S, L), O && O.length && S.push.apply(S, O), w(S.length ? S : null);
605
+ var T = [];
606
+ L && L.length && T.push.apply(T, L), O && O.length && T.push.apply(T, O), w(T.length ? T : null);
607
607
  });
608
608
  }
609
609
  }
@@ -1681,6 +1681,8 @@ class Bt {
1681
1681
  // 启用单点击立马编辑
1682
1682
  c(this, "ENABLE_EDIT_TEXT_ENTER", !0);
1683
1683
  // 启用文本编辑器回车键确认
1684
+ c(this, "ENABLE_EDIT_CLICK_SELECTOR", !0);
1685
+ // 启用点击选择器编辑
1684
1686
  c(this, "ENABLE_SELECTOR_SINGLE", !1);
1685
1687
  c(this, "ENABLE_SELECTOR_SPAN_COL", !0);
1686
1688
  c(this, "ENABLE_SELECTOR_SPAN_ROW", !0);
@@ -2521,7 +2523,7 @@ class si {
2521
2523
  const d = l.getDrawX(), f = l.getDrawY();
2522
2524
  if (i > d && i < d + l.visibleWidth && e > f && e < f + l.visibleHeight && (this.imageEnterAndLeave(l, t), this.visibleHoverCell !== l && (this.ctx.emit("visibleCellMouseleave", l, t), this.visibleHoverCell = l, this.ctx.emit("visibleCellHoverChange", l, t))), i > d && i < d + l.width && e > f && e < f + l.height) {
2523
2525
  if (this.ctx.emit("cellMouseenter", l, t), this.ctx.hoverCell && this.ctx.hoverCell !== l && this.ctx.emit("cellMouseleave", this.ctx.hoverCell, t), this.ctx.hoverCell === l) return;
2524
- ((o = this.ctx.hoverCell) == null ? void 0 : o.rowKey) !== l.rowKey && (this.ctx.hoverCell = l, this.ctx.hoverRow = this.ctx.body.renderRows[l.rowIndex], this.ctx.emit("rowHoverChange", this.ctx.hoverRow, l, t), this.ctx.emit("draw")), this.ctx.hoverCell = l, this.ctx.emit("cellHoverChange", l, t);
2526
+ ((o = this.ctx.hoverCell) == null ? void 0 : o.rowKey) !== l.rowKey && (this.ctx.hoverCell = l, this.ctx.hoverRow = this.ctx.body.renderRows.find((x) => x.rowKey === l.rowKey), this.ctx.emit("rowHoverChange", this.ctx.hoverRow, l, t), this.ctx.emit("draw")), this.ctx.hoverCell = l, this.ctx.emit("cellHoverChange", l, t);
2525
2527
  return;
2526
2528
  }
2527
2529
  }
@@ -3298,9 +3300,11 @@ class ai {
3298
3300
  config: { ENABLE_RESIZE_ROW: t }
3299
3301
  } = this.ctx;
3300
3302
  t && (this.ctx.on("mouseup", () => {
3301
- this.isMouseDown = !1, this.resizeDiff !== 0 && this.resizeTarget && this.resizeRow(this.resizeTarget, this.resizeDiff), this.resizeTarget = null, this.resizeDiff = 0, this.isResizing = !1, this.ctx.rowResizing = !1, this.offsetY = 0;
3303
+ this.isMouseDown = !1, this.resizeDiff !== 0 && this.resizeTarget && this.resizeRow(this.resizeTarget, this.resizeDiff), this.resizeTarget = null, this.resizeDiff = 0, this.isResizing = !1, setTimeout(() => {
3304
+ this.ctx.rowResizing = !1;
3305
+ }, 0), this.offsetY = 0;
3302
3306
  }), this.ctx.on("mousedown", (e) => {
3303
- this.ctx.isTarget(e.target) && (this.offsetY = e.offsetY, this.resizeTarget ? (this.isResizing = !0, this.ctx.rowResizing = !0) : this.isResizing = !1, this.isMouseDown = !0);
3307
+ 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);
3304
3308
  }), this.ctx.on("mousemove", (e) => {
3305
3309
  if (this.ctx.editing) return;
3306
3310
  const i = e.offsetY, s = e.offsetX, {
@@ -4230,9 +4234,9 @@ const mi = (a) => ({
4230
4234
  x: e,
4231
4235
  y: i
4232
4236
  }, u = Mt(s), y = Ht(u), g = await o.getDimensions(l), w = u === "y", p = w ? "top" : "left", E = w ? "bottom" : "right", m = w ? "clientHeight" : "clientWidth", b = r.reference[y] + r.reference[u] - x[u] - r.floating[y], C = x[u] - r.reference[u], R = await (o.getOffsetParent == null ? void 0 : o.getOffsetParent(l));
4233
- let T = R ? R[m] : 0;
4234
- (!T || !await (o.isElement == null ? void 0 : o.isElement(R))) && (T = n.floating[m] || r.floating[y]);
4235
- const L = b / 2 - C / 2, A = T / 2 - g[y] / 2 - 1, D = rt(f[p], A), B = rt(f[E], A), O = D, S = T - g[y] - B, _ = T / 2 - g[y] / 2 + L, G = Ot(O, _, S), K = !h.arrow && ct(s) != null && _ !== G && r.reference[y] / 2 - (_ < O ? D : B) - g[y] / 2 < 0, X = K ? _ < O ? _ - O : _ - S : 0;
4237
+ let S = R ? R[m] : 0;
4238
+ (!S || !await (o.isElement == null ? void 0 : o.isElement(R))) && (S = n.floating[m] || r.floating[y]);
4239
+ const L = b / 2 - C / 2, A = S / 2 - g[y] / 2 - 1, D = rt(f[p], A), B = rt(f[E], A), O = D, T = S - g[y] - B, _ = S / 2 - g[y] / 2 + L, G = Ot(O, _, T), K = !h.arrow && ct(s) != null && _ !== G && r.reference[y] / 2 - (_ < O ? D : B) - g[y] / 2 < 0, X = K ? _ < O ? _ - O : _ - T : 0;
4236
4240
  return {
4237
4241
  [u]: x[u] + X,
4238
4242
  data: {
@@ -4271,7 +4275,7 @@ const mi = (a) => ({
4271
4275
  return {};
4272
4276
  const p = q(s), E = J(n), m = q(n) === n, b = await (h.isRTL == null ? void 0 : h.isRTL(l.floating)), C = x || (m || !g ? [xt(n)] : ui(n)), R = y !== "none";
4273
4277
  !x && R && C.push(...wi(n, g, y, b));
4274
- const T = [n, ...C], L = await re(t, w), A = [];
4278
+ const S = [n, ...C], L = await re(t, w), A = [];
4275
4279
  let D = ((i = r.flip) == null ? void 0 : i.overflows) || [];
4276
4280
  if (d && A.push(L[p]), f) {
4277
4281
  const _ = xi(s, o, b);
@@ -4282,7 +4286,7 @@ const mi = (a) => ({
4282
4286
  overflows: A
4283
4287
  }], !A.every((_) => _ <= 0)) {
4284
4288
  var B, O;
4285
- const _ = (((B = r.flip) == null ? void 0 : B.index) || 0) + 1, G = T[_];
4289
+ const _ = (((B = r.flip) == null ? void 0 : B.index) || 0) + 1, G = S[_];
4286
4290
  if (G)
4287
4291
  return {
4288
4292
  data: {
@@ -4297,8 +4301,8 @@ const mi = (a) => ({
4297
4301
  if (!K)
4298
4302
  switch (u) {
4299
4303
  case "bestFit": {
4300
- var S;
4301
- const X = (S = D.filter((W) => {
4304
+ var T;
4305
+ const X = (T = D.filter((W) => {
4302
4306
  if (R) {
4303
4307
  const P = J(W.placement);
4304
4308
  return P === E || // Create a bias to the `y` side axis due to horizontal
@@ -4306,7 +4310,7 @@ const mi = (a) => ({
4306
4310
  P === "y";
4307
4311
  }
4308
4312
  return !0;
4309
- }).map((W) => [W.placement, W.overflows.filter((P) => P > 0).reduce((P, we) => P + we, 0)]).sort((W, P) => W[1] - P[1])[0]) == null ? void 0 : S[0];
4313
+ }).map((W) => [W.placement, W.overflows.filter((P) => P > 0).reduce((P, we) => P + we, 0)]).sort((W, P) => W[1] - P[1])[0]) == null ? void 0 : T[0];
4310
4314
  X && (K = X);
4311
4315
  break;
4312
4316
  }
@@ -4527,17 +4531,17 @@ function ne(a) {
4527
4531
  const t = z(a);
4528
4532
  return Q(t) ? a.ownerDocument ? a.ownerDocument.body : a.body : N(t) && ht(t) ? t : ne(t);
4529
4533
  }
4530
- function St(a, t, e) {
4534
+ function Tt(a, t, e) {
4531
4535
  var i;
4532
4536
  t === void 0 && (t = []), e === void 0 && (e = !0);
4533
4537
  const s = ne(a), r = s === ((i = a.ownerDocument) == null ? void 0 : i.body), o = M(s);
4534
4538
  if (r) {
4535
- const n = Tt(o);
4536
- return t.concat(o, o.visualViewport || [], ht(s) ? s : [], n && e ? St(n) : []);
4539
+ const n = St(o);
4540
+ return t.concat(o, o.visualViewport || [], ht(s) ? s : [], n && e ? Tt(n) : []);
4537
4541
  }
4538
- return t.concat(s, St(s, [], e));
4542
+ return t.concat(s, Tt(s, [], e));
4539
4543
  }
4540
- function Tt(a) {
4544
+ function St(a) {
4541
4545
  return a.parent && Object.getPrototypeOf(a.parent) ? a.frameElement : null;
4542
4546
  }
4543
4547
  function ae(a) {
@@ -4588,10 +4592,10 @@ function ot(a, t, e, i) {
4588
4592
  let h = (s.left + n.x) / o.x, l = (s.top + n.y) / o.y, d = s.width / o.x, f = s.height / o.y;
4589
4593
  if (r) {
4590
4594
  const x = M(r), u = i && k(i) ? M(i) : i;
4591
- let y = x, g = Tt(y);
4595
+ let y = x, g = St(y);
4592
4596
  for (; g && i && u !== y; ) {
4593
4597
  const w = Z(g), p = g.getBoundingClientRect(), E = F(g), m = p.left + (g.clientLeft + parseFloat(E.paddingLeft)) * w.x, b = p.top + (g.clientTop + parseFloat(E.paddingTop)) * w.y;
4594
- h *= w.x, l *= w.y, d *= w.x, f *= w.y, h += m, l += b, y = M(g), g = Tt(y);
4598
+ h *= w.x, l *= w.y, d *= w.x, f *= w.y, h += m, l += b, y = M(g), g = St(y);
4595
4599
  }
4596
4600
  }
4597
4601
  return ut({
@@ -4601,7 +4605,7 @@ function ot(a, t, e, i) {
4601
4605
  y: l
4602
4606
  });
4603
4607
  }
4604
- function Si(a) {
4608
+ function Ti(a) {
4605
4609
  let {
4606
4610
  elements: t,
4607
4611
  rect: e,
@@ -4627,7 +4631,7 @@ function Si(a) {
4627
4631
  y: e.y * l.y - h.scrollTop * l.y + d.y
4628
4632
  };
4629
4633
  }
4630
- function Ti(a) {
4634
+ function Si(a) {
4631
4635
  return Array.from(a.getClientRects());
4632
4636
  }
4633
4637
  function Lt(a, t) {
@@ -4695,7 +4699,7 @@ function Mi(a, t) {
4695
4699
  const e = t.get(a);
4696
4700
  if (e)
4697
4701
  return e;
4698
- let i = St(a, [], !1).filter((n) => k(n) && tt(n) !== "body"), s = null;
4702
+ let i = Tt(a, [], !1).filter((n) => k(n) && tt(n) !== "body"), s = null;
4699
4703
  const r = F(a).position === "fixed";
4700
4704
  let o = r ? z(a) : a;
4701
4705
  for (; k(o) && !Q(o); ) {
@@ -4803,12 +4807,12 @@ function Ni(a) {
4803
4807
  return F(a).direction === "rtl";
4804
4808
  }
4805
4809
  const Ki = {
4806
- convertOffsetParentRelativeRectToViewportRelativeRect: Si,
4810
+ convertOffsetParentRelativeRectToViewportRelativeRect: Ti,
4807
4811
  getDocumentElement: Y,
4808
4812
  getClippingRect: Di,
4809
4813
  getOffsetParent: de,
4810
4814
  getElementRects: Xi,
4811
- getClientRects: Ti,
4815
+ getClientRects: Si,
4812
4816
  getDimensions: ki,
4813
4817
  getScale: Z,
4814
4818
  isElement: k,
@@ -5049,11 +5053,28 @@ class Wi {
5049
5053
  s !== i && !(s === "" && i === null) && this.ctx.database.setItemValue(t, e, s, !0, !0, !0), this.inputEl.textContent = null, this.editorEl.style.left = "-10000px", this.editorEl.style.top = "-10000px";
5050
5054
  }
5051
5055
  startEdit() {
5052
- const t = this.ctx.focusCell;
5053
- if (!t || ["index", "index-selection", "selection"].includes(t.type) || this.enable)
5056
+ const { ENABLE_EDIT_CLICK_SELECTOR: t } = this.ctx.config;
5057
+ if (!t)
5058
+ return;
5059
+ const e = this.ctx.focusCell;
5060
+ if (!e || ["index", "index-selection", "selection"].includes(e.type) || this.enable)
5054
5061
  return;
5055
- const { rowKey: e, key: i } = t, s = this.ctx.database.getReadonly(e, i);
5056
- t && !s && (this.enable = !0, this.ctx.editing = !0, this.cellTarget = t, this.startEditByInput(this.cellTarget), this.ctx.emit("startEdit", this.cellTarget));
5062
+ const { rowKey: i, key: s } = e, r = this.ctx.database.getReadonly(i, s);
5063
+ e && !r && (this.enable = !0, this.ctx.editing = !0, this.cellTarget = e, this.startEditByInput(this.cellTarget), this.ctx.emit("startEdit", this.cellTarget));
5064
+ }
5065
+ editCell(t, e) {
5066
+ const i = this.ctx.body.renderRows.find((l) => l.rowIndex === t);
5067
+ if (!i)
5068
+ return;
5069
+ const s = i.cells.find((l) => l.colIndex === e);
5070
+ if (!s)
5071
+ return;
5072
+ this.ctx.emit("setSelectorCell", s);
5073
+ const r = this.ctx.focusCell;
5074
+ if (!r || ["index", "index-selection", "selection"].includes(r.type) || this.enable)
5075
+ return;
5076
+ const { rowKey: o, key: n } = r, h = this.ctx.database.getReadonly(o, n);
5077
+ r && !h && (this.enable = !0, this.ctx.editing = !0, this.cellTarget = r, this.startEditByInput(this.cellTarget), this.ctx.emit("startEdit", this.cellTarget));
5057
5078
  }
5058
5079
  doneEdit() {
5059
5080
  this.enable && this.cellTarget && (this.ctx.emit("doneEdit", this.cellTarget), this.doneEditByInput(), this.enable = !1, this.ctx.target.focus(), this.ctx.editing = !1, this.cellTarget = null, this.ctx.emit("draw"));
@@ -5425,6 +5446,9 @@ class Gi {
5425
5446
  filterMethod(t) {
5426
5447
  this.ctx.setScrollY(0), this.ctx.setScrollX(0), this.ctx.database.init(), this.ctx.database.setFilterMethod(t), this.ctx.emit("draw");
5427
5448
  }
5449
+ editCell(t, e) {
5450
+ this.editor.editCell(t, e);
5451
+ }
5428
5452
  setItemValue(t, e, i, s = !0, r = !0, o = !1) {
5429
5453
  this.ctx.database.setItemValue(t, e, i, s, r, o);
5430
5454
  }