@univerjs/sheets-conditional-formatting 0.2.11 → 0.2.12
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 +16 -9
- 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 +1 -1
- package/lib/types/render/icon.render.d.ts +1 -1
- package/lib/types/services/__test__/calculate.databar.spec.d.ts +16 -0
- package/lib/umd/index.js +1 -1
- package/package.json +10 -10
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,7 +565,8 @@ 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;
|
|
@@ -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,7 +1673,7 @@ 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;
|
|
@@ -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>, _injector: Injector, _commandService: ICommandService, _configService: IConfigService);
|
|
8
11
|
}
|
|
@@ -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
|
}
|
|
@@ -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 {};
|