@univerjs/sheets-conditional-formatting-ui 1.0.0-alpha.2 → 1.0.0-alpha.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (85) hide show
  1. package/lib/cjs/index.js +416 -330
  2. package/lib/cjs/locale/ar-SA.js +2 -1
  3. package/lib/cjs/locale/ca-ES.js +2 -1
  4. package/lib/cjs/locale/de-DE.js +2 -1
  5. package/lib/cjs/locale/en-US.js +2 -1
  6. package/lib/cjs/locale/es-ES.js +2 -1
  7. package/lib/cjs/locale/fa-IR.js +2 -1
  8. package/lib/cjs/locale/fr-FR.js +2 -1
  9. package/lib/cjs/locale/id-ID.js +2 -1
  10. package/lib/cjs/locale/it-IT.js +2 -1
  11. package/lib/cjs/locale/ja-JP.js +2 -1
  12. package/lib/cjs/locale/ko-KR.js +2 -1
  13. package/lib/cjs/locale/pl-PL.js +2 -1
  14. package/lib/cjs/locale/pt-BR.js +2 -1
  15. package/lib/cjs/locale/ru-RU.js +2 -1
  16. package/lib/cjs/locale/sk-SK.js +2 -1
  17. package/lib/cjs/locale/vi-VN.js +2 -1
  18. package/lib/cjs/locale/zh-CN.js +2 -1
  19. package/lib/cjs/locale/zh-HK.js +2 -1
  20. package/lib/cjs/locale/zh-TW.js +2 -1
  21. package/lib/es/index.js +416 -331
  22. package/lib/es/locale/ar-SA.js +2 -1
  23. package/lib/es/locale/ca-ES.js +2 -1
  24. package/lib/es/locale/de-DE.js +2 -1
  25. package/lib/es/locale/en-US.js +2 -1
  26. package/lib/es/locale/es-ES.js +2 -1
  27. package/lib/es/locale/fa-IR.js +2 -1
  28. package/lib/es/locale/fr-FR.js +2 -1
  29. package/lib/es/locale/id-ID.js +2 -1
  30. package/lib/es/locale/it-IT.js +2 -1
  31. package/lib/es/locale/ja-JP.js +2 -1
  32. package/lib/es/locale/ko-KR.js +2 -1
  33. package/lib/es/locale/pl-PL.js +2 -1
  34. package/lib/es/locale/pt-BR.js +2 -1
  35. package/lib/es/locale/ru-RU.js +2 -1
  36. package/lib/es/locale/sk-SK.js +2 -1
  37. package/lib/es/locale/vi-VN.js +2 -1
  38. package/lib/es/locale/zh-CN.js +2 -1
  39. package/lib/es/locale/zh-HK.js +2 -1
  40. package/lib/es/locale/zh-TW.js +2 -1
  41. package/lib/index.css +16 -16
  42. package/lib/index.js +416 -331
  43. package/lib/locale/ar-SA.js +2 -1
  44. package/lib/locale/ca-ES.js +2 -1
  45. package/lib/locale/de-DE.js +2 -1
  46. package/lib/locale/en-US.js +2 -1
  47. package/lib/locale/es-ES.js +2 -1
  48. package/lib/locale/fa-IR.js +2 -1
  49. package/lib/locale/fr-FR.js +2 -1
  50. package/lib/locale/id-ID.js +2 -1
  51. package/lib/locale/it-IT.js +2 -1
  52. package/lib/locale/ja-JP.js +2 -1
  53. package/lib/locale/ko-KR.js +2 -1
  54. package/lib/locale/pl-PL.js +2 -1
  55. package/lib/locale/pt-BR.js +2 -1
  56. package/lib/locale/ru-RU.js +2 -1
  57. package/lib/locale/sk-SK.js +2 -1
  58. package/lib/locale/vi-VN.js +2 -1
  59. package/lib/locale/zh-CN.js +2 -1
  60. package/lib/locale/zh-HK.js +2 -1
  61. package/lib/locale/zh-TW.js +2 -1
  62. package/lib/types/controllers/cf.render.controller.d.ts +3 -0
  63. package/lib/types/index.d.ts +1 -0
  64. package/lib/types/locale/en-US.d.ts +1 -0
  65. package/lib/umd/index.js +1 -1
  66. package/lib/umd/locale/ar-SA.js +1 -1
  67. package/lib/umd/locale/ca-ES.js +1 -1
  68. package/lib/umd/locale/de-DE.js +1 -1
  69. package/lib/umd/locale/en-US.js +1 -1
  70. package/lib/umd/locale/es-ES.js +1 -1
  71. package/lib/umd/locale/fa-IR.js +1 -1
  72. package/lib/umd/locale/fr-FR.js +1 -1
  73. package/lib/umd/locale/id-ID.js +1 -1
  74. package/lib/umd/locale/it-IT.js +1 -1
  75. package/lib/umd/locale/ja-JP.js +1 -1
  76. package/lib/umd/locale/ko-KR.js +1 -1
  77. package/lib/umd/locale/pl-PL.js +1 -1
  78. package/lib/umd/locale/pt-BR.js +1 -1
  79. package/lib/umd/locale/ru-RU.js +1 -1
  80. package/lib/umd/locale/sk-SK.js +1 -1
  81. package/lib/umd/locale/vi-VN.js +1 -1
  82. package/lib/umd/locale/zh-CN.js +1 -1
  83. package/lib/umd/locale/zh-HK.js +1 -1
  84. package/lib/umd/locale/zh-TW.js +1 -1
  85. package/package.json +14 -14
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");
@@ -638,10 +638,179 @@ function generateClearCfMutations(injector, allRules, ranges, unitId, subUnitId)
638
638
  };
639
639
  }
640
640
 
