@fileverse-dev/fortune-core 1.1.4 → 1.1.5-live-query-3
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/es/animate.d.ts +14 -0
- package/es/animate.js +52 -0
- package/es/api/common.d.ts +1 -0
- package/es/canvas.js +43 -9
- package/es/index.d.ts +1 -0
- package/es/index.js +2 -1
- package/es/modules/ConditionFormat.js +27 -27
- package/es/types.d.ts +13 -0
- package/lib/animate.d.ts +14 -0
- package/lib/animate.js +59 -0
- package/lib/api/common.d.ts +1 -0
- package/lib/canvas.js +43 -9
- package/lib/index.d.ts +1 -0
- package/lib/index.js +12 -0
- package/lib/modules/ConditionFormat.js +27 -27
- package/lib/types.d.ts +13 -0
- package/package.json +1 -1
package/es/animate.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
declare class CellFadeAnimator {
|
|
2
|
+
private durationMs;
|
|
3
|
+
private active;
|
|
4
|
+
private raf;
|
|
5
|
+
private onTick;
|
|
6
|
+
constructor(durationMs?: number);
|
|
7
|
+
markChanged(sheetId: string, r: number, c: number): void;
|
|
8
|
+
alpha(sheetId: string, r: number, c: number): number;
|
|
9
|
+
setOnTick(cb: (() => void) | null): void;
|
|
10
|
+
private ensureTicking;
|
|
11
|
+
}
|
|
12
|
+
export declare const cellFadeAnimator: CellFadeAnimator;
|
|
13
|
+
export declare function markCellChanged(sheetId: string, r: number, c: number): void;
|
|
14
|
+
export {};
|
package/es/animate.js
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
var CellFadeAnimator = function () {
|
|
2
|
+
function CellFadeAnimator(durationMs) {
|
|
3
|
+
if (durationMs === void 0) {
|
|
4
|
+
durationMs = 350;
|
|
5
|
+
}
|
|
6
|
+
this.durationMs = durationMs;
|
|
7
|
+
this.active = new Map();
|
|
8
|
+
this.raf = null;
|
|
9
|
+
this.onTick = null;
|
|
10
|
+
this.durationMs = durationMs;
|
|
11
|
+
}
|
|
12
|
+
CellFadeAnimator.prototype.markChanged = function (sheetId, r, c) {
|
|
13
|
+
this.active.set("".concat(sheetId, ":").concat(r, ":").concat(c), {
|
|
14
|
+
start: performance.now(),
|
|
15
|
+
dur: this.durationMs
|
|
16
|
+
});
|
|
17
|
+
this.ensureTicking();
|
|
18
|
+
};
|
|
19
|
+
CellFadeAnimator.prototype.alpha = function (sheetId, r, c) {
|
|
20
|
+
var it = this.active.get("".concat(sheetId, ":").concat(r, ":").concat(c));
|
|
21
|
+
if (!it) return 1;
|
|
22
|
+
var t = Math.min(1, (performance.now() - it.start) / it.dur);
|
|
23
|
+
if (t >= 1) {
|
|
24
|
+
this.active.delete("".concat(sheetId, ":").concat(r, ":").concat(c));
|
|
25
|
+
return 1;
|
|
26
|
+
}
|
|
27
|
+
return Math.max(0.05, 1 - Math.pow(1 - t, 3));
|
|
28
|
+
};
|
|
29
|
+
CellFadeAnimator.prototype.setOnTick = function (cb) {
|
|
30
|
+
this.onTick = cb;
|
|
31
|
+
this.ensureTicking();
|
|
32
|
+
};
|
|
33
|
+
CellFadeAnimator.prototype.ensureTicking = function () {
|
|
34
|
+
var _this = this;
|
|
35
|
+
if (this.raf !== null) return;
|
|
36
|
+
if (this.active.size === 0 && !this.onTick) return;
|
|
37
|
+
var _loop = function loop() {
|
|
38
|
+
var _a;
|
|
39
|
+
_this.raf = null;
|
|
40
|
+
if (_this.active.size > 0) (_a = _this.onTick) === null || _a === void 0 ? void 0 : _a.call(_this);
|
|
41
|
+
if (_this.active.size > 0 || _this.onTick) {
|
|
42
|
+
_this.raf = requestAnimationFrame(_loop);
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
this.raf = requestAnimationFrame(_loop);
|
|
46
|
+
};
|
|
47
|
+
return CellFadeAnimator;
|
|
48
|
+
}();
|
|
49
|
+
export var cellFadeAnimator = new CellFadeAnimator(4000);
|
|
50
|
+
export function markCellChanged(sheetId, r, c) {
|
|
51
|
+
cellFadeAnimator.markChanged(sheetId, r, c);
|
|
52
|
+
}
|
package/es/api/common.d.ts
CHANGED
package/es/canvas.js
CHANGED
|
@@ -6,6 +6,7 @@ import { isInlineStringCell } from "./modules/inline-string";
|
|
|
6
6
|
import { getSheetIndex, indexToColumnChar } from "./utils";
|
|
7
7
|
import { getBorderInfoComputeRange } from "./modules/border";
|
|
8
8
|
import { checkCF, getComputeMap, validateCellData } from "./modules";
|
|
9
|
+
import { cellFadeAnimator } from "./animate";
|
|
9
10
|
export var defaultStyle = {
|
|
10
11
|
fillStyle: "#000000",
|
|
11
12
|
textBaseline: "middle",
|
|
@@ -760,7 +761,16 @@ var Canvas = function () {
|
|
|
760
761
|
var horizonAlignPos = startX + 4 + offsetLeft;
|
|
761
762
|
var verticalAlignPos = endY + offsetTop - 2;
|
|
762
763
|
renderCtx.textBaseline = "bottom";
|
|
763
|
-
|
|
764
|
+
var sheetId = this.sheetCtx.currentSheetId;
|
|
765
|
+
var a = cellFadeAnimator.alpha(sheetId, r, c);
|
|
766
|
+
if (a < 0.999) {
|
|
767
|
+
renderCtx.save();
|
|
768
|
+
renderCtx.globalAlpha = a;
|
|
769
|
+
renderCtx.fillText(_.isNil(value) ? "" : value, horizonAlignPos, verticalAlignPos);
|
|
770
|
+
renderCtx.restore();
|
|
771
|
+
} else {
|
|
772
|
+
renderCtx.fillText(_.isNil(value) ? "" : value, horizonAlignPos, verticalAlignPos);
|
|
773
|
+
}
|
|
764
774
|
}
|
|
765
775
|
if ((_d = (_c = flowdata === null || flowdata === void 0 ? void 0 : flowdata[r]) === null || _c === void 0 ? void 0 : _c[c]) === null || _d === void 0 ? void 0 : _d.ps) {
|
|
766
776
|
var ps_w = 12 * this.sheetCtx.zoomRatio;
|
|
@@ -1065,10 +1075,22 @@ var Canvas = function () {
|
|
|
1065
1075
|
if (((_j = (_h = (_g = cell === null || cell === void 0 ? void 0 : cell.ct) === null || _g === void 0 ? void 0 : _g.fa) === null || _h === void 0 ? void 0 : _h.indexOf("[Red]")) !== null && _j !== void 0 ? _j : -1) > -1 && ((_k = cell === null || cell === void 0 ? void 0 : cell.ct) === null || _k === void 0 ? void 0 : _k.t) === "n" && (cell === null || cell === void 0 ? void 0 : cell.v) < 0) {
|
|
1066
1076
|
renderCtx.fillStyle = "#ff0000";
|
|
1067
1077
|
}
|
|
1068
|
-
this.
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1078
|
+
var sheetId = this.sheetCtx.currentSheetId;
|
|
1079
|
+
var a = cellFadeAnimator.alpha(sheetId, r, c);
|
|
1080
|
+
if (a < 0.999) {
|
|
1081
|
+
renderCtx.save();
|
|
1082
|
+
renderCtx.globalAlpha = a;
|
|
1083
|
+
this.cellTextRender(textInfo, renderCtx, {
|
|
1084
|
+
pos_x: pos_x,
|
|
1085
|
+
pos_y: pos_y
|
|
1086
|
+
});
|
|
1087
|
+
renderCtx.restore();
|
|
1088
|
+
} else {
|
|
1089
|
+
this.cellTextRender(textInfo, renderCtx, {
|
|
1090
|
+
pos_x: pos_x,
|
|
1091
|
+
pos_y: pos_y
|
|
1092
|
+
});
|
|
1093
|
+
}
|
|
1072
1094
|
renderCtx.restore();
|
|
1073
1095
|
}
|
|
1074
1096
|
if (cellOverflow_bd_r_render) {
|
|
@@ -1150,10 +1172,22 @@ var Canvas = function () {
|
|
|
1150
1172
|
if (checksCF === null || checksCF === void 0 ? void 0 : checksCF.textColor) {
|
|
1151
1173
|
renderCtx.fillStyle = checksCF.textColor;
|
|
1152
1174
|
}
|
|
1153
|
-
this.
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1175
|
+
var sheetId = this.sheetCtx.currentSheetId;
|
|
1176
|
+
var a = cellFadeAnimator.alpha(sheetId, r, c);
|
|
1177
|
+
if (a < 0.999) {
|
|
1178
|
+
renderCtx.save();
|
|
1179
|
+
renderCtx.globalAlpha = a;
|
|
1180
|
+
this.cellTextRender(textInfo, renderCtx, {
|
|
1181
|
+
pos_x: pos_x,
|
|
1182
|
+
pos_y: pos_y
|
|
1183
|
+
});
|
|
1184
|
+
renderCtx.restore();
|
|
1185
|
+
} else {
|
|
1186
|
+
this.cellTextRender(textInfo, renderCtx, {
|
|
1187
|
+
pos_x: pos_x,
|
|
1188
|
+
pos_y: pos_y
|
|
1189
|
+
});
|
|
1190
|
+
}
|
|
1157
1191
|
renderCtx.restore();
|
|
1158
1192
|
};
|
|
1159
1193
|
Canvas.prototype.cellOverflow_trace = function (r, curC, traceC, traceDir, horizonAlign, textMetrics) {
|
package/es/index.d.ts
CHANGED
package/es/index.js
CHANGED
|
@@ -23,20 +23,20 @@ function compareGreaterThan(cellValue, conditionValue, symbol) {
|
|
|
23
23
|
var cellStr = String(cellValue);
|
|
24
24
|
var conditionStr = String(conditionValue);
|
|
25
25
|
if (hasAlphabeticChars(cellValue) || hasAlphabeticChars(conditionValue)) {
|
|
26
|
-
if (symbol ===
|
|
26
|
+
if (symbol === ">=") {
|
|
27
27
|
return cellStr.localeCompare(conditionStr) >= 0;
|
|
28
28
|
}
|
|
29
29
|
return cellStr.localeCompare(conditionStr) > 0;
|
|
30
30
|
}
|
|
31
31
|
var cellNum = Number(cellValue);
|
|
32
32
|
var conditionNum = Number(conditionValue);
|
|
33
|
-
if (!Number.isNaN(cellNum) && !Number.isNaN(conditionNum) && symbol ===
|
|
33
|
+
if (!Number.isNaN(cellNum) && !Number.isNaN(conditionNum) && symbol === ">=") {
|
|
34
34
|
return cellNum >= conditionNum;
|
|
35
35
|
}
|
|
36
|
-
if (!Number.isNaN(cellNum) && !Number.isNaN(conditionNum) && symbol ===
|
|
36
|
+
if (!Number.isNaN(cellNum) && !Number.isNaN(conditionNum) && symbol === ">") {
|
|
37
37
|
return cellNum > conditionNum;
|
|
38
38
|
}
|
|
39
|
-
if (symbol ===
|
|
39
|
+
if (symbol === ">=") {
|
|
40
40
|
return cellStr.localeCompare(conditionStr) >= 0;
|
|
41
41
|
}
|
|
42
42
|
return cellStr.localeCompare(conditionStr) > 0;
|
|
@@ -45,20 +45,20 @@ function compareLessThan(cellValue, conditionValue, symbol) {
|
|
|
45
45
|
var cellStr = String(cellValue);
|
|
46
46
|
var conditionStr = String(conditionValue);
|
|
47
47
|
if (hasAlphabeticChars(cellValue) || hasAlphabeticChars(conditionValue)) {
|
|
48
|
-
if (symbol ===
|
|
48
|
+
if (symbol === "<=") {
|
|
49
49
|
return cellStr.localeCompare(conditionStr) <= 0;
|
|
50
50
|
}
|
|
51
51
|
return cellStr.localeCompare(conditionStr) < 0;
|
|
52
52
|
}
|
|
53
53
|
var cellNum = Number(cellValue);
|
|
54
54
|
var conditionNum = Number(conditionValue);
|
|
55
|
-
if (!Number.isNaN(cellNum) && !Number.isNaN(conditionNum) && symbol ===
|
|
55
|
+
if (!Number.isNaN(cellNum) && !Number.isNaN(conditionNum) && symbol === "<=") {
|
|
56
56
|
return cellNum <= conditionNum;
|
|
57
57
|
}
|
|
58
58
|
if (!Number.isNaN(cellNum) && !Number.isNaN(conditionNum)) {
|
|
59
59
|
return cellNum < conditionNum;
|
|
60
60
|
}
|
|
61
|
-
if (symbol ===
|
|
61
|
+
if (symbol === "<=") {
|
|
62
62
|
return cellStr.localeCompare(conditionStr) <= 0;
|
|
63
63
|
}
|
|
64
64
|
return cellStr.localeCompare(conditionStr) < 0;
|
|
@@ -67,7 +67,8 @@ function compareBetween(cellValue, value1, value2) {
|
|
|
67
67
|
var cellStr = String(cellValue);
|
|
68
68
|
var val1Str = String(value1);
|
|
69
69
|
var val2Str = String(value2);
|
|
70
|
-
var smallerValue
|
|
70
|
+
var smallerValue;
|
|
71
|
+
var biggerValue;
|
|
71
72
|
if (hasAlphabeticChars(value1) || hasAlphabeticChars(value2) || hasAlphabeticChars(cellValue)) {
|
|
72
73
|
if (val1Str.localeCompare(val2Str) > 0) {
|
|
73
74
|
biggerValue = val1Str;
|
|
@@ -77,24 +78,23 @@ function compareBetween(cellValue, value1, value2) {
|
|
|
77
78
|
smallerValue = val1Str;
|
|
78
79
|
}
|
|
79
80
|
return cellStr.localeCompare(smallerValue) >= 0 && cellStr.localeCompare(biggerValue) <= 0;
|
|
81
|
+
}
|
|
82
|
+
var cellNum = Number(cellValue);
|
|
83
|
+
var val1Num = Number(value1);
|
|
84
|
+
var val2Num = Number(value2);
|
|
85
|
+
if (!Number.isNaN(cellNum) && !Number.isNaN(val1Num) && !Number.isNaN(val2Num)) {
|
|
86
|
+
var smallerNum = Math.min(val1Num, val2Num);
|
|
87
|
+
var biggerNum = Math.max(val1Num, val2Num);
|
|
88
|
+
return cellNum >= smallerNum && cellNum <= biggerNum;
|
|
89
|
+
}
|
|
90
|
+
if (val1Str.localeCompare(val2Str) > 0) {
|
|
91
|
+
biggerValue = val1Str;
|
|
92
|
+
smallerValue = val2Str;
|
|
80
93
|
} else {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
var val2Num = Number(value2);
|
|
84
|
-
if (!Number.isNaN(cellNum) && !Number.isNaN(val1Num) && !Number.isNaN(val2Num)) {
|
|
85
|
-
var smallerNum = Math.min(val1Num, val2Num);
|
|
86
|
-
var biggerNum = Math.max(val1Num, val2Num);
|
|
87
|
-
return cellNum >= smallerNum && cellNum <= biggerNum;
|
|
88
|
-
}
|
|
89
|
-
if (val1Str.localeCompare(val2Str) > 0) {
|
|
90
|
-
biggerValue = val1Str;
|
|
91
|
-
smallerValue = val2Str;
|
|
92
|
-
} else {
|
|
93
|
-
biggerValue = val2Str;
|
|
94
|
-
smallerValue = val1Str;
|
|
95
|
-
}
|
|
96
|
-
return cellStr.localeCompare(smallerValue) >= 0 && cellStr.localeCompare(biggerValue) <= 0;
|
|
94
|
+
biggerValue = val2Str;
|
|
95
|
+
smallerValue = val1Str;
|
|
97
96
|
}
|
|
97
|
+
return cellStr.localeCompare(smallerValue) >= 0 && cellStr.localeCompare(biggerValue) <= 0;
|
|
98
98
|
}
|
|
99
99
|
export function getHistoryRules(fileH) {
|
|
100
100
|
var historyRules = [];
|
|
@@ -558,7 +558,7 @@ export function compute(ctx, ruleArr, d) {
|
|
|
558
558
|
if (_.isNil(cell) || _.isNil(cell.v) || isRealNull(cell.v)) {
|
|
559
559
|
continue;
|
|
560
560
|
}
|
|
561
|
-
if (conditionName === "greaterThan" && compareGreaterThan(cell.v, conditionValue0,
|
|
561
|
+
if (conditionName === "greaterThan" && compareGreaterThan(cell.v, conditionValue0, ">")) {
|
|
562
562
|
if ("".concat(r, "_").concat(c) in computeMap) {
|
|
563
563
|
computeMap["".concat(r, "_").concat(c)].textColor = textColor_1;
|
|
564
564
|
computeMap["".concat(r, "_").concat(c)].cellColor = cellColor_1;
|
|
@@ -568,7 +568,7 @@ export function compute(ctx, ruleArr, d) {
|
|
|
568
568
|
cellColor: cellColor_1
|
|
569
569
|
};
|
|
570
570
|
}
|
|
571
|
-
} else if (conditionName === "greaterThanOrEqual" && compareGreaterThan(cell.v, conditionValue0,
|
|
571
|
+
} else if (conditionName === "greaterThanOrEqual" && compareGreaterThan(cell.v, conditionValue0, ">=")) {
|
|
572
572
|
if ("".concat(r, "_").concat(c) in computeMap) {
|
|
573
573
|
computeMap["".concat(r, "_").concat(c)].textColor = textColor_1;
|
|
574
574
|
computeMap["".concat(r, "_").concat(c)].cellColor = cellColor_1;
|
|
@@ -588,7 +588,7 @@ export function compute(ctx, ruleArr, d) {
|
|
|
588
588
|
cellColor: cellColor_1
|
|
589
589
|
};
|
|
590
590
|
}
|
|
591
|
-
} else if (conditionName === "lessThanOrEqual" && compareLessThan(cell.v, conditionValue0,
|
|
591
|
+
} else if (conditionName === "lessThanOrEqual" && compareLessThan(cell.v, conditionValue0, "<=")) {
|
|
592
592
|
if ("".concat(r, "_").concat(c) in computeMap) {
|
|
593
593
|
computeMap["".concat(r, "_").concat(c)].textColor = textColor_1;
|
|
594
594
|
computeMap["".concat(r, "_").concat(c)].cellColor = cellColor_1;
|
package/es/types.d.ts
CHANGED
|
@@ -144,6 +144,18 @@ export type ConditionRulesProps = {
|
|
|
144
144
|
repeatValue: string;
|
|
145
145
|
projectValue: string;
|
|
146
146
|
};
|
|
147
|
+
export type LiveQueryData = {
|
|
148
|
+
data: {
|
|
149
|
+
row: number;
|
|
150
|
+
column: number;
|
|
151
|
+
function: string;
|
|
152
|
+
value: any;
|
|
153
|
+
id: string;
|
|
154
|
+
name: string;
|
|
155
|
+
subSheetId: string;
|
|
156
|
+
};
|
|
157
|
+
cellData: Cell;
|
|
158
|
+
};
|
|
147
159
|
export type Sheet = {
|
|
148
160
|
name: string;
|
|
149
161
|
config?: SheetConfig;
|
|
@@ -205,6 +217,7 @@ export type Sheet = {
|
|
|
205
217
|
column_focus: number;
|
|
206
218
|
};
|
|
207
219
|
};
|
|
220
|
+
liveQueryList?: Record<string, LiveQueryData>;
|
|
208
221
|
};
|
|
209
222
|
export type CommentBox = {
|
|
210
223
|
r: number;
|
package/lib/animate.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
declare class CellFadeAnimator {
|
|
2
|
+
private durationMs;
|
|
3
|
+
private active;
|
|
4
|
+
private raf;
|
|
5
|
+
private onTick;
|
|
6
|
+
constructor(durationMs?: number);
|
|
7
|
+
markChanged(sheetId: string, r: number, c: number): void;
|
|
8
|
+
alpha(sheetId: string, r: number, c: number): number;
|
|
9
|
+
setOnTick(cb: (() => void) | null): void;
|
|
10
|
+
private ensureTicking;
|
|
11
|
+
}
|
|
12
|
+
export declare const cellFadeAnimator: CellFadeAnimator;
|
|
13
|
+
export declare function markCellChanged(sheetId: string, r: number, c: number): void;
|
|
14
|
+
export {};
|
package/lib/animate.js
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.cellFadeAnimator = void 0;
|
|
7
|
+
exports.markCellChanged = markCellChanged;
|
|
8
|
+
var CellFadeAnimator = function () {
|
|
9
|
+
function CellFadeAnimator(durationMs) {
|
|
10
|
+
if (durationMs === void 0) {
|
|
11
|
+
durationMs = 350;
|
|
12
|
+
}
|
|
13
|
+
this.durationMs = durationMs;
|
|
14
|
+
this.active = new Map();
|
|
15
|
+
this.raf = null;
|
|
16
|
+
this.onTick = null;
|
|
17
|
+
this.durationMs = durationMs;
|
|
18
|
+
}
|
|
19
|
+
CellFadeAnimator.prototype.markChanged = function (sheetId, r, c) {
|
|
20
|
+
this.active.set("".concat(sheetId, ":").concat(r, ":").concat(c), {
|
|
21
|
+
start: performance.now(),
|
|
22
|
+
dur: this.durationMs
|
|
23
|
+
});
|
|
24
|
+
this.ensureTicking();
|
|
25
|
+
};
|
|
26
|
+
CellFadeAnimator.prototype.alpha = function (sheetId, r, c) {
|
|
27
|
+
var it = this.active.get("".concat(sheetId, ":").concat(r, ":").concat(c));
|
|
28
|
+
if (!it) return 1;
|
|
29
|
+
var t = Math.min(1, (performance.now() - it.start) / it.dur);
|
|
30
|
+
if (t >= 1) {
|
|
31
|
+
this.active.delete("".concat(sheetId, ":").concat(r, ":").concat(c));
|
|
32
|
+
return 1;
|
|
33
|
+
}
|
|
34
|
+
return Math.max(0.05, 1 - Math.pow(1 - t, 3));
|
|
35
|
+
};
|
|
36
|
+
CellFadeAnimator.prototype.setOnTick = function (cb) {
|
|
37
|
+
this.onTick = cb;
|
|
38
|
+
this.ensureTicking();
|
|
39
|
+
};
|
|
40
|
+
CellFadeAnimator.prototype.ensureTicking = function () {
|
|
41
|
+
var _this = this;
|
|
42
|
+
if (this.raf !== null) return;
|
|
43
|
+
if (this.active.size === 0 && !this.onTick) return;
|
|
44
|
+
var _loop = function loop() {
|
|
45
|
+
var _a;
|
|
46
|
+
_this.raf = null;
|
|
47
|
+
if (_this.active.size > 0) (_a = _this.onTick) === null || _a === void 0 ? void 0 : _a.call(_this);
|
|
48
|
+
if (_this.active.size > 0 || _this.onTick) {
|
|
49
|
+
_this.raf = requestAnimationFrame(_loop);
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
this.raf = requestAnimationFrame(_loop);
|
|
53
|
+
};
|
|
54
|
+
return CellFadeAnimator;
|
|
55
|
+
}();
|
|
56
|
+
var cellFadeAnimator = exports.cellFadeAnimator = new CellFadeAnimator(4000);
|
|
57
|
+
function markCellChanged(sheetId, r, c) {
|
|
58
|
+
cellFadeAnimator.markChanged(sheetId, r, c);
|
|
59
|
+
}
|
package/lib/api/common.d.ts
CHANGED
package/lib/canvas.js
CHANGED
|
@@ -12,6 +12,7 @@ var _inlineString = require("./modules/inline-string");
|
|
|
12
12
|
var _utils = require("./utils");
|
|
13
13
|
var _border = require("./modules/border");
|
|
14
14
|
var _modules = require("./modules");
|
|
15
|
+
var _animate = require("./animate");
|
|
15
16
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
16
17
|
var defaultStyle = exports.defaultStyle = {
|
|
17
18
|
fillStyle: "#000000",
|
|
@@ -767,7 +768,16 @@ var Canvas = exports.Canvas = function () {
|
|
|
767
768
|
var horizonAlignPos = startX + 4 + offsetLeft;
|
|
768
769
|
var verticalAlignPos = endY + offsetTop - 2;
|
|
769
770
|
renderCtx.textBaseline = "bottom";
|
|
770
|
-
|
|
771
|
+
var sheetId = this.sheetCtx.currentSheetId;
|
|
772
|
+
var a = _animate.cellFadeAnimator.alpha(sheetId, r, c);
|
|
773
|
+
if (a < 0.999) {
|
|
774
|
+
renderCtx.save();
|
|
775
|
+
renderCtx.globalAlpha = a;
|
|
776
|
+
renderCtx.fillText(_lodash.default.isNil(value) ? "" : value, horizonAlignPos, verticalAlignPos);
|
|
777
|
+
renderCtx.restore();
|
|
778
|
+
} else {
|
|
779
|
+
renderCtx.fillText(_lodash.default.isNil(value) ? "" : value, horizonAlignPos, verticalAlignPos);
|
|
780
|
+
}
|
|
771
781
|
}
|
|
772
782
|
if ((_d = (_c = flowdata === null || flowdata === void 0 ? void 0 : flowdata[r]) === null || _c === void 0 ? void 0 : _c[c]) === null || _d === void 0 ? void 0 : _d.ps) {
|
|
773
783
|
var ps_w = 12 * this.sheetCtx.zoomRatio;
|
|
@@ -1072,10 +1082,22 @@ var Canvas = exports.Canvas = function () {
|
|
|
1072
1082
|
if (((_j = (_h = (_g = cell === null || cell === void 0 ? void 0 : cell.ct) === null || _g === void 0 ? void 0 : _g.fa) === null || _h === void 0 ? void 0 : _h.indexOf("[Red]")) !== null && _j !== void 0 ? _j : -1) > -1 && ((_k = cell === null || cell === void 0 ? void 0 : cell.ct) === null || _k === void 0 ? void 0 : _k.t) === "n" && (cell === null || cell === void 0 ? void 0 : cell.v) < 0) {
|
|
1073
1083
|
renderCtx.fillStyle = "#ff0000";
|
|
1074
1084
|
}
|
|
1075
|
-
this.
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1085
|
+
var sheetId = this.sheetCtx.currentSheetId;
|
|
1086
|
+
var a = _animate.cellFadeAnimator.alpha(sheetId, r, c);
|
|
1087
|
+
if (a < 0.999) {
|
|
1088
|
+
renderCtx.save();
|
|
1089
|
+
renderCtx.globalAlpha = a;
|
|
1090
|
+
this.cellTextRender(textInfo, renderCtx, {
|
|
1091
|
+
pos_x: pos_x,
|
|
1092
|
+
pos_y: pos_y
|
|
1093
|
+
});
|
|
1094
|
+
renderCtx.restore();
|
|
1095
|
+
} else {
|
|
1096
|
+
this.cellTextRender(textInfo, renderCtx, {
|
|
1097
|
+
pos_x: pos_x,
|
|
1098
|
+
pos_y: pos_y
|
|
1099
|
+
});
|
|
1100
|
+
}
|
|
1079
1101
|
renderCtx.restore();
|
|
1080
1102
|
}
|
|
1081
1103
|
if (cellOverflow_bd_r_render) {
|
|
@@ -1157,10 +1179,22 @@ var Canvas = exports.Canvas = function () {
|
|
|
1157
1179
|
if (checksCF === null || checksCF === void 0 ? void 0 : checksCF.textColor) {
|
|
1158
1180
|
renderCtx.fillStyle = checksCF.textColor;
|
|
1159
1181
|
}
|
|
1160
|
-
this.
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1182
|
+
var sheetId = this.sheetCtx.currentSheetId;
|
|
1183
|
+
var a = _animate.cellFadeAnimator.alpha(sheetId, r, c);
|
|
1184
|
+
if (a < 0.999) {
|
|
1185
|
+
renderCtx.save();
|
|
1186
|
+
renderCtx.globalAlpha = a;
|
|
1187
|
+
this.cellTextRender(textInfo, renderCtx, {
|
|
1188
|
+
pos_x: pos_x,
|
|
1189
|
+
pos_y: pos_y
|
|
1190
|
+
});
|
|
1191
|
+
renderCtx.restore();
|
|
1192
|
+
} else {
|
|
1193
|
+
this.cellTextRender(textInfo, renderCtx, {
|
|
1194
|
+
pos_x: pos_x,
|
|
1195
|
+
pos_y: pos_y
|
|
1196
|
+
});
|
|
1197
|
+
}
|
|
1164
1198
|
renderCtx.restore();
|
|
1165
1199
|
};
|
|
1166
1200
|
Canvas.prototype.cellOverflow_trace = function (r, curC, traceC, traceDir, horizonAlign, textMetrics) {
|
package/lib/index.d.ts
CHANGED
package/lib/index.js
CHANGED
|
@@ -106,4 +106,16 @@ Object.keys(_types).forEach(function (key) {
|
|
|
106
106
|
}
|
|
107
107
|
});
|
|
108
108
|
});
|
|
109
|
+
var _animate = require("./animate");
|
|
110
|
+
Object.keys(_animate).forEach(function (key) {
|
|
111
|
+
if (key === "default" || key === "__esModule") return;
|
|
112
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
113
|
+
if (key in exports && exports[key] === _animate[key]) return;
|
|
114
|
+
Object.defineProperty(exports, key, {
|
|
115
|
+
enumerable: true,
|
|
116
|
+
get: function get() {
|
|
117
|
+
return _animate[key];
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
});
|
|
109
121
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
@@ -38,20 +38,20 @@ function compareGreaterThan(cellValue, conditionValue, symbol) {
|
|
|
38
38
|
var cellStr = String(cellValue);
|
|
39
39
|
var conditionStr = String(conditionValue);
|
|
40
40
|
if (hasAlphabeticChars(cellValue) || hasAlphabeticChars(conditionValue)) {
|
|
41
|
-
if (symbol ===
|
|
41
|
+
if (symbol === ">=") {
|
|
42
42
|
return cellStr.localeCompare(conditionStr) >= 0;
|
|
43
43
|
}
|
|
44
44
|
return cellStr.localeCompare(conditionStr) > 0;
|
|
45
45
|
}
|
|
46
46
|
var cellNum = Number(cellValue);
|
|
47
47
|
var conditionNum = Number(conditionValue);
|
|
48
|
-
if (!Number.isNaN(cellNum) && !Number.isNaN(conditionNum) && symbol ===
|
|
48
|
+
if (!Number.isNaN(cellNum) && !Number.isNaN(conditionNum) && symbol === ">=") {
|
|
49
49
|
return cellNum >= conditionNum;
|
|
50
50
|
}
|
|
51
|
-
if (!Number.isNaN(cellNum) && !Number.isNaN(conditionNum) && symbol ===
|
|
51
|
+
if (!Number.isNaN(cellNum) && !Number.isNaN(conditionNum) && symbol === ">") {
|
|
52
52
|
return cellNum > conditionNum;
|
|
53
53
|
}
|
|
54
|
-
if (symbol ===
|
|
54
|
+
if (symbol === ">=") {
|
|
55
55
|
return cellStr.localeCompare(conditionStr) >= 0;
|
|
56
56
|
}
|
|
57
57
|
return cellStr.localeCompare(conditionStr) > 0;
|
|
@@ -60,20 +60,20 @@ function compareLessThan(cellValue, conditionValue, symbol) {
|
|
|
60
60
|
var cellStr = String(cellValue);
|
|
61
61
|
var conditionStr = String(conditionValue);
|
|
62
62
|
if (hasAlphabeticChars(cellValue) || hasAlphabeticChars(conditionValue)) {
|
|
63
|
-
if (symbol ===
|
|
63
|
+
if (symbol === "<=") {
|
|
64
64
|
return cellStr.localeCompare(conditionStr) <= 0;
|
|
65
65
|
}
|
|
66
66
|
return cellStr.localeCompare(conditionStr) < 0;
|
|
67
67
|
}
|
|
68
68
|
var cellNum = Number(cellValue);
|
|
69
69
|
var conditionNum = Number(conditionValue);
|
|
70
|
-
if (!Number.isNaN(cellNum) && !Number.isNaN(conditionNum) && symbol ===
|
|
70
|
+
if (!Number.isNaN(cellNum) && !Number.isNaN(conditionNum) && symbol === "<=") {
|
|
71
71
|
return cellNum <= conditionNum;
|
|
72
72
|
}
|
|
73
73
|
if (!Number.isNaN(cellNum) && !Number.isNaN(conditionNum)) {
|
|
74
74
|
return cellNum < conditionNum;
|
|
75
75
|
}
|
|
76
|
-
if (symbol ===
|
|
76
|
+
if (symbol === "<=") {
|
|
77
77
|
return cellStr.localeCompare(conditionStr) <= 0;
|
|
78
78
|
}
|
|
79
79
|
return cellStr.localeCompare(conditionStr) < 0;
|
|
@@ -82,7 +82,8 @@ function compareBetween(cellValue, value1, value2) {
|
|
|
82
82
|
var cellStr = String(cellValue);
|
|
83
83
|
var val1Str = String(value1);
|
|
84
84
|
var val2Str = String(value2);
|
|
85
|
-
var smallerValue
|
|
85
|
+
var smallerValue;
|
|
86
|
+
var biggerValue;
|
|
86
87
|
if (hasAlphabeticChars(value1) || hasAlphabeticChars(value2) || hasAlphabeticChars(cellValue)) {
|
|
87
88
|
if (val1Str.localeCompare(val2Str) > 0) {
|
|
88
89
|
biggerValue = val1Str;
|
|
@@ -92,24 +93,23 @@ function compareBetween(cellValue, value1, value2) {
|
|
|
92
93
|
smallerValue = val1Str;
|
|
93
94
|
}
|
|
94
95
|
return cellStr.localeCompare(smallerValue) >= 0 && cellStr.localeCompare(biggerValue) <= 0;
|
|
96
|
+
}
|
|
97
|
+
var cellNum = Number(cellValue);
|
|
98
|
+
var val1Num = Number(value1);
|
|
99
|
+
var val2Num = Number(value2);
|
|
100
|
+
if (!Number.isNaN(cellNum) && !Number.isNaN(val1Num) && !Number.isNaN(val2Num)) {
|
|
101
|
+
var smallerNum = Math.min(val1Num, val2Num);
|
|
102
|
+
var biggerNum = Math.max(val1Num, val2Num);
|
|
103
|
+
return cellNum >= smallerNum && cellNum <= biggerNum;
|
|
104
|
+
}
|
|
105
|
+
if (val1Str.localeCompare(val2Str) > 0) {
|
|
106
|
+
biggerValue = val1Str;
|
|
107
|
+
smallerValue = val2Str;
|
|
95
108
|
} else {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
var val2Num = Number(value2);
|
|
99
|
-
if (!Number.isNaN(cellNum) && !Number.isNaN(val1Num) && !Number.isNaN(val2Num)) {
|
|
100
|
-
var smallerNum = Math.min(val1Num, val2Num);
|
|
101
|
-
var biggerNum = Math.max(val1Num, val2Num);
|
|
102
|
-
return cellNum >= smallerNum && cellNum <= biggerNum;
|
|
103
|
-
}
|
|
104
|
-
if (val1Str.localeCompare(val2Str) > 0) {
|
|
105
|
-
biggerValue = val1Str;
|
|
106
|
-
smallerValue = val2Str;
|
|
107
|
-
} else {
|
|
108
|
-
biggerValue = val2Str;
|
|
109
|
-
smallerValue = val1Str;
|
|
110
|
-
}
|
|
111
|
-
return cellStr.localeCompare(smallerValue) >= 0 && cellStr.localeCompare(biggerValue) <= 0;
|
|
109
|
+
biggerValue = val2Str;
|
|
110
|
+
smallerValue = val1Str;
|
|
112
111
|
}
|
|
112
|
+
return cellStr.localeCompare(smallerValue) >= 0 && cellStr.localeCompare(biggerValue) <= 0;
|
|
113
113
|
}
|
|
114
114
|
function getHistoryRules(fileH) {
|
|
115
115
|
var historyRules = [];
|
|
@@ -573,7 +573,7 @@ function compute(ctx, ruleArr, d) {
|
|
|
573
573
|
if (_lodash.default.isNil(cell) || _lodash.default.isNil(cell.v) || (0, _validation.isRealNull)(cell.v)) {
|
|
574
574
|
continue;
|
|
575
575
|
}
|
|
576
|
-
if (conditionName === "greaterThan" && compareGreaterThan(cell.v, conditionValue0,
|
|
576
|
+
if (conditionName === "greaterThan" && compareGreaterThan(cell.v, conditionValue0, ">")) {
|
|
577
577
|
if ("".concat(r, "_").concat(c) in computeMap) {
|
|
578
578
|
computeMap["".concat(r, "_").concat(c)].textColor = textColor_1;
|
|
579
579
|
computeMap["".concat(r, "_").concat(c)].cellColor = cellColor_1;
|
|
@@ -583,7 +583,7 @@ function compute(ctx, ruleArr, d) {
|
|
|
583
583
|
cellColor: cellColor_1
|
|
584
584
|
};
|
|
585
585
|
}
|
|
586
|
-
} else if (conditionName === "greaterThanOrEqual" && compareGreaterThan(cell.v, conditionValue0,
|
|
586
|
+
} else if (conditionName === "greaterThanOrEqual" && compareGreaterThan(cell.v, conditionValue0, ">=")) {
|
|
587
587
|
if ("".concat(r, "_").concat(c) in computeMap) {
|
|
588
588
|
computeMap["".concat(r, "_").concat(c)].textColor = textColor_1;
|
|
589
589
|
computeMap["".concat(r, "_").concat(c)].cellColor = cellColor_1;
|
|
@@ -603,7 +603,7 @@ function compute(ctx, ruleArr, d) {
|
|
|
603
603
|
cellColor: cellColor_1
|
|
604
604
|
};
|
|
605
605
|
}
|
|
606
|
-
} else if (conditionName === "lessThanOrEqual" && compareLessThan(cell.v, conditionValue0,
|
|
606
|
+
} else if (conditionName === "lessThanOrEqual" && compareLessThan(cell.v, conditionValue0, "<=")) {
|
|
607
607
|
if ("".concat(r, "_").concat(c) in computeMap) {
|
|
608
608
|
computeMap["".concat(r, "_").concat(c)].textColor = textColor_1;
|
|
609
609
|
computeMap["".concat(r, "_").concat(c)].cellColor = cellColor_1;
|
package/lib/types.d.ts
CHANGED
|
@@ -144,6 +144,18 @@ export type ConditionRulesProps = {
|
|
|
144
144
|
repeatValue: string;
|
|
145
145
|
projectValue: string;
|
|
146
146
|
};
|
|
147
|
+
export type LiveQueryData = {
|
|
148
|
+
data: {
|
|
149
|
+
row: number;
|
|
150
|
+
column: number;
|
|
151
|
+
function: string;
|
|
152
|
+
value: any;
|
|
153
|
+
id: string;
|
|
154
|
+
name: string;
|
|
155
|
+
subSheetId: string;
|
|
156
|
+
};
|
|
157
|
+
cellData: Cell;
|
|
158
|
+
};
|
|
147
159
|
export type Sheet = {
|
|
148
160
|
name: string;
|
|
149
161
|
config?: SheetConfig;
|
|
@@ -205,6 +217,7 @@ export type Sheet = {
|
|
|
205
217
|
column_focus: number;
|
|
206
218
|
};
|
|
207
219
|
};
|
|
220
|
+
liveQueryList?: Record<string, LiveQueryData>;
|
|
208
221
|
};
|
|
209
222
|
export type CommentBox = {
|
|
210
223
|
r: number;
|