@visactor/vtable 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.
Files changed (183) hide show
  1. package/cjs/ListTable.d.ts +1 -1
  2. package/cjs/ListTable.js +21 -13
  3. package/cjs/ListTable.js.map +1 -1
  4. package/cjs/PivotChart.js +16 -16
  5. package/cjs/PivotChart.js.map +1 -1
  6. package/cjs/PivotTable.d.ts +1 -1
  7. package/cjs/PivotTable.js +65 -63
  8. package/cjs/PivotTable.js.map +1 -1
  9. package/cjs/body-helper/body-helper.js +2 -1
  10. package/cjs/components/index.js +1 -2
  11. package/cjs/core/BaseTable.js +2 -2
  12. package/cjs/core/BaseTable.js.map +1 -1
  13. package/cjs/core/record-helper.d.ts +1 -1
  14. package/cjs/core/record-helper.js +60 -12
  15. package/cjs/core/record-helper.js.map +1 -1
  16. package/cjs/core/tableHelper.js +2 -1
  17. package/cjs/data/DataSource.d.ts +3 -1
  18. package/cjs/data/DataSource.js +71 -23
  19. package/cjs/data/DataSource.js.map +1 -1
  20. package/cjs/dataset/dataset.d.ts +9 -1
  21. package/cjs/dataset/dataset.js +344 -187
  22. package/cjs/dataset/dataset.js.map +1 -1
  23. package/cjs/event/event.d.ts +94 -8
  24. package/cjs/event/event.js +698 -191
  25. package/cjs/event/event.js.map +1 -1
  26. package/cjs/event/helper.js +1 -1
  27. package/cjs/event/media-click.js +4 -1
  28. package/cjs/event/media-click.js.map +1 -1
  29. package/cjs/event/scroll.js +1 -1
  30. package/cjs/event/sparkline-event.js +1 -2
  31. package/cjs/event/util.js +2 -2
  32. package/cjs/event/util.js.map +1 -1
  33. package/cjs/index.d.ts +1 -1
  34. package/cjs/index.js +1 -1
  35. package/cjs/index.js.map +1 -1
  36. package/cjs/layout/pivot-header-layout.js +33 -17
  37. package/cjs/layout/pivot-header-layout.js.map +1 -1
  38. package/cjs/plugins/custom-cell-style.js +1 -1
  39. package/cjs/plugins/index.js +2 -1
  40. package/cjs/plugins/interface.js +1 -1
  41. package/cjs/plugins/invert-highlight.js +1 -1
  42. package/cjs/plugins/list-tree-stick-cell.js +1 -1
  43. package/cjs/plugins/plugin-manager.js +1 -1
  44. package/cjs/scenegraph/group-creater/cell-helper.js +27 -10
  45. package/cjs/scenegraph/group-creater/cell-helper.js.map +1 -1
  46. package/cjs/scenegraph/group-creater/cell-type/text-cell.d.ts +1 -1
  47. package/cjs/scenegraph/group-creater/cell-type/text-cell.js +14 -10
  48. package/cjs/scenegraph/group-creater/cell-type/text-cell.js.map +1 -1
  49. package/cjs/scenegraph/group-creater/progress/create-group-for-first-screen.js +17 -4
  50. package/cjs/scenegraph/group-creater/progress/create-group-for-first-screen.js.map +1 -1
  51. package/cjs/scenegraph/layout/compute-col-width.js +6 -1
  52. package/cjs/scenegraph/layout/compute-col-width.js.map +1 -1
  53. package/cjs/scenegraph/layout/compute-row-height.js +11 -3
  54. package/cjs/scenegraph/layout/compute-row-height.js.map +1 -1
  55. package/cjs/scenegraph/layout/update-height.d.ts +4 -3
  56. package/cjs/scenegraph/layout/update-height.js +43 -29
  57. package/cjs/scenegraph/layout/update-height.js.map +1 -1
  58. package/cjs/scenegraph/layout/update-width.d.ts +2 -1
  59. package/cjs/scenegraph/layout/update-width.js +49 -37
  60. package/cjs/scenegraph/layout/update-width.js.map +1 -1
  61. package/cjs/scenegraph/scenegraph.d.ts +2 -2
  62. package/cjs/scenegraph/scenegraph.js +6 -5
  63. package/cjs/scenegraph/scenegraph.js.map +1 -1
  64. package/cjs/scenegraph/utils/corner-custom-merge.d.ts +10 -0
  65. package/cjs/scenegraph/utils/corner-custom-merge.js +68 -0
  66. package/cjs/scenegraph/utils/corner-custom-merge.js.map +1 -0
  67. package/cjs/state/resize/update-resize-column.js +25 -13
  68. package/cjs/state/resize/update-resize-column.js.map +1 -1
  69. package/cjs/state/resize/update-resize-row.js +24 -12
  70. package/cjs/state/resize/update-resize-row.js.map +1 -1
  71. package/cjs/themes.d.ts +4 -2
  72. package/cjs/themes.js +12 -4
  73. package/cjs/themes.js.map +1 -1
  74. package/cjs/tools/get-data-path/create-dataset.js +4 -4
  75. package/cjs/tools/get-data-path/create-dataset.js.map +1 -1
  76. package/cjs/tools/get-data-path/index.js +4 -4
  77. package/cjs/tools/get-data-path/index.js.map +1 -1
  78. package/cjs/tools/style.d.ts +3 -1
  79. package/cjs/tools/style.js +2 -2
  80. package/cjs/tools/style.js.map +1 -1
  81. package/cjs/ts-types/common.d.ts +1 -0
  82. package/cjs/ts-types/common.js.map +1 -1
  83. package/cjs/ts-types/dataset/aggregation.d.ts +1 -0
  84. package/cjs/ts-types/dataset/aggregation.js +21 -3
  85. package/cjs/ts-types/dataset/aggregation.js.map +1 -1
  86. package/cjs/ts-types/new-data-set.d.ts +1 -0
  87. package/cjs/ts-types/new-data-set.js.map +1 -1
  88. package/cjs/ts-types/table-engine.d.ts +3 -2
  89. package/cjs/ts-types/table-engine.js.map +1 -1
  90. package/cjs/vrender.js.map +1 -1
  91. package/dist/vtable.js +2224 -779
  92. package/dist/vtable.min.js +1 -1
  93. package/es/ListTable.d.ts +1 -1
  94. package/es/ListTable.js +21 -15
  95. package/es/ListTable.js.map +1 -1
  96. package/es/PivotChart.js +16 -16
  97. package/es/PivotChart.js.map +1 -1
  98. package/es/PivotTable.d.ts +1 -1
  99. package/es/PivotTable.js +65 -63
  100. package/es/PivotTable.js.map +1 -1
  101. package/es/body-helper/body-helper.js +2 -1
  102. package/es/components/index.js +1 -2
  103. package/es/core/BaseTable.js +2 -2
  104. package/es/core/BaseTable.js.map +1 -1
  105. package/es/core/record-helper.d.ts +1 -1
  106. package/es/core/record-helper.js +60 -12
  107. package/es/core/record-helper.js.map +1 -1
  108. package/es/core/tableHelper.js +2 -1
  109. package/es/data/DataSource.d.ts +3 -1
  110. package/es/data/DataSource.js +70 -23
  111. package/es/data/DataSource.js.map +1 -1
  112. package/es/dataset/dataset.d.ts +9 -1
  113. package/es/dataset/dataset.js +341 -187
  114. package/es/dataset/dataset.js.map +1 -1
  115. package/es/event/event.d.ts +94 -8
  116. package/es/event/event.js +696 -191
  117. package/es/event/event.js.map +1 -1
  118. package/es/event/helper.js +1 -1
  119. package/es/event/media-click.js +4 -1
  120. package/es/event/media-click.js.map +1 -1
  121. package/es/event/scroll.js +1 -1
  122. package/es/event/sparkline-event.js +1 -2
  123. package/es/event/util.js +2 -2
  124. package/es/event/util.js.map +1 -1
  125. package/es/index.d.ts +1 -1
  126. package/es/index.js +1 -1
  127. package/es/index.js.map +1 -1
  128. package/es/layout/pivot-header-layout.js +29 -17
  129. package/es/layout/pivot-header-layout.js.map +1 -1
  130. package/es/plugins/custom-cell-style.js +1 -1
  131. package/es/plugins/index.js +2 -1
  132. package/es/plugins/interface.js +1 -1
  133. package/es/plugins/invert-highlight.js +1 -1
  134. package/es/plugins/list-tree-stick-cell.js +1 -1
  135. package/es/plugins/plugin-manager.js +1 -1
  136. package/es/scenegraph/group-creater/cell-helper.js +23 -9
  137. package/es/scenegraph/group-creater/cell-helper.js.map +1 -1
  138. package/es/scenegraph/group-creater/cell-type/text-cell.d.ts +1 -1
  139. package/es/scenegraph/group-creater/cell-type/text-cell.js +13 -8
  140. package/es/scenegraph/group-creater/cell-type/text-cell.js.map +1 -1
  141. package/es/scenegraph/group-creater/progress/create-group-for-first-screen.js +17 -5
  142. package/es/scenegraph/group-creater/progress/create-group-for-first-screen.js.map +1 -1
  143. package/es/scenegraph/layout/compute-col-width.js +6 -1
  144. package/es/scenegraph/layout/compute-col-width.js.map +1 -1
  145. package/es/scenegraph/layout/compute-row-height.js +11 -3
  146. package/es/scenegraph/layout/compute-row-height.js.map +1 -1
  147. package/es/scenegraph/layout/update-height.d.ts +4 -3
  148. package/es/scenegraph/layout/update-height.js +40 -26
  149. package/es/scenegraph/layout/update-height.js.map +1 -1
  150. package/es/scenegraph/layout/update-width.d.ts +2 -1
  151. package/es/scenegraph/layout/update-width.js +46 -34
  152. package/es/scenegraph/layout/update-width.js.map +1 -1
  153. package/es/scenegraph/scenegraph.d.ts +2 -2
  154. package/es/scenegraph/scenegraph.js +7 -5
  155. package/es/scenegraph/scenegraph.js.map +1 -1
  156. package/es/scenegraph/utils/corner-custom-merge.d.ts +10 -0
  157. package/es/scenegraph/utils/corner-custom-merge.js +59 -0
  158. package/es/scenegraph/utils/corner-custom-merge.js.map +1 -0
  159. package/es/state/resize/update-resize-column.js +19 -10
  160. package/es/state/resize/update-resize-column.js.map +1 -1
  161. package/es/state/resize/update-resize-row.js +19 -9
  162. package/es/state/resize/update-resize-row.js.map +1 -1
  163. package/es/themes.d.ts +4 -2
  164. package/es/themes.js +11 -3
  165. package/es/themes.js.map +1 -1
  166. package/es/tools/get-data-path/create-dataset.js +4 -4
  167. package/es/tools/get-data-path/create-dataset.js.map +1 -1
  168. package/es/tools/get-data-path/index.js +4 -4
  169. package/es/tools/get-data-path/index.js.map +1 -1
  170. package/es/tools/style.d.ts +3 -1
  171. package/es/tools/style.js +2 -2
  172. package/es/tools/style.js.map +1 -1
  173. package/es/ts-types/common.d.ts +1 -0
  174. package/es/ts-types/common.js.map +1 -1
  175. package/es/ts-types/dataset/aggregation.d.ts +1 -0
  176. package/es/ts-types/dataset/aggregation.js +21 -3
  177. package/es/ts-types/dataset/aggregation.js.map +1 -1
  178. package/es/ts-types/new-data-set.d.ts +1 -0
  179. package/es/ts-types/new-data-set.js.map +1 -1
  180. package/es/ts-types/table-engine.d.ts +3 -2
  181. package/es/ts-types/table-engine.js.map +1 -1
  182. package/es/vrender.js.map +1 -1
  183. package/package.json +9 -9
package/dist/vtable.js CHANGED
@@ -42406,6 +42406,7 @@
42406
42406
  class CustomAggregator extends Aggregator {
42407
42407
  type = AggregationType.CUSTOM;
42408
42408
  isRecord = true;
42409
+ recalculateFromChildren;
42409
42410
  aggregationFun;
42410
42411
  values = [];
42411
42412
  fieldValue;
@@ -42415,6 +42416,19 @@
42415
42416
  }
42416
42417
  push(record) {
42417
42418
  if (record) {
42419
+ if (this.recalculateFromChildren && record.isAggregator) {
42420
+ if (this.isRecord && this.records) {
42421
+ this.records.push(...record.records);
42422
+ }
42423
+ if (this.children) {
42424
+ this.children.push(record);
42425
+ }
42426
+ if (this.field) {
42427
+ this.values.push(...record.records.map((item) => item[this.field]));
42428
+ }
42429
+ this.clearCacheValue();
42430
+ return;
42431
+ }
42418
42432
  if (this.isRecord && this.records) {
42419
42433
  if (record.isAggregator) {
42420
42434
  this.records.push(...record.records);
@@ -42483,6 +42497,26 @@
42483
42497
  this.fieldValue = undefined;
42484
42498
  }
42485
42499
  recalculate() {
42500
+ if (this.recalculateFromChildren && this.children?.length && this.field) {
42501
+ this.values = [];
42502
+ this.records = [];
42503
+ this.children.forEach(child => {
42504
+ if (isValid$1(child.changedValue)) {
42505
+ const value = child.value();
42506
+ this.values.push(value);
42507
+ this.records.push({ [this.field]: value });
42508
+ }
42509
+ else if (child instanceof CustomAggregator && child.recalculateFromChildren) {
42510
+ this.values.push(...child.values);
42511
+ this.records.push(...child.records);
42512
+ }
42513
+ else {
42514
+ const records = child.records;
42515
+ this.values.push(...records.map(record => record[this.field]));
42516
+ this.records.push(...records);
42517
+ }
42518
+ });
42519
+ }
42486
42520
  this.fieldValue = undefined;
42487
42521
  this._formatedValue = undefined;
42488
42522
  }
@@ -44430,8 +44464,8 @@
44430
44464
  function isZeroStyle(style) {
44431
44465
  return style === 0 || (isArray$5(style) && style.every(s => s === 0));
44432
44466
  }
44433
- function setActiveCellRangeState(table) {
44434
- const selectRanges = table.stateManager.select.ranges;
44467
+ function setActiveCellRangeState(table, ranges = table.stateManager.select.ranges) {
44468
+ const selectRanges = ranges;
44435
44469
  const setRanges = [];
44436
44470
  for (let i = 0; i < selectRanges.length; i++) {
44437
44471
  const range = selectRanges[i];
@@ -44652,17 +44686,6 @@
44652
44686
  }
44653
44687
  return v1 === v2 ? 0 : v1 < v2 ? 1 : -1;
44654
44688
  }
44655
- function getValueByPath(obj, paths) {
44656
- let res = obj;
44657
- let prop;
44658
- while ((prop = paths.shift())) {
44659
- res = res[prop];
44660
- if (!res) {
44661
- break;
44662
- }
44663
- }
44664
- return res;
44665
- }
44666
44689
  function isAllDigits(str) {
44667
44690
  const pattern = /^-?\d+(\.\d+)?$/;
44668
44691
  return pattern.test(str);
@@ -46939,7 +46962,7 @@
46939
46962
  const DARK = new TableTheme(darkTheme, darkTheme);
46940
46963
  const BRIGHT = new TableTheme(brightTheme, brightTheme);
46941
46964
  const ARCO = new TableTheme(arcoTheme, arcoTheme);
46942
- const DEFAULT = new TableTheme(defaultTheme, defaultTheme);
46965
+ let DEFAULT = new TableTheme(defaultTheme, defaultTheme);
46943
46966
  const SIMPLIFY = new TableTheme(materialDesignTheme, materialDesignTheme);
46944
46967
  const builtin$1 = {
46945
46968
  DEFAULT,
@@ -46948,6 +46971,10 @@
46948
46971
  DARK,
46949
46972
  BRIGHT
46950
46973
  };
46974
+ function setDefaultTheme(theme) {
46975
+ DEFAULT = theme instanceof TableTheme ? theme.extends({}) : new TableTheme(theme, theme);
46976
+ builtin$1.DEFAULT = DEFAULT;
46977
+ }
46951
46978
  const theme$1 = { TableTheme };
46952
46979
  function of$1(value) {
46953
46980
  if (!value) {
@@ -46975,11 +47002,14 @@
46975
47002
  DARK,
46976
47003
  BRIGHT,
46977
47004
  ARCO,
46978
- DEFAULT,
47005
+ get DEFAULT() {
47006
+ return DEFAULT;
47007
+ },
46979
47008
  SIMPLIFY,
46980
47009
  theme: theme$1,
46981
47010
  of: of$1,
46982
- get: get$5
47011
+ get: get$5,
47012
+ setDefaultTheme
46983
47013
  };
46984
47014
 
46985
47015
  var themes$1 = /*#__PURE__*/Object.freeze({
@@ -46987,12 +47017,13 @@
46987
47017
  ARCO: ARCO,
46988
47018
  BRIGHT: BRIGHT,
46989
47019
  DARK: DARK,
46990
- DEFAULT: DEFAULT,
47020
+ get DEFAULT () { return DEFAULT; },
46991
47021
  SIMPLIFY: SIMPLIFY,
46992
47022
  TableTheme: TableTheme,
46993
47023
  default: themes,
46994
47024
  get: get$5,
46995
47025
  of: of$1,
47026
+ setDefaultTheme: setDefaultTheme,
46996
47027
  tableThemeIsChanged: tableThemeIsChanged,
46997
47028
  theme: theme$1
46998
47029
  });
@@ -51967,7 +51998,11 @@
51967
51998
  const colIndex = col - table.leftRowSeriesNumberCount;
51968
51999
  return record[colIndex];
51969
52000
  }
51970
- if (isObject$7(record) && fieldGet in record) {
52001
+ if (Array.isArray(fieldGet)) {
52002
+ const fieldResult = getRecordFieldValue(record, fieldGet);
52003
+ return getValue$2(fieldResult, promiseCallBack);
52004
+ }
52005
+ if (isRecordContainer(record) && fieldGet in record) {
51971
52006
  const fieldResult = record[fieldGet];
51972
52007
  return getValue$2(fieldResult, promiseCallBack);
51973
52008
  }
@@ -51975,10 +52010,6 @@
51975
52010
  const fieldResult = fieldGet(record, col, row, table);
51976
52011
  return getValue$2(fieldResult, promiseCallBack);
51977
52012
  }
51978
- if (Array.isArray(fieldGet)) {
51979
- const fieldResult = getValueByPath(record, [...fieldGet]);
51980
- return getValue$2(fieldResult, promiseCallBack);
51981
- }
51982
52013
  const fieldArray = `${fieldGet}`.split('.');
51983
52014
  if (fieldArray.length <= 1) {
51984
52015
  const fieldResult = record[fieldGet];
@@ -51987,6 +52018,87 @@
51987
52018
  const fieldResult = applyChainSafe(record, (val, name) => getField(val, name, col, row, table, emptyFn), ...fieldArray);
51988
52019
  return getValue$2(fieldResult, promiseCallBack);
51989
52020
  }
52021
+ function isRecordContainer(value) {
52022
+ return value !== null && typeof value === 'object';
52023
+ }
52024
+ function getRecordFieldPath(field) {
52025
+ if (Array.isArray(field)) {
52026
+ return field;
52027
+ }
52028
+ if (typeof field === 'string' && field.includes('.')) {
52029
+ return field.split('.');
52030
+ }
52031
+ return undefined;
52032
+ }
52033
+ function hasRecordField(record, field) {
52034
+ if (!isRecordContainer(record)) {
52035
+ return false;
52036
+ }
52037
+ const path = getRecordFieldPath(field);
52038
+ if (!Array.isArray(field) && field in record) {
52039
+ return true;
52040
+ }
52041
+ if (!path) {
52042
+ return false;
52043
+ }
52044
+ let target = record;
52045
+ for (const key of path) {
52046
+ if (!isRecordContainer(target) || !(key in target)) {
52047
+ return false;
52048
+ }
52049
+ target = target[key];
52050
+ }
52051
+ return true;
52052
+ }
52053
+ function getRecordFieldValue(record, field) {
52054
+ if (record === null || record === undefined) {
52055
+ return undefined;
52056
+ }
52057
+ const path = getRecordFieldPath(field);
52058
+ if (!Array.isArray(field) && isRecordContainer(record) && field in record) {
52059
+ return record[field];
52060
+ }
52061
+ if (!path) {
52062
+ return record[field];
52063
+ }
52064
+ return path.reduce((current, key) => {
52065
+ return current === null || current === undefined ? undefined : current[key];
52066
+ }, record);
52067
+ }
52068
+ function setRecordProperty(record, key, value) {
52069
+ if (key === '__proto__' || key === 'constructor' || key === 'prototype') {
52070
+ Object.defineProperty(record, key, {
52071
+ configurable: true,
52072
+ enumerable: true,
52073
+ value,
52074
+ writable: true
52075
+ });
52076
+ return;
52077
+ }
52078
+ record[key] = value;
52079
+ }
52080
+ function setRecordFieldValue(record, field, value) {
52081
+ if (record === null || record === undefined) {
52082
+ return;
52083
+ }
52084
+ const path = getRecordFieldPath(field);
52085
+ if (!path || (!Array.isArray(field) && isRecordContainer(record) && field in record)) {
52086
+ setRecordProperty(record, field, value);
52087
+ return;
52088
+ }
52089
+ if (path.length === 0) {
52090
+ return;
52091
+ }
52092
+ let target = record;
52093
+ for (let i = 0; i < path.length - 1; i++) {
52094
+ const key = path[i];
52095
+ if (!Object.prototype.hasOwnProperty.call(target, key) || target[key] === null || typeof target[key] !== 'object') {
52096
+ setRecordProperty(target, key, {});
52097
+ }
52098
+ target = target[key];
52099
+ }
52100
+ setRecordProperty(target, path[path.length - 1], value);
52101
+ }
51990
52102
  function _getIndex(sortedIndexMap, index) {
51991
52103
  if (!sortedIndexMap) {
51992
52104
  return index;
@@ -52401,29 +52513,29 @@
52401
52513
  if (field === undefined || field === '') {
52402
52514
  field = col - table.leftRowSeriesNumberCount;
52403
52515
  }
52404
- if (typeof field === 'string' || typeof field === 'number') {
52405
- const beforeChangedValue = this.beforeChangedRecordsMap.get(dataIndex.toString())?.[field];
52516
+ if (typeof field === 'string' || typeof field === 'number' || Array.isArray(field)) {
52517
+ const beforeChangedValue = getRecordFieldValue(this.beforeChangedRecordsMap.get(dataIndex.toString()), field);
52406
52518
  const record = this.getOriginalRecord(dataIndex);
52407
52519
  let formatValue = value;
52408
52520
  if (typeof beforeChangedValue === 'number' && isAllDigits(value)) {
52409
52521
  formatValue = parseFloat(value);
52410
52522
  }
52411
52523
  if (isPromise(record)) {
52412
- record
52524
+ return record
52413
52525
  .then(record => {
52414
- record[field] = formatValue;
52526
+ setRecordFieldValue(record, field, formatValue);
52527
+ return formatValue;
52415
52528
  })
52416
52529
  .catch((err) => {
52530
+ return undefined;
52417
52531
  });
52418
52532
  }
52533
+ if (record) {
52534
+ setRecordFieldValue(record, field, formatValue);
52535
+ }
52419
52536
  else {
52420
- if (record) {
52421
- record[field] = formatValue;
52422
- }
52423
- else {
52424
- this.records[dataIndex] = this.addRecordRule === 'Array' ? [] : {};
52425
- this.records[dataIndex][field] = formatValue;
52426
- }
52537
+ this.records[dataIndex] = this.addRecordRule === 'Array' ? [] : {};
52538
+ setRecordFieldValue(this.records[dataIndex], field, formatValue);
52427
52539
  }
52428
52540
  }
52429
52541
  }
@@ -52447,8 +52559,8 @@
52447
52559
  : undefined;
52448
52560
  this.beforeChangedRecordsMap.set(rawKey, cloneDeep(originRecord, undefined, ['vtable_gantt_linkedFrom', 'vtable_gantt_linkedTo']) ?? {});
52449
52561
  }
52450
- if (typeof field === 'string' || typeof field === 'number') {
52451
- const beforeChangedValue = this.beforeChangedRecordsMap.get(rawKey)?.[field];
52562
+ if (typeof field === 'string' || typeof field === 'number' || Array.isArray(field)) {
52563
+ const beforeChangedValue = getRecordFieldValue(this.beforeChangedRecordsMap.get(rawKey), field);
52452
52564
  const rawRecords = Array.isArray(this.dataSourceObj?.records)
52453
52565
  ? this.dataSourceObj.records
52454
52566
  : null;
@@ -52462,11 +52574,11 @@
52462
52574
  formatValue = parseFloat(value);
52463
52575
  }
52464
52576
  if (record) {
52465
- record[field] = formatValue;
52577
+ setRecordFieldValue(record, field, formatValue);
52466
52578
  }
52467
52579
  else if (rawRecords && typeof recordIndex === 'number') {
52468
52580
  rawRecords[recordIndex] = this.addRecordRule === 'Array' ? [] : {};
52469
- rawRecords[recordIndex][field] = formatValue;
52581
+ setRecordFieldValue(rawRecords[recordIndex], field, formatValue);
52470
52582
  }
52471
52583
  }
52472
52584
  }
@@ -53155,7 +53267,7 @@
53155
53267
  return true;
53156
53268
  }
53157
53269
  const record = this.getOriginalRecord(index);
53158
- return Boolean(record && field in record);
53270
+ return hasRecordField(record, field);
53159
53271
  }
53160
53272
  fieldPromiseCallBack(_index, _field, _value) {
53161
53273
  }
@@ -56345,7 +56457,7 @@
56345
56457
  }
56346
56458
  cells.forEach(function (cell, cellIndex) {
56347
56459
  const parsedCellData = !cell
56348
- ? ' '
56460
+ ? ''
56349
56461
  : cell
56350
56462
  .toString()
56351
56463
  .replace(/&/g, '&amp;')
@@ -58632,6 +58744,70 @@
58632
58744
  }
58633
58745
  }
58634
58746
 
58747
+ function isCornerCustomMergeRange(range, table) {
58748
+ return (!!range?.isCustom &&
58749
+ (range.start.col !== range.end.col || range.start.row !== range.end.row) &&
58750
+ table.isCornerHeader(range.start.col, range.start.row) &&
58751
+ table.isCornerHeader(range.end.col, range.end.row));
58752
+ }
58753
+ function shouldRenderCornerCustomMergeContent(col, row, range, table) {
58754
+ return !isCornerCustomMergeRange(range, table) || (col === range.end.col && row === range.end.row);
58755
+ }
58756
+ function createCornerCustomMergeContainer(customElementsGroup, width, height, range, table) {
58757
+ if (!customElementsGroup || !isCornerCustomMergeRange(range, table)) {
58758
+ return customElementsGroup;
58759
+ }
58760
+ const customContainer = new Group$1({
58761
+ x: 0,
58762
+ y: 0,
58763
+ width,
58764
+ height,
58765
+ fill: false,
58766
+ stroke: false,
58767
+ pickable: false,
58768
+ clip: true
58769
+ });
58770
+ customContainer.name = CUSTOM_CONTAINER_NAME;
58771
+ customContainer.col = range.start.col;
58772
+ customContainer.row = range.start.row;
58773
+ customContainer.appendChild(customElementsGroup);
58774
+ return customContainer;
58775
+ }
58776
+ function queueCornerCustomMergeContentUpdate(range, table, pendingRanges) {
58777
+ if (!pendingRanges) {
58778
+ refreshCornerCustomMergeContent(range, table);
58779
+ return;
58780
+ }
58781
+ pendingRanges.set(getCornerCustomMergeRangeKey(range), range);
58782
+ }
58783
+ function flushCornerCustomMergeContentUpdates(pendingRanges, table) {
58784
+ pendingRanges.forEach(range => {
58785
+ refreshCornerCustomMergeContentForResize(range, table);
58786
+ });
58787
+ pendingRanges.clear();
58788
+ }
58789
+ function getCornerCustomMergeRangeKey(range) {
58790
+ return `${range.start.col}-${range.start.row}-${range.end.col}-${range.end.row}`;
58791
+ }
58792
+ function refreshCornerCustomMergeContent(range, table) {
58793
+ const cellGroup = table.scenegraph.getCell(range.end.col, range.end.row);
58794
+ const customContainer = cellGroup.getChildByName(CUSTOM_CONTAINER_NAME) || cellGroup.getChildByName(CUSTOM_MERGE_CONTAINER_NAME);
58795
+ if (customContainer) {
58796
+ table.reactCustomLayout?.removeCustomCell(range.start.col, range.start.row);
58797
+ customContainer.removeAllChild();
58798
+ cellGroup.removeChild(customContainer);
58799
+ }
58800
+ table.scenegraph.updateCellContent(range.end.col, range.end.row);
58801
+ }
58802
+ function refreshCornerCustomMergeContentForResize(range, table) {
58803
+ const cellGroup = table.scenegraph.getCell(range.end.col, range.end.row);
58804
+ const customContainer = cellGroup.getChildByName(CUSTOM_CONTAINER_NAME) || cellGroup.getChildByName(CUSTOM_MERGE_CONTAINER_NAME);
58805
+ if (customContainer) {
58806
+ cellGroup.removeChild(customContainer);
58807
+ }
58808
+ table.scenegraph.updateCellContent(range.end.col, range.end.row);
58809
+ }
58810
+
58635
58811
  const PROMISE_CELL_UPDATE_TOKEN_KEY = '__vtable_promise_cell_update_token__';
58636
58812
  function nextPromiseCellUpdateToken(cellGroup) {
58637
58813
  const token = (cellGroup[PROMISE_CELL_UPDATE_TOKEN_KEY] ?? 0) + 1;
@@ -58788,8 +58964,15 @@
58788
58964
  function _generateCustomElementsGroup(table, define, col, row, cellWidth, cellHeight, padding, range, customResult) {
58789
58965
  let customElementsGroup;
58790
58966
  let renderDefault = true;
58967
+ const shouldRenderContent = shouldRenderCornerCustomMergeContent(col, row, range, table);
58968
+ if (!shouldRenderContent) {
58969
+ return {
58970
+ customElementsGroup,
58971
+ renderDefault: false
58972
+ };
58973
+ }
58791
58974
  if (customResult) {
58792
- customElementsGroup = customResult.elementsGroup;
58975
+ customElementsGroup = createCornerCustomMergeContainer(customResult.elementsGroup, cellWidth, cellHeight, range, table);
58793
58976
  renderDefault = customResult.renderDefault;
58794
58977
  }
58795
58978
  else if (range?.isCustom && !table.isCornerHeader(col, row)) ;
@@ -58806,8 +58989,10 @@
58806
58989
  customLayout = define?.customLayout;
58807
58990
  }
58808
58991
  if (customLayout || customRender) {
58809
- const customResult = dealWithCustom(customLayout, customRender, col, row, cellWidth, cellHeight, false, table.isAutoRowHeight(row), padding, range, table);
58810
- customElementsGroup = customResult.elementsGroup;
58992
+ const customCol = range && isCornerCustomMergeRange(range, table) ? range.start.col : col;
58993
+ const customRow = range && isCornerCustomMergeRange(range, table) ? range.start.row : row;
58994
+ const customResult = dealWithCustom(customLayout, customRender, customCol, customRow, cellWidth, cellHeight, false, table.isAutoRowHeight(row), padding, range, table);
58995
+ customElementsGroup = createCornerCustomMergeContainer(customResult.elementsGroup, cellWidth, cellHeight, range, table);
58811
58996
  renderDefault = customResult.renderDefault;
58812
58997
  }
58813
58998
  }
@@ -58836,7 +59021,7 @@
58836
59021
  isMerge = range.start.col !== range.end.col || range.start.row !== range.end.row;
58837
59022
  value = customMergeText;
58838
59023
  customStyle = customMergeStyle;
58839
- if (customLayout || customRender) {
59024
+ if ((customLayout || customRender) && shouldRenderCornerCustomMergeContent(col, row, customMergeRange, table)) {
58840
59025
  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), false, table.isAutoRowHeight(row), [0, 0, 0, 0], range, table);
58841
59026
  }
58842
59027
  isCustomMerge = true;
@@ -59228,21 +59413,33 @@
59228
59413
  if (customMerge) {
59229
59414
  const { range: customMergeRange, text: customMergeText, style: customMergeStyle, customLayout: customMergeLayout, customRender: customMergeRender } = customMerge;
59230
59415
  if (customMergeLayout || customMergeRender) {
59416
+ const rangeHeight = table.getRowHeight(row);
59417
+ const rangeWidth = table.getColWidth(col);
59418
+ const contentWidth = table.getColsWidth(customMergeRange.start.col, customMergeRange.end.col);
59419
+ const contentHeight = table.getRowsHeight(customMergeRange.start.row, customMergeRange.end.row);
59420
+ cellGroup.contentWidth = contentWidth;
59421
+ cellGroup.contentHeight = contentHeight;
59422
+ if (!shouldRenderCornerCustomMergeContent(col, row, customMergeRange, table)) {
59423
+ const customContainer = cellGroup.getChildByName(CUSTOM_CONTAINER_NAME);
59424
+ if (customContainer) {
59425
+ cellGroup.removeChild(customContainer);
59426
+ }
59427
+ cellGroup.setAttribute('clip', true);
59428
+ resizeCellGroup(cellGroup, rangeWidth, rangeHeight, customMergeRange, table);
59429
+ return customMergeRange;
59430
+ }
59231
59431
  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), false, table.isAutoRowHeight(row), [0, 0, 0, 0], customMergeRange, table);
59232
- const customElementsGroup = customResult.elementsGroup;
59432
+ const customElementsGroup = createCornerCustomMergeContainer(customResult.elementsGroup, contentWidth, contentHeight, customMergeRange, table);
59233
59433
  if (cellGroup.childrenCount > 0 && customElementsGroup) {
59234
59434
  cellGroup.insertBefore(customElementsGroup, cellGroup.firstChild);
59235
59435
  }
59236
59436
  else if (customElementsGroup) {
59237
59437
  cellGroup.appendChild(customElementsGroup);
59238
59438
  }
59239
- const rangeHeight = table.getRowHeight(row);
59240
- const rangeWidth = table.getColWidth(col);
59241
- const { width: contentWidth } = cellGroup.attribute;
59242
- const { height: contentHeight } = cellGroup.attribute;
59243
- cellGroup.contentWidth = contentWidth;
59244
- cellGroup.contentHeight = contentHeight;
59245
59439
  resizeCellGroup(cellGroup, rangeWidth, rangeHeight, customMergeRange, table);
59440
+ if (isCornerCustomMergeRange(customMergeRange, table)) {
59441
+ cellGroup.setAttribute('clip', false);
59442
+ }
59246
59443
  return customMergeRange;
59247
59444
  }
