@visactor/vtable 0.24.1 → 0.24.2-alpha.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 (51) hide show
  1. package/cjs/PivotTable.js +52 -16
  2. package/cjs/PivotTable.js.map +1 -1
  3. package/cjs/core/BaseTable.js +1 -1
  4. package/cjs/core/BaseTable.js.map +1 -1
  5. package/cjs/dataset/flatDataToObject.d.ts +8 -3
  6. package/cjs/dataset/flatDataToObject.js +35 -8
  7. package/cjs/dataset/flatDataToObject.js.map +1 -1
  8. package/cjs/edit/edit-manager.js +0 -1
  9. package/cjs/edit/edit-manager.js.map +1 -1
  10. package/cjs/index.d.ts +1 -1
  11. package/cjs/index.js +1 -1
  12. package/cjs/index.js.map +1 -1
  13. package/cjs/layout/pivot-header-layout.d.ts +1 -0
  14. package/cjs/layout/pivot-header-layout.js +16 -4
  15. package/cjs/layout/pivot-header-layout.js.map +1 -1
  16. package/cjs/state/state.js +1 -1
  17. package/cjs/themes/component.js +1 -1
  18. package/cjs/ts-types/pivot-table/dimension/basic-dimension.d.ts +6 -1
  19. package/cjs/ts-types/pivot-table/dimension/basic-dimension.js.map +1 -1
  20. package/cjs/ts-types/pivot-table/indicator/basic-indicator.d.ts +3 -0
  21. package/cjs/ts-types/pivot-table/indicator/basic-indicator.js.map +1 -1
  22. package/cjs/ts-types/table-engine.d.ts +3 -0
  23. package/cjs/ts-types/table-engine.js.map +1 -1
  24. package/cjs/vrender.js.map +1 -1
  25. package/dist/vtable.js +159 -32
  26. package/dist/vtable.min.js +1 -1
  27. package/es/PivotTable.js +52 -16
  28. package/es/PivotTable.js.map +1 -1
  29. package/es/core/BaseTable.js +1 -1
  30. package/es/core/BaseTable.js.map +1 -1
  31. package/es/dataset/flatDataToObject.d.ts +8 -3
  32. package/es/dataset/flatDataToObject.js +34 -8
  33. package/es/dataset/flatDataToObject.js.map +1 -1
  34. package/es/edit/edit-manager.js +0 -1
  35. package/es/edit/edit-manager.js.map +1 -1
  36. package/es/index.d.ts +1 -1
  37. package/es/index.js +1 -1
  38. package/es/index.js.map +1 -1
  39. package/es/layout/pivot-header-layout.d.ts +1 -0
  40. package/es/layout/pivot-header-layout.js +12 -2
  41. package/es/layout/pivot-header-layout.js.map +1 -1
  42. package/es/state/state.js +1 -1
  43. package/es/themes/component.js +1 -1
  44. package/es/ts-types/pivot-table/dimension/basic-dimension.d.ts +6 -1
  45. package/es/ts-types/pivot-table/dimension/basic-dimension.js.map +1 -1
  46. package/es/ts-types/pivot-table/indicator/basic-indicator.d.ts +3 -0
  47. package/es/ts-types/pivot-table/indicator/basic-indicator.js.map +1 -1
  48. package/es/ts-types/table-engine.d.ts +3 -0
  49. package/es/ts-types/table-engine.js.map +1 -1
  50. package/es/vrender.js.map +1 -1
  51. package/package.json +5 -5
package/es/PivotTable.js CHANGED
@@ -346,14 +346,37 @@ export class PivotTable extends BaseTable {
346
346
  })), rowKeys = cellDimensionPath.rowHeaderPaths.map((rowPath => {
347
347
  var _a;
348
348
  return null !== (_a = rowPath.indicatorKey) && void 0 !== _a ? _a : rowPath.value;
349
- })), treeNode = this.flatDataToObjects.getTreeNode(rowKeys, colKeys, this.internalProps.layoutMap.getBody(col, row).indicatorKey, !1);
349
+ })), treeNode = this.flatDataToObjects.getTreeNode(rowKeys, colKeys, this.internalProps.layoutMap.getBody(col, row).indicatorKey);
350
350
  return null == treeNode ? void 0 : treeNode.record;
