@univerjs/sheets-conditional-formatting-ui 1.0.0-alpha.8 → 1.0.0-beta.1

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.
Files changed (87) hide show
  1. package/lib/cjs/index.js +300 -348
  2. package/lib/cjs/locale/ar-SA.js +2 -7
  3. package/lib/cjs/locale/ca-ES.js +2 -7
  4. package/lib/cjs/locale/de-DE.js +2 -7
  5. package/lib/cjs/locale/en-US.js +2 -7
  6. package/lib/cjs/locale/es-ES.js +2 -7
  7. package/lib/cjs/locale/fa-IR.js +2 -7
  8. package/lib/cjs/locale/fr-FR.js +2 -7
  9. package/lib/cjs/locale/id-ID.js +2 -7
  10. package/lib/cjs/locale/it-IT.js +2 -7
  11. package/lib/cjs/locale/ja-JP.js +2 -7
  12. package/lib/cjs/locale/ko-KR.js +2 -7
  13. package/lib/cjs/locale/pl-PL.js +2 -7
  14. package/lib/cjs/locale/pt-BR.js +2 -7
  15. package/lib/cjs/locale/ru-RU.js +2 -7
  16. package/lib/cjs/locale/sk-SK.js +2 -7
  17. package/lib/cjs/locale/vi-VN.js +2 -7
  18. package/lib/cjs/locale/zh-CN.js +2 -7
  19. package/lib/cjs/locale/zh-HK.js +2 -7
  20. package/lib/cjs/locale/zh-TW.js +2 -7
  21. package/lib/es/index.js +303 -351
  22. package/lib/es/locale/ar-SA.js +2 -7
  23. package/lib/es/locale/ca-ES.js +2 -7
  24. package/lib/es/locale/de-DE.js +2 -7
  25. package/lib/es/locale/en-US.js +2 -7
  26. package/lib/es/locale/es-ES.js +2 -7
  27. package/lib/es/locale/fa-IR.js +2 -7
  28. package/lib/es/locale/fr-FR.js +2 -7
  29. package/lib/es/locale/id-ID.js +2 -7
  30. package/lib/es/locale/it-IT.js +2 -7
  31. package/lib/es/locale/ja-JP.js +2 -7
  32. package/lib/es/locale/ko-KR.js +2 -7
  33. package/lib/es/locale/pl-PL.js +2 -7
  34. package/lib/es/locale/pt-BR.js +2 -7
  35. package/lib/es/locale/ru-RU.js +2 -7
  36. package/lib/es/locale/sk-SK.js +2 -7
  37. package/lib/es/locale/vi-VN.js +2 -7
  38. package/lib/es/locale/zh-CN.js +2 -7
  39. package/lib/es/locale/zh-HK.js +2 -7
  40. package/lib/es/locale/zh-TW.js +2 -7
  41. package/lib/index.css +40 -30
  42. package/lib/index.js +303 -351
  43. package/lib/locale/ar-SA.js +2 -7
  44. package/lib/locale/ca-ES.js +2 -7
  45. package/lib/locale/de-DE.js +2 -7
  46. package/lib/locale/en-US.js +2 -7
  47. package/lib/locale/es-ES.js +2 -7
  48. package/lib/locale/fa-IR.js +2 -7
  49. package/lib/locale/fr-FR.js +2 -7
  50. package/lib/locale/id-ID.js +2 -7
  51. package/lib/locale/it-IT.js +2 -7
  52. package/lib/locale/ja-JP.js +2 -7
  53. package/lib/locale/ko-KR.js +2 -7
  54. package/lib/locale/pl-PL.js +2 -7
  55. package/lib/locale/pt-BR.js +2 -7
  56. package/lib/locale/ru-RU.js +2 -7
  57. package/lib/locale/sk-SK.js +2 -7
  58. package/lib/locale/vi-VN.js +2 -7
  59. package/lib/locale/zh-CN.js +2 -7
  60. package/lib/locale/zh-HK.js +2 -7
  61. package/lib/locale/zh-TW.js +2 -7
  62. package/lib/types/controllers/cf.auto-fill.controller.d.ts +2 -3
  63. package/lib/types/controllers/cf.copy-paste.controller.d.ts +2 -3
  64. package/lib/types/controllers/cf.painter.controller.d.ts +2 -3
  65. package/lib/types/controllers/cf.render.controller.d.ts +7 -2
  66. package/lib/types/locale/en-US.d.ts +0 -5
  67. package/lib/umd/index.js +1 -1
  68. package/lib/umd/locale/ar-SA.js +1 -1
  69. package/lib/umd/locale/ca-ES.js +1 -1
  70. package/lib/umd/locale/de-DE.js +1 -1
  71. package/lib/umd/locale/en-US.js +1 -1
  72. package/lib/umd/locale/es-ES.js +1 -1
  73. package/lib/umd/locale/fa-IR.js +1 -1
  74. package/lib/umd/locale/fr-FR.js +1 -1
  75. package/lib/umd/locale/id-ID.js +1 -1
  76. package/lib/umd/locale/it-IT.js +1 -1
  77. package/lib/umd/locale/ja-JP.js +1 -1
  78. package/lib/umd/locale/ko-KR.js +1 -1
  79. package/lib/umd/locale/pl-PL.js +1 -1
  80. package/lib/umd/locale/pt-BR.js +1 -1
  81. package/lib/umd/locale/ru-RU.js +1 -1
  82. package/lib/umd/locale/sk-SK.js +1 -1
  83. package/lib/umd/locale/vi-VN.js +1 -1
  84. package/lib/umd/locale/zh-CN.js +1 -1
  85. package/lib/umd/locale/zh-HK.js +1 -1
  86. package/lib/umd/locale/zh-TW.js +1 -1
  87. package/package.json +14 -14
