@visactor/vtable-gantt 1.26.7 → 1.26.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.
@@ -43314,7 +43314,11 @@
43314
43314
  super(config), this.type = AggregationType.CUSTOM, this.isRecord = !0, this.values = [], this.aggregationFun = config.aggregationFun;
43315
43315
  }
43316
43316
  push(record) {
43317
- record && (this.isRecord && this.records && (record.isAggregator ? this.records.push(...record.records) : this.records.push(record)), record.isAggregator && this.children && this.children.push(record), this.field && this.values.push(record[this.field])), this.clearCacheValue();
43317
+ if (record) {
43318
+ if (this.recalculateFromChildren && record.isAggregator) return this.isRecord && this.records && this.records.push(...record.records), this.children && this.children.push(record), this.field && this.values.push(...record.records.map(item => item[this.field])), void this.clearCacheValue();
43319
+ this.isRecord && this.records && (record.isAggregator ? this.records.push(...record.records) : this.records.push(record)), record.isAggregator && this.children && this.children.push(record), this.field && this.values.push(record[this.field]);
43320
+ }
43321
+ this.clearCacheValue();
43318
43322
  }
43319
43323
  updateRecord(oldRecord, newRecord) {
43320
43324
  oldRecord && newRecord && (this.isRecord && this.records && (this.records = this.records.map(item => item === oldRecord ? newRecord : item)), oldRecord.isAggregator && newRecord.isAggregator && this.children && (this.children = this.children.map(item => item === oldRecord ? newRecord : item)), this.field && this.records.length && (this.values = this.records.map(item => item[this.field])), this.clearCacheValue());
@@ -43330,7 +43334,18 @@
43330
43334
  this.records = [], this.children = [], this.changedValue = void 0, this.fieldValue = void 0;
43331
43335
  }
43332
43336
  recalculate() {
43333
- this.fieldValue = void 0, this._formatedValue = void 0;
43337
+ var _a;
43338
+ this.recalculateFromChildren && (null === (_a = this.children) || void 0 === _a ? void 0 : _a.length) && this.field && (this.values = [], this.records = [], this.children.forEach(child => {
43339
+ if (isValid$1(child.changedValue)) {
43340
+ const value = child.value();
43341
+ this.values.push(value), this.records.push({
43342
+ [this.field]: value
43343
+ });
43344
+ } else if (child instanceof CustomAggregator && child.recalculateFromChildren) this.values.push(...child.values), this.records.push(...child.records);else {
43345
+ const records = child.records;
43346
+ this.values.push(...records.map(record => record[this.field])), this.records.push(...records);
43347
+ }
43348
+ })), this.fieldValue = void 0, this._formatedValue = void 0;
43334
43349
  }
43335
43350
  }
43336
43351
  class RecalculateAggregator extends Aggregator {
@@ -44380,8 +44395,8 @@
44380
44395
  function isZeroStyle(style) {
44381
44396
  return 0 === style || isArray$5(style) && style.every(s => 0 === s);
44382
44397
  }
44383
- function setActiveCellRangeState(table) {
44384
- const selectRanges = table.stateManager.select.ranges,
44398
+ function setActiveCellRangeState(table, ranges = table.stateManager.select.ranges) {
44399
+ const selectRanges = ranges,
44385
44400
  setRanges = [];
44386
44401
  for (let i = 0; i < selectRanges.length; i++) {
44387
44402
  const range = selectRanges[i];
@@ -44511,12 +44526,6 @@
44511
44526
  function defaultOrderFn(v1, v2, order) {
44512
44527
  return "desc" !== order ? v1 === v2 ? 0 : v1 > v2 ? 1 : -1 : v1 === v2 ? 0 : v1 < v2 ? 1 : -1;
44513
44528
  }
44514
- function getValueByPath(obj, paths) {
44515
- let prop,
44516
- res = obj;
44517
- for (; (prop = paths.shift()) && (res = res[prop], res););
44518
- return res;
44519
- }
44520
44529
  function isAllDigits(str) {
44521
44530
  return /^-?\d+(\.\d+)?$/.test(str);
44522
44531
  }
@@ -46532,7 +46541,7 @@
46532
46541
  const DARK = new TableTheme(darkTheme, darkTheme);
46533
46542
  const BRIGHT = new TableTheme(brightTheme, brightTheme);
46534
46543
  const ARCO = new TableTheme(arcoTheme, arcoTheme);
46535
- const DEFAULT = new TableTheme(defaultTheme, defaultTheme);
46544
+ let DEFAULT = new TableTheme(defaultTheme, defaultTheme);
46536
46545
  const SIMPLIFY = new TableTheme(materialDesignTheme, materialDesignTheme);
46537
46546
  const builtin$1 = {
46538
46547
  DEFAULT: DEFAULT,
@@ -46541,6 +46550,9 @@
46541
46550
  DARK: DARK,
46542
46551
  BRIGHT: BRIGHT
46543
46552
  };
46553
+ function setDefaultTheme(theme) {
46554
+ DEFAULT = theme instanceof TableTheme ? theme.extends({}) : new TableTheme(theme, theme), builtin$1.DEFAULT = DEFAULT;
46555
+ }
46544
46556
  const theme$1 = {
46545
46557
  TableTheme: TableTheme
46546
46558
  };
@@ -46559,11 +46571,14 @@
46559
46571
  DARK: DARK,
46560
46572
  BRIGHT: BRIGHT,
46561
46573
  ARCO: ARCO,
46562
- DEFAULT: DEFAULT,
46574
+ get DEFAULT() {
46575
+ return DEFAULT;
46576
+ },
46563
46577
  SIMPLIFY: SIMPLIFY,
46564
46578
  theme: theme$1,
46565
46579
  of: of$1,
46566
- get: get$5
46580
+ get: get$5,
46581
+ setDefaultTheme: setDefaultTheme
46567
46582
  };
46568
46583
 
46569
46584
  var themes$1 = /*#__PURE__*/Object.freeze({
@@ -46571,12 +46586,13 @@
46571
46586
  ARCO: ARCO,
46572
46587
  BRIGHT: BRIGHT,
46573
46588
  DARK: DARK,
46574
- DEFAULT: DEFAULT,
46589
+ get DEFAULT () { return DEFAULT; },
46575
46590
  SIMPLIFY: SIMPLIFY,
46576
46591
  TableTheme: TableTheme,
46577
46592
  default: themes,
46578
46593
  get: get$5,
46579
46594
  of: of$1,
46595
+ setDefaultTheme: setDefaultTheme,
46580
46596
  tableThemeIsChanged: tableThemeIsChanged,
46581
46597
  theme: theme$1
46582
46598
  });
@@ -49880,21 +49896,64 @@
49880
49896
  if ((void 0 === fieldGet || "" === fieldGet) && Array.isArray(record)) {
49881
49897
  return record[col - table.leftRowSeriesNumberCount];
49882
49898
  }
49883
- if (isObject$8(record) && fieldGet in record) {
49899
+ if (Array.isArray(fieldGet)) {
49900
+ return getValue$2(getRecordFieldValue(record, fieldGet), promiseCallBack);
49901
+ }
49902
+ if (isRecordContainer(record) && fieldGet in record) {
49884
49903
  return getValue$2(record[fieldGet], promiseCallBack);
49885
49904
  }
49886
49905
  if ("function" == typeof fieldGet) {
49887
49906
  return getValue$2(fieldGet(record, col, row, table), promiseCallBack);
49888
49907
  }
49889
- if (Array.isArray(fieldGet)) {
49890
- return getValue$2(getValueByPath(record, [...fieldGet]), promiseCallBack);
49891
- }
49892
49908
  const fieldArray = `${fieldGet}`.split(".");
49893
49909
  if (fieldArray.length <= 1) {
49894
49910
  return getValue$2(record[fieldGet], promiseCallBack);
49895
49911
  }
49896
49912
  return getValue$2(applyChainSafe(record, (val, name) => getField(val, name, col, row, table, emptyFn), ...fieldArray), promiseCallBack);
49897
49913
  }
49914
+ function isRecordContainer(value) {
49915
+ return null !== value && "object" == typeof value;
49916
+ }
49917
+ function getRecordFieldPath(field) {
49918
+ return Array.isArray(field) ? field : "string" == typeof field && field.includes(".") ? field.split(".") : void 0;
49919
+ }
49920
+ function hasRecordField(record, field) {
49921
+ if (!isRecordContainer(record)) return !1;
49922
+ const path = getRecordFieldPath(field);
49923
+ if (!Array.isArray(field) && field in record) return !0;
49924
+ if (!path) return !1;
49925
+ let target = record;
49926
+ for (const key of path) {
49927
+ if (!isRecordContainer(target) || !(key in target)) return !1;
49928
+ target = target[key];
49929
+ }
49930
+ return !0;
49931
+ }
49932
+ function getRecordFieldValue(record, field) {
49933
+ if (null == record) return;
49934
+ const path = getRecordFieldPath(field);
49935
+ return !Array.isArray(field) && isRecordContainer(record) && field in record ? record[field] : path ? path.reduce((current, key) => null == current ? void 0 : current[key], record) : record[field];
49936
+ }
49937
+ function setRecordProperty(record, key, value) {
49938
+ "__proto__" !== key && "constructor" !== key && "prototype" !== key ? record[key] = value : Object.defineProperty(record, key, {
49939
+ configurable: !0,
49940
+ enumerable: !0,
49941
+ value: value,
49942
+ writable: !0
49943
+ });
49944
+ }
49945
+ function setRecordFieldValue(record, field, value) {
49946
+ if (null == record) return;
49947
+ const path = getRecordFieldPath(field);
49948
+ if (!path || !Array.isArray(field) && isRecordContainer(record) && field in record) return void setRecordProperty(record, field, value);
49949
+ if (0 === path.length) return;
49950
+ let target = record;
49951
+ for (let i = 0; i < path.length - 1; i++) {
49952
+ const key = path[i];
49953
+ Object.prototype.hasOwnProperty.call(target, key) && null !== target[key] && "object" == typeof target[key] || setRecordProperty(target, key, {}), target = target[key];
49954
+ }
49955
+ setRecordProperty(target, path[path.length - 1], value);
49956
+ }
49898
49957
  function _getIndex(sortedIndexMap, index) {
49899
49958
  if (!sortedIndexMap) return index;
49900
49959
  const mapIndex = sortedIndexMap[index];
@@ -50130,21 +50189,19 @@
50130
50189
  return childrenLength;
50131
50190
  }
50132
50191
  changeFieldValue(value, index, field, col, row, table) {
50133
- var _a;
50134
50192
  if (null !== field && index >= 0) {
50135
50193
  const dataIndex = this.getIndexKey(index);
50136
- if (this.cacheBeforeChangedRecord(dataIndex, table), void 0 !== field && "" !== field || (field = col - table.leftRowSeriesNumberCount), "string" == typeof field || "number" == typeof field) {
50137
- const beforeChangedValue = null === (_a = this.beforeChangedRecordsMap.get(dataIndex.toString())) || void 0 === _a ? void 0 : _a[field],
50194
+ if (this.cacheBeforeChangedRecord(dataIndex, table), void 0 !== field && "" !== field || (field = col - table.leftRowSeriesNumberCount), "string" == typeof field || "number" == typeof field || Array.isArray(field)) {
50195
+ const beforeChangedValue = getRecordFieldValue(this.beforeChangedRecordsMap.get(dataIndex.toString()), field),
50138
50196
  record = this.getOriginalRecord(dataIndex);
50139
50197
  let formatValue = value;
50140
- "number" == typeof beforeChangedValue && isAllDigits(value) && (formatValue = parseFloat(value)), isPromise(record) ? record.then(record => {
50141
- record[field] = formatValue;
50142
- }).catch(err => {}) : record ? record[field] = formatValue : (this.records[dataIndex] = "Array" === this.addRecordRule ? [] : {}, this.records[dataIndex][field] = formatValue);
50198
+ if ("number" == typeof beforeChangedValue && isAllDigits(value) && (formatValue = parseFloat(value)), isPromise(record)) return record.then(record => (setRecordFieldValue(record, field, formatValue), formatValue)).catch(err => {});
50199
+ record ? setRecordFieldValue(record, field, formatValue) : (this.records[dataIndex] = "Array" === this.addRecordRule ? [] : {}, setRecordFieldValue(this.records[dataIndex], field, formatValue));
50143
50200
  }
50144
50201
  }
50145
50202
  }
50146
50203
  changeFieldValueByRecordIndex(value, recordIndex, field, table) {
50147
- var _a, _b, _c, _d;
50204
+ var _a, _b, _c;
50148
50205
  if (null === field) return;
50149
50206
  if (null == recordIndex) return;
50150
50207
  const rawKey = recordIndex.toString();
@@ -50153,12 +50210,12 @@
50153
50210
  originRecord = rawRecords ? Array.isArray(recordIndex) ? getValueFromDeepArray(rawRecords, recordIndex) : rawRecords[recordIndex] : void 0;
50154
50211
  this.beforeChangedRecordsMap.set(rawKey, null !== (_b = cloneDeep(originRecord, void 0, ["vtable_gantt_linkedFrom", "vtable_gantt_linkedTo"])) && void 0 !== _b ? _b : {});
50155
50212
  }
50156
- if ("string" == typeof field || "number" == typeof field) {
50157
- const beforeChangedValue = null === (_c = this.beforeChangedRecordsMap.get(rawKey)) || void 0 === _c ? void 0 : _c[field],
50158
- rawRecords = Array.isArray(null === (_d = this.dataSourceObj) || void 0 === _d ? void 0 : _d.records) ? this.dataSourceObj.records : null,
50213
+ if ("string" == typeof field || "number" == typeof field || Array.isArray(field)) {
50214
+ const beforeChangedValue = getRecordFieldValue(this.beforeChangedRecordsMap.get(rawKey), field),
50215
+ rawRecords = Array.isArray(null === (_c = this.dataSourceObj) || void 0 === _c ? void 0 : _c.records) ? this.dataSourceObj.records : null,
50159
50216
  record = rawRecords ? Array.isArray(recordIndex) ? getValueFromDeepArray(rawRecords, recordIndex) : rawRecords[recordIndex] : void 0;
50160
50217
  let formatValue = value;
50161
- "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);
50218
+ "number" == typeof beforeChangedValue && isAllDigits(value) && (formatValue = parseFloat(value)), record ? setRecordFieldValue(record, field, formatValue) : rawRecords && "number" == typeof recordIndex && (rawRecords[recordIndex] = "Array" === this.addRecordRule ? [] : {}, setRecordFieldValue(rawRecords[recordIndex], field, formatValue));
50162
50219
  }
50163
50220
  }
50164
50221
  cacheBeforeChangedRecord(dataIndex, table) {
@@ -50533,8 +50590,7 @@
50533
50590
  hasOriginalField(index, field) {
50534
50591
  if (null === field) return !1;
50535
50592
  if ("function" == typeof field) return !0;
50536
- const record = this.getOriginalRecord(index);
50537
- return Boolean(record && field in record);
50593
+ return hasRecordField(this.getOriginalRecord(index), field);
50538
50594
  }
50539
50595
  fieldPromiseCallBack(_index, _field, _value) {}
50540
50596
  recordPromiseCallBack(_index, _record) {}
@@ -53032,7 +53088,7 @@
53032
53088
  const cells = rowCells.split("\t"),
53033
53089
  rowValues = [];
53034
53090
  0 === rowIndex && result.push("<tbody>"), cells.forEach(function (cell, cellIndex) {
53035
- const parsedCellData = cell ? cell.toString().replace(/&/g, "&amp;").replace(/'/g, "&#39;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/\n/g, "<br>").replace(/(<br(\s*|\/)>(\r\n|\n)?|\r\n|\n)/g, "<br>\r\n").replace(/\x20{2,}/gi, substring => `<span style="mso-spacerun: yes">${"&nbsp;".repeat(substring.length - 1)} </span>`).replace(/\t/gi, "&#9;") : " ";
53091
+ const parsedCellData = cell ? cell.toString().replace(/&/g, "&amp;").replace(/'/g, "&#39;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/\n/g, "<br>").replace(/(<br(\s*|\/)>(\r\n|\n)?|\r\n|\n)/g, "<br>\r\n").replace(/\x20{2,}/gi, substring => `<span style="mso-spacerun: yes">${"&nbsp;".repeat(substring.length - 1)} </span>`).replace(/\t/gi, "&#9;") : "";
53036
53092
  rowValues.push(`<td>${parsedCellData}</td>`);
53037
53093
  }), result.push("<tr>", ...rowValues, "</tr>"), rowIndex === rows.length - 1 && result.push("</tbody>");
53038
53094
  }), result.push("</table>"), [META_HEAD, result.join("")].join("");
@@ -54259,6 +54315,49 @@
54259
54315
  }
54260
54316
  }
54261
54317
 
54318
+ function isCornerCustomMergeRange(range, table) {
54319
+ return !!(null == range ? void 0 : range.isCustom) && (range.start.col !== range.end.col || range.start.row !== range.end.row) && table.isCornerHeader(range.start.col, range.start.row) && table.isCornerHeader(range.end.col, range.end.row);
54320
+ }
54321
+ function shouldRenderCornerCustomMergeContent(col, row, range, table) {
54322
+ return !isCornerCustomMergeRange(range, table) || col === range.end.col && row === range.end.row;
54323
+ }
54324
+ function createCornerCustomMergeContainer(customElementsGroup, width, height, range, table) {
54325
+ if (!customElementsGroup || !isCornerCustomMergeRange(range, table)) return customElementsGroup;
54326
+ const customContainer = new Group$1({
54327
+ x: 0,
54328
+ y: 0,
54329
+ width: width,
54330
+ height: height,
54331
+ fill: !1,
54332
+ stroke: !1,
54333
+ pickable: !1,
54334
+ clip: !0
54335
+ });
54336
+ return customContainer.name = CUSTOM_CONTAINER_NAME, customContainer.col = range.start.col, customContainer.row = range.start.row, customContainer.appendChild(customElementsGroup), customContainer;
54337
+ }
54338
+ function queueCornerCustomMergeContentUpdate(range, table, pendingRanges) {
54339
+ pendingRanges ? pendingRanges.set(getCornerCustomMergeRangeKey(range), range) : refreshCornerCustomMergeContent(range, table);
54340
+ }
54341
+ function flushCornerCustomMergeContentUpdates(pendingRanges, table) {
54342
+ pendingRanges.forEach(range => {
54343
+ refreshCornerCustomMergeContentForResize(range, table);
54344
+ }), pendingRanges.clear();
54345
+ }
54346
+ function getCornerCustomMergeRangeKey(range) {
54347
+ return `${range.start.col}-${range.start.row}-${range.end.col}-${range.end.row}`;
54348
+ }
54349
+ function refreshCornerCustomMergeContent(range, table) {
54350
+ var _a;
54351
+ const cellGroup = table.scenegraph.getCell(range.end.col, range.end.row),
54352
+ customContainer = cellGroup.getChildByName(CUSTOM_CONTAINER_NAME) || cellGroup.getChildByName(CUSTOM_MERGE_CONTAINER_NAME);
54353
+ customContainer && (null === (_a = table.reactCustomLayout) || void 0 === _a || _a.removeCustomCell(range.start.col, range.start.row), customContainer.removeAllChild(), cellGroup.removeChild(customContainer)), table.scenegraph.updateCellContent(range.end.col, range.end.row);
54354
+ }
54355
+ function refreshCornerCustomMergeContentForResize(range, table) {
54356
+ const cellGroup = table.scenegraph.getCell(range.end.col, range.end.row),
54357
+ customContainer = cellGroup.getChildByName(CUSTOM_CONTAINER_NAME) || cellGroup.getChildByName(CUSTOM_MERGE_CONTAINER_NAME);
54358
+ customContainer && cellGroup.removeChild(customContainer), table.scenegraph.updateCellContent(range.end.col, range.end.row);
54359
+ }
54360
+
54262
54361
  const PROMISE_CELL_UPDATE_TOKEN_KEY = "__vtable_promise_cell_update_token__";
54263
54362
  function nextPromiseCellUpdateToken(cellGroup) {
54264
54363
  var _a;
@@ -54357,11 +54456,17 @@
54357
54456
  function _generateCustomElementsGroup(table, define, col, row, cellWidth, cellHeight, padding, range, customResult) {
54358
54457
  let customElementsGroup,
54359
54458
  renderDefault = !0;
54360
- if (customResult) customElementsGroup = customResult.elementsGroup, renderDefault = customResult.renderDefault;else if ((null == range ? void 0 : range.isCustom) && !table.isCornerHeader(col, row)) ;else {
54459
+ if (!shouldRenderCornerCustomMergeContent(col, row, range, table)) return {
54460
+ customElementsGroup: customElementsGroup,
54461
+ renderDefault: !1
54462
+ };
54463
+ if (customResult) customElementsGroup = createCornerCustomMergeContainer(customResult.elementsGroup, cellWidth, cellHeight, range, table), renderDefault = customResult.renderDefault;else if ((null == range ? void 0 : range.isCustom) && !table.isCornerHeader(col, row)) ;else {
54361
54464
  let customRender, customLayout;
54362
54465
  if ("body" !== table.getCellLocation(col, row) ? (customRender = null == define ? void 0 : define.headerCustomRender, customLayout = null == define ? void 0 : define.headerCustomLayout) : (customRender = (null == define ? void 0 : define.customRender) || table.customRender, customLayout = null == define ? void 0 : define.customLayout), customLayout || customRender) {
54363
- const customResult = dealWithCustom(customLayout, customRender, col, row, cellWidth, cellHeight, !1, table.isAutoRowHeight(row), padding, range, table);
54364
- customElementsGroup = customResult.elementsGroup, renderDefault = customResult.renderDefault;
54466
+ const customCol = range && isCornerCustomMergeRange(range, table) ? range.start.col : col,
54467
+ customRow = range && isCornerCustomMergeRange(range, table) ? range.start.row : row,
54468
+ customResult = dealWithCustom(customLayout, customRender, customCol, customRow, cellWidth, cellHeight, !1, table.isAutoRowHeight(row), padding, range, table);
54469
+ customElementsGroup = createCornerCustomMergeContainer(customResult.elementsGroup, cellWidth, cellHeight, range, table), renderDefault = customResult.renderDefault;
54365
54470
  }
54366
54471
  }
54367
54472
  return {
@@ -54390,7 +54495,7 @@
54390
54495
  customLayout: customLayout,
54391
54496
  customRender: customRender
54392
54497
  } = customMerge;
54393
- range = customMergeRange, isMerge = range.start.col !== range.end.col || range.start.row !== range.end.row, value = customMergeText, customStyle = customMergeStyle, (customLayout || customRender) && (customResult = dealWithCustom(customLayout, customRender, customMergeRange.start.col, customMergeRange.start.row, table.getColsWidth(customMergeRange.start.col, customMergeRange.end.col), table.getRowsHeight(customMergeRange.start.row, customMergeRange.end.row), !1, table.isAutoRowHeight(row), [0, 0, 0, 0], range, table)), isCustomMerge = !0;
54498
+ range = customMergeRange, isMerge = range.start.col !== range.end.col || range.start.row !== range.end.row, value = customMergeText, customStyle = customMergeStyle, (customLayout || customRender) && shouldRenderCornerCustomMergeContent(col, row, customMergeRange, table) && (customResult = dealWithCustom(customLayout, customRender, customMergeRange.start.col, customMergeRange.start.row, table.getColsWidth(customMergeRange.start.col, customMergeRange.end.col), table.getRowsHeight(customMergeRange.start.row, customMergeRange.end.row), !1, table.isAutoRowHeight(row), [0, 0, 0, 0], range, table)), isCustomMerge = !0;
54394
54499
  }
54395
54500
  }
54396
54501
  let colForDefine = col,
@@ -54636,17 +54741,17 @@
54636
54741
  customRender: customMergeRender
54637
54742
  } = customMerge;
54638
54743
  if (customMergeLayout || customMergeRender) {
54639
- const customElementsGroup = dealWithCustom(customMergeLayout, customMergeRender, customMergeRange.start.col, customMergeRange.start.row, table.getColsWidth(customMergeRange.start.col, customMergeRange.end.col), table.getRowsHeight(customMergeRange.start.row, customMergeRange.end.row), !1, table.isAutoRowHeight(row), [0, 0, 0, 0], customMergeRange, table).elementsGroup;
54640
- cellGroup.childrenCount > 0 && customElementsGroup ? cellGroup.insertBefore(customElementsGroup, cellGroup.firstChild) : customElementsGroup && cellGroup.appendChild(customElementsGroup);
54641
54744
  const rangeHeight = table.getRowHeight(row),
54642
54745
  rangeWidth = table.getColWidth(col),
54643
- {
54644
- width: contentWidth
54645
- } = cellGroup.attribute,
54646
- {
54647
- height: contentHeight
54648
- } = cellGroup.attribute;
54649
- return cellGroup.contentWidth = contentWidth, cellGroup.contentHeight = contentHeight, resizeCellGroup(cellGroup, rangeWidth, rangeHeight, customMergeRange, table), customMergeRange;
54746
+ contentWidth = table.getColsWidth(customMergeRange.start.col, customMergeRange.end.col),
54747
+ contentHeight = table.getRowsHeight(customMergeRange.start.row, customMergeRange.end.row);
54748
+ if (cellGroup.contentWidth = contentWidth, cellGroup.contentHeight = contentHeight, !shouldRenderCornerCustomMergeContent(col, row, customMergeRange, table)) {
54749
+ const customContainer = cellGroup.getChildByName(CUSTOM_CONTAINER_NAME);
54750
+ return customContainer && cellGroup.removeChild(customContainer), cellGroup.setAttribute("clip", !0), resizeCellGroup(cellGroup, rangeWidth, rangeHeight, customMergeRange, table), customMergeRange;
54751
+ }
54752
+ const customResult = dealWithCustom(customMergeLayout, customMergeRender, customMergeRange.start.col, customMergeRange.start.row, table.getColsWidth(customMergeRange.start.col, customMergeRange.end.col), table.getRowsHeight(customMergeRange.start.row, customMergeRange.end.row), !1, table.isAutoRowHeight(row), [0, 0, 0, 0], customMergeRange, table),
54753
+ customElementsGroup = createCornerCustomMergeContainer(customResult.elementsGroup, contentWidth, contentHeight, customMergeRange, table);
54754
+ return cellGroup.childrenCount > 0 && customElementsGroup ? cellGroup.insertBefore(customElementsGroup, cellGroup.firstChild) : customElementsGroup && cellGroup.appendChild(customElementsGroup), resizeCellGroup(cellGroup, rangeWidth, rangeHeight, customMergeRange, table), isCornerCustomMergeRange(customMergeRange, table) && cellGroup.setAttribute("clip", !1), customMergeRange;
54650
54755
  }
54651
54756
  }
54652
54757
  }
@@ -54815,7 +54920,12 @@
54815
54920
  update ? newHeights[row] = Math.round(height) : table._setRowHeight(row, height);
54816
54921
  }
