@visactor/vtable 0.24.2-alpha.2 → 0.24.2-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 (83) hide show
  1. package/cjs/PivotTable.js +69 -27
  2. package/cjs/PivotTable.js.map +1 -1
  3. package/cjs/core/BaseTable.js +4 -38
  4. package/cjs/core/BaseTable.js.map +1 -1
  5. package/cjs/dataset/dataset.d.ts +1 -0
  6. package/cjs/dataset/dataset.js +14 -0
  7. package/cjs/dataset/dataset.js.map +1 -1
  8. package/cjs/dataset/flatDataToObject.d.ts +8 -3
  9. package/cjs/dataset/flatDataToObject.js +39 -8
  10. package/cjs/dataset/flatDataToObject.js.map +1 -1
  11. package/cjs/edit/edit-manager.js +0 -1
  12. package/cjs/edit/edit-manager.js.map +1 -1
  13. package/cjs/event/drill.js +2 -1
  14. package/cjs/event/media-click.js +1 -2
  15. package/cjs/index.d.ts +1 -1
  16. package/cjs/index.js +1 -1
  17. package/cjs/index.js.map +1 -1
  18. package/cjs/layout/pivot-header-layout.d.ts +1 -0
  19. package/cjs/layout/pivot-header-layout.js +16 -4
  20. package/cjs/layout/pivot-header-layout.js.map +1 -1
  21. package/cjs/scenegraph/graphic/contributions/group-contribution-render.js +9 -18
  22. package/cjs/scenegraph/graphic/contributions/group-contribution-render.js.map +1 -1
  23. package/cjs/scenegraph/group-creater/progress/create-group-for-first-screen.js +3 -3
  24. package/cjs/scenegraph/group-creater/progress/create-group-for-first-screen.js.map +1 -1
  25. package/cjs/scenegraph/group-creater/progress/proxy.js +2 -4
  26. package/cjs/scenegraph/group-creater/progress/proxy.js.map +1 -1
  27. package/cjs/scenegraph/scenegraph.d.ts +0 -1
  28. package/cjs/scenegraph/scenegraph.js +6 -8
  29. package/cjs/scenegraph/scenegraph.js.map +1 -1
  30. package/cjs/scenegraph/select/update-select-border.js +4 -4
  31. package/cjs/scenegraph/select/update-select-border.js.map +1 -1
  32. package/cjs/state/state.js +1 -1
  33. package/cjs/themes/component.js +1 -1
  34. package/cjs/ts-types/pivot-table/dimension/basic-dimension.d.ts +6 -1
  35. package/cjs/ts-types/pivot-table/dimension/basic-dimension.js.map +1 -1
  36. package/cjs/ts-types/pivot-table/indicator/basic-indicator.d.ts +3 -0
  37. package/cjs/ts-types/pivot-table/indicator/basic-indicator.js.map +1 -1
  38. package/cjs/ts-types/table-engine.d.ts +3 -0
  39. package/cjs/ts-types/table-engine.js.map +1 -1
  40. package/cjs/vrender.js.map +1 -1
  41. package/dist/vtable.js +240 -143
  42. package/dist/vtable.min.js +1 -1
  43. package/es/PivotTable.js +69 -27
  44. package/es/PivotTable.js.map +1 -1
  45. package/es/core/BaseTable.js +5 -37
  46. package/es/core/BaseTable.js.map +1 -1
  47. package/es/dataset/dataset.d.ts +1 -0
  48. package/es/dataset/dataset.js +14 -0
  49. package/es/dataset/dataset.js.map +1 -1
  50. package/es/dataset/flatDataToObject.d.ts +8 -3
  51. package/es/dataset/flatDataToObject.js +38 -8
  52. package/es/dataset/flatDataToObject.js.map +1 -1
  53. package/es/edit/edit-manager.js +0 -1
  54. package/es/edit/edit-manager.js.map +1 -1
  55. package/es/event/drill.js +2 -1
  56. package/es/event/media-click.js +1 -2
  57. package/es/index.d.ts +1 -1
  58. package/es/index.js +1 -1
  59. package/es/index.js.map +1 -1
  60. package/es/layout/pivot-header-layout.d.ts +1 -0
  61. package/es/layout/pivot-header-layout.js +12 -2
  62. package/es/layout/pivot-header-layout.js.map +1 -1
  63. package/es/scenegraph/graphic/contributions/group-contribution-render.js +9 -18
  64. package/es/scenegraph/graphic/contributions/group-contribution-render.js.map +1 -1
  65. package/es/scenegraph/group-creater/progress/create-group-for-first-screen.js +3 -3
  66. package/es/scenegraph/group-creater/progress/create-group-for-first-screen.js.map +1 -1
  67. package/es/scenegraph/group-creater/progress/proxy.js +2 -4
  68. package/es/scenegraph/group-creater/progress/proxy.js.map +1 -1
  69. package/es/scenegraph/scenegraph.d.ts +0 -1
  70. package/es/scenegraph/scenegraph.js +6 -8
  71. package/es/scenegraph/scenegraph.js.map +1 -1
  72. package/es/scenegraph/select/update-select-border.js +4 -4
  73. package/es/scenegraph/select/update-select-border.js.map +1 -1
  74. package/es/state/state.js +1 -1
  75. package/es/themes/component.js +1 -1
  76. package/es/ts-types/pivot-table/dimension/basic-dimension.d.ts +6 -1
  77. package/es/ts-types/pivot-table/dimension/basic-dimension.js.map +1 -1
  78. package/es/ts-types/pivot-table/indicator/basic-indicator.d.ts +3 -0
  79. package/es/ts-types/pivot-table/indicator/basic-indicator.js.map +1 -1
  80. package/es/ts-types/table-engine.d.ts +3 -0
  81. package/es/ts-types/table-engine.js.map +1 -1
  82. package/es/vrender.js.map +1 -1
  83. package/package.json +4 -4
