@visactor/vtable 1.26.0 → 1.26.1-alpha.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 (57) hide show
  1. package/cjs/PivotTable.js +84 -12
  2. package/cjs/PivotTable.js.map +1 -1
  3. package/cjs/body-helper/style.js +2 -1
  4. package/cjs/core/BaseTable.js +2 -3
  5. package/cjs/core/BaseTable.js.map +1 -1
  6. package/cjs/dataset/DataStatistics.js +2 -1
  7. package/cjs/edit/edit-manager.js +0 -1
  8. package/cjs/index.d.ts +1 -1
  9. package/cjs/index.js +1 -1
  10. package/cjs/index.js.map +1 -1
  11. package/cjs/layout/index.js +1 -1
  12. package/cjs/layout/layout-helper.js +1 -1
  13. package/cjs/layout/pivot-header-layout.js +1 -1
  14. package/cjs/layout/row-height-map.js +1 -1
  15. package/cjs/layout/simple-header-layout.js +1 -1
  16. package/cjs/layout/tree-helper.js +1 -1
  17. package/cjs/plugins/index.js +1 -1
  18. package/cjs/plugins/interface.js +1 -1
  19. package/cjs/plugins/invert-highlight.js +1 -1
  20. package/cjs/plugins/list-tree-stick-cell.js +1 -1
  21. package/cjs/plugins/plugin-manager.js +1 -1
  22. package/cjs/scenegraph/scenegraph.js +1 -1
  23. package/cjs/ts-types/dataset/aggregation.js +94 -39
  24. package/cjs/ts-types/dataset/aggregation.js.map +1 -1
  25. package/cjs/ts-types/icon.d.ts +2 -2
  26. package/cjs/ts-types/icon.js.map +1 -1
  27. package/cjs/vrender.js.map +1 -1
  28. package/dist/vtable.js +203 -78
  29. package/dist/vtable.min.js +1 -1
  30. package/es/PivotTable.js +84 -12
  31. package/es/PivotTable.js.map +1 -1
  32. package/es/body-helper/style.js +2 -1
  33. package/es/core/BaseTable.js +2 -3
  34. package/es/core/BaseTable.js.map +1 -1
  35. package/es/dataset/DataStatistics.js +2 -1
  36. package/es/edit/edit-manager.js +1 -2
  37. package/es/index.d.ts +1 -1
  38. package/es/index.js +1 -1
  39. package/es/index.js.map +1 -1
  40. package/es/layout/index.js +1 -1
  41. package/es/layout/layout-helper.js +1 -1
  42. package/es/layout/pivot-header-layout.js +1 -1
  43. package/es/layout/row-height-map.js +1 -1
  44. package/es/layout/simple-header-layout.js +1 -1
  45. package/es/layout/tree-helper.js +1 -1
  46. package/es/plugins/index.js +1 -1
  47. package/es/plugins/interface.js +1 -1
  48. package/es/plugins/invert-highlight.js +1 -1
  49. package/es/plugins/list-tree-stick-cell.js +1 -1
  50. package/es/plugins/plugin-manager.js +1 -1
  51. package/es/scenegraph/scenegraph.js +1 -1
  52. package/es/ts-types/dataset/aggregation.js +68 -38
  53. package/es/ts-types/dataset/aggregation.js.map +1 -1
  54. package/es/ts-types/icon.d.ts +2 -2
  55. package/es/ts-types/icon.js.map +1 -1
  56. package/es/vrender.js.map +1 -1
  57. package/package.json +7 -6
