@univerjs/sheets-conditional-formatting-ui 1.0.0-alpha.2 → 1.0.0-alpha.4
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 +722 -494
- 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 +726 -500
- 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 +90 -22
- package/lib/index.js +726 -500
- 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/commands/commands/add-data-bar-cf.command.d.ts +1 -1
- package/lib/types/commands/commands/add-icon-set-cf.command.d.ts +25 -0
- package/lib/types/controllers/cf.panel.controller.d.ts +3 -5
- package/lib/types/controllers/cf.render.controller.d.ts +3 -0
- package/lib/types/index.d.ts +2 -0
- package/lib/types/locale/en-US.d.ts +1 -0
- package/lib/types/menu/quick-insert.menu.d.ts +20 -0
- package/lib/types/views/Preview.d.ts +2 -2
- package/lib/types/views/panel/RuleList.d.ts +1 -1
- package/lib/types/views/panel/rule-edit/HighlightCell.d.ts +4 -2
- 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 +15 -15
package/lib/es/index.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { BooleanNumber, ColorKit, CommandType, DependentOn, Disposable, DisposableCollection, ICommandService, IConfigService, IUniverInstanceService, Inject, Injector, InterceptorEffectEnum, InterceptorManager, LocaleService, ObjectMatrix, Plugin, Range, Rectangle, Tools, UniverInstanceType, createInterceptorKey, generateRandomId, get, merge, registerDependencies, set, toDisposable, touchDependencies } from "@univerjs/core";
|
|
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
|
-
import { ComponentManager,
|
|
5
|
-
import { FormulaRefRangeService, UniverSheetsFormulaPlugin } from "@univerjs/sheets-formula";
|
|
4
|
+
import { ComponentManager, IMenuManagerService, ISidebarService, IconManager, MenuItemType, RibbonDataGroup, RibbonInsertGroup, getMenuHiddenObservable, useDependency, useObservable, useSidebarClick } from "@univerjs/ui";
|
|
6
5
|
import { COPY_TYPE, FormatPainterStatus, IFormatPainterService, ISheetClipboardService, PREDEFINED_HOOK_NAME_PASTE, SheetSkeletonManagerService, getCurrentRangeDisable$, getRepeatRange, useHighlightRange, virtualizeDiscreteRanges } from "@univerjs/sheets-ui";
|
|
6
|
+
import { Observable, debounceTime, filter, map, merge as merge$1, share, startWith } from "rxjs";
|
|
7
|
+
import { bufferTime, debounceTime as debounceTime$1, filter as filter$1 } from "rxjs/operators";
|
|
8
|
+
import { FormulaRefRangeService, UniverSheetsFormulaPlugin } from "@univerjs/sheets-formula";
|
|
7
9
|
import { IRenderManagerService } from "@univerjs/engine-render";
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import { BoldIcon, ConditionsDoubleIcon, DeleteIcon, FontColorDoubleIcon, GripVerticalIcon, IncreaseIcon, ItalicIcon, MoreDownIcon, PaintBucketDoubleIcon, SlashDoubleIcon, StrikethroughIcon, UnderlineIcon } from "@univerjs/icons";
|
|
11
|
-
import { forwardRef, useEffect, useMemo, useRef, useState } from "react";
|
|
10
|
+
import { BoldIcon, ConditionsDoubleIcon, DataBarIcon, DeleteIcon, FontColorDoubleIcon, GripVerticalIcon, IncreaseIcon, ItalicIcon, MoreDownIcon, PaintBucketDoubleIcon, RatingIcon, SlashDoubleIcon, StrikethroughIcon, UnderlineIcon } from "@univerjs/icons";
|
|
11
|
+
import { 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";
|
|
13
13
|
import { LexerTreeBuilder, deserializeRangeWithSheet, operatorToken, serializeRange } from "@univerjs/engine-formula";
|
|
14
14
|
import { FormulaEditor, RangeSelector } from "@univerjs/sheets-formula-ui";
|
|
@@ -81,8 +81,11 @@ 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;
|
|
84
85
|
if (!params) return false;
|
|
85
|
-
const {
|
|
86
|
+
const { min, max, nativeColor, positiveColor, isGradient, stopIfTrue, isShowValue } = params;
|
|
87
|
+
const ranges = (_params$ranges = params.ranges) !== null && _params$ranges !== void 0 ? _params$ranges : accessor.get(SheetsSelectionsService).getCurrentSelections().map((selection) => selection.range);
|
|
88
|
+
if (!ranges.length) return false;
|
|
86
89
|
const conditionalFormattingRuleModel = accessor.get(ConditionalFormattingRuleModel);
|
|
87
90
|
const target = getSheetCommandTarget(accessor.get(IUniverInstanceService));
|
|
88
91
|
if (!target) return false;
|
|
@@ -143,6 +146,37 @@ const AddDuplicateValuesCfCommand = {
|
|
|
143
146
|
}
|
|
144
147
|
};
|
|
145
148
|
|
|
149
|
+
//#endregion
|
|
150
|
+
//#region src/commands/commands/add-icon-set-cf.command.ts
|
|
151
|
+
const AddIconSetConditionalRuleCommand = {
|
|
152
|
+
type: CommandType.COMMAND,
|
|
153
|
+
id: "sheet.command.add-icon-set-conditional-rule",
|
|
154
|
+
handler(accessor, params) {
|
|
155
|
+
var _params$ranges;
|
|
156
|
+
if (!params) return false;
|
|
157
|
+
const ranges = (_params$ranges = params.ranges) !== null && _params$ranges !== void 0 ? _params$ranges : accessor.get(SheetsSelectionsService).getCurrentSelections().map((selection) => selection.range);
|
|
158
|
+
if (!ranges.length) return false;
|
|
159
|
+
const target = getSheetCommandTarget(accessor.get(IUniverInstanceService));
|
|
160
|
+
if (!target) return false;
|
|
161
|
+
const { unitId, subUnitId } = target;
|
|
162
|
+
const rule = {
|
|
163
|
+
ranges,
|
|
164
|
+
cfId: accessor.get(ConditionalFormattingRuleModel).createCfId(unitId, subUnitId),
|
|
165
|
+
stopIfTrue: !!params.stopIfTrue,
|
|
166
|
+
rule: {
|
|
167
|
+
type: CFRuleType.iconSet,
|
|
168
|
+
config: params.config,
|
|
169
|
+
isShowValue: params.isShowValue
|
|
170
|
+
}
|
|
171
|
+
};
|
|
172
|
+
return accessor.get(ICommandService).executeCommand(AddConditionalRuleMutation.id, {
|
|
173
|
+
unitId,
|
|
174
|
+
subUnitId,
|
|
175
|
+
rule
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
};
|
|
179
|
+
|
|
146
180
|
//#endregion
|
|
147
181
|
//#region src/commands/commands/add-number-cf.command.ts
|
|
148
182
|
const AddNumberCfCommand = {
|
|
@@ -393,11 +427,9 @@ function __decorate(decorators, target, key, desc) {
|
|
|
393
427
|
//#region src/controllers/cf.panel.controller.ts
|
|
394
428
|
const CF_PANEL_KEY$1 = "sheet.conditional.formatting.panel";
|
|
395
429
|
let ConditionalFormattingPanelController = class ConditionalFormattingPanelController extends Disposable {
|
|
396
|
-
constructor(_univerInstanceService,
|
|
430
|
+
constructor(_univerInstanceService, _sidebarService, _localeService) {
|
|
397
431
|
super();
|
|
398
432
|
this._univerInstanceService = _univerInstanceService;
|
|
399
|
-
this._injector = _injector;
|
|
400
|
-
this._componentManager = _componentManager;
|
|
401
433
|
this._sidebarService = _sidebarService;
|
|
402
434
|
this._localeService = _localeService;
|
|
403
435
|
_defineProperty(this, "_sidebarDisposable", null);
|
|
@@ -429,10 +461,8 @@ let ConditionalFormattingPanelController = class ConditionalFormattingPanelContr
|
|
|
429
461
|
};
|
|
430
462
|
ConditionalFormattingPanelController = __decorate([
|
|
431
463
|
__decorateParam(0, IUniverInstanceService),
|
|
432
|
-
__decorateParam(1, Inject(
|
|
433
|
-
__decorateParam(2, Inject(
|
|
434
|
-
__decorateParam(3, Inject(ISidebarService)),
|
|
435
|
-
__decorateParam(4, Inject(LocaleService))
|
|
464
|
+
__decorateParam(1, Inject(ISidebarService)),
|
|
465
|
+
__decorateParam(2, Inject(LocaleService))
|
|
436
466
|
], ConditionalFormattingPanelController);
|
|
437
467
|
|
|
438
468
|
//#endregion
|
|
@@ -637,10 +667,317 @@ function generateClearCfMutations(injector, allRules, ranges, unitId, subUnitId)
|
|
|
637
667
|
};
|
|
638
668
|
}
|
|
639
669
|
|
|
670
|
+
//#endregion
|
|
671
|
+
//#region src/menu/manage-rule.ts
|
|
672
|
+
const commandList = [
|
|
673
|
+
SetWorksheetActiveOperation.id,
|
|
674
|
+
AddConditionalRuleMutation.id,
|
|
675
|
+
SetConditionalRuleMutation.id,
|
|
676
|
+
DeleteConditionalRuleMutation.id,
|
|
677
|
+
MoveConditionalRuleMutation.id
|
|
678
|
+
];
|
|
679
|
+
const commonSelections = [
|
|
680
|
+
{
|
|
681
|
+
label: {
|
|
682
|
+
name: "sheets-conditional-formatting-ui.ruleType.highlightCell",
|
|
683
|
+
selectable: false
|
|
684
|
+
},
|
|
685
|
+
value: 3
|
|
686
|
+
},
|
|
687
|
+
{
|
|
688
|
+
label: {
|
|
689
|
+
name: "sheets-conditional-formatting-ui.panel.rankAndAverage",
|
|
690
|
+
selectable: false
|
|
691
|
+
},
|
|
692
|
+
value: 4
|
|
693
|
+
},
|
|
694
|
+
{
|
|
695
|
+
label: {
|
|
696
|
+
name: "sheets-conditional-formatting-ui.ruleType.formula",
|
|
697
|
+
selectable: false
|
|
698
|
+
},
|
|
699
|
+
value: 5
|
|
700
|
+
},
|
|
701
|
+
{
|
|
702
|
+
label: {
|
|
703
|
+
name: "sheets-conditional-formatting-ui.ruleType.colorScale",
|
|
704
|
+
selectable: false
|
|
705
|
+
},
|
|
706
|
+
value: 6
|
|
707
|
+
},
|
|
708
|
+
{
|
|
709
|
+
label: {
|
|
710
|
+
name: "sheets-conditional-formatting-ui.ruleType.dataBar",
|
|
711
|
+
selectable: false
|
|
712
|
+
},
|
|
713
|
+
value: 7
|
|
714
|
+
},
|
|
715
|
+
{
|
|
716
|
+
label: {
|
|
717
|
+
name: "sheets-conditional-formatting-ui.ruleType.iconSet",
|
|
718
|
+
selectable: false
|
|
719
|
+
},
|
|
720
|
+
value: 8
|
|
721
|
+
},
|
|
722
|
+
{
|
|
723
|
+
label: {
|
|
724
|
+
name: "sheets-conditional-formatting-ui.menu.manageConditionalFormatting",
|
|
725
|
+
selectable: false
|
|
726
|
+
},
|
|
727
|
+
value: 2
|
|
728
|
+
},
|
|
729
|
+
{
|
|
730
|
+
label: {
|
|
731
|
+
name: "sheets-conditional-formatting-ui.menu.createConditionalFormatting",
|
|
732
|
+
selectable: false
|
|
733
|
+
},
|
|
734
|
+
value: 1
|
|
735
|
+
},
|
|
736
|
+
{
|
|
737
|
+
label: {
|
|
738
|
+
name: "sheets-conditional-formatting-ui.menu.clearRangeRules",
|
|
739
|
+
selectable: false
|
|
740
|
+
},
|
|
741
|
+
value: 9,
|
|
742
|
+
disabled: false
|
|
743
|
+
},
|
|
744
|
+
{
|
|
745
|
+
label: {
|
|
746
|
+
name: "sheets-conditional-formatting-ui.menu.clearWorkSheetRules",
|
|
747
|
+
selectable: false
|
|
748
|
+
},
|
|
749
|
+
value: 10
|
|
750
|
+
}
|
|
751
|
+
];
|
|
752
|
+
function FactoryManageConditionalFormattingRule(accessor) {
|
|
753
|
+
const selectionManagerService = accessor.get(SheetsSelectionsService);
|
|
754
|
+
const commandService = accessor.get(ICommandService);
|
|
755
|
+
const univerInstanceService = accessor.get(IUniverInstanceService);
|
|
756
|
+
const conditionalFormattingRuleModel = accessor.get(ConditionalFormattingRuleModel);
|
|
757
|
+
const clearRangeEnable$ = new Observable((subscriber) => merge$1(selectionManagerService.selectionMoveEnd$, selectionManagerService.selectionSet$, new Observable((commandSubscribe) => {
|
|
758
|
+
const disposable = commandService.onCommandExecuted((commandInfo) => {
|
|
759
|
+
var _univerInstanceServic;
|
|
760
|
+
const { id, params } = commandInfo;
|
|
761
|
+
const unitId = (_univerInstanceServic = univerInstanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_SHEET)) === null || _univerInstanceServic === void 0 ? void 0 : _univerInstanceServic.getUnitId();
|
|
762
|
+
if (commandList.includes(id) && params.unitId === unitId) commandSubscribe.next(null);
|
|
763
|
+
});
|
|
764
|
+
return () => disposable.dispose();
|
|
765
|
+
})).pipe(debounceTime$1(16)).subscribe(() => {
|
|
766
|
+
var _selectionManagerServ;
|
|
767
|
+
const ranges = ((_selectionManagerServ = selectionManagerService.getCurrentSelections()) === null || _selectionManagerServ === void 0 ? void 0 : _selectionManagerServ.map((selection) => selection.range)) || [];
|
|
768
|
+
const workbook = univerInstanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_SHEET);
|
|
769
|
+
if (!workbook) return;
|
|
770
|
+
const worksheet = workbook.getActiveSheet();
|
|
771
|
+
if (!worksheet) return;
|
|
772
|
+
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) => {
|
|
773
|
+
return checkRangesEditablePermission(accessor, workbook.getUnitId(), worksheet.getSheetId(), ranges);
|
|
774
|
+
});
|
|
775
|
+
subscriber.next(hasPermission);
|
|
776
|
+
}));
|
|
777
|
+
const clearSheetEnable$ = new Observable((subscriber) => new Observable((commandSubscribe) => {
|
|
778
|
+
const disposable = commandService.onCommandExecuted((commandInfo) => {
|
|
779
|
+
var _univerInstanceServic2;
|
|
780
|
+
const { id, params } = commandInfo;
|
|
781
|
+
const unitId = (_univerInstanceServic2 = univerInstanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_SHEET)) === null || _univerInstanceServic2 === void 0 ? void 0 : _univerInstanceServic2.getUnitId();
|
|
782
|
+
if (commandList.includes(id) && params.unitId === unitId) commandSubscribe.next(null);
|
|
783
|
+
});
|
|
784
|
+
return () => disposable.dispose();
|
|
785
|
+
}).pipe(debounceTime$1(16)).subscribe(() => {
|
|
786
|
+
const workbook = univerInstanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_SHEET);
|
|
787
|
+
if (!workbook) return;
|
|
788
|
+
const worksheet = workbook.getActiveSheet();
|
|
789
|
+
if (!worksheet) return;
|
|
790
|
+
const allRule = conditionalFormattingRuleModel.getSubunitRules(workbook.getUnitId(), worksheet.getSheetId()) || [];
|
|
791
|
+
if (!allRule.length) {
|
|
792
|
+
subscriber.next(false);
|
|
793
|
+
return false;
|
|
794
|
+
}
|
|
795
|
+
const hasPermission = allRule.map((rule) => rule.ranges).every((ranges) => {
|
|
796
|
+
return checkRangesEditablePermission(accessor, workbook.getUnitId(), worksheet.getSheetId(), ranges);
|
|
797
|
+
});
|
|
798
|
+
subscriber.next(hasPermission);
|
|
799
|
+
}));
|
|
800
|
+
const selections$ = new Observable((subscriber) => {
|
|
801
|
+
clearRangeEnable$.subscribe((v) => {
|
|
802
|
+
const item = commonSelections.find((item) => item.value === 9);
|
|
803
|
+
if (item) {
|
|
804
|
+
item.disabled = !v;
|
|
805
|
+
subscriber.next(commonSelections);
|
|
806
|
+
}
|
|
807
|
+
});
|
|
808
|
+
clearSheetEnable$.subscribe((v) => {
|
|
809
|
+
const item = commonSelections.find((item) => item.value === 10);
|
|
810
|
+
if (item) {
|
|
811
|
+
item.disabled = !v;
|
|
812
|
+
subscriber.next(commonSelections);
|
|
813
|
+
}
|
|
814
|
+
});
|
|
815
|
+
subscriber.next(commonSelections);
|
|
816
|
+
});
|
|
817
|
+
return {
|
|
818
|
+
id: OpenConditionalFormattingOperator.id,
|
|
819
|
+
type: MenuItemType.SELECTOR,
|
|
820
|
+
icon: "ConditionsDoubleIcon",
|
|
821
|
+
tooltip: "sheets-conditional-formatting-ui.title",
|
|
822
|
+
selections: selections$,
|
|
823
|
+
hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_SHEET),
|
|
824
|
+
disabled$: getCurrentRangeDisable$(accessor, {
|
|
825
|
+
workbookTypes: [WorkbookEditablePermission],
|
|
826
|
+
worksheetTypes: [WorksheetSetCellStylePermission, WorksheetEditPermission],
|
|
827
|
+
rangeTypes: [RangeProtectionPermissionEditPoint]
|
|
828
|
+
})
|
|
829
|
+
};
|
|
830
|
+
}
|
|
831
|
+
|
|
832
|
+
//#endregion
|
|
833
|
+
//#region src/menu/quick-insert.menu.ts
|
|
834
|
+
const DATA_BAR_PARAMS = {
|
|
835
|
+
min: { type: CFValueType.min },
|
|
836
|
+
max: { type: CFValueType.max },
|
|
837
|
+
nativeColor: defaultDataBarNativeColor,
|
|
838
|
+
positiveColor: defaultDataBarPositiveColor,
|
|
839
|
+
isGradient: false,
|
|
840
|
+
isShowValue: true
|
|
841
|
+
};
|
|
842
|
+
function createIconSetParams(iconType) {
|
|
843
|
+
return {
|
|
844
|
+
config: [
|
|
845
|
+
{
|
|
846
|
+
iconType,
|
|
847
|
+
iconId: "0",
|
|
848
|
+
operator: CFNumberOperator.greaterThanOrEqual,
|
|
849
|
+
value: {
|
|
850
|
+
type: CFValueType.percent,
|
|
851
|
+
value: 67
|
|
852
|
+
}
|
|
853
|
+
},
|
|
854
|
+
{
|
|
855
|
+
iconType,
|
|
856
|
+
iconId: "1",
|
|
857
|
+
operator: CFNumberOperator.greaterThanOrEqual,
|
|
858
|
+
value: {
|
|
859
|
+
type: CFValueType.percent,
|
|
860
|
+
value: 33
|
|
861
|
+
}
|
|
862
|
+
},
|
|
863
|
+
{
|
|
864
|
+
iconType,
|
|
865
|
+
iconId: "2",
|
|
866
|
+
operator: CFNumberOperator.lessThanOrEqual,
|
|
867
|
+
value: {
|
|
868
|
+
type: CFValueType.percent,
|
|
869
|
+
value: Number.MAX_SAFE_INTEGER
|
|
870
|
+
}
|
|
871
|
+
}
|
|
872
|
+
],
|
|
873
|
+
isShowValue: true
|
|
874
|
+
};
|
|
875
|
+
}
|
|
876
|
+
function getQuickConditionalFormattingMenuState(accessor) {
|
|
877
|
+
return {
|
|
878
|
+
hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_SHEET),
|
|
879
|
+
disabled$: getCurrentRangeDisable$(accessor, {
|
|
880
|
+
workbookTypes: [WorkbookEditablePermission],
|
|
881
|
+
worksheetTypes: [WorksheetSetCellStylePermission, WorksheetEditPermission],
|
|
882
|
+
rangeTypes: [RangeProtectionPermissionEditPoint]
|
|
883
|
+
})
|
|
884
|
+
};
|
|
885
|
+
}
|
|
886
|
+
function quickDataBarMenuFactory(accessor) {
|
|
887
|
+
return {
|
|
888
|
+
id: AddDataBarConditionalRuleCommand.id,
|
|
889
|
+
type: MenuItemType.BUTTON_SELECTOR,
|
|
890
|
+
icon: "DataBarIcon",
|
|
891
|
+
tooltip: "sheets-conditional-formatting-ui.ruleType.dataBar",
|
|
892
|
+
params: DATA_BAR_PARAMS,
|
|
893
|
+
selectionsCommandId: AddDataBarConditionalRuleCommand.id,
|
|
894
|
+
selections: [
|
|
895
|
+
{
|
|
896
|
+
label: "sheets-conditional-formatting-ui.ruleType.dataBar",
|
|
897
|
+
value: CFRuleType.dataBar,
|
|
898
|
+
params: DATA_BAR_PARAMS
|
|
899
|
+
},
|
|
900
|
+
{
|
|
901
|
+
id: OpenConditionalFormattingOperator.id,
|
|
902
|
+
label: "sheets-conditional-formatting-ui.menu.createConditionalFormatting",
|
|
903
|
+
value: 7,
|
|
904
|
+
params: { value: 7 }
|
|
905
|
+
},
|
|
906
|
+
{
|
|
907
|
+
id: ClearRangeCfCommand.id,
|
|
908
|
+
label: "sheets-conditional-formatting-ui.menu.clearRangeRules",
|
|
909
|
+
value: CFRuleType.dataBar,
|
|
910
|
+
params: { types: [CFRuleType.dataBar] }
|
|
911
|
+
}
|
|
912
|
+
],
|
|
913
|
+
...getQuickConditionalFormattingMenuState(accessor)
|
|
914
|
+
};
|
|
915
|
+
}
|
|
916
|
+
function quickIconSetMenuFactory(accessor) {
|
|
917
|
+
const ratingParams = createIconSetParams(IIconSetType.threeStars);
|
|
918
|
+
return {
|
|
919
|
+
id: AddIconSetConditionalRuleCommand.id,
|
|
920
|
+
type: MenuItemType.BUTTON_SELECTOR,
|
|
921
|
+
icon: "RatingIcon",
|
|
922
|
+
tooltip: "sheets-conditional-formatting-ui.ruleType.iconSet",
|
|
923
|
+
params: ratingParams,
|
|
924
|
+
selectionsCommandId: AddIconSetConditionalRuleCommand.id,
|
|
925
|
+
selections: [
|
|
926
|
+
{
|
|
927
|
+
label: "sheets-conditional-formatting-ui.iconSet.rank",
|
|
928
|
+
value: IIconSetType.threeStars,
|
|
929
|
+
params: ratingParams
|
|
930
|
+
},
|
|
931
|
+
{
|
|
932
|
+
label: "sheets-conditional-formatting-ui.iconSet.shape",
|
|
933
|
+
value: IIconSetType.threeTrafficLights1,
|
|
934
|
+
params: createIconSetParams(IIconSetType.threeTrafficLights1)
|
|
935
|
+
},
|
|
936
|
+
{
|
|
937
|
+
label: "sheets-conditional-formatting-ui.iconSet.direction",
|
|
938
|
+
value: IIconSetType.threeArrows,
|
|
939
|
+
params: createIconSetParams(IIconSetType.threeArrows)
|
|
940
|
+
},
|
|
941
|
+
{
|
|
942
|
+
id: OpenConditionalFormattingOperator.id,
|
|
943
|
+
label: "sheets-conditional-formatting-ui.menu.createConditionalFormatting",
|
|
944
|
+
value: 8,
|
|
945
|
+
params: { value: 8 }
|
|
946
|
+
},
|
|
947
|
+
{
|
|
948
|
+
id: ClearRangeCfCommand.id,
|
|
949
|
+
label: "sheets-conditional-formatting-ui.menu.clearRangeRules",
|
|
950
|
+
value: CFRuleType.iconSet,
|
|
951
|
+
params: { types: [CFRuleType.iconSet] }
|
|
952
|
+
}
|
|
953
|
+
],
|
|
954
|
+
...getQuickConditionalFormattingMenuState(accessor)
|
|
955
|
+
};
|
|
956
|
+
}
|
|
957
|
+
|
|
958
|
+
//#endregion
|
|
959
|
+
//#region src/menu/schema.ts
|
|
960
|
+
const menuSchema = {
|
|
961
|
+
[RibbonInsertGroup.CELL]: {
|
|
962
|
+
[AddDataBarConditionalRuleCommand.id]: {
|
|
963
|
+
order: 3,
|
|
964
|
+
menuItemFactory: quickDataBarMenuFactory
|
|
965
|
+
},
|
|
966
|
+
[AddIconSetConditionalRuleCommand.id]: {
|
|
967
|
+
order: 4,
|
|
968
|
+
menuItemFactory: quickIconSetMenuFactory
|
|
969
|
+
}
|
|
970
|
+
},
|
|
971
|
+
[RibbonDataGroup.RULES]: { [OpenConditionalFormattingOperator.id]: {
|
|
972
|
+
order: 1,
|
|
973
|
+
menuItemFactory: FactoryManageConditionalFormattingRule
|
|
974
|
+
} }
|
|
975
|
+
};
|
|
976
|
+
|
|
640
977
|
//#endregion
|
|
641
978
|
//#region package.json
|
|
642
979
|
var name = "@univerjs/sheets-conditional-formatting-ui";
|
|
643
|
-
var version = "1.0.0-alpha.
|
|
980
|
+
var version = "1.0.0-alpha.4";
|
|
644
981
|
|
|
645
982
|
//#endregion
|
|
646
983
|
//#region src/config/config.ts
|
|
@@ -1166,24 +1503,68 @@ let SheetsCfRenderController = class SheetsCfRenderController extends Disposable
|
|
|
1166
1503
|
_defineProperty(this, "_ruleChangeCacheMap", /* @__PURE__ */ new Map());
|
|
1167
1504
|
this._initViewModelInterceptor();
|
|
1168
1505
|
this._initSkeleton();
|
|
1506
|
+
queueMicrotask(() => this._markActiveSheetRulesDirty());
|
|
1169
1507
|
this.disposeWithMe(() => {
|
|
1170
1508
|
this._ruleChangeCacheMap.clear();
|
|
1171
1509
|
});
|
|
1172
1510
|
}
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1511
|
+
_collectDirtyRanges(items, unitId, subUnitId) {
|
|
1512
|
+
const ranges = [];
|
|
1513
|
+
items.forEach((item) => {
|
|
1514
|
+
var _item$rule, _rule$ranges;
|
|
1515
|
+
if (item.unitId !== unitId || item.subUnitId !== subUnitId) return;
|
|
1516
|
+
const rule = (_item$rule = item.rule) !== null && _item$rule !== void 0 ? _item$rule : item.cfId ? this._conditionalFormattingRuleModel.getRule(unitId, subUnitId, item.cfId) : null;
|
|
1517
|
+
if (rule === null || rule === void 0 || (_rule$ranges = rule.ranges) === null || _rule$ranges === void 0 ? void 0 : _rule$ranges.length) ranges.push(...rule.ranges);
|
|
1518
|
+
});
|
|
1519
|
+
return ranges;
|
|
1520
|
+
}
|
|
1521
|
+
_intersectDirtyRangesWithRenderedRange(ranges, renderedRange) {
|
|
1522
|
+
if (!renderedRange || renderedRange.startRow < 0 || renderedRange.startColumn < 0) return [];
|
|
1523
|
+
return ranges.map((range) => ({
|
|
1524
|
+
startRow: Math.max(range.startRow, renderedRange.startRow),
|
|
1525
|
+
endRow: Math.min(range.endRow, renderedRange.endRow),
|
|
1526
|
+
startColumn: Math.max(range.startColumn, renderedRange.startColumn),
|
|
1527
|
+
endColumn: Math.min(range.endColumn, renderedRange.endColumn)
|
|
1528
|
+
})).filter((range) => range.startRow <= range.endRow && range.startColumn <= range.endColumn);
|
|
1529
|
+
}
|
|
1530
|
+
_markDirtySkeleton(items) {
|
|
1531
|
+
var _render$mainComponent;
|
|
1532
|
+
const workbook = this._univerInstanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_SHEET);
|
|
1533
|
+
const worksheet = workbook === null || workbook === void 0 ? void 0 : workbook.getActiveSheet();
|
|
1534
|
+
if (!workbook || !worksheet) return;
|
|
1535
|
+
const unitId = workbook.getUnitId();
|
|
1536
|
+
const subUnitId = worksheet.getSheetId();
|
|
1537
|
+
const render = this._renderManagerService.getRenderById(unitId);
|
|
1538
|
+
const skeletonManagerService = render === null || render === void 0 ? void 0 : render.with(SheetSkeletonManagerService);
|
|
1539
|
+
const currentSkeleton = skeletonManagerService === null || skeletonManagerService === void 0 ? void 0 : skeletonManagerService.getCurrentSkeleton();
|
|
1540
|
+
const dirtyRanges = this._intersectDirtyRangesWithRenderedRange(this._collectDirtyRanges(items, unitId, subUnitId), currentSkeleton === null || currentSkeleton === void 0 ? void 0 : currentSkeleton.rowColumnSegment);
|
|
1541
|
+
if (dirtyRanges.length) currentSkeleton === null || currentSkeleton === void 0 || currentSkeleton.resetRangeCache(dirtyRanges);
|
|
1542
|
+
skeletonManagerService === null || skeletonManagerService === void 0 || skeletonManagerService.reCalculate();
|
|
1543
|
+
render === null || render === void 0 || (_render$mainComponent = render.mainComponent) === null || _render$mainComponent === void 0 || _render$mainComponent.makeDirty();
|
|
1544
|
+
}
|
|
1545
|
+
_markActiveSheetRulesDirty() {
|
|
1546
|
+
var _this$_conditionalFor;
|
|
1547
|
+
const workbook = this._univerInstanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_SHEET);
|
|
1548
|
+
const worksheet = workbook === null || workbook === void 0 ? void 0 : workbook.getActiveSheet();
|
|
1549
|
+
if (!workbook || !worksheet) return;
|
|
1550
|
+
const unitId = workbook.getUnitId();
|
|
1551
|
+
const subUnitId = worksheet.getSheetId();
|
|
1552
|
+
const rules = (_this$_conditionalFor = this._conditionalFormattingRuleModel.getSubunitRules(unitId, subUnitId)) !== null && _this$_conditionalFor !== void 0 ? _this$_conditionalFor : [];
|
|
1553
|
+
if (!rules.length) return;
|
|
1554
|
+
this._markDirtySkeleton(rules.map((rule) => ({
|
|
1555
|
+
rule,
|
|
1556
|
+
subUnitId,
|
|
1557
|
+
unitId
|
|
1558
|
+
})));
|
|
1178
1559
|
}
|
|
1179
1560
|
_initSkeleton() {
|
|
1180
|
-
this.disposeWithMe(merge$1(this._conditionalFormattingRuleModel.$ruleChange, this._conditionalFormattingViewModel.markDirty$).pipe(bufferTime(16), filter((v) => !!v.length), filter((v) => {
|
|
1561
|
+
this.disposeWithMe(merge$1(this._conditionalFormattingRuleModel.$ruleChange, this._conditionalFormattingViewModel.markDirty$).pipe(bufferTime(16), filter$1((v) => !!v.length), filter$1((v) => {
|
|
1181
1562
|
const workbook = this._univerInstanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_SHEET);
|
|
1182
1563
|
if (!workbook) return false;
|
|
1183
1564
|
const worksheet = workbook.getActiveSheet();
|
|
1184
1565
|
if (!worksheet) return false;
|
|
1185
1566
|
return v.some((item) => item.unitId === workbook.getUnitId() && item.subUnitId === worksheet.getSheetId());
|
|
1186
|
-
})).subscribe(() => this._markDirtySkeleton()));
|
|
1567
|
+
})).subscribe((items) => this._markDirtySkeleton(items)));
|
|
1187
1568
|
}
|
|
1188
1569
|
_initViewModelInterceptor() {
|
|
1189
1570
|
this.disposeWithMe(this._sheetInterceptorService.intercept(INTERCEPTOR_POINT.CELL_CONTENT, {
|
|
@@ -1249,6 +1630,7 @@ let UniverSheetsConditionalFormattingMobileUIPlugin = class UniverSheetsConditio
|
|
|
1249
1630
|
AddAverageCfCommand,
|
|
1250
1631
|
AddColorScaleConditionalRuleCommand,
|
|
1251
1632
|
AddDataBarConditionalRuleCommand,
|
|
1633
|
+
AddIconSetConditionalRuleCommand,
|
|
1252
1634
|
AddDuplicateValuesCfCommand,
|
|
1253
1635
|
AddNumberCfCommand,
|
|
1254
1636
|
AddRankCfCommand,
|
|
@@ -1879,11 +2261,10 @@ const ColorPicker$1 = (props) => {
|
|
|
1879
2261
|
|
|
1880
2262
|
//#endregion
|
|
1881
2263
|
//#region src/views/Preview.tsx
|
|
1882
|
-
|
|
1883
|
-
const rule = props
|
|
1884
|
-
if (!rule) return null;
|
|
2264
|
+
function Preview(props) {
|
|
2265
|
+
const { rule } = props;
|
|
1885
2266
|
const colorList = useMemo(() => {
|
|
1886
|
-
if (rule.type === CFRuleType.colorScale) {
|
|
2267
|
+
if ((rule === null || rule === void 0 ? void 0 : rule.type) === CFRuleType.colorScale) {
|
|
1887
2268
|
const config = rule.config.map((c, index) => ({
|
|
1888
2269
|
color: new ColorKit(c.color),
|
|
1889
2270
|
value: index
|
|
@@ -1894,11 +2275,12 @@ const Preview = (props) => {
|
|
|
1894
2275
|
return null;
|
|
1895
2276
|
}, [rule]);
|
|
1896
2277
|
const iconSet = useMemo(() => {
|
|
1897
|
-
if (rule.type === CFRuleType.iconSet) return rule.config.map((item) => {
|
|
2278
|
+
if ((rule === null || rule === void 0 ? void 0 : rule.type) === CFRuleType.iconSet) return rule.config.map((item) => {
|
|
1898
2279
|
const iconList = iconMap[item.iconType];
|
|
1899
2280
|
return iconList && iconList[Number(item.iconId)];
|
|
1900
2281
|
});
|
|
1901
2282
|
}, [rule]);
|
|
2283
|
+
if (!rule) return null;
|
|
1902
2284
|
const previewClassName = "univer-pointer-events-none univer-flex univer-h-5 univer-min-w-[72px] univer-items-center univer-justify-center univer-text-xs";
|
|
1903
2285
|
switch (rule.type) {
|
|
1904
2286
|
case CFRuleType.dataBar: {
|
|
@@ -1964,7 +2346,7 @@ const Preview = (props) => {
|
|
|
1964
2346
|
});
|
|
1965
2347
|
}
|
|
1966
2348
|
}
|
|
1967
|
-
}
|
|
2349
|
+
}
|
|
1968
2350
|
|
|
1969
2351
|
//#endregion
|
|
1970
2352
|
//#region src/views/panel/rule-edit/styles.ts
|
|
@@ -1987,8 +2369,8 @@ const previewClassName = clsx("univer-mt-5 univer-px-1 univer-py-2 univer-rounde
|
|
|
1987
2369
|
|
|
1988
2370
|
//#endregion
|
|
1989
2371
|
//#region src/views/panel/rule-edit/ColorScale.tsx
|
|
1990
|
-
const createOptionItem$2 = (text
|
|
1991
|
-
label:
|
|
2372
|
+
const createOptionItem$2 = (text) => ({
|
|
2373
|
+
label: `sheets-conditional-formatting-ui.valueType.${text}`,
|
|
1992
2374
|
value: text
|
|
1993
2375
|
});
|
|
1994
2376
|
const TextInput$1 = (props) => {
|
|
@@ -2048,15 +2430,24 @@ const ColorScaleStyleEditor = (props) => {
|
|
|
2048
2430
|
const { interceptorManager } = props;
|
|
2049
2431
|
const localeService = useDependency(LocaleService);
|
|
2050
2432
|
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
|
|
2433
|
+
const commonOptionDefinitions = [
|
|
2434
|
+
createOptionItem$2(CFValueType.num),
|
|
2435
|
+
createOptionItem$2(CFValueType.percent),
|
|
2436
|
+
createOptionItem$2(CFValueType.percentile),
|
|
2437
|
+
createOptionItem$2(CFValueType.formula)
|
|
2056
2438
|
];
|
|
2057
|
-
const minOptions = [createOptionItem$2(CFValueType.min
|
|
2058
|
-
|
|
2059
|
-
|
|
2439
|
+
const minOptions = [createOptionItem$2(CFValueType.min), ...commonOptionDefinitions].map((option) => ({
|
|
2440
|
+
...option,
|
|
2441
|
+
label: localeService.t(option.label)
|
|
2442
|
+
}));
|
|
2443
|
+
const medianOptions = [createOptionItem$2("none"), ...commonOptionDefinitions].map((option) => ({
|
|
2444
|
+
...option,
|
|
2445
|
+
label: localeService.t(option.label)
|
|
2446
|
+
}));
|
|
2447
|
+
const maxOptions = [createOptionItem$2(CFValueType.max), ...commonOptionDefinitions].map((option) => ({
|
|
2448
|
+
...option,
|
|
2449
|
+
label: localeService.t(option.label)
|
|
2450
|
+
}));
|
|
2060
2451
|
const [minType, setMinType] = useState(() => {
|
|
2061
2452
|
var _rule$config$;
|
|
2062
2453
|
const defaultV = CFValueType.min;
|
|
@@ -2202,7 +2593,7 @@ const ColorScaleStyleEditor = (props) => {
|
|
|
2202
2593
|
children: localeService.t("sheets-conditional-formatting-ui.valueType.min")
|
|
2203
2594
|
}),
|
|
2204
2595
|
/* @__PURE__ */ jsxs("div", {
|
|
2205
|
-
className: "univer-mt-3 univer-flex univer-h-8 univer-items-center",
|
|
2596
|
+
className: "univer-mt-3 univer-flex univer-h-8 univer-items-center univer-gap-2",
|
|
2206
2597
|
children: [
|
|
2207
2598
|
/* @__PURE__ */ jsx(Select, {
|
|
2208
2599
|
className: "univer-flex-shrink-0",
|
|
@@ -2270,7 +2661,7 @@ const ColorScaleStyleEditor = (props) => {
|
|
|
2270
2661
|
children: localeService.t("sheets-conditional-formatting-ui.panel.medianValue")
|
|
2271
2662
|
}),
|
|
2272
2663
|
/* @__PURE__ */ jsxs("div", {
|
|
2273
|
-
className: "univer-mt-3 univer-flex univer-h-8 univer-items-center",
|
|
2664
|
+
className: "univer-mt-3 univer-flex univer-h-8 univer-items-center univer-gap-2",
|
|
2274
2665
|
children: [
|
|
2275
2666
|
/* @__PURE__ */ jsx(Select, {
|
|
2276
2667
|
className: "univer-flex-shrink-0",
|
|
@@ -2338,7 +2729,7 @@ const ColorScaleStyleEditor = (props) => {
|
|
|
2338
2729
|
children: localeService.t("sheets-conditional-formatting-ui.valueType.max")
|
|
2339
2730
|
}),
|
|
2340
2731
|
/* @__PURE__ */ jsxs("div", {
|
|
2341
|
-
className: "univer-mt-3 univer-flex univer-h-8 univer-items-center",
|
|
2732
|
+
className: "univer-mt-3 univer-flex univer-h-8 univer-items-center univer-gap-2",
|
|
2342
2733
|
children: [
|
|
2343
2734
|
/* @__PURE__ */ jsx(Select, {
|
|
2344
2735
|
className: "univer-flex-shrink-0",
|
|
@@ -2363,7 +2754,6 @@ const ColorScaleStyleEditor = (props) => {
|
|
|
2363
2754
|
}),
|
|
2364
2755
|
/* @__PURE__ */ jsx(TextInput$1, {
|
|
2365
2756
|
id: "max",
|
|
2366
|
-
className: "univer-ml-1",
|
|
2367
2757
|
value: maxValue,
|
|
2368
2758
|
type: maxType,
|
|
2369
2759
|
onChange: (v) => {
|
|
@@ -2382,7 +2772,6 @@ const ColorScaleStyleEditor = (props) => {
|
|
|
2382
2772
|
}
|
|
2383
2773
|
}),
|
|
2384
2774
|
/* @__PURE__ */ jsx(ColorPicker$1, {
|
|
2385
|
-
className: "univer-ml-1",
|
|
2386
2775
|
color: maxColor,
|
|
2387
2776
|
onChange: (v) => {
|
|
2388
2777
|
setMaxColor(v);
|
|
@@ -2406,8 +2795,8 @@ const ColorScaleStyleEditor = (props) => {
|
|
|
2406
2795
|
|
|
2407
2796
|
//#endregion
|
|
2408
2797
|
//#region src/views/panel/rule-edit/DataBar.tsx
|
|
2409
|
-
const createOptionItem$1 = (text
|
|
2410
|
-
label:
|
|
2798
|
+
const createOptionItem$1 = (text) => ({
|
|
2799
|
+
label: `sheets-conditional-formatting-ui.valueType.${text}`,
|
|
2411
2800
|
value: text
|
|
2412
2801
|
});
|
|
2413
2802
|
const InputText = (props) => {
|
|
@@ -2436,7 +2825,7 @@ const InputText = (props) => {
|
|
|
2436
2825
|
if (type === CFValueType.formula) {
|
|
2437
2826
|
const v = String(_value.current).startsWith("=") ? String(_value.current) || "" : "=";
|
|
2438
2827
|
return /* @__PURE__ */ jsx("div", {
|
|
2439
|
-
className: "univer-
|
|
2828
|
+
className: "univer-w-full",
|
|
2440
2829
|
children: /* @__PURE__ */ jsx(FormulaEditor, {
|
|
2441
2830
|
ref: formulaEditorRef,
|
|
2442
2831
|
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 +2871,20 @@ const DataBarStyleEditor = (props) => {
|
|
|
2482
2871
|
if (!rule) return defaultDataBarNativeColor;
|
|
2483
2872
|
return ((_rule$config3 = rule.config) === null || _rule$config3 === void 0 ? void 0 : _rule$config3.nativeColor) || defaultDataBarNativeColor;
|
|
2484
2873
|
});
|
|
2485
|
-
const
|
|
2486
|
-
createOptionItem$1(CFValueType.num
|
|
2487
|
-
createOptionItem$1(CFValueType.percent
|
|
2488
|
-
createOptionItem$1(CFValueType.percentile
|
|
2489
|
-
createOptionItem$1(CFValueType.formula
|
|
2874
|
+
const commonOptionDefinitions = [
|
|
2875
|
+
createOptionItem$1(CFValueType.num),
|
|
2876
|
+
createOptionItem$1(CFValueType.percent),
|
|
2877
|
+
createOptionItem$1(CFValueType.percentile),
|
|
2878
|
+
createOptionItem$1(CFValueType.formula)
|
|
2490
2879
|
];
|
|
2491
|
-
const minOptions = [createOptionItem$1(CFValueType.min
|
|
2492
|
-
|
|
2880
|
+
const minOptions = [createOptionItem$1(CFValueType.min), ...commonOptionDefinitions].map((option) => ({
|
|
2881
|
+
...option,
|
|
2882
|
+
label: localeService.t(option.label)
|
|
2883
|
+
}));
|
|
2884
|
+
const maxOptions = [createOptionItem$1(CFValueType.max), ...commonOptionDefinitions].map((option) => ({
|
|
2885
|
+
...option,
|
|
2886
|
+
label: localeService.t(option.label)
|
|
2887
|
+
}));
|
|
2493
2888
|
const [minValueType, setMinValueType] = useState(() => {
|
|
2494
2889
|
var _rule$config4;
|
|
2495
2890
|
const defaultV = minOptions[0].value;
|
|
@@ -2596,7 +2991,7 @@ const DataBarStyleEditor = (props) => {
|
|
|
2596
2991
|
});
|
|
2597
2992
|
};
|
|
2598
2993
|
const isShowInput = (type) => {
|
|
2599
|
-
return
|
|
2994
|
+
return commonOptionDefinitions.map((item) => item.value).includes(type);
|
|
2600
2995
|
};
|
|
2601
2996
|
return /* @__PURE__ */ jsxs("div", { children: [
|
|
2602
2997
|
/* @__PURE__ */ jsx("div", {
|
|
@@ -2620,7 +3015,7 @@ const DataBarStyleEditor = (props) => {
|
|
|
2620
3015
|
className: "univer-mt-3 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",
|
|
2621
3016
|
children: localeService.t("sheets-conditional-formatting-ui.panel.fillType")
|
|
2622
3017
|
}), /* @__PURE__ */ jsxs("div", {
|
|
2623
|
-
className: "univer-
|
|
3018
|
+
className: "univer-mt-3 univer-flex univer-items-center univer-gap-3",
|
|
2624
3019
|
children: [/* @__PURE__ */ jsxs(RadioGroup, {
|
|
2625
3020
|
value: isGradient,
|
|
2626
3021
|
onChange: (v) => {
|
|
@@ -2650,7 +3045,7 @@ const DataBarStyleEditor = (props) => {
|
|
|
2650
3045
|
})
|
|
2651
3046
|
})]
|
|
2652
3047
|
}), /* @__PURE__ */ jsxs("div", {
|
|
2653
|
-
className: "univer-
|
|
3048
|
+
className: "univer-flex univer-items-center univer-text-xs",
|
|
2654
3049
|
children: [/* @__PURE__ */ jsx(Checkbox, {
|
|
2655
3050
|
checked: !isShowValue,
|
|
2656
3051
|
onChange: (v) => {
|
|
@@ -2673,7 +3068,7 @@ const DataBarStyleEditor = (props) => {
|
|
|
2673
3068
|
className: "univer-mt-3 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",
|
|
2674
3069
|
children: localeService.t("sheets-conditional-formatting-ui.panel.colorSet")
|
|
2675
3070
|
}), /* @__PURE__ */ jsxs("div", {
|
|
2676
|
-
className: "univer-
|
|
3071
|
+
className: "univer-mt-3 univer-flex univer-items-center univer-gap-2",
|
|
2677
3072
|
children: [/* @__PURE__ */ jsxs("div", {
|
|
2678
3073
|
className: "univer-flex univer-items-center",
|
|
2679
3074
|
children: [/* @__PURE__ */ jsx("div", {
|
|
@@ -2684,7 +3079,7 @@ const DataBarStyleEditor = (props) => {
|
|
|
2684
3079
|
onChange: handleNativeColorChange
|
|
2685
3080
|
})]
|
|
2686
3081
|
}), /* @__PURE__ */ jsxs("div", {
|
|
2687
|
-
className: "univer-
|
|
3082
|
+
className: "univer-flex univer-items-center univer-gap-3",
|
|
2688
3083
|
children: [/* @__PURE__ */ jsx("div", {
|
|
2689
3084
|
className: "univer-text-xs",
|
|
2690
3085
|
children: localeService.t("sheets-conditional-formatting-ui.panel.positive")
|
|
@@ -2700,7 +3095,7 @@ const DataBarStyleEditor = (props) => {
|
|
|
2700
3095
|
children: localeService.t("sheets-conditional-formatting-ui.valueType.min")
|
|
2701
3096
|
}),
|
|
2702
3097
|
/* @__PURE__ */ jsxs("div", {
|
|
2703
|
-
className: "univer-mt-3 univer-flex univer-items-center",
|
|
3098
|
+
className: "univer-mt-3 univer-flex univer-items-center univer-gap-2",
|
|
2704
3099
|
children: [/* @__PURE__ */ jsx(Select, {
|
|
2705
3100
|
className: "univer-w-1/2 univer-flex-shrink-0",
|
|
2706
3101
|
options: minOptions,
|
|
@@ -2722,7 +3117,6 @@ const DataBarStyleEditor = (props) => {
|
|
|
2722
3117
|
}
|
|
2723
3118
|
}), /* @__PURE__ */ jsx(InputText, {
|
|
2724
3119
|
id: "min",
|
|
2725
|
-
className: "univer-ml-3",
|
|
2726
3120
|
disabled: !isShowInput(minValueType),
|
|
2727
3121
|
type: minValueType,
|
|
2728
3122
|
value: minValue,
|
|
@@ -2746,7 +3140,7 @@ const DataBarStyleEditor = (props) => {
|
|
|
2746
3140
|
children: localeService.t("sheets-conditional-formatting-ui.valueType.max")
|
|
2747
3141
|
}),
|
|
2748
3142
|
/* @__PURE__ */ jsxs("div", {
|
|
2749
|
-
className: "univer-mt-3 univer-flex univer-items-center",
|
|
3143
|
+
className: "univer-mt-3 univer-flex univer-items-center univer-gap-2",
|
|
2750
3144
|
children: [/* @__PURE__ */ jsx(Select, {
|
|
2751
3145
|
className: "univer-w-1/2 univer-flex-shrink-0",
|
|
2752
3146
|
options: maxOptions,
|
|
@@ -2767,7 +3161,6 @@ const DataBarStyleEditor = (props) => {
|
|
|
2767
3161
|
});
|
|
2768
3162
|
}
|
|
2769
3163
|
}), /* @__PURE__ */ jsx(InputText, {
|
|
2770
|
-
className: "univer-ml-3",
|
|
2771
3164
|
disabled: !isShowInput(maxValueType),
|
|
2772
3165
|
id: "max",
|
|
2773
3166
|
type: maxValueType,
|
|
@@ -3013,8 +3406,14 @@ const WrapperError = (props) => {
|
|
|
3013
3406
|
|
|
3014
3407
|
//#endregion
|
|
3015
3408
|
//#region src/views/panel/rule-edit/HighlightCell.tsx
|
|
3016
|
-
const
|
|
3017
|
-
|
|
3409
|
+
const textOperators = new Set(Object.values(CFTextOperator));
|
|
3410
|
+
const numberOperators = new Set(Object.values(CFNumberOperator));
|
|
3411
|
+
const timePeriodOperators = new Set(Object.values(CFTimePeriodOperator));
|
|
3412
|
+
const isTextOperator = (value) => typeof value === "string" && textOperators.has(value);
|
|
3413
|
+
const isNumberOperator = (value) => typeof value === "string" && numberOperators.has(value);
|
|
3414
|
+
const isTimePeriodOperator = (value) => typeof value === "string" && timePeriodOperators.has(value);
|
|
3415
|
+
const createOptionItem = (text) => ({
|
|
3416
|
+
label: `sheets-conditional-formatting-ui.operator.${text}`,
|
|
3018
3417
|
value: text
|
|
3019
3418
|
});
|
|
3020
3419
|
function HighlightCellInput(props) {
|
|
@@ -3175,42 +3574,43 @@ function HighlightCellInput(props) {
|
|
|
3175
3574
|
}
|
|
3176
3575
|
return null;
|
|
3177
3576
|
}
|
|
3178
|
-
const getOperatorOptions = (type
|
|
3577
|
+
const getOperatorOptions = (type) => {
|
|
3179
3578
|
switch (type) {
|
|
3180
3579
|
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
|
|
3580
|
+
createOptionItem(CFTextOperator.containsText),
|
|
3581
|
+
createOptionItem(CFTextOperator.notContainsText),
|
|
3582
|
+
createOptionItem(CFTextOperator.beginsWith),
|
|
3583
|
+
createOptionItem(CFTextOperator.endsWith),
|
|
3584
|
+
createOptionItem(CFTextOperator.equal),
|
|
3585
|
+
createOptionItem(CFTextOperator.notEqual),
|
|
3586
|
+
createOptionItem(CFTextOperator.containsBlanks),
|
|
3587
|
+
createOptionItem(CFTextOperator.notContainsBlanks),
|
|
3588
|
+
createOptionItem(CFTextOperator.containsErrors),
|
|
3589
|
+
createOptionItem(CFTextOperator.notContainsErrors)
|
|
3191
3590
|
];
|
|
3192
3591
|
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
|
|
3592
|
+
createOptionItem(CFNumberOperator.between),
|
|
3593
|
+
createOptionItem(CFNumberOperator.notBetween),
|
|
3594
|
+
createOptionItem(CFNumberOperator.equal),
|
|
3595
|
+
createOptionItem(CFNumberOperator.notEqual),
|
|
3596
|
+
createOptionItem(CFNumberOperator.greaterThan),
|
|
3597
|
+
createOptionItem(CFNumberOperator.greaterThanOrEqual),
|
|
3598
|
+
createOptionItem(CFNumberOperator.lessThan),
|
|
3599
|
+
createOptionItem(CFNumberOperator.lessThanOrEqual)
|
|
3201
3600
|
];
|
|
3202
3601
|
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
|
|
3602
|
+
createOptionItem(CFTimePeriodOperator.yesterday),
|
|
3603
|
+
createOptionItem(CFTimePeriodOperator.today),
|
|
3604
|
+
createOptionItem(CFTimePeriodOperator.tomorrow),
|
|
3605
|
+
createOptionItem(CFTimePeriodOperator.last7Days),
|
|
3606
|
+
createOptionItem(CFTimePeriodOperator.lastWeek),
|
|
3607
|
+
createOptionItem(CFTimePeriodOperator.thisWeek),
|
|
3608
|
+
createOptionItem(CFTimePeriodOperator.nextWeek),
|
|
3609
|
+
createOptionItem(CFTimePeriodOperator.lastMonth),
|
|
3610
|
+
createOptionItem(CFTimePeriodOperator.thisMonth),
|
|
3611
|
+
createOptionItem(CFTimePeriodOperator.nextMonth)
|
|
3213
3612
|
];
|
|
3613
|
+
default: return [];
|
|
3214
3614
|
}
|
|
3215
3615
|
};
|
|
3216
3616
|
const HighlightCellStyleEditor = (props) => {
|
|
@@ -3245,77 +3645,74 @@ const HighlightCellStyleEditor = (props) => {
|
|
|
3245
3645
|
label: localeService.t("sheets-conditional-formatting-ui.subRuleType.uniqueValues")
|
|
3246
3646
|
}
|
|
3247
3647
|
];
|
|
3248
|
-
const operatorOptions = useMemo(() => getOperatorOptions(subType
|
|
3648
|
+
const operatorOptions = useMemo(() => getOperatorOptions(subType).map((option) => ({
|
|
3649
|
+
...option,
|
|
3650
|
+
label: localeService.t(option.label)
|
|
3651
|
+
})), [localeService, subType]);
|
|
3249
3652
|
const [operator, setOperator] = useState(() => {
|
|
3250
|
-
|
|
3653
|
+
var _operatorOptions$;
|
|
3654
|
+
const defaultV = (_operatorOptions$ = operatorOptions[0]) === null || _operatorOptions$ === void 0 ? void 0 : _operatorOptions$.value;
|
|
3251
3655
|
if (!rule) return defaultV;
|
|
3252
|
-
return rule.operator
|
|
3656
|
+
return "operator" in rule ? rule.operator : defaultV;
|
|
3253
3657
|
});
|
|
3254
3658
|
const [value, setValue] = useState(() => {
|
|
3255
|
-
var _value2;
|
|
3256
3659
|
const defaultV = "";
|
|
3257
3660
|
if (!rule) return defaultV;
|
|
3258
|
-
|
|
3661
|
+
if ("value" in rule && rule.value !== void 0) return rule.value;
|
|
3662
|
+
return "operator" in rule ? createDefaultValue(rule.subType, rule.operator) : defaultV;
|
|
3259
3663
|
});
|
|
3260
3664
|
const [style, setStyle] = useState({});
|
|
3261
3665
|
const getResult = useMemo(() => (option) => {
|
|
3262
|
-
var _option$
|
|
3263
|
-
|
|
3264
|
-
|
|
3265
|
-
|
|
3266
|
-
|
|
3267
|
-
|
|
3268
|
-
|
|
3269
|
-
|
|
3270
|
-
|
|
3271
|
-
|
|
3272
|
-
|
|
3273
|
-
|
|
3274
|
-
|
|
3275
|
-
|
|
3276
|
-
|
|
3277
|
-
|
|
3278
|
-
|
|
3279
|
-
|
|
3280
|
-
|
|
3281
|
-
|
|
3282
|
-
|
|
3283
|
-
|
|
3284
|
-
|
|
3285
|
-
|
|
3286
|
-
|
|
3287
|
-
|
|
3288
|
-
|
|
3289
|
-
|
|
3290
|
-
|
|
3291
|
-
|
|
3292
|
-
|
|
3293
|
-
|
|
3294
|
-
|
|
3295
|
-
subType: (_option$subType2 = option.subType) !== null && _option$subType2 !== void 0 ? _option$subType2 : subType,
|
|
3296
|
-
operator: (_option$operator2 = option.operator) !== null && _option$operator2 !== void 0 ? _option$operator2 : operator,
|
|
3297
|
-
style: (_option$style2 = option.style) !== null && _option$style2 !== void 0 ? _option$style2 : style,
|
|
3298
|
-
value: (_option$value2 = option.value) !== null && _option$value2 !== void 0 ? _option$value2 : value
|
|
3299
|
-
};
|
|
3300
|
-
}
|
|
3301
|
-
if ([CFNumberOperator.between, CFNumberOperator.notBetween].includes(operator)) {
|
|
3302
|
-
var _option$subType3, _option$operator3, _option$style3, _option$value3;
|
|
3666
|
+
var _option$subType, _option$operator, _option$value, _option$style;
|
|
3667
|
+
const nextSubType = (_option$subType = option.subType) !== null && _option$subType !== void 0 ? _option$subType : subType;
|
|
3668
|
+
const nextOperator = (_option$operator = option.operator) !== null && _option$operator !== void 0 ? _option$operator : operator;
|
|
3669
|
+
const nextValue = (_option$value = option.value) !== null && _option$value !== void 0 ? _option$value : value;
|
|
3670
|
+
const nextStyle = (_option$style = option.style) !== null && _option$style !== void 0 ? _option$style : style;
|
|
3671
|
+
switch (nextSubType) {
|
|
3672
|
+
case CFSubRuleType.duplicateValues: return {
|
|
3673
|
+
type: CFRuleType.highlightCell,
|
|
3674
|
+
subType: CFSubRuleType.duplicateValues,
|
|
3675
|
+
style: nextStyle
|
|
3676
|
+
};
|
|
3677
|
+
case CFSubRuleType.uniqueValues: return {
|
|
3678
|
+
type: CFRuleType.highlightCell,
|
|
3679
|
+
subType: CFSubRuleType.uniqueValues,
|
|
3680
|
+
style: nextStyle
|
|
3681
|
+
};
|
|
3682
|
+
case CFSubRuleType.text: return {
|
|
3683
|
+
type: CFRuleType.highlightCell,
|
|
3684
|
+
subType: CFSubRuleType.text,
|
|
3685
|
+
operator: isTextOperator(nextOperator) ? nextOperator : CFTextOperator.containsText,
|
|
3686
|
+
style: nextStyle,
|
|
3687
|
+
value: typeof nextValue === "string" ? nextValue : void 0
|
|
3688
|
+
};
|
|
3689
|
+
case CFSubRuleType.timePeriod: return {
|
|
3690
|
+
type: CFRuleType.highlightCell,
|
|
3691
|
+
subType: CFSubRuleType.timePeriod,
|
|
3692
|
+
operator: isTimePeriodOperator(nextOperator) ? nextOperator : CFTimePeriodOperator.today,
|
|
3693
|
+
style: nextStyle
|
|
3694
|
+
};
|
|
3695
|
+
case CFSubRuleType.number: {
|
|
3696
|
+
const numberOperator = isNumberOperator(nextOperator) ? nextOperator : CFNumberOperator.equal;
|
|
3697
|
+
if (numberOperator === CFNumberOperator.between || numberOperator === CFNumberOperator.notBetween) {
|
|
3698
|
+
const range = Array.isArray(nextValue) ? nextValue : [0, 100];
|
|
3303
3699
|
return {
|
|
3304
3700
|
type: CFRuleType.highlightCell,
|
|
3305
|
-
subType:
|
|
3306
|
-
operator:
|
|
3307
|
-
style:
|
|
3308
|
-
value:
|
|
3701
|
+
subType: CFSubRuleType.number,
|
|
3702
|
+
operator: numberOperator,
|
|
3703
|
+
style: nextStyle,
|
|
3704
|
+
value: range
|
|
3309
3705
|
};
|
|
3310
3706
|
}
|
|
3311
|
-
|
|
3707
|
+
return {
|
|
3708
|
+
type: CFRuleType.highlightCell,
|
|
3709
|
+
subType: CFSubRuleType.number,
|
|
3710
|
+
operator: numberOperator,
|
|
3711
|
+
style: nextStyle,
|
|
3712
|
+
value: typeof nextValue === "number" ? nextValue : void 0
|
|
3713
|
+
};
|
|
3714
|
+
}
|
|
3312
3715
|
}
|
|
3313
|
-
return {
|
|
3314
|
-
type: CFRuleType.highlightCell,
|
|
3315
|
-
subType: (_option$subType4 = option.subType) !== null && _option$subType4 !== void 0 ? _option$subType4 : subType,
|
|
3316
|
-
operator: (_option$operator4 = option.operator) !== null && _option$operator4 !== void 0 ? _option$operator4 : operator,
|
|
3317
|
-
style: (_option$style4 = option.style) !== null && _option$style4 !== void 0 ? _option$style4 : style
|
|
3318
|
-
};
|
|
3319
3716
|
}, [
|
|
3320
3717
|
subType,
|
|
3321
3718
|
operator,
|
|
@@ -3331,9 +3728,13 @@ const HighlightCellStyleEditor = (props) => {
|
|
|
3331
3728
|
if (!typeOptions.some((item) => item.value === subType)) setSubType(typeOptions[0].value);
|
|
3332
3729
|
}, [typeOptions]);
|
|
3333
3730
|
const onTypeChange = (v) => {
|
|
3334
|
-
|
|
3335
|
-
const
|
|
3336
|
-
|
|
3731
|
+
var _typeOptions$find, _operatorList$;
|
|
3732
|
+
const _subType = (_typeOptions$find = typeOptions.find((item) => item.value === v)) === null || _typeOptions$find === void 0 ? void 0 : _typeOptions$find.value;
|
|
3733
|
+
if (!_subType) return;
|
|
3734
|
+
const _operator = (_operatorList$ = getOperatorOptions(_subType).map((option) => ({
|
|
3735
|
+
...option,
|
|
3736
|
+
label: localeService.t(option.label)
|
|
3737
|
+
}))[0]) === null || _operatorList$ === void 0 ? void 0 : _operatorList$.value;
|
|
3337
3738
|
setSubType(_subType);
|
|
3338
3739
|
setOperator(_operator);
|
|
3339
3740
|
_operator && setValue(createDefaultValue(_subType, _operator));
|
|
@@ -3343,7 +3744,9 @@ const HighlightCellStyleEditor = (props) => {
|
|
|
3343
3744
|
}));
|
|
3344
3745
|
};
|
|
3345
3746
|
const onOperatorChange = (v) => {
|
|
3346
|
-
|
|
3747
|
+
var _operatorOptions$find;
|
|
3748
|
+
const _operator = (_operatorOptions$find = operatorOptions.find((item) => item.value === v)) === null || _operatorOptions$find === void 0 ? void 0 : _operatorOptions$find.value;
|
|
3749
|
+
if (!_operator) return;
|
|
3347
3750
|
setOperator(_operator);
|
|
3348
3751
|
onChange(getResult({ operator: _operator }));
|
|
3349
3752
|
};
|
|
@@ -3351,9 +3754,6 @@ const HighlightCellStyleEditor = (props) => {
|
|
|
3351
3754
|
setValue(value);
|
|
3352
3755
|
onChange(getResult({ value }));
|
|
3353
3756
|
};
|
|
3354
|
-
const inputRenderKey = useMemo(() => {
|
|
3355
|
-
return `${subType}_${operator}_${Math.random()}`;
|
|
3356
|
-
}, [subType, operator]);
|
|
3357
3757
|
return /* @__PURE__ */ jsxs("div", { children: [
|
|
3358
3758
|
/* @__PURE__ */ jsx("div", {
|
|
3359
3759
|
className: "univer-mt-4 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",
|
|
@@ -3380,7 +3780,7 @@ const HighlightCellStyleEditor = (props) => {
|
|
|
3380
3780
|
operator,
|
|
3381
3781
|
rule,
|
|
3382
3782
|
onChange: onInputChange
|
|
3383
|
-
},
|
|
3783
|
+
}, `${subType}_${operator}`),
|
|
3384
3784
|
/* @__PURE__ */ jsx("div", {
|
|
3385
3785
|
className: previewClassName,
|
|
3386
3786
|
children: /* @__PURE__ */ jsx(Preview, { rule: getResult({}) })
|
|
@@ -3448,32 +3848,34 @@ const createDefaultConfigItem = (iconType, index, list) => ({
|
|
|
3448
3848
|
iconType,
|
|
3449
3849
|
iconId: String(index)
|
|
3450
3850
|
});
|
|
3451
|
-
const IconGroupList =
|
|
3452
|
-
const { onClick } = props;
|
|
3851
|
+
const IconGroupList = (props) => {
|
|
3852
|
+
const { iconType, onClick } = props;
|
|
3453
3853
|
const localeService = useDependency(LocaleService);
|
|
3454
|
-
const handleClick = (iconType) => {
|
|
3455
|
-
onClick(iconType);
|
|
3456
|
-
};
|
|
3457
3854
|
return /* @__PURE__ */ jsx("div", {
|
|
3458
|
-
|
|
3855
|
+
dir: useObservable(localeService.direction$, localeService.getDirection()),
|
|
3459
3856
|
className: "univer-w-80",
|
|
3460
|
-
children: iconGroup.map((group
|
|
3857
|
+
children: iconGroup.map((group) => {
|
|
3461
3858
|
return /* @__PURE__ */ jsxs("div", {
|
|
3462
|
-
className: "univer-mb-
|
|
3859
|
+
className: "univer-mb-4 last:univer-mb-0",
|
|
3463
3860
|
children: [/* @__PURE__ */ jsx("div", {
|
|
3464
|
-
className: "univer-mb-1 univer-text-
|
|
3861
|
+
className: "univer-mb-2 univer-px-1 univer-text-xs univer-font-medium univer-text-gray-500 dark:!univer-text-gray-400",
|
|
3465
3862
|
children: localeService.t(group.title)
|
|
3466
3863
|
}), /* @__PURE__ */ jsx("div", {
|
|
3467
|
-
className: "univer-
|
|
3468
|
-
children: group.group.map((groupItem) => {
|
|
3469
|
-
|
|
3470
|
-
|
|
3864
|
+
className: "univer-grid univer-grid-cols-2 univer-gap-1",
|
|
3865
|
+
children: group.group.map((groupItem, groupItemIndex) => {
|
|
3866
|
+
const selected = groupItem.name === iconType;
|
|
3867
|
+
return /* @__PURE__ */ jsx("button", {
|
|
3868
|
+
type: "button",
|
|
3869
|
+
"aria-label": `${localeService.t(group.title)} ${groupItemIndex + 1}`,
|
|
3870
|
+
"aria-pressed": selected,
|
|
3871
|
+
className: clsx("univer-flex univer-h-8 univer-w-full univer-cursor-pointer univer-items-center univer-rounded-md univer-border-0 univer-bg-transparent univer-px-2 univer-outline-none univer-transition-colors focus-visible:univer-ring-2 focus-visible:univer-ring-primary-600 rtl:univer-flex-row-reverse", selected ? "univer-bg-primary-50 univer-ring-1 univer-ring-primary-600 dark:!univer-bg-primary-900" : "hover:univer-bg-gray-100 dark:hover:!univer-bg-gray-700"),
|
|
3471
3872
|
onClick: () => {
|
|
3472
|
-
|
|
3873
|
+
onClick(groupItem.name);
|
|
3473
3874
|
},
|
|
3474
|
-
children: /* @__PURE__ */ jsx("
|
|
3475
|
-
className: "univer-flex univer-
|
|
3875
|
+
children: /* @__PURE__ */ jsx("span", {
|
|
3876
|
+
className: "univer-flex univer-items-center univer-gap-0.5",
|
|
3476
3877
|
children: groupItem.list.map((base64, index) => /* @__PURE__ */ jsx("img", {
|
|
3878
|
+
alt: "",
|
|
3477
3879
|
className: "univer-size-5",
|
|
3478
3880
|
src: base64,
|
|
3479
3881
|
draggable: false
|
|
@@ -3482,12 +3884,14 @@ const IconGroupList = forwardRef((props, ref) => {
|
|
|
3482
3884
|
}, groupItem.name);
|
|
3483
3885
|
})
|
|
3484
3886
|
})]
|
|
3485
|
-
},
|
|
3887
|
+
}, group.title);
|
|
3486
3888
|
})
|
|
3487
3889
|
});
|
|
3488
|
-
}
|
|
3890
|
+
};
|
|
3489
3891
|
const IconItemList = (props) => {
|
|
3490
3892
|
const { onClick } = props;
|
|
3893
|
+
const localeService = useDependency(LocaleService);
|
|
3894
|
+
const direction = useObservable(localeService.direction$, localeService.getDirection());
|
|
3491
3895
|
const list = useMemo(() => {
|
|
3492
3896
|
const result = [];
|
|
3493
3897
|
for (const key in iconMap) {
|
|
@@ -3505,29 +3909,30 @@ const IconItemList = (props) => {
|
|
|
3505
3909
|
const handleClick = (item) => {
|
|
3506
3910
|
onClick(item.iconType, item.iconId);
|
|
3507
3911
|
};
|
|
3508
|
-
return /* @__PURE__ */ jsxs("div", {
|
|
3509
|
-
|
|
3510
|
-
|
|
3511
|
-
|
|
3512
|
-
|
|
3513
|
-
|
|
3514
|
-
|
|
3515
|
-
|
|
3516
|
-
|
|
3517
|
-
|
|
3912
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
3913
|
+
dir: direction,
|
|
3914
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
3915
|
+
"data-u-comp": "cf-icon-set-no-icon-option",
|
|
3916
|
+
className: "univer-mb-2.5 univer-flex univer-cursor-pointer univer-items-center univer-gap-2 univer-text-sm",
|
|
3917
|
+
onClick: () => handleClick({
|
|
3918
|
+
iconType: IIconSetType.empty,
|
|
3919
|
+
iconId: "",
|
|
3920
|
+
base64: ""
|
|
3921
|
+
}),
|
|
3922
|
+
children: localeService.t("sheets-conditional-formatting-ui.iconSet.noCellIcon")
|
|
3923
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
3924
|
+
className: "univer-flex univer-w-64 univer-flex-wrap univer-gap-2",
|
|
3925
|
+
children: list.map((item) => /* @__PURE__ */ jsx("div", {
|
|
3926
|
+
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",
|
|
3927
|
+
children: /* @__PURE__ */ jsx("img", {
|
|
3928
|
+
className: "univer-size-5",
|
|
3929
|
+
src: item.base64,
|
|
3930
|
+
draggable: false,
|
|
3931
|
+
onClick: () => handleClick(item)
|
|
3932
|
+
})
|
|
3933
|
+
}, `${item.iconType}_${item.iconId}`))
|
|
3518
3934
|
})]
|
|
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
|
-
})] });
|
|
3935
|
+
});
|
|
3531
3936
|
};
|
|
3532
3937
|
const IconSetRuleEdit = (props) => {
|
|
3533
3938
|
const { onChange, configList, errorMap = {} } = props;
|
|
@@ -3615,7 +4020,8 @@ const IconSetRuleEdit = (props) => {
|
|
|
3615
4020
|
})]
|
|
3616
4021
|
}),
|
|
3617
4022
|
/* @__PURE__ */ jsxs("div", {
|
|
3618
|
-
|
|
4023
|
+
"data-u-comp": "cf-icon-set-rule-grid",
|
|
4024
|
+
className: "univer-mt-3 univer-grid univer-grid-cols-2 univer-gap-4 rtl:univer-grid-flow-dense",
|
|
3619
4025
|
children: [/* @__PURE__ */ jsx("div", {
|
|
3620
4026
|
className: "univer-flex univer-items-center",
|
|
3621
4027
|
children: /* @__PURE__ */ jsx(Dropdown, {
|
|
@@ -3633,7 +4039,7 @@ const IconSetRuleEdit = (props) => {
|
|
|
3633
4039
|
src: icon,
|
|
3634
4040
|
className: "univer-size-4",
|
|
3635
4041
|
draggable: false
|
|
3636
|
-
}) : /* @__PURE__ */ jsx(SlashDoubleIcon, {
|
|
4042
|
+
}) : /* @__PURE__ */ jsx(SlashDoubleIcon, {}), /* @__PURE__ */ jsx(MoreDownIcon, {})]
|
|
3637
4043
|
})
|
|
3638
4044
|
})
|
|
3639
4045
|
}), !isEnd ? /* @__PURE__ */ jsx(Select, {
|
|
@@ -3686,6 +4092,7 @@ const IconSet = (props) => {
|
|
|
3686
4092
|
const { interceptorManager } = props;
|
|
3687
4093
|
const rule = ((_props$rule = props.rule) === null || _props$rule === void 0 ? void 0 : _props$rule.type) === CFRuleType.iconSet ? props.rule : void 0;
|
|
3688
4094
|
const localeService = useDependency(LocaleService);
|
|
4095
|
+
const direction = useObservable(localeService.direction$, localeService.getDirection());
|
|
3689
4096
|
const [errorMap, setErrorMap] = useState({});
|
|
3690
4097
|
const [currentIconType, setCurrentIconType] = useState(() => {
|
|
3691
4098
|
const defaultV = Object.keys(iconMap)[0];
|
|
@@ -3717,7 +4124,8 @@ const IconSet = (props) => {
|
|
|
3717
4124
|
});
|
|
3718
4125
|
const previewIcon = useMemo(() => {
|
|
3719
4126
|
return /* @__PURE__ */ jsx("div", {
|
|
3720
|
-
|
|
4127
|
+
"data-u-comp": "cf-icon-set-preview",
|
|
4128
|
+
className: "univer-flex univer-items-center rtl:univer-flex-row-reverse",
|
|
3721
4129
|
children: configList.map((item) => {
|
|
3722
4130
|
return getIcon(item.iconType, item.iconId);
|
|
3723
4131
|
}).map((icon, index) => icon ? /* @__PURE__ */ jsx("img", {
|
|
@@ -3817,54 +4225,55 @@ const IconSet = (props) => {
|
|
|
3817
4225
|
});
|
|
3818
4226
|
setConfigList([...configList]);
|
|
3819
4227
|
};
|
|
3820
|
-
|
|
3821
|
-
|
|
3822
|
-
|
|
3823
|
-
|
|
3824
|
-
|
|
3825
|
-
|
|
3826
|
-
|
|
3827
|
-
|
|
3828
|
-
|
|
3829
|
-
|
|
3830
|
-
|
|
3831
|
-
|
|
3832
|
-
|
|
3833
|
-
|
|
3834
|
-
|
|
3835
|
-
|
|
3836
|
-
|
|
3837
|
-
|
|
3838
|
-
|
|
4228
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
4229
|
+
"data-u-comp": "cf-icon-set-editor",
|
|
4230
|
+
dir: direction,
|
|
4231
|
+
children: [
|
|
4232
|
+
/* @__PURE__ */ jsx("div", {
|
|
4233
|
+
className: "univer-mt-4 univer-text-sm univer-text-gray-600",
|
|
4234
|
+
children: localeService.t("sheets-conditional-formatting-ui.panel.styleRule")
|
|
4235
|
+
}),
|
|
4236
|
+
/* @__PURE__ */ jsx("div", {
|
|
4237
|
+
className: "univer-mt-3",
|
|
4238
|
+
children: /* @__PURE__ */ jsx(Dropdown, {
|
|
4239
|
+
overlay: /* @__PURE__ */ jsx("div", {
|
|
4240
|
+
dir: direction,
|
|
4241
|
+
className: "univer-rounded-lg univer-p-3",
|
|
4242
|
+
children: /* @__PURE__ */ jsx(IconGroupList, {
|
|
4243
|
+
iconType: currentIconType,
|
|
4244
|
+
onClick: handleClickIconList
|
|
4245
|
+
})
|
|
4246
|
+
}),
|
|
4247
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
4248
|
+
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),
|
|
4249
|
+
children: [previewIcon, /* @__PURE__ */ jsx(MoreDownIcon, {})]
|
|
3839
4250
|
})
|
|
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
4251
|
})
|
|
4252
|
+
}),
|
|
4253
|
+
/* @__PURE__ */ jsxs("div", {
|
|
4254
|
+
className: "univer-mt-3 univer-flex univer-items-center univer-gap-2 univer-text-xs rtl:univer-flex-row-reverse rtl:univer-justify-end",
|
|
4255
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
4256
|
+
"data-u-comp": "cf-icon-set-option-row",
|
|
4257
|
+
className: "univer-flex univer-items-center univer-text-xs",
|
|
4258
|
+
children: [/* @__PURE__ */ jsx(Checkbox, { onChange: reverseIcon }), localeService.t("sheets-conditional-formatting-ui.iconSet.reverseIconOrder")]
|
|
4259
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
4260
|
+
"data-u-comp": "cf-icon-set-option-row",
|
|
4261
|
+
className: "univer-flex univer-items-center univer-text-xs",
|
|
4262
|
+
children: [/* @__PURE__ */ jsx(Checkbox, {
|
|
4263
|
+
checked: !isShowValue,
|
|
4264
|
+
onChange: (v) => {
|
|
4265
|
+
setIsShowValue(!v);
|
|
4266
|
+
}
|
|
4267
|
+
}), localeService.t("sheets-conditional-formatting-ui.iconSet.onlyShowIcon")]
|
|
4268
|
+
})]
|
|
4269
|
+
}),
|
|
4270
|
+
/* @__PURE__ */ jsx(IconSetRuleEdit, {
|
|
4271
|
+
errorMap,
|
|
4272
|
+
onChange: handleChange,
|
|
4273
|
+
configList
|
|
3845
4274
|
})
|
|
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
|
-
] });
|
|
4275
|
+
]
|
|
4276
|
+
});
|
|
3868
4277
|
};
|
|
3869
4278
|
|
|
3870
4279
|
//#endregion
|
|
@@ -3933,34 +4342,36 @@ const RankStyleEditor = (props) => {
|
|
|
3933
4342
|
const [style, setStyle] = useState({});
|
|
3934
4343
|
const getResult = (config) => {
|
|
3935
4344
|
const { type, isPercent, value, style } = config;
|
|
3936
|
-
|
|
3937
|
-
|
|
3938
|
-
|
|
3939
|
-
|
|
3940
|
-
|
|
3941
|
-
|
|
3942
|
-
|
|
3943
|
-
|
|
3944
|
-
|
|
3945
|
-
|
|
3946
|
-
|
|
3947
|
-
|
|
3948
|
-
|
|
3949
|
-
|
|
3950
|
-
|
|
3951
|
-
|
|
3952
|
-
|
|
3953
|
-
|
|
3954
|
-
|
|
3955
|
-
|
|
3956
|
-
|
|
3957
|
-
|
|
3958
|
-
|
|
3959
|
-
|
|
3960
|
-
|
|
3961
|
-
|
|
3962
|
-
|
|
3963
|
-
|
|
4345
|
+
switch (type) {
|
|
4346
|
+
case "isNotBottom": return {
|
|
4347
|
+
type: CFRuleType.highlightCell,
|
|
4348
|
+
subType: CFSubRuleType.rank,
|
|
4349
|
+
isPercent,
|
|
4350
|
+
isBottom: false,
|
|
4351
|
+
value,
|
|
4352
|
+
style
|
|
4353
|
+
};
|
|
4354
|
+
case "isBottom": return {
|
|
4355
|
+
type: CFRuleType.highlightCell,
|
|
4356
|
+
subType: CFSubRuleType.rank,
|
|
4357
|
+
isPercent,
|
|
4358
|
+
isBottom: true,
|
|
4359
|
+
value,
|
|
4360
|
+
style
|
|
4361
|
+
};
|
|
4362
|
+
case "greaterThanAverage": return {
|
|
4363
|
+
type: CFRuleType.highlightCell,
|
|
4364
|
+
subType: CFSubRuleType.average,
|
|
4365
|
+
operator: CFNumberOperator.greaterThan,
|
|
4366
|
+
style
|
|
4367
|
+
};
|
|
4368
|
+
case "lessThanAverage": return {
|
|
4369
|
+
type: CFRuleType.highlightCell,
|
|
4370
|
+
subType: CFSubRuleType.average,
|
|
4371
|
+
operator: CFNumberOperator.lessThan,
|
|
4372
|
+
style
|
|
4373
|
+
};
|
|
4374
|
+
}
|
|
3964
4375
|
};
|
|
3965
4376
|
useEffect(() => {
|
|
3966
4377
|
return interceptorManager.intercept(interceptorManager.getInterceptPoints().submit, { handler() {
|
|
@@ -3991,17 +4402,21 @@ const RankStyleEditor = (props) => {
|
|
|
3991
4402
|
value: type,
|
|
3992
4403
|
options,
|
|
3993
4404
|
onChange: (v) => {
|
|
3994
|
-
|
|
3995
|
-
|
|
3996
|
-
|
|
3997
|
-
|
|
3998
|
-
|
|
3999
|
-
|
|
4000
|
-
|
|
4405
|
+
var _options$find;
|
|
4406
|
+
const nextType = (_options$find = options.find((option) => option.value === v)) === null || _options$find === void 0 ? void 0 : _options$find.value;
|
|
4407
|
+
if (nextType) {
|
|
4408
|
+
setType(nextType);
|
|
4409
|
+
_onChange({
|
|
4410
|
+
type: nextType,
|
|
4411
|
+
isPercent,
|
|
4412
|
+
value,
|
|
4413
|
+
style
|
|
4414
|
+
});
|
|
4415
|
+
}
|
|
4001
4416
|
}
|
|
4002
4417
|
}),
|
|
4003
4418
|
["isNotBottom", "isBottom"].includes(type) && /* @__PURE__ */ jsxs("div", {
|
|
4004
|
-
className: "univer-mt-3 univer-flex univer-items-center",
|
|
4419
|
+
className: "univer-mt-3 univer-flex univer-items-center univer-gap-2",
|
|
4005
4420
|
children: [/* @__PURE__ */ jsx(InputNumber, {
|
|
4006
4421
|
min: 1,
|
|
4007
4422
|
max: 1e3,
|
|
@@ -4017,7 +4432,7 @@ const RankStyleEditor = (props) => {
|
|
|
4017
4432
|
});
|
|
4018
4433
|
}
|
|
4019
4434
|
}), /* @__PURE__ */ jsxs("div", {
|
|
4020
|
-
className: "univer-
|
|
4435
|
+
className: "univer-flex univer-items-center univer-text-xs",
|
|
4021
4436
|
children: [/* @__PURE__ */ jsx(Checkbox, {
|
|
4022
4437
|
checked: isPercent,
|
|
4023
4438
|
onChange: (v) => {
|
|
@@ -4275,12 +4690,11 @@ const RuleEdit = (props) => {
|
|
|
4275
4690
|
onChange: onStyleChange
|
|
4276
4691
|
}),
|
|
4277
4692
|
/* @__PURE__ */ jsxs("div", {
|
|
4278
|
-
className: "univer-mt-4 univer-flex univer-justify-end",
|
|
4693
|
+
className: "univer-mt-4 univer-flex univer-justify-end univer-gap-2",
|
|
4279
4694
|
children: [/* @__PURE__ */ jsx(Button, {
|
|
4280
4695
|
onClick: handleCancel,
|
|
4281
4696
|
children: localeService.t("sheets-conditional-formatting-ui.panel.cancel")
|
|
4282
4697
|
}), /* @__PURE__ */ jsx(Button, {
|
|
4283
|
-
className: "univer-ml-3",
|
|
4284
4698
|
variant: "primary",
|
|
4285
4699
|
onClick: handleSubmit,
|
|
4286
4700
|
children: localeService.t("sheets-conditional-formatting-ui.panel.submit")
|
|
@@ -4324,7 +4738,7 @@ const getRuleDescribe = (rule, localeService) => {
|
|
|
4324
4738
|
}
|
|
4325
4739
|
}
|
|
4326
4740
|
};
|
|
4327
|
-
|
|
4741
|
+
function RuleList(props) {
|
|
4328
4742
|
const { onClick } = props;
|
|
4329
4743
|
const conditionalFormattingRuleModel = useDependency(ConditionalFormattingRuleModel);
|
|
4330
4744
|
const univerInstanceService = useDependency(IUniverInstanceService);
|
|
@@ -4335,12 +4749,9 @@ const RuleList = (props) => {
|
|
|
4335
4749
|
const conditionalFormattingI18nController = useDependency(ConditionalFormattingI18nController);
|
|
4336
4750
|
const workbook = useObservable(() => univerInstanceService.getCurrentTypeOfUnit$(UniverInstanceType.UNIVER_SHEET), void 0, void 0, []);
|
|
4337
4751
|
const unitId = workbook.getUnitId();
|
|
4338
|
-
const
|
|
4339
|
-
if (!worksheet) throw new Error("No active sheet found");
|
|
4340
|
-
const subUnitId = worksheet.getSheetId();
|
|
4752
|
+
const subUnitId = workbook.getActiveSheet().getSheetId();
|
|
4341
4753
|
const [currentRuleRanges, setCurrentRuleRanges] = useState([]);
|
|
4342
4754
|
const [selectValue, setSelectValue] = useState("2");
|
|
4343
|
-
const [fetchRuleListId, setFetchRuleListId] = useState(0);
|
|
4344
4755
|
const [draggingId, setDraggingId] = useState("");
|
|
4345
4756
|
const selectOption = [{
|
|
4346
4757
|
label: localeService.t("sheets-conditional-formatting-ui.panel.workSheet"),
|
|
@@ -4362,25 +4773,8 @@ const RuleList = (props) => {
|
|
|
4362
4773
|
} else if (selectValue === "2") return [...ruleList];
|
|
4363
4774
|
return [];
|
|
4364
4775
|
};
|
|
4365
|
-
const
|
|
4366
|
-
|
|
4367
|
-
useEffect(() => {
|
|
4368
|
-
const disposable = commandService.onCommandExecuted((commandInfo) => {
|
|
4369
|
-
if (commandInfo.id === SetWorksheetActiveOperation.id) setFetchRuleListId(Math.random());
|
|
4370
|
-
});
|
|
4371
|
-
return () => disposable.dispose();
|
|
4372
|
-
});
|
|
4373
|
-
useEffect(() => {
|
|
4374
|
-
setRuleList(getRuleList);
|
|
4375
|
-
}, [
|
|
4376
|
-
selectValue,
|
|
4377
|
-
fetchRuleListId,
|
|
4378
|
-
unitId,
|
|
4379
|
-
subUnitId
|
|
4380
|
-
]);
|
|
4381
|
-
useEffect(() => {
|
|
4382
|
-
if (selectValue === "2") return;
|
|
4383
|
-
const subscription = new Observable((commandSubscribe) => {
|
|
4776
|
+
const ruleList = useObservable(() => {
|
|
4777
|
+
const commandEvent$ = new Observable((subscriber) => {
|
|
4384
4778
|
const commandList = [
|
|
4385
4779
|
SetSelectionsOperation.id,
|
|
4386
4780
|
AddConditionalRuleMutation.id,
|
|
@@ -4389,29 +4783,25 @@ const RuleList = (props) => {
|
|
|
4389
4783
|
MoveConditionalRuleMutation.id
|
|
4390
4784
|
];
|
|
4391
4785
|
const disposable = commandService.onCommandExecuted((commandInfo) => {
|
|
4392
|
-
|
|
4393
|
-
|
|
4394
|
-
|
|
4786
|
+
var _commandInfo$params;
|
|
4787
|
+
if (commandInfo.id === SetWorksheetActiveOperation.id) {
|
|
4788
|
+
subscriber.next("immediate");
|
|
4789
|
+
return;
|
|
4790
|
+
}
|
|
4791
|
+
const commandUnitId = (_commandInfo$params = commandInfo.params) === null || _commandInfo$params === void 0 ? void 0 : _commandInfo$params.unitId;
|
|
4792
|
+
if (selectValue === "1" && commandList.includes(commandInfo.id) && commandUnitId === unitId) subscriber.next("debounced");
|
|
4395
4793
|
});
|
|
4396
4794
|
return () => disposable.dispose();
|
|
4397
|
-
}).pipe(
|
|
4398
|
-
|
|
4399
|
-
|
|
4400
|
-
|
|
4401
|
-
|
|
4402
|
-
};
|
|
4403
|
-
}, [
|
|
4404
|
-
univerInstanceService,
|
|
4795
|
+
}).pipe(share());
|
|
4796
|
+
return merge$1(conditionalFormattingRuleModel.$ruleChange, commandEvent$.pipe(filter((event) => event === "immediate")), commandEvent$.pipe(filter((event) => event === "debounced"), debounceTime(16))).pipe(map(getRuleList), startWith(getRuleList()));
|
|
4797
|
+
}, [], false, [
|
|
4798
|
+
commandService,
|
|
4799
|
+
conditionalFormattingRuleModel,
|
|
4405
4800
|
selectValue,
|
|
4406
|
-
|
|
4407
|
-
|
|
4801
|
+
subUnitId,
|
|
4802
|
+
unitId
|
|
4408
4803
|
]);
|
|
4409
|
-
|
|
4410
|
-
const dispose = conditionalFormattingRuleModel.$ruleChange.subscribe(() => {
|
|
4411
|
-
setFetchRuleListId(Math.random());
|
|
4412
|
-
});
|
|
4413
|
-
return () => dispose.unsubscribe();
|
|
4414
|
-
}, [conditionalFormattingRuleModel]);
|
|
4804
|
+
useHighlightRange(currentRuleRanges);
|
|
4415
4805
|
const handleDelete = (rule) => {
|
|
4416
4806
|
var _getActiveSheet;
|
|
4417
4807
|
const unitId = univerInstanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_SHEET).getUnitId();
|
|
@@ -4563,7 +4953,7 @@ const RuleList = (props) => {
|
|
|
4563
4953
|
]
|
|
4564
4954
|
})
|
|
4565
4955
|
}) })] });
|
|
4566
|
-
}
|
|
4956
|
+
}
|
|
4567
4957
|
|
|
4568
4958
|
//#endregion
|
|
4569
4959
|
//#region src/views/ConditionFormattingPanel.tsx
|
|
@@ -4623,180 +5013,15 @@ let ComponentsController = class ComponentsController extends Disposable {
|
|
|
4623
5013
|
this.disposeWithMe(this._componentManager.register(CF_PANEL_KEY, ConditionFormattingPanel));
|
|
4624
5014
|
}
|
|
4625
5015
|
_registerIcons() {
|
|
4626
|
-
this.disposeWithMe(this._iconManager.register({
|
|
5016
|
+
this.disposeWithMe(this._iconManager.register({
|
|
5017
|
+
ConditionsDoubleIcon,
|
|
5018
|
+
DataBarIcon,
|
|
5019
|
+
RatingIcon
|
|
5020
|
+
}));
|
|
4627
5021
|
}
|
|
4628
5022
|
};
|
|
4629
5023
|
ComponentsController = __decorate([__decorateParam(0, Inject(ComponentManager)), __decorateParam(1, Inject(IconManager))], ComponentsController);
|
|
4630
5024
|
|
|
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
5025
|
//#endregion
|
|
4801
5026
|
//#region src/menu/cf.menu.controller.ts
|
|
4802
5027
|
/**
|
|
@@ -4876,6 +5101,7 @@ let UniverSheetsConditionalFormattingUIPlugin = class UniverSheetsConditionalFor
|
|
|
4876
5101
|
AddAverageCfCommand,
|
|
4877
5102
|
AddColorScaleConditionalRuleCommand,
|
|
4878
5103
|
AddDataBarConditionalRuleCommand,
|
|
5104
|
+
AddIconSetConditionalRuleCommand,
|
|
4879
5105
|
AddDuplicateValuesCfCommand,
|
|
4880
5106
|
AddNumberCfCommand,
|
|
4881
5107
|
AddRankCfCommand,
|
|
@@ -4900,4 +5126,4 @@ UniverSheetsConditionalFormattingUIPlugin = __decorate([
|
|
|
4900
5126
|
], UniverSheetsConditionalFormattingUIPlugin);
|
|
4901
5127
|
|
|
4902
5128
|
//#endregion
|
|
4903
|
-
export { AddAverageCfCommand, AddColorScaleConditionalRuleCommand, AddDataBarConditionalRuleCommand, AddDuplicateValuesCfCommand, AddNumberCfCommand, AddRankCfCommand, AddTextCfCommand, AddTimePeriodCfCommand, AddUniqueValuesCfCommand, ConditionalFormattingClearController, OpenConditionalFormattingOperator, UniverSheetsConditionalFormattingMobileUIPlugin, UniverSheetsConditionalFormattingUIPlugin };
|
|
5129
|
+
export { AddAverageCfCommand, AddColorScaleConditionalRuleCommand, AddDataBarConditionalRuleCommand, AddDuplicateValuesCfCommand, AddIconSetConditionalRuleCommand, AddNumberCfCommand, AddRankCfCommand, AddTextCfCommand, AddTimePeriodCfCommand, AddUniqueValuesCfCommand, ConditionalFormattingClearController, OpenConditionalFormattingOperator, menuSchema as SheetsConditionalFormattingUIMenuSchema, UniverSheetsConditionalFormattingMobileUIPlugin, UniverSheetsConditionalFormattingUIPlugin };
|