@visactor/vtable 1.13.3-alpha.6 → 1.14.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 (61) hide show
  1. package/cjs/ListTable.js +1 -1
  2. package/cjs/ListTable.js.map +1 -1
  3. package/cjs/PivotTable.js +1 -1
  4. package/cjs/PivotTable.js.map +1 -1
  5. package/cjs/core/BaseTable.d.ts +3 -3
  6. package/cjs/core/BaseTable.js +9 -10
  7. package/cjs/core/BaseTable.js.map +1 -1
  8. package/cjs/core/record-helper.js +1 -1
  9. package/cjs/core/record-helper.js.map +1 -1
  10. package/cjs/edit/edit-manager.d.ts +2 -2
  11. package/cjs/edit/edit-manager.js +16 -7
  12. package/cjs/edit/edit-manager.js.map +1 -1
  13. package/cjs/index.d.ts +1 -1
  14. package/cjs/index.js +1 -1
  15. package/cjs/index.js.map +1 -1
  16. package/cjs/layout/chart-helper/get-axis-config.js +7 -1
  17. package/cjs/layout/chart-helper/get-axis-config.js.map +1 -1
  18. package/cjs/layout/chart-helper/get-axis-domain.js +4 -3
  19. package/cjs/layout/chart-helper/get-axis-domain.js.map +1 -1
  20. package/cjs/plugins/custom-cell-style.d.ts +1 -1
  21. package/cjs/plugins/custom-cell-style.js +1 -2
  22. package/cjs/plugins/custom-cell-style.js.map +1 -1
  23. package/cjs/state/checkbox/checkbox.js +9 -7
  24. package/cjs/state/checkbox/checkbox.js.map +1 -1
  25. package/cjs/ts-types/base-table.d.ts +2 -3
  26. package/cjs/ts-types/base-table.js.map +1 -1
  27. package/cjs/ts-types/table-engine.d.ts +3 -3
  28. package/cjs/ts-types/table-engine.js.map +1 -1
  29. package/cjs/vrender.js.map +1 -1
  30. package/dist/vtable.js +74 -45
  31. package/dist/vtable.min.js +2 -2
  32. package/es/ListTable.js +2 -2
  33. package/es/ListTable.js.map +1 -1
  34. package/es/PivotTable.js +2 -2
  35. package/es/PivotTable.js.map +1 -1
  36. package/es/core/BaseTable.d.ts +3 -3
  37. package/es/core/BaseTable.js +9 -10
  38. package/es/core/BaseTable.js.map +1 -1
  39. package/es/core/record-helper.js +1 -1
  40. package/es/core/record-helper.js.map +1 -1
  41. package/es/edit/edit-manager.d.ts +2 -2
  42. package/es/edit/edit-manager.js +13 -4
  43. package/es/edit/edit-manager.js.map +1 -1
  44. package/es/index.d.ts +1 -1
  45. package/es/index.js +1 -1
  46. package/es/index.js.map +1 -1
  47. package/es/layout/chart-helper/get-axis-config.js +6 -1
  48. package/es/layout/chart-helper/get-axis-config.js.map +1 -1
  49. package/es/layout/chart-helper/get-axis-domain.js +3 -3
  50. package/es/layout/chart-helper/get-axis-domain.js.map +1 -1
  51. package/es/plugins/custom-cell-style.d.ts +1 -1
  52. package/es/plugins/custom-cell-style.js +1 -2
  53. package/es/plugins/custom-cell-style.js.map +1 -1
  54. package/es/state/checkbox/checkbox.js +8 -7
  55. package/es/state/checkbox/checkbox.js.map +1 -1
  56. package/es/ts-types/base-table.d.ts +2 -3
  57. package/es/ts-types/base-table.js.map +1 -1
  58. package/es/ts-types/table-engine.d.ts +3 -3
  59. package/es/ts-types/table-engine.js.map +1 -1
  60. package/es/vrender.js.map +1 -1
  61. package/package.json +6 -6
package/dist/vtable.js CHANGED
@@ -12229,10 +12229,7 @@
12229
12229
  const {
12230
12230
  context: context
12231
12231
  } = drawContext;