package/lib/cjs/index.js CHANGED
@@ -82,10 +82,9 @@ const AddDataBarConditionalRuleCommand = {
82
82
  type: _univerjs_core.CommandType.COMMAND,
83
83
  id: "sheet.command.add-data-bar-conditional-rule",
84
84
  handler(accessor, params) {
85
- var _params$ranges;
86
85
  if (!params) return false;
87
86
  const { min, max, nativeColor, positiveColor, isGradient, stopIfTrue, isShowValue } = params;
88
- const ranges = (_params$ranges = params.ranges) !== null && _params$ranges !== void 0 ? _params$ranges : accessor.get(_univerjs_sheets.SheetsSelectionsService).getCurrentSelections().map((selection) => selection.range);
87
+ const ranges = params.ranges ?? accessor.get(_univerjs_sheets.SheetsSelectionsService).getCurrentSelections().map((selection) => selection.range);
89
88
  if (!ranges.length) return false;
90
89
  const conditionalFormattingRuleModel = accessor.get(_univerjs_sheets_conditional_formatting.ConditionalFormattingRuleModel);
91
90
  const target = (0, _univerjs_sheets.getSheetCommandTarget)(accessor.get(_univerjs_core.IUniverInstanceService));
@@ -153,9 +152,8 @@ const AddIconSetConditionalRuleCommand = {
153
152
  type: _univerjs_core.CommandType.COMMAND,
154
153
  id: "sheet.command.add-icon-set-conditional-rule",
155
154
  handler(accessor, params) {
156
- var _params$ranges;
157
155
  if (!params) return false;
158
- const ranges = (_params$ranges = params.ranges) !== null && _params$ranges !== void 0 ? _params$ranges : accessor.get(_univerjs_sheets.SheetsSelectionsService).getCurrentSelections().map((selection) => selection.range);
156
+ const ranges = params.ranges ?? accessor.get(_univerjs_sheets.SheetsSelectionsService).getCurrentSelections().map((selection) => selection.range);
159
157
  if (!ranges.length) return false;
160
158
  const target = (0, _univerjs_sheets.getSheetCommandTarget)(accessor.get(_univerjs_core.IUniverInstanceService));
161
159
  if (!target) return false;
@@ -987,7 +985,7 @@ const menuSchema = {
987
985
  //#endregion
988
986
  //#region package.json
989
987
  var name = "@univerjs/sheets-conditional-formatting-ui";
990
- var version = "1.0.0-alpha.8";
988
+ var version = "1.0.0-beta.1";
991
989
 
992
990
  //#endregion
993
991
  //#region src/config/config.ts
@@ -1184,12 +1182,11 @@ const specialPastes = [
1184
1182
  _univerjs_sheets_ui.PREDEFINED_HOOK_NAME_PASTE.SPECIAL_PASTE_BESIDES_BORDER
1185
1183
  ];
1186
1184
  let ConditionalFormattingCopyPasteController = class ConditionalFormattingCopyPasteController extends _univerjs_core.Disposable {
1187
- constructor(_sheetClipboardService, _conditionalFormattingRuleModel, _injector, _conditionalFormattingViewModel, _univerInstanceService, _conditionalFormattingRangeTransformService) {
1185
+ constructor(_sheetClipboardService, _conditionalFormattingRuleModel, _injector, _univerInstanceService, _conditionalFormattingRangeTransformService) {
1188
1186
  super();
1189
1187
  this._sheetClipboardService = _sheetClipboardService;
1190
1188
  this._conditionalFormattingRuleModel = _conditionalFormattingRuleModel;
1191
1189
  this._injector = _injector;
1192
- this._conditionalFormattingViewModel = _conditionalFormattingViewModel;
1193
1190
  this._univerInstanceService = _univerInstanceService;
1194
1191
  this._conditionalFormattingRangeTransformService = _conditionalFormattingRangeTransformService;
1195
1192
  _defineProperty(this, "_copyInfo", void 0);
@@ -1209,10 +1206,11 @@ let ConditionalFormattingCopyPasteController = class ConditionalFormattingCopyPa
1209
1206
  }));
1210
1207
  }
1211
1208
  _collectConditionalRule(unitId, subUnitId, range) {
1212
- const matrix = new _univerjs_core.ObjectMatrix();
1209
+ var _this$_conditionalFor;
1210
+ const rules = /* @__PURE__ */ new Map();
1213
1211
  const cfMap = {};
1214
1212
  this._copyInfo = {
1215
- matrix,
1213
+ rules,
1216
1214
  info: {
1217
1215
  unitId,
1218
1216
  subUnitId,
@@ -1223,22 +1221,28 @@ let ConditionalFormattingCopyPasteController = class ConditionalFormattingCopyPa
1223
1221
  return (0, _univerjs_sheets.rangeToDiscreteRange)(range, accessor, unitId, subUnitId);
1224
1222
  });
1225
1223
  if (!discreteRange) return;
1226
- const { rows, cols } = discreteRange;
1227
- const cfIdSet = /* @__PURE__ */ new Set();
1228
- rows.forEach((row, rowIndex) => {
1229
- cols.forEach((col, colIndex) => {
1230
- const cellCfList = this._conditionalFormattingViewModel.getCellCfs(unitId, subUnitId, row, col);
1231
- if (!cellCfList) return;
1232
- cellCfList.forEach((item) => cfIdSet.add(item.cfId));
1233
- matrix.setValue(rowIndex, colIndex, cellCfList.map((item) => item.cfId));
1224
+ const { projectRange } = (0, _univerjs_sheets_ui.virtualizeDiscreteRanges)([discreteRange]);
1225
+ (_this$_conditionalFor = this._conditionalFormattingRuleModel.getSubunitRules(unitId, subUnitId)) === null || _this$_conditionalFor === void 0 || _this$_conditionalFor.forEach((rule) => {
1226
+ const projectedRanges = rule.ranges.flatMap((ruleRange) => {
1227
+ const projected = projectRange(ruleRange);
1228
+ return projected ? [projected] : [];
1234
1229
  });
1235
- });
1236
- cfIdSet.forEach((cfId) => {
1237
- const rule = this._conditionalFormattingRuleModel.getRule(unitId, subUnitId, cfId);
1238
- if (rule) cfMap[cfId] = rule.rule;
1230
+ if (projectedRanges.length) {
1231
+ rules.set(rule.cfId, projectedRanges.length > 1 ? _univerjs_core.Rectangle.mergeRanges(projectedRanges) : projectedRanges);
1232
+ cfMap[rule.cfId] = {
1233
+ rule: rule.rule,
1234
+ stopIfTrue: rule.stopIfTrue
1235
+ };
1236
+ }
1239
1237
  });
1240
1238
  }
1241
1239
  _generateConditionalFormattingMutations(pasteFrom, pasteTo, payload) {
1240
+ var _this$_conditionalFor2;
1241
+ const copyInfo = this._copyInfo;
1242
+ if (!copyInfo) return {
1243
+ redos: [],
1244
+ undos: []
1245
+ };
1242
1246
  const { unitId: copyUnitId, subUnitId: copySubUnitId, range: copyRange } = pasteFrom;
1243
1247
  const { unitId: pastedUnitId, subUnitId: pastedSubUnitId, range: pastedRange } = pasteTo;
1244
1248
  const { copyType = _univerjs_sheets_ui.COPY_TYPE.COPY } = payload;
@@ -1256,109 +1260,86 @@ let ConditionalFormattingCopyPasteController = class ConditionalFormattingCopyPa
1256
1260
  undos: []
1257
1261
  };
1258
1262
  }
1259
- const { ranges: [vCopyRange, vPastedRange], mapFunc } = (0, _univerjs_sheets_ui.virtualizeDiscreteRanges)([copyRange, pastedRange]);
1260
- const repeatRange = (0, _univerjs_sheets_ui.getRepeatRange)(vCopyRange, vPastedRange, true);
1261
- const effectedConditionalFormattingRuleRanges = {};
1262
- _univerjs_core.Range.foreach(vPastedRange, (row, col) => {
1263
- const { row: realRow, col: realCol } = mapFunc(row, col);
1264
- const cellCfList = this._conditionalFormattingViewModel.getCellCfs(pastedUnitId, pastedSubUnitId, realRow, realCol);
1265
- if (cellCfList) cellCfList.forEach((item) => {
1266
- if (!effectedConditionalFormattingRuleRanges[item.cfId]) {
1267
- const rule = this._conditionalFormattingRuleModel.getRule(pastedUnitId, pastedSubUnitId, item.cfId);
1268
- if (!rule) return;
1269
- effectedConditionalFormattingRuleRanges[item.cfId] = {
1270
- unitId: pastedUnitId,
1271
- subUnitId: pastedSubUnitId,
1272
- ranges: rule.ranges,
1273
- add: [],
1274
- remove: []
1275
- };
1276
- }
1277
- effectedConditionalFormattingRuleRanges[item.cfId].remove.push({
1278
- startRow: realRow,
1279
- endRow: realRow,
1280
- startColumn: realCol,
1281
- endColumn: realCol
1282
- });
1263
+ const sourceVirtualization = (0, _univerjs_sheets_ui.virtualizeDiscreteRanges)([copyRange]);
1264
+ const sourceVirtualRange = sourceVirtualization.ranges[0];
1265
+ const targetVirtualization = (0, _univerjs_sheets_ui.virtualizeDiscreteRanges)([pastedRange]);
1266
+ const targetVirtualRange = targetVirtualization.ranges[0];
1267
+ const repeatRange = (0, _univerjs_sheets_ui.getRepeatRange)(sourceVirtualRange, targetVirtualRange, true);
1268
+ const targetRanges = targetVirtualization.mapRange(targetVirtualRange);
1269
+ const isSameSheet = pastedUnitId === copyUnitId && pastedSubUnitId === copySubUnitId;
1270
+ const effectedConditionalFormattingRuleRanges = /* @__PURE__ */ new Map();
1271
+ const getEffectKey = (unitId, subUnitId, cfId) => JSON.stringify([
1272
+ unitId,
1273
+ subUnitId,
1274
+ cfId
1275
+ ]);
1276
+ (_this$_conditionalFor2 = this._conditionalFormattingRuleModel.getSubunitRules(pastedUnitId, pastedSubUnitId)) === null || _this$_conditionalFor2 === void 0 || _this$_conditionalFor2.forEach((rule) => {
1277
+ if (!_univerjs_core.Rectangle.doAnyRangesIntersect(rule.ranges, targetRanges)) return;
1278
+ effectedConditionalFormattingRuleRanges.set(getEffectKey(pastedUnitId, pastedSubUnitId, rule.cfId), {
1279
+ cfId: rule.cfId,
1280
+ unitId: pastedUnitId,
1281
+ subUnitId: pastedSubUnitId,
1282
+ ranges: rule.ranges,
1283
+ add: [],
1284
+ remove: targetRanges
1283
1285
  });
1284
1286
  });
1285
- if (copyType === _univerjs_sheets_ui.COPY_TYPE.CUT && (pastedUnitId !== copyUnitId || pastedSubUnitId !== copySubUnitId)) _univerjs_core.Range.foreach(vCopyRange, (row, col) => {
1286
- const { row: realRow, col: realCol } = mapFunc(row, col);
1287
- const cellCfList = this._conditionalFormattingViewModel.getCellCfs(copyUnitId, copySubUnitId, realRow, realCol);
1288
- if (cellCfList) cellCfList.forEach((item) => {
1289
- if (!effectedConditionalFormattingRuleRanges[item.cfId]) {
1290
- const rule = this._conditionalFormattingRuleModel.getRule(copyUnitId, copySubUnitId, item.cfId);
1291
- if (!rule) return;
1292
- effectedConditionalFormattingRuleRanges[item.cfId] = {
1293
- unitId: copyUnitId,
1294
- subUnitId: copySubUnitId,
1295
- ranges: rule.ranges,
1296
- add: [],
1297
- remove: []
1298
- };
1299
- }
1300
- effectedConditionalFormattingRuleRanges[item.cfId].remove.push({
1301
- startRow: realRow,
1302
- endRow: realRow,
1303
- startColumn: realCol,
1304
- endColumn: realCol
1287
+ if (copyType === _univerjs_sheets_ui.COPY_TYPE.CUT && (pastedUnitId !== copyUnitId || pastedSubUnitId !== copySubUnitId)) {
1288
+ const sourceRanges = sourceVirtualization.mapRange(sourceVirtualRange);
1289
+ copyInfo.rules.forEach((_ranges, cfId) => {
1290
+ const rule = this._conditionalFormattingRuleModel.getRule(copyUnitId, copySubUnitId, cfId);
1291
+ if (!rule) return;
1292
+ effectedConditionalFormattingRuleRanges.set(getEffectKey(copyUnitId, copySubUnitId, cfId), {
1293
+ cfId,
1294
+ unitId: copyUnitId,
1295
+ subUnitId: copySubUnitId,
1296
+ ranges: rule.ranges,
1297
+ add: [],
1298
+ remove: sourceRanges
1305
1299
  });
1306
1300
  });
1307
- });
1308
- const { matrix, info } = this._copyInfo;
1309
- const waitAddRule = [];
1301
+ }
1302
+ const { rules, info } = copyInfo;
1303
+ const waitAddRule = /* @__PURE__ */ new Map();
1310
1304
  const cacheCfIdMap = {};
1311
1305
  const getCurrentSheetCfRule = (copyRangeCfId) => {
1312
1306
  const oldRule = info === null || info === void 0 ? void 0 : info.cfMap[copyRangeCfId];
1313
- const targetRule = [...this._conditionalFormattingRuleModel.getSubunitRules(pastedUnitId, pastedSubUnitId) || [], ...waitAddRule].find((rule) => {
1314
- return _univerjs_core.Tools.diffValue(rule.rule, oldRule);
1315
- });
1316
- if (targetRule) {
1317
- cacheCfIdMap[copyRangeCfId] = targetRule;
1318
- return targetRule;
1319
- } else {
1320
- const rule = {
1321
- rule: oldRule,
1322
- cfId: this._conditionalFormattingRuleModel.createCfId(pastedUnitId, pastedSubUnitId),
1323
- ranges: [],
1324
- stopIfTrue: false
1325
- };
1326
- cacheCfIdMap[copyRangeCfId] = rule;
1327
- waitAddRule.push(rule);
1328
- return rule;
1307
+ if (isSameSheet) {
1308
+ const rule = this._conditionalFormattingRuleModel.getRule(pastedUnitId, pastedSubUnitId, copyRangeCfId);
1309
+ if (rule) {
1310
+ cacheCfIdMap[copyRangeCfId] = rule;
1311
+ return rule;
1312
+ }
1329
1313
  }
1314
+ const rule = {
1315
+ rule: oldRule.rule,
1316
+ cfId: this._conditionalFormattingRuleModel.createCfId(pastedUnitId, pastedSubUnitId),
1317
+ ranges: [],
1318
+ stopIfTrue: oldRule.stopIfTrue
1319
+ };
1320
+ cacheCfIdMap[copyRangeCfId] = rule;
1321
+ waitAddRule.set(rule.cfId, rule);
1322
+ return rule;
1330
1323
  };
1331
- repeatRange.forEach((item) => {
1332
- matrix && matrix.forValue((row, col, copyRangeCfIdList) => {
1333
- const range = _univerjs_core.Rectangle.getPositionRange({
1334
- startRow: row,
1335
- endRow: row,
1336
- startColumn: col,
1337
- endColumn: col
1338
- }, item.startRange);
1339
- const { row: _row, col: _col } = mapFunc(range.startRow, range.startColumn);
1340
- copyRangeCfIdList.forEach((cfId) => {
1341
- const rule = cacheCfIdMap[cfId] || getCurrentSheetCfRule(cfId);
1342
- if (!effectedConditionalFormattingRuleRanges[rule.cfId]) effectedConditionalFormattingRuleRanges[rule.cfId] = {
1343
- unitId: pastedUnitId,
1344
- subUnitId: pastedSubUnitId,
1345
- ranges: rule.ranges,
1346
- add: [],
1347
- remove: []
1348
- };
1349
- effectedConditionalFormattingRuleRanges[rule.cfId].add.push({
1350
- startRow: _row,
1351
- endRow: _row,
1352
- startColumn: _col,
1353
- endColumn: _col
1354
- });
1355
- });
1324
+ const sourceRuleEntries = Array.from(rules.entries());
1325
+ if (!isSameSheet) sourceRuleEntries.reverse();
1326
+ sourceRuleEntries.forEach(([cfId, sourceRanges]) => {
1327
+ const rule = cacheCfIdMap[cfId] || getCurrentSheetCfRule(cfId);
1328
+ const effectKey = getEffectKey(pastedUnitId, pastedSubUnitId, rule.cfId);
1329
+ if (!effectedConditionalFormattingRuleRanges.has(effectKey)) effectedConditionalFormattingRuleRanges.set(effectKey, {
1330
+ cfId: rule.cfId,
1331
+ unitId: pastedUnitId,
1332
+ subUnitId: pastedSubUnitId,
1333
+ ranges: rule.ranges,
1334
+ add: [],
1335
+ remove: []
1356
1336
  });
1337
+ effectedConditionalFormattingRuleRanges.get(effectKey).add.push(...repeatRange.flatMap((item) => sourceRanges.flatMap((sourceRange) => targetVirtualization.mapRange(_univerjs_core.Rectangle.getPositionRange(sourceRange, item.startRange)))));
1357
1338
  });
1358
1339
  const redos = [];
1359
1340
  const undos = [];
1360
- for (const cfId in effectedConditionalFormattingRuleRanges) {
1361
- const { unitId, subUnitId, ranges: sourceRanges, add, remove } = effectedConditionalFormattingRuleRanges[cfId];
1341
+ for (const effect of effectedConditionalFormattingRuleRanges.values()) {
1342
+ const { cfId, unitId, subUnitId, ranges: sourceRanges, add, remove } = effect;
1362
1343
  const ranges = this._conditionalFormattingRangeTransformService.applyRangeDelta(sourceRanges, remove, add);
1363
1344
  if (!ranges.length) {
1364
1345
  const deleteParams = {
@@ -1371,13 +1352,15 @@ let ConditionalFormattingCopyPasteController = class ConditionalFormattingCopyPa
1371
1352
  params: deleteParams
1372
1353
  });
1373
1354
  undos.push(...(0, _univerjs_sheets_conditional_formatting.DeleteConditionalRuleMutationUndoFactory)(this._injector, deleteParams));
1355
+ continue;
1374
1356
  }
1375
- if (waitAddRule.some((rule) => rule.cfId === cfId)) {
1357
+ const waitAdd = waitAddRule.get(cfId);
1358
+ if (waitAdd) {
1376
1359
  const addParams = {
1377
1360
  unitId: pastedUnitId,
1378
1361
  subUnitId: pastedSubUnitId,
1379
1362
  rule: {
1380
- ...waitAddRule.find((rule) => rule.cfId === cfId),
1363
+ ...waitAdd,
1381
1364
  ranges
1382
1365
  }
1383
1366
  };
@@ -1414,9 +1397,8 @@ ConditionalFormattingCopyPasteController = __decorate([
1414
1397
  __decorateParam(0, (0, _univerjs_core.Inject)(_univerjs_sheets_ui.ISheetClipboardService)),
1415
1398
  __decorateParam(1, (0, _univerjs_core.Inject)(_univerjs_sheets_conditional_formatting.ConditionalFormattingRuleModel)),
1416
1399
  __decorateParam(2, (0, _univerjs_core.Inject)(_univerjs_core.Injector)),
1417
- __decorateParam(3, (0, _univerjs_core.Inject)(_univerjs_sheets_conditional_formatting.ConditionalFormattingViewModel)),
1418
- __decorateParam(4, (0, _univerjs_core.Inject)(_univerjs_core.IUniverInstanceService)),
1419
- __decorateParam(5, (0, _univerjs_core.Inject)(_univerjs_sheets_conditional_formatting.ConditionalFormattingRangeTransformService))
1400
+ __decorateParam(3, (0, _univerjs_core.Inject)(_univerjs_core.IUniverInstanceService)),
1401
+ __decorateParam(4, (0, _univerjs_core.Inject)(_univerjs_sheets_conditional_formatting.ConditionalFormattingRangeTransformService))
1420
1402
  ], ConditionalFormattingCopyPasteController);
1421
1403
 
1422
1404
  //#endregion
@@ -1502,7 +1484,7 @@ ConditionalFormattingPermissionController = __decorate([
1502
1484
  //#endregion
1503
1485
  //#region src/controllers/cf.render.controller.ts
1504
1486
  let SheetsCfRenderController = class SheetsCfRenderController extends _univerjs_core.Disposable {
1505
- constructor(_sheetInterceptorService, _conditionalFormattingService, _univerInstanceService, _renderManagerService, _conditionalFormattingViewModel, _conditionalFormattingRuleModel) {
1487
+ constructor(_sheetInterceptorService, _conditionalFormattingService, _univerInstanceService, _renderManagerService, _conditionalFormattingViewModel, _conditionalFormattingRuleModel, _conditionalFormattingRangeIndexModel) {
1506
1488
  super();
1507
1489
  this._sheetInterceptorService = _sheetInterceptorService;
1508
1490
  this._conditionalFormattingService = _conditionalFormattingService;
@@ -1510,20 +1492,75 @@ let SheetsCfRenderController = class SheetsCfRenderController extends _univerjs_
1510
1492
  this._renderManagerService = _renderManagerService;
1511
1493
  this._conditionalFormattingViewModel = _conditionalFormattingViewModel;
1512
1494
  this._conditionalFormattingRuleModel = _conditionalFormattingRuleModel;
1495
+ this._conditionalFormattingRangeIndexModel = _conditionalFormattingRangeIndexModel;
1513
1496
  _defineProperty(this, "_ruleChangeCacheMap", /* @__PURE__ */ new Map());
1497
+ _defineProperty(this, "_boundRenderExtensions", /* @__PURE__ */ new Map());
1514
1498
  this._initViewModelInterceptor();
1499
+ this._initRenderRangeResolvers();
1515
1500
  this._initSkeleton();
1516
1501
  queueMicrotask(() => this._markActiveSheetRulesDirty());
1517
1502
  this.disposeWithMe(() => {
1518
1503
  this._ruleChangeCacheMap.clear();
1504
+ this._boundRenderExtensions.forEach((extensions) => {
1505
+ extensions.forEach((extension) => extension.setRenderRangeResolver(null));
1506
+ });
1507
+ this._boundRenderExtensions.clear();
1519
1508
  });
1520
1509
  }
1510
+ _initRenderRangeResolvers() {
1511
+ const dataBarResolver = this._createRenderRangeResolver(_univerjs_sheets_conditional_formatting.CFRuleType.dataBar);
1512
+ const iconResolver = this._createRenderRangeResolver(_univerjs_sheets_conditional_formatting.CFRuleType.iconSet);
1513
+ const bind = (unitId) => {
1514
+ var _this$_renderManagerS;
1515
+ this._unbindRenderRangeResolvers(unitId);
1516
+ const mainComponent = (_this$_renderManagerS = this._renderManagerService.getRenderUnitById(unitId)) === null || _this$_renderManagerS === void 0 ? void 0 : _this$_renderManagerS.mainComponent;
1517
+ if (!mainComponent || !("getExtensionByKey" in mainComponent)) return;
1518
+ const extensions = /* @__PURE__ */ new Set();
1519
+ const dataBar = mainComponent.getExtensionByKey(_univerjs_sheets_conditional_formatting.dataBarUKey);
1520
+ if (dataBar instanceof _univerjs_sheets_conditional_formatting.DataBar) {
1521
+ dataBar.setRenderRangeResolver(dataBarResolver);
1522
+ extensions.add(dataBar);
1523
+ }
1524
+ const icon = mainComponent.getExtensionByKey(_univerjs_sheets_conditional_formatting.IconUKey);
1525
+ if (icon instanceof _univerjs_sheets_conditional_formatting.ConditionalFormattingIcon) {
1526
+ icon.setRenderRangeResolver(iconResolver);
1527
+ extensions.add(icon);
1528
+ }
1529
+ if (extensions.size) this._boundRenderExtensions.set(unitId, extensions);
1530
+ };
1531
+ this._renderManagerService.getAllRenderersOfType(_univerjs_core.UniverInstanceType.UNIVER_SHEET).forEach((render) => bind(render.unitId));
1532
+ this.disposeWithMe(this._renderManagerService.created$.subscribe((render) => {
1533
+ if (render.type === _univerjs_core.UniverInstanceType.UNIVER_SHEET) bind(render.unitId);
1534
+ }));
1535
+ this.disposeWithMe(this._renderManagerService.disposed$.subscribe((unitId) => this._unbindRenderRangeResolvers(unitId)));
1536
+ }
1537
+ _createRenderRangeResolver(ruleType) {
1538
+ return (unitId, subUnitId, ranges) => {
1539
+ const intersections = [];
1540
+ const indexedRules = this._conditionalFormattingRangeIndexModel.getRulesByRanges(unitId, subUnitId, ranges).filter((rule) => rule.rule.type === ruleType);
1541
+ const matchingRules = indexedRules.length ? indexedRules : (this._conditionalFormattingRuleModel.getSubunitRules(unitId, subUnitId) ?? []).filter((rule) => rule.rule.type === ruleType);
1542
+ ranges.forEach((range) => {
1543
+ matchingRules.forEach((rule) => {
1544
+ rule.ranges.forEach((ruleRange) => {
1545
+ const intersection = (0, _univerjs_core.getIntersectRange)(range, ruleRange);
1546
+ if (intersection) intersections.push(intersection);
1547
+ });
1548
+ });
1549
+ });
1550
+ return intersections.length > 1 ? _univerjs_core.Rectangle.mergeRanges(intersections) : intersections;
1551
+ };
1552
+ }
1553
+ _unbindRenderRangeResolvers(unitId) {
1554
+ const extensions = this._boundRenderExtensions.get(unitId);
1555
+ extensions === null || extensions === void 0 || extensions.forEach((extension) => extension.setRenderRangeResolver(null));
1556
+ this._boundRenderExtensions.delete(unitId);
1557
+ }
1521
1558
  _collectDirtyRanges(items, unitId, subUnitId) {
1522
1559
  const ranges = [];
1523
1560
  items.forEach((item) => {
1524
- var _item$rule, _rule$ranges;
1561
+ var _rule$ranges;
1525
1562
  if (item.unitId !== unitId || item.subUnitId !== subUnitId) return;
1526
- const rule = (_item$rule = item.rule) !== null && _item$rule !== void 0 ? _item$rule : item.cfId ? this._conditionalFormattingRuleModel.getRule(unitId, subUnitId, item.cfId) : null;
1563
+ const rule = item.rule ?? (item.cfId ? this._conditionalFormattingRuleModel.getRule(unitId, subUnitId, item.cfId) : null);
1527
1564
  if (rule === null || rule === void 0 || (_rule$ranges = rule.ranges) === null || _rule$ranges === void 0 ? void 0 : _rule$ranges.length) ranges.push(...rule.ranges);
1528
1565
  });
1529
1566
  return ranges;
@@ -1553,13 +1590,12 @@ let SheetsCfRenderController = class SheetsCfRenderController extends _univerjs_
1553
1590
  render === null || render === void 0 || (_render$mainComponent = render.mainComponent) === null || _render$mainComponent === void 0 || _render$mainComponent.makeDirty();
1554
1591
  }
1555
1592
  _markActiveSheetRulesDirty() {
1556
- var _this$_conditionalFor;
1557
1593
  const workbook = this._univerInstanceService.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_SHEET);
1558
1594
  const worksheet = workbook === null || workbook === void 0 ? void 0 : workbook.getActiveSheet();
1559
1595
  if (!workbook || !worksheet) return;
1560
1596
  const unitId = workbook.getUnitId();
1561
1597
  const subUnitId = worksheet.getSheetId();
1562
- const rules = (_this$_conditionalFor = this._conditionalFormattingRuleModel.getSubunitRules(unitId, subUnitId)) !== null && _this$_conditionalFor !== void 0 ? _this$_conditionalFor : [];
1598
+ const rules = this._conditionalFormattingRuleModel.getSubunitRules(unitId, subUnitId) ?? [];
1563
1599
  if (!rules.length) return;
1564
1600
  this._markDirtySkeleton(rules.map((rule) => ({
1565
1601
  rule,
@@ -1613,7 +1649,8 @@ SheetsCfRenderController = __decorate([
1613
1649
  __decorateParam(2, (0, _univerjs_core.Inject)(_univerjs_core.IUniverInstanceService)),
1614
1650
  __decorateParam(3, (0, _univerjs_core.Inject)(_univerjs_engine_render.IRenderManagerService)),
1615
1651
  __decorateParam(4, (0, _univerjs_core.Inject)(_univerjs_sheets_conditional_formatting.ConditionalFormattingViewModel)),
1616
- __decorateParam(5, (0, _univerjs_core.Inject)(_univerjs_sheets_conditional_formatting.ConditionalFormattingRuleModel))
1652
+ __decorateParam(5, (0, _univerjs_core.Inject)(_univerjs_sheets_conditional_formatting.ConditionalFormattingRuleModel)),
1653
+ __decorateParam(6, (0, _univerjs_core.Inject)(_univerjs_sheets_conditional_formatting.ConditionalFormattingRangeIndexModel))
1617
1654
  ], SheetsCfRenderController);
1618
1655
 
1619
1656
  //#endregion
@@ -1667,13 +1704,12 @@ UniverSheetsConditionalFormattingMobileUIPlugin = __decorate([
1667
1704
  //#endregion
1668
1705
  //#region src/controllers/cf.auto-fill.controller.ts
1669
1706
  let ConditionalFormattingAutoFillController = class ConditionalFormattingAutoFillController extends _univerjs_core.Disposable {
1670
- constructor(_injector, _univerInstanceService, _autoFillService, _conditionalFormattingRuleModel, _conditionalFormattingViewModel, _conditionalFormattingRangeTransformService) {
1707
+ constructor(_injector, _univerInstanceService, _autoFillService, _conditionalFormattingRuleModel, _conditionalFormattingRangeTransformService) {
1671
1708
  super();
1672
1709
  this._injector = _injector;
1673
1710
  this._univerInstanceService = _univerInstanceService;
1674
1711
  this._autoFillService = _autoFillService;
1675
1712
  this._conditionalFormattingRuleModel = _conditionalFormattingRuleModel;
1676
- this._conditionalFormattingViewModel = _conditionalFormattingViewModel;
1677
1713
  this._conditionalFormattingRangeTransformService = _conditionalFormattingRangeTransformService;
1678
1714
  this._initAutoFill();
1679
1715
  }
@@ -1682,11 +1718,24 @@ let ConditionalFormattingAutoFillController = class ConditionalFormattingAutoFil
1682
1718
  redos: [],
1683
1719
  undos: []
1684
1720
  });
1685
- const loopFunc = (sourceStartCell, targetStartCell, relativeRange, rangeMap, rangeDeltaMap, mapFunc) => {
1686
- var _getActiveSheet;
1687
- const unitId = this._univerInstanceService.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_SHEET).getUnitId();
1688
- const subUnitId = (_getActiveSheet = this._univerInstanceService.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_SHEET).getActiveSheet()) === null || _getActiveSheet === void 0 ? void 0 : _getActiveSheet.getSheetId();
1689
- if (!unitId || !subUnitId) return;
1721
+ const generalApplyFunc = (sourceRange, targetRange) => {
1722
+ var _this$_univerInstance, _this$_univerInstance2;
1723
+ const unitId = (_this$_univerInstance = this._univerInstanceService.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_SHEET)) === null || _this$_univerInstance === void 0 ? void 0 : _this$_univerInstance.getUnitId();
1724
+ const subUnitId = (_this$_univerInstance2 = this._univerInstanceService.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_SHEET)) === null || _this$_univerInstance2 === void 0 || (_this$_univerInstance2 = _this$_univerInstance2.getActiveSheet()) === null || _this$_univerInstance2 === void 0 ? void 0 : _this$_univerInstance2.getSheetId();
1725
+ const rangeMap = /* @__PURE__ */ new Map();
1726
+ const rangeDeltaMap = /* @__PURE__ */ new Map();
1727
+ const redos = [];
1728
+ const undos = [];
1729
+ if (!unitId || !subUnitId) return noopReturnFunc();
1730
+ const virtualization = (0, _univerjs_sheets_ui.virtualizeDiscreteRanges)([sourceRange, targetRange]);
1731
+ const [vSourceRange, vTargetRange] = virtualization.ranges;
1732
+ const repeats = _univerjs_sheets.AutoFillTools.getAutoFillRepeatRange(vSourceRange, vTargetRange);
1733
+ const targetRanges = repeats.flatMap((repeat) => virtualization.mapRange(_univerjs_core.Rectangle.getPositionRange(repeat.relativeRange, {
1734
+ startRow: repeat.repeatStartCell.row,
1735
+ endRow: repeat.repeatStartCell.row,
1736
+ startColumn: repeat.repeatStartCell.col,
1737
+ endColumn: repeat.repeatStartCell.col
1738
+ })));
1690
1739
  const getRangeDelta = (cfId) => {
1691
1740
  let rangeDelta = rangeDeltaMap.get(cfId);
1692
1741
  if (!rangeDelta) {
@@ -1698,80 +1747,29 @@ let ConditionalFormattingAutoFillController = class ConditionalFormattingAutoFil
1698
1747
  }
1699
1748
  return rangeDelta;
1700
1749
  };
1701
- const ensureRuleRanges = (cfId) => {
1702
- if (rangeMap.has(cfId)) return true;
1703
- const rule = this._conditionalFormattingRuleModel.getRule(unitId, subUnitId, cfId);
1704
- if (!rule) return false;
1705
- rangeMap.set(cfId, rule.ranges);
1706
- return true;
1707
- };
1708
- const sourceRange = {
1709
- startRow: sourceStartCell.row,
1710
- startColumn: sourceStartCell.col,
1711
- endColumn: sourceStartCell.col,
1712
- endRow: sourceStartCell.row
1713
- };
1714
- const targetRange = {
1715
- startRow: targetStartCell.row,
1716
- startColumn: targetStartCell.col,
1717
- endColumn: targetStartCell.col,
1718
- endRow: targetStartCell.row
1719
- };
1720
- _univerjs_core.Range.foreach(relativeRange, (row, col) => {
1721
- const sourcePositionRange = _univerjs_core.Rectangle.getPositionRange({
1722
- startRow: row,
1723
- startColumn: col,
1724
- endColumn: col,
1725
- endRow: row
1726
- }, sourceRange);
1727
- const targetPositionRange = _univerjs_core.Rectangle.getPositionRange({
1728
- startRow: row,
1729
- startColumn: col,
1730
- endColumn: col,
1731
- endRow: row
1732
- }, targetRange);
1733
- const { row: sourceRow, col: sourceCol } = mapFunc(sourcePositionRange.startRow, sourcePositionRange.startColumn);
1734
- const sourceCellCf = this._conditionalFormattingViewModel.getCellCfs(unitId, subUnitId, sourceRow, sourceCol);
1735
- const { row: targetRow, col: targetCol } = mapFunc(targetPositionRange.startRow, targetPositionRange.startColumn);
1736
- const targetCellCf = this._conditionalFormattingViewModel.getCellCfs(unitId, subUnitId, targetRow, targetCol);
1737
- if (targetCellCf) targetCellCf.forEach((cf) => {
1738
- if (!ensureRuleRanges(cf.cfId)) return;
1739
- getRangeDelta(cf.cfId).remove.push({
1740
- startRow: targetRow,
1741
- endRow: targetRow,
1742
- startColumn: targetCol,
1743
- endColumn: targetCol
1744
- });
1745
- });
1746
- if (sourceCellCf) sourceCellCf.forEach((cf) => {
1747
- if (!ensureRuleRanges(cf.cfId)) return;
1748
- getRangeDelta(cf.cfId).add.push({
1749
- startRow: targetRow,
1750
- endRow: targetRow,
1751
- startColumn: targetCol,
1752
- endColumn: targetCol
1753
- });
1750
+ (this._conditionalFormattingRuleModel.getSubunitRules(unitId, subUnitId) ?? []).forEach((rule) => {
1751
+ if (_univerjs_core.Rectangle.doAnyRangesIntersect(rule.ranges, targetRanges)) {
1752
+ rangeMap.set(rule.cfId, rule.ranges);
1753
+ getRangeDelta(rule.cfId).remove.push(...targetRanges);
1754
+ }
1755
+ const sourceRanges = rule.ranges.flatMap((range) => {
1756
+ const projected = virtualization.projectRange(range);
1757
+ const intersected = projected && (0, _univerjs_core.getIntersectRange)(projected, vSourceRange);
1758
+ return intersected ? [_univerjs_core.Rectangle.getRelativeRange(intersected, vSourceRange)] : [];
1754
1759
  });
1755
- });
1756
- };
1757
- const generalApplyFunc = (sourceRange, targetRange) => {
1758
- var _this$_univerInstance, _this$_univerInstance2;
1759
- const unitId = (_this$_univerInstance = this._univerInstanceService.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_SHEET)) === null || _this$_univerInstance === void 0 ? void 0 : _this$_univerInstance.getUnitId();
1760
- const subUnitId = (_this$_univerInstance2 = this._univerInstanceService.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_SHEET)) === null || _this$_univerInstance2 === void 0 || (_this$_univerInstance2 = _this$_univerInstance2.getActiveSheet()) === null || _this$_univerInstance2 === void 0 ? void 0 : _this$_univerInstance2.getSheetId();
1761
- const rangeMap = /* @__PURE__ */ new Map();
1762
- const rangeDeltaMap = /* @__PURE__ */ new Map();
1763
- const redos = [];
1764
- const undos = [];
1765
- if (!unitId || !subUnitId) return noopReturnFunc();
1766
- const virtualRange = (0, _univerjs_sheets_ui.virtualizeDiscreteRanges)([sourceRange, targetRange]);
1767
- const [vSourceRange, vTargetRange] = virtualRange.ranges;
1768
- const { mapFunc } = virtualRange;
1769
- const sourceStartCell = {
1770
- row: vSourceRange.startRow,
1771
- col: vSourceRange.startColumn
1772
- };
1773
- _univerjs_sheets.AutoFillTools.getAutoFillRepeatRange(vSourceRange, vTargetRange).forEach((repeat) => {
1774
- loopFunc(sourceStartCell, repeat.repeatStartCell, repeat.relativeRange, rangeMap, rangeDeltaMap, mapFunc);
1760
+ const additions = repeats.flatMap((repeat) => sourceRanges.flatMap((range) => {
1761
+ const copiedRange = (0, _univerjs_core.getIntersectRange)(range, repeat.relativeRange);
1762
+ return copiedRange ? virtualization.mapRange(_univerjs_core.Rectangle.getPositionRange(copiedRange, {
1763
+ startRow: repeat.repeatStartCell.row,
1764
+ endRow: repeat.repeatStartCell.row,
1765
+ startColumn: repeat.repeatStartCell.col,
1766
+ endColumn: repeat.repeatStartCell.col
1767
+ })) : [];
1768
+ }));
1769
+ if (additions.length) {
1770
+ rangeMap.set(rule.cfId, rule.ranges);
1771
+ getRangeDelta(rule.cfId).add.push(...additions);
1772
+ }
1775
1773
  });
1776
1774
  rangeDeltaMap.forEach((rangeDelta, cfId) => {
1777
1775
  const ranges = rangeMap.get(cfId);
@@ -1831,8 +1829,7 @@ ConditionalFormattingAutoFillController = __decorate([
1831
1829
  __decorateParam(1, (0, _univerjs_core.Inject)(_univerjs_core.IUniverInstanceService)),
1832
1830
  __decorateParam(2, (0, _univerjs_core.Inject)(_univerjs_sheets.IAutoFillService)),
1833
1831
  __decorateParam(3, (0, _univerjs_core.Inject)(_univerjs_sheets_conditional_formatting.ConditionalFormattingRuleModel)),
1834
- __decorateParam(4, (0, _univerjs_core.Inject)(_univerjs_sheets_conditional_formatting.ConditionalFormattingViewModel)),
1835
- __decorateParam(5, (0, _univerjs_core.Inject)(_univerjs_sheets_conditional_formatting.ConditionalFormattingRangeTransformService))
1832
+ __decorateParam(4, (0, _univerjs_core.Inject)(_univerjs_sheets_conditional_formatting.ConditionalFormattingRangeTransformService))
1836
1833
  ], ConditionalFormattingAutoFillController);
1837
1834
 
1838
1835
  //#endregion
@@ -1866,10 +1863,9 @@ let ConditionalFormattingEditorController = class ConditionalFormattingEditorCon
1866
1863
  */
1867
1864
  _initInterceptorEditorEnd() {
1868
1865
  this.disposeWithMe((0, _univerjs_core.toDisposable)(this._sheetInterceptorService.writeCellInterceptor.intercept(_univerjs_sheets.AFTER_CELL_EDIT, { handler: (value, context, next) => {
1869
- var _result$style;
1870
1866
  if (!value) next(value);
1871
1867
  const result = this._conditionalFormattingService.composeStyle(context.unitId, context.subUnitId, context.row, context.col);
1872
- const cfStyle = (_result$style = result === null || result === void 0 ? void 0 : result.style) !== null && _result$style !== void 0 ? _result$style : {};
1868
+ const cfStyle = (result === null || result === void 0 ? void 0 : result.style) ?? {};
1873
1869
  const keys = Object.keys(cfStyle);
1874
1870
  if (value === null || value === void 0 ? void 0 : value.p) {
1875
1871
  var _value$p$body;
@@ -1950,14 +1946,13 @@ const repeatByRange = (sourceRange, targetRange) => {
1950
1946
  return repeatList;
1951
1947
  };
1952
1948
  let ConditionalFormattingPainterController = class ConditionalFormattingPainterController extends _univerjs_core.Disposable {
1953
- constructor(_injector, _univerInstanceService, _formatPainterService, _sheetsSelectionsService, _conditionalFormattingRuleModel, _conditionalFormattingViewModel, _conditionalFormattingRangeTransformService) {
1949
+ constructor(_injector, _univerInstanceService, _formatPainterService, _sheetsSelectionsService, _conditionalFormattingRuleModel, _conditionalFormattingRangeTransformService) {
1954
1950
  super();
1955
1951
  this._injector = _injector;
1956
1952
  this._univerInstanceService = _univerInstanceService;
1957
1953
  this._formatPainterService = _formatPainterService;
1958
1954
  this._sheetsSelectionsService = _sheetsSelectionsService;
1959
1955
  this._conditionalFormattingRuleModel = _conditionalFormattingRuleModel;
1960
- this._conditionalFormattingViewModel = _conditionalFormattingViewModel;
1961
1956
  this._conditionalFormattingRangeTransformService = _conditionalFormattingRangeTransformService;
1962
1957
  _defineProperty(this, "_painterConfig", null);
1963
1958
  this._initFormattingPainter();
@@ -1967,9 +1962,16 @@ let ConditionalFormattingPainterController = class ConditionalFormattingPainterC
1967
1962
  redos: [],
1968
1963
  undos: []
1969
1964
  });
1970
- const loopFunc = (sourceStartCell, targetStartCell, relativeRange, rangeMap, rangeDeltaMap, config) => {
1971
- const { unitId: sourceUnitId, subUnitId: sourceSubUnitId } = this._painterConfig;
1972
- const { targetUnitId, targetSubUnitId } = config;
1965
+ const generalApplyFunc = (targetUnitId, targetSubUnitId, targetRange) => {
1966
+ const { range: sourceRange, unitId: sourceUnitId, subUnitId: sourceSubUnitId } = this._painterConfig;
1967
+ const isSkipSheet = targetUnitId !== sourceUnitId || sourceSubUnitId !== targetSubUnitId;
1968
+ const rangeMap = /* @__PURE__ */ new Map();
1969
+ const rangeDeltaMap = /* @__PURE__ */ new Map();
1970
+ const redos = [];
1971
+ const undos = [];
1972
+ if (!targetUnitId || !targetSubUnitId || !sourceUnitId || !sourceSubUnitId) return noopReturnFunc();
1973
+ const repeats = repeatByRange(sourceRange, targetRange);
1974
+ const targetRanges = repeats.map((repeat) => _univerjs_core.Rectangle.getPositionRange(repeat.repeatRelativeRange, repeat.startRange));
1973
1975
  const getRangeDelta = (cfId) => {
1974
1976
  let rangeDelta = rangeDeltaMap.get(cfId);
1975
1977
  if (!rangeDelta) {
@@ -1981,83 +1983,38 @@ let ConditionalFormattingPainterController = class ConditionalFormattingPainterC
1981
1983
  }
1982
1984
  return rangeDelta;
1983
1985
  };
1984
- const sourceRange = {
1985
- startRow: sourceStartCell.row,
1986
- startColumn: sourceStartCell.col,
1987
- endColumn: sourceStartCell.col,
1988
- endRow: sourceStartCell.row
1989
- };
1990
- const targetRange = {
1991
- startRow: targetStartCell.row,
1992
- startColumn: targetStartCell.col,
1993
- endColumn: targetStartCell.col,
1994
- endRow: targetStartCell.row
1995
- };
1996
- _univerjs_core.Range.foreach(relativeRange, (row, col) => {
1997
- const sourcePositionRange = _univerjs_core.Rectangle.getPositionRange({
1998
- startRow: row,
1999
- startColumn: col,
2000
- endColumn: col,
2001
- endRow: row
2002
- }, sourceRange);
2003
- const targetPositionRange = _univerjs_core.Rectangle.getPositionRange({
2004
- startRow: row,
2005
- startColumn: col,
2006
- endColumn: col,
2007
- endRow: row
2008
- }, targetRange);
2009
- const sourceCellCf = this._conditionalFormattingViewModel.getCellCfs(sourceUnitId, sourceSubUnitId, sourcePositionRange.startRow, sourcePositionRange.startColumn);
2010
- const targetCellCf = this._conditionalFormattingViewModel.getCellCfs(targetUnitId, targetSubUnitId, targetPositionRange.startRow, targetPositionRange.startColumn);
2011
- if (targetCellCf) targetCellCf.forEach((cf) => {
2012
- if (!rangeMap.has(cf.cfId)) {
2013
- const rule = this._conditionalFormattingRuleModel.getRule(targetUnitId, targetSubUnitId, cf.cfId);
2014
- if (!rule) return;
2015
- rangeMap.set(cf.cfId, rule.ranges);
2016
- }
2017
- getRangeDelta(cf.cfId).remove.push({
2018
- startRow: targetPositionRange.startRow,
2019
- endRow: targetPositionRange.startRow,
2020
- startColumn: targetPositionRange.startColumn,
2021
- endColumn: targetPositionRange.startColumn
2022
- });
2023
- });
2024
- if (sourceCellCf) sourceCellCf.forEach((cf) => {
2025
- if (!rangeMap.has(cf.cfId)) return;
2026
- getRangeDelta(cf.cfId).add.push({
2027
- startRow: targetPositionRange.startRow,
2028
- endRow: targetPositionRange.startRow,
2029
- startColumn: targetPositionRange.startColumn,
2030
- endColumn: targetPositionRange.startColumn
2031
- });
2032
- });
2033
- });
2034
- };
2035
- const generalApplyFunc = (targetUnitId, targetSubUnitId, targetRange) => {
2036
- var _this$_conditionalFor;
2037
- const { range: sourceRange, unitId: sourceUnitId, subUnitId: sourceSubUnitId } = this._painterConfig;
2038
- const isSkipSheet = targetUnitId !== sourceUnitId || sourceSubUnitId !== targetSubUnitId;
2039
- const rangeMap = /* @__PURE__ */ new Map();
2040
- const rangeDeltaMap = /* @__PURE__ */ new Map();
2041
- const redos = [];
2042
- const undos = [];
2043
- if (!targetUnitId || !targetSubUnitId || !sourceUnitId || !sourceSubUnitId) return noopReturnFunc();
2044
- const ruleList = (_this$_conditionalFor = this._conditionalFormattingRuleModel.getSubunitRules(sourceUnitId, sourceSubUnitId)) !== null && _this$_conditionalFor !== void 0 ? _this$_conditionalFor : [];
2045
- ruleList === null || ruleList === void 0 || ruleList.forEach((rule) => {
2046
- const { ranges, cfId } = rule;
2047
- if (ranges.some((range) => _univerjs_core.Rectangle.intersects(sourceRange, range))) rangeMap.set(cfId, isSkipSheet ? [] : ranges);
1986
+ const targetRuleList = this._conditionalFormattingRuleModel.getSubunitRules(targetUnitId, targetSubUnitId) ?? [];
1987
+ const waitAddRule = /* @__PURE__ */ new Map();
1988
+ targetRuleList.forEach((rule) => {
1989
+ if (_univerjs_core.Rectangle.doAnyRangesIntersect(rule.ranges, targetRanges)) {
1990
+ rangeMap.set(rule.cfId, rule.ranges);
1991
+ getRangeDelta(rule.cfId).remove.push(...targetRanges);
1992
+ }
2048
1993
  });
2049
- const sourceStartCell = {
2050
- row: sourceRange.startRow,
2051
- col: sourceRange.startColumn
2052
- };
2053
- repeatByRange(sourceRange, targetRange).forEach((repeat) => {
2054
- loopFunc(sourceStartCell, {
2055
- row: repeat.startRange.startRow,
2056
- col: repeat.startRange.startColumn
2057
- }, repeat.repeatRelativeRange, rangeMap, rangeDeltaMap, {
2058
- targetUnitId,
2059
- targetSubUnitId
1994
+ const sourceRuleList = this._conditionalFormattingRuleModel.getSubunitRules(sourceUnitId, sourceSubUnitId) ?? [];
1995
+ (isSkipSheet ? [...sourceRuleList].reverse() : sourceRuleList).forEach((rule) => {
1996
+ const sourceRanges = rule.ranges.flatMap((range) => {
1997
+ const intersected = (0, _univerjs_core.getIntersectRange)(range, sourceRange);
1998
+ return intersected ? [_univerjs_core.Rectangle.getRelativeRange(intersected, sourceRange)] : [];
2060
1999
  });
2000
+ const additions = repeats.flatMap((repeat) => sourceRanges.flatMap((range) => {
2001
+ const copiedRange = (0, _univerjs_core.getIntersectRange)(range, repeat.repeatRelativeRange);
2002
+ return copiedRange ? [_univerjs_core.Rectangle.getPositionRange(copiedRange, repeat.startRange)] : [];
2003
+ }));
2004
+ if (additions.length) {
2005
+ let targetCfId = rule.cfId;
2006
+ if (isSkipSheet) {
2007
+ targetCfId = this._conditionalFormattingRuleModel.createCfId(targetUnitId, targetSubUnitId);
2008
+ waitAddRule.set(targetCfId, {
2009
+ ..._univerjs_core.Tools.deepClone(rule),
2010
+ cfId: targetCfId,
2011
+ ranges: []
2012
+ });
2013
+ rangeMap.set(targetCfId, []);
2014
+ }
2015
+ if (!rangeMap.has(targetCfId)) rangeMap.set(targetCfId, rule.ranges);
2016
+ getRangeDelta(targetCfId).add.push(...additions);
2017
+ }
2061
2018
  });
2062
2019
  rangeDeltaMap.forEach((rangeDelta, cfId) => {
2063
2020
  const ranges = rangeMap.get(cfId);
@@ -2095,28 +2052,27 @@ let ConditionalFormattingPainterController = class ConditionalFormattingPainterC
2095
2052
  undos.push(...(0, _univerjs_sheets_conditional_formatting.DeleteConditionalRuleMutationUndoFactory)(this._injector, params));
2096
2053
  }
2097
2054
  } else {
2098
- const rule = this._conditionalFormattingRuleModel.getRule(targetUnitId, targetSubUnitId, cfId);
2099
- if (!rule) {
2055
+ const waitAdd = waitAddRule.get(cfId);
2056
+ if (waitAdd) {
2100
2057
  if (ranges.length) {
2101
- const sourceRule = this._conditionalFormattingRuleModel.getRule(sourceUnitId, sourceSubUnitId, cfId);
2102
- if (sourceRule) {
2103
- const params = {
2104
- unitId: targetUnitId,
2105
- subUnitId: targetSubUnitId,
2106
- rule: {
2107
- ..._univerjs_core.Tools.deepClone(sourceRule),
2108
- cfId: this._conditionalFormattingRuleModel.createCfId(targetUnitId, targetSubUnitId),
2109
- ranges
2110
- }
2111
- };
2112
- redos.push({
2113
- id: _univerjs_sheets_conditional_formatting.AddConditionalRuleMutation.id,
2114
- params
2115
- });
2116
- undos.push((0, _univerjs_sheets_conditional_formatting.AddConditionalRuleMutationUndoFactory)(this._injector, params));
2117
- }
2058
+ const params = {
2059
+ unitId: targetUnitId,
2060
+ subUnitId: targetSubUnitId,
2061
+ rule: {
2062
+ ...waitAdd,
2063
+ ranges
2064
+ }
2065
+ };
2066
+ redos.push({
2067
+ id: _univerjs_sheets_conditional_formatting.AddConditionalRuleMutation.id,
2068
+ params
2069
+ });
2070
+ undos.push((0, _univerjs_sheets_conditional_formatting.AddConditionalRuleMutationUndoFactory)(this._injector, params));
2118
2071
  }
2119
- } else if (ranges.length) {
2072
+ return;
2073
+ }
2074
+ const rule = this._conditionalFormattingRuleModel.getRule(targetUnitId, targetSubUnitId, cfId);
2075
+ if (rule) if (ranges.length) {
2120
2076
  const params = {
2121
2077
  unitId: targetUnitId,
2122
2078
  subUnitId: targetSubUnitId,
@@ -2189,8 +2145,7 @@ ConditionalFormattingPainterController = __decorate([
2189
2145
  __decorateParam(2, (0, _univerjs_core.Inject)(_univerjs_sheets_ui.IFormatPainterService)),
2190
2146
  __decorateParam(3, (0, _univerjs_core.Inject)(_univerjs_sheets.SheetsSelectionsService)),
2191
2147
  __decorateParam(4, (0, _univerjs_core.Inject)(_univerjs_sheets_conditional_formatting.ConditionalFormattingRuleModel)),
2192
- __decorateParam(5, (0, _univerjs_core.Inject)(_univerjs_sheets_conditional_formatting.ConditionalFormattingViewModel)),
2193
- __decorateParam(6, (0, _univerjs_core.Inject)(_univerjs_sheets_conditional_formatting.ConditionalFormattingRangeTransformService))
2148
+ __decorateParam(5, (0, _univerjs_core.Inject)(_univerjs_sheets_conditional_formatting.ConditionalFormattingRangeTransformService))
2194
2149
  ], ConditionalFormattingPainterController);
2195
2150
 
2196
2151
  //#endregion
@@ -2295,7 +2250,6 @@ function Preview(props) {
2295
2250
  const previewClassName = "univer-pointer-events-none univer-flex univer-h-5 univer-min-w-[72px] univer-items-center univer-justify-center univer-text-xs";
2296
2251
  switch (rule.type) {
2297
2252
  case _univerjs_sheets_conditional_formatting.CFRuleType.dataBar: {
2298
- var _rule$config$nativeCo, _rule$config$positive;
2299
2253
  const { isGradient } = rule.config;
2300
2254
  const positiveColor = isGradient ? `linear-gradient(to right, ${rule.config.positiveColor || _univerjs_sheets_conditional_formatting.defaultDataBarPositiveColor}, rgb(255 255 255))` : rule.config.positiveColor;
2301
2255
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
@@ -2304,13 +2258,13 @@ function Preview(props) {
2304
2258
  className: "univer-h-full univer-w-1/2 univer-border univer-border-solid",
2305
2259
  style: {
2306
2260
  background: isGradient ? `linear-gradient(to right, rgb(255 255 255),${rule.config.nativeColor || _univerjs_sheets_conditional_formatting.defaultDataBarNativeColor})` : rule.config.nativeColor,
2307
- borderColor: (_rule$config$nativeCo = rule.config.nativeColor) !== null && _rule$config$nativeCo !== void 0 ? _rule$config$nativeCo : _univerjs_sheets_conditional_formatting.defaultDataBarNativeColor
2261
+ borderColor: rule.config.nativeColor ?? _univerjs_sheets_conditional_formatting.defaultDataBarNativeColor
2308
2262
  }
2309
2263
  }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2310
2264
  className: "univer-h-full univer-w-1/2 univer-border univer-border-solid",
2311
2265
  style: {
2312
2266
  background: positiveColor,
2313
- borderColor: (_rule$config$positive = rule.config.positiveColor) !== null && _rule$config$positive !== void 0 ? _rule$config$positive : _univerjs_sheets_conditional_formatting.defaultDataBarPositiveColor
2267
+ borderColor: rule.config.positiveColor ?? _univerjs_sheets_conditional_formatting.defaultDataBarPositiveColor
2314
2268
  }
2315
2269
  })]
2316
2270
  });
@@ -2334,16 +2288,15 @@ function Preview(props) {
2334
2288
  }, index) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.SlashDoubleIcon, {}, index))
2335
2289
  });
2336
2290
  case _univerjs_sheets_conditional_formatting.CFRuleType.highlightCell: {
2337
- var _bg$rgb, _cl$rgb, _replace;
2338
2291
  const { ul, st, it, bl, bg, cl } = rule.style;
2339
2292
  const isUnderline = (ul === null || ul === void 0 ? void 0 : ul.s) === _univerjs_core.BooleanNumber.TRUE;
2340
2293
  const isStrikethrough = (st === null || st === void 0 ? void 0 : st.s) === _univerjs_core.BooleanNumber.TRUE;
2341
2294
  const isItalic = it === _univerjs_core.BooleanNumber.TRUE;
2342
2295
  const isBold = bl === _univerjs_core.BooleanNumber.TRUE;
2343
- const bgColor = (_bg$rgb = bg === null || bg === void 0 ? void 0 : bg.rgb) !== null && _bg$rgb !== void 0 ? _bg$rgb : _univerjs_sheets_conditional_formatting.DEFAULT_BG_COLOR;
2344
- const fontColor = (_cl$rgb = cl === null || cl === void 0 ? void 0 : cl.rgb) !== null && _cl$rgb !== void 0 ? _cl$rgb : _univerjs_sheets_conditional_formatting.DEFAULT_FONT_COLOR;
2296
+ const bgColor = (bg === null || bg === void 0 ? void 0 : bg.rgb) ?? _univerjs_sheets_conditional_formatting.DEFAULT_BG_COLOR;
2297
+ const fontColor = (cl === null || cl === void 0 ? void 0 : cl.rgb) ?? _univerjs_sheets_conditional_formatting.DEFAULT_FONT_COLOR;
2345
2298
  const style = {
2346
- textDecoration: (_replace = `${isUnderline ? "underline" : ""} ${isStrikethrough ? "line-through" : ""}`.replace(/^ /, "")) !== null && _replace !== void 0 ? _replace : void 0,
2299
+ textDecoration: `${isUnderline ? "underline" : ""} ${isStrikethrough ? "line-through" : ""}`.replace(/^ /, "") ?? void 0,
2347
2300
  backgroundColor: bgColor,
2348
2301
  color: fontColor
2349
2302
  };
@@ -2418,7 +2371,7 @@ const TextInput$1 = (props) => {
2418
2371
  className: "univer-ml-1 univer-w-full",
2419
2372
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_sheets_formula_ui.FormulaEditor, {
2420
2373
  ref: formulaEditorRef,
2421
- className: (0, _univerjs_design.clsx)("univer-box-border univer-h-8 univer-w-full univer-cursor-pointer univer-items-center univer-rounded-lg univer-bg-white univer-pt-2 univer-transition-colors hover:univer-border-primary-600 dark:!univer-bg-gray-700 dark:!univer-text-white [&>div:first-child]:univer-px-2.5 [&>div]:univer-h-5 [&>div]:univer-ring-transparent", _univerjs_design.borderClassName),
2374
+ className: (0, _univerjs_design.clsx)("univer-box-border univer-h-8 univer-w-full univer-cursor-pointer univer-items-center univer-rounded-lg univer-bg-gray-0 univer-pt-2 univer-transition-colors hover:univer-border-primary-600 dark:!univer-bg-gray-700 dark:!univer-text-gray-0 [&>div:first-child]:univer-px-2.5 [&>div]:univer-h-5 [&>div]:univer-ring-transparent", _univerjs_design.borderClassName),
2422
2375
  initValue: formulaInitValue,
2423
2376
  unitId,
2424
2377
  subUnitId,
@@ -2839,7 +2792,7 @@ const InputText = (props) => {
2839
2792
  className: "univer-w-full",
2840
2793
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_sheets_formula_ui.FormulaEditor, {
2841
2794
  ref: formulaEditorRef,
2842
- className: (0, _univerjs_design.clsx)("univer-box-border univer-h-8 univer-w-full univer-cursor-pointer univer-items-center univer-rounded-lg univer-bg-white univer-pt-2 univer-transition-colors hover:univer-border-primary-600 dark:!univer-bg-gray-700 dark:!univer-text-white [&>div:first-child]:univer-px-2.5 [&>div]:univer-h-5 [&>div]:univer-ring-transparent", _univerjs_design.borderClassName),
2795
+ className: (0, _univerjs_design.clsx)("univer-box-border univer-h-8 univer-w-full univer-cursor-pointer univer-items-center univer-rounded-lg univer-bg-gray-0 univer-pt-2 univer-transition-colors hover:univer-border-primary-600 dark:!univer-bg-gray-700 dark:!univer-text-gray-0 [&>div:first-child]:univer-px-2.5 [&>div]:univer-h-5 [&>div]:univer-ring-transparent", _univerjs_design.borderClassName),
2843
2796
  initValue: v,
2844
2797
  unitId,
2845
2798
  subUnitId,
@@ -3359,7 +3312,7 @@ const FormulaStyleEditor = (props) => {
3359
3312
  className: "univer-mt-3",
3360
3313
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_sheets_formula_ui.FormulaEditor, {
3361
3314
  ref: formulaEditorRef,
3362
- className: (0, _univerjs_design.clsx)("univer-box-border univer-h-8 univer-w-full univer-cursor-pointer univer-items-center univer-rounded-lg univer-bg-white univer-pt-2 univer-transition-colors hover:univer-border-primary-600 dark:!univer-bg-gray-700 dark:!univer-text-white [&>div:first-child]:univer-px-2.5 [&>div]:univer-h-5 [&>div]:univer-ring-transparent", _univerjs_design.borderClassName),
3315
+ className: (0, _univerjs_design.clsx)("univer-box-border univer-h-8 univer-w-full univer-cursor-pointer univer-items-center univer-rounded-lg univer-bg-gray-0 univer-pt-2 univer-transition-colors hover:univer-border-primary-600 dark:!univer-bg-gray-700 dark:!univer-text-gray-0 [&>div:first-child]:univer-px-2.5 [&>div]:univer-h-5 [&>div]:univer-ring-transparent", _univerjs_design.borderClassName),
3363
3316
  errorText: formulaError,
3364
3317
  isFocus: isFocusFormulaEditor,
3365
3318
  initValue: formula,
@@ -3406,13 +3359,10 @@ const FormulaStyleEditor = (props) => {
3406
3359
  //#endregion
3407
3360
  //#region src/views/wrapper-error/WrapperError.tsx
3408
3361
  const WrapperError = (props) => {
3409
- return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
3410
- className: "univer-relative",
3411
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3412
- className: "univer-absolute univer-bottom-[-13px] univer-z-[999] univer-text-[10px] univer-text-red-500",
3413
- children: props.errorText
3414
- }), props.children]
3415
- });
3362
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [props.children, props.errorText && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3363
+ className: "univer-mt-1 univer-text-xs univer-text-red-500",
3364
+ children: props.errorText
3365
+ })] });
3416
3366
  };
3417
3367
 
3418
3368
  //#endregion
@@ -3674,11 +3624,10 @@ const HighlightCellStyleEditor = (props) => {
3674
3624
  });
3675
3625
  const [style, setStyle] = (0, react.useState)({});
3676
3626
  const getResult = (0, react.useMemo)(() => (option) => {
3677
- var _option$subType, _option$operator, _option$value, _option$style;
3678
- const nextSubType = (_option$subType = option.subType) !== null && _option$subType !== void 0 ? _option$subType : subType;
3679
- const nextOperator = (_option$operator = option.operator) !== null && _option$operator !== void 0 ? _option$operator : operator;
3680
- const nextValue = (_option$value = option.value) !== null && _option$value !== void 0 ? _option$value : value;
3681
- const nextStyle = (_option$style = option.style) !== null && _option$style !== void 0 ? _option$style : style;
3627
+ const nextSubType = option.subType ?? subType;
3628
+ const nextOperator = option.operator ?? operator;
3629
+ const nextValue = option.value ?? value;
3630
+ const nextStyle = option.style ?? style;
3682
3631
  switch (nextSubType) {
3683
3632
  case _univerjs_sheets_conditional_formatting.CFSubRuleType.duplicateValues: return {
3684
3633
  type: _univerjs_sheets_conditional_formatting.CFRuleType.highlightCell,
@@ -3829,7 +3778,7 @@ const TextInput = (props) => {
3829
3778
  children: type !== _univerjs_sheets_conditional_formatting.CFValueType.formula ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.InputNumber, {
3830
3779
  className: (0, _univerjs_design.clsx)({ "univer-border-red-500": error }),
3831
3780
  value: Number(props.value) || 0,
3832
- onChange: (v) => onChange(v !== null && v !== void 0 ? v : 0)
3781
+ onChange: (v) => onChange(v ?? 0)
3833
3782
  }), error && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3834
3783
  className: "univer-absolute univer-text-xs univer-text-red-500",
3835
3784
  children: error
@@ -3837,7 +3786,7 @@ const TextInput = (props) => {
3837
3786
  className: "univer-w-full",
3838
3787
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_sheets_formula_ui.FormulaEditor, {
3839
3788
  ref: formulaEditorRef,
3840
- className: (0, _univerjs_design.clsx)("univer-box-border univer-h-8 univer-w-full univer-cursor-pointer univer-items-center univer-rounded-lg univer-bg-white univer-pt-2 univer-transition-colors hover:univer-border-primary-600 dark:!univer-bg-gray-700 dark:!univer-text-white [&>div:first-child]:univer-px-2.5 [&>div]:univer-h-5 [&>div]:univer-ring-transparent", _univerjs_design.borderClassName),
3789
+ className: (0, _univerjs_design.clsx)("univer-box-border univer-h-8 univer-w-full univer-cursor-pointer univer-items-center univer-rounded-lg univer-bg-gray-0 univer-pt-2 univer-transition-colors hover:univer-border-primary-600 dark:!univer-bg-gray-700 dark:!univer-text-gray-0 [&>div:first-child]:univer-px-2.5 [&>div]:univer-h-5 [&>div]:univer-ring-transparent", _univerjs_design.borderClassName),
3841
3790
  initValue: String(props.value),
3842
3791
  unitId,
3843
3792
  subUnitId,
@@ -3862,8 +3811,9 @@ const createDefaultConfigItem = (iconType, index, list) => ({
3862
3811
  const IconGroupList = (props) => {
3863
3812
  const { iconType, onClick } = props;
3864
3813
  const localeService = (0, _univerjs_ui.useDependency)(_univerjs_core.LocaleService);
3814
+ const direction = (0, _univerjs_ui.useObservable)(localeService.direction$, localeService.getDirection());
3865
3815
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3866
- dir: (0, _univerjs_ui.useObservable)(localeService.direction$, localeService.getDirection()),
3816
+ dir: direction,
3867
3817
  className: "univer-w-80",
3868
3818
  children: _univerjs_sheets_conditional_formatting.iconGroup.map((group) => {
3869
3819
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
@@ -3872,6 +3822,8 @@ const IconGroupList = (props) => {
3872
3822
  className: "univer-mb-2 univer-px-1 univer-text-xs univer-font-medium univer-text-gray-500 dark:!univer-text-gray-400",
3873
3823
  children: localeService.t(group.title)
3874
3824
  }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3825
+ dir: direction,
3826
+ "data-u-comp": "cf-icon-set-group-grid",
3875
3827
  className: "univer-grid univer-grid-cols-2 univer-gap-1",
3876
3828
  children: group.group.map((groupItem, groupItemIndex) => {
3877
3829
  const selected = groupItem.name === iconType;
@@ -3879,11 +3831,12 @@ const IconGroupList = (props) => {
3879
3831
  type: "button",
3880
3832
  "aria-label": `${localeService.t(group.title)} ${groupItemIndex + 1}`,
3881
3833
  "aria-pressed": selected,
3882
- className: (0, _univerjs_design.clsx)("univer-flex univer-h-8 univer-w-full univer-cursor-pointer univer-items-center univer-rounded-md univer-border-0 univer-bg-transparent univer-px-2 univer-outline-none univer-transition-colors focus-visible:univer-ring-2 focus-visible:univer-ring-primary-600 rtl:univer-flex-row-reverse", selected ? "univer-bg-primary-50 univer-ring-1 univer-ring-primary-600 dark:!univer-bg-primary-900" : "hover:univer-bg-gray-100 dark:hover:!univer-bg-gray-700"),
3834
+ className: (0, _univerjs_design.clsx)("univer-flex univer-h-8 univer-w-full univer-cursor-pointer univer-items-center univer-justify-start univer-rounded-md univer-border-0 univer-bg-transparent univer-px-2 univer-outline-none univer-transition-colors focus-visible:univer-ring-2 focus-visible:univer-ring-primary-600", selected ? "univer-bg-primary-50 univer-ring-1 univer-ring-primary-600 dark:!univer-bg-primary-900" : "hover:univer-bg-gray-100 dark:hover:!univer-bg-gray-700"),
3883
3835
  onClick: () => {
3884
3836
  onClick(groupItem.name);
3885
3837
  },
3886
3838
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3839
+ dir: direction,
3887
3840
  className: "univer-flex univer-items-center univer-gap-0.5",
3888
3841
  children: groupItem.list.map((base64, index) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("img", {
3889
3842
  alt: "",
@@ -4047,7 +4000,7 @@ const IconSetRuleEdit = (props) => {
4047
4000
  })
4048
4001
  }),
4049
4002
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
4050
- className: (0, _univerjs_design.clsx)("univer-box-border univer-flex univer-h-8 univer-w-full univer-items-center univer-justify-between univer-rounded-md univer-bg-white univer-px-4 univer-py-2 univer-text-xs univer-text-gray-600 univer-transition-all hover:univer-border-primary-600 dark:!univer-text-gray-200", _univerjs_design.borderClassName),
4003
+ className: (0, _univerjs_design.clsx)("univer-box-border univer-flex univer-h-8 univer-w-full univer-items-center univer-justify-between univer-rounded-md univer-bg-gray-0 univer-px-4 univer-py-2 univer-text-xs univer-text-gray-600 univer-transition-all hover:univer-border-primary-600 dark:!univer-text-gray-200", _univerjs_design.borderClassName),
4051
4004
  children: [icon ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("img", {
4052
4005
  src: icon,
4053
4006
  className: "univer-size-4",
@@ -4259,7 +4212,7 @@ const IconSet = (props) => {
4259
4212
  })
4260
4213
  }),
4261
4214
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
4262
- className: (0, _univerjs_design.clsx)("univer-box-border univer-flex univer-h-8 univer-w-full univer-items-center univer-justify-between univer-rounded-md univer-bg-white univer-px-4 univer-py-2 univer-text-xs univer-text-gray-600 univer-transition-all hover:univer-border-primary-600", _univerjs_design.borderClassName),
4215
+ className: (0, _univerjs_design.clsx)("univer-box-border univer-flex univer-h-8 univer-w-full univer-items-center univer-justify-between univer-rounded-md univer-bg-gray-0 univer-px-4 univer-py-2 univer-text-xs univer-text-gray-600 univer-transition-all hover:univer-border-primary-600", _univerjs_design.borderClassName),
4263
4216
  children: [previewIcon, /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.MoreDownIcon, {})]
4264
4217
  })
4265
4218
  })
@@ -4499,7 +4452,7 @@ const getSubUnitId = (univerInstanceService) => {
4499
4452
  return (_getActiveSheet = univerInstanceService.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_SHEET).getActiveSheet()) === null || _getActiveSheet === void 0 ? void 0 : _getActiveSheet.getSheetId();
4500
4453
  };
4501
4454
  const RuleEdit = (props) => {
4502
- var _props$rule$ranges, _props$rule, _props$rule5;
4455
+ var _props$rule, _props$rule5;
4503
4456
  const localeService = (0, _univerjs_ui.useDependency)(_univerjs_core.LocaleService);
4504
4457
  const commandService = (0, _univerjs_ui.useDependency)(_univerjs_core.ICommandService);
4505
4458
  const univerInstanceService = (0, _univerjs_ui.useDependency)(_univerjs_core.IUniverInstanceService);
@@ -4508,14 +4461,14 @@ const RuleEdit = (props) => {
4508
4461
  const unitId = getUnitId(univerInstanceService);
4509
4462
  const subUnitId = getSubUnitId(univerInstanceService);
4510
4463
  const [errorText, setErrorText] = (0, react.useState)(void 0);
4511
- const rangeResult = (0, react.useRef)((_props$rule$ranges = (_props$rule = props.rule) === null || _props$rule === void 0 ? void 0 : _props$rule.ranges) !== null && _props$rule$ranges !== void 0 ? _props$rule$ranges : []);
4464
+ const rangeResult = (0, react.useRef)(((_props$rule = props.rule) === null || _props$rule === void 0 ? void 0 : _props$rule.ranges) ?? []);
4512
4465
  const rangeSelectorTouched = (0, react.useRef)(false);
4513
4466
  const rangeString = (0, react.useMemo)(() => {
4514
4467
  var _props$rule2;
4515
4468
  let ranges = (_props$rule2 = props.rule) === null || _props$rule2 === void 0 ? void 0 : _props$rule2.ranges;
4516
4469
  if (!(ranges === null || ranges === void 0 ? void 0 : ranges.length)) {
4517
- var _selectionManagerServ, _selectionManagerServ2;
4518
- ranges = (_selectionManagerServ = (_selectionManagerServ2 = selectionManagerService.getCurrentSelections()) === null || _selectionManagerServ2 === void 0 ? void 0 : _selectionManagerServ2.map((s) => s.range)) !== null && _selectionManagerServ !== void 0 ? _selectionManagerServ : [];
4470
+ var _selectionManagerServ;
4471
+ ranges = ((_selectionManagerServ = selectionManagerService.getCurrentSelections()) === null || _selectionManagerServ === void 0 ? void 0 : _selectionManagerServ.map((s) => s.range)) ?? [];
4519
4472
  }
4520
4473
  rangeResult.current = ranges;
4521
4474
  if (!(ranges === null || ranges === void 0 ? void 0 : ranges.length)) return "";
@@ -4829,9 +4782,8 @@ function RuleList(props) {
4829
4782
  });
4830
4783
  };
4831
4784
  const handleDragStart = (_layout, from) => {
4832
- var _dragRule$cfId;
4833
4785
  const dragRule = ruleListByPermissionCheck[from.y];
4834
- setDraggingId((_dragRule$cfId = dragRule === null || dragRule === void 0 ? void 0 : dragRule.cfId) !== null && _dragRule$cfId !== void 0 ? _dragRule$cfId : "");
4786
+ setDraggingId((dragRule === null || dragRule === void 0 ? void 0 : dragRule.cfId) ?? "");
4835
4787
  };
4836
4788
  const handleDragStop = (_layout, from, to) => {
4837
4789
  var _getActiveSheet2, _ruleListByPermission, _ruleListByPermission2;
@@ -4901,7 +4853,7 @@ function RuleList(props) {
4901
4853
  }
4902
4854
  })).map((ele, index) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: ele }, index))
4903
4855
  }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
4904
- className: "univer-flex univer-justify-end univer-space-x-2",
4856
+ className: "univer-flex univer-justify-end univer-gap-2",
4905
4857
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Tooltip, {
4906
4858
  title: localeService.t("sheets-conditional-formatting-ui.panel.createRule"),
4907
4859
  placement: "bottom",
@@ -4931,7 +4883,7 @@ function RuleList(props) {
4931
4883
  onDragStop: handleDragStop,
4932
4884
  onDragStart: handleDragStart,
4933
4885
  itemRender: (rule) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
4934
- className: (0, _univerjs_design.clsx)("univer-group univer-relative univer-flex univer-items-center univer-justify-between univer-rounded univer-py-2 univer-pl-5 univer-pr-8 hover:univer-bg-gray-100 dark:hover:!univer-bg-gray-700", { "univer-bg-gray-100 dark:!univer-bg-gray-700": draggingId === rule.cfId }),
4886
+ className: (0, _univerjs_design.clsx)("univer-group univer-relative univer-flex univer-items-center univer-justify-between univer-rounded univer-py-2 univer-pl-5 univer-pr-8 hover:univer-bg-gray-100 rtl:univer-pl-8 rtl:univer-pr-5 dark:hover:!univer-bg-gray-700", { "univer-bg-gray-100 dark:!univer-bg-gray-700": draggingId === rule.cfId }),
4935
4887
  onMouseMove: () => {
4936
4888
  rule.ranges !== currentRuleRanges && setCurrentRuleRanges(rule.ranges);
4937
4889
  },
@@ -4941,14 +4893,14 @@ function RuleList(props) {
4941
4893
  },
4942
4894
  children: [
4943
4895
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
4944
- className: (0, _univerjs_design.clsx)("univer-absolute univer-left-0 univer-hidden univer-size-5 univer-cursor-grab univer-items-center univer-justify-center univer-rounded group-hover:univer-flex", "draggableHandle"),
4896
+ className: (0, _univerjs_design.clsx)("univer-absolute univer-left-0 univer-hidden univer-size-5 univer-cursor-grab univer-items-center univer-justify-center univer-rounded group-hover:univer-flex rtl:univer-left-auto rtl:univer-right-0", "draggableHandle"),
4945
4897
  onClick: (e) => e.stopPropagation(),
4946
4898
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.GripVerticalIcon, {})
4947
4899
  }),
4948
4900
  /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
4949
4901
  className: "univer-min-w-0 univer-max-w-full univer-flex-shrink univer-overflow-hidden",
4950
4902
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
4951
- className: "univer-text-sm univer-text-gray-900 dark:!univer-text-white",
4903
+ className: "univer-text-sm univer-text-gray-900 dark:!univer-text-gray-0",
4952
4904
  children: getRuleDescribe(rule, localeService)
4953
4905
  }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
4954
4906
  className: "univer-max-w-[250px] univer-overflow-hidden univer-text-ellipsis univer-text-xs univer-text-gray-400",
@@ -4957,7 +4909,7 @@ function RuleList(props) {
4957
4909
  }),
4958
4910
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Preview, { rule: rule.rule }) }),
4959
4911
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
4960
- className: (0, _univerjs_design.clsx)("univer-absolute univer-right-1 univer-hidden univer-size-6 univer-cursor-pointer univer-items-center univer-justify-center univer-rounded univer-text-red-500 group-hover:univer-flex hover:univer-bg-gray-200", { "univer-flex univer-items-center univer-justify-center": draggingId === rule.cfId }),
4912
+ className: (0, _univerjs_design.clsx)("univer-absolute univer-right-1 univer-hidden univer-size-6 univer-cursor-pointer univer-items-center univer-justify-center univer-rounded univer-text-red-500 group-hover:univer-flex hover:univer-bg-gray-200 rtl:univer-left-1 rtl:univer-right-auto", { "univer-flex univer-items-center univer-justify-center": draggingId === rule.cfId }),
4961
4913
  onClick: (e) => {
4962
4914
  e.stopPropagation();
4963
4915
  handleDelete(rule);
@@ -5134,7 +5086,7 @@ _defineProperty(UniverSheetsConditionalFormattingUIPlugin, "packageName", name);
5134
5086
  _defineProperty(UniverSheetsConditionalFormattingUIPlugin, "version", version);
5135
5087
  _defineProperty(UniverSheetsConditionalFormattingUIPlugin, "type", _univerjs_core.UniverInstanceType.UNIVER_SHEET);
5136
5088
  UniverSheetsConditionalFormattingUIPlugin = __decorate([
5137
- (0, _univerjs_core.DependentOn)(_univerjs_engine_render.UniverRenderEnginePlugin, _univerjs_sheets.UniverSheetsPlugin, _univerjs_ui.UniverUIPlugin, _univerjs_sheets_formula.UniverSheetsFormulaPlugin, _univerjs_sheets_conditional_formatting.UniverSheetsConditionalFormattingPlugin, _univerjs_sheets_ui.UniverSheetsUIPlugin),
5089
+ (0, _univerjs_core.DependentOn)(_univerjs_engine_render.UniverRenderEnginePlugin, _univerjs_sheets.UniverSheetsPlugin, _univerjs_sheets_formula.UniverSheetsFormulaPlugin, _univerjs_sheets_conditional_formatting.UniverSheetsConditionalFormattingPlugin, _univerjs_sheets_ui.UniverSheetsUIPlugin),
5138
5090
  __decorateParam(1, (0, _univerjs_core.Inject)(_univerjs_core.Injector)),
5139
5091
  __decorateParam(2, (0, _univerjs_core.Inject)(_univerjs_core.ICommandService)),
5140
5092
  __decorateParam(3, _univerjs_core.IConfigService)