@visactor/vtable 0.18.1 → 0.18.2-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.
package/dist/vtable.js CHANGED
@@ -32707,31 +32707,29 @@
32707
32707
  image.name = 'image';
32708
32708
  image.keepAspectRatio = keepAspectRatio;
32709
32709
  if (keepAspectRatio || imageAutoSizing) {
32710
- image.successCallback = () => {
32711
- const originImage = image.resources.get(image.attribute.image).data;
32712
- if (imageAutoSizing) {
32713
- _adjustWidthHeight(col, row, originImage.width, originImage.height, table.scenegraph, padding);
32714
- }
32715
- if (keepAspectRatio) {
32716
- const { width: cellWidth, height: cellHeight, isMerge } = getCellRange(cellGroup, table);
32717
- const { width: imageWidth, height: imageHeight } = calcKeepAspectRatioSize(originImage.width, originImage.height, cellWidth - padding[1] - padding[3], cellHeight - padding[0] - padding[2]);
32718
- const pos = calcStartPosition(0, 0, cellWidth, cellHeight, imageWidth, imageHeight, textAlign, textBaseline, padding);
32719
- image.setAttributes({
32720
- x: pos.x,
32721
- y: pos.y,
32722
- width: imageWidth,
32723
- height: imageHeight,
32724
- dx: isMerge ? -table.getColsWidth(cellGroup.mergeStartCol, col - 1) : 0,
32725
- dy: isMerge ? -table.getRowsHeight(cellGroup.mergeStartRow, row - 1) : 0
32726
- });
32727
- }
32728
- table.scenegraph.updateNextFrame();
32729
- };
32710
+ if (image.resources &&
32711
+ image.resources.has(image.attribute.image) &&
32712
+ image.resources.get(image.attribute.image).state === 'success') {
32713
+ updateAutoSizingAndKeepAspectRatio(imageAutoSizing, keepAspectRatio, padding, textAlign, textBaseline, image, cellGroup, table);
32714
+ }
32715
+ else {
32716
+ image.successCallback = () => {
32717
+ updateAutoSizingAndKeepAspectRatio(imageAutoSizing, keepAspectRatio, padding, textAlign, textBaseline, image, cellGroup, table);
32718
+ table.scenegraph.updateNextFrame();
32719
+ };
32720
+ }
32730
32721
  }
32731
32722
  else {
32732
- image.successCallback = () => {
32723
+ if (image.resources &&
32724
+ image.resources.has(image.attribute.image) &&
32725
+ image.resources.get(image.attribute.image).state === 'success') {
32733
32726
  updateImageCellContentWhileResize(cellGroup, col, row, table);
32734
- };
32727
+ }
32728
+ else {
32729
+ image.successCallback = () => {
32730
+ updateImageCellContentWhileResize(cellGroup, col, row, table);
32731
+ };
32732
+ }
32735
32733
  }
32736
32734
  image.failCallback = () => {
32737
32735
  const regedIcons = get$1();
@@ -32844,6 +32842,43 @@
32844
32842
  isMerge: false
32845
32843
  };
32846
32844
  }