54817
54922
  } else {
54818
- fillRowsHeight(computeRowHeight(table.columnHeaderLevelCount, 0, table.colCount - 1, table), table.columnHeaderLevelCount, table.rowCount - 1 - table.bottomFrozenRowCount, table, update ? newHeights : void 0);
54923
+ const fillStartRow = table.columnHeaderLevelCount,
54924
+ fillEndRow = table.rowCount - 1 - table.bottomFrozenRowCount,
54925
+ rowForCompute = getFirstUnresizedRow(table, fillStartRow, fillEndRow);
54926
+ if (rowForCompute >= 0) {
54927
+ fillRowsHeight(computeRowHeight(rowForCompute, 0, table.colCount - 1, table), fillStartRow, fillEndRow, table, update ? newHeights : void 0);
54928
+ }
54819
54929
  for (let row = table.rowCount - table.bottomFrozenRowCount; row <= rowEnd; row++) {
54820
54930
  const height = computeRowHeight(row, 0, table.colCount - 1, table);
54821
54931
  update ? newHeights[row] = Math.round(height) : table._setRowHeight(row, height);
@@ -54879,7 +54989,7 @@
54879
54989
  table.isPivotTable() && (layoutMap.disableUseGetBodyCache(), layoutMap.disableUseHeaderPathCache());
54880
54990
  }
54881
54991
  function computeRowHeight(row, startCol, endCol, table) {
54882
- return computeRowHeightInternal(row, startCol, endCol, table, !0);
54992
+ return table.internalProps._heightResizedRowMap.has(row) ? table.getRowHeight(row) : computeRowHeightInternal(row, startCol, endCol, table, !0);
54883
54993
  }
54884
54994
  function computeRowHeightInternal(row, startCol, endCol, table, enableCustomCompute) {
54885
54995
  if (!(table.isAutoRowHeight(row) || "adaptive" === table.heightMode && !1 !== table.options.autoHeightInAdaptiveMode) && "auto" !== table.getDefaultRowHeight(row)) return table.getDefaultRowHeight(row);
@@ -54980,10 +55090,14 @@
54980
55090
  }
54981
55091
  function fillRowsHeight(height, startRow, endRow, table, newHeights) {
54982
55092
  if (!table.internalProps.useOneRowHeightFillAll) {
54983
- for (let row = startRow; row <= endRow; row++) newHeights ? newHeights[row] = height : table._setRowHeight(row, height);
55093
+ for (let row = startRow; row <= endRow; row++) table.internalProps._heightResizedRowMap.has(row) || (newHeights ? newHeights[row] = height : table._setRowHeight(row, height));
54984
55094
  table.internalProps.useOneRowHeightFillAll = !0;
54985
55095
  }
54986
55096
  }
55097
+ function getFirstUnresizedRow(table, startRow, endRow) {
55098
+ for (let row = startRow; row <= endRow; row++) if (!table.internalProps._heightResizedRowMap.has(row)) return row;
55099
+ return -1;
55100
+ }
54987
55101
  function computeCustomRenderHeight(col, row, table) {
54988
55102
  var _a, _b, _c, _d, _e, _f, _g;
54989
55103
  const customRender = table.getCustomRender(col, row);
@@ -55132,14 +55246,15 @@
55132
55246
  };
55133
55247
  }
55134
55248
 
55135
- function updateRowHeight(scene, row, detaY, skipTableHeightMap) {
55136
- !skipTableHeightMap && detaY && scene.table._setRowHeight(row, scene.table.getRowHeight(row) + detaY, !0);
55249
+ function updateRowHeight(scene, row, detaY, skipTableHeightMap, pendingCornerCustomMergeRanges) {
55250
+ const shouldFlushCornerCustomMergeRanges = !pendingCornerCustomMergeRanges;
55251
+ null != pendingCornerCustomMergeRanges || (pendingCornerCustomMergeRanges = new Map()), !skipTableHeightMap && detaY && scene.table._setRowHeight(row, scene.table.getRowHeight(row) + detaY, !0);
55137
55252
  for (let col = 0; col < scene.table.colCount; col++) {
55138
55253
  const cell = scene.getCell(col, row);
55139
55254
  if ("empty" === cell.role) continue;
55140
55255
  const mergeInfo = getCellMergeInfo(scene.table, col, row);
55141
55256
  if (mergeInfo && mergeInfo.start.col !== col) continue;
55142
- updateCellHeightForRow(scene, cell, col, row, cell.attribute.height + detaY, detaY, scene.table.isHeader(col, row)), scene.updateCellContentWhileResize(col, row);
55257
+ updateCellHeightForRow(scene, cell, col, row, cell.attribute.height + detaY, detaY, scene.table.isHeader(col, row), pendingCornerCustomMergeRanges), scene.updateCellContentWhileResize(col, row);
55143
55258
  }
55144
55259
  let rowStart = 0,
55145
55260
  rowEnd = 0;
@@ -55148,11 +55263,12 @@
55148
55263
  const cellGroup = scene.highPerformanceGetCell(colIndex, rowIndex);
55149
55264
  "cell" === cellGroup.role && cellGroup.setAttribute("y", cellGroup.attribute.y + detaY);
55150
55265
  }
55266
+ shouldFlushCornerCustomMergeRanges && flushCornerCustomMergeContentUpdates(pendingCornerCustomMergeRanges, scene.table);
55151
55267
  }
55152
- function updateCellHeightForRow(scene, cell, col, row, height, detaY, isHeader) {
55153
- cell && updateCellHeight(scene, cell, col, row, height, detaY);
55268
+ function updateCellHeightForRow(scene, cell, col, row, height, detaY, isHeader, pendingCornerCustomMergeRanges) {
55269
+ cell && updateCellHeight(scene, cell, col, row, height, detaY, isHeader, pendingCornerCustomMergeRanges);
55154
55270
  }
55155
- function updateCellHeight(scene, cell, col, row, distHeight, detaY, isHeader) {
55271
+ function updateCellHeight(scene, cell, col, row, distHeight, detaY, isHeader, pendingCornerCustomMergeRanges) {
55156
55272
  var _a, _b, _c;
55157
55273
  if (cell.attribute.height === distHeight && !cell.needUpdateHeight) return;
55158
55274
  cell.needUpdateHeight = !1, cell.setAttribute("height", distHeight);
@@ -55169,7 +55285,7 @@
55169
55285
  (null == columnDefine ? void 0 : columnDefine.mergeCell) && (range = scene.table.getCellRange(col, row));
55170
55286
  const newBarCell = Factory.getFunction("createProgressBarCell")(columnDefine, style, cell.attribute.width, value, dataValue, col, row, padding, scene.table, range),
55171
55287
  oldBarCell = cell.getChildByName("progress-bar");
55172
- cell.insertBefore(newBarCell, oldBarCell), cell.removeChild(oldBarCell), oldBarCell.removeAllChild(), oldBarCell.release(), updateMergeCellContentHeight(cell, distHeight, detaY, scene.table.isAutoRowHeight(row), !0, scene.table);
55288
+ cell.insertBefore(newBarCell, oldBarCell), cell.removeChild(oldBarCell), oldBarCell.removeAllChild(), oldBarCell.release(), updateMergeCellContentHeight(cell, distHeight, detaY, scene.table.isAutoRowHeight(row), !0, scene.table, !0, pendingCornerCustomMergeRanges);
55173
55289
  } else if ("sparkline" === type) {
55174
55290
  cell.removeAllChild();
55175
55291
  const headerStyle = scene.table._getCellStyle(col, row),
@@ -55179,6 +55295,13 @@
55179
55295
  let renderDefault = !0;
55180
55296
  const customContainer = cell.getChildByName(CUSTOM_CONTAINER_NAME) || cell.getChildByName(CUSTOM_MERGE_CONTAINER_NAME);
55181
55297
  if (customContainer) {
55298
+ if (scene.table.reactCustomLayout) {
55299
+ const mergeRange = isMergeCellGroup(cell) ? scene.table.getCellRange(cell.mergeStartCol, cell.mergeStartRow) : void 0,
55300
+ shouldUseMergeStart = mergeRange && isCornerCustomMergeRange(mergeRange, scene.table),
55301
+ removeCol = shouldUseMergeStart ? mergeRange.start.col : col,
55302
+ removeRow = shouldUseMergeStart ? mergeRange.start.row : row;
55303
+ scene.table.reactCustomLayout.removeCustomCell(removeCol, removeRow);
55304
+ }
55182
55305
  let customElementsGroup;
55183
55306
  cell.removeChild(customContainer);
55184
55307
  const customMergeRange = getCustomCellMergeCustom(col, row, cell, scene.table);
@@ -55186,7 +55309,7 @@
55186
55309
  if (mergeRow === row) continue;
55187
55310
  const mergedCell = scene.getCell(col, mergeRow),
55188
55311
  customContainer = mergedCell.getChildByName(CUSTOM_CONTAINER_NAME) || mergedCell.getChildByName(CUSTOM_MERGE_CONTAINER_NAME);
55189
- customContainer.removeAllChild(), mergedCell.removeChild(customContainer), getCustomCellMergeCustom(col, mergeRow, mergedCell, scene.table);
55312
+ customContainer && (customContainer.removeAllChild(), mergedCell.removeChild(customContainer)), getCustomCellMergeCustom(col, mergeRow, mergedCell, scene.table);
55190
55313
  } else {
55191
55314
  let customRender, customLayout;
55192
55315
  const cellLocation = scene.table.getCellLocation(col, row),
@@ -55201,31 +55324,31 @@
55201
55324
  customRender = (null == define ? void 0 : define.customRender) || scene.table.customRender, customLayout = null == define ? void 0 : define.customLayout;
55202
55325
  }
55203
55326
  if ((customRender || customLayout) && isMergeCellGroup(cell)) for (let mergeCol = cell.mergeStartCol; mergeCol <= cell.mergeEndCol; mergeCol++) for (let mergeRow = cell.mergeStartRow; mergeRow <= cell.mergeEndRow; mergeRow++) mergeRow !== row && scene.updateCellContent(mergeCol, mergeRow);
55204
- if (customLayout || customRender) {
55205
- const style = scene.table._getCellStyle(col, row),
55206
- padding = getQuadProps(getProp("padding", style, col, row, scene.table));
55207
- let width = cell.attribute.width,
55208
- height = cell.attribute.height;
55209
- isMergeCellGroup(cell) && (width = scene.table.getColsWidth(cell.mergeStartCol, cell.mergeEndCol), height = scene.table.getRowsHeight(cell.mergeStartRow, cell.mergeEndRow));
55210
- const customResult = dealWithCustom(customLayout, customRender, col, row, width, height, !1, scene.table.isAutoRowHeight(row), padding, isMergeCellGroup(cell) ? {
55211
- start: {
55212
- col: cell.mergeStartCol,
55213
- row: cell.mergeStartRow
55214
- },
55215
- end: {
55216
- col: cell.mergeEndCol,
55217
- row: cell.mergeEndRow
55218
- }
55219
- } : void 0, scene.table);
55220
- customElementsGroup = customResult.elementsGroup, renderDefault = customResult.renderDefault;
55327
+ const mergeRange = isMergeCellGroup(cell) ? scene.table.getCellRange(cell.mergeStartCol, cell.mergeStartRow) : void 0;
55328
+ if (shouldRenderCornerCustomMergeContent(col, row, mergeRange, scene.table)) {
55329
+ if (customLayout || customRender) {
55330
+ const style = scene.table._getCellStyle(col, row),
55331
+ padding = getQuadProps(getProp("padding", style, col, row, scene.table));
55332
+ let width = cell.attribute.width,
55333
+ height = cell.attribute.height;
55334
+ isMergeCellGroup(cell) && (width = scene.table.getColsWidth(cell.mergeStartCol, cell.mergeEndCol), height = scene.table.getRowsHeight(cell.mergeStartRow, cell.mergeEndRow));
55335
+ let customCol = col,
55336
+ customRow = row;
55337
+ mergeRange && isCornerCustomMergeRange(mergeRange, scene.table) && (customCol = mergeRange.start.col, customRow = mergeRange.start.row);
55338
+ const customResult = dealWithCustom(customLayout, customRender, customCol, customRow, width, height, !1, scene.table.isAutoRowHeight(row), padding, mergeRange, scene.table);
55339
+ customElementsGroup = createCornerCustomMergeContainer(customResult.elementsGroup, width, height, mergeRange, scene.table), renderDefault = customResult.renderDefault;
55340
+ }
55341
+ } else renderDefault = !1;
55342
+ if (cell.childrenCount > 0 && customElementsGroup ? cell.insertBefore(customElementsGroup, cell.firstChild) : customElementsGroup && cell.appendChild(customElementsGroup), isMergeCellGroup(cell)) {
55343
+ const mergeRange = scene.table.getCellRange(cell.mergeStartCol, cell.mergeStartRow);
55344
+ isCornerCustomMergeRange(mergeRange, scene.table) && cell.setAttribute("clip", !shouldRenderCornerCustomMergeContent(col, row, mergeRange, scene.table));
55221
55345
  }
55222
- cell.childrenCount > 0 && customElementsGroup ? cell.insertBefore(customElementsGroup, cell.firstChild) : customElementsGroup && cell.appendChild(customElementsGroup);
55223
55346
  }
55224
55347
  }
55225
- updateMergeCellContentHeight(cell, distHeight, detaY, scene.table.isAutoRowHeight(row), renderDefault, scene.table);
55348
+ updateMergeCellContentHeight(cell, distHeight, detaY, scene.table.isAutoRowHeight(row), renderDefault, scene.table, !customContainer, pendingCornerCustomMergeRanges);
55226
55349
  }
55227
55350
  }
55228
- function updateMergeCellContentHeight(cellGroup, distHeight, detaY, autoRowHeight, renderDefault, table) {
55351
+ function updateMergeCellContentHeight(cellGroup, distHeight, detaY, autoRowHeight, renderDefault, table, refreshCornerCustomMergeContent = !0, pendingCornerCustomMergeRanges) {
55229
55352
  if (isMergeCellGroup(cellGroup)) {
55230
55353
  distHeight = 0;
55231
55354
  for (let row = cellGroup.mergeStartRow; row <= cellGroup.mergeEndRow; row++) distHeight += table.getRowHeight(row);
@@ -55265,6 +55388,8 @@
55265
55388
  }, table);
55266
55389
  widthChange && (singleCellGroup.needUpdateWidth = !0);
55267
55390
  }
55391
+ const mergeRange = table.getCellRange(cellGroup.mergeStartCol, cellGroup.mergeStartRow);
55392
+ refreshCornerCustomMergeContent && isCornerCustomMergeRange(mergeRange, table) && queueCornerCustomMergeContentUpdate(mergeRange, table, pendingCornerCustomMergeRanges);
55268
55393
  } else {
55269
55394
  const style = table._getCellStyle(cellGroup.col, cellGroup.row),
55270
55395
  padding = getQuadProps(getProp("padding", style, cellGroup.col, cellGroup.row, table));
@@ -55272,19 +55397,20 @@
55272
55397
  }
55273
55398
  }
55274
55399
 
