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