package/es/PivotTable.js CHANGED
@@ -514,7 +514,7 @@ export class PivotTable extends BaseTable {
514
514
  this.pivotSortState = [];
515
515
  const sortRules = null !== (_b = null === (_a = this.internalProps.dataConfig) || void 0 === _a ? void 0 : _a.sortRules) && void 0 !== _b ? _b : [];
516
516
  for (let i = 0; i < sortRules.length; i++) {
517
- const sortRule = sortRules[i], dimensions = [];
517
+ const sortRule = sortRules[i], dimensions = [], sortType = sortRule.sortType ? sortRule.sortType.toUpperCase() : "ASC";
518
518
  if (sortRule.sortByIndicator && sortRule.sortField === (this.dataset.indicatorsAsCol ? this.dataset.rows[this.dataset.rows.length - 1] : this.dataset.columns[this.dataset.columns.length - 1])) {
519
519
  for (let j = 0; j < sortRule.query.length; j++) dimensions.push({
520
520
  dimensionKey: this.dataset.indicatorsAsCol ? this.dataset.columns[j] : this.dataset.rows[j],
@@ -523,17 +523,46 @@ export class PivotTable extends BaseTable {
523
523
  dimensions.push({
524
524
  indicatorKey: sortRule.sortByIndicator,
525
525
  value: null !== (_d = null === (_c = this.internalProps.layoutMap.getIndicatorInfo(sortRule.sortByIndicator)) || void 0 === _c ? void 0 : _c.title) && void 0 !== _d ? _d : sortRule.sortByIndicator
526
+ }), this.pivotSortState.push({
527
+ dimensions: dimensions,
528
+ order: SortType[sortType]
526
529
  });
527
- } else dimensions.push({
528
- dimensionKey: sortRule.sortField,
529
- isPivotCorner: !0,
530
- value: sortRule.sortField
531
- });
532
- const sortType = sortRule.sortType ? sortRule.sortType.toUpperCase() : "ASC";
533
- this.pivotSortState.push({
534
- dimensions: dimensions,
535
- order: SortType[sortType]
536
- });
530
+ } else {
531
+ const sortField = sortRule.sortField, rowIndex = this.dataset.rows.indexOf(sortField), colIndex = this.dataset.columns.indexOf(sortField);
532
+ let pushed = !1;
533
+ if (rowIndex >= 0) {
534
+ const rowDimensions = [];
535
+ for (let k = 0; k <= rowIndex; k++) rowDimensions.push({
536
+ dimensionKey: this.dataset.rows[k],
537
+ isPivotCorner: !0,
538
+ value: this.dataset.rows[k]
539
+ });
540
+ this.pivotSortState.push({
541
+ dimensions: rowDimensions,
542
+ order: SortType[sortType]
543
+ }), pushed = !0;
544
+ }
545
+ if (colIndex >= 0) {
546
+ const colDimensions = [];
547
+ for (let k = 0; k <= colIndex; k++) colDimensions.push({
548
+ dimensionKey: this.dataset.columns[k],
549
+ isPivotCorner: !0,
550
+ value: this.dataset.columns[k]
551
+ });
552
+ this.pivotSortState.push({
553
+ dimensions: colDimensions,
554
+ order: SortType[sortType]
555
+ }), pushed = !0;
556
+ }
557
+ pushed || (dimensions.push({
558
+ dimensionKey: sortField,
559
+ isPivotCorner: !0,
560
+ value: sortField
561
+ }), this.pivotSortState.push({
562
+ dimensions: dimensions,
563
+ order: SortType[sortType]
564
+ }));
565
+ }
537
566
  }
538
567
  }
539
568
  _filterHideIndicatorNode() {
@@ -594,10 +623,53 @@ export class PivotTable extends BaseTable {
594
623
  }
595
624
  }
596
625
  getPivotSortState(col, row) {
626
+ var _a;
597
627
  if (!this.pivotSortState) return;
598
628
  const cellRange = this.getCellRange(col, row);
599
629
  for (let i = 0; i < this.pivotSortState.length; i++) {
600
- const pivotState = this.pivotSortState[i], dimensions = pivotState.dimensions, cell = this.getCellAddressByHeaderPaths(dimensions), order = pivotState.order;
630
+ const pivotState = this.pivotSortState[i], dimensions = pivotState.dimensions;
631
+ if (this.isCornerHeader(col, row)) {
632
+ const layoutMap = this.internalProps.layoutMap, header = layoutMap.getHeader(col, row);
633
+ if (header && header.pivotInfo && dimensions && dimensions.length > 0) {
634
+ let cellPathKeys = [];
635
+ const leftSnCount = null !== (_a = layoutMap.leftRowSeriesNumberColumnCount) && void 0 !== _a ? _a : 0;
636
+ if ("row" === layoutMap.cornerSetting.titleOnDimension) {
637
+ const dimIndex = col - leftSnCount;
638
+ cellPathKeys = layoutMap.rowDimensionKeys.slice(0, dimIndex + 1);
639
+ } else if ("column" === layoutMap.cornerSetting.titleOnDimension) {
640
+ const dimIndex = row;
641
+ cellPathKeys = layoutMap.colDimensionKeys.slice(0, dimIndex + 1);
642
+ } else if ("all" === layoutMap.cornerSetting.titleOnDimension) if (layoutMap.indicatorsAsCol) {
643
+ let indicatorAtIndex = layoutMap.colDimensionKeys.indexOf(layoutMap.indicatorDimensionKey);
644
+ if (-1 === indicatorAtIndex && (indicatorAtIndex = layoutMap.columnHeaderLevelCount - 1),
645
+ row === indicatorAtIndex) {
646
+ const dimIndex = col - leftSnCount;
647
+ cellPathKeys = layoutMap.rowDimensionKeys.slice(0, dimIndex + 1);
648
+ } else {
649
+ const dimIndex = row;
650
+ cellPathKeys = layoutMap.colDimensionKeys.slice(0, dimIndex + 1);
651
+ }
652
+ } else {
653
+ let indicatorAtIndex = layoutMap.rowDimensionKeys.indexOf(layoutMap.indicatorDimensionKey);
654
+ if (-1 === indicatorAtIndex && (indicatorAtIndex = layoutMap.rowHeaderLevelCount - 1),
655
+ col - leftSnCount === indicatorAtIndex) {
656
+ const dimIndex = row;
657
+ cellPathKeys = layoutMap.colDimensionKeys.slice(0, dimIndex + 1);
658
+ } else {
659
+ const dimIndex = col - leftSnCount;
660
+ cellPathKeys = layoutMap.rowDimensionKeys.slice(0, dimIndex + 1);
661
+ }
662
+ }
663
+ if (cellPathKeys.length > 0 && dimensions.length === cellPathKeys.length) {
664
+ if (dimensions.every(((dim, idx) => {
665
+ const isCorner = dim.isPivotCorner || !isValid(dim.isPivotCorner) && dim.dimensionKey && !dim.value, keyMatch = dim.dimensionKey === cellPathKeys[idx] || dim.value === cellPathKeys[idx];
666
+ return isCorner && keyMatch;
667
+ }))) return pivotState.order;
668
+ }
669
+ }
670
+ continue;
671
+ }
672
+ const cell = this.getCellAddressByHeaderPaths(dimensions), order = pivotState.order;
601
673
  if (cell && cellInRange(cellRange, cell.col, cell.row)) return order;
602
674
  }
603
675
  }