@univerjs/sheets-conditional-formatting-ui 1.0.0-alpha.8 → 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/cjs/index.js CHANGED
@@ -82,10 +82,9 @@ const AddDataBarConditionalRuleCommand = {
82
82
  type: _univerjs_core.CommandType.COMMAND,
83
83
  id: "sheet.command.add-data-bar-conditional-rule",
84
84
  handler(accessor, params) {
85
- var _params$ranges;
86
85
  if (!params) return false;
87
86
  const { min, max, nativeColor, positiveColor, isGradient, stopIfTrue, isShowValue } = params;
88
- const ranges = (_params$ranges = params.ranges) !== null && _params$ranges !== void 0 ? _params$ranges : accessor.get(_univerjs_sheets.SheetsSelectionsService).getCurrentSelections().map((selection) => selection.range);
87
+ const ranges = params.ranges ?? accessor.get(_univerjs_sheets.SheetsSelectionsService).getCurrentSelections().map((selection) => selection.range);
89
88
  if (!ranges.length) return false;
90
89
  const conditionalFormattingRuleModel = accessor.get(_univerjs_sheets_conditional_formatting.ConditionalFormattingRuleModel);
91
90
  const target = (0, _univerjs_sheets.getSheetCommandTarget)(accessor.get(_univerjs_core.IUniverInstanceService));
@@ -153,9 +152,8 @@ const AddIconSetConditionalRuleCommand = {
153
152
  type: _univerjs_core.CommandType.COMMAND,
154
153
  id: "sheet.command.add-icon-set-conditional-rule",
155
154
  handler(accessor, params) {
156
- var _params$ranges;
157
155
  if (!params) return false;
158
- const ranges = (_params$ranges = params.ranges) !== null && _params$ranges !== void 0 ? _params$ranges : accessor.get(_univerjs_sheets.SheetsSelectionsService).getCurrentSelections().map((selection) => selection.range);
156
+ const ranges = params.ranges ?? accessor.get(_univerjs_sheets.SheetsSelectionsService).getCurrentSelections().map((selection) => selection.range);
159
157
  if (!ranges.length) return false;
160
158
  const target = (0, _univerjs_sheets.getSheetCommandTarget)(accessor.get(_univerjs_core.IUniverInstanceService));
161
159
  if (!target) return false;
@@ -987,7 +985,7 @@ const menuSchema = {
987
985
  //#endregion
988
986
  //#region package.json
989
987
  var name = "@univerjs/sheets-conditional-formatting-ui";
990
- var version = "1.0.0-alpha.8";
988
+ var version = "1.0.0-beta.0";
991
989
 
992
990
  //#endregion
993
991
  //#region src/config/config.ts
@@ -1521,9 +1519,9 @@ let SheetsCfRenderController = class SheetsCfRenderController extends _univerjs_
1521
1519
  _collectDirtyRanges(items, unitId, subUnitId) {
1522
1520
  const ranges = [];
1523
1521
  items.forEach((item) => {
1524
- var _item$rule, _rule$ranges;
1522
+ var _rule$ranges;
1525
1523
  if (item.unitId !== unitId || item.subUnitId !== subUnitId) return;
1526
- const rule = (_item$rule = item.rule) !== null && _item$rule !== void 0 ? _item$rule : item.cfId ? this._conditionalFormattingRuleModel.getRule(unitId, subUnitId, item.cfId) : null;
1524
+ const rule = item.rule ?? (item.cfId ? this._conditionalFormattingRuleModel.getRule(unitId, subUnitId, item.cfId) : null);
1527
1525
  if (rule === null || rule === void 0 || (_rule$ranges = rule.ranges) === null || _rule$ranges === void 0 ? void 0 : _rule$ranges.length) ranges.push(...rule.ranges);
1528
1526
  });
1529
1527
  return ranges;
@@ -1553,13 +1551,12 @@ let SheetsCfRenderController = class SheetsCfRenderController extends _univerjs_
1553
1551
  render === null || render === void 0 || (_render$mainComponent = render.mainComponent) === null || _render$mainComponent === void 0 || _render$mainComponent.makeDirty();
1554
1552
  }
1555
1553
  _markActiveSheetRulesDirty() {
1556
- var _this$_conditionalFor;
1557
1554
  const workbook = this._univerInstanceService.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_SHEET);
1558
1555
  const worksheet = workbook === null || workbook === void 0 ? void 0 : workbook.getActiveSheet();
1559
1556
  if (!workbook || !worksheet) return;
1560
1557
  const unitId = workbook.getUnitId();
1561
1558
  const subUnitId = worksheet.getSheetId();
1562
- const rules = (_this$_conditionalFor = this._conditionalFormattingRuleModel.getSubunitRules(unitId, subUnitId)) !== null && _this$_conditionalFor !== void 0 ? _this$_conditionalFor : [];
1559
+ const rules = this._conditionalFormattingRuleModel.getSubunitRules(unitId, subUnitId) ?? [];
1563
1560
  if (!rules.length) return;
1564
1561
  this._markDirtySkeleton(rules.map((rule) => ({
1565
1562
  rule,
@@ -1866,10 +1863,9 @@ let ConditionalFormattingEditorController = class ConditionalFormattingEditorCon
1866
1863
  */
1867
1864
  _initInterceptorEditorEnd() {
1868
1865
  this.disposeWithMe((0, _univerjs_core.toDisposable)(this._sheetInterceptorService.writeCellInterceptor.intercept(_univerjs_sheets.AFTER_CELL_EDIT, { handler: (value, context, next) => {
1869
- var _result$style;
1870
1866
  if (!value) next(value);
1871
1867
  const result = this._conditionalFormattingService.composeStyle(context.unitId, context.subUnitId, context.row, context.col);
1872
- const cfStyle = (_result$style = result === null || result === void 0 ? void 0 : result.style) !== null && _result$style !== void 0 ? _result$style : {};
1868
+ const cfStyle = (result === null || result === void 0 ? void 0 : result.style) ?? {};
1873
1869
  const keys = Object.keys(cfStyle);
1874
1870
  if (value === null || value === void 0 ? void 0 : value.p) {
1875
1871
  var _value$p$body;
@@ -2033,7 +2029,6 @@ let ConditionalFormattingPainterController = class ConditionalFormattingPainterC
2033
2029
  });
2034
2030
  };
2035
2031
  const generalApplyFunc = (targetUnitId, targetSubUnitId, targetRange) => {
2036
- var _this$_conditionalFor;
2037
2032
  const { range: sourceRange, unitId: sourceUnitId, subUnitId: sourceSubUnitId } = this._painterConfig;
2038
2033
  const isSkipSheet = targetUnitId !== sourceUnitId || sourceSubUnitId !== targetSubUnitId;
2039
2034
  const rangeMap = /* @__PURE__ */ new Map();
@@ -2041,7 +2036,7 @@ let ConditionalFormattingPainterController = class ConditionalFormattingPainterC
2041
2036
  const redos = [];
2042
2037
  const undos = [];
2043
2038
  if (!targetUnitId || !targetSubUnitId || !sourceUnitId || !sourceSubUnitId) return noopReturnFunc();
2044
- const ruleList = (_this$_conditionalFor = this._conditionalFormattingRuleModel.getSubunitRules(sourceUnitId, sourceSubUnitId)) !== null && _this$_conditionalFor !== void 0 ? _this$_conditionalFor : [];
2039
+ const ruleList = this._conditionalFormattingRuleModel.getSubunitRules(sourceUnitId, sourceSubUnitId) ?? [];
2045
2040
  ruleList === null || ruleList === void 0 || ruleList.forEach((rule) => {
2046
2041
  const { ranges, cfId } = rule;
2047
2042
  if (ranges.some((range) => _univerjs_core.Rectangle.intersects(sourceRange, range))) rangeMap.set(cfId, isSkipSheet ? [] : ranges);
@@ -2295,7 +2290,6 @@ function Preview(props) {
2295
2290
  const previewClassName = "univer-pointer-events-none univer-flex univer-h-5 univer-min-w-[72px] univer-items-center univer-justify-center univer-text-xs";
2296
2291
  switch (rule.type) {
2297
2292
  case _univerjs_sheets_conditional_formatting.CFRuleType.dataBar: {
2298
- var _rule$config$nativeCo, _rule$config$positive;
2299
2293
  const { isGradient } = rule.config;
2300
2294
  const positiveColor = isGradient ? `linear-gradient(to right, ${rule.config.positiveColor || _univerjs_sheets_conditional_formatting.defaultDataBarPositiveColor}, rgb(255 255 255))` : rule.config.positiveColor;
2301
2295
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
@@ -2304,13 +2298,13 @@ function Preview(props) {
2304
2298
  className: "univer-h-full univer-w-1/2 univer-border univer-border-solid",
2305
2299
  style: {
2306
2300
  background: isGradient ? `linear-gradient(to right, rgb(255 255 255),${rule.config.nativeColor || _univerjs_sheets_conditional_formatting.defaultDataBarNativeColor})` : rule.config.nativeColor,
2307
- borderColor: (_rule$config$nativeCo = rule.config.nativeColor) !== null && _rule$config$nativeCo !== void 0 ? _rule$config$nativeCo : _univerjs_sheets_conditional_formatting.defaultDataBarNativeColor
2301
+ borderColor: rule.config.nativeColor ?? _univerjs_sheets_conditional_formatting.defaultDataBarNativeColor
2308
2302
  }
2309
2303
  }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2310
2304
  className: "univer-h-full univer-w-1/2 univer-border univer-border-solid",
2311
2305
  style: {
2312
2306
  background: positiveColor,
2313
- borderColor: (_rule$config$positive = rule.config.positiveColor) !== null && _rule$config$positive !== void 0 ? _rule$config$positive : _univerjs_sheets_conditional_formatting.defaultDataBarPositiveColor
2307
+ borderColor: rule.config.positiveColor ?? _univerjs_sheets_conditional_formatting.defaultDataBarPositiveColor
2314
2308
  }
2315
2309
  })]
2316
2310
  });
@@ -2334,16 +2328,15 @@ function Preview(props) {
2334
2328
  }, index) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.SlashDoubleIcon, {}, index))
2335
2329
  });
2336
2330
  case _univerjs_sheets_conditional_formatting.CFRuleType.highlightCell: {
2337
- var _bg$rgb, _cl$rgb, _replace;
2338
2331
  const { ul, st, it, bl, bg, cl } = rule.style;
2339
2332
  const isUnderline = (ul === null || ul === void 0 ? void 0 : ul.s) === _univerjs_core.BooleanNumber.TRUE;
2340
2333
  const isStrikethrough = (st === null || st === void 0 ? void 0 : st.s) === _univerjs_core.BooleanNumber.TRUE;
2341
2334
  const isItalic = it === _univerjs_core.BooleanNumber.TRUE;
2342
2335
  const isBold = bl === _univerjs_core.BooleanNumber.TRUE;
2343
- const bgColor = (_bg$rgb = bg === null || bg === void 0 ? void 0 : bg.rgb) !== null && _bg$rgb !== void 0 ? _bg$rgb : _univerjs_sheets_conditional_formatting.DEFAULT_BG_COLOR;
2344
- const fontColor = (_cl$rgb = cl === null || cl === void 0 ? void 0 : cl.rgb) !== null && _cl$rgb !== void 0 ? _cl$rgb : _univerjs_sheets_conditional_formatting.DEFAULT_FONT_COLOR;
2336
+ const bgColor = (bg === null || bg === void 0 ? void 0 : bg.rgb) ?? _univerjs_sheets_conditional_formatting.DEFAULT_BG_COLOR;
2337
+ const fontColor = (cl === null || cl === void 0 ? void 0 : cl.rgb) ?? _univerjs_sheets_conditional_formatting.DEFAULT_FONT_COLOR;
2345
2338
  const style = {
2346
- textDecoration: (_replace = `${isUnderline ? "underline" : ""} ${isStrikethrough ? "line-through" : ""}`.replace(/^ /, "")) !== null && _replace !== void 0 ? _replace : void 0,
2339
+ textDecoration: `${isUnderline ? "underline" : ""} ${isStrikethrough ? "line-through" : ""}`.replace(/^ /, "") ?? void 0,
2347
2340
  backgroundColor: bgColor,
2348
2341
  color: fontColor
2349
2342
  };
@@ -3406,13 +3399,10 @@ const FormulaStyleEditor = (props) => {
3406
3399
  //#endregion
3407
3400
  //#region src/views/wrapper-error/WrapperError.tsx
3408
3401
  const WrapperError = (props) => {
3409
- return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
3410
- className: "univer-relative",
3411
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3412
- className: "univer-absolute univer-bottom-[-13px] univer-z-[999] univer-text-[10px] univer-text-red-500",
3413
- children: props.errorText
3414
- }), props.children]
3415
- });
3402
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [props.children, props.errorText && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3403
+ className: "univer-mt-1 univer-text-xs univer-text-red-500",
3404
+ children: props.errorText
3405
+ })] });
3416
3406
  };
3417
3407
 
3418
3408
  //#endregion
@@ -3674,11 +3664,10 @@ const HighlightCellStyleEditor = (props) => {
3674
3664
  });
3675
3665
  const [style, setStyle] = (0, react.useState)({});
3676
3666
  const getResult = (0, react.useMemo)(() => (option) => {
3677
- var _option$subType, _option$operator, _option$value, _option$style;
3678
- const nextSubType = (_option$subType = option.subType) !== null && _option$subType !== void 0 ? _option$subType : subType;
3679
- const nextOperator = (_option$operator = option.operator) !== null && _option$operator !== void 0 ? _option$operator : operator;
3680
- const nextValue = (_option$value = option.value) !== null && _option$value !== void 0 ? _option$value : value;
3681
- const nextStyle = (_option$style = option.style) !== null && _option$style !== void 0 ? _option$style : style;
3667
+ const nextSubType = option.subType ?? subType;
3668
+ const nextOperator = option.operator ?? operator;
3669
+ const nextValue = option.value ?? value;
3670
+ const nextStyle = option.style ?? style;
3682
3671
  switch (nextSubType) {
3683
3672
  case _univerjs_sheets_conditional_formatting.CFSubRuleType.duplicateValues: return {
3684
3673
  type: _univerjs_sheets_conditional_formatting.CFRuleType.highlightCell,
@@ -3829,7 +3818,7 @@ const TextInput = (props) => {
3829
3818
  children: type !== _univerjs_sheets_conditional_formatting.CFValueType.formula ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.InputNumber, {
3830
3819
  className: (0, _univerjs_design.clsx)({ "univer-border-red-500": error }),
3831
3820
  value: Number(props.value) || 0,
3832
- onChange: (v) => onChange(v !== null && v !== void 0 ? v : 0)
3821
+ onChange: (v) => onChange(v ?? 0)
3833
3822
  }), error && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3834
3823
  className: "univer-absolute univer-text-xs univer-text-red-500",
3835
3824
  children: error
@@ -4499,7 +4488,7 @@ const getSubUnitId = (univerInstanceService) => {
4499
4488
  return (_getActiveSheet = univerInstanceService.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_SHEET).getActiveSheet()) === null || _getActiveSheet === void 0 ? void 0 : _getActiveSheet.getSheetId();
4500
4489
  };
4501
4490
  const RuleEdit = (props) => {
4502
- var _props$rule$ranges, _props$rule, _props$rule5;
4491
+ var _props$rule, _props$rule5;
4503
4492
  const localeService = (0, _univerjs_ui.useDependency)(_univerjs_core.LocaleService);
4504
4493
  const commandService = (0, _univerjs_ui.useDependency)(_univerjs_core.ICommandService);
4505
4494
  const univerInstanceService = (0, _univerjs_ui.useDependency)(_univerjs_core.IUniverInstanceService);
@@ -4508,14 +4497,14 @@ const RuleEdit = (props) => {
4508
4497
  const unitId = getUnitId(univerInstanceService);
4509
4498
  const subUnitId = getSubUnitId(univerInstanceService);
4510
4499
  const [errorText, setErrorText] = (0, react.useState)(void 0);
4511
- const rangeResult = (0, react.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 : []);
4500
+ const rangeResult = (0, react.useRef)(((_props$rule = props.rule) === null || _props$rule === void 0 ? void 0 : _props$rule.ranges) ?? []);
4512
4501
  const rangeSelectorTouched = (0, react.useRef)(false);
4513
4502
  const rangeString = (0, react.useMemo)(() => {
4514
4503
  var _props$rule2;
4515
4504
  let ranges = (_props$rule2 = props.rule) === null || _props$rule2 === void 0 ? void 0 : _props$rule2.ranges;
4516
4505
  if (!(ranges === null || ranges === void 0 ? void 0 : ranges.length)) {
4517
- var _selectionManagerServ, _selectionManagerServ2;
4518
- ranges = (_selectionManagerServ = (_selectionManagerServ2 = selectionManagerService.getCurrentSelections()) === null || _selectionManagerServ2 === void 0 ? void 0 : _selectionManagerServ2.map((s) => s.range)) !== null && _selectionManagerServ !== void 0 ? _selectionManagerServ : [];
4506
+ var _selectionManagerServ;
4507
+ ranges = ((_selectionManagerServ = selectionManagerService.getCurrentSelections()) === null || _selectionManagerServ === void 0 ? void 0 : _selectionManagerServ.map((s) => s.range)) ?? [];
4519
4508
  }
4520
4509
  rangeResult.current = ranges;
4521
4510
  if (!(ranges === null || ranges === void 0 ? void 0 : ranges.length)) return "";
@@ -4829,9 +4818,8 @@ function RuleList(props) {
4829
4818
  });
4830
4819
  };
4831
4820
  const handleDragStart = (_layout, from) => {
4832
- var _dragRule$cfId;
4833
4821
  const dragRule = ruleListByPermissionCheck[from.y];
4834
- setDraggingId((_dragRule$cfId = dragRule === null || dragRule === void 0 ? void 0 : dragRule.cfId) !== null && _dragRule$cfId !== void 0 ? _dragRule$cfId : "");
4822
+ setDraggingId((dragRule === null || dragRule === void 0 ? void 0 : dragRule.cfId) ?? "");
4835
4823
  };
4836
4824
  const handleDragStop = (_layout, from, to) => {
4837
4825
  var _getActiveSheet2, _ruleListByPermission, _ruleListByPermission2;
@@ -5134,7 +5122,7 @@ _defineProperty(UniverSheetsConditionalFormattingUIPlugin, "packageName", name);
5134
5122
  _defineProperty(UniverSheetsConditionalFormattingUIPlugin, "version", version);
5135
5123
  _defineProperty(UniverSheetsConditionalFormattingUIPlugin, "type", _univerjs_core.UniverInstanceType.UNIVER_SHEET);
5136
5124
  UniverSheetsConditionalFormattingUIPlugin = __decorate([
5137
- (0, _univerjs_core.DependentOn)(_univerjs_engine_render.UniverRenderEnginePlugin, _univerjs_sheets.UniverSheetsPlugin, _univerjs_ui.UniverUIPlugin, _univerjs_sheets_formula.UniverSheetsFormulaPlugin, _univerjs_sheets_conditional_formatting.UniverSheetsConditionalFormattingPlugin, _univerjs_sheets_ui.UniverSheetsUIPlugin),
5125
+ (0, _univerjs_core.DependentOn)(_univerjs_engine_render.UniverRenderEnginePlugin, _univerjs_sheets.UniverSheetsPlugin, _univerjs_sheets_formula.UniverSheetsFormulaPlugin, _univerjs_sheets_conditional_formatting.UniverSheetsConditionalFormattingPlugin, _univerjs_sheets_ui.UniverSheetsUIPlugin),
5138
5126
  __decorateParam(1, (0, _univerjs_core.Inject)(_univerjs_core.Injector)),
5139
5127
  __decorateParam(2, (0, _univerjs_core.Inject)(_univerjs_core.ICommandService)),
5140
5128
  __decorateParam(3, _univerjs_core.IConfigService)
package/lib/es/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { BooleanNumber, ColorKit, CommandType, DependentOn, Disposable, DisposableCollection, ICommandService, IConfigService, IUniverInstanceService, Inject, Injector, InterceptorEffectEnum, InterceptorManager, LocaleService, ObjectMatrix, Plugin, Range, Rectangle, Tools, UniverInstanceType, createInterceptorKey, generateRandomId, get, merge, registerDependencies, set, toDisposable, touchDependencies } from "@univerjs/core";
2
2
  import { AFTER_CELL_EDIT, AUTO_FILL_APPLY_TYPE, AutoFillTools, ClearSelectionAllCommand, ClearSelectionFormatCommand, IAutoFillService, INTERCEPTOR_POINT, RangeProtectionPermissionEditPoint, RemoveSheetMutation, SetSelectionsOperation, SetWorksheetActiveOperation, SheetInterceptorService, SheetPermissionCheckController, SheetsSelectionsService, 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, UniverUIPlugin, getMenuHiddenObservable, useDependency, useObservable, useSidebarClick } from "@univerjs/ui";
4
+ import { ComponentManager, IMenuManagerService, ISidebarService, IconManager, MenuItemType, RibbonDataGroup, RibbonInsertGroup, getMenuHiddenObservable, useDependency, useObservable, useSidebarClick } from "@univerjs/ui";
5
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";
@@ -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;
@@ -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.8";
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;
@@ -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,
@@ -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);
@@ -2294,7 +2289,6 @@ function Preview(props) {
2294
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";
2295
2290
  switch (rule.type) {
2296
2291
  case CFRuleType.dataBar: {
2297
- var _rule$config$nativeCo, _rule$config$positive;
2298
2292
  const { isGradient } = rule.config;
2299
2293
  const positiveColor = isGradient ? `linear-gradient(to right, ${rule.config.positiveColor || defaultDataBarPositiveColor}, rgb(255 255 255))` : rule.config.positiveColor;
2300
2294
  return /* @__PURE__ */ jsxs("div", {
@@ -2303,13 +2297,13 @@ function Preview(props) {
2303
2297
  className: "univer-h-full univer-w-1/2 univer-border univer-border-solid",
2304
2298
  style: {
2305
2299
  background: isGradient ? `linear-gradient(to right, rgb(255 255 255),${rule.config.nativeColor || defaultDataBarNativeColor})` : rule.config.nativeColor,
2306
- borderColor: (_rule$config$nativeCo = rule.config.nativeColor) !== null && _rule$config$nativeCo !== void 0 ? _rule$config$nativeCo : defaultDataBarNativeColor
2300
+ borderColor: rule.config.nativeColor ?? defaultDataBarNativeColor
2307
2301
  }
2308
2302
  }), /* @__PURE__ */ jsx("div", {
2309
2303
  className: "univer-h-full univer-w-1/2 univer-border univer-border-solid",
2310
2304
  style: {
2311
2305
  background: positiveColor,
2312
- borderColor: (_rule$config$positive = rule.config.positiveColor) !== null && _rule$config$positive !== void 0 ? _rule$config$positive : defaultDataBarPositiveColor
2306
+ borderColor: rule.config.positiveColor ?? defaultDataBarPositiveColor
2313
2307
  }
2314
2308
  })]
2315
2309
  });
@@ -2333,16 +2327,15 @@ function Preview(props) {
2333
2327
  }, index) : /* @__PURE__ */ jsx(SlashDoubleIcon, {}, index))
2334
2328
  });
2335
2329
  case CFRuleType.highlightCell: {
2336
- var _bg$rgb, _cl$rgb, _replace;
2337
2330
  const { ul, st, it, bl, bg, cl } = rule.style;
2338
2331
  const isUnderline = (ul === null || ul === void 0 ? void 0 : ul.s) === BooleanNumber.TRUE;
2339
2332
  const isStrikethrough = (st === null || st === void 0 ? void 0 : st.s) === BooleanNumber.TRUE;
2340
2333
  const isItalic = it === BooleanNumber.TRUE;
2341
2334
  const isBold = bl === BooleanNumber.TRUE;
2342
- const bgColor = (_bg$rgb = bg === null || bg === void 0 ? void 0 : bg.rgb) !== null && _bg$rgb !== void 0 ? _bg$rgb : DEFAULT_BG_COLOR;
2343
- 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;
2344
2337
  const style = {
2345
- 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,
2346
2339
  backgroundColor: bgColor,
2347
2340
  color: fontColor
2348
2341
  };
@@ -3405,13 +3398,10 @@ const FormulaStyleEditor = (props) => {
3405
3398
  //#endregion
3406
3399
  //#region src/views/wrapper-error/WrapperError.tsx
3407
3400
  const WrapperError = (props) => {
3408
- return /* @__PURE__ */ jsxs("div", {
3409
- className: "univer-relative",
3410
- children: [/* @__PURE__ */ jsx("div", {
3411
- className: "univer-absolute univer-bottom-[-13px] univer-z-[999] univer-text-[10px] univer-text-red-500",
3412
- children: props.errorText
3413
- }), props.children]
3414
- });
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
+ })] });
3415
3405
  };
3416
3406
 
3417
3407
  //#endregion
@@ -3673,11 +3663,10 @@ const HighlightCellStyleEditor = (props) => {
3673
3663
  });
3674
3664
  const [style, setStyle] = useState({});
3675
3665
  const getResult = useMemo(() => (option) => {
3676
- var _option$subType, _option$operator, _option$value, _option$style;
3677
- const nextSubType = (_option$subType = option.subType) !== null && _option$subType !== void 0 ? _option$subType : subType;
3678
- const nextOperator = (_option$operator = option.operator) !== null && _option$operator !== void 0 ? _option$operator : operator;
3679
- const nextValue = (_option$value = option.value) !== null && _option$value !== void 0 ? _option$value : value;
3680
- 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;
3681
3670
  switch (nextSubType) {
3682
3671
  case CFSubRuleType.duplicateValues: return {
3683
3672
  type: CFRuleType.highlightCell,
@@ -3828,7 +3817,7 @@ const TextInput = (props) => {
3828
3817
  children: type !== CFValueType.formula ? /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(InputNumber, {
3829
3818
  className: clsx({ "univer-border-red-500": error }),
3830
3819
  value: Number(props.value) || 0,
3831
- onChange: (v) => onChange(v !== null && v !== void 0 ? v : 0)
3820
+ onChange: (v) => onChange(v ?? 0)
3832
3821
  }), error && /* @__PURE__ */ jsx("div", {
3833
3822
  className: "univer-absolute univer-text-xs univer-text-red-500",
3834
3823
  children: error
@@ -4498,7 +4487,7 @@ const getSubUnitId = (univerInstanceService) => {
4498
4487
  return (_getActiveSheet = univerInstanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_SHEET).getActiveSheet()) === null || _getActiveSheet === void 0 ? void 0 : _getActiveSheet.getSheetId();
4499
4488
  };
4500
4489
  const RuleEdit = (props) => {
4501
- var _props$rule$ranges, _props$rule, _props$rule5;
4490
+ var _props$rule, _props$rule5;
4502
4491
  const localeService = useDependency(LocaleService);
4503
4492
  const commandService = useDependency(ICommandService);
4504
4493
  const univerInstanceService = useDependency(IUniverInstanceService);
@@ -4507,14 +4496,14 @@ const RuleEdit = (props) => {
4507
4496
  const unitId = getUnitId(univerInstanceService);
4508
4497
  const subUnitId = getSubUnitId(univerInstanceService);
4509
4498
  const [errorText, setErrorText] = useState(void 0);
4510
- 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) ?? []);
4511
4500
  const rangeSelectorTouched = useRef(false);
4512
4501
  const rangeString = useMemo(() => {
4513
4502
  var _props$rule2;
4514
4503
  let ranges = (_props$rule2 = props.rule) === null || _props$rule2 === void 0 ? void 0 : _props$rule2.ranges;
4515
4504
  if (!(ranges === null || ranges === void 0 ? void 0 : ranges.length)) {
4516
- var _selectionManagerServ, _selectionManagerServ2;
4517
- 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)) ?? [];
4518
4507
  }
4519
4508
  rangeResult.current = ranges;
4520
4509
  if (!(ranges === null || ranges === void 0 ? void 0 : ranges.length)) return "";
@@ -4828,9 +4817,8 @@ function RuleList(props) {
4828
4817
  });
4829
4818
  };
4830
4819
  const handleDragStart = (_layout, from) => {
4831
- var _dragRule$cfId;
4832
4820
  const dragRule = ruleListByPermissionCheck[from.y];
4833
- 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) ?? "");
4834
4822
  };
4835
4823
  const handleDragStop = (_layout, from, to) => {
4836
4824
  var _getActiveSheet2, _ruleListByPermission, _ruleListByPermission2;
@@ -5133,7 +5121,7 @@ _defineProperty(UniverSheetsConditionalFormattingUIPlugin, "packageName", name);
5133
5121
  _defineProperty(UniverSheetsConditionalFormattingUIPlugin, "version", version);
5134
5122
  _defineProperty(UniverSheetsConditionalFormattingUIPlugin, "type", UniverInstanceType.UNIVER_SHEET);
5135
5123
  UniverSheetsConditionalFormattingUIPlugin = __decorate([
5136
- DependentOn(UniverRenderEnginePlugin, UniverSheetsPlugin, UniverUIPlugin, UniverSheetsFormulaPlugin, UniverSheetsConditionalFormattingPlugin, UniverSheetsUIPlugin),
5124
+ DependentOn(UniverRenderEnginePlugin, UniverSheetsPlugin, UniverSheetsFormulaPlugin, UniverSheetsConditionalFormattingPlugin, UniverSheetsUIPlugin),
5137
5125
  __decorateParam(1, Inject(Injector)),
5138
5126
  __decorateParam(2, Inject(ICommandService)),
5139
5127
  __decorateParam(3, IConfigService)
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;