351
351
  }
352
352
  const rowIndex = this.getBodyIndexByRow(row), colIndex = this.getBodyIndexByCol(col);
353
353
  return null === (_a = this.records[rowIndex]) || void 0 === _a ? void 0 : _a[colIndex];
354
354
  }
355
355
  getCellRawRecord(col, row) {
356
- return this.getCellOriginRecord(col, row);
356
+ var _a;
357
+ if (this.internalProps.layoutMap.isHeader(col, row)) return;
358
+ if (this.dataset) {
359
+ const cellDimensionPath = this.internalProps.layoutMap.getCellHeaderPaths(col, row), colKeys = cellDimensionPath.colHeaderPaths.map((colPath => {
360
+ var _a;
361
+ return null !== (_a = colPath.indicatorKey) && void 0 !== _a ? _a : colPath.value;
362
+ })), rowKeys = cellDimensionPath.rowHeaderPaths.map((rowPath => {
363
+ var _a;
364
+ return null !== (_a = rowPath.indicatorKey) && void 0 !== _a ? _a : rowPath.value;
365
+ }));
366
+ 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;
367
+ }
368
+ if (this.flatDataToObjects) {
369
+ const cellDimensionPath = this.internalProps.layoutMap.getCellHeaderPaths(col, row), colKeys = cellDimensionPath.colHeaderPaths.map((colPath => {
370
+ var _a;
371
+ return null !== (_a = colPath.indicatorKey) && void 0 !== _a ? _a : colPath.value;
372
+ })), rowKeys = cellDimensionPath.rowHeaderPaths.map((rowPath => {
373
+ var _a;
374
+ return null !== (_a = rowPath.indicatorKey) && void 0 !== _a ? _a : rowPath.value;
375
+ })), treeNode = this.flatDataToObjects.getTreeNode(rowKeys, colKeys, this.internalProps.layoutMap.getBody(col, row).indicatorKey, !1);
376
+ return null == treeNode ? void 0 : treeNode.record;
377
+ }
378
+ const rowIndex = this.getBodyIndexByRow(row), colIndex = this.getBodyIndexByCol(col);
379
+ return null === (_a = this.records[rowIndex]) || void 0 === _a ? void 0 : _a[colIndex];
357
380
  }