package/cjs/PivotTable.js CHANGED
@@ -348,14 +348,37 @@ class PivotTable extends BaseTable_1.BaseTable {
348
348
  })), rowKeys = cellDimensionPath.rowHeaderPaths.map((rowPath => {
349
349
  var _a;
350
350
  return null !== (_a = rowPath.indicatorKey) && void 0 !== _a ? _a : rowPath.value;
351
- })), treeNode = this.flatDataToObjects.getTreeNode(rowKeys, colKeys, this.internalProps.layoutMap.getBody(col, row).indicatorKey, !1);
351
+ })), treeNode = this.flatDataToObjects.getTreeNode(rowKeys, colKeys, this.internalProps.layoutMap.getBody(col, row).indicatorKey);
352
352
  return null == treeNode ? void 0 : treeNode.record;
353
353
  }
354
354
  const rowIndex = this.getBodyIndexByRow(row), colIndex = this.getBodyIndexByCol(col);
355
355
  return null === (_a = this.records[rowIndex]) || void 0 === _a ? void 0 : _a[colIndex];
356
356
  }
357
357
  getCellRawRecord(col, row) {
358
- return this.getCellOriginRecord(col, row);
358
+ var _a;
359
+ if (this.internalProps.layoutMap.isHeader(col, row)) return;
360
+ if (this.dataset) {
361
+ const cellDimensionPath = this.internalProps.layoutMap.getCellHeaderPaths(col, row), colKeys = cellDimensionPath.colHeaderPaths.map((colPath => {
362
+ var _a;
363
+ return null !== (_a = colPath.indicatorKey) && void 0 !== _a ? _a : colPath.value;
364
+ })), rowKeys = cellDimensionPath.rowHeaderPaths.map((rowPath => {
365
+ var _a;
366
+ return null !== (_a = rowPath.indicatorKey) && void 0 !== _a ? _a : rowPath.value;
367
+ }));
368
+ return this.dataset.getAggregator(this.internalProps.layoutMap.indicatorsAsCol ? rowKeys : rowKeys.slice(0, -1), this.internalProps.layoutMap.indicatorsAsCol ? colKeys.slice(0, -1) : colKeys, this.internalProps.layoutMap.getIndicatorKey(col, row)).records;
369
+ }
370
+ if (this.flatDataToObjects) {
371
+ const cellDimensionPath = this.internalProps.layoutMap.getCellHeaderPaths(col, row), colKeys = cellDimensionPath.colHeaderPaths.map((colPath => {
372
+ var _a;
373
+ return null !== (_a = colPath.indicatorKey) && void 0 !== _a ? _a : colPath.value;
374
+ })), rowKeys = cellDimensionPath.rowHeaderPaths.map((rowPath => {
375
+ var _a;
376
+ return null !== (_a = rowPath.indicatorKey) && void 0 !== _a ? _a : rowPath.value;
377
+ })), treeNode = this.flatDataToObjects.getTreeNode(rowKeys, colKeys, this.internalProps.layoutMap.getBody(col, row).indicatorKey, !1);
378
+ return null == treeNode ? void 0 : treeNode.record;
379
+ }
380
+ const rowIndex = this.getBodyIndexByRow(row), colIndex = this.getBodyIndexByCol(col);
381
+ return null === (_a = this.records[rowIndex]) || void 0 === _a ? void 0 : _a[colIndex];
359
382
  }
