@visactor/vtable 1.19.1 → 1.19.2

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 (77) hide show
  1. package/cjs/ListTable.js +1 -1
  2. package/cjs/ListTable.js.map +1 -1
  3. package/cjs/PivotTable.js +4 -0
  4. package/cjs/PivotTable.js.map +1 -1
  5. package/cjs/core/BaseTable.js +1 -1
  6. package/cjs/core/BaseTable.js.map +1 -1
  7. package/cjs/data/DataSource.js +14 -5
  8. package/cjs/data/DataSource.js.map +1 -1
  9. package/cjs/dataset/dataset.d.ts +1 -0
  10. package/cjs/dataset/dataset.js +66 -2
  11. package/cjs/dataset/dataset.js.map +1 -1
  12. package/cjs/edit/edit-manager.js +8 -5
  13. package/cjs/edit/edit-manager.js.map +1 -1
  14. package/cjs/index.d.ts +2 -1
  15. package/cjs/index.js +11 -2
  16. package/cjs/index.js.map +1 -1
  17. package/cjs/layout/pivot-header-layout.d.ts +1 -0
  18. package/cjs/layout/pivot-header-layout.js +18 -7
  19. package/cjs/layout/pivot-header-layout.js.map +1 -1
  20. package/cjs/layout/simple-header-layout.d.ts +2 -0
  21. package/cjs/layout/simple-header-layout.js +25 -9
  22. package/cjs/layout/simple-header-layout.js.map +1 -1
  23. package/cjs/scenegraph/graphic/icon.js.map +1 -1
  24. package/cjs/scenegraph/group-creater/cell-helper.js +3 -3
  25. package/cjs/scenegraph/group-creater/cell-helper.js.map +1 -1
  26. package/cjs/scenegraph/group-creater/column-helper.js +1 -1
  27. package/cjs/scenegraph/group-creater/column-helper.js.map +1 -1
  28. package/cjs/scenegraph/layout/compute-col-width.js +11 -1
  29. package/cjs/scenegraph/layout/compute-col-width.js.map +1 -1
  30. package/cjs/ts-types/dataset/aggregation.d.ts +8 -6
  31. package/cjs/ts-types/dataset/aggregation.js +109 -54
  32. package/cjs/ts-types/dataset/aggregation.js.map +1 -1
  33. package/cjs/ts-types/list-table/define/basic-define.d.ts +1 -0
  34. package/cjs/ts-types/list-table/define/basic-define.js.map +1 -1
  35. package/cjs/ts-types/new-data-set.d.ts +1 -0
  36. package/cjs/ts-types/new-data-set.js.map +1 -1
  37. package/cjs/vrender.js.map +1 -1
  38. package/dist/vtable.js +500 -44
  39. package/dist/vtable.min.js +2 -2
  40. package/es/ListTable.js +1 -1
  41. package/es/ListTable.js.map +1 -1
  42. package/es/PivotTable.js +4 -0
  43. package/es/PivotTable.js.map +1 -1
  44. package/es/core/BaseTable.js +1 -1
  45. package/es/core/BaseTable.js.map +1 -1
  46. package/es/data/DataSource.js +14 -5
  47. package/es/data/DataSource.js.map +1 -1
  48. package/es/dataset/dataset.d.ts +1 -0
  49. package/es/dataset/dataset.js +66 -2
  50. package/es/dataset/dataset.js.map +1 -1
  51. package/es/edit/edit-manager.js +8 -5
  52. package/es/edit/edit-manager.js.map +1 -1
  53. package/es/index.d.ts +2 -1
  54. package/es/index.js +3 -1
  55. package/es/index.js.map +1 -1
  56. package/es/layout/pivot-header-layout.d.ts +1 -0
  57. package/es/layout/pivot-header-layout.js +18 -7
  58. package/es/layout/pivot-header-layout.js.map +1 -1
  59. package/es/layout/simple-header-layout.d.ts +2 -0
  60. package/es/layout/simple-header-layout.js +25 -9
  61. package/es/layout/simple-header-layout.js.map +1 -1
  62. package/es/scenegraph/graphic/icon.js.map +1 -1
  63. package/es/scenegraph/group-creater/cell-helper.js +3 -3
  64. package/es/scenegraph/group-creater/cell-helper.js.map +1 -1
  65. package/es/scenegraph/group-creater/column-helper.js +1 -1
  66. package/es/scenegraph/group-creater/column-helper.js.map +1 -1
  67. package/es/scenegraph/layout/compute-col-width.js +11 -1
  68. package/es/scenegraph/layout/compute-col-width.js.map +1 -1
  69. package/es/ts-types/dataset/aggregation.d.ts +8 -6
  70. package/es/ts-types/dataset/aggregation.js +109 -54
  71. package/es/ts-types/dataset/aggregation.js.map +1 -1
  72. package/es/ts-types/list-table/define/basic-define.d.ts +1 -0
  73. package/es/ts-types/list-table/define/basic-define.js.map +1 -1
  74. package/es/ts-types/new-data-set.d.ts +1 -0
  75. package/es/ts-types/new-data-set.js.map +1 -1
  76. package/es/vrender.js.map +1 -1
  77. package/package.json +4 -4
