@visactor/vtable-sheet 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.
- package/cjs/core/WorkSheet.js +2 -1
- package/cjs/event/vtable-sheet-event-bus.js +1 -2
- package/cjs/index.d.ts +1 -1
- package/cjs/index.js +1 -1
- package/cjs/index.js.map +1 -1
- package/dist/vtable-sheet.js +81 -29
- package/dist/vtable-sheet.min.js +1 -1
- package/es/core/WorkSheet.js +2 -1
- package/es/event/vtable-sheet-event-bus.js +1 -2
- package/es/index.d.ts +1 -1
- package/es/index.js +1 -1
- package/es/index.js.map +1 -1
- package/package.json +9 -8
package/cjs/core/WorkSheet.js
CHANGED
package/cjs/index.d.ts
CHANGED
|
@@ -2,5 +2,5 @@ import VTableSheet from './components/vtable-sheet';
|
|
|
2
2
|
import type { ISheetDefine, IVTableSheetOptions, IVTableSheetUpdateOptions } from './ts-types';
|
|
3
3
|
import * as TYPES from './ts-types';
|
|
4
4
|
import * as VTable from './vtable';
|
|
5
|
-
export declare const version = "1.26.0";
|
|
5
|
+
export declare const version = "1.26.1-alpha.0";
|
|
6
6
|
export { VTableSheet, TYPES, VTable, ISheetDefine, IVTableSheetOptions, IVTableSheetUpdateOptions };
|
package/cjs/index.js
CHANGED
package/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6EAAoD;AAW3C,sBAXF,sBAAW,CAWE;AATpB,kDAAoC;AASd,sBAAK;AAR3B,iDAAmC;AAQN,wBAAM;AAPnC,0DAAsD;AACzC,QAAA,OAAO,GAAG,
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6EAAoD;AAW3C,sBAXF,sBAAW,CAWE;AATpB,kDAAoC;AASd,sBAAK;AAR3B,iDAAmC;AAQN,wBAAM;AAPnC,0DAAsD;AACzC,QAAA,OAAO,GAAG,gBAAgB,CAAC;AAExC,IAAA,4BAAY,GAAE,CAAC","file":"index.js","sourcesContent":["import VTableSheet from './components/vtable-sheet';\nimport type { ISheetDefine, IVTableSheetOptions, IVTableSheetUpdateOptions } from './ts-types';\nimport * as TYPES from './ts-types';\nimport * as VTable from './vtable';\nimport { importStyles } from './styles/style-manager';\nexport const version = \"1.26.1-alpha.0\";\n// 导入样式\nimportStyles();\n/**\n * @namespace VTableSheet\n */\nexport { VTableSheet, TYPES, VTable, ISheetDefine, IVTableSheetOptions, IVTableSheetUpdateOptions };\n"]}
|
package/dist/vtable-sheet.js
CHANGED
|
@@ -4940,6 +4940,20 @@
|
|
|
4940
4940
|
function crossProduct(dir1, dir2) {
|
|
4941
4941
|
return dir1[0] * dir2[1] - dir1[1] * dir2[0];
|
|
4942
4942
|
}
|
|
4943
|
+
function fixPrecision$1(num, precision = 10) {
|
|
4944
|
+
return Math.round(num * precision) / precision;
|
|
4945
|
+
}
|
|
4946
|
+
function getDecimalPlaces(n) {
|
|
4947
|
+
const dStr = n.toString().split(/[eE]/),
|
|
4948
|
+
s = (dStr[0].split(".")[1] || "").length - (+dStr[1] || 0);
|
|
4949
|
+
return s > 0 ? s : 0;
|
|
4950
|
+
}
|
|
4951
|
+
function precisionAdd(a, b) {
|
|
4952
|
+
return fixPrecision$1(a + b, 10 ** Math.max(getDecimalPlaces(a), getDecimalPlaces(b)));
|
|
4953
|
+
}
|
|
4954
|
+
function precisionSub(a, b) {
|
|
4955
|
+
return fixPrecision$1(a - b, 10 ** Math.max(getDecimalPlaces(a), getDecimalPlaces(b)));
|
|
4956
|
+
}
|
|
4943
4957
|
|
|
4944
4958
|
class Point {
|
|
4945
4959
|
constructor(x = 0, y = 0, x1, y1) {
|
|
@@ -37697,42 +37711,54 @@
|
|
|
37697
37711
|
if (record) if (this.isRecord && this.records && (record.isAggregator ? this.records.push(...record.records) : this.records.push(record)), record.isAggregator && this.children) {
|
|
37698
37712
|
this.children.push(record);
|
|
37699
37713
|
const value = record.value();
|
|
37700
|
-
this.sum
|
|
37714
|
+
this.sum = precisionAdd(this.sum, null != value ? value : 0), this.needSplitPositiveAndNegativeForSum && (value > 0 ? this.positiveSum = precisionAdd(this.positiveSum, value) : value < 0 && (this.nagetiveSum = precisionAdd(this.nagetiveSum, value)));
|
|
37701
37715
|
} else if (this.field && !isNaN(parseFloat(record[this.field]))) {
|
|
37702
37716
|
const value = parseFloat(record[this.field]);
|
|
37703
|
-
this.sum
|
|
37717
|
+
this.sum = precisionAdd(this.sum, value), this.needSplitPositiveAndNegativeForSum && (value > 0 ? this.positiveSum = precisionAdd(this.positiveSum, value) : value < 0 && (this.nagetiveSum = precisionAdd(this.nagetiveSum, value)));
|
|
37704
37718
|
}
|
|
37705
37719
|
this.clearCacheValue();
|
|
37706
37720
|
}
|
|
37707
37721
|
deleteRecord(record) {
|
|
37708
|
-
if (record)
|
|
37709
|
-
this.
|
|
37710
|
-
|
|
37711
|
-
|
|
37712
|
-
|
|
37713
|
-
|
|
37714
|
-
|
|
37722
|
+
if (record) {
|
|
37723
|
+
if (this.isRecord && this.records) {
|
|
37724
|
+
const index = this.records.indexOf(record);
|
|
37725
|
+
-1 !== index && this.records.splice(index, 1);
|
|
37726
|
+
}
|
|
37727
|
+
if (record.isAggregator && this.children) {
|
|
37728
|
+
const index = this.children.indexOf(record);
|
|
37729
|
+
-1 !== index && this.children.splice(index, 1);
|
|
37730
|
+
const value = record.value();
|
|
37731
|
+
this.sum = precisionSub(this.sum, null != value ? value : 0), this.needSplitPositiveAndNegativeForSum && (value > 0 ? this.positiveSum = precisionSub(this.positiveSum, value) : value < 0 && (this.nagetiveSum = precisionSub(this.nagetiveSum, value)));
|
|
37732
|
+
} else if (this.field && !isNaN(parseFloat(record[this.field]))) {
|
|
37733
|
+
const value = parseFloat(record[this.field]);
|
|
37734
|
+
this.sum = precisionSub(this.sum, value), this.needSplitPositiveAndNegativeForSum && (value > 0 ? this.positiveSum = precisionSub(this.positiveSum, value) : value < 0 && (this.nagetiveSum = precisionSub(this.nagetiveSum, value)));
|
|
37735
|
+
}
|
|
37715
37736
|
}
|
|
37716
37737
|
this.clearCacheValue();
|
|
37717
37738
|
}
|
|
37718
37739
|
updateRecord(oldRecord, newRecord) {
|
|
37719
37740
|
if (oldRecord && newRecord) {
|
|
37720
|
-
if (this.isRecord && this.records
|
|
37721
|
-
const
|
|
37722
|
-
|
|
37741
|
+
if (this.isRecord && this.records) {
|
|
37742
|
+
const index = this.records.indexOf(oldRecord);
|
|
37743
|
+
-1 !== index && (this.records[index] = newRecord);
|
|
37744
|
+
}
|
|
37745
|
+
if (oldRecord.isAggregator && this.children) {
|
|
37746
|
+
const oldValue = oldRecord.value(),
|
|
37747
|
+
index = this.children.indexOf(oldRecord);
|
|
37748
|
+
-1 !== index && (this.children[index] = newRecord);
|
|
37723
37749
|
const newValue = newRecord.value();
|
|
37724
|
-
this.
|
|
37750
|
+
this.sum = precisionAdd(this.sum, precisionSub(newValue, oldValue)), this.needSplitPositiveAndNegativeForSum && (oldValue > 0 ? this.positiveSum = precisionSub(this.positiveSum, oldValue) : oldValue < 0 && (this.nagetiveSum = precisionSub(this.nagetiveSum, oldValue)), newValue > 0 ? this.positiveSum = precisionAdd(this.positiveSum, newValue) : newValue < 0 && (this.nagetiveSum = precisionAdd(this.nagetiveSum, newValue)));
|
|
37725
37751
|
} else if (this.field && !isNaN(parseFloat(oldRecord[this.field]))) {
|
|
37726
37752
|
const oldValue = parseFloat(oldRecord[this.field]),
|
|
37727
37753
|
newValue = parseFloat(newRecord[this.field]);
|
|
37728
|
-
this.sum
|
|
37754
|
+
this.sum = precisionAdd(this.sum, precisionSub(newValue, oldValue)), this.needSplitPositiveAndNegativeForSum && (oldValue > 0 ? this.positiveSum = precisionSub(this.positiveSum, oldValue) : oldValue < 0 && (this.nagetiveSum = precisionSub(this.nagetiveSum, oldValue)), newValue > 0 ? this.positiveSum = precisionAdd(this.positiveSum, newValue) : newValue < 0 && (this.nagetiveSum = precisionAdd(this.nagetiveSum, newValue)));
|
|
37729
37755
|
}
|
|
37730
37756
|
this.clearCacheValue();
|
|
37731
37757
|
}
|
|
37732
37758
|
}
|
|
37733
37759
|
value() {
|
|
37734
|
-
var _a
|
|
37735
|
-
return null !== (_a = this.changedValue) && void 0 !== _a ? _a :
|
|
37760
|
+
var _a;
|
|
37761
|
+
return null !== (_a = this.changedValue) && void 0 !== _a ? _a : this.records && this.records.length >= 1 || !1 === this.isRecord ? this.sum : void 0;
|
|
37736
37762
|
}
|
|
37737
37763
|
positiveValue() {
|
|
37738
37764
|
return this.positiveSum;
|
|
@@ -37748,16 +37774,16 @@
|
|
|
37748
37774
|
const child = this.children[i];
|
|
37749
37775
|
if (child.isAggregator) {
|
|
37750
37776
|
const value = child.value();
|
|
37751
|
-
this.sum
|
|
37777
|
+
this.sum = precisionAdd(this.sum, null != value ? value : 0), this.needSplitPositiveAndNegativeForSum && (value > 0 ? this.positiveSum = precisionAdd(this.positiveSum, value) : value < 0 && (this.nagetiveSum = precisionAdd(this.nagetiveSum, value)));
|
|
37752
37778
|
}
|
|
37753
37779
|
} else if (this.records) for (let i = 0; i < this.records.length; i++) {
|
|
37754
37780
|
const record = this.records[i];
|
|
37755
37781
|
if (record.isAggregator) {
|
|
37756
37782
|
const value = record.value();
|
|
37757
|
-
this.sum
|
|
37783
|
+
this.sum = precisionAdd(this.sum, null != value ? value : 0), this.needSplitPositiveAndNegativeForSum && (value > 0 ? this.positiveSum = precisionAdd(this.positiveSum, value) : value < 0 && (this.nagetiveSum = precisionAdd(this.nagetiveSum, value)));
|
|
37758
37784
|
} else if (this.field && !isNaN(parseFloat(record[this.field]))) {
|
|
37759
37785
|
const value = parseFloat(record[this.field]);
|
|
37760
|
-
this.sum
|
|
37786
|
+
this.sum = precisionAdd(this.sum, value), this.needSplitPositiveAndNegativeForSum && (value > 0 ? this.positiveSum = precisionAdd(this.positiveSum, value) : value < 0 && (this.nagetiveSum = precisionAdd(this.nagetiveSum, value)));
|
|
37761
37787
|
}
|
|
37762
37788
|
}
|
|
37763
37789
|
}
|
|
@@ -37800,17 +37826,43 @@
|
|
|
37800
37826
|
super(...arguments), this.type = AggregationType.AVG, this.sum = 0, this.count = 0;
|
|
37801
37827
|
}
|
|
37802
37828
|
push(record) {
|
|
37803
|
-
record && (this.isRecord && this.records && (record.isAggregator ? this.records.push(...record.records) : this.records.push(record)), record.isAggregator && record.type === AggregationType.AVG ? (this.children && this.children.push(record), this.sum
|
|
37829
|
+
record && (this.isRecord && this.records && (record.isAggregator ? this.records.push(...record.records) : this.records.push(record)), record.isAggregator && record.type === AggregationType.AVG ? (this.children && this.children.push(record), this.sum = precisionAdd(this.sum, record.sum), this.count += record.count) : this.field && !isNaN(parseFloat(record[this.field])) && (this.sum = precisionAdd(this.sum, parseFloat(record[this.field])), this.count++)), this.clearCacheValue();
|
|
37804
37830
|
}
|
|
37805
37831
|
deleteRecord(record) {
|
|
37806
|
-
|
|
37832
|
+
if (record) {
|
|
37833
|
+
if (this.isRecord && this.records) {
|
|
37834
|
+
const index = this.records.indexOf(record);
|
|
37835
|
+
-1 !== index && this.records.splice(index, 1);
|
|
37836
|
+
}
|
|
37837
|
+
if (record.isAggregator && record.type === AggregationType.AVG) {
|
|
37838
|
+
if (this.children) {
|
|
37839
|
+
const index = this.children.indexOf(record);
|
|
37840
|
+
-1 !== index && this.children.splice(index, 1);
|
|
37841
|
+
}
|
|
37842
|
+
this.sum = precisionSub(this.sum, record.sum), this.count -= record.count;
|
|
37843
|
+
} else this.field && !isNaN(parseFloat(record[this.field])) && (this.sum = precisionSub(this.sum, parseFloat(record[this.field])), this.count--);
|
|
37844
|
+
}
|
|
37845
|
+
this.clearCacheValue();
|
|
37807
37846
|
}
|
|
37808
37847
|
updateRecord(oldRecord, newRecord) {
|
|
37809
|
-
|
|
37848
|
+
if (oldRecord && newRecord) {
|
|
37849
|
+
if (this.isRecord && this.records) {
|
|
37850
|
+
const index = this.records.indexOf(oldRecord);
|
|
37851
|
+
-1 !== index && (this.records[index] = newRecord);
|
|
37852
|
+
}
|
|
37853
|
+
if (oldRecord.isAggregator && oldRecord.type === AggregationType.AVG) {
|
|
37854
|
+
if (this.children && newRecord.isAggregator) {
|
|
37855
|
+
const index = this.children.indexOf(oldRecord);
|
|
37856
|
+
-1 !== index && (this.children[index] = newRecord);
|
|
37857
|
+
}
|
|
37858
|
+
this.sum = precisionAdd(this.sum, precisionSub(newRecord.sum, oldRecord.sum)), this.count += newRecord.count - oldRecord.count;
|
|
37859
|
+
} else this.field && !isNaN(parseFloat(oldRecord[this.field])) && (this.sum = precisionAdd(this.sum, precisionSub(parseFloat(newRecord[this.field]), parseFloat(oldRecord[this.field]))));
|
|
37860
|
+
this.clearCacheValue();
|
|
37861
|
+
}
|
|
37810
37862
|
}
|
|
37811
37863
|
value() {
|
|
37812
|
-
var _a
|
|
37813
|
-
return null !== (_a = this.changedValue) && void 0 !== _a ? _a :
|
|
37864
|
+
var _a;
|
|
37865
|
+
return null !== (_a = this.changedValue) && void 0 !== _a ? _a : this.records && this.records.length >= 1 || !1 === this.isRecord && this.count > 0 ? this.sum / this.count : void 0;
|
|
37814
37866
|
}
|
|
37815
37867
|
reset() {
|
|
37816
37868
|
this.changedValue = void 0, this.children = [], this.records = [], this.sum = 0, this.count = 0;
|
|
@@ -37820,11 +37872,11 @@
|
|
|
37820
37872
|
const child = this.children[i];
|
|
37821
37873
|
if (child.isAggregator && child.type === AggregationType.AVG) {
|
|
37822
37874
|
const childValue = child.value();
|
|
37823
|
-
this.sum
|
|
37875
|
+
this.sum = precisionAdd(this.sum, childValue * child.count), this.count += child.count;
|
|
37824
37876
|
}
|
|
37825
37877
|
} else if (this.records) for (let i = 0; i < this.records.length; i++) {
|
|
37826
37878
|
const record = this.records[i];
|
|
37827
|
-
record.isAggregator && record.type === AggregationType.AVG ? (this.sum
|
|
37879
|
+
record.isAggregator && record.type === AggregationType.AVG ? (this.sum = precisionAdd(this.sum, record.sum), this.count += record.count) : this.field && !isNaN(parseFloat(record[this.field])) && (this.sum = precisionAdd(this.sum, parseFloat(record[this.field])), this.count++);
|
|
37828
37880
|
}
|
|
37829
37881
|
}
|
|
37830
37882
|
}
|
|
@@ -61178,7 +61230,7 @@
|
|
|
61178
61230
|
}
|
|
61179
61231
|
constructor(container, options = {}) {
|
|
61180
61232
|
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;
|
|
61181
|
-
if (super(), this.showFrozenIcon = !0, this._scrollToRowCorrectTimer = null, this._tableBorderWidth_left = 0, this._tableBorderWidth_right = 0, this._tableBorderWidth_top = 0, this._tableBorderWidth_bottom = 0, this.version = "1.26.0", this.id = `VTable${Date.now()}`, this.isReleased = !1, this._chartEventMap = {}, this.throttleInvalidate = throttle2(this.render.bind(this), 200), "undefined" != typeof window) {
|
|
61233
|
+
if (super(), this.showFrozenIcon = !0, this._scrollToRowCorrectTimer = null, this._tableBorderWidth_left = 0, this._tableBorderWidth_right = 0, this._tableBorderWidth_top = 0, this._tableBorderWidth_bottom = 0, this.version = "1.26.1-alpha.0", this.id = `VTable${Date.now()}`, this.isReleased = !1, this._chartEventMap = {}, this.throttleInvalidate = throttle2(this.render.bind(this), 200), "undefined" != typeof window) {
|
|
61182
61234
|
const g = window;
|
|
61183
61235
|
g[this.id] = this;
|
|
61184
61236
|
const registry = g.__vtable__ || (g.__vtable__ = {
|
|
@@ -83720,7 +83772,7 @@
|
|
|
83720
83772
|
function getCellMatrix(table) {
|
|
83721
83773
|
return {
|
|
83722
83774
|
getValue: (row, col) => {
|
|
83723
|
-
const value = table.
|
|
83775
|
+
const value = table.getCellOriginValue(col, row);
|
|
83724
83776
|
return "number" != typeof value && isNaN(Number(value)) ? {
|
|
83725
83777
|
v: value || "",
|
|
83726
83778
|
t: CellValueType.STRING
|
|
@@ -95772,7 +95824,7 @@
|
|
|
95772
95824
|
importStyle();
|
|
95773
95825
|
}
|
|
95774
95826
|
|
|
95775
|
-
const version = "1.26.0";
|
|
95827
|
+
const version = "1.26.1-alpha.0";
|
|
95776
95828
|
importStyles();
|
|
95777
95829
|
|
|
95778
95830
|
exports.TYPES = index;
|