@univerjs/sheets-conditional-formatting 1.0.0-alpha.7 → 1.0.0-beta.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/cjs/facade.js CHANGED
@@ -4,7 +4,7 @@ let _univerjs_sheets_conditional_formatting = require("@univerjs/sheets-conditio
4
4
  let _univerjs_sheets_facade = require("@univerjs/sheets/facade");
5
5
  let _univerjs_core_facade = require("@univerjs/core/facade");
6
6
 
7
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/typeof.js
7
+ //#region \0@oxc-project+runtime@0.140.0/helpers/esm/typeof.js
8
8
  function _typeof(o) {
9
9
  "@babel/helpers - typeof";
10
10
  return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
@@ -15,7 +15,7 @@ function _typeof(o) {
15
15
  }
16
16
 
17
17
  //#endregion
18
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/toPrimitive.js
18
+ //#region \0@oxc-project+runtime@0.140.0/helpers/esm/toPrimitive.js
19
19
  function toPrimitive(t, r) {
20
20
  if ("object" != _typeof(t) || !t) return t;
21
21
  var e = t[Symbol.toPrimitive];
@@ -28,14 +28,14 @@ function toPrimitive(t, r) {
28
28
  }
29
29
 
30
30
  //#endregion
31
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/toPropertyKey.js
31
+ //#region \0@oxc-project+runtime@0.140.0/helpers/esm/toPropertyKey.js
32
32
  function toPropertyKey(t) {
33
33
  var i = toPrimitive(t, "string");
34
34
  return "symbol" == _typeof(i) ? i : i + "";
35
35
  }
36
36
 
37
37
  //#endregion
38
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/defineProperty.js
38
+ //#region \0@oxc-project+runtime@0.140.0/helpers/esm/defineProperty.js
39
39
  function _defineProperty(e, r, t) {
40
40
  return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
41
41
  value: t,
@@ -2117,50 +2117,6 @@ var FRangeSheetsConditionalFormattingMixin = class extends _univerjs_sheets_faca
2117
2117
  createConditionalFormattingRule() {
2118
2118
  return new FConditionalFormattingBuilder({ ranges: [this._range] });
2119
2119
  }
2120
- addConditionalFormattingRule(rule) {
2121
- const params = {
2122
- unitId: this._workbook.getUnitId(),
2123
- subUnitId: this._worksheet.getSheetId(),
2124
- rule
2125
- };
2126
- this._commandService.syncExecuteCommand(_univerjs_sheets_conditional_formatting.AddCfCommand.id, params);
2127
- return this;
2128
- }
2129
- deleteConditionalFormattingRule(cfId) {
2130
- const params = {
2131
- unitId: this._workbook.getUnitId(),
2132
- subUnitId: this._worksheet.getSheetId(),
2133
- cfId
2134
- };
2135
- this._commandService.syncExecuteCommand(_univerjs_sheets_conditional_formatting.DeleteCfCommand.id, params);
2136
- return this;
2137
- }
2138
- moveConditionalFormattingRule(cfId, toCfId, type = "after") {
2139
- const params = {
2140
- unitId: this._workbook.getUnitId(),
2141
- subUnitId: this._worksheet.getSheetId(),
2142
- start: {
2143
- id: cfId,
2144
- type: "self"
2145
- },
2146
- end: {
2147
- id: toCfId,
2148
- type
2149
- }
2150
- };
2151
- this._commandService.syncExecuteCommand(_univerjs_sheets_conditional_formatting.MoveCfCommand.id, params);
2152
- return this;
2153
- }
2154
- setConditionalFormattingRule(cfId, rule) {
2155
- const params = {
2156
- unitId: this._workbook.getUnitId(),
2157
- subUnitId: this._worksheet.getSheetId(),
2158
- rule,
2159
- cfId
2160
- };
2161
- this._commandService.syncExecuteCommand(_univerjs_sheets_conditional_formatting.SetCfCommand.id, params);
2162
- return this;
2163
- }
2164
2120
  clearConditionalFormatRules() {
2165
2121
  const params = {
2166
2122
  unitId: this._workbook.getUnitId(),
@@ -2182,9 +2138,6 @@ var FWorksheetConditionalFormattingMixin = class extends _univerjs_sheets_facade
2182
2138
  getConditionalFormattingRules() {
2183
2139
  return [...this._getConditionalFormattingRuleModel().getSubunitRules(this._workbook.getUnitId(), this._worksheet.getSheetId()) || []];
2184
2140
  }
2185
- createConditionalFormattingRule() {
2186
- return new FConditionalFormattingBuilder();
2187
- }
2188
2141
  newConditionalFormattingRule() {
2189
2142
  return new FConditionalFormattingBuilder();
2190
2143
  }
package/lib/cjs/index.js CHANGED
@@ -221,7 +221,7 @@ const isAnchorEqual = (anchor1, anchor2) => {
221
221
  const createCfId = () => `${(0, _univerjs_core.generateRandomId)(8)}`;
222
222
 
223
223
  //#endregion
224
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/typeof.js
224
+ //#region \0@oxc-project+runtime@0.140.0/helpers/esm/typeof.js
225
225
  function _typeof(o) {
226
226
  "@babel/helpers - typeof";
227
227
  return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
@@ -232,7 +232,7 @@ function _typeof(o) {
232
232
  }
233
233
 
234
234
  //#endregion
235
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/toPrimitive.js
235
+ //#region \0@oxc-project+runtime@0.140.0/helpers/esm/toPrimitive.js
236
236
  function toPrimitive(t, r) {
237
237
  if ("object" != _typeof(t) || !t) return t;
238
238
  var e = t[Symbol.toPrimitive];
@@ -245,14 +245,14 @@ function toPrimitive(t, r) {
245
245
  }
246
246
 
247
247
  //#endregion
248
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/toPropertyKey.js
248
+ //#region \0@oxc-project+runtime@0.140.0/helpers/esm/toPropertyKey.js
249
249
  function toPropertyKey(t) {
250
250
  var i = toPrimitive(t, "string");
251
251
  return "symbol" == _typeof(i) ? i : i + "";
252
252
  }
253
253
 
254
254
  //#endregion
255
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/defineProperty.js
255
+ //#region \0@oxc-project+runtime@0.140.0/helpers/esm/defineProperty.js
256
256
  function _defineProperty(e, r, t) {
257
257
  return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
258
258
  value: t,
@@ -513,7 +513,7 @@ const AddCfCommand = {
513
513
  };
514
514
 
515
515
  //#endregion
516
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/decorateParam.js
516
+ //#region \0@oxc-project+runtime@0.140.0/helpers/esm/decorateParam.js
517
517
  function __decorateParam(paramIndex, decorator) {
518
518
  return function(target, key) {
519
519
  decorator(target, key, paramIndex);
@@ -521,7 +521,7 @@ function __decorateParam(paramIndex, decorator) {
521
521
  }
522
522
 
523
523
  //#endregion
524
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/decorate.js
524
+ //#region \0@oxc-project+runtime@0.140.0/helpers/esm/decorate.js
525
525
  function __decorate(decorators, target, key, desc) {
526
526
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
527
527
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -557,9 +557,8 @@ let ConditionalFormattingRangeIndexModel = class ConditionalFormattingRangeIndex
557
557
  return new Set(Array.from(ids).map((id) => String(id)));
558
558
  }
559
559
  getRulesByRanges(unitId, subUnitId, ranges) {
560
- var _this$_conditionalFor;
561
560
  const ids = this.getRuleIdsByRanges(unitId, subUnitId, ranges);
562
- return ((_this$_conditionalFor = this._conditionalFormattingRuleModel.getSubunitRules(unitId, subUnitId)) !== null && _this$_conditionalFor !== void 0 ? _this$_conditionalFor : []).filter((rule) => ids.has(rule.cfId));
561
+ return (this._conditionalFormattingRuleModel.getSubunitRules(unitId, subUnitId) ?? []).filter((rule) => ids.has(rule.cfId));
563
562
  }
564
563
  dispose() {
565
564
  this.clear();
@@ -633,7 +632,7 @@ var ConditionalFormattingRangeTransformService = class {
633
632
  copyIntersectingRanges(sourceRanges, sourceRange, targetAnchor) {
634
633
  const fragments = [];
635
634
  sourceRanges.forEach((range) => {
636
- const intersect = _univerjs_core.Rectangle.getIntersects(range, sourceRange);
635
+ const intersect = (0, _univerjs_core.getIntersectRange)(range, sourceRange);
637
636
  if (!intersect) return;
638
637
  fragments.push(this.translateRange(intersect, {
639
638
  row: targetAnchor.row - sourceRange.startRow,
@@ -688,7 +687,7 @@ const ClearRangeCfCommand = {
688
687
  type: _univerjs_core.CommandType.COMMAND,
689
688
  id: "sheet.command.clear-range-conditional-rule",
690
689
  handler(accessor, params) {
691
- var _ref, _params$ranges, _selectionManagerServ;
690
+ var _selectionManagerServ;
692
691
  if (!params) return false;
693
692
  const conditionalFormattingRangeIndexModel = accessor.get(ConditionalFormattingRangeIndexModel);
694
693
  const conditionalFormattingRangeTransformService = accessor.get(ConditionalFormattingRangeTransformService);
@@ -699,7 +698,7 @@ const ClearRangeCfCommand = {
699
698
  const target = (0, _univerjs_sheets.getSheetCommandTarget)(univerInstanceService, params);
700
699
  if (!target) return false;
701
700
  const { unitId, subUnitId } = target;
702
- const ranges = (_ref = (_params$ranges = params.ranges) !== null && _params$ranges !== void 0 ? _params$ranges : (_selectionManagerServ = selectionManagerService.getCurrentSelections()) === null || _selectionManagerServ === void 0 ? void 0 : _selectionManagerServ.map((selection) => selection.range)) !== null && _ref !== void 0 ? _ref : [];
701
+ const ranges = params.ranges ?? ((_selectionManagerServ = selectionManagerService.getCurrentSelections()) === null || _selectionManagerServ === void 0 ? void 0 : _selectionManagerServ.map((selection) => selection.range)) ?? [];
703
702
  const allRuleList = conditionalFormattingRangeIndexModel.getRulesByRanges(unitId, subUnitId, ranges).filter((rule) => {
704
703
  var _params$types;
705
704
  return !((_params$types = params.types) === null || _params$types === void 0 ? void 0 : _params$types.length) || params.types.includes(rule.rule.type);
@@ -710,13 +709,14 @@ const ClearRangeCfCommand = {
710
709
  allRuleList.forEach((oldRule) => {
711
710
  const newRanges = conditionalFormattingRangeTransformService.subtractRanges(oldRule.ranges, ranges);
712
711
  if (newRanges.length) {
712
+ const rule = {
713
+ ...oldRule,
714
+ ranges: newRanges
715
+ };
713
716
  const params = {
714
717
  unitId,
715
718
  subUnitId,
716
- rule: {
717
- ...oldRule,
718
- ranges: newRanges
719
- }
719
+ rule
720
720
  };
721
721
  const undo = setConditionalRuleMutationUndoFactory(accessor, params);
722
722
  redos.push({
@@ -1477,7 +1477,7 @@ var HighlightCellCalculateUnit = class extends BaseCalculateUnit {
1477
1477
  allValue.sort((a, b) => b - a);
1478
1478
  const configRule = context.rule.rule;
1479
1479
  if (configRule.isPercent) {
1480
- if (configRule.isBottom) allValue = allValue.toReversed();
1480
+ if (configRule.isBottom) allValue = allValue.slice().reverse();
1481
1481
  const threshold = _univerjs_core.Tools.clamp(configRule.value, 0, 100) / 100;
1482
1482
  const targetIndex = Math.floor(threshold * allValue.length);
1483
1483
  const safeIndex = _univerjs_core.Tools.clamp(targetIndex - 1, 0, allValue.length - 1);
@@ -1682,7 +1682,10 @@ var HighlightCellCalculateUnit = class extends BaseCalculateUnit {
1682
1682
  const formulaResult = conditionalFormattingFormulaService.getFormulaResultWithCoords(context.unitId, context.subUnitId, context.rule.cfId, _ruleConfig.value, relativeRow, relativeCol);
1683
1683
  if (formulaResult.status === _univerjs_engine_formula.FormulaResultStatus.SUCCESS && formulaResult.result !== void 0) return isFormulaResultMatched(formulaResult.result);
1684
1684
  const cache = preComputingResult === null || preComputingResult === void 0 ? void 0 : preComputingResult.value;
1685
- if (cache) return isFormulaResultMatched(cache.getValue(relativeRow, relativeCol));
1685
+ if (cache) {
1686
+ const value = cache.getValue(relativeRow, relativeCol);
1687
+ return isFormulaResultMatched(value);
1688
+ }
1686
1689
  return false;
1687
1690
  }
1688
1691
  }
@@ -1859,8 +1862,7 @@ let ConditionalFormattingViewModel = class ConditionalFormattingViewModel extend
1859
1862
  return result;
1860
1863
  }
1861
1864
  _getCellCfs(unitId, subUnitId, row, col) {
1862
- var _this$_conditionalFor;
1863
- const subunitRules = (_this$_conditionalFor = this._conditionalFormattingRuleModel.getSubunitRules(unitId, subUnitId)) !== null && _this$_conditionalFor !== void 0 ? _this$_conditionalFor : [];
1865
+ const subunitRules = this._conditionalFormattingRuleModel.getSubunitRules(unitId, subUnitId) ?? [];
1864
1866
  const _calculateUnitManagers = this._ensureCalculateUnitManager(unitId, subUnitId);
1865
1867
  const list = this._conditionalFormattingRangeIndexModel.getRuleIdsByCell(unitId, subUnitId, row, col);
1866
1868
  const rules = subunitRules.filter((rule) => list.has(rule.cfId));
@@ -2125,7 +2127,7 @@ const getCacheStyleMatrix = (unitId, subUnitId, rule, context) => {
2125
2127
  const cellCfItem = conditionalFormattingViewModel.getCellCfs(unitId, subUnitId, row, col);
2126
2128
  if (cellCfItem) {
2127
2129
  const item = cellCfItem.find((item) => item.cfId === rule.cfId);
2128
- !(item === null || item === void 0) && item.result && matrix.setValue(row, col, item.result);
2130
+ item !== null && item !== void 0 && item.result && matrix.setValue(row, col, item.result);
2129
2131
  }
2130
2132
  });
2131
2133
  });
@@ -2541,7 +2543,7 @@ for (const key in iconMap) {
2541
2543
  //#endregion
2542
2544
  //#region package.json
2543
2545
  var name = "@univerjs/sheets-conditional-formatting";
2544
- var version = "1.0.0-alpha.7";
2546
+ var version = "1.0.0-beta.0";
2545
2547
 
2546
2548
  //#endregion
2547
2549
  //#region src/config/config.ts
@@ -2933,7 +2935,7 @@ _defineProperty(UniverSheetsConditionalFormattingPlugin, "packageName", name);
2933
2935
  _defineProperty(UniverSheetsConditionalFormattingPlugin, "version", version);
2934
2936
  _defineProperty(UniverSheetsConditionalFormattingPlugin, "type", _univerjs_core.UniverInstanceType.UNIVER_SHEET);
2935
2937
  UniverSheetsConditionalFormattingPlugin = __decorate([
2936
- (0, _univerjs_core.DependentOn)(_univerjs_engine_formula.UniverFormulaEnginePlugin),
2938
+ (0, _univerjs_core.DependentOn)(_univerjs_engine_formula.UniverFormulaEnginePlugin, _univerjs_sheets.UniverSheetsPlugin),
2937
2939
  __decorateParam(1, (0, _univerjs_core.Inject)(_univerjs_core.Injector)),
2938
2940
  __decorateParam(2, (0, _univerjs_core.Inject)(_univerjs_core.ICommandService)),
2939
2941
  __decorateParam(3, _univerjs_core.IConfigService)
package/lib/es/facade.js CHANGED
@@ -3,7 +3,7 @@ import { AddCfCommand, CFNumberOperator, CFRuleType, CFSubRuleType, CFTextOperat
3
3
  import { FRange, FWorksheet } from "@univerjs/sheets/facade";
4
4
  import { FEnum } from "@univerjs/core/facade";
5
5
 
6
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/typeof.js
6
+ //#region \0@oxc-project+runtime@0.140.0/helpers/esm/typeof.js
7
7
  function _typeof(o) {
8
8
  "@babel/helpers - typeof";
9
9
  return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
@@ -14,7 +14,7 @@ function _typeof(o) {
14
14
  }
15
15
 
16
16
  //#endregion
17
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/toPrimitive.js
17
+ //#region \0@oxc-project+runtime@0.140.0/helpers/esm/toPrimitive.js
18
18
  function toPrimitive(t, r) {
19
19
  if ("object" != _typeof(t) || !t) return t;
20
20
  var e = t[Symbol.toPrimitive];
@@ -27,14 +27,14 @@ function toPrimitive(t, r) {
27
27
  }
28
28
 
29
29
  //#endregion
30
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/toPropertyKey.js
30
+ //#region \0@oxc-project+runtime@0.140.0/helpers/esm/toPropertyKey.js
31
31
  function toPropertyKey(t) {
32
32
  var i = toPrimitive(t, "string");
33
33
  return "symbol" == _typeof(i) ? i : i + "";
34
34
  }
35
35
 
36
36
  //#endregion
37
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/defineProperty.js
37
+ //#region \0@oxc-project+runtime@0.140.0/helpers/esm/defineProperty.js
38
38
  function _defineProperty(e, r, t) {
39
39
  return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
40
40
  value: t,
@@ -2116,50 +2116,6 @@ var FRangeSheetsConditionalFormattingMixin = class extends FRange {
2116
2116
  createConditionalFormattingRule() {
2117
2117
  return new FConditionalFormattingBuilder({ ranges: [this._range] });
2118
2118
  }
2119
- addConditionalFormattingRule(rule) {
2120
- const params = {
2121
- unitId: this._workbook.getUnitId(),
2122
- subUnitId: this._worksheet.getSheetId(),
2123
- rule
2124
- };
2125
- this._commandService.syncExecuteCommand(AddCfCommand.id, params);
2126
- return this;
2127
- }
2128
- deleteConditionalFormattingRule(cfId) {
2129
- const params = {
2130
- unitId: this._workbook.getUnitId(),
2131
- subUnitId: this._worksheet.getSheetId(),
2132
- cfId
2133
- };
2134
- this._commandService.syncExecuteCommand(DeleteCfCommand.id, params);
2135
- return this;
2136
- }
2137
- moveConditionalFormattingRule(cfId, toCfId, type = "after") {
2138
- const params = {
2139
- unitId: this._workbook.getUnitId(),
2140
- subUnitId: this._worksheet.getSheetId(),
2141
- start: {
2142
- id: cfId,
2143
- type: "self"
2144
- },
2145
- end: {
2146
- id: toCfId,
2147
- type
2148
- }
2149
- };
2150
- this._commandService.syncExecuteCommand(MoveCfCommand.id, params);
2151
- return this;
2152
- }
2153
- setConditionalFormattingRule(cfId, rule) {
2154
- const params = {
2155
- unitId: this._workbook.getUnitId(),
2156
- subUnitId: this._worksheet.getSheetId(),
2157
- rule,
2158
- cfId
2159
- };
2160
- this._commandService.syncExecuteCommand(SetCfCommand.id, params);
2161
- return this;
2162
- }
2163
2119
  clearConditionalFormatRules() {
2164
2120
  const params = {
2165
2121
  unitId: this._workbook.getUnitId(),
@@ -2181,9 +2137,6 @@ var FWorksheetConditionalFormattingMixin = class extends FWorksheet {
2181
2137
  getConditionalFormattingRules() {
2182
2138
  return [...this._getConditionalFormattingRuleModel().getSubunitRules(this._workbook.getUnitId(), this._worksheet.getSheetId()) || []];
2183
2139
  }
2184
- createConditionalFormattingRule() {
2185
- return new FConditionalFormattingBuilder();
2186
- }
2187
2140
  newConditionalFormattingRule() {
2188
2141
  return new FConditionalFormattingBuilder();
2189
2142
  }
package/lib/es/index.js CHANGED
@@ -1,5 +1,5 @@
1
- import { BooleanNumber, CellValueType, ColorKit, CommandType, DependentOn, Disposable, ICommandService, IConfigService, IResourceManagerService, IUndoRedoService, IUniverInstanceService, Inject, Injector, LRUMap, ObjectMatrix, Plugin, RTree, Range, Rectangle, RefAlias, Tools, UniverInstanceType, dateKit, generateRandomId, isInternalEditorID, merge, sequenceExecute, touchDependencies } from "@univerjs/core";
2
- import { CopySheetCommand, InsertColMutation, InsertRowMutation, MoveColsMutation, MoveRangeMutation, MoveRowsMutation, RemoveColMutation, RemoveRowMutation, RemoveSheetCommand, ReorderRangeMutation, SetRangeValuesMutation, SheetInterceptorService, SheetsSelectionsService, getSheetCommandTarget } from "@univerjs/sheets";
1
+ import { BooleanNumber, CellValueType, ColorKit, CommandType, DependentOn, Disposable, ICommandService, IConfigService, IResourceManagerService, IUndoRedoService, IUniverInstanceService, Inject, Injector, LRUMap, ObjectMatrix, Plugin, RTree, Range, Rectangle, RefAlias, Tools, UniverInstanceType, dateKit, generateRandomId, getIntersectRange, isInternalEditorID, merge, sequenceExecute, touchDependencies } from "@univerjs/core";
2
+ import { CopySheetCommand, InsertColMutation, InsertRowMutation, MoveColsMutation, MoveRangeMutation, MoveRowsMutation, RemoveColMutation, RemoveRowMutation, RemoveSheetCommand, ReorderRangeMutation, SetRangeValuesMutation, SheetInterceptorService, SheetsSelectionsService, UniverSheetsPlugin, getSheetCommandTarget } from "@univerjs/sheets";
3
3
  import { BehaviorSubject, Subject } from "rxjs";
4
4
  import { BooleanValue, ERROR_TYPE_SET, FormulaResultStatus, OtherFormulaBizType, RegisterOtherFormulaService, UniverFormulaEnginePlugin } from "@univerjs/engine-formula";
5
5
  import { bufferTime, distinctUntilChanged, filter, map } from "rxjs/operators";
@@ -220,7 +220,7 @@ const isAnchorEqual = (anchor1, anchor2) => {
220
220
  const createCfId = () => `${generateRandomId(8)}`;
221
221
 
222
222
  //#endregion
223
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/typeof.js
223
+ //#region \0@oxc-project+runtime@0.140.0/helpers/esm/typeof.js
224
224
  function _typeof(o) {
225
225
  "@babel/helpers - typeof";
226
226
  return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
@@ -231,7 +231,7 @@ function _typeof(o) {
231
231
  }
232
232
 
233
233
  //#endregion
234
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/toPrimitive.js
234
+ //#region \0@oxc-project+runtime@0.140.0/helpers/esm/toPrimitive.js
235
235
  function toPrimitive(t, r) {
236
236
  if ("object" != _typeof(t) || !t) return t;
237
237
  var e = t[Symbol.toPrimitive];
@@ -244,14 +244,14 @@ function toPrimitive(t, r) {
244
244
  }
245
245
 
246
246
  //#endregion
247
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/toPropertyKey.js
247
+ //#region \0@oxc-project+runtime@0.140.0/helpers/esm/toPropertyKey.js
248
248
  function toPropertyKey(t) {
249
249
  var i = toPrimitive(t, "string");
250
250
  return "symbol" == _typeof(i) ? i : i + "";
251
251
  }
252
252
 
253
253
  //#endregion
254
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/defineProperty.js
254
+ //#region \0@oxc-project+runtime@0.140.0/helpers/esm/defineProperty.js
255
255
  function _defineProperty(e, r, t) {
256
256
  return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
257
257
  value: t,
@@ -512,7 +512,7 @@ const AddCfCommand = {
512
512
  };
513
513
 
514
514
  //#endregion
515
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/decorateParam.js
515
+ //#region \0@oxc-project+runtime@0.140.0/helpers/esm/decorateParam.js
516
516
  function __decorateParam(paramIndex, decorator) {
517
517
  return function(target, key) {
518
518
  decorator(target, key, paramIndex);
@@ -520,7 +520,7 @@ function __decorateParam(paramIndex, decorator) {
520
520
  }
521
521
 
522
522
  //#endregion
523
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/decorate.js
523
+ //#region \0@oxc-project+runtime@0.140.0/helpers/esm/decorate.js
524
524
  function __decorate(decorators, target, key, desc) {
525
525
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
526
526
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -556,9 +556,8 @@ let ConditionalFormattingRangeIndexModel = class ConditionalFormattingRangeIndex
556
556
  return new Set(Array.from(ids).map((id) => String(id)));
557
557
  }
558
558
  getRulesByRanges(unitId, subUnitId, ranges) {
559
- var _this$_conditionalFor;
560
559
  const ids = this.getRuleIdsByRanges(unitId, subUnitId, ranges);
561
- return ((_this$_conditionalFor = this._conditionalFormattingRuleModel.getSubunitRules(unitId, subUnitId)) !== null && _this$_conditionalFor !== void 0 ? _this$_conditionalFor : []).filter((rule) => ids.has(rule.cfId));
560
+ return (this._conditionalFormattingRuleModel.getSubunitRules(unitId, subUnitId) ?? []).filter((rule) => ids.has(rule.cfId));
562
561
  }
563
562
  dispose() {
564
563
  this.clear();
@@ -632,7 +631,7 @@ var ConditionalFormattingRangeTransformService = class {
632
631
  copyIntersectingRanges(sourceRanges, sourceRange, targetAnchor) {
633
632
  const fragments = [];
634
633
  sourceRanges.forEach((range) => {
635
- const intersect = Rectangle.getIntersects(range, sourceRange);
634
+ const intersect = getIntersectRange(range, sourceRange);
636
635
  if (!intersect) return;
637
636
  fragments.push(this.translateRange(intersect, {
638
637
  row: targetAnchor.row - sourceRange.startRow,
@@ -687,7 +686,7 @@ const ClearRangeCfCommand = {
687
686
  type: CommandType.COMMAND,
688
687
  id: "sheet.command.clear-range-conditional-rule",
689
688
  handler(accessor, params) {
690
- var _ref, _params$ranges, _selectionManagerServ;
689
+ var _selectionManagerServ;
691
690
  if (!params) return false;
692
691
  const conditionalFormattingRangeIndexModel = accessor.get(ConditionalFormattingRangeIndexModel);
693
692
  const conditionalFormattingRangeTransformService = accessor.get(ConditionalFormattingRangeTransformService);
@@ -698,7 +697,7 @@ const ClearRangeCfCommand = {
698
697
  const target = getSheetCommandTarget(univerInstanceService, params);
699
698
  if (!target) return false;
700
699
  const { unitId, subUnitId } = target;
701
- const ranges = (_ref = (_params$ranges = params.ranges) !== null && _params$ranges !== void 0 ? _params$ranges : (_selectionManagerServ = selectionManagerService.getCurrentSelections()) === null || _selectionManagerServ === void 0 ? void 0 : _selectionManagerServ.map((selection) => selection.range)) !== null && _ref !== void 0 ? _ref : [];
700
+ const ranges = params.ranges ?? ((_selectionManagerServ = selectionManagerService.getCurrentSelections()) === null || _selectionManagerServ === void 0 ? void 0 : _selectionManagerServ.map((selection) => selection.range)) ?? [];
702
701
  const allRuleList = conditionalFormattingRangeIndexModel.getRulesByRanges(unitId, subUnitId, ranges).filter((rule) => {
703
702
  var _params$types;
704
703
  return !((_params$types = params.types) === null || _params$types === void 0 ? void 0 : _params$types.length) || params.types.includes(rule.rule.type);
@@ -709,13 +708,14 @@ const ClearRangeCfCommand = {
709
708
  allRuleList.forEach((oldRule) => {
710
709
  const newRanges = conditionalFormattingRangeTransformService.subtractRanges(oldRule.ranges, ranges);
711
710
  if (newRanges.length) {
711
+ const rule = {
712
+ ...oldRule,
713
+ ranges: newRanges
714
+ };
712
715
  const params = {
713
716
  unitId,
714
717
  subUnitId,
715
- rule: {
716
- ...oldRule,
717
- ranges: newRanges
718
- }
718
+ rule
719
719
  };
720
720
  const undo = setConditionalRuleMutationUndoFactory(accessor, params);
721
721
  redos.push({
@@ -1476,7 +1476,7 @@ var HighlightCellCalculateUnit = class extends BaseCalculateUnit {
1476
1476
  allValue.sort((a, b) => b - a);
1477
1477
  const configRule = context.rule.rule;
1478
1478
  if (configRule.isPercent) {
1479
- if (configRule.isBottom) allValue = allValue.toReversed();
1479
+ if (configRule.isBottom) allValue = allValue.slice().reverse();
1480
1480
  const threshold = Tools.clamp(configRule.value, 0, 100) / 100;
1481
1481
  const targetIndex = Math.floor(threshold * allValue.length);
1482
1482
  const safeIndex = Tools.clamp(targetIndex - 1, 0, allValue.length - 1);
@@ -1681,7 +1681,10 @@ var HighlightCellCalculateUnit = class extends BaseCalculateUnit {
1681
1681
  const formulaResult = conditionalFormattingFormulaService.getFormulaResultWithCoords(context.unitId, context.subUnitId, context.rule.cfId, _ruleConfig.value, relativeRow, relativeCol);
1682
1682
  if (formulaResult.status === FormulaResultStatus.SUCCESS && formulaResult.result !== void 0) return isFormulaResultMatched(formulaResult.result);
1683
1683
  const cache = preComputingResult === null || preComputingResult === void 0 ? void 0 : preComputingResult.value;
1684
- if (cache) return isFormulaResultMatched(cache.getValue(relativeRow, relativeCol));
1684
+ if (cache) {
1685
+ const value = cache.getValue(relativeRow, relativeCol);
1686
+ return isFormulaResultMatched(value);
1687
+ }
1685
1688
  return false;
1686
1689
  }
1687
1690
  }
@@ -1858,8 +1861,7 @@ let ConditionalFormattingViewModel = class ConditionalFormattingViewModel extend
1858
1861
  return result;
1859
1862
  }
1860
1863
  _getCellCfs(unitId, subUnitId, row, col) {
1861
- var _this$_conditionalFor;
1862
- const subunitRules = (_this$_conditionalFor = this._conditionalFormattingRuleModel.getSubunitRules(unitId, subUnitId)) !== null && _this$_conditionalFor !== void 0 ? _this$_conditionalFor : [];
1864
+ const subunitRules = this._conditionalFormattingRuleModel.getSubunitRules(unitId, subUnitId) ?? [];
1863
1865
  const _calculateUnitManagers = this._ensureCalculateUnitManager(unitId, subUnitId);
1864
1866
  const list = this._conditionalFormattingRangeIndexModel.getRuleIdsByCell(unitId, subUnitId, row, col);
1865
1867
  const rules = subunitRules.filter((rule) => list.has(rule.cfId));
@@ -2124,7 +2126,7 @@ const getCacheStyleMatrix = (unitId, subUnitId, rule, context) => {
2124
2126
  const cellCfItem = conditionalFormattingViewModel.getCellCfs(unitId, subUnitId, row, col);
2125
2127
  if (cellCfItem) {
2126
2128
  const item = cellCfItem.find((item) => item.cfId === rule.cfId);
2127
- !(item === null || item === void 0) && item.result && matrix.setValue(row, col, item.result);
2129
+ item !== null && item !== void 0 && item.result && matrix.setValue(row, col, item.result);
2128
2130
  }
2129
2131
  });
2130
2132
  });
@@ -2540,7 +2542,7 @@ for (const key in iconMap) {
2540
2542
  //#endregion
2541
2543
  //#region package.json
2542
2544
  var name = "@univerjs/sheets-conditional-formatting";
2543
- var version = "1.0.0-alpha.7";
2545
+ var version = "1.0.0-beta.0";
2544
2546
 
2545
2547
  //#endregion
2546
2548
  //#region src/config/config.ts
@@ -2932,7 +2934,7 @@ _defineProperty(UniverSheetsConditionalFormattingPlugin, "packageName", name);
2932
2934
  _defineProperty(UniverSheetsConditionalFormattingPlugin, "version", version);
2933
2935
  _defineProperty(UniverSheetsConditionalFormattingPlugin, "type", UniverInstanceType.UNIVER_SHEET);
2934
2936
  UniverSheetsConditionalFormattingPlugin = __decorate([
2935
- DependentOn(UniverFormulaEnginePlugin),
2937
+ DependentOn(UniverFormulaEnginePlugin, UniverSheetsPlugin),
2936
2938
  __decorateParam(1, Inject(Injector)),
2937
2939
  __decorateParam(2, Inject(ICommandService)),
2938
2940
  __decorateParam(3, IConfigService)
package/lib/facade.js CHANGED
@@ -3,7 +3,7 @@ import { AddCfCommand, CFNumberOperator, CFRuleType, CFSubRuleType, CFTextOperat
3
3
  import { FRange, FWorksheet } from "@univerjs/sheets/facade";
4
4
  import { FEnum } from "@univerjs/core/facade";
5
5
 
6
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/typeof.js
6
+ //#region \0@oxc-project+runtime@0.140.0/helpers/esm/typeof.js
7
7
  function _typeof(o) {
8
8
  "@babel/helpers - typeof";
9
9
  return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
@@ -14,7 +14,7 @@ function _typeof(o) {
14
14
  }
15
15
 
16
16
  //#endregion
17
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/toPrimitive.js
17
+ //#region \0@oxc-project+runtime@0.140.0/helpers/esm/toPrimitive.js
18
18
  function toPrimitive(t, r) {
19
19
  if ("object" != _typeof(t) || !t) return t;
20
20
  var e = t[Symbol.toPrimitive];
@@ -27,14 +27,14 @@ function toPrimitive(t, r) {
27
27
  }
28
28
 
29
29
  //#endregion
30
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/toPropertyKey.js
30
+ //#region \0@oxc-project+runtime@0.140.0/helpers/esm/toPropertyKey.js
31
31
  function toPropertyKey(t) {
32
32
  var i = toPrimitive(t, "string");
33
33
  return "symbol" == _typeof(i) ? i : i + "";
34
34
  }
35
35
 
36
36
  //#endregion
37
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/defineProperty.js
37
+ //#region \0@oxc-project+runtime@0.140.0/helpers/esm/defineProperty.js
38
38
  function _defineProperty(e, r, t) {
39
39
  return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
40
40
  value: t,
@@ -2116,50 +2116,6 @@ var FRangeSheetsConditionalFormattingMixin = class extends FRange {
2116
2116
  createConditionalFormattingRule() {
2117
2117
  return new FConditionalFormattingBuilder({ ranges: [this._range] });
2118
2118
  }
2119
- addConditionalFormattingRule(rule) {
2120
- const params = {
2121
- unitId: this._workbook.getUnitId(),
2122
- subUnitId: this._worksheet.getSheetId(),
2123
- rule
2124
- };
2125
- this._commandService.syncExecuteCommand(AddCfCommand.id, params);
2126
- return this;
2127
- }
2128
- deleteConditionalFormattingRule(cfId) {
2129
- const params = {
2130
- unitId: this._workbook.getUnitId(),
2131
- subUnitId: this._worksheet.getSheetId(),
2132
- cfId
2133
- };
2134
- this._commandService.syncExecuteCommand(DeleteCfCommand.id, params);
2135
- return this;
2136
- }
2137
- moveConditionalFormattingRule(cfId, toCfId, type = "after") {
2138
- const params = {
2139
- unitId: this._workbook.getUnitId(),
2140
- subUnitId: this._worksheet.getSheetId(),
2141
- start: {
2142
- id: cfId,
2143
- type: "self"
2144
- },
2145
- end: {
2146
- id: toCfId,
2147
- type
2148
- }
2149
- };
2150
- this._commandService.syncExecuteCommand(MoveCfCommand.id, params);
2151
- return this;
2152
- }
2153
- setConditionalFormattingRule(cfId, rule) {
2154
- const params = {
2155
- unitId: this._workbook.getUnitId(),
2156
- subUnitId: this._worksheet.getSheetId(),
2157
- rule,
2158
- cfId
2159
- };
2160
- this._commandService.syncExecuteCommand(SetCfCommand.id, params);
2161
- return this;
2162
- }
2163
2119
  clearConditionalFormatRules() {
2164
2120
  const params = {
2165
2121
  unitId: this._workbook.getUnitId(),
@@ -2181,9 +2137,6 @@ var FWorksheetConditionalFormattingMixin = class extends FWorksheet {
2181
2137
  getConditionalFormattingRules() {
2182
2138
  return [...this._getConditionalFormattingRuleModel().getSubunitRules(this._workbook.getUnitId(), this._worksheet.getSheetId()) || []];
2183
2139
  }
2184
- createConditionalFormattingRule() {
2185
- return new FConditionalFormattingBuilder();
2186
- }
2187
2140
  newConditionalFormattingRule() {
2188
2141
  return new FConditionalFormattingBuilder();
2189
2142
  }