@univerjs/sheets-conditional-formatting-ui 1.0.0-beta.0 → 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 +274 -310
  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 +276 -312
  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 -18
  42. package/lib/index.js +276 -312
  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 +12 -12
package/lib/es/index.js CHANGED
@@ -1,6 +1,6 @@
1
- import { BooleanNumber, ColorKit, CommandType, DependentOn, Disposable, DisposableCollection, ICommandService, IConfigService, IUniverInstanceService, Inject, Injector, InterceptorEffectEnum, InterceptorManager, LocaleService, ObjectMatrix, Plugin, Range, Rectangle, Tools, UniverInstanceType, createInterceptorKey, generateRandomId, get, merge, registerDependencies, set, toDisposable, touchDependencies } from "@univerjs/core";
1
+ import { BooleanNumber, ColorKit, CommandType, DependentOn, Disposable, DisposableCollection, ICommandService, IConfigService, IUniverInstanceService, Inject, Injector, InterceptorEffectEnum, InterceptorManager, LocaleService, Plugin, Rectangle, Tools, UniverInstanceType, createInterceptorKey, generateRandomId, get, getIntersectRange, merge, registerDependencies, set, toDisposable, touchDependencies } from "@univerjs/core";
2
2
  import { AFTER_CELL_EDIT, AUTO_FILL_APPLY_TYPE, AutoFillTools, ClearSelectionAllCommand, ClearSelectionFormatCommand, IAutoFillService, INTERCEPTOR_POINT, RangeProtectionPermissionEditPoint, RemoveSheetMutation, SetSelectionsOperation, SetWorksheetActiveOperation, SheetInterceptorService, SheetPermissionCheckController, SheetsSelectionsService, UniverSheetsPlugin, WorkbookEditablePermission, WorksheetEditPermission, WorksheetSetCellStylePermission, checkRangesEditablePermission, getSheetCommandTarget, rangeToDiscreteRange, setEndForRange } from "@univerjs/sheets";
3
- import { AddCfCommand, AddConditionalRuleMutation, AddConditionalRuleMutationUndoFactory, CFNumberOperator, CFRuleType, CFSubRuleType, CFTextOperator, CFTimePeriodOperator, CFValueType, CONDITIONAL_FORMATTING_VIEWPORT_CACHE_LENGTH, ClearRangeCfCommand, ClearWorksheetCfCommand, ConditionalFormattingRangeIndexModel, ConditionalFormattingRangeTransformService, ConditionalFormattingRuleModel, ConditionalFormattingService, ConditionalFormattingViewModel, DEFAULT_BG_COLOR, DEFAULT_FONT_COLOR, DEFAULT_PADDING, DEFAULT_WIDTH, DeleteCfCommand, DeleteConditionalRuleMutation, DeleteConditionalRuleMutationUndoFactory, IIconSetType, MoveCfCommand, MoveConditionalRuleMutation, SHEET_CONDITIONAL_FORMATTING_PLUGIN, SetCfCommand, SetConditionalRuleMutation, UniverSheetsConditionalFormattingPlugin, compareWithNumber, createCfId, createDefaultRule, createDefaultValue, createDefaultValueByValueType, defaultDataBarNativeColor, defaultDataBarPositiveColor, getColorScaleFromValue, getOppositeOperator, iconGroup, iconMap, removeUndefinedAttr, setConditionalRuleMutationUndoFactory } from "@univerjs/sheets-conditional-formatting";
3
+ import { AddCfCommand, AddConditionalRuleMutation, AddConditionalRuleMutationUndoFactory, CFNumberOperator, CFRuleType, CFSubRuleType, CFTextOperator, CFTimePeriodOperator, CFValueType, CONDITIONAL_FORMATTING_VIEWPORT_CACHE_LENGTH, ClearRangeCfCommand, ClearWorksheetCfCommand, ConditionalFormattingIcon, ConditionalFormattingRangeIndexModel, ConditionalFormattingRangeTransformService, ConditionalFormattingRuleModel, ConditionalFormattingService, ConditionalFormattingViewModel, DEFAULT_BG_COLOR, DEFAULT_FONT_COLOR, DEFAULT_PADDING, DEFAULT_WIDTH, DataBar, DeleteCfCommand, DeleteConditionalRuleMutation, DeleteConditionalRuleMutationUndoFactory, IIconSetType, IconUKey, MoveCfCommand, MoveConditionalRuleMutation, SHEET_CONDITIONAL_FORMATTING_PLUGIN, SetCfCommand, SetConditionalRuleMutation, UniverSheetsConditionalFormattingPlugin, compareWithNumber, createCfId, createDefaultRule, createDefaultValue, createDefaultValueByValueType, dataBarUKey, defaultDataBarNativeColor, defaultDataBarPositiveColor, getColorScaleFromValue, getOppositeOperator, iconGroup, iconMap, removeUndefinedAttr, setConditionalRuleMutationUndoFactory } from "@univerjs/sheets-conditional-formatting";
4
4
  import { ComponentManager, IMenuManagerService, ISidebarService, IconManager, MenuItemType, RibbonDataGroup, RibbonInsertGroup, getMenuHiddenObservable, useDependency, useObservable, useSidebarClick } from "@univerjs/ui";
5
5
  import { COPY_TYPE, FormatPainterStatus, IFormatPainterService, ISheetClipboardService, PREDEFINED_HOOK_NAME_PASTE, SheetSkeletonManagerService, UniverSheetsMobileUIPlugin, UniverSheetsUIPlugin, getCurrentRangeDisable$, getRepeatRange, useHighlightRange, virtualizeDiscreteRanges } from "@univerjs/sheets-ui";
6
6
  import { Observable, debounceTime, filter, map, merge as merge$1, share, startWith } from "rxjs";
@@ -984,7 +984,7 @@ const menuSchema = {
984
984
  //#endregion
985
985
  //#region package.json
986
986
  var name = "@univerjs/sheets-conditional-formatting-ui";
987
- var version = "1.0.0-beta.0";
987
+ var version = "1.0.0-beta.1";
988
988
 
989
989
  //#endregion
990
990
  //#region src/config/config.ts
@@ -1181,12 +1181,11 @@ const specialPastes = [
1181
1181
  PREDEFINED_HOOK_NAME_PASTE.SPECIAL_PASTE_BESIDES_BORDER
1182
1182
  ];
1183
1183
  let ConditionalFormattingCopyPasteController = class ConditionalFormattingCopyPasteController extends Disposable {
1184
- constructor(_sheetClipboardService, _conditionalFormattingRuleModel, _injector, _conditionalFormattingViewModel, _univerInstanceService, _conditionalFormattingRangeTransformService) {
1184
+ constructor(_sheetClipboardService, _conditionalFormattingRuleModel, _injector, _univerInstanceService, _conditionalFormattingRangeTransformService) {
1185
1185
  super();
1186
1186
  this._sheetClipboardService = _sheetClipboardService;
1187
1187
  this._conditionalFormattingRuleModel = _conditionalFormattingRuleModel;
1188
1188
  this._injector = _injector;
1189
- this._conditionalFormattingViewModel = _conditionalFormattingViewModel;
1190
1189
  this._univerInstanceService = _univerInstanceService;
1191
1190
  this._conditionalFormattingRangeTransformService = _conditionalFormattingRangeTransformService;
1192
1191
  _defineProperty(this, "_copyInfo", void 0);
@@ -1206,10 +1205,11 @@ let ConditionalFormattingCopyPasteController = class ConditionalFormattingCopyPa
1206
1205
  }));
1207
1206
  }
