@visactor/vtable-sheet 1.22.11-alpha.4 → 1.22.11-alpha.5

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/cjs/index.d.ts CHANGED
@@ -2,5 +2,5 @@ import VTableSheet from './components/vtable-sheet';
2
2
  import type { ISheetDefine, IVTableSheetOptions } from './ts-types';
3
3
  import * as TYPES from './ts-types';
4
4
  import * as VTable from './vtable';
5
- export declare const version = "1.22.11-alpha.4";
5
+ export declare const version = "1.22.11-alpha.5";
6
6
  export { VTableSheet, TYPES, VTable, ISheetDefine, IVTableSheetOptions };
package/cjs/index.js CHANGED
@@ -47,4 +47,4 @@ exports.VTable = VTable;
47
47
 
48
48
  const style_manager_1 = require("./styles/style-manager");
49
49
 
50
- exports.version = "1.22.11-alpha.4", (0, style_manager_1.importStyles)();
50
+ exports.version = "1.22.11-alpha.5", (0, style_manager_1.importStyles)();
package/cjs/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6EAAoD;AAW3C,sBAXF,sBAAW,CAWE;AATpB,kDAAoC;AASd,sBAAK;AAR3B,iDAAmC;AAQN,wBAAM;AAPnC,0DAAsD;AACzC,QAAA,OAAO,GAAG,iBAAiB,CAAC;AAEzC,IAAA,4BAAY,GAAE,CAAC","file":"index.js","sourcesContent":["import VTableSheet from './components/vtable-sheet';\nimport type { ISheetDefine, IVTableSheetOptions } from './ts-types';\nimport * as TYPES from './ts-types';\nimport * as VTable from './vtable';\nimport { importStyles } from './styles/style-manager';\nexport const version = \"1.22.11-alpha.4\";\n// 导入样式\nimportStyles();\n/**\n * @namespace VTableSheet\n */\nexport { VTableSheet, TYPES, VTable, ISheetDefine, IVTableSheetOptions };\n"]}
1
+ {"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6EAAoD;AAW3C,sBAXF,sBAAW,CAWE;AATpB,kDAAoC;AASd,sBAAK;AAR3B,iDAAmC;AAQN,wBAAM;AAPnC,0DAAsD;AACzC,QAAA,OAAO,GAAG,iBAAiB,CAAC;AAEzC,IAAA,4BAAY,GAAE,CAAC","file":"index.js","sourcesContent":["import VTableSheet from './components/vtable-sheet';\nimport type { ISheetDefine, IVTableSheetOptions } from './ts-types';\nimport * as TYPES from './ts-types';\nimport * as VTable from './vtable';\nimport { importStyles } from './styles/style-manager';\nexport const version = \"1.22.11-alpha.5\";\n// 导入样式\nimportStyles();\n/**\n * @namespace VTableSheet\n */\nexport { VTableSheet, TYPES, VTable, ISheetDefine, IVTableSheetOptions };\n"]}
@@ -38828,6 +38828,7 @@
38828
38828
  AFTER_UPDATE_CELL_CONTENT_WIDTH: "after_update_cell_content_width",
38829
38829
  AFTER_UPDATE_SELECT_BORDER_HEIGHT: "after_update_select_border_height",
38830
38830
  CHANGE_CELL_VALUE: "change_cell_value",
38831
+ CHANGE_CELL_VALUES: "change_cell_values",
38831
38832
  DRAG_FILL_HANDLE_END: "drag_fill_handle_end",
38832
38833
  MOUSEDOWN_FILL_HANDLE: "mousedown_fill_handle",
38833
38834
  DBLCLICK_FILL_HANDLE: "dblclick_fill_handle",
@@ -40954,6 +40955,24 @@
40954
40955
  }
40955
40956
  }
40956
40957
  }
40958
+ changeFieldValueByRecordIndex(value, recordIndex, field, table) {
40959
+ var _a, _b, _c, _d;
40960
+ if (null === field) return;
40961
+ if (null == recordIndex) return;
40962
+ const rawKey = recordIndex.toString();
40963
+ if (!this.beforeChangedRecordsMap.has(rawKey)) {
40964
+ const rawRecords = Array.isArray(null === (_a = this.dataSourceObj) || void 0 === _a ? void 0 : _a.records) ? this.dataSourceObj.records : null,
40965
+ originRecord = rawRecords ? Array.isArray(recordIndex) ? getValueFromDeepArray(rawRecords, recordIndex) : rawRecords[recordIndex] : void 0;
40966
+ this.beforeChangedRecordsMap.set(rawKey, null !== (_b = cloneDeep$1(originRecord, void 0, ["vtable_gantt_linkedFrom", "vtable_gantt_linkedTo"])) && void 0 !== _b ? _b : {});
40967
+ }
40968
+ if ("string" == typeof field || "number" == typeof field) {
40969
+ const beforeChangedValue = null === (_c = this.beforeChangedRecordsMap.get(rawKey)) || void 0 === _c ? void 0 : _c[field],
40970
+ rawRecords = Array.isArray(null === (_d = this.dataSourceObj) || void 0 === _d ? void 0 : _d.records) ? this.dataSourceObj.records : null,
40971
+ record = rawRecords ? Array.isArray(recordIndex) ? getValueFromDeepArray(rawRecords, recordIndex) : rawRecords[recordIndex] : void 0;
40972
+ let formatValue = value;
40973
+ "number" == typeof beforeChangedValue && isAllDigits(value) && (formatValue = parseFloat(value)), record ? record[field] = formatValue : rawRecords && "number" == typeof recordIndex && (rawRecords[recordIndex] = "Array" === this.addRecordRule ? [] : {}, rawRecords[recordIndex][field] = formatValue);
40974
+ }
40975
+ }
40957
40976
  cacheBeforeChangedRecord(dataIndex, table) {
40958
40977
  var _a;
40959
40978
  if (!this.beforeChangedRecordsMap.has(dataIndex.toString())) {
@@ -41019,9 +41038,16 @@
41019
41038
  }
41020
41039
  }