12232
- context.highPerformanceSave();
12233
- const t1 = graphic.parent.globalTransMatrix,
12234
- t2 = graphic.stage.window.getViewBoxTransform().clone().multiply(t1.a, t1.b, t1.c, t1.d, t1.e, t1.f);
12235
- if (graphic.parent && context.setTransformFromMatrix(t2, !0), drawContribution.dirtyBounds && drawContribution.backupDirtyBounds) {
12232
+ if (context.highPerformanceSave(), context.transformFromMatrix(graphic.transMatrix, !0), drawContribution.dirtyBounds && drawContribution.backupDirtyBounds) {
12236
12233
  tempDirtyBounds.copy(drawContribution.dirtyBounds), tempBackupDirtyBounds.copy(drawContribution.backupDirtyBounds);
12237
12234
  const m = graphic.globalTransMatrix.getInverse();
12238
12235
  drawContribution.dirtyBounds.copy(drawContribution.backupDirtyBounds).transformWithMatrix(m), drawContribution.backupDirtyBounds.copy(drawContribution.dirtyBounds);
@@ -50225,7 +50222,7 @@
50225
50222
  isNeedInitHeaderCheckedStateFromRecord = true;
50226
50223
  }
50227
50224
  if (isNeedInitHeaderCheckedStateFromRecord) {
50228
- initRecordCheckState(state);
50225
+ initRecordCheckState(records, state);
50229
50226
  }
50230
50227
  }
50231
50228
  function updateHeaderCheckedState(field, state, col, row) {
@@ -50245,7 +50242,7 @@
50245
50242
  const mergeCell = state.table.transpose
50246
50243
  ? state.table.getCustomMerge(tableIndex, row)
50247
50244
  : state.table.getCustomMerge(col, tableIndex);
50248
- const data = state.table.dataSource.get(index);
50245
+ const data = state.table.dataSource?.get(index);
50249
50246
  if (mergeCell || data.vtableMerge) {
50250
50247
  return;
50251
50248
  }
@@ -50405,14 +50402,24 @@
50405
50402
  });
50406
50403
  return result;
50407
50404
  }
