@visactor/vtable 1.5.3-alpha.1 → 1.5.3

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 (147) hide show
  1. package/cjs/ListTable.d.ts +1 -2
  2. package/cjs/ListTable.js +194 -26
  3. package/cjs/ListTable.js.map +1 -1
  4. package/cjs/PivotTable.d.ts +1 -1
  5. package/cjs/PivotTable.js +3 -3
  6. package/cjs/PivotTable.js.map +1 -1
  7. package/cjs/core/BaseTable.d.ts +3 -5
  8. package/cjs/core/BaseTable.js +79 -8
  9. package/cjs/core/BaseTable.js.map +1 -1
  10. package/cjs/core/tableHelper.d.ts +2 -0
  11. package/cjs/core/tableHelper.js +18 -9
  12. package/cjs/core/tableHelper.js.map +1 -1
  13. package/cjs/data/CachedDataSource.d.ts +1 -10
  14. package/cjs/data/CachedDataSource.js +3 -78
  15. package/cjs/data/CachedDataSource.js.map +1 -1
  16. package/cjs/dataset/statistics-helper.js +1 -0
  17. package/cjs/edit/edit-manager.d.ts +1 -1
  18. package/cjs/edit/edit-manager.js +4 -5
  19. package/cjs/edit/edit-manager.js.map +1 -1
  20. package/cjs/event/listener/container-dom.js +6 -5
  21. package/cjs/event/listener/container-dom.js.map +1 -1
  22. package/cjs/event/listener/table-group.js.map +1 -1
  23. package/cjs/event/scroll.js +6 -4
  24. package/cjs/event/scroll.js.map +1 -1
  25. package/cjs/index.d.ts +1 -1
  26. package/cjs/index.js +1 -1
  27. package/cjs/index.js.map +1 -1
  28. package/cjs/layout/layout-helper.js +2 -2
  29. package/cjs/layout/layout-helper.js.map +1 -1
  30. package/cjs/layout/row-height-map.js +0 -1
  31. package/cjs/layout/simple-header-layout.d.ts +2 -1
  32. package/cjs/layout/simple-header-layout.js +88 -2
  33. package/cjs/layout/simple-header-layout.js.map +1 -1
  34. package/cjs/plugins/icons.js +1 -1
  35. package/cjs/plugins/themes.js +1 -1
  36. package/cjs/scenegraph/group-creater/cell-helper.js +6 -11
  37. package/cjs/scenegraph/group-creater/cell-helper.js.map +1 -1
  38. package/cjs/scenegraph/group-creater/column-helper.js +2 -7
  39. package/cjs/scenegraph/group-creater/column-helper.js.map +1 -1
  40. package/cjs/scenegraph/scenegraph.js +1 -1
  41. package/cjs/scenegraph/utils/get-cell-merge.js +1 -1
  42. package/cjs/scenegraph/utils/get-cell-merge.js.map +1 -1
  43. package/cjs/scenegraph/utils/get-hierarchy-offset.js +8 -6
  44. package/cjs/scenegraph/utils/get-hierarchy-offset.js.map +1 -1
  45. package/cjs/state/select/is-cell-select-highlight.d.ts +1 -0
  46. package/cjs/state/select/is-cell-select-highlight.js +8 -2
  47. package/cjs/state/select/is-cell-select-highlight.js.map +1 -1
  48. package/cjs/themes/theme.d.ts +0 -2
  49. package/cjs/themes/theme.js +4 -12
  50. package/cjs/themes/theme.js.map +1 -1
  51. package/cjs/tools/helper.js.map +1 -1
  52. package/cjs/ts-types/base-table.d.ts +0 -9
  53. package/cjs/ts-types/base-table.js.map +1 -1
  54. package/cjs/ts-types/new-data-set.d.ts +0 -1
  55. package/cjs/ts-types/new-data-set.js.map +1 -1
  56. package/cjs/ts-types/table-engine.d.ts +1 -9
  57. package/cjs/ts-types/table-engine.js.map +1 -1
  58. package/cjs/ts-types/theme.d.ts +0 -1
  59. package/cjs/ts-types/theme.js.map +1 -1
  60. package/cjs/vrender.js.map +1 -1
  61. package/dist/vtable.js +2901 -3149
  62. package/dist/vtable.min.js +2 -2
  63. package/es/ListTable.d.ts +1 -2
  64. package/es/ListTable.js +192 -30
  65. package/es/ListTable.js.map +1 -1
  66. package/es/PivotTable.d.ts +1 -1
  67. package/es/PivotTable.js +3 -3
  68. package/es/PivotTable.js.map +1 -1
  69. package/es/core/BaseTable.d.ts +3 -5
  70. package/es/core/BaseTable.js +83 -11
  71. package/es/core/BaseTable.js.map +1 -1
  72. package/es/core/tableHelper.d.ts +2 -0
  73. package/es/core/tableHelper.js +16 -6
  74. package/es/core/tableHelper.js.map +1 -1
  75. package/es/data/CachedDataSource.d.ts +1 -10
  76. package/es/data/CachedDataSource.js +0 -79
  77. package/es/data/CachedDataSource.js.map +1 -1
  78. package/es/dataset/statistics-helper.js +2 -1
  79. package/es/edit/edit-manager.d.ts +1 -1
  80. package/es/edit/edit-manager.js +5 -4
  81. package/es/edit/edit-manager.js.map +1 -1
  82. package/es/event/listener/container-dom.js +7 -4
  83. package/es/event/listener/container-dom.js.map +1 -1
  84. package/es/event/listener/table-group.js.map +1 -1
  85. package/es/event/scroll.js +6 -4
  86. package/es/event/scroll.js.map +1 -1
  87. package/es/index.d.ts +1 -1
  88. package/es/index.js +1 -1
  89. package/es/index.js.map +1 -1
  90. package/es/layout/layout-helper.js +2 -2
  91. package/es/layout/layout-helper.js.map +1 -1
  92. package/es/layout/row-height-map.js +1 -2
  93. package/es/layout/simple-header-layout.d.ts +2 -1
  94. package/es/layout/simple-header-layout.js +87 -3
  95. package/es/layout/simple-header-layout.js.map +1 -1
  96. package/es/plugins/icons.js +1 -1
  97. package/es/plugins/themes.js +1 -1
  98. package/es/scenegraph/group-creater/cell-helper.js +6 -11
  99. package/es/scenegraph/group-creater/cell-helper.js.map +1 -1
  100. package/es/scenegraph/group-creater/column-helper.js +2 -7
  101. package/es/scenegraph/group-creater/column-helper.js.map +1 -1
  102. package/es/scenegraph/scenegraph.js +1 -1
  103. package/es/scenegraph/utils/get-cell-merge.js +1 -1
  104. package/es/scenegraph/utils/get-cell-merge.js.map +1 -1
  105. package/es/scenegraph/utils/get-hierarchy-offset.js +9 -7
  106. package/es/scenegraph/utils/get-hierarchy-offset.js.map +1 -1
  107. package/es/state/select/is-cell-select-highlight.d.ts +1 -0
  108. package/es/state/select/is-cell-select-highlight.js +5 -0
  109. package/es/state/select/is-cell-select-highlight.js.map +1 -1
  110. package/es/themes/theme.d.ts +0 -2
  111. package/es/themes/theme.js +4 -11
  112. package/es/themes/theme.js.map +1 -1
  113. package/es/tools/helper.js.map +1 -1
  114. package/es/ts-types/base-table.d.ts +0 -9
  115. package/es/ts-types/base-table.js.map +1 -1
  116. package/es/ts-types/new-data-set.d.ts +0 -1
  117. package/es/ts-types/new-data-set.js.map +1 -1
  118. package/es/ts-types/table-engine.d.ts +1 -9
  119. package/es/ts-types/table-engine.js.map +1 -1
  120. package/es/ts-types/theme.d.ts +0 -1
  121. package/es/ts-types/theme.js.map +1 -1
  122. package/es/vrender.js.map +1 -1
  123. package/package.json +5 -5
  124. package/cjs/core/group-helper.d.ts +0 -6
  125. package/cjs/core/group-helper.js +0 -22
  126. package/cjs/core/group-helper.js.map +0 -1
  127. package/cjs/core/record-helper.d.ts +0 -6
  128. package/cjs/core/record-helper.js +0 -230
  129. package/cjs/core/record-helper.js.map +0 -1
  130. package/cjs/core/style-helper.d.ts +0 -3
  131. package/cjs/core/style-helper.js +0 -110
  132. package/cjs/core/style-helper.js.map +0 -1
  133. package/cjs/layout/cell-range/simple-cell-range.d.ts +0 -4
  134. package/cjs/layout/cell-range/simple-cell-range.js +0 -106
  135. package/cjs/layout/cell-range/simple-cell-range.js.map +0 -1
  136. package/es/core/group-helper.d.ts +0 -6
  137. package/es/core/group-helper.js +0 -14
  138. package/es/core/group-helper.js.map +0 -1
  139. package/es/core/record-helper.d.ts +0 -6
  140. package/es/core/record-helper.js +0 -220
  141. package/es/core/record-helper.js.map +0 -1
  142. package/es/core/style-helper.d.ts +0 -3
  143. package/es/core/style-helper.js +0 -86
  144. package/es/core/style-helper.js.map +0 -1
  145. package/es/layout/cell-range/simple-cell-range.d.ts +0 -4
  146. package/es/layout/cell-range/simple-cell-range.js +0 -99
  147. package/es/layout/cell-range/simple-cell-range.js.map +0 -1
