@visactor/vtable 1.19.9-alpha.3 → 1.20.0-alpha.0

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 (212) hide show
  1. package/cjs/ListTable.d.ts +8 -2
  2. package/cjs/ListTable.js +58 -11
  3. package/cjs/ListTable.js.map +1 -1
  4. package/cjs/PivotChart.d.ts +4 -1
  5. package/cjs/PivotChart.js +8 -3
  6. package/cjs/PivotChart.js.map +1 -1
  7. package/cjs/PivotTable.d.ts +4 -1
  8. package/cjs/PivotTable.js +8 -3
  9. package/cjs/PivotTable.js.map +1 -1
  10. package/cjs/core/BaseTable.d.ts +14 -1
  11. package/cjs/core/BaseTable.js +121 -28
  12. package/cjs/core/BaseTable.js.map +1 -1
  13. package/cjs/core/TABLE_EVENT_TYPE.d.ts +4 -0
  14. package/cjs/core/TABLE_EVENT_TYPE.js +5 -1
  15. package/cjs/core/TABLE_EVENT_TYPE.js.map +1 -1
  16. package/cjs/core/animation.js.map +1 -1
  17. package/cjs/core/group-helper.d.ts +3 -1
  18. package/cjs/core/group-helper.js +8 -4
  19. package/cjs/core/group-helper.js.map +1 -1
  20. package/cjs/core/utils/get-cell-position.js +2 -2
  21. package/cjs/core/utils/get-cell-position.js.map +1 -1
  22. package/cjs/data/DataSource.d.ts +1 -0
  23. package/cjs/data/DataSource.js +21 -12
  24. package/cjs/data/DataSource.js.map +1 -1
  25. package/cjs/edit/edit-manager.js +5 -4
  26. package/cjs/edit/edit-manager.js.map +1 -1
  27. package/cjs/event/drill.js +2 -1
  28. package/cjs/event/event.d.ts +17 -0
  29. package/cjs/event/event.js +238 -4
  30. package/cjs/event/event.js.map +1 -1
  31. package/cjs/event/listener/container-dom.js +8 -153
  32. package/cjs/event/listener/container-dom.js.map +1 -1
  33. package/cjs/event/listener/scroll-bar.js +1 -1
  34. package/cjs/event/listener/scroll-bar.js.map +1 -1
  35. package/cjs/event/listener/table-group.js +27 -25
  36. package/cjs/event/listener/table-group.js.map +1 -1
  37. package/cjs/index.d.ts +1 -1
  38. package/cjs/index.js +1 -1
  39. package/cjs/index.js.map +1 -1
  40. package/cjs/layout/pivot-header-layout.js +1 -1
  41. package/cjs/layout/pivot-layout.js +2 -0
  42. package/cjs/layout/row-height-map.js +1 -1
  43. package/cjs/layout/simple-header-layout.js +1 -1
  44. package/cjs/layout/tree-helper.js +1 -1
  45. package/cjs/plugins/custom-cell-style.js +1 -2
  46. package/cjs/plugins/index.js +1 -1
  47. package/cjs/plugins/interface.js +1 -1
  48. package/cjs/plugins/invert-highlight.js +1 -1
  49. package/cjs/plugins/list-tree-stick-cell.js +1 -1
  50. package/cjs/plugins/plugin-manager.js +1 -1
  51. package/cjs/scenegraph/graphic/contributions/chart-render-helper.js +1 -4
  52. package/cjs/scenegraph/graphic/contributions/chart-render-helper.js.map +1 -1
  53. package/cjs/scenegraph/graphic/contributions/chart-render.js +1 -4
  54. package/cjs/scenegraph/graphic/contributions/chart-render.js.map +1 -1
  55. package/cjs/scenegraph/graphic/contributions/vchart-graphic-picker.js +1 -7
  56. package/cjs/scenegraph/graphic/contributions/vchart-graphic-picker.js.map +1 -1
  57. package/cjs/scenegraph/group-creater/cell-helper.js +2 -1
  58. package/cjs/scenegraph/group-creater/cell-helper.js.map +1 -1
  59. package/cjs/scenegraph/group-creater/progress/proxy.js.map +1 -1
  60. package/cjs/scenegraph/layout/compute-col-width.js +3 -1
  61. package/cjs/scenegraph/layout/compute-col-width.js.map +1 -1
  62. package/cjs/scenegraph/layout/frozen.js +7 -4
  63. package/cjs/scenegraph/layout/frozen.js.map +1 -1
  64. package/cjs/scenegraph/scenegraph.d.ts +6 -2
  65. package/cjs/scenegraph/scenegraph.js +31 -7
  66. package/cjs/scenegraph/scenegraph.js.map +1 -1
  67. package/cjs/scenegraph/select/create-select-border.d.ts +2 -0
  68. package/cjs/scenegraph/select/create-select-border.js +2 -2
  69. package/cjs/scenegraph/select/create-select-border.js.map +1 -1
  70. package/cjs/scenegraph/select/update-custom-select-border.d.ts +6 -0
  71. package/cjs/scenegraph/select/update-custom-select-border.js +69 -0
  72. package/cjs/scenegraph/select/update-custom-select-border.js.map +1 -0
  73. package/cjs/scenegraph/select/update-select-border.js +4 -12
  74. package/cjs/scenegraph/select/update-select-border.js.map +1 -1
  75. package/cjs/scenegraph/utils/cell-pos.d.ts +12 -0
  76. package/cjs/scenegraph/utils/cell-pos.js +26 -1
  77. package/cjs/scenegraph/utils/cell-pos.js.map +1 -1
  78. package/cjs/scenegraph/utils/update-container.d.ts +1 -0
  79. package/cjs/scenegraph/utils/update-container.js +8 -1
  80. package/cjs/scenegraph/utils/update-container.js.map +1 -1
  81. package/cjs/state/select/custom-select.d.ts +2 -2
  82. package/cjs/state/select/custom-select.js +2 -14
  83. package/cjs/state/select/custom-select.js.map +1 -1
  84. package/cjs/state/select/update-position.js +1 -1
  85. package/cjs/state/select/update-position.js.map +1 -1
  86. package/cjs/state/state.d.ts +4 -7
  87. package/cjs/state/state.js +14 -2
  88. package/cjs/state/state.js.map +1 -1
  89. package/cjs/themes/theme-define.js +1 -1
  90. package/cjs/themes/theme-define.js.map +1 -1
  91. package/cjs/tools/style.d.ts +3 -1
  92. package/cjs/tools/style.js +23 -2
  93. package/cjs/tools/style.js.map +1 -1
  94. package/cjs/ts-types/base-table.d.ts +6 -0
  95. package/cjs/ts-types/base-table.js.map +1 -1
  96. package/cjs/ts-types/events.d.ts +21 -1
  97. package/cjs/ts-types/events.js.map +1 -1
  98. package/cjs/ts-types/new-data-set.d.ts +1 -0
  99. package/cjs/ts-types/new-data-set.js.map +1 -1
  100. package/cjs/ts-types/style-define.d.ts +6 -0
  101. package/cjs/ts-types/style-define.js.map +1 -1
  102. package/cjs/ts-types/table-engine.d.ts +3 -0
  103. package/cjs/ts-types/table-engine.js.map +1 -1
  104. package/cjs/vrender.js.map +1 -1
  105. package/dist/vtable.js +2402 -465
  106. package/dist/vtable.min.js +2 -2
  107. package/es/ListTable.d.ts +8 -2
  108. package/es/ListTable.js +59 -9
  109. package/es/ListTable.js.map +1 -1
  110. package/es/PivotChart.d.ts +4 -1
  111. package/es/PivotChart.js +8 -3
  112. package/es/PivotChart.js.map +1 -1
  113. package/es/PivotTable.d.ts +4 -1
  114. package/es/PivotTable.js +8 -3
  115. package/es/PivotTable.js.map +1 -1
  116. package/es/core/BaseTable.d.ts +14 -1
  117. package/es/core/BaseTable.js +116 -24
  118. package/es/core/BaseTable.js.map +1 -1
  119. package/es/core/TABLE_EVENT_TYPE.d.ts +4 -0
  120. package/es/core/TABLE_EVENT_TYPE.js +5 -1
  121. package/es/core/TABLE_EVENT_TYPE.js.map +1 -1
  122. package/es/core/animation.js +1 -1
  123. package/es/core/animation.js.map +1 -1
  124. package/es/core/group-helper.d.ts +3 -1
  125. package/es/core/group-helper.js +8 -4
  126. package/es/core/group-helper.js.map +1 -1
  127. package/es/core/utils/get-cell-position.js +2 -2
  128. package/es/core/utils/get-cell-position.js.map +1 -1
  129. package/es/data/DataSource.d.ts +1 -0
  130. package/es/data/DataSource.js +21 -12
  131. package/es/data/DataSource.js.map +1 -1
  132. package/es/edit/edit-manager.js +5 -4
  133. package/es/edit/edit-manager.js.map +1 -1
  134. package/es/event/drill.js +2 -1
  135. package/es/event/event.d.ts +17 -0
  136. package/es/event/event.js +240 -3
  137. package/es/event/event.js.map +1 -1
  138. package/es/event/listener/container-dom.js +9 -154
  139. package/es/event/listener/container-dom.js.map +1 -1
  140. package/es/event/listener/scroll-bar.js +1 -1
  141. package/es/event/listener/scroll-bar.js.map +1 -1
  142. package/es/event/listener/table-group.js +27 -25
  143. package/es/event/listener/table-group.js.map +1 -1
  144. package/es/index.d.ts +1 -1
  145. package/es/index.js +1 -1
  146. package/es/index.js.map +1 -1
  147. package/es/layout/pivot-header-layout.js +1 -1
  148. package/es/layout/pivot-layout.js +2 -0
  149. package/es/layout/row-height-map.js +1 -1
  150. package/es/layout/simple-header-layout.js +1 -1
  151. package/es/layout/tree-helper.js +1 -1
  152. package/es/plugins/custom-cell-style.js +1 -2
  153. package/es/plugins/index.js +1 -1
  154. package/es/plugins/interface.js +1 -1
  155. package/es/plugins/invert-highlight.js +1 -1
  156. package/es/plugins/list-tree-stick-cell.js +1 -1
  157. package/es/plugins/plugin-manager.js +1 -1
  158. package/es/scenegraph/graphic/contributions/chart-render-helper.js +1 -4
  159. package/es/scenegraph/graphic/contributions/chart-render-helper.js.map +1 -1
  160. package/es/scenegraph/graphic/contributions/chart-render.js +1 -4
  161. package/es/scenegraph/graphic/contributions/chart-render.js.map +1 -1
  162. package/es/scenegraph/graphic/contributions/vchart-graphic-picker.js +1 -7
  163. package/es/scenegraph/graphic/contributions/vchart-graphic-picker.js.map +1 -1
  164. package/es/scenegraph/group-creater/cell-helper.js +2 -1
  165. package/es/scenegraph/group-creater/cell-helper.js.map +1 -1
  166. package/es/scenegraph/group-creater/progress/proxy.js.map +1 -1
  167. package/es/scenegraph/layout/compute-col-width.js +3 -1
  168. package/es/scenegraph/layout/compute-col-width.js.map +1 -1
  169. package/es/scenegraph/layout/frozen.js +7 -4
  170. package/es/scenegraph/layout/frozen.js.map +1 -1
  171. package/es/scenegraph/scenegraph.d.ts +6 -2
  172. package/es/scenegraph/scenegraph.js +29 -8
  173. package/es/scenegraph/scenegraph.js.map +1 -1
  174. package/es/scenegraph/select/create-select-border.d.ts +2 -0
  175. package/es/scenegraph/select/create-select-border.js +1 -1
  176. package/es/scenegraph/select/create-select-border.js.map +1 -1
  177. package/es/scenegraph/select/update-custom-select-border.d.ts +6 -0
  178. package/es/scenegraph/select/update-custom-select-border.js +63 -0
  179. package/es/scenegraph/select/update-custom-select-border.js.map +1 -0
  180. package/es/scenegraph/select/update-select-border.js +4 -11
  181. package/es/scenegraph/select/update-select-border.js.map +1 -1
  182. package/es/scenegraph/utils/cell-pos.d.ts +12 -0
  183. package/es/scenegraph/utils/cell-pos.js +24 -0
  184. package/es/scenegraph/utils/cell-pos.js.map +1 -1
  185. package/es/scenegraph/utils/update-container.d.ts +1 -0
  186. package/es/scenegraph/utils/update-container.js +6 -0
  187. package/es/scenegraph/utils/update-container.js.map +1 -1
  188. package/es/state/select/custom-select.d.ts +2 -2
  189. package/es/state/select/custom-select.js +3 -15
  190. package/es/state/select/custom-select.js.map +1 -1
  191. package/es/state/select/update-position.js +1 -1
  192. package/es/state/select/update-position.js.map +1 -1
  193. package/es/state/state.d.ts +4 -7
  194. package/es/state/state.js +14 -2
  195. package/es/state/state.js.map +1 -1
  196. package/es/themes/theme-define.js +1 -1
  197. package/es/themes/theme-define.js.map +1 -1
  198. package/es/tools/style.d.ts +3 -1
  199. package/es/tools/style.js +20 -0
  200. package/es/tools/style.js.map +1 -1
  201. package/es/ts-types/base-table.d.ts +6 -0
  202. package/es/ts-types/base-table.js.map +1 -1
  203. package/es/ts-types/events.d.ts +21 -1
  204. package/es/ts-types/events.js.map +1 -1
  205. package/es/ts-types/new-data-set.d.ts +1 -0
  206. package/es/ts-types/new-data-set.js.map +1 -1
  207. package/es/ts-types/style-define.d.ts +6 -0
  208. package/es/ts-types/style-define.js.map +1 -1
  209. package/es/ts-types/table-engine.d.ts +3 -0
  210. package/es/ts-types/table-engine.js.map +1 -1
  211. package/es/vrender.js.map +1 -1
  212. package/package.json +8 -8
package/dist/vtable.js CHANGED
@@ -4635,7 +4635,8 @@
4635
4635
  y1: 0,
4636
4636
  strokeBoundsBuffer: 0,
4637
4637
  cornerRadius: 0,
4638
- cornerType: "round"
4638
+ cornerType: "round",
4639
+ drawStrokeWhenZeroWH: !1
4639
4640
  });
4640
4641
  Object.assign(Object.assign({}, DefaultAttribute), {
4641
4642
  width: 0,
@@ -4644,7 +4645,8 @@
4644
4645
  y1: 0,
4645
4646
  cornerRadius: 0,
4646
4647
  length: 0,
4647
- cornerType: "round"
4648
+ cornerType: "round",
4649
+ drawStrokeWhenZeroWH: !1
4648
4650
  });
4649
4651
  const DefaultSymbolAttribute = Object.assign(Object.assign({}, DefaultAttribute), {
4650
4652
  symbolType: "circle",
@@ -4871,6 +4873,34 @@
4871
4873
  }
4872
4874
  return c;
4873
4875
  }
4876
+ static processColorStops(colorStops) {
4877
+ if (!colorStops || 0 === colorStops.length) return [];
4878
+ if (colorStops.some(item => item.length)) {
4879
+ const stops = colorStops.map(item => ({
4880
+ color: item.value,
4881
+ offset: item.length ? parseFloat(item.length.value) / 100 : -1
4882
+ }));
4883
+ stops[0].offset < 0 && (stops[0].offset = 0), stops[stops.length - 1].offset < 0 && (stops[stops.length - 1].offset = 1);
4884
+ for (let i = 1; i < stops.length - 1; i++) if (stops[i].offset < 0) {
4885
+ const prevWithOffsetIdx = i - 1;
4886
+ let nextWithOffsetIdx = i + 1;
4887
+ for (; nextWithOffsetIdx < stops.length && stops[nextWithOffsetIdx].offset < 0;) nextWithOffsetIdx++;
4888
+ const startOffset = stops[prevWithOffsetIdx].offset,
4889
+ endOffset = stops[nextWithOffsetIdx].offset,
4890
+ unspecCount = nextWithOffsetIdx - prevWithOffsetIdx;
4891
+ for (let j = 1; j < unspecCount; j++) stops[prevWithOffsetIdx + j].offset = startOffset + (endOffset - startOffset) * j / unspecCount;
4892
+ i = nextWithOffsetIdx - 1;
4893
+ }
4894
+ return stops;
4895
+ }
4896
+ return colorStops.map((item, index) => {
4897
+ const offset = colorStops.length > 1 ? index / (colorStops.length - 1) : 0;
4898
+ return {
4899
+ color: item.value,
4900
+ offset: offset
4901
+ };
4902
+ });
4903
+ }
4874
4904
  static ParseConic(datum) {
4875
4905
  const {
4876
4906
  orientation: orientation,
@@ -4884,10 +4914,7 @@
4884
4914
  y: .5,
4885
4915
  startAngle: sa,
4886
4916
  endAngle: sa + pi2,
4887
- stops: colorStops.map(item => ({
4888
- color: item.value,
4889
- offset: parseFloat(item.length.value) / 100
4890
- }))
4917
+ stops: GradientParser.processColorStops(colorStops)
4891
4918
  };
4892
4919
  }
4893
4920
  static ParseRadial(datum) {
@@ -4902,10 +4929,7 @@
4902
4929
  y1: .5,
4903
4930
  r0: 0,
4904
4931
  r1: 1,
4905
- stops: colorStops.map(item => ({
4906
- color: item.value,
4907
- offset: parseFloat(item.length.value) / 100
4908
- }))
4932
+ stops: GradientParser.processColorStops(colorStops)
4909
4933
  };
4910
4934
  }
4911
4935
  static ParseLinear(datum) {
@@ -4927,10 +4951,7 @@
4927
4951
  y0: y0,
4928
4952
  x1: x1,
4929
4953
  y1: y1,
4930
- stops: colorStops.map(item => ({
4931
- color: item.value,
4932
- offset: parseFloat(item.length.value) / 100
4933
- }))
4954
+ stops: GradientParser.processColorStops(colorStops)
4934
4955
  };
4935
4956
  }
4936
4957
  }
@@ -5126,6 +5147,9 @@
5126
5147
  return c > 3 && r && Object.defineProperty(target, key, r), r;
5127
5148
  };
5128
5149
  let ATextMeasure = class {
5150
+ constructor() {
5151
+ this.id = "ATextMeasure";
5152
+ }
5129
5153
  configure(service, env) {
5130
5154
  this.canvas = service.canvas, this.context = service.context, service.bindTextMeasure(this);
5131
5155
  }
@@ -5518,7 +5542,11 @@
5518
5542
  return c > 3 && r && Object.defineProperty(target, key, r), r;
5519
5543
  };
5520
5544
  const TextMeasureContribution = Symbol.for("TextMeasureContribution");
5521
- let DefaultTextMeasureContribution = class extends ATextMeasure {};
5545
+ let DefaultTextMeasureContribution = class extends ATextMeasure {
5546
+ constructor() {
5547
+ super(...arguments), this.id = "DefaultTextMeasureContribution";
5548
+ }
5549
+ };
5522
5550
  DefaultTextMeasureContribution = __decorate$$([injectable()], DefaultTextMeasureContribution);
5523
5551
 
5524
5552
  const container = new Container$2();
@@ -6099,13 +6127,17 @@
6099
6127
  return this.tryInitCanvas(), this._context;
6100
6128
  }
