e-virt-table 0.1.7 → 0.1.8

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
@@ -917,6 +917,18 @@ class ii {
917
917
  const i = this.rowKeyMap.get(t);
918
918
  i.expand = e, this.clearBufferData(), this.ctx.emit("draw");
919
919
  }
920
+ setExpandRowKeys(t, e = !0) {
921
+ t.forEach((i) => {
922
+ const s = this.rowKeyMap.get(i);
923
+ s.expand = e;
924
+ }), this.clearBufferData(), this.ctx.emit("draw");
925
+ }
926
+ getExpandRowKeys() {
927
+ let t = [];
928
+ return this.rowKeyMap.forEach((e, i) => {
929
+ e.expand && t.push(i);
930
+ }), t;
931
+ }
920
932
  expandAll(t) {
921
933
  this.rowKeyMap.forEach((e) => {
922
934
  e.expand = t;
@@ -1051,27 +1063,36 @@ class ii {
1051
1063
  };
1052
1064
  a[e] !== null && typeof a[e] == "object" && (l = JSON.parse(JSON.stringify(a[e])));
1053
1065
  const c = `${t}​_${e}`;
1054
- if (this.originalDataMap.has(c) || this.originalDataMap.set(c, l), this.changedDataMap.set(c, i), a[e] = i, o) {
1055
- const f = this.ctx.database.getRowDataItemForRowKey(t), d = {
1066
+ this.originalDataMap.has(c) || this.originalDataMap.set(c, l);
1067
+ const f = this.originalDataMap.get(c), { BEFORE_VALUE_CHANGE_METHOD: d } = this.ctx.config;
1068
+ let x = i;
1069
+ if (typeof d == "function" && (x = d({
1070
+ rowKey: t,
1071
+ key: e,
1072
+ oldValue: l,
1073
+ value: i,
1074
+ originalValue: f
1075
+ })), this.changedDataMap.set(c, x), a[e] = x, o) {
1076
+ const u = this.ctx.database.getRowDataItemForRowKey(t), g = {
1056
1077
  rowKey: t,
1057
1078
  key: e,
1058
- value: i,
1059
- row: f
1079
+ value: x,
1080
+ row: u
1060
1081
  };
1061
- this.ctx.emit("change", [d], [f]), this.ctx.emit("editChange", {
1082
+ this.ctx.emit("change", [g], [u]), this.ctx.emit("editChange", {
1062
1083
  rowKey: t,
1063
1084
  key: e,
1064
1085
  oldValue: l,
1065
- value: i,
1066
- originalValue: this.originalDataMap.get(c),
1067
- row: f
1086
+ value: x,
1087
+ originalValue: f,
1088
+ row: u
1068
1089
  });
1069
1090
  }
1070
1091
  return this.ctx.hasEvent("iterationChange") && this.ctx.emit("iterationChange", {
1071
1092
  rowKey: t,
1072
1093
  key: e,
1073
1094
  oldValue: l,
1074
- value: i,
1095
+ value: x,
1075
1096
  originalValue: this.originalDataMap.get(c),
1076
1097
  row: this.ctx.database.getRowDataItemForRowKey(t)
1077
1098
  }), s && this.ctx.history.pushState({
@@ -1083,12 +1104,12 @@ class ii {
1083
1104
  rowKey: t,
1084
1105
  key: e,
1085
1106
  oldValue: l,
1086
- newValue: i
1107
+ newValue: x
1087
1108
  }
1088
1109
  ]
1089
1110
  }), this.getValidator(t, e), r && this.ctx.emit("draw"), {
1090
1111
  oldValue: l,
1091
- newValue: i
1112
+ newValue: x
1092
1113
  };
1093
1114
  }
1094
1115
  /**
@@ -1275,7 +1296,7 @@ class ii {
1275
1296
  return t ? (this.headerMap.set(t, e), !0) : !1;
1276
1297
  }
1277
1298
  getReadonly(t, e) {
1278
- const i = this.rowKeyMap.get(t), s = this.headerMap.get(e), r = i == null ? void 0 : i.readonly, o = s == null ? void 0 : s.readonly, { CELL_READONLY_METHOD: a } = this.ctx.config;
1299
+ const i = this.rowKeyMap.get(t), s = this.headerMap.get(e), r = i == null ? void 0 : i.readonly, o = s == null ? void 0 : s.readonly, { BODY_CELL_READONLY_METHOD: a } = this.ctx.config;
1279
1300
  if (typeof a == "function") {
1280
1301
  const c = a({
1281
1302
  row: i.item,
@@ -1294,7 +1315,7 @@ class ii {
1294
1315
  }
1295
1316
  getValidator(t, e) {
1296
1317
  return new Promise((i) => {
1297
- const s = this.rowKeyMap.get(t), r = this.headerMap.get(e), { CELL_RULES_METHOD: o } = this.ctx.config, a = r.column;
1318
+ const s = this.rowKeyMap.get(t), r = this.headerMap.get(e), { BODY_CELL_RULES_METHOD: o } = this.ctx.config, a = r.column;
1298
1319
  let l = a.rules;
1299
1320
  if (typeof o == "function") {
1300
1321
  const f = o({
@@ -1767,16 +1788,17 @@ class Wt {
1767
1788
  h(this, "HEADER_CELL_STYLE_METHOD");
1768
1789
  h(this, "BODY_CELL_STYLE_METHOD");
1769
1790
  h(this, "FOOTER_CELL_STYLE_METHOD");
1770
- h(this, "CELL_READONLY_METHOD");
1771
- h(this, "CELL_FORMATTER_METHOD");
1772
- h(this, "CELL_RULES_METHOD");
1773
- h(this, "CELL_TYPE_METHOD");
1774
- h(this, "CELL_EDITOR_TYPE_METHOD");
1775
- h(this, "CELL_RENDER_METHOD");
1776
- h(this, "CELL_HOVER_ICON_METHOD");
1791
+ h(this, "BODY_CELL_READONLY_METHOD");
1792
+ h(this, "BODY_CELL_FORMATTER_METHOD");
1793
+ h(this, "BODY_CELL_RULES_METHOD");
1794
+ h(this, "BODY_CELL_TYPE_METHOD");
1795
+ h(this, "BODY_CELL_EDITOR_TYPE_METHOD");
1796
+ h(this, "BODY_CELL_RENDER_METHOD");
1797
+ h(this, "BODY_CELL_HOVER_ICON_METHOD");
1777
1798
  h(this, "SPAN_METHOD");
1778
1799
  h(this, "SELECTABLE_METHOD");
1779
1800
  h(this, "EXPAND_LAZY_METHOD");
1801
+ h(this, "BEFORE_VALUE_CHANGE_METHOD");
1780
1802
  Object.assign(this, t);
1781
1803
  }
1782
1804
  init(t) {
@@ -1943,6 +1965,7 @@ class ee extends te {
1943
1965
  constructor(e, i, s, r, o, a, l, c, f, d = "body") {
1944
1966
  super(e, r, o, a, l, c.fixed, d);
1945
1967
  h(this, "formatter");
1968
+ h(this, "formatterFooter");
1946
1969
  h(this, "hoverIconName", "");
1947
1970
  h(this, "operation", !1);
1948
1971
  h(this, "align");
@@ -1970,6 +1993,7 @@ class ee extends te {
1970
1993
  h(this, "displayText", "");
1971
1994
  h(this, "visibleWidth", 0);
1972
1995
  h(this, "visibleHeight", 0);
1996
+ h(this, "isHasChanged", !1);
1973
1997
  h(this, "drawX", 0);
1974
1998
  h(this, "drawY", 0);
1975
1999
  h(this, "drawCellBgColor", "");
@@ -1989,7 +2013,7 @@ class ee extends te {
1989
2013
  h(this, "overflowTooltipShow", !0);
1990
2014
  h(this, "overflowTooltipMaxWidth", 500);
1991
2015
  h(this, "overflowTooltipPlacement", "top");
1992
- this.visibleWidth = this.width, this.visibleHeight = this.height, this.colIndex = s, this.rowIndex = i, this.key = c.key, this.type = c.type || "text", this.editorType = c.editorType || "text", this.cellType = d, this.align = c.align || "center", this.verticalAlign = c.verticalAlign || "middle", this.fixed = c.fixed, this.level = c.level, this.operation = c.operation || !1, this.column = c, this.rules = c.rules, this.row = f, this.rowKey = this.cellType === "body" ? this.ctx.database.getRowKeyForRowIndex(i) : `${this.cellType}_${this.rowIndex}`, this.value = this.getValue(), this.render = c.render, this.overflowTooltipShow = c.overflowTooltipShow !== !1, this.overflowTooltipMaxWidth = c.overflowTooltipMaxWidth || 500, this.overflowTooltipPlacement = c.overflowTooltipPlacement || "top", this.renderFooter = c.renderFooter, this.hoverIconName = c.hoverIconName, this.formatter = c.formatter, this.update();
2016
+ this.visibleWidth = this.width, this.visibleHeight = this.height, this.colIndex = s, this.rowIndex = i, this.key = c.key, this.type = c.type || "text", this.editorType = c.editorType || "text", this.cellType = d, this.align = c.align || "center", this.verticalAlign = c.verticalAlign || "middle", this.fixed = c.fixed, this.level = c.level, this.operation = c.operation || !1, this.column = c, this.rules = c.rules, this.row = f, this.rowKey = this.cellType === "body" ? this.ctx.database.getRowKeyForRowIndex(i) : `${this.cellType}_${this.rowIndex}`, this.value = this.getValue(), this.render = c.render, this.overflowTooltipShow = c.overflowTooltipShow !== !1, this.overflowTooltipMaxWidth = c.overflowTooltipMaxWidth || 500, this.overflowTooltipPlacement = c.overflowTooltipPlacement || "top", this.renderFooter = c.renderFooter, this.hoverIconName = c.hoverIconName, this.formatter = c.formatter, this.formatterFooter = c.formatterFooter, this.update();
1993
2017
  }
1994
2018
  getValidationMessage() {
1995
2019
  const e = this.ctx.database.getValidationError(this.rowKey, this.key);
@@ -2000,7 +2024,7 @@ class ee extends te {
2000
2024
  return this.message;
2001
2025
  }
2002
2026
  update() {
2003
- this.drawX = this.getDrawX(), this.drawY = this.getDrawY(), this.drawTextX = this.drawX, this.drawTextY = this.drawY, this.updateSpan(), this.updateStyle(), this.updateType(), this.updateHoverIcon(), this.updateSelection(), this.updateTree(), this.updateEditorType(), this.updateRender(), this.getValidationMessage(), this.updateContainer(), this.text = this.getText(), this.displayText = this.getDisplayText();
2027
+ this.drawX = this.getDrawX(), this.drawY = this.getDrawY(), this.drawTextX = this.drawX, this.drawTextY = this.drawY, this.isHasChanged = this.ctx.database.isHasChangedData(this.rowKey, this.key), this.updateSpan(), this.updateStyle(), this.updateType(), this.updateHoverIcon(), this.updateSelection(), this.updateTree(), this.updateEditorType(), this.updateRender(), this.getValidationMessage(), this.updateContainer(), this.text = this.getText(), this.displayText = this.getDisplayText();
2004
2028
  }
2005
2029
  updateSpan() {
2006
2030
  if (this.cellType === "footer")
@@ -2023,7 +2047,7 @@ class ee extends te {
2023
2047
  }
2024
2048
  }
2025
2049
  updateType() {
2026
- const { CELL_TYPE_METHOD: e } = this.ctx.config;
2050
+ const { BODY_CELL_TYPE_METHOD: e } = this.ctx.config;
2027
2051
  if (typeof e == "function") {
2028
2052
  const s = e({
2029
2053
  row: this.row,
@@ -2036,7 +2060,7 @@ class ee extends te {
2036
2060
  }
2037
2061
  }
2038
2062
  updateEditorType() {
2039
- const { CELL_EDITOR_TYPE_METHOD: e } = this.ctx.config;
2063
+ const { BODY_CELL_EDITOR_TYPE_METHOD: e } = this.ctx.config;
2040
2064
  if (typeof e == "function") {
2041
2065
  const s = e({
2042
2066
  row: this.row,
@@ -2049,7 +2073,7 @@ class ee extends te {
2049
2073
  }
2050
2074
  }
2051
2075
  updateRender() {
2052
- const { CELL_RENDER_METHOD: e } = this.ctx.config;
2076
+ const { BODY_CELL_RENDER_METHOD: e } = this.ctx.config;
2053
2077
  if (typeof e == "function") {
2054
2078
  const s = e({
2055
2079
  row: this.row,
@@ -2140,6 +2164,7 @@ class ee extends te {
2140
2164
  rowIndex: this.rowIndex,
2141
2165
  colIndex: this.colIndex,
2142
2166
  column: this.column,
2167
+ isHasChanged: this.isHasChanged,
2143
2168
  value: this.getValue()
2144
2169
  }) || {};
2145
2170
  b && (w = b), m && (y = m);
@@ -2155,7 +2180,7 @@ class ee extends te {
2155
2180
  }
2156
2181
  }
2157
2182
  updateHoverIcon() {
2158
- const { CELL_HOVER_ICON_METHOD: e, CELL_HOVER_ICON_SIZE: i, CELL_PADDING: s } = this.ctx.config;
2183
+ const { BODY_CELL_HOVER_ICON_METHOD: e, CELL_HOVER_ICON_SIZE: i, CELL_PADDING: s } = this.ctx.config;
2159
2184
  if (typeof e == "function") {
2160
2185
  const l = e({
2161
2186
  row: this.row,
@@ -2185,7 +2210,13 @@ class ee extends te {
2185
2210
  */
2186
2211
  getText() {
2187
2212
  if (this.cellType === "footer")
2188
- return this.row[this.key];
2213
+ return typeof this.formatterFooter == "function" ? this.formatterFooter({
2214
+ row: this.row,
2215
+ rowIndex: this.rowIndex,
2216
+ colIndex: this.colIndex,
2217
+ column: this.column,
2218
+ value: this.row[this.key]
2219
+ }) : this.row[this.key];
2189
2220
  if (typeof this.formatter == "function")
2190
2221
  return this.formatter({
2191
2222
  row: this.row,
@@ -2194,7 +2225,7 @@ class ee extends te {
2194
2225
  column: this.column,
2195
2226
  value: this.getValue()
2196
2227
  });
2197
- const { CELL_FORMATTER_METHOD: e } = this.ctx.config;
2228
+ const { BODY_CELL_FORMATTER_METHOD: e } = this.ctx.config;
2198
2229
  return typeof e == "function" ? e({
2199
2230
  row: this.row,
2200
2231
  rowIndex: this.rowIndex,
@@ -2580,13 +2611,13 @@ class hi {
2580
2611
  column: t.column,
2581
2612
  value: t.getValue()
2582
2613
  }).then((l) => {
2583
- this.ctx.database.setExpandChildren(t.rowKey, l), this.ctx.database.expandLoading(t.rowKey, !1);
2614
+ this.ctx.database.setExpandChildren(t.rowKey, l), this.ctx.database.expandLoading(t.rowKey, !1), this.ctx.emit("expandChange", this.ctx.database.getExpandRowKeys());
2584
2615
  }).catch((l) => {
2585
2616
  this.ctx.database.expandLoading(t.rowKey, !1), console.error(l);
2586
2617
  }));
2587
2618
  else {
2588
2619
  const a = this.ctx.database.getIsExpand(t.rowKey);
2589
- this.ctx.database.expandItem(t.rowKey, !a), this.ctx.emit("expandChange");
2620
+ this.ctx.database.expandItem(t.rowKey, !a), this.ctx.emit("expandChange", this.ctx.database.getExpandRowKeys());
2590
2621
  }
2591
2622
  }
2592
2623
  }
@@ -3912,10 +3943,12 @@ class ui {
3912
3943
  if (!i || i.height > l.visibleHeight || i.width > l.visibleWidth - r - s)
3913
3944
  return;
3914
3945
  let u = 0;
3915
- if (x && (u = a.visibleHeight), i.fixed || !(i.drawX < r || i.drawX + i.width > e - s || i.drawY < this.ctx.header.height || i.drawY + i.height > t - u - d))
3946
+ x && (u = a.visibleHeight);
3947
+ const g = i.drawX < r, w = i.drawX + i.width > e - s, y = i.drawY < o.height, p = i.drawY + i.height > t - u - d;
3948
+ if (i.fixed && !(y || p) || !(g || w || y || p))
3916
3949
  return;
3917
- const g = r - i.drawX + 1, w = i.drawX + i.width - (e - s) + 1, y = o.height - i.drawY, p = i.drawY + i.height - (t - u - d);
3918
- w > 0 && !i.fixed ? this.ctx.setScrollX(c + w) : g > 0 && !i.fixed && this.ctx.setScrollX(c - g), y > 0 ? this.ctx.setScrollY(f - y) : p > 0 && this.ctx.setScrollY(f + p), this.ctx.emit("adjustBoundaryPosition", i);
3950
+ const b = r - i.drawX + 1, m = i.drawX + i.width - (e - s) + 1, E = o.height - i.drawY, C = i.drawY + i.height - (t - u - d);
3951
+ m > 0 && !i.fixed ? this.ctx.setScrollX(c + m) : b > 0 && !i.fixed && this.ctx.setScrollX(c - b), E > 0 ? this.ctx.setScrollY(f - E) : C > 0 && this.ctx.setScrollY(f + C), this.ctx.emit("adjustBoundaryPosition", i);
3919
3952
  }
3920
3953
  destroy() {
3921
3954
  this.timerX && (clearTimeout(this.timerX), this.timerX = 0), this.timerY && (clearTimeout(this.timerY), this.timerY = 0);
@@ -5615,6 +5648,9 @@ class Qi {
5615
5648
  scrollYTo(t) {
5616
5649
  this.ctx.setScrollY(t);
5617
5650
  }
5651
+ setExpandRowKeys(t, e = !0) {
5652
+ this.ctx.database.setExpandRowKeys(t, e);
5653
+ }
5618
5654
  clearSelection() {
5619
5655
  this.ctx.database.clearSelection(), this.ctx.emit("draw");
5620
5656
  }