@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
@@ -7,8 +7,9 @@ export const registeredAggregators = {};
7
7
  export class Aggregator {
8
8
  constructor(config) {
9
9
  var _a;
10
- this.isAggregator = !0, this.isRecord = !0, this.records = [], this.key = config.key,
11
- this.field = config.field, this.formatFun = config.formatFun, this.isRecord = null !== (_a = config.isRecord) && void 0 !== _a ? _a : this.isRecord;
10
+ this.isAggregator = !0, this.isRecord = !0, this.records = [], this.children = [],
11
+ this.key = config.key, this.field = config.field, this.formatFun = config.formatFun,
12
+ this.isRecord = null !== (_a = config.isRecord) && void 0 !== _a ? _a : this.isRecord;
12
13
  }
13
14
  clearCacheValue() {
14
15
  this._formatedValue = void 0;
@@ -18,7 +19,7 @@ export class Aggregator {
18
19
  this._formatedValue;
19
20
  }
20
21
  reset() {
21
- this.records = [], this.clearCacheValue();
22
+ this.records = [], this.changedValue = void 0, this.children = [], this.clearCacheValue();
22
23
  }
23
24
  }
24
25
 
@@ -28,21 +29,24 @@ export class RecordAggregator extends Aggregator {
28
29
  }
29
30
  push(record) {
30
31
  record && this.isRecord && this.records && (record.isAggregator ? this.records.push(...record.records) : this.records.push(record)),
31
- this.clearCacheValue();
32
+ record.isAggregator && this.children && this.children.push(record), this.clearCacheValue();
32
33
  }
33
34
  deleteRecord(record) {
34
- record && this.isRecord && this.records && (this.records = this.records.filter((item => item !== record))),
35
+ record && (this.isRecord && this.records && (this.records = this.records.filter((item => item !== record))),
36
+ record.isAggregator && this.children && (this.children = this.children.filter((item => item !== record)))),
35
37
  this.clearCacheValue();
36
38
  }
37
39
  updateRecord(oldRecord, newRecord) {
38
40
  oldRecord && newRecord && (this.isRecord && this.records && (this.records = this.records.map((item => item === oldRecord ? newRecord : item))),
41
+ oldRecord.isAggregator && newRecord.isAggregator && this.children && (this.children = this.children.map((item => item === oldRecord ? newRecord : item))),
39
42
  this.clearCacheValue());
40
43
  }
41
44
  value() {
42
- return this.records;
45
+ var _a;
46
+ return null !== (_a = this.changedValue) && void 0 !== _a ? _a : this.records;
43
47
  }
44
48
  reset() {
45
- this.records = [];
49
+ this.children = [], this.changedValue = void 0, this.records = [];
46
50
  }
47
51
  recalculate() {}
48
52
  }
@@ -52,24 +56,27 @@ export class NoneAggregator extends Aggregator {
52
56
  super(...arguments), this.type = AggregationType.NONE, this.isRecord = !0;
53
57
  }
54
58
  push(record) {
55
- record && (this.isRecord && (this.records = [ record ]), this.field && (this.fieldValue = record[this.field])),
56
- this.clearCacheValue();
59
+ record && (this.isRecord && (this.records = [ record ]), record.isAggregator && this.children && (this.children = [ record ]),
60
+ this.field && (this.fieldValue = record[this.field])), this.clearCacheValue();
57
61
  }
58
62
  deleteRecord(record) {
59
63
  record && (this.isRecord && this.records && (this.records = this.records.filter((item => item !== record))),
64
+ record.isAggregator && this.children && (this.children = this.children.filter((item => item !== record))),
60
65
  this.field && this.records.length && (this.fieldValue = this.records[this.records.length - 1][this.field])),
61
66
  this.clearCacheValue();
62
67
  }