32845
+ function updateImageDxDy(startCol, endCol, startRow, endRow, table) {
32846
+ for (let col = startCol; col <= endCol; col++) {
32847
+ for (let row = startRow; row <= endRow; row++) {
32848
+ const cellGroup = table.scenegraph.getCell(col, row);
32849
+ if (cellGroup) {
32850
+ const image = cellGroup.getChildByName('image');
32851
+ if (image) {
32852
+ image.setAttributes({
32853
+ dx: -table.getColsWidth(cellGroup.mergeStartCol, col - 1),
32854
+ dy: -table.getRowsHeight(cellGroup.mergeStartRow, row - 1)
32855
+ });
32856
+ }
32857
+ }
32858
+ }
32859
+ }
32860
+ }
32861
+ function updateAutoSizingAndKeepAspectRatio(imageAutoSizing, keepAspectRatio, padding, textAlign, textBaseline, image, cellGroup, table) {
32862
+ const originImage = image.resources.get(image.attribute.image).data;
32863
+ const { col, row } = cellGroup;
32864
+ if (imageAutoSizing) {
32865
+ _adjustWidthHeight(col, row, originImage.width, originImage.height, table.scenegraph, padding);
32866
+ }
32867
+ if (keepAspectRatio) {
32868
+ const { width: cellWidth, height: cellHeight, isMerge } = getCellRange(cellGroup, table);
32869
+ const { width: imageWidth, height: imageHeight } = calcKeepAspectRatioSize(originImage.width, originImage.height, cellWidth - padding[1] - padding[3], cellHeight - padding[0] - padding[2]);
32870
+ const pos = calcStartPosition(0, 0, cellWidth, cellHeight, imageWidth, imageHeight, textAlign, textBaseline, padding);
32871
+ image.setAttributes({
32872
+ x: pos.x,
32873
+ y: pos.y,
32874
+ width: imageWidth,
32875
+ height: imageHeight
32876
+ });
32877
+ if (isMerge) {
32878
+ updateImageDxDy(cellGroup.mergeStartCol, cellGroup.mergeEndCol, cellGroup.mergeStartRow, cellGroup.mergeEndRow, table);
32879
+ }
32880
+ }
32881
+ }
32847
32882
 
32848
32883
  function createProgressBarCell(progressBarDefine, style, width, value, dataValue, col, row, padding, table) {
32849
32884
  if (progressBarDefine.dependField) {
@@ -41863,7 +41898,7 @@
41863
41898
  });
41864
41899
  });
41865
41900
  });
41866
- changedCells.length = 0;
41901
+ changedCells.clear();
41867
41902
  const { scrollTop, scrollLeft, frozenRowCount, frozenColCount } = table;
41868
41903
  const frozenRowsHeight = table.getFrozenRowsHeight();
41869
41904
  const frozenColsWidth = table.getFrozenColsWidth();
@@ -41962,24 +41997,26 @@
41962
41997
  const textBottom = graphic.globalAABBBounds.y2;
41963
41998
  if (textTop < minTop) {
41964
41999
  const deltaHeight = textTop - minTop;
41965
- changedCells.push({
41966
- col: cellGroup.col,
41967
- row: cellGroup.row,
41968
- dx: cellGroup.firstChild?.attribute.dx ?? 0,
41969
- dy: cellGroup.firstChild?.attribute.dy ?? 0
41970
- });
42000
+ !changedCells.has(`${cellGroup.col}-${cellGroup.row}`) &&
42001
+ changedCells.set(`${cellGroup.col}-${cellGroup.row}`, {
42002
+ col: cellGroup.col,
42003
+ row: cellGroup.row,
42004
+ dx: cellGroup.firstChild?.attribute.dx ?? 0,
42005
+ dy: cellGroup.firstChild?.attribute.dy ?? 0
42006
+ });
41971
42007
  cellGroup.forEachChildren((child) => {
41972
42008
  child.setAttribute('dy', (child.attribute.dy ?? 0) - deltaHeight + 2);
41973
42009
  });
41974
42010
  }