@@ -700,16 +700,80 @@ export class Dataset {
700
700
  for (const key in this.collectValuesBy) "xField" !== this.collectValuesBy[key].type && "yField" !== this.collectValuesBy[key].type || (this.dataConfig.dimensionSortArray ? this.cacheCollectedValues[key] = arraySortByAnotherArray(this.collectedValues[key], this.dataConfig.dimensionSortArray) : this.cacheCollectedValues[key] = this.collectedValues[key]);
701
701
  }
702
702
  changeTreeNodeValue(rowKey = [], colKey = [], indicator, newValue) {
703
- var _a, _b, _c;
703
+ var _a, _b, _c, _d, _e;
704
704
  const indicatorIndex = this.indicatorKeys.indexOf(indicator);
705
705
  let flatRowKey, flatColKey;
706
706
  flatRowKey = "string" == typeof rowKey ? rowKey : rowKey.join(this.stringJoinChar),
707
707
  flatColKey = "string" == typeof colKey ? colKey : colKey.join(this.stringJoinChar),
708
+ "string" == typeof newValue && (isNaN(parseFloat(newValue)) || (newValue = parseFloat(newValue))),
708
709
  (null === (_a = this.changedTree[flatRowKey]) || void 0 === _a ? void 0 : _a[flatColKey]) ? this.changedTree[flatRowKey][flatColKey][indicatorIndex] = newValue : this.changedTree[flatRowKey] ? (this.changedTree[flatRowKey][flatColKey] = [],
709
710
  this.changedTree[flatRowKey][flatColKey][indicatorIndex] = newValue) : (this.changedTree[flatRowKey] = {},
710
711
  this.changedTree[flatRowKey][flatColKey] = [], this.changedTree[flatRowKey][flatColKey][indicatorIndex] = newValue);
711
712
  const cellAggregator = null === (_c = null === (_b = this.tree[flatRowKey]) || void 0 === _b ? void 0 : _b[flatColKey]) || void 0 === _c ? void 0 : _c[indicatorIndex];
712
- 1 === (null == cellAggregator ? void 0 : cellAggregator.records.length) && (cellAggregator.records[0][this.indicatorKeys[indicatorIndex]] = newValue);
713
+ if (1 === (null == cellAggregator ? void 0 : cellAggregator.records.length) && (cellAggregator.records[0][this.indicatorKeys[indicatorIndex]] = newValue),
714
+ null !== (_e = null === (_d = this.dataConfig) || void 0 === _d ? void 0 : _d.updateAggregationOnEditCell) && void 0 !== _e && _e) if (cellAggregator) cellAggregator.changedValue = newValue,
715
+ this.recalculateTotals(rowKey, colKey, indicator); else {
716
+ const newCellAggregator = new SumAggregator({
717
+ key: indicator,
718
+ field: indicator,
719
+ isRecord: !0
720
+ });
721
+ newCellAggregator.changedValue = newValue, this.recalculateTotals(rowKey, colKey, indicator, newCellAggregator);
722
+ }
723
+ }
724
+ recalculateTotals(rowKey = [], colKey = [], indicator, newCellAggregator) {
725
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11;
726
+ if (!this.totals || 0 === Object.keys(this.tree).length || !((null === (_a = this.totals.row) || void 0 === _a ? void 0 : _a.showGrandTotals) || (null === (_b = this.totals.row) || void 0 === _b ? void 0 : _b.subTotalsDimensions) && this.totals.row.subTotalsDimensions.length > 0 && !1 !== this.totals.row.showSubTotals) && !((null === (_c = this.totals.column) || void 0 === _c ? void 0 : _c.showGrandTotals) || (null === (_d = this.totals.column) || void 0 === _d ? void 0 : _d.subTotalsDimensions) && this.totals.column.subTotalsDimensions.length > 0 && !1 !== this.totals.column.showSubTotals)) return;
727
+ const flatRowKey = Array.isArray(rowKey) ? rowKey.join(this.stringJoinChar) : rowKey, flatColKey = Array.isArray(colKey) ? colKey.join(this.stringJoinChar) : colKey, indicatorIndex = this.indicatorKeysIncludeCalculatedFieldDependIndicatorKeys.indexOf(indicator), aggregatorsToReset = new Set, subTotalAggregators = new Set, rowKeyParts = flatRowKey.split(this.stringJoinChar), colKeyParts = flatColKey.split(this.stringJoinChar), addAggregatorToResetSet = (agg, rowKey, colKey) => {
728
+ !agg || rowKey === flatRowKey && colKey === flatColKey || (aggregatorsToReset.add(agg),
729
+ rowKey !== flatRowKey && colKey !== flatColKey || subTotalAggregators.add(agg));
730
+ };
731
+ if ((null === (_f = null === (_e = this.totals) || void 0 === _e ? void 0 : _e.row) || void 0 === _f ? void 0 : _f.subTotalsDimensions) && !1 !== this.totals.row.showSubTotals) for (let i = 0; i < this.totals.row.subTotalsDimensions.length; i++) {
732
+ const dimension = this.totals.row.subTotalsDimensions[i], dimensionIndex = this.rows.indexOf(dimension);
733
+ if (dimensionIndex >= 0 && dimensionIndex < rowKeyParts.length) {
734
+ const rowSubTotalKeyParts = rowKeyParts.slice(0, dimensionIndex + 1);
735
+ "tree" !== this.rowHierarchyType && rowSubTotalKeyParts.push(this.rowSubTotalLabel);
736
+ const flatRowSubTotalKey = rowSubTotalKeyParts.join(this.stringJoinChar);
737
+ if ((null === (_h = null === (_g = this.tree[flatRowSubTotalKey]) || void 0 === _g ? void 0 : _g[flatColKey]) || void 0 === _h ? void 0 : _h[indicatorIndex]) && addAggregatorToResetSet(this.tree[flatRowSubTotalKey][flatColKey][indicatorIndex], flatRowSubTotalKey, flatColKey),
738
+ (null === (_k = null === (_j = this.totals) || void 0 === _j ? void 0 : _j.column) || void 0 === _k ? void 0 : _k.subTotalsDimensions) && !1 !== this.totals.column.showSubTotals) for (let j = 0; j < this.totals.column.subTotalsDimensions.length; j++) {
739
+ const colDimension = this.totals.column.subTotalsDimensions[j], colDimensionIndex = this.columns.indexOf(colDimension);
740
+ if (colDimensionIndex >= 0 && colDimensionIndex < colKeyParts.length) {
741
+ const colSubTotalKeyParts = colKeyParts.slice(0, colDimensionIndex + 1);
742
+ colSubTotalKeyParts.push(this.colSubTotalLabel);
743
+ const flatColSubTotalKey = colSubTotalKeyParts.join(this.stringJoinChar);
744
+ (null === (_m = null === (_l = this.tree[flatRowSubTotalKey]) || void 0 === _l ? void 0 : _l[flatColSubTotalKey]) || void 0 === _m ? void 0 : _m[indicatorIndex]) && addAggregatorToResetSet(this.tree[flatRowSubTotalKey][flatColSubTotalKey][indicatorIndex], flatRowSubTotalKey, flatColSubTotalKey);
745
+ }
746
+ }
747
+ (null === (_p = null === (_o = this.totals) || void 0 === _o ? void 0 : _o.column) || void 0 === _p ? void 0 : _p.showGrandTotals) && (null === (_r = null === (_q = this.tree[flatRowSubTotalKey]) || void 0 === _q ? void 0 : _q[this.colGrandTotalLabel]) || void 0 === _r ? void 0 : _r[indicatorIndex]) && addAggregatorToResetSet(this.tree[flatRowSubTotalKey][this.colGrandTotalLabel][indicatorIndex], flatRowSubTotalKey, this.colGrandTotalLabel);
748
+ }
749
+ }
750
+ if (null === (_t = null === (_s = this.totals) || void 0 === _s ? void 0 : _s.row) || void 0 === _t ? void 0 : _t.showGrandTotals) {
751
+ if ((null === (_v = null === (_u = this.tree[this.rowGrandTotalLabel]) || void 0 === _u ? void 0 : _u[flatColKey]) || void 0 === _v ? void 0 : _v[indicatorIndex]) && addAggregatorToResetSet(this.tree[this.rowGrandTotalLabel][flatColKey][indicatorIndex], this.rowGrandTotalLabel, flatColKey),
752
+ (null === (_x = null === (_w = this.totals) || void 0 === _w ? void 0 : _w.column) || void 0 === _x ? void 0 : _x.subTotalsDimensions) && !1 !== this.totals.column.showSubTotals) for (let j = 0; j < this.totals.column.subTotalsDimensions.length; j++) {
753
+ const colDimension = this.totals.column.subTotalsDimensions[j], colDimensionIndex = this.columns.indexOf(colDimension);
754
+ if (colDimensionIndex >= 0 && colDimensionIndex < colKeyParts.length) {
755
+ const colSubTotalKeyParts = colKeyParts.slice(0, colDimensionIndex + 1);
756
+ colSubTotalKeyParts.push(this.colSubTotalLabel);
757
+ const flatColSubTotalKey = colSubTotalKeyParts.join(this.stringJoinChar);
758
+ (null === (_z = null === (_y = this.tree[this.rowGrandTotalLabel]) || void 0 === _y ? void 0 : _y[flatColSubTotalKey]) || void 0 === _z ? void 0 : _z[indicatorIndex]) && addAggregatorToResetSet(this.tree[this.rowGrandTotalLabel][flatColSubTotalKey][indicatorIndex], this.rowGrandTotalLabel, flatColSubTotalKey);
759
+ }
760
+ }
761
+ (null === (_1 = null === (_0 = this.totals) || void 0 === _0 ? void 0 : _0.column) || void 0 === _1 ? void 0 : _1.showGrandTotals) && (null === (_3 = null === (_2 = this.tree[this.rowGrandTotalLabel]) || void 0 === _2 ? void 0 : _2[this.colGrandTotalLabel]) || void 0 === _3 ? void 0 : _3[indicatorIndex]) && addAggregatorToResetSet(this.tree[this.rowGrandTotalLabel][this.colGrandTotalLabel][indicatorIndex], this.rowGrandTotalLabel, this.colGrandTotalLabel);
762
+ }
763
+ if ((null === (_5 = null === (_4 = this.totals) || void 0 === _4 ? void 0 : _4.column) || void 0 === _5 ? void 0 : _5.subTotalsDimensions) && !1 !== this.totals.column.showSubTotals) for (let j = 0; j < this.totals.column.subTotalsDimensions.length; j++) {
764
+ const colDimension = this.totals.column.subTotalsDimensions[j], colDimensionIndex = this.columns.indexOf(colDimension);
765
+ if (colDimensionIndex >= 0 && colDimensionIndex < colKeyParts.length) {
766
+ const colSubTotalKeyParts = colKeyParts.slice(0, colDimensionIndex + 1);
767
+ colSubTotalKeyParts.push(this.colSubTotalLabel);
768
+ const flatColSubTotalKey = colSubTotalKeyParts.join(this.stringJoinChar);
769
+ (null === (_7 = null === (_6 = this.tree[flatRowKey]) || void 0 === _6 ? void 0 : _6[flatColSubTotalKey]) || void 0 === _7 ? void 0 : _7[indicatorIndex]) && addAggregatorToResetSet(this.tree[flatRowKey][flatColSubTotalKey][indicatorIndex], flatRowKey, flatColSubTotalKey);
770
+ }
771
+ }
772
+ (null === (_9 = null === (_8 = this.totals) || void 0 === _8 ? void 0 : _8.column) || void 0 === _9 ? void 0 : _9.showGrandTotals) && (null === (_11 = null === (_10 = this.tree[flatRowKey]) || void 0 === _10 ? void 0 : _10[this.colGrandTotalLabel]) || void 0 === _11 ? void 0 : _11[indicatorIndex]) && addAggregatorToResetSet(this.tree[flatRowKey][this.colGrandTotalLabel][indicatorIndex], flatRowKey, this.colGrandTotalLabel),
773
+ aggregatorsToReset.forEach((agg => {
774
+ newCellAggregator && subTotalAggregators.has(agg) && agg.push(newCellAggregator),
775
+ agg.recalculate();
776
+ }));
713
777
  }
714
778
  changeRecordFieldValue(fieldName, oldValue, value) {
715
779
  let isIndicatorName = !1;