@visactor/vtable 0.20.4-alpha.1 → 0.20.4-alpha.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 (41) hide show
  1. package/cjs/core/BaseTable.d.ts +9 -1
  2. package/cjs/core/BaseTable.js +15 -9
  3. package/cjs/core/BaseTable.js.map +1 -1
  4. package/cjs/index.d.ts +1 -1
  5. package/cjs/index.js +1 -1
  6. package/cjs/index.js.map +1 -1
  7. package/cjs/plugins/custom-cell-style.d.ts +19 -0
  8. package/cjs/plugins/custom-cell-style.js +60 -0
  9. package/cjs/plugins/custom-cell-style.js.map +1 -0
  10. package/cjs/scenegraph/scenegraph.js +1 -2
  11. package/cjs/state/state.js +2 -1
  12. package/cjs/themes/theme.js +1 -1
  13. package/cjs/tools/isx.d.ts +1 -1
  14. package/cjs/tools/util.d.ts +1 -1
  15. package/cjs/ts-types/base-table.d.ts +10 -2
  16. package/cjs/ts-types/base-table.js.map +1 -1
  17. package/cjs/ts-types/common.d.ts +12 -2
  18. package/cjs/ts-types/common.js.map +1 -1
  19. package/cjs/vrender.js.map +1 -1
  20. package/dist/vtable.js +135 -2
  21. package/dist/vtable.min.js +1 -1
  22. package/es/core/BaseTable.d.ts +9 -1
  23. package/es/core/BaseTable.js +16 -8
  24. package/es/core/BaseTable.js.map +1 -1
  25. package/es/index.d.ts +1 -1
  26. package/es/index.js +1 -1
  27. package/es/index.js.map +1 -1
  28. package/es/plugins/custom-cell-style.d.ts +19 -0
  29. package/es/plugins/custom-cell-style.js +52 -0
  30. package/es/plugins/custom-cell-style.js.map +1 -0
  31. package/es/scenegraph/scenegraph.js +1 -2
  32. package/es/state/state.js +2 -1
  33. package/es/themes/theme.js +1 -1
  34. package/es/tools/isx.d.ts +1 -1
  35. package/es/tools/util.d.ts +1 -1
  36. package/es/ts-types/base-table.d.ts +10 -2
  37. package/es/ts-types/base-table.js.map +1 -1
  38. package/es/ts-types/common.d.ts +12 -2
  39. package/es/ts-types/common.js.map +1 -1
  40. package/es/vrender.js.map +1 -1
  41. package/package.json +2 -2
package/dist/vtable.js CHANGED
@@ -52618,6 +52618,118 @@
52618
52618
  return high < 0 ? 0 : high;
52619
52619
  }
52620
52620
 
