@univerjs/sheets-conditional-formatting-ui 1.0.0-alpha.2 → 1.0.0-alpha.3
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 +416 -330
- package/lib/cjs/locale/ar-SA.js +2 -1
- package/lib/cjs/locale/ca-ES.js +2 -1
- package/lib/cjs/locale/de-DE.js +2 -1
- package/lib/cjs/locale/en-US.js +2 -1
- package/lib/cjs/locale/es-ES.js +2 -1
- package/lib/cjs/locale/fa-IR.js +2 -1
- package/lib/cjs/locale/fr-FR.js +2 -1
- package/lib/cjs/locale/id-ID.js +2 -1
- package/lib/cjs/locale/it-IT.js +2 -1
- package/lib/cjs/locale/ja-JP.js +2 -1
- package/lib/cjs/locale/ko-KR.js +2 -1
- package/lib/cjs/locale/pl-PL.js +2 -1
- package/lib/cjs/locale/pt-BR.js +2 -1
- package/lib/cjs/locale/ru-RU.js +2 -1
- package/lib/cjs/locale/sk-SK.js +2 -1
- package/lib/cjs/locale/vi-VN.js +2 -1
- package/lib/cjs/locale/zh-CN.js +2 -1
- package/lib/cjs/locale/zh-HK.js +2 -1
- package/lib/cjs/locale/zh-TW.js +2 -1
- package/lib/es/index.js +416 -331
- package/lib/es/locale/ar-SA.js +2 -1
- package/lib/es/locale/ca-ES.js +2 -1
- package/lib/es/locale/de-DE.js +2 -1
- package/lib/es/locale/en-US.js +2 -1
- package/lib/es/locale/es-ES.js +2 -1
- package/lib/es/locale/fa-IR.js +2 -1
- package/lib/es/locale/fr-FR.js +2 -1
- package/lib/es/locale/id-ID.js +2 -1
- package/lib/es/locale/it-IT.js +2 -1
- package/lib/es/locale/ja-JP.js +2 -1
- package/lib/es/locale/ko-KR.js +2 -1
- package/lib/es/locale/pl-PL.js +2 -1
- package/lib/es/locale/pt-BR.js +2 -1
- package/lib/es/locale/ru-RU.js +2 -1
- package/lib/es/locale/sk-SK.js +2 -1
- package/lib/es/locale/vi-VN.js +2 -1
- package/lib/es/locale/zh-CN.js +2 -1
- package/lib/es/locale/zh-HK.js +2 -1
- package/lib/es/locale/zh-TW.js +2 -1
- package/lib/index.css +16 -16
- package/lib/index.js +416 -331
- package/lib/locale/ar-SA.js +2 -1
- package/lib/locale/ca-ES.js +2 -1
- package/lib/locale/de-DE.js +2 -1
- package/lib/locale/en-US.js +2 -1
- package/lib/locale/es-ES.js +2 -1
- package/lib/locale/fa-IR.js +2 -1
- package/lib/locale/fr-FR.js +2 -1
- package/lib/locale/id-ID.js +2 -1
- package/lib/locale/it-IT.js +2 -1
- package/lib/locale/ja-JP.js +2 -1
- package/lib/locale/ko-KR.js +2 -1
- package/lib/locale/pl-PL.js +2 -1
- package/lib/locale/pt-BR.js +2 -1
- package/lib/locale/ru-RU.js +2 -1
- package/lib/locale/sk-SK.js +2 -1
- package/lib/locale/vi-VN.js +2 -1
- package/lib/locale/zh-CN.js +2 -1
- package/lib/locale/zh-HK.js +2 -1
- package/lib/locale/zh-TW.js +2 -1
- package/lib/types/controllers/cf.render.controller.d.ts +3 -0
- package/lib/types/index.d.ts +1 -0
- package/lib/types/locale/en-US.d.ts +1 -0
- 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
|
@@ -2,11 +2,11 @@ import { BooleanNumber, ColorKit, CommandType, DependentOn, Disposable, Disposab
|
|
|
2
2
|
import { AFTER_CELL_EDIT, AUTO_FILL_APPLY_TYPE, AutoFillTools, ClearSelectionAllCommand, ClearSelectionFormatCommand, IAutoFillService, INTERCEPTOR_POINT, RangeProtectionPermissionEditPoint, RemoveSheetMutation, SetSelectionsOperation, SetWorksheetActiveOperation, SheetInterceptorService, SheetPermissionCheckController, SheetsSelectionsService, WorkbookEditablePermission, WorksheetEditPermission, WorksheetSetCellStylePermission, checkRangesEditablePermission, getSheetCommandTarget, rangeToDiscreteRange, setEndForRange } from "@univerjs/sheets";
|
|
3
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
4
|
import { ComponentManager, ILayoutService, IMenuManagerService, ISidebarService, IconManager, MenuItemType, RibbonDataGroup, getMenuHiddenObservable, useDependency, useObservable, useScrollYOverContainer, useSidebarClick } from "@univerjs/ui";
|
|
5
|
-
import { FormulaRefRangeService, UniverSheetsFormulaPlugin } from "@univerjs/sheets-formula";
|
|
6
5
|
import { COPY_TYPE, FormatPainterStatus, IFormatPainterService, ISheetClipboardService, PREDEFINED_HOOK_NAME_PASTE, SheetSkeletonManagerService, getCurrentRangeDisable$, getRepeatRange, useHighlightRange, virtualizeDiscreteRanges } from "@univerjs/sheets-ui";
|
|
7
|
-
import { IRenderManagerService } from "@univerjs/engine-render";
|
|
8
6
|
import { Observable, debounceTime, merge as merge$1 } from "rxjs";
|
|
9
7
|
import { bufferTime, debounceTime as debounceTime$1, filter } from "rxjs/operators";
|
|
8
|
+
import { FormulaRefRangeService, UniverSheetsFormulaPlugin } from "@univerjs/sheets-formula";
|
|
9
|
+
import { IRenderManagerService } from "@univerjs/engine-render";
|
|
10
10
|
import { BoldIcon, ConditionsDoubleIcon, DeleteIcon, FontColorDoubleIcon, GripVerticalIcon, IncreaseIcon, ItalicIcon, MoreDownIcon, PaintBucketDoubleIcon, SlashDoubleIcon, StrikethroughIcon, UnderlineIcon } from "@univerjs/icons";
|
|
11
11
|
import { forwardRef, useEffect, useMemo, useRef, useState } from "react";
|
|
12
12
|
import { Button, Checkbox, ColorPicker, DraggableList, Dropdown, Input, InputNumber, Radio, RadioGroup, Select, Tooltip, borderClassName, clsx } from "@univerjs/design";
|
|
@@ -637,10 +637,179 @@ function generateClearCfMutations(injector, allRules, ranges, unitId, subUnitId)
|
|
|
637
637
|
};
|
|
638
638
|
}
|
|
639
639
|
|
|
640
|
+
//#endregion
|
|
641
|
+
//#region src/menu/manage-rule.ts
|
|
642
|
+
const commandList = [
|
|
643
|
+
SetWorksheetActiveOperation.id,
|
|
644
|
+
AddConditionalRuleMutation.id,
|
|
645
|
+
SetConditionalRuleMutation.id,
|
|
646
|
+
DeleteConditionalRuleMutation.id,
|
|
647
|
+
MoveConditionalRuleMutation.id
|
|
648
|
+
];
|
|
649
|
+
const commonSelections = [
|
|
650
|
+
{
|
|
651
|
+
label: {
|
|
652
|
+
name: "sheets-conditional-formatting-ui.ruleType.highlightCell",
|
|
653
|
+
selectable: false
|
|
654
|
+
},
|
|
655
|
+
value: 3
|
|
656
|
+
},
|
|
657
|
+
{
|
|
658
|
+
label: {
|
|
659
|
+
name: "sheets-conditional-formatting-ui.panel.rankAndAverage",
|
|
660
|
+
selectable: false
|
|
661
|
+
},
|
|
662
|
+
value: 4
|
|
663
|
+
},
|
|
664
|
+
{
|
|
665
|
+
label: {
|
|
666
|
+
name: "sheets-conditional-formatting-ui.ruleType.formula",
|
|
667
|
+
selectable: false
|
|
668
|
+
},
|
|
669
|
+
value: 5
|
|
670
|
+
},
|
|
671
|
+
{
|
|
672
|
+
label: {
|
|
673
|
+
name: "sheets-conditional-formatting-ui.ruleType.colorScale",
|
|
674
|
+
selectable: false
|
|
675
|
+
},
|
|
676
|
+
value: 6
|
|
677
|
+
},
|
|
678
|
+
{
|
|
679
|
+
label: {
|
|
680
|
+
name: "sheets-conditional-formatting-ui.ruleType.dataBar",
|
|
681
|
+
selectable: false
|
|
682
|
+
},
|
|
683
|
+
value: 7
|
|
684
|
+
},
|
|
685
|
+
{
|
|
686
|
+
label: {
|
|
687
|
+
name: "sheets-conditional-formatting-ui.ruleType.iconSet",
|
|
688
|
+
selectable: false
|
|
689
|
+
},
|
|
690
|
+
value: 8
|
|
691
|
+
},
|
|
692
|
+
{
|
|
693
|
+
label: {
|
|
694
|
+
name: "sheets-conditional-formatting-ui.menu.manageConditionalFormatting",
|
|
695
|
+
selectable: false
|
|
696
|
+
},
|
|
697
|
+
value: 2
|
|
698
|
+
},
|
|
699
|
+
{
|
|
700
|
+
label: {
|
|
701
|
+
name: "sheets-conditional-formatting-ui.menu.createConditionalFormatting",
|
|
702
|
+
selectable: false
|
|
703
|
+
},
|
|
704
|
+
value: 1
|
|
705
|
+
},
|
|
706
|
+
{
|
|
707
|
+
label: {
|
|
708
|
+
name: "sheets-conditional-formatting-ui.menu.clearRangeRules",
|
|
709
|
+
selectable: false
|
|
710
|
+
},
|
|
711
|
+
value: 9,
|
|
712
|
+
disabled: false
|
|
713
|
+
},
|
|
714
|
+
{
|
|
715
|
+
label: {
|
|
716
|
+
name: "sheets-conditional-formatting-ui.menu.clearWorkSheetRules",
|
|
717
|
+
selectable: false
|
|
718
|
+
},
|
|
719
|
+
value: 10
|
|
720
|
+
}
|
|
721
|
+
];
|
|
722
|
+
function FactoryManageConditionalFormattingRule(accessor) {
|
|
723
|
+
const selectionManagerService = accessor.get(SheetsSelectionsService);
|
|
724
|
+
const commandService = accessor.get(ICommandService);
|
|
725
|
+
const univerInstanceService = accessor.get(IUniverInstanceService);
|
|
726
|
+
const conditionalFormattingRuleModel = accessor.get(ConditionalFormattingRuleModel);
|
|
727
|
+
const clearRangeEnable$ = new Observable((subscriber) => merge$1(selectionManagerService.selectionMoveEnd$, selectionManagerService.selectionSet$, new Observable((commandSubscribe) => {
|
|
728
|
+
const disposable = commandService.onCommandExecuted((commandInfo) => {
|
|
729
|
+
var _univerInstanceServic;
|
|
730
|
+
const { id, params } = commandInfo;
|
|
731
|
+
const unitId = (_univerInstanceServic = univerInstanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_SHEET)) === null || _univerInstanceServic === void 0 ? void 0 : _univerInstanceServic.getUnitId();
|
|
732
|
+
if (commandList.includes(id) && params.unitId === unitId) commandSubscribe.next(null);
|
|
733
|
+
});
|
|
734
|
+
return () => disposable.dispose();
|
|
735
|
+
})).pipe(debounceTime$1(16)).subscribe(() => {
|
|
736
|
+
var _selectionManagerServ;
|
|
737
|
+
const ranges = ((_selectionManagerServ = selectionManagerService.getCurrentSelections()) === null || _selectionManagerServ === void 0 ? void 0 : _selectionManagerServ.map((selection) => selection.range)) || [];
|
|
738
|
+
const workbook = univerInstanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_SHEET);
|
|
739
|
+
if (!workbook) return;
|
|
740
|
+
const worksheet = workbook.getActiveSheet();
|
|
741
|
+
if (!worksheet) return;
|
|
742
|
+
const hasPermission = (conditionalFormattingRuleModel.getSubunitRules(workbook.getUnitId(), worksheet.getSheetId()) || []).filter((rule) => rule.ranges.some((ruleRange) => ranges.some((range) => Rectangle.intersects(range, ruleRange)))).map((rule) => rule.ranges).every((ranges) => {
|
|
743
|
+
return checkRangesEditablePermission(accessor, workbook.getUnitId(), worksheet.getSheetId(), ranges);
|
|
744
|
+
});
|
|
745
|
+
subscriber.next(hasPermission);
|
|
746
|
+
}));
|
|
747
|
+
const clearSheetEnable$ = new Observable((subscriber) => new Observable((commandSubscribe) => {
|
|
748
|
+
const disposable = commandService.onCommandExecuted((commandInfo) => {
|
|
749
|
+
var _univerInstanceServic2;
|
|
750
|
+
const { id, params } = commandInfo;
|
|
751
|
+
const unitId = (_univerInstanceServic2 = univerInstanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_SHEET)) === null || _univerInstanceServic2 === void 0 ? void 0 : _univerInstanceServic2.getUnitId();
|
|
752
|
+
if (commandList.includes(id) && params.unitId === unitId) commandSubscribe.next(null);
|
|
753
|
+
});
|
|
754
|
+
return () => disposable.dispose();
|
|
755
|
+
}).pipe(debounceTime$1(16)).subscribe(() => {
|
|
756
|
+
const workbook = univerInstanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_SHEET);
|
|
757
|
+
if (!workbook) return;
|
|
758
|
+
const worksheet = workbook.getActiveSheet();
|
|
759
|
+
if (!worksheet) return;
|
|
760
|
+
const allRule = conditionalFormattingRuleModel.getSubunitRules(workbook.getUnitId(), worksheet.getSheetId()) || [];
|
|
761
|
+
if (!allRule.length) {
|
|
762
|
+
subscriber.next(false);
|
|
763
|
+
return false;
|
|
764
|
+
}
|
|
765
|
+
const hasPermission = allRule.map((rule) => rule.ranges).every((ranges) => {
|
|
766
|
+
return checkRangesEditablePermission(accessor, workbook.getUnitId(), worksheet.getSheetId(), ranges);
|
|
767
|
+
});
|
|
768
|
+
subscriber.next(hasPermission);
|
|
769
|
+
}));
|
|
770
|
+
const selections$ = new Observable((subscriber) => {
|
|
771
|
+
clearRangeEnable$.subscribe((v) => {
|
|
772
|
+
const item = commonSelections.find((item) => item.value === 9);
|
|
773
|
+
if (item) {
|
|
774
|
+
item.disabled = !v;
|
|
775
|
+
subscriber.next(commonSelections);
|
|
776
|
+
}
|
|
777
|
+
});
|
|
778
|
+
clearSheetEnable$.subscribe((v) => {
|
|
779
|
+
const item = commonSelections.find((item) => item.value === 10);
|
|
780
|
+
if (item) {
|
|
781
|
+
item.disabled = !v;
|
|
782
|
+
subscriber.next(commonSelections);
|
|
783
|
+
}
|
|
784
|
+
});
|
|
785
|
+
subscriber.next(commonSelections);
|
|
786
|
+
});
|
|
787
|
+
return {
|
|
788
|
+
id: OpenConditionalFormattingOperator.id,
|
|
789
|
+
type: MenuItemType.SELECTOR,
|
|
790
|
+
icon: "ConditionsDoubleIcon",
|
|
791
|
+
tooltip: "sheets-conditional-formatting-ui.title",
|
|
792
|
+
selections: selections$,
|
|
793
|
+
hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_SHEET),
|
|
794
|
+
disabled$: getCurrentRangeDisable$(accessor, {
|
|
795
|
+
workbookTypes: [WorkbookEditablePermission],
|
|
796
|
+
worksheetTypes: [WorksheetSetCellStylePermission, WorksheetEditPermission],
|
|
797
|
+
rangeTypes: [RangeProtectionPermissionEditPoint]
|
|
798
|
+
})
|
|
799
|
+
};
|
|
800
|
+
}
|
|
801
|
+
|
|
802
|
+
//#endregion
|
|
803
|
+
//#region src/menu/schema.ts
|
|
804
|
+
const menuSchema = { [RibbonDataGroup.RULES]: { [OpenConditionalFormattingOperator.id]: {
|
|
805
|
+
order: 1,
|
|
806
|
+
menuItemFactory: FactoryManageConditionalFormattingRule
|
|
807
|
+
} } };
|
|
808
|
+
|
|
640
809
|
//#endregion
|
|
641
810
|
//#region package.json
|
|
642
811
|
var name = "@univerjs/sheets-conditional-formatting-ui";
|
|
643
|
-
var version = "1.0.0-alpha.
|
|
812
|
+
var version = "1.0.0-alpha.3";
|
|
644
813
|
|
|
645
814
|
//#endregion
|
|
646
815
|
//#region src/config/config.ts
|
|
@@ -1166,15 +1335,59 @@ let SheetsCfRenderController = class SheetsCfRenderController extends Disposable
|
|
|
1166
1335
|
_defineProperty(this, "_ruleChangeCacheMap", /* @__PURE__ */ new Map());
|
|
1167
1336
|
this._initViewModelInterceptor();
|
|
1168
1337
|
this._initSkeleton();
|
|
1338
|
+
queueMicrotask(() => this._markActiveSheetRulesDirty());
|
|
1169
1339
|
this.disposeWithMe(() => {
|
|
1170
1340
|
this._ruleChangeCacheMap.clear();
|
|
1171
1341
|
});
|
|
1172
1342
|
}
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1343
|
+
_collectDirtyRanges(items, unitId, subUnitId) {
|
|
1344
|
+
const ranges = [];
|
|
1345
|
+
items.forEach((item) => {
|
|
1346
|
+
var _item$rule, _rule$ranges;
|
|
1347
|
+
if (item.unitId !== unitId || item.subUnitId !== subUnitId) return;
|
|
1348
|
+
const rule = (_item$rule = item.rule) !== null && _item$rule !== void 0 ? _item$rule : item.cfId ? this._conditionalFormattingRuleModel.getRule(unitId, subUnitId, item.cfId) : null;
|
|
1349
|
+
if (rule === null || rule === void 0 || (_rule$ranges = rule.ranges) === null || _rule$ranges === void 0 ? void 0 : _rule$ranges.length) ranges.push(...rule.ranges);
|
|
1350
|
+
});
|
|
1351
|
+
return ranges;
|
|
1352
|
+
}
|
|
1353
|
+
_intersectDirtyRangesWithRenderedRange(ranges, renderedRange) {
|
|
1354
|
+
if (!renderedRange || renderedRange.startRow < 0 || renderedRange.startColumn < 0) return [];
|
|
1355
|
+
return ranges.map((range) => ({
|
|
1356
|
+
startRow: Math.max(range.startRow, renderedRange.startRow),
|
|
1357
|
+
endRow: Math.min(range.endRow, renderedRange.endRow),
|
|
1358
|
+
startColumn: Math.max(range.startColumn, renderedRange.startColumn),
|
|
1359
|
+
endColumn: Math.min(range.endColumn, renderedRange.endColumn)
|
|
1360
|
+
})).filter((range) => range.startRow <= range.endRow && range.startColumn <= range.endColumn);
|
|
1361
|
+
}
|
|
1362
|
+
_markDirtySkeleton(items) {
|
|
1363
|
+
var _render$mainComponent;
|
|
1364
|
+
const workbook = this._univerInstanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_SHEET);
|
|
1365
|
+
const worksheet = workbook === null || workbook === void 0 ? void 0 : workbook.getActiveSheet();
|
|
1366
|
+
if (!workbook || !worksheet) return;
|
|
1367
|
+
const unitId = workbook.getUnitId();
|
|
1368
|
+
const subUnitId = worksheet.getSheetId();
|
|
1369
|
+
const render = this._renderManagerService.getRenderById(unitId);
|
|
1370
|
+
const skeletonManagerService = render === null || render === void 0 ? void 0 : render.with(SheetSkeletonManagerService);
|
|
1371
|
+
const currentSkeleton = skeletonManagerService === null || skeletonManagerService === void 0 ? void 0 : skeletonManagerService.getCurrentSkeleton();
|
|
1372
|
+
const dirtyRanges = this._intersectDirtyRangesWithRenderedRange(this._collectDirtyRanges(items, unitId, subUnitId), currentSkeleton === null || currentSkeleton === void 0 ? void 0 : currentSkeleton.rowColumnSegment);
|
|
1373
|
+
if (dirtyRanges.length) currentSkeleton === null || currentSkeleton === void 0 || currentSkeleton.resetRangeCache(dirtyRanges);
|
|
1374
|
+
skeletonManagerService === null || skeletonManagerService === void 0 || skeletonManagerService.reCalculate();
|
|
1375
|
+
render === null || render === void 0 || (_render$mainComponent = render.mainComponent) === null || _render$mainComponent === void 0 || _render$mainComponent.makeDirty();
|
|
1376
|
+
}
|
|
1377
|
+
_markActiveSheetRulesDirty() {
|
|
1378
|
+
var _this$_conditionalFor;
|
|
1379
|
+
const workbook = this._univerInstanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_SHEET);
|
|
1380
|
+
const worksheet = workbook === null || workbook === void 0 ? void 0 : workbook.getActiveSheet();
|
|
1381
|
+
if (!workbook || !worksheet) return;
|
|
1382
|
+
const unitId = workbook.getUnitId();
|
|
1383
|
+
const subUnitId = worksheet.getSheetId();
|
|
1384
|
+
const rules = (_this$_conditionalFor = this._conditionalFormattingRuleModel.getSubunitRules(unitId, subUnitId)) !== null && _this$_conditionalFor !== void 0 ? _this$_conditionalFor : [];
|
|
1385
|
+
if (!rules.length) return;
|
|
1386
|
+
this._markDirtySkeleton(rules.map((rule) => ({
|
|
1387
|
+
rule,
|
|
1388
|
+
subUnitId,
|
|
1389
|
+
unitId
|
|
1390
|
+
})));
|
|
1178
1391
|
}
|
|
1179
1392
|
_initSkeleton() {
|
|
1180
1393
|
this.disposeWithMe(merge$1(this._conditionalFormattingRuleModel.$ruleChange, this._conditionalFormattingViewModel.markDirty$).pipe(bufferTime(16), filter((v) => !!v.length), filter((v) => {
|
|
@@ -1183,7 +1396,7 @@ let SheetsCfRenderController = class SheetsCfRenderController extends Disposable
|
|
|
1183
1396
|
const worksheet = workbook.getActiveSheet();
|
|
1184
1397
|
if (!worksheet) return false;
|
|
1185
1398
|
return v.some((item) => item.unitId === workbook.getUnitId() && item.subUnitId === worksheet.getSheetId());
|
|
1186
|
-
})).subscribe(() => this._markDirtySkeleton()));
|
|
1399
|
+
})).subscribe((items) => this._markDirtySkeleton(items)));
|
|
1187
1400
|
}
|
|
1188
1401
|
_initViewModelInterceptor() {
|
|
1189
1402
|
this.disposeWithMe(this._sheetInterceptorService.intercept(INTERCEPTOR_POINT.CELL_CONTENT, {
|
|
@@ -1987,8 +2200,8 @@ const previewClassName = clsx("univer-mt-5 univer-px-1 univer-py-2 univer-rounde
|
|
|
1987
2200
|
|
|
1988
2201
|
//#endregion
|
|
1989
2202
|
//#region src/views/panel/rule-edit/ColorScale.tsx
|
|
1990
|
-
const createOptionItem$2 = (text
|
|
1991
|
-
label:
|
|
2203
|
+
const createOptionItem$2 = (text) => ({
|
|
2204
|
+
label: `sheets-conditional-formatting-ui.valueType.${text}`,
|
|
1992
2205
|
value: text
|
|
1993
2206
|
});
|
|
1994
2207
|
const TextInput$1 = (props) => {
|
|
@@ -2048,15 +2261,24 @@ const ColorScaleStyleEditor = (props) => {
|
|
|
2048
2261
|
const { interceptorManager } = props;
|
|
2049
2262
|
const localeService = useDependency(LocaleService);
|
|
2050
2263
|
const rule = ((_props$rule = props.rule) === null || _props$rule === void 0 ? void 0 : _props$rule.type) === CFRuleType.colorScale ? props.rule : void 0;
|
|
2051
|
-
const
|
|
2052
|
-
createOptionItem$2(CFValueType.num
|
|
2053
|
-
createOptionItem$2(CFValueType.percent
|
|
2054
|
-
createOptionItem$2(CFValueType.percentile
|
|
2055
|
-
createOptionItem$2(CFValueType.formula
|
|
2264
|
+
const commonOptionDefinitions = [
|
|
2265
|
+
createOptionItem$2(CFValueType.num),
|
|
2266
|
+
createOptionItem$2(CFValueType.percent),
|
|
2267
|
+
createOptionItem$2(CFValueType.percentile),
|
|
2268
|
+
createOptionItem$2(CFValueType.formula)
|
|
2056
2269
|
];
|
|
2057
|
-
const minOptions = [createOptionItem$2(CFValueType.min
|
|
2058
|
-
|
|
2059
|
-
|
|
2270
|
+
const minOptions = [createOptionItem$2(CFValueType.min), ...commonOptionDefinitions].map((option) => ({
|
|
2271
|
+
...option,
|
|
2272
|
+
label: localeService.t(option.label)
|
|
2273
|
+
}));
|
|
2274
|
+
const medianOptions = [createOptionItem$2("none"), ...commonOptionDefinitions].map((option) => ({
|
|
2275
|
+
...option,
|
|
2276
|
+
label: localeService.t(option.label)
|
|
2277
|
+
}));
|
|
2278
|
+
const maxOptions = [createOptionItem$2(CFValueType.max), ...commonOptionDefinitions].map((option) => ({
|
|
2279
|
+
...option,
|
|
2280
|
+
label: localeService.t(option.label)
|
|
2281
|
+
}));
|
|
2060
2282
|
const [minType, setMinType] = useState(() => {
|
|
2061
2283
|
var _rule$config$;
|
|
2062
2284
|
const defaultV = CFValueType.min;
|
|
@@ -2202,7 +2424,7 @@ const ColorScaleStyleEditor = (props) => {
|
|
|
2202
2424
|
children: localeService.t("sheets-conditional-formatting-ui.valueType.min")
|
|
2203
2425
|
}),
|
|
2204
2426
|
/* @__PURE__ */ jsxs("div", {
|
|
2205
|
-
className: "univer-mt-3 univer-flex univer-h-8 univer-items-center",
|
|
2427
|
+
className: "univer-mt-3 univer-flex univer-h-8 univer-items-center univer-gap-2",
|
|
2206
2428
|
children: [
|
|
2207
2429
|
/* @__PURE__ */ jsx(Select, {
|
|
2208
2430
|
className: "univer-flex-shrink-0",
|
|
@@ -2270,7 +2492,7 @@ const ColorScaleStyleEditor = (props) => {
|
|
|
2270
2492
|
children: localeService.t("sheets-conditional-formatting-ui.panel.medianValue")
|
|
2271
2493
|
}),
|
|
2272
2494
|
/* @__PURE__ */ jsxs("div", {
|
|
2273
|
-
className: "univer-mt-3 univer-flex univer-h-8 univer-items-center",
|
|
2495
|
+
className: "univer-mt-3 univer-flex univer-h-8 univer-items-center univer-gap-2",
|
|
2274
2496
|
children: [
|
|
2275
2497
|
/* @__PURE__ */ jsx(Select, {
|
|
2276
2498
|
className: "univer-flex-shrink-0",
|
|
@@ -2338,7 +2560,7 @@ const ColorScaleStyleEditor = (props) => {
|
|
|
2338
2560
|
children: localeService.t("sheets-conditional-formatting-ui.valueType.max")
|
|
2339
2561
|
}),
|
|
2340
2562
|
/* @__PURE__ */ jsxs("div", {
|
|
2341
|
-
className: "univer-mt-3 univer-flex univer-h-8 univer-items-center",
|
|
2563
|
+
className: "univer-mt-3 univer-flex univer-h-8 univer-items-center univer-gap-2",
|
|
2342
2564
|
children: [
|
|
2343
2565
|
/* @__PURE__ */ jsx(Select, {
|
|
2344
2566
|
className: "univer-flex-shrink-0",
|
|
@@ -2363,7 +2585,6 @@ const ColorScaleStyleEditor = (props) => {
|
|
|
2363
2585
|
}),
|
|
2364
2586
|
/* @__PURE__ */ jsx(TextInput$1, {
|
|
2365
2587
|
id: "max",
|
|
2366
|
-
className: "univer-ml-1",
|
|
2367
2588
|
value: maxValue,
|
|
2368
2589
|
type: maxType,
|
|
2369
2590
|
onChange: (v) => {
|
|
@@ -2382,7 +2603,6 @@ const ColorScaleStyleEditor = (props) => {
|
|
|
2382
2603
|
}
|
|
2383
2604
|
}),
|
|
2384
2605
|
/* @__PURE__ */ jsx(ColorPicker$1, {
|
|
2385
|
-
className: "univer-ml-1",
|
|
2386
2606
|
color: maxColor,
|
|
2387
2607
|
onChange: (v) => {
|
|
2388
2608
|
setMaxColor(v);
|
|
@@ -2406,8 +2626,8 @@ const ColorScaleStyleEditor = (props) => {
|
|
|
2406
2626
|
|
|
2407
2627
|
//#endregion
|
|
2408
2628
|
//#region src/views/panel/rule-edit/DataBar.tsx
|
|
2409
|
-
const createOptionItem$1 = (text
|
|
2410
|
-
label:
|
|
2629
|
+
const createOptionItem$1 = (text) => ({
|
|
2630
|
+
label: `sheets-conditional-formatting-ui.valueType.${text}`,
|
|
2411
2631
|
value: text
|
|
2412
2632
|
});
|
|
2413
2633
|
const InputText = (props) => {
|
|
@@ -2436,7 +2656,7 @@ const InputText = (props) => {
|
|
|
2436
2656
|
if (type === CFValueType.formula) {
|
|
2437
2657
|
const v = String(_value.current).startsWith("=") ? String(_value.current) || "" : "=";
|
|
2438
2658
|
return /* @__PURE__ */ jsx("div", {
|
|
2439
|
-
className: "univer-
|
|
2659
|
+
className: "univer-w-full",
|
|
2440
2660
|
children: /* @__PURE__ */ jsx(FormulaEditor, {
|
|
2441
2661
|
ref: formulaEditorRef,
|
|
2442
2662
|
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),
|
|
@@ -2482,14 +2702,20 @@ const DataBarStyleEditor = (props) => {
|
|
|
2482
2702
|
if (!rule) return defaultDataBarNativeColor;
|
|
2483
2703
|
return ((_rule$config3 = rule.config) === null || _rule$config3 === void 0 ? void 0 : _rule$config3.nativeColor) || defaultDataBarNativeColor;
|
|
2484
2704
|
});
|
|
2485
|
-
const
|
|
2486
|
-
createOptionItem$1(CFValueType.num
|
|
2487
|
-
createOptionItem$1(CFValueType.percent
|
|
2488
|
-
createOptionItem$1(CFValueType.percentile
|
|
2489
|
-
createOptionItem$1(CFValueType.formula
|
|
2705
|
+
const commonOptionDefinitions = [
|
|
2706
|
+
createOptionItem$1(CFValueType.num),
|
|
2707
|
+
createOptionItem$1(CFValueType.percent),
|
|
2708
|
+
createOptionItem$1(CFValueType.percentile),
|
|
2709
|
+
createOptionItem$1(CFValueType.formula)
|
|
2490
2710
|
];
|
|
2491
|
-
const minOptions = [createOptionItem$1(CFValueType.min
|
|
2492
|
-
|
|
2711
|
+
const minOptions = [createOptionItem$1(CFValueType.min), ...commonOptionDefinitions].map((option) => ({
|
|
2712
|
+
...option,
|
|
2713
|
+
label: localeService.t(option.label)
|
|
2714
|
+
}));
|
|
2715
|
+
const maxOptions = [createOptionItem$1(CFValueType.max), ...commonOptionDefinitions].map((option) => ({
|
|
2716
|
+
...option,
|
|
2717
|
+
label: localeService.t(option.label)
|
|
2718
|
+
}));
|
|
2493
2719
|
const [minValueType, setMinValueType] = useState(() => {
|
|
2494
2720
|
var _rule$config4;
|
|
2495
2721
|
const defaultV = minOptions[0].value;
|
|
@@ -2596,7 +2822,7 @@ const DataBarStyleEditor = (props) => {
|
|
|
2596
2822
|
});
|
|
2597
2823
|
};
|
|
2598
2824
|
const isShowInput = (type) => {
|
|
2599
|
-
return
|
|
2825
|
+
return commonOptionDefinitions.map((item) => item.value).includes(type);
|
|
2600
2826
|
};
|
|
2601
2827
|
return /* @__PURE__ */ jsxs("div", { children: [
|
|
2602
2828
|
/* @__PURE__ */ jsx("div", {
|
|
@@ -2620,7 +2846,7 @@ const DataBarStyleEditor = (props) => {
|
|
|
2620
2846
|
className: "univer-mt-3 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",
|
|
2621
2847
|
children: localeService.t("sheets-conditional-formatting-ui.panel.fillType")
|
|
2622
2848
|
}), /* @__PURE__ */ jsxs("div", {
|
|
2623
|
-
className: "univer-
|
|
2849
|
+
className: "univer-mt-3 univer-flex univer-items-center univer-gap-3",
|
|
2624
2850
|
children: [/* @__PURE__ */ jsxs(RadioGroup, {
|
|
2625
2851
|
value: isGradient,
|
|
2626
2852
|
onChange: (v) => {
|
|
@@ -2650,7 +2876,7 @@ const DataBarStyleEditor = (props) => {
|
|
|
2650
2876
|
})
|
|
2651
2877
|
})]
|
|
2652
2878
|
}), /* @__PURE__ */ jsxs("div", {
|
|
2653
|
-
className: "univer-
|
|
2879
|
+
className: "univer-flex univer-items-center univer-text-xs",
|
|
2654
2880
|
children: [/* @__PURE__ */ jsx(Checkbox, {
|
|
2655
2881
|
checked: !isShowValue,
|
|
2656
2882
|
onChange: (v) => {
|
|
@@ -2673,7 +2899,7 @@ const DataBarStyleEditor = (props) => {
|
|
|
2673
2899
|
className: "univer-mt-3 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",
|
|
2674
2900
|
children: localeService.t("sheets-conditional-formatting-ui.panel.colorSet")
|
|
2675
2901
|
}), /* @__PURE__ */ jsxs("div", {
|
|
2676
|
-
className: "univer-
|
|
2902
|
+
className: "univer-mt-3 univer-flex univer-items-center univer-gap-2",
|
|
2677
2903
|
children: [/* @__PURE__ */ jsxs("div", {
|
|
2678
2904
|
className: "univer-flex univer-items-center",
|
|
2679
2905
|
children: [/* @__PURE__ */ jsx("div", {
|
|
@@ -2684,7 +2910,7 @@ const DataBarStyleEditor = (props) => {
|
|
|
2684
2910
|
onChange: handleNativeColorChange
|
|
2685
2911
|
})]
|
|
2686
2912
|
}), /* @__PURE__ */ jsxs("div", {
|
|
2687
|
-
className: "univer-
|
|
2913
|
+
className: "univer-flex univer-items-center univer-gap-3",
|
|
2688
2914
|
children: [/* @__PURE__ */ jsx("div", {
|
|
2689
2915
|
className: "univer-text-xs",
|
|
2690
2916
|
children: localeService.t("sheets-conditional-formatting-ui.panel.positive")
|
|
@@ -2700,7 +2926,7 @@ const DataBarStyleEditor = (props) => {
|
|
|
2700
2926
|
children: localeService.t("sheets-conditional-formatting-ui.valueType.min")
|
|
2701
2927
|
}),
|
|
2702
2928
|
/* @__PURE__ */ jsxs("div", {
|
|
2703
|
-
className: "univer-mt-3 univer-flex univer-items-center",
|
|
2929
|
+
className: "univer-mt-3 univer-flex univer-items-center univer-gap-2",
|
|
2704
2930
|
children: [/* @__PURE__ */ jsx(Select, {
|
|
2705
2931
|
className: "univer-w-1/2 univer-flex-shrink-0",
|
|
2706
2932
|
options: minOptions,
|
|
@@ -2722,7 +2948,6 @@ const DataBarStyleEditor = (props) => {
|
|
|
2722
2948
|
}
|
|
2723
2949
|
}), /* @__PURE__ */ jsx(InputText, {
|
|
2724
2950
|
id: "min",
|
|
2725
|
-
className: "univer-ml-3",
|
|
2726
2951
|
disabled: !isShowInput(minValueType),
|
|
2727
2952
|
type: minValueType,
|
|
2728
2953
|
value: minValue,
|
|
@@ -2746,7 +2971,7 @@ const DataBarStyleEditor = (props) => {
|
|
|
2746
2971
|
children: localeService.t("sheets-conditional-formatting-ui.valueType.max")
|
|
2747
2972
|
}),
|
|
2748
2973
|
/* @__PURE__ */ jsxs("div", {
|
|
2749
|
-
className: "univer-mt-3 univer-flex univer-items-center",
|
|
2974
|
+
className: "univer-mt-3 univer-flex univer-items-center univer-gap-2",
|
|
2750
2975
|
children: [/* @__PURE__ */ jsx(Select, {
|
|
2751
2976
|
className: "univer-w-1/2 univer-flex-shrink-0",
|
|
2752
2977
|
options: maxOptions,
|
|
@@ -2767,7 +2992,6 @@ const DataBarStyleEditor = (props) => {
|
|
|
2767
2992
|
});
|
|
2768
2993
|
}
|
|
2769
2994
|
}), /* @__PURE__ */ jsx(InputText, {
|
|
2770
|
-
className: "univer-ml-3",
|
|
2771
2995
|
disabled: !isShowInput(maxValueType),
|
|
2772
2996
|
id: "max",
|
|
2773
2997
|
type: maxValueType,
|
|
@@ -3013,8 +3237,8 @@ const WrapperError = (props) => {
|
|
|
3013
3237
|
|
|
3014
3238
|
//#endregion
|
|
3015
3239
|
//#region src/views/panel/rule-edit/HighlightCell.tsx
|
|
3016
|
-
const createOptionItem = (text
|
|
3017
|
-
label:
|
|
3240
|
+
const createOptionItem = (text) => ({
|
|
3241
|
+
label: `sheets-conditional-formatting-ui.operator.${text}`,
|
|
3018
3242
|
value: text
|
|
3019
3243
|
});
|
|
3020
3244
|
function HighlightCellInput(props) {
|
|
@@ -3175,42 +3399,43 @@ function HighlightCellInput(props) {
|
|
|
3175
3399
|
}
|
|
3176
3400
|
return null;
|
|
3177
3401
|
}
|
|
3178
|
-
const getOperatorOptions = (type
|
|
3402
|
+
const getOperatorOptions = (type) => {
|
|
3179
3403
|
switch (type) {
|
|
3180
3404
|
case CFSubRuleType.text: return [
|
|
3181
|
-
createOptionItem(CFTextOperator.containsText
|
|
3182
|
-
createOptionItem(CFTextOperator.notContainsText
|
|
3183
|
-
createOptionItem(CFTextOperator.beginsWith
|
|
3184
|
-
createOptionItem(CFTextOperator.endsWith
|
|
3185
|
-
createOptionItem(CFTextOperator.equal
|
|
3186
|
-
createOptionItem(CFTextOperator.notEqual
|
|
3187
|
-
createOptionItem(CFTextOperator.containsBlanks
|
|
3188
|
-
createOptionItem(CFTextOperator.notContainsBlanks
|
|
3189
|
-
createOptionItem(CFTextOperator.containsErrors
|
|
3190
|
-
createOptionItem(CFTextOperator.notContainsErrors
|
|
3405
|
+
createOptionItem(CFTextOperator.containsText),
|
|
3406
|
+
createOptionItem(CFTextOperator.notContainsText),
|
|
3407
|
+
createOptionItem(CFTextOperator.beginsWith),
|
|
3408
|
+
createOptionItem(CFTextOperator.endsWith),
|
|
3409
|
+
createOptionItem(CFTextOperator.equal),
|
|
3410
|
+
createOptionItem(CFTextOperator.notEqual),
|
|
3411
|
+
createOptionItem(CFTextOperator.containsBlanks),
|
|
3412
|
+
createOptionItem(CFTextOperator.notContainsBlanks),
|
|
3413
|
+
createOptionItem(CFTextOperator.containsErrors),
|
|
3414
|
+
createOptionItem(CFTextOperator.notContainsErrors)
|
|
3191
3415
|
];
|
|
3192
3416
|
case CFSubRuleType.number: return [
|
|
3193
|
-
createOptionItem(CFNumberOperator.between
|
|
3194
|
-
createOptionItem(CFNumberOperator.notBetween
|
|
3195
|
-
createOptionItem(CFNumberOperator.equal
|
|
3196
|
-
createOptionItem(CFNumberOperator.notEqual
|
|
3197
|
-
createOptionItem(CFNumberOperator.greaterThan
|
|
3198
|
-
createOptionItem(CFNumberOperator.greaterThanOrEqual
|
|
3199
|
-
createOptionItem(CFNumberOperator.lessThan
|
|
3200
|
-
createOptionItem(CFNumberOperator.lessThanOrEqual
|
|
3417
|
+
createOptionItem(CFNumberOperator.between),
|
|
3418
|
+
createOptionItem(CFNumberOperator.notBetween),
|
|
3419
|
+
createOptionItem(CFNumberOperator.equal),
|
|
3420
|
+
createOptionItem(CFNumberOperator.notEqual),
|
|
3421
|
+
createOptionItem(CFNumberOperator.greaterThan),
|
|
3422
|
+
createOptionItem(CFNumberOperator.greaterThanOrEqual),
|
|
3423
|
+
createOptionItem(CFNumberOperator.lessThan),
|
|
3424
|
+
createOptionItem(CFNumberOperator.lessThanOrEqual)
|
|
3201
3425
|
];
|
|
3202
3426
|
case CFSubRuleType.timePeriod: return [
|
|
3203
|
-
createOptionItem(CFTimePeriodOperator.yesterday
|
|
3204
|
-
createOptionItem(CFTimePeriodOperator.today
|
|
3205
|
-
createOptionItem(CFTimePeriodOperator.tomorrow
|
|
3206
|
-
createOptionItem(CFTimePeriodOperator.last7Days
|
|
3207
|
-
createOptionItem(CFTimePeriodOperator.lastWeek
|
|
3208
|
-
createOptionItem(CFTimePeriodOperator.thisWeek
|
|
3209
|
-
createOptionItem(CFTimePeriodOperator.nextWeek
|
|
3210
|
-
createOptionItem(CFTimePeriodOperator.lastMonth
|
|
3211
|
-
createOptionItem(CFTimePeriodOperator.thisMonth
|
|
3212
|
-
createOptionItem(CFTimePeriodOperator.nextMonth
|
|
3427
|
+
createOptionItem(CFTimePeriodOperator.yesterday),
|
|
3428
|
+
createOptionItem(CFTimePeriodOperator.today),
|
|
3429
|
+
createOptionItem(CFTimePeriodOperator.tomorrow),
|
|
3430
|
+
createOptionItem(CFTimePeriodOperator.last7Days),
|
|
3431
|
+
createOptionItem(CFTimePeriodOperator.lastWeek),
|
|
3432
|
+
createOptionItem(CFTimePeriodOperator.thisWeek),
|
|
3433
|
+
createOptionItem(CFTimePeriodOperator.nextWeek),
|
|
3434
|
+
createOptionItem(CFTimePeriodOperator.lastMonth),
|
|
3435
|
+
createOptionItem(CFTimePeriodOperator.thisMonth),
|
|
3436
|
+
createOptionItem(CFTimePeriodOperator.nextMonth)
|
|
3213
3437
|
];
|
|
3438
|
+
default: return [];
|
|
3214
3439
|
}
|
|
3215
3440
|
};
|
|
3216
3441
|
const HighlightCellStyleEditor = (props) => {
|
|
@@ -3245,9 +3470,13 @@ const HighlightCellStyleEditor = (props) => {
|
|
|
3245
3470
|
label: localeService.t("sheets-conditional-formatting-ui.subRuleType.uniqueValues")
|
|
3246
3471
|
}
|
|
3247
3472
|
];
|
|
3248
|
-
const operatorOptions = useMemo(() => getOperatorOptions(subType
|
|
3473
|
+
const operatorOptions = useMemo(() => getOperatorOptions(subType).map((option) => ({
|
|
3474
|
+
...option,
|
|
3475
|
+
label: localeService.t(option.label)
|
|
3476
|
+
})), [localeService, subType]);
|
|
3249
3477
|
const [operator, setOperator] = useState(() => {
|
|
3250
|
-
|
|
3478
|
+
var _operatorOptions$;
|
|
3479
|
+
const defaultV = (_operatorOptions$ = operatorOptions[0]) === null || _operatorOptions$ === void 0 ? void 0 : _operatorOptions$.value;
|
|
3251
3480
|
if (!rule) return defaultV;
|
|
3252
3481
|
return rule.operator || defaultV;
|
|
3253
3482
|
});
|
|
@@ -3259,8 +3488,16 @@ const HighlightCellStyleEditor = (props) => {
|
|
|
3259
3488
|
});
|
|
3260
3489
|
const [style, setStyle] = useState({});
|
|
3261
3490
|
const getResult = useMemo(() => (option) => {
|
|
3262
|
-
var _option$
|
|
3491
|
+
var _option$subType5, _option$operator4, _option$style5;
|
|
3263
3492
|
switch (option.subType || subType) {
|
|
3493
|
+
case CFSubRuleType.duplicateValues:
|
|
3494
|
+
case CFSubRuleType.uniqueValues:
|
|
3495
|
+
var _option$subType, _option$style;
|
|
3496
|
+
return {
|
|
3497
|
+
type: CFRuleType.highlightCell,
|
|
3498
|
+
subType: (_option$subType = option.subType) !== null && _option$subType !== void 0 ? _option$subType : subType,
|
|
3499
|
+
style: (_option$style = option.style) !== null && _option$style !== void 0 ? _option$style : style
|
|
3500
|
+
};
|
|
3264
3501
|
case CFSubRuleType.text:
|
|
3265
3502
|
if ([
|
|
3266
3503
|
CFTextOperator.beginsWith,
|
|
@@ -3270,12 +3507,12 @@ const HighlightCellStyleEditor = (props) => {
|
|
|
3270
3507
|
CFTextOperator.equal,
|
|
3271
3508
|
CFTextOperator.notEqual
|
|
3272
3509
|
].includes(operator)) {
|
|
3273
|
-
var _option$
|
|
3510
|
+
var _option$subType2, _option$operator, _option$style2, _option$value;
|
|
3274
3511
|
return {
|
|
3275
3512
|
type: CFRuleType.highlightCell,
|
|
3276
|
-
subType: (_option$
|
|
3513
|
+
subType: (_option$subType2 = option.subType) !== null && _option$subType2 !== void 0 ? _option$subType2 : subType,
|
|
3277
3514
|
operator: (_option$operator = option.operator) !== null && _option$operator !== void 0 ? _option$operator : operator,
|
|
3278
|
-
style: (_option$
|
|
3515
|
+
style: (_option$style2 = option.style) !== null && _option$style2 !== void 0 ? _option$style2 : style,
|
|
3279
3516
|
value: (_option$value = option.value) !== null && _option$value !== void 0 ? _option$value : value
|
|
3280
3517
|
};
|
|
3281
3518
|
}
|
|
@@ -3289,22 +3526,22 @@ const HighlightCellStyleEditor = (props) => {
|
|
|
3289
3526
|
CFNumberOperator.lessThan,
|
|
3290
3527
|
CFNumberOperator.lessThanOrEqual
|
|
3291
3528
|
].includes(operator)) {
|
|
3292
|
-
var _option$
|
|
3529
|
+
var _option$subType3, _option$operator2, _option$style3, _option$value2;
|
|
3293
3530
|
return {
|
|
3294
3531
|
type: CFRuleType.highlightCell,
|
|
3295
|
-
subType: (_option$
|
|
3532
|
+
subType: (_option$subType3 = option.subType) !== null && _option$subType3 !== void 0 ? _option$subType3 : subType,
|
|
3296
3533
|
operator: (_option$operator2 = option.operator) !== null && _option$operator2 !== void 0 ? _option$operator2 : operator,
|
|
3297
|
-
style: (_option$
|
|
3534
|
+
style: (_option$style3 = option.style) !== null && _option$style3 !== void 0 ? _option$style3 : style,
|
|
3298
3535
|
value: (_option$value2 = option.value) !== null && _option$value2 !== void 0 ? _option$value2 : value
|
|
3299
3536
|
};
|
|
3300
3537
|
}
|
|
3301
3538
|
if ([CFNumberOperator.between, CFNumberOperator.notBetween].includes(operator)) {
|
|
3302
|
-
var _option$
|
|
3539
|
+
var _option$subType4, _option$operator3, _option$style4, _option$value3;
|
|
3303
3540
|
return {
|
|
3304
3541
|
type: CFRuleType.highlightCell,
|
|
3305
|
-
subType: (_option$
|
|
3542
|
+
subType: (_option$subType4 = option.subType) !== null && _option$subType4 !== void 0 ? _option$subType4 : subType,
|
|
3306
3543
|
operator: (_option$operator3 = option.operator) !== null && _option$operator3 !== void 0 ? _option$operator3 : operator,
|
|
3307
|
-
style: (_option$
|
|
3544
|
+
style: (_option$style4 = option.style) !== null && _option$style4 !== void 0 ? _option$style4 : style,
|
|
3308
3545
|
value: (_option$value3 = option.value) !== null && _option$value3 !== void 0 ? _option$value3 : value
|
|
3309
3546
|
};
|
|
3310
3547
|
}
|
|
@@ -3312,9 +3549,9 @@ const HighlightCellStyleEditor = (props) => {
|
|
|
3312
3549
|
}
|
|
3313
3550
|
return {
|
|
3314
3551
|
type: CFRuleType.highlightCell,
|
|
3315
|
-
subType: (_option$
|
|
3552
|
+
subType: (_option$subType5 = option.subType) !== null && _option$subType5 !== void 0 ? _option$subType5 : subType,
|
|
3316
3553
|
operator: (_option$operator4 = option.operator) !== null && _option$operator4 !== void 0 ? _option$operator4 : operator,
|
|
3317
|
-
style: (_option$
|
|
3554
|
+
style: (_option$style5 = option.style) !== null && _option$style5 !== void 0 ? _option$style5 : style
|
|
3318
3555
|
};
|
|
3319
3556
|
}, [
|
|
3320
3557
|
subType,
|
|
@@ -3331,9 +3568,12 @@ const HighlightCellStyleEditor = (props) => {
|
|
|
3331
3568
|
if (!typeOptions.some((item) => item.value === subType)) setSubType(typeOptions[0].value);
|
|
3332
3569
|
}, [typeOptions]);
|
|
3333
3570
|
const onTypeChange = (v) => {
|
|
3571
|
+
var _operatorList$;
|
|
3334
3572
|
const _subType = v;
|
|
3335
|
-
const
|
|
3336
|
-
|
|
3573
|
+
const _operator = (_operatorList$ = getOperatorOptions(_subType).map((option) => ({
|
|
3574
|
+
...option,
|
|
3575
|
+
label: localeService.t(option.label)
|
|
3576
|
+
}))[0]) === null || _operatorList$ === void 0 ? void 0 : _operatorList$.value;
|
|
3337
3577
|
setSubType(_subType);
|
|
3338
3578
|
setOperator(_operator);
|
|
3339
3579
|
_operator && setValue(createDefaultValue(_subType, _operator));
|
|
@@ -3451,11 +3691,13 @@ const createDefaultConfigItem = (iconType, index, list) => ({
|
|
|
3451
3691
|
const IconGroupList = forwardRef((props, ref) => {
|
|
3452
3692
|
const { onClick } = props;
|
|
3453
3693
|
const localeService = useDependency(LocaleService);
|
|
3694
|
+
const direction = useObservable(localeService.direction$, localeService.getDirection());
|
|
3454
3695
|
const handleClick = (iconType) => {
|
|
3455
3696
|
onClick(iconType);
|
|
3456
3697
|
};
|
|
3457
3698
|
return /* @__PURE__ */ jsx("div", {
|
|
3458
3699
|
ref,
|
|
3700
|
+
dir: direction,
|
|
3459
3701
|
className: "univer-w-80",
|
|
3460
3702
|
children: iconGroup.map((group, index) => {
|
|
3461
3703
|
return /* @__PURE__ */ jsxs("div", {
|
|
@@ -3467,7 +3709,7 @@ const IconGroupList = forwardRef((props, ref) => {
|
|
|
3467
3709
|
className: "univer-flex univer-flex-wrap",
|
|
3468
3710
|
children: group.group.map((groupItem) => {
|
|
3469
3711
|
return /* @__PURE__ */ jsx("div", {
|
|
3470
|
-
className: "univer-mb-1 univer-flex univer-w-1/2 univer-items-center",
|
|
3712
|
+
className: "univer-mb-1 univer-flex univer-w-1/2 univer-items-center rtl:univer-flex-row-reverse rtl:univer-justify-end",
|
|
3471
3713
|
onClick: () => {
|
|
3472
3714
|
handleClick(groupItem.name);
|
|
3473
3715
|
},
|
|
@@ -3488,6 +3730,8 @@ const IconGroupList = forwardRef((props, ref) => {
|
|
|
3488
3730
|
});
|
|
3489
3731
|
const IconItemList = (props) => {
|
|
3490
3732
|
const { onClick } = props;
|
|
3733
|
+
const localeService = useDependency(LocaleService);
|
|
3734
|
+
const direction = useObservable(localeService.direction$, localeService.getDirection());
|
|
3491
3735
|
const list = useMemo(() => {
|
|
3492
3736
|
const result = [];
|
|
3493
3737
|
for (const key in iconMap) {
|
|
@@ -3505,29 +3749,30 @@ const IconItemList = (props) => {
|
|
|
3505
3749
|
const handleClick = (item) => {
|
|
3506
3750
|
onClick(item.iconType, item.iconId);
|
|
3507
3751
|
};
|
|
3508
|
-
return /* @__PURE__ */ jsxs("div", {
|
|
3509
|
-
|
|
3510
|
-
|
|
3511
|
-
|
|
3512
|
-
|
|
3513
|
-
|
|
3514
|
-
|
|
3515
|
-
|
|
3516
|
-
|
|
3517
|
-
|
|
3752
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
3753
|
+
dir: direction,
|
|
3754
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
3755
|
+
"data-u-comp": "cf-icon-set-no-icon-option",
|
|
3756
|
+
className: "univer-mb-2.5 univer-flex univer-cursor-pointer univer-items-center univer-gap-2 univer-text-sm",
|
|
3757
|
+
onClick: () => handleClick({
|
|
3758
|
+
iconType: IIconSetType.empty,
|
|
3759
|
+
iconId: "",
|
|
3760
|
+
base64: ""
|
|
3761
|
+
}),
|
|
3762
|
+
children: localeService.t("sheets-conditional-formatting-ui.iconSet.noCellIcon")
|
|
3763
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
3764
|
+
className: "univer-flex univer-w-64 univer-flex-wrap univer-gap-2",
|
|
3765
|
+
children: list.map((item) => /* @__PURE__ */ jsx("div", {
|
|
3766
|
+
className: "univer-mb-2 univer-flex univer-cursor-pointer univer-items-center univer-justify-center univer-rounded hover:univer-bg-gray-100 dark:hover:!univer-bg-gray-700",
|
|
3767
|
+
children: /* @__PURE__ */ jsx("img", {
|
|
3768
|
+
className: "univer-size-5",
|
|
3769
|
+
src: item.base64,
|
|
3770
|
+
draggable: false,
|
|
3771
|
+
onClick: () => handleClick(item)
|
|
3772
|
+
})
|
|
3773
|
+
}, `${item.iconType}_${item.iconId}`))
|
|
3518
3774
|
})]
|
|
3519
|
-
})
|
|
3520
|
-
className: "univer-flex univer-w-64 univer-flex-wrap",
|
|
3521
|
-
children: list.map((item) => /* @__PURE__ */ jsx("div", {
|
|
3522
|
-
className: "univer-mb-2 univer-mr-2 univer-flex univer-cursor-pointer univer-items-center univer-justify-center univer-rounded hover:univer-bg-gray-100 dark:hover:!univer-bg-gray-700",
|
|
3523
|
-
children: /* @__PURE__ */ jsx("img", {
|
|
3524
|
-
className: "univer-size-5",
|
|
3525
|
-
src: item.base64,
|
|
3526
|
-
draggable: false,
|
|
3527
|
-
onClick: () => handleClick(item)
|
|
3528
|
-
})
|
|
3529
|
-
}, `${item.iconType}_${item.iconId}`))
|
|
3530
|
-
})] });
|
|
3775
|
+
});
|
|
3531
3776
|
};
|
|
3532
3777
|
const IconSetRuleEdit = (props) => {
|
|
3533
3778
|
const { onChange, configList, errorMap = {} } = props;
|
|
@@ -3615,7 +3860,8 @@ const IconSetRuleEdit = (props) => {
|
|
|
3615
3860
|
})]
|
|
3616
3861
|
}),
|
|
3617
3862
|
/* @__PURE__ */ jsxs("div", {
|
|
3618
|
-
|
|
3863
|
+
"data-u-comp": "cf-icon-set-rule-grid",
|
|
3864
|
+
className: "univer-mt-3 univer-grid univer-grid-cols-2 univer-gap-4 rtl:univer-grid-flow-dense",
|
|
3619
3865
|
children: [/* @__PURE__ */ jsx("div", {
|
|
3620
3866
|
className: "univer-flex univer-items-center",
|
|
3621
3867
|
children: /* @__PURE__ */ jsx(Dropdown, {
|
|
@@ -3686,6 +3932,7 @@ const IconSet = (props) => {
|
|
|
3686
3932
|
const { interceptorManager } = props;
|
|
3687
3933
|
const rule = ((_props$rule = props.rule) === null || _props$rule === void 0 ? void 0 : _props$rule.type) === CFRuleType.iconSet ? props.rule : void 0;
|
|
3688
3934
|
const localeService = useDependency(LocaleService);
|
|
3935
|
+
const direction = useObservable(localeService.direction$, localeService.getDirection());
|
|
3689
3936
|
const [errorMap, setErrorMap] = useState({});
|
|
3690
3937
|
const [currentIconType, setCurrentIconType] = useState(() => {
|
|
3691
3938
|
const defaultV = Object.keys(iconMap)[0];
|
|
@@ -3717,7 +3964,8 @@ const IconSet = (props) => {
|
|
|
3717
3964
|
});
|
|
3718
3965
|
const previewIcon = useMemo(() => {
|
|
3719
3966
|
return /* @__PURE__ */ jsx("div", {
|
|
3720
|
-
|
|
3967
|
+
"data-u-comp": "cf-icon-set-preview",
|
|
3968
|
+
className: "univer-flex univer-items-center rtl:univer-flex-row-reverse",
|
|
3721
3969
|
children: configList.map((item) => {
|
|
3722
3970
|
return getIcon(item.iconType, item.iconId);
|
|
3723
3971
|
}).map((icon, index) => icon ? /* @__PURE__ */ jsx("img", {
|
|
@@ -3820,51 +4068,58 @@ const IconSet = (props) => {
|
|
|
3820
4068
|
const layoutService = useDependency(ILayoutService);
|
|
3821
4069
|
const [iconGroupListEl, setIconGroupListEl] = useState();
|
|
3822
4070
|
useScrollYOverContainer(iconGroupListEl, layoutService.rootContainerElement);
|
|
3823
|
-
return /* @__PURE__ */ jsxs("div", {
|
|
3824
|
-
|
|
3825
|
-
|
|
3826
|
-
|
|
3827
|
-
|
|
3828
|
-
|
|
3829
|
-
|
|
3830
|
-
|
|
3831
|
-
|
|
3832
|
-
|
|
3833
|
-
|
|
3834
|
-
|
|
3835
|
-
|
|
3836
|
-
|
|
3837
|
-
|
|
3838
|
-
|
|
4071
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
4072
|
+
"data-u-comp": "cf-icon-set-editor",
|
|
4073
|
+
dir: direction,
|
|
4074
|
+
children: [
|
|
4075
|
+
/* @__PURE__ */ jsx("div", {
|
|
4076
|
+
className: "univer-mt-4 univer-text-sm univer-text-gray-600",
|
|
4077
|
+
children: localeService.t("sheets-conditional-formatting-ui.panel.styleRule")
|
|
4078
|
+
}),
|
|
4079
|
+
/* @__PURE__ */ jsx("div", {
|
|
4080
|
+
className: "univer-mt-3",
|
|
4081
|
+
children: /* @__PURE__ */ jsx(Dropdown, {
|
|
4082
|
+
overlay: /* @__PURE__ */ jsx("div", {
|
|
4083
|
+
dir: direction,
|
|
4084
|
+
className: "univer-rounded-lg univer-p-4",
|
|
4085
|
+
children: /* @__PURE__ */ jsx(IconGroupList, {
|
|
4086
|
+
ref: (el) => {
|
|
4087
|
+
!iconGroupListEl && el && setIconGroupListEl(el);
|
|
4088
|
+
},
|
|
4089
|
+
iconType: currentIconType,
|
|
4090
|
+
onClick: handleClickIconList
|
|
4091
|
+
})
|
|
4092
|
+
}),
|
|
4093
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
4094
|
+
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),
|
|
4095
|
+
children: [previewIcon, /* @__PURE__ */ jsx(MoreDownIcon, {})]
|
|
3839
4096
|
})
|
|
3840
|
-
}),
|
|
3841
|
-
children: /* @__PURE__ */ jsxs("div", {
|
|
3842
|
-
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),
|
|
3843
|
-
children: [previewIcon, /* @__PURE__ */ jsx(MoreDownIcon, {})]
|
|
3844
4097
|
})
|
|
4098
|
+
}),
|
|
4099
|
+
/* @__PURE__ */ jsxs("div", {
|
|
4100
|
+
className: "univer-mt-3 univer-flex univer-items-center univer-gap-2 univer-text-xs rtl:univer-flex-row-reverse rtl:univer-justify-end",
|
|
4101
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
4102
|
+
"data-u-comp": "cf-icon-set-option-row",
|
|
4103
|
+
className: "univer-flex univer-items-center univer-text-xs",
|
|
4104
|
+
children: [/* @__PURE__ */ jsx(Checkbox, { onChange: reverseIcon }), localeService.t("sheets-conditional-formatting-ui.iconSet.reverseIconOrder")]
|
|
4105
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
4106
|
+
"data-u-comp": "cf-icon-set-option-row",
|
|
4107
|
+
className: "univer-flex univer-items-center univer-text-xs",
|
|
4108
|
+
children: [/* @__PURE__ */ jsx(Checkbox, {
|
|
4109
|
+
checked: !isShowValue,
|
|
4110
|
+
onChange: (v) => {
|
|
4111
|
+
setIsShowValue(!v);
|
|
4112
|
+
}
|
|
4113
|
+
}), localeService.t("sheets-conditional-formatting-ui.iconSet.onlyShowIcon")]
|
|
4114
|
+
})]
|
|
4115
|
+
}),
|
|
4116
|
+
/* @__PURE__ */ jsx(IconSetRuleEdit, {
|
|
4117
|
+
errorMap,
|
|
4118
|
+
onChange: handleChange,
|
|
4119
|
+
configList
|
|
3845
4120
|
})
|
|
3846
|
-
|
|
3847
|
-
|
|
3848
|
-
className: "univer-mt-3 univer-flex univer-items-center univer-text-xs",
|
|
3849
|
-
children: [/* @__PURE__ */ jsxs("div", {
|
|
3850
|
-
className: "univer-flex univer-items-center univer-text-xs",
|
|
3851
|
-
children: [/* @__PURE__ */ jsx(Checkbox, { onChange: reverseIcon }), localeService.t("sheets-conditional-formatting-ui.iconSet.reverseIconOrder")]
|
|
3852
|
-
}), /* @__PURE__ */ jsxs("div", {
|
|
3853
|
-
className: "univer-ml-6 univer-flex univer-items-center univer-text-xs",
|
|
3854
|
-
children: [/* @__PURE__ */ jsx(Checkbox, {
|
|
3855
|
-
checked: !isShowValue,
|
|
3856
|
-
onChange: (v) => {
|
|
3857
|
-
setIsShowValue(!v);
|
|
3858
|
-
}
|
|
3859
|
-
}), localeService.t("sheets-conditional-formatting-ui.iconSet.onlyShowIcon")]
|
|
3860
|
-
})]
|
|
3861
|
-
}),
|
|
3862
|
-
/* @__PURE__ */ jsx(IconSetRuleEdit, {
|
|
3863
|
-
errorMap,
|
|
3864
|
-
onChange: handleChange,
|
|
3865
|
-
configList
|
|
3866
|
-
})
|
|
3867
|
-
] });
|
|
4121
|
+
]
|
|
4122
|
+
});
|
|
3868
4123
|
};
|
|
3869
4124
|
|
|
3870
4125
|
//#endregion
|
|
@@ -4001,7 +4256,7 @@ const RankStyleEditor = (props) => {
|
|
|
4001
4256
|
}
|
|
4002
4257
|
}),
|
|
4003
4258
|
["isNotBottom", "isBottom"].includes(type) && /* @__PURE__ */ jsxs("div", {
|
|
4004
|
-
className: "univer-mt-3 univer-flex univer-items-center",
|
|
4259
|
+
className: "univer-mt-3 univer-flex univer-items-center univer-gap-2",
|
|
4005
4260
|
children: [/* @__PURE__ */ jsx(InputNumber, {
|
|
4006
4261
|
min: 1,
|
|
4007
4262
|
max: 1e3,
|
|
@@ -4017,7 +4272,7 @@ const RankStyleEditor = (props) => {
|
|
|
4017
4272
|
});
|
|
4018
4273
|
}
|
|
4019
4274
|
}), /* @__PURE__ */ jsxs("div", {
|
|
4020
|
-
className: "univer-
|
|
4275
|
+
className: "univer-flex univer-items-center univer-text-xs",
|
|
4021
4276
|
children: [/* @__PURE__ */ jsx(Checkbox, {
|
|
4022
4277
|
checked: isPercent,
|
|
4023
4278
|
onChange: (v) => {
|
|
@@ -4275,12 +4530,11 @@ const RuleEdit = (props) => {
|
|
|
4275
4530
|
onChange: onStyleChange
|
|
4276
4531
|
}),
|
|
4277
4532
|
/* @__PURE__ */ jsxs("div", {
|
|
4278
|
-
className: "univer-mt-4 univer-flex univer-justify-end",
|
|
4533
|
+
className: "univer-mt-4 univer-flex univer-justify-end univer-gap-2",
|
|
4279
4534
|
children: [/* @__PURE__ */ jsx(Button, {
|
|
4280
4535
|
onClick: handleCancel,
|
|
4281
4536
|
children: localeService.t("sheets-conditional-formatting-ui.panel.cancel")
|
|
4282
4537
|
}), /* @__PURE__ */ jsx(Button, {
|
|
4283
|
-
className: "univer-ml-3",
|
|
4284
4538
|
variant: "primary",
|
|
4285
4539
|
onClick: handleSubmit,
|
|
4286
4540
|
children: localeService.t("sheets-conditional-formatting-ui.panel.submit")
|
|
@@ -4628,175 +4882,6 @@ let ComponentsController = class ComponentsController extends Disposable {
|
|
|
4628
4882
|
};
|
|
4629
4883
|
ComponentsController = __decorate([__decorateParam(0, Inject(ComponentManager)), __decorateParam(1, Inject(IconManager))], ComponentsController);
|
|
4630
4884
|
|
|
4631
|
-
//#endregion
|
|
4632
|
-
//#region src/menu/manage-rule.ts
|
|
4633
|
-
const commandList = [
|
|
4634
|
-
SetWorksheetActiveOperation.id,
|
|
4635
|
-
AddConditionalRuleMutation.id,
|
|
4636
|
-
SetConditionalRuleMutation.id,
|
|
4637
|
-
DeleteConditionalRuleMutation.id,
|
|
4638
|
-
MoveConditionalRuleMutation.id
|
|
4639
|
-
];
|
|
4640
|
-
const commonSelections = [
|
|
4641
|
-
{
|
|
4642
|
-
label: {
|
|
4643
|
-
name: "sheets-conditional-formatting-ui.ruleType.highlightCell",
|
|
4644
|
-
selectable: false
|
|
4645
|
-
},
|
|
4646
|
-
value: 3
|
|
4647
|
-
},
|
|
4648
|
-
{
|
|
4649
|
-
label: {
|
|
4650
|
-
name: "sheets-conditional-formatting-ui.panel.rankAndAverage",
|
|
4651
|
-
selectable: false
|
|
4652
|
-
},
|
|
4653
|
-
value: 4
|
|
4654
|
-
},
|
|
4655
|
-
{
|
|
4656
|
-
label: {
|
|
4657
|
-
name: "sheets-conditional-formatting-ui.ruleType.formula",
|
|
4658
|
-
selectable: false
|
|
4659
|
-
},
|
|
4660
|
-
value: 5
|
|
4661
|
-
},
|
|
4662
|
-
{
|
|
4663
|
-
label: {
|
|
4664
|
-
name: "sheets-conditional-formatting-ui.ruleType.colorScale",
|
|
4665
|
-
selectable: false
|
|
4666
|
-
},
|
|
4667
|
-
value: 6
|
|
4668
|
-
},
|
|
4669
|
-
{
|
|
4670
|
-
label: {
|
|
4671
|
-
name: "sheets-conditional-formatting-ui.ruleType.dataBar",
|
|
4672
|
-
selectable: false
|
|
4673
|
-
},
|
|
4674
|
-
value: 7
|
|
4675
|
-
},
|
|
4676
|
-
{
|
|
4677
|
-
label: {
|
|
4678
|
-
name: "sheets-conditional-formatting-ui.ruleType.iconSet",
|
|
4679
|
-
selectable: false
|
|
4680
|
-
},
|
|
4681
|
-
value: 8
|
|
4682
|
-
},
|
|
4683
|
-
{
|
|
4684
|
-
label: {
|
|
4685
|
-
name: "sheets-conditional-formatting-ui.menu.manageConditionalFormatting",
|
|
4686
|
-
selectable: false
|
|
4687
|
-
},
|
|
4688
|
-
value: 2
|
|
4689
|
-
},
|
|
4690
|
-
{
|
|
4691
|
-
label: {
|
|
4692
|
-
name: "sheets-conditional-formatting-ui.menu.createConditionalFormatting",
|
|
4693
|
-
selectable: false
|
|
4694
|
-
},
|
|
4695
|
-
value: 1
|
|
4696
|
-
},
|
|
4697
|
-
{
|
|
4698
|
-
label: {
|
|
4699
|
-
name: "sheets-conditional-formatting-ui.menu.clearRangeRules",
|
|
4700
|
-
selectable: false
|
|
4701
|
-
},
|
|
4702
|
-
value: 9,
|
|
4703
|
-
disabled: false
|
|
4704
|
-
},
|
|
4705
|
-
{
|
|
4706
|
-
label: {
|
|
4707
|
-
name: "sheets-conditional-formatting-ui.menu.clearWorkSheetRules",
|
|
4708
|
-
selectable: false
|
|
4709
|
-
},
|
|
4710
|
-
value: 10
|
|
4711
|
-
}
|
|
4712
|
-
];
|
|
4713
|
-
function FactoryManageConditionalFormattingRule(accessor) {
|
|
4714
|
-
const selectionManagerService = accessor.get(SheetsSelectionsService);
|
|
4715
|
-
const commandService = accessor.get(ICommandService);
|
|
4716
|
-
const univerInstanceService = accessor.get(IUniverInstanceService);
|
|
4717
|
-
const conditionalFormattingRuleModel = accessor.get(ConditionalFormattingRuleModel);
|
|
4718
|
-
const clearRangeEnable$ = new Observable((subscriber) => merge$1(selectionManagerService.selectionMoveEnd$, selectionManagerService.selectionSet$, new Observable((commandSubscribe) => {
|
|
4719
|
-
const disposable = commandService.onCommandExecuted((commandInfo) => {
|
|
4720
|
-
var _univerInstanceServic;
|
|
4721
|
-
const { id, params } = commandInfo;
|
|
4722
|
-
const unitId = (_univerInstanceServic = univerInstanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_SHEET)) === null || _univerInstanceServic === void 0 ? void 0 : _univerInstanceServic.getUnitId();
|
|
4723
|
-
if (commandList.includes(id) && params.unitId === unitId) commandSubscribe.next(null);
|
|
4724
|
-
});
|
|
4725
|
-
return () => disposable.dispose();
|
|
4726
|
-
})).pipe(debounceTime$1(16)).subscribe(() => {
|
|
4727
|
-
var _selectionManagerServ;
|
|
4728
|
-
const ranges = ((_selectionManagerServ = selectionManagerService.getCurrentSelections()) === null || _selectionManagerServ === void 0 ? void 0 : _selectionManagerServ.map((selection) => selection.range)) || [];
|
|
4729
|
-
const workbook = univerInstanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_SHEET);
|
|
4730
|
-
if (!workbook) return;
|
|
4731
|
-
const worksheet = workbook.getActiveSheet();
|
|
4732
|
-
if (!worksheet) return;
|
|
4733
|
-
const hasPermission = (conditionalFormattingRuleModel.getSubunitRules(workbook.getUnitId(), worksheet.getSheetId()) || []).filter((rule) => rule.ranges.some((ruleRange) => ranges.some((range) => Rectangle.intersects(range, ruleRange)))).map((rule) => rule.ranges).every((ranges) => {
|
|
4734
|
-
return checkRangesEditablePermission(accessor, workbook.getUnitId(), worksheet.getSheetId(), ranges);
|
|
4735
|
-
});
|
|
4736
|
-
subscriber.next(hasPermission);
|
|
4737
|
-
}));
|
|
4738
|
-
const clearSheetEnable$ = new Observable((subscriber) => new Observable((commandSubscribe) => {
|
|
4739
|
-
const disposable = commandService.onCommandExecuted((commandInfo) => {
|
|
4740
|
-
var _univerInstanceServic2;
|
|
4741
|
-
const { id, params } = commandInfo;
|
|
4742
|
-
const unitId = (_univerInstanceServic2 = univerInstanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_SHEET)) === null || _univerInstanceServic2 === void 0 ? void 0 : _univerInstanceServic2.getUnitId();
|
|
4743
|
-
if (commandList.includes(id) && params.unitId === unitId) commandSubscribe.next(null);
|
|
4744
|
-
});
|
|
4745
|
-
return () => disposable.dispose();
|
|
4746
|
-
}).pipe(debounceTime$1(16)).subscribe(() => {
|
|
4747
|
-
const workbook = univerInstanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_SHEET);
|
|
4748
|
-
if (!workbook) return;
|
|
4749
|
-
const worksheet = workbook.getActiveSheet();
|
|
4750
|
-
if (!worksheet) return;
|
|
4751
|
-
const allRule = conditionalFormattingRuleModel.getSubunitRules(workbook.getUnitId(), worksheet.getSheetId()) || [];
|
|
4752
|
-
if (!allRule.length) {
|
|
4753
|
-
subscriber.next(false);
|
|
4754
|
-
return false;
|
|
4755
|
-
}
|
|
4756
|
-
const hasPermission = allRule.map((rule) => rule.ranges).every((ranges) => {
|
|
4757
|
-
return checkRangesEditablePermission(accessor, workbook.getUnitId(), worksheet.getSheetId(), ranges);
|
|
4758
|
-
});
|
|
4759
|
-
subscriber.next(hasPermission);
|
|
4760
|
-
}));
|
|
4761
|
-
const selections$ = new Observable((subscriber) => {
|
|
4762
|
-
clearRangeEnable$.subscribe((v) => {
|
|
4763
|
-
const item = commonSelections.find((item) => item.value === 9);
|
|
4764
|
-
if (item) {
|
|
4765
|
-
item.disabled = !v;
|
|
4766
|
-
subscriber.next(commonSelections);
|
|
4767
|
-
}
|
|
4768
|
-
});
|
|
4769
|
-
clearSheetEnable$.subscribe((v) => {
|
|
4770
|
-
const item = commonSelections.find((item) => item.value === 10);
|
|
4771
|
-
if (item) {
|
|
4772
|
-
item.disabled = !v;
|
|
4773
|
-
subscriber.next(commonSelections);
|
|
4774
|
-
}
|
|
4775
|
-
});
|
|
4776
|
-
subscriber.next(commonSelections);
|
|
4777
|
-
});
|
|
4778
|
-
return {
|
|
4779
|
-
id: OpenConditionalFormattingOperator.id,
|
|
4780
|
-
type: MenuItemType.SELECTOR,
|
|
4781
|
-
icon: "ConditionsDoubleIcon",
|
|
4782
|
-
tooltip: "sheets-conditional-formatting-ui.title",
|
|
4783
|
-
selections: selections$,
|
|
4784
|
-
hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_SHEET),
|
|
4785
|
-
disabled$: getCurrentRangeDisable$(accessor, {
|
|
4786
|
-
workbookTypes: [WorkbookEditablePermission],
|
|
4787
|
-
worksheetTypes: [WorksheetSetCellStylePermission, WorksheetEditPermission],
|
|
4788
|
-
rangeTypes: [RangeProtectionPermissionEditPoint]
|
|
4789
|
-
})
|
|
4790
|
-
};
|
|
4791
|
-
}
|
|
4792
|
-
|
|
4793
|
-
//#endregion
|
|
4794
|
-
//#region src/menu/schema.ts
|
|
4795
|
-
const menuSchema = { [RibbonDataGroup.RULES]: { [OpenConditionalFormattingOperator.id]: {
|
|
4796
|
-
order: 1,
|
|
4797
|
-
menuItemFactory: FactoryManageConditionalFormattingRule
|
|
4798
|
-
} } };
|
|
4799
|
-
|
|
4800
4885
|
//#endregion
|
|
4801
4886
|
//#region src/menu/cf.menu.controller.ts
|
|
4802
4887
|
/**
|
|
@@ -4900,4 +4985,4 @@ UniverSheetsConditionalFormattingUIPlugin = __decorate([
|
|
|
4900
4985
|
], UniverSheetsConditionalFormattingUIPlugin);
|
|
4901
4986
|
|
|
4902
4987
|
//#endregion
|
|
4903
|
-
export { AddAverageCfCommand, AddColorScaleConditionalRuleCommand, AddDataBarConditionalRuleCommand, AddDuplicateValuesCfCommand, AddNumberCfCommand, AddRankCfCommand, AddTextCfCommand, AddTimePeriodCfCommand, AddUniqueValuesCfCommand, ConditionalFormattingClearController, OpenConditionalFormattingOperator, UniverSheetsConditionalFormattingMobileUIPlugin, UniverSheetsConditionalFormattingUIPlugin };
|
|
4988
|
+
export { AddAverageCfCommand, AddColorScaleConditionalRuleCommand, AddDataBarConditionalRuleCommand, AddDuplicateValuesCfCommand, AddNumberCfCommand, AddRankCfCommand, AddTextCfCommand, AddTimePeriodCfCommand, AddUniqueValuesCfCommand, ConditionalFormattingClearController, OpenConditionalFormattingOperator, menuSchema as SheetsConditionalFormattingUIMenuSchema, UniverSheetsConditionalFormattingMobileUIPlugin, UniverSheetsConditionalFormattingUIPlugin };
|