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