55275
- function updateColWidth(scene, col, detaX, skipTableWidthMap) {
55276
- skipTableWidthMap || scene.table._setColWidth(col, scene.table.getColWidth(col) + detaX, !0);
55400
+ function updateColWidth(scene, col, detaX, skipTableWidthMap, pendingCornerCustomMergeRanges) {
55401
+ const shouldFlushCornerCustomMergeRanges = !pendingCornerCustomMergeRanges;
55402
+ null != pendingCornerCustomMergeRanges || (pendingCornerCustomMergeRanges = new Map()), skipTableWidthMap || scene.table._setColWidth(col, scene.table.getColWidth(col) + detaX, !0);
55277
55403
  const colOrCornerHeaderColumn = scene.getColGroup(col, !0),
55278
55404
  rightTopColumn = scene.getColGroupInRightTopCorner(col);
55279
- colOrCornerHeaderColumn && !rightTopColumn && updateColunmWidth(colOrCornerHeaderColumn, detaX, "col-corner", scene), rightTopColumn && updateColunmWidth(rightTopColumn, detaX, "right-top", scene);
55405
+ colOrCornerHeaderColumn && !rightTopColumn && updateColunmWidth(colOrCornerHeaderColumn, detaX, "col-corner", scene, pendingCornerCustomMergeRanges), rightTopColumn && updateColunmWidth(rightTopColumn, detaX, "right-top", scene, pendingCornerCustomMergeRanges);
55280
55406
  const rowHeaderOrBodyColumn = scene.getColGroup(col);
55281
- rowHeaderOrBodyColumn && updateColunmWidth(rowHeaderOrBodyColumn, detaX, "row-body", scene);
55407
+ rowHeaderOrBodyColumn && updateColunmWidth(rowHeaderOrBodyColumn, detaX, "row-body", scene, pendingCornerCustomMergeRanges);
55282
55408
  const leftBottomColumn = scene.getColGroupInLeftBottomCorner(col);
55283
- leftBottomColumn && updateColunmWidth(leftBottomColumn, detaX, "left-bottom", scene);
55409
+ leftBottomColumn && updateColunmWidth(leftBottomColumn, detaX, "left-bottom", scene, pendingCornerCustomMergeRanges);
55284
55410
  const bottomColumn = scene.getColGroupInBottom(col);
55285
- bottomColumn && updateColunmWidth(bottomColumn, detaX, "bottom", scene);
55411
+ bottomColumn && updateColunmWidth(bottomColumn, detaX, "bottom", scene, pendingCornerCustomMergeRanges);
55286
55412
  const rightBottomColumn = scene.getColGroupInRightBottomCorner(col);
55287
- rightBottomColumn && updateColunmWidth(rightBottomColumn, detaX, "right-bottom", scene), col < scene.frozenColCount ? (scene.cornerHeaderGroup.forEachChildrenSkipChild((column, index) => {
55413
+ rightBottomColumn && updateColunmWidth(rightBottomColumn, detaX, "right-bottom", scene, pendingCornerCustomMergeRanges), col < scene.frozenColCount ? (scene.cornerHeaderGroup.forEachChildrenSkipChild((column, index) => {
55288
55414
  column.col > col && column.setAttribute("x", column.attribute.x + detaX);
55289
55415
  }), scene.rowHeaderGroup.forEachChildrenSkipChild((column, index) => {
55290
55416
  column.col > col && column.setAttribute("x", column.attribute.x + detaX);
@@ -55298,14 +55424,14 @@
55298
55424
  column.col > col && column.setAttribute("x", column.attribute.x + detaX);
55299
55425
  }), rightBottomColumn && scene.rightBottomCornerGroup.forEachChildrenSkipChild((column, index) => {
55300
55426
  column.col > col && column.setAttribute("x", column.attribute.x + detaX);
55301
- });
55427
+ }), shouldFlushCornerCustomMergeRanges && flushCornerCustomMergeContentUpdates(pendingCornerCustomMergeRanges, scene.table);
55302
55428
  }
55303
- function updateColunmWidth(columnGroup, detaX, mode, scene) {
55429
+ function updateColunmWidth(columnGroup, detaX, mode, scene, pendingCornerCustomMergeRanges) {
55304
55430
  var _a, _b, _c, _d, _e, _f, _g;
55305
55431
  let needRerangeRow = !1;
55306
55432
  const oldColumnWidth = null !== (_a = null == columnGroup ? void 0 : columnGroup.attribute.width) && void 0 !== _a ? _a : 0;
55307
55433
  if (null == columnGroup || columnGroup.setAttribute("width", oldColumnWidth + detaX), null == columnGroup || columnGroup.forEachChildren((cell, index) => {
55308
- if (updateCellWidth(scene, cell, cell.col, cell.row, oldColumnWidth, oldColumnWidth + detaX, detaX, "row-body" !== mode || cell.col < scene.table.rowHeaderLevelCount, scene.table.internalProps.autoWrapText)) {
55434
+ if (updateCellWidth(scene, cell, cell.col, cell.row, oldColumnWidth, oldColumnWidth + detaX, detaX, "row-body" !== mode || cell.col < scene.table.rowHeaderLevelCount, scene.table.internalProps.autoWrapText, pendingCornerCustomMergeRanges)) {
55309
55435
  const mergeInfo = getCellMergeInfo(scene.table, cell.col, cell.row);
55310
55436
  if (mergeInfo && mergeInfo.end.row - mergeInfo.start.row) for (let row = mergeInfo.start.row; row <= mergeInfo.end.row; row++) resetRowHeight(scene, row);else resetRowHeight(scene, cell.row);
55311
55437
  needRerangeRow = !0;
@@ -55347,7 +55473,7 @@
55347
55473
  }
55348
55474
  }
55349
55475
  }
55350
- function updateCellWidth(scene, cell, col, row, oldWidth, distWidth, detaX, isHeader, autoWrapText) {
55476
+ function updateCellWidth(scene, cell, col, row, oldWidth, distWidth, detaX, isHeader, autoWrapText, pendingCornerCustomMergeRanges) {
55351
55477
  var _a, _b, _c, _d, _e;
55352
55478
  if (cell.attribute.width === distWidth && !cell.needUpdateWidth) return !1;
55353
55479
  cell.needUpdateWidth = !1, cell.setAttribute("width", distWidth);
@@ -55369,7 +55495,7 @@
55369
55495
  const newBarCell = Factory.getFunction("createProgressBarCell")(columnDefine, style, cellGroup.attribute.width, value, dataValue, col, row, padding, scene.table, range),
55370
55496
  oldBarCell = cellGroup.getChildByName("progress-bar");
55371
55497
  cellGroup.insertBefore(newBarCell, oldBarCell), cellGroup.removeChild(oldBarCell), oldBarCell.removeAllChild(), oldBarCell.release();
55372
- const cellChange = updateMergeCellContentWidth(cellGroup, distWidth, detaX, autoRowHeight, !0, scene.table);
55498
+ const cellChange = updateMergeCellContentWidth(cellGroup, distWidth, detaX, autoRowHeight, !0, scene.table, !0, pendingCornerCustomMergeRanges);
55373
55499
  isHeightChange = isHeightChange || cellChange;
55374
55500
  } else if ("sparkline" === type) {
55375
55501
  cellGroup.removeAllChild();
@@ -55388,6 +55514,13 @@
55388
55514
  let renderDefault = !0;
55389
55515
  const customContainer = cell.getChildByName(CUSTOM_CONTAINER_NAME) || cell.getChildByName(CUSTOM_MERGE_CONTAINER_NAME);
55390
55516
  if (customContainer) {
55517
+ if (scene.table.reactCustomLayout) {
55518
+ const mergeRange = isMergeCellGroup(cellGroup) ? scene.table.getCellRange(cellGroup.mergeStartCol, cellGroup.mergeStartRow) : void 0,
55519
+ shouldUseMergeStart = mergeRange && isCornerCustomMergeRange(mergeRange, scene.table),
55520
+ removeCol = shouldUseMergeStart ? mergeRange.start.col : col,
55521
+ removeRow = shouldUseMergeStart ? mergeRange.start.row : row;
55522
+ scene.table.reactCustomLayout.removeCustomCell(removeCol, removeRow);
55523
+ }
55391
55524
  let customElementsGroup;
55392
55525
  cell.removeChild(customContainer);
55393
55526
  const customMergeRange = getCustomCellMergeCustom(col, row, cell, scene.table);
@@ -55395,7 +55528,7 @@
55395
55528
  if (mergeCol === col) continue;
55396
55529
  const mergedCell = scene.getCell(mergeCol, row),
55397
55530
  customContainer = mergedCell.getChildByName(CUSTOM_CONTAINER_NAME) || mergedCell.getChildByName(CUSTOM_MERGE_CONTAINER_NAME);
55398
- customContainer.removeAllChild(), mergedCell.removeChild(customContainer), getCustomCellMergeCustom(mergeCol, row, mergedCell, scene.table);
55531
+ customContainer && (customContainer.removeAllChild(), mergedCell.removeChild(customContainer)), getCustomCellMergeCustom(mergeCol, row, mergedCell, scene.table);
55399
55532
  } else {
55400
55533
  let customRender, customLayout;
55401
55534
  const cellType = scene.table.getCellLocation(col, row),
@@ -55410,28 +55543,28 @@
55410
55543
  customRender = (null == define ? void 0 : define.customRender) || scene.table.customRender, customLayout = null == define ? void 0 : define.customLayout;
55411
55544
  }
55412
55545
  if ((customRender || customLayout) && isMergeCellGroup(cellGroup)) for (let mergeCol = cellGroup.mergeStartCol; mergeCol <= cellGroup.mergeEndCol; mergeCol++) if (mergeCol !== col) for (let mergeRow = cellGroup.mergeStartRow; mergeRow <= cellGroup.mergeEndRow; mergeRow++) scene.updateCellContent(mergeCol, mergeRow);
55413
- if (customLayout || customRender) {
55414
- const style = scene.table._getCellStyle(col, row),
55415
- padding = getQuadProps(getProp("padding", style, col, row, scene.table));
55416
- let width = cellGroup.attribute.width,
55417
- height = cellGroup.attribute.height;
55418
- isMergeCellGroup(cellGroup) && (width = scene.table.getColsWidth(cellGroup.mergeStartCol, cellGroup.mergeEndCol), height = scene.table.getRowsHeight(cellGroup.mergeStartRow, cellGroup.mergeEndRow));
55419
- const customResult = dealWithCustom(customLayout, customRender, col, row, width, height, !1, scene.table.isAutoRowHeight(row), padding, isMergeCellGroup(cellGroup) ? {
55420
- start: {
55421
- col: cellGroup.mergeStartCol,
55422
- row: cellGroup.mergeStartRow
55423
- },
55424
- end: {
55425
- col: cellGroup.mergeEndCol,
55426
- row: cellGroup.mergeEndRow
55427
- }
55428
- } : void 0, scene.table);
55429
- customElementsGroup = customResult.elementsGroup, renderDefault = customResult.renderDefault, isHeightChange = !0;
55546
+ const mergeRange = isMergeCellGroup(cellGroup) ? scene.table.getCellRange(cellGroup.mergeStartCol, cellGroup.mergeStartRow) : void 0;
55547
+ if (shouldRenderCornerCustomMergeContent(col, row, mergeRange, scene.table)) {
55548
+ if (customLayout || customRender) {
55549
+ const style = scene.table._getCellStyle(col, row),
55550
+ padding = getQuadProps(getProp("padding", style, col, row, scene.table));
55551
+ let width = cellGroup.attribute.width,
55552
+ height = cellGroup.attribute.height;
55553
+ isMergeCellGroup(cellGroup) && (width = scene.table.getColsWidth(cellGroup.mergeStartCol, cellGroup.mergeEndCol), height = scene.table.getRowsHeight(cellGroup.mergeStartRow, cellGroup.mergeEndRow));
55554
+ let customCol = col,
55555
+ customRow = row;
55556
+ mergeRange && isCornerCustomMergeRange(mergeRange, scene.table) && (customCol = mergeRange.start.col, customRow = mergeRange.start.row);
55557
+ const customResult = dealWithCustom(customLayout, customRender, customCol, customRow, width, height, !1, scene.table.isAutoRowHeight(row), padding, mergeRange, scene.table);
55558
+ customElementsGroup = createCornerCustomMergeContainer(customResult.elementsGroup, width, height, mergeRange, scene.table), renderDefault = customResult.renderDefault, isHeightChange = !0;
55559
+ }
55560
+ } else renderDefault = !1;
55561
+ if (cell.childrenCount > 0 && customElementsGroup ? cell.insertBefore(customElementsGroup, cell.firstChild) : customElementsGroup && cell.appendChild(customElementsGroup), isMergeCellGroup(cellGroup)) {
55562
+ const mergeRange = scene.table.getCellRange(cellGroup.mergeStartCol, cellGroup.mergeStartRow);
55563
+ isCornerCustomMergeRange(mergeRange, scene.table) && cell.setAttribute("clip", !shouldRenderCornerCustomMergeContent(col, row, mergeRange, scene.table));
55430
55564
  }
55431
- cell.childrenCount > 0 && customElementsGroup ? cell.insertBefore(customElementsGroup, cell.firstChild) : customElementsGroup && cell.appendChild(customElementsGroup);
55432
55565
  }
55433
55566
  }
55434
- const cellChange = updateMergeCellContentWidth(cellGroup, distWidth, detaX, autoRowHeight, renderDefault, scene.table);
55567
+ const cellChange = updateMergeCellContentWidth(cellGroup, distWidth, detaX, autoRowHeight, renderDefault, scene.table, !customContainer, pendingCornerCustomMergeRanges);
55435
55568
  isHeightChange = isHeightChange || cellChange;
55436
55569
  }
55437
55570
  if (!autoWrapText) {
@@ -55439,7 +55572,7 @@
55439
55572
  }
55440
55573
  return !(!autoRowHeight || !autoWrapText) && isHeightChange;
55441
55574
  }
55442
- function updateMergeCellContentWidth(cellGroup, distWidth, detaX, autoRowHeight, renderDefault, table) {
55575
+ function updateMergeCellContentWidth(cellGroup, distWidth, detaX, autoRowHeight, renderDefault, table, refreshCornerCustomMergeContent = !0, pendingCornerCustomMergeRanges) {
55443
55576
  if (isMergeCellGroup(cellGroup)) {
55444
55577
  distWidth = 0;
55445
55578
  let isHeightChange = !1;
@@ -55493,7 +55626,8 @@
55493
55626
  }, table);
55494
55627
  heightChange && (singleCellGroup.needUpdateHeight = !0), isHeightChange = isHeightChange || changed;
55495
55628
  }
55496
- return isHeightChange;
55629
+ const mergeRange = table.getCellRange(cellGroup.mergeStartCol, cellGroup.mergeStartRow);
55630
+ return refreshCornerCustomMergeContent && isCornerCustomMergeRange(mergeRange, table) && queueCornerCustomMergeContentUpdate(mergeRange, table, pendingCornerCustomMergeRanges), isHeightChange;
55497
55631
  }
55498
55632
  const style = table._getCellStyle(cellGroup.col, cellGroup.row),
55499
55633
  padding = getQuadProps(getProp("padding", style, cellGroup.col, cellGroup.row, table)),
@@ -57048,8 +57182,12 @@
57048
57182
  const maxWidthColumnMap = new Map(),
57049
57183
  minWidthColumnMap = new Map();
57050
57184
  for (let col = startCol; col < endColPlus1; col++) {
57051
- const width = update && null !== (_a = newWidths[col]) && void 0 !== _a ? _a : table.getColWidth(col),
57052
- maxWidth = table.getMaxColWidth(col),
57185
+ const width = update && null !== (_a = newWidths[col]) && void 0 !== _a ? _a : table.getColWidth(col);
57186
+ if ("adaptive" === table.widthMode && table.internalProps._widthResizedColMap.has(col)) {
57187
+ totalDrawWidth -= width;
57188
+ continue;
57189
+ }
57190
+ const maxWidth = table.getMaxColWidth(col),
57053
57191
  minWidth = table.getMinColWidth(col);
57054
57192
  if (actualWidth += width, adaptiveColumns.push(col), maxWidth === width ? maxWidthColumnMap.set(col, width) : minWidth === width && minWidthColumnMap.set(col, width), null === (_b = table.options.customConfig) || void 0 === _b ? void 0 : _b.shrinkSparklineFirst) {
57055
57193
  "sparkline" === table.getBodyColumnType(col, 0) && (sparklineColumns.push({
@@ -57337,7 +57475,7 @@
57337
57475
  let targetRow = distRow;
57338
57476
  for (; targetRow < bodyBottomRow && table.getRowsHeight(table.frozenRowCount, targetRow) < visibleBodyHeight;) {
57339
57477
  const nextRow = targetRow + 1;
57340
- computeRowsHeight(table, nextRow, nextRow, !1), targetRow = nextRow;
57478
+ table.internalProps._heightResizedRowMap.has(nextRow) || computeRowsHeight(table, nextRow, nextRow, !1), targetRow = nextRow;
57341
57479
  }
57342
57480
  return targetRow;
57343
57481
  }
@@ -57357,7 +57495,20 @@
57357
57495
  let distCol, distRow, distColForCompute, distRowForCompute;
57358
57496
  proxy.setParamsForRow(), proxy.setParamsForColumn(), "adaptive" === table.widthMode || table.options.autoWrapText && ("adaptive" === table.heightMode || table.isAutoRowHeight(table.columnHeaderLevelCount)) ? (distColForCompute = table.colCount - 1, distCol = Math.min(proxy.firstScreenColLimit - 1, table.colCount - 1)) : distCol = Math.min(proxy.firstScreenColLimit - 1, table.colCount - 1), "adaptive" === table.heightMode ? (distRowForCompute = table.rowCount - 1, distRow = Math.min(proxy.firstScreenRowLimit - 1, table.rowCount - 1)) : distRow = Math.min(proxy.firstScreenRowLimit - 1, table.rowCount - 1);
57359
57497
  let bodyDistRow = Math.min(proxy.bodyBottomRow, distRow - table.bottomFrozenRowCount);
57360
- 0 === table.internalProps._widthResizedColMap.size && computeColsWidth(table, 0, null != distColForCompute ? distColForCompute : distCol), 0 === table.internalProps._heightResizedRowMap.size && (computeRowsHeight(table, 0, "auto" === table.options.canvasHeight || (null === (_a = table.options.customConfig) || void 0 === _a ? void 0 : _a.forceComputeAllRowHeight) ? table.rowCount - 1 : null != distRowForCompute ? distRowForCompute : distRow), "autoHeight" === table.heightMode && (bodyDistRow = fillVisibleBodyRows$1(proxy, bodyDistRow), syncVisibleBodyRows(proxy, bodyDistRow))), distCol < table.colCount - table.rightFrozenColCount && table.colCount - table.rightFrozenColCount <= table.colCount - 1 && computeColsWidth(table, table.colCount - table.rightFrozenColCount, table.colCount - 1), distRow < table.rowCount - table.bottomFrozenRowCount && table.rowCount - table.bottomFrozenRowCount <= table.rowCount - 1 && computeRowsHeight(table, table.rowCount - table.bottomFrozenRowCount, table.rowCount - 1), table.scenegraph.colHeaderGroup.setAttribute("x", table.getFrozenColsWidth()), table.scenegraph.rowHeaderGroup.setAttribute("y", table.getFrozenRowsHeight()), table.scenegraph.bottomFrozenGroup.setAttribute("x", table.getFrozenColsWidth()), table.scenegraph.rightFrozenGroup.setAttribute("y", table.getFrozenRowsHeight()), table.scenegraph.bodyGroup.setAttributes({
57498
+ const colEndForCompute = null != distColForCompute ? distColForCompute : distCol;
57499
+ let hasUnresizedColumns = !1;
57500
+ for (let col = 0; col <= colEndForCompute; col++) if (!table.internalProps._widthResizedColMap.has(col)) {
57501
+ hasUnresizedColumns = !0;
57502
+ break;
57503
+ }
57504
+ hasUnresizedColumns && computeColsWidth(table, 0, colEndForCompute);
57505
+ const rowEndForCompute = "auto" === table.options.canvasHeight || (null === (_a = table.options.customConfig) || void 0 === _a ? void 0 : _a.forceComputeAllRowHeight) ? table.rowCount - 1 : null != distRowForCompute ? distRowForCompute : distRow;
57506
+ let hasUnresizedRows = !1;
57507
+ for (let row = 0; row <= rowEndForCompute; row++) if (!table.internalProps._heightResizedRowMap.has(row)) {
57508
+ hasUnresizedRows = !0;
57509
+ break;
57510
+ }
57511
+ hasUnresizedRows && computeRowsHeight(table, 0, rowEndForCompute), "autoHeight" === table.heightMode && (bodyDistRow = fillVisibleBodyRows$1(proxy, bodyDistRow), syncVisibleBodyRows(proxy, bodyDistRow)), distCol < table.colCount - table.rightFrozenColCount && table.colCount - table.rightFrozenColCount <= table.colCount - 1 && computeColsWidth(table, table.colCount - table.rightFrozenColCount, table.colCount - 1), distRow < table.rowCount - table.bottomFrozenRowCount && table.rowCount - table.bottomFrozenRowCount <= table.rowCount - 1 && computeRowsHeight(table, table.rowCount - table.bottomFrozenRowCount, table.rowCount - 1), table.scenegraph.colHeaderGroup.setAttribute("x", table.getFrozenColsWidth()), table.scenegraph.rowHeaderGroup.setAttribute("y", table.getFrozenRowsHeight()), table.scenegraph.bottomFrozenGroup.setAttribute("x", table.getFrozenColsWidth()), table.scenegraph.rightFrozenGroup.setAttribute("y", table.getFrozenRowsHeight()), table.scenegraph.bodyGroup.setAttributes({
57361
57512
  x: table.getFrozenColsWidth(),
57362
57513
  y: table.getFrozenRowsHeight()
57363
57514
  }), createColGroup(cornerHeaderGroup, xOrigin, yOrigin, 0, table.frozenColCount - 1, 0, table.frozenRowCount - 1, table.isListTable() ? "columnHeader" : "cornerHeader", table), distCol - table.rightFrozenColCount >= table.frozenColCount && createColGroup(colHeaderGroup, xOrigin, yOrigin, table.frozenColCount, distCol - table.rightFrozenColCount, 0, table.frozenRowCount - 1, "columnHeader", table), table.frozenColCount > 0 && (table.leftRowSeriesNumberCount > 0 && createColGroup(rowHeaderGroup, xOrigin, yOrigin, 0, table.leftRowSeriesNumberCount - 1, table.frozenRowCount, bodyDistRow, "rowHeader", table), table.frozenColCount > table.leftRowSeriesNumberCount && createColGroup(rowHeaderGroup, xOrigin, yOrigin, table.leftRowSeriesNumberCount, Math.min(table.frozenColCount - 1, table.rowHeaderLevelCount + table.leftRowSeriesNumberCount - 1), table.frozenRowCount, bodyDistRow, "rowHeader", table), table.frozenColCount > table.rowHeaderLevelCount + table.leftRowSeriesNumberCount && createColGroup(rowHeaderGroup, xOrigin, yOrigin, table.rowHeaderLevelCount + table.leftRowSeriesNumberCount, table.frozenColCount - 1, table.frozenRowCount, bodyDistRow, "body", table)), table.bottomFrozenRowCount > 0 && (table.frozenColCount > 0 && (table.leftRowSeriesNumberCount > 0 && createColGroup(leftBottomCornerGroup, xOrigin, yOrigin, 0, table.leftRowSeriesNumberCount - 1, table.rowCount - 1 - table.bottomFrozenRowCount + 1, table.rowCount - 1, "rowHeader", table), table.rowHeaderLevelCount > 0 && createColGroup(leftBottomCornerGroup, xOrigin, yOrigin, table.leftRowSeriesNumberCount, table.leftRowSeriesNumberCount + table.rowHeaderLevelCount - 1, table.rowCount - 1 - table.bottomFrozenRowCount + 1, table.rowCount - 1, "rowHeader", table), table.frozenColCount > table.rowHeaderLevelCount + table.leftRowSeriesNumberCount && createColGroup(leftBottomCornerGroup, xOrigin, yOrigin, table.rowHeaderLevelCount + table.leftRowSeriesNumberCount, table.frozenColCount - 1, table.rowCount - 1 - table.bottomFrozenRowCount + 1, table.rowCount - 1, "body", table)), distCol - table.rightFrozenColCount >= table.frozenColCount && createColGroup(bottomFrozenGroup, xOrigin, yOrigin, table.frozenColCount, distCol - table.rightFrozenColCount, table.rowCount - 1 - table.bottomFrozenRowCount + 1, table.rowCount - 1, table.isPivotChart() ? "rowHeader" : "body", table)), table.rightFrozenColCount > 0 && (createColGroup(rightTopCornerGroup, xOrigin, yOrigin, table.colCount - 1 - table.rightFrozenColCount + 1, table.colCount - 1, 0, table.frozenRowCount - 1, "columnHeader", table), createColGroup(rightFrozenGroup, xOrigin, yOrigin, table.colCount - 1 - table.rightFrozenColCount + 1, table.colCount - 1, table.frozenRowCount, bodyDistRow, table.isPivotChart() ? "rowHeader" : "body", table)), table.bottomFrozenRowCount > 0 && table.rightFrozenColCount > 0 && createColGroup(rightBottomCornerGroup, xOrigin, yOrigin, table.colCount - 1 - table.rightFrozenColCount + 1, table.colCount - 1, table.rowCount - 1 - table.bottomFrozenRowCount + 1, table.rowCount - 1, "body", table), distCol - table.rightFrozenColCount >= table.frozenColCount && createColGroup(bodyGroup, xOrigin, yOrigin, table.frozenColCount, distCol - table.rightFrozenColCount, table.frozenRowCount, bodyDistRow, "body", table), bodyGroup.firstChild || colHeaderGroup.firstChild || cornerHeaderGroup.firstChild || rowHeaderGroup.firstChild ? (proxy.currentRow = null !== (_e = null !== (_c = null === (_b = bodyGroup.firstChild) || void 0 === _b ? void 0 : _b.rowNumber) && void 0 !== _c ? _c : null === (_d = rowHeaderGroup.firstChild) || void 0 === _d ? void 0 : _d.rowNumber) && void 0 !== _e ? _e : proxy.totalRow, proxy.rowEnd = proxy.currentRow, proxy.rowUpdatePos = proxy.rowEnd + 1, proxy.referenceRow = proxy.rowStart + Math.floor((proxy.rowEnd - proxy.rowStart) / 2), proxy.currentCol = null !== (_o = null !== (_l = null !== (_j = null !== (_g = null === (_f = bodyGroup.lastChild) || void 0 === _f ? void 0 : _f.col) && void 0 !== _g ? _g : null === (_h = colHeaderGroup.lastChild) || void 0 === _h ? void 0 : _h.col) && void 0 !== _j ? _j : null === (_k = rowHeaderGroup.lastChild) || void 0 === _k ? void 0 : _k.col) && void 0 !== _l ? _l : null === (_m = cornerHeaderGroup.lastChild) || void 0 === _m ? void 0 : _m.col) && void 0 !== _o ? _o : proxy.totalCol, proxy.colEnd = proxy.currentCol, proxy.colUpdatePos = proxy.colEnd + 1, proxy.referenceCol = proxy.colStart + Math.floor((proxy.colEnd - proxy.colStart) / 2), proxy.progress()) : (proxy.currentRow = proxy.totalRow, proxy.rowEnd = proxy.currentRow, proxy.rowUpdatePos = proxy.rowEnd + 1, proxy.referenceRow = proxy.rowStart + Math.floor((proxy.rowEnd - proxy.rowStart) / 2), proxy.currentCol = proxy.totalCol, proxy.colEnd = proxy.currentCol, proxy.colUpdatePos = proxy.colEnd + 1, proxy.referenceCol = proxy.colStart + Math.floor((proxy.colEnd - proxy.colStart) / 2));
@@ -60314,6 +60465,7 @@
60314
60465
  }
60315
60466
  releaseStage() {
60316
60467
  var _a, _b, _c;
60468
+ this.clear = !0, this._needUpdateContainer = !1;
60317
60469
  const releaseAppRef = this.releaseVRenderAppRef;
60318
60470
  this.releaseVRenderAppRef = void 0;
60319
60471
  try {
@@ -60505,8 +60657,8 @@
60505
60657
  updateCellSelectBorder(this, cellRange), moveSelectingRangeComponentsToSelectedRangeComponents(this);
60506
60658
  });
60507
60659
  }
60508
- updateColWidth(col, detaX, skipUpdateContainer, skipTableWidthMap) {
60509
- updateColWidth(this, col, Math.round(detaX), skipTableWidthMap), skipUpdateContainer || this.updateContainer({
60660
+ updateColWidth(col, detaX, skipUpdateContainer, skipTableWidthMap, pendingCornerCustomMergeRanges) {
60661
+ updateColWidth(this, col, Math.round(detaX), skipTableWidthMap, pendingCornerCustomMergeRanges), skipUpdateContainer || this.updateContainer({
60510
60662
  async: !0
60511
60663
  });
60512
60664
  }
@@ -60679,8 +60831,8 @@
60679
60831
  height: this.tableGroup.attribute.height
60680
60832
  })));
60681
60833
  }
60682
- updateRowHeight(row, detaY, skipTableHeightMap) {
60683
- detaY = Math.round(detaY), updateRowHeight(this, row, detaY, skipTableHeightMap), this.updateContainerHeight(row, detaY);
60834
+ updateRowHeight(row, detaY, skipTableHeightMap, pendingCornerCustomMergeRanges) {
60835
+ detaY = Math.round(detaY), updateRowHeight(this, row, detaY, skipTableHeightMap, pendingCornerCustomMergeRanges), this.updateContainerHeight(row, detaY);
60684
60836
  }
60685
60837
  updateRowsHeight(rows, detaYs, skipTableHeightMap) {
60686
60838
  for (let i = 0; i < rows.length; i++) {
@@ -60889,7 +61041,7 @@
60889
61041
  var _a;
60890
61042
  updateConfig.async ? this._needUpdateContainer || (this._needUpdateContainer = !0, setTimeout(() => {
60891
61043
  var _a;
60892
- this.updateContainerSync(null !== (_a = updateConfig.needUpdateCellY) && void 0 !== _a && _a);
61044
+ this._needUpdateContainer && !this.clear ? this.updateContainerSync(null !== (_a = updateConfig.needUpdateCellY) && void 0 !== _a && _a) : this._needUpdateContainer = !1;
60893
61045
  }, 0)) : (this._needUpdateContainer = !0, this.updateContainerSync(null !== (_a = updateConfig.needUpdateCellY) && void 0 !== _a && _a));
60894
61046
  }
60895
61047
  updateContainerSync(needUpdateCellY = !1) {
@@ -62031,17 +62183,20 @@
62031
62183
  }), state.table.internalProps.title && state.table.internalProps.title.resize(), state.table.internalProps.emptyTip && state.table.internalProps.emptyTip.resize(), state.columnResize.col < state.table.frozenColCount && !state.table.isPivotTable() && !state.table.transpose ? state.table.scenegraph.component.setFrozenColumnShadow(state.table.frozenColCount - 1, state.columnResize.isRightFrozen) : state.table.options.frozenColCount && state.table.scenegraph.component.setFrozenColumnShadow(state.table.frozenColCount - 1), (state.columnResize.col >= state.table.colCount - state.table.rightFrozenColCount && !state.table.isPivotTable() && !state.table.transpose || state.table.options.rightFrozenColCount) && state.table.scenegraph.component.setRightFrozenColumnShadow(state.table.colCount - state.table.rightFrozenColCount), state.table.scenegraph.updateNextFrame();
62032
62184
  }
62033
62185
  function updateResizeColForColumn(detaX, state) {
62034
- "adaptive" === state.table.widthMode && state.columnResize.col < state.table.colCount - 1 ? (state.table.scenegraph.updateColWidth(state.columnResize.col, detaX), state.table.scenegraph.updateColWidth(state.columnResize.col + 1, -detaX), state.table.internalProps._widthResizedColMap.add(state.columnResize.col), state.table.internalProps._widthResizedColMap.add(state.columnResize.col + 1)) : (state.table.scenegraph.updateColWidth(state.columnResize.col, detaX), state.table.internalProps._widthResizedColMap.add(state.columnResize.col));
62186
+ const pendingCornerCustomMergeRanges = new Map();
62187
+ "adaptive" === state.table.widthMode && state.columnResize.col < state.table.colCount - 1 ? (state.table.scenegraph.updateColWidth(state.columnResize.col, detaX, void 0, void 0, pendingCornerCustomMergeRanges), state.table.scenegraph.updateColWidth(state.columnResize.col + 1, -detaX, void 0, void 0, pendingCornerCustomMergeRanges), state.table.internalProps._widthResizedColMap.add(state.columnResize.col), state.table.internalProps._widthResizedColMap.add(state.columnResize.col + 1)) : (state.table.scenegraph.updateColWidth(state.columnResize.col, detaX, void 0, void 0, pendingCornerCustomMergeRanges), state.table.internalProps._widthResizedColMap.add(state.columnResize.col)), flushCornerCustomMergeContentUpdates(pendingCornerCustomMergeRanges, state.table);
62035
62188
  }
62036
62189
  function updateResizeColForAll$1(detaX, state) {
62037
- const layout = state.table.internalProps.layoutMap;
62190
+ const layout = state.table.internalProps.layoutMap,
62191
+ pendingCornerCustomMergeRanges = new Map();
62038
62192
  for (let col = state.table.frozenColCount; col < state.table.colCount - state.table.rightFrozenColCount; col++) {
62039
62193
  if (!(state.table.internalProps.transpose || state.table.isPivotTable() && !layout.indicatorsAsCol)) {
62040
62194
  const cellDefine = layout.getBody(col, state.table.columnHeaderLevelCount);
62041
62195
  if (null == cellDefine ? void 0 : cellDefine.disableColumnResize) continue;
62042
62196
  }
62043
- state.table.scenegraph.updateColWidth(col, detaX), state.table.internalProps._widthResizedColMap.add(col);
62197
+ state.table.scenegraph.updateColWidth(col, detaX, void 0, void 0, pendingCornerCustomMergeRanges), state.table.internalProps._widthResizedColMap.add(col);
62044
62198
  }
62199
+ flushCornerCustomMergeContentUpdates(pendingCornerCustomMergeRanges, state.table);
62045
62200
  }
62046
62201
  function updateResizeColForIndicator$1(detaX, state) {
62047
62202
  const layout = state.table.internalProps.layoutMap;
@@ -62051,14 +62206,16 @@
62051
62206
  headerPath = headerPaths.colHeaderPaths[headerPaths.colHeaderPaths.length - 1];
62052
62207
  resizeDimensionKey = headerPath.dimensionKey, resizeDimensionValue = headerPath.value;
62053
62208
  }
62209
+ const pendingCornerCustomMergeRanges = new Map();
62054
62210
  for (let col = state.table.rowHeaderLevelCount; col < state.table.colCount - state.table.rightFrozenColCount; col++) {
62055
62211
  const indicatorKey = layout.getIndicatorKey(col, state.table.columnHeaderLevelCount);
62056
- if (layout.indicatorsAsCol && indicatorKey === resizeIndicatorKey) state.table.scenegraph.updateColWidth(col, detaX), state.table.internalProps._widthResizedColMap.add(col);else if (!layout.indicatorsAsCol) {
62212
+ if (layout.indicatorsAsCol && indicatorKey === resizeIndicatorKey) state.table.scenegraph.updateColWidth(col, detaX, void 0, void 0, pendingCornerCustomMergeRanges), state.table.internalProps._widthResizedColMap.add(col);else if (!layout.indicatorsAsCol) {
62057
62213
  const headerPaths = layout.getCellHeaderPaths(col, state.table.columnHeaderLevelCount - 1),
62058
62214
  headerPath = null == headerPaths ? void 0 : headerPaths.colHeaderPaths[headerPaths.colHeaderPaths.length - 1];
62059
- headerPath && resizeDimensionKey === headerPath.dimensionKey && resizeDimensionValue === headerPath.value && (state.table.scenegraph.updateColWidth(col, detaX), state.table.internalProps._widthResizedColMap.add(col));
62215
+ headerPath && resizeDimensionKey === headerPath.dimensionKey && resizeDimensionValue === headerPath.value && (state.table.scenegraph.updateColWidth(col, detaX, void 0, void 0, pendingCornerCustomMergeRanges), state.table.internalProps._widthResizedColMap.add(col));
62060
62216
  }
62061
62217
  }
62218
+ flushCornerCustomMergeContentUpdates(pendingCornerCustomMergeRanges, state.table);
62062
62219
  }
62063
62220
  function updateResizeColForIndicatorGroup$1(detaX, state) {
62064
62221
  const layout = state.table.internalProps.layoutMap,
@@ -62067,15 +62224,17 @@
62067
62224
  startCol = node.startInTotal + state.table.frozenColCount,
62068
62225
  endCol = node.startInTotal + state.table.frozenColCount + node.size - 1,
62069
62226
  totalColWidth = state.table.getColsWidth(startCol, endCol),
62070
- moveX = detaX;
62227
+ moveX = detaX,
62228
+ pendingCornerCustomMergeRanges = new Map();
62071
62229
  for (let col = startCol; col <= endCol; col++) {
62072
62230
  if (!(state.table.internalProps.transpose || state.table.isPivotTable() && !layout.indicatorsAsCol)) {
62073
62231
  const cellDefine = layout.getBody(col, state.table.columnHeaderLevelCount);
62074
62232
  if (null == cellDefine ? void 0 : cellDefine.disableColumnResize) continue;
62075
62233
  }
62076
62234
  let deltaWidth = state.table.getColWidth(col) / totalColWidth * moveX;
62077
- deltaWidth > 0 && deltaWidth < .5 ? deltaWidth = .5 : deltaWidth < 0 && deltaWidth >= -.5 && (deltaWidth = -.5), state.table.scenegraph.updateColWidth(col, deltaWidth), state.table.internalProps._widthResizedColMap.add(col);
62235
+ deltaWidth > 0 && deltaWidth < .5 ? deltaWidth = .5 : deltaWidth < 0 && deltaWidth >= -.5 && (deltaWidth = -.5), state.table.scenegraph.updateColWidth(col, deltaWidth, void 0, void 0, pendingCornerCustomMergeRanges), state.table.internalProps._widthResizedColMap.add(col);
62078
62236
  }
62237
+ flushCornerCustomMergeContentUpdates(pendingCornerCustomMergeRanges, state.table);
62079
62238
  }
62080
62239
 
62081
62240
  function setRadioState(col, row, field, type, indexInCell, state) {
@@ -62540,10 +62699,13 @@
62540
62699
  }), state.table.internalProps.title && state.table.internalProps.title.resize(), state.table.internalProps.emptyTip && state.table.internalProps.emptyTip.resize(), state.table.scenegraph.updateNextFrame();
62541
62700
  }
62542
62701
  function updateResizeColForRow(detaY, state) {
62543
- "adaptive" === state.table.heightMode && state.rowResize.row < state.table.rowCount - 1 ? (state.table.scenegraph.updateRowHeight(state.rowResize.row, detaY), state.table.scenegraph.updateRowHeight(state.rowResize.row + 1, -detaY), state.table.internalProps._heightResizedRowMap.add(state.rowResize.row), state.table.internalProps._heightResizedRowMap.add(state.rowResize.row + 1)) : (state.table.scenegraph.updateRowHeight(state.rowResize.row, detaY), state.table.internalProps._heightResizedRowMap.add(state.rowResize.row));
62702
+ const pendingCornerCustomMergeRanges = new Map();
62703
+ "adaptive" === state.table.heightMode && state.rowResize.row < state.table.rowCount - 1 ? (state.table.scenegraph.updateRowHeight(state.rowResize.row, detaY, void 0, pendingCornerCustomMergeRanges), state.table.scenegraph.updateRowHeight(state.rowResize.row + 1, -detaY, void 0, pendingCornerCustomMergeRanges), state.table.internalProps._heightResizedRowMap.add(state.rowResize.row), state.table.internalProps._heightResizedRowMap.add(state.rowResize.row + 1)) : (state.table.scenegraph.updateRowHeight(state.rowResize.row, detaY, void 0, pendingCornerCustomMergeRanges), state.table.internalProps._heightResizedRowMap.add(state.rowResize.row)), flushCornerCustomMergeContentUpdates(pendingCornerCustomMergeRanges, state.table);
62544
62704
  }
62545
62705
  function updateResizeColForAll(detaY, state) {
62546
- for (let row = state.table.frozenRowCount; row < state.table.rowCount - state.table.bottomFrozenRowCount; row++) state.table.scenegraph.updateRowHeight(row, detaY), state.table.internalProps._heightResizedRowMap.add(row);
62706
+ const pendingCornerCustomMergeRanges = new Map();
62707
+ for (let row = state.table.frozenRowCount; row < state.table.rowCount - state.table.bottomFrozenRowCount; row++) state.table.scenegraph.updateRowHeight(row, detaY, void 0, pendingCornerCustomMergeRanges), state.table.internalProps._heightResizedRowMap.add(row);
62708
+ flushCornerCustomMergeContentUpdates(pendingCornerCustomMergeRanges, state.table);
62547
62709
  }
62548
62710
  function updateResizeColForIndicator(detaY, state) {
62549
62711
  var _a, _b;
@@ -62554,16 +62716,18 @@
62554
62716
  headerPath = null === (_a = headerPaths.rowHeaderPaths) || void 0 === _a ? void 0 : _a[headerPaths.rowHeaderPaths.length - 1];
62555
62717
  resizeDimensionKey = null == headerPath ? void 0 : headerPath.dimensionKey, resizeDimensionValue = null == headerPath ? void 0 : headerPath.value;
62556
62718
  } else resizeIndicatorKey = layout.getIndicatorKey(state.table.rowHeaderLevelCount, state.rowResize.row);
62719
+ const pendingCornerCustomMergeRanges = new Map();
62557
62720
  for (let row = state.table.columnHeaderLevelCount; row < state.table.rowCount - state.table.bottomFrozenRowCount; row++) {
62558
62721
  const indicatorKey = layout.getIndicatorKey(state.table.rowHeaderLevelCount, row);
62559
62722
  if (layout.indicatorsAsCol || indicatorKey !== resizeIndicatorKey) {
62560
62723
  if (layout.indicatorsAsCol) {
62561
62724
  const headerPaths = layout.getCellHeaderPaths(state.table.rowHeaderLevelCount - 1, row),
62562
62725
  headerPath = null === (_b = null == headerPaths ? void 0 : headerPaths.rowHeaderPaths) || void 0 === _b ? void 0 : _b[headerPaths.rowHeaderPaths.length - 1];
62563
- headerPath && resizeDimensionKey === headerPath.dimensionKey && resizeDimensionValue === headerPath.value && (state.table.scenegraph.updateRowHeight(row, detaY), state.table.internalProps._heightResizedRowMap.add(row));
62726
+ headerPath && resizeDimensionKey === headerPath.dimensionKey && resizeDimensionValue === headerPath.value && (state.table.scenegraph.updateRowHeight(row, detaY, void 0, pendingCornerCustomMergeRanges), state.table.internalProps._heightResizedRowMap.add(row));
62564
62727
  }
62565
- } else state.table.scenegraph.updateRowHeight(row, detaY), state.table.internalProps._heightResizedRowMap.add(row);
62728
+ } else state.table.scenegraph.updateRowHeight(row, detaY, void 0, pendingCornerCustomMergeRanges), state.table.internalProps._heightResizedRowMap.add(row);
62566
62729
  }
62730
+ flushCornerCustomMergeContentUpdates(pendingCornerCustomMergeRanges, state.table);
62567
62731
  }
62568
62732
  function updateResizeColForIndicatorGroup(detaY, state) {
62569
62733
  const layout = state.table.internalProps.layoutMap,
@@ -62572,11 +62736,13 @@
62572
62736
  startRow = node.startInTotal + state.table.frozenRowCount,
62573
62737
  endRow = node.startInTotal + state.table.frozenRowCount + node.size - 1,
62574
62738
  totalRowHeight = state.table.getRowsHeight(startRow, endRow),
62575
- moveY = detaY;
62739
+ moveY = detaY,
62740
+ pendingCornerCustomMergeRanges = new Map();
62576
62741
  for (let row = startRow; row <= endRow; row++) {
62577
62742
  let deltaHeight = state.table.getRowHeight(row) / totalRowHeight * moveY;
62578
- deltaHeight > 0 && deltaHeight < .5 ? deltaHeight = .5 : deltaHeight < 0 && deltaHeight >= -.5 && (deltaHeight = -.51), state.table.scenegraph.updateRowHeight(row, deltaHeight), state.table.internalProps._heightResizedRowMap.add(row);
62743
+ deltaHeight > 0 && deltaHeight < .5 ? deltaHeight = .5 : deltaHeight < 0 && deltaHeight >= -.5 && (deltaHeight = -.51), state.table.scenegraph.updateRowHeight(row, deltaHeight, void 0, pendingCornerCustomMergeRanges), state.table.internalProps._heightResizedRowMap.add(row);
62579
62744
  }
62745
+ flushCornerCustomMergeContentUpdates(pendingCornerCustomMergeRanges, state.table);
62580
62746
  }
62581
62747
 
62582
62748
  function updateCustomSelectBorder(scene, selectRange, style) {
@@ -63678,6 +63844,7 @@
63678
63844
  clickToPreview: clickToPreview
63679
63845
  } = columnDefine;
63680
63846
  if (!1 === clickToPreview) return;
63847
+ if (!cellValue) return;
63681
63848
  const previewManager = getMediaPreviewManager(table),
63682
63849
  overlay = document.createElement("div");
63683
63850
  overlay.style.width = "100%", overlay.style.height = "100%", overlay.style.position = "fixed", overlay.style.top = "0", overlay.style.left = "0", overlay.style.backgroundColor = "rgba(30, 30, 30, 0.4)", overlay.style.display = "flex", overlay.style.justifyContent = "center", overlay.style.alignItems = "center", overlay.style.overflow = "hidden", overlay.style.zIndex = "9999";
@@ -63694,6 +63861,7 @@
63694
63861
  clickToPreview: clickToPreview
63695
63862
  } = columnDefine;
63696
63863
  if (!1 === clickToPreview) return;
63864
+ if (!cellValue) return;
63697
63865
  const previewManager = getMediaPreviewManager(table),
63698
63866
  overlay = document.createElement("div");
63699
63867
  overlay.style.width = "100%", overlay.style.height = "100%", overlay.style.position = "fixed", overlay.style.top = "0", overlay.style.left = "0", overlay.style.backgroundColor = "rgba(30, 30, 30, 0.4)", overlay.style.display = "flex", overlay.style.justifyContent = "center", overlay.style.alignItems = "center", overlay.style.overflow = "hidden", overlay.style.zIndex = "9999";
@@ -63709,6 +63877,7 @@
63709
63877
  clickToPreview: clickToPreview
63710
63878
  } = columnDefine;
63711
63879
  if (!1 === clickToPreview) return;
63880
+ if (!cellValue) return;
63712
63881
  const previewManager = getMediaPreviewManager(table),
63713
63882
  overlay = document.createElement("div");
63714
63883
  overlay.style.width = "100%", overlay.style.height = "100%", overlay.style.position = "fixed", overlay.style.top = "0", overlay.style.left = "0", overlay.style.backgroundColor = "rgba(30, 30, 30, 0.4)", overlay.style.display = "flex", overlay.style.justifyContent = "center", overlay.style.alignItems = "center", overlay.style.overflow = "hidden", overlay.style.zIndex = "9999";
@@ -65322,7 +65491,7 @@
65322
65491
  };