@@ -52,10 +52,9 @@ export declare abstract class BaseTable extends EventTarget implements BaseTable
52
52
  version: string;
53
53
  pagination?: IPagination | undefined;
54
54
  id: string;
55
- headerStyleCache: Map<string, any>;
56
- bodyStyleCache: Map<string, any>;
57
- bodyMergeTitleCache: Map<string, any>;
58
- bodyBottomStyleCache: Map<string, any>;
55
+ headerStyleCache: any;
56
+ bodyStyleCache: any;
57
+ bodyBottomStyleCache: any;
59
58
  container: HTMLElement;
60
59
  isReleased: boolean;
61
60
  _chartEventMap: Record<string, {
@@ -405,5 +404,4 @@ export declare abstract class BaseTable extends EventTarget implements BaseTable
405
404
  hideMoverLine(col: number, row: number): void;
406
405
  disableScroll(): void;
407
406
  enableScroll(): void;
408
- getGroupTitleLevel(col: number, row: number): number | undefined;
409
407
  }
@@ -1,5 +1,7 @@
1
1
  import * as columnStyleContents from "../body-helper/style";
2
2
 
3
+ import * as headerStyleContents from "../header-helper/style";
4
+
3
5
  import { importStyle } from "./style";
4
6
 
5
7
  import * as style from "../tools/style";