50408
- function initRecordCheckState(state) {
50405
+ function initRecordCheckState(records, state) {
50409
50406
  const table = state.table;
50410
- const start = table.internalProps.transpose ? table.rowHeaderLevelCount : table.columnHeaderLevelCount;
50411
- const end = table.internalProps.transpose ? table.colCount : table.rowCount;
50407
+ const start = table.isPivotTable()
50408
+ ? 0
50409
+ : table.internalProps.transpose
50410
+ ? table.rowHeaderLevelCount
50411
+ : table.columnHeaderLevelCount;
50412
+ const end = table.isPivotTable()
50413
+ ? isArray$1(records)
50414
+ ? records.length
50415
+ : 0
50416
+ : table.internalProps.transpose
50417
+ ? table.colCount
50418
+ : table.rowCount;
50412
50419
  for (let index = 0; index + start < end; index++) {
50413
- const record = table.dataSource.get(index);
50420
+ const record = table.isPivotTable() ? records[index] : table.dataSource.get(index);
50414
50421
  state._checkboxCellTypeFields.forEach(field => {
50415
- const value = record[field];
50422
+ const value = record && record[field];
50416
50423
  let isChecked;
50417
50424
  if (isObject$4(value)) {
50418
50425
  isChecked = value.checked;
@@ -50434,7 +50441,7 @@
50434
50441
  isChecked = globalChecked;
50435
50442
  }
50436
50443
  }
50437
- const dataIndex = state.table.dataSource.getIndexKey(index).toString();
50444
+ const dataIndex = table.isPivotTable() ? index.toString() : state.table.dataSource.getIndexKey(index).toString();
50438
50445
  if (!state.checkedState.get(dataIndex)) {
50439
50446
  state.checkedState.set(dataIndex, {});
50440
50447
  }
@@ -58043,7 +58050,7 @@
58043
58050
  const { targetRange, targetTicks } = getTargetRangeAndTicks(col, row, index, isZeroAlign, isTickAlign, range, indicatorKeys, subAxisPosition, path, layout);
58044
58051
  if (index !== 0 && targetTicks) {
58045
58052
  const getAxisDomainRangeAndLabels = Factory.getFunction('getAxisDomainRangeAndLabels');
58046
- const { range: newRange, ticks: newTicks } = getAxisDomainRangeAndLabels(range.min, range.max, isZeroAlign, position === 'bottom' || position === 'top'
58053
+ const { range: newRange, ticks: newTicks } = getAxisDomainRangeAndLabels(range.min, range.max, merge({}, axisOption, { nice: true, tick: { forceTickCount: targetTicks.length } }), isZeroAlign, position === 'bottom' || position === 'top'
58047
58054
  ? layout._table.getColWidth(col) || layout._table.tableNoFrameWidth
58048
58055
  : layout._table.getRowHeight(row) || layout._table.tableNoFrameHeight, {
58049
58056
  targetTicks,
@@ -58175,7 +58182,7 @@
58175
58182
  });
58176
58183
  this.table.scenegraph.updateNextFrame();
58177
58184
  }
58178
- arrangeCustomCellStyle(cellPos, customStyleId) {
58185
+ arrangeCustomCellStyle(cellPos, customStyleId, forceFastUpdate) {
58179
58186
  const index = this.customCellStyleArrangement.findIndex(style => {
58180
58187
  if (style.cellPosition.range && cellPos.range) {
58181
58188
  return (style.cellPosition.range.start.col === cellPos.range.start.col &&
@@ -58208,7 +58215,6 @@
58208
58215
  this.customCellStyleArrangement.splice(index, 1);
58209
58216
  }
58210
58217
  const style = this.getCustomCellStyleOption(customStyleId)?.style;
58211
- let forceFastUpdate;
58212
58218
  if (style) {
58213
58219
  forceFastUpdate = true;
58214
58220
  for (const key in style) {
@@ -58520,7 +58526,7 @@
58520
58526
  return TABLE_EVENT_TYPE;
58521
58527
  }
58522
58528
  options;
58523
- version = "1.13.3-alpha.6";
58529
+ version = "1.14.0";
58524
58530
  pagination;
58525
58531
  id = `VTable${Date.now()}`;
58526
58532
  headerStyleCache;
@@ -59035,16 +59041,15 @@
59035
59041
  element.parentElement.offsetHeight -
59036
59042
  parseInt(computedStyle.paddingTop || '0px', 10) -
59037
59043
  parseInt(computedStyle.paddingBottom || '0px', 20);
59038
- widthWithoutPadding = (widthWithoutPadding ?? 1) - (this.options.tableSizeAntiJitter ? 1 : 0);
59039
- heightWithoutPadding = (heightWithoutPadding ?? 1) - (this.options.tableSizeAntiJitter ? 1 : 0);
59040
59044
  }
59041
59045
  }
59042
- element.style.width = (widthWithoutPadding && `${widthWithoutPadding - padding.left - padding.right}px`) || '0px';
59043
- element.style.height =
59044
- (heightWithoutPadding && `${heightWithoutPadding - padding.top - padding.bottom}px`) || '0px';
59046
+ const width1 = widthWithoutPadding ?? 1 - 1;
59047
+ const height1 = heightWithoutPadding ?? 1 - 1;
59048
+ element.style.width = (width1 && `${width1 - padding.left - padding.right}px`) || '0px';
59049
+ element.style.height = (height1 && `${height1 - padding.top - padding.bottom}px`) || '0px';
59045
59050
  const { canvas } = this.internalProps;
59046
- widthP = (canvas.parentElement?.offsetWidth ?? 1) - (this.options.tableSizeAntiJitter ? 1 : 0);
59047
- heightP = (canvas.parentElement?.offsetHeight ?? 1) - (this.options.tableSizeAntiJitter ? 1 : 0);
59051
+ widthP = canvas.parentElement?.offsetWidth ?? 1 - 1;
59052
+ heightP = canvas.parentElement?.offsetHeight ?? 1 - 1;
59048
59053
  if (this?.scenegraph?.stage) {
59049
59054
  this.scenegraph.stage.resize(widthP, heightP);
59050
59055
  }
@@ -61089,8 +61094,8 @@
61089
61094
  registerCustomCellStyle(customStyleId, customStyle) {
61090
61095
  this.customCellStylePlugin?.registerCustomCellStyle(customStyleId, customStyle);
61091
61096
  }
61092
- arrangeCustomCellStyle(cellPos, customStyleId) {
61093
- this.customCellStylePlugin?.arrangeCustomCellStyle(cellPos, customStyleId);
61097
+ arrangeCustomCellStyle(cellPos, customStyleId, forceFastUpdate) {
61098
+ this.customCellStylePlugin?.arrangeCustomCellStyle(cellPos, customStyleId, forceFastUpdate);
61094
61099
  }
61095
61100
  isSeriesNumber(col, row) {
61096
61101
  return this.internalProps.layoutMap.isSeriesNumber(col, row);
@@ -63583,7 +63588,7 @@
63583
63588
  }
63584
63589
  }
63585
63590
 
63586
- class EditManeger {
63591
+ class EditManager {
63587
63592
  table;
63588
63593
  editingEditor;
63589
63594
  isValidatingValue = false;
@@ -63677,20 +63682,16 @@
63677
63682
  }
63678
63683
  if (!this.editingEditor.getValue) ;
63679
63684
  if (this.editingEditor.validateValue) {
63680
- const maybePromiseOrValue = this.editingEditor.validateValue?.();
63685
+ this.isValidatingValue = true;
63686
+ const newValue = this.editingEditor.getValue();
63687
+ const oldValue = this.table.getCellOriginValue(this.editCell.col, this.editCell.row);
63688
+ const maybePromiseOrValue = this.editingEditor.validateValue?.(newValue, oldValue, this.editCell, this.table);
63681
63689
  if (isPromise(maybePromiseOrValue)) {
63682
63690
  this.isValidatingValue = true;
63683
63691
  return new Promise((resolve, reject) => {
63684
63692
  maybePromiseOrValue
63685
63693
  .then(result => {
63686
- if (result) {
63687
- this.doExit();
63688
- resolve(true);
63689
- }
63690
- else {
63691
- this.isValidatingValue = false;
63692
- resolve(false);
63693
- }
63694
+ dealWithValidateValue(result, this, oldValue, resolve);
63694
63695
  })
63695
63696
  .catch((err) => {
63696
63697
  this.isValidatingValue = false;
@@ -63698,11 +63699,7 @@
63698
63699
  });
63699
63700
  });
63700
63701
  }
63701
- else if (maybePromiseOrValue) {
63702
- this.doExit();
63703
- return true;
63704
- }
63705
- return false;
63702
+ return dealWithValidateValue(maybePromiseOrValue, this, oldValue);
63706
63703
  }
63707
63704
  this.doExit();
63708
63705
  return true;
@@ -63733,6 +63730,35 @@
63733
63730
  }
63734
63731
  }
63735
63732
  }
63733
+ function dealWithValidateValue(validateValue, editManager, oldValue, resolve) {
63734
+ editManager.isValidatingValue = false;
63735
+ if (validateValue === 'validate-exit') {
63736
+ editManager.doExit();
63737
+ resolve?.(true);
63738
+ return true;
63739
+ }
63740
+ else if (validateValue === 'invalidate-exit') {
63741
+ editManager.editingEditor.setValue(oldValue);
63742
+ editManager.doExit();
63743
+ resolve?.(true);
63744
+ return true;
63745
+ }
63746
+ else if (validateValue === 'validate-not-exit') {
63747
+ resolve?.(false);
63748
+ return false;
63749
+ }
63750
+ else if (validateValue === 'invalidate-not-exit') {
63751
+ resolve?.(false);
63752
+ return false;
63753
+ }
63754
+ else if (validateValue === true) {
63755
+ editManager.doExit();
63756
+ resolve?.(true);
63757
+ return true;
63758
+ }
63759
+ resolve?.(false);
63760
+ return false;
63761
+ }
63736
63762
 
63737
63763
  function getGroupByDataConfig(groupByOption) {
63738
63764
  if (isString$2(groupByOption)) {
@@ -63873,7 +63899,10 @@
63873
63899
  isCanChange = true;
63874
63900
  }
63875
63901
  else {
63876
- isCanChange = maybePromiseOrValue;
63902
+ isCanChange =
63903
+ maybePromiseOrValue === true ||
63904
+ maybePromiseOrValue === 'validate-exit' ||
63905
+ maybePromiseOrValue === 'invalidate-exit';
63877
63906
  }
63878
63907
  }
63879
63908
  }
@@ -64513,7 +64542,7 @@
64513
64542
  this.showHeader = options.showHeader ?? true;
64514
64543
  this.transpose = options.transpose ?? false;
64515
64544
  if (Env.mode !== 'node') {
64516
- this.editorManager = new EditManeger(this);
64545
+ this.editorManager = new EditManager(this);
64517
64546
  }
64518
64547
  this.refreshHeader();
64519
64548
  this.internalProps.useOneRowHeightFillAll = false;
@@ -71009,7 +71038,7 @@
71009
71038
  scaleTicks = scale.forceTicks(target?.targetTicks?.length ?? axisOption?.tick?.forceTickCount);
71010
71039
  }
71011
71040
  else {
71012
- scaleTicks = scale.ticks(axisOption?.tick?.tickCount ?? DEFAULT_CONTINUOUS_TICK_COUNT, {
71041
+ scaleTicks = scale.ticks(isNumber$2(axisOption?.tick?.tickCount) ? axisOption.tick.tickCount : DEFAULT_CONTINUOUS_TICK_COUNT, {
71013
71042
  noDecimals: axisOption?.tick?.noDecimals
71014
71043
  });
71015
71044
  }
@@ -75977,7 +76006,7 @@
75977
76006
  this.pivotSortState = options.pivotSortState;
75978
76007
  }
75979
76008
  if (Env.mode !== 'node') {
75980
- this.editorManager = new EditManeger(this);
76009
+ this.editorManager = new EditManager(this);
75981
76010
  }
75982
76011
  this.refreshHeader();
75983
76012
  this.internalProps.useOneRowHeightFillAll = false;
@@ -79019,7 +79048,7 @@
79019
79048
  }
79020
79049
 
79021
79050
  registerForVrender();
79022
- const version = "1.13.3-alpha.6";
79051
+ const version = "1.14.0";
79023
79052
  function getIcons() {
79024
79053
  return get$2();
79025
79054
  }