@univerjs/sheets-conditional-formatting-ui 1.0.0-alpha.6 → 1.0.0-alpha.8

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/index.js CHANGED
@@ -1,12 +1,12 @@
1
1
  import { BooleanNumber, ColorKit, CommandType, DependentOn, Disposable, DisposableCollection, ICommandService, IConfigService, IUniverInstanceService, Inject, Injector, InterceptorEffectEnum, InterceptorManager, LocaleService, ObjectMatrix, Plugin, Range, Rectangle, Tools, UniverInstanceType, createInterceptorKey, generateRandomId, get, merge, registerDependencies, set, toDisposable, touchDependencies } from "@univerjs/core";
2
- import { AFTER_CELL_EDIT, AUTO_FILL_APPLY_TYPE, AutoFillTools, ClearSelectionAllCommand, ClearSelectionFormatCommand, IAutoFillService, INTERCEPTOR_POINT, RangeProtectionPermissionEditPoint, RemoveSheetMutation, SetSelectionsOperation, SetWorksheetActiveOperation, SheetInterceptorService, SheetPermissionCheckController, SheetsSelectionsService, WorkbookEditablePermission, WorksheetEditPermission, WorksheetSetCellStylePermission, checkRangesEditablePermission, getSheetCommandTarget, rangeToDiscreteRange, setEndForRange } from "@univerjs/sheets";
2
+ import { AFTER_CELL_EDIT, AUTO_FILL_APPLY_TYPE, AutoFillTools, ClearSelectionAllCommand, ClearSelectionFormatCommand, IAutoFillService, INTERCEPTOR_POINT, RangeProtectionPermissionEditPoint, RemoveSheetMutation, SetSelectionsOperation, SetWorksheetActiveOperation, SheetInterceptorService, SheetPermissionCheckController, SheetsSelectionsService, UniverSheetsPlugin, WorkbookEditablePermission, WorksheetEditPermission, WorksheetSetCellStylePermission, checkRangesEditablePermission, getSheetCommandTarget, rangeToDiscreteRange, setEndForRange } from "@univerjs/sheets";
3
3
  import { AddCfCommand, AddConditionalRuleMutation, AddConditionalRuleMutationUndoFactory, CFNumberOperator, CFRuleType, CFSubRuleType, CFTextOperator, CFTimePeriodOperator, CFValueType, CONDITIONAL_FORMATTING_VIEWPORT_CACHE_LENGTH, ClearRangeCfCommand, ClearWorksheetCfCommand, ConditionalFormattingRangeIndexModel, ConditionalFormattingRangeTransformService, ConditionalFormattingRuleModel, ConditionalFormattingService, ConditionalFormattingViewModel, DEFAULT_BG_COLOR, DEFAULT_FONT_COLOR, DEFAULT_PADDING, DEFAULT_WIDTH, DeleteCfCommand, DeleteConditionalRuleMutation, DeleteConditionalRuleMutationUndoFactory, IIconSetType, MoveCfCommand, MoveConditionalRuleMutation, SHEET_CONDITIONAL_FORMATTING_PLUGIN, SetCfCommand, SetConditionalRuleMutation, UniverSheetsConditionalFormattingPlugin, compareWithNumber, createCfId, createDefaultRule, createDefaultValue, createDefaultValueByValueType, defaultDataBarNativeColor, defaultDataBarPositiveColor, getColorScaleFromValue, getOppositeOperator, iconGroup, iconMap, removeUndefinedAttr, setConditionalRuleMutationUndoFactory } from "@univerjs/sheets-conditional-formatting";