641
+ //#endregion
642
+ //#region src/menu/manage-rule.ts
643
+ const commandList = [
644
+ _univerjs_sheets.SetWorksheetActiveOperation.id,
645
+ _univerjs_sheets_conditional_formatting.AddConditionalRuleMutation.id,
646
+ _univerjs_sheets_conditional_formatting.SetConditionalRuleMutation.id,
647
+ _univerjs_sheets_conditional_formatting.DeleteConditionalRuleMutation.id,
648
+ _univerjs_sheets_conditional_formatting.MoveConditionalRuleMutation.id
649
+ ];
650
+ const commonSelections = [
651
+ {
652
+ label: {
653
+ name: "sheets-conditional-formatting-ui.ruleType.highlightCell",
654
+ selectable: false
655
+ },
656
+ value: 3
657
+ },
658
+ {
659
+ label: {
660
+ name: "sheets-conditional-formatting-ui.panel.rankAndAverage",
661
+ selectable: false
662
+ },
663
+ value: 4
664
+ },
665
+ {
666
+ label: {
667
+ name: "sheets-conditional-formatting-ui.ruleType.formula",
668
+ selectable: false
669
+ },
670
+ value: 5
671
+ },
672
+ {
673
+ label: {
674
+ name: "sheets-conditional-formatting-ui.ruleType.colorScale",
675
+ selectable: false
676
+ },
677
+ value: 6
678
+ },
679
+ {
680
+ label: {
681
+ name: "sheets-conditional-formatting-ui.ruleType.dataBar",
682
+ selectable: false
683
+ },
684
+ value: 7
685
+ },
686
+ {
687
+ label: {
688
+ name: "sheets-conditional-formatting-ui.ruleType.iconSet",
689
+ selectable: false
690
+ },
691
+ value: 8
692
+ },
693
+ {
694
+ label: {
695
+ name: "sheets-conditional-formatting-ui.menu.manageConditionalFormatting",
696
+ selectable: false
697
+ },
698
+ value: 2
699
+ },
700
+ {
701
+ label: {
702
+ name: "sheets-conditional-formatting-ui.menu.createConditionalFormatting",
703
+ selectable: false
704
+ },
705
+ value: 1
706
+ },
707
+ {
708
+ label: {
709
+ name: "sheets-conditional-formatting-ui.menu.clearRangeRules",
710
+ selectable: false
711
+ },
712
+ value: 9,
713
+ disabled: false
714
+ },
715
+ {
716
+ label: {
717
+ name: "sheets-conditional-formatting-ui.menu.clearWorkSheetRules",
718
+ selectable: false
719
+ },
720
+ value: 10
721
+ }
722
+ ];
723
+ function FactoryManageConditionalFormattingRule(accessor) {
724
+ const selectionManagerService = accessor.get(_univerjs_sheets.SheetsSelectionsService);
725
+ const commandService = accessor.get(_univerjs_core.ICommandService);
726
+ const univerInstanceService = accessor.get(_univerjs_core.IUniverInstanceService);
727
+ const conditionalFormattingRuleModel = accessor.get(_univerjs_sheets_conditional_formatting.ConditionalFormattingRuleModel);
728
+ const clearRangeEnable$ = new rxjs.Observable((subscriber) => (0, rxjs.merge)(selectionManagerService.selectionMoveEnd$, selectionManagerService.selectionSet$, new rxjs.Observable((commandSubscribe) => {
729
+ const disposable = commandService.onCommandExecuted((commandInfo) => {
730
+ var _univerInstanceServic;
731
+ const { id, params } = commandInfo;
732
+ const unitId = (_univerInstanceServic = univerInstanceService.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_SHEET)) === null || _univerInstanceServic === void 0 ? void 0 : _univerInstanceServic.getUnitId();
733
+ if (commandList.includes(id) && params.unitId === unitId) commandSubscribe.next(null);
734
+ });
735
+ return () => disposable.dispose();
736
+ })).pipe((0, rxjs_operators.debounceTime)(16)).subscribe(() => {
737
+ var _selectionManagerServ;
738
+ const ranges = ((_selectionManagerServ = selectionManagerService.getCurrentSelections()) === null || _selectionManagerServ === void 0 ? void 0 : _selectionManagerServ.map((selection) => selection.range)) || [];
739
+ const workbook = univerInstanceService.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_SHEET);
740
+ if (!workbook) return;
741
+ const worksheet = workbook.getActiveSheet();
742
+ if (!worksheet) return;
743
+ 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) => {
744
+ return (0, _univerjs_sheets.checkRangesEditablePermission)(accessor, workbook.getUnitId(), worksheet.getSheetId(), ranges);
745
+ });
746
+ subscriber.next(hasPermission);
747
+ }));
748
+ const clearSheetEnable$ = new rxjs.Observable((subscriber) => new rxjs.Observable((commandSubscribe) => {
749
+ const disposable = commandService.onCommandExecuted((commandInfo) => {
750
+ var _univerInstanceServic2;
751
+ const { id, params } = commandInfo;
752
+ const unitId = (_univerInstanceServic2 = univerInstanceService.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_SHEET)) === null || _univerInstanceServic2 === void 0 ? void 0 : _univerInstanceServic2.getUnitId();
753
+ if (commandList.includes(id) && params.unitId === unitId) commandSubscribe.next(null);
754
+ });
755
+ return () => disposable.dispose();
756
+ }).pipe((0, rxjs_operators.debounceTime)(16)).subscribe(() => {
757
+ const workbook = univerInstanceService.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_SHEET);
758
+ if (!workbook) return;
759
+ const worksheet = workbook.getActiveSheet();
760
+ if (!worksheet) return;
761
+ const allRule = conditionalFormattingRuleModel.getSubunitRules(workbook.getUnitId(), worksheet.getSheetId()) || [];
762
+ if (!allRule.length) {
763
+ subscriber.next(false);
764
+ return false;
765
+ }
766
+ const hasPermission = allRule.map((rule) => rule.ranges).every((ranges) => {
767
+ return (0, _univerjs_sheets.checkRangesEditablePermission)(accessor, workbook.getUnitId(), worksheet.getSheetId(), ranges);
768
+ });
769
+ subscriber.next(hasPermission);
770
+ }));
771
+ const selections$ = new rxjs.Observable((subscriber) => {
772
+ clearRangeEnable$.subscribe((v) => {
773
+ const item = commonSelections.find((item) => item.value === 9);
774
+ if (item) {
775
+ item.disabled = !v;
776
+ subscriber.next(commonSelections);
777
+ }
778
+ });
779
+ clearSheetEnable$.subscribe((v) => {
780
+ const item = commonSelections.find((item) => item.value === 10);
781
+ if (item) {
782
+ item.disabled = !v;
783
+ subscriber.next(commonSelections);
784
+ }
785
+ });
786
+ subscriber.next(commonSelections);
787
+ });
788
+ return {
789
+ id: OpenConditionalFormattingOperator.id,
790
+ type: _univerjs_ui.MenuItemType.SELECTOR,
791
+ icon: "ConditionsDoubleIcon",
792
+ tooltip: "sheets-conditional-formatting-ui.title",
793
+ selections: selections$,
794
+ hidden$: (0, _univerjs_ui.getMenuHiddenObservable)(accessor, _univerjs_core.UniverInstanceType.UNIVER_SHEET),
795
+ disabled$: (0, _univerjs_sheets_ui.getCurrentRangeDisable$)(accessor, {
796
+ workbookTypes: [_univerjs_sheets.WorkbookEditablePermission],
797
+ worksheetTypes: [_univerjs_sheets.WorksheetSetCellStylePermission, _univerjs_sheets.WorksheetEditPermission],
798
+ rangeTypes: [_univerjs_sheets.RangeProtectionPermissionEditPoint]
799
+ })
800
+ };
801
+ }
802
+
803
+ //#endregion
804
+ //#region src/menu/schema.ts
805
+ const menuSchema = { [_univerjs_ui.RibbonDataGroup.RULES]: { [OpenConditionalFormattingOperator.id]: {
806
+ order: 1,
807
+ menuItemFactory: FactoryManageConditionalFormattingRule
808
+ } } };
809
+
641
810
  //#endregion
642
811
  //#region package.json
643
812
  var name = "@univerjs/sheets-conditional-formatting-ui";
644
- var version = "1.0.0-alpha.2";
813
+ var version = "1.0.0-alpha.3";
645
814
 
646
815
  //#endregion
647
816
  //#region src/config/config.ts
@@ -1167,15 +1336,59 @@ let SheetsCfRenderController = class SheetsCfRenderController extends _univerjs_
1167
1336
  _defineProperty(this, "_ruleChangeCacheMap", /* @__PURE__ */ new Map());
1168
1337
  this._initViewModelInterceptor();
1169
1338
  this._initSkeleton();
1339
+ queueMicrotask(() => this._markActiveSheetRulesDirty());
1170
1340
  this.disposeWithMe(() => {
1171
1341
  this._ruleChangeCacheMap.clear();
1172
1342
  });
1173
1343
  }
