@visactor/vtable 1.19.1-alpha.1 → 1.19.1

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 (57) hide show
  1. package/cjs/core/BaseTable.d.ts +1 -0
  2. package/cjs/core/BaseTable.js +40 -7
  3. package/cjs/core/BaseTable.js.map +1 -1
  4. package/cjs/core/animation.js +1 -1
  5. package/cjs/core/animation.js.map +1 -1
  6. package/cjs/event/listener/table-group.js +2 -2
  7. package/cjs/event/listener/table-group.js.map +1 -1
  8. package/cjs/index.d.ts +1 -1
  9. package/cjs/index.js +1 -1
  10. package/cjs/index.js.map +1 -1
  11. package/cjs/layout/pivot-header-layout.js +7 -11
  12. package/cjs/layout/pivot-header-layout.js.map +1 -1
  13. package/cjs/layout/row-height-map.js +10 -3
  14. package/cjs/layout/row-height-map.js.map +1 -1
  15. package/cjs/scenegraph/graphic/contributions/group-contribution-render.js +4 -2
  16. package/cjs/scenegraph/graphic/contributions/group-contribution-render.js.map +1 -1
  17. package/cjs/scenegraph/graphic/icon.d.ts +1 -0
  18. package/cjs/scenegraph/graphic/icon.js +30 -2
  19. package/cjs/scenegraph/graphic/icon.js.map +1 -1
  20. package/cjs/scenegraph/group-creater/cell-helper.js +1 -1
  21. package/cjs/scenegraph/group-creater/cell-helper.js.map +1 -1
  22. package/cjs/tools/env.d.ts +1 -0
  23. package/cjs/tools/env.js +13 -2
  24. package/cjs/tools/env.js.map +1 -1
  25. package/cjs/ts-types/base-table.d.ts +1 -0
  26. package/cjs/ts-types/base-table.js.map +1 -1
  27. package/cjs/vrender.js.map +1 -1
  28. package/dist/vtable.js +496 -384
  29. package/dist/vtable.min.js +2 -2
  30. package/es/core/BaseTable.d.ts +1 -0
  31. package/es/core/BaseTable.js +40 -7
  32. package/es/core/BaseTable.js.map +1 -1
  33. package/es/core/animation.js +1 -1
  34. package/es/core/animation.js.map +1 -1
  35. package/es/event/listener/table-group.js +3 -1
  36. package/es/event/listener/table-group.js.map +1 -1
  37. package/es/index.d.ts +1 -1
  38. package/es/index.js +1 -1
  39. package/es/index.js.map +1 -1
  40. package/es/layout/pivot-header-layout.js +7 -11
  41. package/es/layout/pivot-header-layout.js.map +1 -1
  42. package/es/layout/row-height-map.js +10 -3
  43. package/es/layout/row-height-map.js.map +1 -1
  44. package/es/scenegraph/graphic/contributions/group-contribution-render.js +4 -2
  45. package/es/scenegraph/graphic/contributions/group-contribution-render.js.map +1 -1
  46. package/es/scenegraph/graphic/icon.d.ts +1 -0
  47. package/es/scenegraph/graphic/icon.js +6 -1
  48. package/es/scenegraph/graphic/icon.js.map +1 -1
  49. package/es/scenegraph/group-creater/cell-helper.js +1 -1
  50. package/es/scenegraph/group-creater/cell-helper.js.map +1 -1
  51. package/es/tools/env.d.ts +1 -0
  52. package/es/tools/env.js +11 -0
  53. package/es/tools/env.js.map +1 -1
  54. package/es/ts-types/base-table.d.ts +1 -0
  55. package/es/ts-types/base-table.js.map +1 -1
  56. package/es/vrender.js.map +1 -1
  57. package/package.json +7 -7
@@ -171,6 +171,7 @@ export declare abstract class BaseTable extends EventTarget implements BaseTable
171
171
  _setRowHeight(row: number, height: number, clearCache?: boolean): void;
172
172
  setRowHeight(row: number, height: number): void;
173
173
  getRowsHeight(startRow: number, endRow: number): number;
174
+ _getRangeSizeForContainerFit(start: number, end: number, totalSize: number, type?: 'col' | 'row'): number;
174
175
  getColWidthDefined(col: number): string | number;
175
176
  getColWidthDefinedNumber(col: number): number;
176
177
  isAutoRowHeight(row?: number): boolean;
@@ -90,7 +90,7 @@ export class BaseTable extends EventTarget {
90
90
  }
