@univerjs/sheets-conditional-formatting 0.2.11 → 0.2.13
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/lib/cjs/index.js +1 -1
- package/lib/es/index.js +22 -15
- package/lib/types/base/const.d.ts +1 -1
- package/lib/types/controllers/config.schema.d.ts +20 -0
- package/lib/types/plugin.d.ts +5 -2
- package/lib/types/render/data-bar.render.d.ts +2 -2
- package/lib/types/render/icon.render.d.ts +2 -2
- package/lib/types/services/__test__/calculate.databar.spec.d.ts +16 -0
- package/lib/types/services/__test__/test.util.d.ts +6 -6
- package/lib/umd/index.js +1 -1
- package/package.json +16 -16
package/lib/es/index.js
CHANGED
|
@@ -2,7 +2,7 @@ var __defProp = Object.defineProperty;
|
|
|
2
2
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value;
|
|
3
3
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: !0 });
|
|
4
4
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key != "symbol" ? key + "" : key, value);
|
|
5
|
-
import { Tools, Inject, Injector, CommandType, ObjectMatrix, Range, ICommandService, Disposable, toDisposable, RefAlias, CellValueType, BooleanNumber, ColorKit, Rectangle, createInterceptorKey, OnLifecycle, LifecycleStages, IUniverInstanceService, IResourceManagerService, InterceptorManager, UniverInstanceType, Plugin } from "@univerjs/core";
|
|
5
|
+
import { Tools, Inject, Injector, CommandType, ObjectMatrix, Range, ICommandService, Disposable, toDisposable, RefAlias, CellValueType, BooleanNumber, ColorKit, Rectangle, createInterceptorKey, OnLifecycle, LifecycleStages, IUniverInstanceService, IResourceManagerService, InterceptorManager, UniverInstanceType, Plugin, IConfigService } from "@univerjs/core";
|
|
6
6
|
import { SheetInterceptorService, RemoveSheetCommand, ReorderRangeMutation, MoveRangeMutation, MoveColsMutation, MoveRowsMutation, InsertRowMutation, RemoveRowMutation, RemoveColMutation, InsertColMutation, SetRangeValuesMutation } from "@univerjs/sheets";
|
|
7
7
|
import { Subject, Observable } from "rxjs";
|
|
8
8
|
import { bufferTime, filter, map } from "rxjs/operators";
|
|
@@ -565,16 +565,17 @@ const dataBarUKey = "sheet-conditional-rule-data-bar", defaultDataBarPositiveCol
|
|
|
565
565
|
__publicField(this, "Z_INDEX", EXTENSION_Z_INDEX$1);
|
|
566
566
|
__publicField(this, "_radius", 1);
|
|
567
567
|
}
|
|
568
|
-
|
|
568
|
+
// eslint-disable-next-line max-lines-per-function
|
|
569
|
+
draw(ctx, _parentScale, spreadsheetSkeleton, diffRanges) {
|
|
569
570
|
const { rowHeightAccumulation, columnWidthAccumulation, worksheet, dataMergeCache } = spreadsheetSkeleton;
|
|
570
571
|
if (!worksheet)
|
|
571
572
|
return !1;
|
|
572
573
|
ctx.save(), Range.foreach(spreadsheetSkeleton.rowColumnSegment, (row, col) => {
|
|
574
|
+
if (!worksheet.getRowVisible(row) || !worksheet.getColVisible(col))
|
|
575
|
+
return;
|
|
573
576
|
const cellData = worksheet.getCell(row, col);
|
|
574
577
|
if (cellData && cellData.dataBar) {
|
|
575
|
-
|
|
576
|
-
return;
|
|
577
|
-
const { color, value, startPoint, isGradient } = cellData.dataBar, cellInfo = this.getCellIndex(row, col, rowHeightAccumulation, columnWidthAccumulation, dataMergeCache);
|
|
578
|
+
const { color, value, startPoint, isGradient } = cellData.dataBar, cellInfo = this.getCellByIndex(row, col, rowHeightAccumulation, columnWidthAccumulation, dataMergeCache);
|
|
578
579
|
let { isMerged, isMergedMainCell, mergeInfo, startY, endY, startX, endX } = cellInfo;
|
|
579
580
|
if (isMerged || (isMergedMainCell && (startY = mergeInfo.startY, endY = mergeInfo.endY, startX = mergeInfo.startX, endX = mergeInfo.endX), !this.isRenderDiffRangesByCell(mergeInfo, diffRanges)))
|
|
580
581
|
return;
|
|
@@ -785,6 +786,7 @@ const serialTimeToTimestamp = /* @__PURE__ */ __name((value) => {
|
|
|
785
786
|
Object.freeze(EMPTY_STYLE);
|
|
786
787
|
const dataBarCellCalculateUnit = {
|
|
787
788
|
type: CFRuleType.dataBar,
|
|
789
|
+
// eslint-disable-next-line max-lines-per-function
|
|
788
790
|
handle: /* @__PURE__ */ __name(async (rule, context) => {
|
|
789
791
|
const ruleConfig = rule.rule, conditionalFormattingFormulaService = context.accessor.get(ConditionalFormattingFormulaService), { worksheet } = context, matrix = new ObjectMatrix(), ranges = filterRange(rule.ranges, worksheet.getMaxRows() - 1, worksheet.getMaxColumns() - 1);
|
|
790
792
|
ranges.forEach((range) => {
|
|
@@ -814,8 +816,8 @@ const dataBarCellCalculateUnit = {
|
|
|
814
816
|
if (_max.status === FormulaResultStatus.WAIT)
|
|
815
817
|
return conditionalFormattingFormulaService.getCache(context.unitId, context.subUnitId, rule.cfId) || computeResult;
|
|
816
818
|
if (_max.status === FormulaResultStatus.SUCCESS) {
|
|
817
|
-
const v = Number(_max.result);
|
|
818
|
-
max =
|
|
819
|
+
const v = Number.isNaN(Number(_max.result)) ? 0 : Number(_max.result);
|
|
820
|
+
max = Math.max(v, min), min = Math.min(v, min);
|
|
819
821
|
} else
|
|
820
822
|
return computeResult;
|
|
821
823
|
const isGradient = ruleConfig.config.isGradient, isShowValue = ruleConfig.isShowValue, getSafeValue = /* @__PURE__ */ __name((v) => Math.max(Math.min(100, v), 0), "getSafeValue");
|
|
@@ -1178,6 +1180,8 @@ let ConditionalFormattingService = (_a3 = class extends Disposable {
|
|
|
1178
1180
|
configList.forEach((config) => {
|
|
1179
1181
|
this._handleCalculateUnit(config.unitId, config.subUnitId, config.rule);
|
|
1180
1182
|
});
|
|
1183
|
+
}), this.disposeWithMe(() => {
|
|
1184
|
+
this.interceptorManager.dispose();
|
|
1181
1185
|
});
|
|
1182
1186
|
}
|
|
1183
1187
|
composeStyle(unitId, subUnitId, row, col) {
|
|
@@ -1440,15 +1444,17 @@ const getUnitId = /* @__PURE__ */ __name((u) => u.getCurrentUnitForType(UniverIn
|
|
|
1440
1444
|
}
|
|
1441
1445
|
}
|
|
1442
1446
|
] : [];
|
|
1443
|
-
}, "setConditionalRuleMutationUndoFactory");
|
|
1447
|
+
}, "setConditionalRuleMutationUndoFactory"), PLUGIN_CONFIG_KEY = "ssheets-conditional-formatting.config", defaultPluginConfig = {};
|
|
1444
1448
|
var __defProp2 = Object.defineProperty, __getOwnPropDesc = Object.getOwnPropertyDescriptor, __decorateClass = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
1445
1449
|
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
1446
1450
|
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
1447
1451
|
return kind && result && __defProp2(target, key, result), result;
|
|
1448
1452
|
}, "__decorateClass"), __decorateParam = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam"), _a4;
|
|
1449
1453
|
let UniverSheetsConditionalFormattingPlugin = (_a4 = class extends Plugin {
|
|
1450
|
-
constructor(_config, _injector, _commandService) {
|
|
1451
|
-
super(), this._injector = _injector, this._commandService = _commandService,
|
|
1454
|
+
constructor(_config = defaultPluginConfig, _injector, _commandService, _configService) {
|
|
1455
|
+
super(), this._config = _config, this._injector = _injector, this._commandService = _commandService, this._configService = _configService;
|
|
1456
|
+
const { ...rest } = this._config;
|
|
1457
|
+
this._configService.setConfig(PLUGIN_CONFIG_KEY, rest), [
|
|
1452
1458
|
[ConditionalFormattingService],
|
|
1453
1459
|
[ConditionalFormattingFormulaService],
|
|
1454
1460
|
[ConditionalFormattingRuleModel],
|
|
@@ -1468,7 +1474,8 @@ let UniverSheetsConditionalFormattingPlugin = (_a4 = class extends Plugin {
|
|
|
1468
1474
|
}, __name(_a4, "UniverSheetsConditionalFormattingPlugin"), __publicField(_a4, "pluginName", SHEET_CONDITIONAL_FORMATTING_PLUGIN), __publicField(_a4, "type", UniverInstanceType.UNIVER_SHEET), _a4);
|
|
1469
1475
|
UniverSheetsConditionalFormattingPlugin = __decorateClass([
|
|
1470
1476
|
__decorateParam(1, Inject(Injector)),
|
|
1471
|
-
__decorateParam(2, Inject(ICommandService))
|
|
1477
|
+
__decorateParam(2, Inject(ICommandService)),
|
|
1478
|
+
__decorateParam(3, IConfigService)
|
|
1472
1479
|
], UniverSheetsConditionalFormattingPlugin);
|
|
1473
1480
|
const getStringFromDataStream = /* @__PURE__ */ __name((data) => {
|
|
1474
1481
|
var _a5;
|
|
@@ -1666,22 +1673,22 @@ const EMPTY_ICON_TYPE = "EMPTY_ICON_TYPE", IconUKey = "sheet-conditional-rule-ic
|
|
|
1666
1673
|
__publicField(this, "_radius", 1);
|
|
1667
1674
|
this._init();
|
|
1668
1675
|
}
|
|
1669
|
-
draw(ctx,
|
|
1676
|
+
draw(ctx, _parentScale, spreadsheetSkeleton, diffRanges) {
|
|
1670
1677
|
const { rowHeightAccumulation, columnWidthAccumulation, worksheet, dataMergeCache } = spreadsheetSkeleton;
|
|
1671
1678
|
if (!worksheet)
|
|
1672
1679
|
return !1;
|
|
1673
1680
|
ctx.save(), Range.foreach(spreadsheetSkeleton.rowColumnSegment, (row, col) => {
|
|
1681
|
+
if (!worksheet.getRowVisible(row) || !worksheet.getColVisible(col))
|
|
1682
|
+
return;
|
|
1674
1683
|
const cellData = worksheet.getCell(row, col);
|
|
1675
1684
|
if (cellData != null && cellData.iconSet) {
|
|
1676
|
-
if (!worksheet.getColVisible(col) || !worksheet.getRowRawVisible(row))
|
|
1677
|
-
return;
|
|
1678
1685
|
const { iconType, iconId } = cellData.iconSet;
|
|
1679
1686
|
if (iconType === EMPTY_ICON_TYPE)
|
|
1680
1687
|
return;
|
|
1681
1688
|
const icon = this._imageMap.get(this._createKey(iconType, iconId));
|
|
1682
1689
|
if (!icon)
|
|
1683
1690
|
return;
|
|
1684
|
-
const cellInfo = this.
|
|
1691
|
+
const cellInfo = this.getCellByIndex(row, col, rowHeightAccumulation, columnWidthAccumulation, dataMergeCache);
|
|
1685
1692
|
let { isMerged, isMergedMainCell, mergeInfo, startY, endY, startX, endX } = cellInfo;
|
|
1686
1693
|
if (isMerged || (isMergedMainCell && (startY = mergeInfo.startY, endY = mergeInfo.endY, startX = mergeInfo.startX, endX = mergeInfo.endX), !this.isRenderDiffRangesByCell(mergeInfo, diffRanges)))
|
|
1687
1694
|
return;
|
|
@@ -60,6 +60,6 @@ export declare enum CFValueType {
|
|
|
60
60
|
}
|
|
61
61
|
export declare const DEFAULT_BG_COLOR = "#fff";
|
|
62
62
|
export declare const DEFAULT_FONT_COLOR = "#000000";
|
|
63
|
-
export declare const createDefaultRule: () => IConditionFormattingRule<import('
|
|
63
|
+
export declare const createDefaultRule: () => IConditionFormattingRule<import('..').IConditionalFormattingRuleConfig>;
|
|
64
64
|
export declare const createDefaultValue: (subType: CFSubRuleType, operator: CFTextOperator | CFNumberOperator | CFTimePeriodOperator) => 10 | "" | [number, number];
|
|
65
65
|
export declare const createDefaultValueByValueType: (type: CFValueType, defaultValue?: number) => number | "" | "=";
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2023-present DreamNum Inc.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
export declare const PLUGIN_CONFIG_KEY = "ssheets-conditional-formatting.config";
|
|
17
|
+
export declare const configSymbol: unique symbol;
|
|
18
|
+
export interface IUniverSheetsConditionalFormattingConfig {
|
|
19
|
+
}
|
|
20
|
+
export declare const defaultPluginConfig: IUniverSheetsConditionalFormattingConfig;
|
package/lib/types/plugin.d.ts
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
import { ICommandService, Injector, Plugin, UniverInstanceType } from '@univerjs/core';
|
|
1
|
+
import { ICommandService, IConfigService, Injector, Plugin, UniverInstanceType } from '@univerjs/core';
|
|
2
|
+
import { IUniverSheetsConditionalFormattingConfig } from './controllers/config.schema';
|
|
2
3
|
export declare class UniverSheetsConditionalFormattingPlugin extends Plugin {
|
|
4
|
+
private readonly _config;
|
|
3
5
|
readonly _injector: Injector;
|
|
4
6
|
private _commandService;
|
|
7
|
+
private readonly _configService;
|
|
5
8
|
static pluginName: string;
|
|
6
9
|
static type: UniverInstanceType;
|
|
7
|
-
constructor(_config:
|
|
10
|
+
constructor(_config: Partial<IUniverSheetsConditionalFormattingConfig> | undefined, _injector: Injector, _commandService: ICommandService, _configService: IConfigService);
|
|
8
11
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { SheetExtension, SpreadsheetSkeleton, UniverRenderingContext } from '@univerjs/engine-render';
|
|
1
2
|
import { IRange, IScale } from '@univerjs/core';
|
|
2
|
-
import { SpreadsheetSkeleton, UniverRenderingContext, SheetExtension } from '@univerjs/engine-render';
|
|
3
3
|
export declare const dataBarUKey = "sheet-conditional-rule-data-bar";
|
|
4
4
|
export declare const defaultDataBarPositiveColor = "#ffbe38";
|
|
5
5
|
export declare const defaultDataBarNativeColor = "#abd91a";
|
|
@@ -9,6 +9,6 @@ export declare class DataBar extends SheetExtension {
|
|
|
9
9
|
uKey: string;
|
|
10
10
|
Z_INDEX: number;
|
|
11
11
|
_radius: number;
|
|
12
|
-
draw(ctx: UniverRenderingContext,
|
|
12
|
+
draw(ctx: UniverRenderingContext, _parentScale: IScale, spreadsheetSkeleton: SpreadsheetSkeleton, diffRanges: IRange[]): false | undefined;
|
|
13
13
|
private _drawRectWithRoundedCorner;
|
|
14
14
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { SheetExtension, SpreadsheetSkeleton, UniverRenderingContext } from '@univerjs/engine-render';
|
|
1
2
|
import { IRange, IScale } from '@univerjs/core';
|
|
2
|
-
import { SpreadsheetSkeleton, UniverRenderingContext, SheetExtension } from '@univerjs/engine-render';
|
|
3
3
|
export declare const IconUKey = "sheet-conditional-rule-icon";
|
|
4
4
|
export declare const DEFAULT_WIDTH = 15;
|
|
5
5
|
export declare const DEFAULT_PADDING = 2;
|
|
@@ -11,7 +11,7 @@ export declare class ConditionalFormattingIcon extends SheetExtension {
|
|
|
11
11
|
Z_INDEX: number;
|
|
12
12
|
_radius: number;
|
|
13
13
|
constructor();
|
|
14
|
-
draw(ctx: UniverRenderingContext,
|
|
14
|
+
draw(ctx: UniverRenderingContext, _parentScale: IScale, spreadsheetSkeleton: SpreadsheetSkeleton, diffRanges: IRange[]): false | undefined;
|
|
15
15
|
private _init;
|
|
16
16
|
private _createKey;
|
|
17
17
|
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2023-present DreamNum Inc.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
export {};
|
|
@@ -5,12 +5,12 @@ import { ConditionalFormattingViewModel } from '../../models/conditional-formatt
|
|
|
5
5
|
export declare const createTestBed: (dependencies?: Dependency[]) => {
|
|
6
6
|
univer: Univer;
|
|
7
7
|
get: {
|
|
8
|
-
<T>(id: import('@
|
|
9
|
-
<T>(id: import('@
|
|
10
|
-
<T>(id: import('@
|
|
11
|
-
<T>(id: import('@
|
|
12
|
-
<T>(id: import('@
|
|
13
|
-
<T>(id: import('@
|
|
8
|
+
<T>(id: import('@wendellhu/redi').DependencyIdentifier<T>, lookUp?: import('@wendellhu/redi').LookUp): T;
|
|
9
|
+
<T>(id: import('@wendellhu/redi').DependencyIdentifier<T>, quantity: import("@wendellhu/redi").Quantity.MANY, lookUp?: import('@wendellhu/redi').LookUp): T[];
|
|
10
|
+
<T>(id: import('@wendellhu/redi').DependencyIdentifier<T>, quantity: import("@wendellhu/redi").Quantity.OPTIONAL, lookUp?: import('@wendellhu/redi').LookUp): T | null;
|
|
11
|
+
<T>(id: import('@wendellhu/redi').DependencyIdentifier<T>, quantity: import("@wendellhu/redi").Quantity.REQUIRED, lookUp?: import('@wendellhu/redi').LookUp): T;
|
|
12
|
+
<T>(id: import('@wendellhu/redi').DependencyIdentifier<T>, quantity?: import('@wendellhu/redi').Quantity, lookUp?: import('@wendellhu/redi').LookUp): T[] | T | null;
|
|
13
|
+
<T>(id: import('@wendellhu/redi').DependencyIdentifier<T>, quantityOrLookup?: import('@wendellhu/redi').Quantity | import('@wendellhu/redi').LookUp, lookUp?: import('@wendellhu/redi').LookUp): T[] | T | null;
|
|
14
14
|
};
|
|
15
15
|
workbook: import('@univerjs/core').Workbook;
|
|
16
16
|
unitId: string;
|