1174
- _markDirtySkeleton() {
1175
- var _this$_renderManagerS, _this$_renderManagerS2;
1176
- const unitId = this._univerInstanceService.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_SHEET).getUnitId();
1177
- (_this$_renderManagerS = this._renderManagerService.getRenderById(unitId)) === null || _this$_renderManagerS === void 0 || _this$_renderManagerS.with(_univerjs_sheets_ui.SheetSkeletonManagerService).reCalculate();
1178
- (_this$_renderManagerS2 = this._renderManagerService.getRenderById(unitId)) === null || _this$_renderManagerS2 === void 0 || (_this$_renderManagerS2 = _this$_renderManagerS2.mainComponent) === null || _this$_renderManagerS2 === void 0 || _this$_renderManagerS2.makeDirty();
1344
+ _collectDirtyRanges(items, unitId, subUnitId) {
1345
+ const ranges = [];
1346
+ items.forEach((item) => {
1347
+ var _item$rule, _rule$ranges;
1348
+ if (item.unitId !== unitId || item.subUnitId !== subUnitId) return;
1349
+ const rule = (_item$rule = item.rule) !== null && _item$rule !== void 0 ? _item$rule : item.cfId ? this._conditionalFormattingRuleModel.getRule(unitId, subUnitId, item.cfId) : null;
1350
+ if (rule === null || rule === void 0 || (_rule$ranges = rule.ranges) === null || _rule$ranges === void 0 ? void 0 : _rule$ranges.length) ranges.push(...rule.ranges);
1351
+ });
1352
+ return ranges;
1353
+ }
1354
+ _intersectDirtyRangesWithRenderedRange(ranges, renderedRange) {
1355
+ if (!renderedRange || renderedRange.startRow < 0 || renderedRange.startColumn < 0) return [];
1356
+ return ranges.map((range) => ({
1357
+ startRow: Math.max(range.startRow, renderedRange.startRow),
1358
+ endRow: Math.min(range.endRow, renderedRange.endRow),
1359
+ startColumn: Math.max(range.startColumn, renderedRange.startColumn),
1360
+ endColumn: Math.min(range.endColumn, renderedRange.endColumn)
1361
+ })).filter((range) => range.startRow <= range.endRow && range.startColumn <= range.endColumn);
1362
+ }
1363
+ _markDirtySkeleton(items) {
1364
+ var _render$mainComponent;
1365
+ const workbook = this._univerInstanceService.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_SHEET);
1366
+ const worksheet = workbook === null || workbook === void 0 ? void 0 : workbook.getActiveSheet();
1367
+ if (!workbook || !worksheet) return;
1368
+ const unitId = workbook.getUnitId();
1369
+ const subUnitId = worksheet.getSheetId();
1370
+ const render = this._renderManagerService.getRenderById(unitId);
1371
+ const skeletonManagerService = render === null || render === void 0 ? void 0 : render.with(_univerjs_sheets_ui.SheetSkeletonManagerService);
1372
+ const currentSkeleton = skeletonManagerService === null || skeletonManagerService === void 0 ? void 0 : skeletonManagerService.getCurrentSkeleton();
1373
+ const dirtyRanges = this._intersectDirtyRangesWithRenderedRange(this._collectDirtyRanges(items, unitId, subUnitId), currentSkeleton === null || currentSkeleton === void 0 ? void 0 : currentSkeleton.rowColumnSegment);
1374
+ if (dirtyRanges.length) currentSkeleton === null || currentSkeleton === void 0 || currentSkeleton.resetRangeCache(dirtyRanges);
1375
+ skeletonManagerService === null || skeletonManagerService === void 0 || skeletonManagerService.reCalculate();
1376
+ render === null || render === void 0 || (_render$mainComponent = render.mainComponent) === null || _render$mainComponent === void 0 || _render$mainComponent.makeDirty();
1377
+ }
1378
+ _markActiveSheetRulesDirty() {
1379
+ var _this$_conditionalFor;
1380
+ const workbook = this._univerInstanceService.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_SHEET);
1381
+ const worksheet = workbook === null || workbook === void 0 ? void 0 : workbook.getActiveSheet();
1382
+ if (!workbook || !worksheet) return;
1383
+ const unitId = workbook.getUnitId();
1384
+ const subUnitId = worksheet.getSheetId();
1385
+ const rules = (_this$_conditionalFor = this._conditionalFormattingRuleModel.getSubunitRules(unitId, subUnitId)) !== null && _this$_conditionalFor !== void 0 ? _this$_conditionalFor : [];
1386
+ if (!rules.length) return;
1387
+ this._markDirtySkeleton(rules.map((rule) => ({
1388
+ rule,
1389
+ subUnitId,
1390
+ unitId
1391
+ })));
1179
1392
  }
1180
1393
  _initSkeleton() {
1181
1394
  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 +1397,7 @@ let SheetsCfRenderController = class SheetsCfRenderController extends _univerjs_
1184
1397
  const worksheet = workbook.getActiveSheet();
1185
1398
  if (!worksheet) return false;
1186
1399
  return v.some((item) => item.unitId === workbook.getUnitId() && item.subUnitId === worksheet.getSheetId());
1187
- })).subscribe(() => this._markDirtySkeleton()));
1400
+ })).subscribe((items) => this._markDirtySkeleton(items)));
1188
1401
  }
