@univerjs/sheets-conditional-formatting-ui 1.0.0-alpha.7 → 1.0.0-beta.0

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/es/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
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";
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";
@@ -81,10 +81,9 @@ const AddDataBarConditionalRuleCommand = {
81
81
  type: CommandType.COMMAND,
82
82
  id: "sheet.command.add-data-bar-conditional-rule",
83
83
  handler(accessor, params) {
84
- var _params$ranges;
85
84
  if (!params) return false;
86
85
  const { min, max, nativeColor, positiveColor, isGradient, stopIfTrue, isShowValue } = params;
87
- const ranges = (_params$ranges = params.ranges) !== null && _params$ranges !== void 0 ? _params$ranges : accessor.get(SheetsSelectionsService).getCurrentSelections().map((selection) => selection.range);
86
+ const ranges = params.ranges ?? accessor.get(SheetsSelectionsService).getCurrentSelections().map((selection) => selection.range);
88
87
  if (!ranges.length) return false;
89
88
  const conditionalFormattingRuleModel = accessor.get(ConditionalFormattingRuleModel);
90
89
  const target = getSheetCommandTarget(accessor.get(IUniverInstanceService));
@@ -152,9 +151,8 @@ const AddIconSetConditionalRuleCommand = {
152
151
  type: CommandType.COMMAND,
153
152
  id: "sheet.command.add-icon-set-conditional-rule",
154
153
  handler(accessor, params) {
155
- var _params$ranges;
156
154
  if (!params) return false;
157
- const ranges = (_params$ranges = params.ranges) !== null && _params$ranges !== void 0 ? _params$ranges : accessor.get(SheetsSelectionsService).getCurrentSelections().map((selection) => selection.range);
155
+ const ranges = params.ranges ?? accessor.get(SheetsSelectionsService).getCurrentSelections().map((selection) => selection.range);
158
156
  if (!ranges.length) return false;
159
157
  const target = getSheetCommandTarget(accessor.get(IUniverInstanceService));
160
158
  if (!target) return false;
@@ -365,7 +363,7 @@ const AddUniqueValuesCfCommand = {
365
363
  };
366
364
 
367
365
  //#endregion
368
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/typeof.js
366
+ //#region \0@oxc-project+runtime@0.140.0/helpers/esm/typeof.js
369
367
  function _typeof(o) {
370
368
  "@babel/helpers - typeof";
371
369
  return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
@@ -376,7 +374,7 @@ function _typeof(o) {
376
374
  }
377
375
 
378
376
  //#endregion
379
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/toPrimitive.js
377
+ //#region \0@oxc-project+runtime@0.140.0/helpers/esm/toPrimitive.js
380
378
  function toPrimitive(t, r) {
381
379
  if ("object" != _typeof(t) || !t) return t;
382
380
  var e = t[Symbol.toPrimitive];
@@ -389,14 +387,14 @@ function toPrimitive(t, r) {
389
387
  }
390
388
 
391
389
  //#endregion
392
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/toPropertyKey.js
390
+ //#region \0@oxc-project+runtime@0.140.0/helpers/esm/toPropertyKey.js
393
391
  function toPropertyKey(t) {
394
392
  var i = toPrimitive(t, "string");
395
393
  return "symbol" == _typeof(i) ? i : i + "";
396
394
  }
397
395
 
398
396
  //#endregion
399
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/defineProperty.js
397
+ //#region \0@oxc-project+runtime@0.140.0/helpers/esm/defineProperty.js
400
398
  function _defineProperty(e, r, t) {
401
399
  return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
402
400
  value: t,
@@ -407,7 +405,7 @@ function _defineProperty(e, r, t) {
407
405
  }
408
406
 
409
407
  //#endregion
410
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/decorateParam.js
408
+ //#region \0@oxc-project+runtime@0.140.0/helpers/esm/decorateParam.js
411
409
  function __decorateParam(paramIndex, decorator) {
412
410
  return function(target, key) {
413
411
  decorator(target, key, paramIndex);
@@ -415,7 +413,7 @@ function __decorateParam(paramIndex, decorator) {
415
413
  }
416
414
 
417
415
  //#endregion
418
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/decorate.js
416
+ //#region \0@oxc-project+runtime@0.140.0/helpers/esm/decorate.js
419
417
  function __decorate(decorators, target, key, desc) {
420
418
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
421
419
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -986,7 +984,7 @@ const menuSchema = {
986
984
  //#endregion
987
985
  //#region package.json
988
986
  var name = "@univerjs/sheets-conditional-formatting-ui";
989
- var version = "1.0.0-alpha.7";
987
+ var version = "1.0.0-beta.0";
990
988
 
991
989
  //#endregion
992
990
  //#region src/config/config.ts
@@ -1520,9 +1518,9 @@ let SheetsCfRenderController = class SheetsCfRenderController extends Disposable
1520
1518
  _collectDirtyRanges(items, unitId, subUnitId) {
1521
1519
  const ranges = [];
1522
1520
  items.forEach((item) => {
1523
- var _item$rule, _rule$ranges;
1521
+ var _rule$ranges;
1524
1522
  if (item.unitId !== unitId || item.subUnitId !== subUnitId) return;
1525
- const rule = (_item$rule = item.rule) !== null && _item$rule !== void 0 ? _item$rule : item.cfId ? this._conditionalFormattingRuleModel.getRule(unitId, subUnitId, item.cfId) : null;
1523
+ const rule = item.rule ?? (item.cfId ? this._conditionalFormattingRuleModel.getRule(unitId, subUnitId, item.cfId) : null);
1526
1524
  if (rule === null || rule === void 0 || (_rule$ranges = rule.ranges) === null || _rule$ranges === void 0 ? void 0 : _rule$ranges.length) ranges.push(...rule.ranges);
1527
1525
  });
1528
1526
  return ranges;
@@ -1543,7 +1541,7 @@ let SheetsCfRenderController = class SheetsCfRenderController extends Disposable
1543
1541
  if (!workbook || !worksheet) return;
1544
1542
  const unitId = workbook.getUnitId();
1545
1543
  const subUnitId = worksheet.getSheetId();
1546
- const render = this._renderManagerService.getRenderById(unitId);
1544
+ const render = this._renderManagerService.getRenderUnitById(unitId);
1547
1545
  const skeletonManagerService = render === null || render === void 0 ? void 0 : render.with(SheetSkeletonManagerService);
1548
1546
  const currentSkeleton = skeletonManagerService === null || skeletonManagerService === void 0 ? void 0 : skeletonManagerService.getCurrentSkeleton();
1549
1547
  const dirtyRanges = this._intersectDirtyRangesWithRenderedRange(this._collectDirtyRanges(items, unitId, subUnitId), currentSkeleton === null || currentSkeleton === void 0 ? void 0 : currentSkeleton.rowColumnSegment);
@@ -1552,13 +1550,12 @@ let SheetsCfRenderController = class SheetsCfRenderController extends Disposable
1552
1550
  render === null || render === void 0 || (_render$mainComponent = render.mainComponent) === null || _render$mainComponent === void 0 || _render$mainComponent.makeDirty();
1553
1551
  }
1554
1552
  _markActiveSheetRulesDirty() {
1555
- var _this$_conditionalFor;
1556
1553
  const workbook = this._univerInstanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_SHEET);
1557
1554
  const worksheet = workbook === null || workbook === void 0 ? void 0 : workbook.getActiveSheet();
1558
1555
  if (!workbook || !worksheet) return;
1559
1556
  const unitId = workbook.getUnitId();
1560
1557
  const subUnitId = worksheet.getSheetId();
1561
- const rules = (_this$_conditionalFor = this._conditionalFormattingRuleModel.getSubunitRules(unitId, subUnitId)) !== null && _this$_conditionalFor !== void 0 ? _this$_conditionalFor : [];
1558
+ const rules = this._conditionalFormattingRuleModel.getSubunitRules(unitId, subUnitId) ?? [];
1562
1559
  if (!rules.length) return;
1563
1560
  this._markDirtySkeleton(rules.map((rule) => ({
1564
1561
  rule,
@@ -1657,7 +1654,7 @@ _defineProperty(UniverSheetsConditionalFormattingMobileUIPlugin, "packageName",
1657
1654
  _defineProperty(UniverSheetsConditionalFormattingMobileUIPlugin, "version", version);
1658
1655
  _defineProperty(UniverSheetsConditionalFormattingMobileUIPlugin, "type", UniverInstanceType.UNIVER_SHEET);
1659
1656
  UniverSheetsConditionalFormattingMobileUIPlugin = __decorate([
1660
- DependentOn(UniverSheetsConditionalFormattingPlugin),
1657
+ DependentOn(UniverRenderEnginePlugin, UniverSheetsPlugin, UniverSheetsFormulaPlugin, UniverSheetsConditionalFormattingPlugin, UniverSheetsMobileUIPlugin),
1661
1658
  __decorateParam(1, Inject(Injector)),
1662
1659
  __decorateParam(2, Inject(ICommandService)),
1663
1660
  __decorateParam(3, IConfigService)
@@ -1865,10 +1862,9 @@ let ConditionalFormattingEditorController = class ConditionalFormattingEditorCon
1865
1862
  */
1866
1863
  _initInterceptorEditorEnd() {
1867
1864
  this.disposeWithMe(toDisposable(this._sheetInterceptorService.writeCellInterceptor.intercept(AFTER_CELL_EDIT, { handler: (value, context, next) => {
1868
- var _result$style;
1869
1865
  if (!value) next(value);
1870
1866
  const result = this._conditionalFormattingService.composeStyle(context.unitId, context.subUnitId, context.row, context.col);
1871
- const cfStyle = (_result$style = result === null || result === void 0 ? void 0 : result.style) !== null && _result$style !== void 0 ? _result$style : {};
1867
+ const cfStyle = (result === null || result === void 0 ? void 0 : result.style) ?? {};
1872
1868
  const keys = Object.keys(cfStyle);
1873
1869
  if (value === null || value === void 0 ? void 0 : value.p) {
1874
1870
  var _value$p$body;
@@ -2032,7 +2028,6 @@ let ConditionalFormattingPainterController = class ConditionalFormattingPainterC
2032
2028
  });
2033
2029
  };
2034
2030
  const generalApplyFunc = (targetUnitId, targetSubUnitId, targetRange) => {
2035
- var _this$_conditionalFor;
2036
2031
  const { range: sourceRange, unitId: sourceUnitId, subUnitId: sourceSubUnitId } = this._painterConfig;
2037
2032
  const isSkipSheet = targetUnitId !== sourceUnitId || sourceSubUnitId !== targetSubUnitId;
2038
2033
  const rangeMap = /* @__PURE__ */ new Map();
@@ -2040,7 +2035,7 @@ let ConditionalFormattingPainterController = class ConditionalFormattingPainterC
2040
2035
  const redos = [];
2041
2036
  const undos = [];
2042
2037
  if (!targetUnitId || !targetSubUnitId || !sourceUnitId || !sourceSubUnitId) return noopReturnFunc();
2043
- const ruleList = (_this$_conditionalFor = this._conditionalFormattingRuleModel.getSubunitRules(sourceUnitId, sourceSubUnitId)) !== null && _this$_conditionalFor !== void 0 ? _this$_conditionalFor : [];
2038
+ const ruleList = this._conditionalFormattingRuleModel.getSubunitRules(sourceUnitId, sourceSubUnitId) ?? [];
2044
2039
  ruleList === null || ruleList === void 0 || ruleList.forEach((rule) => {
2045
2040
  const { ranges, cfId } = rule;
2046
2041
  if (ranges.some((range) => Rectangle.intersects(sourceRange, range))) rangeMap.set(cfId, isSkipSheet ? [] : ranges);
@@ -2209,7 +2204,7 @@ let ConditionalFormattingViewportController = class ConditionalFormattingViewpor
2209
2204
  this._unitDisposable.dispose();
2210
2205
  this._unitDisposable = new DisposableCollection();
2211
2206
  const unitId = unit.getUnitId();
2212
- const render = this._renderManagerService.getRenderById(unitId);
2207
+ const render = this._renderManagerService.getRenderUnitById(unitId);
2213
2208
  if (!render) return;
2214
2209
  const sheetSkeletonManagerService = render.with(SheetSkeletonManagerService);
2215
2210
  this._unitDisposable.add(sheetSkeletonManagerService.currentSkeleton$.subscribe((s) => {
@@ -2248,10 +2243,11 @@ const ColorPicker$1 = (props) => {
2248
2243
  const { color, onChange, disable = false, Icon = PaintBucketDoubleIcon, className } = props;
2249
2244
  const colorKit = useMemo(() => new ColorKit(color), [color]);
2250
2245
  const renderIcon = () => {
2251
- return /* @__PURE__ */ jsx(Icon, {
2246
+ const iconProps = {
2252
2247
  className: clsx("univer-fill-primary-600", disable && className),
2253
2248
  extend: { colorChannel1: colorKit.isValid ? color : "" }
2254
- });
2249
+ };
2250
+ return /* @__PURE__ */ jsx(Icon, { ...iconProps });
2255
2251
  };
2256
2252
  return !disable ? /* @__PURE__ */ jsx(Dropdown, {
2257
2253
  overlay: /* @__PURE__ */ jsx("div", {
@@ -2293,7 +2289,6 @@ function Preview(props) {
2293
2289
  const previewClassName = "univer-pointer-events-none univer-flex univer-h-5 univer-min-w-[72px] univer-items-center univer-justify-center univer-text-xs";
2294
2290
  switch (rule.type) {
2295
2291
  case CFRuleType.dataBar: {
2296
- var _rule$config$nativeCo, _rule$config$positive;
2297
2292
  const { isGradient } = rule.config;
2298
2293
  const positiveColor = isGradient ? `linear-gradient(to right, ${rule.config.positiveColor || defaultDataBarPositiveColor}, rgb(255 255 255))` : rule.config.positiveColor;
2299
2294
  return /* @__PURE__ */ jsxs("div", {
@@ -2302,13 +2297,13 @@ function Preview(props) {
2302
2297
  className: "univer-h-full univer-w-1/2 univer-border univer-border-solid",
2303
2298
  style: {
2304
2299
  background: isGradient ? `linear-gradient(to right, rgb(255 255 255),${rule.config.nativeColor || defaultDataBarNativeColor})` : rule.config.nativeColor,
2305
- borderColor: (_rule$config$nativeCo = rule.config.nativeColor) !== null && _rule$config$nativeCo !== void 0 ? _rule$config$nativeCo : defaultDataBarNativeColor
2300
+ borderColor: rule.config.nativeColor ?? defaultDataBarNativeColor
2306
2301
  }
2307
2302
  }), /* @__PURE__ */ jsx("div", {
2308
2303
  className: "univer-h-full univer-w-1/2 univer-border univer-border-solid",
2309
2304
  style: {
2310
2305
  background: positiveColor,
2311
- borderColor: (_rule$config$positive = rule.config.positiveColor) !== null && _rule$config$positive !== void 0 ? _rule$config$positive : defaultDataBarPositiveColor
2306
+ borderColor: rule.config.positiveColor ?? defaultDataBarPositiveColor
2312
2307
  }
2313
2308
  })]
2314
2309
  });
@@ -2332,16 +2327,15 @@ function Preview(props) {
2332
2327
  }, index) : /* @__PURE__ */ jsx(SlashDoubleIcon, {}, index))
2333
2328
  });
2334
2329
  case CFRuleType.highlightCell: {
2335
- var _bg$rgb, _cl$rgb, _replace;
2336
2330
  const { ul, st, it, bl, bg, cl } = rule.style;
2337
2331
  const isUnderline = (ul === null || ul === void 0 ? void 0 : ul.s) === BooleanNumber.TRUE;
2338
2332
  const isStrikethrough = (st === null || st === void 0 ? void 0 : st.s) === BooleanNumber.TRUE;
2339
2333
  const isItalic = it === BooleanNumber.TRUE;
2340
2334
  const isBold = bl === BooleanNumber.TRUE;
2341
- const bgColor = (_bg$rgb = bg === null || bg === void 0 ? void 0 : bg.rgb) !== null && _bg$rgb !== void 0 ? _bg$rgb : DEFAULT_BG_COLOR;
2342
- const fontColor = (_cl$rgb = cl === null || cl === void 0 ? void 0 : cl.rgb) !== null && _cl$rgb !== void 0 ? _cl$rgb : DEFAULT_FONT_COLOR;
2335
+ const bgColor = (bg === null || bg === void 0 ? void 0 : bg.rgb) ?? DEFAULT_BG_COLOR;
2336
+ const fontColor = (cl === null || cl === void 0 ? void 0 : cl.rgb) ?? DEFAULT_FONT_COLOR;
2343
2337
  const style = {
2344
- textDecoration: (_replace = `${isUnderline ? "underline" : ""} ${isStrikethrough ? "line-through" : ""}`.replace(/^ /, "")) !== null && _replace !== void 0 ? _replace : void 0,
2338
+ textDecoration: `${isUnderline ? "underline" : ""} ${isStrikethrough ? "line-through" : ""}`.replace(/^ /, "") ?? void 0,
2345
2339
  backgroundColor: bgColor,
2346
2340
  color: fontColor
2347
2341
  };
@@ -2410,7 +2404,7 @@ const TextInput$1 = (props) => {
2410
2404
  const [isFocusFormulaEditor, setIsFocusFormulaEditor] = useState(false);
2411
2405
  useSidebarClick((e) => {
2412
2406
  var _formulaEditorRef$cur;
2413
- !((_formulaEditorRef$cur = formulaEditorRef.current) === null || _formulaEditorRef$cur === void 0) && _formulaEditorRef$cur.isClickOutSide(e) && setIsFocusFormulaEditor(false);
2407
+ (_formulaEditorRef$cur = formulaEditorRef.current) !== null && _formulaEditorRef$cur !== void 0 && _formulaEditorRef$cur.isClickOutSide(e) && setIsFocusFormulaEditor(false);
2414
2408
  });
2415
2409
  if (type === CFValueType.formula) return /* @__PURE__ */ jsx("div", {
2416
2410
  className: "univer-ml-1 univer-w-full",
@@ -2818,7 +2812,7 @@ const InputText = (props) => {
2818
2812
  const [isFocusFormulaEditor, setIsFocusFormulaEditor] = useState(false);
2819
2813
  useSidebarClick((e) => {
2820
2814
  var _formulaEditorRef$cur;
2821
- !((_formulaEditorRef$cur = formulaEditorRef.current) === null || _formulaEditorRef$cur === void 0) && _formulaEditorRef$cur.isClickOutSide(e) && setIsFocusFormulaEditor(false);
2815
+ (_formulaEditorRef$cur = formulaEditorRef.current) !== null && _formulaEditorRef$cur !== void 0 && _formulaEditorRef$cur.isClickOutSide(e) && setIsFocusFormulaEditor(false);
2822
2816
  });
2823
2817
  const _value = useRef(value);
2824
2818
  const config = useMemo(() => {
@@ -3344,7 +3338,7 @@ const FormulaStyleEditor = (props) => {
3344
3338
  };
3345
3339
  useSidebarClick((e) => {
3346
3340
  var _formulaEditorRef$cur;
3347
- !((_formulaEditorRef$cur = formulaEditorRef.current) === null || _formulaEditorRef$cur === void 0) && _formulaEditorRef$cur.isClickOutSide(e) && setIsFocusFormulaEditor(false);
3341
+ (_formulaEditorRef$cur = formulaEditorRef.current) !== null && _formulaEditorRef$cur !== void 0 && _formulaEditorRef$cur.isClickOutSide(e) && setIsFocusFormulaEditor(false);
3348
3342
  });
3349
3343
  return /* @__PURE__ */ jsxs("div", {
3350
3344
  ref: divEleRef,
@@ -3404,13 +3398,10 @@ const FormulaStyleEditor = (props) => {
3404
3398
  //#endregion
3405
3399
  //#region src/views/wrapper-error/WrapperError.tsx
3406
3400
  const WrapperError = (props) => {
3407
- return /* @__PURE__ */ jsxs("div", {
3408
- className: "univer-relative",
3409
- children: [/* @__PURE__ */ jsx("div", {
3410
- className: "univer-absolute univer-bottom-[-13px] univer-z-[999] univer-text-[10px] univer-text-red-500",
3411
- children: props.errorText
3412
- }), props.children]
3413
- });
3401
+ return /* @__PURE__ */ jsxs("div", { children: [props.children, props.errorText && /* @__PURE__ */ jsx("div", {
3402
+ className: "univer-mt-1 univer-text-xs univer-text-red-500",
3403
+ children: props.errorText
3404
+ })] });
3414
3405
  };
3415
3406
 
3416
3407
  //#endregion
@@ -3672,11 +3663,10 @@ const HighlightCellStyleEditor = (props) => {
3672
3663
  });
3673
3664
  const [style, setStyle] = useState({});
3674
3665
  const getResult = useMemo(() => (option) => {
3675
- var _option$subType, _option$operator, _option$value, _option$style;
3676
- const nextSubType = (_option$subType = option.subType) !== null && _option$subType !== void 0 ? _option$subType : subType;
3677
- const nextOperator = (_option$operator = option.operator) !== null && _option$operator !== void 0 ? _option$operator : operator;
3678
- const nextValue = (_option$value = option.value) !== null && _option$value !== void 0 ? _option$value : value;
3679
- const nextStyle = (_option$style = option.style) !== null && _option$style !== void 0 ? _option$style : style;
3666
+ const nextSubType = option.subType ?? subType;
3667
+ const nextOperator = option.operator ?? operator;
3668
+ const nextValue = option.value ?? value;
3669
+ const nextStyle = option.style ?? style;
3680
3670
  switch (nextSubType) {
3681
3671
  case CFSubRuleType.duplicateValues: return {
3682
3672
  type: CFRuleType.highlightCell,
@@ -3820,14 +3810,14 @@ const TextInput = (props) => {
3820
3810
  const [isFocusFormulaEditor, setIsFocusFormulaEditor] = useState(false);
3821
3811
  useSidebarClick((e) => {
3822
3812
  var _formulaEditorRef$cur;
3823
- !((_formulaEditorRef$cur = formulaEditorRef.current) === null || _formulaEditorRef$cur === void 0) && _formulaEditorRef$cur.isClickOutSide(e) && setIsFocusFormulaEditor(false);
3813
+ (_formulaEditorRef$cur = formulaEditorRef.current) !== null && _formulaEditorRef$cur !== void 0 && _formulaEditorRef$cur.isClickOutSide(e) && setIsFocusFormulaEditor(false);
3824
3814
  });
3825
3815
  return /* @__PURE__ */ jsx("div", {
3826
3816
  className: "univer-relative",
3827
3817
  children: type !== CFValueType.formula ? /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(InputNumber, {
3828
3818
  className: clsx({ "univer-border-red-500": error }),
3829
3819
  value: Number(props.value) || 0,
3830
- onChange: (v) => onChange(v !== null && v !== void 0 ? v : 0)
3820
+ onChange: (v) => onChange(v ?? 0)
3831
3821
  }), error && /* @__PURE__ */ jsx("div", {
3832
3822
  className: "univer-absolute univer-text-xs univer-text-red-500",
3833
3823
  children: error
@@ -3980,7 +3970,8 @@ const IconSetRuleEdit = (props) => {
3980
3970
  };
3981
3971
  const handleOperatorChange = (operator, index) => {
3982
3972
  onChange([String(index), "operator"], operator);
3983
- handleValueValueChange(createDefaultValue(CFSubRuleType.number, operator), index);
3973
+ const defaultValue = createDefaultValue(CFSubRuleType.number, operator);
3974
+ handleValueValueChange(defaultValue, index);
3984
3975
  };
3985
3976
  const handleValueTypeChange = (v, index) => {
3986
3977
  onChange([
@@ -3989,7 +3980,8 @@ const IconSetRuleEdit = (props) => {
3989
3980
  "type"
3990
3981
  ], v);
3991
3982
  const item = configList[index];
3992
- handleValueValueChange(createDefaultValue(CFSubRuleType.number, item.operator), index);
3983
+ const defaultValue = createDefaultValue(CFSubRuleType.number, item.operator);
3984
+ handleValueValueChange(defaultValue, index);
3993
3985
  };
3994
3986
  return useMemo(() => {
3995
3987
  return configList.map((item, index) => {
@@ -4228,7 +4220,8 @@ const IconSet = (props) => {
4228
4220
  const reverseIcon = () => {
4229
4221
  const iconList = configList.map((item) => ({ ...item }));
4230
4222
  configList.forEach((item, index) => {
4231
- const newIcon = iconList[configList.length - 1 - index];
4223
+ const mirrorIndex = configList.length - 1 - index;
4224
+ const newIcon = iconList[mirrorIndex];
4232
4225
  item.iconId = newIcon.iconId;
4233
4226
  item.iconType = newIcon.iconType;
4234
4227
  });
@@ -4494,7 +4487,7 @@ const getSubUnitId = (univerInstanceService) => {
4494
4487
  return (_getActiveSheet = univerInstanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_SHEET).getActiveSheet()) === null || _getActiveSheet === void 0 ? void 0 : _getActiveSheet.getSheetId();
4495
4488
  };
4496
4489
  const RuleEdit = (props) => {
4497
- var _props$rule$ranges, _props$rule, _props$rule5;
4490
+ var _props$rule, _props$rule5;
4498
4491
  const localeService = useDependency(LocaleService);
4499
4492
  const commandService = useDependency(ICommandService);
4500
4493
  const univerInstanceService = useDependency(IUniverInstanceService);
@@ -4503,14 +4496,14 @@ const RuleEdit = (props) => {
4503
4496
  const unitId = getUnitId(univerInstanceService);
4504
4497
  const subUnitId = getSubUnitId(univerInstanceService);
4505
4498
  const [errorText, setErrorText] = useState(void 0);
4506
- const rangeResult = useRef((_props$rule$ranges = (_props$rule = props.rule) === null || _props$rule === void 0 ? void 0 : _props$rule.ranges) !== null && _props$rule$ranges !== void 0 ? _props$rule$ranges : []);
4499
+ const rangeResult = useRef(((_props$rule = props.rule) === null || _props$rule === void 0 ? void 0 : _props$rule.ranges) ?? []);
4507
4500
  const rangeSelectorTouched = useRef(false);
4508
4501
  const rangeString = useMemo(() => {
4509
4502
  var _props$rule2;
4510
4503
  let ranges = (_props$rule2 = props.rule) === null || _props$rule2 === void 0 ? void 0 : _props$rule2.ranges;
4511
4504
  if (!(ranges === null || ranges === void 0 ? void 0 : ranges.length)) {
4512
- var _selectionManagerServ, _selectionManagerServ2;
4513
- ranges = (_selectionManagerServ = (_selectionManagerServ2 = selectionManagerService.getCurrentSelections()) === null || _selectionManagerServ2 === void 0 ? void 0 : _selectionManagerServ2.map((s) => s.range)) !== null && _selectionManagerServ !== void 0 ? _selectionManagerServ : [];
4505
+ var _selectionManagerServ;
4506
+ ranges = ((_selectionManagerServ = selectionManagerService.getCurrentSelections()) === null || _selectionManagerServ === void 0 ? void 0 : _selectionManagerServ.map((s) => s.range)) ?? [];
4514
4507
  }
4515
4508
  rangeResult.current = ranges;
4516
4509
  if (!(ranges === null || ranges === void 0 ? void 0 : ranges.length)) return "";
@@ -4604,7 +4597,8 @@ const RuleEdit = (props) => {
4604
4597
  const onRangeSelectorChange = (rangeString) => {
4605
4598
  if (!rangeSelectorTouched.current && rangeString.length < 1 && rangeResult.current.length > 0) return;
4606
4599
  rangeSelectorTouched.current = true;
4607
- rangeResult.current = rangeString.split(",").filter((e) => !!e).map(deserializeRangeWithSheet).map((item) => item.range);
4600
+ const result = rangeString.split(",").filter((e) => !!e).map(deserializeRangeWithSheet).map((item) => item.range);
4601
+ rangeResult.current = result;
4608
4602
  };
4609
4603
  const handleSubmit = () => {
4610
4604
  const getRanges = () => {
@@ -4823,9 +4817,8 @@ function RuleList(props) {
4823
4817
  });
4824
4818
  };
4825
4819
  const handleDragStart = (_layout, from) => {
4826
- var _dragRule$cfId;
4827
4820
  const dragRule = ruleListByPermissionCheck[from.y];
4828
- setDraggingId((_dragRule$cfId = dragRule === null || dragRule === void 0 ? void 0 : dragRule.cfId) !== null && _dragRule$cfId !== void 0 ? _dragRule$cfId : "");
4821
+ setDraggingId((dragRule === null || dragRule === void 0 ? void 0 : dragRule.cfId) ?? "");
4829
4822
  };
4830
4823
  const handleDragStop = (_layout, from, to) => {
4831
4824
  var _getActiveSheet2, _ruleListByPermission, _ruleListByPermission2;
@@ -5128,7 +5121,7 @@ _defineProperty(UniverSheetsConditionalFormattingUIPlugin, "packageName", name);
5128
5121
  _defineProperty(UniverSheetsConditionalFormattingUIPlugin, "version", version);
5129
5122
  _defineProperty(UniverSheetsConditionalFormattingUIPlugin, "type", UniverInstanceType.UNIVER_SHEET);
5130
5123
  UniverSheetsConditionalFormattingUIPlugin = __decorate([
5131
- DependentOn(UniverSheetsConditionalFormattingPlugin, UniverSheetsFormulaPlugin),
5124
+ DependentOn(UniverRenderEnginePlugin, UniverSheetsPlugin, UniverSheetsFormulaPlugin, UniverSheetsConditionalFormattingPlugin, UniverSheetsUIPlugin),
5132
5125
  __decorateParam(1, Inject(Injector)),
5133
5126
  __decorateParam(2, Inject(ICommandService)),
5134
5127
  __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
  } };
package/lib/index.css CHANGED
@@ -10,10 +10,6 @@
10
10
  position: relative;
11
11
  }
12
12
 
13
- .univer-bottom-\[-13px\] {
14
- bottom: -13px;
15
- }
16
-
17
13
  .univer-left-0 {
18
14
  left: 0;
19
15
  }
@@ -22,10 +18,6 @@
22
18
  right: .25rem;
23
19
  }
24
20
 
25
- .univer-z-\[999\] {
26
- z-index: 999;
27
- }
28
-
29
21
  .univer-my-2\.5 {
30
22
  margin-top: .625rem;
31
23
  margin-bottom: .625rem;
@@ -341,10 +333,6 @@
341
333
  padding-top: .5rem;
342
334
  }
343
335
 
344
- .univer-text-\[10px\] {
345
- font-size: 10px;
346
- }
347
-
348
336
  .univer-text-sm {
349
337
  font-size: .875rem;
350
338
  line-height: 1.25rem;