1208
1207
  _collectConditionalRule(unitId, subUnitId, range) {
1209
- const matrix = new ObjectMatrix();
1208
+ var _this$_conditionalFor;
1209
+ const rules = /* @__PURE__ */ new Map();
1210
1210
  const cfMap = {};
1211
1211
  this._copyInfo = {
1212
- matrix,
1212
+ rules,
1213
1213
  info: {
1214
1214
  unitId,
1215
1215
  subUnitId,
@@ -1220,22 +1220,28 @@ let ConditionalFormattingCopyPasteController = class ConditionalFormattingCopyPa
1220
1220
  return rangeToDiscreteRange(range, accessor, unitId, subUnitId);
1221
1221
  });
1222
1222
  if (!discreteRange) return;
1223
- const { rows, cols } = discreteRange;
1224
- const cfIdSet = /* @__PURE__ */ new Set();
1225
- rows.forEach((row, rowIndex) => {
1226
- cols.forEach((col, colIndex) => {
1227
- const cellCfList = this._conditionalFormattingViewModel.getCellCfs(unitId, subUnitId, row, col);
1228
- if (!cellCfList) return;
1229
- cellCfList.forEach((item) => cfIdSet.add(item.cfId));
1230
- matrix.setValue(rowIndex, colIndex, cellCfList.map((item) => item.cfId));
1223
+ const { projectRange } = virtualizeDiscreteRanges([discreteRange]);
1224
+ (_this$_conditionalFor = this._conditionalFormattingRuleModel.getSubunitRules(unitId, subUnitId)) === null || _this$_conditionalFor === void 0 || _this$_conditionalFor.forEach((rule) => {
1225
+ const projectedRanges = rule.ranges.flatMap((ruleRange) => {
1226
+ const projected = projectRange(ruleRange);
1227
+ return projected ? [projected] : [];
1231
1228
  });
1232
- });
1233
- cfIdSet.forEach((cfId) => {
1234
- const rule = this._conditionalFormattingRuleModel.getRule(unitId, subUnitId, cfId);
1235
- if (rule) cfMap[cfId] = rule.rule;
1229
+ if (projectedRanges.length) {
1230
+ rules.set(rule.cfId, projectedRanges.length > 1 ? Rectangle.mergeRanges(projectedRanges) : projectedRanges);
1231
+ cfMap[rule.cfId] = {
1232
+ rule: rule.rule,
1233
+ stopIfTrue: rule.stopIfTrue
1234
+ };
1235
+ }
1236
1236
  });
1237
1237
  }
1238
1238
  _generateConditionalFormattingMutations(pasteFrom, pasteTo, payload) {
1239
+ var _this$_conditionalFor2;
1240
+ const copyInfo = this._copyInfo;
1241
+ if (!copyInfo) return {
1242
+ redos: [],
1243
+ undos: []
1244
+ };
1239
1245
  const { unitId: copyUnitId, subUnitId: copySubUnitId, range: copyRange } = pasteFrom;
1240
1246
  const { unitId: pastedUnitId, subUnitId: pastedSubUnitId, range: pastedRange } = pasteTo;
1241
1247
  const { copyType = COPY_TYPE.COPY } = payload;
@@ -1253,109 +1259,86 @@ let ConditionalFormattingCopyPasteController = class ConditionalFormattingCopyPa
1253
1259
  undos: []
1254
1260
  };
1255
1261
  }
1256
- const { ranges: [vCopyRange, vPastedRange], mapFunc } = virtualizeDiscreteRanges([copyRange, pastedRange]);
1257
- const repeatRange = getRepeatRange(vCopyRange, vPastedRange, true);
1258
- const effectedConditionalFormattingRuleRanges = {};
1259
- Range.foreach(vPastedRange, (row, col) => {
1260
- const { row: realRow, col: realCol } = mapFunc(row, col);
1261
- const cellCfList = this._conditionalFormattingViewModel.getCellCfs(pastedUnitId, pastedSubUnitId, realRow, realCol);
1262
- if (cellCfList) cellCfList.forEach((item) => {
1263
- if (!effectedConditionalFormattingRuleRanges[item.cfId]) {
1264
- const rule = this._conditionalFormattingRuleModel.getRule(pastedUnitId, pastedSubUnitId, item.cfId);
1265
- if (!rule) return;
1266
- effectedConditionalFormattingRuleRanges[item.cfId] = {
1267
- unitId: pastedUnitId,
1268
- subUnitId: pastedSubUnitId,
1269
- ranges: rule.ranges,
1270
- add: [],
1271
- remove: []
1272
- };
1273
- }
1274
- effectedConditionalFormattingRuleRanges[item.cfId].remove.push({
1275
- startRow: realRow,
1276
- endRow: realRow,
1277
- startColumn: realCol,
1278
- endColumn: realCol
1279
- });
1262
+ const sourceVirtualization = virtualizeDiscreteRanges([copyRange]);
1263
+ const sourceVirtualRange = sourceVirtualization.ranges[0];
1264
+ const targetVirtualization = virtualizeDiscreteRanges([pastedRange]);
1265
+ const targetVirtualRange = targetVirtualization.ranges[0];
1266
+ const repeatRange = getRepeatRange(sourceVirtualRange, targetVirtualRange, true);
1267
+ const targetRanges = targetVirtualization.mapRange(targetVirtualRange);
1268
+ const isSameSheet = pastedUnitId === copyUnitId && pastedSubUnitId === copySubUnitId;
1269
+ const effectedConditionalFormattingRuleRanges = /* @__PURE__ */ new Map();
1270
+ const getEffectKey = (unitId, subUnitId, cfId) => JSON.stringify([
1271
+ unitId,
1272
+ subUnitId,
1273
+ cfId
1274
+ ]);
1275
+ (_this$_conditionalFor2 = this._conditionalFormattingRuleModel.getSubunitRules(pastedUnitId, pastedSubUnitId)) === null || _this$_conditionalFor2 === void 0 || _this$_conditionalFor2.forEach((rule) => {
1276
+ if (!Rectangle.doAnyRangesIntersect(rule.ranges, targetRanges)) return;
1277
+ effectedConditionalFormattingRuleRanges.set(getEffectKey(pastedUnitId, pastedSubUnitId, rule.cfId), {
1278
+ cfId: rule.cfId,
1279
+ unitId: pastedUnitId,
1280
+ subUnitId: pastedSubUnitId,
1281
+ ranges: rule.ranges,
1282
+ add: [],
1283
+ remove: targetRanges
1280
1284
  });
1281
1285
  });
1282
- if (copyType === COPY_TYPE.CUT && (pastedUnitId !== copyUnitId || pastedSubUnitId !== copySubUnitId)) Range.foreach(vCopyRange, (row, col) => {
1283
- const { row: realRow, col: realCol } = mapFunc(row, col);
1284
- const cellCfList = this._conditionalFormattingViewModel.getCellCfs(copyUnitId, copySubUnitId, realRow, realCol);
1285
- if (cellCfList) cellCfList.forEach((item) => {
1286
- if (!effectedConditionalFormattingRuleRanges[item.cfId]) {
1287
- const rule = this._conditionalFormattingRuleModel.getRule(copyUnitId, copySubUnitId, item.cfId);
1288
- if (!rule) return;
1289
- effectedConditionalFormattingRuleRanges[item.cfId] = {
1290
- unitId: copyUnitId,
1291
- subUnitId: copySubUnitId,
1292
- ranges: rule.ranges,
1293
- add: [],
1294
- remove: []
1295
- };
1296
- }
1297
- effectedConditionalFormattingRuleRanges[item.cfId].remove.push({
1298
- startRow: realRow,
1299
- endRow: realRow,
1300
- startColumn: realCol,
1301
- endColumn: realCol
1286
+ if (copyType === COPY_TYPE.CUT && (pastedUnitId !== copyUnitId || pastedSubUnitId !== copySubUnitId)) {
1287
+ const sourceRanges = sourceVirtualization.mapRange(sourceVirtualRange);
1288
+ copyInfo.rules.forEach((_ranges, cfId) => {
1289
+ const rule = this._conditionalFormattingRuleModel.getRule(copyUnitId, copySubUnitId, cfId);
1290
+ if (!rule) return;
1291
+ effectedConditionalFormattingRuleRanges.set(getEffectKey(copyUnitId, copySubUnitId, cfId), {
1292
+ cfId,
1293
+ unitId: copyUnitId,
1294
+ subUnitId: copySubUnitId,
1295
+ ranges: rule.ranges,
1296
+ add: [],
1297
+ remove: sourceRanges
1302
1298
  });
1303
1299
  });
1304
- });
1305
- const { matrix, info } = this._copyInfo;
1306
- const waitAddRule = [];
1300
+ }
1301
+ const { rules, info } = copyInfo;
1302
+ const waitAddRule = /* @__PURE__ */ new Map();
1307
1303
  const cacheCfIdMap = {};
1308
1304
  const getCurrentSheetCfRule = (copyRangeCfId) => {
1309
1305
  const oldRule = info === null || info === void 0 ? void 0 : info.cfMap[copyRangeCfId];
1310
- const targetRule = [...this._conditionalFormattingRuleModel.getSubunitRules(pastedUnitId, pastedSubUnitId) || [], ...waitAddRule].find((rule) => {
1311
- return Tools.diffValue(rule.rule, oldRule);
1312
- });
1313
- if (targetRule) {
1314
- cacheCfIdMap[copyRangeCfId] = targetRule;
1315
- return targetRule;
1316
- } else {
1317
- const rule = {
1318
- rule: oldRule,
1319
- cfId: this._conditionalFormattingRuleModel.createCfId(pastedUnitId, pastedSubUnitId),
1320
- ranges: [],
1321
- stopIfTrue: false
1322
- };
1323
- cacheCfIdMap[copyRangeCfId] = rule;
1324
- waitAddRule.push(rule);
1325
- return rule;
1306
+ if (isSameSheet) {
1307
+ const rule = this._conditionalFormattingRuleModel.getRule(pastedUnitId, pastedSubUnitId, copyRangeCfId);
1308
+ if (rule) {
1309
+ cacheCfIdMap[copyRangeCfId] = rule;
1310
+ return rule;
1311
+ }
1326
1312
  }
1313
+ const rule = {
1314
+ rule: oldRule.rule,
1315
+ cfId: this._conditionalFormattingRuleModel.createCfId(pastedUnitId, pastedSubUnitId),
1316
+ ranges: [],
1317
+ stopIfTrue: oldRule.stopIfTrue
1318
+ };
1319
+ cacheCfIdMap[copyRangeCfId] = rule;
1320
+ waitAddRule.set(rule.cfId, rule);
1321
+ return rule;
1327
1322
  };
1328
- repeatRange.forEach((item) => {
1329
- matrix && matrix.forValue((row, col, copyRangeCfIdList) => {
1330
- const range = Rectangle.getPositionRange({
1331
- startRow: row,
1332
- endRow: row,
1333
- startColumn: col,
1334
- endColumn: col
1335
- }, item.startRange);
1336
- const { row: _row, col: _col } = mapFunc(range.startRow, range.startColumn);
1337
- copyRangeCfIdList.forEach((cfId) => {
1338
- const rule = cacheCfIdMap[cfId] || getCurrentSheetCfRule(cfId);
1339
- if (!effectedConditionalFormattingRuleRanges[rule.cfId]) effectedConditionalFormattingRuleRanges[rule.cfId] = {
1340
- unitId: pastedUnitId,
1341
- subUnitId: pastedSubUnitId,
1342
- ranges: rule.ranges,
1343
- add: [],
1344
- remove: []
1345
- };
1346
- effectedConditionalFormattingRuleRanges[rule.cfId].add.push({
1347
- startRow: _row,
1348
- endRow: _row,
1349
- startColumn: _col,
1350
- endColumn: _col
1351
- });
1352
- });
1323
+ const sourceRuleEntries = Array.from(rules.entries());
1324
+ if (!isSameSheet) sourceRuleEntries.reverse();
1325
+ sourceRuleEntries.forEach(([cfId, sourceRanges]) => {
1326
+ const rule = cacheCfIdMap[cfId] || getCurrentSheetCfRule(cfId);
1327
+ const effectKey = getEffectKey(pastedUnitId, pastedSubUnitId, rule.cfId);
1328
+ if (!effectedConditionalFormattingRuleRanges.has(effectKey)) effectedConditionalFormattingRuleRanges.set(effectKey, {
1329
+ cfId: rule.cfId,
1330
+ unitId: pastedUnitId,
1331
+ subUnitId: pastedSubUnitId,
1332
+ ranges: rule.ranges,
1333
+ add: [],
1334
+ remove: []
1353
1335
  });
1336
+ effectedConditionalFormattingRuleRanges.get(effectKey).add.push(...repeatRange.flatMap((item) => sourceRanges.flatMap((sourceRange) => targetVirtualization.mapRange(Rectangle.getPositionRange(sourceRange, item.startRange)))));
1354
1337
  });
1355
1338
  const redos = [];
1356
1339
  const undos = [];
1357
- for (const cfId in effectedConditionalFormattingRuleRanges) {
1358
- const { unitId, subUnitId, ranges: sourceRanges, add, remove } = effectedConditionalFormattingRuleRanges[cfId];
1340
+ for (const effect of effectedConditionalFormattingRuleRanges.values()) {
1341
+ const { cfId, unitId, subUnitId, ranges: sourceRanges, add, remove } = effect;
1359
1342
  const ranges = this._conditionalFormattingRangeTransformService.applyRangeDelta(sourceRanges, remove, add);
1360
1343
  if (!ranges.length) {
1361
1344
  const deleteParams = {
@@ -1368,13 +1351,15 @@ let ConditionalFormattingCopyPasteController = class ConditionalFormattingCopyPa
1368
1351
  params: deleteParams
1369
1352
  });
1370
1353
  undos.push(...DeleteConditionalRuleMutationUndoFactory(this._injector, deleteParams));
1354
+ continue;
1371
1355
  }
1372
- if (waitAddRule.some((rule) => rule.cfId === cfId)) {
1356
+ const waitAdd = waitAddRule.get(cfId);
1357
+ if (waitAdd) {
1373
1358
  const addParams = {
1374
1359
  unitId: pastedUnitId,
1375
1360
  subUnitId: pastedSubUnitId,
1376
1361
  rule: {
1377
- ...waitAddRule.find((rule) => rule.cfId === cfId),
1362
+ ...waitAdd,
1378
1363
  ranges
1379
1364
  }
1380
1365
  };
@@ -1411,9 +1396,8 @@ ConditionalFormattingCopyPasteController = __decorate([
1411
1396
  __decorateParam(0, Inject(ISheetClipboardService)),
1412
1397
  __decorateParam(1, Inject(ConditionalFormattingRuleModel)),
1413
1398
  __decorateParam(2, Inject(Injector)),
1414
- __decorateParam(3, Inject(ConditionalFormattingViewModel)),
1415
- __decorateParam(4, Inject(IUniverInstanceService)),
1416
- __decorateParam(5, Inject(ConditionalFormattingRangeTransformService))
1399
+ __decorateParam(3, Inject(IUniverInstanceService)),
1400
+ __decorateParam(4, Inject(ConditionalFormattingRangeTransformService))
1417
1401
  ], ConditionalFormattingCopyPasteController);
1418
1402
 
1419
1403
  //#endregion
@@ -1499,7 +1483,7 @@ ConditionalFormattingPermissionController = __decorate([
1499
1483
  //#endregion
1500
1484
  //#region src/controllers/cf.render.controller.ts
1501
1485
  let SheetsCfRenderController = class SheetsCfRenderController extends Disposable {
1502
- constructor(_sheetInterceptorService, _conditionalFormattingService, _univerInstanceService, _renderManagerService, _conditionalFormattingViewModel, _conditionalFormattingRuleModel) {
1486
+ constructor(_sheetInterceptorService, _conditionalFormattingService, _univerInstanceService, _renderManagerService, _conditionalFormattingViewModel, _conditionalFormattingRuleModel, _conditionalFormattingRangeIndexModel) {
1503
1487
  super();
1504
1488
  this._sheetInterceptorService = _sheetInterceptorService;
1505
1489
  this._conditionalFormattingService = _conditionalFormattingService;
@@ -1507,14 +1491,69 @@ let SheetsCfRenderController = class SheetsCfRenderController extends Disposable
1507
1491
  this._renderManagerService = _renderManagerService;
1508
1492
  this._conditionalFormattingViewModel = _conditionalFormattingViewModel;
1509
1493
  this._conditionalFormattingRuleModel = _conditionalFormattingRuleModel;
1494
+ this._conditionalFormattingRangeIndexModel = _conditionalFormattingRangeIndexModel;
1510
1495
  _defineProperty(this, "_ruleChangeCacheMap", /* @__PURE__ */ new Map());
1496
+ _defineProperty(this, "_boundRenderExtensions", /* @__PURE__ */ new Map());
1511
1497
  this._initViewModelInterceptor();
1498
+ this._initRenderRangeResolvers();
1512
1499
  this._initSkeleton();
1513
1500
  queueMicrotask(() => this._markActiveSheetRulesDirty());
1514
1501
  this.disposeWithMe(() => {
1515
1502
  this._ruleChangeCacheMap.clear();
1503
+ this._boundRenderExtensions.forEach((extensions) => {
1504
+ extensions.forEach((extension) => extension.setRenderRangeResolver(null));
1505
+ });
1506
+ this._boundRenderExtensions.clear();
1516
1507
  });
1517
1508
  }
1509
+ _initRenderRangeResolvers() {
1510
+ const dataBarResolver = this._createRenderRangeResolver(CFRuleType.dataBar);
1511
+ const iconResolver = this._createRenderRangeResolver(CFRuleType.iconSet);
1512
+ const bind = (unitId) => {
1513
+ var _this$_renderManagerS;
1514
+ this._unbindRenderRangeResolvers(unitId);
1515
+ const mainComponent = (_this$_renderManagerS = this._renderManagerService.getRenderUnitById(unitId)) === null || _this$_renderManagerS === void 0 ? void 0 : _this$_renderManagerS.mainComponent;
1516
+ if (!mainComponent || !("getExtensionByKey" in mainComponent)) return;
1517
+ const extensions = /* @__PURE__ */ new Set();
1518
+ const dataBar = mainComponent.getExtensionByKey(dataBarUKey);
1519
+ if (dataBar instanceof DataBar) {
1520
+ dataBar.setRenderRangeResolver(dataBarResolver);
1521
+ extensions.add(dataBar);
1522
+ }
1523
+ const icon = mainComponent.getExtensionByKey(IconUKey);
1524
+ if (icon instanceof ConditionalFormattingIcon) {
1525
+ icon.setRenderRangeResolver(iconResolver);
1526
+ extensions.add(icon);
1527
+ }
1528
+ if (extensions.size) this._boundRenderExtensions.set(unitId, extensions);
1529
+ };
1530
+ this._renderManagerService.getAllRenderersOfType(UniverInstanceType.UNIVER_SHEET).forEach((render) => bind(render.unitId));
1531
+ this.disposeWithMe(this._renderManagerService.created$.subscribe((render) => {
1532
+ if (render.type === UniverInstanceType.UNIVER_SHEET) bind(render.unitId);
1533
+ }));
1534
+ this.disposeWithMe(this._renderManagerService.disposed$.subscribe((unitId) => this._unbindRenderRangeResolvers(unitId)));
1535
+ }
1536
+ _createRenderRangeResolver(ruleType) {
1537
+ return (unitId, subUnitId, ranges) => {
1538
+ const intersections = [];
1539
+ const indexedRules = this._conditionalFormattingRangeIndexModel.getRulesByRanges(unitId, subUnitId, ranges).filter((rule) => rule.rule.type === ruleType);
1540
+ const matchingRules = indexedRules.length ? indexedRules : (this._conditionalFormattingRuleModel.getSubunitRules(unitId, subUnitId) ?? []).filter((rule) => rule.rule.type === ruleType);
1541
+ ranges.forEach((range) => {
1542
+ matchingRules.forEach((rule) => {
1543
+ rule.ranges.forEach((ruleRange) => {
1544
+ const intersection = getIntersectRange(range, ruleRange);
1545
+ if (intersection) intersections.push(intersection);
1546
+ });
1547
+ });
1548
+ });
1549
+ return intersections.length > 1 ? Rectangle.mergeRanges(intersections) : intersections;
1550
+ };
1551
+ }
1552
+ _unbindRenderRangeResolvers(unitId) {
1553
+ const extensions = this._boundRenderExtensions.get(unitId);
1554
+ extensions === null || extensions === void 0 || extensions.forEach((extension) => extension.setRenderRangeResolver(null));
1555
+ this._boundRenderExtensions.delete(unitId);
1556
+ }
1518
1557
  _collectDirtyRanges(items, unitId, subUnitId) {
1519
1558
  const ranges = [];
1520
1559
  items.forEach((item) => {
@@ -1609,7 +1648,8 @@ SheetsCfRenderController = __decorate([
1609
1648
  __decorateParam(2, Inject(IUniverInstanceService)),
1610
1649
  __decorateParam(3, Inject(IRenderManagerService)),
1611
1650
  __decorateParam(4, Inject(ConditionalFormattingViewModel)),
1612
- __decorateParam(5, Inject(ConditionalFormattingRuleModel))
1651
+ __decorateParam(5, Inject(ConditionalFormattingRuleModel)),
1652
+ __decorateParam(6, Inject(ConditionalFormattingRangeIndexModel))
1613
1653
  ], SheetsCfRenderController);
1614
1654
 
1615
1655
  //#endregion
@@ -1663,13 +1703,12 @@ UniverSheetsConditionalFormattingMobileUIPlugin = __decorate([
1663
1703
  //#endregion
1664
1704
  //#region src/controllers/cf.auto-fill.controller.ts
1665
1705
  let ConditionalFormattingAutoFillController = class ConditionalFormattingAutoFillController extends Disposable {
1666
- constructor(_injector, _univerInstanceService, _autoFillService, _conditionalFormattingRuleModel, _conditionalFormattingViewModel, _conditionalFormattingRangeTransformService) {
1706
+ constructor(_injector, _univerInstanceService, _autoFillService, _conditionalFormattingRuleModel, _conditionalFormattingRangeTransformService) {
1667
1707
  super();
1668
1708
  this._injector = _injector;
1669
1709
  this._univerInstanceService = _univerInstanceService;
1670
1710
  this._autoFillService = _autoFillService;
1671
1711
  this._conditionalFormattingRuleModel = _conditionalFormattingRuleModel;
1672
- this._conditionalFormattingViewModel = _conditionalFormattingViewModel;
1673
1712
  this._conditionalFormattingRangeTransformService = _conditionalFormattingRangeTransformService;
1674
1713
  this._initAutoFill();
1675
1714
  }
@@ -1678,11 +1717,24 @@ let ConditionalFormattingAutoFillController = class ConditionalFormattingAutoFil
1678
1717
  redos: [],
1679
1718
  undos: []
1680
1719
  });
1681
- const loopFunc = (sourceStartCell, targetStartCell, relativeRange, rangeMap, rangeDeltaMap, mapFunc) => {
1682
- var _getActiveSheet;
1683
- const unitId = this._univerInstanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_SHEET).getUnitId();
1684
- const subUnitId = (_getActiveSheet = this._univerInstanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_SHEET).getActiveSheet()) === null || _getActiveSheet === void 0 ? void 0 : _getActiveSheet.getSheetId();
1685
- if (!unitId || !subUnitId) return;
1720
+ const generalApplyFunc = (sourceRange, targetRange) => {
1721
+ var _this$_univerInstance, _this$_univerInstance2;
1722
+ const unitId = (_this$_univerInstance = this._univerInstanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_SHEET)) === null || _this$_univerInstance === void 0 ? void 0 : _this$_univerInstance.getUnitId();
1723
+ const subUnitId = (_this$_univerInstance2 = this._univerInstanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_SHEET)) === null || _this$_univerInstance2 === void 0 || (_this$_univerInstance2 = _this$_univerInstance2.getActiveSheet()) === null || _this$_univerInstance2 === void 0 ? void 0 : _this$_univerInstance2.getSheetId();
1724
+ const rangeMap = /* @__PURE__ */ new Map();
1725
+ const rangeDeltaMap = /* @__PURE__ */ new Map();
1726
+ const redos = [];
1727
+ const undos = [];
1728
+ if (!unitId || !subUnitId) return noopReturnFunc();
1729
+ const virtualization = virtualizeDiscreteRanges([sourceRange, targetRange]);
1730
+ const [vSourceRange, vTargetRange] = virtualization.ranges;
1731
+ const repeats = AutoFillTools.getAutoFillRepeatRange(vSourceRange, vTargetRange);
1732
+ const targetRanges = repeats.flatMap((repeat) => virtualization.mapRange(Rectangle.getPositionRange(repeat.relativeRange, {
1733
+ startRow: repeat.repeatStartCell.row,
1734
+ endRow: repeat.repeatStartCell.row,
1735
+ startColumn: repeat.repeatStartCell.col,
1736
+ endColumn: repeat.repeatStartCell.col
1737
+ })));
1686
1738
  const getRangeDelta = (cfId) => {
1687
1739
  let rangeDelta = rangeDeltaMap.get(cfId);
1688
1740
  if (!rangeDelta) {
@@ -1694,80 +1746,29 @@ let ConditionalFormattingAutoFillController = class ConditionalFormattingAutoFil
1694
1746
  }
1695
1747
  return rangeDelta;
1696
1748
  };
1697
- const ensureRuleRanges = (cfId) => {
1698
- if (rangeMap.has(cfId)) return true;
1699
- const rule = this._conditionalFormattingRuleModel.getRule(unitId, subUnitId, cfId);
1700
- if (!rule) return false;
1701
- rangeMap.set(cfId, rule.ranges);
1702
- return true;
1703
- };
1704
- const sourceRange = {
1705
- startRow: sourceStartCell.row,
1706
- startColumn: sourceStartCell.col,
1707
- endColumn: sourceStartCell.col,
1708
- endRow: sourceStartCell.row
1709
- };
1710
- const targetRange = {
1711
- startRow: targetStartCell.row,
1712
- startColumn: targetStartCell.col,
1713
- endColumn: targetStartCell.col,
1714
- endRow: targetStartCell.row
1715
- };
1716
- Range.foreach(relativeRange, (row, col) => {
1717
- const sourcePositionRange = Rectangle.getPositionRange({
1718
- startRow: row,
1719
- startColumn: col,
1720
- endColumn: col,
1721
- endRow: row
1722
- }, sourceRange);
1723
- const targetPositionRange = Rectangle.getPositionRange({
1724
- startRow: row,
1725
- startColumn: col,
1726
- endColumn: col,
1727
- endRow: row
1728
- }, targetRange);
1729
- const { row: sourceRow, col: sourceCol } = mapFunc(sourcePositionRange.startRow, sourcePositionRange.startColumn);
1730
- const sourceCellCf = this._conditionalFormattingViewModel.getCellCfs(unitId, subUnitId, sourceRow, sourceCol);
1731
- const { row: targetRow, col: targetCol } = mapFunc(targetPositionRange.startRow, targetPositionRange.startColumn);
1732
- const targetCellCf = this._conditionalFormattingViewModel.getCellCfs(unitId, subUnitId, targetRow, targetCol);
1733
- if (targetCellCf) targetCellCf.forEach((cf) => {
1734
- if (!ensureRuleRanges(cf.cfId)) return;
1735
- getRangeDelta(cf.cfId).remove.push({
1736
- startRow: targetRow,
1737
- endRow: targetRow,
1738
- startColumn: targetCol,
1739
- endColumn: targetCol
1740
- });
1741
- });
1742
- if (sourceCellCf) sourceCellCf.forEach((cf) => {
1743
- if (!ensureRuleRanges(cf.cfId)) return;
1744
- getRangeDelta(cf.cfId).add.push({
1745
- startRow: targetRow,
1746
- endRow: targetRow,
1747
- startColumn: targetCol,
1748
- endColumn: targetCol
1749
- });
1749
+ (this._conditionalFormattingRuleModel.getSubunitRules(unitId, subUnitId) ?? []).forEach((rule) => {
1750
+ if (Rectangle.doAnyRangesIntersect(rule.ranges, targetRanges)) {
1751
+ rangeMap.set(rule.cfId, rule.ranges);
1752
+ getRangeDelta(rule.cfId).remove.push(...targetRanges);
1753
+ }
1754
+ const sourceRanges = rule.ranges.flatMap((range) => {
1755
+ const projected = virtualization.projectRange(range);
1756
+ const intersected = projected && getIntersectRange(projected, vSourceRange);
1757
+ return intersected ? [Rectangle.getRelativeRange(intersected, vSourceRange)] : [];
1750
1758
  });
1751
- });
1752
- };
1753
- const generalApplyFunc = (sourceRange, targetRange) => {
1754
- var _this$_univerInstance, _this$_univerInstance2;
1755
- const unitId = (_this$_univerInstance = this._univerInstanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_SHEET)) === null || _this$_univerInstance === void 0 ? void 0 : _this$_univerInstance.getUnitId();
1756
- const subUnitId = (_this$_univerInstance2 = this._univerInstanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_SHEET)) === null || _this$_univerInstance2 === void 0 || (_this$_univerInstance2 = _this$_univerInstance2.getActiveSheet()) === null || _this$_univerInstance2 === void 0 ? void 0 : _this$_univerInstance2.getSheetId();
1757
- const rangeMap = /* @__PURE__ */ new Map();
1758
- const rangeDeltaMap = /* @__PURE__ */ new Map();
1759
- const redos = [];
1760
- const undos = [];
1761
- if (!unitId || !subUnitId) return noopReturnFunc();
1762
- const virtualRange = virtualizeDiscreteRanges([sourceRange, targetRange]);
1763
- const [vSourceRange, vTargetRange] = virtualRange.ranges;
1764
- const { mapFunc } = virtualRange;
1765
- const sourceStartCell = {
1766
- row: vSourceRange.startRow,
1767
- col: vSourceRange.startColumn
1768
- };
1769
- AutoFillTools.getAutoFillRepeatRange(vSourceRange, vTargetRange).forEach((repeat) => {
1770
- loopFunc(sourceStartCell, repeat.repeatStartCell, repeat.relativeRange, rangeMap, rangeDeltaMap, mapFunc);
1759
+ const additions = repeats.flatMap((repeat) => sourceRanges.flatMap((range) => {
1760
+ const copiedRange = getIntersectRange(range, repeat.relativeRange);
1761
+ return copiedRange ? virtualization.mapRange(Rectangle.getPositionRange(copiedRange, {
1762
+ startRow: repeat.repeatStartCell.row,
1763
+ endRow: repeat.repeatStartCell.row,
1764
+ startColumn: repeat.repeatStartCell.col,
1765
+ endColumn: repeat.repeatStartCell.col
1766
+ })) : [];
1767
+ }));
1768
+ if (additions.length) {
1769
+ rangeMap.set(rule.cfId, rule.ranges);
1770
+ getRangeDelta(rule.cfId).add.push(...additions);
1771
+ }
1771
1772
  });
1772
1773
  rangeDeltaMap.forEach((rangeDelta, cfId) => {
1773
1774
  const ranges = rangeMap.get(cfId);
@@ -1827,8 +1828,7 @@ ConditionalFormattingAutoFillController = __decorate([
1827
1828
  __decorateParam(1, Inject(IUniverInstanceService)),
1828
1829
  __decorateParam(2, Inject(IAutoFillService)),
1829
1830
  __decorateParam(3, Inject(ConditionalFormattingRuleModel)),
1830
- __decorateParam(4, Inject(ConditionalFormattingViewModel)),
1831
- __decorateParam(5, Inject(ConditionalFormattingRangeTransformService))
1831
+ __decorateParam(4, Inject(ConditionalFormattingRangeTransformService))
1832
1832
  ], ConditionalFormattingAutoFillController);
1833
1833
 
1834
1834
  //#endregion
@@ -1945,14 +1945,13 @@ const repeatByRange = (sourceRange, targetRange) => {
1945
1945
  return repeatList;
1946
1946
  };
1947
1947
  let ConditionalFormattingPainterController = class ConditionalFormattingPainterController extends Disposable {
1948
- constructor(_injector, _univerInstanceService, _formatPainterService, _sheetsSelectionsService, _conditionalFormattingRuleModel, _conditionalFormattingViewModel, _conditionalFormattingRangeTransformService) {
1948
+ constructor(_injector, _univerInstanceService, _formatPainterService, _sheetsSelectionsService, _conditionalFormattingRuleModel, _conditionalFormattingRangeTransformService) {
1949
1949
  super();
1950
1950
  this._injector = _injector;
1951
1951
  this._univerInstanceService = _univerInstanceService;
1952
1952
  this._formatPainterService = _formatPainterService;
1953
1953
  this._sheetsSelectionsService = _sheetsSelectionsService;
1954
1954
  this._conditionalFormattingRuleModel = _conditionalFormattingRuleModel;
1955
- this._conditionalFormattingViewModel = _conditionalFormattingViewModel;
1956
1955
  this._conditionalFormattingRangeTransformService = _conditionalFormattingRangeTransformService;
1957
1956
  _defineProperty(this, "_painterConfig", null);
1958
1957
  this._initFormattingPainter();
@@ -1962,9 +1961,16 @@ let ConditionalFormattingPainterController = class ConditionalFormattingPainterC
1962
1961
  redos: [],
1963
1962
  undos: []
1964
1963
  });
1965
- const loopFunc = (sourceStartCell, targetStartCell, relativeRange, rangeMap, rangeDeltaMap, config) => {
1966
- const { unitId: sourceUnitId, subUnitId: sourceSubUnitId } = this._painterConfig;
1967
- const { targetUnitId, targetSubUnitId } = config;
1964
+ const generalApplyFunc = (targetUnitId, targetSubUnitId, targetRange) => {
1965
+ const { range: sourceRange, unitId: sourceUnitId, subUnitId: sourceSubUnitId } = this._painterConfig;
1966
+ const isSkipSheet = targetUnitId !== sourceUnitId || sourceSubUnitId !== targetSubUnitId;
1967
+ const rangeMap = /* @__PURE__ */ new Map();
1968
+ const rangeDeltaMap = /* @__PURE__ */ new Map();
1969
+ const redos = [];
1970
+ const undos = [];
1971
+ if (!targetUnitId || !targetSubUnitId || !sourceUnitId || !sourceSubUnitId) return noopReturnFunc();
1972
+ const repeats = repeatByRange(sourceRange, targetRange);
1973
+ const targetRanges = repeats.map((repeat) => Rectangle.getPositionRange(repeat.repeatRelativeRange, repeat.startRange));
1968
1974
  const getRangeDelta = (cfId) => {
1969
1975
  let rangeDelta = rangeDeltaMap.get(cfId);
1970
1976
  if (!rangeDelta) {
@@ -1976,82 +1982,38 @@ let ConditionalFormattingPainterController = class ConditionalFormattingPainterC
1976
1982
  }
1977
1983
  return rangeDelta;
1978
1984
  };
1979
- const sourceRange = {
1980
- startRow: sourceStartCell.row,
1981
- startColumn: sourceStartCell.col,
1982
- endColumn: sourceStartCell.col,
1983
- endRow: sourceStartCell.row
1984
- };
1985
- const targetRange = {
1986
- startRow: targetStartCell.row,
1987
- startColumn: targetStartCell.col,
1988
- endColumn: targetStartCell.col,
1989
- endRow: targetStartCell.row
1990
- };
1991
- Range.foreach(relativeRange, (row, col) => {
1992
- const sourcePositionRange = Rectangle.getPositionRange({
1993
- startRow: row,
1994
- startColumn: col,
1995
- endColumn: col,
1996
- endRow: row
1997
- }, sourceRange);
1998
- const targetPositionRange = Rectangle.getPositionRange({
1999
- startRow: row,
2000
- startColumn: col,
2001
- endColumn: col,
2002
- endRow: row
2003
- }, targetRange);
2004
- const sourceCellCf = this._conditionalFormattingViewModel.getCellCfs(sourceUnitId, sourceSubUnitId, sourcePositionRange.startRow, sourcePositionRange.startColumn);
2005
- const targetCellCf = this._conditionalFormattingViewModel.getCellCfs(targetUnitId, targetSubUnitId, targetPositionRange.startRow, targetPositionRange.startColumn);
2006
- if (targetCellCf) targetCellCf.forEach((cf) => {
2007
- if (!rangeMap.has(cf.cfId)) {
2008
- const rule = this._conditionalFormattingRuleModel.getRule(targetUnitId, targetSubUnitId, cf.cfId);
2009
- if (!rule) return;
2010
- rangeMap.set(cf.cfId, rule.ranges);
2011
- }
2012
- getRangeDelta(cf.cfId).remove.push({
2013
- startRow: targetPositionRange.startRow,
2014
- endRow: targetPositionRange.startRow,
2015
- startColumn: targetPositionRange.startColumn,
2016
- endColumn: targetPositionRange.startColumn
2017
- });
2018
- });
2019
- if (sourceCellCf) sourceCellCf.forEach((cf) => {
2020
- if (!rangeMap.has(cf.cfId)) return;
2021
- getRangeDelta(cf.cfId).add.push({
2022
- startRow: targetPositionRange.startRow,
2023
- endRow: targetPositionRange.startRow,
2024
- startColumn: targetPositionRange.startColumn,
2025
- endColumn: targetPositionRange.startColumn
2026
- });
2027
- });
2028
- });
2029
- };
2030
- const generalApplyFunc = (targetUnitId, targetSubUnitId, targetRange) => {
2031
- const { range: sourceRange, unitId: sourceUnitId, subUnitId: sourceSubUnitId } = this._painterConfig;
2032
- const isSkipSheet = targetUnitId !== sourceUnitId || sourceSubUnitId !== targetSubUnitId;
2033
- const rangeMap = /* @__PURE__ */ new Map();
2034
- const rangeDeltaMap = /* @__PURE__ */ new Map();
2035
- const redos = [];
2036
- const undos = [];
2037
- if (!targetUnitId || !targetSubUnitId || !sourceUnitId || !sourceSubUnitId) return noopReturnFunc();
2038
- const ruleList = this._conditionalFormattingRuleModel.getSubunitRules(sourceUnitId, sourceSubUnitId) ?? [];
2039
- ruleList === null || ruleList === void 0 || ruleList.forEach((rule) => {
2040
- const { ranges, cfId } = rule;
2041
- if (ranges.some((range) => Rectangle.intersects(sourceRange, range))) rangeMap.set(cfId, isSkipSheet ? [] : ranges);
1985
+ const targetRuleList = this._conditionalFormattingRuleModel.getSubunitRules(targetUnitId, targetSubUnitId) ?? [];
1986
+ const waitAddRule = /* @__PURE__ */ new Map();
1987
+ targetRuleList.forEach((rule) => {
1988
+ if (Rectangle.doAnyRangesIntersect(rule.ranges, targetRanges)) {
1989
+ rangeMap.set(rule.cfId, rule.ranges);
1990
+ getRangeDelta(rule.cfId).remove.push(...targetRanges);
1991
+ }
2042
1992
  });
2043
- const sourceStartCell = {
2044
- row: sourceRange.startRow,
2045
- col: sourceRange.startColumn
2046
- };
2047
- repeatByRange(sourceRange, targetRange).forEach((repeat) => {
2048
- loopFunc(sourceStartCell, {
2049
- row: repeat.startRange.startRow,
2050
- col: repeat.startRange.startColumn
2051
- }, repeat.repeatRelativeRange, rangeMap, rangeDeltaMap, {
2052
- targetUnitId,
2053
- targetSubUnitId
1993
+ const sourceRuleList = this._conditionalFormattingRuleModel.getSubunitRules(sourceUnitId, sourceSubUnitId) ?? [];
1994
+ (isSkipSheet ? [...sourceRuleList].reverse() : sourceRuleList).forEach((rule) => {
1995
+ const sourceRanges = rule.ranges.flatMap((range) => {
1996
+ const intersected = getIntersectRange(range, sourceRange);
1997
+ return intersected ? [Rectangle.getRelativeRange(intersected, sourceRange)] : [];
2054
1998
  });
1999
+ const additions = repeats.flatMap((repeat) => sourceRanges.flatMap((range) => {
2000
+ const copiedRange = getIntersectRange(range, repeat.repeatRelativeRange);
2001
+ return copiedRange ? [Rectangle.getPositionRange(copiedRange, repeat.startRange)] : [];
2002
+ }));
2003
+ if (additions.length) {
2004
+ let targetCfId = rule.cfId;
2005
+ if (isSkipSheet) {
2006
+ targetCfId = this._conditionalFormattingRuleModel.createCfId(targetUnitId, targetSubUnitId);
2007
+ waitAddRule.set(targetCfId, {
2008
+ ...Tools.deepClone(rule),
2009
+ cfId: targetCfId,
2010
+ ranges: []
2011
+ });
2012
+ rangeMap.set(targetCfId, []);
2013
+ }
2014
+ if (!rangeMap.has(targetCfId)) rangeMap.set(targetCfId, rule.ranges);
2015
+ getRangeDelta(targetCfId).add.push(...additions);
2016
+ }
2055
2017
  });
2056
2018
  rangeDeltaMap.forEach((rangeDelta, cfId) => {
2057
2019
  const ranges = rangeMap.get(cfId);
@@ -2089,28 +2051,27 @@ let ConditionalFormattingPainterController = class ConditionalFormattingPainterC
2089
2051
  undos.push(...DeleteConditionalRuleMutationUndoFactory(this._injector, params));
2090
2052
  }
2091
2053
  } else {
2092
- const rule = this._conditionalFormattingRuleModel.getRule(targetUnitId, targetSubUnitId, cfId);
2093
- if (!rule) {
2054
+ const waitAdd = waitAddRule.get(cfId);
2055
+ if (waitAdd) {
2094
2056
  if (ranges.length) {
2095
- const sourceRule = this._conditionalFormattingRuleModel.getRule(sourceUnitId, sourceSubUnitId, cfId);
2096
- if (sourceRule) {
2097
- const params = {
2098
- unitId: targetUnitId,
2099
- subUnitId: targetSubUnitId,
2100
- rule: {
2101
- ...Tools.deepClone(sourceRule),
2102
- cfId: this._conditionalFormattingRuleModel.createCfId(targetUnitId, targetSubUnitId),
2103
- ranges
2104
- }
2105
- };
2106
- redos.push({
2107
- id: AddConditionalRuleMutation.id,
2108
- params
2109
- });
2110
- undos.push(AddConditionalRuleMutationUndoFactory(this._injector, params));
2111
- }
2057
+ const params = {
2058
+ unitId: targetUnitId,
2059
+ subUnitId: targetSubUnitId,
2060
+ rule: {
2061
+ ...waitAdd,
2062
+ ranges
2063
+ }
2064
+ };
2065
+ redos.push({
2066
+ id: AddConditionalRuleMutation.id,
2067
+ params
2068
+ });
2069
+ undos.push(AddConditionalRuleMutationUndoFactory(this._injector, params));
2112
2070
  }
2113
- } else if (ranges.length) {
2071
+ return;
2072
+ }
2073
+ const rule = this._conditionalFormattingRuleModel.getRule(targetUnitId, targetSubUnitId, cfId);
2074
+ if (rule) if (ranges.length) {
2114
2075
  const params = {
2115
2076
  unitId: targetUnitId,
2116
2077
  subUnitId: targetSubUnitId,
@@ -2183,8 +2144,7 @@ ConditionalFormattingPainterController = __decorate([
2183
2144
  __decorateParam(2, Inject(IFormatPainterService)),
2184
2145
  __decorateParam(3, Inject(SheetsSelectionsService)),
2185
2146
  __decorateParam(4, Inject(ConditionalFormattingRuleModel)),
2186
- __decorateParam(5, Inject(ConditionalFormattingViewModel)),
2187
- __decorateParam(6, Inject(ConditionalFormattingRangeTransformService))
2147
+ __decorateParam(5, Inject(ConditionalFormattingRangeTransformService))
2188
2148
  ], ConditionalFormattingPainterController);
2189
2149
 
2190
2150
  //#endregion
@@ -2410,7 +2370,7 @@ const TextInput$1 = (props) => {
2410
2370
  className: "univer-ml-1 univer-w-full",
2411
2371
  children: /* @__PURE__ */ jsx(FormulaEditor, {
2412
2372
  ref: formulaEditorRef,
2413
- className: 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", borderClassName),
2373
+ className: 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", borderClassName),
2414
2374
  initValue: formulaInitValue,
2415
2375
  unitId,
2416
2376
  subUnitId,
@@ -2831,7 +2791,7 @@ const InputText = (props) => {
2831
2791
  className: "univer-w-full",
2832
2792
  children: /* @__PURE__ */ jsx(FormulaEditor, {
2833
2793
  ref: formulaEditorRef,
2834
- className: 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", borderClassName),
2794
+ className: 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", borderClassName),
2835
2795
  initValue: v,
2836
2796
  unitId,
2837
2797
  subUnitId,
@@ -3351,7 +3311,7 @@ const FormulaStyleEditor = (props) => {
3351
3311
  className: "univer-mt-3",
3352
3312
  children: /* @__PURE__ */ jsx(FormulaEditor, {
3353
3313
  ref: formulaEditorRef,
3354
- className: 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", borderClassName),
3314
+ className: 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", borderClassName),
3355
3315
  errorText: formulaError,
3356
3316
  isFocus: isFocusFormulaEditor,
3357
3317
  initValue: formula,
@@ -3825,7 +3785,7 @@ const TextInput = (props) => {
3825
3785
  className: "univer-w-full",
3826
3786
  children: /* @__PURE__ */ jsx(FormulaEditor, {
3827
3787
  ref: formulaEditorRef,
3828
- className: 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", borderClassName),
3788
+ className: 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", borderClassName),
3829
3789
  initValue: String(props.value),
3830
3790
  unitId,
3831
3791
  subUnitId,
@@ -3850,8 +3810,9 @@ const createDefaultConfigItem = (iconType, index, list) => ({
3850
3810
  const IconGroupList = (props) => {
3851
3811
  const { iconType, onClick } = props;
3852
3812
  const localeService = useDependency(LocaleService);
3813
+ const direction = useObservable(localeService.direction$, localeService.getDirection());
3853
3814
  return /* @__PURE__ */ jsx("div", {
3854
- dir: useObservable(localeService.direction$, localeService.getDirection()),
3815
+ dir: direction,
3855
3816
  className: "univer-w-80",
3856
3817
  children: iconGroup.map((group) => {
3857
3818
  return /* @__PURE__ */ jsxs("div", {
@@ -3860,6 +3821,8 @@ const IconGroupList = (props) => {
3860
3821
  className: "univer-mb-2 univer-px-1 univer-text-xs univer-font-medium univer-text-gray-500 dark:!univer-text-gray-400",
3861
3822
  children: localeService.t(group.title)
3862
3823
  }), /* @__PURE__ */ jsx("div", {
3824
+ dir: direction,
3825
+ "data-u-comp": "cf-icon-set-group-grid",
3863
3826
  className: "univer-grid univer-grid-cols-2 univer-gap-1",
3864
3827
  children: group.group.map((groupItem, groupItemIndex) => {
3865
3828
  const selected = groupItem.name === iconType;
@@ -3867,11 +3830,12 @@ const IconGroupList = (props) => {
3867
3830
  type: "button",
3868
3831
  "aria-label": `${localeService.t(group.title)} ${groupItemIndex + 1}`,
3869
3832
  "aria-pressed": selected,
3870
- className: 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"),
3833
+ className: 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"),
3871
3834
  onClick: () => {
3872
3835
  onClick(groupItem.name);
3873
3836
  },
3874
3837
  children: /* @__PURE__ */ jsx("span", {
3838
+ dir: direction,
3875
3839
  className: "univer-flex univer-items-center univer-gap-0.5",
3876
3840
  children: groupItem.list.map((base64, index) => /* @__PURE__ */ jsx("img", {
3877
3841
  alt: "",
@@ -4035,7 +3999,7 @@ const IconSetRuleEdit = (props) => {
4035
3999
  })
4036
4000
  }),
4037
4001
  children: /* @__PURE__ */ jsxs("div", {
4038
- className: 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", borderClassName),
4002
+ className: 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", borderClassName),
4039
4003
  children: [icon ? /* @__PURE__ */ jsx("img", {
4040
4004
  src: icon,
4041
4005
  className: "univer-size-4",
@@ -4247,7 +4211,7 @@ const IconSet = (props) => {
4247
4211
  })
4248
4212
  }),
4249
4213
  children: /* @__PURE__ */ jsxs("div", {
4250
- className: 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", borderClassName),
4214
+ className: 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", borderClassName),
4251
4215
  children: [previewIcon, /* @__PURE__ */ jsx(MoreDownIcon, {})]
4252
4216
  })
4253
4217
  })
@@ -4888,7 +4852,7 @@ function RuleList(props) {
4888
4852
  }
4889
4853
  })).map((ele, index) => /* @__PURE__ */ jsx("span", { children: ele }, index))
4890
4854
  }), /* @__PURE__ */ jsxs("div", {
4891
- className: "univer-flex univer-justify-end univer-space-x-2",
4855
+ className: "univer-flex univer-justify-end univer-gap-2",
4892
4856
  children: [/* @__PURE__ */ jsx(Tooltip, {
4893
4857
  title: localeService.t("sheets-conditional-formatting-ui.panel.createRule"),
4894
4858
  placement: "bottom",
@@ -4918,7 +4882,7 @@ function RuleList(props) {
4918
4882
  onDragStop: handleDragStop,
4919
4883
  onDragStart: handleDragStart,
4920
4884
  itemRender: (rule) => /* @__PURE__ */ jsxs("div", {
4921
- className: 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 }),
4885
+ className: 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 }),
4922
4886
  onMouseMove: () => {
4923
4887
  rule.ranges !== currentRuleRanges && setCurrentRuleRanges(rule.ranges);
4924
4888
  },
@@ -4928,14 +4892,14 @@ function RuleList(props) {
4928
4892
  },
4929
4893
  children: [
4930
4894
  /* @__PURE__ */ jsx("div", {
4931
- className: 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"),
4895
+ className: 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"),
4932
4896
  onClick: (e) => e.stopPropagation(),
4933
4897
  children: /* @__PURE__ */ jsx(GripVerticalIcon, {})
4934
4898
  }),
4935
4899
  /* @__PURE__ */ jsxs("div", {
4936
4900
  className: "univer-min-w-0 univer-max-w-full univer-flex-shrink univer-overflow-hidden",
4937
4901
  children: [/* @__PURE__ */ jsx("div", {
4938
- className: "univer-text-sm univer-text-gray-900 dark:!univer-text-white",
4902
+ className: "univer-text-sm univer-text-gray-900 dark:!univer-text-gray-0",
4939
4903
  children: getRuleDescribe(rule, localeService)
4940
4904
  }), /* @__PURE__ */ jsx("div", {
4941
4905
  className: "univer-max-w-[250px] univer-overflow-hidden univer-text-ellipsis univer-text-xs univer-text-gray-400",
@@ -4944,7 +4908,7 @@ function RuleList(props) {
4944
4908
  }),
4945
4909
  /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(Preview, { rule: rule.rule }) }),
4946
4910
  /* @__PURE__ */ jsx("div", {
4947
- className: 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 }),
4911
+ className: 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 }),
4948
4912
  onClick: (e) => {
4949
4913
  e.stopPropagation();
4950
4914
  handleDelete(rule);