63
68
  updateRecord(oldRecord, newRecord) {
64
69
  oldRecord && newRecord && (this.isRecord && this.records && (this.records = this.records.map((item => item === oldRecord ? newRecord : item))),
70
+ oldRecord.isAggregator && newRecord.isAggregator && this.children && (this.children = this.children.map((item => item === oldRecord ? newRecord : item))),
65
71
  this.field && this.records.length && (this.fieldValue = this.records[this.records.length - 1][this.field]),
66
72
  this.clearCacheValue());
67
73
  }
68
74
  value() {
69
- return this.fieldValue;
75
+ var _a;
76
+ return null !== (_a = this.changedValue) && void 0 !== _a ? _a : this.fieldValue;
70
77
  }
71
78
  reset() {
72
- this.records = [], this.fieldValue = void 0;
79
+ this.children = [], this.changedValue = void 0, this.records = [], this.fieldValue = void 0;
73
80
  }
74
81
  recalculate() {}
75
82
  }
@@ -81,25 +88,28 @@ export class CustomAggregator extends Aggregator {
81
88
  }
82
89
  push(record) {
83
90
  record && (this.isRecord && this.records && (record.isAggregator ? this.records.push(...record.records) : this.records.push(record)),
84
- this.field && this.values.push(record[this.field])), this.clearCacheValue();
91
+ record.isAggregator && this.children && this.children.push(record), this.field && this.values.push(record[this.field])),
92
+ this.clearCacheValue();
85
93
  }
86
94
  updateRecord(oldRecord, newRecord) {
87
95
  oldRecord && newRecord && (this.isRecord && this.records && (this.records = this.records.map((item => item === oldRecord ? newRecord : item))),
96
+ oldRecord.isAggregator && newRecord.isAggregator && this.children && (this.children = this.children.map((item => item === oldRecord ? newRecord : item))),
88
97
  this.field && this.records.length && (this.values = this.records.map((item => item[this.field]))),
89
98
  this.clearCacheValue());
90
99
  }
91
100
  deleteRecord(record) {
92
101
  record && (this.isRecord && this.records && (this.records = this.records.filter((item => item !== record))),
102
+ record.isAggregator && this.children && (this.children = this.children.filter((item => item !== record))),
93
103
  this.field && this.records.length && (this.values = this.records.map((item => item[this.field])))),
94
104
  this.clearCacheValue();
95
105
  }
96
106
  value() {
97
- var _a;
107
+ var _a, _b;
98
108
  return this.fieldValue || (this.fieldValue = null === (_a = this.aggregationFun) || void 0 === _a ? void 0 : _a.call(this, this.values, this.records, this.field)),
99
- this.fieldValue;
109
+ null !== (_b = this.changedValue) && void 0 !== _b ? _b : this.fieldValue;
100
110
  }
101
111
  reset() {
102
- this.records = [], this.fieldValue = void 0;
112
+ this.records = [], this.children = [], this.changedValue = void 0, this.fieldValue = void 0;
103
113
  }
104
114
  recalculate() {
105
115
  this.fieldValue = void 0, this._formatedValue = void 0;
@@ -113,26 +123,28 @@ export class RecalculateAggregator extends Aggregator {
113
123
  }
114
124
  push(record) {
115
125
  record && this.isRecord && this.records && (record.isAggregator ? this.records.push(...record.records) : this.records.push(record)),
116
- this.clearCacheValue();
126
+ this.children && record.isAggregator && this.children.push(record), this.clearCacheValue();
117
127
  }
118
128
  deleteRecord(record) {
119
- record && this.isRecord && this.records && (this.records = this.records.filter((item => item !== record))),
129
+ record && (this.isRecord && this.records && (this.records = this.records.filter((item => item !== record))),
130
+ record.isAggregator && this.children && (this.children = this.children.filter((item => item !== record)))),
120
131
  this.clearCacheValue();
121
132
  }
122
133
  updateRecord(oldRecord, newRecord) {
123
134
  oldRecord && newRecord && (this.isRecord && this.records && (this.records = this.records.map((item => item === oldRecord ? newRecord : item))),
135
+ oldRecord.isAggregator && newRecord.isAggregator && this.children && (this.children = this.children.map((item => item === oldRecord ? newRecord : item))),
124
136
  this.clearCacheValue());
125
137
  }
126
138
  value() {
127
- var _a;
139
+ var _a, _b;
128
140
  if (!this.fieldValue) {
129
141
  const aggregatorValue = _getDependAggregatorValues(this.dependAggregators, this.dependIndicatorKeys);
130
142
  this.fieldValue = null === (_a = this.calculateFun) || void 0 === _a ? void 0 : _a.call(this, aggregatorValue, this.records, this.field);
131
143
  }
132
- return this.fieldValue;
144
+ return null !== (_b = this.changedValue) && void 0 !== _b ? _b : this.fieldValue;
133
145
  }
134
146
  reset() {
135
- this.records = [], this.fieldValue = void 0;
147
+ this.records = [], this.children = [], this.changedValue = void 0, this.fieldValue = void 0;
136
148
  }
137
149
  recalculate() {}
138
150
  }