360
383
  updateSortRules(sortRules) {
361
384
  this.internalProps.dataConfig.sortRules = sortRules, this.dataset.updateSortRules(sortRules),
@@ -509,9 +532,15 @@ class PivotTable extends BaseTable_1.BaseTable {
509
532
  this.editorManager.completeEdit();
510
533
  }
511
534
  getEditor(col, row) {
512
- var _a;
513
- const define = this.getBodyColumnDefine(col, row);
514
- let editorDefine = null !== (_a = null == define ? void 0 : define.editor) && void 0 !== _a ? _a : this.options.editor;
535
+ var _a, _b;
536
+ let editorDefine;
537
+ if (this.isHeader(col, row) && !this.isCornerHeader(col, row)) {
538
+ const define = this.getHeaderDefine(col, row);
539
+ editorDefine = null !== (_a = null == define ? void 0 : define.headerEditor) && void 0 !== _a ? _a : this.options.headerEditor;
540
+ } else {
541
+ const define = this.getBodyColumnDefine(col, row);
542
+ editorDefine = null !== (_b = null == define ? void 0 : define.editor) && void 0 !== _b ? _b : this.options.editor;
543
+ }
515
544
  if ("function" == typeof editorDefine) {
516
545
  editorDefine = editorDefine({
517
546
  col: col,
@@ -541,9 +570,12 @@ class PivotTable extends BaseTable_1.BaseTable {
541
570
  changeCellValue(col, row, value, workOnEditableCell = !1) {
542
571
  if (workOnEditableCell && this.isHasEditorDefine(col, row) || !1 === workOnEditableCell) {
543
572
  let newValue = value;
544
- if ("number" == typeof this.getCellRawValue(col, row) && (0, util_1.isAllDigits)(value) && (newValue = parseFloat(value)),
545
- this._changeCellValueToDataSet(col, row, newValue), this.scenegraph.updateCellContent(col, row),
546
- "adaptive" === this.widthMode || this.autoFillWidth && this.getAllColsWidth() <= this.tableNoFrameWidth) 0 === this.internalProps._widthResizedColMap.size && this.scenegraph.recalculateColWidths(); else if (!this.internalProps._widthResizedColMap.has(col)) {
573
+ const oldValue = this.getCellOriginValue(col, row);
574
+ "number" == typeof this.getCellRawValue(col, row) && (0, util_1.isAllDigits)(value) && (newValue = parseFloat(value)),
575
+ this._changeCellValueToDataSet(col, row, oldValue, newValue);
576
+ const range = this.getCellRange(col, row);
577
+ for (let sCol = range.start.col; sCol <= range.end.col; sCol++) for (let sRow = range.start.row; sRow <= range.end.row; sRow++) this.scenegraph.updateCellContent(sCol, sRow);
578
+ if ("adaptive" === this.widthMode || this.autoFillWidth && this.getAllColsWidth() <= this.tableNoFrameWidth) 0 === this.internalProps._widthResizedColMap.size && this.scenegraph.recalculateColWidths(); else if (!this.internalProps._widthResizedColMap.has(col)) {
547
579
  const oldWidth = this.getColWidth(col), newWidth = (0, compute_col_width_1.computeColWidth)(col, 0, this.rowCount - 1, this, !1);
548
580
  newWidth !== oldWidth && this.scenegraph.updateColWidth(col, newWidth - oldWidth);
549
581
  }
@@ -569,9 +601,10 @@ class PivotTable extends BaseTable_1.BaseTable {
569
601
  workOnEditableCell && this.isHasEditorDefine(startCol + j, startRow + i) || !1 === workOnEditableCell) {
570
602
  const value = rowValues[j];
571
603
  let newValue = value;
572
- const rawValue = this.getCellRawValue(startCol + j, startRow + i);
604
+ const oldValue = this.getCellOriginValue(startCol + j, startRow + i), rawValue = this.getCellRawValue(startCol + j, startRow + i);
573
605
  "number" == typeof rawValue && (0, util_1.isAllDigits)(value) && (newValue = parseFloat(value)),
574
- this._changeCellValueToDataSet(startCol + j, startRow + i, newValue), this.fireListeners(TABLE_EVENT_TYPE_1.TABLE_EVENT_TYPE.CHANGE_CELL_VALUE, {
606
+ this._changeCellValueToDataSet(startCol + j, startRow + i, oldValue, newValue),
607
+ this.fireListeners(TABLE_EVENT_TYPE_1.TABLE_EVENT_TYPE.CHANGE_CELL_VALUE, {
575
608
  col: startCol + j,
576
609
  row: startRow + i,
577
610
  rawValue: rawValue,
@@ -596,25 +629,34 @@ class PivotTable extends BaseTable_1.BaseTable {
596
629
  }
597
630
  this.scenegraph.updateNextFrame();
598
631
  }
599
- _changeCellValueToDataSet(col, row, newValue) {
632
+ _changeCellValueToDataSet(col, row, oldValue, newValue) {
633
+ var _a, _b, _c, _d, _e, _f;
600
634
  if (this.dataset) {
601
- const cellDimensionPath = this.internalProps.layoutMap.getCellHeaderPaths(col, row), colKeys = cellDimensionPath.colHeaderPaths.map((colPath => {
602
- var _a;
603
- return null !== (_a = colPath.indicatorKey) && void 0 !== _a ? _a : colPath.value;
604
- })), rowKeys = cellDimensionPath.rowHeaderPaths.map((rowPath => {
605
- var _a;
606
- return null !== (_a = rowPath.indicatorKey) && void 0 !== _a ? _a : rowPath.value;
607
- }));
608
- this.dataset.changeTreeNodeValue(this.internalProps.layoutMap.indicatorsAsCol ? rowKeys : rowKeys.slice(0, -1), this.internalProps.layoutMap.indicatorsAsCol ? colKeys.slice(0, -1) : colKeys, this.internalProps.layoutMap.getIndicatorKey(col, row), newValue);
635
+ const cellDimensionPath = this.internalProps.layoutMap.getCellHeaderPaths(col, row);
636
+ if (this.isHeader(col, row)) this.internalProps.layoutMap.changeTreeNodeTitle(col, row, newValue),
637
+ !this.isCornerHeader(col, row) && this.dataset.changeRecordFieldValue((null === (_a = cellDimensionPath.colHeaderPaths) || void 0 === _a ? void 0 : _a.length) ? null !== (_b = cellDimensionPath.colHeaderPaths[cellDimensionPath.colHeaderPaths.length - 1].indicatorKey) && void 0 !== _b ? _b : cellDimensionPath.colHeaderPaths[cellDimensionPath.colHeaderPaths.length - 1].dimensionKey : null !== (_c = cellDimensionPath.rowHeaderPaths[cellDimensionPath.rowHeaderPaths.length - 1].indicatorKey) && void 0 !== _c ? _c : cellDimensionPath.rowHeaderPaths[cellDimensionPath.rowHeaderPaths.length - 1].dimensionKey, oldValue, newValue); else {
638
+ const colKeys = cellDimensionPath.colHeaderPaths.map((colPath => {
639
+ var _a;
640
+ return null !== (_a = colPath.indicatorKey) && void 0 !== _a ? _a : colPath.value;
641
+ })), rowKeys = cellDimensionPath.rowHeaderPaths.map((rowPath => {
642
+ var _a;
643
+ return null !== (_a = rowPath.indicatorKey) && void 0 !== _a ? _a : rowPath.value;
644
+ }));
645
+ this.dataset.changeTreeNodeValue(this.internalProps.layoutMap.indicatorsAsCol ? rowKeys : rowKeys.slice(0, -1), this.internalProps.layoutMap.indicatorsAsCol ? colKeys.slice(0, -1) : colKeys, this.internalProps.layoutMap.getIndicatorKey(col, row), newValue);
646
+ }
609
647
  } else if (this.flatDataToObjects) {
610
- const cellDimensionPath = this.internalProps.layoutMap.getCellHeaderPaths(col, row), colKeys = cellDimensionPath.colHeaderPaths.map((colPath => {
611
- var _a;
612
- return null !== (_a = colPath.indicatorKey) && void 0 !== _a ? _a : colPath.value;
613
- })), rowKeys = cellDimensionPath.rowHeaderPaths.map((rowPath => {
614
- var _a;
615
- return null !== (_a = rowPath.indicatorKey) && void 0 !== _a ? _a : rowPath.value;
616
- }));
617
- this.flatDataToObjects.changeTreeNodeValue(rowKeys, colKeys, this.internalProps.layoutMap.getBody(col, row).indicatorKey, newValue);
648
+ const cellDimensionPath = this.internalProps.layoutMap.getCellHeaderPaths(col, row);
649
+ if (this.isHeader(col, row)) this.internalProps.layoutMap.changeTreeNodeTitle(col, row, newValue),
650
+ !this.isCornerHeader(col, row) && this.flatDataToObjects.changeRecordFieldValue((null === (_d = cellDimensionPath.colHeaderPaths) || void 0 === _d ? void 0 : _d.length) ? null !== (_e = cellDimensionPath.colHeaderPaths[cellDimensionPath.colHeaderPaths.length - 1].indicatorKey) && void 0 !== _e ? _e : cellDimensionPath.colHeaderPaths[cellDimensionPath.colHeaderPaths.length - 1].dimensionKey : null !== (_f = cellDimensionPath.rowHeaderPaths[cellDimensionPath.rowHeaderPaths.length - 1].indicatorKey) && void 0 !== _f ? _f : cellDimensionPath.rowHeaderPaths[cellDimensionPath.rowHeaderPaths.length - 1].dimensionKey, oldValue, newValue); else {
651
+ const colKeys = cellDimensionPath.colHeaderPaths.map((colPath => {
652
+ var _a;
653
+ return null !== (_a = colPath.indicatorKey) && void 0 !== _a ? _a : colPath.value;
654
+ })), rowKeys = cellDimensionPath.rowHeaderPaths.map((rowPath => {
655
+ var _a;
656
+ return null !== (_a = rowPath.indicatorKey) && void 0 !== _a ? _a : rowPath.value;
657
+ }));
658
+ this.flatDataToObjects.changeTreeNodeValue(rowKeys, colKeys, this.internalProps.layoutMap.getBody(col, row).indicatorKey, newValue);
659
+ }
618
660
  } else {
619
661
  const rowIndex = this.getBodyIndexByRow(row), colIndex = this.getBodyIndexByCol(col);
620
662
  this.records[rowIndex][colIndex] = newValue;