@@ -34,7 +36,7 @@ import { BodyHelper } from "../body-helper/body-helper";
34
36
 
35
37
  import { HeaderHelper } from "../header-helper/header-helper";
36
38
 
37
- import { AABBBounds, isNumber, isBoolean, isValid, cloneDeep } from "@visactor/vutils";
39
+ import { AABBBounds, isNumber, isBoolean, isFunction, isValid, cloneDeep } from "@visactor/vutils";
38
40
 
39
41
  import { measureTextBounds, textMeasure } from "../scenegraph/utils/text-measure";
40
42
 
@@ -50,11 +52,13 @@ import { defaultPixelRatio } from "../tools/pixel-ratio";
50
52
 
51
53
  import { setBatchRenderChartCount } from "../scenegraph/graphic/contributions/chart-render-helper";
52
54
 
55
+ import { isLeftOrRightAxis, isTopOrBottomAxis } from "../layout/chart-helper/get-axis-config";
56
+
53
57
  import { NumberRangeMap } from "../layout/row-height-map";
54
58
 
55
59
  import { RowSeriesNumberHelper } from "./row-series-number-helper";
56
60
 
57
- import { CustomCellStylePlugin } from "../plugins/custom-cell-style";
61
+ import { CustomCellStylePlugin, mergeStyle } from "../plugins/custom-cell-style";
58
62
 
59
63
  import { hideCellSelectBorder, restoreCellSelectBorder } from "../scenegraph/select/update-select-border";
60
64
 
@@ -66,19 +70,19 @@ import { Factory } from "./factory";
66
70
 