4
- import { ComponentManager, IMenuManagerService, ISidebarService, IconManager, MenuItemType, RibbonDataGroup, RibbonInsertGroup, getMenuHiddenObservable, useDependency, useObservable, useSidebarClick } from "@univerjs/ui";
5
- import { COPY_TYPE, FormatPainterStatus, IFormatPainterService, ISheetClipboardService, PREDEFINED_HOOK_NAME_PASTE, SheetSkeletonManagerService, getCurrentRangeDisable$, getRepeatRange, useHighlightRange, virtualizeDiscreteRanges } from "@univerjs/sheets-ui";
4
+ import { ComponentManager, IMenuManagerService, ISidebarService, IconManager, MenuItemType, RibbonDataGroup, RibbonInsertGroup, UniverUIPlugin, getMenuHiddenObservable, useDependency, useObservable, useSidebarClick } from "@univerjs/ui";
5
+ import { COPY_TYPE, FormatPainterStatus, IFormatPainterService, ISheetClipboardService, PREDEFINED_HOOK_NAME_PASTE, SheetSkeletonManagerService, UniverSheetsMobileUIPlugin, UniverSheetsUIPlugin, getCurrentRangeDisable$, getRepeatRange, useHighlightRange, virtualizeDiscreteRanges } from "@univerjs/sheets-ui";
6
6
  import { Observable, debounceTime, filter, map, merge as merge$1, share, startWith } from "rxjs";
7
7
  import { bufferTime, debounceTime as debounceTime$1, filter as filter$1 } from "rxjs/operators";
8
+ import { IRenderManagerService, UniverRenderEnginePlugin } from "@univerjs/engine-render";
8
9
  import { FormulaRefRangeService, UniverSheetsFormulaPlugin } from "@univerjs/sheets-formula";
9
- import { IRenderManagerService } from "@univerjs/engine-render";
10
10
  import { BoldIcon, ConditionsDoubleIcon, DataBarIcon, DeleteIcon, FontColorDoubleIcon, GripVerticalIcon, IncreaseIcon, ItalicIcon, MoreDownIcon, PaintBucketDoubleIcon, RatingIcon, SlashDoubleIcon, StrikethroughIcon, UnderlineIcon } from "@univerjs/icons";
11
11
  import { useEffect, useMemo, useRef, useState } from "react";
12
12
  import { Button, Checkbox, ColorPicker, DraggableList, Dropdown, Input, InputNumber, Radio, RadioGroup, Select, Tooltip, borderClassName, clsx } from "@univerjs/design";
@@ -365,7 +365,7 @@ const AddUniqueValuesCfCommand = {
365
365
  };
366
366
 
367
367
  //#endregion