59248
59445
  }
@@ -59476,8 +59673,13 @@
59476
59673
  !table.options.customComputeRowHeight &&
59477
59674
  !table.options.rowHeightConfig &&
59478
59675
  checkFixedStyleAndNoWrap(table, rowStart)) {
59479
- const height = computeRowHeight(table.columnHeaderLevelCount, 0, table.colCount - 1, table);
59480
- fillRowsHeight(height, table.columnHeaderLevelCount, table.rowCount - 1 - table.bottomFrozenRowCount, table, update ? newHeights : undefined);
59676
+ const fillStartRow = table.columnHeaderLevelCount;
59677
+ const fillEndRow = table.rowCount - 1 - table.bottomFrozenRowCount;
59678
+ const rowForCompute = getFirstUnresizedRow(table, fillStartRow, fillEndRow);
59679
+ if (rowForCompute >= 0) {
59680
+ const height = computeRowHeight(rowForCompute, 0, table.colCount - 1, table);
59681
+ fillRowsHeight(height, fillStartRow, fillEndRow, table, update ? newHeights : undefined);
59682
+ }
59481
59683
  for (let row = table.rowCount - table.bottomFrozenRowCount; row <= rowEnd; row++) {
59482
59684
  const height = computeRowHeight(row, 0, table.colCount - 1, table);
59483
59685
  if (update) {
@@ -59651,6 +59853,9 @@
59651
59853
  }
59652
59854
  }
59653
59855
  function computeRowHeight(row, startCol, endCol, table) {
59856
+ if (table.internalProps._heightResizedRowMap.has(row)) {
59857
+ return table.getRowHeight(row);
59858
+ }
59654
59859
  return computeRowHeightInternal(row, startCol, endCol, table, true);
59655
59860
  }
59656
59861
  function computeRowHeightInternal(row, startCol, endCol, table, enableCustomCompute) {
@@ -59836,6 +60041,9 @@
59836
60041
  return;
59837
60042
  }
59838
60043
  for (let row = startRow; row <= endRow; row++) {
60044
+ if (table.internalProps._heightResizedRowMap.has(row)) {
60045
+ continue;
60046
+ }
59839
60047
  if (newHeights) {
59840
60048
  newHeights[row] = height;
59841
60049
  }
@@ -59845,6 +60053,14 @@
59845
60053
  }
59846
60054
  table.internalProps.useOneRowHeightFillAll = true;
59847
60055
  }
60056
+ function getFirstUnresizedRow(table, startRow, endRow) {
60057
+ for (let row = startRow; row <= endRow; row++) {
60058
+ if (!table.internalProps._heightResizedRowMap.has(row)) {
60059
+ return row;
60060
+ }
60061
+ }
60062
+ return -1;
60063
+ }
59848
60064
  function computeCustomRenderHeight(col, row, table) {
59849
60065
  const customRender = table.getCustomRender(col, row);
59850
60066
  let customLayout = table.getCustomLayout(col, row);
@@ -60088,7 +60304,9 @@
60088
60304
  };
60089
60305
  }
60090
60306
 
60091
- function updateRowHeight(scene, row, detaY, skipTableHeightMap) {
60307
+ function updateRowHeight(scene, row, detaY, skipTableHeightMap, pendingCornerCustomMergeRanges) {
60308
+ const shouldFlushCornerCustomMergeRanges = !pendingCornerCustomMergeRanges;
60309
+ pendingCornerCustomMergeRanges ??= new Map();
60092
60310
  if (!skipTableHeightMap && detaY) {
60093
60311
  scene.table._setRowHeight(row, scene.table.getRowHeight(row) + detaY, true);
60094
60312
  }
@@ -60102,7 +60320,7 @@
60102
60320
  continue;
60103
60321
  }
60104
60322
  const height = cell.attribute.height;
60105
- updateCellHeightForRow(scene, cell, col, row, height + detaY, detaY, scene.table.isHeader(col, row));
60323
+ updateCellHeightForRow(scene, cell, col, row, height + detaY, detaY, scene.table.isHeader(col, row), pendingCornerCustomMergeRanges);
60106
60324
  scene.updateCellContentWhileResize(col, row);
60107
60325
  }
60108
60326
  let rowStart = 0;
@@ -60127,16 +60345,19 @@
60127
60345
  }
60128
60346
  }
60129
60347
  }
60348
+ if (shouldFlushCornerCustomMergeRanges) {
60349
+ flushCornerCustomMergeContentUpdates(pendingCornerCustomMergeRanges, scene.table);
60350
+ }
60130
60351
  }
60131
- function updateCellHeightForRow(scene, cell, col, row, height, detaY, isHeader) {
60352
+ function updateCellHeightForRow(scene, cell, col, row, height, detaY, isHeader, pendingCornerCustomMergeRanges) {
60132
60353
  const cellGroup = cell;
60133
60354
  const distHeight = height;
60134
60355
  if (!cellGroup) {
60135
60356
  return;
60136
60357
  }
60137
- updateCellHeight(scene, cellGroup, col, row, distHeight, detaY);
60358
+ updateCellHeight(scene, cellGroup, col, row, distHeight, detaY, isHeader, pendingCornerCustomMergeRanges);
60138
60359
  }
60139
- function updateCellHeight(scene, cell, col, row, distHeight, detaY, isHeader) {
60360
+ function updateCellHeight(scene, cell, col, row, distHeight, detaY, isHeader, pendingCornerCustomMergeRanges) {
60140
60361
  if (cell.attribute.height === distHeight && !cell.needUpdateHeight) {
60141
60362
  return;
60142
60363
  }
@@ -60162,7 +60383,7 @@
60162
60383
  cell.removeChild(oldBarCell);
60163
60384
  oldBarCell.removeAllChild();
60164
60385
  oldBarCell.release();
60165
- updateMergeCellContentHeight(cell, distHeight, detaY, scene.table.isAutoRowHeight(row), true, scene.table);
60386
+ updateMergeCellContentHeight(cell, distHeight, detaY, scene.table.isAutoRowHeight(row), true, scene.table, true, pendingCornerCustomMergeRanges);
60166
60387
  }
60167
60388
  else if (type === 'sparkline') {
60168
60389
  cell.removeAllChild();
@@ -60182,6 +60403,15 @@
60182
60403
  const customContainer = cell.getChildByName(CUSTOM_CONTAINER_NAME) ||
60183
60404
  cell.getChildByName(CUSTOM_MERGE_CONTAINER_NAME);
60184
60405
  if (customContainer) {
60406
+ if (scene.table.reactCustomLayout) {
60407
+ const mergeRange = isMergeCellGroup(cell)
60408
+ ? scene.table.getCellRange(cell.mergeStartCol, cell.mergeStartRow)
60409
+ : undefined;
60410
+ const shouldUseMergeStart = mergeRange && isCornerCustomMergeRange(mergeRange, scene.table);
60411
+ const removeCol = shouldUseMergeStart ? mergeRange.start.col : col;
60412
+ const removeRow = shouldUseMergeStart ? mergeRange.start.row : row;
60413
+ scene.table.reactCustomLayout.removeCustomCell(removeCol, removeRow);
60414
+ }
60185
60415
  let customElementsGroup;
60186
60416
  cell.removeChild(customContainer);
60187
60417
  const customMergeRange = getCustomCellMergeCustom(col, row, cell, scene.table);
@@ -60193,8 +60423,10 @@
60193
60423
  const mergedCell = scene.getCell(col, mergeRow);
60194
60424
  const customContainer = mergedCell.getChildByName(CUSTOM_CONTAINER_NAME) ||
60195
60425
  mergedCell.getChildByName(CUSTOM_MERGE_CONTAINER_NAME);
60196
- customContainer.removeAllChild();
60197
- mergedCell.removeChild(customContainer);
60426
+ if (customContainer) {
60427
+ customContainer.removeAllChild();
60428
+ mergedCell.removeChild(customContainer);
60429
+ }
60198
60430
  getCustomCellMergeCustom(col, mergeRow, mergedCell, scene.table);
60199
60431
  }
60200
60432
  }
@@ -60225,7 +60457,14 @@
60225
60457
  }
60226
60458
  }
60227
60459
  }
60228
- if (customLayout || customRender) {
60460
+ const mergeRange = isMergeCellGroup(cell)
60461
+ ? scene.table.getCellRange(cell.mergeStartCol, cell.mergeStartRow)
60462
+ : undefined;
60463
+ const shouldRenderContent = shouldRenderCornerCustomMergeContent(col, row, mergeRange, scene.table);
60464
+ if (!shouldRenderContent) {
60465
+ renderDefault = false;
60466
+ }
60467
+ else if (customLayout || customRender) {
60229
60468
  const style = scene.table._getCellStyle(col, row);
60230
60469
  const padding = getQuadProps(getProp('padding', style, col, row, scene.table));
60231
60470
  let width = cell.attribute.width;
@@ -60234,13 +60473,14 @@
60234
60473
  width = scene.table.getColsWidth(cell.mergeStartCol, cell.mergeEndCol);
60235
60474
  height = scene.table.getRowsHeight(cell.mergeStartRow, cell.mergeEndRow);
60236
60475
  }
60237
- const customResult = dealWithCustom(customLayout, customRender, col, row, width, height, false, scene.table.isAutoRowHeight(row), padding, isMergeCellGroup(cell)
60238
- ? {
60239
- start: { col: cell.mergeStartCol, row: cell.mergeStartRow },
60240
- end: { col: cell.mergeEndCol, row: cell.mergeEndRow }
60241
- }
60242
- : undefined, scene.table);
60243
- customElementsGroup = customResult.elementsGroup;
60476
+ let customCol = col;
60477
+ let customRow = row;
60478
+ if (mergeRange && isCornerCustomMergeRange(mergeRange, scene.table)) {
60479
+ customCol = mergeRange.start.col;
60480
+ customRow = mergeRange.start.row;
60481
+ }
60482
+ const customResult = dealWithCustom(customLayout, customRender, customCol, customRow, width, height, false, scene.table.isAutoRowHeight(row), padding, mergeRange, scene.table);
60483
+ customElementsGroup = createCornerCustomMergeContainer(customResult.elementsGroup, width, height, mergeRange, scene.table);
60244
60484
  renderDefault = customResult.renderDefault;
60245
60485
  }
60246
60486
  if (cell.childrenCount > 0 && customElementsGroup) {
@@ -60249,12 +60489,18 @@
60249
60489
  else if (customElementsGroup) {
60250
60490
  cell.appendChild(customElementsGroup);
60251
60491
  }
60492
+ if (isMergeCellGroup(cell)) {
60493
+ const mergeRange = scene.table.getCellRange(cell.mergeStartCol, cell.mergeStartRow);
60494
+ if (isCornerCustomMergeRange(mergeRange, scene.table)) {
60495
+ cell.setAttribute('clip', !shouldRenderCornerCustomMergeContent(col, row, mergeRange, scene.table));
60496
+ }
60497
+ }
60252
60498
  }
60253
60499
  }
60254
- updateMergeCellContentHeight(cell, distHeight, detaY, scene.table.isAutoRowHeight(row), renderDefault, scene.table);
60500
+ updateMergeCellContentHeight(cell, distHeight, detaY, scene.table.isAutoRowHeight(row), renderDefault, scene.table, !customContainer, pendingCornerCustomMergeRanges);
60255
60501
  }
60256
60502
  }
60257
- function updateMergeCellContentHeight(cellGroup, distHeight, detaY, autoRowHeight, renderDefault, table) {
60503
+ function updateMergeCellContentHeight(cellGroup, distHeight, detaY, autoRowHeight, renderDefault, table, refreshCornerCustomMergeContent = true, pendingCornerCustomMergeRanges) {
60258
60504
  if (isMergeCellGroup(cellGroup)) {
60259
60505
  distHeight = 0;
60260
60506
  for (let row = cellGroup.mergeStartRow; row <= cellGroup.mergeEndRow; row++) {
@@ -60296,6 +60542,10 @@
60296
60542
  }
60297
60543
  }
60298
60544
  }
60545
+ const mergeRange = table.getCellRange(cellGroup.mergeStartCol, cellGroup.mergeStartRow);
60546
+ if (refreshCornerCustomMergeContent && isCornerCustomMergeRange(mergeRange, table)) {
60547
+ queueCornerCustomMergeContentUpdate(mergeRange, table, pendingCornerCustomMergeRanges);
60548
+ }
60299
60549
  }
60300
60550
  else {
60301
60551
  const style = table._getCellStyle(cellGroup.col, cellGroup.row);
@@ -60304,33 +60554,35 @@
60304
60554
  }
60305
60555
  }
60306
60556
 
60307
- function updateColWidth(scene, col, detaX, skipTableWidthMap) {
60557
+ function updateColWidth(scene, col, detaX, skipTableWidthMap, pendingCornerCustomMergeRanges) {
60558
+ const shouldFlushCornerCustomMergeRanges = !pendingCornerCustomMergeRanges;
60559
+ pendingCornerCustomMergeRanges ??= new Map();
60308
60560
  if (!skipTableWidthMap) {
60309
60561
  scene.table._setColWidth(col, scene.table.getColWidth(col) + detaX, true);
60310
60562
  }
60311
60563
  const colOrCornerHeaderColumn = scene.getColGroup(col, true);
60312
60564
  const rightTopColumn = scene.getColGroupInRightTopCorner(col);
60313
60565
  if (colOrCornerHeaderColumn && !rightTopColumn) {
60314
- updateColunmWidth(colOrCornerHeaderColumn, detaX, 'col-corner', scene);
60566
+ updateColunmWidth(colOrCornerHeaderColumn, detaX, 'col-corner', scene, pendingCornerCustomMergeRanges);
60315
60567
  }
60316
60568
  if (rightTopColumn) {
60317
- updateColunmWidth(rightTopColumn, detaX, 'right-top', scene);
60569
+ updateColunmWidth(rightTopColumn, detaX, 'right-top', scene, pendingCornerCustomMergeRanges);
60318
60570
  }
60319
60571
  const rowHeaderOrBodyColumn = scene.getColGroup(col);
60320
60572
  if (rowHeaderOrBodyColumn) {
60321
- updateColunmWidth(rowHeaderOrBodyColumn, detaX, 'row-body', scene);
60573
+ updateColunmWidth(rowHeaderOrBodyColumn, detaX, 'row-body', scene, pendingCornerCustomMergeRanges);
60322
60574
  }
60323
60575
  const leftBottomColumn = scene.getColGroupInLeftBottomCorner(col);
60324
60576
  if (leftBottomColumn) {
60325
- updateColunmWidth(leftBottomColumn, detaX, 'left-bottom', scene);
60577
+ updateColunmWidth(leftBottomColumn, detaX, 'left-bottom', scene, pendingCornerCustomMergeRanges);
60326
60578
  }
60327
60579
  const bottomColumn = scene.getColGroupInBottom(col);
60328
60580
  if (bottomColumn) {
60329
- updateColunmWidth(bottomColumn, detaX, 'bottom', scene);
60581
+ updateColunmWidth(bottomColumn, detaX, 'bottom', scene, pendingCornerCustomMergeRanges);
60330
60582
  }
60331
60583
  const rightBottomColumn = scene.getColGroupInRightBottomCorner(col);
60332
60584
  if (rightBottomColumn) {
60333
- updateColunmWidth(rightBottomColumn, detaX, 'right-bottom', scene);
60585
+ updateColunmWidth(rightBottomColumn, detaX, 'right-bottom', scene, pendingCornerCustomMergeRanges);
60334
60586
  }
60335
60587
  if (col < scene.frozenColCount) {
60336
60588
  scene.cornerHeaderGroup.forEachChildrenSkipChild((column, index) => {
@@ -60377,13 +60629,16 @@
60377
60629
  }
60378
60630
  });
60379
60631
  }
60632
+ if (shouldFlushCornerCustomMergeRanges) {
60633
+ flushCornerCustomMergeContentUpdates(pendingCornerCustomMergeRanges, scene.table);
60634
+ }
60380
60635
  }
60381
- function updateColunmWidth(columnGroup, detaX, mode, scene) {
60636
+ function updateColunmWidth(columnGroup, detaX, mode, scene, pendingCornerCustomMergeRanges) {
60382
60637
  let needRerangeRow = false;
60383
60638
  const oldColumnWidth = columnGroup?.attribute.width ?? 0;
60384
60639
  columnGroup?.setAttribute('width', oldColumnWidth + detaX);
60385
60640
  columnGroup?.forEachChildren((cell, index) => {
60386
- const isHeightChange = updateCellWidth(scene, cell, cell.col, cell.row, oldColumnWidth, oldColumnWidth + detaX, detaX, mode === 'row-body' ? cell.col < scene.table.rowHeaderLevelCount : true, scene.table.internalProps.autoWrapText);
60641
+ const isHeightChange = updateCellWidth(scene, cell, cell.col, cell.row, oldColumnWidth, oldColumnWidth + detaX, detaX, mode === 'row-body' ? cell.col < scene.table.rowHeaderLevelCount : true, scene.table.internalProps.autoWrapText, pendingCornerCustomMergeRanges);
60387
60642
  if (isHeightChange) {
60388
60643
  const mergeInfo = getCellMergeInfo(scene.table, cell.col, cell.row);
60389
60644
  if (mergeInfo && mergeInfo.end.row - mergeInfo.start.row) {
@@ -60470,7 +60725,7 @@
60470
60725
  }
60471
60726
  }
60472
60727
  }
60473
- function updateCellWidth(scene, cell, col, row, oldWidth, distWidth, detaX, isHeader, autoWrapText) {
60728
+ function updateCellWidth(scene, cell, col, row, oldWidth, distWidth, detaX, isHeader, autoWrapText, pendingCornerCustomMergeRanges) {
60474
60729
  if (cell.attribute.width === distWidth && !cell.needUpdateWidth) {
60475
60730
  return false;
60476
60731
  }
@@ -60502,7 +60757,7 @@
60502
60757
  cellGroup.removeChild(oldBarCell);
60503
60758
  oldBarCell.removeAllChild();
60504
60759
  oldBarCell.release();
60505
- const cellChange = updateMergeCellContentWidth(cellGroup, distWidth, detaX, autoRowHeight, true, scene.table);
60760
+ const cellChange = updateMergeCellContentWidth(cellGroup, distWidth, detaX, autoRowHeight, true, scene.table, true, pendingCornerCustomMergeRanges);
60506
60761
  isHeightChange = isHeightChange || cellChange;
60507
60762
  }
60508
60763
  else if (type === 'sparkline') {
@@ -60535,6 +60790,15 @@
60535
60790
  const customContainer = cell.getChildByName(CUSTOM_CONTAINER_NAME) ||
60536
60791
  cell.getChildByName(CUSTOM_MERGE_CONTAINER_NAME);
60537
60792
  if (customContainer) {
60793
+ if (scene.table.reactCustomLayout) {
60794
+ const mergeRange = isMergeCellGroup(cellGroup)
60795
+ ? scene.table.getCellRange(cellGroup.mergeStartCol, cellGroup.mergeStartRow)
60796
+ : undefined;
60797
+ const shouldUseMergeStart = mergeRange && isCornerCustomMergeRange(mergeRange, scene.table);
60798
+ const removeCol = shouldUseMergeStart ? mergeRange.start.col : col;
60799
+ const removeRow = shouldUseMergeStart ? mergeRange.start.row : row;
60800
+ scene.table.reactCustomLayout.removeCustomCell(removeCol, removeRow);
60801
+ }
60538
60802
  let customElementsGroup;
60539
60803
  cell.removeChild(customContainer);
60540
60804
  const customMergeRange = getCustomCellMergeCustom(col, row, cell, scene.table);
@@ -60546,8 +60810,10 @@
60546
60810
  const mergedCell = scene.getCell(mergeCol, row);
60547
60811
  const customContainer = mergedCell.getChildByName(CUSTOM_CONTAINER_NAME) ||
60548
60812
  mergedCell.getChildByName(CUSTOM_MERGE_CONTAINER_NAME);
60549
- customContainer.removeAllChild();
60550
- mergedCell.removeChild(customContainer);
60813
+ if (customContainer) {
60814
+ customContainer.removeAllChild();
60815
+ mergedCell.removeChild(customContainer);
60816
+ }
60551
60817
  getCustomCellMergeCustom(mergeCol, row, mergedCell, scene.table);
60552
60818
  }
60553
60819
  }
@@ -60578,7 +60844,14 @@
60578
60844
  }
60579
60845
  }
60580
60846
  }
60581
- if (customLayout || customRender) {
60847
+ const mergeRange = isMergeCellGroup(cellGroup)
60848
+ ? scene.table.getCellRange(cellGroup.mergeStartCol, cellGroup.mergeStartRow)
60849
+ : undefined;
60850
+ const shouldRenderContent = shouldRenderCornerCustomMergeContent(col, row, mergeRange, scene.table);
60851
+ if (!shouldRenderContent) {
60852
+ renderDefault = false;
60853
+ }
60854
+ else if (customLayout || customRender) {
60582
60855
  const style = scene.table._getCellStyle(col, row);
60583
60856
  const padding = getQuadProps(getProp('padding', style, col, row, scene.table));
60584
60857
  let width = cellGroup.attribute.width;
@@ -60587,13 +60860,14 @@
60587
60860
  width = scene.table.getColsWidth(cellGroup.mergeStartCol, cellGroup.mergeEndCol);
60588
60861
  height = scene.table.getRowsHeight(cellGroup.mergeStartRow, cellGroup.mergeEndRow);
60589
60862
  }
60590
- const customResult = dealWithCustom(customLayout, customRender, col, row, width, height, false, scene.table.isAutoRowHeight(row), padding, isMergeCellGroup(cellGroup)
60591
- ? {
60592
- start: { col: cellGroup.mergeStartCol, row: cellGroup.mergeStartRow },
60593
- end: { col: cellGroup.mergeEndCol, row: cellGroup.mergeEndRow }
60594
- }
60595
- : undefined, scene.table);
60596
- customElementsGroup = customResult.elementsGroup;
60863
+ let customCol = col;
60864
+ let customRow = row;
60865
+ if (mergeRange && isCornerCustomMergeRange(mergeRange, scene.table)) {
60866
+ customCol = mergeRange.start.col;
60867
+ customRow = mergeRange.start.row;
60868
+ }
60869
+ const customResult = dealWithCustom(customLayout, customRender, customCol, customRow, width, height, false, scene.table.isAutoRowHeight(row), padding, mergeRange, scene.table);
60870
+ customElementsGroup = createCornerCustomMergeContainer(customResult.elementsGroup, width, height, mergeRange, scene.table);
60597
60871
  renderDefault = customResult.renderDefault;
60598
60872
  isHeightChange = true;
60599
60873
  }
@@ -60603,9 +60877,15 @@
60603
60877
  else if (customElementsGroup) {
60604
60878
  cell.appendChild(customElementsGroup);
60605
60879
  }
60880
+ if (isMergeCellGroup(cellGroup)) {
60881
+ const mergeRange = scene.table.getCellRange(cellGroup.mergeStartCol, cellGroup.mergeStartRow);
60882
+ if (isCornerCustomMergeRange(mergeRange, scene.table)) {
60883
+ cell.setAttribute('clip', !shouldRenderCornerCustomMergeContent(col, row, mergeRange, scene.table));
60884
+ }
60885
+ }
60606
60886
  }
60607
60887
  }
60608
- const cellChange = updateMergeCellContentWidth(cellGroup, distWidth, detaX, autoRowHeight, renderDefault, scene.table);
60888
+ const cellChange = updateMergeCellContentWidth(cellGroup, distWidth, detaX, autoRowHeight, renderDefault, scene.table, !customContainer, pendingCornerCustomMergeRanges);
60609
60889
  isHeightChange = isHeightChange || cellChange;
60610
60890
  }
60611
60891
  if (!autoWrapText) {
@@ -60614,7 +60894,7 @@
60614
60894
  }
60615
60895
  return autoRowHeight && autoWrapText ? isHeightChange : false;
60616
60896
  }
60617
- function updateMergeCellContentWidth(cellGroup, distWidth, detaX, autoRowHeight, renderDefault, table) {
60897
+ function updateMergeCellContentWidth(cellGroup, distWidth, detaX, autoRowHeight, renderDefault, table, refreshCornerCustomMergeContent = true, pendingCornerCustomMergeRanges) {
60618
60898
  if (isMergeCellGroup(cellGroup)) {
60619
60899
  distWidth = 0;
60620
60900
  let isHeightChange = false;
@@ -60676,6 +60956,10 @@
60676
60956
  isHeightChange = isHeightChange || changed;
60677
60957
  }
60678
60958
  }
60959
+ const mergeRange = table.getCellRange(cellGroup.mergeStartCol, cellGroup.mergeStartRow);
60960
+ if (refreshCornerCustomMergeContent && isCornerCustomMergeRange(mergeRange, table)) {
60961
+ queueCornerCustomMergeContentUpdate(mergeRange, table, pendingCornerCustomMergeRanges);
60962
+ }
60679
60963
  return isHeightChange;
60680
60964
  }
60681
60965
  const style = table._getCellStyle(cellGroup.col, cellGroup.row);
@@ -62734,9 +63018,7 @@
62734
63018
  return undefined;
62735
63019
  }
62736
63020
  function shouldSkipCustomRenderCellValueForComputation(col, row, table) {
62737
- return (table.isListTable() &&
62738
- !table.isHeader(col, row) &&
62739
- !table.internalProps.dataSource?.dataSourceObj?.records);
63021
+ return (table.isListTable() && !table.isHeader(col, row) && !table.internalProps.dataSource?.dataSourceObj?.records);
62740
63022
  }