91
91
  constructor(container, options = {}) {
92
92
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;
93
- if (super(), this.showFrozenIcon = !0, this.version = "1.19.1-alpha.1", this.id = `VTable${Date.now()}`,
93
+ if (super(), this.showFrozenIcon = !0, this.version = "1.19.1", this.id = `VTable${Date.now()}`,
94
94
  this.isReleased = !1, this._chartEventMap = {}, this.throttleInvalidate = throttle2(this.render.bind(this), 200),
95
95
  "node" === Env.mode ? (options = container, container = null) : container instanceof HTMLElement || (options = container,
96
96
  container = container.container ? container.container : null), !container && "node" !== options.mode && !options.canvas) throw new Error("vtable's container is undefined");
@@ -532,13 +532,14 @@ export class BaseTable extends EventTarget {
532
532
  if (null != cachedColWidth) return cachedColWidth;
533
533
  const cachedLowerColWidth = this._colRangeWidthsMap.get(`$${startCol}$${endCol - 1}`);
534
534
  if (null != cachedLowerColWidth) {
535
- const addWidth = cachedLowerColWidth + this.getColWidth(endCol);
536
- return startCol >= 0 && endCol >= 0 && !Number.isNaN(addWidth) && this._colRangeWidthsMap.set(`$${startCol}$${endCol}`, Math.round(addWidth)),
535
+ let addWidth = cachedLowerColWidth + this.getColWidth(endCol);
536
+ return this.rightFrozenColCount > 0 && endCol === this.colCount - this.rightFrozenColCount && (addWidth = this._getRangeSizeForContainerFit(startCol, endCol, addWidth, "col")),
537
+ startCol >= 0 && endCol >= 0 && !Number.isNaN(addWidth) && this._colRangeWidthsMap.set(`$${startCol}$${endCol}`, Math.round(addWidth)),
537
538
  Math.round(addWidth);
538
539
  }
539
540
  let w = 0;
540
541
  for (let col = startCol; col <= endCol; col++) w += this.getColWidth(col);
541
- return startCol >= 0 && endCol >= 0 && this._colRangeWidthsMap.set(`$${startCol}$${endCol}`, Math.round(w)),
542
+ return w = this._getRangeSizeForContainerFit(startCol, endCol, w, "col"), startCol >= 0 && endCol >= 0 && this._colRangeWidthsMap.set(`$${startCol}$${endCol}`, Math.round(w)),
542
543
  Math.round(w);
543
544
  }
544
545
  getRowHeight(row) {
@@ -587,12 +588,43 @@ export class BaseTable extends EventTarget {
587
588
  }
588
589
  h = this.rowHeightsMap.getSumInRange(startRow, endRow);
589
590
  } else {
591
+ const bottomFrozenStartRow = this.rowCount - this.bottomFrozenRowCount;
590
592
  for (let i = startRow; i < Math.min(endRow + 1, this.columnHeaderLevelCount); i++) h += this.getRowHeight(i);
591
- endRow >= this.columnHeaderLevelCount && (h += this.defaultRowHeight * (Math.min(endRow, this.rowCount - this.bottomFrozenRowCount - 1) - Math.max(this.columnHeaderLevelCount, startRow) + 1));
592
- for (let i = this.rowCount - this.bottomFrozenRowCount; i < endRow + 1; i++) h += this.getRowHeight(i);
593
+ endRow >= this.columnHeaderLevelCount && (h += this.defaultRowHeight * (Math.min(endRow, bottomFrozenStartRow - 1) - Math.max(this.columnHeaderLevelCount, startRow) + 1));
594
+ let currentBottomFrozenRowsHeight = 0;
595
+ for (let i = bottomFrozenStartRow; i < endRow + 1; i++) currentBottomFrozenRowsHeight += this.getRowHeight(i);
596
+ h = this._getRangeSizeForContainerFit(startRow, endRow, h + currentBottomFrozenRowsHeight, "row");
593
597
  }
594
598
  return Math.round(h);
595
599
  }
600
+ _getRangeSizeForContainerFit(start, end, totalSize, type = "col") {
601
+ var _a;
602
+ if (!isFinite(start) || !isFinite(end)) return totalSize;
603
+ const keyMap = "col" === type ? {
604
+ totalCount: "colCount",
605
+ frozenCount: "rightFrozenColCount",
606
+ fitType: "width",
607
+ tableSize: "tableNoFrameWidth",
608
+ getSize: "getColWidth"
609
+ } : {
610
+ totalCount: "rowCount",
611
+ frozenCount: "bottomFrozenRowCount",
612
+ fitType: "height",
613
+ tableSize: "tableNoFrameHeight",
614
+ getSize: "getRowHeight"
615
+ }, tableSize = this[keyMap.tableSize];
616
+ if (totalSize >= tableSize) return totalSize;
617
+ const frozenStart = this[keyMap.totalCount] - this[keyMap.frozenCount];
618
+ if (!isFinite(this[keyMap.totalCount]) || this[keyMap.frozenCount] <= 0 || frozenStart < 0) return totalSize;
619
+ if (start > frozenStart || end < frozenStart || start === end || !(null === (_a = this.containerFit) || void 0 === _a ? void 0 : _a[keyMap.fitType])) return totalSize;
620
+ const last = this[keyMap.totalCount] - 1;
621
+ let size = tableSize;
622
+ if (start > 0) for (let i = 0; i < start; i++) if (size -= this[keyMap.getSize](i),
623
+ size <= 0) return totalSize;
624
+ if (end !== last) for (let i = end + 1; i <= last; i++) if (size -= this[keyMap.getSize](i),
625
+ size <= 0) return totalSize;
626
+ return size;
627
+ }
596
628
  getColWidthDefined(col) {
597
629
  var _a;
598
630
  const {layoutMap: layoutMap} = this.internalProps;
@@ -1040,7 +1072,8 @@ export class BaseTable extends EventTarget {
1040
1072
  return 0;
1041
1073
  }
1042
1074
  getDrawRange() {
1043
- const width = Math.min(this.tableNoFrameWidth, this.getAllColsWidth()), height = Math.min(this.tableNoFrameHeight, this.getAllRowsHeight());
1075
+ var _a, _b;
1076
+ const width = (null === (_a = this.containerFit) || void 0 === _a ? void 0 : _a.width) ? this.tableNoFrameWidth : Math.min(this.tableNoFrameWidth, this.getAllColsWidth()), height = (null === (_b = this.containerFit) || void 0 === _b ? void 0 : _b.height) ? this.tableNoFrameHeight : Math.min(this.tableNoFrameHeight, this.getAllRowsHeight());
1044
1077
  return new Rect(this.tableX, this.tableY, width, height);
1045
1078
  }
1046
1079
  _getMouseAbstractPoint(evt) {