358
381
  updateSortRules(sortRules) {
359
382
  this.internalProps.dataConfig.sortRules = sortRules, this.dataset.updateSortRules(sortRules),
@@ -506,9 +529,15 @@ export class PivotTable extends BaseTable {
506
529
  this.editorManager.completeEdit();
507
530
  }
508
531
  getEditor(col, row) {
509
- var _a;
510
- const define = this.getBodyColumnDefine(col, row);
511
- let editorDefine = null !== (_a = null == define ? void 0 : define.editor) && void 0 !== _a ? _a : this.options.editor;
532
+ var _a, _b;
533
+ let editorDefine;
534
+ if (this.isHeader(col, row) && !this.isCornerHeader(col, row)) {
535
+ const define = this.getHeaderDefine(col, row);
536
+ editorDefine = null !== (_a = null == define ? void 0 : define.headerEditor) && void 0 !== _a ? _a : this.options.headerEditor;
537
+ } else {
538
+ const define = this.getBodyColumnDefine(col, row);
539
+ editorDefine = null !== (_b = null == define ? void 0 : define.editor) && void 0 !== _b ? _b : this.options.editor;
540
+ }
512
541
  if ("function" == typeof editorDefine) {
513
542
  editorDefine = editorDefine({
514
543
  col: col,
@@ -538,9 +567,11 @@ export class PivotTable extends BaseTable {
538
567
  changeCellValue(col, row, value, workOnEditableCell = !1) {
539
568
  if (workOnEditableCell && this.isHasEditorDefine(col, row) || !1 === workOnEditableCell) {
540
569
  let newValue = value;
541
- if ("number" == typeof this.getCellRawValue(col, row) && isAllDigits(value) && (newValue = parseFloat(value)),
542
- this._changeCellValueToDataSet(col, row, newValue), this.scenegraph.updateCellContent(col, row),
543
- "adaptive" === this.widthMode || this.autoFillWidth && this.getAllColsWidth() <= this.tableNoFrameWidth) 0 === this.internalProps._widthResizedColMap.size && this.scenegraph.recalculateColWidths(); else if (!this.internalProps._widthResizedColMap.has(col)) {
570
+ "number" == typeof this.getCellRawValue(col, row) && isAllDigits(value) && (newValue = parseFloat(value)),
571
+ this._changeCellValueToDataSet(col, row, newValue);
572
+ const range = this.getCellRange(col, row);
573
+ 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);
574
+ 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)) {
544
575
  const oldWidth = this.getColWidth(col), newWidth = computeColWidth(col, 0, this.rowCount - 1, this, !1);
545
576
  newWidth !== oldWidth && this.scenegraph.updateColWidth(col, newWidth - oldWidth);
546
577
  }
@@ -594,6 +625,7 @@ export class PivotTable extends BaseTable {
594
625
  this.scenegraph.updateNextFrame();
595
626
  }
596
627
  _changeCellValueToDataSet(col, row, newValue) {
628
+ var _a, _b, _c;
597
629
  if (this.dataset) {
598
630
  const cellDimensionPath = this.internalProps.layoutMap.getCellHeaderPaths(col, row), colKeys = cellDimensionPath.colHeaderPaths.map((colPath => {
599
631
  var _a;
@@ -604,14 +636,18 @@ export class PivotTable extends BaseTable {
604
636
  }));
605
637
  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);
606
638
  } else if (this.flatDataToObjects) {
607
- const cellDimensionPath = this.internalProps.layoutMap.getCellHeaderPaths(col, row), colKeys = cellDimensionPath.colHeaderPaths.map((colPath => {
608
- var _a;
609
- return null !== (_a = colPath.indicatorKey) && void 0 !== _a ? _a : colPath.value;
610
- })), rowKeys = cellDimensionPath.rowHeaderPaths.map((rowPath => {
611
- var _a;
612
- return null !== (_a = rowPath.indicatorKey) && void 0 !== _a ? _a : rowPath.value;
613
- }));
614
- this.flatDataToObjects.changeTreeNodeValue(rowKeys, colKeys, this.internalProps.layoutMap.getBody(col, row).indicatorKey, newValue);
639
+ const cellDimensionPath = this.internalProps.layoutMap.getCellHeaderPaths(col, row);
640
+ if (this.isHeader(col, row)) this.internalProps.layoutMap.changeTreeNodeTitle(col, row, newValue),
641
+ this.flatDataToObjects.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, newValue); else {
642
+ const colKeys = cellDimensionPath.colHeaderPaths.map((colPath => {
643
+ var _a;
644
+ return null !== (_a = colPath.indicatorKey) && void 0 !== _a ? _a : colPath.value;
645
+ })), rowKeys = cellDimensionPath.rowHeaderPaths.map((rowPath => {
646
+ var _a;
647
+ return null !== (_a = rowPath.indicatorKey) && void 0 !== _a ? _a : rowPath.value;
648
+ }));
649
+ this.flatDataToObjects.changeTreeNodeValue(rowKeys, colKeys, this.internalProps.layoutMap.getBody(col, row).indicatorKey, newValue);
650
+ }
615
651
  } else {
616
652
  const rowIndex = this.getBodyIndexByRow(row), colIndex = this.getBodyIndexByCol(col);
617
653
  this.records[rowIndex][colIndex] = newValue;