62741
63023
  function computeTextWidth(col, row, cellType, table) {
62742
63024
  let maxWidth = 0;
@@ -62896,6 +63178,10 @@
62896
63178
  const minWidthColumnMap = new Map();
62897
63179
  for (let col = startCol; col < endColPlus1; col++) {
62898
63180
  const width = update ? newWidths[col] ?? table.getColWidth(col) : table.getColWidth(col);
63181
+ if (table.widthMode === 'adaptive' && table.internalProps._widthResizedColMap.has(col)) {
63182
+ totalDrawWidth -= width;
63183
+ continue;
63184
+ }
62899
63185
  const maxWidth = table.getMaxColWidth(col);
62900
63186
  const minWidth = table.getMinColWidth(col);
62901
63187
  actualWidth += width;
@@ -63351,7 +63637,9 @@
63351
63637
  let targetRow = distRow;
63352
63638
  while (targetRow < bodyBottomRow && table.getRowsHeight(table.frozenRowCount, targetRow) < visibleBodyHeight) {
63353
63639
  const nextRow = targetRow + 1;
63354
- computeRowsHeight(table, nextRow, nextRow, false);
63640
+ if (!table.internalProps._heightResizedRowMap.has(nextRow)) {
63641
+ computeRowsHeight(table, nextRow, nextRow, false);
63642
+ }
63355
63643
  targetRow = nextRow;
63356
63644
  }
63357
63645
  return targetRow;
@@ -63389,18 +63677,34 @@
63389
63677
  distRow = Math.min(proxy.firstScreenRowLimit - 1, table.rowCount - 1);
63390
63678
  }
63391
63679
  let bodyDistRow = Math.min(proxy.bodyBottomRow, distRow - table.bottomFrozenRowCount);
63392
- if (table.internalProps._widthResizedColMap.size === 0) {
63393
- computeColsWidth(table, 0, distColForCompute ?? distCol);
63680
+ const colEndForCompute = distColForCompute ?? distCol;
63681
+ let hasUnresizedColumns = false;
63682
+ for (let col = 0; col <= colEndForCompute; col++) {
63683
+ if (!table.internalProps._widthResizedColMap.has(col)) {
63684
+ hasUnresizedColumns = true;
63685
+ break;
63686
+ }
63687
+ }
63688
+ if (hasUnresizedColumns) {
63689
+ computeColsWidth(table, 0, colEndForCompute);
63394
63690
  }
63395
- if (table.internalProps._heightResizedRowMap.size === 0) {
63396
- computeRowsHeight(table, 0, table.options.canvasHeight === 'auto' || table.options.customConfig?.forceComputeAllRowHeight
63397
- ? table.rowCount - 1
63398
- : distRowForCompute ?? distRow);
63399
- if (table.heightMode === 'autoHeight') {
63400
- bodyDistRow = fillVisibleBodyRows$1(proxy, bodyDistRow);
63401
- syncVisibleBodyRows(proxy, bodyDistRow);
63691
+ const rowEndForCompute = table.options.canvasHeight === 'auto' || table.options.customConfig?.forceComputeAllRowHeight
63692
+ ? table.rowCount - 1
63693
+ : distRowForCompute ?? distRow;
63694
+ let hasUnresizedRows = false;
63695
+ for (let row = 0; row <= rowEndForCompute; row++) {
63696
+ if (!table.internalProps._heightResizedRowMap.has(row)) {
63697
+ hasUnresizedRows = true;
63698
+ break;
63402
63699
  }
63403
63700
  }
63701
+ if (hasUnresizedRows) {
63702
+ computeRowsHeight(table, 0, rowEndForCompute);
63703
+ }
63704
+ if (table.heightMode === 'autoHeight') {
63705
+ bodyDistRow = fillVisibleBodyRows$1(proxy, bodyDistRow);
63706
+ syncVisibleBodyRows(proxy, bodyDistRow);
63707
+ }
63404
63708
  if (distCol < table.colCount - table.rightFrozenColCount) {
63405
63709
  if (table.colCount - table.rightFrozenColCount <= table.colCount - 1) {
63406
63710
  computeColsWidth(table, table.colCount - table.rightFrozenColCount, table.colCount - 1);
@@ -68337,6 +68641,8 @@
68337
68641
  this.table.reactCustomLayout?.clearCache();
68338
68642
  }
68339
68643
  releaseStage() {
68644
+ this.clear = true;
68645
+ this._needUpdateContainer = false;
68340
68646
  const releaseAppRef = this.releaseVRenderAppRef;
68341
68647
  this.releaseVRenderAppRef = undefined;
68342
68648
  try {
@@ -68651,8 +68957,8 @@
68651
68957
  moveSelectingRangeComponentsToSelectedRangeComponents(this);
68652
68958
  });
68653
68959
  }
68654
- updateColWidth(col, detaX, skipUpdateContainer, skipTableWidthMap) {
68655
- updateColWidth(this, col, Math.round(detaX), skipTableWidthMap);
68960
+ updateColWidth(col, detaX, skipUpdateContainer, skipTableWidthMap, pendingCornerCustomMergeRanges) {
68961
+ updateColWidth(this, col, Math.round(detaX), skipTableWidthMap, pendingCornerCustomMergeRanges);
68656
68962
  if (!skipUpdateContainer) {
68657
68963
  this.updateContainer({ async: true });
68658
68964
  }
@@ -69042,9 +69348,9 @@
69042
69348
  }
69043
69349
  }
69044
69350
  }
69045
- updateRowHeight(row, detaY, skipTableHeightMap) {
69351
+ updateRowHeight(row, detaY, skipTableHeightMap, pendingCornerCustomMergeRanges) {
69046
69352
  detaY = Math.round(detaY);
69047
- updateRowHeight(this, row, detaY, skipTableHeightMap);
69353
+ updateRowHeight(this, row, detaY, skipTableHeightMap, pendingCornerCustomMergeRanges);
69048
69354
  this.updateContainerHeight(row, detaY);
69049
69355
  }
69050
69356
  updateRowsHeight(rows, detaYs, skipTableHeightMap) {
@@ -69539,6 +69845,10 @@
69539
69845
  if (!this._needUpdateContainer) {
69540
69846
  this._needUpdateContainer = true;
69541
69847
  setTimeout(() => {
69848
+ if (!this._needUpdateContainer || this.clear) {
69849
+ this._needUpdateContainer = false;
69850
+ return;
69851
+ }
69542
69852
  this.updateContainerSync(updateConfig.needUpdateCellY ?? false);
69543
69853
  }, 0);
69544
69854
  }
@@ -71418,19 +71728,22 @@
71418
71728
  state.table.scenegraph.updateNextFrame();
71419
71729
  }
71420
71730
  function updateResizeColForColumn(detaX, state) {
71731
+ const pendingCornerCustomMergeRanges = new Map();
71421
71732
  if (state.table.widthMode === 'adaptive' && state.columnResize.col < state.table.colCount - 1) {
71422
- state.table.scenegraph.updateColWidth(state.columnResize.col, detaX);
71423
- state.table.scenegraph.updateColWidth(state.columnResize.col + 1, -detaX);
71733
+ state.table.scenegraph.updateColWidth(state.columnResize.col, detaX, undefined, undefined, pendingCornerCustomMergeRanges);
71734
+ state.table.scenegraph.updateColWidth(state.columnResize.col + 1, -detaX, undefined, undefined, pendingCornerCustomMergeRanges);
71424
71735
  state.table.internalProps._widthResizedColMap.add(state.columnResize.col);
71425
71736
  state.table.internalProps._widthResizedColMap.add(state.columnResize.col + 1);
71426
71737
  }
71427
71738
  else {
71428
- state.table.scenegraph.updateColWidth(state.columnResize.col, detaX);
71739
+ state.table.scenegraph.updateColWidth(state.columnResize.col, detaX, undefined, undefined, pendingCornerCustomMergeRanges);
71429
71740
  state.table.internalProps._widthResizedColMap.add(state.columnResize.col);
71430
71741
  }
71742
+ flushCornerCustomMergeContentUpdates(pendingCornerCustomMergeRanges, state.table);
71431
71743
  }
71432
71744
  function updateResizeColForAll$1(detaX, state) {
71433
71745
  const layout = state.table.internalProps.layoutMap;
71746
+ const pendingCornerCustomMergeRanges = new Map();
71434
71747
  for (let col = state.table.frozenColCount; col < state.table.colCount - state.table.rightFrozenColCount; col++) {
71435
71748
  if (!(state.table.internalProps.transpose || (state.table.isPivotTable() && !layout.indicatorsAsCol))) {
71436
71749
  const cellDefine = layout.getBody(col, state.table.columnHeaderLevelCount);
@@ -71438,9 +71751,10 @@
71438
71751
  continue;
71439
71752
  }
71440
71753
  }
71441
- state.table.scenegraph.updateColWidth(col, detaX);
71754
+ state.table.scenegraph.updateColWidth(col, detaX, undefined, undefined, pendingCornerCustomMergeRanges);
71442
71755
  state.table.internalProps._widthResizedColMap.add(col);
71443
71756
  }
71757
+ flushCornerCustomMergeContentUpdates(pendingCornerCustomMergeRanges, state.table);
71444
71758
  }
71445
71759
  function updateResizeColForIndicator$1(detaX, state) {
71446
71760
  const layout = state.table.internalProps.layoutMap;
@@ -71456,21 +71770,23 @@
71456
71770
  resizeDimensionKey = headerPath.dimensionKey;
71457
71771
  resizeDimensionValue = headerPath.value;
71458
71772
  }
71773
+ const pendingCornerCustomMergeRanges = new Map();
71459
71774
  for (let col = state.table.rowHeaderLevelCount; col < state.table.colCount - state.table.rightFrozenColCount; col++) {
71460
71775
  const indicatorKey = layout.getIndicatorKey(col, state.table.columnHeaderLevelCount);
71461
71776
  if (layout.indicatorsAsCol && indicatorKey === resizeIndicatorKey) {
71462
- state.table.scenegraph.updateColWidth(col, detaX);
71777
+ state.table.scenegraph.updateColWidth(col, detaX, undefined, undefined, pendingCornerCustomMergeRanges);
71463
71778
  state.table.internalProps._widthResizedColMap.add(col);
71464
71779
  }
71465
71780
  else if (!layout.indicatorsAsCol) {
71466
71781
  const headerPaths = layout.getCellHeaderPaths(col, state.table.columnHeaderLevelCount - 1);
71467
71782
  const headerPath = headerPaths?.colHeaderPaths[headerPaths.colHeaderPaths.length - 1];
71468
71783
  if (headerPath && resizeDimensionKey === headerPath.dimensionKey && resizeDimensionValue === headerPath.value) {
71469
- state.table.scenegraph.updateColWidth(col, detaX);
71784
+ state.table.scenegraph.updateColWidth(col, detaX, undefined, undefined, pendingCornerCustomMergeRanges);
71470
71785
  state.table.internalProps._widthResizedColMap.add(col);
71471
71786
  }
71472
71787
  }
71473
71788
  }
71789
+ flushCornerCustomMergeContentUpdates(pendingCornerCustomMergeRanges, state.table);
71474
71790
  }
71475
71791
  function updateResizeColForIndicatorGroup$1(detaX, state) {
71476
71792
  const layout = state.table.internalProps.layoutMap;
@@ -71480,6 +71796,7 @@
71480
71796
  const endCol = node.startInTotal + state.table.frozenColCount + node.size - 1;
71481
71797
  const totalColWidth = state.table.getColsWidth(startCol, endCol);
71482
71798
  const moveX = detaX;
71799
+ const pendingCornerCustomMergeRanges = new Map();
71483
71800
  for (let col = startCol; col <= endCol; col++) {
71484
71801
  if (!(state.table.internalProps.transpose || (state.table.isPivotTable() && !layout.indicatorsAsCol))) {
71485
71802
  const cellDefine = layout.getBody(col, state.table.columnHeaderLevelCount);
@@ -71495,9 +71812,10 @@
71495
71812
  else if (deltaWidth < 0 && deltaWidth >= -0.5) {
71496
71813
  deltaWidth = -0.5;
71497
71814
  }
71498
- state.table.scenegraph.updateColWidth(col, deltaWidth);
71815
+ state.table.scenegraph.updateColWidth(col, deltaWidth, undefined, undefined, pendingCornerCustomMergeRanges);
71499
71816
  state.table.internalProps._widthResizedColMap.add(col);
71500
71817
  }
71818
+ flushCornerCustomMergeContentUpdates(pendingCornerCustomMergeRanges, state.table);
71501
71819
  }
71502
71820
 
71503
71821
  function setRadioState(col, row, field, type, indexInCell, state) {
@@ -72339,22 +72657,26 @@
72339
72657
  state.table.scenegraph.updateNextFrame();
72340
72658
  }
72341
72659
  function updateResizeColForRow(detaY, state) {
72660
+ const pendingCornerCustomMergeRanges = new Map();
72342
72661
  if (state.table.heightMode === 'adaptive' && state.rowResize.row < state.table.rowCount - 1) {
72343
- state.table.scenegraph.updateRowHeight(state.rowResize.row, detaY);
72344
- state.table.scenegraph.updateRowHeight(state.rowResize.row + 1, -detaY);
72662
+ state.table.scenegraph.updateRowHeight(state.rowResize.row, detaY, undefined, pendingCornerCustomMergeRanges);
72663
+ state.table.scenegraph.updateRowHeight(state.rowResize.row + 1, -detaY, undefined, pendingCornerCustomMergeRanges);
72345
72664
  state.table.internalProps._heightResizedRowMap.add(state.rowResize.row);
72346
72665
  state.table.internalProps._heightResizedRowMap.add(state.rowResize.row + 1);
72347
72666
  }
72348
72667
  else {
72349
- state.table.scenegraph.updateRowHeight(state.rowResize.row, detaY);
72668
+ state.table.scenegraph.updateRowHeight(state.rowResize.row, detaY, undefined, pendingCornerCustomMergeRanges);
72350
72669
  state.table.internalProps._heightResizedRowMap.add(state.rowResize.row);
72351
72670
  }
72671
+ flushCornerCustomMergeContentUpdates(pendingCornerCustomMergeRanges, state.table);
72352
72672
  }
72353
72673
  function updateResizeColForAll(detaY, state) {
72674
+ const pendingCornerCustomMergeRanges = new Map();
72354
72675
  for (let row = state.table.frozenRowCount; row < state.table.rowCount - state.table.bottomFrozenRowCount; row++) {
72355
- state.table.scenegraph.updateRowHeight(row, detaY);
72676
+ state.table.scenegraph.updateRowHeight(row, detaY, undefined, pendingCornerCustomMergeRanges);
72356
72677
  state.table.internalProps._heightResizedRowMap.add(row);
72357
72678
  }
72679
+ flushCornerCustomMergeContentUpdates(pendingCornerCustomMergeRanges, state.table);
72358
72680
  }
72359
72681
  function updateResizeColForIndicator(detaY, state) {
72360
72682
  const layout = state.table.internalProps.layoutMap;
@@ -72370,21 +72692,23 @@
72370
72692
  resizeDimensionKey = headerPath?.dimensionKey;
72371
72693
  resizeDimensionValue = headerPath?.value;
72372
72694
  }
72695
+ const pendingCornerCustomMergeRanges = new Map();
72373
72696
  for (let row = state.table.columnHeaderLevelCount; row < state.table.rowCount - state.table.bottomFrozenRowCount; row++) {
72374
72697
  const indicatorKey = layout.getIndicatorKey(state.table.rowHeaderLevelCount, row);
72375
72698
  if (!layout.indicatorsAsCol && indicatorKey === resizeIndicatorKey) {
72376
- state.table.scenegraph.updateRowHeight(row, detaY);
72699
+ state.table.scenegraph.updateRowHeight(row, detaY, undefined, pendingCornerCustomMergeRanges);
72377
72700
  state.table.internalProps._heightResizedRowMap.add(row);
72378
72701
  }
72379
72702
  else if (layout.indicatorsAsCol) {
72380
72703
  const headerPaths = layout.getCellHeaderPaths(state.table.rowHeaderLevelCount - 1, row);
72381
72704
  const headerPath = headerPaths?.rowHeaderPaths?.[headerPaths.rowHeaderPaths.length - 1];
72382
72705
  if (headerPath && resizeDimensionKey === headerPath.dimensionKey && resizeDimensionValue === headerPath.value) {
72383
- state.table.scenegraph.updateRowHeight(row, detaY);
72706
+ state.table.scenegraph.updateRowHeight(row, detaY, undefined, pendingCornerCustomMergeRanges);
72384
72707
  state.table.internalProps._heightResizedRowMap.add(row);
72385
72708
  }
72386
72709
  }
72387
72710
  }
72711
+ flushCornerCustomMergeContentUpdates(pendingCornerCustomMergeRanges, state.table);
72388
72712
  }
72389
72713
  function updateResizeColForIndicatorGroup(detaY, state) {
72390
72714
  const layout = state.table.internalProps.layoutMap;
@@ -72394,6 +72718,7 @@
72394
72718
  const endRow = node.startInTotal + state.table.frozenRowCount + node.size - 1;
72395
72719
  const totalRowHeight = state.table.getRowsHeight(startRow, endRow);
72396
72720
  const moveY = detaY;
72721
+ const pendingCornerCustomMergeRanges = new Map();
72397
72722
  for (let row = startRow; row <= endRow; row++) {
72398
72723
  const prevHeight = state.table.getRowHeight(row);
72399
72724
  let deltaHeight = (prevHeight / totalRowHeight) * moveY;
@@ -72403,9 +72728,10 @@
72403
72728
  else if (deltaHeight < 0 && deltaHeight >= -0.5) {
72404
72729
  deltaHeight = -0.51;
72405
72730
  }
72406
- state.table.scenegraph.updateRowHeight(row, deltaHeight);
72731
+ state.table.scenegraph.updateRowHeight(row, deltaHeight, undefined, pendingCornerCustomMergeRanges);
72407
72732
  state.table.internalProps._heightResizedRowMap.add(row);
72408
72733
  }
72734
+ flushCornerCustomMergeContentUpdates(pendingCornerCustomMergeRanges, state.table);
72409
72735
  }
72410
72736
 
72411
72737
  function updateCustomSelectBorder(scene, selectRange, style) {
@@ -74190,6 +74516,9 @@
74190
74516
  if (clickToPreview === false) {
74191
74517
  return;
74192
74518
  }
74519
+ if (!cellValue) {
74520
+ return;
74521
+ }
74193
74522
  const previewManager = getMediaPreviewManager(table);
74194
74523
  const overlay = document.createElement('div');
74195
74524
  overlay.style.width = '100%';
@@ -74227,6 +74556,9 @@
74227
74556
  if (clickToPreview === false) {
74228
74557
  return;
74229
74558
  }
74559
+ if (!cellValue) {
74560
+ return;
74561
+ }
74230
74562
  const previewManager = getMediaPreviewManager(table);
74231
74563
  const overlay = document.createElement('div');
74232
74564
  overlay.style.width = '100%';
@@ -74261,6 +74593,9 @@
74261
74593
  if (clickToPreview === false) {
74262
74594
  return;
74263
74595
  }
74596
+ if (!cellValue) {
74597
+ return;
74598
+ }
74264
74599
  const previewManager = getMediaPreviewManager(table);
74265
74600
  const overlay = document.createElement('div');
74266
74601
  overlay.style.width = '100%';
@@ -77066,7 +77401,17 @@
77066
77401
  _enableTableScroll = true;
77067
77402
  cutWaitPaste = false;
77068
77403
  clipboardCheckTimer = null;
77069
- cutOperationTime = 0;
77404
+ cutOperationId = 0;
77405
+ clipboardOperationId = 0;
77406
+ pasteOperationId = 0;
77407
+ pasteWriteInProgress = false;
77408
+ pasteWritePromise = Promise.resolve();
77409
+ clipboardWritePromise = Promise.resolve();
77410
+ lastCopiedClipboardData = null;
77411
+ internalFormulaHtmlMarkerId = 0;
77412
+ fieldKeyIds = new WeakMap();
77413
+ fieldKeyId = 0;
77414
+ activeCutState = null;
77070
77415
  lastClipboardContent = '';
77071
77416
  cutCellRange = null;
77072
77417
  cutRanges = null;
@@ -77446,6 +77791,9 @@
77446
77791
  return false;
77447
77792
  }
77448
77793
  release() {
77794
+ this.clipboardOperationId++;
77795
+ this.pasteOperationId++;
77796
+ this.resetCutState();
77449
77797
  this.gesture?.release();
77450
77798
  this.globalEventListeners.forEach(item => {
77451
77799
  if (item.env === 'document') {
@@ -77471,27 +77819,68 @@
77471
77819
  }
77472
77820
  async handleCopy(e, isCut = false) {
77473
77821
  const table = this.table;
77474
- !isCut && (this.cutWaitPaste = false);
77475
- this.copySourceRange = null;
77476
- const sourceRanges = table.stateManager.select.ranges;
77477
- if (sourceRanges && sourceRanges.length === 1) {
77478
- const sourceRange = sourceRanges[0];
77479
- this.copySourceRange = {
77480
- startCol: Math.min(sourceRange.start.col, sourceRange.end.col),
77481
- startRow: Math.min(sourceRange.start.row, sourceRange.end.row)
77482
- };
77822
+ const operationId = ++this.clipboardOperationId;
77823
+ this.pasteOperationId++;
77824
+ if (!isCut) {
77825
+ this.resetCutState();
77483
77826
  }
77484
- else if (!sourceRanges?.length) {
77827
+ const copySnapshot = this.getCopySnapshot(isCut);
77828
+ this.copySourceRange = null;
77829
+ this.lastCopiedClipboardData = null;
77830
+ if (!copySnapshot) {
77485
77831
  this.copySourceRange = null;
77486
- return;
77832
+ return null;
77487
77833
  }
77488
77834
  const data = this.table.getCopyValue(table.options.keyboardOptions?.getCopyCellValue?.value);
77489
77835
  if (isValid$1(data)) {
77490
77836
  e.preventDefault();
77837
+ let copySucceeded = false;
77838
+ let copiedClipboardData = null;
77839
+ const canUseAsyncClipboard = window.isSecureContext && !!navigator.clipboard?.writeText;
77840
+ const canWriteRichClipboard = window.isSecureContext && !!navigator.clipboard?.write && !!window.ClipboardItem;
77841
+ const hasEventClipboard = !!e.clipboardData;
77842
+ const dataHTML = !canUseAsyncClipboard || canWriteRichClipboard || hasEventClipboard ? this.getCopyDataHTML(data) : null;
77843
+ const formulaClipboardData = this.getCopyFormulaPlainData(data, isCut);
77844
+ if (formulaClipboardData === null) {
77845
+ return null;
77846
+ }
77847
+ const plainClipboardData = data;
77848
+ const internalFormulaText = formulaClipboardData !== plainClipboardData ? formulaClipboardData : undefined;
77849
+ const internalFormulaHtmlMarker = internalFormulaText ? this.createInternalFormulaHtmlMarker() : undefined;
77850
+ const clipboardHTML = dataHTML && internalFormulaHtmlMarker
77851
+ ? this.attachInternalFormulaHtmlMarker(dataHTML, internalFormulaHtmlMarker)
77852
+ : dataHTML;
77853
+ const eventClipboardWriteData = hasEventClipboard
77854
+ ? this.setCopyDataToEventClipboard(plainClipboardData, clipboardHTML, e, internalFormulaText, internalFormulaHtmlMarker)
77855
+ : null;
77856
+ if (eventClipboardWriteData) {
77857
+ copiedClipboardData = eventClipboardWriteData;
77858
+ this.lastCopiedClipboardData = copiedClipboardData;
77859
+ if (isCut) {
77860
+ this.lastClipboardContent = this.getClipboardSignature(copiedClipboardData);
77861
+ copySnapshot.clipboardData = copiedClipboardData;
77862
+ copySnapshot.clipboardSignature = this.lastClipboardContent;
77863
+ }
77864
+ this.copySourceRange = copySnapshot.copySourceRange;
77865
+ this.afterCopyData(data, isCut, copySnapshot, !isCut);
77866
+ if (isCut && table.keyboardOptions?.showCopyCellBorder) {
77867
+ window.setTimeout(() => {
77868
+ if (!this.isClipboardOperationCurrent(operationId)) {
77869
+ return;
77870
+ }
77871
+ setActiveCellRangeState(table, copySnapshot.ranges);
77872
+ table.clearSelected();
77873
+ }, 0);
77874
+ }
77875
+ return copySnapshot;
77876
+ }
77491
77877
  const element = table.getElement();
77492
77878
  if (element && element !== document.activeElement) {
77493
77879
  element.focus();
77494
77880
  await new Promise(resolve => setTimeout(resolve, 10));
77881
+ if (!this.isClipboardOperationCurrent(operationId)) {
77882
+ return null;
77883
+ }
77495
77884
  }
77496
77885
  try {
77497
77886
  if (navigator.clipboard && navigator.clipboard.writeText) {
@@ -77502,6 +77891,9 @@
77502
77891
  name: 'clipboard-write'
77503
77892
  });
77504
77893
  hasPermission = permissionState.state === 'granted';
77894
+ if (!this.isClipboardOperationCurrent(operationId)) {
77895
+ return null;
77896
+ }
77505
77897
  }
77506
77898
  catch (permissionError) {
77507
77899
  hasPermission = true;
@@ -77509,56 +77901,395 @@
77509
77901
  }
77510
77902
  if (hasPermission) {
77511
77903
  try {
77512
- if (window.ClipboardItem) {
77513
- let htmlValues = data;
77514
- if (table.stateManager.select.ranges.length === 1 &&
77515
- table.options.keyboardOptions?.getCopyCellValue?.html) {
77516
- htmlValues = this.table.getCopyValue(table.options.keyboardOptions?.getCopyCellValue.html);
77517
- }
77518
- const dataHTML = setDataToHTML(htmlValues);
77519
- await navigator.clipboard.write([
77520
- new ClipboardItem({
77521
- 'text/html': new Blob([dataHTML], { type: 'text/html' }),
77522
- 'text/plain': new Blob([data], { type: 'text/plain' })
77523
- })
77524
- ]);
77904
+ if (!this.isClipboardOperationCurrent(operationId)) {
77905
+ return null;
77525
77906
  }
77526
- else {
77527
- await navigator.clipboard.writeText(data);
77907
+ copiedClipboardData = await this.queueClipboardWrite(async () => {
77908
+ if (!this.isClipboardOperationCurrent(operationId)) {
77909
+ return null;
77910
+ }
77911
+ if (canWriteRichClipboard && clipboardHTML) {
77912
+ await navigator.clipboard.write([
77913
+ new ClipboardItem({
77914
+ 'text/html': new Blob([clipboardHTML], { type: 'text/html' }),
77915
+ 'text/plain': new Blob([plainClipboardData], { type: 'text/plain' })
77916
+ })
77917
+ ]);
77918
+ return {
77919
+ html: clipboardHTML,
77920
+ text: plainClipboardData,
77921
+ hasHtml: true,
77922
+ hasText: true,
77923
+ internalFormulaText,
77924
+ internalFormulaHtmlMarker
77925
+ };
77926
+ }
77927
+ await navigator.clipboard.writeText(plainClipboardData);
77928
+ return { html: '', text: plainClipboardData, hasText: true, internalFormulaText };
77929
+ });
77930
+ if (copiedClipboardData) {
77931
+ copySucceeded = true;
77528
77932
  }
77529
77933
  }
77530
77934
  catch (clipboardError) {
77531
- this.fallbackCopyToClipboard(data, e);
77935
+ if (!this.isClipboardOperationCurrent(operationId)) {
77936
+ return null;
77937
+ }
77938
+ copySucceeded = this.fallbackCopyToClipboard(plainClipboardData);
77939
+ if (!this.isClipboardOperationCurrent(operationId)) {
77940
+ return null;
77941
+ }
77942
+ if (copySucceeded) {
77943
+ copiedClipboardData = { html: '', text: plainClipboardData, hasText: true, internalFormulaText };
77944
+ }
77532
77945
  }
77533
77946
  }
77534
77947
  else {
77535
- this.fallbackCopyToClipboard(data, e);
77948
+ copySucceeded = this.fallbackCopyToClipboard(plainClipboardData);
77949
+ if (copySucceeded) {
77950
+ copiedClipboardData = { html: '', text: plainClipboardData, hasText: true, internalFormulaText };
77951
+ }
77536
77952
  }
77537
77953
  }
77538
77954
  else {
77539
- this.fallbackCopyToClipboard(data, e);
77955
+ copySucceeded = this.fallbackCopyToClipboard(plainClipboardData);
77956
+ if (copySucceeded) {
77957
+ copiedClipboardData = { html: '', text: plainClipboardData, hasText: true, internalFormulaText };
77958
+ }
77540
77959
  }
77541
- table.fireListeners(TABLE_EVENT_TYPE.COPY_DATA, {
77542
- cellRange: table.stateManager.select.ranges,
77543
- copyData: data,
77544
- isCut
77545
- });
77960
+ if (!copySucceeded) {
77961
+ return null;
77962
+ }
77963
+ if (!this.isClipboardOperationCurrent(operationId)) {
77964
+ return null;
77965
+ }
77966
+ this.lastCopiedClipboardData = copiedClipboardData;
77967
+ if (isCut) {
77968
+ this.lastClipboardContent = this.getClipboardSignature(copiedClipboardData);
77969
+ copySnapshot.clipboardData = copiedClipboardData;
77970
+ copySnapshot.clipboardSignature = this.lastClipboardContent;
77971
+ }
77972
+ this.copySourceRange = copySnapshot.copySourceRange;
77973
+ this.afterCopyData(data, isCut, copySnapshot, false);
77546
77974
  }
77547
77975
  catch (error) {
77548
- this.fallbackCopyToClipboard(data, e);
77976
+ if (!this.isClipboardOperationCurrent(operationId)) {
77977
+ return null;
77978
+ }
77979
+ if (!this.fallbackCopyToClipboard(plainClipboardData)) {
77980
+ return null;
77981
+ }
77982
+ if (!this.isClipboardOperationCurrent(operationId)) {
77983
+ return null;
77984
+ }
77985
+ this.lastCopiedClipboardData = { html: '', text: plainClipboardData, hasText: true, internalFormulaText };
77986
+ if (isCut) {
77987
+ this.lastClipboardContent = this.getClipboardSignature(this.lastCopiedClipboardData);
77988
+ copySnapshot.clipboardData = this.lastCopiedClipboardData;
77989
+ copySnapshot.clipboardSignature = this.lastClipboardContent;
77990
+ }
77991
+ this.copySourceRange = copySnapshot.copySourceRange;
77992
+ this.afterCopyData(data, isCut, copySnapshot, false);
77549
77993
  }
77550
77994
  }
77995
+ else {
77996
+ return null;
77997
+ }
77551
77998
  if (table.keyboardOptions?.showCopyCellBorder) {
77552
- setActiveCellRangeState(table);
77999
+ setActiveCellRangeState(table, copySnapshot.ranges);
77553
78000
  table.clearSelected();
77554
78001
  }
78002
+ return copySnapshot;
77555
78003
  }
77556
- fallbackCopyToClipboard(data, e) {
78004
+ afterCopyData(data, isCut, copySnapshot, updateCopyCellBorder = true) {
78005
+ const table = this.table;
77557
78006
  try {
77558
- if (e.clipboardData) {
77559
- e.clipboardData.setData('text/plain', data);
77560
- return;
78007
+ table.fireListeners(TABLE_EVENT_TYPE.COPY_DATA, {
78008
+ cellRange: this.cloneRanges(copySnapshot.ranges),
78009
+ copyData: data,
78010
+ isCut
78011
+ });
78012
+ }
78013
+ catch (error) {
78014
+ }
78015
+ if (updateCopyCellBorder && table.keyboardOptions?.showCopyCellBorder) {
78016
+ setActiveCellRangeState(table, copySnapshot.ranges);
78017
+ table.clearSelected();
78018
+ }
78019
+ }
78020
+ getCopySnapshot(includeCellInfos) {
78021
+ const ranges = this.table.stateManager.select.ranges;
78022
+ if (!ranges?.length) {
78023
+ return null;
78024
+ }
78025
+ const clonedRanges = ranges.map(range => ({
78026
+ start: { col: range.start.col, row: range.start.row },
78027
+ end: { col: range.end.col, row: range.end.row }
78028
+ }));
78029
+ const sourceRange = ranges.length === 1 ? ranges[0] : null;
78030
+ const sourceCellMatrix = this.getSourceCellMatrix(clonedRanges);
78031
+ const sourceCells = this.getSourceCells(sourceCellMatrix);
78032
+ const sourceSize = this.getSourceSize(clonedRanges, sourceCellMatrix);
78033
+ return {
78034
+ ranges: clonedRanges,
78035
+ copySourceRange: sourceRange
78036
+ ? {
78037
+ startCol: Math.min(sourceRange.start.col, sourceRange.end.col),
78038
+ startRow: Math.min(sourceRange.start.row, sourceRange.end.row)
78039
+ }
78040
+ : null,
78041
+ cellInfos: includeCellInfos ? this.table.getSelectedCellInfos() : null,
78042
+ sourceCells,
78043
+ sourceCellMatrix,
78044
+ sourceColCount: sourceSize.colCount,
78045
+ sourceRowCount: sourceSize.rowCount,
78046
+ clipboardData: null,
78047
+ clipboardSignature: ''
78048
+ };
78049
+ }
78050
+ cloneRanges(ranges) {
78051
+ return ranges.map(range => ({
78052
+ start: { col: range.start.col, row: range.start.row },
78053
+ end: { col: range.end.col, row: range.end.row }
78054
+ }));
78055
+ }
78056
+ getSourceCellMatrix(ranges) {
78057
+ const table = this.table;
78058
+ const createSourceCell = (col, row) => {
78059
+ const recordShowIndex = table.getRecordShowIndexByCell?.(col, row);
78060
+ const recordIndex = recordShowIndex >= 0 ? table.dataSource?.getIndexKey?.(recordShowIndex) : undefined;
78061
+ const field = table.internalProps?.layoutMap?.getBody?.(col, row)?.field;
78062
+ return { col, row, recordIndex, field, value: table.getCellOriginValue?.(col, row) };
78063
+ };
78064
+ if (ranges.length === 1) {
78065
+ const range = ranges[0];
78066
+ const startCol = Math.min(range.start.col, range.end.col);
78067
+ const endCol = Math.max(range.start.col, range.end.col);
78068
+ const startRow = Math.min(range.start.row, range.end.row);
78069
+ const endRow = Math.max(range.start.row, range.end.row);
78070
+ const sourceCellMatrix = [];
78071
+ for (let row = startRow; row <= endRow; row++) {
78072
+ const rowCells = [];
78073
+ for (let col = startCol; col <= endCol; col++) {
78074
+ rowCells.push(createSourceCell(col, row));
78075
+ }
78076
+ sourceCellMatrix.push(rowCells);
78077
+ }
78078
+ return sourceCellMatrix;
78079
+ }
78080
+ let minCol = Math.min(ranges[0].start.col, ranges[0].end.col);
78081
+ let maxCol = Math.max(ranges[0].start.col, ranges[0].end.col);
78082
+ let minRow = Math.min(ranges[0].start.row, ranges[0].end.row);
78083
+ let maxRow = Math.max(ranges[0].start.row, ranges[0].end.row);
78084
+ ranges.forEach(range => {
78085
+ minCol = Math.min(minCol, range.start.col, range.end.col);
78086
+ maxCol = Math.max(maxCol, range.start.col, range.end.col);
78087
+ minRow = Math.min(minRow, range.start.row, range.end.row);
78088
+ maxRow = Math.max(maxRow, range.start.row, range.end.row);
78089
+ });
78090
+ const isExistDataInRow = (row) => ranges.some(range => {
78091
+ const startRow = Math.min(range.start.row, range.end.row);
78092
+ const endRow = Math.max(range.start.row, range.end.row);
78093
+ return startRow <= row && endRow >= row;
78094
+ });
78095
+ const isExistDataInCol = (col) => ranges.some(range => {
78096
+ const startCol = Math.min(range.start.col, range.end.col);
78097
+ const endCol = Math.max(range.start.col, range.end.col);
78098
+ return startCol <= col && endCol >= col;
78099
+ });
78100
+ const getRangeExistDataInCell = (col, row) => ranges.some(range => {
78101
+ const startRow = Math.min(range.start.row, range.end.row);
78102
+ const endRow = Math.max(range.start.row, range.end.row);
78103
+ const startCol = Math.min(range.start.col, range.end.col);
78104
+ const endCol = Math.max(range.start.col, range.end.col);
78105
+ return startCol <= col && endCol >= col && startRow <= row && endRow >= row;
78106
+ });
78107
+ const sourceCellMatrix = [];
78108
+ for (let row = minRow; row <= maxRow; row++) {
78109
+ if (!isExistDataInRow(row)) {
78110
+ continue;
78111
+ }
78112
+ const rowCells = [];
78113
+ for (let col = minCol; col <= maxCol; col++) {
78114
+ if (!isExistDataInCol(col)) {
78115
+ continue;
78116
+ }
78117
+ rowCells.push(getRangeExistDataInCell(col, row) ? createSourceCell(col, row) : null);
78118
+ }
78119
+ sourceCellMatrix.push(rowCells);
78120
+ }
78121
+ return sourceCellMatrix;
78122
+ }
78123
+ getSourceCells(sourceCellMatrix) {
78124
+ const sourceCells = [];
78125
+ for (let row = 0; row < sourceCellMatrix.length; row++) {
78126
+ for (let col = 0; col < sourceCellMatrix[row].length; col++) {
78127
+ const sourceCell = sourceCellMatrix[row][col];
78128
+ if (sourceCell) {
78129
+ sourceCells.push(sourceCell);
78130
+ }
78131
+ }
78132
+ }
78133
+ return sourceCells;
78134
+ }
78135
+ getSourceSize(ranges, sourceCellMatrix) {
78136
+ if (sourceCellMatrix.length) {
78137
+ return {
78138
+ colCount: sourceCellMatrix[0]?.length ?? 0,
78139
+ rowCount: sourceCellMatrix.length
78140
+ };
78141
+ }
78142
+ if (ranges.length === 1) {
78143
+ const range = ranges[0];
78144
+ return {
78145
+ colCount: Math.abs(range.end.col - range.start.col) + 1,
78146
+ rowCount: Math.abs(range.end.row - range.start.row) + 1
78147
+ };
78148
+ }
78149
+ return { colCount: 0, rowCount: 0 };
78150
+ }
78151
+ getClipboardSignature(data) {
78152
+ return data
78153
+ ? JSON.stringify({
78154
+ html: data.hasHtml ? data.html : null,
78155
+ text: data.hasText ? data.text : null
78156
+ })
78157
+ : '';
78158
+ }
78159
+ isClipboardOperationCurrent(operationId) {
78160
+ return operationId === this.clipboardOperationId && !this.table.isReleased;
78161
+ }
78162
+ isPasteOperationCurrent(operationId) {
78163
+ return (operationId === undefined || operationId === this.pasteOperationId) && !this.table.isReleased;
78164
+ }
78165
+ async queueClipboardWrite(write) {
78166
+ const previousWrite = this.clipboardWritePromise;
78167
+ let settleCurrentWrite = () => {
78168
+ return;
78169
+ };
78170
+ this.clipboardWritePromise = previousWrite
78171
+ .catch(() => {
78172
+ })
78173
+ .then(() => new Promise(resolve => {
78174
+ settleCurrentWrite = resolve;
78175
+ }));
78176
+ await previousWrite.catch(() => {
78177
+ });
78178
+ try {
78179
+ return await write();
78180
+ }
78181
+ finally {
78182
+ settleCurrentWrite();
78183
+ }
78184
+ }
78185
+ isClipboardDataChanged(clipboardData, cutState) {
78186
+ if (!clipboardData || clipboardData.readFailed) {
78187
+ return null;
78188
+ }
78189
+ const sourceData = cutState.clipboardData;
78190
+ if (!sourceData) {
78191
+ return this.getClipboardSignature(clipboardData) !== cutState.clipboardSignature;
78192
+ }
78193
+ if (sourceData.hasHtml && !clipboardData.hasHtml) {
78194
+ return null;
78195
+ }
78196
+ if (sourceData.hasText && !clipboardData.hasText) {
78197
+ return null;
78198
+ }
78199
+ let hasComparableType = false;
78200
+ if (clipboardData.hasHtml && sourceData.hasHtml) {
78201
+ hasComparableType = true;
78202
+ if (clipboardData.html !== sourceData.html) {
78203
+ return true;
78204
+ }
78205
+ }
78206
+ if (clipboardData.hasText && sourceData.hasText) {
78207
+ hasComparableType = true;
78208
+ if (clipboardData.text !== sourceData.text) {
78209
+ return true;
77561
78210
  }
78211
+ }
78212
+ if (hasComparableType) {
78213
+ return false;
78214
+ }
78215
+ return null;
78216
+ }
78217
+ isClipboardDataSameAsLastCopy(clipboardData) {
78218
+ const sourceData = this.lastCopiedClipboardData;
78219
+ if (!clipboardData || clipboardData.readFailed || !sourceData) {
78220
+ return false;
78221
+ }
78222
+ return this.isClipboardDataSameBySignature(clipboardData, sourceData);
78223
+ }
78224
+ isClipboardDataSameBySignature(clipboardData, sourceData) {
78225
+ return (sourceData.hasHtml === clipboardData.hasHtml &&
78226
+ sourceData.hasText === clipboardData.hasText &&
78227
+ (!sourceData.hasHtml || sourceData.html === clipboardData.html) &&
78228
+ (!sourceData.hasText || sourceData.text === clipboardData.text));
78229
+ }
78230
+ getCopyFormulaPlainData(data, isCut) {
78231
+ const table = this.table;
78232
+ if (table.stateManager.select.ranges.length !== 1 || !table.options.keyboardOptions?.getCopyCellValue?.html) {
78233
+ return data;
78234
+ }
78235
+ try {
78236
+ return this.table.getCopyValue(table.options.keyboardOptions.getCopyCellValue.html);
78237
+ }
78238
+ catch (error) {
78239
+ return isCut ? null : data;
78240
+ }
78241
+ }
78242
+ getCopyDataHTML(data) {
78243
+ const table = this.table;
78244
+ let htmlValues = data;
78245
+ try {
78246
+ if (table.stateManager.select.ranges.length === 1 &&
78247
+ table.options.keyboardOptions?.getCopyCellValue?.html) {
78248
+ htmlValues = this.table.getCopyValue(table.options.keyboardOptions?.getCopyCellValue.html);
78249
+ }
78250
+ return setDataToHTML(htmlValues);
78251
+ }
78252
+ catch (error) {
78253
+ try {
78254
+ return setDataToHTML(data);
78255
+ }
78256
+ catch (fallbackError) {
78257
+ return null;
78258
+ }
78259
+ }
78260
+ }
78261
+ createInternalFormulaHtmlMarker() {
78262
+ return `vtable-formula-${Date.now()}-${++this.internalFormulaHtmlMarkerId}`;
78263
+ }
78264
+ attachInternalFormulaHtmlMarker(html, marker) {
78265
+ return `${html}<!--${marker}-->`;
78266
+ }
78267
+ setCopyDataToEventClipboard(data, dataHTML, e, internalFormulaText, internalFormulaHtmlMarker) {
78268
+ const clipboardData = e.clipboardData;
78269
+ if (!clipboardData) {
78270
+ return null;
78271
+ }
78272
+ try {
78273
+ clipboardData.setData('text/plain', data);
78274
+ const copiedClipboardData = { html: '', text: data, hasText: true, internalFormulaText };
78275
+ if (dataHTML) {
78276
+ try {
78277
+ clipboardData.setData('text/html', dataHTML);
78278
+ copiedClipboardData.html = dataHTML;
78279
+ copiedClipboardData.hasHtml = true;
78280
+ copiedClipboardData.internalFormulaHtmlMarker = internalFormulaHtmlMarker;
78281
+ }
78282
+ catch (error) {
78283
+ }
78284
+ }
78285
+ return copiedClipboardData;
78286
+ }
78287
+ catch (error) {
78288
+ return null;
78289
+ }
78290
+ }
78291
+ fallbackCopyToClipboard(data) {
78292
+ try {
77562
78293
  if (document.activeElement && document.activeElement !== document.body) {
77563
78294
  document.activeElement.blur();
77564
78295
  }
@@ -77578,6 +78309,7 @@
77578
78309
  const successful = document.execCommand('copy');
77579
78310
  if (!successful) {
77580
78311
  }
78312
+ return successful;
77581
78313
  }
77582
78314
  catch (execError) {
77583
78315
  }
@@ -77587,321 +78319,648 @@
77587
78319
  }
77588
78320
  catch (error) {
77589
78321
  }
78322
+ return false;
77590
78323
  }
77591
78324
  async handleCut(e) {
77592
- this.handleCopy(e, true);
78325
+ const copySnapshot = await this.handleCopy(e, true);
78326
+ if (!copySnapshot) {
78327
+ return;
78328
+ }
78329
+ const cutState = {
78330
+ id: ++this.cutOperationId,
78331
+ ranges: this.cloneRanges(copySnapshot.ranges),
78332
+ cellInfos: copySnapshot.cellInfos,
78333
+ sourceCells: copySnapshot.sourceCells,
78334
+ sourceCellMatrix: copySnapshot.sourceCellMatrix,
78335
+ sourceColCount: copySnapshot.sourceColCount,
78336
+ sourceRowCount: copySnapshot.sourceRowCount,
78337
+ clipboardData: copySnapshot.clipboardData,
78338
+ clipboardSignature: copySnapshot.clipboardSignature,
78339
+ copySourceRange: copySnapshot.copySourceRange,
78340
+ isSingleRange: copySnapshot.ranges.length === 1
78341
+ };
77593
78342
  this.cutWaitPaste = true;
77594
- this.cutCellRange = this.table.getSelectedCellInfos();
77595
- this.cutRanges = this.table.stateManager.select.ranges?.map(r => ({
77596
- start: { col: r.start.col, row: r.start.row },
77597
- end: { col: r.end.col, row: r.end.row }
77598
- }));
78343
+ this.activeCutState = cutState;
78344
+ this.cutCellRange = cutState.cellInfos;
78345
+ this.cutRanges = cutState.ranges;
77599
78346
  if (this.clipboardCheckTimer) {
77600
78347
  clearTimeout(this.clipboardCheckTimer);
77601
78348
  }
77602
78349
  this.clipboardCheckTimer = window.setTimeout(() => {
77603
78350
  if (this.cutWaitPaste) {
77604
- this.cutWaitPaste = false;
77605
- this.cutCellRange = null;
77606
- this.cutRanges = null;
77607
- this.clipboardCheckTimer = null;
78351
+ this.resetCutState();
77608
78352
  }
77609
78353
  }, 30000);
77610
- this.saveClipboardContent();
78354
+ this.lastClipboardContent = cutState.clipboardSignature;
77611
78355
  }
77612
78356
  handlePaste(e) {
78357
+ const pasteOperationId = ++this.pasteOperationId;
78358
+ const pasteRange = this.getPasteRange();
78359
+ if (!pasteRange) {
78360
+ return;
78361
+ }
78362
+ const eventClipboardData = this.getEventClipboardData(e);
78363
+ const pasteCopySourceRange = this.copySourceRange;
77613
78364
  if (!this.cutWaitPaste) {
77614
- this.executePaste(e);
78365
+ this.readClipboardDataForPaste(eventClipboardData)
78366
+ .then(clipboardData => {
78367
+ if (!this.isPasteOperationCurrent(pasteOperationId)) {
78368
+ return;
78369
+ }
78370
+ const copySourceRange = this.isClipboardDataSameAsLastCopy(clipboardData) ? pasteCopySourceRange : null;
78371
+ this.executePaste(clipboardData, {
78372
+ pasteRange,
78373
+ copySourceRange,
78374
+ pasteOperationId
78375
+ });
78376
+ })
78377
+ .catch(error => {
78378
+ });
78379
+ return;
78380
+ }
78381
+ const cutState = this.activeCutState;
78382
+ if (!cutState) {
78383
+ this.executePaste(eventClipboardData, {
78384
+ pasteRange,
78385
+ copySourceRange: this.isClipboardDataSameAsLastCopy(eventClipboardData) ? pasteCopySourceRange : null,
78386
+ pasteOperationId
78387
+ });
77615
78388
  return;
77616
78389
  }
77617
- this.checkClipboardChanged()
77618
- .then(changed => {
77619
- this.executePaste(e);
77620
- if (!changed) {
77621
- this.clearCutArea(this.table);
78390
+ this.readClipboardDataForPaste(eventClipboardData)
78391
+ .then(async (clipboardData) => {
78392
+ if (!this.isPasteOperationCurrent(pasteOperationId) || this.activeCutState?.id !== cutState.id) {
78393
+ return;
77622
78394
  }
77623
- if (this.cutWaitPaste) {
77624
- this.cutWaitPaste = false;
77625
- this.cutCellRange = null;
77626
- this.cutRanges = null;
77627
- if (this.clipboardCheckTimer) {
77628
- clearTimeout(this.clipboardCheckTimer);
77629
- this.clipboardCheckTimer = null;
78395
+ const changed = this.isClipboardDataChanged(clipboardData, cutState);
78396
+ if (changed === null) {
78397
+ await this.executePaste(clipboardData, {
78398
+ pasteRange,
78399
+ copySourceRange: this.isClipboardDataSameAsLastCopy(clipboardData) ? pasteCopySourceRange : null,
78400
+ pasteOperationId
78401
+ });
78402
+ return;
78403
+ }
78404
+ const pasteResult = await this.executePaste(clipboardData, {
78405
+ pasteRange,
78406
+ copySourceRange: changed ? null : cutState.copySourceRange,
78407
+ cutState: changed ? null : cutState,
78408
+ pasteOperationId
78409
+ });
78410
+ if (!this.isPasteOperationCurrent(pasteOperationId) || this.activeCutState?.id !== cutState.id) {
78411
+ return;
78412
+ }
78413
+ if (!changed && pasteResult.pasted && this.activeCutState?.id === cutState.id) {
78414
+ if (pasteResult.migratedSourceCells.length === cutState.sourceCells.length) {
78415
+ const cleared = await this.clearCutArea(pasteResult.migratedSourceCells, pasteResult.changedCells);
78416
+ if (!cleared) {
78417
+ this.resetCutState();
78418
+ return;
78419
+ }
78420
+ if (this.activeCutState?.id === cutState.id) {
78421
+ this.resetCutState();
78422
+ }
77630
78423
  }
78424
+ return;
78425
+ }
78426
+ if (changed && this.activeCutState?.id === cutState.id) {
78427
+ this.resetCutState();
77631
78428
  }
77632
78429
  })
77633
- .catch(() => {
77634
- this.executePaste(e);
77635
- if (this.cutWaitPaste) {
77636
- this.cutWaitPaste = false;
77637
- this.cutCellRange = null;
77638
- if (this.clipboardCheckTimer) {
77639
- clearTimeout(this.clipboardCheckTimer);
77640
- this.clipboardCheckTimer = null;
77641
- }
78430
+ .catch(async () => {
78431
+ if (!this.isPasteOperationCurrent(pasteOperationId)) {
78432
+ return;
77642
78433
  }
78434
+ await this.executePaste(eventClipboardData, {
78435
+ pasteRange,
78436
+ copySourceRange: this.isClipboardDataSameAsLastCopy(eventClipboardData) ? pasteCopySourceRange : null,
78437
+ pasteOperationId
78438
+ });
77643
78439
  });
77644
78440
  }
77645
- async executePaste(e) {
78441
+ async executePaste(clipboardData, pasteContext) {
77646
78442
  const table = this.table;
77647
- if (table.editorManager?.editingEditor) {
77648
- return;
78443
+ const emptyResult = this.getEmptyPasteResult();
78444
+ const pasteClipboardData = this.getPasteClipboardData(clipboardData, pasteContext);
78445
+ if (!this.isPasteOperationCurrent(pasteContext.pasteOperationId) ||
78446
+ table.editorManager?.editingEditor) {
78447
+ return emptyResult;
78448
+ }
78449
+ if (this.pasteWriteInProgress) {
78450
+ await this.pasteWritePromise.catch(() => {
78451
+ });
78452
+ if (!this.isPasteOperationCurrent(pasteContext.pasteOperationId) ||
78453
+ table.editorManager?.editingEditor) {
78454
+ return emptyResult;
78455
+ }
77649
78456
  }
77650
- if (table.changeCellValues && table.stateManager.select.ranges?.length > 0) {
77651
- try {
77652
- if (navigator.clipboard && navigator.clipboard.read) {
77653
- try {
77654
- const clipboardItems = await navigator.clipboard.read();
77655
- let handled = false;
77656
- for (const item of clipboardItems) {
77657
- if (item.types.includes('text/html')) {
77658
- await this.pasteHtmlToTable(item);
77659
- handled = true;
77660
- break;
77661
- }
77662
- else if (item.types.includes('text/plain')) {
77663
- await this.pasteTextToTable(item);
77664
- handled = true;
77665
- break;
78457
+ let pasteResult = emptyResult;
78458
+ let settlePasteWrite = () => {
78459
+ return;
78460
+ };
78461
+ this.pasteWritePromise = new Promise(resolve => {
78462
+ settlePasteWrite = resolve;
78463
+ });
78464
+ this.pasteWriteInProgress = true;
78465
+ try {
78466
+ if (table.changeCellValues) {
78467
+ try {
78468
+ if (pasteClipboardData?.html) {
78469
+ try {
78470
+ const htmlResult = await this.processPastedHTML(pasteClipboardData.html, pasteContext);
78471
+ if (htmlResult.pasted) {
78472
+ pasteResult = htmlResult;
78473
+ return pasteResult;
77666
78474
  }
77667
78475
  }
77668
- if (!handled) {
77669
- await this.fallbackPasteFromClipboard(e);
78476
+ catch (error) {
78477
+ if (/<table\b/i.test(pasteClipboardData.html)) {
78478
+ return emptyResult;
78479
+ }
77670
78480
  }
77671
78481
  }
77672
- catch (clipboardError) {
77673
- await this.fallbackPasteFromClipboard(e);
78482
+ if (pasteClipboardData?.hasText || pasteClipboardData?.text) {
78483
+ pasteResult = await this.processPastedText(pasteClipboardData.internalFormulaText ?? pasteClipboardData.text, pasteContext);
78484
+ return pasteResult;
77674
78485
  }
77675
78486
  }
77676
- else {
77677
- await this.fallbackPasteFromClipboard(e);
78487
+ catch (error) {
78488
+ if (pasteContext.cutState) {
78489
+ this.resetCutState();
78490
+ }
77678
78491
  }
77679
78492
  }
77680
- catch (error) {
77681
- await this.fallbackPasteFromClipboard(e);
77682
- }
78493
+ return pasteResult;
77683
78494
  }
77684
- if (table.keyboardOptions?.showCopyCellBorder) {
77685
- clearActiveCellRangeState(table);
77686
- }
77687
- }
77688
- async fallbackPasteFromClipboard(e) {
77689
- const table = this.table;
77690
- const ranges = table.stateManager.select.ranges;
77691
- const col = Math.min(ranges[0].start.col, ranges[0].end.col);
77692
- const row = Math.min(ranges[0].start.row, ranges[0].end.row);
77693
- try {
77694
- const element = table.getElement();
77695
- if (element && element !== document.activeElement) {
77696
- element.focus();
77697
- await new Promise(resolve => setTimeout(resolve, 10));
77698
- }
77699
- const clipboardData = e.clipboardData || window.clipboardData || window.Clipboard;
77700
- if (clipboardData) {
77701
- const pastedData = clipboardData.getData('text') || clipboardData.getData('Text');
77702
- if (pastedData) {
77703
- await this.processPastedText(pastedData, col, row);
77704
- return;
77705
- }
78495
+ finally {
78496
+ this.pasteWriteInProgress = false;
78497
+ settlePasteWrite();
78498
+ if (!pasteContext.cutState && table.keyboardOptions?.showCopyCellBorder) {
78499
+ clearActiveCellRangeState(table);
77706
78500
  }
77707
78501
  }
77708
- catch (error) {
77709
- }
77710
78502
  }
77711
- async processPastedText(pastedData, col, row) {
77712
- const table = this.table;
77713
- const rows = pastedData.split('\n');
77714
- const values = [];
77715
- rows.forEach(function (rowCells) {
77716
- const cells = rowCells.split('\t');
77717
- const rowValues = [];
77718
- values.push(rowValues);
77719
- cells.forEach(function (cell, cellIndex) {
77720
- if (cellIndex === cells.length - 1) {
77721
- cell = cell.trim();
77722
- }
77723
- rowValues.push(cell);
77724
- });
77725
- });
77726
- let processedValues;
77727
- if (table.options.keyboardOptions?.processFormulaBeforePaste && this.copySourceRange) {
77728
- processedValues = table.options.keyboardOptions.processFormulaBeforePaste(values, this.copySourceRange.startCol, this.copySourceRange.startRow, col, row);
78503
+ getPasteClipboardData(clipboardData, pasteContext) {
78504
+ if (!clipboardData || !pasteContext.copySourceRange) {
78505
+ return clipboardData;
77729
78506
  }
77730
- const changedCellResults = await table.changeCellValues(col, row, processedValues ? processedValues : values, true);
77731
- if (table.hasListeners(TABLE_EVENT_TYPE.PASTED_DATA)) {
77732
- table.fireListeners(TABLE_EVENT_TYPE.PASTED_DATA, {
77733
- col,
77734
- row,
77735
- pasteData: processedValues ? processedValues : values,
77736
- changedCellResults
77737
- });
78507
+ const sourceData = pasteContext.cutState?.clipboardData ?? this.lastCopiedClipboardData;
78508
+ if (!sourceData?.internalFormulaText ||
78509
+ !sourceData.internalFormulaHtmlMarker ||
78510
+ !sourceData.hasHtml ||
78511
+ !clipboardData.hasHtml ||
78512
+ !this.isClipboardDataSameBySignature(clipboardData, sourceData) ||
78513
+ !clipboardData.html.includes(sourceData.internalFormulaHtmlMarker)) {
78514
+ return clipboardData;
77738
78515
  }
78516
+ return {
78517
+ ...clipboardData,
78518
+ internalFormulaText: sourceData.internalFormulaText
78519
+ };
77739
78520
  }
77740
- clearCutArea(table) {
77741
- try {
77742
- const ranges = this.cutRanges;
77743
- if (!ranges || ranges.length === 0) {
77744
- return;
77745
- }
77746
- table.changeCellValuesByRanges(ranges, '');
77747
- }
77748
- catch (error) {
78521
+ getPasteRange() {
78522
+ const ranges = this.table.stateManager.select.ranges;
78523
+ if (!ranges?.length) {
78524
+ return null;
77749
78525
  }
78526
+ const selectRangeLength = ranges.length;
78527
+ const range = ranges[selectRangeLength - 1];
78528
+ return {
78529
+ col: Math.min(range.start.col, range.end.col),
78530
+ row: Math.min(range.start.row, range.end.row),
78531
+ maxCol: Math.max(range.start.col, range.end.col),
78532
+ maxRow: Math.max(range.start.row, range.end.row)
78533
+ };
77750
78534
  }
77751
- async checkClipboardChanged() {
77752
- if (!navigator.clipboard || !navigator.clipboard.readText) {
77753
- return false;
78535
+ getEventClipboardData(e) {
78536
+ const clipboardData = e.clipboardData || window.clipboardData;
78537
+ if (!clipboardData) {
78538
+ return null;
77754
78539
  }
77755
78540
  try {
77756
- const currentContent = await navigator.clipboard.readText();
77757
- return currentContent !== this.lastClipboardContent;
78541
+ const types = Array.from(clipboardData.types ?? []);
78542
+ const html = clipboardData.getData('text/html') || '';
78543
+ const text = clipboardData.getData('text/plain') || clipboardData.getData('text') || clipboardData.getData('Text') || '';
78544
+ const hasHtml = types.includes('text/html') || !!html;
78545
+ const hasText = types.includes('text/plain') || types.includes('text') || types.includes('Text') || !!text;
78546
+ return {
78547
+ html,
78548
+ text,
78549
+ hasHtml,
78550
+ hasText
78551
+ };
77758
78552
  }
77759
- catch (err) {
77760
- return false;
78553
+ catch (error) {
78554
+ return { html: '', text: '', readFailed: true };
77761
78555
  }
77762
78556
  }
77763
- saveClipboardContent() {
77764
- if (navigator.clipboard && navigator.clipboard.readText) {
77765
- setTimeout(() => {
77766
- navigator.clipboard
77767
- .readText()
77768
- .then(text => {
77769
- this.lastClipboardContent = text;
77770
- })
77771
- .catch(err => {
77772
- });
77773
- }, 50);
78557
+ async readClipboardDataForPaste(eventClipboardData) {
78558
+ if (eventClipboardData?.readFailed || eventClipboardData?.hasHtml || eventClipboardData?.hasText) {
78559
+ return eventClipboardData;
77774
78560
  }
77775
- }
77776
- pasteHtmlToTable(item) {
77777
- const regex = /<tr[^>]*>([\s\S]*?)<\/tr>/g;
77778
- const cellRegex = /<td[^>]*>([\s\S]*?)<\/td>/g;
77779
- const table = this.table;
77780
- const ranges = table.stateManager.select.ranges;
77781
- const selectRangeLength = ranges.length;
77782
- const col = Math.min(ranges[selectRangeLength - 1].start.col, ranges[selectRangeLength - 1].end.col);
77783
- const row = Math.min(ranges[selectRangeLength - 1].start.row, ranges[selectRangeLength - 1].end.row);
77784
- const maxCol = Math.max(ranges[selectRangeLength - 1].start.col, ranges[selectRangeLength - 1].end.col);
77785
- const maxRow = Math.max(ranges[selectRangeLength - 1].start.row, ranges[selectRangeLength - 1].end.row);
77786
- let pasteValuesColCount = 0;
77787
- let pasteValuesRowCount = 0;
77788
- let values = [];
77789
- item.getType('text/html').then((blob) => {
77790
- blob.text().then(async (pastedData) => {
77791
- if (pastedData && /(<table)|(<TABLE)/g.test(pastedData)) {
77792
- const matches = Array.from(pastedData.matchAll(regex));
77793
- for (const match of matches) {
77794
- const rowContent = match[1];
77795
- const cellMatches = Array.from(rowContent.matchAll(cellRegex));
77796
- const rowValues = cellMatches.map(cellMatch => {
77797
- return (cellMatch[1]
77798
- .replace(/(<(?!br)([^>]+)>)/gi, '')
77799
- .replace(/<br(\s*|\/)>[\r\n]?/gim, '\n')
77800
- .replace(/&amp;/g, '&')
77801
- .replace(/&lt;/g, '<')
77802
- .replace(/&gt;/g, '>')
77803
- .replace(/&#9;/gi, '\t')
77804
- .replace(/&nbsp;/g, ' '));
77805
- });
77806
- values.push(rowValues);
77807
- pasteValuesColCount = Math.max(pasteValuesColCount, rowValues?.length ?? 0);
77808
- }
77809
- pasteValuesRowCount = values.length ?? 0;
77810
- values = this.handlePasteValues(values, pasteValuesRowCount, pasteValuesColCount, maxRow - row + 1, maxCol - col + 1);
77811
- let processedValues;
77812
- if (table.options.keyboardOptions?.processFormulaBeforePaste && this.copySourceRange) {
77813
- processedValues = table.options.keyboardOptions.processFormulaBeforePaste(values, this.copySourceRange.startCol, this.copySourceRange.startRow, col, row);
77814
- }
77815
- const changedCellResults = await table.changeCellValues(col, row, processedValues ? processedValues : values, true);
77816
- if (table.hasListeners(TABLE_EVENT_TYPE.PASTED_DATA)) {
77817
- table.fireListeners(TABLE_EVENT_TYPE.PASTED_DATA, {
77818
- col,
77819
- row,
77820
- pasteData: processedValues ? processedValues : values,
77821
- changedCellResults
77822
- });
78561
+ if (navigator.clipboard?.read) {
78562
+ try {
78563
+ const clipboardItems = await navigator.clipboard.read();
78564
+ const clipboardData = { html: '', text: '' };
78565
+ for (const item of clipboardItems) {
78566
+ if (!clipboardData.html && item.types.includes('text/html')) {
78567
+ try {
78568
+ clipboardData.html = await (await item.getType('text/html')).text();
78569
+ clipboardData.hasHtml = true;
78570
+ }
78571
+ catch (error) {
78572
+ }
77823
78573
  }
77824
- }
77825
- else {
77826
- navigator.clipboard.read().then(clipboardItems => {
77827
- for (const item of clipboardItems) {
77828
- if (item.types.includes('text/plain')) {
77829
- item.getType('text/plain').then((blob) => {
77830
- blob.text().then(data => this._pasteValue(data));
77831
- });
77832
- }
78574
+ if (!clipboardData.text && item.types.includes('text/plain')) {
78575
+ try {
78576
+ clipboardData.text = await (await item.getType('text/plain')).text();
78577
+ clipboardData.hasText = true;
77833
78578
  }
77834
- });
78579
+ catch (error) {
78580
+ }
78581
+ }
77835
78582
  }
77836
- });
77837
- });
78583
+ if (clipboardData.hasHtml || clipboardData.hasText) {
78584
+ return clipboardData;
78585
+ }
78586
+ }
78587
+ catch (error) {
78588
+ }
78589
+ }
78590
+ if (navigator.clipboard?.readText) {
78591
+ try {
78592
+ return { html: '', text: await navigator.clipboard.readText(), hasText: true };
78593
+ }
78594
+ catch (error) {
78595
+ }
78596
+ }
78597
+ return eventClipboardData ?? { html: '', text: '', readFailed: true };
78598
+ }
78599
+ decodeHTMLCellValue(cellHTML) {
78600
+ const template = document.createElement('template');
78601
+ template.innerHTML = cellHTML.replace(/<br\b[^>]*>(?:\r\n|\r|\n)?/gim, '\n').replace(/&nbsp;/gi, ' ');
78602
+ return template.content.textContent ?? '';
77838
78603
  }
77839
- async _pasteValue(pastedData) {
78604
+ async processPastedHTML(pastedData, pasteContext) {
78605
+ const regex = /<tr[^>]*>([\s\S]*?)<\/tr>/gi;
78606
+ const cellRegex = /<t[dh][^>]*>([\s\S]*?)<\/t[dh]>/gi;
77840
78607
  const table = this.table;
77841
- const ranges = table.stateManager.select.ranges;
77842
- const selectRangeLength = ranges.length;
77843
- const col = Math.min(ranges[selectRangeLength - 1].start.col, ranges[selectRangeLength - 1].end.col);
77844
- const row = Math.min(ranges[selectRangeLength - 1].start.row, ranges[selectRangeLength - 1].end.row);
77845
- const maxCol = Math.max(ranges[selectRangeLength - 1].start.col, ranges[selectRangeLength - 1].end.col);
77846
- const maxRow = Math.max(ranges[selectRangeLength - 1].start.row, ranges[selectRangeLength - 1].end.row);
78608
+ const pasteRange = pasteContext.pasteRange;
78609
+ const { col, row, maxCol, maxRow } = pasteRange;
77847
78610
  let pasteValuesColCount = 0;
77848
78611
  let pasteValuesRowCount = 0;
77849
78612
  let values = [];
77850
- const rows = pastedData.split('\n');
77851
- rows.forEach(function (rowCells, rowIndex) {
77852
- const cells = rowCells.split('\t');
77853
- const rowValues = [];
77854
- values.push(rowValues);
77855
- cells.forEach(function (cell, cellIndex) {
77856
- if (cellIndex === cells.length - 1) {
77857
- cell = cell.trim();
77858
- }
77859
- rowValues.push(cell);
78613
+ if (!pastedData || !/<table\b/i.test(pastedData)) {
78614
+ return this.getEmptyPasteResult();
78615
+ }
78616
+ const matches = Array.from(pastedData.matchAll(regex));
78617
+ for (const match of matches) {
78618
+ const rowContent = match[1];
78619
+ const cellMatches = Array.from(rowContent.matchAll(cellRegex));
78620
+ if (!cellMatches.length) {
78621
+ continue;
78622
+ }
78623
+ const rowValues = cellMatches.map(cellMatch => {
78624
+ return this.decodeHTMLCellValue(cellMatch[1]);
77860
78625
  });
78626
+ values.push(rowValues);
77861
78627
  pasteValuesColCount = Math.max(pasteValuesColCount, rowValues?.length ?? 0);
77862
- });
78628
+ }
77863
78629
  pasteValuesRowCount = values.length ?? 0;
78630
+ if (!pasteValuesRowCount || !pasteValuesColCount) {
78631
+ return this.getEmptyPasteResult();
78632
+ }
77864
78633
  values = this.handlePasteValues(values, pasteValuesRowCount, pasteValuesColCount, maxRow - row + 1, maxCol - col + 1);
77865
78634
  let processedValues;
77866
- if (table.options.keyboardOptions?.processFormulaBeforePaste && this.copySourceRange) {
77867
- processedValues = table.options.keyboardOptions.processFormulaBeforePaste(values, this.copySourceRange.startCol, this.copySourceRange.startRow, col, row);
78635
+ if (table.options.keyboardOptions?.processFormulaBeforePaste && pasteContext.copySourceRange) {
78636
+ processedValues = table.options.keyboardOptions.processFormulaBeforePaste(values, pasteContext.copySourceRange.startCol, pasteContext.copySourceRange.startRow, col, row);
78637
+ }
78638
+ const valuesToPaste = processedValues ? processedValues : values;
78639
+ const targetCells = this.getPasteTargetCells(pasteRange, valuesToPaste);
78640
+ if (!this.isPasteOperationCurrent(pasteContext.pasteOperationId)) {
78641
+ return this.getEmptyPasteResult();
78642
+ }
78643
+ if (pasteContext.cutState) {
78644
+ const validatedCellResults = await this.validatePasteTargetCells(pasteRange, valuesToPaste);
78645
+ if (!this.isPasteOperationCurrent(pasteContext.pasteOperationId)) {
78646
+ return this.getEmptyPasteResult();
78647
+ }
78648
+ if (!this.isFullPasteAllowed(valuesToPaste, validatedCellResults)) {
78649
+ return this.getEmptyPasteResult(validatedCellResults);
78650
+ }
78651
+ }
78652
+ const rawChangedCellResults = await table.changeCellValues(col, row, valuesToPaste, !pasteContext.cutState, true, undefined, () => !this.isPasteOperationCurrent(pasteContext.pasteOperationId));
78653
+ if (!this.isPasteOperationCurrent(pasteContext.pasteOperationId)) {
78654
+ return this.getEmptyPasteResult();
78655
+ }
78656
+ const changedCellResults = this.normalizeChangedCellResults(rawChangedCellResults, pasteRange, valuesToPaste);
78657
+ const changedCells = this.getChangedCells(targetCells, changedCellResults);
78658
+ const migratedSourceCells = this.getMigratedSourceCells(pasteContext.cutState, changedCellResults);
78659
+ if (!changedCells.length) {
78660
+ return this.getEmptyPasteResult(changedCellResults);
77868
78661
  }
77869
- const changedCellResults = await table.changeCellValues(col, row, processedValues ? processedValues : values, true);
77870
- if (table.hasListeners(TABLE_EVENT_TYPE.PASTED_DATA)) {
78662
+ this.firePastedDataEvent(col, row, valuesToPaste, changedCellResults);
78663
+ return { pasted: true, changedCellResults, changedCells, migratedSourceCells };
78664
+ }
78665
+ async processPastedText(pastedData, pasteContext) {
78666
+ const table = this.table;
78667
+ const pasteRange = pasteContext.pasteRange;
78668
+ const { col, row, maxCol, maxRow } = pasteRange;
78669
+ let values = this.parsePlainTextPastedData(pastedData);
78670
+ const pasteValuesRowCount = values.length;
78671
+ const pasteValuesColCount = Math.max(...values.map(rowValues => rowValues.length));
78672
+ if (!pasteValuesRowCount || !pasteValuesColCount) {
78673
+ return this.getEmptyPasteResult();
78674
+ }
78675
+ values = this.handlePasteValues(values, pasteValuesRowCount, pasteValuesColCount, maxRow - row + 1, maxCol - col + 1);
78676
+ let processedValues;
78677
+ if (table.options.keyboardOptions?.processFormulaBeforePaste && pasteContext.copySourceRange) {
78678
+ processedValues = table.options.keyboardOptions.processFormulaBeforePaste(values, pasteContext.copySourceRange.startCol, pasteContext.copySourceRange.startRow, col, row);
78679
+ }
78680
+ const valuesToPaste = processedValues ? processedValues : values;
78681
+ const targetCells = this.getPasteTargetCells(pasteRange, valuesToPaste);
78682
+ if (!this.isPasteOperationCurrent(pasteContext.pasteOperationId)) {
78683
+ return this.getEmptyPasteResult();
78684
+ }
78685
+ if (pasteContext.cutState) {
78686
+ const validatedCellResults = await this.validatePasteTargetCells(pasteRange, valuesToPaste);
78687
+ if (!this.isPasteOperationCurrent(pasteContext.pasteOperationId)) {
78688
+ return this.getEmptyPasteResult();
78689
+ }
78690
+ if (!this.isFullPasteAllowed(valuesToPaste, validatedCellResults)) {
78691
+ return this.getEmptyPasteResult(validatedCellResults);
78692
+ }
78693
+ }
78694
+ const rawChangedCellResults = await table.changeCellValues(col, row, valuesToPaste, !pasteContext.cutState, true, undefined, () => !this.isPasteOperationCurrent(pasteContext.pasteOperationId));
78695
+ if (!this.isPasteOperationCurrent(pasteContext.pasteOperationId)) {
78696
+ return this.getEmptyPasteResult();
78697
+ }
78698
+ const changedCellResults = this.normalizeChangedCellResults(rawChangedCellResults, pasteRange, valuesToPaste);
78699
+ const changedCells = this.getChangedCells(targetCells, changedCellResults);
78700
+ const migratedSourceCells = this.getMigratedSourceCells(pasteContext.cutState, changedCellResults);
78701
+ if (!changedCells.length) {
78702
+ return this.getEmptyPasteResult(changedCellResults);
78703
+ }
78704
+ this.firePastedDataEvent(col, row, valuesToPaste, changedCellResults);
78705
+ return { pasted: true, changedCellResults, changedCells, migratedSourceCells };
78706
+ }
78707
+ firePastedDataEvent(col, row, pasteData, changedCellResults) {
78708
+ const table = this.table;
78709
+ if (!table.hasListeners(TABLE_EVENT_TYPE.PASTED_DATA)) {
78710
+ return;
78711
+ }
78712
+ try {
77871
78713
  table.fireListeners(TABLE_EVENT_TYPE.PASTED_DATA, {
77872
78714
  col,
77873
78715
  row,
77874
- pasteData: processedValues ? processedValues : values,
78716
+ pasteData,
77875
78717
  changedCellResults
77876
78718
  });
77877
78719
  }
78720
+ catch (error) {
78721
+ }
77878
78722
  }
77879
- async pasteTextToTable(item) {
78723
+ getEmptyPasteResult(changedCellResults = []) {
78724
+ return {
78725
+ pasted: false,
78726
+ changedCellResults,
78727
+ changedCells: [],
78728
+ migratedSourceCells: []
78729
+ };
78730
+ }
78731
+ getPasteTargetCells(pasteRange, values) {
78732
+ const targetCells = [];
78733
+ for (let rowIndex = 0; rowIndex < values.length; rowIndex++) {
78734
+ targetCells[rowIndex] = [];
78735
+ for (let colIndex = 0; colIndex < values[rowIndex].length; colIndex++) {
78736
+ targetCells[rowIndex][colIndex] = this.getCellIdentity(pasteRange.col + colIndex, pasteRange.row + rowIndex);
78737
+ }
78738
+ }
78739
+ return targetCells;
78740
+ }
78741
+ getChangedCells(targetCells, changedCellResults) {
78742
+ const changedCells = [];
78743
+ for (let rowIndex = 0; rowIndex < changedCellResults.length; rowIndex++) {
78744
+ for (let colIndex = 0; colIndex < (changedCellResults[rowIndex]?.length ?? 0); colIndex++) {
78745
+ if (changedCellResults[rowIndex][colIndex] && targetCells[rowIndex]?.[colIndex]) {
78746
+ changedCells.push(targetCells[rowIndex][colIndex]);
78747
+ }
78748
+ }
78749
+ }
78750
+ return changedCells;
78751
+ }
78752
+ normalizeChangedCellResults(changedCellResults, pasteRange, values) {
78753
+ if (Array.isArray(changedCellResults)) {
78754
+ return changedCellResults;
78755
+ }
77880
78756
  const table = this.table;
77881
- const ranges = table.stateManager.select.ranges;
77882
- const selectRangeLength = ranges.length;
77883
- const col = Math.min(ranges[selectRangeLength - 1].start.col, ranges[selectRangeLength - 1].end.col);
77884
- const row = Math.min(ranges[selectRangeLength - 1].start.row, ranges[selectRangeLength - 1].end.row);
77885
- const maxCol = Math.max(ranges[selectRangeLength - 1].start.col, ranges[selectRangeLength - 1].end.col);
77886
- const maxRow = Math.max(ranges[selectRangeLength - 1].start.row, ranges[selectRangeLength - 1].end.row);
78757
+ return values.map((rowValues, rowIndex) => rowValues.map((_value, colIndex) => {
78758
+ const targetCol = pasteRange.col + colIndex;
78759
+ const targetRow = pasteRange.row + rowIndex;
78760
+ return (targetCol < table.colCount &&
78761
+ targetRow < table.rowCount &&
78762
+ (!table.isHasEditorDefine || table.isHasEditorDefine(targetCol, targetRow)));
78763
+ }));
78764
+ }
78765
+ async validatePasteTargetCells(pasteRange, values) {
78766
+ const table = this.table;
78767
+ const changedCellResults = [];
78768
+ for (let rowIndex = 0; rowIndex < values.length; rowIndex++) {
78769
+ changedCellResults[rowIndex] = [];
78770
+ for (let colIndex = 0; colIndex < values[rowIndex].length; colIndex++) {
78771
+ const targetCol = pasteRange.col + colIndex;
78772
+ const targetRow = pasteRange.row + rowIndex;
78773
+ const tableAny = table;
78774
+ let canChange = targetCol < tableAny.colCount &&
78775
+ targetRow < tableAny.rowCount &&
78776
+ (!tableAny.isHasEditorDefine || tableAny.isHasEditorDefine(targetCol, targetRow));
78777
+ if (canChange) {
78778
+ const editor = tableAny.getEditor?.(targetCol, targetRow);
78779
+ const oldValue = table.getCellOriginValue?.(targetCol, targetRow);
78780
+ const validateResult = editor?.validateValue?.(values[rowIndex][colIndex], oldValue, { col: targetCol, row: targetRow }, table) ??
78781
+ true;
78782
+ const resolvedValidateResult = validateResult && typeof validateResult.then === 'function'
78783
+ ? await validateResult
78784
+ : validateResult;
78785
+ canChange =
78786
+ resolvedValidateResult === true ||
78787
+ resolvedValidateResult === 'validate-exit' ||
78788
+ resolvedValidateResult === 'validate-not-exit';
78789
+ }
78790
+ changedCellResults[rowIndex][colIndex] = canChange;
78791
+ }
78792
+ }
78793
+ return changedCellResults;
78794
+ }
78795
+ isFullPasteAllowed(values, changedCellResults) {
78796
+ return values.every((rowValues, rowIndex) => rowValues.every((_value, colIndex) => changedCellResults[rowIndex]?.[colIndex] === true));
78797
+ }
78798
+ getMigratedSourceCells(cutState, changedCellResults) {
78799
+ if (!cutState?.sourceCells.length || !cutState.sourceColCount || !cutState.sourceRowCount) {
78800
+ return [];
78801
+ }
78802
+ const migratedSourceCells = [];
78803
+ const migratedKeys = new Set();
78804
+ if (!cutState.isSingleRange) {
78805
+ for (let rowIndex = 0; rowIndex < changedCellResults.length; rowIndex++) {
78806
+ for (let colIndex = 0; colIndex < (changedCellResults[rowIndex]?.length ?? 0); colIndex++) {
78807
+ if (!changedCellResults[rowIndex][colIndex]) {
78808
+ continue;
78809
+ }
78810
+ const sourceRow = rowIndex % cutState.sourceRowCount;
78811
+ const sourceCol = colIndex % cutState.sourceColCount;
78812
+ const sourceCell = cutState.sourceCellMatrix[sourceRow]?.[sourceCol];
78813
+ if (!sourceCell) {
78814
+ continue;
78815
+ }
78816
+ const sourceKey = this.getCellKey(sourceCell);
78817
+ if (!migratedKeys.has(sourceKey)) {
78818
+ migratedKeys.add(sourceKey);
78819
+ migratedSourceCells.push(sourceCell);
78820
+ }
78821
+ }
78822
+ }
78823
+ return migratedSourceCells.length === cutState.sourceCells.length ? migratedSourceCells : [];
78824
+ }
78825
+ for (let rowIndex = 0; rowIndex < changedCellResults.length; rowIndex++) {
78826
+ for (let colIndex = 0; colIndex < (changedCellResults[rowIndex]?.length ?? 0); colIndex++) {
78827
+ if (!changedCellResults[rowIndex][colIndex]) {
78828
+ continue;
78829
+ }
78830
+ const sourceRow = rowIndex % cutState.sourceRowCount;
78831
+ const sourceCol = colIndex % cutState.sourceColCount;
78832
+ const sourceIndex = sourceRow * cutState.sourceColCount + sourceCol;
78833
+ const sourceCell = cutState.sourceCells[sourceIndex];
78834
+ if (!sourceCell) {
78835
+ continue;
78836
+ }
78837
+ const sourceKey = this.getCellKey(sourceCell);
78838
+ if (migratedKeys.has(sourceKey)) {
78839
+ continue;
78840
+ }
78841
+ migratedKeys.add(sourceKey);
78842
+ migratedSourceCells.push(sourceCell);
78843
+ }
78844
+ }
78845
+ return migratedSourceCells;
78846
+ }
78847
+ getCellIdentity(col, row) {
78848
+ const table = this.table;
78849
+ const recordShowIndex = table.getRecordShowIndexByCell?.(col, row);
78850
+ const recordIndex = recordShowIndex >= 0 ? table.dataSource?.getIndexKey?.(recordShowIndex) : undefined;
78851
+ const field = table.internalProps?.layoutMap?.getBody?.(col, row)?.field;
78852
+ return { col, row, recordIndex, field };
78853
+ }
78854
+ async clearCutArea(migratedSourceCells, changedTargetCells) {
77887
78855
  try {
77888
- const blob = await item.getType('text/plain');
77889
- const pastedData = await blob.text();
77890
- const values = this.parsePastedData(pastedData);
77891
- const pasteValuesRowCount = values.length;
77892
- const pasteValuesColCount = Math.max(...values.map(row => row.length), 0);
77893
- const processedValues = this.handlePasteValues(values, pasteValuesRowCount, pasteValuesColCount, maxRow - row + 1, maxCol - col + 1);
77894
- const changedCellResults = await table.changeCellValues(col, row, processedValues, true);
77895
- if (table.hasListeners(TABLE_EVENT_TYPE.PASTED_DATA)) {
77896
- table.fireListeners(TABLE_EVENT_TYPE.PASTED_DATA, {
77897
- col,
77898
- row,
77899
- pasteData: processedValues,
77900
- changedCellResults
78856
+ const table = this.table;
78857
+ const changedTargetKeys = new Set();
78858
+ changedTargetCells.forEach(cell => {
78859
+ changedTargetKeys.add(this.getCellKey(cell));
78860
+ changedTargetKeys.add(this.getCoordKey(cell));
78861
+ });
78862
+ const clearedKeys = new Set();
78863
+ const sourceChanges = [];
78864
+ const coordChanges = [];
78865
+ for (let i = 0; i < migratedSourceCells.length; i++) {
78866
+ const sourceCell = migratedSourceCells[i];
78867
+ const sourceKey = this.getCellKey(sourceCell);
78868
+ if (clearedKeys.has(sourceKey) ||
78869
+ changedTargetKeys.has(sourceKey) ||
78870
+ changedTargetKeys.has(this.getCoordKey(sourceCell))) {
78871
+ continue;
78872
+ }
78873
+ const currentAddress = this.getCurrentCellAddress(sourceCell);
78874
+ if (!currentAddress) {
78875
+ continue;
78876
+ }
78877
+ if (!this.isSourceCellUnchanged(sourceCell, currentAddress)) {
78878
+ continue;
78879
+ }
78880
+ if (sourceCell.recordIndex !== undefined &&
78881
+ sourceCell.field !== undefined &&
78882
+ table.changeCellValuesByRecords) {
78883
+ sourceChanges.push({ recordIndex: sourceCell.recordIndex, field: sourceCell.field, value: '' });
78884
+ }
78885
+ else {
78886
+ coordChanges.push(currentAddress);
78887
+ }
78888
+ clearedKeys.add(sourceKey);
78889
+ }
78890
+ if (sourceChanges.length) {
78891
+ table.changeCellValuesByRecords(sourceChanges, {
78892
+ triggerEvent: true,
78893
+ autoRefresh: false
77901
78894
  });
77902
78895
  }
78896
+ for (let i = 0; i < coordChanges.length; i++) {
78897
+ await table.changeCellValues(coordChanges[i].col, coordChanges[i].row, [['']], false);
78898
+ }
78899
+ if (sourceChanges.length) {
78900
+ table.refreshAfterSourceChange?.();
78901
+ }
78902
+ return true;
77903
78903
  }
77904
78904
  catch (error) {
78905
+ return false;
78906
+ }
78907
+ }
78908
+ isSourceCellUnchanged(sourceCell, currentAddress) {
78909
+ const table = this.table;
78910
+ return Object.is(table.getCellOriginValue?.(currentAddress.col, currentAddress.row), sourceCell.value);
78911
+ }
78912
+ getCurrentCellAddress(sourceCell) {
78913
+ const table = this.table;
78914
+ if (sourceCell.recordIndex !== undefined && sourceCell.field !== undefined && table.getCellAddrByFieldRecord) {
78915
+ const address = table.getCellAddrByFieldRecord(sourceCell.field, sourceCell.recordIndex);
78916
+ if (address && address.col >= 0 && address.row >= 0) {
78917
+ return address;
78918
+ }
78919
+ return null;
78920
+ }
78921
+ return { col: sourceCell.col, row: sourceCell.row };
78922
+ }
78923
+ getCellKey(cell) {
78924
+ if (cell.recordIndex !== undefined && cell.field !== undefined) {
78925
+ return `record:${this.getStableKeyPart(cell.recordIndex)}:${this.getStableKeyPart(cell.field)}`;
78926
+ }
78927
+ return this.getCoordKey(cell);
78928
+ }
78929
+ getCoordKey(cell) {
78930
+ return `coord:${cell.col}:${cell.row}`;
78931
+ }
78932
+ getStableKeyPart(value) {
78933
+ if (value === null) {
78934
+ return 'null';
78935
+ }
78936
+ const valueType = typeof value;
78937
+ if (valueType === 'string' || valueType === 'number' || valueType === 'boolean') {
78938
+ return `${valueType}:${JSON.stringify(value)}`;
78939
+ }
78940
+ if (Array.isArray(value)) {
78941
+ return `array:[${value.map(item => this.getStableKeyPart(item)).join(',')}]`;
78942
+ }
78943
+ if (valueType === 'object' || valueType === 'function') {
78944
+ let id = this.fieldKeyIds.get(value);
78945
+ if (id === undefined) {
78946
+ id = ++this.fieldKeyId;
78947
+ this.fieldKeyIds.set(value, id);
78948
+ }
78949
+ return `${valueType}:#${id}`;
78950
+ }
78951
+ return `${valueType}:${String(value)}`;
78952
+ }
78953
+ resetCutState() {
78954
+ this.cutWaitPaste = false;
78955
+ this.activeCutState = null;
78956
+ this.cutCellRange = null;
78957
+ this.cutRanges = null;
78958
+ if (this.table.keyboardOptions?.showCopyCellBorder) {
78959
+ clearActiveCellRangeState(this.table);
78960
+ }
78961
+ if (this.clipboardCheckTimer) {
78962
+ clearTimeout(this.clipboardCheckTimer);
78963
+ this.clipboardCheckTimer = null;
77905
78964
  }
77906
78965
  }
77907
78966
  parsePastedData(pastedData) {
@@ -77917,6 +78976,13 @@
77917
78976
  });
77918
78977
  return values;
77919
78978
  }
78979
+ parsePlainTextPastedData(pastedData) {
78980
+ const rows = pastedData.replace(/\r\n|\r/g, '\n').split('\n');
78981
+ if (rows.length > 1 && rows[rows.length - 1] === '') {
78982
+ rows.pop();
78983
+ }
78984
+ return rows.map(rowCells => rowCells.split('\t'));
78985
+ }
77920
78986
  processCellValue(cell) {
77921
78987
  if (cell.includes('\n')) {
77922
78988
  cell = cell
@@ -81924,7 +82990,7 @@
81924
82990
  return TABLE_EVENT_TYPE;
81925
82991
  }
81926
82992
  options;
81927
- version = "1.26.7";
82993
+ version = "1.26.8";
81928
82994
  pagination;
81929
82995
  id = `VTable${Date.now()}`;
81930
82996
  headerStyleCache;
@@ -83658,7 +84724,7 @@
83658
84724
  this.editorManager?.cancelEdit();
83659
84725
  this.options = options;
83660
84726
  this._hasAutoImageColumn = undefined;
83661
- const { frozenColCount = 0, unfreezeAllOnExceedsMaxWidth, defaultRowHeight = 40, defaultHeaderRowHeight, defaultColWidth = 80, defaultHeaderColWidth = 80, keyboardOptions, eventOptions, rowSeriesNumber, enableCheckboxCascade, enableHeaderCheckboxCascade, columnResizeMode, rowResizeMode = 'none', resize, dragHeaderMode, dragOrder, showFrozenIcon, allowFrozenColCount, padding, hover, menu, select: click, pixelRatio, widthMode, heightMode, autoFillWidth, autoFillHeight, containerFit, widthAdaptiveMode, heightAdaptiveMode, customRender, renderChartAsync, renderChartAsyncBatchCount, canvasWidth, canvasHeight, contentOffsetX: translateX = 0, contentOffsetY: translateY = 0, overscrollBehavior, limitMinWidth, limitMinHeight } = options;
84727
+ const { frozenColCount = 0, unfreezeAllOnExceedsMaxWidth, defaultRowHeight = 40, defaultHeaderRowHeight, defaultColWidth = 80, defaultHeaderColWidth, keyboardOptions, eventOptions, rowSeriesNumber, enableCheckboxCascade, enableHeaderCheckboxCascade, columnResizeMode, rowResizeMode = 'none', resize, dragHeaderMode, dragOrder, showFrozenIcon, allowFrozenColCount, padding, hover, menu, select: click, pixelRatio, widthMode, heightMode, autoFillWidth, autoFillHeight, containerFit, widthAdaptiveMode, heightAdaptiveMode, customRender, renderChartAsync, renderChartAsyncBatchCount, canvasWidth, canvasHeight, contentOffsetX: translateX = 0, contentOffsetY: translateY = 0, overscrollBehavior, limitMinWidth, limitMinHeight } = options;
83662
84728
  const { groupConfig, groupBy, groupTitleFieldFormat, groupTitleCustomLayout, enableTreeStickCell } = options;
83663
84729
  if (pixelRatio && pixelRatio !== this.internalProps.pixelRatio) {
83664
84730
  this.internalProps.pixelRatio = pixelRatio;
@@ -88314,6 +89380,37 @@
88314
89380
  }
88315
89381
  }
88316
89382
  }
89383
+ function isSameRecordIndex(sourceRecordIndex, currentRecordIndex) {
89384
+ if (Array.isArray(sourceRecordIndex) || Array.isArray(currentRecordIndex)) {
89385
+ return (Array.isArray(sourceRecordIndex) &&
89386
+ Array.isArray(currentRecordIndex) &&
89387
+ sourceRecordIndex.length === currentRecordIndex.length &&
89388
+ sourceRecordIndex.every((value, index) => value === currentRecordIndex[index]));
89389
+ }
89390
+ return sourceRecordIndex === currentRecordIndex;
89391
+ }
89392
+ function isTargetCellSnapshotCurrent(table, snapshot) {
89393
+ if (table.isHeader(snapshot.col, snapshot.row) !== snapshot.isHeader) {
89394
+ return false;
89395
+ }
89396
+ if (snapshot.isHeader) {
89397
+ return true;
89398
+ }
89399
+ const recordShowIndex = table.getRecordShowIndexByCell(snapshot.col, snapshot.row);
89400
+ const recordIndex = recordShowIndex >= 0 ? table.dataSource.getIndexKey(recordShowIndex) : undefined;
89401
+ const { field } = table.internalProps.layoutMap.getBody(snapshot.col, snapshot.row);
89402
+ return isSameRecordIndex(snapshot.recordIndex, recordIndex) && snapshot.field === field;
89403
+ }
89404
+ function areTargetCellSnapshotsCurrent(table, snapshots) {
89405
+ for (let i = 0; i < snapshots.length; i++) {
89406
+ for (let j = 0; j < snapshots[i].length; j++) {
89407
+ if (!isTargetCellSnapshotCurrent(table, snapshots[i][j])) {
89408
+ return false;
89409
+ }
89410
+ }
89411
+ }
89412
+ return true;
89413
+ }
88317
89414
  function listTableChangeCellValue(col, row, value, workOnEditableCell, triggerEvent, table, noTriggerChangeCellValuesEvent) {
88318
89415
  if ((workOnEditableCell && table.isHasEditorDefine(col, row)) || workOnEditableCell === false) {
88319
89416
  const recordShowIndex = table.getRecordShowIndexByCell(col, row);
@@ -88405,12 +89502,13 @@
88405
89502
  table.scenegraph.updateNextFrame();
88406
89503
  }
88407
89504
  }
88408
- async function listTableChangeCellValues(startCol, startRow, values, workOnEditableCell, triggerEvent, table, noTriggerChangeCellValuesEvent) {
89505
+ async function listTableChangeCellValues(startCol, startRow, values, workOnEditableCell, triggerEvent, table, noTriggerChangeCellValuesEvent, shouldCancel) {
88409
89506
  const changedCellResults = [];
88410
89507
  let pasteColEnd = startCol;
88411
89508
  let pasteRowEnd = startRow;
88412
89509
  const beforeChangeValues = [];
88413
89510
  const oldValues = [];
89511
+ const targetSnapshots = [];
88414
89512
  let cellUpdateType;
88415
89513
  for (let i = 0; i < values.length; i++) {
88416
89514
  if (startRow + i > table.rowCount - 1) {
@@ -88419,20 +89517,64 @@
88419
89517
  const rowValues = values[i];
88420
89518
  const rawRowValues = [];
88421
89519
  const oldRowValues = [];
89520
+ const rowTargetSnapshots = [];
88422
89521
  beforeChangeValues.push(rawRowValues);
88423
89522
  oldValues.push(oldRowValues);
89523
+ targetSnapshots.push(rowTargetSnapshots);
88424
89524
  for (let j = 0; j < rowValues.length; j++) {
88425
89525
  if (startCol + j > table.colCount - 1) {
88426
89526
  break;
88427
89527
  }
89528
+ const col = startCol + j;
89529
+ const row = startRow + i;
88428
89530
  cellUpdateType = getCellUpdateType(startCol + j, startRow + i, table, cellUpdateType);
88429
- const beforeChangeValue = table.getCellRawValue(startCol + j, startRow + i);
89531
+ const beforeChangeValue = table.getCellRawValue(col, row);
88430
89532
  rawRowValues.push(beforeChangeValue);
88431
- const oldValue = table.getCellOriginValue(startCol + j, startRow + i);
89533
+ const oldValue = table.getCellOriginValue(col, row);
88432
89534
  oldRowValues.push(oldValue);
89535
+ const isHeader = table.isHeader(col, row);
89536
+ const recordShowIndex = table.getRecordShowIndexByCell(col, row);
89537
+ const recordIndex = recordShowIndex >= 0 ? table.dataSource.getIndexKey(recordShowIndex) : undefined;
89538
+ const { field } = table.internalProps.layoutMap.getBody(col, row);
89539
+ rowTargetSnapshots.push({ col, row, isHeader, recordIndex, field });
88433
89540
  }
88434
89541
  }
88435
89542
  const resultChangeValues = [];
89543
+ const preValidatedCellResults = shouldCancel && workOnEditableCell ? [] : null;
89544
+ if (preValidatedCellResults) {
89545
+ for (let i = 0; i < values.length; i++) {
89546
+ if (shouldCancel?.()) {
89547
+ return changedCellResults;
89548
+ }
89549
+ if (startRow + i > table.rowCount - 1) {
89550
+ break;
89551
+ }
89552
+ preValidatedCellResults[i] = [];
89553
+ const rowValues = values[i];
89554
+ for (let j = 0; j < rowValues.length; j++) {
89555
+ if (startCol + j > table.colCount - 1) {
89556
+ break;
89557
+ }
89558
+ let isCanChange = false;
89559
+ if (table.isHasEditorDefine(startCol + j, startRow + i)) {
89560
+ const editor = table.getEditor(startCol + j, startRow + i);
89561
+ const oldValue = oldValues[i][j];
89562
+ const value = rowValues[j];
89563
+ const maybePromiseOrValue = editor?.validateValue?.(value, oldValue, { col: startCol + j, row: startRow + i }, table) ?? true;
89564
+ const validateResult = isPromise(maybePromiseOrValue) ? await maybePromiseOrValue : maybePromiseOrValue;
89565
+ if (shouldCancel?.()) {
89566
+ return changedCellResults;
89567
+ }
89568
+ isCanChange =
89569
+ validateResult === true || validateResult === 'validate-exit' || validateResult === 'validate-not-exit';
89570
+ }
89571
+ preValidatedCellResults[i][j] = isCanChange;
89572
+ }
89573
+ }
89574
+ }
89575
+ if (shouldCancel?.() || !areTargetCellSnapshotsCurrent(table, targetSnapshots)) {
89576
+ return changedCellResults;
89577
+ }
88436
89578
  for (let i = 0; i < values.length; i++) {
88437
89579
  if (startRow + i > table.rowCount - 1) {
88438
89580
  break;
@@ -88447,7 +89589,10 @@
88447
89589
  }
88448
89590
  thisRowPasteColEnd = startCol + j;
88449
89591
  let isCanChange = false;
88450
- if (workOnEditableCell === false) {
89592
+ if (preValidatedCellResults) {
89593
+ isCanChange = preValidatedCellResults[i]?.[j] === true;
89594
+ }
89595
+ else if (workOnEditableCell === false) {
88451
89596
  isCanChange = true;
88452
89597
  }
88453
89598
  else {
@@ -88458,6 +89603,9 @@
88458
89603
  const maybePromiseOrValue = editor?.validateValue?.(value, oldValue, { col: startCol + j, row: startRow + i }, table) ?? true;
88459
89604
  if (isPromise(maybePromiseOrValue)) {
88460
89605
  const validateResult = await maybePromiseOrValue;
89606
+ if (shouldCancel?.()) {
89607
+ return changedCellResults;
89608
+ }
88461
89609
  isCanChange =
88462
89610
  validateResult === true || validateResult === 'validate-exit' || validateResult === 'validate-not-exit';
88463
89611
  }
@@ -88481,7 +89629,10 @@
88481
89629
  table.internalProps.layoutMap.updateColumnTitle(startCol + j, startRow + i, value);
88482
89630
  }
88483
89631
  else {
88484
- table.dataSource.changeFieldValue(value, recordShowIndex, field, startCol + j, startRow + i, table);
89632
+ const changeResult = table.dataSource.changeFieldValue(value, recordShowIndex, field, startCol + j, startRow + i, table);
89633
+ if (isPromise(changeResult)) {
89634
+ await changeResult;
89635
+ }
88485
89636
  }
88486
89637
  const changedValue = table.getCellOriginValue(startCol + j, startRow + i);
88487
89638
  if (oldValue !== changedValue && triggerEvent) {
@@ -89539,6 +90690,9 @@
89539
90690
  clearLayoutColumnState(column.children ?? column.columns);
89540
90691
  });
89541
90692
  }
90693
+ function isSameField(left, right) {
90694
+ return left === right || (Array.isArray(left) && Array.isArray(right) && arrayEqual(left, right));
90695
+ }
89542
90696
  class ListTable extends BaseTable {
89543
90697
  showHeader = true;
89544
90698
  listTreeStickCellPlugin;
@@ -90022,7 +91176,7 @@
90022
91176
  return this.dataSource.getTableIndex(recordIndex) + this.columnHeaderLevelCount;
90023
91177
  }
90024
91178
  getTableIndexByField(field) {
90025
- const colObj = this.internalProps.layoutMap.columnObjects.find((col) => col.field === field);
91179
+ const colObj = this.internalProps.layoutMap.columnObjects.find((col) => isSameField(col.field, field));
90026
91180
  if (!colObj) {
90027
91181
  return -1;
90028
91182
  }
@@ -90336,7 +91490,7 @@
90336
91490
  }
90337
91491
  getCellRangeByField(field, index) {
90338
91492
  const { layoutMap } = this.internalProps;
90339
- const colObj = layoutMap.columnObjects.find((col) => col.field === field);
91493
+ const colObj = layoutMap.columnObjects.find((col) => isSameField(col.field, field));
90340
91494
  if (colObj) {
90341
91495
  const layoutRange = layoutMap.getBodyLayoutRangeById(colObj.id);
90342
91496
  let startRow;
@@ -90500,7 +91654,7 @@
90500
91654
  if (field && columns && columns.length > 0) {
90501
91655
  for (let i = 0; i < columns.length; i++) {
90502
91656
  const header = columns[i];
90503
- if (((fieldKey && fieldKey === header.fieldKey) || (!fieldKey && header.field === field)) &&
91657
+ if (((fieldKey && fieldKey === header.fieldKey) || (!fieldKey && isSameField(header.field, field))) &&
90504
91658
  header.sort &&
90505
91659
  typeof header.sort === 'function') {
90506
91660
  return header.sort;
@@ -90529,7 +91683,7 @@
90529
91683
  if (this.internalProps.layoutMap.headerObjects.some(item => item.define.sort !== false)) {
90530
91684
  this.dataSource.sort(normalizedSortState.map((item) => {
90531
91685
  const sortFunc = this._getSortFuncFromHeaderOption(this.internalProps.columns, item.field);
90532
- this.internalProps.layoutMap.headerObjects.find((col) => col && col.field === item.field);
91686
+ this.internalProps.layoutMap.headerObjects.find((col) => col && isSameField(col.field, item.field));
90533
91687
  return {
90534
91688
  field: item.field,
90535
91689
  order: item.order,
@@ -90686,7 +91840,7 @@
90686
91840
  if (this.internalProps.layoutMap.headerObjectsIncludeHided.some(item => item.define.sort !== false)) {
90687
91841
  this.dataSource.sort(sortState.map((item) => {
90688
91842
  const sortFunc = this._getSortFuncFromHeaderOption(undefined, item.field);
90689
- this.internalProps.layoutMap.headerObjectsIncludeHided.find((col) => col && col.field === item.field);
91843
+ this.internalProps.layoutMap.headerObjectsIncludeHided.find((col) => col && isSameField(col.field, item.field));
90690
91844
  return {
90691
91845
  field: item.field,
90692
91846
  order: item.order || 'asc',
@@ -90818,8 +91972,8 @@
90818
91972
  changeCellValue(col, row, value, workOnEditableCell = false, triggerEvent = true, noTriggerChangeCellValuesEvent) {
90819
91973
  return listTableChangeCellValue(col, row, value, workOnEditableCell, triggerEvent, this, noTriggerChangeCellValuesEvent);
90820
91974
  }
90821
- changeCellValues(startCol, startRow, values, workOnEditableCell = false, triggerEvent = true, noTriggerChangeCellValuesEvent) {
90822
- return listTableChangeCellValues(startCol, startRow, values, workOnEditableCell, triggerEvent, this, noTriggerChangeCellValuesEvent);
91975
+ changeCellValues(startCol, startRow, values, workOnEditableCell = false, triggerEvent = true, noTriggerChangeCellValuesEvent, shouldCancel) {
91976
+ return listTableChangeCellValues(startCol, startRow, values, workOnEditableCell, triggerEvent, this, noTriggerChangeCellValuesEvent, shouldCancel);
90823
91977
  }
90824
91978
  changeCellValuesByRanges(ranges, value, workOnEditableCell = false, triggerEvent = true, noTriggerChangeCellValuesEvent) {
90825
91979
  return listTableChangeCellValuesByRanges(ranges, value, workOnEditableCell, triggerEvent, this, noTriggerChangeCellValuesEvent);
@@ -90855,15 +92009,20 @@
90855
92009
  const records = this.dataSource.dataSourceObj?.records;
90856
92010
  let record;
90857
92011
  let oldValue;
90858
- if (Array.isArray(records) && (typeof field === 'string' || typeof field === 'number')) {
92012
+ if (Array.isArray(records) && (typeof field === 'string' || typeof field === 'number' || Array.isArray(field))) {
90859
92013
  record = Array.isArray(recordIndex) ? getValueFromDeepArray(records, recordIndex) : records[recordIndex];
90860
- oldValue = record?.[field];
92014
+ oldValue = getRecordFieldValue(record, field);
90861
92015
  }
90862
92016
  this.dataSource.changeFieldValueByRecordIndex(value, recordIndex, field, this);
92017
+ if (Array.isArray(records)) {
92018
+ record = Array.isArray(recordIndex) ? getValueFromDeepArray(records, recordIndex) : records[recordIndex];
92019
+ }
90863
92020
  if (!triggerEvent) {
90864
92021
  return;
90865
92022
  }
90866
- const changedValue = record && (typeof field === 'string' || typeof field === 'number') ? record?.[field] : value;
92023
+ const changedValue = record && (typeof field === 'string' || typeof field === 'number' || Array.isArray(field))
92024
+ ? getRecordFieldValue(record, field)
92025
+ : value;
90867
92026
  if (oldValue !== changedValue) {
90868
92027
  const cellAddr = this.getCellAddrByFieldRecord(field, recordIndex);
90869
92028
  const changeValue = {
@@ -90901,13 +92060,18 @@
90901
92060
  const records = this.dataSource.dataSourceObj?.records;
90902
92061
  let record;
90903
92062
  let oldValue;
90904
- if (Array.isArray(records) && (typeof field === 'string' || typeof field === 'number')) {
92063
+ if (Array.isArray(records) && (typeof field === 'string' || typeof field === 'number' || Array.isArray(field))) {
90905
92064
  record = Array.isArray(recordIndex) ? getValueFromDeepArray(records, recordIndex) : records[recordIndex];
90906
- oldValue = record?.[field];
92065
+ oldValue = getRecordFieldValue(record, field);
90907
92066
  }
90908
92067
  this.dataSource.changeFieldValueByRecordIndex(value, recordIndex, field, this);
92068
+ if (Array.isArray(records)) {
92069
+ record = Array.isArray(recordIndex) ? getValueFromDeepArray(records, recordIndex) : records[recordIndex];
92070
+ }
90909
92071
  if (triggerEvent) {
90910
- const changedValue = record && (typeof field === 'string' || typeof field === 'number') ? record?.[field] : value;
92072
+ const changedValue = record && (typeof field === 'string' || typeof field === 'number' || Array.isArray(field))
92073
+ ? getRecordFieldValue(record, field)
92074
+ : value;
90911
92075
  if (oldValue !== changedValue) {
90912
92076
  const changeValue = {
90913
92077
  col: (this.getCellAddrByFieldRecord(field, recordIndex)?.col ?? -1),
@@ -96570,6 +97734,7 @@
96570
97734
  }
96571
97735
 
96572
97736
  function createCellGroup(table, value, columnGroup, xOrigin, yOrigin, col, row, colWidth, cellWidth, cellHeight, padding, textAlign, textBaseline, mayHaveIcon, customElementsGroup, renderDefault, cellTheme, range, isAsync) {
97737
+ const isCornerCustomMergeContentCell = isCornerCustomMergeRange(range, table) && col === range.end.col && row === range.end.row;
96573
97738
  const headerStyle = table._getCellStyle(col, row);
96574
97739
  const functionalPadding = getFunctionalProp('padding', headerStyle, col, row, table);
96575
97740
  if (isValid$1(functionalPadding)) {
@@ -96603,7 +97768,7 @@
96603
97768
  cursor: cellTheme?.group?.cursor ?? undefined,
96604
97769
  lineDash: cellTheme?.group?.lineDash ?? undefined,
96605
97770
  lineCap: 'butt',
96606
- clip: true,
97771
+ clip: !isCornerCustomMergeContentCell,
96607
97772
  cornerRadius: cellTheme.group.cornerRadius
96608
97773
  });
96609
97774
  }
@@ -96622,7 +97787,7 @@
96622
97787
  cursor: cellTheme?.group?.cursor ?? undefined,
96623
97788
  lineDash: cellTheme?.group?.lineDash ?? undefined,
96624
97789
  lineCap: 'butt',
96625
- clip: true,
97790
+ clip: !isCornerCustomMergeContentCell,
96626
97791
  cornerRadius: cellTheme.group.cornerRadius
96627
97792
  });
96628
97793
  cellGroup.role = 'cell';
@@ -96633,6 +97798,12 @@
96633
97798
  if (customElementsGroup) {
96634
97799
  cellGroup.appendChild(customElementsGroup);
96635
97800
  }
97801
+ if (isCornerCustomMergeContentCell) {
97802
+ cellGroup.setAttributes({
97803
+ width: Math.max(cellGroup.attribute.width, customElementsGroup?.attribute.width ?? 0),
97804
+ height: Math.max(cellGroup.attribute.height, customElementsGroup?.attribute.height ?? 0)
97805
+ });
97806
+ }
96636
97807
  if (renderDefault) {
96637
97808
  const textStr = value;
96638
97809
  let icons;
@@ -99417,6 +100588,7 @@
99417
100588
  (colHeader.indicatorKey
99418
100589
  ? this.getIndicatorInfoByIndicatorKey(colHeader.indicatorKey)?.title ?? ''
99419
100590
  : colHeader.value);
100591
+ colHeaderPath.dataValue = colHeader.dataValue;
99420
100592
  colHeaderPath.virtual = colHeader.virtual;
99421
100593
  colHeaderPath.role = colHeader.role;
99422
100594
  headerPaths.colHeaderPaths.push(colHeaderPath);
@@ -99431,6 +100603,7 @@
99431
100603
  (rowHeader.indicatorKey
99432
100604
  ? this.getIndicatorInfoByIndicatorKey(rowHeader.indicatorKey)?.title ?? ''
99433
100605
  : rowHeader.value);
100606
+ rowHeaderPath.dataValue = rowHeader.dataValue;
99434
100607
  rowHeaderPath.virtual = rowHeader.virtual;
99435
100608
  rowHeaderPath.role = rowHeader.role;
99436
100609
  headerPaths.rowHeaderPaths.push(rowHeaderPath);
@@ -100078,10 +101251,14 @@
100078
101251
  const dimension = treeNodes[j];
100079
101252
  const isMatch = (!isValid$1(currentPath.indicatorKey) &&
100080
101253
  dimension.dimensionKey === currentPath.dimensionKey &&
100081
- dimension.value === currentPath.value) ||
101254
+ (isValid$1(currentPath.dataValue)
101255
+ ? (dimension.dataValue ?? dimension.value) === currentPath.dataValue
101256
+ : dimension.value === currentPath.value)) ||
100082
101257
  (isValid$1(currentPath.indicatorKey) &&
100083
101258
  dimension.indicatorKey === currentPath.indicatorKey &&
100084
- ((isValid$1(dimension.value) && isValid$1(currentPath.value) && currentPath.value === dimension.value) ||
101259
+ ((isValid$1(currentPath.dataValue) &&
101260
+ (dimension.dataValue ?? dimension.value) === currentPath.dataValue) ||
101261
+ (isValid$1(dimension.value) && isValid$1(currentPath.value) && currentPath.value === dimension.value) ||
100085
101262
  !isValid$1(dimension.value) ||
100086
101263
  !isValid$1(currentPath.value)));
100087
101264
  if (isMatch) {
@@ -100232,7 +101409,9 @@
100232
101409
  const cellIDs = this.headerObjects
100233
101410
  .filter((hd) => {
100234
101411
  return ((hd?.field === rowDimension.dimensionKey || hd?.field === rowDimension.indicatorKey) &&
100235
- hd?.title === rowDimension.value);
101412
+ (isValid$1(rowDimension.dataValue)
101413
+ ? (hd.dataValue ?? hd.define?.dataValue ?? hd.title) === rowDimension.dataValue
101414
+ : hd?.title === rowDimension.value));
100236
101415
  })
100237
101416
  .map((hd) => {
100238
101417
  return hd.id;
@@ -100242,15 +101421,19 @@
100242
101421
  });
100243
101422
  const findedCellIdPath = findedCellIdPaths.find(pathIds => {
100244
101423
  const fullCellIds = this.findFullCellIds(pathIds);
101424
+ const matchHeaderPath = (curHd, rowDimensionPath) => rowDimensionPath.dimensionKey === curHd.field &&
101425
+ (isValid$1(rowDimensionPath.dataValue)
101426
+ ? (curHd.dataValue ?? curHd.define?.dataValue ?? curHd.title) ===
101427
+ rowDimensionPath.dataValue
101428
+ : rowDimensionPath.value === curHd.title);
100245
101429
  return (fullCellIds.length === rowHeaderPaths.length &&
100246
- fullCellIds.every(id => {
100247
- const curHd = this._headerObjectMap[id];
100248
- return rowHeaderPaths.find(rowDimensionPath => {
100249
- return rowDimensionPath.dimensionKey === curHd.field && rowDimensionPath.value === curHd.title;
100250
- });
100251
- }));
101430
+ (rowHeaderPaths.some(rowDimensionPath => isValid$1(rowDimensionPath.dataValue))
101431
+ ? fullCellIds.every((id, index) => matchHeaderPath(this._headerObjectMap[id], rowHeaderPaths[index]))
101432
+ : fullCellIds.every(id => rowHeaderPaths.some(rowDimensionPath => matchHeaderPath(this._headerObjectMap[id], rowDimensionPath)))));
100252
101433
  });
100253
- row = this._rowHeaderCellIds.indexOf(findedCellIdPath) + this.columnHeaderLevelCount;
101434
+ if (findedCellIdPath) {
101435
+ row = this._rowHeaderCellIds.indexOf(findedCellIdPath) + this.columnHeaderLevelCount;
101436
+ }
100254
101437
  }
100255
101438
  else {
100256
101439
  rowDimensionFinded = this.matchDimensionPath(rowHeaderPaths, this.rowTree, needLowestLevel_rowPaths, true);
@@ -100261,7 +101444,7 @@
100261
101444
  return undefined;
100262
101445
  }
100263
101446
  }
100264
- if (rowDimensionFinded || forceBody) {
101447
+ if (rowDimensionFinded || (forceBody && !isValid$1(row))) {
100265
101448
  row = this.columnHeaderLevelCount;
100266
101449
  const { startInTotal, afterSpanLevel } = rowDimensionFinded ?? defaultDimension;
100267
101450
  row += startInTotal ?? 0;
@@ -100770,7 +101953,7 @@
100770
101953
  collectedValues =
100771
101954
  this.dataset.collectedValues[key]?.[path
100772
101955
  .map(pathObj => {
100773
- return pathObj.value;
101956
+ return pathObj.dataValue ?? pathObj.value;
100774
101957
  })
100775
101958
  .join(this.dataset.stringJoinChar)];
100776
101959
  break;
@@ -100795,7 +101978,7 @@
100795
101978
  collectedValues =
100796
101979
  this.dataset.collectedValues[key]?.[path
100797
101980
  .map(pathObj => {
100798
- return pathObj.value;
101981
+ return pathObj.dataValue ?? pathObj.value;
100799
101982
  })
100800
101983
  .join(this.dataset.stringJoinChar)];
100801
101984
  break;
@@ -100854,7 +102037,7 @@
100854
102037
  if (path.colHeaderPaths.length) {
100855
102038
  path.colHeaderPaths.forEach(path => {
100856
102039
  if (path.dimensionKey) {
100857
- colKey.push(path.value);
102040
+ colKey.push(path.dataValue ?? path.value);
100858
102041
  }
100859
102042
  });
100860
102043
  }
@@ -100866,7 +102049,7 @@
100866
102049
  if (path.rowHeaderPaths.length) {
100867
102050
  path.rowHeaderPaths.forEach(path => {
100868
102051
  if (path.dimensionKey) {
100869
- rowKey.push(path.value);
102052
+ rowKey.push(path.dataValue ?? path.value);
100870
102053
  }
100871
102054
  });
100872
102055
  }
@@ -101543,6 +102726,8 @@
101543
102726
  totals;
101544
102727
  indicatorStatistics = [];
101545
102728
  stringJoinChar = String.fromCharCode(0);
102729
+ groupedGrandTotalKey = String.fromCharCode(1) + 'vtable_grouped_grand_total';
102730
+ groupedGrandTotalSubtotalKey = String.fromCharCode(1) + 'vtable_grouped_grand_total_subtotal';
101546
102731
  rowsIsTotal = [];
101547
102732
  colsIsTotal = [];
101548
102733
  colGrandTotalLabel;
@@ -101678,12 +102863,12 @@
101678
102863
  return this.rowsHasValue[index];
101679
102864
  }), this.indicatorsAsCol ? undefined : this.indicators, this.totals?.row?.showGrandTotals ||
101680
102865
  (!this.indicatorsAsCol && this.columns.length === 0) ||
101681
- (this.indicatorsAsCol && this.rows.length === 0), this.rowGrandTotalLabel, this.totals?.row?.showGrandTotalsOnTop ?? false);
102866
+ (this.indicatorsAsCol && this.rows.length === 0), this.rowGrandTotalLabel, this.totals?.row?.showGrandTotalsOnTop ?? false, this.totals?.row?.grandTotalDimensions, this.rowSubTotalLabel, this.totals?.row?.showSubTotalsOnTop ?? false, this.rows);
101682
102867
  }
101683
102868
  else {
101684
102869
  this.rowHeaderTree = this.ArrToTree(this.rowKeys, this.rows.filter((key, index) => {
101685
102870
  return this.rowsHasValue[index];
101686
- }), this.indicatorsAsCol ? undefined : this.indicators, this.rowsIsTotal, this.totals?.row?.showGrandTotals || (this.indicatorsAsCol && this.rows.length === 0), this.rowGrandTotalLabel, this.rowSubTotalLabel, this.totals?.row?.showGrandTotalsOnTop ?? false, this.totals?.row?.showSubTotalsOnTop ?? false);
102871
+ }), this.indicatorsAsCol ? undefined : this.indicators, this.rowsIsTotal, this.totals?.row?.showGrandTotals || (this.indicatorsAsCol && this.rows.length === 0), this.rowGrandTotalLabel, this.rowSubTotalLabel, this.totals?.row?.showGrandTotalsOnTop ?? false, this.totals?.row?.showSubTotalsOnTop ?? false, this.totals?.row?.grandTotalDimensions, true, this.rows);
101687
102872
  }
101688
102873
  }
101689
102874
  if (this.customColTree) {
@@ -101692,7 +102877,7 @@
101692
102877
  else {
101693
102878
  this.colHeaderTree = this.ArrToTree(this.colKeys, this.columns.filter((key, index) => {
101694
102879
  return this.columnsHasValue[index];
101695
- }), this.indicatorsAsCol ? this.indicators : undefined, this.colsIsTotal, this.totals?.column?.showGrandTotals || (!this.indicatorsAsCol && this.columns.length === 0), this.colGrandTotalLabel, this.colSubTotalLabel, this.totals?.column?.showGrandTotalsOnLeft ?? false, this.totals?.column?.showSubTotalsOnLeft ?? false);
102880
+ }), this.indicatorsAsCol ? this.indicators : undefined, this.colsIsTotal, this.totals?.column?.showGrandTotals || (!this.indicatorsAsCol && this.columns.length === 0), this.colGrandTotalLabel, this.colSubTotalLabel, this.totals?.column?.showGrandTotalsOnLeft ?? false, this.totals?.column?.showSubTotalsOnLeft ?? false, this.totals?.column?.grandTotalDimensions, false, this.columns);
101696
102881
  }
101697
102882
  typeof window !== 'undefined' ? window.performance.now() : 0;
101698
102883
  if (this.dataConfig?.isPivotChart) {
@@ -101799,6 +102984,9 @@
101799
102984
  if ((this.filterRules?.length ?? 0) >= 1) {
101800
102985
  isNeedFilter = true;
101801
102986
  }
102987
+ const records = (Array.isArray(this.records) ? this.records : Object.values(this.records).flat()).filter(record => !isNeedFilter || this.filterRecord(record));
102988
+ this.rowsHasValue = this.rows.map(row => records.some(record => record && row in record));
102989
+ this.columnsHasValue = this.columns.map(column => records.some(record => record && column in record));
101802
102990
  if (Array.isArray(this.records)) {
101803
102991
  if (!this.filteredRecords) {
101804
102992
  this.filteredRecords = [];
@@ -101851,77 +103039,94 @@
101851
103039
  }
101852
103040
  return isReserved;
101853
103041
  }
101854
- processRecord(record, assignedIndicatorKey) {
101855
- this.derivedFieldRules?.forEach((derivedFieldRule, i) => {
101856
- if (derivedFieldRule.fieldName && derivedFieldRule.derivedFunc) {
101857
- record[derivedFieldRule.fieldName] = derivedFieldRule.derivedFunc(record);
103042
+ collectValue(field, collectKeys, record) {
103043
+ if (!this.collectedValues[field]) {
103044
+ this.collectedValues[field] = {};
103045
+ }
103046
+ if (!this.collectedValues[field][collectKeys]) {
103047
+ if (this.collectValuesBy[field].sumBy) {
103048
+ this.collectedValues[field][collectKeys] = {};
101858
103049
  }
101859
- });
101860
- for (const field in this.collectValuesBy) {
101861
- if (isValid$1(record[field])) {
101862
- if (!this.collectedValues[field]) {
101863
- this.collectedValues[field] = {};
101864
- }
101865
- const collectKeys = this.collectValuesBy[field].by.map(byField => record[byField]).join(this.stringJoinChar);
101866
- if (!this.collectedValues[field][collectKeys]) {
101867
- if (this.collectValuesBy[field].sumBy) {
101868
- this.collectedValues[field][collectKeys] = {};
101869
- }
101870
- else if (this.collectValuesBy[field].range) {
101871
- this.collectedValues[field][collectKeys] = {
101872
- min: Number.MAX_SAFE_INTEGER,
101873
- max: Number.MIN_SAFE_INTEGER
101874
- };
101875
- }
101876
- else {
101877
- this.collectedValues[field][collectKeys] = [];
101878
- }
101879
- }
101880
- if (this.collectValuesBy[field].sumBy) {
101881
- const sumByKeys = this.collectValuesBy[field].sumBy
101882
- ?.map(byField => record[byField])
101883
- .join(this.stringJoinChar);
101884
- if (!this.collectedValues[field][collectKeys][sumByKeys]) {
101885
- this.collectedValues[field][collectKeys][sumByKeys] = new registeredAggregators[AggregationType.SUM]({
101886
- key: field,
101887
- field: field,
101888
- isRecord: undefined,
101889
- needSplitPositiveAndNegative: this.needSplitPositiveAndNegative
101890
- });
101891
- }
101892
- this.collectedValues[field][collectKeys][sumByKeys].push(record);
101893
- }
101894
- else if (this.collectValuesBy[field].range) {
101895
- const fieldRange = this.collectedValues[field][collectKeys];
101896
- let max = Math.max(record[field], fieldRange.max);
101897
- let min = Math.min(record[field], fieldRange.min);
101898
- if (this.collectValuesBy[field].considerFields) {
101899
- for (const considerField of this.collectValuesBy[field].considerFields) {
101900
- if (record[considerField]) {
101901
- if (typeof record[considerField] === 'number') {
101902
- max = Math.max(record[considerField], max);
101903
- min = Math.min(record[considerField], min);
101904
- }
101905
- else if (Array.isArray(record[considerField])) {
101906
- max = Math.max(...record[considerField], max);
101907
- min = Math.min(...record[considerField], min);
101908
- }
101909
- }
103050
+ else if (this.collectValuesBy[field].range) {
103051
+ this.collectedValues[field][collectKeys] = {
103052
+ min: Number.MAX_SAFE_INTEGER,
103053
+ max: Number.MIN_SAFE_INTEGER
103054
+ };
103055
+ }
103056
+ else {
103057
+ this.collectedValues[field][collectKeys] = [];
103058
+ }
103059
+ }
103060
+ if (this.collectValuesBy[field].sumBy) {
103061
+ const sumByKeys = this.collectValuesBy[field].sumBy
103062
+ ?.map(byField => record[byField])
103063
+ .join(this.stringJoinChar);
103064
+ if (!this.collectedValues[field][collectKeys][sumByKeys]) {
103065
+ this.collectedValues[field][collectKeys][sumByKeys] = new registeredAggregators[AggregationType.SUM]({
103066
+ key: field,
103067
+ field,
103068
+ isRecord: undefined,
103069
+ needSplitPositiveAndNegative: this.needSplitPositiveAndNegative
103070
+ });
103071
+ }
103072
+ this.collectedValues[field][collectKeys][sumByKeys].push(record);
103073
+ }
103074
+ else if (this.collectValuesBy[field].range) {
103075
+ const fieldRange = this.collectedValues[field][collectKeys];
103076
+ let max = Math.max(record[field], fieldRange.max);
103077
+ let min = Math.min(record[field], fieldRange.min);
103078
+ if (this.collectValuesBy[field].considerFields) {
103079
+ for (const considerField of this.collectValuesBy[field].considerFields) {
103080
+ if (record[considerField]) {
103081
+ if (typeof record[considerField] === 'number') {
103082
+ max = Math.max(record[considerField], max);
103083
+ min = Math.min(record[considerField], min);
103084
+ }
103085
+ else if (Array.isArray(record[considerField])) {
103086
+ max = Math.max(...record[considerField], max);
103087
+ min = Math.min(...record[considerField], min);
101910
103088
  }
101911
- }
101912
- if (!isNaN(max)) {
101913
- fieldRange.max = max;
101914
- fieldRange.min = min;
101915
- }
101916
- }
101917
- else {
101918
- const fieldRange = this.collectedValues[field][collectKeys];
101919
- if (fieldRange.indexOf(record[field]) === -1) {
101920
- fieldRange.push(record[field]);
101921
103089
  }
101922
103090
  }
101923
103091
  }
103092
+ if (!isNaN(max)) {
103093
+ fieldRange.max = max;
103094
+ fieldRange.min = min;
103095
+ }
103096
+ }
103097
+ else {
103098
+ const fieldValues = this.collectedValues[field][collectKeys];
103099
+ if (fieldValues.indexOf(record[field]) === -1) {
103100
+ fieldValues.push(record[field]);
103101
+ }
101924
103102
  }
103103
+ }
103104
+ getGroupedCollectedValueKeys(by, record) {
103105
+ if (!this.dataConfig?.isPivotChart) {
103106
+ return [];
103107
+ }
103108
+ const keys = new Set();
103109
+ [
103110
+ { dimensions: this.rows, totals: this.totals?.row },
103111
+ { dimensions: this.columns, totals: this.totals?.column }
103112
+ ].forEach(({ dimensions, totals }) => {
103113
+ if (!totals?.showGrandTotals) {
103114
+ return;
103115
+ }
103116
+ const dimensionIndexes = this.getGrandTotalDimensionIndexes(dimensions, totals.grandTotalDimensions);
103117
+ if (dimensionIndexes.length && dimensionIndexes.every(index => by.indexOf(dimensions[index]) !== -1)) {
103118
+ keys.add(join([this.groupedGrandTotalKey, ...dimensionIndexes.map(index => record[dimensions[index]])], this.stringJoinChar));
103119
+ keys.add(join([this.groupedGrandTotalKey, this.groupedGrandTotalSubtotalKey], this.stringJoinChar));
103120
+ }
103121
+ });
103122
+ return Array.from(keys);
103123
+ }
103124
+ processRecord(record, assignedIndicatorKey) {
103125
+ this.derivedFieldRules?.forEach((derivedFieldRule, i) => {
103126
+ if (derivedFieldRule.fieldName && derivedFieldRule.derivedFunc) {
103127
+ record[derivedFieldRule.fieldName] = derivedFieldRule.derivedFunc(record);
103128
+ }
103129
+ });
101925
103130
  let isToTalRecord = false;
101926
103131
  const colKeys = [];
101927
103132
  const rowKeys = [];
@@ -101951,29 +103156,43 @@
101951
103156
  else {
101952
103157
  const rowKey = [];
101953
103158
  rowKeys.push({ rowKey, indicatorKey: assignedIndicatorKey });
101954
- for (let l = 0, len1 = this.rows.length; l < len1; l++) {
101955
- const rowAttr = this.rows[l];
101956
- if (rowAttr in record) {
101957
- this.rowsHasValue[l] = true;
101958
- rowKey.push(record[rowAttr]);
101959
- }
101960
- else if (rowAttr !== IndicatorDimensionKeyPlaceholder) {
101961
- if (this.dataConfig?.totals?.row?.showGrandTotals &&
101962
- l === 0 &&
101963
- !this.rows.find((rk) => {
101964
- return rk in record;
101965
- })) {
101966
- rowKey.push(this.rowGrandTotalLabel);
101967
- isToTalRecord = true;
101968
- break;
101969
- }
101970
- else if (this.dataConfig?.totals?.row?.subTotalsDimensions &&
101971
- this.dataConfig?.totals?.row?.subTotalsDimensions.indexOf(this.rows[l - 1]) >= 0) {
101972
- if (this.rowHierarchyType !== 'tree') {
101973
- rowKey.push(this.rowSubTotalLabel);
103159
+ const customGroupedGrandTotalKey = this.dataConfig?.totals?.row?.showGrandTotals && this.rowsHasValue[0]
103160
+ ? this.getCustomGroupedGrandTotalKey(record, this.rows, this.dataConfig?.totals?.row?.grandTotalDimensions)
103161
+ : undefined;
103162
+ if (customGroupedGrandTotalKey) {
103163
+ rowKey.push(...customGroupedGrandTotalKey);
103164
+ isToTalRecord = true;
103165
+ }
103166
+ else {
103167
+ for (let l = 0, len1 = this.rows.length; l < len1; l++) {
103168
+ const rowAttr = this.rows[l];
103169
+ if (rowAttr in record) {
103170
+ this.rowsHasValue[l] = true;
103171
+ rowKey.push(record[rowAttr]);
103172
+ }
103173
+ else if (rowAttr !== IndicatorDimensionKeyPlaceholder) {
103174
+ if (this.dataConfig?.totals?.row?.showGrandTotals &&
103175
+ l === 0 &&
103176
+ !this.rows.find((rk) => {
103177
+ return rk in record;
103178
+ })) {
103179
+ if (this.getGrandTotalDimensionIndexes(this.rows, this.dataConfig.totals.row.grandTotalDimensions).length) {
103180
+ rowKey.push(this.groupedGrandTotalKey, this.groupedGrandTotalSubtotalKey);
103181
+ }
103182
+ else {
103183
+ rowKey.push(this.rowGrandTotalLabel);
103184
+ }
103185
+ isToTalRecord = true;
103186
+ break;
103187
+ }
103188
+ else if (this.dataConfig?.totals?.row?.subTotalsDimensions &&
103189
+ this.dataConfig?.totals?.row?.subTotalsDimensions.indexOf(this.rows[l - 1]) >= 0) {
103190
+ if (this.rowHierarchyType !== 'tree') {
103191
+ rowKey.push(this.rowSubTotalLabel);
103192
+ }
103193
+ isToTalRecord = true;
103194
+ break;
101974
103195
  }
101975
- isToTalRecord = true;
101976
- break;
101977
103196
  }
101978
103197
  }
101979
103198
  }
@@ -102004,31 +103223,57 @@
102004
103223
  else {
102005
103224
  const colKey = [];
102006
103225
  colKeys.push({ colKey, indicatorKey: assignedIndicatorKey });
102007
- for (let n = 0, len2 = this.columns.length; n < len2; n++) {
102008
- const colAttr = this.columns[n];
102009
- if (colAttr in record) {
102010
- this.columnsHasValue[n] = true;
102011
- colKey.push(record[colAttr]);
102012
- }
102013
- else if (colAttr !== IndicatorDimensionKeyPlaceholder) {
102014
- if (this.dataConfig?.totals?.column?.showGrandTotals &&
102015
- n === 0 &&
102016
- !this.columns.find((ck) => {
102017
- return ck in record;
102018
- })) {
102019
- colKey.push(this.colGrandTotalLabel);
102020
- isToTalRecord = true;
102021
- break;
102022
- }
102023
- else if (this.dataConfig?.totals?.column?.subTotalsDimensions &&
102024
- this.dataConfig?.totals?.column?.subTotalsDimensions.indexOf(this.columns[n - 1]) >= 0) {
102025
- colKey.push(this.colSubTotalLabel);
102026
- isToTalRecord = true;
102027
- break;
103226
+ const customGroupedGrandTotalKey = this.dataConfig?.totals?.column?.showGrandTotals && this.columnsHasValue[0]
103227
+ ? this.getCustomGroupedGrandTotalKey(record, this.columns, this.dataConfig?.totals?.column?.grandTotalDimensions)
103228
+ : undefined;
103229
+ if (customGroupedGrandTotalKey) {
103230
+ colKey.push(...customGroupedGrandTotalKey);
103231
+ isToTalRecord = true;
103232
+ }
103233
+ else {
103234
+ for (let n = 0, len2 = this.columns.length; n < len2; n++) {
103235
+ const colAttr = this.columns[n];
103236
+ if (colAttr in record) {
103237
+ this.columnsHasValue[n] = true;
103238
+ colKey.push(record[colAttr]);
103239
+ }
103240
+ else if (colAttr !== IndicatorDimensionKeyPlaceholder) {
103241
+ if (this.dataConfig?.totals?.column?.showGrandTotals &&
103242
+ n === 0 &&
103243
+ !this.columns.find((ck) => {
103244
+ return ck in record;
103245
+ })) {
103246
+ if (this.getGrandTotalDimensionIndexes(this.columns, this.dataConfig.totals.column.grandTotalDimensions)
103247
+ .length) {
103248
+ colKey.push(this.groupedGrandTotalKey, this.groupedGrandTotalSubtotalKey);
103249
+ }
103250
+ else {
103251
+ colKey.push(this.colGrandTotalLabel);
103252
+ }
103253
+ isToTalRecord = true;
103254
+ break;
103255
+ }
103256
+ else if (this.dataConfig?.totals?.column?.subTotalsDimensions &&
103257
+ this.dataConfig?.totals?.column?.subTotalsDimensions.indexOf(this.columns[n - 1]) >= 0) {
103258
+ colKey.push(this.colSubTotalLabel);
103259
+ isToTalRecord = true;
103260
+ break;
103261
+ }
102028
103262
  }
102029
103263
  }
102030
103264
  }
102031
103265
  }
103266
+ if (!isToTalRecord) {
103267
+ for (const field in this.collectValuesBy) {
103268
+ if (isValid$1(record[field])) {
103269
+ const collectKeys = this.collectValuesBy[field].by.map(byField => record[byField]).join(this.stringJoinChar);
103270
+ this.collectValue(field, collectKeys, record);
103271
+ this.getGroupedCollectedValueKeys(this.collectValuesBy[field].by, record).forEach(groupedCollectKeys => {
103272
+ this.collectValue(field, groupedCollectKeys, record);
103273
+ });
103274
+ }
103275
+ }
103276
+ }
102032
103277
  for (let row_i = 0; row_i < rowKeys.length; row_i++) {
102033
103278
  const rowKey = rowKeys[row_i].rowKey;
102034
103279
  let assignedIndicatorKey_value;
@@ -102223,18 +103468,18 @@
102223
103468
  return this.rowsHasValue[index];
102224
103469
  }), this.indicatorsAsCol ? undefined : this.indicators, this.totals?.row?.showGrandTotals ||
102225
103470
  (!this.indicatorsAsCol && this.columns.length === 0) ||
102226
- (this.indicatorsAsCol && this.rows.length === 0), this.rowGrandTotalLabel, this.totals?.row?.showGrandTotalsOnTop ?? false);
103471
+ (this.indicatorsAsCol && this.rows.length === 0), this.rowGrandTotalLabel, this.totals?.row?.showGrandTotalsOnTop ?? false, this.totals?.row?.grandTotalDimensions, this.rowSubTotalLabel, this.totals?.row?.showSubTotalsOnTop ?? false, this.rows);
102227
103472
  }
102228
103473
  else {
102229
103474
  this.rowHeaderTree = this.ArrToTree(this.rowKeys, this.rows.filter((key, index) => {
102230
103475
  return this.rowsHasValue[index];
102231
- }), this.indicatorsAsCol ? undefined : this.indicators, this.rowsIsTotal, this.totals?.row?.showGrandTotals || (this.indicatorsAsCol && this.rows.length === 0), this.rowGrandTotalLabel, this.rowSubTotalLabel, this.totals?.row?.showGrandTotalsOnTop ?? false, this.totals?.row?.showSubTotalsOnTop ?? false);
103476
+ }), this.indicatorsAsCol ? undefined : this.indicators, this.rowsIsTotal, this.totals?.row?.showGrandTotals || (this.indicatorsAsCol && this.rows.length === 0), this.rowGrandTotalLabel, this.rowSubTotalLabel, this.totals?.row?.showGrandTotalsOnTop ?? false, this.totals?.row?.showSubTotalsOnTop ?? false, this.totals?.row?.grandTotalDimensions, true, this.rows);
102232
103477
  }
102233
103478
  }
102234
103479
  if (!this.customColTree) {
102235
103480
  this.colHeaderTree = this.ArrToTree(this.colKeys, this.columns.filter((key, index) => {
102236
103481
  return this.columnsHasValue[index];
102237
- }), this.indicatorsAsCol ? this.indicators : undefined, this.colsIsTotal, this.totals?.column?.showGrandTotals || (!this.indicatorsAsCol && this.columns.length === 0), this.colGrandTotalLabel, this.colSubTotalLabel, this.totals?.column?.showGrandTotalsOnLeft ?? false, this.totals?.column?.showSubTotalsOnLeft ?? false);
103482
+ }), this.indicatorsAsCol ? this.indicators : undefined, this.colsIsTotal, this.totals?.column?.showGrandTotals || (!this.indicatorsAsCol && this.columns.length === 0), this.colGrandTotalLabel, this.colSubTotalLabel, this.totals?.column?.showGrandTotalsOnLeft ?? false, this.totals?.column?.showSubTotalsOnLeft ?? false, this.totals?.column?.grandTotalDimensions, false, this.columns);
102238
103483
  }
102239
103484
  }
102240
103485
  updateFilterRules(filterRules, isResetTree = false) {
@@ -102296,7 +103541,7 @@
102296
103541
  });
102297
103542
  }
102298
103543
  if (rowKey.length < this.rows.length && this.rowHierarchyType === 'grid-tree') {
102299
- if (rowKey[0] === this.rowGrandTotalLabel) ;
103544
+ if (rowKey[0] === this.rowGrandTotalLabel || rowKey[0] === this.groupedGrandTotalKey) ;
102300
103545
  else if (((this.totals?.row?.subTotalsDimensions &&
102301
103546
  this.totals?.row?.subTotalsDimensions?.length >= 1 &&
102302
103547
  this.totals.row.subTotalsDimensions.find((dimension) => dimension === rowDimensionKey)) ||
@@ -102319,7 +103564,7 @@
102319
103564
  });
102320
103565
  }
102321
103566
  if (colKey.length < this.columns.length && this.columnHierarchyType === 'grid-tree') {
102322
- if (colKey[0] === this.colGrandTotalLabel) ;
103567
+ if (colKey[0] === this.colGrandTotalLabel || colKey[0] === this.groupedGrandTotalKey) ;
102323
103568
  else if (((this.totals?.column?.subTotalsDimensions &&
102324
103569
  this.totals?.column?.subTotalsDimensions?.length >= 1 &&
102325
103570
  this.totals.column.subTotalsDimensions.find((dimension) => dimension === colDimensionKey)) ||
@@ -102330,6 +103575,28 @@
102330
103575
  }
102331
103576
  flatColKey = join(colKey, this.stringJoinChar);
102332
103577
  }
103578
+ if (Array.isArray(rowKey) &&
103579
+ rowKey[0] === this.rowGrandTotalLabel &&
103580
+ !this.tree[flatRowKey] &&
103581
+ this.getGrandTotalDimensionIndexes(this.rows.filter((_, index) => this.rowsHasValue[index]), this.totals?.row?.grandTotalDimensions, this.rows).length) {
103582
+ const internalRowKey = rowKey.slice();
103583
+ internalRowKey[0] = this.groupedGrandTotalKey;
103584
+ if (internalRowKey.length === 2 && internalRowKey[1] === this.rowSubTotalLabel) {
103585
+ internalRowKey[1] = this.groupedGrandTotalSubtotalKey;
103586
+ }
103587
+ flatRowKey = join(internalRowKey, this.stringJoinChar);
103588
+ }
103589
+ if (Array.isArray(colKey) &&
103590
+ colKey[0] === this.colGrandTotalLabel &&
103591
+ !this.tree[flatRowKey]?.[flatColKey] &&
103592
+ this.getGrandTotalDimensionIndexes(this.columns.filter((_, index) => this.columnsHasValue[index]), this.totals?.column?.grandTotalDimensions, this.columns).length) {
103593
+ const internalColKey = colKey.slice();
103594
+ internalColKey[0] = this.groupedGrandTotalKey;
103595
+ if (internalColKey.length === 2 && internalColKey[1] === this.colSubTotalLabel) {
103596
+ internalColKey[1] = this.groupedGrandTotalSubtotalKey;
103597
+ }
103598
+ flatColKey = join(internalColKey, this.stringJoinChar);
103599
+ }
102333
103600
  const agg = this.tree[flatRowKey]?.[flatColKey]?.[indicatorIndex];
102334
103601
  if (considerChangedValue && isValid$1(this.changedTree[flatRowKey]?.[flatColKey]?.[indicatorIndex])) {
102335
103602
  const changeValue = this.changedTree[flatRowKey][flatColKey][indicatorIndex];
@@ -102408,7 +103675,7 @@
102408
103675
  this.colKeys.sort(sortfun);
102409
103676
  }
102410
103677
  }
102411
- arrSort(fieldArr, isRow) {
103678
+ arrSort(fieldArr, isRow, pathPrefix) {
102412
103679
  let field;
102413
103680
  const that = this;
102414
103681
  const sortersArr = function (_this) {
@@ -102440,20 +103707,24 @@
102440
103707
  let bChanged = b;
102441
103708
  if (sorter.fieldIndex < fieldArr.length - 1) {
102442
103709
  aChanged = a.slice(0, sorter.fieldIndex + 1);
102443
- if (that.rowHierarchyType === 'grid' && isRow) {
103710
+ if (!pathPrefix?.length && that.rowHierarchyType === 'grid' && isRow) {
102444
103711
  aChanged.push(that.rowSubTotalLabel);
102445
103712
  }
102446
- else if (!isRow) {
103713
+ else if (!pathPrefix?.length && !isRow) {
102447
103714
  aChanged.push(that.colSubTotalLabel);
102448
103715
  }
102449
103716
  bChanged = b.slice(0, sorter.fieldIndex + 1);
102450
- if (that.rowHierarchyType === 'grid' && isRow) {
103717
+ if (!pathPrefix?.length && that.rowHierarchyType === 'grid' && isRow) {
102451
103718
  bChanged.push(that.rowSubTotalLabel);
102452
103719
  }
102453
- else if (!isRow) {
103720
+ else if (!pathPrefix?.length && !isRow) {
102454
103721
  bChanged.push(that.colSubTotalLabel);
102455
103722
  }
102456
103723
  }
103724
+ if (pathPrefix?.length) {
103725
+ aChanged = [...pathPrefix, ...aChanged];
103726
+ bChanged = [...pathPrefix, ...bChanged];
103727
+ }
102457
103728
  comparison = sorter.func(aChanged, bChanged, sorter.sortRule?.sortType);
102458
103729
  }
102459
103730
  else {
@@ -102474,12 +103745,14 @@
102474
103745
  if (that.rowHierarchyType === 'grid' &&
102475
103746
  rowKey.length < that.rows.length &&
102476
103747
  rowKey[rowKey.length - 1] !== that.rowSubTotalLabel &&
102477
- rowKey[rowKey.length - 1] !== that.rowGrandTotalLabel) {
103748
+ rowKey[rowKey.length - 1] !== that.rowGrandTotalLabel &&
103749
+ rowKey[0] !== that.groupedGrandTotalKey) {
102478
103750
  rowKey.push(that.rowSubTotalLabel);
102479
103751
  }
102480
103752
  if (colKey.length < that.columns.length &&
102481
103753
  colKey[colKey.length - 1] !== that.colSubTotalLabel &&
102482
- colKey[colKey.length - 1] !== that.colGrandTotalLabel) {
103754
+ colKey[colKey.length - 1] !== that.colGrandTotalLabel &&
103755
+ colKey[0] !== that.groupedGrandTotalKey) {
102483
103756
  colKey.push(that.colSubTotalLabel);
102484
103757
  }
102485
103758
  return that.getAggregator(rowKey, colKey, sortRule.sortByIndicator).value();
@@ -102588,56 +103861,63 @@
102588
103861
  }
102589
103862
  }
102590
103863
  }
102591
- if (that.totals?.column?.showGrandTotals || this.rows.length === 0) {
102592
- const flatColTotalKey = that.colGrandTotalLabel;
102593
- if (this.totalRecordsTree?.[flatRowKey]?.[flatColTotalKey]) {
102594
- this.tree[flatRowKey][flatColTotalKey] = this.totalRecordsTree?.[flatRowKey]?.[flatColTotalKey];
102595
- return;
102596
- }
102597
- if (!this.tree[flatRowKey][flatColTotalKey]) {
102598
- this.tree[flatRowKey][flatColTotalKey] = [];
102599
- }
102600
- const toComputeIndicatorKeys = this.indicatorKeysIncludeCalculatedFieldDependIndicatorKeys;
102601
- for (let i = 0; i < toComputeIndicatorKeys.length; i++) {
102602
- if (this.calculatedFiledKeys.indexOf(toComputeIndicatorKeys[i]) >= 0) {
102603
- const calculatedFieldRule = this.calculatedFieldRules?.find(rule => rule.key === toComputeIndicatorKeys[i]);
102604
- if (!this.tree[flatRowKey]?.[flatColTotalKey]?.[i]) {
102605
- this.tree[flatRowKey][flatColTotalKey][i] = new registeredAggregators[AggregationType.RECALCULATE]({
102606
- key: toComputeIndicatorKeys[i],
102607
- field: toComputeIndicatorKeys[i],
102608
- isRecord: true,
102609
- formatFun: this.indicators?.find((indicator) => {
102610
- if (typeof indicator !== 'string') {
102611
- return indicator.indicatorKey === toComputeIndicatorKeys[i];
102612
- }
102613
- return false;
102614
- })?.format,
102615
- calculateFun: calculatedFieldRule?.calculateFun,
102616
- dependAggregators: this.tree[flatRowKey][flatColTotalKey],
102617
- dependIndicatorKeys: calculatedFieldRule?.dependIndicatorKeys
102618
- });
102619
- }
102620
- if (flatColTotalKey !== flatColKey) {
102621
- this.tree[flatRowKey][flatColTotalKey][i].push(that.tree[flatRowKey]?.[flatColKey]?.[i]);
102622
- }
103864
+ if ((that.totals?.column?.showGrandTotals || this.rows.length === 0) && colKey[0] !== this.groupedGrandTotalKey) {
103865
+ const flatColTotalKeys = this.getGrandTotalKeys(colKey, that.columns.filter((_, index) => that.columnsHasValue[index]), that.totals?.column?.grandTotalDimensions, that.colGrandTotalLabel, that.columns);
103866
+ for (const flatColTotalKey of flatColTotalKeys) {
103867
+ if (this.totalRecordsTree?.[flatRowKey]?.[flatColTotalKey]) {
103868
+ this.tree[flatRowKey][flatColTotalKey] = this.totalRecordsTree?.[flatRowKey]?.[flatColTotalKey];
103869
+ continue;
102623
103870
  }
102624
- else {
102625
- if (!this.tree[flatRowKey][flatColTotalKey][i]) {
102626
- const aggRule = this.getAggregatorRule(toComputeIndicatorKeys[i]);
102627
- this.tree[flatRowKey][flatColTotalKey][i] = new registeredAggregators[aggRule?.aggregationType ?? AggregationType.SUM]({
102628
- key: toComputeIndicatorKeys[i],
102629
- field: aggRule?.field ?? toComputeIndicatorKeys[i],
102630
- formatFun: aggRule?.formatFun ??
102631
- this.indicators?.find((indicator) => {
103871
+ if (!this.tree[flatRowKey][flatColTotalKey]) {
103872
+ this.tree[flatRowKey][flatColTotalKey] = [];
103873
+ }
103874
+ const toComputeIndicatorKeys = this.indicatorKeysIncludeCalculatedFieldDependIndicatorKeys;
103875
+ for (let i = 0; i < toComputeIndicatorKeys.length; i++) {
103876
+ if (this.calculatedFiledKeys.indexOf(toComputeIndicatorKeys[i]) >= 0) {
103877
+ const calculatedFieldRule = this.calculatedFieldRules?.find(rule => rule.key === toComputeIndicatorKeys[i]);
103878
+ if (!this.tree[flatRowKey]?.[flatColTotalKey]?.[i]) {
103879
+ this.tree[flatRowKey][flatColTotalKey][i] = new registeredAggregators[AggregationType.RECALCULATE]({
103880
+ key: toComputeIndicatorKeys[i],
103881
+ field: toComputeIndicatorKeys[i],
103882
+ isRecord: true,
103883
+ formatFun: this.indicators?.find((indicator) => {
102632
103884
  if (typeof indicator !== 'string') {
102633
103885
  return indicator.indicatorKey === toComputeIndicatorKeys[i];
102634
103886
  }
102635
103887
  return false;
102636
- })?.format
102637
- });
103888
+ })?.format,
103889
+ calculateFun: calculatedFieldRule?.calculateFun,
103890
+ dependAggregators: this.tree[flatRowKey][flatColTotalKey],
103891
+ dependIndicatorKeys: calculatedFieldRule?.dependIndicatorKeys
103892
+ });
103893
+ }
103894
+ if (flatColTotalKey !== flatColKey) {
103895
+ this.tree[flatRowKey][flatColTotalKey][i].push(that.tree[flatRowKey]?.[flatColKey]?.[i]);
103896
+ }
102638
103897
  }
102639
- if (flatColTotalKey !== flatColKey) {
102640
- this.tree[flatRowKey][flatColTotalKey][i].push(that.tree[flatRowKey]?.[flatColKey]?.[i]);
103898
+ else {
103899
+ if (!this.tree[flatRowKey][flatColTotalKey][i]) {
103900
+ const aggRule = this.getAggregatorRule(toComputeIndicatorKeys[i]);
103901
+ this.tree[flatRowKey][flatColTotalKey][i] = new registeredAggregators[aggRule?.aggregationType ?? AggregationType.SUM]({
103902
+ key: toComputeIndicatorKeys[i],
103903
+ field: aggRule?.field ?? toComputeIndicatorKeys[i],
103904
+ aggregationFun: aggRule?.aggregationFun,
103905
+ formatFun: aggRule?.formatFun ??
103906
+ this.indicators?.find((indicator) => {
103907
+ if (typeof indicator !== 'string') {
103908
+ return indicator.indicatorKey === toComputeIndicatorKeys[i];
103909
+ }
103910
+ return false;
103911
+ })?.format
103912
+ });
103913
+ if (this.tree[flatRowKey][flatColTotalKey][i] instanceof CustomAggregator &&
103914
+ flatColTotalKey.startsWith(this.groupedGrandTotalKey)) {
103915
+ this.tree[flatRowKey][flatColTotalKey][i].recalculateFromChildren = true;
103916
+ }
103917
+ }
103918
+ if (flatColTotalKey !== flatColKey) {
103919
+ this.tree[flatRowKey][flatColTotalKey][i].push(that.tree[flatRowKey]?.[flatColKey]?.[i]);
103920
+ }
102641
103921
  }
102642
103922
  }
102643
103923
  }
@@ -102719,52 +103999,60 @@
102719
103999
  }
102720
104000
  }
102721
104001
  }
102722
- if (that.totals?.row?.showGrandTotals || this.columns.length === 0) {
102723
- const flatRowTotalKey = that.rowGrandTotalLabel;
102724
- if (!this.tree[flatRowTotalKey]) {
102725
- this.tree[flatRowTotalKey] = {};
102726
- rowTotalKeys.push(flatRowTotalKey);
102727
- }
102728
- if (!this.tree[flatRowTotalKey][flatColKey]) {
102729
- this.tree[flatRowTotalKey][flatColKey] = [];
102730
- }
102731
- const toComputeIndicatorKeys = this.indicatorKeysIncludeCalculatedFieldDependIndicatorKeys;
102732
- for (let i = 0; i < toComputeIndicatorKeys.length; i++) {
102733
- if (!this.tree[flatRowTotalKey][flatColKey][i]) {
102734
- if (this.calculatedFiledKeys.indexOf(toComputeIndicatorKeys[i]) >= 0) {
102735
- const calculatedFieldRule = this.calculatedFieldRules?.find(rule => rule.key === toComputeIndicatorKeys[i]);
102736
- this.tree[flatRowTotalKey][flatColKey][i] = new registeredAggregators[AggregationType.RECALCULATE]({
102737
- key: toComputeIndicatorKeys[i],
102738
- field: toComputeIndicatorKeys[i],
102739
- isRecord: true,
102740
- formatFun: this.indicators?.find((indicator) => {
102741
- if (typeof indicator !== 'string') {
102742
- return indicator.indicatorKey === toComputeIndicatorKeys[i];
102743
- }
102744
- return false;
102745
- })?.format,
102746
- calculateFun: calculatedFieldRule?.calculateFun,
102747
- dependAggregators: this.tree[flatRowTotalKey][flatColKey],
102748
- dependIndicatorKeys: calculatedFieldRule?.dependIndicatorKeys
102749
- });
102750
- }
102751
- else {
102752
- const aggRule = this.getAggregatorRule(toComputeIndicatorKeys[i]);
102753
- this.tree[flatRowTotalKey][flatColKey][i] = new registeredAggregators[aggRule?.aggregationType ?? AggregationType.SUM]({
102754
- key: toComputeIndicatorKeys[i],
102755
- field: aggRule?.field ?? toComputeIndicatorKeys[i],
102756
- formatFun: aggRule?.formatFun ??
102757
- this.indicators?.find((indicator) => {
104002
+ if ((that.totals?.row?.showGrandTotals || this.columns.length === 0) &&
104003
+ rowKey[0] !== this.groupedGrandTotalKey) {
104004
+ const flatRowTotalKeys = this.getGrandTotalKeys(rowKey, that.rows.filter((_, index) => that.rowsHasValue[index]), that.totals?.row?.grandTotalDimensions, that.rowGrandTotalLabel, that.rows);
104005
+ for (const flatRowTotalKey of flatRowTotalKeys) {
104006
+ if (!this.tree[flatRowTotalKey]) {
104007
+ this.tree[flatRowTotalKey] = {};
104008
+ rowTotalKeys.push(flatRowTotalKey);
104009
+ }
104010
+ if (!this.tree[flatRowTotalKey][flatColKey]) {
104011
+ this.tree[flatRowTotalKey][flatColKey] = [];
104012
+ }
104013
+ const toComputeIndicatorKeys = this.indicatorKeysIncludeCalculatedFieldDependIndicatorKeys;
104014
+ for (let i = 0; i < toComputeIndicatorKeys.length; i++) {
104015
+ if (!this.tree[flatRowTotalKey][flatColKey][i]) {
104016
+ if (this.calculatedFiledKeys.indexOf(toComputeIndicatorKeys[i]) >= 0) {
104017
+ const calculatedFieldRule = this.calculatedFieldRules?.find(rule => rule.key === toComputeIndicatorKeys[i]);
104018
+ this.tree[flatRowTotalKey][flatColKey][i] = new registeredAggregators[AggregationType.RECALCULATE]({
104019
+ key: toComputeIndicatorKeys[i],
104020
+ field: toComputeIndicatorKeys[i],
104021
+ isRecord: true,
104022
+ formatFun: this.indicators?.find((indicator) => {
102758
104023
  if (typeof indicator !== 'string') {
102759
104024
  return indicator.indicatorKey === toComputeIndicatorKeys[i];
102760
104025
  }
102761
104026
  return false;
102762
- })?.format
102763
- });
104027
+ })?.format,
104028
+ calculateFun: calculatedFieldRule?.calculateFun,
104029
+ dependAggregators: this.tree[flatRowTotalKey][flatColKey],
104030
+ dependIndicatorKeys: calculatedFieldRule?.dependIndicatorKeys
104031
+ });
104032
+ }
104033
+ else {
104034
+ const aggRule = this.getAggregatorRule(toComputeIndicatorKeys[i]);
104035
+ this.tree[flatRowTotalKey][flatColKey][i] = new registeredAggregators[aggRule?.aggregationType ?? AggregationType.SUM]({
104036
+ key: toComputeIndicatorKeys[i],
104037
+ field: aggRule?.field ?? toComputeIndicatorKeys[i],
104038
+ aggregationFun: aggRule?.aggregationFun,
104039
+ formatFun: aggRule?.formatFun ??
104040
+ this.indicators?.find((indicator) => {
104041
+ if (typeof indicator !== 'string') {
104042
+ return indicator.indicatorKey === toComputeIndicatorKeys[i];
104043
+ }
104044
+ return false;
104045
+ })?.format
104046
+ });
104047
+ if (this.tree[flatRowTotalKey][flatColKey][i] instanceof CustomAggregator &&
104048
+ flatRowTotalKey.startsWith(this.groupedGrandTotalKey)) {
104049
+ this.tree[flatRowTotalKey][flatColKey][i].recalculateFromChildren = true;
104050
+ }
104051
+ }
104052
+ }
104053
+ if (flatRowTotalKey !== flatRowKey) {
104054
+ this.tree[flatRowTotalKey][flatColKey][i].push(that.tree[flatRowKey]?.[flatColKey]?.[i]);
102764
104055
  }
102765
- }
102766
- if (flatRowTotalKey !== flatRowKey) {
102767
- this.tree[flatRowTotalKey][flatColKey][i].push(that.tree[flatRowKey]?.[flatColKey]?.[i]);
102768
104056
  }
102769
104057
  }
102770
104058
  }
@@ -102783,7 +104071,64 @@
102783
104071
  }
102784
104072
  }
102785
104073
  }
102786
- ArrToTree1(arr, rows, indicators, isGrandTotal, grandTotalLabel, showGrandTotalsOnTop) {
104074
+ getGrandTotalDimensionIndexes(dimensions, grandTotalDimensions, configuredDimensions = dimensions) {
104075
+ if (!grandTotalDimensions?.length) {
104076
+ return [];
104077
+ }
104078
+ return grandTotalDimensions
104079
+ .map(dimension => ({
104080
+ configuredIndex: configuredDimensions.indexOf(dimension),
104081
+ activeIndex: dimensions.indexOf(dimension)
104082
+ }))
104083
+ .filter(({ configuredIndex, activeIndex }, position, indexes) => configuredIndex > 0 &&
104084
+ activeIndex >= 0 &&
104085
+ indexes.findIndex(item => item.activeIndex === activeIndex) === position)
104086
+ .map(({ activeIndex }) => activeIndex)
104087
+ .sort((a, b) => a - b);
104088
+ }
104089
+ getCustomGroupedGrandTotalKey(record, dimensions, grandTotalDimensions) {
104090
+ const dimensionIndexes = this.getGrandTotalDimensionIndexes(dimensions, grandTotalDimensions);
104091
+ if (!dimensionIndexes.length ||
104092
+ dimensions.some((dimension, index) => dimensionIndexes.indexOf(index) === -1 && dimension in record)) {
104093
+ return undefined;
104094
+ }
104095
+ const prefixIndexes = [];
104096
+ for (const index of dimensionIndexes) {
104097
+ if (!(dimensions[index] in record)) {
104098
+ break;
104099
+ }
104100
+ prefixIndexes.push(index);
104101
+ }
104102
+ if (!prefixIndexes.length ||
104103
+ dimensionIndexes.slice(prefixIndexes.length).some(index => dimensions[index] in record)) {
104104
+ return undefined;
104105
+ }
104106
+ return [this.groupedGrandTotalKey, ...prefixIndexes.map(index => record[dimensions[index]])];
104107
+ }
104108
+ getGroupedGrandTotalPaths(keys, dimensions, grandTotalDimensions, isRow = true, configuredDimensions = dimensions) {
104109
+ const dimensionIndexes = this.getGrandTotalDimensionIndexes(dimensions, grandTotalDimensions, configuredDimensions);
104110
+ const groupedPaths = new Map();
104111
+ keys.forEach(key => {
104112
+ const path = dimensionIndexes.map(index => key[index]);
104113
+ groupedPaths.set(join(path, this.stringJoinChar), path);
104114
+ });
104115
+ return Array.from(groupedPaths.values()).sort(this.arrSort(dimensionIndexes.map(index => dimensions[index]), isRow, [this.groupedGrandTotalKey]));
104116
+ }
104117
+ getGrandTotalKeys(dimensionKey, dimensions, grandTotalDimensions, grandTotalLabel, configuredDimensions = dimensions) {
104118
+ const dimensionIndexes = this.getGrandTotalDimensionIndexes(dimensions, grandTotalDimensions, configuredDimensions);
104119
+ if (!dimensionIndexes.length) {
104120
+ return [grandTotalLabel];
104121
+ }
104122
+ const groupedKey = [
104123
+ this.groupedGrandTotalKey,
104124
+ ...dimensionIndexes.map(dimensionIndex => dimensionKey[dimensionIndex])
104125
+ ];
104126
+ return [
104127
+ ...groupedKey.slice(1).map((_, index) => join(groupedKey.slice(0, index + 2), this.stringJoinChar)),
104128
+ join([this.groupedGrandTotalKey, this.groupedGrandTotalSubtotalKey], this.stringJoinChar)
104129
+ ];
104130
+ }
104131
+ ArrToTree1(arr, rows, indicators, isGrandTotal, grandTotalLabel, showGrandTotalsOnTop, grandTotalDimensions, subTotalLabel, showSubTotalsOnTop, configuredRows = rows) {
102787
104132
  const result = [];
102788
104133
  const concatStr = this.stringJoinChar;
102789
104134
  const map = new Map();
@@ -102829,13 +104174,77 @@
102829
104174
  node = item;
102830
104175
  });
102831
104176
  }
104177
+ const createIndicatorChildren = () => indicators?.map(indicator => {
104178
+ if (typeof indicator === 'string') {
104179
+ return {
104180
+ indicatorKey: indicator,
104181
+ value: indicator
104182
+ };
104183
+ }
104184
+ return {
104185
+ indicatorKey: indicator.indicatorKey,
104186
+ value: indicator.title
104187
+ };
104188
+ }) ?? [];
102832
104189
  arr.forEach(item => addList(item, false));
102833
104190
  if (isGrandTotal) {
102834
- addList([grandTotalLabel], isGrandTotal);
104191
+ const grandTotalDimensionIndexes = this.getGrandTotalDimensionIndexes(rows, grandTotalDimensions, configuredRows);
104192
+ if (!grandTotalDimensionIndexes.length) {
104193
+ addList([grandTotalLabel], isGrandTotal);
104194
+ }
104195
+ else {
104196
+ const grandTotalNode = {
104197
+ value: grandTotalLabel,
104198
+ dataValue: this.groupedGrandTotalKey,
104199
+ dimensionKey: rows[0],
104200
+ children: [],
104201
+ role: 'grand-total'
104202
+ };
104203
+ const grandTotalMap = new Map();
104204
+ this.getGroupedGrandTotalPaths(arr, rows, grandTotalDimensions, true, configuredRows).forEach(list => {
104205
+ let parent = grandTotalNode;
104206
+ const path = [this.groupedGrandTotalKey];
104207
+ grandTotalDimensionIndexes.forEach((dimensionIndex, index) => {
104208
+ const value = list[index];
104209
+ path.push(value);
104210
+ const flatKey = join(path, concatStr);
104211
+ let item = grandTotalMap.get(flatKey);
104212
+ if (!item) {
104213
+ item = {
104214
+ value,
104215
+ dataValue: value,
104216
+ dimensionKey: rows[dimensionIndex],
104217
+ children: index === grandTotalDimensionIndexes.length - 1 ? createIndicatorChildren() : []
104218
+ };
104219
+ grandTotalMap.set(flatKey, item);
104220
+ parent.children.push(item);
104221
+ }
104222
+ parent = item;
104223
+ });
104224
+ });
104225
+ const totalChild = {
104226
+ value: subTotalLabel,
104227
+ dataValue: this.groupedGrandTotalSubtotalKey,
104228
+ dimensionKey: rows[grandTotalDimensionIndexes[0]],
104229
+ children: createIndicatorChildren()
104230
+ };
104231
+ if (showSubTotalsOnTop) {
104232
+ grandTotalNode.children.unshift(totalChild);
104233
+ }
104234
+ else {
104235
+ grandTotalNode.children.push(totalChild);
104236
+ }
104237
+ if (showGrandTotalsOnTop) {
104238
+ result.unshift(grandTotalNode);
104239
+ }
104240
+ else {
104241
+ result.push(grandTotalNode);
104242
+ }
104243
+ }
102835
104244
  }
102836
104245
  return result;
102837
104246
  }
102838
- ArrToTree(arr, rows, indicators, subTotalFlags, isGrandTotal, grandTotalLabel, subTotalLabel, showGrandTotalsOnTop, showSubTotalsOnTop) {
104247
+ ArrToTree(arr, rows, indicators, subTotalFlags, isGrandTotal, grandTotalLabel, subTotalLabel, showGrandTotalsOnTop, showSubTotalsOnTop, grandTotalDimensions, isRow, configuredRows = rows) {
102839
104248
  let result = [];
102840
104249
  const concatStr = this.stringJoinChar;
102841
104250
  const map = new Map();
@@ -102918,24 +104327,69 @@
102918
104327
  });
102919
104328
  }
102920
104329
  if (isGrandTotal && arr?.length) {
104330
+ const grandTotalDimensionIndexes = this.getGrandTotalDimensionIndexes(rows, grandTotalDimensions, configuredRows);
104331
+ const createIndicatorChildren = () => indicators?.map(indicator => {
104332
+ if (typeof indicator === 'string') {
104333
+ return {
104334
+ indicatorKey: indicator,
104335
+ value: indicator
104336
+ };
104337
+ }
104338
+ return {
104339
+ indicatorKey: indicator.indicatorKey,
104340
+ value: indicator.title
104341
+ };
104342
+ }) ?? [];
102921
104343
  const node = {
102922
104344
  value: grandTotalLabel,
104345
+ dataValue: grandTotalDimensionIndexes.length ? this.groupedGrandTotalKey : undefined,
102923
104346
  dimensionKey: rows[0],
102924
- levelSpan: subTotalFlags.length,
102925
- children: indicators?.map(indicator => {
102926
- if (typeof indicator === 'string') {
102927
- return {
102928
- indicatorKey: indicator,
102929
- value: indicator
102930
- };
102931
- }
102932
- return {
102933
- indicatorKey: indicator.indicatorKey,
102934
- value: indicator.title
102935
- };
102936
- }) ?? [],
104347
+ levelSpan: Math.max(1, grandTotalDimensionIndexes[0] ?? subTotalFlags.length),
104348
+ children: [],
102937
104349
  role: 'grand-total'
102938
104350
  };
104351
+ if (grandTotalDimensionIndexes.length) {
104352
+ const grandTotalMap = new Map();
104353
+ this.getGroupedGrandTotalPaths(arr, rows, grandTotalDimensions, isRow, configuredRows).forEach(list => {
104354
+ let parent = node;
104355
+ const path = [this.groupedGrandTotalKey];
104356
+ grandTotalDimensionIndexes.forEach((dimensionIndex, index) => {
104357
+ const value = list[index];
104358
+ path.push(value);
104359
+ const flatKey = join(path, concatStr);
104360
+ let item = grandTotalMap.get(flatKey);
104361
+ if (!item) {
104362
+ const nextDimensionIndex = grandTotalDimensionIndexes[index + 1] ?? rows.length;
104363
+ item = {
104364
+ value,
104365
+ dataValue: value,
104366
+ dimensionKey: rows[dimensionIndex],
104367
+ levelSpan: nextDimensionIndex - dimensionIndex,
104368
+ children: index === grandTotalDimensionIndexes.length - 1 ? createIndicatorChildren() : []
104369
+ };
104370
+ grandTotalMap.set(flatKey, item);
104371
+ parent.children.push(item);
104372
+ }
104373
+ parent = item;
104374
+ });
104375
+ });
104376
+ const totalChild = {
104377
+ value: subTotalLabel,
104378
+ dataValue: this.groupedGrandTotalSubtotalKey,
104379
+ dimensionKey: rows[grandTotalDimensionIndexes[0]],
104380
+ levelSpan: rows.length - grandTotalDimensionIndexes[0],
104381
+ children: createIndicatorChildren()
104382
+ };
104383
+ if (showSubTotalsOnTop) {
104384
+ node.children.unshift(totalChild);
104385
+ }
104386
+ else {
104387
+ node.children.push(totalChild);
104388
+ }
104389
+ }
104390
+ else {
104391
+ node.children = createIndicatorChildren();
104392
+ }
102939
104393
  if (showGrandTotalsOnTop) {
102940
104394
  result.unshift(node);
102941
104395
  }
@@ -102989,7 +104443,7 @@
102989
104443
  });
102990
104444
  }
102991
104445
  if (rowKey.length < this.rows.length && this.rowHierarchyType === 'grid-tree') {
102992
- if (rowKey[0] === this.rowGrandTotalLabel) ;
104446
+ if (rowKey[0] === this.rowGrandTotalLabel || rowKey[0] === this.groupedGrandTotalKey) ;
102993
104447
  else if (((this.totals?.row?.subTotalsDimensions &&
102994
104448
  this.totals?.row?.subTotalsDimensions?.length >= 1 &&
102995
104449
  this.totals.row.subTotalsDimensions.find((dimension) => dimension === rowDimensionKey)) ||
@@ -103012,7 +104466,7 @@
103012
104466
  });
103013
104467
  }
103014
104468
  if (colKey.length < this.columns.length && this.columnHierarchyType === 'grid-tree') {
103015
- if (colKey[0] === this.colGrandTotalLabel) ;
104469
+ if (colKey[0] === this.colGrandTotalLabel || colKey[0] === this.groupedGrandTotalKey) ;
103016
104470
  else if (((this.totals?.column?.subTotalsDimensions &&
103017
104471
  this.totals?.column?.subTotalsDimensions?.length >= 1 &&
103018
104472
  this.totals.column.subTotalsDimensions.find((dimension) => dimension === colDimensionKey)) ||
@@ -103073,13 +104527,13 @@
103073
104527
  this.totals.column.showSubTotals !== false)))) {
103074
104528
  return;
103075
104529
  }
103076
- const flatRowKey = Array.isArray(rowKey) ? rowKey.join(this.stringJoinChar) : rowKey;
103077
- const flatColKey = Array.isArray(colKey) ? colKey.join(this.stringJoinChar) : colKey;
104530
+ const flatRowKey = Array.isArray(rowKey) ? join(rowKey, this.stringJoinChar) : rowKey;
104531
+ const flatColKey = Array.isArray(colKey) ? join(colKey, this.stringJoinChar) : colKey;
103078
104532
  const indicatorIndex = this.indicatorKeysIncludeCalculatedFieldDependIndicatorKeys.indexOf(indicator);
103079
104533
  const aggregatorsToReset = new Set();
103080
104534
  const subTotalAggregators = new Set();
103081
- const rowKeyParts = flatRowKey.split(this.stringJoinChar);
103082
- const colKeyParts = flatColKey.split(this.stringJoinChar);
104535
+ const rowKeyParts = Array.isArray(rowKey) ? rowKey.slice() : rowKey.split(this.stringJoinChar);
104536
+ const colKeyParts = Array.isArray(colKey) ? colKey.slice() : colKey.split(this.stringJoinChar);
103083
104537
  const addAggregatorToResetSet = (agg, rowKey, colKey) => {
103084
104538
  if (agg && !(rowKey === flatRowKey && colKey === flatColKey)) {
103085
104539
  aggregatorsToReset.add(agg);
@@ -103088,6 +104542,8 @@
103088
104542
  }
103089
104543
  }
103090
104544
  };
104545
+ const rowAggregateKeys = [];
104546
+ const colAggregateKeys = [];
103091
104547
  if (this.totals?.row?.subTotalsDimensions && this.totals.row.showSubTotals !== false) {
103092
104548
  for (let i = 0; i < this.totals.row.subTotalsDimensions.length; i++) {
103093
104549
  const dimension = this.totals.row.subTotalsDimensions[i];
@@ -103098,80 +104554,59 @@
103098
104554
  rowSubTotalKeyParts.push(this.rowSubTotalLabel);
103099
104555
  }
103100
104556
  const flatRowSubTotalKey = rowSubTotalKeyParts.join(this.stringJoinChar);
103101
- if (this.tree[flatRowSubTotalKey]?.[flatColKey]?.[indicatorIndex]) {
103102
- addAggregatorToResetSet(this.tree[flatRowSubTotalKey][flatColKey][indicatorIndex], flatRowSubTotalKey, flatColKey);
103103
- }
103104
- if (this.totals?.column?.subTotalsDimensions && this.totals.column.showSubTotals !== false) {
103105
- for (let j = 0; j < this.totals.column.subTotalsDimensions.length; j++) {
103106
- const colDimension = this.totals.column.subTotalsDimensions[j];
103107
- const colDimensionIndex = this.columns.indexOf(colDimension);
103108
- if (colDimensionIndex >= 0 && colDimensionIndex < colKeyParts.length) {
103109
- const colSubTotalKeyParts = colKeyParts.slice(0, colDimensionIndex + 1);
103110
- colSubTotalKeyParts.push(this.colSubTotalLabel);
103111
- const flatColSubTotalKey = colSubTotalKeyParts.join(this.stringJoinChar);
103112
- if (this.tree[flatRowSubTotalKey]?.[flatColSubTotalKey]?.[indicatorIndex]) {
103113
- addAggregatorToResetSet(this.tree[flatRowSubTotalKey][flatColSubTotalKey][indicatorIndex], flatRowSubTotalKey, flatColSubTotalKey);
103114
- }
103115
- }
103116
- }
103117
- }
103118
- if (this.totals?.column?.showGrandTotals) {
103119
- if (this.tree[flatRowSubTotalKey]?.[this.colGrandTotalLabel]?.[indicatorIndex]) {
103120
- addAggregatorToResetSet(this.tree[flatRowSubTotalKey][this.colGrandTotalLabel][indicatorIndex], flatRowSubTotalKey, this.colGrandTotalLabel);
103121
- }
104557
+ if (rowAggregateKeys.indexOf(flatRowSubTotalKey) === -1) {
104558
+ rowAggregateKeys.push(flatRowSubTotalKey);
103122
104559
  }
103123
104560
  }
103124
104561
  }
103125
104562
  }
103126
104563
  if (this.totals?.row?.showGrandTotals) {
103127
- if (this.tree[this.rowGrandTotalLabel]?.[flatColKey]?.[indicatorIndex]) {
103128
- addAggregatorToResetSet(this.tree[this.rowGrandTotalLabel][flatColKey][indicatorIndex], this.rowGrandTotalLabel, flatColKey);
103129
- if (this.totals?.column?.subTotalsDimensions && this.totals.column.showSubTotals !== false) {
103130
- for (let j = 0; j < this.totals.column.subTotalsDimensions.length; j++) {
103131
- const colDimension = this.totals.column.subTotalsDimensions[j];
103132
- const colDimensionIndex = this.columns.indexOf(colDimension);
103133
- if (colDimensionIndex >= 0 && colDimensionIndex < colKeyParts.length) {
103134
- const colSubTotalKeyParts = colKeyParts.slice(0, colDimensionIndex + 1);
103135
- colSubTotalKeyParts.push(this.colSubTotalLabel);
103136
- const flatColSubTotalKey = colSubTotalKeyParts.join(this.stringJoinChar);
103137
- if (this.tree[this.rowGrandTotalLabel]?.[flatColSubTotalKey]?.[indicatorIndex]) {
103138
- addAggregatorToResetSet(this.tree[this.rowGrandTotalLabel][flatColSubTotalKey][indicatorIndex], this.rowGrandTotalLabel, flatColSubTotalKey);
103139
- }
103140
- }
103141
- }
103142
- }
103143
- if (this.totals?.column?.showGrandTotals) {
103144
- if (this.tree[this.rowGrandTotalLabel]?.[this.colGrandTotalLabel]?.[indicatorIndex]) {
103145
- addAggregatorToResetSet(this.tree[this.rowGrandTotalLabel][this.colGrandTotalLabel][indicatorIndex], this.rowGrandTotalLabel, this.colGrandTotalLabel);
103146
- }
104564
+ const rowGrandTotalKeys = this.getGrandTotalKeys(rowKeyParts, this.rows.filter((_, index) => this.rowsHasValue[index]), this.totals.row.grandTotalDimensions, this.rowGrandTotalLabel, this.rows);
104565
+ for (const rowGrandTotalKey of rowGrandTotalKeys) {
104566
+ if (rowAggregateKeys.indexOf(rowGrandTotalKey) === -1) {
104567
+ rowAggregateKeys.push(rowGrandTotalKey);
103147
104568
  }
103148
104569
  }
103149
- if (this.totals?.column?.subTotalsDimensions && this.totals.column.showSubTotals !== false) {
103150
- for (let j = 0; j < this.totals.column.subTotalsDimensions.length; j++) {
103151
- const colDimension = this.totals.column.subTotalsDimensions[j];
103152
- const colDimensionIndex = this.columns.indexOf(colDimension);
103153
- if (colDimensionIndex >= 0 && colDimensionIndex < colKeyParts.length) {
103154
- const colSubTotalKeyParts = colKeyParts.slice(0, colDimensionIndex + 1);
103155
- colSubTotalKeyParts.push(this.colSubTotalLabel);
103156
- const flatColSubTotalKey = colSubTotalKeyParts.join(this.stringJoinChar);
103157
- if (this.tree[flatRowKey]?.[flatColSubTotalKey]?.[indicatorIndex]) {
103158
- addAggregatorToResetSet(this.tree[flatRowKey][flatColSubTotalKey][indicatorIndex], flatRowKey, flatColSubTotalKey);
103159
- }
104570
+ }
104571
+ if (this.totals?.column?.subTotalsDimensions && this.totals.column.showSubTotals !== false) {
104572
+ for (let j = 0; j < this.totals.column.subTotalsDimensions.length; j++) {
104573
+ const colDimension = this.totals.column.subTotalsDimensions[j];
104574
+ const colDimensionIndex = this.columns.indexOf(colDimension);
104575
+ if (colDimensionIndex >= 0 && colDimensionIndex < colKeyParts.length) {
104576
+ const colSubTotalKeyParts = colKeyParts.slice(0, colDimensionIndex + 1);
104577
+ colSubTotalKeyParts.push(this.colSubTotalLabel);
104578
+ const flatColSubTotalKey = colSubTotalKeyParts.join(this.stringJoinChar);
104579
+ if (colAggregateKeys.indexOf(flatColSubTotalKey) === -1) {
104580
+ colAggregateKeys.push(flatColSubTotalKey);
103160
104581
  }
103161
104582
  }
103162
104583
  }
103163
- if (this.totals?.column?.showGrandTotals) {
103164
- if (this.tree[flatRowKey]?.[this.colGrandTotalLabel]?.[indicatorIndex]) {
103165
- addAggregatorToResetSet(this.tree[flatRowKey][this.colGrandTotalLabel][indicatorIndex], flatRowKey, this.colGrandTotalLabel);
104584
+ }
104585
+ if (this.totals?.column?.showGrandTotals) {
104586
+ const colGrandTotalKeys = this.getGrandTotalKeys(colKeyParts, this.columns.filter((_, index) => this.columnsHasValue[index]), this.totals.column.grandTotalDimensions, this.colGrandTotalLabel, this.columns);
104587
+ for (const colGrandTotalKey of colGrandTotalKeys) {
104588
+ if (colAggregateKeys.indexOf(colGrandTotalKey) === -1) {
104589
+ colAggregateKeys.push(colGrandTotalKey);
103166
104590
  }
103167
104591
  }
103168
- aggregatorsToReset.forEach(agg => {
103169
- if (newCellAggregator && subTotalAggregators.has(agg)) {
103170
- agg.push(newCellAggregator);
103171
- }
103172
- agg.recalculate();
103173
- });
103174
104592
  }
104593
+ rowAggregateKeys.forEach(rowAggregateKey => {
104594
+ addAggregatorToResetSet(this.tree[rowAggregateKey]?.[flatColKey]?.[indicatorIndex], rowAggregateKey, flatColKey);
104595
+ });
104596
+ colAggregateKeys.forEach(colAggregateKey => {
104597
+ addAggregatorToResetSet(this.tree[flatRowKey]?.[colAggregateKey]?.[indicatorIndex], flatRowKey, colAggregateKey);
104598
+ });
104599
+ rowAggregateKeys.forEach(rowAggregateKey => {
104600
+ colAggregateKeys.forEach(colAggregateKey => {
104601
+ addAggregatorToResetSet(this.tree[rowAggregateKey]?.[colAggregateKey]?.[indicatorIndex], rowAggregateKey, colAggregateKey);
104602
+ });
104603
+ });
104604
+ aggregatorsToReset.forEach(agg => {
104605
+ if (newCellAggregator && subTotalAggregators.has(agg)) {
104606
+ agg.push(newCellAggregator);
104607
+ }
104608
+ agg.recalculate();
104609
+ });
103175
104610
  }
103176
104611
  changeRecordFieldValue(fieldName, oldValue, value) {
103177
104612
  let isIndicatorName = false;
@@ -103784,7 +105219,7 @@
103784
105219
  index
103785
105220
  };
103786
105221
  }
103787
- return colPath.indicatorKey ?? colPath.value;
105222
+ return colPath.indicatorKey ?? colPath.dataValue ?? colPath.value;
103788
105223
  });
103789
105224
  const rowKeys = cellDimensionPath.rowHeaderPaths
103790
105225
  ?.filter((path) => {
@@ -103797,7 +105232,7 @@
103797
105232
  index
103798
105233
  };
103799
105234
  }
103800
- return rowPath.indicatorKey ?? rowPath.value;
105235
+ return rowPath.indicatorKey ?? rowPath.dataValue ?? rowPath.value;
103801
105236
  });
103802
105237
  const aggregator = this.dataset.getAggregator(rowKeys, colKeys, this.internalProps.layoutMap.getIndicatorKey(col, row), true, indicatorPosition);
103803
105238
  if (aggregator.records && aggregator.records.length >= 1) {
@@ -103808,10 +105243,10 @@
103808
105243
  else if (this.flatDataToObjects) {
103809
105244
  const cellDimensionPath = this.internalProps.layoutMap.getCellHeaderPaths(col, row);
103810
105245
  const colKeys = cellDimensionPath.colHeaderPaths.map((colPath) => {
103811
- return colPath.indicatorKey ?? colPath.value;
105246
+ return colPath.indicatorKey ?? colPath.dataValue ?? colPath.value;
103812
105247
  });
103813
105248
  const rowKeys = cellDimensionPath.rowHeaderPaths.map((rowPath) => {
103814
- return rowPath.indicatorKey ?? rowPath.value;
105249
+ return rowPath.indicatorKey ?? rowPath.dataValue ?? rowPath.value;
103815
105250
  });
103816
105251
  const treeNode = this.flatDataToObjects.getTreeNode(rowKeys, colKeys, this.internalProps.layoutMap.getBody(col, row).indicatorKey, false);
103817
105252
  if (treeNode?.record) {
@@ -103863,7 +105298,7 @@
103863
105298
  index
103864
105299
  };
103865
105300
  }
103866
- return colPath.indicatorKey ?? colPath.value;
105301
+ return colPath.indicatorKey ?? colPath.dataValue ?? colPath.value;
103867
105302
  });
103868
105303
  const rowKeys = cellDimensionPath.rowHeaderPaths
103869
105304
  ?.filter((path) => {
@@ -103876,7 +105311,7 @@
103876
105311
  index
103877
105312
  };
103878
105313
  }
103879
- return rowPath.indicatorKey ?? rowPath.value;
105314
+ return rowPath.indicatorKey ?? rowPath.dataValue ?? rowPath.value;
103880
105315
  });
103881
105316
  const aggregator = this.dataset.getAggregator(rowKeys, colKeys, this.internalProps.layoutMap.getIndicatorKey(col, row), true, indicatorPosition);
103882
105317
  const { fieldFormat } = this.internalProps.layoutMap.getBody(col, row);
@@ -103889,10 +105324,10 @@
103889
105324
  else if (this.flatDataToObjects) {
103890
105325
  const cellDimensionPath = this.internalProps.layoutMap.getCellHeaderPaths(col, row);
103891
105326
  const colKeys = cellDimensionPath.colHeaderPaths.map((colPath) => {
103892
- return colPath.indicatorKey ?? colPath.value;
105327
+ return colPath.indicatorKey ?? colPath.dataValue ?? colPath.value;
103893
105328
  });
103894
105329
  const rowKeys = cellDimensionPath.rowHeaderPaths.map((rowPath) => {
103895
- return rowPath.indicatorKey ?? rowPath.value;
105330
+ return rowPath.indicatorKey ?? rowPath.dataValue ?? rowPath.value;
103896
105331
  });
103897
105332
  const valueNode = this.flatDataToObjects.getTreeNode(rowKeys, colKeys, this.internalProps.layoutMap.getBody(col, row).indicatorKey);
103898
105333
  const { fieldFormat } = this.internalProps.layoutMap.getBody(col, row);
@@ -103927,7 +105362,7 @@
103927
105362
  index
103928
105363
  };
103929
105364
  }
103930
- return colPath.indicatorKey ?? colPath.value;
105365
+ return colPath.indicatorKey ?? colPath.dataValue ?? colPath.value;
103931
105366
  });
103932
105367
  const rowKeys = cellDimensionPath.rowHeaderPaths
103933
105368
  ?.filter((path) => {
@@ -103940,7 +105375,7 @@
103940
105375
  index
103941
105376
  };
103942
105377
  }
103943
- return rowPath.indicatorKey ?? rowPath.value;
105378
+ return rowPath.indicatorKey ?? rowPath.dataValue ?? rowPath.value;
103944
105379
  });
103945
105380
  const aggregator = this.dataset.getAggregator(rowKeys, colKeys, this.internalProps.layoutMap.getIndicatorKey(col, row), true, indicatorPosition);
103946
105381
  return aggregator.value ? aggregator.value() : undefined;
@@ -103948,10 +105383,10 @@
103948
105383
  else if (this.flatDataToObjects) {
103949
105384
  const cellDimensionPath = this.internalProps.layoutMap.getCellHeaderPaths(col, row);
103950
105385
  const colKeys = cellDimensionPath.colHeaderPaths.map((colPath) => {
103951
- return colPath.indicatorKey ?? colPath.value;
105386
+ return colPath.indicatorKey ?? colPath.dataValue ?? colPath.value;
103952
105387
  });
103953
105388
  const rowKeys = cellDimensionPath.rowHeaderPaths.map((rowPath) => {
103954
- return rowPath.indicatorKey ?? rowPath.value;
105389
+ return rowPath.indicatorKey ?? rowPath.dataValue ?? rowPath.value;
103955
105390
  });
103956
105391
  const treeNode = this.flatDataToObjects.getTreeNode(rowKeys, colKeys, this.internalProps.layoutMap.getBody(col, row).indicatorKey);
103957
105392
  return treeNode?.value;
@@ -103983,7 +105418,7 @@
103983
105418
  index
103984
105419
  };
103985
105420
  }
103986
- return colPath.indicatorKey ?? colPath.value;
105421
+ return colPath.indicatorKey ?? colPath.dataValue ?? colPath.value;
103987
105422
  });
103988
105423
  const rowKeys = cellDimensionPath.rowHeaderPaths
103989
105424
  ?.filter((path) => {
@@ -103996,7 +105431,7 @@
103996
105431
  index
103997
105432
  };
103998
105433
  }
103999
- return rowPath.indicatorKey ?? rowPath.value;
105434
+ return rowPath.indicatorKey ?? rowPath.dataValue ?? rowPath.value;
104000
105435
  });
104001
105436
  const aggregator = this.dataset.getAggregator(rowKeys, colKeys, this.internalProps.layoutMap.getIndicatorKey(col, row), false, indicatorPosition);
104002
105437
  return aggregator.value ? aggregator.value() : undefined;
@@ -104004,10 +105439,10 @@
104004
105439
  else if (this.flatDataToObjects) {
104005
105440
  const cellDimensionPath = this.internalProps.layoutMap.getCellHeaderPaths(col, row);
104006
105441
  const colKeys = cellDimensionPath.colHeaderPaths.map((colPath) => {
104007
- return colPath.indicatorKey ?? colPath.value;
105442
+ return colPath.indicatorKey ?? colPath.dataValue ?? colPath.value;
104008
105443
  });
104009
105444
  const rowKeys = cellDimensionPath.rowHeaderPaths.map((rowPath) => {
104010
- return rowPath.indicatorKey ?? rowPath.value;
105445
+ return rowPath.indicatorKey ?? rowPath.dataValue ?? rowPath.value;
104011
105446
  });
104012
105447
  const treeNode = this.flatDataToObjects.getTreeNode(rowKeys, colKeys, this.internalProps.layoutMap.getBody(col, row).indicatorKey, false);
104013
105448
  return treeNode?.value;
@@ -104038,7 +105473,7 @@
104038
105473
  index
104039
105474
  };
104040
105475
  }
104041
- return colPath.indicatorKey ?? colPath.value;
105476
+ return colPath.indicatorKey ?? colPath.dataValue ?? colPath.value;
104042
105477
  });
104043
105478
  const rowKeys = cellDimensionPath.rowHeaderPaths
104044
105479
  ?.filter((path) => {
@@ -104051,7 +105486,7 @@
104051
105486
  index
104052
105487
  };
104053
105488
  }
104054
- return rowPath.indicatorKey ?? rowPath.value;
105489
+ return rowPath.indicatorKey ?? rowPath.dataValue ?? rowPath.value;
104055
105490
  });
104056
105491
  const aggregator = this.dataset.getAggregator(rowKeys, colKeys, this.internalProps.layoutMap.getIndicatorKey(col, row), true, indicatorPosition);
104057
105492
  return aggregator.records;
@@ -104059,10 +105494,10 @@
104059
105494
  else if (this.flatDataToObjects) {
104060
105495
  const cellDimensionPath = this.internalProps.layoutMap.getCellHeaderPaths(col, row);
104061
105496
  const colKeys = cellDimensionPath.colHeaderPaths.map((colPath) => {
104062
- return colPath.indicatorKey ?? colPath.value;
105497
+ return colPath.indicatorKey ?? colPath.dataValue ?? colPath.value;
104063
105498
  });
104064
105499
  const rowKeys = cellDimensionPath.rowHeaderPaths.map((rowPath) => {
104065
- return rowPath.indicatorKey ?? rowPath.value;
105500
+ return rowPath.indicatorKey ?? rowPath.dataValue ?? rowPath.value;
104066
105501
  });
104067
105502
  const treeNode = this.flatDataToObjects.getTreeNode(rowKeys, colKeys, this.internalProps.layoutMap.getBody(col, row).indicatorKey);
104068
105503
  return treeNode?.record;
@@ -104093,7 +105528,7 @@
104093
105528
  index
104094
105529
  };
104095
105530
  }
104096
- return colPath.indicatorKey ?? colPath.value;
105531
+ return colPath.indicatorKey ?? colPath.dataValue ?? colPath.value;
104097
105532
  });
104098
105533
  const rowKeys = cellDimensionPath.rowHeaderPaths
104099
105534
  ?.filter((path) => {
@@ -104106,7 +105541,7 @@
104106
105541
  index
104107
105542
  };
104108
105543
  }
104109
- return rowPath.indicatorKey ?? rowPath.value;
105544
+ return rowPath.indicatorKey ?? rowPath.dataValue ?? rowPath.value;
104110
105545
  });
104111
105546
  const aggregator = this.dataset.getAggregator(rowKeys, colKeys, this.internalProps.layoutMap.getIndicatorKey(col, row), false, indicatorPosition);
104112
105547
  return aggregator.records;
@@ -104114,10 +105549,10 @@
104114
105549
  else if (this.flatDataToObjects) {
104115
105550
  const cellDimensionPath = this.internalProps.layoutMap.getCellHeaderPaths(col, row);
104116
105551
  const colKeys = cellDimensionPath.colHeaderPaths.map((colPath) => {
104117
- return colPath.indicatorKey ?? colPath.value;
105552
+ return colPath.indicatorKey ?? colPath.dataValue ?? colPath.value;
104118
105553
  });
104119
105554
  const rowKeys = cellDimensionPath.rowHeaderPaths.map((rowPath) => {
104120
- return rowPath.indicatorKey ?? rowPath.value;
105555
+ return rowPath.indicatorKey ?? rowPath.dataValue ?? rowPath.value;
104121
105556
  });
104122
105557
  const treeNode = this.flatDataToObjects.getTreeNode(rowKeys, colKeys, this.internalProps.layoutMap.getBody(col, row).indicatorKey, false);
104123
105558
  return treeNode?.record;
@@ -104829,7 +106264,11 @@
104829
106264
  this.scenegraph.updateNextFrame();
104830
106265
  }
104831
106266
  }
104832
- changeCellValues(startCol, startRow, values, workOnEditableCell = false) {
106267
+ changeCellValues(startCol, startRow, values, workOnEditableCell = false, triggerEvent = true, _noTriggerChangeCellValuesEvent, shouldCancel) {
106268
+ const changedCellResults = [];
106269
+ if (shouldCancel?.()) {
106270
+ return changedCellResults;
106271
+ }
104833
106272
  let pasteColEnd = startCol;
104834
106273
  let pasteRowEnd = startRow;
104835
106274
  const beforeChangeValues = [];
@@ -104857,6 +106296,7 @@
104857
106296
  if (startRow + i > this.rowCount - 1) {
104858
106297
  break;
104859
106298
  }
106299
+ changedCellResults[i] = [];
104860
106300
  pasteRowEnd = startRow + i;
104861
106301
  const rowValues = values[i];
104862
106302
  let thisRowPasteColEnd = startCol;
@@ -104871,12 +106311,13 @@
104871
106311
  let newValue = value;
104872
106312
  const oldValue = oldValues[i][j];
104873
106313
  const rawValue = beforeChangeValues[i][j];
104874
- if (typeof rawValue === 'number' && isAllDigits(value)) {
106314
+ if (typeof rawValue === 'number' && typeof value === 'string' && isAllDigits(value)) {
104875
106315
  newValue = parseFloat(value);
104876
106316
  }
106317
+ changedCellResults[i][j] = true;
104877
106318
  this._changeCellValueToDataSet(startCol + j, startRow + i, oldValue, newValue);
104878
106319
  const changedValue = this.getCellOriginValue(startCol + j, startRow + i);
104879
- if (changedValue !== oldValue) {
106320
+ if (changedValue !== oldValue && triggerEvent) {
104880
106321
  this.fireListeners(TABLE_EVENT_TYPE.CHANGE_CELL_VALUE, {
104881
106322
  col: startCol + j,
104882
106323
  row: startRow + i,
@@ -104886,6 +106327,9 @@
104886
106327
  });
104887
106328
  }
104888
106329
  }
106330
+ else {
106331
+ changedCellResults[i][j] = false;
106332
+ }
104889
106333
  }
104890
106334
  pasteColEnd = Math.max(pasteColEnd, thisRowPasteColEnd);
104891
106335
  }
@@ -104938,6 +106382,7 @@
104938
106382
  this.scenegraph.updateRowsHeight(rows, deltaYs);
104939
106383
  }
104940
106384
  this.scenegraph.updateNextFrame();
106385
+ return changedCellResults;
104941
106386
  }
104942
106387
  _changeCellValueToDataSet(col, row, oldValue, newValue) {
104943
106388
  if (this.internalProps.recordsIsTwoDimensionalArray) {
@@ -104972,7 +106417,7 @@
104972
106417
  index
104973
106418
  };
104974
106419
  }
104975
- return colPath.indicatorKey ?? colPath.value;
106420
+ return colPath.indicatorKey ?? colPath.dataValue ?? colPath.value;
104976
106421
  });
104977
106422
  const rowKeys = cellDimensionPath.rowHeaderPaths
104978
106423
  ?.filter((path) => {
@@ -104985,7 +106430,7 @@
104985
106430
  index
104986
106431
  };
104987
106432
  }
104988
- return rowPath.indicatorKey ?? rowPath.value;
106433
+ return rowPath.indicatorKey ?? rowPath.dataValue ?? rowPath.value;
104989
106434
  });
104990
106435
  this.dataset.changeTreeNodeValue(rowKeys, colKeys, this.internalProps.layoutMap.getIndicatorKey(col, row), newValue, indicatorPosition);
104991
106436
  }
@@ -105003,10 +106448,10 @@
105003
106448
  }
105004
106449
  else {
105005
106450
  const colKeys = cellDimensionPath.colHeaderPaths.map((colPath) => {
105006
- return colPath.indicatorKey ?? colPath.value;
106451
+ return colPath.indicatorKey ?? colPath.dataValue ?? colPath.value;
105007
106452
  });
105008
106453
  const rowKeys = cellDimensionPath.rowHeaderPaths.map((rowPath) => {
105009
- return rowPath.indicatorKey ?? rowPath.value;
106454
+ return rowPath.indicatorKey ?? rowPath.dataValue ?? rowPath.value;
105010
106455
  });
105011
106456
  this.flatDataToObjects.changeTreeNodeValue(rowKeys, colKeys, this.internalProps.layoutMap.getBody(col, row).indicatorKey, newValue);
105012
106457
  }
@@ -105255,7 +106700,7 @@
105255
106700
  this.setCustomStateNameToSpec();
105256
106701
  this.internalProps.columnResizeType = options.resize?.columnResizeType ?? options.columnResizeType ?? 'column';
105257
106702
  this.internalProps.rowResizeType = options.resize?.rowResizeType ?? options.rowResizeType ?? 'row';
105258
- this.internalProps.dataConfig = { isPivotChart: true };
106703
+ this.internalProps.dataConfig = { ...cloneDeep(options.dataConfig), isPivotChart: true };
105259
106704
  this.internalProps.columnWidthConfig = options.columnWidthConfig;
105260
106705
  this.internalProps.columnWidthConfigForRowHeader = options.columnWidthConfigForRowHeader;
105261
106706
  this._axes = isArray$5(options.axes) ? options.axes : [];
@@ -105425,7 +106870,7 @@
105425
106870
  this._selectedDataItemsInChart = [];
105426
106871
  internalProps.columnResizeType = options.resize?.columnResizeType ?? options.columnResizeType ?? 'column';
105427
106872
  internalProps.rowResizeType = options.resize?.rowResizeType ?? options.rowResizeType ?? 'row';
105428
- internalProps.dataConfig = { isPivotChart: true };
106873
+ internalProps.dataConfig = { ...cloneDeep(options.dataConfig), isPivotChart: true };
105429
106874
  this.internalProps.columnWidthConfig = options.columnWidthConfig;
105430
106875
  this.internalProps.columnWidthConfigForRowHeader = options.columnWidthConfigForRowHeader;
105431
106876
  this._axes = isArray$5(options.axes) ? options.axes : [];
@@ -105640,7 +107085,7 @@
105640
107085
  index
105641
107086
  };
105642
107087
  }
105643
- return colPath.indicatorKey ?? colPath.value;
107088
+ return colPath.indicatorKey ?? colPath.dataValue ?? colPath.value;
105644
107089
  });
105645
107090
  const rowKeys = cellDimensionPath.rowHeaderPaths.map((rowPath, index) => {
105646
107091
  if (rowPath.indicatorKey) {
@@ -105649,7 +107094,7 @@
105649
107094
  index
105650
107095
  };
105651
107096
  }
105652
- return rowPath.indicatorKey ?? rowPath.value;
107097
+ return rowPath.indicatorKey ?? rowPath.dataValue ?? rowPath.value;
105653
107098
  });
105654
107099
  const aggregator = this.dataset.getAggregator(rowKeys, colKeys, this.internalProps.layoutMap.getIndicatorKey(col, row), true, indicatorPosition);
105655
107100
  return aggregator.value ? aggregator.value() : undefined;
@@ -105692,7 +107137,7 @@
105692
107137
  index
105693
107138
  };
105694
107139
  }
105695
- return colPath.indicatorKey ?? colPath.value;
107140
+ return colPath.indicatorKey ?? colPath.dataValue ?? colPath.value;
105696
107141
  });
105697
107142
  const rowKeys = cellDimensionPath.rowHeaderPaths.map((rowPath, index) => {
105698
107143
  if (rowPath.indicatorKey) {
@@ -105701,7 +107146,7 @@
105701
107146
  index
105702
107147
  };
105703
107148
  }
105704
- return rowPath.indicatorKey ?? rowPath.value;
107149
+ return rowPath.indicatorKey ?? rowPath.dataValue ?? rowPath.value;
105705
107150
  });
105706
107151
  const aggregator = this.dataset.getAggregator(rowKeys, colKeys, this.internalProps.layoutMap.getIndicatorKey(col, row), true, indicatorPosition);
105707
107152
  return aggregator.value ? aggregator.value() : undefined;
@@ -105729,7 +107174,7 @@
105729
107174
  index
105730
107175
  };
105731
107176
  }
105732
- return colPath.indicatorKey ?? colPath.value;
107177
+ return colPath.indicatorKey ?? colPath.dataValue ?? colPath.value;
105733
107178
  });
105734
107179
  const rowKeys = cellDimensionPath.rowHeaderPaths.map((rowPath, index) => {
105735
107180
  if (rowPath.indicatorKey) {
@@ -105738,7 +107183,7 @@
105738
107183
  index
105739
107184
  };
105740
107185
  }
105741
- return rowPath.indicatorKey ?? rowPath.value;
107186
+ return rowPath.indicatorKey ?? rowPath.dataValue ?? rowPath.value;
105742
107187
  });
105743
107188
  const aggregator = this.dataset.getAggregator(rowKeys, colKeys, this.internalProps.layoutMap.getIndicatorKey(col, row), true, indicatorPosition);
105744
107189
  return aggregator.records;
@@ -106725,7 +108170,7 @@
106725
108170
 
106726
108171
  function createDataset(options) {
106727
108172
  const layoutNodeId = { seqId: 0 };
106728
- const dataConfig = { isPivotChart: true };
108173
+ const dataConfig = { ...options.dataConfig, isPivotChart: true };
106729
108174
  let columnDimensionTree;
106730
108175
  let rowDimensionTree;
106731
108176
  let columnTree;
@@ -106742,7 +108187,7 @@
106742
108187
  }
106743
108188
  rowDimensionTree = new DimensionTree(options.rowTree ?? [], layoutNodeId);
106744
108189
  }
106745
- const rowKeys = rowDimensionTree.dimensionKeys?.count
108190
+ const rowKeys = rowDimensionTree?.dimensionKeys?.count
106746
108191
  ? rowDimensionTree.dimensionKeys.valueArr()
106747
108192
  : options.rows?.reduce((keys, rowObj) => {
106748
108193
  if (typeof rowObj === 'string') {
@@ -106753,7 +108198,7 @@
106753
108198
  }
106754
108199
  return keys;
106755
108200
  }, []) ?? [];
106756
- const columnKeys = columnDimensionTree.dimensionKeys?.count
108201
+ const columnKeys = columnDimensionTree?.dimensionKeys?.count
106757
108202
  ? columnDimensionTree.dimensionKeys.valueArr()
106758
108203
  : options.columns?.reduce((keys, columnObj) => {
106759
108204
  if (typeof columnObj === 'string') {
@@ -106983,10 +108428,10 @@
106983
108428
  }
106984
108429
  const cellDimensionPath = layoutMap.getCellHeaderPaths(col, row);
106985
108430
  const colKeys = cellDimensionPath.colHeaderPaths.map((colPath) => {
106986
- return colPath.indicatorKey ?? colPath.value;
108431
+ return colPath.indicatorKey ?? colPath.dataValue ?? colPath.value;
106987
108432
  });
106988
108433
  const rowKeys = cellDimensionPath.rowHeaderPaths.map((rowPath) => {
106989
- return rowPath.indicatorKey ?? rowPath.value;
108434
+ return rowPath.indicatorKey ?? rowPath.dataValue ?? rowPath.value;
106990
108435
  });
106991
108436
  const aggregator = dataset.getAggregator(!layoutMap.indicatorsAsCol ? rowKeys.slice(0, -1) : rowKeys, layoutMap.indicatorsAsCol ? colKeys.slice(0, -1) : colKeys, layoutMap.getIndicatorKey(col, row));
106992
108437
  const result = compareData(aggregator.value ? aggregator.value() : undefined, data, col, row, layoutMap, compareFunc);
@@ -107022,7 +108467,7 @@
107022
108467
  }
107023
108468
 
107024
108469
  registerForVrender();
107025
- const version = "1.26.7";
108470
+ const version = "1.26.8";
107026
108471
  function getIcons() {
107027
108472
  return get$4();
107028
108473
  }