6101
6129
  constructor(contributions) {
6102
- this.contributions = contributions, this.configured = !1, this.global = application.global, this.global.hooks.onSetEnv.tap("graphic-util", (lastEnv, env, global) => {
6130
+ this.contributions = contributions, this.configured = !1, this.global = application.global, this._textMeasureMap = new Map(), this.global.hooks.onSetEnv.tap("graphic-util", (lastEnv, env, global) => {
6103
6131
  this.configured = !1, this.configure(global, env);
6104
6132
  });
6105
6133
  }
6106
6134
  get textMeasure() {
6107
6135
  return this._textMeasure || this.configure(this.global, this.global.env), this._textMeasure;
6108
6136
  }
6137
+ getTextMeasureInstance(textMeasureId) {
6138
+ if (!textMeasureId) return this.textMeasure;
6139
+ return this._textMeasureMap.get(textMeasureId) || this.textMeasure;
6140
+ }
6109
6141
  configure(global, env) {
6110
6142
  this.configured || (this.contributions.getContributions().forEach(contribution => {
6111
6143
  contribution.configure(this, env);
@@ -6118,7 +6150,7 @@
6118
6150
  }
6119
6151
  }
6120
6152
  bindTextMeasure(tm) {
6121
- this._textMeasure = tm;
6153
+ this._textMeasure && "DefaultTextMeasureContribution" !== tm.id || (this._textMeasure = tm), this._textMeasureMap.has(tm.id) || this._textMeasureMap.set(tm.id, tm);
6122
6154
  }
6123
6155
  measureText(text, tc, method = "native") {
6124
6156
  var _a;
@@ -9298,7 +9330,7 @@
9298
9330
  });
9299
9331
  }
9300
9332
  setAttributes(params, forceUpdateTag = !1, context) {
9301
- (params = this.onBeforeAttributeUpdate && this.onBeforeAttributeUpdate(params, this.attribute, null, context) || params).background ? this.loadImage(params.background, !0) : params.shadowGraphic && this.setShadowGraphic(params.shadowGraphic), this._setAttributes(params, forceUpdateTag, context);
9333
+ params && ((params = this.onBeforeAttributeUpdate && this.onBeforeAttributeUpdate(params, this.attribute, null, context) || params).background ? this.loadImage(params.background, !0) : params.shadowGraphic && this.setShadowGraphic(params.shadowGraphic), this._setAttributes(params, forceUpdateTag, context));
9302
9334
  }
9303
9335
  _setAttributes(params, forceUpdateTag = !1, context) {
9304
9336
  const keys = Object.keys(params);
@@ -10123,8 +10155,8 @@
10123
10155
  function strokeVisible(opacity, strokeOpacity) {
10124
10156
  return opacity * strokeOpacity > 0;
10125
10157
  }
10126
- function rectStrokeVisible(opacity, strokeOpacity, width, height) {
10127
- return opacity * strokeOpacity > 0 && 0 !== width && 0 !== height;
10158
+ function rectStrokeVisible(opacity, strokeOpacity, width, height, drawStrokeWhenZeroWH) {
10159
+ return drawStrokeWhenZeroWH ? opacity * strokeOpacity > 0 : opacity * strokeOpacity > 0 && 0 !== width && 0 !== height;
10128
10160
  }
10129
10161
  function intersect(x0, y0, x1, y1, x2, y2, x3, y3) {
10130
10162
  const x10 = x1 - x0,
@@ -10715,7 +10747,7 @@
10715
10747
  this.cache.layoutData.lines.forEach(item => {
10716
10748
  mergedText += item.str;
10717
10749
  });
10718
- return (Array.isArray(text) ? text.join("") : text) !== mergedText;
10750
+ return (Array.isArray(text) ? text.join("") : text).toString() !== mergedText;
10719
10751
  }
10720
10752
  return "vertical" === attribute.direction && this.cache.verticalList && this.cache.verticalList[0] ? this.cache.verticalList[0].map(item => item.text).join("") !== attribute.text.toString() : null != this.clipedText && this.clipedText !== attribute.text.toString();
10721
10753
  }
@@ -10814,7 +10846,7 @@
10814
10846
  return fontSize ? .1 * fontSize : 0;
10815
10847
  }
10816
10848
  updateHorizontalMultilineAABBBounds(text) {
10817
- var _a;
10849
+ var _a, _b;
10818
10850
  const textTheme = this.getGraphicTheme(),
10819
10851
  attribute = this.attribute,
10820
10852
  {
@@ -10841,7 +10873,7 @@
10841
10873
  const bbox = this.cache.layoutData.bbox;
10842
10874
  return this._AABBBounds.set(bbox.xOffset, bbox.yOffset, bbox.xOffset + bbox.width, bbox.yOffset + bbox.height), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
10843
10875
  }
10844
- const textMeasure = application.graphicUtil.textMeasure,
10876
+ const textMeasure = application.graphicUtil.getTextMeasureInstance(this.textMeasureId || (null === (_b = this.stage) || void 0 === _b ? void 0 : _b.textMeasureId)),
10845
10877
  layoutData = new CanvasTextLayout(fontFamily, {
10846
10878
  fontSize: fontSize,
10847
10879
  fontWeight: fontWeight,
@@ -10859,7 +10891,7 @@
10859
10891
  return this.cache.layoutData = layoutData, this.clearUpdateShapeTag(), this._AABBBounds.set(bbox.xOffset, bbox.yOffset, bbox.xOffset + bbox.width, bbox.yOffset + bbox.height), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
10860
10892
  }
10861
10893
  updateWrapAABBBounds(text) {
10862
- var _a, _b, _c;
10894
+ var _a, _b, _c, _d;
10863
10895
  const textTheme = this.getGraphicTheme(),
10864
10896
  {
10865
10897
  fontFamily = textTheme.fontFamily,
@@ -10885,7 +10917,7 @@
10885
10917
  const bbox = this.cache.layoutData.bbox;
10886
10918
  return this._AABBBounds.set(bbox.xOffset, bbox.yOffset, bbox.xOffset + bbox.width, bbox.yOffset + bbox.height), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
10887
10919
  }
10888
- const textMeasure = application.graphicUtil.textMeasure,
10920
+ const textMeasure = application.graphicUtil.getTextMeasureInstance(this.textMeasureId || (null === (_b = this.stage) || void 0 === _b ? void 0 : _b.textMeasureId)),
10889
10921
  textOptions = {
10890
10922
  fontSize: fontSize,
10891
10923
  fontWeight: fontWeight,
@@ -10917,7 +10949,7 @@
10917
10949
  if ("" !== str && "" === clip.str || clip.wordBreaked) {
10918
10950
  if (ellipsis) {
10919
10951
  const clipEllipsis = textMeasure.clipTextWithSuffix(str, textOptions, maxLineWidth, ellipsis, !1, suffixPosition);
10920
- clip.str = null !== (_b = clipEllipsis.str) && void 0 !== _b ? _b : "", clip.width = null !== (_c = clipEllipsis.width) && void 0 !== _c ? _c : 0;
10952
+ clip.str = null !== (_c = clipEllipsis.str) && void 0 !== _c ? _c : "", clip.width = null !== (_d = clipEllipsis.width) && void 0 !== _d ? _d : 0;
10921
10953
  } else clip.str = "", clip.width = 0;
10922
10954
  needCut = !1;
10923
10955
  }
@@ -10980,9 +11012,9 @@
10980
11012
  return this.cache.layoutData = layoutData, this.clearUpdateShapeTag(), this._AABBBounds.set(bbox.xOffset, bbox.yOffset, bbox.xOffset + bbox.width, bbox.yOffset + bbox.height), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
10981
11013
  }
10982
11014
  updateVerticalMultilineAABBBounds(text) {
10983
- var _a, _b;
11015
+ var _a, _b, _c;
10984
11016
  const textTheme = this.getGraphicTheme(),
10985
- textMeasure = application.graphicUtil.textMeasure;
11017
+ textMeasure = application.graphicUtil.getTextMeasureInstance(this.textMeasureId || (null === (_a = this.stage) || void 0 === _a ? void 0 : _a.textMeasureId));
10986
11018
  let width;
10987
11019
  const attribute = this.attribute,
10988
11020
  {
@@ -11003,7 +11035,7 @@
11003
11035
  } = attribute;
11004
11036
  if (!verticalMode) {
11005
11037
  const t = textAlign;
11006
- textAlign = null !== (_a = Text.baselineMapAlign[textBaseline]) && void 0 !== _a ? _a : "left", textBaseline = null !== (_b = Text.alignMapBaseline[t]) && void 0 !== _b ? _b : "top";
11038
+ textAlign = null !== (_b = Text.baselineMapAlign[textBaseline]) && void 0 !== _b ? _b : "left", textBaseline = null !== (_c = Text.alignMapBaseline[t]) && void 0 !== _c ? _c : "top";
11007
11039
  }
11008
11040
  if (width = 0, !this.shouldUpdateShape() && this.cache) {
11009
11041
  this.cache.verticalList.forEach(item => {
@@ -11117,7 +11149,7 @@
11117
11149
  return isArray$9(text) ? !text.every(t => null == t || "" === t) : null != text && "" !== text;
11118
11150
  }
11119
11151
  updateMultilineAABBBounds(text) {
11120
- var _a, _b, _c, _d;
11152
+ var _a, _b, _c, _d, _e;
11121
11153
  const textTheme = this.getGraphicTheme(),
11122
11154
  {
11123
11155
  fontFamily = textTheme.fontFamily,
@@ -11141,7 +11173,7 @@
11141
11173
  const bbox = this.cache.layoutData.bbox;
11142
11174
  return this._AABBBounds.set(bbox.xOffset, bbox.yOffset, bbox.xOffset + bbox.width, bbox.yOffset + bbox.height), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
11143
11175
  }
11144
- const textMeasure = application.graphicUtil.textMeasure,
11176
+ const textMeasure = application.graphicUtil.getTextMeasureInstance(this.textMeasureId || (null === (_c = this.stage) || void 0 === _c ? void 0 : _c.textMeasureId)),
11145
11177
  layoutObj = new CanvasTextLayout(fontFamily, {
11146
11178
  fontSize: fontSize,
11147
11179
  fontWeight: fontWeight,
@@ -11170,7 +11202,7 @@
11170
11202
  if ("" !== str && "" === clip.str) {
11171
11203
  if (ellipsis) {
11172
11204
  const clipEllipsis = layoutObj.textMeasure.clipTextWithSuffix(str, layoutObj.textOptions, maxLineWidth, ellipsis, !1, suffixPosition);
11173
- clip.str = null !== (_c = clipEllipsis.str) && void 0 !== _c ? _c : "", clip.width = null !== (_d = clipEllipsis.width) && void 0 !== _d ? _d : 0;
11205
+ clip.str = null !== (_d = clipEllipsis.str) && void 0 !== _d ? _d : "", clip.width = null !== (_e = clipEllipsis.width) && void 0 !== _e ? _e : 0;
11174
11206
  } else clip.str = "", clip.width = 0;
11175
11207
  needCut = !1;
11176
11208
  }
@@ -12274,7 +12306,7 @@
12274
12306
  case "right":
12275
12307
  deltaX = -aabbBounds.width();
12276
12308
  }
12277
- return aabbBounds.translate(deltaX, deltaY), application.graphicService.updateTempAABBBounds(aabbBounds), null == attribute.forceBoundsHeight && null == attribute.forceBoundsWidth || application.graphicService.updateHTMLTextAABBBounds(attribute, richtextTheme, aabbBounds), this.widthWithoutTransform = aabbBounds.x2 - aabbBounds.x1, this.heightWithoutTransform = aabbBounds.y2 - aabbBounds.y1, application.graphicService.transformAABBBounds(attribute, aabbBounds, richtextTheme, !1, this), 0 === aabbBounds.width() && 0 === aabbBounds.height() && aabbBounds.clear(), aabbBounds;
12309
+ return height || ("middle" === this.verticalDirection ? deltaY -= aabbBounds.height() / 2 : "bottom" === this.verticalDirection && (deltaY -= aabbBounds.height())), aabbBounds.translate(deltaX, deltaY), application.graphicService.updateTempAABBBounds(aabbBounds), null == attribute.forceBoundsHeight && null == attribute.forceBoundsWidth || application.graphicService.updateHTMLTextAABBBounds(attribute, richtextTheme, aabbBounds), this.widthWithoutTransform = aabbBounds.x2 - aabbBounds.x1, this.heightWithoutTransform = aabbBounds.y2 - aabbBounds.y1, application.graphicService.transformAABBBounds(attribute, aabbBounds, richtextTheme, !1, this), 0 === aabbBounds.width() && 0 === aabbBounds.height() && aabbBounds.clear(), aabbBounds;
12278
12310
  }
12279
12311
  needUpdateTags(keys) {
12280
12312
  return super.needUpdateTags(keys, RICHTEXT_UPDATE_TAG_KEY);
@@ -14673,7 +14705,8 @@
14673
14705
  y1: y1,
14674
14706
  x: originX = rectAttribute.x,
14675
14707
  y: originY = rectAttribute.y,
14676
- fillStrokeOrder = rectAttribute.fillStrokeOrder
14708
+ fillStrokeOrder = rectAttribute.fillStrokeOrder,
14709
+ drawStrokeWhenZeroWH = rectAttribute.drawStrokeWhenZeroWH
14677
14710
  } = rect.attribute;
14678
14711
  let {
14679
14712
  width: width,
@@ -14681,7 +14714,7 @@
14681
14714
  } = rect.attribute;
14682
14715
  width = (null != width ? width : x1 - originX) || 0, height = (null != height ? height : y1 - originY) || 0;
14683
14716
  const fVisible = rectFillVisible(opacity, fillOpacity, width, height, fill),
14684
- sVisible = rectStrokeVisible(opacity, strokeOpacity, width, height),
14717
+ sVisible = rectStrokeVisible(opacity, strokeOpacity, width, height, drawStrokeWhenZeroWH),
14685
14718
  doFill = runFill(fill, background),
14686
14719
  doStroke = runStroke(stroke, lineWidth);
14687
14720
  if (!rect.valid || !visible) return;
@@ -16742,13 +16775,13 @@
16742
16775
  this._skipRender > 1 && this.renderNextFrame(), this._skipRender = 0;
16743
16776
  } else this._skipRender = 1;
16744
16777
  }, this.beforeRender = stage => {
16745
- this._beforeRender && this._beforeRender(stage);
16778
+ this._beforeRenderList.forEach(cb => cb(stage));
16746
16779
  }, this.afterClearScreen = drawParams => {
16747
16780
  this._afterClearScreen && this._afterClearScreen(drawParams);
16748
16781
  }, this.afterClearRect = drawParams => {
16749
16782
  this._afterClearRect && this._afterClearRect(drawParams);
16750
16783
  }, this.afterRender = stage => {
16751
- this.renderCount++, this._afterRender && this._afterRender(stage), this._afterNextRenderCbs && this._afterNextRenderCbs.forEach(cb => cb(stage)), this._afterNextRenderCbs = null, this.tickedBeforeRender = !1;
16784
+ this.renderCount++, this._afterRenderList.forEach(cb => cb(stage)), this._afterNextRenderCbs && this._afterNextRenderCbs.forEach(cb => cb(stage)), this._afterNextRenderCbs = null, this.tickedBeforeRender = !1;
16752
16785
  }, this.afterTickCb = () => {
16753
16786
  this.tickedBeforeRender = !0, "rendering" !== this.state && this.renderNextFrame();
16754
16787
  }, this.params = params, this.theme = new Theme(), this.hooks = {
@@ -16756,7 +16789,7 @@
16756
16789
  afterRender: new SyncHook(["stage"]),
16757
16790
  afterClearScreen: new SyncHook(["stage"]),
16758
16791
  afterClearRect: new SyncHook(["stage"])
16759
- }, this.global = application.global, !this.global.env && isBrowserEnv() && this.global.setEnv("browser"), this.window = container.get(VWindow), this.renderService = container.get(RenderService), this.pluginService = container.get(PluginService), this.layerService = container.get(LayerService), this.graphicService = container.get(GraphicService), this.pluginService.active(this, params), this.window.create({
16792
+ }, this.global = application.global, !this.global.env && isBrowserEnv() && this.global.setEnv("browser"), this.window = container.get(VWindow), this.renderService = container.get(RenderService), this.pluginService = container.get(PluginService), this.layerService = container.get(LayerService), this.graphicService = container.get(GraphicService), this.pluginService.active(this, params), this._beforeRenderList = [], this._afterRenderList = [], this.window.create({
16760
16793
  width: params.width,
16761
16794
  height: params.height,
16762
16795
  viewBox: params.viewBox,
@@ -16767,7 +16800,7 @@
16767
16800
  canvas: params.canvas
16768
16801
  }), this.state = "normal", this.renderCount = 0, this.tryInitEventSystem(), this._background = null !== (_a = params.background) && void 0 !== _a ? _a : DefaultConfig.BACKGROUND, this.appendChild(this.layerService.createLayer(this, {
16769
16802
  main: !0
16770
- })), this.nextFrameRenderLayerSet = new Set(), this.willNextFrameRender = !1, this.stage = this, this.renderStyle = params.renderStyle, params.autoRender && this.enableAutoRender(), params.autoRefresh && this.enableAutoRefresh(), !1 === params.disableDirtyBounds && this.enableDirtyBounds(), params.enableHtmlAttribute && this.enableHtmlAttribute(params.enableHtmlAttribute), params.ReactDOM && this.enableReactAttribute(params.ReactDOM), params.enableLayout && this.enableLayout(), this.hooks.beforeRender.tap("constructor", this.beforeRender), this.hooks.afterRender.tap("constructor", this.afterRender), this.hooks.afterClearScreen.tap("constructor", this.afterClearScreen), this.hooks.afterClearRect.tap("constructor", this.afterClearRect), this._beforeRender = params.beforeRender, this._afterRender = params.afterRender, this._afterClearScreen = params.afterClearScreen, this._afterClearRect = params.afterClearRect, this.supportInteractiveLayer = !1 !== params.interactiveLayer, params.optimize || (params.optimize = {
16803
+ })), this.nextFrameRenderLayerSet = new Set(), this.willNextFrameRender = !1, this.stage = this, this.renderStyle = params.renderStyle, params.autoRender && this.enableAutoRender(), params.autoRefresh && this.enableAutoRefresh(), !1 === params.disableDirtyBounds && this.enableDirtyBounds(), params.enableHtmlAttribute && this.enableHtmlAttribute(params.enableHtmlAttribute), params.ReactDOM && this.enableReactAttribute(params.ReactDOM), params.enableLayout && this.enableLayout(), this.hooks.beforeRender.tap("constructor", this.beforeRender), this.hooks.afterRender.tap("constructor", this.afterRender), params.beforeRender && this._beforeRenderList.push(params.beforeRender), params.afterRender && this._afterRenderList.push(params.afterRender), this.hooks.afterClearScreen.tap("constructor", this.afterClearScreen), this.hooks.afterClearRect.tap("constructor", this.afterClearRect), this._afterClearScreen = params.afterClearScreen, this._afterClearRect = params.afterClearRect, this.supportInteractiveLayer = !1 !== params.interactiveLayer, params.optimize || (params.optimize = {
16771
16804
  tickRenderMode: "effect"
16772
16805
  }), this.optmize(params.optimize), params.background && isString$6(this._background) && this._background.includes("/") && this.setAttributes({
16773
16806
  background: this._background
@@ -16882,10 +16915,16 @@
16882
16915
  options.enableView3dTransform && this.enableView3dTransform();
16883
16916
  }
16884
16917
  setBeforeRender(cb) {
16885
- this._beforeRender = cb;
16918
+ this._beforeRenderList.push(cb);
16919
+ }
16920
+ removeBeforeRender(cb) {
16921
+ this._beforeRenderList = this._beforeRenderList.filter(c => c !== cb);
16886
16922
  }
16887
16923
  setAfterRender(cb) {
16888
- this._afterRender = cb;
16924
+ this._afterRenderList.push(cb);
16925
+ }
16926
+ removeAfterRender(cb) {
16927
+ this._afterRenderList = this._afterRenderList.filter(c => c !== cb);
16889
16928
  }
16890
16929
  afterNextRender(cb) {
16891
16930
  this._afterNextRenderCbs || (this._afterNextRenderCbs = []), this._afterNextRenderCbs.push(cb);
@@ -23678,6 +23717,7 @@
23678
23717
  return this.getEndProps();
23679
23718
  }
23680
23719
  stop() {}
23720
+ release() {}
23681
23721
  }
23682
23722
  class WaitStep extends Step {
23683
23723
  constructor(type, props, duration, easing) {
@@ -23685,8 +23725,6 @@
23685
23725
  }
23686
23726
  onStart() {
23687
23727
  super.onStart();
23688
- }
23689
- onFirstRun() {
23690
23728
  const fromProps = this.getFromProps();
23691
23729
  this.target.setAttributes(fromProps);
23692
23730
  }
@@ -23895,7 +23933,9 @@
23895
23933
  this.status !== AnimateStatus.END && this.onEnd(), this.status = AnimateStatus.END, this.target && ("start" === type ? this.target.setAttributes(this._startProps) : "end" === type ? this.target.setAttributes(this._endProps) : type && this.target.setAttributes(type));
23896
23934
  }
23897
23935
  release() {
23898
- this.status = AnimateStatus.END, this._onRemove && this._onRemove.forEach(cb => cb()), this._onStart = [], this._onFrame = [], this._onEnd = [], this._onRemove = [];
23936
+ this.status = AnimateStatus.END, this._onRemove && this._onRemove.forEach(cb => cb()), this._onStart = [], this._onFrame = [], this._onEnd = [], this._onRemove = [], this.forEachStep(step => {
23937
+ step.release();
23938
+ });
23899
23939
  }
23900
23940
  getDuration() {
23901
23941
  return this._duration;
@@ -23969,6 +24009,10 @@
23969
24009
  getLoop() {
23970
24010
  return this._loopCount;
23971
24011
  }
24012
+ forEachStep(cb) {
24013
+ let step = this._firstStep;
24014
+ for (; step;) cb(step), step = step.next;
24015
+ }
23972
24016
  }
23973
24017
 
23974
24018
  const performanceRAF = new PerformanceRAF();
@@ -24201,6 +24245,9 @@
24201
24245
  constructor(target) {
24202
24246
  this._animates = [], this._startCallbacks = [], this._endCallbacks = [], this._started = !1, this._activeCount = 0, this._target = target;
24203
24247
  }
24248
+ get started() {
24249
+ return this._started;
24250
+ }
24204
24251
  onStart(cb) {
24205
24252
  cb ? (this._startCallbacks.push(cb), this._started && this._activeCount > 0 && cb()) : this._startCallbacks.forEach(cb => {
24206
24253
  cb();
@@ -24341,14 +24388,14 @@
24341
24388
  return delayAfterValue > 0 && (totalDelay += delayAfterValue), totalDelay > 0 && animate.wait(totalDelay), loop && loop > 0 && animate.loop(loop), bounce && animate.bounce(!0), animate;
24342
24389
  }
24343
24390
  _handleRunAnimate(animate, custom, customType, from, props, duration, easing, customParameters, controlOptions, options, type, graphic) {
24344
- var _a, _b, _c, _d;
24391
+ var _a, _b, _c, _d, _e, _f;
24345
24392
  if (custom && customType) {
24346
24393
  const customParams = Object.assign({
24347
- width: graphic.stage.width,
24348
- height: graphic.stage.height,
24394
+ width: (null === (_a = graphic.stage) || void 0 === _a ? void 0 : _a.width) || 0,
24395
+ height: (null === (_b = graphic.stage) || void 0 === _b ? void 0 : _b.height) || 0,
24349
24396
  group: this._target.parent
24350
24397
  }, this.resolveValue(customParameters, graphic)),
24351
- objOptions = isFunction$7(options) ? options.call(null, null !== (_b = customParams && (null === (_a = customParams.data) || void 0 === _a ? void 0 : _a[0])) && void 0 !== _b ? _b : null === (_d = null === (_c = graphic.context) || void 0 === _c ? void 0 : _c.data) || void 0 === _d ? void 0 : _d[0], graphic, customParams) : options;
24398
+ objOptions = isFunction$7(options) ? options.call(null, null !== (_d = customParams && (null === (_c = customParams.data) || void 0 === _c ? void 0 : _c[0])) && void 0 !== _d ? _d : null === (_f = null === (_e = graphic.context) || void 0 === _e ? void 0 : _e.data) || void 0 === _f ? void 0 : _f[0], graphic, customParams) : options;
24352
24399
  customParams.options = objOptions, customParams.controlOptions = controlOptions, 1 === customType ? this.createCustomAnimation(animate, custom, from, props, duration, easing, customParams) : 2 === customType && this.createCustomInterpolatorAnimation(animate, custom, props, duration, easing, customParams);
24353
24400
  } else "to" === type ? animate.to(props, duration, easing) : "from" === type && animate.from(props, duration, easing);
24354
24401
  }
@@ -24568,7 +24615,7 @@
24568
24615
  reApplyState(state) {
24569
24616
  var _a;
24570
24617
  const stateInfo = null === (_a = this.stateList) || void 0 === _a ? void 0 : _a.find(stateInfo => stateInfo.state === state);
24571
- if (stateInfo) {
24618
+ if (stateInfo && stateInfo.executor.started) {
24572
24619
  const stateList = this.stateList.slice();
24573
24620
  stateInfo.executor.stop(), this.stateList = stateList, stateInfo.executor.execute(stateInfo.animationConfig);
24574
24621
  }
@@ -24711,6 +24758,45 @@
24711
24758
  this._animator && this._animator.stop();
24712
24759
  }
24713
24760
  }
24761
+ class AStageAnimate extends ACustomAnimate {
24762
+ constructor(customFrom, customTo, duration, easing, params) {
24763
+ super(customFrom, customTo, duration, easing, params), this.willCallBeforeStageRender = !0, this.willCallAfterStageRender = !0, this._beforeStageRender = () => {
24764
+ if (!this.willCallBeforeStageRender) return;
24765
+ this.willCallBeforeStageRender = !1;
24766
+ const stage = this.target.stage,
24767
+ canvas = stage.window.getContext().canvas.nativeCanvas,
24768
+ outputCanvas = this.beforeStageRender(stage, canvas);
24769
+ outputCanvas && this.renderToStage(stage, outputCanvas);
24770
+ }, this._afterStageRender = () => {
24771
+ if (!this.willCallAfterStageRender) return;
24772
+ this.willCallAfterStageRender = !1;
24773
+ const stage = this.target.stage,
24774
+ canvas = stage.window.getContext().canvas.nativeCanvas,
24775
+ outputCanvas = this.afterStageRender(stage, canvas);
24776
+ outputCanvas && this.renderToStage(stage, outputCanvas);
24777
+ }, this.props = {};
24778
+ }
24779
+ beforeStageRender(stage, canvas) {
24780
+ return !1;
24781
+ }
24782
+ afterStageRender(stage, canvas) {
24783
+ return !1;
24784
+ }
24785
+ onFirstRun() {
24786
+ super.onFirstRun(), this.target.stage.setBeforeRender(this._beforeStageRender), this.target.stage.setAfterRender(this._afterStageRender), this.target.stage.disableDirtyBounds();
24787
+ }
24788
+ stop() {
24789
+ super.stop(), this.target.stage.removeBeforeRender(this._beforeStageRender), this.target.stage.removeAfterRender(this._afterStageRender);
24790
+ }
24791
+ onUpdate(end, ratio, out) {
24792
+ super.onUpdate(end, ratio, out), this.willCallBeforeStageRender = !0, this.willCallAfterStageRender = !0;
24793
+ }
24794
+ renderToStage(stage, canvas) {
24795
+ const stageCanvas = stage.window.getContext().canvas.nativeCanvas,
24796
+ ctx = stageCanvas.getContext("2d");
24797
+ return !!ctx && (ctx.clearRect(0, 0, stageCanvas.width, stageCanvas.height), ctx.drawImage(canvas, 0, 0), stageCanvas);
24798
+ }
24799
+ }
24714
24800
 
24715
24801
  class ComponentAnimator {
24716
24802
  constructor(component) {
@@ -25093,7 +25179,7 @@
25093
25179
  }
25094
25180
  class GrowAngleIn extends GrowAngleBase {
25095
25181
  onBind() {
25096
- var _a, _b;
25182
+ var _a, _b, _c;
25097
25183
  super.onBind();
25098
25184
  const {
25099
25185
  from: from,
@@ -25102,7 +25188,7 @@
25102
25188
  fromAttrs = null !== (_b = null === (_a = this.target.context) || void 0 === _a ? void 0 : _a.lastAttrs) && void 0 !== _b ? _b : from;
25103
25189
  this.props = to, this.propKeys = Object.keys(to).filter(key => null != to[key]), this.from = fromAttrs, this.to = to;
25104
25190
  const finalAttribute = this.target.getFinalAttribute();
25105
- finalAttribute && this.target.setAttributes(finalAttribute), this.target.setAttributes(fromAttrs), this.determineUpdateFunction();
25191
+ finalAttribute && this.target.setAttributes(finalAttribute), !1 !== (null === (_c = this.params.controlOptions) || void 0 === _c ? void 0 : _c.immediatelyApply) && this.target.setAttributes(fromAttrs), this.determineUpdateFunction();
25106
25192
  }
25107
25193
  }
25108
25194
  class GrowAngleOut extends GrowAngleBase {
@@ -25710,7 +25796,7 @@
25710
25796
  }
25711
25797
  class GrowRadiusIn extends GrowPointsBase {
25712
25798
  onBind() {
25713
- var _a, _b;
25799
+ var _a, _b, _c;
25714
25800
  super.onBind();
25715
25801
  const {
25716
25802
  from: from,
@@ -25719,7 +25805,7 @@
25719
25805
  fromAttrs = null !== (_b = null === (_a = this.target.context) || void 0 === _a ? void 0 : _a.lastAttrs) && void 0 !== _b ? _b : from;
25720
25806
  this.props = to, this.propKeys = Object.keys(to).filter(key => null != to[key]), this.from = fromAttrs, this.to = to;
25721
25807
  const finalAttribute = this.target.getFinalAttribute();
25722
- finalAttribute && this.target.setAttributes(finalAttribute), this.target.setAttributes(fromAttrs);
25808
+ finalAttribute && this.target.setAttributes(finalAttribute), !1 !== (null === (_c = this.params.controlOptions) || void 0 === _c ? void 0 : _c.immediatelyApply) && this.target.setAttributes(fromAttrs);
25723
25809
  }
25724
25810
  }
25725
25811
  class GrowRadiusOut extends GrowPointsBase {
@@ -25834,7 +25920,7 @@
25834
25920
  super(from, to, duration, easing, params);
25835
25921
  }
25836
25922
  onBind() {
25837
- var _a, _b;
25923
+ var _a, _b, _c;
25838
25924
  super.onBind();
25839
25925
  const {
25840
25926
  from: from,
@@ -25843,7 +25929,7 @@
25843
25929
  fromAttrs = null !== (_b = null === (_a = this.target.context) || void 0 === _a ? void 0 : _a.lastAttrs) && void 0 !== _b ? _b : from;
25844
25930
  this.props = to, this.propKeys = Object.keys(to).filter(key => null != to[key]), this.from = fromAttrs, this.to = to;
25845
25931
  const finalAttribute = this.target.getFinalAttribute();
25846
- finalAttribute && this.target.setAttributes(finalAttribute), this.target.setAttributes(fromAttrs);
25932
+ finalAttribute && this.target.setAttributes(finalAttribute), !1 !== (null === (_c = this.params.controlOptions) || void 0 === _c ? void 0 : _c.immediatelyApply) && this.target.setAttributes(fromAttrs);
25847
25933
  }
25848
25934
  onEnd(cb) {
25849
25935
  super.onEnd(cb);
@@ -27627,8 +27713,1271 @@
27627
27713
  }
27628
27714
  }
27629
27715
 
27716
+ class DisappearAnimateBase extends AStageAnimate {
27717
+ constructor(from, to, duration, easing, params) {
27718
+ super(from, to, duration, easing, params), this.webglCanvas = null, this.gl = null, this.program = null, this.currentAnimationRatio = 0, this.animationTime = 0;
27719
+ }
27720
+ onUpdate(end, ratio, out) {
27721
+ super.onUpdate(end, ratio, out), this.currentAnimationRatio = ratio, this.animationTime = ratio * Math.PI * 2;
27722
+ }
27723
+ getAnimationTime() {
27724
+ return this.currentAnimationRatio > 0 ? this.animationTime : Date.now() / 1e3;
27725
+ }
27726
+ getDurationFromParent() {
27727
+ return this.duration || 1e3;
27728
+ }
27729
+ initWebGL(canvas) {
27730
+ try {
27731
+ if (this.webglCanvas = vglobal.createCanvas({
27732
+ width: canvas.width,
27733
+ height: canvas.height,
27734
+ dpr: vglobal.devicePixelRatio
27735
+ }), !this.webglCanvas) return (void 0), !1;
27736
+ this.webglCanvas.style.width = canvas.style.width || `${canvas.width}px`, this.webglCanvas.style.height = canvas.style.height || `${canvas.height}px`;
27737
+ let glContext = null;
27738
+ try {
27739
+ glContext = this.webglCanvas.getContext("webgl"), glContext || (glContext = this.webglCanvas.getContext("experimental-webgl"));
27740
+ } catch (e) {
27741
+ }
27742
+ if (this.gl = glContext, !this.gl) return (void 0), !1;
27743
+ const shaders = this.getShaderSources();
27744
+ return this.program = this.createShaderProgram(shaders.vertex, shaders.fragment), null !== this.program;
27745
+ } catch (error) {
27746
+ return !1;
27747
+ }
27748
+ }
27749
+ createShaderProgram(vertexSource, fragmentSource) {
27750
+ if (!this.gl) return null;
27751
+ const vertexShader = this.createShader(this.gl.VERTEX_SHADER, vertexSource),
27752
+ fragmentShader = this.createShader(this.gl.FRAGMENT_SHADER, fragmentSource);
27753
+ if (!vertexShader || !fragmentShader) return null;
27754
+ const program = this.gl.createProgram();
27755
+ return program ? (this.gl.attachShader(program, vertexShader), this.gl.attachShader(program, fragmentShader), this.gl.linkProgram(program), this.gl.getProgramParameter(program, this.gl.LINK_STATUS) ? program : (null)) : null;
27756
+ }
27757
+ createShader(type, source) {
27758
+ if (!this.gl) return null;
27759
+ const shader = this.gl.createShader(type);
27760
+ return shader ? (this.gl.shaderSource(shader, source), this.gl.compileShader(shader), this.gl.getShaderParameter(shader, this.gl.COMPILE_STATUS) ? shader : (this.gl.deleteShader(shader), null)) : null;
27761
+ }
27762
+ setupWebGLState(canvas) {
27763
+ this.gl && this.webglCanvas && (this.webglCanvas.width === canvas.width && this.webglCanvas.height === canvas.height || (this.webglCanvas.width = canvas.width, this.webglCanvas.height = canvas.height), this.gl.viewport(0, 0, this.webglCanvas.width, this.webglCanvas.height), this.gl.clearColor(0, 0, 0, 0), this.gl.clear(this.gl.COLOR_BUFFER_BIT));
27764
+ }
27765
+ createFullScreenQuad() {
27766
+ if (!this.gl) return null;
27767
+ const vertices = new Float32Array([-1, -1, 0, 1, 1, -1, 1, 1, -1, 1, 0, 0, 1, 1, 1, 0]),
27768
+ vertexBuffer = this.gl.createBuffer();
27769
+ return this.gl.bindBuffer(this.gl.ARRAY_BUFFER, vertexBuffer), this.gl.bufferData(this.gl.ARRAY_BUFFER, vertices, this.gl.STATIC_DRAW), vertexBuffer;
27770
+ }
27771
+ createTextureFromCanvas(canvas) {
27772
+ if (!this.gl) return null;
27773
+ const texture = this.gl.createTexture();
27774
+ return this.gl.activeTexture(this.gl.TEXTURE0), this.gl.bindTexture(this.gl.TEXTURE_2D, texture), this.gl.texImage2D(this.gl.TEXTURE_2D, 0, this.gl.RGBA, this.gl.RGBA, this.gl.UNSIGNED_BYTE, canvas), this.gl.texParameteri(this.gl.TEXTURE_2D, this.gl.TEXTURE_WRAP_S, this.gl.CLAMP_TO_EDGE), this.gl.texParameteri(this.gl.TEXTURE_2D, this.gl.TEXTURE_WRAP_T, this.gl.CLAMP_TO_EDGE), this.gl.texParameteri(this.gl.TEXTURE_2D, this.gl.TEXTURE_MIN_FILTER, this.gl.LINEAR), this.gl.texParameteri(this.gl.TEXTURE_2D, this.gl.TEXTURE_MAG_FILTER, this.gl.LINEAR), texture;
27775
+ }
27776
+ setupVertexAttributes() {
27777
+ if (!this.gl || !this.program) return;
27778
+ const positionLocation = this.gl.getAttribLocation(this.program, "a_position"),
27779
+ texCoordLocation = this.gl.getAttribLocation(this.program, "a_texCoord");
27780
+ this.gl.enableVertexAttribArray(positionLocation), this.gl.vertexAttribPointer(positionLocation, 2, this.gl.FLOAT, !1, 16, 0), this.gl.enableVertexAttribArray(texCoordLocation), this.gl.vertexAttribPointer(texCoordLocation, 2, this.gl.FLOAT, !1, 16, 8);
27781
+ }
27782
+ createOutputCanvas(canvas) {
27783
+ const outputCanvas = vglobal.createCanvas({
27784
+ width: canvas.width,
27785
+ height: canvas.height,
27786
+ dpr: vglobal.devicePixelRatio
27787
+ }),
27788
+ ctx = outputCanvas.getContext("2d");
27789
+ return ctx ? (ctx.clearRect(0, 0, canvas.width, canvas.height), ctx.drawImage(canvas, 0, 0), {
27790
+ canvas: outputCanvas,
27791
+ ctx: ctx
27792
+ }) : null;
27793
+ }
27794
+ getShaderSources() {
27795
+ return null;
27796
+ }
27797
+ applyWebGLEffect(canvas) {
27798
+ return null;
27799
+ }
27800
+ applyCanvas2DEffect(canvas) {
27801
+ return null;
27802
+ }
27803
+ supportsWebGL() {
27804
+ return null !== this.getShaderSources();
27805
+ }
27806
+ supportsCanvas2D() {
27807
+ return this.applyCanvas2DEffect !== DisappearAnimateBase.prototype.applyCanvas2DEffect;
27808
+ }
27809
+ release() {
27810
+ super.release(), this.gl && (this.program && (this.gl.deleteProgram(this.program), this.program = null), this.gl = null), this.webglCanvas && (this.webglCanvas = null), this.currentAnimationRatio = 0, this.animationTime = 0;
27811
+ }
27812
+ afterStageRender(stage, canvas) {
27813
+ let result = null;
27814
+ if (this.supportsWebGL() && (this.gl || this.initWebGL(canvas) || (void 0), this.gl)) {
27815
+ if (result = this.applyWebGLEffect(canvas), result) return result;
27816
+ }
27817
+ if (this.supportsCanvas2D()) {
27818
+ if (result = this.applyCanvas2DEffect(canvas), result) return result;
27819
+ }
27820
+ return this.supportsWebGL() || this.supportsCanvas2D() || (void 0), canvas;
27821
+ }
27822
+ }
27823
+
27824
+ class Canvas2DEffectBase extends DisappearAnimateBase {
27825
+ constructor(from, to, duration, easing, params) {
27826
+ super(from, to, duration, easing, params);
27827
+ }
27828
+ getShaderSources() {
27829
+ return null;
27830
+ }
27831
+ applyWebGLEffect(canvas) {
27832
+ return null;
27833
+ }
27834
+ }
27835
+ class HybridEffectBase extends DisappearAnimateBase {
27836
+ constructor(from, to, duration, easing, params) {
27837
+ super(from, to, duration, easing, params);
27838
+ }
27839
+ getShaderSources() {
27840
+ return null;
27841
+ }
27842
+ applyWebGLEffect(canvas) {
27843
+ return null;
27844
+ }
27845
+ applyCanvas2DEffect(canvas) {
27846
+ return null;
27847
+ }
27848
+ supportsWebGL() {
27849
+ return this.getShaderSources !== HybridEffectBase.prototype.getShaderSources && null !== this.getShaderSources();
27850
+ }
27851
+ supportsCanvas2D() {
27852
+ return this.applyCanvas2DEffect !== HybridEffectBase.prototype.applyCanvas2DEffect;
27853
+ }
27854
+ afterStageRender(stage, canvas) {
27855
+ var _a, _b;
27856
+ let result = null;
27857
+ if (!1 !== (null === (_b = null === (_a = this.params) || void 0 === _a ? void 0 : _a.options) || void 0 === _b ? void 0 : _b.useWebGL)) {
27858
+ if (this.supportsWebGL() && (this.gl || this.initWebGL(canvas) || (void 0), this.gl)) {
27859
+ if (result = this.applyWebGLEffect(canvas), result) return result;
27860
+ }
27861
+ if (this.supportsCanvas2D()) {
27862
+ if (result = this.applyCanvas2DEffect(canvas), result) return result;
27863
+ }
27864
+ } else if (this.supportsCanvas2D()) {
27865
+ if (result = this.applyCanvas2DEffect(canvas), result) return result;
27866
+ } else ;
27867
+ return this.supportsWebGL() || this.supportsCanvas2D() || (void 0), canvas;
27868
+ }
27869
+ }
27870
+
27871
+ class ImageProcessUtils {
27872
+ static createTempCanvas(width, height, dpr) {
27873
+ return vglobal.createCanvas({
27874
+ width: width,
27875
+ height: height,
27876
+ dpr: dpr || vglobal.devicePixelRatio
27877
+ });
27878
+ }
27879
+ static cloneImageData(imageData) {
27880
+ const clonedData = new Uint8ClampedArray(imageData.data);
27881
+ return new ImageData(clonedData, imageData.width, imageData.height);
27882
+ }
27883
+ static lerp(start, end, t) {
27884
+ return start * (1 - t) + end * t;
27885
+ }
27886
+ static smoothstep(edge0, edge1, x) {
27887
+ const t = Math.max(0, Math.min(1, (x - edge0) / (edge1 - edge0)));
27888
+ return t * t * (3 - 2 * t);
27889
+ }
27890
+ static distance(x1, y1, x2, y2) {
27891
+ const dx = x2 - x1,
27892
+ dy = y2 - y1;
27893
+ return Math.sqrt(dx * dx + dy * dy);
27894
+ }
27895
+ static normalizeAngle(angle) {
27896
+ return (angle + Math.PI) / (2 * Math.PI);
27897
+ }
27898
+ static pixelNoise(x, y, pixelSize) {
27899
+ if (pixelSize <= 0) return 0;
27900
+ const gridX = Math.floor(x / pixelSize) * pixelSize,
27901
+ gridY = Math.floor(y / pixelSize) * pixelSize,
27902
+ n = 43758.5453 * Math.sin(12.9898 * gridX + 78.233 * gridY);
27903
+ return n - Math.floor(n);
27904
+ }
27905
+ static generateNoiseTexture(width, height) {
27906
+ const data = new Uint8Array(width * height);
27907
+ for (let i = 0; i < data.length; i++) data[i] = Math.floor(256 * Math.random());
27908
+ return data;
27909
+ }
27910
+ static applyCSSFilter(canvas, filter) {
27911
+ const outputCanvas = this.createTempCanvas(canvas.width, canvas.height),
27912
+ ctx = outputCanvas.getContext("2d");
27913
+ return ctx ? (ctx.filter = filter, ctx.drawImage(canvas, 0, 0), ctx.filter = "none", outputCanvas) : canvas;
27914
+ }
27915
+ static extractChannel(imageData, channelIndex) {
27916
+ const {
27917
+ data: data,
27918
+ width: width,
27919
+ height: height
27920
+ } = imageData,
27921
+ channelData = new Uint8ClampedArray(data.length);
27922
+ for (let i = 0; i < data.length; i += 4) channelData[i] = 0, channelData[i + 1] = 0, channelData[i + 2] = 0, channelData[i + 3] = data[i + 3], channelIndex >= 0 && channelIndex <= 2 && (channelData[i + channelIndex] = data[i + channelIndex]);
27923
+ return new ImageData(channelData, width, height);
27924
+ }
27925
+ static blendImageData(imageData1, imageData2, ratio) {
27926
+ const {
27927
+ data: data1,
27928
+ width: width,
27929
+ height: height
27930
+ } = imageData1,
27931
+ {
27932
+ data: data2
27933
+ } = imageData2,
27934
+ result = new Uint8ClampedArray(data1.length);
27935
+ for (let i = 0; i < data1.length; i += 4) result[i] = Math.round(this.lerp(data1[i], data2[i], ratio)), result[i + 1] = Math.round(this.lerp(data1[i + 1], data2[i + 1], ratio)), result[i + 2] = Math.round(this.lerp(data1[i + 2], data2[i + 2], ratio)), result[i + 3] = Math.round(this.lerp(data1[i + 3], data2[i + 3], ratio));
27936
+ return new ImageData(result, width, height);
27937
+ }
27938
+ static getLuminance(r, g, b) {
27939
+ return .299 * r + .587 * g + .114 * b;
27940
+ }
27941
+ static applySepiaToPixel(r, g, b) {
27942
+ return [Math.min(255, .393 * r + .769 * g + .189 * b), Math.min(255, .349 * r + .686 * g + .168 * b), Math.min(255, .272 * r + .534 * g + .131 * b)];
27943
+ }
27944
+ static calculateDynamicStrength(baseStrength, animationTime) {
27945
+ return baseStrength * (animationTime / (2 * Math.PI));
27946
+ }
27947
+ }
27948
+ class ShaderLibrary {}
27949
+ ShaderLibrary.STANDARD_VERTEX_SHADER = "\n attribute vec2 a_position;\n attribute vec2 a_texCoord;\n varying vec2 v_texCoord;\n\n void main() {\n gl_Position = vec4(a_position, 0.0, 1.0);\n v_texCoord = a_texCoord;\n }\n ", ShaderLibrary.SHADER_FUNCTIONS = "\n // 亮度计算函数\n float luminance(vec3 color) {\n return dot(color, vec3(0.299, 0.587, 0.114));\n }\n\n // 褐色调函数\n vec3 sepia(vec3 color) {\n float r = color.r * 0.393 + color.g * 0.769 + color.b * 0.189;\n float g = color.r * 0.349 + color.g * 0.686 + color.b * 0.168;\n float b = color.r * 0.272 + color.g * 0.534 + color.b * 0.131;\n return vec3(r, g, b);\n }\n\n // 线性插值函数\n float lerp(float a, float b, float t) {\n return a * (1.0 - t) + b * t;\n }\n\n\n // 简单噪声函数\n float pixelNoise(vec2 coord, float pixelSize) {\n vec2 gridCoord = floor(coord / pixelSize) * pixelSize;\n return fract(sin(dot(gridCoord, vec2(12.9898, 78.233))) * 43758.5453123);\n }\n\n // 动态强度计算\n float calculateDynamicStrength(float baseStrength, float time) {\n return baseStrength * (time / 6.28318531); // 2π\n }\n ";
27950
+
27951
+ class Dissolve extends HybridEffectBase {
27952
+ constructor(from, to, duration, easing, params) {
27953
+ var _a, _b, _c, _d;
27954
+ super(from, to, duration, easing, params), this.noiseData = null;
27955
+ const rawNoiseScale = null === (_a = null == params ? void 0 : params.options) || void 0 === _a ? void 0 : _a.noiseScale,
27956
+ clampedNoiseScale = void 0 !== rawNoiseScale ? Math.max(0, Math.floor(rawNoiseScale)) : 8;
27957
+ this.dissolveConfig = {
27958
+ dissolveType: (null === (_b = null == params ? void 0 : params.options) || void 0 === _b ? void 0 : _b.dissolveType) || "outward",
27959
+ useWebGL: void 0 === (null === (_c = null == params ? void 0 : params.options) || void 0 === _c ? void 0 : _c.useWebGL) || params.options.useWebGL,
27960
+ noiseScale: clampedNoiseScale,
27961
+ fadeEdge: void 0 === (null === (_d = null == params ? void 0 : params.options) || void 0 === _d ? void 0 : _d.fadeEdge) || params.options.fadeEdge
27962
+ };
27963
+ }
27964
+ getShaderSources() {
27965
+ return {
27966
+ vertex: ShaderLibrary.STANDARD_VERTEX_SHADER,
27967
+ fragment: `\n precision mediump float;\n uniform sampler2D u_texture;\n uniform sampler2D u_noiseTexture;\n uniform float u_time;\n uniform int u_dissolveType;\n uniform vec2 u_resolution;\n uniform float u_noiseScale;\n uniform bool u_fadeEdge;\n varying vec2 v_texCoord;\n\n ${ShaderLibrary.SHADER_FUNCTIONS}\n\n // 向外溶解函数\n float outwardDissolve(vec2 uv, float time, float pixelSize, vec2 resolution) {\n vec2 center = vec2(0.5, 0.5);\n float distFromCenter = length(uv - center);\n float maxDist = length(vec2(0.5, 0.5));\n\n // 归一化距离 (0为中心,1为边缘)\n float normalizedDist = distFromCenter / maxDist;\n\n // 向外溶解:从边缘开始溶解,time控制溶解进度\n // 增加安全边距,确保动画结束时完全溶解\n float edgeThreshold = 1.2 - time * 1.5;\n\n // 当pixelSize > 0时添加颗粒效果\n if (pixelSize > 0.0) {\n // 添加基于像素大小的噪声,让边缘呈现颗粒状\n vec2 pixelCoord = uv * resolution; // 转换为像素坐标\n float noiseValue = pixelNoise(pixelCoord, pixelSize);\n float noiseInfluence = (noiseValue - 0.5) * 0.4; // 增强噪声影响\n edgeThreshold += noiseInfluence;\n return normalizedDist > edgeThreshold ? 0.0 : 1.0;\n } else {\n // 平滑溶解:根据fadeEdge决定是否使用渐变\n if (u_fadeEdge) {\n // 柔和边缘:返回渐变值\n float fadeWidth = 0.15; // 渐变宽度\n return 1.0 - smoothstep(edgeThreshold - fadeWidth, edgeThreshold, normalizedDist);\n } else {\n // 硬边缘:返回0或1\n return normalizedDist > edgeThreshold ? 0.0 : 1.0;\n }\n }\n }\n\n // 向内溶解函数\n float inwardDissolve(vec2 uv, float time, float pixelSize, vec2 resolution) {\n vec2 center = vec2(0.5, 0.5);\n float distFromCenter = length(uv - center);\n float maxDist = length(vec2(0.5, 0.5));\n\n float normalizedDist = distFromCenter / maxDist;\n\n // 向内溶解:从中心开始溶解,time控制溶解进度\n // 增加系数,确保动画结束时完全溶解\n float centerThreshold = time * 1.4;\n\n // 当pixelSize > 0时添加颗粒效果\n if (pixelSize > 0.0) {\n vec2 pixelCoord = uv * resolution;\n float noiseValue = pixelNoise(pixelCoord, pixelSize);\n float noiseInfluence = (noiseValue - 0.5) * 0.4;\n centerThreshold += noiseInfluence;\n return normalizedDist < centerThreshold ? 0.0 : 1.0;\n } else {\n // 平滑溶解:根据fadeEdge决定是否使用渐变\n if (u_fadeEdge) {\n // 柔和边缘:返回渐变值\n float fadeWidth = 0.15; // 渐变宽度\n return smoothstep(centerThreshold, centerThreshold + fadeWidth, normalizedDist);\n } else {\n // 硬边缘:返回0或1\n return normalizedDist < centerThreshold ? 0.0 : 1.0;\n }\n }\n }\n\n // 径向溶解函数\n float radialDissolve(vec2 uv, float time, float pixelSize, vec2 resolution) {\n vec2 center = vec2(0.5, 0.5);\n float angle = atan(uv.y - center.y, uv.x - center.x);\n float normalizedAngle = (angle + 3.14159) / (2.0 * 3.14159);\n\n // 径向溶解:按角度顺序溶解,time控制溶解进度\n // 增加系数,确保动画结束时完全溶解\n float angleThreshold = time * 1.2;\n\n // 当pixelSize > 0时添加颗粒效果\n if (pixelSize > 0.0) {\n vec2 pixelCoord = uv * resolution;\n float noiseValue = pixelNoise(pixelCoord, pixelSize);\n float noiseInfluence = (noiseValue - 0.5) * 0.3;\n angleThreshold += noiseInfluence;\n return normalizedAngle < angleThreshold ? 0.0 : 1.0;\n } else {\n // 平滑溶解:根据fadeEdge决定是否使用渐变\n if (u_fadeEdge) {\n // 柔和边缘:返回渐变值\n float fadeWidth = 0.08; // 渐变宽度\n return smoothstep(angleThreshold, angleThreshold + fadeWidth, normalizedAngle);\n } else {\n // 硬边缘:返回0或1\n return normalizedAngle < angleThreshold ? 0.0 : 1.0;\n }\n }\n }\n\n // 从左到右溶解函数\n float leftToRightDissolve(vec2 uv, float time, float pixelSize, vec2 resolution) {\n // 左到右溶解:从x=0开始向x=1溶解\n float dissolvePosition = time * 1.2; // 增加系数确保完全溶解\n\n // 当pixelSize > 0时添加颗粒效果\n if (pixelSize > 0.0) {\n vec2 pixelCoord = uv * resolution;\n float noiseValue = pixelNoise(pixelCoord, pixelSize);\n float noiseInfluence = (noiseValue - 0.5) * 0.3;\n dissolvePosition += noiseInfluence;\n return uv.x < dissolvePosition ? 0.0 : 1.0;\n } else {\n // 平滑溶解:根据fadeEdge决定是否使用渐变\n if (u_fadeEdge) {\n // 柔和边缘:返回渐变值\n float fadeWidth = 0.08; // 渐变宽度\n return smoothstep(dissolvePosition, dissolvePosition + fadeWidth, uv.x);\n } else {\n // 硬边缘:返回0或1\n return uv.x < dissolvePosition ? 0.0 : 1.0;\n }\n }\n }\n\n // 从右到左溶解函数\n float rightToLeftDissolve(vec2 uv, float time, float pixelSize, vec2 resolution) {\n // 右到左溶解:从x=1开始向x=0溶解\n float dissolvePosition = 1.0 - time * 1.2; // 增加系数确保完全溶解\n\n // 当pixelSize > 0时添加颗粒效果\n if (pixelSize > 0.0) {\n vec2 pixelCoord = uv * resolution;\n float noiseValue = pixelNoise(pixelCoord, pixelSize);\n float noiseInfluence = (noiseValue - 0.5) * 0.3;\n dissolvePosition += noiseInfluence;\n return uv.x > dissolvePosition ? 0.0 : 1.0;\n } else {\n // 平滑溶解:根据fadeEdge决定是否使用渐变\n if (u_fadeEdge) {\n // 柔和边缘:返回渐变值\n float fadeWidth = 0.08; // 渐变宽度\n return smoothstep(dissolvePosition - fadeWidth, dissolvePosition, uv.x);\n } else {\n // 硬边缘:返回0或1\n return uv.x > dissolvePosition ? 0.0 : 1.0;\n }\n }\n }\n\n // 从上到下溶解函数\n float topToBottomDissolve(vec2 uv, float time, float pixelSize, vec2 resolution) {\n // 上到下溶解:从y=0开始向y=1溶解\n float dissolvePosition = time * 1.2; // 增加系数确保完全溶解\n\n // 当pixelSize > 0时添加颗粒效果\n if (pixelSize > 0.0) {\n vec2 pixelCoord = uv * resolution;\n float noiseValue = pixelNoise(pixelCoord, pixelSize);\n float noiseInfluence = (noiseValue - 0.5) * 0.3;\n dissolvePosition += noiseInfluence;\n return uv.y < dissolvePosition ? 0.0 : 1.0;\n } else {\n // 平滑溶解:根据fadeEdge决定是否使用渐变\n if (u_fadeEdge) {\n // 柔和边缘:返回渐变值\n float fadeWidth = 0.08; // 渐变宽度\n return smoothstep(dissolvePosition, dissolvePosition + fadeWidth, uv.y);\n } else {\n // 硬边缘:返回0或1\n return uv.y < dissolvePosition ? 0.0 : 1.0;\n }\n }\n }\n\n // 从下到上溶解函数\n float bottomToTopDissolve(vec2 uv, float time, float pixelSize, vec2 resolution) {\n // 下到上溶解:从y=1开始向y=0溶解\n float dissolvePosition = 1.0 - time * 1.2; // 增加系数确保完全溶解\n\n // 当pixelSize > 0时添加颗粒效果\n if (pixelSize > 0.0) {\n vec2 pixelCoord = uv * resolution;\n float noiseValue = pixelNoise(pixelCoord, pixelSize);\n float noiseInfluence = (noiseValue - 0.5) * 0.3;\n dissolvePosition += noiseInfluence;\n return uv.y > dissolvePosition ? 0.0 : 1.0;\n } else {\n // 平滑溶解:根据fadeEdge决定是否使用渐变\n if (u_fadeEdge) {\n // 柔和边缘:返回渐变值\n float fadeWidth = 0.08; // 渐变宽度\n return smoothstep(dissolvePosition - fadeWidth, dissolvePosition, uv.y);\n } else {\n // 硬边缘:返回0或1\n return uv.y > dissolvePosition ? 0.0 : 1.0;\n }\n }\n }\n\n void main() {\n vec2 uv = v_texCoord;\n vec4 texColor = texture2D(u_texture, uv);\n\n float alpha = 1.0;\n\n // 根据溶解类型选择对应的溶解函数\n if (u_dissolveType == 0) {\n alpha = outwardDissolve(uv, u_time, u_noiseScale, u_resolution);\n } else if (u_dissolveType == 1) {\n alpha = inwardDissolve(uv, u_time, u_noiseScale, u_resolution);\n } else if (u_dissolveType == 2) {\n alpha = radialDissolve(uv, u_time, u_noiseScale, u_resolution);\n } else if (u_dissolveType == 3) {\n alpha = leftToRightDissolve(uv, u_time, u_noiseScale, u_resolution);\n } else if (u_dissolveType == 4) {\n alpha = rightToLeftDissolve(uv, u_time, u_noiseScale, u_resolution);\n } else if (u_dissolveType == 5) {\n alpha = topToBottomDissolve(uv, u_time, u_noiseScale, u_resolution);\n } else if (u_dissolveType == 6) {\n alpha = bottomToTopDissolve(uv, u_time, u_noiseScale, u_resolution);\n }\n\n gl_FragColor = vec4(texColor.rgb, texColor.a * alpha);\n }\n `
27968
+ };
27969
+ }
27970
+ applyWebGLEffect(canvas) {
27971
+ if (!this.gl || !this.program || !this.webglCanvas) return canvas;
27972
+ this.setupWebGLState(canvas);
27973
+ const texture = this.createTextureFromCanvas(canvas);
27974
+ if (!texture) return canvas;
27975
+ this.noiseData || (this.noiseData = ImageProcessUtils.generateNoiseTexture(256, 256));
27976
+ const noiseTexture = this.gl.createTexture();
27977
+ this.gl.activeTexture(this.gl.TEXTURE1), this.gl.bindTexture(this.gl.TEXTURE_2D, noiseTexture), this.gl.texImage2D(this.gl.TEXTURE_2D, 0, this.gl.LUMINANCE, 256, 256, 0, this.gl.LUMINANCE, this.gl.UNSIGNED_BYTE, this.noiseData), this.gl.texParameteri(this.gl.TEXTURE_2D, this.gl.TEXTURE_WRAP_S, this.gl.REPEAT), this.gl.texParameteri(this.gl.TEXTURE_2D, this.gl.TEXTURE_WRAP_T, this.gl.REPEAT), this.gl.texParameteri(this.gl.TEXTURE_2D, this.gl.TEXTURE_MIN_FILTER, this.gl.LINEAR), this.gl.texParameteri(this.gl.TEXTURE_2D, this.gl.TEXTURE_MAG_FILTER, this.gl.LINEAR);
27978
+ const vertexBuffer = this.createFullScreenQuad();
27979
+ return vertexBuffer ? (this.gl.useProgram(this.program), this.setupVertexAttributes(), this.setUniforms(), this.gl.enable(this.gl.BLEND), this.gl.blendFunc(this.gl.SRC_ALPHA, this.gl.ONE_MINUS_SRC_ALPHA), this.gl.drawArrays(this.gl.TRIANGLE_STRIP, 0, 4), this.gl.deleteTexture(texture), this.gl.deleteTexture(noiseTexture), this.gl.deleteBuffer(vertexBuffer), this.webglCanvas) : canvas;
27980
+ }
27981
+ setUniforms() {
27982
+ if (!this.gl || !this.program || !this.webglCanvas) return;
27983
+ const textureLocation = this.gl.getUniformLocation(this.program, "u_texture"),
27984
+ noiseTextureLocation = this.gl.getUniformLocation(this.program, "u_noiseTexture"),
27985
+ timeLocation = this.gl.getUniformLocation(this.program, "u_time"),
27986
+ dissolveTypeLocation = this.gl.getUniformLocation(this.program, "u_dissolveType"),
27987
+ resolutionLocation = this.gl.getUniformLocation(this.program, "u_resolution"),
27988
+ noiseScaleLocation = this.gl.getUniformLocation(this.program, "u_noiseScale"),
27989
+ fadeEdgeLocation = this.gl.getUniformLocation(this.program, "u_fadeEdge");
27990
+ this.gl.uniform1i(textureLocation, 0), this.gl.uniform1i(noiseTextureLocation, 1), this.gl.uniform1f(timeLocation, this.currentAnimationRatio), this.gl.uniform2f(resolutionLocation, this.webglCanvas.width, this.webglCanvas.height), this.gl.uniform1f(noiseScaleLocation, this.dissolveConfig.noiseScale), this.gl.uniform1i(fadeEdgeLocation, this.dissolveConfig.fadeEdge ? 1 : 0);
27991
+ this.gl.uniform1i(dissolveTypeLocation, {
27992
+ outward: 0,
27993
+ inward: 1,
27994
+ radial: 2,
27995
+ leftToRight: 3,
27996
+ rightToLeft: 4,
27997
+ topToBottom: 5,
27998
+ bottomToTop: 6
27999
+ }[this.dissolveConfig.dissolveType] || 0);
28000
+ }
28001
+ applyCanvas2DEffect(canvas) {
28002
+ const outputCanvas = this.createOutputCanvas(canvas);
28003
+ if (!outputCanvas) return canvas;
28004
+ const {
28005
+ canvas: outputCanvasElement,
28006
+ ctx: ctx
28007
+ } = outputCanvas,
28008
+ imageData = ctx.getImageData(0, 0, canvas.width, canvas.height),
28009
+ progress = this.currentAnimationRatio;
28010
+ let dissolvedImageData;
28011
+ switch (this.dissolveConfig.dissolveType) {
28012
+ case "outward":
28013
+ dissolvedImageData = this.applyOutwardDissolve(imageData, progress);
28014
+ break;
28015
+ case "inward":
28016
+ dissolvedImageData = this.applyInwardDissolve(imageData, progress);
28017
+ break;
28018
+ case "radial":
28019
+ dissolvedImageData = this.applyRadialDissolve(imageData, progress);
28020
+ break;
28021
+ case "leftToRight":
28022
+ dissolvedImageData = this.applyLeftToRightDissolve(imageData, progress);
28023
+ break;
28024
+ case "rightToLeft":
28025
+ dissolvedImageData = this.applyRightToLeftDissolve(imageData, progress);
28026
+ break;
28027
+ case "topToBottom":
28028
+ dissolvedImageData = this.applyTopToBottomDissolve(imageData, progress);
28029
+ break;
28030
+ case "bottomToTop":
28031
+ dissolvedImageData = this.applyBottomToTopDissolve(imageData, progress);
28032
+ break;
28033
+ default:
28034
+ dissolvedImageData = imageData;
28035
+ }
28036
+ return ctx.putImageData(dissolvedImageData, 0, 0), outputCanvasElement;
28037
+ }
28038
+ applyOutwardDissolve(imageData, progress) {
28039
+ const {
28040
+ data: data,
28041
+ width: width,
28042
+ height: height
28043
+ } = imageData,
28044
+ result = new Uint8ClampedArray(data.length);
28045
+ result.set(data);
28046
+ const centerX = width / 2,
28047
+ centerY = height / 2,
28048
+ maxDist = Math.sqrt(centerX * centerX + centerY * centerY),
28049
+ pixelSize = this.dissolveConfig.noiseScale;
28050
+ for (let y = 0; y < height; y++) for (let x = 0; x < width; x++) {
28051
+ const dx = x - centerX,
28052
+ dy = y - centerY,
28053
+ normalizedDist = Math.sqrt(dx * dx + dy * dy) / maxDist;
28054
+ let dissolveThreshold = 1.2 - 1.4 * progress,
28055
+ alpha = 1;
28056
+ if (pixelSize > 0) {
28057
+ dissolveThreshold += .4 * (ImageProcessUtils.pixelNoise(x, y, pixelSize) - .5), alpha = normalizedDist > dissolveThreshold ? 0 : 1;
28058
+ } else if (this.dissolveConfig.fadeEdge) {
28059
+ const fadeStart = dissolveThreshold - .15;
28060
+ alpha = normalizedDist < fadeStart ? 1 : normalizedDist > dissolveThreshold ? 0 : 1 - (normalizedDist - fadeStart) / (dissolveThreshold - fadeStart);
28061
+ } else alpha = normalizedDist > dissolveThreshold ? 0 : 1;
28062
+ const index = 4 * (y * width + x);
28063
+ result[index + 3] = Math.floor(result[index + 3] * alpha);
28064
+ }
28065
+ return new ImageData(result, width, height);
28066
+ }
28067
+ applyInwardDissolve(imageData, progress) {
28068
+ const {
28069
+ data: data,
28070
+ width: width,
28071
+ height: height
28072
+ } = imageData,
28073
+ result = new Uint8ClampedArray(data.length);
28074
+ result.set(data);
28075
+ const centerX = width / 2,
28076
+ centerY = height / 2,
28077
+ maxDist = Math.sqrt(centerX * centerX + centerY * centerY),
28078
+ pixelSize = this.dissolveConfig.noiseScale;
28079
+ for (let y = 0; y < height; y++) for (let x = 0; x < width; x++) {
28080
+ const dx = x - centerX,
28081
+ dy = y - centerY,
28082
+ normalizedDist = Math.sqrt(dx * dx + dy * dy) / maxDist;
28083
+ let dissolveThreshold = 1.4 * progress,
28084
+ alpha = 1;
28085
+ if (pixelSize > 0) {
28086
+ dissolveThreshold += .4 * (ImageProcessUtils.pixelNoise(x, y, pixelSize) - .5), alpha = normalizedDist < dissolveThreshold ? 0 : 1;
28087
+ } else if (this.dissolveConfig.fadeEdge) {
28088
+ const fadeEnd = dissolveThreshold + .15;
28089
+ alpha = normalizedDist < dissolveThreshold ? 0 : normalizedDist > fadeEnd ? 1 : (normalizedDist - dissolveThreshold) / (fadeEnd - dissolveThreshold);
28090
+ } else alpha = normalizedDist < dissolveThreshold ? 0 : 1;
28091
+ const index = 4 * (y * width + x);
28092
+ result[index + 3] = Math.floor(result[index + 3] * alpha);
28093
+ }
28094
+ return new ImageData(result, width, height);
28095
+ }
28096
+ applyRadialDissolve(imageData, progress) {
28097
+ const {
28098
+ data: data,
28099
+ width: width,
28100
+ height: height
28101
+ } = imageData,
28102
+ result = new Uint8ClampedArray(data.length);
28103
+ result.set(data);
28104
+ const centerX = width / 2,
28105
+ centerY = height / 2,
28106
+ pixelSize = this.dissolveConfig.noiseScale;
28107
+ for (let y = 0; y < height; y++) for (let x = 0; x < width; x++) {
28108
+ const dx = x - centerX,
28109
+ dy = y - centerY,
28110
+ normalizedAngle = (Math.atan2(dy, dx) + Math.PI) / (2 * Math.PI);
28111
+ let dissolveThreshold = 1.2 * progress,
28112
+ alpha = 1;
28113
+ if (pixelSize > 0) {
28114
+ dissolveThreshold += .3 * (ImageProcessUtils.pixelNoise(x, y, pixelSize) - .5), alpha = normalizedAngle < dissolveThreshold ? 0 : 1;
28115
+ } else if (this.dissolveConfig.fadeEdge) {
28116
+ const fadeEnd = dissolveThreshold + .08;
28117
+ alpha = normalizedAngle < dissolveThreshold ? 0 : normalizedAngle > fadeEnd ? 1 : (normalizedAngle - dissolveThreshold) / (fadeEnd - dissolveThreshold);
28118
+ } else alpha = normalizedAngle < dissolveThreshold ? 0 : 1;
28119
+ const index = 4 * (y * width + x);
28120
+ result[index + 3] = Math.floor(result[index + 3] * alpha);
28121
+ }
28122
+ return new ImageData(result, width, height);
28123
+ }
28124
+ applyLeftToRightDissolve(imageData, progress) {
28125
+ const {
28126
+ data: data,
28127
+ width: width,
28128
+ height: height
28129
+ } = imageData,
28130
+ result = new Uint8ClampedArray(data.length);
28131
+ result.set(data);
28132
+ const pixelSize = this.dissolveConfig.noiseScale;
28133
+ for (let y = 0; y < height; y++) for (let x = 0; x < width; x++) {
28134
+ const normalizedX = x / width;
28135
+ let dissolveThreshold = 1.2 * progress,
28136
+ alpha = 1;
28137
+ if (pixelSize > 0) {
28138
+ dissolveThreshold += .3 * (ImageProcessUtils.pixelNoise(x, y, pixelSize) - .5), alpha = normalizedX < dissolveThreshold ? 0 : 1;
28139
+ } else if (this.dissolveConfig.fadeEdge) {
28140
+ const fadeEnd = dissolveThreshold + .08;
28141
+ alpha = normalizedX < dissolveThreshold ? 0 : normalizedX > fadeEnd ? 1 : (normalizedX - dissolveThreshold) / (fadeEnd - dissolveThreshold);
28142
+ } else alpha = normalizedX < dissolveThreshold ? 0 : 1;
28143
+ const index = 4 * (y * width + x);
28144
+ result[index + 3] = Math.floor(result[index + 3] * alpha);
28145
+ }
28146
+ return new ImageData(result, width, height);
28147
+ }
28148
+ applyRightToLeftDissolve(imageData, progress) {
28149
+ const {
28150
+ data: data,
28151
+ width: width,
28152
+ height: height
28153
+ } = imageData,
28154
+ result = new Uint8ClampedArray(data.length);
28155
+ result.set(data);
28156
+ const pixelSize = this.dissolveConfig.noiseScale;
28157
+ for (let y = 0; y < height; y++) for (let x = 0; x < width; x++) {
28158
+ const normalizedX = x / width;
28159
+ let dissolveThreshold = 1 - 1.2 * progress,
28160
+ alpha = 1;
28161
+ if (pixelSize > 0) {
28162
+ dissolveThreshold += .3 * (ImageProcessUtils.pixelNoise(x, y, pixelSize) - .5), alpha = normalizedX > dissolveThreshold ? 0 : 1;
28163
+ } else if (this.dissolveConfig.fadeEdge) {
28164
+ const fadeStart = dissolveThreshold - .08;
28165
+ alpha = normalizedX < fadeStart ? 1 : normalizedX > dissolveThreshold ? 0 : 1 - (normalizedX - fadeStart) / (dissolveThreshold - fadeStart);
28166
+ } else alpha = normalizedX > dissolveThreshold ? 0 : 1;
28167
+ const index = 4 * (y * width + x);
28168
+ result[index + 3] = Math.floor(result[index + 3] * alpha);
28169
+ }
28170
+ return new ImageData(result, width, height);
28171
+ }
28172
+ applyTopToBottomDissolve(imageData, progress) {
28173
+ const {
28174
+ data: data,
28175
+ width: width,
28176
+ height: height
28177
+ } = imageData,
28178
+ result = new Uint8ClampedArray(data.length);
28179
+ result.set(data);
28180
+ const pixelSize = this.dissolveConfig.noiseScale;
28181
+ for (let y = 0; y < height; y++) for (let x = 0; x < width; x++) {
28182
+ const normalizedY = y / height;
28183
+ let dissolveThreshold = 1.2 * progress,
28184
+ alpha = 1;
28185
+ if (pixelSize > 0) {
28186
+ dissolveThreshold += .3 * (ImageProcessUtils.pixelNoise(x, y, pixelSize) - .5), alpha = normalizedY < dissolveThreshold ? 0 : 1;
28187
+ } else if (this.dissolveConfig.fadeEdge) {
28188
+ const fadeEnd = dissolveThreshold + .08;
28189
+ alpha = normalizedY < dissolveThreshold ? 0 : normalizedY > fadeEnd ? 1 : (normalizedY - dissolveThreshold) / (fadeEnd - dissolveThreshold);
28190
+ } else alpha = normalizedY < dissolveThreshold ? 0 : 1;
28191
+ const index = 4 * (y * width + x);
28192
+ result[index + 3] = Math.floor(result[index + 3] * alpha);
28193
+ }
28194
+ return new ImageData(result, width, height);
28195
+ }
28196
+ applyBottomToTopDissolve(imageData, progress) {
28197
+ const {
28198
+ data: data,
28199
+ width: width,
28200
+ height: height
28201
+ } = imageData,
28202
+ result = new Uint8ClampedArray(data.length);
28203
+ result.set(data);
28204
+ const pixelSize = this.dissolveConfig.noiseScale;
28205
+ for (let y = 0; y < height; y++) for (let x = 0; x < width; x++) {
28206
+ const normalizedY = y / height;
28207
+ let dissolveThreshold = 1 - 1.2 * progress,
28208
+ alpha = 1;
28209
+ if (pixelSize > 0) {
28210
+ dissolveThreshold += .3 * (ImageProcessUtils.pixelNoise(x, y, pixelSize) - .5), alpha = normalizedY > dissolveThreshold ? 0 : 1;
28211
+ } else if (this.dissolveConfig.fadeEdge) {
28212
+ const fadeStart = dissolveThreshold - .08;
28213
+ alpha = normalizedY < fadeStart ? 1 : normalizedY > dissolveThreshold ? 0 : 1 - (normalizedY - fadeStart) / (dissolveThreshold - fadeStart);
28214
+ } else alpha = normalizedY > dissolveThreshold ? 0 : 1;
28215
+ const index = 4 * (y * width + x);
28216
+ result[index + 3] = Math.floor(result[index + 3] * alpha);
28217
+ }
28218
+ return new ImageData(result, width, height);
28219
+ }
28220
+ }
28221
+
28222
+ class Grayscale extends HybridEffectBase {
28223
+ constructor(from, to, duration, easing, params) {
28224
+ var _a, _b, _c;
28225
+ super(from, to, duration, easing, params);
28226
+ const rawStrength = void 0 !== (null === (_a = null == params ? void 0 : params.options) || void 0 === _a ? void 0 : _a.strength) ? params.options.strength : 1,
28227
+ clampedStrength = Math.max(0, Math.min(1, rawStrength));
28228
+ this.colorConfig = {
28229
+ effectType: (null === (_b = null == params ? void 0 : params.options) || void 0 === _b ? void 0 : _b.effectType) || "grayscale",
28230
+ strength: clampedStrength,
28231
+ useWebGL: void 0 === (null === (_c = null == params ? void 0 : params.options) || void 0 === _c ? void 0 : _c.useWebGL) || params.options.useWebGL
28232
+ };
28233
+ }
28234
+ getShaderSources() {
28235
+ return {
28236
+ vertex: ShaderLibrary.STANDARD_VERTEX_SHADER,
28237
+ fragment: `\n precision mediump float;\n uniform sampler2D u_texture;\n uniform float u_time;\n uniform float u_strength;\n uniform int u_effectType;\n uniform vec2 u_resolution;\n varying vec2 v_texCoord;\n\n ${ShaderLibrary.SHADER_FUNCTIONS}\n\n void main() {\n vec2 uv = v_texCoord;\n vec4 originalColor = texture2D(u_texture, uv);\n vec3 color = originalColor.rgb;\n\n // 计算动态强度\n float dynamicStrength = calculateDynamicStrength(u_strength, u_time);\n\n if (u_effectType == 0) {\n // 灰度效果\n float gray = luminance(color);\n vec3 grayColor = vec3(gray);\n color = mix(color, grayColor, dynamicStrength);\n } else if (u_effectType == 1) {\n // 褐色调效果\n vec3 sepiaColor = sepia(color);\n color = mix(color, sepiaColor, dynamicStrength);\n }\n\n gl_FragColor = vec4(color, originalColor.a);\n }\n `
28238
+ };
28239
+ }
28240
+ applyWebGLEffect(canvas) {
28241
+ if (!this.gl || !this.program || !this.webglCanvas) return null;
28242
+ this.setupWebGLState(canvas);
28243
+ const texture = this.createTextureFromCanvas(canvas);
28244
+ if (!texture) return null;
28245
+ const vertexBuffer = this.createFullScreenQuad();
28246
+ if (!vertexBuffer) return this.gl.deleteTexture(texture), null;
28247
+ try {
28248
+ return this.gl.useProgram(this.program), this.setupVertexAttributes(), this.setColorUniforms(), this.gl.drawArrays(this.gl.TRIANGLE_STRIP, 0, 4), this.webglCanvas;
28249
+ } finally {
28250
+ this.gl.deleteTexture(texture), this.gl.deleteBuffer(vertexBuffer);
28251
+ }
28252
+ }
28253
+ setColorUniforms() {
28254
+ if (!this.gl || !this.program) return;
28255
+ const currentTime = this.getAnimationTime(),
28256
+ timeLocation = this.gl.getUniformLocation(this.program, "u_time"),
28257
+ strengthLocation = this.gl.getUniformLocation(this.program, "u_strength"),
28258
+ effectTypeLocation = this.gl.getUniformLocation(this.program, "u_effectType"),
28259
+ resolutionLocation = this.gl.getUniformLocation(this.program, "u_resolution");
28260
+ this.gl.uniform1f(timeLocation, currentTime), this.gl.uniform1f(strengthLocation, this.colorConfig.strength), this.gl.uniform2f(resolutionLocation, this.webglCanvas.width, this.webglCanvas.height);
28261
+ this.gl.uniform1i(effectTypeLocation, {
28262
+ grayscale: 0,
28263
+ sepia: 1
28264
+ }[this.colorConfig.effectType] || 0);
28265
+ }
28266
+ applyCanvas2DEffect(canvas) {
28267
+ if (this.colorConfig.strength <= 0) {
28268
+ const outputCanvas = this.createOutputCanvas(canvas);
28269
+ return outputCanvas ? outputCanvas.canvas : null;
28270
+ }
28271
+ if (this.canUseCSSFilter()) return this.applyCSSFilter(canvas);
28272
+ const outputCanvas = this.createOutputCanvas(canvas);
28273
+ if (!outputCanvas) return null;
28274
+ const {
28275
+ ctx: ctx
28276
+ } = outputCanvas;
28277
+ try {
28278
+ const imageData = ctx.getImageData(0, 0, canvas.width, canvas.height),
28279
+ currentTime = this.getAnimationTime();
28280
+ let processedImageData;
28281
+ switch (this.colorConfig.effectType) {
28282
+ case "grayscale":
28283
+ default:
28284
+ processedImageData = this.applyGrayscaleEffect(imageData, this.colorConfig.strength, currentTime);
28285
+ break;
28286
+ case "sepia":
28287
+ processedImageData = this.applySepiaEffect(imageData, this.colorConfig.strength, currentTime);
28288
+ }
28289
+ return ctx.clearRect(0, 0, canvas.width, canvas.height), ctx.putImageData(processedImageData, 0, 0), outputCanvas.canvas;
28290
+ } catch (error) {
28291
+ return null;
28292
+ }
28293
+ }
28294
+ canUseCSSFilter() {
28295
+ var _a;
28296
+ return !!window.useFilterAPI && "undefined" != typeof CSS && (null === (_a = CSS.supports) || void 0 === _a ? void 0 : _a.call(CSS, "filter", "grayscale(1)"));
28297
+ }
28298
+ applyCSSFilter(canvas) {
28299
+ try {
28300
+ const outputCanvas = ImageProcessUtils.createTempCanvas(canvas.width, canvas.height),
28301
+ ctx = outputCanvas.getContext("2d");
28302
+ if (!ctx) return null;
28303
+ const currentTime = this.getAnimationTime(),
28304
+ dynamicStrength = ImageProcessUtils.calculateDynamicStrength(this.colorConfig.strength, currentTime);
28305
+ let filterValue = "";
28306
+ return "grayscale" === this.colorConfig.effectType ? filterValue = `grayscale(${Math.min(1, dynamicStrength)})` : "sepia" === this.colorConfig.effectType && (filterValue = `sepia(${Math.min(1, dynamicStrength)})`), ctx.filter = filterValue, ctx.drawImage(canvas, 0, 0), ctx.filter = "none", outputCanvas;
28307
+ } catch (error) {
28308
+ return null;
28309
+ }
28310
+ }
28311
+ applyGrayscaleEffect(imageData, strength, time) {
28312
+ const {
28313
+ data: data,
28314
+ width: width,
28315
+ height: height
28316
+ } = imageData,
28317
+ result = new Uint8ClampedArray(data.length),
28318
+ dynamicStrength = ImageProcessUtils.calculateDynamicStrength(strength, time);
28319
+ for (let i = 0; i < data.length; i += 4) {
28320
+ const r = data[i],
28321
+ g = data[i + 1],
28322
+ b = data[i + 2],
28323
+ a = data[i + 3],
28324
+ gray = ImageProcessUtils.getLuminance(r, g, b);
28325
+ result[i] = Math.round(ImageProcessUtils.lerp(r, gray, dynamicStrength)), result[i + 1] = Math.round(ImageProcessUtils.lerp(g, gray, dynamicStrength)), result[i + 2] = Math.round(ImageProcessUtils.lerp(b, gray, dynamicStrength)), result[i + 3] = a;
28326
+ }
28327
+ return new ImageData(result, width, height);
28328
+ }
28329
+ applySepiaEffect(imageData, strength, time) {
28330
+ const {
28331
+ data: data,
28332
+ width: width,
28333
+ height: height
28334
+ } = imageData,
28335
+ result = new Uint8ClampedArray(data.length),
28336
+ dynamicStrength = ImageProcessUtils.calculateDynamicStrength(strength, time);
28337
+ for (let i = 0; i < data.length; i += 4) {
28338
+ const r = data[i],
28339
+ g = data[i + 1],
28340
+ b = data[i + 2],
28341
+ a = data[i + 3],
28342
+ [sepiaR, sepiaG, sepiaB] = ImageProcessUtils.applySepiaToPixel(r, g, b);
28343
+ result[i] = Math.round(ImageProcessUtils.lerp(r, sepiaR, dynamicStrength)), result[i + 1] = Math.round(ImageProcessUtils.lerp(g, sepiaG, dynamicStrength)), result[i + 2] = Math.round(ImageProcessUtils.lerp(b, sepiaB, dynamicStrength)), result[i + 3] = a;
28344
+ }
28345
+ return new ImageData(result, width, height);
28346
+ }
28347
+ afterStageRender(stage, canvas) {
28348
+ if (this.canUseCSSFilter() && this.colorConfig.strength > 0) {
28349
+ const cssResult = this.applyCSSFilter(canvas);
28350
+ if (cssResult) return cssResult;
28351
+ }
28352
+ return super.afterStageRender(stage, canvas);
28353
+ }
28354
+ }
28355
+
28356
+ class Distortion extends HybridEffectBase {
28357
+ constructor(from, to, duration, easing, params) {
28358
+ var _a, _b, _c;
28359
+ super(from, to, duration, easing, params), this.distortionConfig = {
28360
+ distortionType: (null === (_a = null == params ? void 0 : params.options) || void 0 === _a ? void 0 : _a.distortionType) || "wave",
28361
+ strength: (null === (_b = null == params ? void 0 : params.options) || void 0 === _b ? void 0 : _b.strength) || .3,
28362
+ useWebGL: void 0 === (null === (_c = null == params ? void 0 : params.options) || void 0 === _c ? void 0 : _c.useWebGL) || params.options.useWebGL
28363
+ };
28364
+ }
28365
+ getShaderSources() {
28366
+ return {
28367
+ vertex: "\n attribute vec2 a_position;\n attribute vec2 a_texCoord;\n varying vec2 v_texCoord;\n\n void main() {\n gl_Position = vec4(a_position, 0.0, 1.0);\n v_texCoord = a_texCoord;\n }\n ",
28368
+ fragment: "\n precision mediump float;\n uniform sampler2D u_texture;\n uniform float u_time;\n uniform float u_strength;\n uniform int u_distortionType;\n uniform vec2 u_resolution;\n varying vec2 v_texCoord;\n\n // 波浪扭曲函数\n vec2 wave(vec2 uv, float time, float strength) {\n float waveX = sin(uv.y * 10.0 + time * 3.0) * strength * 0.1;\n float waveY = sin(uv.x * 10.0 + time * 2.0) * strength * 0.1;\n return uv + vec2(waveX, waveY);\n }\n\n // 涟漪扭曲函数\n vec2 ripple(vec2 uv, float time, float strength) {\n vec2 center = vec2(0.5, 0.5);\n float distance = length(uv - center);\n float ripple = sin(distance * 20.0 - time * 5.0) * strength * 0.1;\n vec2 direction = normalize(uv - center);\n return uv + direction * ripple;\n }\n\n // 漩涡扭曲函数\n vec2 swirl(vec2 uv, float time, float strength) {\n vec2 center = vec2(0.5, 0.5);\n vec2 delta = uv - center;\n float dist = length(delta);\n float originalAngle = atan(delta.y, delta.x);\n float rotationAngle = dist * strength * time * 2.0;\n float finalAngle = originalAngle + rotationAngle;\n return center + dist * vec2(cos(finalAngle), sin(finalAngle));\n }\n\n void main() {\n vec2 uv = v_texCoord;\n\n // 根据扭曲类型应用相应变换\n if (u_distortionType == 0) {\n uv = wave(uv, u_time, u_strength);\n } else if (u_distortionType == 1) {\n uv = ripple(uv, u_time, u_strength);\n } else if (u_distortionType == 2) {\n uv = swirl(uv, u_time, u_strength);\n }\n\n // 边界检查\n if (uv.x < 0.0 || uv.x > 1.0 || uv.y < 0.0 || uv.y > 1.0) {\n gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0);\n } else {\n gl_FragColor = texture2D(u_texture, uv);\n }\n }\n "
28369
+ };
28370
+ }
28371
+ applyWebGLEffect(canvas) {
28372
+ if (!this.gl || !this.program || !this.webglCanvas) return null;
28373
+ this.setupWebGLState(canvas);
28374
+ const texture = this.createTextureFromCanvas(canvas);
28375
+ if (!texture) return null;
28376
+ const vertexBuffer = this.createFullScreenQuad();
28377
+ if (!vertexBuffer) return this.gl.deleteTexture(texture), null;
28378
+ try {
28379
+ return this.gl.useProgram(this.program), this.setupVertexAttributes(), this.setDistortionUniforms(), this.gl.drawArrays(this.gl.TRIANGLE_STRIP, 0, 4), this.webglCanvas;
28380
+ } finally {
28381
+ this.gl.deleteTexture(texture), this.gl.deleteBuffer(vertexBuffer);
28382
+ }
28383
+ }
28384
+ setDistortionUniforms() {
28385
+ if (!this.gl || !this.program) return;
28386
+ const currentTime = this.getAnimationTime(),
28387
+ timeLocation = this.gl.getUniformLocation(this.program, "u_time"),
28388
+ strengthLocation = this.gl.getUniformLocation(this.program, "u_strength"),
28389
+ distortionTypeLocation = this.gl.getUniformLocation(this.program, "u_distortionType"),
28390
+ resolutionLocation = this.gl.getUniformLocation(this.program, "u_resolution");
28391
+ this.gl.uniform1f(timeLocation, currentTime), this.gl.uniform1f(strengthLocation, this.distortionConfig.strength), this.gl.uniform2f(resolutionLocation, this.webglCanvas.width, this.webglCanvas.height);
28392
+ this.gl.uniform1i(distortionTypeLocation, {
28393
+ wave: 0,
28394
+ ripple: 1,
28395
+ swirl: 2
28396
+ }[this.distortionConfig.distortionType] || 0);
28397
+ }
28398
+ applyCanvas2DEffect(canvas) {
28399
+ const outputCanvas = this.createOutputCanvas(canvas);
28400
+ if (!outputCanvas) return null;
28401
+ const {
28402
+ ctx: ctx
28403
+ } = outputCanvas;
28404
+ try {
28405
+ const imageData = ctx.getImageData(0, 0, canvas.width, canvas.height),
28406
+ currentTime = this.getAnimationTime();
28407
+ let distortedImageData;
28408
+ switch (this.distortionConfig.distortionType) {
28409
+ case "wave":
28410
+ distortedImageData = this.applyWaveDistortion(imageData, this.distortionConfig.strength, currentTime);
28411
+ break;
28412
+ case "ripple":
28413
+ distortedImageData = this.applyRippleDistortion(imageData, this.distortionConfig.strength, currentTime);
28414
+ break;
28415
+ case "swirl":
28416
+ distortedImageData = this.applySwirlDistortion(imageData, this.distortionConfig.strength, currentTime);
28417
+ break;
28418
+ default:
28419
+ distortedImageData = imageData;
28420
+ }
28421
+ return ctx.clearRect(0, 0, canvas.width, canvas.height), ctx.putImageData(distortedImageData, 0, 0), outputCanvas.canvas;
28422
+ } catch (error) {
28423
+ return null;
28424
+ }
28425
+ }
28426
+ applyWaveDistortion(imageData, strength, time) {
28427
+ const {
28428
+ data: data,
28429
+ width: width,
28430
+ height: height
28431
+ } = imageData,
28432
+ result = new Uint8ClampedArray(data.length);
28433
+ for (let y = 0; y < height; y++) for (let x = 0; x < width; x++) {
28434
+ const waveX = Math.sin(.1 * y + 3 * time) * strength * 20,
28435
+ waveY = Math.sin(.1 * x + 2 * time) * strength * 20,
28436
+ sourceX = Math.round(x - waveX),
28437
+ sourceY = Math.round(y - waveY),
28438
+ targetIndex = 4 * (y * width + x);
28439
+ if (sourceX >= 0 && sourceX < width && sourceY >= 0 && sourceY < height) {
28440
+ const sourceIndex = 4 * (sourceY * width + sourceX);
28441
+ result[targetIndex] = data[sourceIndex], result[targetIndex + 1] = data[sourceIndex + 1], result[targetIndex + 2] = data[sourceIndex + 2], result[targetIndex + 3] = data[sourceIndex + 3];
28442
+ } else result[targetIndex + 3] = 0;
28443
+ }
28444
+ return new ImageData(result, width, height);
28445
+ }
28446
+ applyRippleDistortion(imageData, strength, time) {
28447
+ const {
28448
+ data: data,
28449
+ width: width,
28450
+ height: height
28451
+ } = imageData,
28452
+ result = new Uint8ClampedArray(data.length),
28453
+ centerX = width / 2,
28454
+ centerY = height / 2;
28455
+ for (let y = 0; y < height; y++) for (let x = 0; x < width; x++) {
28456
+ const dx = x - centerX,
28457
+ dy = y - centerY,
28458
+ distance = Math.sqrt(dx * dx + dy * dy),
28459
+ ripple = Math.sin(.2 * distance - 5 * time) * strength * 10,
28460
+ angle = Math.atan2(dy, dx),
28461
+ sourceX = Math.round(x - Math.cos(angle) * ripple),
28462
+ sourceY = Math.round(y - Math.sin(angle) * ripple),
28463
+ targetIndex = 4 * (y * width + x);
28464
+ if (sourceX >= 0 && sourceX < width && sourceY >= 0 && sourceY < height) {
28465
+ const sourceIndex = 4 * (sourceY * width + sourceX);
28466
+ result[targetIndex] = data[sourceIndex], result[targetIndex + 1] = data[sourceIndex + 1], result[targetIndex + 2] = data[sourceIndex + 2], result[targetIndex + 3] = data[sourceIndex + 3];
28467
+ } else result[targetIndex + 3] = 0;
28468
+ }
28469
+ return new ImageData(result, width, height);
28470
+ }
28471
+ applySwirlDistortion(imageData, strength, time) {
28472
+ const {
28473
+ data: data,
28474
+ width: width,
28475
+ height: height
28476
+ } = imageData,
28477
+ result = new Uint8ClampedArray(data.length),
28478
+ centerX = width / 2,
28479
+ centerY = height / 2;
28480
+ for (let y = 0; y < height; y++) for (let x = 0; x < width; x++) {
28481
+ const dx = x - centerX,
28482
+ dy = y - centerY,
28483
+ distance = Math.sqrt(dx * dx + dy * dy),
28484
+ finalAngle = Math.atan2(dy, dx) + distance * strength * time * .02,
28485
+ sourceX = Math.round(centerX + distance * Math.cos(finalAngle)),
28486
+ sourceY = Math.round(centerY + distance * Math.sin(finalAngle)),
28487
+ targetIndex = 4 * (y * width + x);
28488
+ if (sourceX >= 0 && sourceX < width && sourceY >= 0 && sourceY < height) {
28489
+ const sourceIndex = 4 * (sourceY * width + sourceX);
28490
+ result[targetIndex] = data[sourceIndex], result[targetIndex + 1] = data[sourceIndex + 1], result[targetIndex + 2] = data[sourceIndex + 2], result[targetIndex + 3] = data[sourceIndex + 3];
28491
+ } else result[targetIndex + 3] = 0;
28492
+ }
28493
+ return new ImageData(result, width, height);
28494
+ }
28495
+ afterStageRender(stage, canvas) {
28496
+ return this.distortionConfig.strength <= 0 ? canvas : super.afterStageRender(stage, canvas);
28497
+ }
28498
+ }
28499
+
28500
+ class Particle extends HybridEffectBase {
28501
+ constructor(from, to, duration, easing, params) {
28502
+ var _a, _b, _c, _d, _e;
28503
+ super(from, to, duration, easing, params), this.particles = [], this.positionBuffer = null, this.colorBuffer = null, this.particleConfig = {
28504
+ effectType: (null === (_a = null == params ? void 0 : params.options) || void 0 === _a ? void 0 : _a.effectType) || "gravity",
28505
+ count: (null === (_b = null == params ? void 0 : params.options) || void 0 === _b ? void 0 : _b.count) || 4e3,
28506
+ size: (null === (_c = null == params ? void 0 : params.options) || void 0 === _c ? void 0 : _c.size) || 20,
28507
+ strength: (null === (_d = null == params ? void 0 : params.options) || void 0 === _d ? void 0 : _d.strength) || 1.5,
28508
+ useWebGL: void 0 === (null === (_e = null == params ? void 0 : params.options) || void 0 === _e ? void 0 : _e.useWebGL) || params.options.useWebGL
28509
+ };
28510
+ }
28511
+ getShaderSources() {
28512
+ return {
28513
+ vertex: "\n attribute vec2 a_position;\n attribute vec4 a_color;\n attribute float a_size;\n\n uniform vec2 u_resolution;\n uniform float u_time;\n uniform float u_forceStrength;\n uniform int u_effectType;\n\n varying vec4 v_color;\n\n void main() {\n // 将像素坐标转换为剪辑空间坐标\n vec2 clipSpace = ((a_position / u_resolution) * 2.0) - 1.0;\n clipSpace.y = -clipSpace.y; // 翻转Y轴\n\n gl_Position = vec4(clipSpace, 0.0, 1.0);\n gl_PointSize = a_size;\n v_color = a_color;\n }\n ",
28514
+ fragment: "\n precision mediump float;\n varying vec4 v_color;\n\n void main() {\n // 创建圆形粒子\n vec2 coord = gl_PointCoord - vec2(0.5);\n float distance = length(coord);\n\n if (distance > 0.5) {\n discard;\n }\n\n // 保持原始颜色,只调整透明度渐变\n gl_FragColor = vec4(v_color.rgb, v_color.a);\n }\n "
28515
+ };
28516
+ }
28517
+ applyWebGLEffect(canvas) {
28518
+ if (!this.gl || !this.program || !this.webglCanvas) return null;
28519
+ this.setupWebGLState(canvas), 0 === this.particles.length && this.extractParticles(canvas), this.updateParticles(canvas);
28520
+ const gl = this.gl;
28521
+ return gl.enable(gl.BLEND), gl.blendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA), gl.useProgram(this.program), this.prepareAndDrawParticles(gl), this.webglCanvas;
28522
+ }
28523
+ applyCanvas2DEffect(canvas) {
28524
+ const output = this.createOutputCanvas(canvas);
28525
+ if (!output) return null;
28526
+ const {
28527
+ canvas: outputCanvas,
28528
+ ctx: ctx
28529
+ } = output,
28530
+ progress = this.currentAnimationRatio;
28531
+ switch (this.particleConfig.effectType) {
28532
+ case "explode":
28533
+ this.applyCanvas2DExplode(ctx, canvas, progress);
28534
+ break;
28535
+ case "gravity":
28536
+ this.applyCanvas2DGravity(ctx, canvas, progress);
28537
+ break;
28538
+ case "vortex":
28539
+ this.applyCanvas2DVortex(ctx, canvas, progress);
28540
+ break;
28541
+ default:
28542
+ ctx.globalAlpha = Math.max(0, 1 - progress), ctx.drawImage(canvas, 0, 0);
28543
+ }
28544
+ return outputCanvas;
28545
+ }
28546
+ extractParticles(canvas) {
28547
+ const tempCanvas = ImageProcessUtils.createTempCanvas(canvas.width, canvas.height, 1),
28548
+ tempCtx = tempCanvas.getContext("2d");
28549
+ if (!tempCtx) return;
28550
+ tempCtx.drawImage(canvas, 0, 0, tempCanvas.width, tempCanvas.height);
28551
+ const data = tempCtx.getImageData(0, 0, tempCanvas.width, tempCanvas.height).data;
28552
+ this.particles = [];
28553
+ const step = Math.max(1, Math.floor(Math.sqrt(tempCanvas.width * tempCanvas.height / (1.5 * this.particleConfig.count))));
28554
+ for (let y = 0; y < tempCanvas.height; y += step) for (let x = 0; x < tempCanvas.width; x += step) {
28555
+ const index = 4 * (y * tempCanvas.width + x),
28556
+ r = data[index],
28557
+ g = data[index + 1],
28558
+ b = data[index + 2],
28559
+ a = data[index + 3];
28560
+ if (a > 5) {
28561
+ const realX = x / tempCanvas.width * canvas.width,
28562
+ realY = y / tempCanvas.height * canvas.height,
28563
+ particle = {
28564
+ x: realX,
28565
+ y: realY,
28566
+ originX: realX,
28567
+ originY: realY,
28568
+ vx: 0,
28569
+ vy: 0,
28570
+ r: r / 255,
28571
+ g: g / 255,
28572
+ b: b / 255,
28573
+ a: Math.max(.6, a / 255),
28574
+ life: 1,
28575
+ size: this.particleConfig.size * (1 + .5 * Math.random())
28576
+ };
28577
+ this.particles.push(particle);
28578
+ }
28579
+ }
28580
+ }
28581
+ updateParticles(canvas) {
28582
+ const centerX = canvas.width / 2,
28583
+ centerY = canvas.height / 2,
28584
+ progress = this.currentAnimationRatio,
28585
+ duration = this.getDurationFromParent(),
28586
+ isShortAnimation = duration < 2e3,
28587
+ timeMultiplier = isShortAnimation ? Math.max(1.5, 3e3 / duration) : 1,
28588
+ intensityBoost = isShortAnimation ? Math.min(2, 2e3 / duration) : 1;
28589
+ this.particles.forEach(particle => {
28590
+ const dx = particle.x - centerX,
28591
+ dy = particle.y - centerY,
28592
+ distance = Math.sqrt(dx * dx + dy * dy),
28593
+ angle = Math.atan2(dy, dx);
28594
+ this.applyParticleForces(particle, angle, distance, progress, intensityBoost, canvas), this.updateParticleProperties(particle, progress, isShortAnimation, timeMultiplier, intensityBoost);
28595
+ });
28596
+ }
28597
+ applyParticleForces(particle, angle, distance, progress, intensityBoost, canvas) {
28598
+ const time = this.getAnimationTime();
28599
+ switch (this.particleConfig.effectType) {
28600
+ case "explode":
28601
+ const explodeIntensity = progress * this.particleConfig.strength * intensityBoost * 5;
28602
+ particle.vx += Math.cos(angle) * explodeIntensity, particle.vy += Math.sin(angle) * explodeIntensity;
28603
+ break;
28604
+ case "gravity":
28605
+ this.applyGravityEffect(particle, progress, intensityBoost, canvas, time);
28606
+ break;
28607
+ case "vortex":
28608
+ this.applyVortexEffect(particle, progress, intensityBoost, canvas, angle, distance);
28609
+ }
28610
+ }
28611
+ applyGravityEffect(particle, progress, intensityBoost, canvas, time) {
28612
+ const gravityThreshold = (particle.originX + .7 * particle.originY) / (canvas.width + canvas.height) * .8;
28613
+ if (progress > gravityThreshold) {
28614
+ const gravityProgress = (progress - gravityThreshold) / (1 - gravityThreshold),
28615
+ gravityForce = this.particleConfig.strength * gravityProgress * gravityProgress * 12 * intensityBoost;
28616
+ particle.vy += gravityForce;
28617
+ const turbulence = Math.sin(3 * time + .02 * particle.originX) * Math.cos(2 * time + .015 * particle.originY);
28618
+ particle.vx += turbulence * this.particleConfig.strength * 2 * intensityBoost;
28619
+ }
28620
+ }
28621
+ applyVortexEffect(particle, progress, intensityBoost, canvas, angle, distance) {
28622
+ const centerX = canvas.width / 2,
28623
+ centerY = canvas.height / 2,
28624
+ spiralAngle = angle + progress * Math.PI * .8,
28625
+ targetRadius = distance + progress * Math.max(canvas.width, canvas.height) * .7 * 1.8,
28626
+ targetX = centerX + Math.cos(spiralAngle) * targetRadius,
28627
+ targetY = centerY + Math.sin(spiralAngle) * targetRadius,
28628
+ baseForce = progress * this.particleConfig.strength * .08 * intensityBoost;
28629
+ particle.vx += (targetX - particle.x) * baseForce, particle.vy += (targetY - particle.y) * baseForce;
28630
+ }
28631
+ updateParticleProperties(particle, progress, isShortAnimation, timeMultiplier, intensityBoost) {
28632
+ const dragCoeff = isShortAnimation ? .99 : .98;
28633
+ if (particle.vx *= dragCoeff, particle.vy *= dragCoeff, particle.x += particle.vx, particle.y += particle.vy, isShortAnimation) {
28634
+ const lifeDecayRate = Math.max(.1, .5 / timeMultiplier);
28635
+ particle.life = Math.max(0, 1 - progress * lifeDecayRate), particle.a = Math.max(.2, particle.life * Math.min(1, 1.2 * particle.a)), particle.size = Math.max(.7 * this.particleConfig.size, this.particleConfig.size * (.5 + .5 * particle.life));
28636
+ } else particle.life = Math.max(0, 1 - .2 * progress), particle.a = Math.max(.1, particle.life * Math.min(1, 1.5 * particle.a)), particle.size = Math.max(.5 * this.particleConfig.size, this.particleConfig.size * (.3 + .7 * particle.life));
28637
+ }
28638
+ prepareAndDrawParticles(gl) {
28639
+ const positions = new Float32Array(2 * this.particles.length),
28640
+ colors = new Float32Array(4 * this.particles.length),
28641
+ sizes = new Float32Array(this.particles.length);
28642
+ this.particles.forEach((particle, i) => {
28643
+ positions[2 * i] = particle.x, positions[2 * i + 1] = particle.y, colors[4 * i] = particle.r, colors[4 * i + 1] = particle.g, colors[4 * i + 2] = particle.b, colors[4 * i + 3] = Math.max(.1, particle.a), sizes[i] = Math.max(6, 1.5 * particle.size);
28644
+ }), this.updateParticleBuffers(gl, positions, colors, sizes), this.setParticleUniforms(gl), gl.drawArrays(gl.POINTS, 0, this.particles.length), this.cleanupTempBuffers(gl);
28645
+ }
28646
+ updateParticleBuffers(gl, positions, colors, sizes) {
28647
+ this.positionBuffer || (this.positionBuffer = gl.createBuffer()), gl.bindBuffer(gl.ARRAY_BUFFER, this.positionBuffer), gl.bufferData(gl.ARRAY_BUFFER, positions, gl.DYNAMIC_DRAW);
28648
+ const positionLocation = gl.getAttribLocation(this.program, "a_position");
28649
+ gl.enableVertexAttribArray(positionLocation), gl.vertexAttribPointer(positionLocation, 2, gl.FLOAT, !1, 0, 0), this.colorBuffer || (this.colorBuffer = gl.createBuffer()), gl.bindBuffer(gl.ARRAY_BUFFER, this.colorBuffer), gl.bufferData(gl.ARRAY_BUFFER, colors, gl.DYNAMIC_DRAW);
28650
+ const colorLocation = gl.getAttribLocation(this.program, "a_color");
28651
+ gl.enableVertexAttribArray(colorLocation), gl.vertexAttribPointer(colorLocation, 4, gl.FLOAT, !1, 0, 0);
28652
+ const sizeBuffer = gl.createBuffer();
28653
+ gl.bindBuffer(gl.ARRAY_BUFFER, sizeBuffer), gl.bufferData(gl.ARRAY_BUFFER, sizes, gl.DYNAMIC_DRAW);
28654
+ const sizeLocation = gl.getAttribLocation(this.program, "a_size");
28655
+ gl.enableVertexAttribArray(sizeLocation), gl.vertexAttribPointer(sizeLocation, 1, gl.FLOAT, !1, 0, 0), this._tempSizeBuffer = sizeBuffer;
28656
+ }
28657
+ setParticleUniforms(gl) {
28658
+ const resolutionLocation = gl.getUniformLocation(this.program, "u_resolution"),
28659
+ timeLocation = gl.getUniformLocation(this.program, "u_time"),
28660
+ forceStrengthLocation = gl.getUniformLocation(this.program, "u_forceStrength"),
28661
+ effectTypeLocation = gl.getUniformLocation(this.program, "u_effectType");
28662
+ gl.uniform2f(resolutionLocation, this.webglCanvas.width, this.webglCanvas.height), gl.uniform1f(timeLocation, this.getAnimationTime()), gl.uniform1f(forceStrengthLocation, this.particleConfig.strength);
28663
+ gl.uniform1i(effectTypeLocation, {
28664
+ explode: 0,
28665
+ vortex: 1,
28666
+ gravity: 2
28667
+ }[this.particleConfig.effectType] || 0);
28668
+ }
28669
+ cleanupTempBuffers(gl) {
28670
+ const tempSizeBuffer = this._tempSizeBuffer;
28671
+ tempSizeBuffer && (gl.deleteBuffer(tempSizeBuffer), delete this._tempSizeBuffer);
28672
+ }
28673
+ applyCanvas2DExplode(ctx, canvas, progress) {
28674
+ const centerX = canvas.width / 2,
28675
+ centerY = canvas.height / 2;
28676
+ ctx.save(), ctx.globalAlpha = Math.max(0, 1 - progress), ctx.translate(centerX, centerY);
28677
+ const scale = 1 + .5 * progress;
28678
+ ctx.scale(scale, scale), ctx.translate(-centerX, -centerY), ctx.drawImage(canvas, 0, 0), ctx.restore();
28679
+ }
28680
+ applyCanvas2DGravity(ctx, canvas, progress) {
28681
+ ctx.save(), ctx.globalAlpha = Math.max(0, 1 - progress);
28682
+ const offsetY = progress * canvas.height * .3;
28683
+ ctx.drawImage(canvas, 0, offsetY), ctx.restore();
28684
+ }
28685
+ applyCanvas2DVortex(ctx, canvas, progress) {
28686
+ const centerX = canvas.width / 2,
28687
+ centerY = canvas.height / 2;
28688
+ ctx.save(), ctx.globalAlpha = Math.max(0, 1 - progress), ctx.translate(centerX, centerY), ctx.rotate(progress * Math.PI * 2), ctx.translate(-centerX, -centerY), ctx.drawImage(canvas, 0, 0), ctx.restore();
28689
+ }
28690
+ }
28691
+
28692
+ class Glitch extends Canvas2DEffectBase {
28693
+ constructor(from, to, duration, easing, params) {
28694
+ var _a, _b;
28695
+ super(from, to, duration, easing, params), this.glitchConfig = {
28696
+ effectType: (null === (_a = null == params ? void 0 : params.options) || void 0 === _a ? void 0 : _a.effectType) || "rgb-shift",
28697
+ intensity: void 0 !== (null === (_b = null == params ? void 0 : params.options) || void 0 === _b ? void 0 : _b.intensity) ? params.options.intensity : .5
28698
+ };
28699
+ }
28700
+ applyCanvas2DEffect(canvas) {
28701
+ if (this.glitchConfig.intensity <= 0) {
28702
+ const outputCanvas = this.createOutputCanvas(canvas);
28703
+ return outputCanvas ? outputCanvas.canvas : null;
28704
+ }
28705
+ try {
28706
+ switch (this.glitchConfig.effectType) {
28707
+ case "rgb-shift":
28708
+ default:
28709
+ return this.applyRGBShiftGlitch(canvas);
28710
+ case "digital-distortion":
28711
+ return this.applyDigitalDistortionGlitch(canvas);
28712
+ case "scan-lines":
28713
+ return this.applyScanLineGlitch(canvas);
28714
+ case "data-corruption":
28715
+ return this.applyDataCorruptionGlitch(canvas);
28716
+ }
28717
+ } catch (error) {
28718
+ return null;
28719
+ }
28720
+ }
28721
+ applyRGBShiftGlitch(canvas) {
28722
+ const outputCanvas = this.createOutputCanvas(canvas);
28723
+ if (!outputCanvas) return null;
28724
+ const {
28725
+ ctx: ctx
28726
+ } = outputCanvas;
28727
+ try {
28728
+ ctx.clearRect(0, 0, canvas.width, canvas.height);
28729
+ const dynamicIntensity = ImageProcessUtils.calculateDynamicStrength(this.glitchConfig.intensity, this.getAnimationTime()),
28730
+ maxOffset = Math.floor(20 * dynamicIntensity),
28731
+ redOffset = this.generateRandomOffset(maxOffset),
28732
+ greenOffset = this.generateRandomOffset(maxOffset, .3),
28733
+ blueOffset = this.generateRandomOffset(-maxOffset),
28734
+ tempCanvas = ImageProcessUtils.createTempCanvas(canvas.width, canvas.height),
28735
+ tempCtx = tempCanvas.getContext("2d");
28736
+ tempCtx.drawImage(canvas, 0, 0);
28737
+ const originalImageData = tempCtx.getImageData(0, 0, canvas.width, canvas.height),
28738
+ redChannelData = ImageProcessUtils.extractChannel(originalImageData, 0),
28739
+ greenChannelData = ImageProcessUtils.extractChannel(originalImageData, 1),
28740
+ blueChannelData = ImageProcessUtils.extractChannel(originalImageData, 2);
28741
+ return ctx.globalCompositeOperation = "screen", tempCtx.clearRect(0, 0, canvas.width, canvas.height), tempCtx.putImageData(redChannelData, 0, 0), ctx.drawImage(tempCanvas, redOffset.x, redOffset.y), tempCtx.clearRect(0, 0, canvas.width, canvas.height), tempCtx.putImageData(greenChannelData, 0, 0), ctx.drawImage(tempCanvas, greenOffset.x, greenOffset.y), tempCtx.clearRect(0, 0, canvas.width, canvas.height), tempCtx.putImageData(blueChannelData, 0, 0), ctx.drawImage(tempCanvas, blueOffset.x, blueOffset.y), ctx.globalCompositeOperation = "source-over", outputCanvas.canvas;
28742
+ } catch (error) {
28743
+ return null;
28744
+ }
28745
+ }
28746
+ applyDigitalDistortionGlitch(canvas) {
28747
+ const outputCanvas = this.createOutputCanvas(canvas);
28748
+ if (!outputCanvas) return null;
28749
+ const {
28750
+ ctx: ctx
28751
+ } = outputCanvas;
28752
+ try {
28753
+ const imageData = ctx.getImageData(0, 0, canvas.width, canvas.height),
28754
+ dynamicIntensity = ImageProcessUtils.calculateDynamicStrength(this.glitchConfig.intensity, this.getAnimationTime()),
28755
+ distortedImageData = this.processDigitalDistortion(imageData, dynamicIntensity);
28756
+ return ctx.clearRect(0, 0, canvas.width, canvas.height), ctx.putImageData(distortedImageData, 0, 0), outputCanvas.canvas;
28757
+ } catch (error) {
28758
+ return null;
28759
+ }
28760
+ }
28761
+ applyScanLineGlitch(canvas) {
28762
+ const outputCanvas = this.createOutputCanvas(canvas);
28763
+ if (!outputCanvas) return null;
28764
+ const {
28765
+ ctx: ctx
28766
+ } = outputCanvas;
28767
+ try {
28768
+ const dynamicIntensity = ImageProcessUtils.calculateDynamicStrength(this.glitchConfig.intensity, this.getAnimationTime()),
28769
+ lineSpacing = Math.max(2, Math.floor(10 - 8 * dynamicIntensity));
28770
+ ctx.globalCompositeOperation = "multiply";
28771
+ for (let y = 0; y < canvas.height; y += lineSpacing) if (Math.random() < dynamicIntensity) {
28772
+ const opacity = .1 + .4 * dynamicIntensity;
28773
+ ctx.fillStyle = `rgba(0, 0, 0, ${opacity})`, ctx.fillRect(0, y, canvas.width, 1);
28774
+ }
28775
+ ctx.globalCompositeOperation = "screen";
28776
+ const brightLineCount = Math.floor(20 * dynamicIntensity);
28777
+ for (let i = 0; i < brightLineCount; i++) {
28778
+ const y = Math.random() * canvas.height,
28779
+ opacity = .3 * dynamicIntensity;
28780
+ ctx.fillStyle = `rgba(255, 255, 255, ${opacity})`, ctx.fillRect(0, Math.floor(y), canvas.width, 1);
28781
+ }
28782
+ return ctx.globalCompositeOperation = "source-over", outputCanvas.canvas;
28783
+ } catch (error) {
28784
+ return null;
28785
+ }
28786
+ }
28787
+ applyDataCorruptionGlitch(canvas) {
28788
+ const outputCanvas = this.createOutputCanvas(canvas);
28789
+ if (!outputCanvas) return null;
28790
+ const {
28791
+ ctx: ctx
28792
+ } = outputCanvas;
28793
+ try {
28794
+ const imageData = ctx.getImageData(0, 0, canvas.width, canvas.height),
28795
+ dynamicIntensity = ImageProcessUtils.calculateDynamicStrength(this.glitchConfig.intensity, this.getAnimationTime()),
28796
+ corruptedImageData = this.processDataCorruption(imageData, dynamicIntensity);
28797
+ return ctx.clearRect(0, 0, canvas.width, canvas.height), ctx.putImageData(corruptedImageData, 0, 0), outputCanvas.canvas;
28798
+ } catch (error) {
28799
+ return null;
28800
+ }
28801
+ }
28802
+ generateRandomOffset(maxOffset, scale = 1) {
28803
+ return {
28804
+ x: (Math.random() - .5) * maxOffset,
28805
+ y: (Math.random() - .5) * maxOffset * scale
28806
+ };
28807
+ }
28808
+ processDigitalDistortion(imageData, intensity) {
28809
+ const {
28810
+ data: data,
28811
+ width: width,
28812
+ height: height
28813
+ } = imageData,
28814
+ result = new Uint8ClampedArray(data),
28815
+ sliceCount = Math.floor(20 * intensity) + 5,
28816
+ sliceHeight = Math.floor(height / sliceCount);
28817
+ for (let i = 0; i < sliceCount; i++) if (Math.random() < intensity) {
28818
+ const y = i * sliceHeight,
28819
+ sliceEnd = Math.min(y + sliceHeight, height),
28820
+ offset = Math.floor((Math.random() - .5) * width * intensity * .1);
28821
+ this.shiftSliceHorizontal(result, width, height, y, sliceEnd, offset);
28822
+ }
28823
+ const noiseIntensity = .3 * intensity;
28824
+ for (let i = 0; i < data.length; i += 4) Math.random() < noiseIntensity && (result[i] = 255 * Math.random(), result[i + 1] = 255 * Math.random(), result[i + 2] = 255 * Math.random());
28825
+ return new ImageData(result, width, height);
28826
+ }
28827
+ shiftSliceHorizontal(data, width, height, startY, endY, offset) {
28828
+ const tempRow = new Uint8ClampedArray(4 * width);
28829
+ for (let y = startY; y < endY; y++) {
28830
+ const rowStart = y * width * 4;
28831
+ for (let x = 0; x < 4 * width; x++) tempRow[x] = data[rowStart + x];
28832
+ for (let x = 0; x < width; x++) {
28833
+ const targetIndex = rowStart + 4 * x,
28834
+ sourceIndex = 4 * ((x - offset + width) % width);
28835
+ data[targetIndex] = tempRow[sourceIndex], data[targetIndex + 1] = tempRow[sourceIndex + 1], data[targetIndex + 2] = tempRow[sourceIndex + 2], data[targetIndex + 3] = tempRow[sourceIndex + 3];
28836
+ }
28837
+ }
28838
+ }
28839
+ processDataCorruption(imageData, intensity) {
28840
+ const {
28841
+ data: data,
28842
+ width: width,
28843
+ height: height
28844
+ } = imageData,
28845
+ result = new Uint8ClampedArray(data),
28846
+ stripeCount = Math.floor(15 * intensity) + 5;
28847
+ for (let i = 0; i < stripeCount; i++) if (Math.random() < intensity) {
28848
+ const x = Math.floor(Math.random() * width),
28849
+ stripeWidth = Math.floor(5 * Math.random()) + 1,
28850
+ color = Math.random() < .5 ? 0 : 255;
28851
+ for (let y = 0; y < height; y++) for (let dx = 0; dx < stripeWidth && x + dx < width; dx++) {
28852
+ const index = 4 * (y * width + x + dx);
28853
+ result[index] = color, result[index + 1] = color, result[index + 2] = color;
28854
+ }
28855
+ }
28856
+ const corruptionCount = Math.floor(20 * intensity);
28857
+ for (let i = 0; i < corruptionCount; i++) {
28858
+ const blockX = Math.floor(Math.random() * width),
28859
+ blockY = Math.floor(Math.random() * height),
28860
+ blockW = Math.floor(20 * Math.random()) + 5,
28861
+ blockH = Math.floor(10 * Math.random()) + 2;
28862
+ this.corruptBlock(result, width, height, blockX, blockY, blockW, blockH);
28863
+ }
28864
+ return new ImageData(result, width, height);
28865
+ }
28866
+ corruptBlock(data, width, height, x, y, w, h) {
28867
+ for (let dy = 0; dy < h && y + dy < height; dy++) for (let dx = 0; dx < w && x + dx < width; dx++) {
28868
+ const index = 4 * ((y + dy) * width + (x + dx));
28869
+ Math.random() < .7 && (data[index] = 255 * Math.random(), data[index + 1] = 255 * Math.random(), data[index + 2] = 255 * Math.random());
28870
+ }
28871
+ }
28872
+ }
28873
+
28874
+ class GaussianBlur extends AStageAnimate {
28875
+ constructor(from, to, duration, easing, params) {
28876
+ var _a, _b;
28877
+ super(from, to, duration, easing, params), this.blurConfig = {
28878
+ blurRadius: (null === (_a = null == params ? void 0 : params.options) || void 0 === _a ? void 0 : _a.blurRadius) || 8,
28879
+ useOptimizedBlur: void 0 === (null === (_b = null == params ? void 0 : params.options) || void 0 === _b ? void 0 : _b.useOptimizedBlur) || params.options.useOptimizedBlur
28880
+ };
28881
+ }
28882
+ applyCSSBlur(canvas, radius) {
28883
+ const c = vglobal.createCanvas({
28884
+ width: canvas.width,
28885
+ height: canvas.height,
28886
+ dpr: vglobal.devicePixelRatio
28887
+ }),
28888
+ ctx = c.getContext("2d");
28889
+ return ctx ? (ctx.filter = `blur(${radius}px)`, ctx.drawImage(canvas, 0, 0), ctx.filter = "none", c) : canvas;
28890
+ }
28891
+ applyDownsampleBlur(imageData, radius) {
28892
+ const {
28893
+ width: width,
28894
+ height: height
28895
+ } = imageData,
28896
+ downsample = Math.max(1, Math.floor(radius / 2)),
28897
+ smallWidth = Math.floor(width / downsample),
28898
+ smallHeight = Math.floor(height / downsample),
28899
+ tempCanvas = vglobal.createCanvas({
28900
+ width: smallWidth,
28901
+ height: smallHeight,
28902
+ dpr: 1
28903
+ }),
28904
+ tempCtx = tempCanvas.getContext("2d");
28905
+ if (!tempCtx) return imageData;
28906
+ const originalCanvas = vglobal.createCanvas({
28907
+ width: width,
28908
+ height: height,
28909
+ dpr: 1
28910
+ }),
28911
+ originalCtx = originalCanvas.getContext("2d");
28912
+ return originalCtx ? (originalCtx.putImageData(imageData, 0, 0), tempCtx.drawImage(originalCanvas, 0, 0, smallWidth, smallHeight), tempCtx.filter = `blur(${radius / downsample}px)`, tempCtx.drawImage(tempCanvas, 0, 0), tempCtx.filter = "none", originalCtx.clearRect(0, 0, width, height), originalCtx.drawImage(tempCanvas, 0, 0, width, height), originalCtx.getImageData(0, 0, width, height)) : imageData;
28913
+ }
28914
+ afterStageRender(stage, canvas) {
28915
+ if (this.blurConfig.blurRadius <= 0) return canvas;
28916
+ let result;
28917
+ if (this.blurConfig.useOptimizedBlur) result = this.applyCSSBlur(canvas, this.blurConfig.blurRadius);else {
28918
+ const c = vglobal.createCanvas({
28919
+ width: canvas.width,
28920
+ height: canvas.height,
28921
+ dpr: vglobal.devicePixelRatio
28922
+ }),
28923
+ ctx = c.getContext("2d");
28924
+ if (!ctx) return !1;
28925
+ ctx.clearRect(0, 0, canvas.width, canvas.height), ctx.drawImage(canvas, 0, 0);
28926
+ const imageData = ctx.getImageData(0, 0, canvas.width, canvas.height),
28927
+ blurredImageData = this.applyDownsampleBlur(imageData, this.blurConfig.blurRadius);
28928
+ ctx.putImageData(blurredImageData, 0, 0), result = c;
28929
+ }
28930
+ const ctx = result.getContext("2d");
28931
+ return ctx && (ctx.globalCompositeOperation = "overlay", ctx.fillStyle = "rgba(255, 255, 255, 0.1)", ctx.fillRect(0, 0, result.width, result.height), ctx.globalCompositeOperation = "source-over"), result;
28932
+ }
28933
+ }
28934
+
28935
+ class Pixelation extends DisappearAnimateBase {
28936
+ constructor(from, to, duration, easing, params) {
28937
+ var _a, _b;
28938
+ super(from, to, duration, easing, params), this.pixelationConfig = {
28939
+ maxPixelSize: (null === (_a = null == params ? void 0 : params.options) || void 0 === _a ? void 0 : _a.maxPixelSize) || 20,
28940
+ method: (null === (_b = null == params ? void 0 : params.options) || void 0 === _b ? void 0 : _b.method) || "out"
28941
+ };
28942
+ }
28943
+ applyDownsamplePixelation(canvas, pixelSize) {
28944
+ if (pixelSize <= 1) return canvas;
28945
+ const {
28946
+ width: width,
28947
+ height: height
28948
+ } = canvas,
28949
+ smallWidth = Math.ceil(width / pixelSize),
28950
+ smallHeight = Math.ceil(height / pixelSize),
28951
+ smallCanvas = vglobal.createCanvas({
28952
+ width: smallWidth,
28953
+ height: smallHeight,
28954
+ dpr: 1
28955
+ }),
28956
+ smallCtx = smallCanvas.getContext("2d");
28957
+ if (!smallCtx) return canvas;
28958
+ const outputCanvas = vglobal.createCanvas({
28959
+ width: width,
28960
+ height: height,
28961
+ dpr: vglobal.devicePixelRatio
28962
+ }),
28963
+ outputCtx = outputCanvas.getContext("2d");
28964
+ return outputCtx ? (smallCtx.imageSmoothingEnabled = !1, outputCtx.imageSmoothingEnabled = !1, smallCtx.drawImage(canvas, 0, 0, smallWidth, smallHeight), outputCtx.drawImage(smallCanvas, 0, 0, width, height), outputCanvas) : canvas;
28965
+ }
28966
+ updateAnimationProgress() {
28967
+ if ("in" === this.pixelationConfig.method) {
28968
+ return this.pixelationConfig.maxPixelSize - this.currentAnimationRatio * (this.pixelationConfig.maxPixelSize - 1);
28969
+ }
28970
+ return 1 + this.currentAnimationRatio * (this.pixelationConfig.maxPixelSize - 1);
28971
+ }
28972
+ afterStageRender(stage, canvas) {
28973
+ const currentPixelSize = this.updateAnimationProgress();
28974
+ if (currentPixelSize <= 1) return canvas;
28975
+ return this.applyDownsamplePixelation(canvas, currentPixelSize);
28976
+ }
28977
+ }
28978
+
27630
28979
  const registerCustomAnimate = () => {
27631
- AnimateExecutor.registerBuiltInAnimate("increaseCount", IncreaseCount), AnimateExecutor.registerBuiltInAnimate("fromTo", FromTo), AnimateExecutor.registerBuiltInAnimate("scaleIn", ScaleIn), AnimateExecutor.registerBuiltInAnimate("scaleOut", ScaleOut), AnimateExecutor.registerBuiltInAnimate("growHeightIn", GrowHeightIn), AnimateExecutor.registerBuiltInAnimate("growHeightOut", GrowHeightOut), AnimateExecutor.registerBuiltInAnimate("growWidthIn", GrowWidthIn), AnimateExecutor.registerBuiltInAnimate("growWidthOut", GrowWidthOut), AnimateExecutor.registerBuiltInAnimate("growCenterIn", GrowCenterIn), AnimateExecutor.registerBuiltInAnimate("growCenterOut", GrowCenterOut), AnimateExecutor.registerBuiltInAnimate("clipIn", ClipIn), AnimateExecutor.registerBuiltInAnimate("clipOut", ClipOut), AnimateExecutor.registerBuiltInAnimate("fadeIn", FadeIn), AnimateExecutor.registerBuiltInAnimate("fadeOut", FadeOut), AnimateExecutor.registerBuiltInAnimate("growPointsIn", GrowPointsIn), AnimateExecutor.registerBuiltInAnimate("growPointsOut", GrowPointsOut), AnimateExecutor.registerBuiltInAnimate("growPointsXIn", GrowPointsXIn), AnimateExecutor.registerBuiltInAnimate("growPointsXOut", GrowPointsXOut), AnimateExecutor.registerBuiltInAnimate("growPointsYIn", GrowPointsYIn), AnimateExecutor.registerBuiltInAnimate("growPointsYOut", GrowPointsYOut), AnimateExecutor.registerBuiltInAnimate("growAngleIn", GrowAngleIn), AnimateExecutor.registerBuiltInAnimate("growAngleOut", GrowAngleOut), AnimateExecutor.registerBuiltInAnimate("growRadiusIn", GrowRadiusIn), AnimateExecutor.registerBuiltInAnimate("growRadiusOut", GrowRadiusOut), AnimateExecutor.registerBuiltInAnimate("moveIn", MoveIn), AnimateExecutor.registerBuiltInAnimate("moveOut", MoveOut), AnimateExecutor.registerBuiltInAnimate("rotateIn", RotateIn), AnimateExecutor.registerBuiltInAnimate("rotateOut", RotateOut), AnimateExecutor.registerBuiltInAnimate("update", Update), AnimateExecutor.registerBuiltInAnimate("state", State), AnimateExecutor.registerBuiltInAnimate("labelItemAppear", LabelItemAppear), AnimateExecutor.registerBuiltInAnimate("labelItemDisappear", LabelItemDisappear), AnimateExecutor.registerBuiltInAnimate("poptipAppear", PoptipAppear), AnimateExecutor.registerBuiltInAnimate("poptipDisappear", PoptipDisappear), AnimateExecutor.registerBuiltInAnimate("inputText", InputText), AnimateExecutor.registerBuiltInAnimate("inputRichText", InputRichText), AnimateExecutor.registerBuiltInAnimate("outputRichText", OutputRichText), AnimateExecutor.registerBuiltInAnimate("slideRichText", SlideRichText), AnimateExecutor.registerBuiltInAnimate("slideOutRichText", SlideOutRichText), AnimateExecutor.registerBuiltInAnimate("slideIn", SlideIn), AnimateExecutor.registerBuiltInAnimate("growIn", GrowIn), AnimateExecutor.registerBuiltInAnimate("spinIn", SpinIn), AnimateExecutor.registerBuiltInAnimate("moveScaleIn", MoveScaleIn), AnimateExecutor.registerBuiltInAnimate("moveRotateIn", MoveRotateIn), AnimateExecutor.registerBuiltInAnimate("strokeIn", StrokeIn), AnimateExecutor.registerBuiltInAnimate("slideOut", SlideOut), AnimateExecutor.registerBuiltInAnimate("growOut", GrowOut), AnimateExecutor.registerBuiltInAnimate("spinOut", SpinOut), AnimateExecutor.registerBuiltInAnimate("moveScaleOut", MoveScaleOut), AnimateExecutor.registerBuiltInAnimate("moveRotateOut", MoveRotateOut), AnimateExecutor.registerBuiltInAnimate("strokeOut", StrokeOut), AnimateExecutor.registerBuiltInAnimate("pulse", PulseAnimate), AnimateExecutor.registerBuiltInAnimate("MotionPath", MotionPath), AnimateExecutor.registerBuiltInAnimate("streamLight", StreamLight);
28980
+ AnimateExecutor.registerBuiltInAnimate("increaseCount", IncreaseCount), AnimateExecutor.registerBuiltInAnimate("fromTo", FromTo), AnimateExecutor.registerBuiltInAnimate("scaleIn", ScaleIn), AnimateExecutor.registerBuiltInAnimate("scaleOut", ScaleOut), AnimateExecutor.registerBuiltInAnimate("growHeightIn", GrowHeightIn), AnimateExecutor.registerBuiltInAnimate("growHeightOut", GrowHeightOut), AnimateExecutor.registerBuiltInAnimate("growWidthIn", GrowWidthIn), AnimateExecutor.registerBuiltInAnimate("growWidthOut", GrowWidthOut), AnimateExecutor.registerBuiltInAnimate("growCenterIn", GrowCenterIn), AnimateExecutor.registerBuiltInAnimate("growCenterOut", GrowCenterOut), AnimateExecutor.registerBuiltInAnimate("clipIn", ClipIn), AnimateExecutor.registerBuiltInAnimate("clipOut", ClipOut), AnimateExecutor.registerBuiltInAnimate("fadeIn", FadeIn), AnimateExecutor.registerBuiltInAnimate("fadeOut", FadeOut), AnimateExecutor.registerBuiltInAnimate("growPointsIn", GrowPointsIn), AnimateExecutor.registerBuiltInAnimate("growPointsOut", GrowPointsOut), AnimateExecutor.registerBuiltInAnimate("growPointsXIn", GrowPointsXIn), AnimateExecutor.registerBuiltInAnimate("growPointsXOut", GrowPointsXOut), AnimateExecutor.registerBuiltInAnimate("growPointsYIn", GrowPointsYIn), AnimateExecutor.registerBuiltInAnimate("growPointsYOut", GrowPointsYOut), AnimateExecutor.registerBuiltInAnimate("growAngleIn", GrowAngleIn), AnimateExecutor.registerBuiltInAnimate("growAngleOut", GrowAngleOut), AnimateExecutor.registerBuiltInAnimate("growRadiusIn", GrowRadiusIn), AnimateExecutor.registerBuiltInAnimate("growRadiusOut", GrowRadiusOut), AnimateExecutor.registerBuiltInAnimate("moveIn", MoveIn), AnimateExecutor.registerBuiltInAnimate("moveOut", MoveOut), AnimateExecutor.registerBuiltInAnimate("rotateIn", RotateIn), AnimateExecutor.registerBuiltInAnimate("rotateOut", RotateOut), AnimateExecutor.registerBuiltInAnimate("update", Update), AnimateExecutor.registerBuiltInAnimate("state", State), AnimateExecutor.registerBuiltInAnimate("labelItemAppear", LabelItemAppear), AnimateExecutor.registerBuiltInAnimate("labelItemDisappear", LabelItemDisappear), AnimateExecutor.registerBuiltInAnimate("poptipAppear", PoptipAppear), AnimateExecutor.registerBuiltInAnimate("poptipDisappear", PoptipDisappear), AnimateExecutor.registerBuiltInAnimate("inputText", InputText), AnimateExecutor.registerBuiltInAnimate("inputRichText", InputRichText), AnimateExecutor.registerBuiltInAnimate("outputRichText", OutputRichText), AnimateExecutor.registerBuiltInAnimate("slideRichText", SlideRichText), AnimateExecutor.registerBuiltInAnimate("slideOutRichText", SlideOutRichText), AnimateExecutor.registerBuiltInAnimate("slideIn", SlideIn), AnimateExecutor.registerBuiltInAnimate("growIn", GrowIn), AnimateExecutor.registerBuiltInAnimate("spinIn", SpinIn), AnimateExecutor.registerBuiltInAnimate("moveScaleIn", MoveScaleIn), AnimateExecutor.registerBuiltInAnimate("moveRotateIn", MoveRotateIn), AnimateExecutor.registerBuiltInAnimate("strokeIn", StrokeIn), AnimateExecutor.registerBuiltInAnimate("slideOut", SlideOut), AnimateExecutor.registerBuiltInAnimate("growOut", GrowOut), AnimateExecutor.registerBuiltInAnimate("spinOut", SpinOut), AnimateExecutor.registerBuiltInAnimate("moveScaleOut", MoveScaleOut), AnimateExecutor.registerBuiltInAnimate("moveRotateOut", MoveRotateOut), AnimateExecutor.registerBuiltInAnimate("strokeOut", StrokeOut), AnimateExecutor.registerBuiltInAnimate("pulse", PulseAnimate), AnimateExecutor.registerBuiltInAnimate("MotionPath", MotionPath), AnimateExecutor.registerBuiltInAnimate("streamLight", StreamLight), AnimateExecutor.registerBuiltInAnimate("dissolve", Dissolve), AnimateExecutor.registerBuiltInAnimate("grayscale", Grayscale), AnimateExecutor.registerBuiltInAnimate("distortion", Distortion), AnimateExecutor.registerBuiltInAnimate("particle", Particle), AnimateExecutor.registerBuiltInAnimate("glitch", Glitch), AnimateExecutor.registerBuiltInAnimate("gaussianBlur", GaussianBlur), AnimateExecutor.registerBuiltInAnimate("pixelation", Pixelation);
27632
28981
  };
27633
28982
 
27634
28983
  class AxisEnter extends AComponentAnimate {
@@ -34442,6 +35791,25 @@
34442
35791
  function isZeroStyle(style) {
34443
35792
  return style === 0 || (isArray$7(style) && style.every(s => s === 0));
34444
35793
  }
35794
+ function setActiveCellRangeState(table) {
35795
+ const selectRanges = table.stateManager.select.ranges;
35796
+ const setRanges = [];
35797
+ for (let i = 0; i < selectRanges.length; i++) {
35798
+ const range = selectRanges[i];
35799
+ setRanges.push({
35800
+ range,
35801
+ style: {
35802
+ cellBorderColor: 'blue',
35803
+ cellBorderLineWidth: 2,
35804
+ cellBorderLineDash: [5, 5]
35805
+ }
35806
+ });
35807
+ }
35808
+ table.stateManager.setCustomSelectRanges(setRanges);
35809
+ }
35810
+ function clearActiveCellRangeState(table) {
35811
+ table.stateManager.setCustomSelectRanges([]);
35812
+ }
34445
35813
 
34446
35814
  const judgeType$1 = (value) => {
34447
35815
  switch (Object.prototype.toString.call(value)) {
@@ -34924,6 +36292,7 @@
34924
36292
  DROPDOWN_MENU_CLICK: 'dropdown_menu_click',
34925
36293
  MOUSEOVER_CHART_SYMBOL: 'mouseover_chart_symbol',
34926
36294
  DRAG_SELECT_END: 'drag_select_end',
36295
+ SELECTED_CHANGED: 'selected_changed',
34927
36296
  COPY_DATA: 'copy_data',
34928
36297
  DROPDOWN_ICON_CLICK: 'dropdown_icon_click',
34929
36298
  DROPDOWN_MENU_CLEAR: 'dropdown_menu_clear',
@@ -34942,8 +36311,10 @@
34942
36311
  SWITCH_STATE_CHANGE: 'switch_state_change',
34943
36312
  BEFORE_SET_SIZE: 'before_set_size',
34944
36313
  BEFORE_INIT: 'before_init',
36314
+ BEFORE_UPDATE_OPTION: 'before_update_option',
34945
36315
  AFTER_RENDER: 'after_render',
34946
36316
  INITIALIZED: 'initialized',
36317
+ UPDATED: 'updated',
34947
36318
  CHANGE_CELL_VALUE: 'change_cell_value',
34948
36319
  DRAG_FILL_HANDLE_END: 'drag_fill_handle_end',
34949
36320
  MOUSEDOWN_FILL_HANDLE: 'mousedown_fill_handle',
@@ -34952,7 +36323,8 @@
34952
36323
  EMPTY_TIP_DBLCLICK: 'empty_tip_dblclick',
34953
36324
  BUTTON_CLICK: 'button_click',
34954
36325
  BEFORE_CACHE_CHART_IMAGE: 'before_cache_chart_image',
34955
- PASTED_DATA: 'pasted_data'
36326
+ PASTED_DATA: 'pasted_data',
36327
+ PLUGIN_EVENT: 'plugin_event'
34956
36328
  };
34957
36329
 
34958
36330
  const judgeType = (value) => {
@@ -36642,7 +38014,7 @@
36642
38014
  return hasThemeProperty(obj, names) || hasThemeProperty(superTheme, names);
36643
38015
  }
36644
38016
  extends(obj) {
36645
- return new TableTheme(ingoreNoneValueMerge({}, obj), ingoreNoneValueMerge(this.internalTheme.superTheme, this.internalTheme.obj));
38017
+ return new TableTheme(ingoreNoneValueMerge({}, obj), ingoreNoneValueMerge({}, this.internalTheme.superTheme, this.internalTheme.obj));
36646
38018
  }
36647
38019
  getStyle(style) {
36648
38020
  const that = this;
@@ -37005,6 +38377,7 @@
37005
38377
  return isValid$3(mapIndex) ? mapIndex : index;
37006
38378
  }
37007
38379
  class DataSource extends EventTarget$1 {
38380
+ addRecordRule = 'Object';
37008
38381
  dataConfig;
37009
38382
  dataSourceObj;
37010
38383
  _get;
@@ -37029,6 +38402,7 @@
37029
38402
  lastFilterRules;
37030
38403
  constructor(dataSourceObj, dataConfig, pagination, columns, rowHierarchyType, hierarchyExpandLevel) {
37031
38404
  super();
38405
+ this.addRecordRule = dataConfig?.addRecordRule || 'Object';
37032
38406
  this.registerAggregators();
37033
38407
  this.dataSourceObj = dataSourceObj;
37034
38408
  this.dataConfig = dataConfig;
@@ -37179,6 +38553,9 @@
37179
38553
  if (isHasFilterRule || isHasAggregation) {
37180
38554
  for (let i = 0, len = records.length; i < len; i++) {
37181
38555
  const record = records[i];
38556
+ if (record === undefined || record === null) {
38557
+ continue;
38558
+ }
37182
38559
  if (this.dataConfig?.filterRules?.length >= 1) {
37183
38560
  if (this.filterRecord(record)) {
37184
38561
  filteredRecords.push(record);
@@ -37425,7 +38802,7 @@
37425
38802
  record[field] = formatValue;
37426
38803
  }
37427
38804
  else {
37428
- this.records[dataIndex] = {};
38805
+ this.records[dataIndex] = this.addRecordRule === 'Array' ? [] : {};
37429
38806
  this.records[dataIndex][field] = formatValue;
37430
38807
  }
37431
38808
  }
@@ -37682,10 +39059,30 @@
37682
39059
  }
37683
39060
  const sortedIndexArray = Array.from({ length: this._sourceLength }, (_, i) => i);
37684
39061
  sortedIndexArray.sort((indexA, indexB) => {
39062
+ const recordA = this.getOriginalRecord(indexA);
39063
+ const recordB = this.getOriginalRecord(indexB);
39064
+ const isEmptyA = recordA === null || recordA === undefined || (typeof recordA === 'object' && Object.keys(recordA).length === 0);
39065
+ const isEmptyB = recordB === null || recordB === undefined || (typeof recordB === 'object' && Object.keys(recordB).length === 0);
37685
39066
  return states.reduce((result, state) => {
37686
39067
  if (result !== 0) {
37687
39068
  return result;
37688
39069
  }
39070
+ if (state.order === 'asc' || state.order === 'desc') {
39071
+ if (isEmptyA && !isEmptyB) {
39072
+ return 1;
39073
+ }
39074
+ if (!isEmptyA && isEmptyB) {
39075
+ return -1;
39076
+ }
39077
+ if (isEmptyA && isEmptyB) {
39078
+ return indexA - indexB;
39079
+ }
39080
+ }
39081
+ else {
39082
+ if (isEmptyA || isEmptyB) {
39083
+ return indexA - indexB;
39084
+ }
39085
+ }
37689
39086
  const orderFn = state.orderFn ||
37690
39087
  (state.order !== 'desc'
37691
39088
  ? (v1, v2) => (v1 === v2 ? 0 : v1 > v2 ? 1 : -1)
@@ -42110,6 +43507,66 @@
42110
43507
  }
42111
43508
  return { x, y };
42112
43509
  }
43510
+ function calculateCellRangeDistribution(startCol, startRow, endCol, endRow, table) {
43511
+ let needRowHeader = false;
43512
+ let needRightRowHeader = false;
43513
+ let needColumnHeader = false;
43514
+ let needBottomColumnHeader = false;
43515
+ let needBody = false;
43516
+ let needCornerHeader = false;
43517
+ let needRightTopCornerHeader = false;
43518
+ let needRightBottomCornerHeader = false;
43519
+ let needLeftBottomCornerHeader = false;
43520
+ if (startCol <= table.frozenColCount - 1 && startRow <= table.frozenRowCount - 1) {
43521
+ needCornerHeader = true;
43522
+ }
43523
+ if (endCol >= table.colCount - table.rightFrozenColCount && startRow <= table.frozenRowCount - 1) {
43524
+ needRightTopCornerHeader = true;
43525
+ }
43526
+ if (startCol <= table.frozenColCount - 1 && endRow >= table.rowCount - table.bottomFrozenRowCount) {
43527
+ needLeftBottomCornerHeader = true;
43528
+ }
43529
+ if (endCol >= table.colCount - table.rightFrozenColCount && endRow >= table.rowCount - table.bottomFrozenRowCount) {
43530
+ needRightBottomCornerHeader = true;
43531
+ }
43532
+ if (startCol <= table.frozenColCount - 1 &&
43533
+ endRow >= table.frozenRowCount &&
43534
+ startRow <= table.rowCount - table.bottomFrozenRowCount - 1) {
43535
+ needRowHeader = true;
43536
+ }
43537
+ if (endCol >= table.colCount - table.rightFrozenColCount &&
43538
+ endRow >= table.frozenRowCount &&
43539
+ startRow <= table.rowCount - table.bottomFrozenRowCount - 1) {
43540
+ needRightRowHeader = true;
43541
+ }
43542
+ if (startRow <= table.frozenRowCount - 1 &&
43543
+ endCol >= table.frozenColCount &&
43544
+ startCol <= table.colCount - table.rightFrozenColCount - 1) {
43545
+ needColumnHeader = true;
43546
+ }
43547
+ if (endRow >= table.rowCount - table.bottomFrozenRowCount &&
43548
+ endCol >= table.frozenColCount &&
43549
+ startCol <= table.colCount - table.rightFrozenColCount - 1) {
43550
+ needBottomColumnHeader = true;
43551
+ }
43552
+ if (startCol <= table.colCount - table.rightFrozenColCount - 1 &&
43553
+ endCol >= table.frozenColCount &&
43554
+ startRow <= table.rowCount - table.bottomFrozenRowCount - 1 &&
43555
+ endRow >= table.frozenRowCount) {
43556
+ needBody = true;
43557
+ }
43558
+ return {
43559
+ needRowHeader,
43560
+ needRightRowHeader,
43561
+ needColumnHeader,
43562
+ needBottomColumnHeader,
43563
+ needBody,
43564
+ needCornerHeader,
43565
+ needRightTopCornerHeader,
43566
+ needLeftBottomCornerHeader,
43567
+ needRightBottomCornerHeader
43568
+ };
43569
+ }
42113
43570
 
42114
43571
  function getProp(name, cellStyle, col, row, _table) {
42115
43572
  const prop = cellStyle && isValid$3(cellStyle[name]) ? cellStyle[name] : undefined;
@@ -43700,6 +45157,10 @@
43700
45157
  lineDash: cellTheme?.group?.lineDash ?? undefined,
43701
45158
  y: table.scenegraph.getCellGroupY(row)
43702
45159
  });
45160
+ oldCellGroup.mergeStartCol = undefined;
45161
+ oldCellGroup.mergeStartRow = undefined;
45162
+ oldCellGroup.mergeEndCol = undefined;
45163
+ oldCellGroup.mergeEndRow = undefined;
43703
45164
  oldCellGroup.forEachChildren((child) => {
43704
45165
  child.setAttributes({
43705
45166
  dx: 0,
@@ -47553,7 +49014,7 @@
47553
49014
  const formatResult = table.options.specFormat(chart.attribute.spec, chartInstance, chart);
47554
49015
  if (formatResult.needFormatSpec && formatResult.spec) {
47555
49016
  const spec = formatResult.spec;
47556
- chartInstance.updateSpecSync(spec, false, { reuse: false, morph: false });
49017
+ chartInstance.updateSpecSync(spec);
47557
49018
  updateSpec = formatResult.updateSpec ?? true;
47558
49019
  }
47559
49020
  }
@@ -47734,7 +49195,7 @@
47734
49195
  const formatResult = table.options.specFormat(chart.attribute.spec, activeChartInstance, chart);
47735
49196
  if (formatResult.needFormatSpec && formatResult.spec) {
47736
49197
  const spec = formatResult.spec;
47737
- activeChartInstance.updateSpecSync(spec, false, { reuse: false, morph: false });
49198
+ activeChartInstance.updateSpecSync(spec);
47738
49199
  }
47739
49200
  }
47740
49201
  const viewBox = chart.getViewBox();
@@ -49081,17 +50542,10 @@
49081
50542
  type = 'chart';
49082
50543
  numberType = CHART_NUMBER_TYPE;
49083
50544
  contains(chart, point, params) {
49084
- const vChart = chart.activeChartInstance;
49085
- if (!vChart) {
49086
- return false;
49087
- }
49088
- const vchartStage = vChart.getStage();
49089
- vchartStage.dirtyBounds?.clear();
49090
- const pick = vchartStage.pick(point.x, point.y);
49091
- if (pick.graphic === null && pick.group.name === 'root') {
50545
+ if (!chart.AABBBounds.containsPoint(point)) {
49092
50546
  return false;
49093
50547
  }
49094
- return pick;
50548
+ return true;
49095
50549
  }
49096
50550
  };
49097
50551
  VChartPicker = __decorate([
@@ -49255,7 +50709,7 @@
49255
50709
  table.scenegraph.updateColWidth(col, newColWidth - oldColWidths[col], true, true);
49256
50710
  }
49257
50711
  }
49258
- table.scenegraph.updateContainer(true);
50712
+ table.scenegraph.updateContainer({ async: true });
49259
50713
  }
49260
50714
  if (table.isPivotTable()) {
49261
50715
  layoutMap.disableUseGetBodyCache();
@@ -52198,53 +53652,7 @@
52198
53652
  selectComp.fillhandle?.delete();
52199
53653
  });
52200
53654
  scene.selectingRangeComponents = new Map();
52201
- let needRowHeader = false;
52202
- let needRightRowHeader = false;
52203
- let needColumnHeader = false;
52204
- let needBottomColumnHeader = false;
52205
- let needBody = false;
52206
- let needCornerHeader = false;
52207
- let needRightTopCornerHeader = false;
52208
- let needRightBottomCornerHeader = false;
52209
- let needLeftBottomCornerHeader = false;
52210
- if (startCol <= table.frozenColCount - 1 && startRow <= table.frozenRowCount - 1) {
52211
- needCornerHeader = true;
52212
- }
52213
- if (endCol >= table.colCount - table.rightFrozenColCount && startRow <= table.frozenRowCount - 1) {
52214
- needRightTopCornerHeader = true;
52215
- }
52216
- if (startCol <= table.frozenColCount - 1 && endRow >= table.rowCount - table.bottomFrozenRowCount) {
52217
- needLeftBottomCornerHeader = true;
52218
- }
52219
- if (endCol >= table.colCount - table.rightFrozenColCount && endRow >= table.rowCount - table.bottomFrozenRowCount) {
52220
- needRightBottomCornerHeader = true;
52221
- }
52222
- if (startCol <= table.frozenColCount - 1 &&
52223
- endRow >= table.frozenRowCount &&
52224
- startRow <= table.rowCount - table.bottomFrozenRowCount - 1) {
52225
- needRowHeader = true;
52226
- }
52227
- if (endCol >= table.colCount - table.rightFrozenColCount &&
52228
- endRow >= table.frozenRowCount &&
52229
- startRow <= table.rowCount - table.bottomFrozenRowCount - 1) {
52230
- needRightRowHeader = true;
52231
- }
52232
- if (startRow <= table.frozenRowCount - 1 &&
52233
- endCol >= table.frozenColCount &&
52234
- startCol <= table.colCount - table.rightFrozenColCount - 1) {
52235
- needColumnHeader = true;
52236
- }
52237
- if (endRow >= table.rowCount - table.bottomFrozenRowCount &&
52238
- endCol >= table.frozenColCount &&
52239
- startCol <= table.colCount - table.rightFrozenColCount - 1) {
52240
- needBottomColumnHeader = true;
52241
- }
52242
- if (startCol <= table.colCount - table.rightFrozenColCount - 1 &&
52243
- endCol >= table.frozenColCount &&
52244
- startRow <= table.rowCount - table.bottomFrozenRowCount - 1 &&
52245
- endRow >= table.frozenRowCount) {
52246
- needBody = true;
52247
- }
53655
+ const { needRowHeader, needRightRowHeader, needColumnHeader, needBottomColumnHeader, needBody, needCornerHeader, needRightTopCornerHeader, needLeftBottomCornerHeader, needRightBottomCornerHeader } = calculateCellRangeDistribution(startCol, startRow, endCol, endRow, table);
52248
53656
  if (needCornerHeader) {
52249
53657
  const cornerEndCol = Math.min(endCol, table.frozenColCount - 1);
52250
53658
  const cornerEndRow = Math.min(endRow, table.frozenRowCount - 1);
@@ -53509,7 +54917,7 @@
53509
54917
  scene.proxy.rowStart = scene.bodyGroup.firstChild?.firstChild?.row ?? scene.table.frozenRowCount;
53510
54918
  scene.bodyGroup.setAttribute('y', scene.colHeaderGroup.attribute.height);
53511
54919
  scene.rowHeaderGroup.setAttribute('y', scene.cornerHeaderGroup.attribute.height);
53512
- scene.updateContainer();
54920
+ scene.updateContainer({ needUpdateCellY: true });
53513
54921
  scene.updateBorderSizeAndPosition();
53514
54922
  scene.hasFrozen = true;
53515
54923
  }
@@ -53521,6 +54929,9 @@
53521
54929
  continue;
53522
54930
  }
53523
54931
  const rowCell = child.firstChild;
54932
+ if (!scene.colHeaderGroup.children[i]) {
54933
+ createColGroup(scene.colHeaderGroup, 0, 0, rowCell.col, rowCell.col, 0, 0, 'columnHeader', scene.table);
54934
+ }
53524
54935
  scene.colHeaderGroup.children[i]?.appendChild(rowCell);
53525
54936
  if (!hasSetedHeight) {
53526
54937
  scene.colHeaderGroup.setAttribute('height', scene.colHeaderGroup.attribute.height + rowCell.attribute.height);
@@ -53537,6 +54948,9 @@
53537
54948
  continue;
53538
54949
  }
53539
54950
  const rowCell = child.firstChild;
54951
+ if (!scene.cornerHeaderGroup.children[i]) {
54952
+ createColGroup(scene.cornerHeaderGroup, 0, 0, rowCell.col, rowCell.col, 0, 0, scene.table.isListTable() ? 'columnHeader' : 'cornerHeader', scene.table);
54953
+ }
53540
54954
  scene.cornerHeaderGroup.children[i]?.appendChild(rowCell);
53541
54955
  if (!hasSetedHeight) {
53542
54956
  scene.cornerHeaderGroup.setAttribute('height', scene.cornerHeaderGroup.attribute.height + rowCell.attribute.height);
@@ -53553,7 +54967,10 @@
53553
54967
  continue;
53554
54968
  }
53555
54969
  const rowCell = child.firstChild;
53556
- scene.rightTopCornerGroup.children[i]?.appendChild(rowCell);
54970
+ if (!scene.rightTopCornerGroup.children[i]) {
54971
+ createColGroup(scene.rightTopCornerGroup, 0, 0, rowCell.col, rowCell.col, 0, 0, 'columnHeader', scene.table);
54972
+ }
54973
+ scene.rightTopCornerGroup.children[i].appendChild(rowCell);
53557
54974
  if (!hasSetedHeight) {
53558
54975
  scene.rightTopCornerGroup.setAttribute('height', scene.rightTopCornerGroup.attribute.height + rowCell.attribute.height);
53559
54976
  scene.rightFrozenGroup.setAttribute('height', scene.rightFrozenGroup.attribute.height - rowCell.attribute.height);
@@ -54004,6 +55421,13 @@
54004
55421
  });
54005
55422
  return x;
54006
55423
  }
55424
+ function updateContainerChildrenY(containerGroup, y) {
55425
+ containerGroup.forEachChildrenSkipChild((row, index) => {
55426
+ row.setAttribute('y', y);
55427
+ y += row.attribute.height;
55428
+ });
55429
+ return y;
55430
+ }
54007
55431
 
54008
55432
  function hideHoverIcon(col, row, scene) {
54009
55433
  if (col === -1 || row === -1) {
@@ -55173,7 +56597,7 @@
55173
56597
  updateColWidth(col, detaX, skipUpdateContainer, skipTableWidthMap) {
55174
56598
  updateColWidth(this, col, Math.round(detaX), skipTableWidthMap);
55175
56599
  if (!skipUpdateContainer) {
55176
- this.updateContainer(true);
56600
+ this.updateContainer({ async: true });
55177
56601
  }
55178
56602
  }
55179
56603
  updateChartSizeForResizeColWidth(col) {
@@ -55892,26 +57316,67 @@
55892
57316
  this.bottomFrozenGroup.setAttribute('x', this.table.getFrozenColsWidth());
55893
57317
  this.bodyGroup.setAttribute('x', this.rowHeaderGroup.attribute.width);
55894
57318
  }
55895
- updateContainer(async = false) {
55896
- if (async) {
57319
+ updateContainerAttrHeightAndY() {
57320
+ for (let i = 0; i < this.cornerHeaderGroup.children.length; i++) {
57321
+ updateContainerChildrenY(this.cornerHeaderGroup.children[i], 0);
57322
+ }
57323
+ for (let i = 0; i < this.colHeaderGroup.children.length; i++) {
57324
+ updateContainerChildrenY(this.colHeaderGroup.children[i], 0);
57325
+ }
57326
+ for (let i = 0; i < this.rightTopCornerGroup.children.length; i++) {
57327
+ updateContainerChildrenY(this.rightTopCornerGroup.children[i], 0);
57328
+ }
57329
+ for (let i = 0; i < this.rowHeaderGroup.children.length; i++) {
57330
+ this.rowHeaderGroup.children[i].firstChild &&
57331
+ updateContainerChildrenY(this.rowHeaderGroup.children[i], this.rowHeaderGroup.children[i].firstChild.row > 0
57332
+ ? this.table.getRowsHeight(this.table.frozenRowCount ?? 0, this.rowHeaderGroup.children[i].firstChild.row - 1)
57333
+ : 0);
57334
+ }
57335
+ for (let i = 0; i < this.bodyGroup.children.length; i++) {
57336
+ this.bodyGroup.children[i].firstChild &&
57337
+ updateContainerChildrenY(this.bodyGroup.children[i], this.bodyGroup.children[i].firstChild.row > 0
57338
+ ? this.table.getRowsHeight(this.table.frozenRowCount ?? 0, this.bodyGroup.children[i].firstChild.row - 1)
57339
+ : 0);
57340
+ }
57341
+ for (let i = 0; i < this.rightFrozenGroup.children.length; i++) {
57342
+ this.rightFrozenGroup.children[i].firstChild &&
57343
+ updateContainerChildrenY(this.rightFrozenGroup.children[i], this.rightFrozenGroup.children[i].firstChild.row > 0
57344
+ ? this.table.getRowsHeight(this.table.frozenRowCount ?? 0, this.rightFrozenGroup.children[i].firstChild.row - 1)
57345
+ : 0);
57346
+ }
57347
+ for (let i = 0; i < this.leftBottomCornerGroup.children.length; i++) {
57348
+ updateContainerChildrenY(this.leftBottomCornerGroup.children[i], 0);
57349
+ }
57350
+ for (let i = 0; i < this.bottomFrozenGroup.children.length; i++) {
57351
+ updateContainerChildrenY(this.bottomFrozenGroup.children[i], 0);
57352
+ }
57353
+ for (let i = 0; i < this.rightBottomCornerGroup.children.length; i++) {
57354
+ updateContainerChildrenY(this.rightBottomCornerGroup.children[i], 0);
57355
+ }
57356
+ }
57357
+ updateContainer(updateConfig = { async: false, needUpdateCellY: false }) {
57358
+ if (updateConfig.async) {
55897
57359
  if (!this._needUpdateContainer) {
55898
57360
  this._needUpdateContainer = true;
55899
57361
  setTimeout(() => {
55900
- this.updateContainerSync();
57362
+ this.updateContainerSync(updateConfig.needUpdateCellY ?? false);
55901
57363
  }, 0);
55902
57364
  }
55903
57365
  }
55904
57366
  else {
55905
57367
  this._needUpdateContainer = true;
55906
- this.updateContainerSync();
57368
+ this.updateContainerSync(updateConfig.needUpdateCellY ?? false);
55907
57369
  }
55908
57370
  }
55909
- updateContainerSync() {
57371
+ updateContainerSync(needUpdateCellY = false) {
55910
57372
  if (!this._needUpdateContainer) {
55911
57373
  return;
55912
57374
  }
55913
57375
  this._needUpdateContainer = false;
55914
57376
  this.updateContainerAttrWidthAndX();
57377
+ if (needUpdateCellY) {
57378
+ this.updateContainerAttrHeightAndY();
57379
+ }
55915
57380
  this.updateTableSize();
55916
57381
  this.component.updateScrollBar();
55917
57382
  this.updateNextFrame();
@@ -56561,6 +58026,7 @@
56561
58026
  const { table, interactionState } = state;
56562
58027
  const { scenegraph } = table;
56563
58028
  const { highlightScope, disableHeader, cellPos, disableCtrlMultiSelect } = state.select;
58029
+ state.select.isSelectAll = isSelectAll;
56564
58030
  if (col !== -1 && row !== -1 && makeSelectCellVisible) {
56565
58031
  table._makeVisibleCell(col, row);
56566
58032
  }
@@ -58260,6 +59726,126 @@
58260
59726
  }
58261
59727
  }
58262
59728
 
59729
+ function updateCustomSelectBorder(scene, selectRange, style) {
59730
+ const table = scene.table;
59731
+ const newStartCol = selectRange.start.col;
59732
+ const newStartRow = selectRange.start.row;
59733
+ const newEndCol = selectRange.end.col;
59734
+ const newEndRow = selectRange.end.row;
59735
+ selectRange.skipBodyMerge;
59736
+ const startCol = Math.max(Math.min(newEndCol, newStartCol), 0);
59737
+ const startRow = Math.max(Math.min(newEndRow, newStartRow), 0);
59738
+ const endCol = Math.min(Math.max(newEndCol, newStartCol), table.colCount - 1);
59739
+ const endRow = Math.min(Math.max(newEndRow, newStartRow), table.rowCount - 1);
59740
+ const { needRowHeader, needRightRowHeader, needColumnHeader, needBottomColumnHeader, needBody, needCornerHeader, needRightTopCornerHeader, needLeftBottomCornerHeader, needRightBottomCornerHeader } = calculateCellRangeDistribution(startCol, startRow, endCol, endRow, table);
59741
+ if (needCornerHeader) {
59742
+ const cornerEndCol = Math.min(endCol, table.frozenColCount - 1);
59743
+ const cornerEndRow = Math.min(endRow, table.frozenRowCount - 1);
59744
+ const strokeArray = [true, !needColumnHeader, !needRowHeader, true];
59745
+ createCustomCellSelectBorder(scene, startCol, startRow, cornerEndCol, cornerEndRow, 'cornerHeader', `${startCol}${startRow}${endCol}${endRow}`, strokeArray, style);
59746
+ }
59747
+ if (needRightTopCornerHeader) {
59748
+ const cornerStartCol = Math.max(startCol, table.colCount - table.rightFrozenColCount);
59749
+ const cornerEndRow = Math.min(endRow, table.frozenRowCount - 1);
59750
+ const strokeArray = [true, true, !needRightRowHeader, !needColumnHeader];
59751
+ createCustomCellSelectBorder(scene, cornerStartCol, startRow, endCol, cornerEndRow, 'rightTopCorner', `${startCol}${startRow}${endCol}${endRow}`, strokeArray, style);
59752
+ }
59753
+ if (needLeftBottomCornerHeader) {
59754
+ const cornerEndCol = Math.min(endCol, table.frozenColCount - 1);
59755
+ const cornerStartRow = Math.max(startRow, table.rowCount - table.bottomFrozenRowCount);
59756
+ const strokeArray = [!needRowHeader, !needBottomColumnHeader, true, true];
59757
+ createCustomCellSelectBorder(scene, startCol, cornerStartRow, cornerEndCol, endRow, 'leftBottomCorner', `${startCol}${startRow}${endCol}${endRow}`, strokeArray, style);
59758
+ }
59759
+ if (needRightBottomCornerHeader) {
59760
+ const cornerStartCol = Math.max(startCol, table.colCount - table.rightFrozenColCount);
59761
+ const cornerStartRow = Math.max(startRow, table.rowCount - table.bottomFrozenRowCount);
59762
+ const strokeArray = [!needRightRowHeader, true, true, !needBottomColumnHeader];
59763
+ createCustomCellSelectBorder(scene, cornerStartCol, cornerStartRow, endCol, endRow, 'rightBottomCorner', `${startCol}${startRow}${endCol}${endRow}`, strokeArray, style);
59764
+ }
59765
+ if (needColumnHeader) {
59766
+ const columnHeaderStartCol = Math.max(startCol, table.frozenColCount);
59767
+ const columnHeaderEndCol = Math.min(endCol, table.colCount - table.rightFrozenColCount - 1);
59768
+ const columnHeaderEndRow = Math.min(endRow, table.frozenRowCount - 1);
59769
+ const strokeArray = [true, !needRightTopCornerHeader, !needBody, !needCornerHeader];
59770
+ createCustomCellSelectBorder(scene, columnHeaderStartCol, startRow, columnHeaderEndCol, columnHeaderEndRow, 'columnHeader', `${startCol}${startRow}${endCol}${endRow}`, strokeArray, style);
59771
+ }
59772
+ if (needBottomColumnHeader) {
59773
+ const columnHeaderStartCol = Math.max(startCol, table.frozenColCount);
59774
+ const columnHeaderEndCol = Math.min(endCol, table.colCount - table.rightFrozenColCount - 1);
59775
+ const columnHeaderStartRow = Math.max(startRow, table.rowCount - table.bottomFrozenRowCount);
59776
+ const strokeArray = [!needBody, !needRightBottomCornerHeader, true, !needLeftBottomCornerHeader];
59777
+ createCustomCellSelectBorder(scene, columnHeaderStartCol, columnHeaderStartRow, columnHeaderEndCol, endRow, 'bottomFrozen', `${startCol}${startRow}${endCol}${endRow}`, strokeArray, style);
59778
+ }
59779
+ if (needRowHeader) {
59780
+ const columnHeaderStartRow = Math.max(startRow, table.frozenRowCount);
59781
+ const columnHeaderEndRow = Math.min(endRow, table.rowCount - table.bottomFrozenRowCount - 1);
59782
+ const columnHeaderEndCol = Math.min(endCol, table.frozenColCount - 1);
59783
+ const strokeArray = [!needCornerHeader, !needBody, !needLeftBottomCornerHeader, true];
59784
+ createCustomCellSelectBorder(scene, startCol, columnHeaderStartRow, columnHeaderEndCol, columnHeaderEndRow, 'rowHeader', `${startCol}${startRow}${endCol}${endRow}`, strokeArray, style);
59785
+ }
59786
+ if (needRightRowHeader) {
59787
+ const columnHeaderStartRow = Math.max(startRow, table.frozenRowCount);
59788
+ const columnHeaderEndRow = Math.min(endRow, table.rowCount - table.bottomFrozenRowCount - 1);
59789
+ const columnHeaderStartCol = Math.max(startCol, table.colCount - table.rightFrozenColCount);
59790
+ const strokeArray = [!needRightTopCornerHeader, true, !needRightBottomCornerHeader, !needBody];
59791
+ createCustomCellSelectBorder(scene, columnHeaderStartCol, columnHeaderStartRow, endCol, columnHeaderEndRow, 'rightFrozen', `${startCol}${startRow}${endCol}${endRow}`, strokeArray, style);
59792
+ }
59793
+ if (needBody) {
59794
+ const columnHeaderStartCol = Math.max(startCol, table.frozenColCount);
59795
+ const columnHeaderStartRow = Math.max(startRow, table.frozenRowCount);
59796
+ const columnHeaderEndCol = Math.min(endCol, table.colCount - table.rightFrozenColCount - 1);
59797
+ const columnHeaderEndRow = Math.min(endRow, table.rowCount - table.bottomFrozenRowCount - 1);
59798
+ const strokeArray = [!needColumnHeader, !needRightRowHeader, !needBottomColumnHeader, !needRowHeader];
59799
+ createCustomCellSelectBorder(scene, columnHeaderStartCol, columnHeaderStartRow, columnHeaderEndCol, columnHeaderEndRow, 'body', `${startCol}${startRow}${endCol}${endRow}`, strokeArray, style);
59800
+ }
59801
+ }
59802
+ function createCustomCellSelectBorder(scene, start_Col, start_Row, end_Col, end_Row, selectRangeType, selectId, strokes, style) {
59803
+ const startCol = Math.min(start_Col, end_Col);
59804
+ const startRow = Math.min(start_Row, end_Row);
59805
+ const endCol = Math.max(start_Col, end_Col);
59806
+ const endRow = Math.max(start_Row, end_Row);
59807
+ const firstCellBound = scene.highPerformanceGetCell(startCol, startRow).globalAABBBounds;
59808
+ const rect = createRect({
59809
+ pickable: false,
59810
+ fill: style.cellBgColor ?? false,
59811
+ lineWidth: style.cellBorderLineWidth ?? 0,
59812
+ lineDash: style.cellBorderLineDash ?? [],
59813
+ stroke: strokes.map(stroke => {
59814
+ if (stroke) {
59815
+ return style.cellBorderColor;
59816
+ }
59817
+ return false;
59818
+ }),
59819
+ x: firstCellBound.x1 - scene.tableGroup.attribute.x,
59820
+ y: firstCellBound.y1 - scene.tableGroup.attribute.y,
59821
+ width: 0,
59822
+ height: 0,
59823
+ visible: true,
59824
+ cornerRadius: getCornerRadius(selectRangeType, scene.table.theme.frameStyle?.cornerRadius, start_Col, start_Row, end_Col, end_Row, scene.table)
59825
+ });
59826
+ scene.customSelectedRangeComponents.set(`${startCol}-${startRow}-${endCol}-${endRow}-${selectId}`, {
59827
+ rect,
59828
+ role: selectRangeType
59829
+ });
59830
+ scene.tableGroup.insertAfter(rect, selectRangeType === 'body'
59831
+ ? scene.bodyGroup
59832
+ : selectRangeType === 'columnHeader'
59833
+ ? scene.colHeaderGroup
59834
+ : selectRangeType === 'rowHeader'
59835
+ ? scene.rowHeaderGroup
59836
+ : selectRangeType === 'cornerHeader'
59837
+ ? scene.cornerHeaderGroup
59838
+ : selectRangeType === 'rightTopCorner'
59839
+ ? scene.rightTopCornerGroup
59840
+ : selectRangeType === 'rightFrozen'
59841
+ ? scene.rightFrozenGroup
59842
+ : selectRangeType === 'leftBottomCorner'
59843
+ ? scene.leftBottomCornerGroup
59844
+ : selectRangeType === 'bottomFrozen'
59845
+ ? scene.bottomFrozenGroup
59846
+ : scene.rightBottomCornerGroup);
59847
+ }
59848
+
58263
59849
  function deletaCustomSelectRanges(state) {
58264
59850
  const { customSelectedRangeComponents } = state.table.scenegraph;
58265
59851
  customSelectedRangeComponents.forEach((selectComp, key) => {
@@ -58269,20 +59855,8 @@
58269
59855
  state.select.customSelectRanges = [];
58270
59856
  }
58271
59857
  function addCustomSelectRanges(customSelectRanges, state) {
58272
- const { customSelectedRangeComponents } = state.table.scenegraph;
58273
59858
  customSelectRanges.forEach((customRange) => {
58274
- const { range, style } = customRange;
58275
- const rect = createRect({
58276
- fill: style.cellBgColor ?? false,
58277
- stroke: style.cellBorderColor ?? false,
58278
- lineWidth: style.cellBorderLineWidth ?? 0,
58279
- lineDash: style.cellBorderLineDash ?? [],
58280
- pickable: false
58281
- });
58282
- customSelectedRangeComponents.set(`${range.start.col}-${range.start.row}-${range.end.col}-${range.end.row}`, {
58283
- rect,
58284
- role: 'body'
58285
- });
59859
+ updateCustomSelectBorder(state.table.scenegraph, customRange.range, customRange.style);
58286
59860
  });
58287
59861
  state.select.customSelectRanges = customSelectRanges;
58288
59862
  updateAllSelectComponent(state.table.scenegraph);
@@ -58647,7 +60221,17 @@
58647
60221
  if (row > this.table.rowCount - 1) {
58648
60222
  row = this.table.rowCount - 1;
58649
60223
  }
60224
+ const oldCellPosCol = this.select.cellPos.col;
60225
+ const oldCellPosRow = this.select.cellPos.row;
58650
60226
  updateSelectPosition(this, col, row, isShift, isCtrl, isSelectAll, makeSelectCellVisible, skipBodyMerge);
60227
+ if (this.table.hasListeners(TABLE_EVENT_TYPE.SELECTED_CHANGED) &&
60228
+ (oldCellPosCol !== col || oldCellPosRow !== row)) {
60229
+ this.table.fireListeners(TABLE_EVENT_TYPE.SELECTED_CHANGED, {
60230
+ ranges: this.select.ranges,
60231
+ col: col,
60232
+ row: row
60233
+ });
60234
+ }
58651
60235
  }
58652
60236
  checkCellRangeInSelect(cellPosStart, cellPosEnd) {
58653
60237
  return checkMultiCellInSelect(cellPosStart, cellPosEnd, this.select.ranges, this.select.highlightScope);
@@ -59384,6 +60968,9 @@
59384
60968
  event
59385
60969
  });
59386
60970
  }
60971
+ setSelectInline(selectInline) {
60972
+ this.select.selectInline = selectInline;
60973
+ }
59387
60974
  updateSortState(sortState) {
59388
60975
  sortState = Array.isArray(sortState) ? sortState : [sortState];
59389
60976
  for (let index = 0; index < sortState.length; index++) {
@@ -59456,7 +61043,10 @@
59456
61043
  }
59457
61044
  this.frozen.icon = iconMark;
59458
61045
  }
59459
- updateCursor(mode = 'default') {
61046
+ updateCursor(mode) {
61047
+ if (!mode) {
61048
+ mode = this.table.options.defaultCursor ?? 'default';
61049
+ }
59460
61050
  this.table.getElement().style.cursor = mode;
59461
61051
  }
59462
61052
  updateDrillState(dimensionKey, title, drillDown, drillUp, col, row) {
@@ -59929,8 +61519,7 @@
59929
61519
  mergeCellInfo: eventArgsSet.eventArgs?.mergeInfo
59930
61520
  });
59931
61521
  }
59932
- if (stateManager.interactionState === InteractionState.grabing &&
59933
- !table.editorManager?.editingEditor) {
61522
+ if (stateManager.interactionState === InteractionState.grabing) {
59934
61523
  if (Math.abs(lastX - e.x) + Math.abs(lastY - e.y) >= 1) {
59935
61524
  if (stateManager.isResizeCol() || stateManager.isResizeRow()) ;
59936
61525
  else if (stateManager.isMoveCol()) {
@@ -60144,7 +61733,7 @@
60144
61733
  }
60145
61734
  const isCompleteEdit = table.editorManager?.completeEdit(e.nativeEvent);
60146
61735
  getPromiseValue(isCompleteEdit, isCompleteEdit => {
60147
- if (isCompleteEdit === false) {
61736
+ if (!table.options.customConfig?.selectCellWhenCellEditorNotExists && isCompleteEdit === false) {
60148
61737
  return;
60149
61738
  }
60150
61739
  const hitIcon = eventArgsSet?.eventArgs?.target?.role?.startsWith('icon')
@@ -60431,9 +62020,13 @@
60431
62020
  eventArgsSet.eventArgs?.target !== stateManager.residentHoverIcon?.icon) {
60432
62021
  stateManager.hideMenu();
60433
62022
  }
60434
- const isCompleteEdit = table.editorManager?.completeEdit(e.nativeEvent);
62023
+ let isCompleteEdit = false;
62024
+ const target = e.target;
62025
+ if (target !== table.scenegraph.tableGroup && !target.isDescendantsOf(table.scenegraph.tableGroup)) {
62026
+ isCompleteEdit = table.editorManager?.completeEdit(e.nativeEvent);
62027
+ }
60435
62028
  getPromiseValue(isCompleteEdit, isCompleteEdit => {
60436
- if (isCompleteEdit === false) {
62029
+ if (!table.options.customConfig?.selectCellWhenCellEditorNotExists && isCompleteEdit === false) {
60437
62030
  return;
60438
62031
  }
60439
62032
  const hitIcon = e.target.role?.startsWith('icon') ? e.target : undefined;
@@ -60480,7 +62073,12 @@
60480
62073
  stateManager.updateInteractionState(InteractionState.default);
60481
62074
  eventManager.dealTableHover();
60482
62075
  const isHasSelected = !!stateManager.select.ranges?.length;
60483
- if (table.options.select?.blankAreaClickDeselect ?? true) {
62076
+ if (table.options.customConfig?.cancelSelectCellHook) {
62077
+ if (table.options.customConfig?.cancelSelectCellHook(e)) {
62078
+ eventManager.dealTableSelect();
62079
+ }
62080
+ }
62081
+ else if (table.options.select?.blankAreaClickDeselect ?? true) {
60484
62082
  eventManager.dealTableSelect();
60485
62083
  }
60486
62084
  stateManager.endSelectCells(true, isHasSelected);
@@ -60814,7 +62412,7 @@
60814
62412
  scenegraph.table.eventManager.isDraging = false;
60815
62413
  });
60816
62414
  scenegraph.component.hScrollBar.addEventListener('pointermove', (e) => {
60817
- scenegraph.table.stateManager.updateCursor('default');
62415
+ scenegraph.table.stateManager.updateCursor();
60818
62416
  e.stopPropagation();
60819
62417
  });
60820
62418
  scenegraph.component.hScrollBar.addEventListener('pointerdown', (e) => {
@@ -61096,121 +62694,17 @@
61096
62694
  }
61097
62695
  handler.on(table.getElement(), 'copy', async (e) => {
61098
62696
  if (table.keyboardOptions?.copySelected) {
61099
- const data = table.getCopyValue();
61100
- if (isValid$3(data)) {
61101
- e.preventDefault();
61102
- const permissionState = await navigator.permissions.query({ name: 'clipboard-write' });
61103
- if (navigator.clipboard?.write && permissionState.state === 'granted') {
61104
- const setDataToHTML = (data) => {
61105
- const result = ['<table>'];
61106
- const META_HEAD = [
61107
- '<meta name="author" content="Visactor"/>',
61108
- '<style type="text/css">td{white-space:normal}br{mso-data-placement:same-cell}</style>'
61109
- ].join('');
61110
- const rows = data.split('\r\n');
61111
- rows.forEach(function (rowCells, rowIndex) {
61112
- const cells = rowCells.split('\t');
61113
- const rowValues = [];
61114
- if (rowIndex === 0) {
61115
- result.push('<tbody>');
61116
- }
61117
- cells.forEach(function (cell, cellIndex) {
61118
- const parsedCellData = !cell
61119
- ? ' '
61120
- : cell
61121
- .toString()
61122
- .replace(/&/g, '&amp;')
61123
- .replace(/'/g, '&#39;')
61124
- .replace(/</g, '&lt;')
61125
- .replace(/>/g, '&gt;')
61126
- .replace(/\n/g, '<br>')
61127
- .replace(/(<br(\s*|\/)>(\r\n|\n)?|\r\n|\n)/g, '<br>\r\n')
61128
- .replace(/\x20{2,}/gi, (substring) => {
61129
- return `<span style="mso-spacerun: yes">${'&nbsp;'.repeat(substring.length - 1)} </span>`;
61130
- })
61131
- .replace(/\t/gi, '&#9;');
61132
- rowValues.push(`<td>${parsedCellData}</td>`);
61133
- });
61134
- result.push('<tr>', ...rowValues, '</tr>');
61135
- if (rowIndex === rows.length - 1) {
61136
- result.push('</tbody>');
61137
- }
61138
- });
61139
- result.push('</table>');
61140
- return [META_HEAD, result.join('')].join('');
61141
- };
61142
- const dataHTML = setDataToHTML(data);
61143
- navigator.clipboard.write([
61144
- new ClipboardItem({
61145
- 'text/html': new Blob([dataHTML], { type: 'text/html' }),
61146
- 'text/plain': new Blob([data], { type: 'text/plain' })
61147
- })
61148
- ]);
61149
- }
61150
- else {
61151
- if (browser.IE) {
61152
- window.clipboardData.setData('Text', data);
61153
- }
61154
- else {
61155
- e.clipboardData.setData('text/plain', data);
61156
- }
61157
- }
61158
- table.fireListeners(TABLE_EVENT_TYPE.COPY_DATA, {
61159
- cellRange: table.stateManager.select.ranges,
61160
- copyData: data
61161
- });
61162
- }
62697
+ eventManager.handleCopy(e);
62698
+ }
62699
+ });
62700
+ handler.on(table.getElement(), 'cut', async (e) => {
62701
+ if (table.keyboardOptions?.cutSelected) {
62702
+ eventManager.handleCut(e);
61163
62703
  }
61164
62704
  });
61165
62705
  handler.on(table.getElement(), 'paste', async (e) => {
61166
- if (table.keyboardOptions?.pasteValueToCell && table.changeCellValues) {
61167
- if (table.editorManager?.editingEditor) {
61168
- return;
61169
- }
61170
- if (table.stateManager.select.ranges?.length > 0) {
61171
- if (navigator.clipboard?.read) {
61172
- navigator.clipboard.read().then(clipboardItems => {
61173
- for (const item of clipboardItems) {
61174
- if (item.types.includes('text/html')) {
61175
- pasteHtmlToTable(item);
61176
- }
61177
- else if (item.types.length === 1 && item.types[0] === 'text/plain') {
61178
- pasteTextToTable(item);
61179
- }
61180
- else ;
61181
- }
61182
- });
61183
- }
61184
- else {
61185
- const ranges = table.stateManager.select.ranges;
61186
- const col = Math.min(ranges[0].start.col, ranges[0].end.col);
61187
- const row = Math.min(ranges[0].start.row, ranges[0].end.row);
61188
- const clipboardData = e.clipboardData || window.Clipboard;
61189
- const pastedData = clipboardData.getData('text');
61190
- const rows = pastedData.split('\n');
61191
- const values = [];
61192
- rows.forEach(function (rowCells, rowIndex) {
61193
- const cells = rowCells.split('\t');
61194
- const rowValues = [];
61195
- values.push(rowValues);
61196
- cells.forEach(function (cell, cellIndex) {
61197
- if (cellIndex === cells.length - 1) {
61198
- cell = cell.trim();
61199
- }
61200
- rowValues.push(cell);
61201
- });
61202
- });
61203
- const changedCellResults = await table.changeCellValues(col, row, values);
61204
- if (table.hasListeners(TABLE_EVENT_TYPE.PASTED_DATA)) {
61205
- table.fireListeners(TABLE_EVENT_TYPE.PASTED_DATA, {
61206
- col,
61207
- row,
61208
- pasteData: values,
61209
- changedCellResults
61210
- });
61211
- }
61212
- }
61213
- }
62706
+ if (table.keyboardOptions?.pasteValueToCell) {
62707
+ eventManager.handlePaste(e);
61214
62708
  }
61215
62709
  });
61216
62710
  handler.on(table.getElement(), 'contextmenu', (e) => {
@@ -61240,162 +62734,6 @@
61240
62734
  }
61241
62735
  });
61242
62736
  }
61243
- const regex = /<tr[^>]*>([\s\S]*?)<\/tr>/g;
61244
- const cellRegex = /<td[^>]*>([\s\S]*?)<\/td>/g;
61245
- function pasteHtmlToTable(item) {
61246
- const ranges = table.stateManager.select.ranges;
61247
- const selectRangeLength = ranges.length;
61248
- const col = Math.min(ranges[selectRangeLength - 1].start.col, ranges[selectRangeLength - 1].end.col);
61249
- const row = Math.min(ranges[selectRangeLength - 1].start.row, ranges[selectRangeLength - 1].end.row);
61250
- const maxCol = Math.max(ranges[selectRangeLength - 1].start.col, ranges[selectRangeLength - 1].end.col);
61251
- const maxRow = Math.max(ranges[selectRangeLength - 1].start.row, ranges[selectRangeLength - 1].end.row);
61252
- let pasteValuesColCount = 0;
61253
- let pasteValuesRowCount = 0;
61254
- let values = [];
61255
- item.getType('text/html').then((blob) => {
61256
- blob.text().then(async (pastedData) => {
61257
- if (pastedData && /(<table)|(<TABLE)/g.test(pastedData)) {
61258
- const matches = Array.from(pastedData.matchAll(regex));
61259
- for (const match of matches) {
61260
- const rowContent = match[1];
61261
- const cellMatches = Array.from(rowContent.matchAll(cellRegex));
61262
- const rowValues = cellMatches.map(cellMatch => {
61263
- return (cellMatch[1]
61264
- .replace(/(<(?!br)([^>]+)>)/gi, '')
61265
- .replace(/<br(\s*|\/)>[\r\n]?/gim, '\n')
61266
- .replace(/&amp;/g, '&')
61267
- .replace(/&lt;/g, '<')
61268
- .replace(/&gt;/g, '>')
61269
- .replace(/&#9;/gi, '\t')
61270
- .replace(/&nbsp;/g, ' '));
61271
- });
61272
- values.push(rowValues);
61273
- pasteValuesColCount = Math.max(pasteValuesColCount, rowValues?.length ?? 0);
61274
- }
61275
- pasteValuesRowCount = values.length ?? 0;
61276
- values = handlePasteValues(values, pasteValuesRowCount, pasteValuesColCount, maxRow - row + 1, maxCol - col + 1);
61277
- const changedCellResults = await table.changeCellValues(col, row, values, true);
61278
- if (table.hasListeners(TABLE_EVENT_TYPE.PASTED_DATA)) {
61279
- table.fireListeners(TABLE_EVENT_TYPE.PASTED_DATA, {
61280
- col,
61281
- row,
61282
- pasteData: values,
61283
- changedCellResults
61284
- });
61285
- }
61286
- }
61287
- else {
61288
- navigator.clipboard.read().then(clipboardItems => {
61289
- for (const item of clipboardItems) {
61290
- if (item.types.includes('text/plain')) {
61291
- item.getType('text/plain').then((blob) => {
61292
- blob.text().then(_pasteValue);
61293
- });
61294
- }
61295
- }
61296
- });
61297
- }
61298
- });
61299
- });
61300
- }
61301
- async function _pasteValue(pastedData) {
61302
- const ranges = table.stateManager.select.ranges;
61303
- const selectRangeLength = ranges.length;
61304
- const col = Math.min(ranges[selectRangeLength - 1].start.col, ranges[selectRangeLength - 1].end.col);
61305
- const row = Math.min(ranges[selectRangeLength - 1].start.row, ranges[selectRangeLength - 1].end.row);
61306
- const maxCol = Math.max(ranges[selectRangeLength - 1].start.col, ranges[selectRangeLength - 1].end.col);
61307
- const maxRow = Math.max(ranges[selectRangeLength - 1].start.row, ranges[selectRangeLength - 1].end.row);
61308
- let pasteValuesColCount = 0;
61309
- let pasteValuesRowCount = 0;
61310
- let values = [];
61311
- const rows = pastedData.split('\n');
61312
- rows.forEach(function (rowCells, rowIndex) {
61313
- const cells = rowCells.split('\t');
61314
- const rowValues = [];
61315
- values.push(rowValues);
61316
- cells.forEach(function (cell, cellIndex) {
61317
- if (cellIndex === cells.length - 1) {
61318
- cell = cell.trim();
61319
- }
61320
- rowValues.push(cell);
61321
- });
61322
- pasteValuesColCount = Math.max(pasteValuesColCount, rowValues?.length ?? 0);
61323
- });
61324
- pasteValuesRowCount = values.length ?? 0;
61325
- values = handlePasteValues(values, pasteValuesRowCount, pasteValuesColCount, maxRow - row + 1, maxCol - col + 1);
61326
- const changedCellResults = await table.changeCellValues(col, row, values, true);
61327
- if (table.hasListeners(TABLE_EVENT_TYPE.PASTED_DATA)) {
61328
- table.fireListeners(TABLE_EVENT_TYPE.PASTED_DATA, {
61329
- col,
61330
- row,
61331
- pasteData: values,
61332
- changedCellResults
61333
- });
61334
- }
61335
- }
61336
- function pasteTextToTable(item) {
61337
- const ranges = table.stateManager.select.ranges;
61338
- const selectRangeLength = ranges.length;
61339
- const col = Math.min(ranges[selectRangeLength - 1].start.col, ranges[selectRangeLength - 1].end.col);
61340
- const row = Math.min(ranges[selectRangeLength - 1].start.row, ranges[selectRangeLength - 1].end.row);
61341
- const maxCol = Math.max(ranges[selectRangeLength - 1].start.col, ranges[selectRangeLength - 1].end.col);
61342
- const maxRow = Math.max(ranges[selectRangeLength - 1].start.row, ranges[selectRangeLength - 1].end.row);
61343
- let pasteValuesColCount = 0;
61344
- let pasteValuesRowCount = 0;
61345
- item.getType('text/plain').then((blob) => {
61346
- blob.text().then(async (pastedData) => {
61347
- const rows = pastedData.replace(/\r(?!\n)/g, '\r\n').split('\r\n');
61348
- let values = [];
61349
- if (rows.length > 1 && rows[rows.length - 1] === '') {
61350
- rows.pop();
61351
- }
61352
- rows.forEach(function (rowCells, rowIndex) {
61353
- const cells = rowCells.split('\t');
61354
- const rowValues = [];
61355
- values.push(rowValues);
61356
- cells.forEach(function (cell, cellIndex) {
61357
- if (cell.includes('\n')) {
61358
- cell = cell
61359
- .replace(/^"(.*)"$/, '$1')
61360
- .replace(/["]*/g, match => new Array(Math.floor(match.length / 2)).fill('"').join(''));
61361
- }
61362
- rowValues.push(cell);
61363
- });
61364
- pasteValuesColCount = Math.max(pasteValuesColCount, rowValues?.length ?? 0);
61365
- });
61366
- pasteValuesRowCount = values.length ?? 0;
61367
- values = handlePasteValues(values, pasteValuesRowCount, pasteValuesColCount, maxRow - row + 1, maxCol - col + 1);
61368
- const changedCellResults = await table.changeCellValues(col, row, values, true);
61369
- if (table.hasListeners(TABLE_EVENT_TYPE.PASTED_DATA)) {
61370
- table.fireListeners(TABLE_EVENT_TYPE.PASTED_DATA, {
61371
- col,
61372
- row,
61373
- pasteData: values,
61374
- changedCellResults
61375
- });
61376
- }
61377
- });
61378
- });
61379
- }
61380
- function handlePasteValues(values, rowCount, colCount, selectedRowCount, selectedColCount) {
61381
- if (selectedColCount > colCount || selectedRowCount > rowCount) {
61382
- if (selectedColCount % colCount === 0 && selectedRowCount % rowCount === 0) {
61383
- const toPasteValues = [];
61384
- for (let i = 0; i < selectedRowCount; i++) {
61385
- const rowPasteValue = [];
61386
- toPasteValues.push(rowPasteValue);
61387
- for (let j = 0; j < selectedColCount; j++) {
61388
- const copiedRow = i % rowCount;
61389
- const copiedCol = j % colCount;
61390
- rowPasteValue.push(values[copiedRow][copiedCol]);
61391
- }
61392
- }
61393
- return toPasteValues;
61394
- }
61395
- return values;
61396
- }
61397
- return values;
61398
- }
61399
62737
  const globalPointerdownCallback = (e) => {
61400
62738
  if (table.isReleased) {
61401
62739
  return;
@@ -61622,7 +62960,7 @@
61622
62960
  const targetCol = table.getTargetColAtConsiderRightFrozen(selectX, considerFrozenX);
61623
62961
  const targetRow = table.getTargetRowAtConsiderBottomFrozen(selectY, considerFrozenY);
61624
62962
  if (!table.options.select?.disableDragSelect && isValid$3(targetCol) && isValid$3(targetRow)) {
61625
- table.stateManager.updateSelectPos(targetCol.col, targetRow.row, false, false, false, false);
62963
+ table.stateManager.updateSelectPos(table.stateManager.select.selectInline === 'row' ? table.colCount - 1 : targetCol.col, table.stateManager.select.selectInline === 'col' ? table.rowCount - 1 : targetRow.row, false, false, false, false);
61626
62964
  }
61627
62965
  });
61628
62966
  }
@@ -62242,6 +63580,11 @@
62242
63580
  inertiaScroll;
62243
63581
  bindSparklineHoverEvent;
62244
63582
  _enableTableScroll = true;
63583
+ cutWaitPaste = false;
63584
+ clipboardCheckTimer = null;
63585
+ cutOperationTime = 0;
63586
+ lastClipboardContent = '';
63587
+ cutCellRange = null;
62245
63588
  constructor(table) {
62246
63589
  this.table = table;
62247
63590
  this.handleTextStickBindId = [];
@@ -62366,7 +63709,7 @@
62366
63709
  this.table.stateManager.updateSelectPos(-1, -1);
62367
63710
  return false;
62368
63711
  }
62369
- this.table.stateManager.updateSelectPos(eventArgs.col, eventArgs.row, eventArgs.event.shiftKey, eventArgs.event.ctrlKey || eventArgs.event.metaKey, false, isSelectMoving ? false : this.table.options.select?.makeSelectCellVisible ?? true);
63712
+ this.table.stateManager.updateSelectPos(this.table.stateManager.select.selectInline === 'row' ? this.table.colCount - 1 : eventArgs.col, this.table.stateManager.select.selectInline === 'col' ? this.table.rowCount - 1 : eventArgs.row, eventArgs.event.shiftKey, eventArgs.event.ctrlKey || eventArgs.event.metaKey, false, isSelectMoving ? false : this.table.options.select?.makeSelectCellVisible ?? true);
62370
63713
  return true;
62371
63714
  }
62372
63715
  return false;
@@ -62609,6 +63952,383 @@
62609
63952
  disableScroll() {
62610
63953
  this._enableTableScroll = false;
62611
63954
  }
63955
+ async handleCopy(e, isCut = false) {
63956
+ const table = this.table;
63957
+ !isCut && (this.cutWaitPaste = false);
63958
+ const data = this.table.getCopyValue();
63959
+ if (isValid$3(data)) {
63960
+ e.preventDefault();
63961
+ const permissionState = await navigator.permissions.query({ name: 'clipboard-write' });
63962
+ if (navigator.clipboard?.write && permissionState.state === 'granted') {
63963
+ const setDataToHTML = (data) => {
63964
+ const result = ['<table>'];
63965
+ const META_HEAD = [
63966
+ '<meta name="author" content="Visactor"/>',
63967
+ '<style type="text/css">td{white-space:normal}br{mso-data-placement:same-cell}</style>'
63968
+ ].join('');
63969
+ const rows = data.split('\r\n');
63970
+ rows.forEach(function (rowCells, rowIndex) {
63971
+ const cells = rowCells.split('\t');
63972
+ const rowValues = [];
63973
+ if (rowIndex === 0) {
63974
+ result.push('<tbody>');
63975
+ }
63976
+ cells.forEach(function (cell, cellIndex) {
63977
+ const parsedCellData = !cell
63978
+ ? ' '
63979
+ : cell
63980
+ .toString()
63981
+ .replace(/&/g, '&amp;')
63982
+ .replace(/'/g, '&#39;')
63983
+ .replace(/</g, '&lt;')
63984
+ .replace(/>/g, '&gt;')
63985
+ .replace(/\n/g, '<br>')
63986
+ .replace(/(<br(\s*|\/)>(\r\n|\n)?|\r\n|\n)/g, '<br>\r\n')
63987
+ .replace(/\x20{2,}/gi, (substring) => {
63988
+ return `<span style="mso-spacerun: yes">${'&nbsp;'.repeat(substring.length - 1)} </span>`;
63989
+ })
63990
+ .replace(/\t/gi, '&#9;');
63991
+ rowValues.push(`<td>${parsedCellData}</td>`);
63992
+ });
63993
+ result.push('<tr>', ...rowValues, '</tr>');
63994
+ if (rowIndex === rows.length - 1) {
63995
+ result.push('</tbody>');
63996
+ }
63997
+ });
63998
+ result.push('</table>');
63999
+ return [META_HEAD, result.join('')].join('');
64000
+ };
64001
+ const dataHTML = setDataToHTML(data);
64002
+ navigator.clipboard.write([
64003
+ new ClipboardItem({
64004
+ 'text/html': new Blob([dataHTML], { type: 'text/html' }),
64005
+ 'text/plain': new Blob([data], { type: 'text/plain' })
64006
+ })
64007
+ ]);
64008
+ }
64009
+ else {
64010
+ if (browser.IE) {
64011
+ window.clipboardData.setData('Text', data);
64012
+ }
64013
+ else {
64014
+ e.clipboardData.setData('text/plain', data);
64015
+ }
64016
+ }
64017
+ table.fireListeners(TABLE_EVENT_TYPE.COPY_DATA, {
64018
+ cellRange: table.stateManager.select.ranges,
64019
+ copyData: data,
64020
+ isCut
64021
+ });
64022
+ }
64023
+ if (table.keyboardOptions?.showCopyCellBorder) {
64024
+ setActiveCellRangeState(table);
64025
+ table.clearSelected();
64026
+ }
64027
+ }
64028
+ async handleCut(e) {
64029
+ this.handleCopy(e, true);
64030
+ this.cutWaitPaste = true;
64031
+ this.cutCellRange = this.table.getSelectedCellInfos();
64032
+ if (this.clipboardCheckTimer) {
64033
+ clearTimeout(this.clipboardCheckTimer);
64034
+ }
64035
+ this.clipboardCheckTimer = window.setTimeout(() => {
64036
+ if (this.cutWaitPaste) {
64037
+ this.cutWaitPaste = false;
64038
+ this.cutCellRange = null;
64039
+ this.clipboardCheckTimer = null;
64040
+ }
64041
+ }, 30000);
64042
+ this.saveClipboardContent();
64043
+ }
64044
+ handlePaste(e) {
64045
+ if (!this.cutWaitPaste) {
64046
+ this.executePaste(e);
64047
+ return;
64048
+ }
64049
+ this.checkClipboardChanged()
64050
+ .then(changed => {
64051
+ this.executePaste(e);
64052
+ if (!changed) {
64053
+ this.clearCutArea(this.table);
64054
+ }
64055
+ if (this.cutWaitPaste) {
64056
+ this.cutWaitPaste = false;
64057
+ this.cutCellRange = null;
64058
+ if (this.clipboardCheckTimer) {
64059
+ clearTimeout(this.clipboardCheckTimer);
64060
+ this.clipboardCheckTimer = null;
64061
+ }
64062
+ }
64063
+ })
64064
+ .catch(() => {
64065
+ this.executePaste(e);
64066
+ if (this.cutWaitPaste) {
64067
+ this.cutWaitPaste = false;
64068
+ this.cutCellRange = null;
64069
+ if (this.clipboardCheckTimer) {
64070
+ clearTimeout(this.clipboardCheckTimer);
64071
+ this.clipboardCheckTimer = null;
64072
+ }
64073
+ }
64074
+ });
64075
+ }
64076
+ async executePaste(e) {
64077
+ const table = this.table;
64078
+ if (table.changeCellValues) {
64079
+ if (table.editorManager?.editingEditor) {
64080
+ return;
64081
+ }
64082
+ if (table.stateManager.select.ranges?.length > 0) {
64083
+ if (navigator.clipboard?.read) {
64084
+ navigator.clipboard.read().then(clipboardItems => {
64085
+ for (const item of clipboardItems) {
64086
+ if (item.types.includes('text/html')) {
64087
+ this.pasteHtmlToTable(item);
64088
+ }
64089
+ else if (item.types.length === 1 && item.types[0] === 'text/plain') {
64090
+ this.pasteTextToTable(item);
64091
+ }
64092
+ else ;
64093
+ }
64094
+ });
64095
+ }
64096
+ else {
64097
+ const ranges = table.stateManager.select.ranges;
64098
+ const col = Math.min(ranges[0].start.col, ranges[0].end.col);
64099
+ const row = Math.min(ranges[0].start.row, ranges[0].end.row);
64100
+ const clipboardData = e.clipboardData || window.Clipboard;
64101
+ const pastedData = clipboardData.getData('text');
64102
+ const rows = pastedData.split('\n');
64103
+ const values = [];
64104
+ rows.forEach(function (rowCells, rowIndex) {
64105
+ const cells = rowCells.split('\t');
64106
+ const rowValues = [];
64107
+ values.push(rowValues);
64108
+ cells.forEach(function (cell, cellIndex) {
64109
+ if (cellIndex === cells.length - 1) {
64110
+ cell = cell.trim();
64111
+ }
64112
+ rowValues.push(cell);
64113
+ });
64114
+ });
64115
+ const changedCellResults = await table.changeCellValues(col, row, values);
64116
+ if (table.hasListeners(TABLE_EVENT_TYPE.PASTED_DATA)) {
64117
+ table.fireListeners(TABLE_EVENT_TYPE.PASTED_DATA, {
64118
+ col,
64119
+ row,
64120
+ pasteData: values,
64121
+ changedCellResults
64122
+ });
64123
+ }
64124
+ }
64125
+ }
64126
+ }
64127
+ if (table.keyboardOptions?.showCopyCellBorder) {
64128
+ clearActiveCellRangeState(table);
64129
+ }
64130
+ }
64131
+ clearCutArea(table) {
64132
+ try {
64133
+ const selectCells = this.cutCellRange;
64134
+ if (!selectCells || selectCells.length === 0) {
64135
+ return;
64136
+ }
64137
+ for (let i = 0; i < selectCells.length; i++) {
64138
+ for (let j = 0; j < selectCells[i].length; j++) {
64139
+ if (selectCells[i][j]) {
64140
+ table.changeCellValue(selectCells[i][j].col, selectCells[i][j].row, undefined);
64141
+ }
64142
+ }
64143
+ }
64144
+ }
64145
+ catch (error) {
64146
+ }
64147
+ }
64148
+ async checkClipboardChanged() {
64149
+ if (!navigator.clipboard || !navigator.clipboard.readText) {
64150
+ return false;
64151
+ }
64152
+ try {
64153
+ const currentContent = await navigator.clipboard.readText();
64154
+ return currentContent !== this.lastClipboardContent;
64155
+ }
64156
+ catch (err) {
64157
+ return false;
64158
+ }
64159
+ }
64160
+ saveClipboardContent() {
64161
+ if (navigator.clipboard && navigator.clipboard.readText) {
64162
+ setTimeout(() => {
64163
+ navigator.clipboard
64164
+ .readText()
64165
+ .then(text => {
64166
+ this.lastClipboardContent = text;
64167
+ })
64168
+ .catch(err => {
64169
+ });
64170
+ }, 50);
64171
+ }
64172
+ }
64173
+ pasteHtmlToTable(item) {
64174
+ const regex = /<tr[^>]*>([\s\S]*?)<\/tr>/g;
64175
+ const cellRegex = /<td[^>]*>([\s\S]*?)<\/td>/g;
64176
+ const table = this.table;
64177
+ const ranges = table.stateManager.select.ranges;
64178
+ const selectRangeLength = ranges.length;
64179
+ const col = Math.min(ranges[selectRangeLength - 1].start.col, ranges[selectRangeLength - 1].end.col);
64180
+ const row = Math.min(ranges[selectRangeLength - 1].start.row, ranges[selectRangeLength - 1].end.row);
64181
+ const maxCol = Math.max(ranges[selectRangeLength - 1].start.col, ranges[selectRangeLength - 1].end.col);
64182
+ const maxRow = Math.max(ranges[selectRangeLength - 1].start.row, ranges[selectRangeLength - 1].end.row);
64183
+ let pasteValuesColCount = 0;
64184
+ let pasteValuesRowCount = 0;
64185
+ let values = [];
64186
+ item.getType('text/html').then((blob) => {
64187
+ blob.text().then(async (pastedData) => {
64188
+ if (pastedData && /(<table)|(<TABLE)/g.test(pastedData)) {
64189
+ const matches = Array.from(pastedData.matchAll(regex));
64190
+ for (const match of matches) {
64191
+ const rowContent = match[1];
64192
+ const cellMatches = Array.from(rowContent.matchAll(cellRegex));
64193
+ const rowValues = cellMatches.map(cellMatch => {
64194
+ return (cellMatch[1]
64195
+ .replace(/(<(?!br)([^>]+)>)/gi, '')
64196
+ .replace(/<br(\s*|\/)>[\r\n]?/gim, '\n')
64197
+ .replace(/&amp;/g, '&')
64198
+ .replace(/&lt;/g, '<')
64199
+ .replace(/&gt;/g, '>')
64200
+ .replace(/&#9;/gi, '\t')
64201
+ .replace(/&nbsp;/g, ' '));
64202
+ });
64203
+ values.push(rowValues);
64204
+ pasteValuesColCount = Math.max(pasteValuesColCount, rowValues?.length ?? 0);
64205
+ }
64206
+ pasteValuesRowCount = values.length ?? 0;
64207
+ values = this.handlePasteValues(values, pasteValuesRowCount, pasteValuesColCount, maxRow - row + 1, maxCol - col + 1);
64208
+ const changedCellResults = await table.changeCellValues(col, row, values, true);
64209
+ if (table.hasListeners(TABLE_EVENT_TYPE.PASTED_DATA)) {
64210
+ table.fireListeners(TABLE_EVENT_TYPE.PASTED_DATA, {
64211
+ col,
64212
+ row,
64213
+ pasteData: values,
64214
+ changedCellResults
64215
+ });
64216
+ }
64217
+ }
64218
+ else {
64219
+ navigator.clipboard.read().then(clipboardItems => {
64220
+ for (const item of clipboardItems) {
64221
+ if (item.types.includes('text/plain')) {
64222
+ item.getType('text/plain').then((blob) => {
64223
+ blob.text().then(this._pasteValue);
64224
+ });
64225
+ }
64226
+ }
64227
+ });
64228
+ }
64229
+ });
64230
+ });
64231
+ }
64232
+ async _pasteValue(pastedData) {
64233
+ const table = this.table;
64234
+ const ranges = table.stateManager.select.ranges;
64235
+ const selectRangeLength = ranges.length;
64236
+ const col = Math.min(ranges[selectRangeLength - 1].start.col, ranges[selectRangeLength - 1].end.col);
64237
+ const row = Math.min(ranges[selectRangeLength - 1].start.row, ranges[selectRangeLength - 1].end.row);
64238
+ const maxCol = Math.max(ranges[selectRangeLength - 1].start.col, ranges[selectRangeLength - 1].end.col);
64239
+ const maxRow = Math.max(ranges[selectRangeLength - 1].start.row, ranges[selectRangeLength - 1].end.row);
64240
+ let pasteValuesColCount = 0;
64241
+ let pasteValuesRowCount = 0;
64242
+ let values = [];
64243
+ const rows = pastedData.split('\n');
64244
+ rows.forEach(function (rowCells, rowIndex) {
64245
+ const cells = rowCells.split('\t');
64246
+ const rowValues = [];
64247
+ values.push(rowValues);
64248
+ cells.forEach(function (cell, cellIndex) {
64249
+ if (cellIndex === cells.length - 1) {
64250
+ cell = cell.trim();
64251
+ }
64252
+ rowValues.push(cell);
64253
+ });
64254
+ pasteValuesColCount = Math.max(pasteValuesColCount, rowValues?.length ?? 0);
64255
+ });
64256
+ pasteValuesRowCount = values.length ?? 0;
64257
+ values = this.handlePasteValues(values, pasteValuesRowCount, pasteValuesColCount, maxRow - row + 1, maxCol - col + 1);
64258
+ const changedCellResults = await table.changeCellValues(col, row, values, true);
64259
+ if (table.hasListeners(TABLE_EVENT_TYPE.PASTED_DATA)) {
64260
+ table.fireListeners(TABLE_EVENT_TYPE.PASTED_DATA, {
64261
+ col,
64262
+ row,
64263
+ pasteData: values,
64264
+ changedCellResults
64265
+ });
64266
+ }
64267
+ }
64268
+ pasteTextToTable(item) {
64269
+ const table = this.table;
64270
+ const ranges = table.stateManager.select.ranges;
64271
+ const selectRangeLength = ranges.length;
64272
+ const col = Math.min(ranges[selectRangeLength - 1].start.col, ranges[selectRangeLength - 1].end.col);
64273
+ const row = Math.min(ranges[selectRangeLength - 1].start.row, ranges[selectRangeLength - 1].end.row);
64274
+ const maxCol = Math.max(ranges[selectRangeLength - 1].start.col, ranges[selectRangeLength - 1].end.col);
64275
+ const maxRow = Math.max(ranges[selectRangeLength - 1].start.row, ranges[selectRangeLength - 1].end.row);
64276
+ let pasteValuesColCount = 0;
64277
+ let pasteValuesRowCount = 0;
64278
+ item.getType('text/plain').then((blob) => {
64279
+ blob.text().then(async (pastedData) => {
64280
+ const rows = pastedData.replace(/\r(?!\n)/g, '\r\n').split('\r\n');
64281
+ let values = [];
64282
+ if (rows.length > 1 && rows[rows.length - 1] === '') {
64283
+ rows.pop();
64284
+ }
64285
+ rows.forEach(function (rowCells, rowIndex) {
64286
+ const cells = rowCells.split('\t');
64287
+ const rowValues = [];
64288
+ values.push(rowValues);
64289
+ cells.forEach(function (cell, cellIndex) {
64290
+ if (cell.includes('\n')) {
64291
+ cell = cell
64292
+ .replace(/^"(.*)"$/, '$1')
64293
+ .replace(/["]*/g, match => new Array(Math.floor(match.length / 2)).fill('"').join(''));
64294
+ }
64295
+ rowValues.push(cell);
64296
+ });
64297
+ pasteValuesColCount = Math.max(pasteValuesColCount, rowValues?.length ?? 0);
64298
+ });
64299
+ pasteValuesRowCount = values.length ?? 0;
64300
+ values = this.handlePasteValues(values, pasteValuesRowCount, pasteValuesColCount, maxRow - row + 1, maxCol - col + 1);
64301
+ const changedCellResults = await table.changeCellValues(col, row, values, true);
64302
+ if (table.hasListeners(TABLE_EVENT_TYPE.PASTED_DATA)) {
64303
+ table.fireListeners(TABLE_EVENT_TYPE.PASTED_DATA, {
64304
+ col,
64305
+ row,
64306
+ pasteData: values,
64307
+ changedCellResults
64308
+ });
64309
+ }
64310
+ });
64311
+ });
64312
+ }
64313
+ handlePasteValues(values, rowCount, colCount, selectedRowCount, selectedColCount) {
64314
+ if (selectedColCount > colCount || selectedRowCount > rowCount) {
64315
+ if (selectedColCount % colCount === 0 && selectedRowCount % rowCount === 0) {
64316
+ const toPasteValues = [];
64317
+ for (let i = 0; i < selectedRowCount; i++) {
64318
+ const rowPasteValue = [];
64319
+ toPasteValues.push(rowPasteValue);
64320
+ for (let j = 0; j < selectedColCount; j++) {
64321
+ const copiedRow = i % rowCount;
64322
+ const copiedCol = j % colCount;
64323
+ rowPasteValue.push(values[copiedRow][copiedCol]);
64324
+ }
64325
+ }
64326
+ return toPasteValues;
64327
+ }
64328
+ return values;
64329
+ }
64330
+ return values;
64331
+ }
62612
64332
  }
62613
64333
 
62614
64334
  let defaultStyle$4;
@@ -65705,7 +67425,7 @@
65705
67425
  for (let col = startCol; col >= 0; col--) {
65706
67426
  const width = _this.getColWidth(col);
65707
67427
  const left = right - width;
65708
- if (Math.round(left) <= Math.round(absoluteX) && Math.round(absoluteX) < Math.round(right)) {
67428
+ if (Math.round(left) <= absoluteX && absoluteX < Math.round(right)) {
65709
67429
  return {
65710
67430
  left,
65711
67431
  col,
@@ -65723,7 +67443,7 @@
65723
67443
  for (let col = startCol; col < colCount; col++) {
65724
67444
  const width = _this.getColWidth(col);
65725
67445
  const right = left + width;
65726
- if (Math.round(left) <= Math.round(absoluteX) && Math.round(absoluteX) < Math.round(right)) {
67446
+ if (Math.round(left) <= absoluteX && absoluteX < Math.round(right)) {
65727
67447
  return {
65728
67448
  left,
65729
67449
  col,
@@ -67259,6 +68979,8 @@
67259
68979
  customRender;
67260
68980
  canvasWidth;
67261
68981
  canvasHeight;
68982
+ contentOffsetX;
68983
+ contentOffsetY;
67262
68984
  _vDataSet;
67263
68985
  scenegraph;
67264
68986
  stateManager;
@@ -67271,7 +68993,7 @@
67271
68993
  return TABLE_EVENT_TYPE;
67272
68994
  }
67273
68995
  options;
67274
- version = "1.19.9-alpha.3";
68996
+ version = "1.20.0-alpha.0";
67275
68997
  pagination;
67276
68998
  id = `VTable${Date.now()}`;
67277
68999
  headerStyleCache;
@@ -67311,7 +69033,7 @@
67311
69033
  if (options.customConfig?.imageAnonymous === false) {
67312
69034
  vglobal.isImageAnonymous = false;
67313
69035
  }
67314
- const { frozenColCount = 0, unfreezeAllOnExceedsMaxWidth, frozenRowCount, defaultRowHeight = 40, defaultHeaderRowHeight, defaultColWidth = 80, defaultHeaderColWidth, widthMode = 'standard', heightMode = 'standard', autoFillWidth = false, autoFillHeight = false, containerFit = { width: false, height: false }, widthAdaptiveMode = 'only-body', heightAdaptiveMode = 'only-body', keyboardOptions, eventOptions, rowSeriesNumber, enableCheckboxCascade, enableHeaderCheckboxCascade, columnResizeMode, rowResizeMode = 'none', resize, dragHeaderMode, dragOrder, showFrozenIcon, allowFrozenColCount, padding, hover, menu, select: click, customRender, pixelRatio = defaultPixelRatio, renderChartAsync, renderChartAsyncBatchCount, mode, modeParams, canvasWidth, canvasHeight, overscrollBehavior, limitMinWidth, limitMinHeight, clearDOM = true } = options;
69036
+ const { frozenColCount = 0, unfreezeAllOnExceedsMaxWidth, frozenRowCount, defaultRowHeight = 40, defaultHeaderRowHeight, defaultColWidth = 80, defaultHeaderColWidth, widthMode = 'standard', heightMode = 'standard', autoFillWidth = false, autoFillHeight = false, containerFit = { width: false, height: false }, widthAdaptiveMode = 'only-body', heightAdaptiveMode = 'only-body', keyboardOptions, eventOptions, rowSeriesNumber, enableCheckboxCascade, enableHeaderCheckboxCascade, columnResizeMode, rowResizeMode = 'none', resize, dragHeaderMode, dragOrder, showFrozenIcon, allowFrozenColCount, padding, hover, menu, select: click, customRender, pixelRatio = defaultPixelRatio, renderChartAsync, renderChartAsyncBatchCount, mode, modeParams, canvasWidth, canvasHeight, contentOffsetX: translateX, contentOffsetY: translateY, overscrollBehavior, limitMinWidth, limitMinHeight, clearDOM = true } = options;
67315
69037
  const { groupConfig, groupBy, groupTitleFieldFormat, groupTitleCustomLayout, enableTreeStickCell } = options;
67316
69038
  this.container = container;
67317
69039
  this.options = options;
@@ -67356,6 +69078,8 @@
67356
69078
  }
67357
69079
  this.tableNoFrameWidth = 0;
67358
69080
  this.tableNoFrameHeight = 0;
69081
+ this.contentOffsetX = translateX ?? 0;
69082
+ this.contentOffsetY = translateY ?? 0;
67359
69083
  this.canvasWidth = isNumber$4(canvasWidth) ? canvasWidth : undefined;
67360
69084
  this.canvasHeight = isNumber$4(canvasHeight) ? canvasHeight : undefined;
67361
69085
  this.columnWidthComputeMode = options.columnWidthComputeMode ?? 'normal';
@@ -67591,6 +69315,13 @@
67591
69315
  this.options.canvasWidth = canvasWidth;
67592
69316
  this.resize();
67593
69317
  }
69318
+ setContentInsetXY(contentOffsetX, contentOffsetY) {
69319
+ this.contentOffsetX = contentOffsetX;
69320
+ this.contentOffsetY = contentOffsetY;
69321
+ this.options.contentOffsetX = contentOffsetX;
69322
+ this.options.contentOffsetY = contentOffsetY;
69323
+ this.resize();
69324
+ }
67594
69325
  resize() {
67595
69326
  this._updateSize();
67596
69327
  this.internalProps.legends?.forEach(legend => {
@@ -67676,6 +69407,7 @@
67676
69407
  }
67677
69408
  set frozenRowCount(frozenRowCount) {
67678
69409
  this.internalProps.frozenRowCount = frozenRowCount;
69410
+ this.options.frozenRowCount = frozenRowCount;
67679
69411
  this.stateManager.setFrozenRow(this.internalProps.frozenRowCount);
67680
69412
  }
67681
69413
  get rightFrozenColCount() {
@@ -67883,8 +69615,8 @@
67883
69615
  const { padding } = this;
67884
69616
  let widthP = 0;
67885
69617
  let heightP = 0;
67886
- this.tableX = 0;
67887
- this.tableY = 0;
69618
+ this.tableX = this.contentOffsetX;
69619
+ this.tableY = this.contentOffsetY;
67888
69620
  if (this.options.canvas && this.options.viewBox) {
67889
69621
  widthP = this.options.viewBox.x2 - this.options.viewBox.x1;
67890
69622
  heightP = this.options.viewBox.y2 - this.options.viewBox.y1;
@@ -67978,24 +69710,26 @@
67978
69710
  const lineWidths = toBoxArray(this.internalProps.theme.frameStyle?.borderLineWidth ?? [null]);
67979
69711
  const shadowWidths = toBoxArray(this.internalProps.theme.frameStyle?.shadowBlur ?? [0]);
67980
69712
  if (this.theme.frameStyle?.innerBorder) {
67981
- this.tableX = 0;
67982
- this.tableY = 0;
67983
- this.tableNoFrameWidth = width - (shadowWidths[1] ?? 0);
67984
- this.tableNoFrameHeight = height - (shadowWidths[2] ?? 0);
69713
+ this.tableX += this.contentOffsetX;
69714
+ this.tableY += this.contentOffsetY;
69715
+ this.tableNoFrameWidth = width - (shadowWidths[1] ?? 0) - this.contentOffsetX;
69716
+ this.tableNoFrameHeight = height - (shadowWidths[2] ?? 0) - this.contentOffsetY;
67985
69717
  }
67986
69718
  else {
67987
- this.tableX = (lineWidths[3] ?? 0) + (shadowWidths[3] ?? 0);
67988
- this.tableY = (lineWidths[0] ?? 0) + (shadowWidths[0] ?? 0);
69719
+ this.tableX += (lineWidths[3] ?? 0) + (shadowWidths[3] ?? 0);
69720
+ this.tableY += (lineWidths[0] ?? 0) + (shadowWidths[0] ?? 0);
67989
69721
  const rightBorder = (lineWidths[1] ?? 0) + (shadowWidths[1] ?? 0);
67990
69722
  this.tableNoFrameWidth =
67991
69723
  width -
67992
69724
  (rightBorder > vScrollBarWidth ? rightBorder - vScrollBarWidth : 0) -
67993
- ((lineWidths[3] ?? 0) + (shadowWidths[3] ?? 0));
69725
+ ((lineWidths[3] ?? 0) + (shadowWidths[3] ?? 0)) -
69726
+ this.contentOffsetX;
67994
69727
  const bottomBorder = (lineWidths[2] ?? 0) + (shadowWidths[2] ?? 0);
67995
69728
  this.tableNoFrameHeight =
67996
69729
  height -
67997
69730
  (bottomBorder > hScrollBarWidth ? bottomBorder - hScrollBarWidth : 0) -
67998
- ((lineWidths[0] ?? 0) + (shadowWidths[0] ?? 0));
69731
+ ((lineWidths[0] ?? 0) + (shadowWidths[0] ?? 0)) -
69732
+ this.contentOffsetY;
67999
69733
  }
68000
69734
  }
68001
69735
  this._clearColRangeWidthsMap();
@@ -68809,6 +70543,7 @@
68809
70543
  internalProps.tooltipHandler?.release?.();
68810
70544
  internalProps.menuHandler?.release?.();
68811
70545
  super.release?.();
70546
+ this.pluginManager.release();
68812
70547
  internalProps.handler?.release?.();
68813
70548
  this.eventManager.release();
68814
70549
  internalProps.focusControl?.release?.();
@@ -68836,17 +70571,20 @@
68836
70571
  this.scenegraph = null;
68837
70572
  this.internalProps = null;
68838
70573
  this.reactCustomLayout?.clearCache();
68839
- this.pluginManager.release();
68840
70574
  clearChartRenderQueue();
68841
70575
  }
68842
70576
  fireListeners(type, event) {
68843
70577
  return super.fireListeners(type, event);
68844
70578
  }
68845
- updateOption(options) {
70579
+ updateOption(options, updateConfig = {
70580
+ clearColWidthCache: true,
70581
+ clearRowHeightCache: true
70582
+ }) {
70583
+ this.fireListeners(TABLE_EVENT_TYPE.BEFORE_UPDATE_OPTION, { options, container: this.container });
68846
70584
  this.editorManager?.cancelEdit();
68847
70585
  this.options = options;
68848
70586
  this._hasAutoImageColumn = undefined;
68849
- 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, overscrollBehavior, limitMinWidth, limitMinHeight } = options;
70587
+ 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;
68850
70588
  const { groupConfig, groupBy, groupTitleFieldFormat, groupTitleCustomLayout, enableTreeStickCell } = options;
68851
70589
  if (pixelRatio && pixelRatio !== this.internalProps.pixelRatio) {
68852
70590
  this.internalProps.pixelRatio = pixelRatio;
@@ -68890,6 +70628,8 @@
68890
70628
  }
68891
70629
  }
68892
70630
  this.customRender = customRender;
70631
+ this.contentOffsetX = translateX ?? 0;
70632
+ this.contentOffsetY = translateY ?? 0;
68893
70633
  this.canvasWidth = isNumber$4(canvasWidth) ? canvasWidth : undefined;
68894
70634
  this.canvasHeight = isNumber$4(canvasHeight) ? canvasHeight : undefined;
68895
70635
  const internalProps = this.internalProps;
@@ -68922,14 +70662,18 @@
68922
70662
  internalProps.groupTitleCustomLayout =
68923
70663
  groupConfig?.titleCustomLayout ?? groupTitleCustomLayout;
68924
70664
  internalProps.enableTreeStickCell = groupConfig?.enableTreeStickCell ?? enableTreeStickCell;
68925
- internalProps._rowHeightsMap = new NumberRangeMap(this);
68926
- internalProps._rowRangeHeightsMap = new Map();
68927
- internalProps._colRangeWidthsMap = new Map();
68928
- internalProps._widthResizedColMap = new Set();
68929
- internalProps._heightResizedRowMap = new Set();
68930
- this.colWidthsMap = new NumberMap();
68931
- this.colContentWidthsMap = new NumberMap();
68932
- this.colWidthsLimit = {};
70665
+ if (updateConfig?.clearColWidthCache) {
70666
+ internalProps._widthResizedColMap.clear();
70667
+ this.colWidthsMap = new NumberMap();
70668
+ this.colContentWidthsMap = new NumberMap();
70669
+ this.colWidthsLimit = {};
70670
+ }
70671
+ if (updateConfig?.clearRowHeightCache) {
70672
+ internalProps._heightResizedRowMap.clear();
70673
+ internalProps._rowHeightsMap = new NumberRangeMap(this);
70674
+ internalProps._rowRangeHeightsMap = new Map();
70675
+ internalProps._colRangeWidthsMap = new Map();
70676
+ }
68933
70677
  internalProps.stick.changedCells.clear();
68934
70678
  internalProps.theme = themes.of(options.theme ?? themes.DEFAULT);
68935
70679
  internalProps.theme.isPivot = this.isPivotTable();
@@ -69013,8 +70757,12 @@
69013
70757
  internalProps.menuHandler = new MenuHandler(this);
69014
70758
  }
69015
70759
  this.clearCellStyleCache();
69016
- this.clearColWidthCache();
69017
- this.clearRowHeightCache();
70760
+ if (updateConfig?.clearColWidthCache) {
70761
+ this.clearColWidthCache();
70762
+ }
70763
+ if (updateConfig?.clearRowHeightCache) {
70764
+ this.clearRowHeightCache();
70765
+ }
69018
70766
  internalProps.customMergeCell = getCustomMergeCellFunc(options.customMergeCell);
69019
70767
  this.customCellStylePlugin?.updateCustomCell(options.customCellStyle ?? [], options.customCellStyleArrangement ?? []);
69020
70768
  this._adjustCanvasSizeByOption();
@@ -69144,13 +70892,17 @@
69144
70892
  selectCells(cellRanges) {
69145
70893
  const { scrollLeft, scrollTop } = this;
69146
70894
  cellRanges.forEach((cellRange, index) => {
69147
- if (cellRange.start.col === cellRange.end.col && cellRange.start.row === cellRange.end.row) {
69148
- this.stateManager.updateSelectPos(cellRange.start.col, cellRange.start.row, false, index >= 1, false, this.options.select?.makeSelectCellVisible ?? true, true);
70895
+ const startRow = cellRange.start.row;
70896
+ const startCol = cellRange.start.col;
70897
+ const endRow = cellRange.end.row;
70898
+ const endCol = cellRange.end.col;
70899
+ if (startCol === endCol && startRow === endRow) {
70900
+ this.stateManager.updateSelectPos(startCol, startRow, false, index >= 1, false, this.options.select?.makeSelectCellVisible ?? true, true);
69149
70901
  }
69150
70902
  else {
69151
- this.stateManager.updateSelectPos(cellRange.start.col, cellRange.start.row, false, index >= 1, false, this.options.select?.makeSelectCellVisible ?? true, true);
70903
+ this.stateManager.updateSelectPos(startCol, startRow, false, index >= 1, false, this.options.select?.makeSelectCellVisible ?? true, true);
69152
70904
  this.stateManager.updateInteractionState(InteractionState.grabing);
69153
- this.stateManager.updateSelectPos(cellRange.end.col, cellRange.end.row, false, index >= 1, false, this.options.select?.makeSelectCellVisible ?? true, true);
70905
+ this.stateManager.updateSelectPos(endCol, endRow, false, index >= 1, false, this.options.select?.makeSelectCellVisible ?? true, true);
69154
70906
  }
69155
70907
  this.stateManager.endSelectCells(false, false);
69156
70908
  this.stateManager.updateInteractionState(InteractionState.default);
@@ -69158,6 +70910,96 @@
69158
70910
  this.setScrollTop(scrollTop);
69159
70911
  this.setScrollLeft(scrollLeft);
69160
70912
  }
70913
+ selectRow(rowIndex, isCtrl, isShift) {
70914
+ const currentSelectRanges = this.stateManager.select.ranges;
70915
+ if (isCtrl) {
70916
+ currentSelectRanges.push({
70917
+ start: { col: 0, row: rowIndex },
70918
+ end: { col: this.colCount - 1, row: rowIndex }
70919
+ });
70920
+ this.selectCells(currentSelectRanges);
70921
+ }
70922
+ else if (isShift) {
70923
+ const lastSelectRange = currentSelectRanges[currentSelectRanges.length - 1];
70924
+ if (lastSelectRange) {
70925
+ lastSelectRange.end.row = rowIndex;
70926
+ }
70927
+ this.selectCells(currentSelectRanges);
70928
+ }
70929
+ else {
70930
+ this.selectCells([
70931
+ {
70932
+ start: { col: 0, row: rowIndex },
70933
+ end: { col: this.colCount - 1, row: rowIndex }
70934
+ }
70935
+ ]);
70936
+ }
70937
+ }
70938
+ selectCol(colIndex, isCtrl, isShift) {
70939
+ const currentSelectRanges = this.stateManager.select.ranges;
70940
+ if (isCtrl) {
70941
+ currentSelectRanges.push({
70942
+ start: { col: colIndex, row: 0 },
70943
+ end: { col: colIndex, row: this.rowCount - 1 }
70944
+ });
70945
+ this.selectCells(currentSelectRanges);
70946
+ }
70947
+ else if (isShift) {
70948
+ const lastSelectRange = currentSelectRanges[currentSelectRanges.length - 1];
70949
+ if (lastSelectRange) {
70950
+ lastSelectRange.end.col = colIndex;
70951
+ }
70952
+ this.selectCells(currentSelectRanges);
70953
+ }
70954
+ else {
70955
+ this.selectCells([
70956
+ {
70957
+ start: { col: colIndex, row: 0 },
70958
+ end: { col: colIndex, row: this.rowCount - 1 }
70959
+ }
70960
+ ]);
70961
+ }
70962
+ }
70963
+ startDragSelectCol(colIndex, isCtrl, isShift) {
70964
+ const lastSelectRange = this.stateManager.select.ranges[this.stateManager.select.ranges.length - 1];
70965
+ const startCol = isShift && lastSelectRange?.start?.col ? lastSelectRange?.start?.col : colIndex;
70966
+ const startRow = 0;
70967
+ const endCol = colIndex;
70968
+ const endRow = this.rowCount - 1;
70969
+ this.stateManager.updateSelectPos(startCol, startRow, isShift, isCtrl, false, this.options.select?.makeSelectCellVisible ?? true, true);
70970
+ this.stateManager.updateInteractionState(InteractionState.grabing);
70971
+ this.stateManager.updateSelectPos(endCol, endRow, isShift, isCtrl, false, this.options.select?.makeSelectCellVisible ?? true, true);
70972
+ }
70973
+ dragSelectCol(colIndex, isCtrl) {
70974
+ const currentSelectRanges = this.stateManager.select.ranges;
70975
+ const lastSelectRange = currentSelectRanges[currentSelectRanges.length - 1];
70976
+ if (lastSelectRange) {
70977
+ lastSelectRange.end.col = colIndex;
70978
+ }
70979
+ this.stateManager.updateSelectPos(colIndex, this.rowCount - 1, false, isCtrl, false, this.options.select?.makeSelectCellVisible ?? true, true);
70980
+ }
70981
+ endDragSelect() {
70982
+ this.stateManager.updateInteractionState(InteractionState.default);
70983
+ this.stateManager.endSelectCells(false, false);
70984
+ }
70985
+ startDragSelectRow(rowIndex, isCtrl, isShift) {
70986
+ const lastSelectRange = this.stateManager.select.ranges[this.stateManager.select.ranges.length - 1];
70987
+ const startCol = 0;
70988
+ const startRow = isShift && lastSelectRange?.start?.row ? lastSelectRange?.start?.row : rowIndex;
70989
+ const endCol = this.colCount - 1;
70990
+ const endRow = rowIndex;
70991
+ this.stateManager.updateSelectPos(startCol, startRow, isShift, isCtrl, false, this.options.select?.makeSelectCellVisible ?? true, true);
70992
+ this.stateManager.updateInteractionState(InteractionState.grabing);
70993
+ this.stateManager.updateSelectPos(endCol, endRow, isShift, isCtrl, false, this.options.select?.makeSelectCellVisible ?? true, true);
70994
+ }
70995
+ dragSelectRow(rowIndex, isCtrl) {
70996
+ const currentSelectRanges = this.stateManager.select.ranges;
70997
+ const lastSelectRange = currentSelectRanges[currentSelectRanges.length - 1];
70998
+ if (lastSelectRange) {
70999
+ lastSelectRange.end.row = rowIndex;
71000
+ }
71001
+ this.stateManager.updateSelectPos(this.colCount - 1, rowIndex, false, isCtrl, false, this.options.select?.makeSelectCellVisible ?? true, true);
71002
+ }
69161
71003
  get recordsCount() {
69162
71004
  return this.records?.length;
69163
71005
  }
@@ -73661,7 +75503,8 @@
73661
75503
  this.isValidatingValue = true;
73662
75504
  const newValue = this.editingEditor.getValue();
73663
75505
  const oldValue = this.table.getCellOriginValue(this.editCell.col, this.editCell.row);
73664
- const maybePromiseOrValue = this.editingEditor.validateValue?.(newValue, oldValue, this.editCell, this.table);
75506
+ const target = e?.target;
75507
+ const maybePromiseOrValue = this.editingEditor.validateValue?.(newValue, oldValue, this.editCell, this.table, !!this.table.getElement().contains(target));
73665
75508
  if (isPromise(maybePromiseOrValue)) {
73666
75509
  this.isValidatingValue = true;
73667
75510
  return new Promise((resolve, reject) => {
@@ -73691,6 +75534,7 @@
73691
75534
  }
73692
75535
  changedValues.push(rowChangedValues);
73693
75536
  }
75537
+ this.editingEditor.beforeEnd?.();
73694
75538
  this.table.changeCellValues(range.start.col, range.start.row, changedValues);
73695
75539
  this.editingEditor.exit && (void 0);
73696
75540
  this.editingEditor.exit?.();
@@ -73742,9 +75586,9 @@
73742
75586
  return false;
73743
75587
  }
73744
75588
 
73745
- function getGroupByDataConfig(groupByOption) {
75589
+ function getGroupByDataConfig(groupByOption, addRecordRule) {
73746
75590
  if (isString$4(groupByOption)) {
73747
- return { groupByRules: [groupByOption] };
75591
+ return { groupByRules: [groupByOption], addRecordRule };
73748
75592
  }
73749
75593
  if (isArray$7(groupByOption)) {
73750
75594
  const groupByRules = groupByOption.map(item => {
@@ -73753,9 +75597,9 @@
73753
75597
  }
73754
75598
  return item.key;
73755
75599
  });
73756
- return { groupByRules };
75600
+ return { groupByRules, addRecordRule };
73757
75601
  }
73758
- return {};
75602
+ return { addRecordRule };
73759
75603
  }
73760
75604
 
73761
75605
  function listTableChangeCellValue(col, row, value, workOnEditableCell, triggerEvent, table) {
@@ -74725,7 +76569,9 @@
74725
76569
  this.pagination = options.pagination;
74726
76570
  internalProps.sortState = options.sortState;
74727
76571
  internalProps.multipleSort = !!options.multipleSort;
74728
- internalProps.dataConfig = this.internalProps.groupBy ? getGroupByDataConfig(this.internalProps.groupBy) : {};
76572
+ internalProps.dataConfig = this.internalProps.groupBy
76573
+ ? getGroupByDataConfig(this.internalProps.groupBy, options.addRecordRule)
76574
+ : { addRecordRule: options.addRecordRule };
74729
76575
  internalProps.columns = options.columns
74730
76576
  ? cloneDeepSpec(options.columns, ['children'])
74731
76577
  : options.header
@@ -74839,9 +76685,27 @@
74839
76685
  this.renderAsync();
74840
76686
  this.eventManager.updateEventBinder();
74841
76687
  }
74842
- addColumn(column) {
76688
+ addColumn(column, colIndex, isMaintainArrayData = true) {
74843
76689
  const columns = this.options.columns;
74844
- columns.push(column);
76690
+ if (colIndex === undefined) {
76691
+ columns.push(column);
76692
+ }
76693
+ else {
76694
+ columns.splice(colIndex, 0, column);
76695
+ }
76696
+ if (isMaintainArrayData) {
76697
+ for (let i = 0; i < this.records.length; i++) {
76698
+ const record = this.records[i];
76699
+ if (Array.isArray(record)) {
76700
+ record.splice(colIndex, 0, undefined);
76701
+ }
76702
+ }
76703
+ }
76704
+ this.updateColumns(columns);
76705
+ }
76706
+ deleteColumn(colIndex) {
76707
+ const columns = this.options.columns;
76708
+ columns.splice(colIndex, 1);
74845
76709
  this.updateColumns(columns);
74846
76710
  }
74847
76711
  get columns() {
@@ -75038,16 +76902,19 @@
75038
76902
  }
75039
76903
  return ifCan;
75040
76904
  }
75041
- updateOption(options) {
76905
+ updateOption(options, updateConfig = {
76906
+ clearColWidthCache: true,
76907
+ clearRowHeightCache: true
76908
+ }) {
75042
76909
  const internalProps = this.internalProps;
75043
- super.updateOption(options);
76910
+ super.updateOption(options, updateConfig);
75044
76911
  internalProps.frozenColDragHeaderMode =
75045
76912
  options.dragOrder?.frozenColDragHeaderMode ?? options.frozenColDragHeaderMode;
75046
76913
  this.pagination = options.pagination;
75047
76914
  internalProps.sortState = options.sortState;
75048
76915
  internalProps.dataConfig = this.internalProps.groupBy
75049
- ? getGroupByDataConfig(this.internalProps.groupBy)
75050
- : {};
76916
+ ? getGroupByDataConfig(this.internalProps.groupBy, options.addRecordRule)
76917
+ : { addRecordRule: options.addRecordRule };
75051
76918
  this.showHeader = options.showHeader ?? true;
75052
76919
  internalProps.columns = options.columns
75053
76920
  ? cloneDeepSpec(options.columns, ['children'])
@@ -75104,6 +76971,9 @@
75104
76971
  }
75105
76972
  }
75106
76973
  this.pluginManager.updatePlugins(options.plugins);
76974
+ setTimeout(() => {
76975
+ this.fireListeners(TABLE_EVENT_TYPE.UPDATED, null);
76976
+ }, 0);
75107
76977
  return new Promise(resolve => {
75108
76978
  setTimeout(resolve, 0);
75109
76979
  });
@@ -75826,6 +77696,61 @@
75826
77696
  });
75827
77697
  }
75828
77698
  }
77699
+ mergeCells(startCol, startRow, endCol, endRow) {
77700
+ for (let i = startCol; i <= endCol; i++) {
77701
+ for (let j = startRow; j <= endRow; j++) {
77702
+ const cellRange = this.getCellRange(i, j);
77703
+ if (cellRange.start.col !== cellRange.end.col || cellRange.start.row !== cellRange.end.row) {
77704
+ return;
77705
+ }
77706
+ }
77707
+ }
77708
+ if (!this.options.customMergeCell) {
77709
+ this.options.customMergeCell = [];
77710
+ }
77711
+ else if (typeof this.options.customMergeCell === 'function') {
77712
+ this.options.customMergeCell = [];
77713
+ }
77714
+ this.options.customMergeCell.push({
77715
+ text: this.getCellValue(startCol, startRow),
77716
+ range: {
77717
+ start: {
77718
+ col: startCol,
77719
+ row: startRow
77720
+ },
77721
+ end: {
77722
+ col: endCol,
77723
+ row: endRow
77724
+ }
77725
+ }
77726
+ });
77727
+ this.internalProps.customMergeCell = getCustomMergeCellFunc(this.options.customMergeCell);
77728
+ for (let i = startCol; i <= endCol; i++) {
77729
+ for (let j = startRow; j <= endRow; j++) {
77730
+ this.scenegraph.updateCellContent(i, j);
77731
+ }
77732
+ }
77733
+ this.scenegraph.updateNextFrame();
77734
+ }
77735
+ unmergeCells(startCol, startRow, endCol, endRow) {
77736
+ if (!this.options.customMergeCell) {
77737
+ this.options.customMergeCell = [];
77738
+ }
77739
+ else if (typeof this.options.customMergeCell === 'function') {
77740
+ this.options.customMergeCell = [];
77741
+ }
77742
+ this.options.customMergeCell = this.options.customMergeCell.filter(item => {
77743
+ const { start, end } = item.range;
77744
+ return !(start.col === startCol && start.row === startRow && end.col === endCol && end.row === endRow);
77745
+ });
77746
+ this.internalProps.customMergeCell = getCustomMergeCellFunc(this.options.customMergeCell);
77747
+ for (let i = startCol; i <= endCol; i++) {
77748
+ for (let j = startRow; j <= endRow; j++) {
77749
+ this.scenegraph.updateCellContent(i, j);
77750
+ }
77751
+ }
77752
+ this.scenegraph.updateNextFrame();
77753
+ }
75829
77754
  }
75830
77755
 
75831
77756
  function isXAxis(orient) {
@@ -87986,9 +89911,12 @@
87986
89911
  }
87987
89912
  return ifCan;
87988
89913
  }
87989
- updateOption(options) {
89914
+ updateOption(options, updateConfig = {
89915
+ clearColWidthCache: true,
89916
+ clearRowHeightCache: true
89917
+ }) {
87990
89918
  const internalProps = this.internalProps;
87991
- super.updateOption(options);
89919
+ super.updateOption(options, updateConfig);
87992
89920
  if (!options.rowHierarchyType) {
87993
89921
  options.rowHierarchyType = 'grid';
87994
89922
  }
@@ -88121,6 +90049,9 @@
88121
90049
  this.internalProps.emptyTip?.resetVisible();
88122
90050
  }
88123
90051
  }
90052
+ setTimeout(() => {
90053
+ this.fireListeners(TABLE_EVENT_TYPE.UPDATED, null);
90054
+ }, 0);
88124
90055
  return new Promise(resolve => {
88125
90056
  setTimeout(resolve, 0);
88126
90057
  });
@@ -89677,9 +91608,12 @@
89677
91608
  }
89678
91609
  return ifCan;
89679
91610
  }
89680
- updateOption(options) {
91611
+ updateOption(options, updateConfig = {
91612
+ clearColWidthCache: true,
91613
+ clearRowHeightCache: true
91614
+ }) {
89681
91615
  const internalProps = this.internalProps;
89682
- super.updateOption(options);
91616
+ super.updateOption(options, updateConfig);
89683
91617
  this.layoutNodeId = { seqId: 0 };
89684
91618
  this.internalProps.columns = cloneDeep$1(options.columns);
89685
91619
  this.internalProps.rows = cloneDeep$1(options.rows);
@@ -89810,6 +91744,9 @@
89810
91744
  this.internalProps.emptyTip?.resetVisible();
89811
91745
  }
89812
91746
  }
91747
+ setTimeout(() => {
91748
+ this.fireListeners(TABLE_EVENT_TYPE.UPDATED, null);
91749
+ }, 0);
89813
91750
  return new Promise(resolve => {
89814
91751
  setTimeout(resolve, 0);
89815
91752
  });
@@ -91202,7 +93139,7 @@
91202
93139
  }
91203
93140
 
91204
93141
  registerForVrender();
91205
- const version = "1.19.9-alpha.3";
93142
+ const version = "1.20.0-alpha.0";
91206
93143
  function getIcons() {
91207
93144
  return get$2();
91208
93145
  }