65323
65492
  let EventManager$1 = class EventManager {
65324
65493
  constructor(table) {
65325
- 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(() => {
65494
+ this.isDown = !1, this.isDraging = !1, this.globalEventListeners = [], this._enableTableScroll = !0, this.cutWaitPaste = !1, this.clipboardCheckTimer = null, this.cutOperationId = 0, this.clipboardOperationId = 0, this.pasteOperationId = 0, this.pasteWriteInProgress = !1, this.pasteWritePromise = Promise.resolve(), this.clipboardWritePromise = Promise.resolve(), this.lastCopiedClipboardData = null, this.internalFormulaHtmlMarkerId = 0, this.fieldKeyIds = new WeakMap(), this.fieldKeyId = 0, this.activeCutState = null, 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(() => {
65326
65495
  this.bindSelfEvent();
65327
65496
  }, 0));
65328
65497
  }
@@ -65543,7 +65712,7 @@
65543
65712
  }
65544
65713
  release() {
65545
65714
  var _a;
65546
- null === (_a = this.gesture) || void 0 === _a || _a.release(), this.globalEventListeners.forEach(item => {
65715
+ this.clipboardOperationId++, this.pasteOperationId++, this.resetCutState(), null === (_a = this.gesture) || void 0 === _a || _a.release(), this.globalEventListeners.forEach(item => {
65547
65716
  "document" === item.env ? document.removeEventListener(item.name, item.callback) : "body" === item.env ? document.body.removeEventListener(item.name, item.callback) : "window" === item.env ? window.removeEventListener(item.name, item.callback) : "vglobal" === item.env && vglobal.removeEventListener(item.name, item.callback);
65548
65717
  }), this.globalEventListeners = [];
65549
65718
  }
@@ -65556,289 +65725,807 @@
65556
65725
  handleCopy(e, isCut = !1) {
65557
65726
  var _a, _b, _c, _d, _e, _f;
65558
65727
  return __awaiter$1(this, void 0, void 0, function* () {
65559
- const table = this.table;
65560
- !isCut && (this.cutWaitPaste = !1), this.copySourceRange = null;
65561
- const sourceRanges = table.stateManager.select.ranges;
65562
- if (sourceRanges && 1 === sourceRanges.length) {
65563
- const sourceRange = sourceRanges[0];
65564
- this.copySourceRange = {
65565
- startCol: Math.min(sourceRange.start.col, sourceRange.end.col),
65566
- startRow: Math.min(sourceRange.start.row, sourceRange.end.row)
65567
- };
65568
- } else if (!(null == sourceRanges ? void 0 : sourceRanges.length)) return void (this.copySourceRange = null);
65728
+ const table = this.table,
65729
+ operationId = ++this.clipboardOperationId;
65730
+ this.pasteOperationId++, isCut || this.resetCutState();
65731
+ const copySnapshot = this.getCopySnapshot(isCut);
65732
+ if (this.copySourceRange = null, this.lastCopiedClipboardData = null, !copySnapshot) return this.copySourceRange = null, null;
65569
65733
  const data = this.table.getCopyValue(null === (_b = null === (_a = table.options.keyboardOptions) || void 0 === _a ? void 0 : _a.getCopyCellValue) || void 0 === _b ? void 0 : _b.value);
65570
- if (isValid$1(data)) {
65734
+ if (!isValid$1(data)) return null;
65735
+ {
65571
65736
  e.preventDefault();
65737
+ let copySucceeded = !1,
65738
+ copiedClipboardData = null;
65739
+ const canUseAsyncClipboard = window.isSecureContext && !!(null === (_c = navigator.clipboard) || void 0 === _c ? void 0 : _c.writeText),
65740
+ canWriteRichClipboard = window.isSecureContext && !!(null === (_d = navigator.clipboard) || void 0 === _d ? void 0 : _d.write) && !!window.ClipboardItem,
65741
+ hasEventClipboard = !!e.clipboardData,
65742
+ dataHTML = !canUseAsyncClipboard || canWriteRichClipboard || hasEventClipboard ? this.getCopyDataHTML(data) : null,
65743
+ formulaClipboardData = this.getCopyFormulaPlainData(data, isCut);
65744
+ if (null === formulaClipboardData) return null;
65745
+ const plainClipboardData = data,
65746
+ internalFormulaText = formulaClipboardData !== plainClipboardData ? formulaClipboardData : void 0,
65747
+ internalFormulaHtmlMarker = internalFormulaText ? this.createInternalFormulaHtmlMarker() : void 0,
65748
+ clipboardHTML = dataHTML && internalFormulaHtmlMarker ? this.attachInternalFormulaHtmlMarker(dataHTML, internalFormulaHtmlMarker) : dataHTML,
65749
+ eventClipboardWriteData = hasEventClipboard ? this.setCopyDataToEventClipboard(plainClipboardData, clipboardHTML, e, internalFormulaText, internalFormulaHtmlMarker) : null;
65750
+ if (eventClipboardWriteData) return copiedClipboardData = eventClipboardWriteData, this.lastCopiedClipboardData = copiedClipboardData, isCut && (this.lastClipboardContent = this.getClipboardSignature(copiedClipboardData), copySnapshot.clipboardData = copiedClipboardData, copySnapshot.clipboardSignature = this.lastClipboardContent), this.copySourceRange = copySnapshot.copySourceRange, this.afterCopyData(data, isCut, copySnapshot, !isCut), isCut && (null === (_e = table.keyboardOptions) || void 0 === _e ? void 0 : _e.showCopyCellBorder) && window.setTimeout(() => {
65751
+ this.isClipboardOperationCurrent(operationId) && (setActiveCellRangeState(table, copySnapshot.ranges), table.clearSelected());
65752
+ }, 0), copySnapshot;
65572
65753
  const element = table.getElement();
65573
- element && element !== document.activeElement && (element.focus(), yield new Promise(resolve => setTimeout(resolve, 10)));
65754
+ if (element && element !== document.activeElement && (element.focus(), yield new Promise(resolve => setTimeout(resolve, 10)), !this.isClipboardOperationCurrent(operationId))) return null;
65574
65755
  try {
65575
65756
  if (navigator.clipboard && navigator.clipboard.writeText) {
65576
65757
  let hasPermission = !0;
65577
65758
  if (navigator.permissions && navigator.permissions.query) try {
65578
- hasPermission = "granted" === (yield navigator.permissions.query({
65759
+ if (hasPermission = "granted" === (yield navigator.permissions.query({
65579
65760
  name: "clipboard-write"
65580
- })).state;
65761
+ })).state, !this.isClipboardOperationCurrent(operationId)) return null;
65581
65762
  } catch (permissionError) {
65582
65763
  hasPermission = !0;
65583
65764
  }
65584
65765
  if (hasPermission) try {
65585
- if (window.ClipboardItem) {
65586
- let htmlValues = data;
65587
- 1 === table.stateManager.select.ranges.length && (null === (_d = null === (_c = table.options.keyboardOptions) || void 0 === _c ? void 0 : _c.getCopyCellValue) || void 0 === _d ? void 0 : _d.html) && (htmlValues = this.table.getCopyValue(null === (_e = table.options.keyboardOptions) || void 0 === _e ? void 0 : _e.getCopyCellValue.html));
65588
- const dataHTML = setDataToHTML(htmlValues);
65589
- yield navigator.clipboard.write([new ClipboardItem({
65590
- "text/html": new Blob([dataHTML], {
65766
+ if (!this.isClipboardOperationCurrent(operationId)) return null;
65767
+ copiedClipboardData = yield this.queueClipboardWrite(() => __awaiter$1(this, void 0, void 0, function* () {
65768
+ return this.isClipboardOperationCurrent(operationId) ? canWriteRichClipboard && clipboardHTML ? (yield navigator.clipboard.write([new ClipboardItem({
65769
+ "text/html": new Blob([clipboardHTML], {
65591
65770
  type: "text/html"
65592
65771
  }),
65593
- "text/plain": new Blob([data], {
65772
+ "text/plain": new Blob([plainClipboardData], {
65594
65773
  type: "text/plain"
65595
65774
  })
65596
- })]);
65597
- } else yield navigator.clipboard.writeText(data);
65775
+ })]), {
65776
+ html: clipboardHTML,
65777
+ text: plainClipboardData,
65778
+ hasHtml: !0,
65779
+ hasText: !0,
65780
+ internalFormulaText: internalFormulaText,
65781
+ internalFormulaHtmlMarker: internalFormulaHtmlMarker
65782
+ }) : (yield navigator.clipboard.writeText(plainClipboardData), {
65783
+ html: "",
65784
+ text: plainClipboardData,
65785
+ hasText: !0,
65786
+ internalFormulaText: internalFormulaText
65787
+ }) : null;
65788
+ })), copiedClipboardData && (copySucceeded = !0);
65598
65789
  } catch (clipboardError) {
65599
- this.fallbackCopyToClipboard(data, e);
65600
- } else this.fallbackCopyToClipboard(data, e);
65601
- } else this.fallbackCopyToClipboard(data, e);
65602
- table.fireListeners(TABLE_EVENT_TYPE.COPY_DATA, {
65603
- cellRange: table.stateManager.select.ranges,
65604
- copyData: data,
65605
- isCut: isCut
65790
+ if (!this.isClipboardOperationCurrent(operationId)) return null;
65791
+ if (copySucceeded = this.fallbackCopyToClipboard(plainClipboardData), !this.isClipboardOperationCurrent(operationId)) return null;
65792
+ copySucceeded && (copiedClipboardData = {
65793
+ html: "",
65794
+ text: plainClipboardData,
65795
+ hasText: !0,
65796
+ internalFormulaText: internalFormulaText
65797
+ });
65798
+ } else copySucceeded = this.fallbackCopyToClipboard(plainClipboardData), copySucceeded && (copiedClipboardData = {
65799
+ html: "",
65800
+ text: plainClipboardData,
65801
+ hasText: !0,
65802
+ internalFormulaText: internalFormulaText
65803
+ });
65804
+ } else copySucceeded = this.fallbackCopyToClipboard(plainClipboardData), copySucceeded && (copiedClipboardData = {
65805
+ html: "",
65806
+ text: plainClipboardData,
65807
+ hasText: !0,
65808
+ internalFormulaText: internalFormulaText
65606
65809
  });
65810
+ if (!copySucceeded) return null;
65811
+ if (!this.isClipboardOperationCurrent(operationId)) return null;
65812
+ this.lastCopiedClipboardData = copiedClipboardData, isCut && (this.lastClipboardContent = this.getClipboardSignature(copiedClipboardData), copySnapshot.clipboardData = copiedClipboardData, copySnapshot.clipboardSignature = this.lastClipboardContent), this.copySourceRange = copySnapshot.copySourceRange, this.afterCopyData(data, isCut, copySnapshot, !1);
65607
65813
  } catch (error) {
65608
- this.fallbackCopyToClipboard(data, e);
65814
+ if (!this.isClipboardOperationCurrent(operationId)) return null;
65815
+ if (!this.fallbackCopyToClipboard(plainClipboardData)) return null;
65816
+ if (!this.isClipboardOperationCurrent(operationId)) return null;
65817
+ this.lastCopiedClipboardData = {
65818
+ html: "",
65819
+ text: plainClipboardData,
65820
+ hasText: !0,
65821
+ internalFormulaText: internalFormulaText
65822
+ }, isCut && (this.lastClipboardContent = this.getClipboardSignature(this.lastCopiedClipboardData), copySnapshot.clipboardData = this.lastCopiedClipboardData, copySnapshot.clipboardSignature = this.lastClipboardContent), this.copySourceRange = copySnapshot.copySourceRange, this.afterCopyData(data, isCut, copySnapshot, !1);
65823
+ }
65824
+ }
65825
+ return (null === (_f = table.keyboardOptions) || void 0 === _f ? void 0 : _f.showCopyCellBorder) && (setActiveCellRangeState(table, copySnapshot.ranges), table.clearSelected()), copySnapshot;
65826
+ });
65827
+ }
65828
+ afterCopyData(data, isCut, copySnapshot, updateCopyCellBorder = !0) {
65829
+ var _a;
65830
+ const table = this.table;
65831
+ try {
65832
+ table.fireListeners(TABLE_EVENT_TYPE.COPY_DATA, {
65833
+ cellRange: this.cloneRanges(copySnapshot.ranges),
65834
+ copyData: data,
65835
+ isCut: isCut
65836
+ });
65837
+ } catch (error) {}
65838
+ updateCopyCellBorder && (null === (_a = table.keyboardOptions) || void 0 === _a ? void 0 : _a.showCopyCellBorder) && (setActiveCellRangeState(table, copySnapshot.ranges), table.clearSelected());
65839
+ }
65840
+ getCopySnapshot(includeCellInfos) {
65841
+ const ranges = this.table.stateManager.select.ranges;
65842
+ if (!(null == ranges ? void 0 : ranges.length)) return null;
65843
+ const clonedRanges = ranges.map(range => ({
65844
+ start: {
65845
+ col: range.start.col,
65846
+ row: range.start.row
65847
+ },
65848
+ end: {
65849
+ col: range.end.col,
65850
+ row: range.end.row
65609
65851
  }
65852
+ })),
65853
+ sourceRange = 1 === ranges.length ? ranges[0] : null,
65854
+ sourceCellMatrix = this.getSourceCellMatrix(clonedRanges),
65855
+ sourceCells = this.getSourceCells(sourceCellMatrix),
65856
+ sourceSize = this.getSourceSize(clonedRanges, sourceCellMatrix);
65857
+ return {
65858
+ ranges: clonedRanges,
65859
+ copySourceRange: sourceRange ? {
65860
+ startCol: Math.min(sourceRange.start.col, sourceRange.end.col),
65861
+ startRow: Math.min(sourceRange.start.row, sourceRange.end.row)
65862
+ } : null,
65863
+ cellInfos: includeCellInfos ? this.table.getSelectedCellInfos() : null,
65864
+ sourceCells: sourceCells,
65865
+ sourceCellMatrix: sourceCellMatrix,
65866
+ sourceColCount: sourceSize.colCount,
65867
+ sourceRowCount: sourceSize.rowCount,
65868
+ clipboardData: null,
65869
+ clipboardSignature: ""
65870
+ };
65871
+ }
65872
+ cloneRanges(ranges) {
65873
+ return ranges.map(range => ({
65874
+ start: {
65875
+ col: range.start.col,
65876
+ row: range.start.row
65877
+ },
65878
+ end: {
65879
+ col: range.end.col,
65880
+ row: range.end.row
65881
+ }
65882
+ }));
65883
+ }
65884
+ getSourceCellMatrix(ranges) {
65885
+ const table = this.table,
65886
+ createSourceCell = (col, row) => {
65887
+ var _a, _b, _c, _d, _e, _f, _g, _h;
65888
+ const recordShowIndex = null === (_a = table.getRecordShowIndexByCell) || void 0 === _a ? void 0 : _a.call(table, col, row);
65889
+ return {
65890
+ col: col,
65891
+ row: row,
65892
+ recordIndex: recordShowIndex >= 0 ? null === (_c = null === (_b = table.dataSource) || void 0 === _b ? void 0 : _b.getIndexKey) || void 0 === _c ? void 0 : _c.call(_b, recordShowIndex) : void 0,
65893
+ field: null === (_g = null === (_f = null === (_e = null === (_d = table.internalProps) || void 0 === _d ? void 0 : _d.layoutMap) || void 0 === _e ? void 0 : _e.getBody) || void 0 === _f ? void 0 : _f.call(_e, col, row)) || void 0 === _g ? void 0 : _g.field,
65894
+ value: null === (_h = table.getCellOriginValue) || void 0 === _h ? void 0 : _h.call(table, col, row)
65895
+ };
65896
+ };
65897
+ if (1 === ranges.length) {
65898
+ const range = ranges[0],
65899
+ startCol = Math.min(range.start.col, range.end.col),
65900
+ endCol = Math.max(range.start.col, range.end.col),
65901
+ startRow = Math.min(range.start.row, range.end.row),
65902
+ endRow = Math.max(range.start.row, range.end.row),
65903
+ sourceCellMatrix = [];
65904
+ for (let row = startRow; row <= endRow; row++) {
65905
+ const rowCells = [];
65906
+ for (let col = startCol; col <= endCol; col++) rowCells.push(createSourceCell(col, row));
65907
+ sourceCellMatrix.push(rowCells);
65908
+ }
65909
+ return sourceCellMatrix;
65910
+ }
65911
+ let minCol = Math.min(ranges[0].start.col, ranges[0].end.col),
65912
+ maxCol = Math.max(ranges[0].start.col, ranges[0].end.col),
65913
+ minRow = Math.min(ranges[0].start.row, ranges[0].end.row),
65914
+ maxRow = Math.max(ranges[0].start.row, ranges[0].end.row);
65915
+ ranges.forEach(range => {
65916
+ minCol = Math.min(minCol, range.start.col, range.end.col), maxCol = Math.max(maxCol, range.start.col, range.end.col), minRow = Math.min(minRow, range.start.row, range.end.row), maxRow = Math.max(maxRow, range.start.row, range.end.row);
65917
+ });
65918
+ const isExistDataInRow = row => ranges.some(range => {
65919
+ const startRow = Math.min(range.start.row, range.end.row),
65920
+ endRow = Math.max(range.start.row, range.end.row);
65921
+ return startRow <= row && endRow >= row;
65922
+ }),
65923
+ isExistDataInCol = col => ranges.some(range => {
65924
+ const startCol = Math.min(range.start.col, range.end.col),
65925
+ endCol = Math.max(range.start.col, range.end.col);
65926
+ return startCol <= col && endCol >= col;
65927
+ }),
65928
+ getRangeExistDataInCell = (col, row) => ranges.some(range => {
65929
+ const startRow = Math.min(range.start.row, range.end.row),
65930
+ endRow = Math.max(range.start.row, range.end.row),
65931
+ startCol = Math.min(range.start.col, range.end.col),
65932
+ endCol = Math.max(range.start.col, range.end.col);
65933
+ return startCol <= col && endCol >= col && startRow <= row && endRow >= row;
65934
+ }),
65935
+ sourceCellMatrix = [];
65936
+ for (let row = minRow; row <= maxRow; row++) {
65937
+ if (!isExistDataInRow(row)) continue;
65938
+ const rowCells = [];
65939
+ for (let col = minCol; col <= maxCol; col++) isExistDataInCol(col) && rowCells.push(getRangeExistDataInCell(col, row) ? createSourceCell(col, row) : null);
65940
+ sourceCellMatrix.push(rowCells);
65941
+ }
65942
+ return sourceCellMatrix;
65943
+ }
65944
+ getSourceCells(sourceCellMatrix) {
65945
+ const sourceCells = [];
65946
+ for (let row = 0; row < sourceCellMatrix.length; row++) for (let col = 0; col < sourceCellMatrix[row].length; col++) {
65947
+ const sourceCell = sourceCellMatrix[row][col];
65948
+ sourceCell && sourceCells.push(sourceCell);
65949
+ }
65950
+ return sourceCells;
65951
+ }
65952
+ getSourceSize(ranges, sourceCellMatrix) {
65953
+ var _a, _b;
65954
+ if (sourceCellMatrix.length) return {
65955
+ colCount: null !== (_b = null === (_a = sourceCellMatrix[0]) || void 0 === _a ? void 0 : _a.length) && void 0 !== _b ? _b : 0,
65956
+ rowCount: sourceCellMatrix.length
65957
+ };
65958
+ if (1 === ranges.length) {
65959
+ const range = ranges[0];
65960
+ return {
65961
+ colCount: Math.abs(range.end.col - range.start.col) + 1,
65962
+ rowCount: Math.abs(range.end.row - range.start.row) + 1
65963
+ };
65964
+ }
65965
+ return {
65966
+ colCount: 0,
65967
+ rowCount: 0
65968
+ };
65969
+ }
65970
+ getClipboardSignature(data) {
65971
+ return data ? JSON.stringify({
65972
+ html: data.hasHtml ? data.html : null,
65973
+ text: data.hasText ? data.text : null
65974
+ }) : "";
65975
+ }
65976
+ isClipboardOperationCurrent(operationId) {
65977
+ return operationId === this.clipboardOperationId && !this.table.isReleased;
65978
+ }
65979
+ isPasteOperationCurrent(operationId) {
65980
+ return (void 0 === operationId || operationId === this.pasteOperationId) && !this.table.isReleased;
65981
+ }
65982
+ queueClipboardWrite(write) {
65983
+ return __awaiter$1(this, void 0, void 0, function* () {
65984
+ const previousWrite = this.clipboardWritePromise;
65985
+ let settleCurrentWrite = () => {};
65986
+ this.clipboardWritePromise = previousWrite.catch(() => {}).then(() => new Promise(resolve => {
65987
+ settleCurrentWrite = resolve;
65988
+ })), yield previousWrite.catch(() => {});
65989
+ try {
65990
+ return yield write();
65991
+ } finally {
65992
+ settleCurrentWrite();
65610
65993
  }
65611
- (null === (_f = table.keyboardOptions) || void 0 === _f ? void 0 : _f.showCopyCellBorder) && (setActiveCellRangeState(table), table.clearSelected());
65612
65994
  });
65613
65995
  }
65614
- fallbackCopyToClipboard(data, e) {
65996
+ isClipboardDataChanged(clipboardData, cutState) {
65997
+ if (!clipboardData || clipboardData.readFailed) return null;
65998
+ const sourceData = cutState.clipboardData;
65999
+ if (!sourceData) return this.getClipboardSignature(clipboardData) !== cutState.clipboardSignature;
66000
+ if (sourceData.hasHtml && !clipboardData.hasHtml) return null;
66001
+ if (sourceData.hasText && !clipboardData.hasText) return null;
66002
+ let hasComparableType = !1;
66003
+ return !(!clipboardData.hasHtml || !sourceData.hasHtml || (hasComparableType = !0, clipboardData.html === sourceData.html)) || !(!clipboardData.hasText || !sourceData.hasText || (hasComparableType = !0, clipboardData.text === sourceData.text)) || !hasComparableType && null;
66004
+ }
66005
+ isClipboardDataSameAsLastCopy(clipboardData) {
66006
+ const sourceData = this.lastCopiedClipboardData;
66007
+ return !(!clipboardData || clipboardData.readFailed || !sourceData) && this.isClipboardDataSameBySignature(clipboardData, sourceData);
66008
+ }
66009
+ isClipboardDataSameBySignature(clipboardData, sourceData) {
66010
+ return !(sourceData.hasHtml !== clipboardData.hasHtml || sourceData.hasText !== clipboardData.hasText || sourceData.hasHtml && sourceData.html !== clipboardData.html || sourceData.hasText && sourceData.text !== clipboardData.text);
66011
+ }
66012
+ getCopyFormulaPlainData(data, isCut) {
66013
+ var _a, _b;
66014
+ const table = this.table;
66015
+ if (1 !== table.stateManager.select.ranges.length || !(null === (_b = null === (_a = table.options.keyboardOptions) || void 0 === _a ? void 0 : _a.getCopyCellValue) || void 0 === _b ? void 0 : _b.html)) return data;
66016
+ try {
66017
+ return this.table.getCopyValue(table.options.keyboardOptions.getCopyCellValue.html);
66018
+ } catch (error) {
66019
+ return isCut ? null : data;
66020
+ }
66021
+ }
66022
+ getCopyDataHTML(data) {
66023
+ var _a, _b, _c;
66024
+ const table = this.table;
66025
+ let htmlValues = data;
66026
+ try {
66027
+ return 1 === table.stateManager.select.ranges.length && (null === (_b = null === (_a = table.options.keyboardOptions) || void 0 === _a ? void 0 : _a.getCopyCellValue) || void 0 === _b ? void 0 : _b.html) && (htmlValues = this.table.getCopyValue(null === (_c = table.options.keyboardOptions) || void 0 === _c ? void 0 : _c.getCopyCellValue.html)), setDataToHTML(htmlValues);
66028
+ } catch (error) {
66029
+ try {
66030
+ return setDataToHTML(data);
66031
+ } catch (fallbackError) {
66032
+ return null;
66033
+ }
66034
+ }
66035
+ }
66036
+ createInternalFormulaHtmlMarker() {
66037
+ return `vtable-formula-${Date.now()}-${++this.internalFormulaHtmlMarkerId}`;
66038
+ }
66039
+ attachInternalFormulaHtmlMarker(html, marker) {
66040
+ return `${html}\x3c!--${marker}--\x3e`;
66041
+ }
66042
+ setCopyDataToEventClipboard(data, dataHTML, e, internalFormulaText, internalFormulaHtmlMarker) {
66043
+ const clipboardData = e.clipboardData;
66044
+ if (!clipboardData) return null;
66045
+ try {
66046
+ clipboardData.setData("text/plain", data);
66047
+ const copiedClipboardData = {
66048
+ html: "",
66049
+ text: data,
66050
+ hasText: !0,
66051
+ internalFormulaText: internalFormulaText
66052
+ };
66053
+ if (dataHTML) try {
66054
+ clipboardData.setData("text/html", dataHTML), copiedClipboardData.html = dataHTML, copiedClipboardData.hasHtml = !0, copiedClipboardData.internalFormulaHtmlMarker = internalFormulaHtmlMarker;
66055
+ } catch (error) {}
66056
+ return copiedClipboardData;
66057
+ } catch (error) {
66058
+ return null;
66059
+ }
66060
+ }
66061
+ fallbackCopyToClipboard(data) {
65615
66062
  try {
65616
- if (e.clipboardData) return void e.clipboardData.setData("text/plain", data);
65617
66063
  document.activeElement && document.activeElement !== document.body && document.activeElement.blur();
65618
66064
  const textArea = document.createElement("textarea");
65619
66065
  textArea.value = data, textArea.style.position = "fixed", textArea.style.left = "-999999px", textArea.style.top = "-999999px", textArea.style.opacity = "0", textArea.setAttribute("readonly", ""), textArea.setAttribute("aria-hidden", "true"), document.body.appendChild(textArea), textArea.focus(), textArea.select(), textArea.setSelectionRange(0, data.length);
65620
66066
  try {
65621
- document.execCommand("copy");
66067
+ const successful = document.execCommand("copy");
66068
+ return successful;
65622
66069
  } catch (execError) {} finally {
65623
66070
  document.body.removeChild(textArea);
65624
66071
  }
65625
66072
  } catch (error) {}
66073
+ return !1;
65626
66074
  }
65627
66075
  handleCut(e) {
65628
- var _a;
65629
66076
  return __awaiter$1(this, void 0, void 0, function* () {
65630
- 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 => ({
65631
- start: {
65632
- col: r.start.col,
65633
- row: r.start.row
65634
- },
65635
- end: {
65636
- col: r.end.col,
65637
- row: r.end.row
65638
- }
65639
- })), this.clipboardCheckTimer && clearTimeout(this.clipboardCheckTimer), this.clipboardCheckTimer = window.setTimeout(() => {
65640
- this.cutWaitPaste && (this.cutWaitPaste = !1, this.cutCellRange = null, this.cutRanges = null, this.clipboardCheckTimer = null);
65641
- }, 3e4), this.saveClipboardContent();
66077
+ const copySnapshot = yield this.handleCopy(e, !0);
66078
+ if (!copySnapshot) return;
66079
+ const cutState = {
66080
+ id: ++this.cutOperationId,
66081
+ ranges: this.cloneRanges(copySnapshot.ranges),
66082
+ cellInfos: copySnapshot.cellInfos,
66083
+ sourceCells: copySnapshot.sourceCells,
66084
+ sourceCellMatrix: copySnapshot.sourceCellMatrix,
66085
+ sourceColCount: copySnapshot.sourceColCount,
66086
+ sourceRowCount: copySnapshot.sourceRowCount,
66087
+ clipboardData: copySnapshot.clipboardData,
66088
+ clipboardSignature: copySnapshot.clipboardSignature,
66089
+ copySourceRange: copySnapshot.copySourceRange,
66090
+ isSingleRange: 1 === copySnapshot.ranges.length
66091
+ };
66092
+ this.cutWaitPaste = !0, this.activeCutState = cutState, this.cutCellRange = cutState.cellInfos, this.cutRanges = cutState.ranges, this.clipboardCheckTimer && clearTimeout(this.clipboardCheckTimer), this.clipboardCheckTimer = window.setTimeout(() => {
66093
+ this.cutWaitPaste && this.resetCutState();
66094
+ }, 3e4), this.lastClipboardContent = cutState.clipboardSignature;
65642
66095
  });
65643
66096
  }
65644
66097
  handlePaste(e) {
65645
- this.cutWaitPaste ? this.checkClipboardChanged().then(changed => {
65646
- 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));
65647
- }).catch(() => {
65648
- this.executePaste(e), this.cutWaitPaste && (this.cutWaitPaste = !1, this.cutCellRange = null, this.clipboardCheckTimer && (clearTimeout(this.clipboardCheckTimer), this.clipboardCheckTimer = null));
65649
- }) : this.executePaste(e);
66098
+ const pasteOperationId = ++this.pasteOperationId,
66099
+ pasteRange = this.getPasteRange();
66100
+ if (!pasteRange) return;
66101
+ const eventClipboardData = this.getEventClipboardData(e),
66102
+ pasteCopySourceRange = this.copySourceRange;
66103
+ if (!this.cutWaitPaste) return void this.readClipboardDataForPaste(eventClipboardData).then(clipboardData => {
66104
+ if (!this.isPasteOperationCurrent(pasteOperationId)) return;
66105
+ const copySourceRange = this.isClipboardDataSameAsLastCopy(clipboardData) ? pasteCopySourceRange : null;
66106
+ this.executePaste(clipboardData, {
66107
+ pasteRange: pasteRange,
66108
+ copySourceRange: copySourceRange,
66109
+ pasteOperationId: pasteOperationId
66110
+ });
66111
+ }).catch(error => {});
66112
+ const cutState = this.activeCutState;
66113
+ cutState ? this.readClipboardDataForPaste(eventClipboardData).then(clipboardData => __awaiter$1(this, void 0, void 0, function* () {
66114
+ var _a, _b, _c, _d, _e;
66115
+ if (!this.isPasteOperationCurrent(pasteOperationId) || (null === (_a = this.activeCutState) || void 0 === _a ? void 0 : _a.id) !== cutState.id) return;
66116
+ const changed = this.isClipboardDataChanged(clipboardData, cutState);
66117
+ if (null === changed) return void (yield this.executePaste(clipboardData, {
66118
+ pasteRange: pasteRange,
66119
+ copySourceRange: this.isClipboardDataSameAsLastCopy(clipboardData) ? pasteCopySourceRange : null,
66120
+ pasteOperationId: pasteOperationId
66121
+ }));
66122
+ const pasteResult = yield this.executePaste(clipboardData, {
66123
+ pasteRange: pasteRange,
66124
+ copySourceRange: changed ? null : cutState.copySourceRange,
66125
+ cutState: changed ? null : cutState,
66126
+ pasteOperationId: pasteOperationId
66127
+ });
66128
+ if (this.isPasteOperationCurrent(pasteOperationId) && (null === (_b = this.activeCutState) || void 0 === _b ? void 0 : _b.id) === cutState.id) if (changed || !pasteResult.pasted || (null === (_c = this.activeCutState) || void 0 === _c ? void 0 : _c.id) !== cutState.id) changed && (null === (_e = this.activeCutState) || void 0 === _e ? void 0 : _e.id) === cutState.id && this.resetCutState();else if (pasteResult.migratedSourceCells.length === cutState.sourceCells.length) {
66129
+ if (!(yield this.clearCutArea(pasteResult.migratedSourceCells, pasteResult.changedCells))) return void this.resetCutState();
66130
+ (null === (_d = this.activeCutState) || void 0 === _d ? void 0 : _d.id) === cutState.id && this.resetCutState();
66131
+ }
66132
+ })).catch(() => __awaiter$1(this, void 0, void 0, function* () {
66133
+ this.isPasteOperationCurrent(pasteOperationId) && (yield this.executePaste(eventClipboardData, {
66134
+ pasteRange: pasteRange,
66135
+ copySourceRange: this.isClipboardDataSameAsLastCopy(eventClipboardData) ? pasteCopySourceRange : null,
66136
+ pasteOperationId: pasteOperationId
66137
+ }));
66138
+ })) : this.executePaste(eventClipboardData, {
66139
+ pasteRange: pasteRange,
66140
+ copySourceRange: this.isClipboardDataSameAsLastCopy(eventClipboardData) ? pasteCopySourceRange : null,
66141
+ pasteOperationId: pasteOperationId
66142
+ });
65650
66143
  }
65651
- executePaste(e) {
65652
- var _a, _b, _c;
66144
+ executePaste(clipboardData, pasteContext) {
66145
+ var _a, _b, _c, _d;
65653
66146
  return __awaiter$1(this, void 0, void 0, function* () {
65654
- const table = this.table;
65655
- if (!(null === (_a = table.editorManager) || void 0 === _a ? void 0 : _a.editingEditor)) {
65656
- if (table.changeCellValues && (null === (_b = table.stateManager.select.ranges) || void 0 === _b ? void 0 : _b.length) > 0) try {
65657
- if (navigator.clipboard && navigator.clipboard.read) try {
65658
- const clipboardItems = yield navigator.clipboard.read();
65659
- let handled = !1;
65660
- for (const item of clipboardItems) {
65661
- if (item.types.includes("text/html")) {
65662
- yield this.pasteHtmlToTable(item), handled = !0;
65663
- break;
65664
- }
65665
- if (item.types.includes("text/plain")) {
65666
- yield this.pasteTextToTable(item), handled = !0;
65667
- break;
65668
- }
65669
- }
65670
- handled || (yield this.fallbackPasteFromClipboard(e));
65671
- } catch (clipboardError) {
65672
- yield this.fallbackPasteFromClipboard(e);
65673
- } else yield this.fallbackPasteFromClipboard(e);
66147
+ const table = this.table,
66148
+ emptyResult = this.getEmptyPasteResult(),
66149
+ pasteClipboardData = this.getPasteClipboardData(clipboardData, pasteContext);
66150
+ if (!this.isPasteOperationCurrent(pasteContext.pasteOperationId) || (null === (_a = table.editorManager) || void 0 === _a ? void 0 : _a.editingEditor)) return emptyResult;
66151
+ if (this.pasteWriteInProgress && (yield this.pasteWritePromise.catch(() => {}), !this.isPasteOperationCurrent(pasteContext.pasteOperationId) || (null === (_b = table.editorManager) || void 0 === _b ? void 0 : _b.editingEditor))) return emptyResult;
66152
+ let pasteResult = emptyResult,
66153
+ settlePasteWrite = () => {};
66154
+ this.pasteWritePromise = new Promise(resolve => {
66155
+ settlePasteWrite = resolve;
66156
+ }), this.pasteWriteInProgress = !0;
66157
+ try {
66158
+ if (table.changeCellValues) try {
66159
+ if (null == pasteClipboardData ? void 0 : pasteClipboardData.html) try {
66160
+ const htmlResult = yield this.processPastedHTML(pasteClipboardData.html, pasteContext);
66161
+ if (htmlResult.pasted) return pasteResult = htmlResult, pasteResult;
66162
+ } catch (error) {
66163
+ if (/<table\b/i.test(pasteClipboardData.html)) return emptyResult;
66164
+ }
66165
+ if ((null == pasteClipboardData ? void 0 : pasteClipboardData.hasText) || (null == pasteClipboardData ? void 0 : pasteClipboardData.text)) return pasteResult = yield this.processPastedText(null !== (_c = pasteClipboardData.internalFormulaText) && void 0 !== _c ? _c : pasteClipboardData.text, pasteContext), pasteResult;
65674
66166
  } catch (error) {
65675
- yield this.fallbackPasteFromClipboard(e);
66167
+ pasteContext.cutState && this.resetCutState();
65676
66168
  }
65677
- (null === (_c = table.keyboardOptions) || void 0 === _c ? void 0 : _c.showCopyCellBorder) && clearActiveCellRangeState(table);
66169
+ return pasteResult;
66170
+ } finally {
66171
+ this.pasteWriteInProgress = !1, settlePasteWrite(), !pasteContext.cutState && (null === (_d = table.keyboardOptions) || void 0 === _d ? void 0 : _d.showCopyCellBorder) && clearActiveCellRangeState(table);
65678
66172
  }
65679
66173
  });
65680
66174
  }
65681
- fallbackPasteFromClipboard(e) {
66175
+ getPasteClipboardData(clipboardData, pasteContext) {
66176
+ var _a, _b;
66177
+ if (!clipboardData || !pasteContext.copySourceRange) return clipboardData;
66178
+ const sourceData = null !== (_b = null === (_a = pasteContext.cutState) || void 0 === _a ? void 0 : _a.clipboardData) && void 0 !== _b ? _b : this.lastCopiedClipboardData;
66179
+ return (null == sourceData ? void 0 : sourceData.internalFormulaText) && sourceData.internalFormulaHtmlMarker && sourceData.hasHtml && clipboardData.hasHtml && this.isClipboardDataSameBySignature(clipboardData, sourceData) && clipboardData.html.includes(sourceData.internalFormulaHtmlMarker) ? Object.assign(Object.assign({}, clipboardData), {
66180
+ internalFormulaText: sourceData.internalFormulaText
66181
+ }) : clipboardData;
66182
+ }
66183
+ getPasteRange() {
66184
+ const ranges = this.table.stateManager.select.ranges;
66185
+ if (!(null == ranges ? void 0 : ranges.length)) return null;
66186
+ const range = ranges[ranges.length - 1];
66187
+ return {
66188
+ col: Math.min(range.start.col, range.end.col),
66189
+ row: Math.min(range.start.row, range.end.row),
66190
+ maxCol: Math.max(range.start.col, range.end.col),
66191
+ maxRow: Math.max(range.start.row, range.end.row)
66192
+ };
66193
+ }
66194
+ getEventClipboardData(e) {
66195
+ var _a;
66196
+ const clipboardData = e.clipboardData || window.clipboardData;
66197
+ if (!clipboardData) return null;
66198
+ try {
66199
+ const types = Array.from(null !== (_a = clipboardData.types) && void 0 !== _a ? _a : []),
66200
+ html = clipboardData.getData("text/html") || "",
66201
+ text = clipboardData.getData("text/plain") || clipboardData.getData("text") || clipboardData.getData("Text") || "",
66202
+ hasHtml = types.includes("text/html") || !!html;
66203
+ return {
66204
+ html: html,
66205
+ text: text,
66206
+ hasHtml: hasHtml,
66207
+ hasText: types.includes("text/plain") || types.includes("text") || types.includes("Text") || !!text
66208
+ };
66209
+ } catch (error) {
66210
+ return {
66211
+ html: "",
66212
+ text: "",
66213
+ readFailed: !0
66214
+ };
66215
+ }
66216
+ }
66217
+ readClipboardDataForPaste(eventClipboardData) {
66218
+ var _a, _b;
65682
66219
  return __awaiter$1(this, void 0, void 0, function* () {
65683
- const table = this.table,
65684
- ranges = table.stateManager.select.ranges,
65685
- col = Math.min(ranges[0].start.col, ranges[0].end.col),
65686
- row = Math.min(ranges[0].start.row, ranges[0].end.row);
65687
- try {
65688
- const element = table.getElement();
65689
- element && element !== document.activeElement && (element.focus(), yield new Promise(resolve => setTimeout(resolve, 10)));
65690
- const clipboardData = e.clipboardData || window.clipboardData || window.Clipboard;
65691
- if (clipboardData) {
65692
- const pastedData = clipboardData.getData("text") || clipboardData.getData("Text");
65693
- if (pastedData) return void (yield this.processPastedText(pastedData, col, row));
65694
- }
66220
+ if ((null == eventClipboardData ? void 0 : eventClipboardData.readFailed) || (null == eventClipboardData ? void 0 : eventClipboardData.hasHtml) || (null == eventClipboardData ? void 0 : eventClipboardData.hasText)) return eventClipboardData;
66221
+ if (null === (_a = navigator.clipboard) || void 0 === _a ? void 0 : _a.read) try {
66222
+ const clipboardItems = yield navigator.clipboard.read(),
66223
+ clipboardData = {
66224
+ html: "",
66225
+ text: ""
66226
+ };
66227
+ for (const item of clipboardItems) {
66228
+ if (!clipboardData.html && item.types.includes("text/html")) try {
66229
+ clipboardData.html = yield (yield item.getType("text/html")).text(), clipboardData.hasHtml = !0;
66230
+ } catch (error) {}
66231
+ if (!clipboardData.text && item.types.includes("text/plain")) try {
66232
+ clipboardData.text = yield (yield item.getType("text/plain")).text(), clipboardData.hasText = !0;
66233
+ } catch (error) {}
66234
+ }
66235
+ if (clipboardData.hasHtml || clipboardData.hasText) return clipboardData;
66236
+ } catch (error) {}
66237
+ if (null === (_b = navigator.clipboard) || void 0 === _b ? void 0 : _b.readText) try {
66238
+ return {
66239
+ html: "",
66240
+ text: yield navigator.clipboard.readText(),
66241
+ hasText: !0
66242
+ };
65695
66243
  } catch (error) {}
66244
+ return null != eventClipboardData ? eventClipboardData : {
66245
+ html: "",
66246
+ text: "",
66247
+ readFailed: !0
66248
+ };
65696
66249
  });
65697
66250
  }
65698
- processPastedText(pastedData, col, row) {
66251
+ decodeHTMLCellValue(cellHTML) {
65699
66252
  var _a;
66253
+ const template = document.createElement("template");
66254
+ return template.innerHTML = cellHTML.replace(/<br\b[^>]*>(?:\r\n|\r|\n)?/gim, "\n").replace(/&nbsp;/gi, " "), null !== (_a = template.content.textContent) && void 0 !== _a ? _a : "";
66255
+ }
66256
+ processPastedHTML(pastedData, pasteContext) {
66257
+ var _a, _b, _c;
65700
66258
  return __awaiter$1(this, void 0, void 0, function* () {
65701
- const table = this.table,
65702
- rows = pastedData.split("\n"),
66259
+ const cellRegex = /<t[dh][^>]*>([\s\S]*?)<\/t[dh]>/gi,
66260
+ table = this.table,
66261
+ pasteRange = pasteContext.pasteRange,
66262
+ {
66263
+ col: col,
66264
+ row: row,
66265
+ maxCol: maxCol,
66266
+ maxRow: maxRow
66267
+ } = pasteRange;
66268
+ let pasteValuesColCount = 0,
66269
+ pasteValuesRowCount = 0,
65703
66270
  values = [];
66271
+ if (!pastedData || !/<table\b/i.test(pastedData)) return this.getEmptyPasteResult();
66272
+ const matches = Array.from(pastedData.matchAll(/<tr[^>]*>([\s\S]*?)<\/tr>/gi));
66273
+ for (const match of matches) {
66274
+ const rowContent = match[1],
66275
+ cellMatches = Array.from(rowContent.matchAll(cellRegex));
66276
+ if (!cellMatches.length) continue;
66277
+ const rowValues = cellMatches.map(cellMatch => this.decodeHTMLCellValue(cellMatch[1]));
66278
+ values.push(rowValues), pasteValuesColCount = Math.max(pasteValuesColCount, null !== (_a = null == rowValues ? void 0 : rowValues.length) && void 0 !== _a ? _a : 0);
66279
+ }
66280
+ if (pasteValuesRowCount = null !== (_b = values.length) && void 0 !== _b ? _b : 0, !pasteValuesRowCount || !pasteValuesColCount) return this.getEmptyPasteResult();
65704
66281
  let processedValues;
65705
- rows.forEach(function (rowCells) {
65706
- const cells = rowCells.split("\t"),
65707
- rowValues = [];
65708
- values.push(rowValues), cells.forEach(function (cell, cellIndex) {
65709
- cellIndex === cells.length - 1 && (cell = cell.trim()), rowValues.push(cell);
65710
- });
65711
- }), (null === (_a = table.options.keyboardOptions) || void 0 === _a ? void 0 : _a.processFormulaBeforePaste) && this.copySourceRange && (processedValues = table.options.keyboardOptions.processFormulaBeforePaste(values, this.copySourceRange.startCol, this.copySourceRange.startRow, col, row));
65712
- const changedCellResults = yield table.changeCellValues(col, row, processedValues || values, !0);
65713
- table.hasListeners(TABLE_EVENT_TYPE.PASTED_DATA) && table.fireListeners(TABLE_EVENT_TYPE.PASTED_DATA, {
66282
+ values = this.handlePasteValues(values, pasteValuesRowCount, pasteValuesColCount, maxRow - row + 1, maxCol - col + 1), (null === (_c = table.options.keyboardOptions) || void 0 === _c ? void 0 : _c.processFormulaBeforePaste) && pasteContext.copySourceRange && (processedValues = table.options.keyboardOptions.processFormulaBeforePaste(values, pasteContext.copySourceRange.startCol, pasteContext.copySourceRange.startRow, col, row));
66283
+ const valuesToPaste = processedValues || values,
66284
+ targetCells = this.getPasteTargetCells(pasteRange, valuesToPaste);
66285
+ if (!this.isPasteOperationCurrent(pasteContext.pasteOperationId)) return this.getEmptyPasteResult();
66286
+ if (pasteContext.cutState) {
66287
+ const validatedCellResults = yield this.validatePasteTargetCells(pasteRange, valuesToPaste);
66288
+ if (!this.isPasteOperationCurrent(pasteContext.pasteOperationId)) return this.getEmptyPasteResult();
66289
+ if (!this.isFullPasteAllowed(valuesToPaste, validatedCellResults)) return this.getEmptyPasteResult(validatedCellResults);
66290
+ }
66291
+ const rawChangedCellResults = yield table.changeCellValues(col, row, valuesToPaste, !pasteContext.cutState, !0, void 0, () => !this.isPasteOperationCurrent(pasteContext.pasteOperationId));
66292
+ if (!this.isPasteOperationCurrent(pasteContext.pasteOperationId)) return this.getEmptyPasteResult();
66293
+ const changedCellResults = this.normalizeChangedCellResults(rawChangedCellResults, pasteRange, valuesToPaste),
66294
+ changedCells = this.getChangedCells(targetCells, changedCellResults),
66295
+ migratedSourceCells = this.getMigratedSourceCells(pasteContext.cutState, changedCellResults);
66296
+ return changedCells.length ? (this.firePastedDataEvent(col, row, valuesToPaste, changedCellResults), {
66297
+ pasted: !0,
66298
+ changedCellResults: changedCellResults,
66299
+ changedCells: changedCells,
66300
+ migratedSourceCells: migratedSourceCells
66301
+ }) : this.getEmptyPasteResult(changedCellResults);
66302
+ });
66303
+ }
66304
+ processPastedText(pastedData, pasteContext) {
66305
+ var _a;
66306
+ return __awaiter$1(this, void 0, void 0, function* () {
66307
+ const table = this.table,
66308
+ pasteRange = pasteContext.pasteRange,
66309
+ {
66310
+ col: col,
66311
+ row: row,
66312
+ maxCol: maxCol,
66313
+ maxRow: maxRow
66314
+ } = pasteRange;
66315
+ let values = this.parsePlainTextPastedData(pastedData);
66316
+ const pasteValuesRowCount = values.length,
66317
+ pasteValuesColCount = Math.max(...values.map(rowValues => rowValues.length));
66318
+ if (!pasteValuesRowCount || !pasteValuesColCount) return this.getEmptyPasteResult();
66319
+ let processedValues;
66320
+ values = this.handlePasteValues(values, pasteValuesRowCount, pasteValuesColCount, maxRow - row + 1, maxCol - col + 1), (null === (_a = table.options.keyboardOptions) || void 0 === _a ? void 0 : _a.processFormulaBeforePaste) && pasteContext.copySourceRange && (processedValues = table.options.keyboardOptions.processFormulaBeforePaste(values, pasteContext.copySourceRange.startCol, pasteContext.copySourceRange.startRow, col, row));
66321
+ const valuesToPaste = processedValues || values,
66322
+ targetCells = this.getPasteTargetCells(pasteRange, valuesToPaste);
66323
+ if (!this.isPasteOperationCurrent(pasteContext.pasteOperationId)) return this.getEmptyPasteResult();
66324
+ if (pasteContext.cutState) {
66325
+ const validatedCellResults = yield this.validatePasteTargetCells(pasteRange, valuesToPaste);
66326
+ if (!this.isPasteOperationCurrent(pasteContext.pasteOperationId)) return this.getEmptyPasteResult();
66327
+ if (!this.isFullPasteAllowed(valuesToPaste, validatedCellResults)) return this.getEmptyPasteResult(validatedCellResults);
66328
+ }
66329
+ const rawChangedCellResults = yield table.changeCellValues(col, row, valuesToPaste, !pasteContext.cutState, !0, void 0, () => !this.isPasteOperationCurrent(pasteContext.pasteOperationId));
66330
+ if (!this.isPasteOperationCurrent(pasteContext.pasteOperationId)) return this.getEmptyPasteResult();
66331
+ const changedCellResults = this.normalizeChangedCellResults(rawChangedCellResults, pasteRange, valuesToPaste),
66332
+ changedCells = this.getChangedCells(targetCells, changedCellResults),
66333
+ migratedSourceCells = this.getMigratedSourceCells(pasteContext.cutState, changedCellResults);
66334
+ return changedCells.length ? (this.firePastedDataEvent(col, row, valuesToPaste, changedCellResults), {
66335
+ pasted: !0,
66336
+ changedCellResults: changedCellResults,
66337
+ changedCells: changedCells,
66338
+ migratedSourceCells: migratedSourceCells
66339
+ }) : this.getEmptyPasteResult(changedCellResults);
66340
+ });
66341
+ }
66342
+ firePastedDataEvent(col, row, pasteData, changedCellResults) {
66343
+ const table = this.table;
66344
+ if (table.hasListeners(TABLE_EVENT_TYPE.PASTED_DATA)) try {
66345
+ table.fireListeners(TABLE_EVENT_TYPE.PASTED_DATA, {
65714
66346
  col: col,
65715
66347
  row: row,
65716
- pasteData: processedValues || values,
66348
+ pasteData: pasteData,
65717
66349
  changedCellResults: changedCellResults
65718
66350
  });
65719
- });
65720
- }
65721
- clearCutArea(table) {
65722
- try {
65723
- const ranges = this.cutRanges;
65724
- if (!ranges || 0 === ranges.length) return;
65725
- table.changeCellValuesByRanges(ranges, "");
65726
66351
  } catch (error) {}
65727
66352
  }
65728
- checkClipboardChanged() {
65729
- return __awaiter$1(this, void 0, void 0, function* () {
65730
- if (!navigator.clipboard || !navigator.clipboard.readText) return !1;
65731
- try {
65732
- return (yield navigator.clipboard.readText()) !== this.lastClipboardContent;
65733
- } catch (err) {
65734
- return !1;
65735
- }
65736
- });
66353
+ getEmptyPasteResult(changedCellResults = []) {
66354
+ return {
66355
+ pasted: !1,
66356
+ changedCellResults: changedCellResults,
66357
+ changedCells: [],
66358
+ migratedSourceCells: []
66359
+ };
65737
66360
  }
65738
- saveClipboardContent() {
65739
- navigator.clipboard && navigator.clipboard.readText && setTimeout(() => {
65740
- navigator.clipboard.readText().then(text => {
65741
- this.lastClipboardContent = text;
65742
- }).catch(err => {});
65743
- }, 50);
65744
- }
65745
- pasteHtmlToTable(item) {
65746
- const regex = /<tr[^>]*>([\s\S]*?)<\/tr>/g,
65747
- cellRegex = /<td[^>]*>([\s\S]*?)<\/td>/g,
65748
- table = this.table,
65749
- ranges = table.stateManager.select.ranges,
65750
- selectRangeLength = ranges.length,
65751
- col = Math.min(ranges[selectRangeLength - 1].start.col, ranges[selectRangeLength - 1].end.col),
65752
- row = Math.min(ranges[selectRangeLength - 1].start.row, ranges[selectRangeLength - 1].end.row),
65753
- maxCol = Math.max(ranges[selectRangeLength - 1].start.col, ranges[selectRangeLength - 1].end.col),
65754
- maxRow = Math.max(ranges[selectRangeLength - 1].start.row, ranges[selectRangeLength - 1].end.row);
65755
- let pasteValuesColCount = 0,
65756
- pasteValuesRowCount = 0,
65757
- values = [];
65758
- item.getType("text/html").then(blob => {
65759
- blob.text().then(pastedData => __awaiter$1(this, void 0, void 0, function* () {
65760
- var _a, _b, _c;
65761
- if (pastedData && /(<table)|(<TABLE)/g.test(pastedData)) {
65762
- const matches = Array.from(pastedData.matchAll(regex));
65763
- for (const match of matches) {
65764
- const rowContent = match[1],
65765
- rowValues = Array.from(rowContent.matchAll(cellRegex)).map(cellMatch => cellMatch[1].replace(/(<(?!br)([^>]+)>)/gi, "").replace(/<br(\s*|\/)>[\r\n]?/gim, "\n").replace(/&amp;/g, "&").replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&#9;/gi, "\t").replace(/&nbsp;/g, " "));
65766
- values.push(rowValues), pasteValuesColCount = Math.max(pasteValuesColCount, null !== (_a = null == rowValues ? void 0 : rowValues.length) && void 0 !== _a ? _a : 0);
65767
- }
65768
- let processedValues;
65769
- pasteValuesRowCount = null !== (_b = values.length) && void 0 !== _b ? _b : 0, values = this.handlePasteValues(values, pasteValuesRowCount, pasteValuesColCount, maxRow - row + 1, maxCol - col + 1), (null === (_c = table.options.keyboardOptions) || void 0 === _c ? void 0 : _c.processFormulaBeforePaste) && this.copySourceRange && (processedValues = table.options.keyboardOptions.processFormulaBeforePaste(values, this.copySourceRange.startCol, this.copySourceRange.startRow, col, row));
65770
- const changedCellResults = yield table.changeCellValues(col, row, processedValues || values, !0);
65771
- table.hasListeners(TABLE_EVENT_TYPE.PASTED_DATA) && table.fireListeners(TABLE_EVENT_TYPE.PASTED_DATA, {
65772
- col: col,
65773
- row: row,
65774
- pasteData: processedValues || values,
65775
- changedCellResults: changedCellResults
65776
- });
65777
- } else navigator.clipboard.read().then(clipboardItems => {
65778
- for (const item of clipboardItems) item.types.includes("text/plain") && item.getType("text/plain").then(blob => {
65779
- blob.text().then(data => this._pasteValue(data));
65780
- });
65781
- });
65782
- }));
65783
- });
66361
+ getPasteTargetCells(pasteRange, values) {
66362
+ const targetCells = [];
66363
+ for (let rowIndex = 0; rowIndex < values.length; rowIndex++) {
66364
+ targetCells[rowIndex] = [];
66365
+ for (let colIndex = 0; colIndex < values[rowIndex].length; colIndex++) targetCells[rowIndex][colIndex] = this.getCellIdentity(pasteRange.col + colIndex, pasteRange.row + rowIndex);
66366
+ }
66367
+ return targetCells;
65784
66368
  }
65785
- _pasteValue(pastedData) {
65786
- var _a, _b;
66369
+ getChangedCells(targetCells, changedCellResults) {
66370
+ var _a, _b, _c;
66371
+ const changedCells = [];
66372
+ for (let rowIndex = 0; rowIndex < changedCellResults.length; rowIndex++) for (let colIndex = 0; colIndex < (null !== (_b = null === (_a = changedCellResults[rowIndex]) || void 0 === _a ? void 0 : _a.length) && void 0 !== _b ? _b : 0); colIndex++) changedCellResults[rowIndex][colIndex] && (null === (_c = targetCells[rowIndex]) || void 0 === _c ? void 0 : _c[colIndex]) && changedCells.push(targetCells[rowIndex][colIndex]);
66373
+ return changedCells;
66374
+ }
66375
+ normalizeChangedCellResults(changedCellResults, pasteRange, values) {
66376
+ if (Array.isArray(changedCellResults)) return changedCellResults;
66377
+ const table = this.table;
66378
+ return values.map((rowValues, rowIndex) => rowValues.map((_value, colIndex) => {
66379
+ const targetCol = pasteRange.col + colIndex,
66380
+ targetRow = pasteRange.row + rowIndex;
66381
+ return targetCol < table.colCount && targetRow < table.rowCount && (!table.isHasEditorDefine || table.isHasEditorDefine(targetCol, targetRow));
66382
+ }));
66383
+ }
66384
+ validatePasteTargetCells(pasteRange, values) {
66385
+ var _a, _b, _c, _d;
65787
66386
  return __awaiter$1(this, void 0, void 0, function* () {
65788
66387
  const table = this.table,
65789
- ranges = table.stateManager.select.ranges,
65790
- selectRangeLength = ranges.length,
65791
- col = Math.min(ranges[selectRangeLength - 1].start.col, ranges[selectRangeLength - 1].end.col),
65792
- row = Math.min(ranges[selectRangeLength - 1].start.row, ranges[selectRangeLength - 1].end.row),
65793
- maxCol = Math.max(ranges[selectRangeLength - 1].start.col, ranges[selectRangeLength - 1].end.col),
65794
- maxRow = Math.max(ranges[selectRangeLength - 1].start.row, ranges[selectRangeLength - 1].end.row);
65795
- let pasteValuesColCount = 0,
65796
- pasteValuesRowCount = 0,
65797
- values = [];
65798
- let processedValues;
65799
- pastedData.split("\n").forEach(function (rowCells, rowIndex) {
65800
- var _a;
65801
- const cells = rowCells.split("\t"),
65802
- rowValues = [];
65803
- values.push(rowValues), cells.forEach(function (cell, cellIndex) {
65804
- cellIndex === cells.length - 1 && (cell = cell.trim()), rowValues.push(cell);
65805
- }), pasteValuesColCount = Math.max(pasteValuesColCount, null !== (_a = null == rowValues ? void 0 : rowValues.length) && void 0 !== _a ? _a : 0);
65806
- }), pasteValuesRowCount = null !== (_a = values.length) && void 0 !== _a ? _a : 0, values = this.handlePasteValues(values, pasteValuesRowCount, pasteValuesColCount, maxRow - row + 1, maxCol - col + 1), (null === (_b = table.options.keyboardOptions) || void 0 === _b ? void 0 : _b.processFormulaBeforePaste) && this.copySourceRange && (processedValues = table.options.keyboardOptions.processFormulaBeforePaste(values, this.copySourceRange.startCol, this.copySourceRange.startRow, col, row));
65807
- const changedCellResults = yield table.changeCellValues(col, row, processedValues || values, !0);
65808
- table.hasListeners(TABLE_EVENT_TYPE.PASTED_DATA) && table.fireListeners(TABLE_EVENT_TYPE.PASTED_DATA, {
65809
- col: col,
65810
- row: row,
65811
- pasteData: processedValues || values,
65812
- changedCellResults: changedCellResults
65813
- });
66388
+ changedCellResults = [];
66389
+ for (let rowIndex = 0; rowIndex < values.length; rowIndex++) {
66390
+ changedCellResults[rowIndex] = [];
66391
+ for (let colIndex = 0; colIndex < values[rowIndex].length; colIndex++) {
66392
+ const targetCol = pasteRange.col + colIndex,
66393
+ targetRow = pasteRange.row + rowIndex,
66394
+ tableAny = table;
66395
+ let canChange = targetCol < tableAny.colCount && targetRow < tableAny.rowCount && (!tableAny.isHasEditorDefine || tableAny.isHasEditorDefine(targetCol, targetRow));
66396
+ if (canChange) {
66397
+ const editor = null === (_a = tableAny.getEditor) || void 0 === _a ? void 0 : _a.call(tableAny, targetCol, targetRow),
66398
+ oldValue = null === (_b = table.getCellOriginValue) || void 0 === _b ? void 0 : _b.call(table, targetCol, targetRow),
66399
+ validateResult = null === (_d = null === (_c = null == editor ? void 0 : editor.validateValue) || void 0 === _c ? void 0 : _c.call(editor, values[rowIndex][colIndex], oldValue, {
66400
+ col: targetCol,
66401
+ row: targetRow
66402
+ }, table)) || void 0 === _d || _d,
66403
+ resolvedValidateResult = validateResult && "function" == typeof validateResult.then ? yield validateResult : validateResult;
66404
+ canChange = !0 === resolvedValidateResult || "validate-exit" === resolvedValidateResult || "validate-not-exit" === resolvedValidateResult;
66405
+ }
66406
+ changedCellResults[rowIndex][colIndex] = canChange;
66407
+ }
66408
+ }
66409
+ return changedCellResults;
65814
66410
  });
65815
66411
  }
65816
- pasteTextToTable(item) {
66412
+ isFullPasteAllowed(values, changedCellResults) {
66413
+ return values.every((rowValues, rowIndex) => rowValues.every((_value, colIndex) => {
66414
+ var _a;
66415
+ return !0 === (null === (_a = changedCellResults[rowIndex]) || void 0 === _a ? void 0 : _a[colIndex]);
66416
+ }));
66417
+ }
66418
+ getMigratedSourceCells(cutState, changedCellResults) {
66419
+ var _a, _b, _c, _d, _e;
66420
+ if (!(null == cutState ? void 0 : cutState.sourceCells.length) || !cutState.sourceColCount || !cutState.sourceRowCount) return [];
66421
+ const migratedSourceCells = [],
66422
+ migratedKeys = new Set();
66423
+ if (!cutState.isSingleRange) {
66424
+ for (let rowIndex = 0; rowIndex < changedCellResults.length; rowIndex++) for (let colIndex = 0; colIndex < (null !== (_b = null === (_a = changedCellResults[rowIndex]) || void 0 === _a ? void 0 : _a.length) && void 0 !== _b ? _b : 0); colIndex++) {
66425
+ if (!changedCellResults[rowIndex][colIndex]) continue;
66426
+ const sourceRow = rowIndex % cutState.sourceRowCount,
66427
+ sourceCol = colIndex % cutState.sourceColCount,
66428
+ sourceCell = null === (_c = cutState.sourceCellMatrix[sourceRow]) || void 0 === _c ? void 0 : _c[sourceCol];
66429
+ if (!sourceCell) continue;
66430
+ const sourceKey = this.getCellKey(sourceCell);
66431
+ migratedKeys.has(sourceKey) || (migratedKeys.add(sourceKey), migratedSourceCells.push(sourceCell));
66432
+ }
66433
+ return migratedSourceCells.length === cutState.sourceCells.length ? migratedSourceCells : [];
66434
+ }
66435
+ for (let rowIndex = 0; rowIndex < changedCellResults.length; rowIndex++) for (let colIndex = 0; colIndex < (null !== (_e = null === (_d = changedCellResults[rowIndex]) || void 0 === _d ? void 0 : _d.length) && void 0 !== _e ? _e : 0); colIndex++) {
66436
+ if (!changedCellResults[rowIndex][colIndex]) continue;
66437
+ const sourceRow = rowIndex % cutState.sourceRowCount,
66438
+ sourceCol = colIndex % cutState.sourceColCount,
66439
+ sourceIndex = sourceRow * cutState.sourceColCount + sourceCol,
66440
+ sourceCell = cutState.sourceCells[sourceIndex];
66441
+ if (!sourceCell) continue;
66442
+ const sourceKey = this.getCellKey(sourceCell);
66443
+ migratedKeys.has(sourceKey) || (migratedKeys.add(sourceKey), migratedSourceCells.push(sourceCell));
66444
+ }
66445
+ return migratedSourceCells;
66446
+ }
66447
+ getCellIdentity(col, row) {
66448
+ var _a, _b, _c, _d, _e, _f, _g;
66449
+ const table = this.table,
66450
+ recordShowIndex = null === (_a = table.getRecordShowIndexByCell) || void 0 === _a ? void 0 : _a.call(table, col, row);
66451
+ return {
66452
+ col: col,
66453
+ row: row,
66454
+ recordIndex: recordShowIndex >= 0 ? null === (_c = null === (_b = table.dataSource) || void 0 === _b ? void 0 : _b.getIndexKey) || void 0 === _c ? void 0 : _c.call(_b, recordShowIndex) : void 0,
66455
+ field: null === (_g = null === (_f = null === (_e = null === (_d = table.internalProps) || void 0 === _d ? void 0 : _d.layoutMap) || void 0 === _e ? void 0 : _e.getBody) || void 0 === _f ? void 0 : _f.call(_e, col, row)) || void 0 === _g ? void 0 : _g.field
66456
+ };
66457
+ }
66458
+ clearCutArea(migratedSourceCells, changedTargetCells) {
66459
+ var _a, _b;
65817
66460
  return __awaiter$1(this, void 0, void 0, function* () {
65818
- const table = this.table,
65819
- ranges = table.stateManager.select.ranges,
65820
- selectRangeLength = ranges.length,
65821
- col = Math.min(ranges[selectRangeLength - 1].start.col, ranges[selectRangeLength - 1].end.col),
65822
- row = Math.min(ranges[selectRangeLength - 1].start.row, ranges[selectRangeLength - 1].end.row),
65823
- maxCol = Math.max(ranges[selectRangeLength - 1].start.col, ranges[selectRangeLength - 1].end.col),
65824
- maxRow = Math.max(ranges[selectRangeLength - 1].start.row, ranges[selectRangeLength - 1].end.row);
65825
66461
  try {
65826
- const blob = yield item.getType("text/plain"),
65827
- pastedData = yield blob.text(),
65828
- values = this.parsePastedData(pastedData),
65829
- pasteValuesRowCount = values.length,
65830
- pasteValuesColCount = Math.max(...values.map(row => row.length), 0),
65831
- processedValues = this.handlePasteValues(values, pasteValuesRowCount, pasteValuesColCount, maxRow - row + 1, maxCol - col + 1),
65832
- changedCellResults = yield table.changeCellValues(col, row, processedValues, !0);
65833
- table.hasListeners(TABLE_EVENT_TYPE.PASTED_DATA) && table.fireListeners(TABLE_EVENT_TYPE.PASTED_DATA, {
65834
- col: col,
65835
- row: row,
65836
- pasteData: processedValues,
65837
- changedCellResults: changedCellResults
66462
+ const table = this.table,
66463
+ changedTargetKeys = new Set();
66464
+ changedTargetCells.forEach(cell => {
66465
+ changedTargetKeys.add(this.getCellKey(cell)), changedTargetKeys.add(this.getCoordKey(cell));
65838
66466
  });
65839
- } catch (error) {}
66467
+ const clearedKeys = new Set(),
66468
+ sourceChanges = [],
66469
+ coordChanges = [];
66470
+ for (let i = 0; i < migratedSourceCells.length; i++) {
66471
+ const sourceCell = migratedSourceCells[i],
66472
+ sourceKey = this.getCellKey(sourceCell);
66473
+ if (clearedKeys.has(sourceKey) || changedTargetKeys.has(sourceKey) || changedTargetKeys.has(this.getCoordKey(sourceCell))) continue;
66474
+ const currentAddress = this.getCurrentCellAddress(sourceCell);
66475
+ currentAddress && this.isSourceCellUnchanged(sourceCell, currentAddress) && (void 0 !== sourceCell.recordIndex && void 0 !== sourceCell.field && table.changeCellValuesByRecords ? sourceChanges.push({
66476
+ recordIndex: sourceCell.recordIndex,
66477
+ field: sourceCell.field,
66478
+ value: ""
66479
+ }) : coordChanges.push(currentAddress), clearedKeys.add(sourceKey));
66480
+ }
66481
+ sourceChanges.length && table.changeCellValuesByRecords(sourceChanges, {
66482
+ triggerEvent: !0,
66483
+ autoRefresh: !1
66484
+ });
66485
+ for (let i = 0; i < coordChanges.length; i++) yield table.changeCellValues(coordChanges[i].col, coordChanges[i].row, [[""]], !1);
66486
+ return sourceChanges.length && (null === (_b = (_a = table).refreshAfterSourceChange) || void 0 === _b || _b.call(_a)), !0;
66487
+ } catch (error) {
66488
+ return !1;
66489
+ }
65840
66490
  });
65841
66491
  }
66492
+ isSourceCellUnchanged(sourceCell, currentAddress) {
66493
+ var _a;
66494
+ const table = this.table;
66495
+ return Object.is(null === (_a = table.getCellOriginValue) || void 0 === _a ? void 0 : _a.call(table, currentAddress.col, currentAddress.row), sourceCell.value);
66496
+ }
66497
+ getCurrentCellAddress(sourceCell) {
66498
+ const table = this.table;
66499
+ if (void 0 !== sourceCell.recordIndex && void 0 !== sourceCell.field && table.getCellAddrByFieldRecord) {
66500
+ const address = table.getCellAddrByFieldRecord(sourceCell.field, sourceCell.recordIndex);
66501
+ return address && address.col >= 0 && address.row >= 0 ? address : null;
66502
+ }
66503
+ return {
66504
+ col: sourceCell.col,
66505
+ row: sourceCell.row
66506
+ };
66507
+ }
66508
+ getCellKey(cell) {
66509
+ return void 0 !== cell.recordIndex && void 0 !== cell.field ? `record:${this.getStableKeyPart(cell.recordIndex)}:${this.getStableKeyPart(cell.field)}` : this.getCoordKey(cell);
66510
+ }
66511
+ getCoordKey(cell) {
66512
+ return `coord:${cell.col}:${cell.row}`;
66513
+ }
66514
+ getStableKeyPart(value) {
66515
+ if (null === value) return "null";
66516
+ const valueType = typeof value;
66517
+ if ("string" === valueType || "number" === valueType || "boolean" === valueType) return `${valueType}:${JSON.stringify(value)}`;
66518
+ if (Array.isArray(value)) return `array:[${value.map(item => this.getStableKeyPart(item)).join(",")}]`;
66519
+ if ("object" === valueType || "function" === valueType) {
66520
+ let id = this.fieldKeyIds.get(value);
66521
+ return void 0 === id && (id = ++this.fieldKeyId, this.fieldKeyIds.set(value, id)), `${valueType}:#${id}`;
66522
+ }
66523
+ return `${valueType}:${String(value)}`;
66524
+ }
66525
+ resetCutState() {
66526
+ var _a;
66527
+ this.cutWaitPaste = !1, this.activeCutState = null, this.cutCellRange = null, this.cutRanges = null, (null === (_a = this.table.keyboardOptions) || void 0 === _a ? void 0 : _a.showCopyCellBorder) && clearActiveCellRangeState(this.table), this.clipboardCheckTimer && (clearTimeout(this.clipboardCheckTimer), this.clipboardCheckTimer = null);
66528
+ }
65842
66529
  parsePastedData(pastedData) {
65843
66530
  const rows = pastedData.replace(/\r(?!\n)/g, "\r\n").split("\r\n"),
65844
66531
  values = [];
@@ -65847,6 +66534,10 @@
65847
66534
  values.push(rowValues);
65848
66535
  }), values;
65849
66536
  }
66537
+ parsePlainTextPastedData(pastedData) {
66538
+ const rows = pastedData.replace(/\r\n|\r/g, "\n").split("\n");
66539
+ return rows.length > 1 && "" === rows[rows.length - 1] && rows.pop(), rows.map(rowCells => rowCells.split("\t"));
66540
+ }
65850
66541
  processCellValue(cell) {
65851
66542
  cell.includes("\n") && (cell = cell.replace(/^"(.*)"$/, "$1").replace(/["]*/g, match => new Array(Math.floor(match.length / 2)).fill('"').join("")));
65852
66543
  const numValue = Number(cell);
@@ -68046,7 +68737,7 @@
68046
68737
  }
68047
68738
  constructor(container, options = {}) {
68048
68739
  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;
68049
- if (super(), this.showFrozenIcon = !0, this._scrollToRowCorrectTimer = null, this._tableBorderWidth_left = 0, this._tableBorderWidth_right = 0, this._tableBorderWidth_top = 0, this._tableBorderWidth_bottom = 0, this.version = "1.26.7", this.id = `VTable${Date.now()}`, this.isReleased = !1, this._chartEventMap = {}, this.throttleInvalidate = throttle2(this.render.bind(this), 200), "undefined" != typeof window) {
68740
+ if (super(), this.showFrozenIcon = !0, this._scrollToRowCorrectTimer = null, this._tableBorderWidth_left = 0, this._tableBorderWidth_right = 0, this._tableBorderWidth_top = 0, this._tableBorderWidth_bottom = 0, this.version = "1.26.8", this.id = `VTable${Date.now()}`, this.isReleased = !1, this._chartEventMap = {}, this.throttleInvalidate = throttle2(this.render.bind(this), 200), "undefined" != typeof window) {
68050
68741
  const g = window;
68051
68742
  g[this.id] = this;
68052
68743
  const registry = g.__vtable__ || (g.__vtable__ = {
@@ -69051,7 +69742,7 @@
69051
69742
  defaultRowHeight = 40,
69052
69743
  defaultHeaderRowHeight: defaultHeaderRowHeight,
69053
69744
  defaultColWidth = 80,
69054
- defaultHeaderColWidth = 80,
69745
+ defaultHeaderColWidth: defaultHeaderColWidth,
69055
69746
  keyboardOptions: keyboardOptions,
69056
69747
  eventOptions: eventOptions,
69057
69748
  rowSeriesNumber: rowSeriesNumber,
@@ -72045,6 +72736,23 @@
72045
72736
  if (null == r ? void 0 : r.start) for (let col = r.start.col; col <= r.end.col; col++) for (let row = r.start.row; row <= r.end.row; row++) table.scenegraph.updateCellContent(col, row);
72046
72737
  }
72047
72738
  }
72739
+ function isSameRecordIndex(sourceRecordIndex, currentRecordIndex) {
72740
+ return Array.isArray(sourceRecordIndex) || Array.isArray(currentRecordIndex) ? Array.isArray(sourceRecordIndex) && Array.isArray(currentRecordIndex) && sourceRecordIndex.length === currentRecordIndex.length && sourceRecordIndex.every((value, index) => value === currentRecordIndex[index]) : sourceRecordIndex === currentRecordIndex;
72741
+ }
72742
+ function isTargetCellSnapshotCurrent(table, snapshot) {
72743
+ if (table.isHeader(snapshot.col, snapshot.row) !== snapshot.isHeader) return !1;
72744
+ if (snapshot.isHeader) return !0;
72745
+ const recordShowIndex = table.getRecordShowIndexByCell(snapshot.col, snapshot.row),
72746
+ recordIndex = recordShowIndex >= 0 ? table.dataSource.getIndexKey(recordShowIndex) : void 0,
72747
+ {
72748
+ field: field
72749
+ } = table.internalProps.layoutMap.getBody(snapshot.col, snapshot.row);
72750
+ return isSameRecordIndex(snapshot.recordIndex, recordIndex) && snapshot.field === field;
72751
+ }
72752
+ function areTargetCellSnapshotsCurrent(table, snapshots) {
72753
+ for (let i = 0; i < snapshots.length; i++) for (let j = 0; j < snapshots[i].length; j++) if (!isTargetCellSnapshotCurrent(table, snapshots[i][j])) return !1;
72754
+ return !0;
72755
+ }
72048
72756
  function listTableChangeCellValue(col, row, value, workOnEditableCell, triggerEvent, table, noTriggerChangeCellValuesEvent) {
72049
72757
  var _a, _b;
72050
72758
  if (workOnEditableCell && table.isHasEditorDefine(col, row) || !1 === workOnEditableCell) {
@@ -72099,29 +72807,70 @@
72099
72807
  table.scenegraph.updateNextFrame();
72100
72808
  }
72101
72809
  }
72102
- function listTableChangeCellValues(startCol, startRow, values, workOnEditableCell, triggerEvent, table, noTriggerChangeCellValuesEvent) {
72103
- var _a, _b;
72810
+ function listTableChangeCellValues(startCol, startRow, values, workOnEditableCell, triggerEvent, table, noTriggerChangeCellValuesEvent, shouldCancel) {
72811
+ var _a, _b, _c, _d, _e;
72104
72812
  return __awaiter(this, void 0, void 0, function* () {
72105
72813
  const changedCellResults = [];
72106
72814
  let pasteColEnd = startCol,
72107
72815
  pasteRowEnd = startRow;
72108
72816
  const beforeChangeValues = [],
72109
- oldValues = [];
72817
+ oldValues = [],
72818
+ targetSnapshots = [];
72110
72819
  let cellUpdateType;
72111
72820
  for (let i = 0; i < values.length && !(startRow + i > table.rowCount - 1); i++) {
72112
72821
  const rowValues = values[i],
72113
72822
  rawRowValues = [],
72114
- oldRowValues = [];
72115
- beforeChangeValues.push(rawRowValues), oldValues.push(oldRowValues);
72823
+ oldRowValues = [],
72824
+ rowTargetSnapshots = [];
72825
+ beforeChangeValues.push(rawRowValues), oldValues.push(oldRowValues), targetSnapshots.push(rowTargetSnapshots);
72116
72826
  for (let j = 0; j < rowValues.length && !(startCol + j > table.colCount - 1); j++) {
72827
+ const col = startCol + j,
72828
+ row = startRow + i;
72117
72829
  cellUpdateType = getCellUpdateType(startCol + j, startRow + i, table, cellUpdateType);
72118
- const beforeChangeValue = table.getCellRawValue(startCol + j, startRow + i);
72830
+ const beforeChangeValue = table.getCellRawValue(col, row);
72119
72831
  rawRowValues.push(beforeChangeValue);
72120
- const oldValue = table.getCellOriginValue(startCol + j, startRow + i);
72832
+ const oldValue = table.getCellOriginValue(col, row);
72121
72833
  oldRowValues.push(oldValue);
72834
+ const isHeader = table.isHeader(col, row),
72835
+ recordShowIndex = table.getRecordShowIndexByCell(col, row),
72836
+ recordIndex = recordShowIndex >= 0 ? table.dataSource.getIndexKey(recordShowIndex) : void 0,
72837
+ {
72838
+ field: field
72839
+ } = table.internalProps.layoutMap.getBody(col, row);
72840
+ rowTargetSnapshots.push({
72841
+ col: col,
72842
+ row: row,
72843
+ isHeader: isHeader,
72844
+ recordIndex: recordIndex,
72845
+ field: field
72846
+ });
72122
72847
  }
72123
72848
  }
72124
- const resultChangeValues = [];
72849
+ const resultChangeValues = [],
72850
+ preValidatedCellResults = shouldCancel && workOnEditableCell ? [] : null;
72851
+ if (preValidatedCellResults) for (let i = 0; i < values.length; i++) {
72852
+ if (null == shouldCancel ? void 0 : shouldCancel()) return changedCellResults;
72853
+ if (startRow + i > table.rowCount - 1) break;
72854
+ preValidatedCellResults[i] = [];
72855
+ const rowValues = values[i];
72856
+ for (let j = 0; j < rowValues.length && !(startCol + j > table.colCount - 1); j++) {
72857
+ let isCanChange = !1;
72858
+ if (table.isHasEditorDefine(startCol + j, startRow + i)) {
72859
+ const editor = table.getEditor(startCol + j, startRow + i),
72860
+ oldValue = oldValues[i][j],
72861
+ value = rowValues[j],
72862
+ maybePromiseOrValue = null === (_b = null === (_a = null == editor ? void 0 : editor.validateValue) || void 0 === _a ? void 0 : _a.call(editor, value, oldValue, {
72863
+ col: startCol + j,
72864
+ row: startRow + i
72865
+ }, table)) || void 0 === _b || _b,
72866
+ validateResult = isPromise(maybePromiseOrValue) ? yield maybePromiseOrValue : maybePromiseOrValue;
72867
+ if (null == shouldCancel ? void 0 : shouldCancel()) return changedCellResults;
72868
+ isCanChange = !0 === validateResult || "validate-exit" === validateResult || "validate-not-exit" === validateResult;
72869
+ }
72870
+ preValidatedCellResults[i][j] = isCanChange;
72871
+ }
72872
+ }
72873
+ if ((null == shouldCancel ? void 0 : shouldCancel()) || !areTargetCellSnapshotsCurrent(table, targetSnapshots)) return changedCellResults;
72125
72874
  for (let i = 0; i < values.length && !(startRow + i > table.rowCount - 1); i++) {
72126
72875
  changedCellResults[i] = [], pasteRowEnd = startRow + i;
72127
72876
  const rowValues = values[i];
@@ -72129,16 +72878,17 @@
72129
72878
  for (let j = 0; j < rowValues.length && !(startCol + j > table.colCount - 1); j++) {
72130
72879
  thisRowPasteColEnd = startCol + j;
72131
72880
  let isCanChange = !1;
72132
- if (!1 === workOnEditableCell) isCanChange = !0;else if (table.isHasEditorDefine(startCol + j, startRow + i)) {
72881
+ if (preValidatedCellResults) isCanChange = !0 === (null === (_c = preValidatedCellResults[i]) || void 0 === _c ? void 0 : _c[j]);else if (!1 === workOnEditableCell) isCanChange = !0;else if (table.isHasEditorDefine(startCol + j, startRow + i)) {
72133
72882
  const editor = table.getEditor(startCol + j, startRow + i),
72134
72883
  oldValue = oldValues[i][j],
72135
72884
  value = rowValues[j],
72136
- maybePromiseOrValue = null === (_b = null === (_a = null == editor ? void 0 : editor.validateValue) || void 0 === _a ? void 0 : _a.call(editor, value, oldValue, {
72885
+ maybePromiseOrValue = null === (_e = null === (_d = null == editor ? void 0 : editor.validateValue) || void 0 === _d ? void 0 : _d.call(editor, value, oldValue, {
72137
72886
  col: startCol + j,
72138
72887
  row: startRow + i
72139
- }, table)) || void 0 === _b || _b;
72888
+ }, table)) || void 0 === _e || _e;
72140
72889
  if (isPromise(maybePromiseOrValue)) {
72141
72890
  const validateResult = yield maybePromiseOrValue;
72891
+ if (null == shouldCancel ? void 0 : shouldCancel()) return changedCellResults;
72142
72892
  isCanChange = !0 === validateResult || "validate-exit" === validateResult || "validate-not-exit" === validateResult;
72143
72893
  } else isCanChange = !0 === maybePromiseOrValue || "validate-exit" === maybePromiseOrValue || "validate-not-exit" === maybePromiseOrValue;
72144
72894
  }
@@ -72152,7 +72902,10 @@
72152
72902
  } = table.internalProps.layoutMap.getBody(startCol + j, startRow + i),
72153
72903
  beforeChangeValue = beforeChangeValues[i][j],
72154
72904
  oldValue = oldValues[i][j];
72155
- 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);
72905
+ if (table.isHeader(startCol + j, startRow + i)) table.internalProps.layoutMap.updateColumnTitle(startCol + j, startRow + i, value);else {
72906
+ const changeResult = table.dataSource.changeFieldValue(value, recordShowIndex, field, startCol + j, startRow + i, table);
72907
+ isPromise(changeResult) && (yield changeResult);
72908
+ }
72156
72909
  const changedValue = table.getCellOriginValue(startCol + j, startRow + i);
72157
72910
  if (oldValue !== changedValue && triggerEvent) {
72158
72911
  const changeValue = {
@@ -72849,6 +73602,9 @@
72849
73602
  }), clearLayoutColumnState(null !== (_a = column.children) && void 0 !== _a ? _a : column.columns);
72850
73603
  });
72851
73604
  }
73605
+ function isSameField(left, right) {
73606
+ return left === right || Array.isArray(left) && Array.isArray(right) && arrayEqual(left, right);
73607
+ }
72852
73608
  class ListTable extends BaseTable {
72853
73609
  constructor(container, options) {
72854
73610
  var _a, _b, _c, _d, _e, _f, _g, _h;
@@ -73151,7 +73907,7 @@
73151
73907
  return this.transpose ? this.dataSource.getTableIndex(recordIndex) + this.rowHeaderLevelCount : this.dataSource.getTableIndex(recordIndex) + this.columnHeaderLevelCount;
73152
73908
  }
73153
73909
  getTableIndexByField(field) {
73154
- const colObj = this.internalProps.layoutMap.columnObjects.find(col => col.field === field);
73910
+ const colObj = this.internalProps.layoutMap.columnObjects.find(col => isSameField(col.field, field));
73155
73911
  if (!colObj) return -1;
73156
73912
  const layoutRange = this.internalProps.layoutMap.getBodyLayoutRangeById(colObj.id);
73157
73913
  return this.transpose ? layoutRange.start.row : layoutRange.start.col;
@@ -73294,7 +74050,7 @@
73294
74050
  const {
73295
74051
  layoutMap: layoutMap
73296
74052
  } = this.internalProps,
73297
- colObj = layoutMap.columnObjects.find(col => col.field === field);
74053
+ colObj = layoutMap.columnObjects.find(col => isSameField(col.field, field));
73298
74054
  if (colObj) {
73299
74055
  const layoutRange = layoutMap.getBodyLayoutRangeById(colObj.id);
73300
74056
  let startRow;
@@ -73409,7 +74165,7 @@
73409
74165
  _getSortFuncFromHeaderOption(columns, field, fieldKey) {
73410
74166
  if (columns || (columns = this.internalProps.columns), field && columns && columns.length > 0) for (let i = 0; i < columns.length; i++) {
73411
74167
  const header = columns[i];
73412
- if ((fieldKey && fieldKey === header.fieldKey || !fieldKey && header.field === field) && header.sort && "function" == typeof header.sort) return header.sort;
74168
+ if ((fieldKey && fieldKey === header.fieldKey || !fieldKey && isSameField(header.field, field)) && header.sort && "function" == typeof header.sort) return header.sort;
73413
74169
  if (header.columns) {
73414
74170
  const sort = this._getSortFuncFromHeaderOption(header.columns, field, fieldKey);
73415
74171
  if (sort) return sort;
@@ -73421,7 +74177,7 @@
73421
74177
  const normalizedSortState = (Array.isArray(sortState) ? sortState : sortState ? [sortState] : []).filter(Boolean);
73422
74178
  if (normalizedSortState.length ? this.internalProps.sortState = sortState : this.internalProps.sortState = null, executeSort) if (normalizedSortState.length) this.internalProps.layoutMap.headerObjects.some(item => !1 !== item.define.sort) && (this.dataSource.sort(normalizedSortState.map(item => {
73423
74179
  const sortFunc = this._getSortFuncFromHeaderOption(this.internalProps.columns, item.field);
73424
- this.internalProps.layoutMap.headerObjects.find(col => col && col.field === item.field);
74180
+ this.internalProps.layoutMap.headerObjects.find(col => col && isSameField(col.field, item.field));
73425
74181
  return {
73426
74182
  field: item.field,
73427
74183
  order: item.order,
@@ -73519,7 +74275,7 @@
73519
74275
  const sortState = Array.isArray(this.sortState) ? this.sortState : [this.sortState];
73520
74276
  sortState.some(item => item.order && item.field && "normal" !== item.order) && this.internalProps.layoutMap.headerObjectsIncludeHided.some(item => !1 !== item.define.sort) && this.dataSource.sort(sortState.map(item => {
73521
74277
  const sortFunc = this._getSortFuncFromHeaderOption(void 0, item.field);
73522
- this.internalProps.layoutMap.headerObjectsIncludeHided.find(col => col && col.field === item.field);
74278
+ this.internalProps.layoutMap.headerObjectsIncludeHided.find(col => col && isSameField(col.field, item.field));
73523
74279
  return {
73524
74280
  field: item.field,
73525
74281
  order: item.order || "asc",
@@ -73605,8 +74361,8 @@
73605
74361
  changeCellValue(col, row, value, workOnEditableCell = !1, triggerEvent = !0, noTriggerChangeCellValuesEvent) {
73606
74362
  return listTableChangeCellValue(col, row, value, workOnEditableCell, triggerEvent, this, noTriggerChangeCellValuesEvent);
73607
74363
  }
73608
- changeCellValues(startCol, startRow, values, workOnEditableCell = !1, triggerEvent = !0, noTriggerChangeCellValuesEvent) {
73609
- return listTableChangeCellValues(startCol, startRow, values, workOnEditableCell, triggerEvent, this, noTriggerChangeCellValuesEvent);
74364
+ changeCellValues(startCol, startRow, values, workOnEditableCell = !1, triggerEvent = !0, noTriggerChangeCellValuesEvent, shouldCancel) {
74365
+ return listTableChangeCellValues(startCol, startRow, values, workOnEditableCell, triggerEvent, this, noTriggerChangeCellValuesEvent, shouldCancel);
73610
74366
  }
73611
74367
  changeCellValuesByRanges(ranges, value, workOnEditableCell = !1, triggerEvent = !0, noTriggerChangeCellValuesEvent) {
73612
74368
  return listTableChangeCellValuesByRanges(ranges, value, workOnEditableCell, triggerEvent, this, noTriggerChangeCellValuesEvent);
@@ -73641,8 +74397,8 @@
73641
74397
  autoRefresh = null === (_b = null == options ? void 0 : options.autoRefresh) || void 0 === _b || _b,
73642
74398
  records = null === (_c = this.dataSource.dataSourceObj) || void 0 === _c ? void 0 : _c.records;
73643
74399
  let record, oldValue;
73644
- 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;
73645
- const changedValue = !record || "string" != typeof field && "number" != typeof field ? value : null == record ? void 0 : record[field];
74400
+ if (Array.isArray(records) && ("string" == typeof field || "number" == typeof field || Array.isArray(field)) && (record = Array.isArray(recordIndex) ? getValueFromDeepArray(records, recordIndex) : records[recordIndex], oldValue = getRecordFieldValue(record, field)), this.dataSource.changeFieldValueByRecordIndex(value, recordIndex, field, this), Array.isArray(records) && (record = Array.isArray(recordIndex) ? getValueFromDeepArray(records, recordIndex) : records[recordIndex]), !triggerEvent) return;
74401
+ const changedValue = record && ("string" == typeof field || "number" == typeof field || Array.isArray(field)) ? getRecordFieldValue(record, field) : value;
73646
74402
  if (oldValue !== changedValue) {
73647
74403
  const cellAddr = this.getCellAddrByFieldRecord(field, recordIndex),
73648
74404
  changeValue = {
@@ -73681,8 +74437,8 @@
73681
74437
  } = changeValues[i],
73682
74438
  records = null === (_c = this.dataSource.dataSourceObj) || void 0 === _c ? void 0 : _c.records;
73683
74439
  let record, oldValue;
73684
- 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) {
73685
- const changedValue = !record || "string" != typeof field && "number" != typeof field ? value : null == record ? void 0 : record[field];
74440
+ if (Array.isArray(records) && ("string" == typeof field || "number" == typeof field || Array.isArray(field)) && (record = Array.isArray(recordIndex) ? getValueFromDeepArray(records, recordIndex) : records[recordIndex], oldValue = getRecordFieldValue(record, field)), this.dataSource.changeFieldValueByRecordIndex(value, recordIndex, field, this), Array.isArray(records) && (record = Array.isArray(recordIndex) ? getValueFromDeepArray(records, recordIndex) : records[recordIndex]), triggerEvent) {
74441
+ const changedValue = record && ("string" == typeof field || "number" == typeof field || Array.isArray(field)) ? getRecordFieldValue(record, field) : value;
73686
74442
  if (oldValue !== changedValue) {
73687
74443
  const changeValue = {
73688
74444
  col: null !== (_e = null === (_d = this.getCellAddrByFieldRecord(field, recordIndex)) || void 0 === _d ? void 0 : _d.col) && void 0 !== _e ? _e : -1,
@@ -77383,8 +78139,9 @@
77383
78139
  }
77384
78140
 
77385
78141
  function createCellGroup(table, value, columnGroup, xOrigin, yOrigin, col, row, colWidth, cellWidth, cellHeight, padding, textAlign, textBaseline, mayHaveIcon, customElementsGroup, renderDefault, cellTheme, range, isAsync) {
77386
- 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, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9;
77387
- const headerStyle = table._getCellStyle(col, row),
78142
+ 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, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11;
78143
+ const isCornerCustomMergeContentCell = isCornerCustomMergeRange(range, table) && col === range.end.col && row === range.end.row,
78144
+ headerStyle = table._getCellStyle(col, row),
77388
78145
  functionalPadding = getFunctionalProp("padding", headerStyle, col, row, table);
77389
78146
  isValid$1(functionalPadding) && (padding = functionalPadding), (null === (_a = null == cellTheme ? void 0 : cellTheme.text) || void 0 === _a ? void 0 : _a.textAlign) && (textAlign = null === (_b = null == cellTheme ? void 0 : cellTheme.text) || void 0 === _b ? void 0 : _b.textAlign), (null === (_c = null == cellTheme ? void 0 : cellTheme.text) || void 0 === _c ? void 0 : _c.textBaseline) && (textBaseline = null === (_d = null == cellTheme ? void 0 : cellTheme.text) || void 0 === _d ? void 0 : _d.textBaseline);
77390
78147
  const autoRowHeight = table.isAutoRowHeight(row),
@@ -77406,7 +78163,7 @@
77406
78163
  cursor: null !== (_q = null === (_p = null == cellTheme ? void 0 : cellTheme.group) || void 0 === _p ? void 0 : _p.cursor) && void 0 !== _q ? _q : void 0,
77407
78164
  lineDash: null !== (_s = null === (_r = null == cellTheme ? void 0 : cellTheme.group) || void 0 === _r ? void 0 : _r.lineDash) && void 0 !== _s ? _s : void 0,
77408
78165
  lineCap: "butt",
77409
- clip: !0,
78166
+ clip: !isCornerCustomMergeContentCell,
77410
78167
  cornerRadius: cellTheme.group.cornerRadius
77411
78168
  })), cellGroup && "cell" === cellGroup.role || (cellGroup = new Group$1({
77412
78169
  x: xOrigin,
@@ -77421,9 +78178,12 @@
77421
78178
  cursor: null !== (_2 = null === (_1 = null == cellTheme ? void 0 : cellTheme.group) || void 0 === _1 ? void 0 : _1.cursor) && void 0 !== _2 ? _2 : void 0,
77422
78179
  lineDash: null !== (_4 = null === (_3 = null == cellTheme ? void 0 : cellTheme.group) || void 0 === _3 ? void 0 : _3.lineDash) && void 0 !== _4 ? _4 : void 0,
77423
78180
  lineCap: "butt",
77424
- clip: !0,
78181
+ clip: !isCornerCustomMergeContentCell,
77425
78182
  cornerRadius: cellTheme.group.cornerRadius
77426
- }), cellGroup.role = "cell", cellGroup.col = col, cellGroup.row = row, cellGroup = null !== (_5 = null == columnGroup ? void 0 : columnGroup.addCellGroup(cellGroup)) && void 0 !== _5 ? _5 : cellGroup), customElementsGroup && cellGroup.appendChild(customElementsGroup), renderDefault) {
78183
+ }), cellGroup.role = "cell", cellGroup.col = col, cellGroup.row = row, cellGroup = null !== (_5 = null == columnGroup ? void 0 : columnGroup.addCellGroup(cellGroup)) && void 0 !== _5 ? _5 : cellGroup), customElementsGroup && cellGroup.appendChild(customElementsGroup), isCornerCustomMergeContentCell && cellGroup.setAttributes({
78184
+ width: Math.max(cellGroup.attribute.width, null !== (_6 = null == customElementsGroup ? void 0 : customElementsGroup.attribute.width) && void 0 !== _6 ? _6 : 0),
78185
+ height: Math.max(cellGroup.attribute.height, null !== (_7 = null == customElementsGroup ? void 0 : customElementsGroup.attribute.height) && void 0 !== _7 ? _7 : 0)
78186
+ }), renderDefault) {
77427
78187
  const textStr = value;
77428
78188
  let icons;
77429
78189
  if (mayHaveIcon) {
@@ -77431,11 +78191,11 @@
77431
78191
  iconRow = row;
77432
78192
  range && (iconCol = range.start.col, iconRow = range.start.row), icons = table.getCellIcons(iconCol, iconRow);
77433
78193
  }
77434
- createCellContent(cellGroup, icons, textStr, padding, autoColWidth, autoRowHeight, autoWrapText, "number" == typeof lineClamp ? lineClamp : void 0, cellGroup.attribute.width, cellGroup.attribute.height, textAlign, textBaseline, table, cellTheme, range), (null === (_6 = null == cellTheme ? void 0 : cellTheme._vtable) || void 0 === _6 ? void 0 : _6.marked) && createMark(null === (_7 = null == cellTheme ? void 0 : cellTheme._vtable) || void 0 === _7 ? void 0 : _7.marked, cellGroup);
78194
+ createCellContent(cellGroup, icons, textStr, padding, autoColWidth, autoRowHeight, autoWrapText, "number" == typeof lineClamp ? lineClamp : void 0, cellGroup.attribute.width, cellGroup.attribute.height, textAlign, textBaseline, table, cellTheme, range), (null === (_8 = null == cellTheme ? void 0 : cellTheme._vtable) || void 0 === _8 ? void 0 : _8.marked) && createMark(null === (_9 = null == cellTheme ? void 0 : cellTheme._vtable) || void 0 === _9 ? void 0 : _9.marked, cellGroup);
77435
78195
  }
77436
78196
  return customElementsGroup && cellGroup.setAttributes({
77437
- width: Math.max(cellGroup.attribute.width, null !== (_8 = customElementsGroup.attribute.width) && void 0 !== _8 ? _8 : 0),
77438
- height: Math.max(cellGroup.attribute.height, null !== (_9 = customElementsGroup.attribute.height) && void 0 !== _9 ? _9 : 0)
78197
+ width: Math.max(cellGroup.attribute.width, null !== (_10 = customElementsGroup.attribute.width) && void 0 !== _10 ? _10 : 0),
78198
+ height: Math.max(cellGroup.attribute.height, null !== (_11 = customElementsGroup.attribute.height) && void 0 !== _11 ? _11 : 0)
77439
78199
  }), cellGroup;
77440
78200
  }
77441
78201
 
@@ -79542,30 +80302,36 @@
79542
80302
  }
79543
80303
  else if (Array.isArray(markLine)) {
79544
80304
  return markLine.map((item, index) => {
80305
+ const style = item.style;
79545
80306
  return {
79546
80307
  ...item,
79547
80308
  date: item.date,
79548
80309
  scrollToMarkLine: item.scrollToMarkLine,
79549
80310
  position: item.position ?? 'left',
79550
- style: {
79551
- lineColor: item.style?.lineColor || 'red',
79552
- lineWidth: item.style?.lineWidth || 1,
79553
- lineDash: item.style?.lineDash
79554
- }
80311
+ style: typeof style === 'function'
80312
+ ? style
80313
+ : {
80314
+ lineColor: style?.lineColor || 'red',
80315
+ lineWidth: style?.lineWidth ?? 1,
80316
+ lineDash: style?.lineDash
80317
+ }
79555
80318
  };
79556
80319
  });
79557
80320
  }
80321
+ const style = markLine.style;
79558
80322
  return [
79559
80323
  {
79560
80324
  ...markLine,
79561
80325
  date: markLine.date,
79562
80326
  scrollToMarkLine: markLine.scrollToMarkLine ?? true,
79563
80327
  position: markLine.position ?? 'left',
79564
- style: {
79565
- lineColor: markLine.style?.lineColor || 'red',
79566
- lineWidth: markLine.style?.lineWidth || 1,
79567
- lineDash: markLine.style?.lineDash
79568
- }
80328
+ style: typeof style === 'function'
80329
+ ? style
80330
+ : {
80331
+ lineColor: style?.lineColor || 'red',
80332
+ lineWidth: style?.lineWidth ?? 1,
80333
+ lineDash: style?.lineDash
80334
+ }
79569
80335
  }
79570
80336
  ];
79571
80337
  }
@@ -81714,6 +82480,15 @@
81714
82480
  }
81715
82481
  }
81716
82482
 
82483
+ function resolveMarkLineStyle(line, args) {
82484
+ const style = typeof line.style === 'function' ? line.style(args) : line.style;
82485
+ const lineWidth = typeof style?.lineWidth === 'function' ? style.lineWidth(args) : style?.lineWidth;
82486
+ return {
82487
+ lineColor: style?.lineColor || 'red',
82488
+ lineWidth: lineWidth ?? 1,
82489
+ lineDash: style?.lineDash
82490
+ };
82491
+ }
81717
82492
  class MarkLine {
81718
82493
  _scene;
81719
82494
  group;
@@ -81759,7 +82534,6 @@
81759
82534
  const minDate = this._scene._gantt.parsedOptions.minDate;
81760
82535
  minDate &&
81761
82536
  markLine.forEach(line => {
81762
- const style = line.style;
81763
82537
  const contentStyle = line.contentStyle || {};
81764
82538
  const date = this._scene._gantt.parsedOptions.timeScaleIncludeHour
81765
82539
  ? createDateAtMidnight(line.date)
@@ -81782,6 +82556,15 @@
81782
82556
  else if (line.position === 'middle') {
81783
82557
  dateX = cellStartX + cellWidth / 2;
81784
82558
  }
82559
+ const style = resolveMarkLineStyle(line, {
82560
+ date,
82561
+ dateIndex: cellIndex,
82562
+ dateX,
82563
+ cellStartX,
82564
+ cellWidth,
82565
+ timelineColWidth: this._scene._gantt.parsedOptions.timelineColWidth,
82566
+ millisecondsPerPixel: this._scene._gantt.getCurrentMillisecondsPerPixel()
82567
+ });
81785
82568
  const markLineGroup = new Group$2({
81786
82569
  pickable: false,
81787
82570
  x: dateX - this.markLineContainerWidth / 2,
@@ -88429,7 +89212,7 @@
88429
89212
  PluginManager: PluginManager
88430
89213
  });
88431
89214
 
88432
- const version = "1.26.7";
89215
+ const version = "1.26.8";
88433
89216
 
88434
89217
  exports.Gantt = Gantt;
88435
89218
  exports.TABLE_EVENT_TYPE = TABLE_EVENT_TYPE;