52621
+ class CustomCellStylePlugin {
52622
+ table;
52623
+ customCellStyle;
52624
+ customCellStyleArrangement;
52625
+ constructor(table, customCellStyle, customCellStyleArrangement) {
52626
+ this.table = table;
52627
+ this.customCellStyle = customCellStyle;
52628
+ this.customCellStyleArrangement = customCellStyleArrangement;
52629
+ }
52630
+ getCustomCellStyle(col, row) {
52631
+ const customStyleId = this.getCustomCellStyleId(col, row);
52632
+ if (customStyleId) {
52633
+ const styleOption = this.getCustomCellStyleOption(customStyleId);
52634
+ return styleOption.style;
52635
+ }
52636
+ return undefined;
52637
+ }
52638
+ getCustomCellStyleId(col, row) {
52639
+ let customStyleId;
52640
+ this.customCellStyleArrangement.forEach(style => {
52641
+ if (style.range) {
52642
+ if (style.range.start.col <= col &&
52643
+ style.range.end.col >= col &&
52644
+ style.range.start.row <= row &&
52645
+ style.range.end.row >= row) {
52646
+ customStyleId = style.customStyleId;
52647
+ }
52648
+ }
52649
+ else if (style.col === col && style.row === row) {
52650
+ customStyleId = style.customStyleId;
52651
+ }
52652
+ });
52653
+ return customStyleId;
52654
+ }
52655
+ getCustomCellStyleOption(customStyleId) {
52656
+ return this.customCellStyle.find(style => style.id === customStyleId);
52657
+ }
52658
+ registerCustomCellStyle(customStyleId, customStyle) {
52659
+ const index = this.customCellStyle.findIndex(style => style.id === customStyleId);
52660
+ if (index === -1) {
52661
+ this.customCellStyle.push({
52662
+ id: customStyleId,
52663
+ style: customStyle
52664
+ });
52665
+ }
52666
+ else {
52667
+ this.customCellStyle[index] = {
52668
+ id: customStyleId,
52669
+ style: customStyle
52670
+ };
52671
+ }
52672
+ this.customCellStyleArrangement.forEach(cellPos => {
52673
+ if (cellPos.customStyleId === customStyleId) {
52674
+ if (cellPos.range) {
52675
+ for (let col = cellPos.range.start.col; col <= cellPos.range.end.col; col++) {
52676
+ for (let row = cellPos.range.start.row; row <= cellPos.range.end.row; row++) {
52677
+ this.table.scenegraph.updateCellContent(col, row);
52678
+ }
52679
+ }
52680
+ }
52681
+ else {
52682
+ this.table.scenegraph.updateCellContent(cellPos.col, cellPos.row);
52683
+ }
52684
+ }
52685
+ });
52686
+ this.table.scenegraph.updateNextFrame();
52687
+ }
52688
+ arrangeCustomCellStyle(cellPos, customStyleId) {
52689
+ const index = this.customCellStyleArrangement.findIndex(style => {
52690
+ if (style.range && cellPos.range) {
52691
+ return (style.range.start.col === cellPos.range.start.col &&
52692
+ style.range.start.row === cellPos.range.start.row &&
52693
+ style.range.end.col === cellPos.range.end.col &&
52694
+ style.range.end.row === cellPos.range.end.row);
52695
+ }
52696
+ return style.col === cellPos.col && style.row === cellPos.row;
52697
+ });
52698
+ if (index === -1) {
52699
+ this.customCellStyleArrangement.push({
52700
+ customStyleId: customStyleId,
52701
+ col: cellPos.col,
52702
+ row: cellPos.row,
52703
+ range: cellPos.range
52704
+ });
52705
+ }
52706
+ else {
52707
+ this.customCellStyleArrangement[index].customStyleId = customStyleId;
52708
+ }
52709
+ if (cellPos.range) {
52710
+ for (let col = cellPos.range.start.col; col <= cellPos.range.end.col; col++) {
52711
+ for (let row = cellPos.range.start.row; row <= cellPos.range.end.row; row++) {
52712
+ this.table.scenegraph.updateCellContent(col, row);
52713
+ }
52714
+ }
52715
+ }
52716
+ else {
52717
+ this.table.scenegraph.updateCellContent(cellPos.col, cellPos.row);
52718
+ }
52719
+ this.table.scenegraph.updateNextFrame();
52720
+ }
52721
+ }
52722
+ function mergeStyle(cacheStyle, customCellStyle) {
52723
+ cacheStyle = cacheStyle.clone();
52724
+ for (const key in customCellStyle) {
52725
+ const value = customCellStyle[key];
52726
+ if (value) {
52727
+ cacheStyle[`_${key}`] = value;
52728
+ }
52729
+ }
52730
+ return cacheStyle;
52731
+ }
52732
+
52621
52733
  const { toBoxArray } = style;
52622
52734
  const { isTouchEvent } = event;
52623
52735
  const rangeReg = /^\$(\d+)\$(\d+)$/;
@@ -52648,7 +52760,7 @@
52648
52760
  return TABLE_EVENT_TYPE;
52649
52761
  }
52650
52762
  options;
52651
- version = "0.20.4-alpha.1";
52763
+ version = "0.20.4-alpha.3";
52652
52764
  pagination;
52653
52765
  id = `VTable${Date.now()}`;
52654
52766
  headerStyleCache;