@@ -145,7 +157,8 @@ export class SumAggregator extends Aggregator {
145
157
  }
146
158
  push(record) {
147
159
  if (record) if (this.isRecord && this.records && (record.isAggregator ? this.records.push(...record.records) : this.records.push(record)),
148
- record.isAggregator) {
160
+ record.isAggregator && this.children) {
161
+ this.children.push(record);
149
162
  const value = record.value();
150
163
  this.sum += null != value ? value : 0, this.needSplitPositiveAndNegativeForSum && (value > 0 ? this.positiveSum += value : value < 0 && (this.nagetiveSum += value));
151
164
  } else if (this.field && !isNaN(parseFloat(record[this.field]))) {
@@ -156,7 +169,8 @@ export class SumAggregator extends Aggregator {
156
169
  }
157
170
  deleteRecord(record) {
158
171
  if (record) if (this.isRecord && this.records && (this.records = this.records.filter((item => item !== record))),
159
- record.isAggregator) {
172
+ record.isAggregator && this.children) {
173
+ this.children = this.children.filter((item => item !== record));
160
174
  const value = record.value();
161
175
  this.sum -= null != value ? value : 0, this.needSplitPositiveAndNegativeForSum && (value > 0 ? this.positiveSum -= value : value < 0 && (this.nagetiveSum -= value));
162
176
  } else if (this.field && !isNaN(parseFloat(record[this.field]))) {
@@ -168,9 +182,11 @@ export class SumAggregator extends Aggregator {
168
182
  updateRecord(oldRecord, newRecord) {
169
183
  if (oldRecord && newRecord) {
170
184
  if (this.isRecord && this.records && (this.records = this.records.map((item => item === oldRecord ? newRecord : item))),
171
- oldRecord.isAggregator) {
172
- const oldValue = oldRecord.value(), newValue = newRecord.value();
173
- this.sum += newValue - oldValue, this.needSplitPositiveAndNegativeForSum && (oldValue > 0 ? this.positiveSum -= oldValue : oldValue < 0 && (this.nagetiveSum -= oldValue),
185
+ oldRecord.isAggregator && this.children) {
186
+ const oldValue = oldRecord.value();
187
+ this.children = this.children.filter((item => item !== oldRecord));
188
+ const newValue = newRecord.value();
189
+ this.children.push(newRecord), this.sum += newValue - oldValue, this.needSplitPositiveAndNegativeForSum && (oldValue > 0 ? this.positiveSum -= oldValue : oldValue < 0 && (this.nagetiveSum -= oldValue),
174
190
  newValue > 0 ? this.positiveSum += newValue : newValue < 0 && (this.nagetiveSum += newValue));
175
191
  } else if (this.field && !isNaN(parseFloat(oldRecord[this.field]))) {
176
192
  const oldValue = parseFloat(oldRecord[this.field]), newValue = parseFloat(newRecord[this.field]);
@@ -181,8 +197,8 @@ export class SumAggregator extends Aggregator {
181
197
  }
182
198
  }
183
199
  value() {
184
- var _a;
185
- return (null === (_a = this.records) || void 0 === _a ? void 0 : _a.length) >= 1 ? this.sum : void 0;
200
+ var _a, _b;
201
+ return null !== (_a = this.changedValue) && void 0 !== _a ? _a : (null === (_b = this.records) || void 0 === _b ? void 0 : _b.length) >= 1 ? this.sum : void 0;
186
202
  }
187
203
  positiveValue() {
188
204
  return this.positiveSum;
@@ -194,7 +210,13 @@ export class SumAggregator extends Aggregator {
194
210
  super.reset(), this.records = [], this.sum = 0;
195
211
  }
196
212
  recalculate() {
197
- if (this.sum = 0, this._formatedValue = void 0, this.records) for (let i = 0; i < this.records.length; i++) {
213
+ if (this.sum = 0, this._formatedValue = void 0, this.children && this.children.length > 0) for (let i = 0; i < this.children.length; i++) {
214
+ const child = this.children[i];
215
+ if (child.isAggregator) {
216
+ const value = child.value();
217
+ this.sum += null != value ? value : 0, this.needSplitPositiveAndNegativeForSum && (value > 0 ? this.positiveSum += value : value < 0 && (this.nagetiveSum += value));
218
+ }
219
+ } else if (this.records) for (let i = 0; i < this.records.length; i++) {
198
220
  const record = this.records[i];
199
221
  if (record.isAggregator) {
200
222
  const value = record.value();
@@ -213,24 +235,34 @@ export class CountAggregator extends Aggregator {
213
235
  }
214
236
  push(record) {
215
237
  record && (this.isRecord && this.records && (record.isAggregator ? this.records.push(...record.records) : this.records.push(record)),
216
- record.isAggregator ? this.count += record.value() : this.count++), this.clearCacheValue();
238
+ record.isAggregator ? (this.children && this.children.push(record), this.count += record.value()) : this.count++),
239
+ this.clearCacheValue();
217
240
  }
218
241
  deleteRecord(record) {
219
242
  record && (this.isRecord && this.records && (this.records = this.records.filter((item => item !== record))),
220
- record.isAggregator ? this.count -= record.value() : this.count--), this.clearCacheValue();
243
+ record.isAggregator ? (this.children && (this.children = this.children.filter((item => item !== record))),
244
+ this.count -= record.value()) : this.count--), this.clearCacheValue();
221
245
  }
222
246
  updateRecord(oldRecord, newRecord) {
223
247
  oldRecord && newRecord && (this.isRecord && this.records && (this.records = this.records.map((item => item === oldRecord ? newRecord : item))),
224
- oldRecord.isAggregator && (this.count += newRecord.value() - oldRecord.value()));
248
+ oldRecord.isAggregator && (this.count += newRecord.value() - oldRecord.value()),
249
+ oldRecord.isAggregator && newRecord.isAggregator && this.children && (this.children = this.children.map((item => item === oldRecord ? newRecord : item))));
225
250
  }
226
251
  value() {
227
- return this.count;
252
+ var _a;
253
+ return null !== (_a = this.changedValue) && void 0 !== _a ? _a : this.count;
228
254
  }
229
255
  reset() {
230
- this.records = [], this.count = 0;
256
+ this.changedValue = void 0, this.children = [], this.records = [], this.count = 0;
231
257
  }
232
258
  recalculate() {
233
- if (this.count = 0, this._formatedValue = void 0, this.records) for (let i = 0; i < this.records.length; i++) {
259
+ if (this.count = 0, this._formatedValue = void 0, this.children && this.children.length > 0) for (let i = 0; i < this.children.length; i++) {
260
+ const child = this.children[i];
261
+ if (child.isAggregator) {
262
+ const value = child.value();
263
+ this.count += null != value ? value : 0;
264
+ } else this.count++;
265
+ } else if (this.records) for (let i = 0; i < this.records.length; i++) {
234
266
  const record = this.records[i];
235
267
  record.isAggregator ? this.count += record.value() : this.count++;
236
268
  }
@@ -243,31 +275,38 @@ export class AvgAggregator extends Aggregator {
243
275
  }
244
276
  push(record) {
245
277
  record && (this.isRecord && this.records && (record.isAggregator ? this.records.push(...record.records) : this.records.push(record)),
246
- record.isAggregator && record.type === AggregationType.AVG ? (this.sum += record.sum,
247
- this.count += record.count) : this.field && !isNaN(parseFloat(record[this.field])) && (this.sum += parseFloat(record[this.field]),
278
+ record.isAggregator && record.type === AggregationType.AVG ? (this.children && this.children.push(record),
279
+ this.sum += record.sum, this.count += record.count) : this.field && !isNaN(parseFloat(record[this.field])) && (this.sum += parseFloat(record[this.field]),
248
280
  this.count++)), this.clearCacheValue();
249
281
  }
250
282
  deleteRecord(record) {
251
283
  record && (this.isRecord && this.records && (this.records = this.records.filter((item => item !== record))),
252
- record.isAggregator && record.type === AggregationType.AVG ? (this.sum -= record.sum,
253
- this.count -= record.count) : this.field && !isNaN(parseFloat(record[this.field])) && (this.sum -= parseFloat(record[this.field]),
284
+ record.isAggregator && record.type === AggregationType.AVG ? (this.children && (this.children = this.children.filter((item => item !== record))),
285
+ this.sum -= record.sum, this.count -= record.count) : this.field && !isNaN(parseFloat(record[this.field])) && (this.sum -= parseFloat(record[this.field]),
254
286
  this.count--)), this.clearCacheValue();
255
287
  }
256
288
  updateRecord(oldRecord, newRecord) {
257
289
  oldRecord && newRecord && (this.isRecord && this.records && (this.records = this.records.map((item => item === oldRecord ? newRecord : item))),
258
- oldRecord.isAggregator && oldRecord.type === AggregationType.AVG ? (this.sum += newRecord.sum - oldRecord.sum,
259
- this.count += newRecord.count - oldRecord.count) : this.field && !isNaN(parseFloat(oldRecord[this.field])) && (this.sum += parseFloat(newRecord[this.field]) - parseFloat(oldRecord[this.field])),
290
+ oldRecord.isAggregator && oldRecord.type === AggregationType.AVG ? (this.children && newRecord.isAggregator && (this.children = this.children.map((item => item === oldRecord ? newRecord : item))),
291
+ this.sum += newRecord.sum - oldRecord.sum, this.count += newRecord.count - oldRecord.count) : this.field && !isNaN(parseFloat(oldRecord[this.field])) && (this.sum += parseFloat(newRecord[this.field]) - parseFloat(oldRecord[this.field])),
260
292
  this.clearCacheValue());
261
293
  }
262
294
  value() {
263
- var _a;
264
- return (null === (_a = this.records) || void 0 === _a ? void 0 : _a.length) >= 1 ? this.sum / this.count : void 0;
295
+ var _a, _b;
296
+ return null !== (_a = this.changedValue) && void 0 !== _a ? _a : (null === (_b = this.records) || void 0 === _b ? void 0 : _b.length) >= 1 ? this.sum / this.count : void 0;
265
297
  }
266
298
  reset() {
267
- this.records = [], this.sum = 0, this.count = 0;
299
+ this.changedValue = void 0, this.children = [], this.records = [], this.sum = 0,
300
+ this.count = 0;
268
301
  }
269
302
  recalculate() {
270
- if (this.sum = 0, this.count = 0, this._formatedValue = void 0, this.records) for (let i = 0; i < this.records.length; i++) {
303
+ if (this.sum = 0, this.count = 0, this._formatedValue = void 0, this.children && this.children.length > 0) for (let i = 0; i < this.children.length; i++) {
304
+ const child = this.children[i];
305
+ if (child.isAggregator && child.type === AggregationType.AVG) {
306
+ const childValue = child.value();
307
+ this.sum += childValue * child.count, this.count += child.count;
308
+ }
309
+ } else if (this.records) for (let i = 0; i < this.records.length; i++) {
271
310
  const record = this.records[i];
272
311
  record.isAggregator && record.type === AggregationType.AVG ? (this.sum += record.sum,
273
312
  this.count += record.count) : this.field && !isNaN(parseFloat(record[this.field])) && (this.sum += parseFloat(record[this.field]),
@@ -282,26 +321,34 @@ export class MaxAggregator extends Aggregator {
282
321
  }
283
322
  push(record) {
284
323
  record && (this.isRecord && this.records && (record.isAggregator ? this.records.push(...record.records) : this.records.push(record)),
285
- record.isAggregator ? this.max = record.max > this.max ? record.max : this.max : "number" == typeof record ? this.max = record > this.max ? record : this.max : this.field && "number" == typeof record[this.field] ? this.max = record[this.field] > this.max ? record[this.field] : this.max : this.field && !isNaN(record[this.field]) && (this.max = parseFloat(record[this.field]) > this.max ? parseFloat(record[this.field]) : this.max)),
324
+ record.isAggregator ? (this.children && this.children.push(record), this.max = record.max > this.max ? record.max : this.max) : "number" == typeof record ? this.max = record > this.max ? record : this.max : this.field && "number" == typeof record[this.field] ? this.max = record[this.field] > this.max ? record[this.field] : this.max : this.field && !isNaN(record[this.field]) && (this.max = parseFloat(record[this.field]) > this.max ? parseFloat(record[this.field]) : this.max)),
286
325
  this.clearCacheValue();
287
326
  }
288
327
  deleteRecord(record) {
289
328
  record && (this.isRecord && this.records && (this.records = this.records.filter((item => item !== record))),
329
+ record.isAggregator && this.children && (this.children = this.children.filter((item => item !== record))),
290
330
  this.recalculate());
291
331
  }
292
332
  updateRecord(oldRecord, newRecord) {
293
333
  oldRecord && newRecord && (this.isRecord && this.records && (this.records = this.records.map((item => item === oldRecord ? newRecord : item))),
334
+ oldRecord.isAggregator && newRecord.isAggregator && this.children && (this.children = this.children.map((item => item === oldRecord ? newRecord : item))),
294
335
  this.recalculate());
295
336
  }
296
337
  value() {
297
- var _a;
298
- return (null === (_a = this.records) || void 0 === _a ? void 0 : _a.length) >= 1 ? this.max : void 0;
338
+ var _a, _b;
339
+ return null !== (_a = this.changedValue) && void 0 !== _a ? _a : (null === (_b = this.records) || void 0 === _b ? void 0 : _b.length) >= 1 ? this.max : void 0;
299
340
  }
300
341
  reset() {
301
- this.records = [], this.max = Number.MIN_SAFE_INTEGER;
342
+ this.records = [], this.changedValue = void 0, this.children = [], this.max = Number.MIN_SAFE_INTEGER;
302
343
  }
303
344
  recalculate() {
304
- if (this.max = Number.MIN_SAFE_INTEGER, this._formatedValue = void 0, this.records) for (let i = 0; i < this.records.length; i++) {
345
+ if (this.max = Number.MIN_SAFE_INTEGER, this._formatedValue = void 0, this.children && this.children.length > 0) for (let i = 0; i < this.children.length; i++) {
346
+ const child = this.children[i];
347
+ if (child.isAggregator) {
348
+ const childValue = child.value();
349
+ this.max = Math.max(this.max, childValue);
350
+ }
351
+ } else if (this.records) for (let i = 0; i < this.records.length; i++) {
305
352
  const record = this.records[i];
306
353
  record.isAggregator ? this.max = record.max > this.max ? record.max : this.max : "number" == typeof record ? this.max = record > this.max ? record : this.max : this.field && "number" == typeof record[this.field] ? this.max = record[this.field] > this.max ? record[this.field] : this.max : this.field && !isNaN(record[this.field]) && (this.max = parseFloat(record[this.field]) > this.max ? parseFloat(record[this.field]) : this.max);
307
354
  }
@@ -314,26 +361,34 @@ export class MinAggregator extends Aggregator {
314
361
  }
315
362
  push(record) {
316
363
  record && (this.isRecord && this.records && (record.isAggregator ? this.records.push(...record.records) : this.records.push(record)),
317
- record.isAggregator ? this.min = record.min < this.min ? record.min : this.min : "number" == typeof record ? this.min = record < this.min ? record : this.min : this.field && "number" == typeof record[this.field] ? this.min = record[this.field] < this.min ? record[this.field] : this.min : this.field && !isNaN(record[this.field]) && (this.min = parseFloat(record[this.field]) < this.min ? parseFloat(record[this.field]) : this.min)),
364
+ record.isAggregator ? (this.children && this.children.push(record), this.min = record.min < this.min ? record.min : this.min) : "number" == typeof record ? this.min = record < this.min ? record : this.min : this.field && "number" == typeof record[this.field] ? this.min = record[this.field] < this.min ? record[this.field] : this.min : this.field && !isNaN(record[this.field]) && (this.min = parseFloat(record[this.field]) < this.min ? parseFloat(record[this.field]) : this.min)),
318
365
  this.clearCacheValue();
319
366
  }
320
367
  deleteRecord(record) {
321
368
  record && (this.isRecord && this.records && (this.records = this.records.filter((item => item !== record))),
369
+ record.isAggregator && this.children && (this.children = this.children.filter((item => item !== record))),
322
370
  this.recalculate());
323
371
  }
324
372
  updateRecord(oldRecord, newRecord) {
325
373
  oldRecord && newRecord && (this.isRecord && this.records && (this.records = this.records.map((item => item === oldRecord ? newRecord : item))),
374
+ oldRecord.isAggregator && newRecord.isAggregator && this.children && (this.children = this.children.map((item => item === oldRecord ? newRecord : item))),
326
375
  this.recalculate());
327
376
  }
328
377
  value() {
329
- var _a;
330
- return (null === (_a = this.records) || void 0 === _a ? void 0 : _a.length) >= 1 ? this.min : void 0;
378
+ var _a, _b;
379
+ return null !== (_a = this.changedValue) && void 0 !== _a ? _a : (null === (_b = this.records) || void 0 === _b ? void 0 : _b.length) >= 1 ? this.min : void 0;
331
380
  }
332
381
  reset() {
333
- this.records = [], this.min = Number.MAX_SAFE_INTEGER;
382
+ this.records = [], this.changedValue = void 0, this.children = [], this.min = Number.MAX_SAFE_INTEGER;
334
383
  }
335
384
  recalculate() {
336
- if (this.min = Number.MAX_SAFE_INTEGER, this._formatedValue = void 0, this.records) for (let i = 0; i < this.records.length; i++) {
385
+ if (this.min = Number.MAX_SAFE_INTEGER, this._formatedValue = void 0, this.children && this.children.length > 0) for (let i = 0; i < this.children.length; i++) {
386
+ const child = this.children[i];
387
+ if (child.isAggregator) {
388
+ const childValue = child.value();
389
+ this.min = Math.min(this.min, childValue);
390
+ }
391
+ } else if (this.records) for (let i = 0; i < this.records.length; i++) {
337
392
  const record = this.records[i];
338
393
  record.isAggregator ? this.min = record.min < this.min ? record.min : this.min : "number" == typeof record ? this.min = record < this.min ? record : this.min : this.field && "number" == typeof record[this.field] ? this.min = record[this.field] < this.min ? record[this.field] : this.min : this.field && !isNaN(record[this.field]) && (this.min = parseFloat(record[this.field]) < this.min ? parseFloat(record[this.field]) : this.min);
339
394
  }