1189
1402
  _initViewModelInterceptor() {
1190
1403
  this.disposeWithMe(this._sheetInterceptorService.intercept(_univerjs_sheets.INTERCEPTOR_POINT.CELL_CONTENT, {
@@ -1988,8 +2201,8 @@ const previewClassName = (0, _univerjs_design.clsx)("univer-mt-5 univer-px-1 uni
1988
2201
 
1989
2202
  //#endregion
1990
2203
  //#region src/views/panel/rule-edit/ColorScale.tsx
1991
- const createOptionItem$2 = (text, localeService) => ({
1992
- label: localeService.t(`sheets-conditional-formatting-ui.valueType.${text}`),
2204
+ const createOptionItem$2 = (text) => ({
2205
+ label: `sheets-conditional-formatting-ui.valueType.${text}`,
1993
2206
  value: text
1994
2207
  });
1995
2208
  const TextInput$1 = (props) => {
@@ -2049,15 +2262,24 @@ const ColorScaleStyleEditor = (props) => {
2049
2262
  const { interceptorManager } = props;
2050
2263
  const localeService = (0, _univerjs_ui.useDependency)(_univerjs_core.LocaleService);
2051
2264
  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 commonOptions = [
2053
- createOptionItem$2(_univerjs_sheets_conditional_formatting.CFValueType.num, localeService),
2054
- createOptionItem$2(_univerjs_sheets_conditional_formatting.CFValueType.percent, localeService),
2055
- createOptionItem$2(_univerjs_sheets_conditional_formatting.CFValueType.percentile, localeService),
2056
- createOptionItem$2(_univerjs_sheets_conditional_formatting.CFValueType.formula, localeService)
2265
+ const commonOptionDefinitions = [
2266
+ createOptionItem$2(_univerjs_sheets_conditional_formatting.CFValueType.num),
2267
+ createOptionItem$2(_univerjs_sheets_conditional_formatting.CFValueType.percent),
2268
+ createOptionItem$2(_univerjs_sheets_conditional_formatting.CFValueType.percentile),
2269
+ createOptionItem$2(_univerjs_sheets_conditional_formatting.CFValueType.formula)
2057
2270
  ];
2058
- const minOptions = [createOptionItem$2(_univerjs_sheets_conditional_formatting.CFValueType.min, localeService), ...commonOptions];
2059
- const medianOptions = [createOptionItem$2("none", localeService), ...commonOptions];
2060
- const maxOptions = [createOptionItem$2(_univerjs_sheets_conditional_formatting.CFValueType.max, localeService), ...commonOptions];
2271
+ const minOptions = [createOptionItem$2(_univerjs_sheets_conditional_formatting.CFValueType.min), ...commonOptionDefinitions].map((option) => ({
2272
+ ...option,
2273
+ label: localeService.t(option.label)
2274
+ }));
2275
+ const medianOptions = [createOptionItem$2("none"), ...commonOptionDefinitions].map((option) => ({
2276
+ ...option,
2277
+ label: localeService.t(option.label)
2278
+ }));
2279
+ const maxOptions = [createOptionItem$2(_univerjs_sheets_conditional_formatting.CFValueType.max), ...commonOptionDefinitions].map((option) => ({
2280
+ ...option,
2281
+ label: localeService.t(option.label)
2282
+ }));
2061
2283
  const [minType, setMinType] = (0, react.useState)(() => {
2062
2284
  var _rule$config$;
2063
2285
  const defaultV = _univerjs_sheets_conditional_formatting.CFValueType.min;
@@ -2203,7 +2425,7 @@ const ColorScaleStyleEditor = (props) => {
2203
2425
  children: localeService.t("sheets-conditional-formatting-ui.valueType.min")
2204
2426
  }),
2205
2427
  /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2206
- className: "univer-mt-3 univer-flex univer-h-8 univer-items-center",
2428
+ className: "univer-mt-3 univer-flex univer-h-8 univer-items-center univer-gap-2",
2207
2429
  children: [
2208
2430
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Select, {
2209
2431
  className: "univer-flex-shrink-0",
@@ -2271,7 +2493,7 @@ const ColorScaleStyleEditor = (props) => {
2271
2493
  children: localeService.t("sheets-conditional-formatting-ui.panel.medianValue")
2272
2494
  }),
2273
2495
  /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2274
- className: "univer-mt-3 univer-flex univer-h-8 univer-items-center",
2496
+ className: "univer-mt-3 univer-flex univer-h-8 univer-items-center univer-gap-2",
2275
2497
  children: [
2276
2498
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Select, {
2277
2499
  className: "univer-flex-shrink-0",
@@ -2339,7 +2561,7 @@ const ColorScaleStyleEditor = (props) => {
2339
2561
  children: localeService.t("sheets-conditional-formatting-ui.valueType.max")
2340
2562
  }),
2341
2563
  /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2342
- className: "univer-mt-3 univer-flex univer-h-8 univer-items-center",
2564
+ className: "univer-mt-3 univer-flex univer-h-8 univer-items-center univer-gap-2",
2343
2565
  children: [
2344
2566
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Select, {
2345
2567
  className: "univer-flex-shrink-0",
@@ -2364,7 +2586,6 @@ const ColorScaleStyleEditor = (props) => {
2364
2586
  }),
2365
2587
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)(TextInput$1, {
2366
2588
  id: "max",
2367
- className: "univer-ml-1",
2368
2589
  value: maxValue,
2369
2590
  type: maxType,
2370
2591
  onChange: (v) => {
@@ -2383,7 +2604,6 @@ const ColorScaleStyleEditor = (props) => {
2383
2604
  }
2384
2605
  }),
2385
2606
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ColorPicker, {
2386
- className: "univer-ml-1",
2387
2607
  color: maxColor,
2388
2608
  onChange: (v) => {
2389
2609
  setMaxColor(v);
@@ -2407,8 +2627,8 @@ const ColorScaleStyleEditor = (props) => {
2407
2627
 
2408
2628
  //#endregion
2409
2629
  //#region src/views/panel/rule-edit/DataBar.tsx
2410
- const createOptionItem$1 = (text, localeService) => ({
2411
- label: localeService.t(`sheets-conditional-formatting-ui.valueType.${text}`),
2630
+ const createOptionItem$1 = (text) => ({
2631
+ label: `sheets-conditional-formatting-ui.valueType.${text}`,
2412
2632
  value: text
2413
2633
  });
2414
2634
  const InputText = (props) => {
@@ -2437,7 +2657,7 @@ const InputText = (props) => {
2437
2657
  if (type === _univerjs_sheets_conditional_formatting.CFValueType.formula) {
2438
2658
  const v = String(_value.current).startsWith("=") ? String(_value.current) || "" : "=";
2439
2659
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2440
- className: "univer-ml-3 univer-w-full",
2660
+ className: "univer-w-full",
2441
2661
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_sheets_formula_ui.FormulaEditor, {
2442
2662
  ref: formulaEditorRef,
2443
2663
  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 +2703,20 @@ const DataBarStyleEditor = (props) => {
2483
2703
  if (!rule) return _univerjs_sheets_conditional_formatting.defaultDataBarNativeColor;
2484
2704
  return ((_rule$config3 = rule.config) === null || _rule$config3 === void 0 ? void 0 : _rule$config3.nativeColor) || _univerjs_sheets_conditional_formatting.defaultDataBarNativeColor;
2485
2705
  });
2486
- const commonOptions = [
2487
- createOptionItem$1(_univerjs_sheets_conditional_formatting.CFValueType.num, localeService),
2488
- createOptionItem$1(_univerjs_sheets_conditional_formatting.CFValueType.percent, localeService),
2489
- createOptionItem$1(_univerjs_sheets_conditional_formatting.CFValueType.percentile, localeService),
2490
- createOptionItem$1(_univerjs_sheets_conditional_formatting.CFValueType.formula, localeService)
2706
+ const commonOptionDefinitions = [
2707
+ createOptionItem$1(_univerjs_sheets_conditional_formatting.CFValueType.num),
2708
+ createOptionItem$1(_univerjs_sheets_conditional_formatting.CFValueType.percent),
2709
+ createOptionItem$1(_univerjs_sheets_conditional_formatting.CFValueType.percentile),
2710
+ createOptionItem$1(_univerjs_sheets_conditional_formatting.CFValueType.formula)
2491
2711
  ];
2492
- const minOptions = [createOptionItem$1(_univerjs_sheets_conditional_formatting.CFValueType.min, localeService), ...commonOptions];
2493
- const maxOptions = [createOptionItem$1(_univerjs_sheets_conditional_formatting.CFValueType.max, localeService), ...commonOptions];
2712
+ const minOptions = [createOptionItem$1(_univerjs_sheets_conditional_formatting.CFValueType.min), ...commonOptionDefinitions].map((option) => ({
2713
+ ...option,
2714
+ label: localeService.t(option.label)
2715
+ }));
2716
+ const maxOptions = [createOptionItem$1(_univerjs_sheets_conditional_formatting.CFValueType.max), ...commonOptionDefinitions].map((option) => ({
2717
+ ...option,
2718
+ label: localeService.t(option.label)
2719
+ }));
2494
2720
  const [minValueType, setMinValueType] = (0, react.useState)(() => {
2495
2721
  var _rule$config4;
2496
2722
  const defaultV = minOptions[0].value;
@@ -2597,7 +2823,7 @@ const DataBarStyleEditor = (props) => {
2597
2823
  });
2598
2824
  };
2599
2825
  const isShowInput = (type) => {
2600
- return commonOptions.map((item) => item.value).includes(type);
2826
+ return commonOptionDefinitions.map((item) => item.value).includes(type);
2601
2827
  };
2602
2828
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [
2603
2829
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
@@ -2621,7 +2847,7 @@ const DataBarStyleEditor = (props) => {
2621
2847
  className: "univer-mt-3 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",
2622
2848
  children: localeService.t("sheets-conditional-formatting-ui.panel.fillType")
2623
2849
  }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2624
- className: "univer-ml-1 univer-mt-3 univer-flex univer-items-center",
2850
+ className: "univer-mt-3 univer-flex univer-items-center univer-gap-3",
2625
2851
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_univerjs_design.RadioGroup, {
2626
2852
  value: isGradient,
2627
2853
  onChange: (v) => {
@@ -2651,7 +2877,7 @@ const DataBarStyleEditor = (props) => {
2651
2877
  })
2652
2878
  })]
2653
2879
  }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2654
- className: "univer-ml-6 univer-flex univer-items-center univer-text-xs",
2880
+ className: "univer-flex univer-items-center univer-text-xs",
2655
2881
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Checkbox, {
2656
2882
  checked: !isShowValue,
2657
2883
  onChange: (v) => {
@@ -2674,7 +2900,7 @@ const DataBarStyleEditor = (props) => {
2674
2900
  className: "univer-mt-3 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",
2675
2901
  children: localeService.t("sheets-conditional-formatting-ui.panel.colorSet")
2676
2902
  }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2677
- className: "univer-ml-1 univer-mt-3 univer-flex univer-items-center",
2903
+ className: "univer-mt-3 univer-flex univer-items-center univer-gap-2",
2678
2904
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2679
2905
  className: "univer-flex univer-items-center",
2680
2906
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
@@ -2685,7 +2911,7 @@ const DataBarStyleEditor = (props) => {
2685
2911
  onChange: handleNativeColorChange
2686
2912
  })]
2687
2913
  }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2688
- className: "univer-ml-3 univer-flex univer-items-center",
2914
+ className: "univer-flex univer-items-center univer-gap-3",
2689
2915
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2690
2916
  className: "univer-text-xs",
2691
2917
  children: localeService.t("sheets-conditional-formatting-ui.panel.positive")
@@ -2701,7 +2927,7 @@ const DataBarStyleEditor = (props) => {
2701
2927
  children: localeService.t("sheets-conditional-formatting-ui.valueType.min")
2702
2928
  }),
2703
2929
  /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2704
- className: "univer-mt-3 univer-flex univer-items-center",
2930
+ className: "univer-mt-3 univer-flex univer-items-center univer-gap-2",
2705
2931
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Select, {
2706
2932
  className: "univer-w-1/2 univer-flex-shrink-0",
2707
2933
  options: minOptions,
@@ -2723,7 +2949,6 @@ const DataBarStyleEditor = (props) => {
2723
2949
  }
2724
2950
  }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(InputText, {
2725
2951
  id: "min",
2726
- className: "univer-ml-3",
2727
2952
  disabled: !isShowInput(minValueType),
2728
2953
  type: minValueType,
2729
2954
  value: minValue,
@@ -2747,7 +2972,7 @@ const DataBarStyleEditor = (props) => {
2747
2972
  children: localeService.t("sheets-conditional-formatting-ui.valueType.max")
2748
2973
  }),
2749
2974
  /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2750
- className: "univer-mt-3 univer-flex univer-items-center",
2975
+ className: "univer-mt-3 univer-flex univer-items-center univer-gap-2",
2751
2976
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Select, {
2752
2977
  className: "univer-w-1/2 univer-flex-shrink-0",
2753
2978
  options: maxOptions,
@@ -2768,7 +2993,6 @@ const DataBarStyleEditor = (props) => {
2768
2993
  });
2769
2994
  }
2770
2995
  }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(InputText, {
2771
- className: "univer-ml-3",
2772
2996
  disabled: !isShowInput(maxValueType),
2773
2997
  id: "max",
2774
2998
  type: maxValueType,
@@ -3014,8 +3238,8 @@ const WrapperError = (props) => {
3014
3238
 
3015
3239
  //#endregion
3016
3240
  //#region src/views/panel/rule-edit/HighlightCell.tsx
3017
- const createOptionItem = (text, localeService) => ({
3018
- label: localeService.t(`sheets-conditional-formatting-ui.operator.${text}`),
3241
+ const createOptionItem = (text) => ({
3242
+ label: `sheets-conditional-formatting-ui.operator.${text}`,
3019
3243
  value: text
3020
3244
  });
3021
3245
  function HighlightCellInput(props) {
@@ -3176,42 +3400,43 @@ function HighlightCellInput(props) {
3176
3400
  }
3177
3401
  return null;
3178
3402
  }
3179
- const getOperatorOptions = (type, localeService) => {
3403
+ const getOperatorOptions = (type) => {
3180
3404
  switch (type) {
3181
3405
  case _univerjs_sheets_conditional_formatting.CFSubRuleType.text: return [
3182
- createOptionItem(_univerjs_sheets_conditional_formatting.CFTextOperator.containsText, localeService),
3183
- createOptionItem(_univerjs_sheets_conditional_formatting.CFTextOperator.notContainsText, localeService),
3184
- createOptionItem(_univerjs_sheets_conditional_formatting.CFTextOperator.beginsWith, localeService),
3185
- createOptionItem(_univerjs_sheets_conditional_formatting.CFTextOperator.endsWith, localeService),
3186
- createOptionItem(_univerjs_sheets_conditional_formatting.CFTextOperator.equal, localeService),
3187
- createOptionItem(_univerjs_sheets_conditional_formatting.CFTextOperator.notEqual, localeService),
3188
- createOptionItem(_univerjs_sheets_conditional_formatting.CFTextOperator.containsBlanks, localeService),
3189
- createOptionItem(_univerjs_sheets_conditional_formatting.CFTextOperator.notContainsBlanks, localeService),
3190
- createOptionItem(_univerjs_sheets_conditional_formatting.CFTextOperator.containsErrors, localeService),
3191
- createOptionItem(_univerjs_sheets_conditional_formatting.CFTextOperator.notContainsErrors, localeService)
3406
+ createOptionItem(_univerjs_sheets_conditional_formatting.CFTextOperator.containsText),
3407
+ createOptionItem(_univerjs_sheets_conditional_formatting.CFTextOperator.notContainsText),
3408
+ createOptionItem(_univerjs_sheets_conditional_formatting.CFTextOperator.beginsWith),
3409
+ createOptionItem(_univerjs_sheets_conditional_formatting.CFTextOperator.endsWith),
3410
+ createOptionItem(_univerjs_sheets_conditional_formatting.CFTextOperator.equal),
3411
+ createOptionItem(_univerjs_sheets_conditional_formatting.CFTextOperator.notEqual),
3412
+ createOptionItem(_univerjs_sheets_conditional_formatting.CFTextOperator.containsBlanks),
3413
+ createOptionItem(_univerjs_sheets_conditional_formatting.CFTextOperator.notContainsBlanks),
3414
+ createOptionItem(_univerjs_sheets_conditional_formatting.CFTextOperator.containsErrors),
3415
+ createOptionItem(_univerjs_sheets_conditional_formatting.CFTextOperator.notContainsErrors)
3192
3416
  ];
3193
3417
  case _univerjs_sheets_conditional_formatting.CFSubRuleType.number: return [
3194
- createOptionItem(_univerjs_sheets_conditional_formatting.CFNumberOperator.between, localeService),
3195
- createOptionItem(_univerjs_sheets_conditional_formatting.CFNumberOperator.notBetween, localeService),
3196
- createOptionItem(_univerjs_sheets_conditional_formatting.CFNumberOperator.equal, localeService),
3197
- createOptionItem(_univerjs_sheets_conditional_formatting.CFNumberOperator.notEqual, localeService),
3198
- createOptionItem(_univerjs_sheets_conditional_formatting.CFNumberOperator.greaterThan, localeService),
3199
- createOptionItem(_univerjs_sheets_conditional_formatting.CFNumberOperator.greaterThanOrEqual, localeService),
3200
- createOptionItem(_univerjs_sheets_conditional_formatting.CFNumberOperator.lessThan, localeService),
3201
- createOptionItem(_univerjs_sheets_conditional_formatting.CFNumberOperator.lessThanOrEqual, localeService)
3418
+ createOptionItem(_univerjs_sheets_conditional_formatting.CFNumberOperator.between),
3419
+ createOptionItem(_univerjs_sheets_conditional_formatting.CFNumberOperator.notBetween),
3420
+ createOptionItem(_univerjs_sheets_conditional_formatting.CFNumberOperator.equal),
3421
+ createOptionItem(_univerjs_sheets_conditional_formatting.CFNumberOperator.notEqual),
3422
+ createOptionItem(_univerjs_sheets_conditional_formatting.CFNumberOperator.greaterThan),
3423
+ createOptionItem(_univerjs_sheets_conditional_formatting.CFNumberOperator.greaterThanOrEqual),
3424
+ createOptionItem(_univerjs_sheets_conditional_formatting.CFNumberOperator.lessThan),
3425
+ createOptionItem(_univerjs_sheets_conditional_formatting.CFNumberOperator.lessThanOrEqual)
3202
3426
  ];
3203
3427
  case _univerjs_sheets_conditional_formatting.CFSubRuleType.timePeriod: return [
3204
- createOptionItem(_univerjs_sheets_conditional_formatting.CFTimePeriodOperator.yesterday, localeService),
3205
- createOptionItem(_univerjs_sheets_conditional_formatting.CFTimePeriodOperator.today, localeService),
3206
- createOptionItem(_univerjs_sheets_conditional_formatting.CFTimePeriodOperator.tomorrow, localeService),
3207
- createOptionItem(_univerjs_sheets_conditional_formatting.CFTimePeriodOperator.last7Days, localeService),
3208
- createOptionItem(_univerjs_sheets_conditional_formatting.CFTimePeriodOperator.lastWeek, localeService),
3209
- createOptionItem(_univerjs_sheets_conditional_formatting.CFTimePeriodOperator.thisWeek, localeService),
3210
- createOptionItem(_univerjs_sheets_conditional_formatting.CFTimePeriodOperator.nextWeek, localeService),
3211
- createOptionItem(_univerjs_sheets_conditional_formatting.CFTimePeriodOperator.lastMonth, localeService),
3212
- createOptionItem(_univerjs_sheets_conditional_formatting.CFTimePeriodOperator.thisMonth, localeService),
3213
- createOptionItem(_univerjs_sheets_conditional_formatting.CFTimePeriodOperator.nextMonth, localeService)
3428
+ createOptionItem(_univerjs_sheets_conditional_formatting.CFTimePeriodOperator.yesterday),
3429
+ createOptionItem(_univerjs_sheets_conditional_formatting.CFTimePeriodOperator.today),
3430
+ createOptionItem(_univerjs_sheets_conditional_formatting.CFTimePeriodOperator.tomorrow),
3431
+ createOptionItem(_univerjs_sheets_conditional_formatting.CFTimePeriodOperator.last7Days),
3432
+ createOptionItem(_univerjs_sheets_conditional_formatting.CFTimePeriodOperator.lastWeek),
3433
+ createOptionItem(_univerjs_sheets_conditional_formatting.CFTimePeriodOperator.thisWeek),
3434
+ createOptionItem(_univerjs_sheets_conditional_formatting.CFTimePeriodOperator.nextWeek),
3435
+ createOptionItem(_univerjs_sheets_conditional_formatting.CFTimePeriodOperator.lastMonth),
3436
+ createOptionItem(_univerjs_sheets_conditional_formatting.CFTimePeriodOperator.thisMonth),
3437
+ createOptionItem(_univerjs_sheets_conditional_formatting.CFTimePeriodOperator.nextMonth)
3214
3438
  ];
3439
+ default: return [];
3215
3440
  }
3216
3441
  };
3217
3442
  const HighlightCellStyleEditor = (props) => {
@@ -3246,9 +3471,13 @@ const HighlightCellStyleEditor = (props) => {
3246
3471
  label: localeService.t("sheets-conditional-formatting-ui.subRuleType.uniqueValues")
3247
3472
  }
3248
3473
  ];
3249
- const operatorOptions = (0, react.useMemo)(() => getOperatorOptions(subType, localeService), [subType]);
3474
+ const operatorOptions = (0, react.useMemo)(() => getOperatorOptions(subType).map((option) => ({
3475
+ ...option,
3476
+ label: localeService.t(option.label)
3477
+ })), [localeService, subType]);
3250
3478
  const [operator, setOperator] = (0, react.useState)(() => {
3251
- const defaultV = operatorOptions ? operatorOptions[0].value : void 0;
3479
+ var _operatorOptions$;
3480
+ const defaultV = (_operatorOptions$ = operatorOptions[0]) === null || _operatorOptions$ === void 0 ? void 0 : _operatorOptions$.value;
3252
3481
  if (!rule) return defaultV;
3253
3482
  return rule.operator || defaultV;
3254
3483
  });
@@ -3260,8 +3489,16 @@ const HighlightCellStyleEditor = (props) => {
3260
3489
  });
3261
3490
  const [style, setStyle] = (0, react.useState)({});
3262
3491
  const getResult = (0, react.useMemo)(() => (option) => {
3263
- var _option$subType4, _option$operator4, _option$style4;
3492
+ var _option$subType5, _option$operator4, _option$style5;
3264
3493
  switch (option.subType || subType) {
3494
+ case _univerjs_sheets_conditional_formatting.CFSubRuleType.duplicateValues:
3495
+ case _univerjs_sheets_conditional_formatting.CFSubRuleType.uniqueValues:
3496
+ var _option$subType, _option$style;
3497
+ return {
3498
+ type: _univerjs_sheets_conditional_formatting.CFRuleType.highlightCell,
3499
+ subType: (_option$subType = option.subType) !== null && _option$subType !== void 0 ? _option$subType : subType,
3500
+ style: (_option$style = option.style) !== null && _option$style !== void 0 ? _option$style : style
3501
+ };
3265
3502
  case _univerjs_sheets_conditional_formatting.CFSubRuleType.text:
3266
3503
  if ([
3267
3504
  _univerjs_sheets_conditional_formatting.CFTextOperator.beginsWith,
@@ -3271,12 +3508,12 @@ const HighlightCellStyleEditor = (props) => {
3271
3508
  _univerjs_sheets_conditional_formatting.CFTextOperator.equal,
3272
3509
  _univerjs_sheets_conditional_formatting.CFTextOperator.notEqual
3273
3510
  ].includes(operator)) {
3274
- var _option$subType, _option$operator, _option$style, _option$value;
3511
+ var _option$subType2, _option$operator, _option$style2, _option$value;
3275
3512
  return {
3276
3513
  type: _univerjs_sheets_conditional_formatting.CFRuleType.highlightCell,
3277
- subType: (_option$subType = option.subType) !== null && _option$subType !== void 0 ? _option$subType : subType,
3514
+ subType: (_option$subType2 = option.subType) !== null && _option$subType2 !== void 0 ? _option$subType2 : subType,
3278
3515
  operator: (_option$operator = option.operator) !== null && _option$operator !== void 0 ? _option$operator : operator,
3279
- style: (_option$style = option.style) !== null && _option$style !== void 0 ? _option$style : style,
3516
+ style: (_option$style2 = option.style) !== null && _option$style2 !== void 0 ? _option$style2 : style,
3280
3517
  value: (_option$value = option.value) !== null && _option$value !== void 0 ? _option$value : value
3281
3518
  };
3282
3519
  }
@@ -3290,22 +3527,22 @@ const HighlightCellStyleEditor = (props) => {
3290
3527
  _univerjs_sheets_conditional_formatting.CFNumberOperator.lessThan,
3291
3528
  _univerjs_sheets_conditional_formatting.CFNumberOperator.lessThanOrEqual
3292
3529
  ].includes(operator)) {
3293
- var _option$subType2, _option$operator2, _option$style2, _option$value2;
3530
+ var _option$subType3, _option$operator2, _option$style3, _option$value2;
3294
3531
  return {
3295
3532
  type: _univerjs_sheets_conditional_formatting.CFRuleType.highlightCell,
3296
- subType: (_option$subType2 = option.subType) !== null && _option$subType2 !== void 0 ? _option$subType2 : subType,
3533
+ subType: (_option$subType3 = option.subType) !== null && _option$subType3 !== void 0 ? _option$subType3 : subType,
3297
3534
  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,
3535
+ style: (_option$style3 = option.style) !== null && _option$style3 !== void 0 ? _option$style3 : style,
3299
3536
  value: (_option$value2 = option.value) !== null && _option$value2 !== void 0 ? _option$value2 : value
3300
3537
  };
3301
3538
  }
3302
3539
  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;
3540
+ var _option$subType4, _option$operator3, _option$style4, _option$value3;
3304
3541
  return {
3305
3542
  type: _univerjs_sheets_conditional_formatting.CFRuleType.highlightCell,
3306
- subType: (_option$subType3 = option.subType) !== null && _option$subType3 !== void 0 ? _option$subType3 : subType,
3543
+ subType: (_option$subType4 = option.subType) !== null && _option$subType4 !== void 0 ? _option$subType4 : subType,
3307
3544
  operator: (_option$operator3 = option.operator) !== null && _option$operator3 !== void 0 ? _option$operator3 : operator,
3308
- style: (_option$style3 = option.style) !== null && _option$style3 !== void 0 ? _option$style3 : style,
3545
+ style: (_option$style4 = option.style) !== null && _option$style4 !== void 0 ? _option$style4 : style,
3309
3546
  value: (_option$value3 = option.value) !== null && _option$value3 !== void 0 ? _option$value3 : value
3310
3547
  };
3311
3548
  }
@@ -3313,9 +3550,9 @@ const HighlightCellStyleEditor = (props) => {
3313
3550
  }
3314
3551
  return {
3315
3552
  type: _univerjs_sheets_conditional_formatting.CFRuleType.highlightCell,
3316
- subType: (_option$subType4 = option.subType) !== null && _option$subType4 !== void 0 ? _option$subType4 : subType,
3553
+ subType: (_option$subType5 = option.subType) !== null && _option$subType5 !== void 0 ? _option$subType5 : subType,
3317
3554
  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
3555
+ style: (_option$style5 = option.style) !== null && _option$style5 !== void 0 ? _option$style5 : style
3319
3556
  };
3320
3557
  }, [
3321
3558
  subType,
@@ -3332,9 +3569,12 @@ const HighlightCellStyleEditor = (props) => {
3332
3569
  if (!typeOptions.some((item) => item.value === subType)) setSubType(typeOptions[0].value);
3333
3570
  }, [typeOptions]);
3334
3571
  const onTypeChange = (v) => {
3572
+ var _operatorList$;
3335
3573
  const _subType = v;
3336
- const operatorList = getOperatorOptions(_subType, localeService);
3337
- const _operator = operatorList && operatorList[0].value;
3574
+ const _operator = (_operatorList$ = getOperatorOptions(_subType).map((option) => ({
3575
+ ...option,
3576
+ label: localeService.t(option.label)
3577
+ }))[0]) === null || _operatorList$ === void 0 ? void 0 : _operatorList$.value;
3338
3578
  setSubType(_subType);
3339
3579
  setOperator(_operator);
3340
3580
  _operator && setValue((0, _univerjs_sheets_conditional_formatting.createDefaultValue)(_subType, _operator));
@@ -3452,11 +3692,13 @@ const createDefaultConfigItem = (iconType, index, list) => ({
3452
3692
  const IconGroupList = (0, react.forwardRef)((props, ref) => {
3453
3693
  const { onClick } = props;
3454
3694
  const localeService = (0, _univerjs_ui.useDependency)(_univerjs_core.LocaleService);
3695
+ const direction = (0, _univerjs_ui.useObservable)(localeService.direction$, localeService.getDirection());
3455
3696
  const handleClick = (iconType) => {
3456
3697
  onClick(iconType);
3457
3698
  };
3458
3699
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3459
3700
  ref,
3701
+ dir: direction,
3460
3702
  className: "univer-w-80",
3461
3703
  children: _univerjs_sheets_conditional_formatting.iconGroup.map((group, index) => {
3462
3704
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
@@ -3468,7 +3710,7 @@ const IconGroupList = (0, react.forwardRef)((props, ref) => {
3468
3710
  className: "univer-flex univer-flex-wrap",
3469
3711
  children: group.group.map((groupItem) => {
3470
3712
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3471
- className: "univer-mb-1 univer-flex univer-w-1/2 univer-items-center",
3713
+ className: "univer-mb-1 univer-flex univer-w-1/2 univer-items-center rtl:univer-flex-row-reverse rtl:univer-justify-end",
3472
3714
  onClick: () => {
3473
3715
  handleClick(groupItem.name);
3474
3716
  },
@@ -3489,6 +3731,8 @@ const IconGroupList = (0, react.forwardRef)((props, ref) => {
3489
3731
  });
3490
3732
  const IconItemList = (props) => {
3491
3733
  const { onClick } = props;
3734
+ const localeService = (0, _univerjs_ui.useDependency)(_univerjs_core.LocaleService);
3735
+ const direction = (0, _univerjs_ui.useObservable)(localeService.direction$, localeService.getDirection());
3492
3736
  const list = (0, react.useMemo)(() => {
3493
3737
  const result = [];
3494
3738
  for (const key in _univerjs_sheets_conditional_formatting.iconMap) {
@@ -3506,29 +3750,30 @@ const IconItemList = (props) => {
3506
3750
  const handleClick = (item) => {
3507
3751
  onClick(item.iconType, item.iconId);
3508
3752
  };
3509
- return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
3510
- className: "univer-mb-2.5 univer-flex univer-cursor-pointer univer-items-center univer-pl-1",
3511
- onClick: () => handleClick({
3512
- iconType: _univerjs_sheets_conditional_formatting.IIconSetType.empty,
3513
- iconId: "",
3514
- base64: ""
3515
- }),
3516
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.SlashDoubleIcon, { className: "univer-size-5" }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3517
- className: "univer-ml-2",
3518
- children: "无单元格图标"
3753
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
3754
+ dir: direction,
3755
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3756
+ "data-u-comp": "cf-icon-set-no-icon-option",
3757
+ className: "univer-mb-2.5 univer-flex univer-cursor-pointer univer-items-center univer-gap-2 univer-text-sm",
3758
+ onClick: () => handleClick({
3759
+ iconType: _univerjs_sheets_conditional_formatting.IIconSetType.empty,
3760
+ iconId: "",
3761
+ base64: ""
3762
+ }),
3763
+ children: localeService.t("sheets-conditional-formatting-ui.iconSet.noCellIcon")
3764
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3765
+ className: "univer-flex univer-w-64 univer-flex-wrap univer-gap-2",
3766
+ children: list.map((item) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3767
+ 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",
3768
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("img", {
3769
+ className: "univer-size-5",
3770
+ src: item.base64,
3771
+ draggable: false,
3772
+ onClick: () => handleClick(item)
3773
+ })
3774
+ }, `${item.iconType}_${item.iconId}`))
3519
3775
  })]
3520
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
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
- })] });
3776
+ });
3532
3777
  };
3533
3778
  const IconSetRuleEdit = (props) => {
3534
3779
  const { onChange, configList, errorMap = {} } = props;
@@ -3616,7 +3861,8 @@ const IconSetRuleEdit = (props) => {
3616
3861
  })]
3617
3862
  }),
3618
3863
  /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
3619
- className: "univer-mt-3 univer-grid univer-grid-cols-2 univer-gap-4",
3864
+ "data-u-comp": "cf-icon-set-rule-grid",
3865
+ className: "univer-mt-3 univer-grid univer-grid-cols-2 univer-gap-4 rtl:univer-grid-flow-dense",
3620
3866
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3621
3867
  className: "univer-flex univer-items-center",
3622
3868
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Dropdown, {
@@ -3687,6 +3933,7 @@ const IconSet = (props) => {
3687
3933
  const { interceptorManager } = props;
3688
3934
  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
3935
  const localeService = (0, _univerjs_ui.useDependency)(_univerjs_core.LocaleService);
3936
+ const direction = (0, _univerjs_ui.useObservable)(localeService.direction$, localeService.getDirection());
3690
3937
  const [errorMap, setErrorMap] = (0, react.useState)({});
3691
3938
  const [currentIconType, setCurrentIconType] = (0, react.useState)(() => {
3692
3939
  const defaultV = Object.keys(_univerjs_sheets_conditional_formatting.iconMap)[0];
@@ -3718,7 +3965,8 @@ const IconSet = (props) => {
3718
3965
  });
3719
3966
  const previewIcon = (0, react.useMemo)(() => {
3720
3967
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3721
- className: "univer-flex univer-items-center",
3968
+ "data-u-comp": "cf-icon-set-preview",
3969
+ className: "univer-flex univer-items-center rtl:univer-flex-row-reverse",
3722
3970
  children: configList.map((item) => {
3723
3971
  return getIcon(item.iconType, item.iconId);
3724
3972
  }).map((icon, index) => icon ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("img", {
@@ -3821,51 +4069,58 @@ const IconSet = (props) => {
3821
4069
  const layoutService = (0, _univerjs_ui.useDependency)(_univerjs_ui.ILayoutService);
3822
4070
  const [iconGroupListEl, setIconGroupListEl] = (0, react.useState)();
3823
4071
  (0, _univerjs_ui.useScrollYOverContainer)(iconGroupListEl, layoutService.rootContainerElement);
3824
- return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [
3825
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3826
- className: "univer-mt-4 univer-text-sm univer-text-gray-600",
3827
- children: localeService.t("sheets-conditional-formatting-ui.panel.styleRule")
3828
- }),
3829
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3830
- className: "univer-mt-3",
3831
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Dropdown, {
3832
- overlay: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3833
- className: "univer-rounded-lg univer-p-4",
3834
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(IconGroupList, {
3835
- ref: (el) => {
3836
- !iconGroupListEl && el && setIconGroupListEl(el);
3837
- },
3838
- iconType: currentIconType,
3839
- onClick: handleClickIconList
4072
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
4073
+ "data-u-comp": "cf-icon-set-editor",
4074
+ dir: direction,
4075
+ children: [
4076
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
4077
+ className: "univer-mt-4 univer-text-sm univer-text-gray-600",
4078
+ children: localeService.t("sheets-conditional-formatting-ui.panel.styleRule")
4079
+ }),
4080
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
4081
+ className: "univer-mt-3",
4082
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Dropdown, {
4083
+ overlay: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
4084
+ dir: direction,
4085
+ className: "univer-rounded-lg univer-p-4",
4086
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(IconGroupList, {
4087
+ ref: (el) => {
4088
+ !iconGroupListEl && el && setIconGroupListEl(el);
4089
+ },
4090
+ iconType: currentIconType,
4091
+ onClick: handleClickIconList
4092
+ })
4093
+ }),
4094
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
4095
+ 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),
4096
+ children: [previewIcon, /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.MoreDownIcon, {})]
3840
4097
  })
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
4098
  })
4099
+ }),
4100
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
4101
+ className: "univer-mt-3 univer-flex univer-items-center univer-gap-2 univer-text-xs rtl:univer-flex-row-reverse rtl:univer-justify-end",
4102
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
4103
+ "data-u-comp": "cf-icon-set-option-row",
4104
+ className: "univer-flex univer-items-center univer-text-xs",
4105
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Checkbox, { onChange: reverseIcon }), localeService.t("sheets-conditional-formatting-ui.iconSet.reverseIconOrder")]
4106
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
4107
+ "data-u-comp": "cf-icon-set-option-row",
4108
+ className: "univer-flex univer-items-center univer-text-xs",
4109
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Checkbox, {
4110
+ checked: !isShowValue,
4111
+ onChange: (v) => {
4112
+ setIsShowValue(!v);
4113
+ }
4114
+ }), localeService.t("sheets-conditional-formatting-ui.iconSet.onlyShowIcon")]
4115
+ })]
4116
+ }),
4117
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(IconSetRuleEdit, {
4118
+ errorMap,
4119
+ onChange: handleChange,
4120
+ configList
3846
4121
  })
3847
- }),
3848
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
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
- ] });
4122
+ ]
4123
+ });
3869
4124
  };
3870
4125
 
3871
4126
  //#endregion
@@ -4002,7 +4257,7 @@ const RankStyleEditor = (props) => {
4002
4257
  }
4003
4258
  }),
4004
4259
  ["isNotBottom", "isBottom"].includes(type) && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
4005
- className: "univer-mt-3 univer-flex univer-items-center",
4260
+ className: "univer-mt-3 univer-flex univer-items-center univer-gap-2",
4006
4261
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.InputNumber, {
4007
4262
  min: 1,
4008
4263
  max: 1e3,
@@ -4018,7 +4273,7 @@ const RankStyleEditor = (props) => {
4018
4273
  });
4019
4274
  }
4020
4275
  }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
4021
- className: "univer-ml-3 univer-flex univer-items-center univer-text-xs",
4276
+ className: "univer-flex univer-items-center univer-text-xs",
4022
4277
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Checkbox, {
4023
4278
  checked: isPercent,
4024
4279
  onChange: (v) => {
@@ -4276,12 +4531,11 @@ const RuleEdit = (props) => {
4276
4531
  onChange: onStyleChange
4277
4532
  }),
4278
4533
  /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
4279
- className: "univer-mt-4 univer-flex univer-justify-end",
4534
+ className: "univer-mt-4 univer-flex univer-justify-end univer-gap-2",
4280
4535
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Button, {
4281
4536
  onClick: handleCancel,
4282
4537
  children: localeService.t("sheets-conditional-formatting-ui.panel.cancel")
4283
4538
  }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Button, {
4284
- className: "univer-ml-3",
4285
4539
  variant: "primary",
4286
4540
  onClick: handleSubmit,
4287
4541
  children: localeService.t("sheets-conditional-formatting-ui.panel.submit")
@@ -4629,175 +4883,6 @@ let ComponentsController = class ComponentsController extends _univerjs_core.Dis
4629
4883
  };
4630
4884
  ComponentsController = __decorate([__decorateParam(0, (0, _univerjs_core.Inject)(_univerjs_ui.ComponentManager)), __decorateParam(1, (0, _univerjs_core.Inject)(_univerjs_ui.IconManager))], ComponentsController);
4631
4885
 
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
4886
  //#endregion
4802
4887
  //#region src/menu/cf.menu.controller.ts
4803
4888
  /**
@@ -4917,6 +5002,7 @@ Object.defineProperty(exports, 'ConditionalFormattingClearController', {
4917
5002
  }
4918
5003
  });
4919
5004
  exports.OpenConditionalFormattingOperator = OpenConditionalFormattingOperator;
5005
+ exports.SheetsConditionalFormattingUIMenuSchema = menuSchema;
4920
5006
  Object.defineProperty(exports, 'UniverSheetsConditionalFormattingMobileUIPlugin', {
4921
5007
  enumerable: true,
4922
5008
  get: function () {