@@ -52657,6 +52769,7 @@
52657
52769
  container;
52658
52770
  isReleased = false;
52659
52771
  _chartEventMap = {};
52772
+ customCellStylePlugin;
52660
52773
  constructor(container, options = {}) {
52661
52774
  super();
52662
52775
  if (!container && options.mode !== 'node') {
@@ -52797,6 +52910,7 @@
52797
52910
  this.bodyBottomStyleCache = new Map();
52798
52911
  internalProps.stick = { changedCells: new Map() };
52799
52912
  internalProps.customMergeCell = options.customMergeCell;
52913
+ this.customCellStylePlugin = new CustomCellStylePlugin(this, options.customCellStyle ?? [], options.customCellStyleArrangement ?? []);
52800
52914
  }
52801
52915
  throttleInvalidate = throttle2(this.render.bind(this), 200);
52802
52916
  getContainer() {
@@ -54318,6 +54432,7 @@
54318
54432
  return table.internalProps.dataSource?.hasField(index, field);
54319
54433
  }
54320
54434
  _getCellStyle(col, row) {
54435
+ const customCellStyle = this.customCellStylePlugin.getCustomCellStyle(col, row);
54321
54436
  const { layoutMap } = this.internalProps;
54322
54437
  const isHeader = layoutMap.isHeader(col, row);
54323
54438
  if (isHeader) {
@@ -54335,6 +54450,9 @@
54335
54450
  }
54336
54451
  let cacheStyle = this.headerStyleCache.get(cacheKey);
54337
54452
  if (cacheStyle) {
54453
+ if (customCellStyle) {
54454
+ return mergeStyle(cacheStyle, customCellStyle);
54455
+ }
54338
54456
  return cacheStyle;
54339
54457
  }
54340
54458
  const hd = layoutMap.getHeader(col, row);
@@ -54400,6 +54518,9 @@
54400
54518
  }, styleClass, this.options.autoWrapText, this.theme);
54401
54519
  }
54402
54520
  this.headerStyleCache.set(cacheKey, cacheStyle);
54521
+ if (customCellStyle) {
54522
+ return mergeStyle(cacheStyle, customCellStyle);
54523
+ }
54403
54524
  return cacheStyle;
54404
54525
  }
54405
54526
  let cacheKey;
@@ -54419,6 +54540,9 @@
54419
54540
  cacheStyle = this.bodyStyleCache.get(cacheKey);
54420
54541
  }
54421
54542
  if (cacheStyle) {
54543
+ if (customCellStyle) {
54544
+ return mergeStyle(cacheStyle, customCellStyle);
54545
+ }
54422
54546
  return cacheStyle;
54423
54547
  }
54424
54548
  const column = layoutMap.getBody(col, row);
@@ -54444,6 +54568,9 @@
54444
54568
  this.bodyStyleCache.set(cacheKey, cacheStyle);
54445
54569
  }
54446
54570
  }
54571
+ if (customCellStyle) {
54572
+ return mergeStyle(cacheStyle, customCellStyle);
54573
+ }
54447
54574
  return cacheStyle;
54448
54575
  }
54449
54576
  clearCellStyleCache() {
@@ -54994,6 +55121,12 @@
54994
55121
  }
54995
55122
  }
54996
55123
  }
55124
+ registerCustomCellStyle(customStyleId, customStyle) {
55125
+ this.customCellStylePlugin.registerCustomCellStyle(customStyleId, customStyle);
55126
+ }
55127
+ arrangeCustomCellStyle(cellPos, customStyleId) {
55128
+ this.customCellStylePlugin.arrangeCustomCellStyle(cellPos, customStyleId);
55129
+ }
54997
55130
  }
54998
55131
 
54999
55132
  var core = /*#__PURE__*/Object.freeze({
@@ -64157,7 +64290,7 @@
64157
64290
  }
64158
64291
 
64159
64292
  registerForVrender();
64160
- const version = "0.20.4-alpha.1";
64293
+ const version = "0.20.4-alpha.3";
64161
64294
  function getIcons() {
64162
64295
  return get$2();
64163
64296
  }