41021
41040
  adjustBeforeChangedRecordsMap(insertIndex, insertCount, type = "add") {
41022
- for (let key = this.beforeChangedRecordsMap.size - 1; key >= insertIndex; key--) {
41023
- const record = this.beforeChangedRecordsMap.get(key.toString());
41024
- this.beforeChangedRecordsMap.delete(key.toString()), this.beforeChangedRecordsMap.set((key + ("add" === type ? insertCount : -insertCount)).toString(), record);
41041
+ const delta = "add" === type ? insertCount : -insertCount,
41042
+ numericKeys = [];
41043
+ this.beforeChangedRecordsMap.forEach((_, key) => {
41044
+ const numKey = Number(key);
41045
+ Number.isInteger(numKey) && numKey.toString() === key && numKey >= insertIndex && numericKeys.push(numKey);
41046
+ }), numericKeys.sort((a, b) => "add" === type ? b - a : a - b);
41047
+ for (let i = 0; i < numericKeys.length; i++) {
41048
+ const key = numericKeys[i],
41049
+ record = this.beforeChangedRecordsMap.get(key.toString());
41050
+ this.beforeChangedRecordsMap.delete(key.toString()), this.beforeChangedRecordsMap.set((key + delta).toString(), record);
41025
41051
  }
41026
41052
  }
41027
41053
  deleteRecords(recordIndexs) {
@@ -57385,7 +57411,7 @@
57385
57411
  };
57386
57412
  let EventManager$1 = class EventManager {
57387
57413
  constructor(table) {
57388
- this.isDown = !1, this.isDraging = !1, this.globalEventListeners = [], this._enableTableScroll = !0, this.cutWaitPaste = !1, this.clipboardCheckTimer = null, this.cutOperationTime = 0, this.lastClipboardContent = "", this.cutCellRange = null, this.copySourceRange = null, this.table = table, this.handleTextStickBindId = [], this.inertiaScroll = new InertiaScroll(table.stateManager), "node" === Env$1.mode || table.options.disableInteraction || (this.bindOuterEvent(), setTimeout(() => {
57414
+ this.isDown = !1, this.isDraging = !1, this.globalEventListeners = [], this._enableTableScroll = !0, this.cutWaitPaste = !1, this.clipboardCheckTimer = null, this.cutOperationTime = 0, this.lastClipboardContent = "", this.cutCellRange = null, this.cutRanges = null, this.copySourceRange = null, this.table = table, this.handleTextStickBindId = [], this.inertiaScroll = new InertiaScroll(table.stateManager), "node" === Env$1.mode || table.options.disableInteraction || (this.bindOuterEvent(), setTimeout(() => {
57389
57415
  this.bindSelfEvent();
57390
57416
  }, 0));
57391
57417
  }
@@ -57687,15 +57713,25 @@
57687
57713
  } catch (error) {}
57688
57714
  }
57689
57715
  handleCut(e) {
57716
+ var _a;
57690
57717
  return __awaiter$1(this, void 0, void 0, function* () {
57691
- this.handleCopy(e, !0), this.cutWaitPaste = !0, this.cutCellRange = this.table.getSelectedCellInfos(), this.clipboardCheckTimer && clearTimeout(this.clipboardCheckTimer), this.clipboardCheckTimer = window.setTimeout(() => {
57692
- this.cutWaitPaste && (this.cutWaitPaste = !1, this.cutCellRange = null, this.clipboardCheckTimer = null);
57718
+ this.handleCopy(e, !0), this.cutWaitPaste = !0, this.cutCellRange = this.table.getSelectedCellInfos(), this.cutRanges = null === (_a = this.table.stateManager.select.ranges) || void 0 === _a ? void 0 : _a.map(r => ({
57719
+ start: {
57720
+ col: r.start.col,
57721
+ row: r.start.row
57722
+ },
57723
+ end: {
57724
+ col: r.end.col,
57725
+ row: r.end.row
57726
+ }
57727
+ })), this.clipboardCheckTimer && clearTimeout(this.clipboardCheckTimer), this.clipboardCheckTimer = window.setTimeout(() => {
57728
+ this.cutWaitPaste && (this.cutWaitPaste = !1, this.cutCellRange = null, this.cutRanges = null, this.clipboardCheckTimer = null);
57693
57729
  }, 3e4), this.saveClipboardContent();
57694
57730
  });
57695
57731
  }
57696
57732
  handlePaste(e) {
57697
57733
  this.cutWaitPaste ? this.checkClipboardChanged().then(changed => {
57698
- this.executePaste(e), changed || this.clearCutArea(this.table), this.cutWaitPaste && (this.cutWaitPaste = !1, this.cutCellRange = null, this.clipboardCheckTimer && (clearTimeout(this.clipboardCheckTimer), this.clipboardCheckTimer = null));
57734
+ this.executePaste(e), changed || this.clearCutArea(this.table), this.cutWaitPaste && (this.cutWaitPaste = !1, this.cutCellRange = null, this.cutRanges = null, this.clipboardCheckTimer && (clearTimeout(this.clipboardCheckTimer), this.clipboardCheckTimer = null));
57699
57735
  }).catch(() => {
57700
57736
  this.executePaste(e), this.cutWaitPaste && (this.cutWaitPaste = !1, this.cutCellRange = null, this.clipboardCheckTimer && (clearTimeout(this.clipboardCheckTimer), this.clipboardCheckTimer = null));
57701
57737
  }) : this.executePaste(e);
@@ -57772,9 +57808,9 @@
57772
57808
  }
57773
57809
  clearCutArea(table) {
57774
57810
  try {
57775
- const selectCells = this.cutCellRange;
57776
- if (!selectCells || 0 === selectCells.length) return;
57777
- for (let i = 0; i < selectCells.length; i++) for (let j = 0; j < selectCells[i].length; j++) selectCells[i][j] && table.changeCellValue(selectCells[i][j].col, selectCells[i][j].row, void 0);
57811
+ const ranges = this.cutRanges;
57812
+ if (!ranges || 0 === ranges.length) return;
57813
+ table.changeCellValuesByIds(ranges, "");
57778
57814
  } catch (error) {}
57779
57815
  }
57780
57816
  checkClipboardChanged() {
@@ -59712,6 +59748,15 @@
59712
59748
  constructor(table, customCellStyle, customCellStyleArrangement) {
59713
59749
  this.table = table, this.customCellStyle = customCellStyle, this.customCellStyleArrangement = customCellStyleArrangement;
59714
59750
  }
59751
+ clearCustomCellStyleArrangement() {
59752
+ this.customCellStyleArrangement = [];
59753
+ }
59754
+ addCustomCellStyleArrangement(cellPosition, customStyleId) {
59755
+ this.customCellStyleArrangement.push({
59756
+ cellPosition: cellPosition,
59757
+ customStyleId: customStyleId
59758
+ });
59759
+ }
59715
59760
  getCustomCellStyle(col, row) {
59716
59761
  const customStyleIds = this.getCustomCellStyleIds(col, row);
59717
59762
  if (customStyleIds.length) {
@@ -60017,7 +60062,7 @@
60017
60062
  }
60018
60063
  constructor(container, options = {}) {
60019
60064
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z;
60020
- if (super(), this.showFrozenIcon = !0, this.version = "1.22.11-alpha.4", this.id = `VTable${Date.now()}`, this.isReleased = !1, this._chartEventMap = {}, this.throttleInvalidate = throttle2(this.render.bind(this), 200), "node" === Env$1.mode ? (options = container, container = null) : container instanceof HTMLElement || (options = container, container = container.container ? container.container : null), !container && "node" !== options.mode && !options.canvas) throw new Error("vtable's container is undefined");
60065
+ if (super(), this.showFrozenIcon = !0, this.version = "1.22.11-alpha.5", this.id = `VTable${Date.now()}`, this.isReleased = !1, this._chartEventMap = {}, this.throttleInvalidate = throttle2(this.render.bind(this), 200), "node" === Env$1.mode ? (options = container, container = null) : container instanceof HTMLElement || (options = container, container = container.container ? container.container : null), !container && "node" !== options.mode && !options.canvas) throw new Error("vtable's container is undefined");
60021
60066
  this.pluginManager = new PluginManager(this, options), this.fireListeners(TABLE_EVENT_TYPE.BEFORE_INIT, {
60022
60067
  options: options,
60023
60068
  container: container
@@ -63828,15 +63873,16 @@
63828
63873
  step((generator = generator.apply(thisArg, _arguments || [])).next());
63829
63874
  });
63830
63875
  };
63831
- function listTableChangeCellValue(col, row, value, workOnEditableCell, triggerEvent, table) {
63876
+ function listTableChangeCellValue(col, row, value, workOnEditableCell, triggerEvent, table, silentChangeCellValuesEvent) {
63832
63877
  if (workOnEditableCell && table.isHasEditorDefine(col, row) || !1 === workOnEditableCell) {
63833
- const recordIndex = table.getRecordShowIndexByCell(col, row),
63878
+ const recordShowIndex = table.getRecordShowIndexByCell(col, row),
63879
+ recordIndex = recordShowIndex >= 0 ? table.dataSource.getIndexKey(recordShowIndex) : void 0,
63834
63880
  {
63835
63881
  field: field
63836
63882
  } = table.internalProps.layoutMap.getBody(col, row),
63837
63883
  beforeChangeValue = table.getCellRawValue(col, row),
63838
63884
  oldValue = table.getCellOriginValue(col, row);
63839
- table.isHeader(col, row) ? table.internalProps.layoutMap.updateColumnTitle(col, row, value) : table.dataSource.changeFieldValue(value, recordIndex, field, col, row, table);
63885
+ table.isHeader(col, row) ? table.internalProps.layoutMap.updateColumnTitle(col, row, value) : table.dataSource.changeFieldValue(value, recordShowIndex, field, col, row, table);
63840
63886
  const range = table.getCellRange(col, row),
63841
63887
  aggregators = table.internalProps.layoutMap.getAggregatorsByCell(col, row);
63842
63888
  if (aggregators) {
@@ -63859,16 +63905,24 @@
63859
63905
  table.scenegraph.updateRowHeight(row, newHeight - oldHeight);
63860
63906
  }
63861
63907
  const changedValue = table.getCellOriginValue(col, row);
63862
- oldValue !== changedValue && triggerEvent && table.fireListeners(TABLE_EVENT_TYPE.CHANGE_CELL_VALUE, {
63863
- col: col,
63864
- row: row,
63865
- rawValue: beforeChangeValue,
63866
- currentValue: oldValue,
63867
- changedValue: changedValue
63868
- }), table.scenegraph.updateNextFrame();
63908
+ if (oldValue !== changedValue && triggerEvent) {
63909
+ const changeValue = {
63910
+ col: col,
63911
+ row: row,
63912
+ recordIndex: recordIndex,
63913
+ field: field,
63914
+ rawValue: beforeChangeValue,
63915
+ currentValue: oldValue,
63916
+ changedValue: changedValue
63917
+ };
63918
+ table.fireListeners(TABLE_EVENT_TYPE.CHANGE_CELL_VALUE, changeValue), silentChangeCellValuesEvent || table.fireListeners(TABLE_EVENT_TYPE.CHANGE_CELL_VALUES, {
63919
+ values: [changeValue]
63920
+ });
63921
+ }
63922
+ table.scenegraph.updateNextFrame();
63869
63923
  }
63870
63924
  }
63871
- function listTableChangeCellValues(startCol, startRow, values, workOnEditableCell, triggerEvent, table) {
63925
+ function listTableChangeCellValues(startCol, startRow, values, workOnEditableCell, triggerEvent, table, silentChangeCellValuesEvent) {
63872
63926
  var _a, _b;
63873
63927
  return __awaiter(this, void 0, void 0, function* () {
63874
63928
  const changedCellResults = [];
@@ -63890,6 +63944,7 @@
63890
63944
  oldRowValues.push(oldValue);
63891
63945
  }
63892
63946
  }
63947
+ const resultChangeValues = [];
63893
63948
  for (let i = 0; i < values.length && !(startRow + i > table.rowCount - 1); i++) {
63894
63949
  changedCellResults[i] = [], pasteRowEnd = startRow + i;
63895
63950
  const rowValues = values[i];
@@ -63913,25 +63968,34 @@
63913
63968
  if (isCanChange) {
63914
63969
  changedCellResults[i][j] = !0;
63915
63970
  const value = rowValues[j],
63916
- recordIndex = table.getRecordShowIndexByCell(startCol + j, startRow + i),
63971
+ recordShowIndex = table.getRecordShowIndexByCell(startCol + j, startRow + i),
63972
+ recordIndex = recordShowIndex >= 0 ? table.dataSource.getIndexKey(recordShowIndex) : void 0,
63917
63973
  {
63918
63974
  field: field
63919
63975
  } = table.internalProps.layoutMap.getBody(startCol + j, startRow + i),
63920
63976
  beforeChangeValue = beforeChangeValues[i][j],
63921
63977
  oldValue = oldValues[i][j];
63922
- table.isHeader(startCol + j, startRow + i) ? table.internalProps.layoutMap.updateColumnTitle(startCol + j, startRow + i, value) : table.dataSource.changeFieldValue(value, recordIndex, field, startCol + j, startRow + i, table);
63978
+ table.isHeader(startCol + j, startRow + i) ? table.internalProps.layoutMap.updateColumnTitle(startCol + j, startRow + i, value) : table.dataSource.changeFieldValue(value, recordShowIndex, field, startCol + j, startRow + i, table);
63923
63979
  const changedValue = table.getCellOriginValue(startCol + j, startRow + i);
63924
- oldValue !== changedValue && triggerEvent && table.fireListeners(TABLE_EVENT_TYPE.CHANGE_CELL_VALUE, {
63925
- col: startCol + j,
63926
- row: startRow + i,
63927
- rawValue: beforeChangeValue,
63928
- currentValue: oldValue,
63929
- changedValue: changedValue
63930
- });
63980
+ if (oldValue !== changedValue && triggerEvent) {
63981
+ const changeValue = {
63982
+ col: startCol + j,
63983
+ row: startRow + i,
63984
+ recordIndex: recordIndex,
63985
+ field: field,
63986
+ rawValue: beforeChangeValue,
63987
+ currentValue: oldValue,
63988
+ changedValue: changedValue
63989
+ };
63990
+ table.fireListeners(TABLE_EVENT_TYPE.CHANGE_CELL_VALUE, changeValue), resultChangeValues.push(changeValue);
63991
+ }
63931
63992
  } else changedCellResults[i][j] = !1;
63932
63993
  }
63933
63994
  pasteColEnd = Math.max(pasteColEnd, thisRowPasteColEnd);
63934
63995
  }
63996
+ silentChangeCellValuesEvent || table.fireListeners(TABLE_EVENT_TYPE.CHANGE_CELL_VALUES, {
63997
+ values: resultChangeValues
63998
+ });
63935
63999
  const startRange = table.getCellRange(startCol, startRow),
63936
64000
  range = table.getCellRange(pasteColEnd, pasteRowEnd),
63937
64001
  aggregators = table.internalProps.layoutMap.getAggregatorsByCellRange(startRange.start.col, startRange.start.row, range.end.col, range.end.row);
@@ -63965,6 +64029,58 @@
63965
64029
  return table.scenegraph.updateNextFrame(), changedCellResults;
63966
64030
  });
63967
64031
  }
64032
+ function listTableChangeCellValuesByIds(ranges, value, workOnEditableCell, triggerEvent, table, silentChangeCellValuesEvent) {
64033
+ var _a, _b;
64034
+ return __awaiter(this, void 0, void 0, function* () {
64035
+ const resultChangeValues = [],
64036
+ processed = new Set(),
64037
+ nextValue = null != value ? value : "";
64038
+ for (let i = 0; i < (null !== (_a = null == ranges ? void 0 : ranges.length) && void 0 !== _a ? _a : 0); i++) {
64039
+ const range = ranges[i],
64040
+ startCol = Math.min(range.start.col, range.end.col),
64041
+ endCol = Math.max(range.start.col, range.end.col),
64042
+ startRow = Math.min(range.start.row, range.end.row),
64043
+ endRow = Math.max(range.start.row, range.end.row);
64044
+ if (startCol > endCol || startRow > endRow) continue;
64045
+ const values = [],
64046
+ oldValues = [];
64047
+ for (let row = startRow; row <= endRow; row++) {
64048
+ const rowValues = [],
64049
+ rowOldValues = [];
64050
+ for (let col = startCol; col <= endCol; col++) rowValues.push(nextValue), rowOldValues.push(table.getCellOriginValue(col, row));
64051
+ values.push(rowValues), oldValues.push(rowOldValues);
64052
+ }
64053
+ const changedCellResults = yield listTableChangeCellValues(startCol, startRow, values, workOnEditableCell, triggerEvent, table, !0);
64054
+ for (let r = 0; r < values.length; r++) for (let c = 0; c < values[r].length; c++) {
64055
+ const col = startCol + c,
64056
+ row = startRow + r,
64057
+ key = `${col},${row}`;
64058
+ if (processed.has(key)) continue;
64059
+ if (processed.add(key), !triggerEvent || !(null === (_b = null == changedCellResults ? void 0 : changedCellResults[r]) || void 0 === _b ? void 0 : _b[c])) continue;
64060
+ const oldValue = oldValues[r][c],
64061
+ changedValue = table.getCellOriginValue(col, row);
64062
+ if (oldValue === changedValue) continue;
64063
+ const recordShowIndex = table.getRecordShowIndexByCell(col, row),
64064
+ recordIndex = recordShowIndex >= 0 ? table.dataSource.getIndexKey(recordShowIndex) : void 0,
64065
+ {
64066
+ field: field
64067
+ } = table.internalProps.layoutMap.getBody(col, row);
64068
+ resultChangeValues.push({
64069
+ col: col,
64070
+ row: row,
64071
+ recordIndex: recordIndex,
64072
+ field: field,
64073
+ rawValue: oldValue,
64074
+ currentValue: oldValue,
64075
+ changedValue: changedValue
64076
+ });
64077
+ }
64078
+ }
64079
+ !silentChangeCellValuesEvent && triggerEvent && table.fireListeners(TABLE_EVENT_TYPE.CHANGE_CELL_VALUES, {
64080
+ values: resultChangeValues
64081
+ });
64082
+ });
64083
+ }
63968
64084
  function getCellUpdateType(col, row, table, oldCellUpdateType) {
63969
64085
  if ("group" === oldCellUpdateType) return oldCellUpdateType;
63970
64086
  if ("sort" === oldCellUpdateType && !table.internalProps.groupBy) return oldCellUpdateType;
@@ -65128,43 +65244,165 @@
65128
65244
  }
65129
65245
  return isValid$2(editorDefine);
65130
65246
  }
65131
- changeCellValue(col, row, value, workOnEditableCell = !1, triggerEvent = !0) {
65132
- return listTableChangeCellValue(col, row, value, workOnEditableCell, triggerEvent, this);
65247
+ changeCellValue(col, row, value, workOnEditableCell = !1, triggerEvent = !0, silentChangeCellValuesEvent) {
65248
+ return listTableChangeCellValue(col, row, value, workOnEditableCell, triggerEvent, this, silentChangeCellValuesEvent);
65249
+ }
65250
+ changeCellValues(startCol, startRow, values, workOnEditableCell = !1, triggerEvent = !0, silentChangeCellValuesEvent) {
65251
+ return listTableChangeCellValues(startCol, startRow, values, workOnEditableCell, triggerEvent, this, silentChangeCellValuesEvent);
65252
+ }
65253
+ changeCellValuesByIds(ranges, value, workOnEditableCell = !1, triggerEvent = !0, silentChangeCellValuesEvent) {
65254
+ return listTableChangeCellValuesByIds(ranges, value, workOnEditableCell, triggerEvent, this, silentChangeCellValuesEvent);
65255
+ }
65256
+ changeSourceCellValue(recordIndex, field, value) {
65257
+ const tableIndex = this.getTableIndexByRecordIndex(recordIndex),
65258
+ cellAddr = this.getCellAddrByFieldRecord(field, recordIndex);
65259
+ if (tableIndex < 0 || cellAddr.col < 0 || cellAddr.row < 0) return;
65260
+ this.dataSource.changeFieldValue(value, tableIndex, field, cellAddr.col, cellAddr.row, this);
65261
+ const beforeChangeValue = this.getCellRawValue(cellAddr.col, cellAddr.row),
65262
+ oldValue = this.getCellOriginValue(cellAddr.col, cellAddr.row),
65263
+ changedValue = this.getCellOriginValue(cellAddr.col, cellAddr.row);
65264
+ if (oldValue !== changedValue) {
65265
+ const changeValue = {
65266
+ col: cellAddr.col,
65267
+ row: cellAddr.row,
65268
+ recordIndex: recordIndex,
65269
+ field: field,
65270
+ rawValue: beforeChangeValue,
65271
+ currentValue: oldValue,
65272
+ changedValue: changedValue
65273
+ };
65274
+ this.fireListeners(TABLE_EVENT_TYPE.CHANGE_CELL_VALUE, changeValue), this.fireListeners(TABLE_EVENT_TYPE.CHANGE_CELL_VALUES, {
65275
+ values: [changeValue]
65276
+ });
65277
+ }
65133
65278
  }
65134
- changeCellValues(startCol, startRow, values, workOnEditableCell = !1, triggerEvent = !0) {
65135
- return listTableChangeCellValues(startCol, startRow, values, workOnEditableCell, triggerEvent, this);
65279
+ changeCellValueByRecord(recordIndex, field, value, options) {
65280
+ var _a, _b, _c, _d, _e;
65281
+ const triggerEvent = null === (_a = null == options ? void 0 : options.triggerEvent) || void 0 === _a || _a,
65282
+ silentChangeCellValuesEvent = null == options ? void 0 : options.silentChangeCellValuesEvent,
65283
+ autoRefresh = null === (_b = null == options ? void 0 : options.autoRefresh) || void 0 === _b || _b,
65284
+ records = null === (_c = this.dataSource.dataSourceObj) || void 0 === _c ? void 0 : _c.records;
65285
+ let record, oldValue;
65286
+ if (!Array.isArray(records) || "string" != typeof field && "number" != typeof field || (record = Array.isArray(recordIndex) ? getValueFromDeepArray(records, recordIndex) : records[recordIndex], oldValue = null == record ? void 0 : record[field]), this.dataSource.changeFieldValueByRecordIndex(value, recordIndex, field, this), !triggerEvent) return;
65287
+ const changedValue = !record || "string" != typeof field && "number" != typeof field ? value : null == record ? void 0 : record[field];
65288
+ if (oldValue !== changedValue) {
65289
+ const cellAddr = this.getCellAddrByFieldRecord(field, recordIndex),
65290
+ changeValue = {
65291
+ col: null !== (_d = null == cellAddr ? void 0 : cellAddr.col) && void 0 !== _d ? _d : -1,
65292
+ row: null !== (_e = null == cellAddr ? void 0 : cellAddr.row) && void 0 !== _e ? _e : -1,
65293
+ recordIndex: recordIndex,
65294
+ field: field,
65295
+ rawValue: oldValue,
65296
+ currentValue: oldValue,
65297
+ changedValue: changedValue
65298
+ };
65299
+ this.fireListeners(TABLE_EVENT_TYPE.CHANGE_CELL_VALUE, changeValue), silentChangeCellValuesEvent || this.fireListeners(TABLE_EVENT_TYPE.CHANGE_CELL_VALUES, {
65300
+ values: [changeValue]
65301
+ });
65302
+ }
65303
+ autoRefresh && this.refreshAfterSourceChange();
65304
+ }
65305
+ changeCellValueBySource(recordIndex, field, value, triggerEvent = !0, silentChangeCellValuesEvent) {
65306
+ return this.changeCellValueByRecord(recordIndex, field, value, {
65307
+ triggerEvent: triggerEvent,
65308
+ silentChangeCellValuesEvent: silentChangeCellValuesEvent,
65309
+ autoRefresh: !0
65310
+ });
65136
65311
  }
65137
- addRecord(record, recordIndex) {
65312
+ changeCellValuesByRecords(changeValues, options) {
65313
+ var _a, _b, _c, _d, _e, _f, _g;
65314
+ const triggerEvent = null === (_a = null == options ? void 0 : options.triggerEvent) || void 0 === _a || _a,
65315
+ silentChangeCellValuesEvent = null == options ? void 0 : options.silentChangeCellValuesEvent,
65316
+ autoRefresh = null === (_b = null == options ? void 0 : options.autoRefresh) || void 0 === _b || _b,
65317
+ resultChangeValues = [];
65318
+ for (let i = 0; i < changeValues.length; i++) {
65319
+ const {
65320
+ recordIndex: recordIndex,
65321
+ field: field,
65322
+ value: value
65323
+ } = changeValues[i],
65324
+ records = null === (_c = this.dataSource.dataSourceObj) || void 0 === _c ? void 0 : _c.records;
65325
+ let record, oldValue;
65326
+ if (!Array.isArray(records) || "string" != typeof field && "number" != typeof field || (record = Array.isArray(recordIndex) ? getValueFromDeepArray(records, recordIndex) : records[recordIndex], oldValue = null == record ? void 0 : record[field]), this.dataSource.changeFieldValueByRecordIndex(value, recordIndex, field, this), triggerEvent) {
65327
+ const changedValue = !record || "string" != typeof field && "number" != typeof field ? value : null == record ? void 0 : record[field];
65328
+ if (oldValue !== changedValue) {
65329
+ const changeValue = {
65330
+ col: null !== (_e = null === (_d = this.getCellAddrByFieldRecord(field, recordIndex)) || void 0 === _d ? void 0 : _d.col) && void 0 !== _e ? _e : -1,
65331
+ row: null !== (_g = null === (_f = this.getCellAddrByFieldRecord(field, recordIndex)) || void 0 === _f ? void 0 : _f.row) && void 0 !== _g ? _g : -1,
65332
+ recordIndex: recordIndex,
65333
+ field: field,
65334
+ rawValue: oldValue,
65335
+ currentValue: oldValue,
65336
+ changedValue: changedValue
65337
+ };
65338
+ this.fireListeners(TABLE_EVENT_TYPE.CHANGE_CELL_VALUE, changeValue), resultChangeValues.push(changeValue);
65339
+ }
65340
+ }
65341
+ }
65342
+ !silentChangeCellValuesEvent && resultChangeValues.length && triggerEvent && this.fireListeners(TABLE_EVENT_TYPE.CHANGE_CELL_VALUES, {
65343
+ values: resultChangeValues
65344
+ }), autoRefresh && this.refreshAfterSourceChange();
65345
+ }
65346
+ changeCellValuesBySource(changeValues, triggerEvent = !0, silentChangeCellValuesEvent) {
65347
+ return this.changeCellValuesByRecords(changeValues, {
65348
+ triggerEvent: triggerEvent,
65349
+ silentChangeCellValuesEvent: silentChangeCellValuesEvent,
65350
+ autoRefresh: !0
65351
+ });
65352
+ }
65353
+ refreshAfterSourceChange(options) {
65354
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
65355
+ const reapplyFilter = null === (_a = null == options ? void 0 : options.reapplyFilter) || void 0 === _a || _a,
65356
+ reapplySort = null === (_b = null == options ? void 0 : options.reapplySort) || void 0 === _b || _b,
65357
+ clearRowHeightCache = null === (_c = null == options ? void 0 : options.clearRowHeightCache) || void 0 === _c || _c;
65358
+ this.scenegraph.clearCells(), this.sortState && reapplySort && (null === (_e = (_d = this.dataSource).clearSortedIndexMap) || void 0 === _e || _e.call(_d), null === (_g = null === (_f = this.dataSource.sortedIndexMap) || void 0 === _f ? void 0 : _f.clear) || void 0 === _g || _g.call(_f)), reapplyFilter ? this.sortState && reapplySort ? (this.dataSource.updateFilterRulesForSorted(null === (_h = this.dataSource.dataConfig) || void 0 === _h ? void 0 : _h.filterRules), sortRecords(this)) : this.dataSource.updateFilterRules(null === (_j = this.dataSource.dataConfig) || void 0 === _j ? void 0 : _j.filterRules) : this.sortState && reapplySort && sortRecords(this);
65359
+ const traverseColumns = columns => {
65360
+ var _a, _b, _c, _d;
65361
+ for (let i = 0; i < (null !== (_a = null == columns ? void 0 : columns.length) && void 0 !== _a ? _a : 0); i++) {
65362
+ const column = columns[i],
65363
+ aggregators = null == column ? void 0 : column.vtable_aggregator;
65364
+ if (aggregators) if (Array.isArray(aggregators)) for (let j = 0; j < aggregators.length; j++) null === (_c = null === (_b = aggregators[j]) || void 0 === _b ? void 0 : _b.recalculate) || void 0 === _c || _c.call(_b);else null === (_d = null == aggregators ? void 0 : aggregators.recalculate) || void 0 === _d || _d.call(aggregators);
65365
+ (null == column ? void 0 : column.columns) && traverseColumns(column.columns);
65366
+ }
65367
+ };
65368
+ traverseColumns(this.internalProps.columns), this.refreshRowColCount(), this.internalProps.layoutMap.clearCellRangeMap(), this.internalProps.useOneRowHeightFillAll = !1, this.stateManager.initCheckedState(this.records), this.scenegraph.createSceneGraph(!clearRowHeightCache), null === (_k = this.internalProps.emptyTip) || void 0 === _k || _k.resetVisible(), this.resize();
65369
+ }
65370
+ addRecord(record, recordIndex, triggerEvent = !0) {
65138
65371
  var _a;
65139
65372
  const success = listTableAddRecord(record, recordIndex, this);
65140
- adjustHeightResizedRowMapWithAddRecordIndex(this, recordIndex, [record]), null === (_a = this.internalProps.emptyTip) || void 0 === _a || _a.resetVisible(), success && this.fireListeners(TABLE_EVENT_TYPE.ADD_RECORD, {
65373
+ adjustHeightResizedRowMapWithAddRecordIndex(this, recordIndex, [record]), null === (_a = this.internalProps.emptyTip) || void 0 === _a || _a.resetVisible(), triggerEvent && success && this.fireListeners(TABLE_EVENT_TYPE.ADD_RECORD, {
65141
65374
  records: [record],
65142
65375
  recordIndex: recordIndex,
65143
65376
  recordCount: 1
65144
65377
  });
65145
65378
  }
65146
- addRecords(records, recordIndex) {
65379
+ addRecords(records, recordIndex, triggerEvent = !0) {
65147
65380
  var _a;
65148
65381
  const success = listTableAddRecords(records, recordIndex, this);
65149
- "number" == typeof recordIndex && adjustHeightResizedRowMapWithAddRecordIndex(this, recordIndex, records), null === (_a = this.internalProps.emptyTip) || void 0 === _a || _a.resetVisible(), success && this.fireListeners(TABLE_EVENT_TYPE.ADD_RECORD, {
65382
+ "number" == typeof recordIndex && adjustHeightResizedRowMapWithAddRecordIndex(this, recordIndex, records), null === (_a = this.internalProps.emptyTip) || void 0 === _a || _a.resetVisible(), triggerEvent && success && this.fireListeners(TABLE_EVENT_TYPE.ADD_RECORD, {
65150
65383
  records: records,
65151
65384
  recordIndex: recordIndex,
65152
65385
  recordCount: records.length
65153
65386
  });
65154
65387
  }
65155
- deleteRecords(recordIndexs) {
65388
+ deleteRecords(recordIndexs, triggerEvent = !0) {
65156
65389
  var _a;
65157
- listTableDeleteRecords(recordIndexs, this), adjustHeightResizedRowMapWithDeleteRecordIndex(this, recordIndexs), null === (_a = this.internalProps.emptyTip) || void 0 === _a || _a.resetVisible();
65390
+ const deletedRecords = [];
65391
+ (null == recordIndexs ? void 0 : recordIndexs.length) > 0 && recordIndexs.forEach(index => {
65392
+ let record = null;
65393
+ record = "number" == typeof index ? this.dataSource.get(index) : [], deletedRecords.push(record);
65394
+ }), listTableDeleteRecords(recordIndexs, this), adjustHeightResizedRowMapWithDeleteRecordIndex(this, recordIndexs), null === (_a = this.internalProps.emptyTip) || void 0 === _a || _a.resetVisible();
65158
65395
  const rowIndexs = [];
65159
65396
  for (let i = 0; i < recordIndexs.length; i++) rowIndexs.push(this.getBodyRowIndexByRecordIndex(recordIndexs[i]) + this.columnHeaderLevelCount);
65160
- this.fireListeners(TABLE_EVENT_TYPE.DELETE_RECORD, {
65397
+ triggerEvent && this.fireListeners(TABLE_EVENT_TYPE.DELETE_RECORD, {
65161
65398
  recordIndexs: recordIndexs,
65399
+ records: deletedRecords,
65162
65400
  rowIndexs: rowIndexs,
65163
65401
  deletedCount: (Array.isArray(recordIndexs[0]), recordIndexs.length)
65164
65402
  });
65165
65403
  }
65166
- updateRecords(records, recordIndexs) {
65167
- listTableUpdateRecords(records, recordIndexs, this), this.fireListeners(TABLE_EVENT_TYPE.UPDATE_RECORD, {
65404
+ updateRecords(records, recordIndexs, triggerEvent = !0) {
65405
+ listTableUpdateRecords(records, recordIndexs, this), triggerEvent && this.fireListeners(TABLE_EVENT_TYPE.UPDATE_RECORD, {
65168
65406
  records: records,
65169
65407
  recordIndexs: recordIndexs,
65170
65408
  updateCount: records.length
@@ -69384,8 +69622,8 @@
69384
69622
  }(ExcelEditCellKeyboardResponse || (ExcelEditCellKeyboardResponse = {}));
69385
69623
  class ExcelEditCellKeyboardPlugin {
69386
69624
  constructor(pluginOptions) {
69387
- var _a, _b;
69388
- this.id = "excel-edit-cell-keyboard", this.name = "Excel Edit Cell Keyboard", this.runTime = [TABLE_EVENT_TYPE.INITIALIZED], this.id = null !== (_a = null == pluginOptions ? void 0 : pluginOptions.id) && void 0 !== _a ? _a : this.id, this.pluginOptions = pluginOptions, this.responseKeyboard = null !== (_b = null == pluginOptions ? void 0 : pluginOptions.responseKeyboard) && void 0 !== _b ? _b : [ExcelEditCellKeyboardResponse.ENTER, ExcelEditCellKeyboardResponse.TAB, ExcelEditCellKeyboardResponse.ARROW_LEFT, ExcelEditCellKeyboardResponse.ARROW_RIGHT, ExcelEditCellKeyboardResponse.ARROW_DOWN, ExcelEditCellKeyboardResponse.ARROW_UP, ExcelEditCellKeyboardResponse.DELETE, ExcelEditCellKeyboardResponse.BACKSPACE], this.bindEvent();
69625
+ var _a, _b, _c;
69626
+ this.id = "excel-edit-cell-keyboard", this.name = "Excel Edit Cell Keyboard", this.runTime = [TABLE_EVENT_TYPE.INITIALIZED], this.id = null !== (_a = null == pluginOptions ? void 0 : pluginOptions.id) && void 0 !== _a ? _a : this.id, this.pluginOptions = pluginOptions, this.responseKeyboard = null !== (_b = null == pluginOptions ? void 0 : pluginOptions.responseKeyboard) && void 0 !== _b ? _b : [ExcelEditCellKeyboardResponse.ENTER, ExcelEditCellKeyboardResponse.TAB, ExcelEditCellKeyboardResponse.ARROW_LEFT, ExcelEditCellKeyboardResponse.ARROW_RIGHT, ExcelEditCellKeyboardResponse.ARROW_DOWN, ExcelEditCellKeyboardResponse.ARROW_UP, ExcelEditCellKeyboardResponse.DELETE, ExcelEditCellKeyboardResponse.BACKSPACE], this.aggregateDeleteToOneChangeCellValuesEvent = null !== (_c = null == pluginOptions ? void 0 : pluginOptions.aggregateDeleteToOneChangeCellValuesEvent) && void 0 !== _c && _c, this.bindEvent();
69389
69627
  }
69390
69628
  run(...args) {
69391
69629
  const table = args[2];
@@ -69416,7 +69654,7 @@
69416
69654
  (null == selectCells ? void 0 : selectCells.length) > 0 && (document.activeElement === this.table.getElement() || Object.values(this.table.editorManager.cacheLastSelectedCellEditor || {}).some(editor => {
69417
69655
  var _a;
69418
69656
  return (null === (_a = editor.getInputElement) || void 0 === _a ? void 0 : _a.call(editor)) === document.activeElement;
69419
- })) && (deleteSelectRange(selectCells, this.table, null === (_c = null === (_b = this.pluginOptions) || void 0 === _b ? void 0 : _b.deleteWorkOnEditableCell) || void 0 === _c || _c), event.stopPropagation(), event.preventDefault());
69657
+ })) && (deleteSelectRange(selectCells, this.table, null === (_c = null === (_b = this.pluginOptions) || void 0 === _b ? void 0 : _b.deleteWorkOnEditableCell) || void 0 === _c || _c, this.aggregateDeleteToOneChangeCellValuesEvent), event.stopPropagation(), event.preventDefault());
69420
69658
  }
69421
69659
  } else this.table.editorManager.completeEdit(), this.table.getElement().focus(), eventKey === ExcelEditCellKeyboardResponse.ENTER ? this.table.selectCell(col, row + 1) : eventKey === ExcelEditCellKeyboardResponse.TAB && this.table.selectCell(col + 1, row), event.stopPropagation(), event.preventDefault();
69422
69660
  }
@@ -69438,8 +69676,11 @@
69438
69676
  document.removeEventListener("keydown", this.handleKeyDown, !0);
69439
69677
  }
69440
69678
  }
69441
- function deleteSelectRange(selectCells, tableInstance, workOnEditableCell = !1) {
69442
- for (let i = 0; i < selectCells.length; i++) for (let j = 0; j < selectCells[i].length; j++) tableInstance.changeCellValue(selectCells[i][j].col, selectCells[i][j].row, "", workOnEditableCell);
69679
+ function deleteSelectRange(selectCells, tableInstance, workOnEditableCell = !1, aggregateToOneChangeCellValuesEvent = !1) {
69680
+ if (aggregateToOneChangeCellValuesEvent) {
69681
+ const ranges = tableInstance.stateManager.select.ranges;
69682
+ (null == ranges ? void 0 : ranges.length) && tableInstance.changeCellValuesByIds(ranges, "", workOnEditableCell, !0);
69683
+ } else for (let i = 0; i < selectCells.length; i++) for (let j = 0; j < selectCells[i].length; j++) tableInstance.changeCellValue(selectCells[i][j].col, selectCells[i][j].row, "", workOnEditableCell);
69443
69684
  }
69444
69685
 
69445
69686
  const MENU_CONTAINER_CLASS = "vtable-context-menu-container";
@@ -81673,9 +81914,7 @@
81673
81914
  } else (runtime === TABLE_EVENT_TYPE.UPDATE_RECORD || runtime === TABLE_EVENT_TYPE.ADD_RECORD || runtime === TABLE_EVENT_TYPE.DELETE_RECORD) && this.syncFilterWithTableData();
81674
81915
  }
81675
81916
  updatePluginOptions(pluginOptions) {
81676
- this.pluginOptions = lodashExports.merge(this.pluginOptions, pluginOptions), this.filterToolbar.updateStyles(this.pluginOptions.styles), this.table.updateColumns(this.columns, {
81677
- clearRowHeightCache: !1
81678
- });
81917
+ this.pluginOptions = lodashExports.merge(this.pluginOptions, pluginOptions), this.filterToolbar.updateStyles(this.pluginOptions.styles);
81679
81918
  }
81680
81919
  update() {
81681
81920
  this.filterStateManager && this.reapplyActiveFilters();
@@ -91004,7 +91243,7 @@
91004
91243
  importStyle();
91005
91244
  }
91006
91245
 
91007
- const version = "1.22.11-alpha.4";
91246
+ const version = "1.22.11-alpha.5";
91008
91247
  importStyles();
91009
91248
 
91010
91249
  exports.TYPES = index;