67
71
  import { getCellAt, getCellAtRelativePosition, getColAt, getRowAt, getTargetColAt, getTargetColAtConsiderRightFrozen, getTargetRowAt, getTargetRowAtConsiderBottomFrozen } from "./utils/get-cell-position";
68
72
 
69
- import { getCellStyle } from "./style-helper";
70
-
71
73
  const {toBoxArray: toBoxArray} = utilStyle, {isTouchEvent: isTouchEvent} = event, rangeReg = /^\$(\d+)\$(\d+)$/;
72
74
 
73
75
  importStyle();
74
76
 
77
+ const EMPTY_STYLE = {};
78
+
75
79
  export class BaseTable extends EventTarget {
76
80
  static get EVENT_TYPE() {
77
81
  return TABLE_EVENT_TYPE;
78
82
  }
79
83
  constructor(container, options = {}) {
80
84
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
81
- if (super(), this.showFrozenIcon = !0, this.version = "1.5.3-alpha.1", this.id = `VTable${Date.now()}`,
85
+ if (super(), this.showFrozenIcon = !0, this.version = "1.5.3", this.id = `VTable${Date.now()}`,
82
86
  this.isReleased = !1, this._chartEventMap = {}, this.throttleInvalidate = throttle2(this.render.bind(this), 200),
83
87
  !container && "node" !== options.mode) throw new Error("vtable's container is undefined");
84
88
  const {frozenColCount: frozenColCount = 0, frozenRowCount: frozenRowCount, defaultRowHeight: defaultRowHeight = 40, defaultHeaderRowHeight: defaultHeaderRowHeight, defaultColWidth: defaultColWidth = 80, defaultHeaderColWidth: defaultHeaderColWidth, widthMode: widthMode = "standard", heightMode: heightMode = "standard", autoFillWidth: autoFillWidth = !1, autoFillHeight: autoFillHeight = !1, widthAdaptiveMode: widthAdaptiveMode = "only-body", heightAdaptiveMode: heightAdaptiveMode = "only-body", keyboardOptions: keyboardOptions, eventOptions: eventOptions, rowSeriesNumber: rowSeriesNumber, columnResizeMode: columnResizeMode, rowResizeMode: rowResizeMode = "none", dragHeaderMode: dragHeaderMode, showFrozenIcon: showFrozenIcon, allowFrozenColCount: allowFrozenColCount, padding: padding, hover: hover, menu: menu, select: click, customRender: customRender, pixelRatio: pixelRatio = defaultPixelRatio, renderChartAsync: renderChartAsync, renderChartAsyncBatchCount: renderChartAsyncBatchCount, mode: mode, modeParams: modeParams, canvasWidth: canvasWidth, canvasHeight: canvasHeight, overscrollBehavior: overscrollBehavior, limitMinWidth: limitMinWidth, limitMinHeight: limitMinHeight, clearDOM: clearDOM = !0} = options;
@@ -166,8 +170,8 @@ export class BaseTable extends EventTarget {
166
170
  const MenuHandler = Factory.getComponent("menuHandler");
167
171
  internalProps.menuHandler = new MenuHandler(this);
168
172
  }
169
- this.headerStyleCache = new Map, this.bodyStyleCache = new Map, this.bodyMergeTitleCache = new Map,
170
- this.bodyBottomStyleCache = new Map, internalProps.stick = {
173
+ this.headerStyleCache = new Map, this.bodyStyleCache = new Map, this.bodyBottomStyleCache = new Map,
174
+ internalProps.stick = {
171
175
  changedCells: new Map
172
176
  }, internalProps.customMergeCell = options.customMergeCell, this.customCellStylePlugin = new CustomCellStylePlugin(this, null !== (_k = options.customCellStyle) && void 0 !== _k ? _k : [], null !== (_l = options.customCellStyleArrangement) && void 0 !== _l ? _l : []);
173
177
  }
@@ -1204,11 +1208,80 @@ export class BaseTable extends EventTarget {
1204
1208
  return null === (_a = this.internalProps.dataSource) || void 0 === _a ? void 0 : _a.hasField(index, field);
1205
1209
  }
1206
1210
  _getCellStyle(col, row) {
1207
- return getCellStyle(col, row, this);
1211
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
1212
+ const customCellStyle = this.customCellStylePlugin.getCustomCellStyle(col, row), {layoutMap: layoutMap} = this.internalProps;
1213
+ if (layoutMap.isHeader(col, row)) {
1214
+ let cacheKey;
1215
+ if (!this.isPivotTable() || this.isBottomFrozenRow(row) || this.isRightFrozenColumn(col)) cacheKey = `${col}-${row}`; else {
1216
+ const define = this.getHeaderDefine(col, row), isCorner = this.isCornerHeader(col, row);
1217
+ cacheKey = (null == define ? void 0 : define.dimensionKey) ? isCorner ? `dim-cor-${define.dimensionKey}` : `dim-${define.dimensionKey}` : (null == define ? void 0 : define.indicatorKey) ? `ind-${define.indicatorKey}` : `${col}-${row}`;
1218
+ }
1219
+ let cacheStyle = this.headerStyleCache.get(cacheKey);
1220
+ if (cacheStyle) return customCellStyle ? mergeStyle(cacheStyle, customCellStyle) : cacheStyle;
1221
+ const hd = layoutMap.getHeader(col, row);
1222
+ let paddingForAxis;
1223
+ if (this.isPivotChart() && isTopOrBottomAxis(col, row, layoutMap) && layoutMap.isAxisCell(col, row)) {
1224
+ paddingForAxis = null !== (_b = null === (_a = layoutMap.getBody(col, this.rowHeaderLevelCount).style) || void 0 === _a ? void 0 : _a.padding) && void 0 !== _b ? _b : this.theme.bodyStyle.padding;
1225
+ } else if (this.isPivotChart() && isLeftOrRightAxis(col, row, layoutMap) && layoutMap.isAxisCell(col, row)) {
1226
+ paddingForAxis = null !== (_d = null === (_c = layoutMap.getBody(this.columnHeaderLevelCount, row).style) || void 0 === _c ? void 0 : _c.padding) && void 0 !== _d ? _d : this.theme.bodyStyle.padding;
1227
+ }
1228
+ if ((!hd || hd.isEmpty) && (layoutMap.isLeftBottomCorner(col, row) || layoutMap.isRightBottomCorner(col, row) || layoutMap.isCornerHeader(col, row) || layoutMap.isRightTopCorner(col, row))) return EMPTY_STYLE;
1229
+ const styleClass = this.internalProps.headerHelper.getStyleClass((null == hd ? void 0 : hd.headerType) || "text");
1230
+ if (layoutMap.isBottomFrozenRow(col, row) && this.theme.bottomFrozenStyle) cacheStyle = headerStyleContents.of(paddingForAxis ? {
1231
+ padding: paddingForAxis
1232
+ } : {}, this.theme.bottomFrozenStyle, {
1233
+ col: col,
1234
+ row: row,
1235
+ table: this,
1236
+ value: this.getCellValue(col, row),
1237
+ dataValue: this.getCellOriginValue(col, row),
1238
+ cellHeaderPaths: this.getCellHeaderPaths(col, row)
1239
+ }, styleClass, this.options.autoWrapText, this.theme); else if (layoutMap.isRightFrozenColumn(col, row) && this.theme.rightFrozenStyle) cacheStyle = headerStyleContents.of(paddingForAxis ? {
1240
+ padding: paddingForAxis
1241
+ } : {}, this.theme.rightFrozenStyle, {
1242
+ col: col,
1243
+ row: row,
1244
+ table: this,
1245
+ value: this.getCellValue(col, row),
1246
+ dataValue: this.getCellOriginValue(col, row),
1247
+ cellHeaderPaths: this.getCellHeaderPaths(col, row)
1248
+ }, styleClass, this.options.autoWrapText, this.theme); else {
1249
+ const style = (null == hd ? void 0 : hd.style) || {};
1250
+ paddingForAxis && (style.padding = paddingForAxis), cacheStyle = headerStyleContents.of(style, layoutMap.isColumnHeader(col, row) || layoutMap.isBottomFrozenRow(col, row) ? this.theme.headerStyle : layoutMap.isRowHeader(col, row) || layoutMap.isRightFrozenColumn(col, row) ? this.theme.rowHeaderStyle : this.theme.cornerHeaderStyle, {
1251
+ col: col,
1252
+ row: row,
1253
+ table: this,
1254
+ value: this.getCellValue(col, row),
1255
+ dataValue: this.getCellOriginValue(col, row),
1256
+ cellHeaderPaths: this.getCellHeaderPaths(col, row)
1257
+ }, styleClass, this.options.autoWrapText, this.theme);
1258
+ }
1259
+ return this.headerStyleCache.set(cacheKey, cacheStyle), customCellStyle ? mergeStyle(cacheStyle, customCellStyle) : cacheStyle;
1260
+ }
1261
+ let bgColorFunc, cacheKey;
1262
+ (null === (_f = null === (_e = this.internalProps) || void 0 === _e ? void 0 : _e.dataConfig) || void 0 === _f ? void 0 : _f.mappingRules) && !this.isHeader(col, row) && (null === (_j = null === (_h = null === (_g = this.internalProps) || void 0 === _g ? void 0 : _g.dataConfig) || void 0 === _h ? void 0 : _h.mappingRules) || void 0 === _j || _j.forEach(((mappingRule, i) => {
1263
+ mappingRule.bgColor && this.internalProps.layoutMap.getIndicatorKey(col, row) === mappingRule.bgColor.indicatorKey && (bgColorFunc = mappingRule.bgColor.mapping);
1264
+ })));
1265
+ const cellType = this.getCellType(col, row);
1266
+ let cacheStyle;
1267
+ if (cacheKey = this.isSeriesNumberInBody(col, row) ? `${col}-series-` + cellType : this.isListTable() && !this.transpose || this.isPivotTable() && this.internalProps.layoutMap.indicatorsAsCol ? col + cellType : row + cellType,
1268
+ cacheStyle = layoutMap.isBottomFrozenRow(row) ? this.bodyBottomStyleCache.get(cacheKey) : this.bodyStyleCache.get(cacheKey),
1269
+ cacheStyle) return customCellStyle ? mergeStyle(cacheStyle, customCellStyle) : cacheStyle;
1270
+ const column = layoutMap.getBody(col, row), styleClass = this.internalProps.bodyHelper.getStyleClass(this.getCellType(col, row)), style = null == column ? void 0 : column.style;
1271
+ return cacheStyle = columnStyleContents.of(style, layoutMap.isBottomFrozenRow(row) && this.theme.bottomFrozenStyle ? this.theme.bottomFrozenStyle : layoutMap.isRightFrozenColumn(col) && this.theme.rightFrozenStyle ? this.theme.rightFrozenStyle : this.theme.bodyStyle, {
1272
+ col: col,
1273
+ row: row,
1274
+ table: this,
1275
+ value: this.getCellValue(col, row),
1276
+ dataValue: this.getCellOriginValue(col, row),
1277
+ cellHeaderPaths: this.getCellHeaderPaths(col, row)
1278
+ }, styleClass, this.options.autoWrapText, this.theme), bgColorFunc && (cacheStyle = mergeStyle(cacheStyle, {
1279
+ bgColor: bgColorFunc
1280
+ })), isFunction(style) || (layoutMap.isBottomFrozenRow(row) ? this.bodyBottomStyleCache.set(cacheKey, cacheStyle) : this.bodyStyleCache.set(cacheKey, cacheStyle)),
1281
+ customCellStyle ? mergeStyle(cacheStyle, customCellStyle) : cacheStyle;
1208
1282
  }
1209
1283
  clearCellStyleCache() {
1210
- this.headerStyleCache.clear(), this.bodyStyleCache.clear(), this.bodyMergeTitleCache.clear(),
1211
- this.bodyBottomStyleCache.clear();
1284
+ this.headerStyleCache.clear(), this.bodyStyleCache.clear(), this.bodyBottomStyleCache.clear();
1212
1285
  }
1213
1286
  clearRowHeightCache() {
1214
1287
  this.internalProps._rowHeightsMap.clear(), this._clearRowRangeHeightsMap();
@@ -1711,6 +1784,5 @@ export class BaseTable extends EventTarget {
1711
1784
  enableScroll() {
1712
1785
  this.eventManager.enableScroll();
1713
1786
  }
1714
- getGroupTitleLevel(col, row) {}
1715
1787
  }
1716
1788
  //# sourceMappingURL=BaseTable.js.map