@univerjs/sheets-conditional-formatting 0.2.1 → 0.2.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/README.md +11 -4
- package/lib/cjs/index.js +1 -1
- package/lib/es/index.js +28 -25
- package/lib/types/services/conditional-formatting-formula.service.d.ts +1 -0
- package/lib/umd/index.js +1 -1
- package/package.json +11 -11
package/lib/es/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
var CA = Object.defineProperty;
|
|
2
2
|
var YA = (f, v, e) => v in f ? CA(f, v, { enumerable: !0, configurable: !0, writable: !0, value: e }) : f[v] = e;
|
|
3
3
|
var D = (f, v, e) => YA(f, typeof v != "symbol" ? v + "" : v, e);
|
|
4
|
-
import { Tools as _, ObjectMatrix as Y, Range as W, CommandType as vA, ICommandService as PA, Disposable as WA, toDisposable as OA, RefAlias as
|
|
4
|
+
import { Tools as _, ObjectMatrix as Y, Range as W, CommandType as vA, ICommandService as PA, Disposable as WA, toDisposable as OA, RefAlias as hA, CellValueType as c, BooleanNumber as EA, ColorKit as JA, Rectangle as R, createInterceptorKey as jA, OnLifecycle as UA, LifecycleStages as RA, IUniverInstanceService as MA, IResourceManagerService as VA, afterInitApply as bA, InterceptorManager as FA, UniverInstanceType as NA, Plugin as IA } from "@univerjs/core";
|
|
5
5
|
import { Inject as J, Injector as XA } from "@wendellhu/redi";
|
|
6
6
|
import { SheetInterceptorService as zA, RemoveSheetCommand as qA, ReorderRangeMutation as KA, MoveRangeMutation as yA, MoveColsMutation as xA, MoveRowsMutation as GA, InsertRowMutation as _A, RemoveRowMutation as $A, RemoveColMutation as Av, InsertColMutation as vv, SetRangeValuesMutation as ev } from "@univerjs/sheets";
|
|
7
7
|
import { Subject as LA } from "rxjs";
|
|
@@ -10,7 +10,7 @@ import { IActiveDirtyManagerService as nv, SetFormulaCalculationResultMutation a
|
|
|
10
10
|
import E from "dayjs";
|
|
11
11
|
import { isObject as kv, SpreadsheetExtensionRegistry as aA, SheetExtension as sA, FIX_ONE_PIXEL_BLUR_OFFSET as wv } from "@univerjs/engine-render";
|
|
12
12
|
const oA = "SHEET_CONDITIONAL_FORMATTING_PLUGIN";
|
|
13
|
-
var o = /* @__PURE__ */ ((f) => (f.beginsWith = "beginsWith", f.endsWith = "endsWith", f.containsText = "containsText", f.notContainsText = "notContainsText", f.equal = "equal", f.notEqual = "notEqual", f.containsBlanks = "containsBlanks", f.notContainsBlanks = "notContainsBlanks", f.containsErrors = "containsErrors", f.notContainsErrors = "notContainsErrors", f))(o || {}), g = /* @__PURE__ */ ((f) => (f.today = "today", f.yesterday = "yesterday", f.tomorrow = "tomorrow", f.last7Days = "last7Days", f.thisMonth = "thisMonth", f.lastMonth = "lastMonth", f.nextMonth = "nextMonth", f.thisWeek = "thisWeek", f.lastWeek = "lastWeek", f.nextWeek = "nextWeek", f))(g || {}), H = /* @__PURE__ */ ((f) => (f.greaterThan = "greaterThan", f.greaterThanOrEqual = "greaterThanOrEqual", f.lessThan = "lessThan", f.lessThanOrEqual = "lessThanOrEqual", f.notBetween = "notBetween", f.between = "between", f.equal = "equal", f.notEqual = "notEqual", f))(H || {}),
|
|
13
|
+
var o = /* @__PURE__ */ ((f) => (f.beginsWith = "beginsWith", f.endsWith = "endsWith", f.containsText = "containsText", f.notContainsText = "notContainsText", f.equal = "equal", f.notEqual = "notEqual", f.containsBlanks = "containsBlanks", f.notContainsBlanks = "notContainsBlanks", f.containsErrors = "containsErrors", f.notContainsErrors = "notContainsErrors", f))(o || {}), g = /* @__PURE__ */ ((f) => (f.today = "today", f.yesterday = "yesterday", f.tomorrow = "tomorrow", f.last7Days = "last7Days", f.thisMonth = "thisMonth", f.lastMonth = "lastMonth", f.nextMonth = "nextMonth", f.thisWeek = "thisWeek", f.lastWeek = "lastWeek", f.nextWeek = "nextWeek", f))(g || {}), H = /* @__PURE__ */ ((f) => (f.greaterThan = "greaterThan", f.greaterThanOrEqual = "greaterThanOrEqual", f.lessThan = "lessThan", f.lessThanOrEqual = "lessThanOrEqual", f.notBetween = "notBetween", f.between = "between", f.equal = "equal", f.notEqual = "notEqual", f))(H || {}), j = /* @__PURE__ */ ((f) => (f.highlightCell = "highlightCell", f.dataBar = "dataBar", f.colorScale = "colorScale", f.iconSet = "iconSet", f))(j || {}), a = /* @__PURE__ */ ((f) => (f.uniqueValues = "uniqueValues", f.duplicateValues = "duplicateValues", f.rank = "rank", f.text = "text", f.timePeriod = "timePeriod", f.number = "number", f.average = "average", f.formula = "formula", f))(a || {}), z = /* @__PURE__ */ ((f) => (f.num = "num", f.min = "min", f.max = "max", f.percent = "percent", f.percentile = "percentile", f.formula = "formula", f))(z || {});
|
|
14
14
|
const re = "#fff", He = "#000000", Qe = () => ({
|
|
15
15
|
cfId: void 0,
|
|
16
16
|
ranges: [],
|
|
@@ -413,6 +413,9 @@ let M = class extends WA {
|
|
|
413
413
|
this._cache.clear(), this._formulaMap.clear();
|
|
414
414
|
}));
|
|
415
415
|
}
|
|
416
|
+
dispose() {
|
|
417
|
+
this._formulaChange$.complete();
|
|
418
|
+
}
|
|
416
419
|
_initCache() {
|
|
417
420
|
const v = this._injector.get(G);
|
|
418
421
|
this.disposeWithMe(v.ruleComputeStatus$.subscribe((e) => {
|
|
@@ -484,7 +487,7 @@ let M = class extends WA {
|
|
|
484
487
|
let A = this._formulaMap.get(v);
|
|
485
488
|
A || (A = /* @__PURE__ */ new Map(), this._formulaMap.set(v, A));
|
|
486
489
|
let Z = A.get(e);
|
|
487
|
-
return Z || (Z = new
|
|
490
|
+
return Z || (Z = new hA([], ["formulaId", "formulaText"]), A.set(e, Z)), Z;
|
|
488
491
|
}
|
|
489
492
|
_ensureCacheMap(v, e) {
|
|
490
493
|
let A = this._cache.get(v);
|
|
@@ -735,7 +738,7 @@ const av = (f) => {
|
|
|
735
738
|
}).filter((A) => !!A), K = {};
|
|
736
739
|
Object.freeze(K);
|
|
737
740
|
const gv = {
|
|
738
|
-
type:
|
|
741
|
+
type: j.dataBar,
|
|
739
742
|
handle: async (f, v) => {
|
|
740
743
|
const e = f.rule, A = v.accessor.get(M), { worksheet: Z } = v, n = new Y(), m = tA(f.ranges, Z.getMaxRows() - 1, Z.getMaxColumns() - 1);
|
|
741
744
|
m.forEach((t) => {
|
|
@@ -804,7 +807,7 @@ const gv = {
|
|
|
804
807
|
return T;
|
|
805
808
|
}
|
|
806
809
|
}, cv = {
|
|
807
|
-
type:
|
|
810
|
+
type: j.highlightCell,
|
|
808
811
|
handle: async (f, v) => {
|
|
809
812
|
const e = f.rule, { worksheet: A } = v, Z = tA(f.ranges, A.getMaxRows() - 1, A.getMaxColumns() - 1), m = (() => {
|
|
810
813
|
switch (e.subType) {
|
|
@@ -977,7 +980,7 @@ const gv = {
|
|
|
977
980
|
return !1;
|
|
978
981
|
const { unitId: k, subUnitId: w } = v, L = v.accessor.get(M), t = (p, Q) => ({ startRow: p, endRow: p, startColumn: Q, endColumn: Q }), B = t(f.ranges[0].startRow, f.ranges[0].startColumn), d = _.deepClone(m.sequenceNodes), r = Array.isArray(d) ? d.map((p) => {
|
|
979
982
|
if (typeof p == "object" && p.nodeType === Nv.REFERENCE) {
|
|
980
|
-
const Q = Xv(p.token), i = R.getRelativeRange(Q.range, B),
|
|
983
|
+
const Q = Xv(p.token), i = R.getRelativeRange(Q.range, B), h = R.getPositionRange(i, t(S, N), Q.range), y = Lv(h);
|
|
981
984
|
return {
|
|
982
985
|
...p,
|
|
983
986
|
token: y
|
|
@@ -1007,7 +1010,7 @@ const gv = {
|
|
|
1007
1010
|
}), l;
|
|
1008
1011
|
}
|
|
1009
1012
|
}, Cv = "", Yv = {
|
|
1010
|
-
type:
|
|
1013
|
+
type: j.colorScale,
|
|
1011
1014
|
handle: async (f, v) => {
|
|
1012
1015
|
var X;
|
|
1013
1016
|
const e = f.rule, A = v.accessor.get(M), { worksheet: Z } = v, n = new Y(), m = tA(f.ranges, Z.getMaxRows() - 1, Z.getMaxColumns() - 1);
|
|
@@ -1042,7 +1045,7 @@ const gv = {
|
|
|
1042
1045
|
}), T;
|
|
1043
1046
|
}
|
|
1044
1047
|
}, Ov = {
|
|
1045
|
-
type:
|
|
1048
|
+
type: j.iconSet,
|
|
1046
1049
|
handle: async (f, v) => {
|
|
1047
1050
|
var k;
|
|
1048
1051
|
const e = f.rule, A = v.accessor.get(M), { worksheet: Z } = v, n = new Y(), m = tA(f.ranges, Z.getMaxRows() - 1, Z.getMaxColumns() - 1);
|
|
@@ -1099,12 +1102,12 @@ const gv = {
|
|
|
1099
1102
|
}), T;
|
|
1100
1103
|
}
|
|
1101
1104
|
};
|
|
1102
|
-
var
|
|
1103
|
-
for (var Z = A > 1 ? void 0 : A ?
|
|
1105
|
+
var hv = Object.defineProperty, jv = Object.getOwnPropertyDescriptor, Uv = (f, v, e, A) => {
|
|
1106
|
+
for (var Z = A > 1 ? void 0 : A ? jv(v, e) : v, n = f.length - 1, m; n >= 0; n--)
|
|
1104
1107
|
(m = f[n]) && (Z = (A ? m(v, e, Z) : m(Z)) || Z);
|
|
1105
|
-
return A && Z &&
|
|
1108
|
+
return A && Z && hv(v, e, Z), Z;
|
|
1106
1109
|
}, I = (f, v) => (e, A) => v(e, A, f);
|
|
1107
|
-
const Rv =
|
|
1110
|
+
const Rv = jA("conditional-formatting-before-update-rule-result");
|
|
1108
1111
|
let G = class extends WA {
|
|
1109
1112
|
constructor(v, e, A, Z, n, m, T) {
|
|
1110
1113
|
super();
|
|
@@ -1124,15 +1127,15 @@ let G = class extends WA {
|
|
|
1124
1127
|
return T > -1 && m.splice(T + 1), m.reduce((S, N) => {
|
|
1125
1128
|
var w;
|
|
1126
1129
|
const X = N.rule.type, k = n.cfList.find((L) => L.cfId === N.cfId);
|
|
1127
|
-
if (k != null && k.isDirty && this._handleCalculateUnit(v, e, N), X ===
|
|
1130
|
+
if (k != null && k.isDirty && this._handleCalculateUnit(v, e, N), X === j.highlightCell)
|
|
1128
1131
|
k.ruleCache && _.deepMerge(S, { style: k.ruleCache });
|
|
1129
|
-
else if (X ===
|
|
1132
|
+
else if (X === j.colorScale) {
|
|
1130
1133
|
const L = k == null ? void 0 : k.ruleCache;
|
|
1131
1134
|
L && (S.style = { ...(w = S.style) != null ? w : {}, bg: { rgb: L } });
|
|
1132
|
-
} else if (X ===
|
|
1135
|
+
} else if (X === j.dataBar) {
|
|
1133
1136
|
const L = k == null ? void 0 : k.ruleCache;
|
|
1134
1137
|
L && L !== K && (S.dataBar = L, S.isShowValue = L.isShowValue);
|
|
1135
|
-
} else if (X ===
|
|
1138
|
+
} else if (X === j.iconSet) {
|
|
1136
1139
|
const L = k == null ? void 0 : k.ruleCache;
|
|
1137
1140
|
L && L !== K && (S.iconSet = L, S.isShowValue = L.isShowValue);
|
|
1138
1141
|
}
|
|
@@ -1444,12 +1447,12 @@ class yv extends sA {
|
|
|
1444
1447
|
if (!l.getColVisible(X) || !l.getRowRawVisible(N))
|
|
1445
1448
|
return;
|
|
1446
1449
|
const { color: w, value: L, startPoint: t, isGradient: B } = k.dataBar, d = this.getCellIndex(N, X, m, T, S);
|
|
1447
|
-
let { isMerged: r, isMergedMainCell: u, mergeInfo: p, startY: Q, endY: i, startX:
|
|
1448
|
-
if (r || (u && (Q = p.startY, i = p.endY,
|
|
1450
|
+
let { isMerged: r, isMergedMainCell: u, mergeInfo: p, startY: Q, endY: i, startX: h, endX: y } = d;
|
|
1451
|
+
if (r || (u && (Q = p.startY, i = p.endY, h = p.startX, y = p.endX), !this.isRenderDiffRangesByCell(p, n)))
|
|
1449
1452
|
return;
|
|
1450
|
-
const ZA = y -
|
|
1453
|
+
const ZA = y - h, kA = i + wv - Q, fA = ZA - this._paddingRightAndLeft * 2, pA = kA - this._paddingTopAndBottom * 2;
|
|
1451
1454
|
if (L > 0) {
|
|
1452
|
-
const x = Math.max(fA * (1 - t / 100) * L / 100, 1), V =
|
|
1455
|
+
const x = Math.max(fA * (1 - t / 100) * L / 100, 1), V = h + this._paddingRightAndLeft + t / 100 * fA, b = Q + this._paddingTopAndBottom;
|
|
1453
1456
|
if (B) {
|
|
1454
1457
|
const F = e.createLinearGradient(V, b, V + x, b);
|
|
1455
1458
|
F.addColorStop(0, w), F.addColorStop(1, "rgb(255 255 255)"), e.fillStyle = F, e.strokeStyle = w, e.lineWidth = 1;
|
|
@@ -1457,7 +1460,7 @@ class yv extends sA {
|
|
|
1457
1460
|
e.fillStyle = w;
|
|
1458
1461
|
this._drawRectWithRoundedCorner(e, V, b, x, pA, !1, !0, !0, !1), B && e.stroke();
|
|
1459
1462
|
} else {
|
|
1460
|
-
const x = Math.max(fA * t / 100 * Math.abs(L) / 100, 1), V =
|
|
1463
|
+
const x = Math.max(fA * t / 100 * Math.abs(L) / 100, 1), V = h + this._paddingRightAndLeft + t / 100 * fA - x, b = Q + this._paddingTopAndBottom;
|
|
1461
1464
|
if (B) {
|
|
1462
1465
|
const F = e.createLinearGradient(V, b, V + x, b);
|
|
1463
1466
|
F.addColorStop(0, "rgb(255 255 255)"), F.addColorStop(1, w), e.fillStyle = F, e.strokeStyle = w, e.lineWidth = 1;
|
|
@@ -1671,10 +1674,10 @@ class Le extends sA {
|
|
|
1671
1674
|
if (!t)
|
|
1672
1675
|
return;
|
|
1673
1676
|
const B = this.getCellIndex(N, X, m, T, S);
|
|
1674
|
-
let { isMerged: d, isMergedMainCell: r, mergeInfo: u, startY: p, endY: Q, startX: i, endX:
|
|
1675
|
-
if (d || (r && (p = u.startY, Q = u.endY, i = u.startX,
|
|
1677
|
+
let { isMerged: d, isMergedMainCell: r, mergeInfo: u, startY: p, endY: Q, startX: i, endX: h } = B;
|
|
1678
|
+
if (d || (r && (p = u.startY, Q = u.endY, i = u.startX, h = u.endX), !this.isRenderDiffRangesByCell(u, n)))
|
|
1676
1679
|
return;
|
|
1677
|
-
const y =
|
|
1680
|
+
const y = h - i, ZA = Q - p;
|
|
1678
1681
|
if (this._width > ZA || this._width > y + this._paddingRightAndLeft * 2)
|
|
1679
1682
|
return;
|
|
1680
1683
|
const kA = (ZA - this._width) / 2 + p;
|
|
@@ -1700,7 +1703,7 @@ export {
|
|
|
1700
1703
|
gA as AddConditionalRuleMutation,
|
|
1701
1704
|
ie as AddConditionalRuleMutationUndoFactory,
|
|
1702
1705
|
H as CFNumberOperator,
|
|
1703
|
-
|
|
1706
|
+
j as CFRuleType,
|
|
1704
1707
|
a as CFSubRuleType,
|
|
1705
1708
|
o as CFTextOperator,
|
|
1706
1709
|
g as CFTimePeriodOperator,
|
|
@@ -35,6 +35,7 @@ export declare class ConditionalFormattingFormulaService extends Disposable {
|
|
|
35
35
|
formulaId: string;
|
|
36
36
|
}>;
|
|
37
37
|
constructor(_commandService: ICommandService, _injector: Injector, _activeDirtyManagerService: IActiveDirtyManagerService, _conditionalFormattingViewModel: ConditionalFormattingViewModel, _conditionalFormattingRuleModel: ConditionalFormattingRuleModel);
|
|
38
|
+
dispose(): void;
|
|
38
39
|
private _initCache;
|
|
39
40
|
private _initRuleChange;
|
|
40
41
|
private _initFormulaCalculationResultChange;
|