@univerjs/sheets-conditional-formatting 0.2.15 → 0.3.0-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/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,
|
|
5
|
+
import { Tools, Inject, Injector, ObjectMatrix, Range, CommandType, ICommandService, Disposable, toDisposable, RefAlias, CellValueType, BooleanNumber, ColorKit, Rectangle, createInterceptorKey, OnLifecycle, LifecycleStages, IUniverInstanceService, IResourceManagerService, InterceptorManager, UniverInstanceType, Plugin, IConfigService } from "@univerjs/core";
|
|
6
6
|
import { Subject, Observable } from "rxjs";
|
|
7
7
|
import { bufferTime, filter, map } from "rxjs/operators";
|
|
8
8
|
import { SheetInterceptorService, RemoveSheetCommand, ReorderRangeMutation, MoveRangeMutation, MoveColsMutation, MoveRowsMutation, InsertRowMutation, RemoveRowMutation, RemoveColMutation, InsertColMutation, SetRangeValuesMutation } from "@univerjs/sheets";
|
|
@@ -237,98 +237,7 @@ let ConditionalFormattingRuleModel = (_a = class {
|
|
|
237
237
|
ConditionalFormattingRuleModel = __decorateClass$3([
|
|
238
238
|
__decorateParam$3(0, Inject(Injector))
|
|
239
239
|
], ConditionalFormattingRuleModel);
|
|
240
|
-
const
|
|
241
|
-
type: CommandType.MUTATION,
|
|
242
|
-
id: "sheet.mutation.move-conditional-rule",
|
|
243
|
-
handler(accessor, params) {
|
|
244
|
-
if (!params)
|
|
245
|
-
return !1;
|
|
246
|
-
const { unitId, subUnitId, start, end } = params;
|
|
247
|
-
return accessor.get(ConditionalFormattingRuleModel).moveRulePriority(unitId, subUnitId, start, end), !0;
|
|
248
|
-
}
|
|
249
|
-
}, MoveConditionalRuleMutationUndoFactory = /* @__PURE__ */ __name((param) => {
|
|
250
|
-
const { unitId, subUnitId } = param, undo = anchorUndoFactory(param.start, param.end);
|
|
251
|
-
if (!undo)
|
|
252
|
-
return [];
|
|
253
|
-
const [start, end] = undo;
|
|
254
|
-
return [
|
|
255
|
-
{
|
|
256
|
-
id: MoveConditionalRuleMutation.id,
|
|
257
|
-
params: { unitId, subUnitId, start, end }
|
|
258
|
-
}
|
|
259
|
-
];
|
|
260
|
-
}, "MoveConditionalRuleMutationUndoFactory"), DeleteConditionalRuleMutationUndoFactory = /* @__PURE__ */ __name((accessor, param) => {
|
|
261
|
-
const conditionalFormattingRuleModel = accessor.get(ConditionalFormattingRuleModel), { unitId, subUnitId, cfId } = param, ruleList = [...conditionalFormattingRuleModel.getSubunitRules(unitId, subUnitId) || []], index = ruleList.findIndex((item) => item.cfId === cfId), beforeRule = ruleList[index - 1];
|
|
262
|
-
if (index > -1) {
|
|
263
|
-
const rule = ruleList[index], result = [{
|
|
264
|
-
id: AddConditionalRuleMutation.id,
|
|
265
|
-
params: { unitId, subUnitId, rule: Tools.deepClone(rule) }
|
|
266
|
-
}];
|
|
267
|
-
if (ruleList.splice(index, 1), index !== 0) {
|
|
268
|
-
const firstRule = ruleList[0];
|
|
269
|
-
if (firstRule) {
|
|
270
|
-
const transformResult = transformSupportSymmetryAnchor({ id: firstRule.cfId, type: "before" }, { id: beforeRule.cfId, type: "after" }, ruleList, (rule2) => rule2.cfId);
|
|
271
|
-
if (!transformResult)
|
|
272
|
-
return result;
|
|
273
|
-
const [start, end] = transformResult, params = {
|
|
274
|
-
unitId,
|
|
275
|
-
subUnitId,
|
|
276
|
-
start,
|
|
277
|
-
end
|
|
278
|
-
};
|
|
279
|
-
result.push({ id: MoveConditionalRuleMutation.id, params });
|
|
280
|
-
}
|
|
281
|
-
}
|
|
282
|
-
return result;
|
|
283
|
-
}
|
|
284
|
-
return [];
|
|
285
|
-
}, "DeleteConditionalRuleMutationUndoFactory"), DeleteConditionalRuleMutation = {
|
|
286
|
-
type: CommandType.MUTATION,
|
|
287
|
-
id: "sheet.mutation.delete-conditional-rule",
|
|
288
|
-
handler(accessor, params) {
|
|
289
|
-
if (!params)
|
|
290
|
-
return !1;
|
|
291
|
-
const { unitId, subUnitId, cfId } = params;
|
|
292
|
-
return accessor.get(ConditionalFormattingRuleModel).deleteRule(unitId, subUnitId, cfId), !0;
|
|
293
|
-
}
|
|
294
|
-
}, AddConditionalRuleMutationUndoFactory = /* @__PURE__ */ __name((accessor, param) => ({ id: DeleteConditionalRuleMutation.id, params: { unitId: param.unitId, subUnitId: param.subUnitId, cfId: param.rule.cfId } }), "AddConditionalRuleMutationUndoFactory"), AddConditionalRuleMutation = {
|
|
295
|
-
type: CommandType.MUTATION,
|
|
296
|
-
id: "sheet.mutation.add-conditional-rule",
|
|
297
|
-
handler(accessor, params) {
|
|
298
|
-
if (!params)
|
|
299
|
-
return !1;
|
|
300
|
-
const { unitId, subUnitId, rule } = params;
|
|
301
|
-
return accessor.get(ConditionalFormattingRuleModel).addRule(unitId, subUnitId, rule), !0;
|
|
302
|
-
}
|
|
303
|
-
}, ConditionalFormattingFormulaMarkDirty = {
|
|
304
|
-
type: CommandType.MUTATION,
|
|
305
|
-
id: "sheet.mutation.conditional-formatting-formula-mark-dirty",
|
|
306
|
-
handler() {
|
|
307
|
-
return !0;
|
|
308
|
-
}
|
|
309
|
-
}, SetConditionalRuleMutation = {
|
|
310
|
-
type: CommandType.MUTATION,
|
|
311
|
-
id: "sheet.mutation.set-conditional-rule",
|
|
312
|
-
handler(accessor, params) {
|
|
313
|
-
if (!params)
|
|
314
|
-
return !1;
|
|
315
|
-
const { unitId, subUnitId, rule } = params, cfId = params.cfId || params.rule.cfId;
|
|
316
|
-
return accessor.get(ConditionalFormattingRuleModel).setRule(unitId, subUnitId, rule, cfId), !0;
|
|
317
|
-
}
|
|
318
|
-
}, setConditionalRuleMutationUndoFactory = /* @__PURE__ */ __name((accessor, param) => {
|
|
319
|
-
const conditionalFormattingRuleModel = accessor.get(ConditionalFormattingRuleModel), { unitId, subUnitId } = param, cfId = param.cfId || param.rule.cfId, rule = conditionalFormattingRuleModel.getRule(unitId, subUnitId, cfId);
|
|
320
|
-
return rule ? [
|
|
321
|
-
{
|
|
322
|
-
id: SetConditionalRuleMutation.id,
|
|
323
|
-
params: {
|
|
324
|
-
unitId,
|
|
325
|
-
subUnitId,
|
|
326
|
-
cfId,
|
|
327
|
-
rule: Tools.deepClone(rule)
|
|
328
|
-
}
|
|
329
|
-
}
|
|
330
|
-
] : [];
|
|
331
|
-
}, "setConditionalRuleMutationUndoFactory"), _ConditionalFormattingViewModel = class _ConditionalFormattingViewModel {
|
|
240
|
+
const _ConditionalFormattingViewModel = class _ConditionalFormattingViewModel {
|
|
332
241
|
constructor() {
|
|
333
242
|
// Map<unitID ,<sheetId ,ObjectMatrix>>
|
|
334
243
|
__publicField(this, "_model", /* @__PURE__ */ new Map());
|
|
@@ -575,7 +484,76 @@ for (const key in iconMap) {
|
|
|
575
484
|
const v = iconMap[key];
|
|
576
485
|
Object.freeze(v);
|
|
577
486
|
}
|
|
578
|
-
const EMPTY_ICON_TYPE = "EMPTY_ICON_TYPE"
|
|
487
|
+
const EMPTY_ICON_TYPE = "EMPTY_ICON_TYPE", AddConditionalRuleMutationUndoFactory = /* @__PURE__ */ __name((accessor, param) => ({ id: DeleteConditionalRuleMutation.id, params: { unitId: param.unitId, subUnitId: param.subUnitId, cfId: param.rule.cfId } }), "AddConditionalRuleMutationUndoFactory"), AddConditionalRuleMutation = {
|
|
488
|
+
type: CommandType.MUTATION,
|
|
489
|
+
id: "sheet.mutation.add-conditional-rule",
|
|
490
|
+
handler(accessor, params) {
|
|
491
|
+
if (!params)
|
|
492
|
+
return !1;
|
|
493
|
+
const { unitId, subUnitId, rule } = params;
|
|
494
|
+
return accessor.get(ConditionalFormattingRuleModel).addRule(unitId, subUnitId, rule), !0;
|
|
495
|
+
}
|
|
496
|
+
}, MoveConditionalRuleMutation = {
|
|
497
|
+
type: CommandType.MUTATION,
|
|
498
|
+
id: "sheet.mutation.move-conditional-rule",
|
|
499
|
+
handler(accessor, params) {
|
|
500
|
+
if (!params)
|
|
501
|
+
return !1;
|
|
502
|
+
const { unitId, subUnitId, start, end } = params;
|
|
503
|
+
return accessor.get(ConditionalFormattingRuleModel).moveRulePriority(unitId, subUnitId, start, end), !0;
|
|
504
|
+
}
|
|
505
|
+
}, MoveConditionalRuleMutationUndoFactory = /* @__PURE__ */ __name((param) => {
|
|
506
|
+
const { unitId, subUnitId } = param, undo = anchorUndoFactory(param.start, param.end);
|
|
507
|
+
if (!undo)
|
|
508
|
+
return [];
|
|
509
|
+
const [start, end] = undo;
|
|
510
|
+
return [
|
|
511
|
+
{
|
|
512
|
+
id: MoveConditionalRuleMutation.id,
|
|
513
|
+
params: { unitId, subUnitId, start, end }
|
|
514
|
+
}
|
|
515
|
+
];
|
|
516
|
+
}, "MoveConditionalRuleMutationUndoFactory"), DeleteConditionalRuleMutationUndoFactory = /* @__PURE__ */ __name((accessor, param) => {
|
|
517
|
+
const conditionalFormattingRuleModel = accessor.get(ConditionalFormattingRuleModel), { unitId, subUnitId, cfId } = param, ruleList = [...conditionalFormattingRuleModel.getSubunitRules(unitId, subUnitId) || []], index = ruleList.findIndex((item) => item.cfId === cfId), beforeRule = ruleList[index - 1];
|
|
518
|
+
if (index > -1) {
|
|
519
|
+
const rule = ruleList[index], result = [{
|
|
520
|
+
id: AddConditionalRuleMutation.id,
|
|
521
|
+
params: { unitId, subUnitId, rule: Tools.deepClone(rule) }
|
|
522
|
+
}];
|
|
523
|
+
if (ruleList.splice(index, 1), index !== 0) {
|
|
524
|
+
const firstRule = ruleList[0];
|
|
525
|
+
if (firstRule) {
|
|
526
|
+
const transformResult = transformSupportSymmetryAnchor({ id: firstRule.cfId, type: "before" }, { id: beforeRule.cfId, type: "after" }, ruleList, (rule2) => rule2.cfId);
|
|
527
|
+
if (!transformResult)
|
|
528
|
+
return result;
|
|
529
|
+
const [start, end] = transformResult, params = {
|
|
530
|
+
unitId,
|
|
531
|
+
subUnitId,
|
|
532
|
+
start,
|
|
533
|
+
end
|
|
534
|
+
};
|
|
535
|
+
result.push({ id: MoveConditionalRuleMutation.id, params });
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
return result;
|
|
539
|
+
}
|
|
540
|
+
return [];
|
|
541
|
+
}, "DeleteConditionalRuleMutationUndoFactory"), DeleteConditionalRuleMutation = {
|
|
542
|
+
type: CommandType.MUTATION,
|
|
543
|
+
id: "sheet.mutation.delete-conditional-rule",
|
|
544
|
+
handler(accessor, params) {
|
|
545
|
+
if (!params)
|
|
546
|
+
return !1;
|
|
547
|
+
const { unitId, subUnitId, cfId } = params;
|
|
548
|
+
return accessor.get(ConditionalFormattingRuleModel).deleteRule(unitId, subUnitId, cfId), !0;
|
|
549
|
+
}
|
|
550
|
+
}, ConditionalFormattingFormulaMarkDirty = {
|
|
551
|
+
type: CommandType.MUTATION,
|
|
552
|
+
id: "sheet.mutation.conditional-formatting-formula-mark-dirty",
|
|
553
|
+
handler() {
|
|
554
|
+
return !0;
|
|
555
|
+
}
|
|
556
|
+
};
|
|
579
557
|
var __defProp$2 = Object.defineProperty, __getOwnPropDesc$2 = Object.getOwnPropertyDescriptor, __decorateClass$2 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
580
558
|
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$2(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
581
559
|
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
@@ -766,7 +744,7 @@ const dataBarUKey = "sheet-conditional-rule-data-bar", defaultDataBarPositiveCol
|
|
|
766
744
|
return;
|
|
767
745
|
const cellData = worksheet.getCell(row, col);
|
|
768
746
|
if (cellData && cellData.dataBar) {
|
|
769
|
-
const { color, value, startPoint, isGradient } = cellData.dataBar, cellInfo = spreadsheetSkeleton.
|
|
747
|
+
const { color, value, startPoint, isGradient } = cellData.dataBar, cellInfo = spreadsheetSkeleton.getCellByIndexWithNoHeader(row, col);
|
|
770
748
|
let { isMerged, isMergedMainCell, mergeInfo, startY, endY, startX, endX } = cellInfo;
|
|
771
749
|
if (isMerged || (isMergedMainCell && (startY = mergeInfo.startY, endY = mergeInfo.endY, startX = mergeInfo.startX, endX = mergeInfo.endX), !this.isRenderDiffRangesByCell(mergeInfo, diffRanges)))
|
|
772
750
|
return;
|
|
@@ -1613,7 +1591,29 @@ ConditionalFormattingService = __decorateClass$1([
|
|
|
1613
1591
|
const getUnitId = /* @__PURE__ */ __name((u) => u.getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET).getUnitId(), "getUnitId"), getSubUnitId = /* @__PURE__ */ __name((u) => {
|
|
1614
1592
|
var _a5;
|
|
1615
1593
|
return (_a5 = u.getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET).getActiveSheet()) == null ? void 0 : _a5.getSheetId();
|
|
1616
|
-
}, "getSubUnitId"),
|
|
1594
|
+
}, "getSubUnitId"), SetConditionalRuleMutation = {
|
|
1595
|
+
type: CommandType.MUTATION,
|
|
1596
|
+
id: "sheet.mutation.set-conditional-rule",
|
|
1597
|
+
handler(accessor, params) {
|
|
1598
|
+
if (!params)
|
|
1599
|
+
return !1;
|
|
1600
|
+
const { unitId, subUnitId, rule } = params, cfId = params.cfId || params.rule.cfId;
|
|
1601
|
+
return accessor.get(ConditionalFormattingRuleModel).setRule(unitId, subUnitId, rule, cfId), !0;
|
|
1602
|
+
}
|
|
1603
|
+
}, setConditionalRuleMutationUndoFactory = /* @__PURE__ */ __name((accessor, param) => {
|
|
1604
|
+
const conditionalFormattingRuleModel = accessor.get(ConditionalFormattingRuleModel), { unitId, subUnitId } = param, cfId = param.cfId || param.rule.cfId, rule = conditionalFormattingRuleModel.getRule(unitId, subUnitId, cfId);
|
|
1605
|
+
return rule ? [
|
|
1606
|
+
{
|
|
1607
|
+
id: SetConditionalRuleMutation.id,
|
|
1608
|
+
params: {
|
|
1609
|
+
unitId,
|
|
1610
|
+
subUnitId,
|
|
1611
|
+
cfId,
|
|
1612
|
+
rule: Tools.deepClone(rule)
|
|
1613
|
+
}
|
|
1614
|
+
}
|
|
1615
|
+
] : [];
|
|
1616
|
+
}, "setConditionalRuleMutationUndoFactory"), PLUGIN_CONFIG_KEY = "ssheets-conditional-formatting.config", defaultPluginConfig = {};
|
|
1617
1617
|
var __defProp2 = Object.defineProperty, __getOwnPropDesc = Object.getOwnPropertyDescriptor, __decorateClass = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
1618
1618
|
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
1619
1619
|
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
package/lib/types/index.d.ts
CHANGED
|
@@ -14,11 +14,6 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
export * from './base/const';
|
|
17
|
-
export { AddConditionalRuleMutation, AddConditionalRuleMutationUndoFactory, type IAddConditionalRuleMutationParams } from './commands/mutations/add-conditional-rule.mutation';
|
|
18
|
-
export { DeleteConditionalRuleMutation, DeleteConditionalRuleMutationUndoFactory, type IDeleteConditionalRuleMutationParams } from './commands/mutations/delete-conditional-rule.mutation';
|
|
19
|
-
export { ConditionalFormattingFormulaMarkDirty } from './commands/mutations/formula-mark-dirty.mutation';
|
|
20
|
-
export { type IMoveConditionalRuleMutationParams, MoveConditionalRuleMutation, MoveConditionalRuleMutationUndoFactory } from './commands/mutations/move-conditional-rule.mutation';
|
|
21
|
-
export { type ISetConditionalRuleMutationParams, SetConditionalRuleMutation, setConditionalRuleMutationUndoFactory } from './commands/mutations/set-conditional-rule.mutation';
|
|
22
17
|
export * from './models/conditional-formatting-rule-model';
|
|
23
18
|
export * from './models/conditional-formatting-view-model';
|
|
24
19
|
export * from './models/icon-map';
|
|
@@ -36,3 +31,8 @@ export * from './utils/create-cf-id';
|
|
|
36
31
|
export * from './utils/is-ranges-equal';
|
|
37
32
|
export * from './utils/remove-undefined-attr';
|
|
38
33
|
export * from './utils/type';
|
|
34
|
+
export { AddConditionalRuleMutation, AddConditionalRuleMutationUndoFactory, type IAddConditionalRuleMutationParams, } from './commands/mutations/add-conditional-rule.mutation';
|
|
35
|
+
export { DeleteConditionalRuleMutation, DeleteConditionalRuleMutationUndoFactory, type IDeleteConditionalRuleMutationParams, } from './commands/mutations/delete-conditional-rule.mutation';
|
|
36
|
+
export { ConditionalFormattingFormulaMarkDirty } from './commands/mutations/formula-mark-dirty.mutation';
|
|
37
|
+
export { type IMoveConditionalRuleMutationParams, MoveConditionalRuleMutation, MoveConditionalRuleMutationUndoFactory, } from './commands/mutations/move-conditional-rule.mutation';
|
|
38
|
+
export { type ISetConditionalRuleMutationParams, SetConditionalRuleMutation, setConditionalRuleMutationUndoFactory, } from './commands/mutations/set-conditional-rule.mutation';
|
|
@@ -19,7 +19,7 @@ export declare class ConditionalFormattingViewModel {
|
|
|
19
19
|
}>;
|
|
20
20
|
private _ensureMatrix;
|
|
21
21
|
getMatrix(unitId: string, subUnitId: string): ObjectMatrix<ICellItem> | undefined;
|
|
22
|
-
getCellCf(unitId: string, subUnitId: string, row: number, col: number, matrix?: ObjectMatrix<ICellItem>): ICellItem
|
|
22
|
+
getCellCf(unitId: string, subUnitId: string, row: number, col: number, matrix?: ObjectMatrix<ICellItem>): import('@univerjs/core').Nullable<ICellItem>;
|
|
23
23
|
setCellCfRuleCache(unitId: string, subUnitId: string, row: number, col: number, cfId: string, value: any): void;
|
|
24
24
|
deleteCellCf(unitId: string, subUnitId: string, row: number, col: number, cfId: string, matrix?: ObjectMatrix<ICellItem>): void;
|
|
25
25
|
pushCellCf(unitId: string, subUnitId: string, row: number, col: number, cfId: string): void;
|