41975
42011
  else if (textBottom > maxTop) {
41976
42012
  const deltaHeight = textBottom - maxTop;
41977
- changedCells.push({
41978
- col: cellGroup.col,
41979
- row: cellGroup.row,
41980
- dx: cellGroup.firstChild?.attribute.dx ?? 0,
41981
- dy: cellGroup.firstChild?.attribute.dy ?? 0
41982
- });
42013
+ !changedCells.has(`${cellGroup.col}-${cellGroup.row}`) &&
42014
+ changedCells.set(`${cellGroup.col}-${cellGroup.row}`, {
42015
+ col: cellGroup.col,
42016
+ row: cellGroup.row,
42017
+ dx: cellGroup.firstChild?.attribute.dx ?? 0,
42018
+ dy: cellGroup.firstChild?.attribute.dy ?? 0
42019
+ });
41983
42020
  cellGroup.forEachChildren((child) => {
41984
42021
  child.setAttribute('dy', (child.attribute.dy ?? 0) - deltaHeight);
41985
42022
  });
@@ -42011,24 +42048,26 @@
42011
42048
  const textRight = text.globalAABBBounds.x2;
42012
42049
  if (textLeft < minLeft) {
42013
42050
  const deltaWidth = textLeft - minLeft;
42014
- changedCells.push({
42015
- col: cellGroup.col,
42016
- row: cellGroup.row,
42017
- dx: cellGroup.firstChild?.attribute.dx ?? 0,
42018
- dy: cellGroup.firstChild?.attribute.dy ?? 0
42019
- });
42051
+ !changedCells.has(`${cellGroup.col}-${cellGroup.row}`) &&
42052
+ changedCells.set(`${cellGroup.col}-${cellGroup.row}`, {
42053
+ col: cellGroup.col,
42054
+ row: cellGroup.row,
42055
+ dx: cellGroup.firstChild?.attribute.dx ?? 0,
42056
+ dy: cellGroup.firstChild?.attribute.dy ?? 0
42057
+ });
42020
42058
  cellGroup.forEachChildren((child) => {
42021
42059
  child.setAttribute('dx', (child.attribute.dx ?? 0) - deltaWidth + 2);
42022
42060
  });
42023
42061
  }
42024
42062
  else if (textRight > maxLeft) {
42025
42063
  const deltaWidth = textRight - maxLeft;
42026
- changedCells.push({
42027
- col: cellGroup.col,
42028
- row: cellGroup.row,
42029
- dx: cellGroup.firstChild?.attribute.dx ?? 0,
42030
- dy: cellGroup.firstChild?.attribute.dy ?? 0
42031
- });
42064
+ !changedCells.has(`${cellGroup.col}-${cellGroup.row}`) &&
42065
+ changedCells.set(`${cellGroup.col}-${cellGroup.row}`, {
42066
+ col: cellGroup.col,
42067
+ row: cellGroup.row,
42068
+ dx: cellGroup.firstChild?.attribute.dx ?? 0,
42069
+ dy: cellGroup.firstChild?.attribute.dy ?? 0
42070
+ });
42032
42071
  cellGroup.forEachChildren((child) => {
42033
42072
  child.setAttribute('dx', (child.attribute.dx ?? 0) - deltaWidth);
42034
42073
  });
@@ -50623,7 +50662,7 @@
50623
50662
  return TABLE_EVENT_TYPE;
50624
50663
  }
50625
50664
  options;
50626
- version = "0.18.1";
50665
+ version = "0.18.2-alpha.0";
50627
50666
  pagination;
50628
50667
  id = `VTable${Date.now()}`;
50629
50668
  headerStyleCache;
@@ -50768,7 +50807,7 @@
50768
50807
  this.headerStyleCache = new Map();
50769
50808
  this.bodyStyleCache = new Map();
50770
50809
  this.bodyBottomStyleCache = new Map();
50771
- internalProps.stick = { changedCells: [] };
50810
+ internalProps.stick = { changedCells: new Map() };
50772
50811
  internalProps.customMergeCell = options.customMergeCell;
50773
50812
  }
50774
50813
  throttleInvalidate = throttle2(this.render.bind(this), 200);
@@ -51734,6 +51773,7 @@
51734
51773
  this.colWidthsMap = new NumberMap();
51735
51774
  this.colContentWidthsMap = new NumberMap();
51736
51775
  this.colWidthsLimit = {};
51776
+ internalProps.stick.changedCells.clear();
51737
51777
  internalProps.theme = themes.of(options.theme ?? themes.DEFAULT);
51738
51778
  this.scenegraph.updateStageBackground();
51739
51779
  internalProps.autoWrapText = options.autoWrapText;
@@ -61869,7 +61909,7 @@
61869
61909
  }
61870
61910
 
61871
61911
  registerForVrender();
61872
- const version = "0.18.1";
61912
+ const version = "0.18.2-alpha.0";
61873
61913
  function getIcons() {
61874
61914
  return get$1();
61875
61915
  }