368
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/typeof.js
368
+ //#region \0@oxc-project+runtime@0.140.0/helpers/esm/typeof.js
369
369
  function _typeof(o) {
370
370
  "@babel/helpers - typeof";
371
371
  return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
@@ -376,7 +376,7 @@ function _typeof(o) {
376
376
  }
377
377
 
378
378
  //#endregion
379
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/toPrimitive.js
379
+ //#region \0@oxc-project+runtime@0.140.0/helpers/esm/toPrimitive.js
380
380
  function toPrimitive(t, r) {
381
381
  if ("object" != _typeof(t) || !t) return t;
382
382
  var e = t[Symbol.toPrimitive];
@@ -389,14 +389,14 @@ function toPrimitive(t, r) {
389
389
  }
390
390
 
391
391
  //#endregion
392
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/toPropertyKey.js
392
+ //#region \0@oxc-project+runtime@0.140.0/helpers/esm/toPropertyKey.js
393
393
  function toPropertyKey(t) {
394
394
  var i = toPrimitive(t, "string");
395
395
  return "symbol" == _typeof(i) ? i : i + "";
396
396
  }
397
397
 
398
398
  //#endregion
399
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/defineProperty.js
399
+ //#region \0@oxc-project+runtime@0.140.0/helpers/esm/defineProperty.js
400
400
  function _defineProperty(e, r, t) {
401
401
  return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
402
402
  value: t,
@@ -407,7 +407,7 @@ function _defineProperty(e, r, t) {
407
407
  }
408
408
 
409
409
  //#endregion
410
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/decorateParam.js
410
+ //#region \0@oxc-project+runtime@0.140.0/helpers/esm/decorateParam.js
411
411
  function __decorateParam(paramIndex, decorator) {
412
412
  return function(target, key) {
413
413
  decorator(target, key, paramIndex);
@@ -415,7 +415,7 @@ function __decorateParam(paramIndex, decorator) {
415
415
  }
416
416
 
417
417
  //#endregion
418
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/decorate.js
418
+ //#region \0@oxc-project+runtime@0.140.0/helpers/esm/decorate.js
419
419
  function __decorate(decorators, target, key, desc) {
420
420
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
421
421
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -798,14 +798,14 @@ function FactoryManageConditionalFormattingRule(accessor) {
798
798
  subscriber.next(hasPermission);
799
799
  }));
800
800
  const selections$ = new Observable((subscriber) => {
801
- clearRangeEnable$.subscribe((v) => {
801
+ const clearRangeSubscription = clearRangeEnable$.subscribe((v) => {
802
802
  const item = commonSelections.find((item) => item.value === 9);
803
803
  if (item) {
804
804
  item.disabled = !v;
805
805
  subscriber.next(commonSelections);
806
806
  }
807
807
  });
808
- clearSheetEnable$.subscribe((v) => {
808
+ const clearSheetSubscription = clearSheetEnable$.subscribe((v) => {
809
809
  const item = commonSelections.find((item) => item.value === 10);
810
810
  if (item) {
811
811
  item.disabled = !v;
@@ -813,6 +813,10 @@ function FactoryManageConditionalFormattingRule(accessor) {
813
813
  }
814
814
  });
815
815
  subscriber.next(commonSelections);
816
+ return () => {
817
+ clearRangeSubscription.unsubscribe();
818
+ clearSheetSubscription.unsubscribe();
819
+ };
816
820
  });
817
821
  return {
818
822
  id: OpenConditionalFormattingOperator.id,
@@ -970,6 +974,11 @@ const menuSchema = {
970
974
  },
971
975
  [RibbonDataGroup.RULES]: { [OpenConditionalFormattingOperator.id]: {
972
976
  order: 1,
977
+ gridLayout: {
978
+ row: 2,
979
+ column: 1,
980
+ showLabel: true
981
+ },
973
982
  menuItemFactory: FactoryManageConditionalFormattingRule
974
983
  } }
975
984
  };
@@ -977,7 +986,7 @@ const menuSchema = {
977
986
  //#endregion
978
987
  //#region package.json
979
988
  var name = "@univerjs/sheets-conditional-formatting-ui";
980
- var version = "1.0.0-alpha.6";
989
+ var version = "1.0.0-alpha.8";
981
990
 
982
991
  //#endregion
983
992
  //#region src/config/config.ts
@@ -1534,7 +1543,7 @@ let SheetsCfRenderController = class SheetsCfRenderController extends Disposable
1534
1543
  if (!workbook || !worksheet) return;
1535
1544
  const unitId = workbook.getUnitId();
1536
1545
  const subUnitId = worksheet.getSheetId();
1537
- const render = this._renderManagerService.getRenderById(unitId);
1546
+ const render = this._renderManagerService.getRenderUnitById(unitId);
1538
1547
  const skeletonManagerService = render === null || render === void 0 ? void 0 : render.with(SheetSkeletonManagerService);
1539
1548
  const currentSkeleton = skeletonManagerService === null || skeletonManagerService === void 0 ? void 0 : skeletonManagerService.getCurrentSkeleton();
1540
1549
  const dirtyRanges = this._intersectDirtyRangesWithRenderedRange(this._collectDirtyRanges(items, unitId, subUnitId), currentSkeleton === null || currentSkeleton === void 0 ? void 0 : currentSkeleton.rowColumnSegment);
@@ -1648,7 +1657,7 @@ _defineProperty(UniverSheetsConditionalFormattingMobileUIPlugin, "packageName",
1648
1657
  _defineProperty(UniverSheetsConditionalFormattingMobileUIPlugin, "version", version);
1649
1658
  _defineProperty(UniverSheetsConditionalFormattingMobileUIPlugin, "type", UniverInstanceType.UNIVER_SHEET);
1650
1659
  UniverSheetsConditionalFormattingMobileUIPlugin = __decorate([
1651
- DependentOn(UniverSheetsConditionalFormattingPlugin),
1660
+ DependentOn(UniverRenderEnginePlugin, UniverSheetsPlugin, UniverSheetsFormulaPlugin, UniverSheetsConditionalFormattingPlugin, UniverSheetsMobileUIPlugin),
1652
1661
  __decorateParam(1, Inject(Injector)),
1653
1662
  __decorateParam(2, Inject(ICommandService)),
1654
1663
  __decorateParam(3, IConfigService)
@@ -2200,7 +2209,7 @@ let ConditionalFormattingViewportController = class ConditionalFormattingViewpor
2200
2209
  this._unitDisposable.dispose();
2201
2210
  this._unitDisposable = new DisposableCollection();
2202
2211
  const unitId = unit.getUnitId();
2203
- const render = this._renderManagerService.getRenderById(unitId);
2212
+ const render = this._renderManagerService.getRenderUnitById(unitId);
2204
2213
  if (!render) return;
2205
2214
  const sheetSkeletonManagerService = render.with(SheetSkeletonManagerService);
2206
2215
  this._unitDisposable.add(sheetSkeletonManagerService.currentSkeleton$.subscribe((s) => {
@@ -2239,10 +2248,11 @@ const ColorPicker$1 = (props) => {
2239
2248
  const { color, onChange, disable = false, Icon = PaintBucketDoubleIcon, className } = props;
2240
2249
  const colorKit = useMemo(() => new ColorKit(color), [color]);
2241
2250
  const renderIcon = () => {
2242
- return /* @__PURE__ */ jsx(Icon, {
2251
+ const iconProps = {
2243
2252
  className: clsx("univer-fill-primary-600", disable && className),
2244
2253
  extend: { colorChannel1: colorKit.isValid ? color : "" }
2245
- });
2254
+ };
2255
+ return /* @__PURE__ */ jsx(Icon, { ...iconProps });
2246
2256
  };
2247
2257
  return !disable ? /* @__PURE__ */ jsx(Dropdown, {
2248
2258
  overlay: /* @__PURE__ */ jsx("div", {
@@ -2401,7 +2411,7 @@ const TextInput$1 = (props) => {
2401
2411
  const [isFocusFormulaEditor, setIsFocusFormulaEditor] = useState(false);
2402
2412
  useSidebarClick((e) => {
2403
2413
  var _formulaEditorRef$cur;
2404
- !((_formulaEditorRef$cur = formulaEditorRef.current) === null || _formulaEditorRef$cur === void 0) && _formulaEditorRef$cur.isClickOutSide(e) && setIsFocusFormulaEditor(false);
2414
+ (_formulaEditorRef$cur = formulaEditorRef.current) !== null && _formulaEditorRef$cur !== void 0 && _formulaEditorRef$cur.isClickOutSide(e) && setIsFocusFormulaEditor(false);
2405
2415
  });
2406
2416
  if (type === CFValueType.formula) return /* @__PURE__ */ jsx("div", {
2407
2417
  className: "univer-ml-1 univer-w-full",
@@ -2809,7 +2819,7 @@ const InputText = (props) => {
2809
2819
  const [isFocusFormulaEditor, setIsFocusFormulaEditor] = useState(false);
2810
2820
  useSidebarClick((e) => {
2811
2821
  var _formulaEditorRef$cur;
2812
- !((_formulaEditorRef$cur = formulaEditorRef.current) === null || _formulaEditorRef$cur === void 0) && _formulaEditorRef$cur.isClickOutSide(e) && setIsFocusFormulaEditor(false);
2822
+ (_formulaEditorRef$cur = formulaEditorRef.current) !== null && _formulaEditorRef$cur !== void 0 && _formulaEditorRef$cur.isClickOutSide(e) && setIsFocusFormulaEditor(false);
2813
2823
  });
2814
2824
  const _value = useRef(value);
2815
2825
  const config = useMemo(() => {
@@ -3335,7 +3345,7 @@ const FormulaStyleEditor = (props) => {
3335
3345
  };
3336
3346
  useSidebarClick((e) => {
3337
3347
  var _formulaEditorRef$cur;
3338
- !((_formulaEditorRef$cur = formulaEditorRef.current) === null || _formulaEditorRef$cur === void 0) && _formulaEditorRef$cur.isClickOutSide(e) && setIsFocusFormulaEditor(false);
3348
+ (_formulaEditorRef$cur = formulaEditorRef.current) !== null && _formulaEditorRef$cur !== void 0 && _formulaEditorRef$cur.isClickOutSide(e) && setIsFocusFormulaEditor(false);
3339
3349
  });
3340
3350
  return /* @__PURE__ */ jsxs("div", {
3341
3351
  ref: divEleRef,
@@ -3811,7 +3821,7 @@ const TextInput = (props) => {
3811
3821
  const [isFocusFormulaEditor, setIsFocusFormulaEditor] = useState(false);
3812
3822
  useSidebarClick((e) => {
3813
3823
  var _formulaEditorRef$cur;
3814
- !((_formulaEditorRef$cur = formulaEditorRef.current) === null || _formulaEditorRef$cur === void 0) && _formulaEditorRef$cur.isClickOutSide(e) && setIsFocusFormulaEditor(false);
3824
+ (_formulaEditorRef$cur = formulaEditorRef.current) !== null && _formulaEditorRef$cur !== void 0 && _formulaEditorRef$cur.isClickOutSide(e) && setIsFocusFormulaEditor(false);
3815
3825
  });
3816
3826
  return /* @__PURE__ */ jsx("div", {
3817
3827
  className: "univer-relative",
@@ -3971,7 +3981,8 @@ const IconSetRuleEdit = (props) => {
3971
3981
  };
3972
3982
  const handleOperatorChange = (operator, index) => {
3973
3983
  onChange([String(index), "operator"], operator);
3974
- handleValueValueChange(createDefaultValue(CFSubRuleType.number, operator), index);
3984
+ const defaultValue = createDefaultValue(CFSubRuleType.number, operator);
3985
+ handleValueValueChange(defaultValue, index);
3975
3986
  };
3976
3987
  const handleValueTypeChange = (v, index) => {
3977
3988
  onChange([
@@ -3980,7 +3991,8 @@ const IconSetRuleEdit = (props) => {
3980
3991
  "type"
3981
3992
  ], v);
3982
3993
  const item = configList[index];
3983
- handleValueValueChange(createDefaultValue(CFSubRuleType.number, item.operator), index);
3994
+ const defaultValue = createDefaultValue(CFSubRuleType.number, item.operator);
3995
+ handleValueValueChange(defaultValue, index);
3984
3996
  };
3985
3997
  return useMemo(() => {
3986
3998
  return configList.map((item, index) => {
@@ -4219,7 +4231,8 @@ const IconSet = (props) => {
4219
4231
  const reverseIcon = () => {
4220
4232
  const iconList = configList.map((item) => ({ ...item }));
4221
4233
  configList.forEach((item, index) => {
4222
- const newIcon = iconList[configList.length - 1 - index];
4234
+ const mirrorIndex = configList.length - 1 - index;
4235
+ const newIcon = iconList[mirrorIndex];
4223
4236
  item.iconId = newIcon.iconId;
4224
4237
  item.iconType = newIcon.iconType;
4225
4238
  });
@@ -4595,7 +4608,8 @@ const RuleEdit = (props) => {
4595
4608
  const onRangeSelectorChange = (rangeString) => {
4596
4609
  if (!rangeSelectorTouched.current && rangeString.length < 1 && rangeResult.current.length > 0) return;
4597
4610
  rangeSelectorTouched.current = true;
4598
- rangeResult.current = rangeString.split(",").filter((e) => !!e).map(deserializeRangeWithSheet).map((item) => item.range);
4611
+ const result = rangeString.split(",").filter((e) => !!e).map(deserializeRangeWithSheet).map((item) => item.range);
4612
+ rangeResult.current = result;
4599
4613
  };
4600
4614
  const handleSubmit = () => {
4601
4615
  const getRanges = () => {
@@ -5119,7 +5133,7 @@ _defineProperty(UniverSheetsConditionalFormattingUIPlugin, "packageName", name);
5119
5133
  _defineProperty(UniverSheetsConditionalFormattingUIPlugin, "version", version);
5120
5134
  _defineProperty(UniverSheetsConditionalFormattingUIPlugin, "type", UniverInstanceType.UNIVER_SHEET);
5121
5135
  UniverSheetsConditionalFormattingUIPlugin = __decorate([
5122
- DependentOn(UniverSheetsConditionalFormattingPlugin, UniverSheetsFormulaPlugin),
5136
+ DependentOn(UniverRenderEnginePlugin, UniverSheetsPlugin, UniverUIPlugin, UniverSheetsFormulaPlugin, UniverSheetsConditionalFormattingPlugin, UniverSheetsUIPlugin),
5123
5137
  __decorateParam(1, Inject(Injector)),
5124
5138
  __decorateParam(2, Inject(ICommandService)),
5125
5139
  __decorateParam(3, IConfigService)
@@ -87,9 +87,9 @@ const locale = { "sheets-conditional-formatting-ui": {
87
87
  lastWeek: "Semana pasada",
88
88
  nextWeek: "Semana siguiente",
89
89
  today: "Hoy",
90
- topN: "Top {0}",
90
+ topN: "Principales {0}",
91
91
  bottomN: "Inferior {0}",
92
- topNPercent: "Top {0}%",
92
+ topNPercent: "Principales {0}%",
93
93
  bottomNPercent: "Inferior {0}%"
94
94
  } },
95
95
  operator: {
@@ -150,7 +150,7 @@ const locale = { "sheets-conditional-formatting-ui": {
150
150
  errorMessage: {
151
151
  notBlank: "شرط نمی‌تواند خالی باشد",
152
152
  formulaError: "فرمول اشتباه",
153
- rangeError: "Bad selection"
153
+ rangeError: "انتخاب نامعتبر"
154
154
  },
155
155
  permission: { dialog: { setStyleErr: "محدوده محافظت شده است و شما مجوز تنظیم سبک‌ها را ندارید. برای تنظیم سبک‌ها، لطفا با سازنده تماس بگیرید." } }
156
156
  } };
@@ -87,9 +87,9 @@ const locale = { "sheets-conditional-formatting-ui": {
87
87
  lastWeek: "Poprzedni tydzień",
88
88
  nextWeek: "Następny tydzień",
89
89
  today: "Dzisiaj",
90
- topN: "Top {0}",
90
+ topN: "Górne {0}",
91
91
  bottomN: "Ostatnie {0}",
92
- topNPercent: "Top {0}%",
92
+ topNPercent: "Górne {0}%",
93
93
  bottomNPercent: "Ostatnie {0}%"
94
94
  } },
95
95
  operator: {
@@ -87,9 +87,9 @@ const locale = { "sheets-conditional-formatting-ui": {
87
87
  lastWeek: "Tuần trước",
88
88
  nextWeek: "Tuần sau",
89
89
  today: "Hôm nay",
90
- topN: "Top {0}",
90
+ topN: "Trên cùng {0}",
91
91
  bottomN: "Cuối {0}",
92
- topNPercent: "Top {0}%",
92
+ topNPercent: "Trên cùng {0}%",
93
93
  bottomNPercent: "Cuối {0}%"
94
94
  } },
95
95
  operator: {
@@ -150,7 +150,7 @@ const locale = { "sheets-conditional-formatting-ui": {
150
150
  errorMessage: {
151
151
  notBlank: "Điều kiện không được để trống",
152
152
  formulaError: "Lỗi công thức",
153
- rangeError: "Bad selection"
153
+ rangeError: "Lựa chọn không hợp lệ"
154
154
  },
155
155
  permission: { dialog: { setStyleErr: "Phạm vi này đã được bảo vệ, hiện không có quyền thiết lập kiểu. Nếu cần thiết lập kiểu, vui lòng liên hệ với người tạo." } }
156
156
  } };