@univerjs/sheets-conditional-formatting-ui 1.0.3 → 1.1.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
@@ -389,7 +389,7 @@ const AddUniqueValuesCfCommand = {
389
389
  const CF_PANEL_KEY = "sheet.conditional.formatting.panel";
390
390
 
391
391
  //#endregion
392
- //#region \0@oxc-project+runtime@0.149.0/helpers/esm/typeof.js
392
+ //#region \0@oxc-project+runtime@0.153.0/helpers/esm/typeof.js
393
393
  function _typeof(o) {
394
394
  "@babel/helpers - typeof";
395
395
  return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
@@ -400,7 +400,7 @@ function _typeof(o) {
400
400
  }
401
401
 
402
402
  //#endregion
403
- //#region \0@oxc-project+runtime@0.149.0/helpers/esm/toPrimitive.js
403
+ //#region \0@oxc-project+runtime@0.153.0/helpers/esm/toPrimitive.js
404
404
  function toPrimitive(t, r) {
405
405
  if ("object" != _typeof(t) || !t) return t;
406
406
  var e = t[Symbol.toPrimitive];
@@ -413,14 +413,14 @@ function toPrimitive(t, r) {
413
413
  }
414
414
 
415
415
  //#endregion
416
- //#region \0@oxc-project+runtime@0.149.0/helpers/esm/toPropertyKey.js
416
+ //#region \0@oxc-project+runtime@0.153.0/helpers/esm/toPropertyKey.js
417
417
  function toPropertyKey(t) {
418
418
  var i = toPrimitive(t, "string");
419
419
  return "symbol" == _typeof(i) ? i : i + "";
420
420
  }
421
421
 
422
422
  //#endregion
423
- //#region \0@oxc-project+runtime@0.149.0/helpers/esm/defineProperty.js
423
+ //#region \0@oxc-project+runtime@0.153.0/helpers/esm/defineProperty.js
424
424
  function _defineProperty(e, r, t) {
425
425
  return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
426
426
  value: t,
@@ -431,7 +431,7 @@ function _defineProperty(e, r, t) {
431
431
  }
432
432
 
433
433
  //#endregion
434
- //#region \0@oxc-project+runtime@0.149.0/helpers/esm/decorateParam.js
434
+ //#region \0@oxc-project+runtime@0.153.0/helpers/esm/decorateParam.js
435
435
  function __decorateParam(paramIndex, decorator) {
436
436
  return function(target, key) {
437
437
  decorator(target, key, paramIndex);
@@ -439,7 +439,7 @@ function __decorateParam(paramIndex, decorator) {
439
439
  }
440
440
 
441
441
  //#endregion
442
- //#region \0@oxc-project+runtime@0.149.0/helpers/esm/decorate.js
442
+ //#region \0@oxc-project+runtime@0.153.0/helpers/esm/decorate.js
443
443
  function __decorate(decorators, target, key, desc) {
444
444
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
445
445
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -986,8 +986,7 @@ const conditionalFormattingRuleMenuSchema = { [_univerjs_ui.RibbonDataGroup.RULE
986
986
  order: 1,
987
987
  gridLayout: {
988
988
  row: 2,
989
- column: 1,
990
- showLabel: true
989
+ column: 1
991
990
  },
992
991
  menuItemFactory: FactoryManageConditionalFormattingRule
993
992
  } } };
@@ -1008,7 +1007,7 @@ const menuSchema = {
1008
1007
  //#endregion
1009
1008
  //#region package.json
1010
1009
  var name = "@univerjs/sheets-conditional-formatting-ui";
1011
- var version = "1.0.3";
1010
+ var version = "1.1.0";
1012
1011
 
1013
1012
  //#endregion
1014
1013
  //#region src/config/config.ts
@@ -1700,8 +1699,9 @@ const ColorPicker = (props) => {
1700
1699
  };
1701
1700
 
1702
1701
  //#endregion
1703
- //#region src/views/Preview.tsx
1704
- function Preview(props) {
1702
+ //#region src/views/ConditionalFormattingRulePreview.tsx
1703
+ /** Shows a rule's configured appearance without evaluating worksheet values. */
1704
+ function ConditionalFormattingRulePreview(props) {
1705
1705
  const { rule } = props;
1706
1706
  const colorList = (0, react.useMemo)(() => {
1707
1707
  if ((rule === null || rule === void 0 ? void 0 : rule.type) === _univerjs_sheets_conditional_formatting.CFRuleType.colorScale) {
@@ -1787,6 +1787,56 @@ function Preview(props) {
1787
1787
  }
1788
1788
  }
1789
1789
 
1790
+ //#endregion
1791
+ //#region src/views/panel/rule-edit/RuleNumberInput.tsx
1792
+ /**
1793
+ * Copyright 2023-present DreamNum Co., Ltd.
1794
+ *
1795
+ * Licensed under the Apache License, Version 2.0 (the "License");
1796
+ * you may not use this file except in compliance with the License.
1797
+ * You may obtain a copy of the License at
1798
+ *
1799
+ * http://www.apache.org/licenses/LICENSE-2.0
1800
+ *
1801
+ * Unless required by applicable law or agreed to in writing, software
1802
+ * distributed under the License is distributed on an "AS IS" BASIS,
1803
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1804
+ * See the License for the specific language governing permissions and
1805
+ * limitations under the License.
1806
+ */
1807
+ function RuleNumberInput({ value, onChange, min = Number.MIN_SAFE_INTEGER, max = Number.MAX_SAFE_INTEGER, disabled, className }) {
1808
+ const [draftState, setDraftState] = (0, react.useState)({
1809
+ value,
1810
+ text: String(value)
1811
+ });
1812
+ if (!Object.is(draftState.value, value)) setDraftState({
1813
+ value,
1814
+ text: String(value)
1815
+ });
1816
+ const draft = draftState.text;
1817
+ const setDraft = (text) => setDraftState({
1818
+ value,
1819
+ text
1820
+ });
1821
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Input, {
1822
+ className,
1823
+ disabled,
1824
+ inputMode: "decimal",
1825
+ value: draft,
1826
+ "aria-invalid": !Number.isFinite(Number(draft)),
1827
+ onChange: (next) => {
1828
+ setDraft(next);
1829
+ const number = Number(next);
1830
+ if (Number.isFinite(number)) {
1831
+ const bounded = Math.min(max, Math.max(min, number));
1832
+ if (bounded !== number) setDraft(String(bounded));
1833
+ onChange(bounded);
1834
+ }
1835
+ },
1836
+ onBlur: () => setDraft(String(value))
1837
+ });
1838
+ }
1839
+
1790
1840
  //#endregion
1791
1841
  //#region src/views/panel/rule-edit/styles.ts
1792
1842
  /**
@@ -1857,7 +1907,7 @@ const TextInput$1 = (props) => {
1857
1907
  onFocus: () => setIsFocusFormulaEditor(true)
1858
1908
  })
1859
1909
  });
1860
- else return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.InputNumber, {
1910
+ else return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RuleNumberInput, {
1861
1911
  className,
1862
1912
  value: Number(props.value) || 0,
1863
1913
  onChange: (v) => props.onChange(v || 0),
@@ -2015,7 +2065,7 @@ const ColorScaleStyleEditor = (props) => {
2015
2065
  }),
2016
2066
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2017
2067
  className: previewClassName,
2018
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Preview, { rule: getResult({
2068
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ConditionalFormattingRulePreview, { rule: getResult({
2019
2069
  minType,
2020
2070
  medianType,
2021
2071
  maxType,
@@ -2281,7 +2331,7 @@ const InputText = (props) => {
2281
2331
  })
2282
2332
  });
2283
2333
  }
2284
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.InputNumber, {
2334
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RuleNumberInput, {
2285
2335
  className,
2286
2336
  value: Number(value) || 0,
2287
2337
  disabled,
@@ -2441,7 +2491,7 @@ const DataBarStyleEditor = (props) => {
2441
2491
  }),
2442
2492
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2443
2493
  className: previewClassName,
2444
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Preview, { rule: getResult({
2494
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ConditionalFormattingRulePreview, { rule: getResult({
2445
2495
  isGradient,
2446
2496
  minValue,
2447
2497
  minValueType,
@@ -2815,7 +2865,7 @@ const FormulaStyleEditor = (props) => {
2815
2865
  }),
2816
2866
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2817
2867
  className: previewClassName,
2818
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Preview, { rule: getResult({
2868
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ConditionalFormattingRulePreview, { rule: getResult({
2819
2869
  style,
2820
2870
  formula
2821
2871
  }) })
@@ -2968,7 +3018,7 @@ function HighlightCellInput(props) {
2968
3018
  className: "univer-mt-3",
2969
3019
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(WrapperError, {
2970
3020
  errorText: numberError,
2971
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.InputNumber, {
3021
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RuleNumberInput, {
2972
3022
  className: "univer-w-full",
2973
3023
  min: Number.MIN_SAFE_INTEGER,
2974
3024
  max: Number.MAX_SAFE_INTEGER,
@@ -2993,7 +3043,7 @@ function HighlightCellInput(props) {
2993
3043
  className: "univer-mt-3 univer-flex univer-items-center",
2994
3044
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(WrapperError, {
2995
3045
  errorText: numberMinError,
2996
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.InputNumber, {
3046
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RuleNumberInput, {
2997
3047
  min: Number.MIN_SAFE_INTEGER,
2998
3048
  max: Number.MAX_SAFE_INTEGER,
2999
3049
  value: inputNumberMin,
@@ -3001,7 +3051,7 @@ function HighlightCellInput(props) {
3001
3051
  })
3002
3052
  }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(WrapperError, {
3003
3053
  errorText: numberMaxError,
3004
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.InputNumber, {
3054
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RuleNumberInput, {
3005
3055
  className: "univer-ml-3",
3006
3056
  min: Number.MIN_SAFE_INTEGER,
3007
3057
  max: Number.MAX_SAFE_INTEGER,
@@ -3222,7 +3272,7 @@ const HighlightCellStyleEditor = (props) => {
3222
3272
  }, `${subType}_${operator}`),
3223
3273
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3224
3274
  className: previewClassName,
3225
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Preview, { rule: getResult({}) })
3275
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ConditionalFormattingRulePreview, { rule: getResult({}) })
3226
3276
  }),
3227
3277
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ConditionalStyleEditor, {
3228
3278
  ColorPickerComponent,
@@ -3255,7 +3305,7 @@ const TextInput = (props) => {
3255
3305
  });
3256
3306
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3257
3307
  className: "univer-relative",
3258
- 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, {
3308
+ 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)(RuleNumberInput, {
3259
3309
  className: (0, _univerjs_design.clsx)({ "univer-border-red-500": error }),
3260
3310
  value: Number(props.value) || 0,
3261
3311
  onChange: (v) => onChange(v ?? 0)
@@ -3909,7 +3959,7 @@ const RankStyleEditor = (props) => {
3909
3959
  }),
3910
3960
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3911
3961
  className: previewClassName,
3912
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Preview, { rule: getResult({
3962
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ConditionalFormattingRulePreview, { rule: getResult({
3913
3963
  type,
3914
3964
  isPercent,
3915
3965
  value,
@@ -4172,8 +4222,9 @@ const RuleEdit = (props) => {
4172
4222
  };
4173
4223
 
4174
4224
  //#endregion
4175
- //#region src/views/panel/RuleList.tsx
4176
- const getRuleDescribe = (rule, localeService) => {
4225
+ //#region src/utils/get-rule-describe.ts
4226
+ /** Returns the localized description used by the built-in conditional formatting rule list. */
4227
+ function getRuleDescribe(rule, localeService) {
4177
4228
  const ruleConfig = rule.rule;
4178
4229
  switch (ruleConfig.type) {
4179
4230
  case _univerjs_sheets_conditional_formatting.CFRuleType.colorScale: return localeService.t("sheets-conditional-formatting-ui.ruleType.colorScale");
@@ -4188,7 +4239,8 @@ const getRuleDescribe = (rule, localeService) => {
4188
4239
  case _univerjs_sheets_conditional_formatting.CFSubRuleType.uniqueValues: return localeService.t("sheets-conditional-formatting-ui.subRuleType.uniqueValues");
4189
4240
  case _univerjs_sheets_conditional_formatting.CFSubRuleType.number: {
4190
4241
  const operator = ruleConfig.operator;
4191
- return localeService.t(`sheets-conditional-formatting-ui.preview.describe.${operator}`, ...Array.isArray(ruleConfig.value) ? ruleConfig.value.map((e) => String(e)) : [String(ruleConfig.value || "")]);
4242
+ const values = Array.isArray(ruleConfig.value) ? ruleConfig.value.map((value) => String(value)) : [String(ruleConfig.value ?? "")];
4243
+ return localeService.t(`sheets-conditional-formatting-ui.preview.describe.${operator}`, ...values);
4192
4244
  }
4193
4245
  case _univerjs_sheets_conditional_formatting.CFSubRuleType.text: {
4194
4246
  const operator = ruleConfig.operator;
@@ -4198,15 +4250,16 @@ const getRuleDescribe = (rule, localeService) => {
4198
4250
  const operator = ruleConfig.operator;
4199
4251
  return localeService.t(`sheets-conditional-formatting-ui.preview.describe.${operator}`);
4200
4252
  }
4201
- case _univerjs_sheets_conditional_formatting.CFSubRuleType.rank: if (ruleConfig.isPercent) {
4202
- if (ruleConfig.isBottom) return localeService.t("sheets-conditional-formatting-ui.preview.describe.bottomNPercent", String(ruleConfig.value));
4203
- else return localeService.t("sheets-conditional-formatting-ui.preview.describe.topNPercent", String(ruleConfig.value));
4204
- } else if (ruleConfig.isBottom) return localeService.t("sheets-conditional-formatting-ui.preview.describe.bottomN", String(ruleConfig.value));
4205
- else return localeService.t("sheets-conditional-formatting-ui.preview.describe.topN", String(ruleConfig.value));
4253
+ case _univerjs_sheets_conditional_formatting.CFSubRuleType.rank:
4254
+ if (ruleConfig.isPercent) return localeService.t(ruleConfig.isBottom ? "sheets-conditional-formatting-ui.preview.describe.bottomNPercent" : "sheets-conditional-formatting-ui.preview.describe.topNPercent", String(ruleConfig.value));
4255
+ return localeService.t(ruleConfig.isBottom ? "sheets-conditional-formatting-ui.preview.describe.bottomN" : "sheets-conditional-formatting-ui.preview.describe.topN", String(ruleConfig.value));
4206
4256
  case _univerjs_sheets_conditional_formatting.CFSubRuleType.formula: return localeService.t("sheets-conditional-formatting-ui.ruleType.formula");
4207
4257
  }
4208
4258
  }
4209
- };
4259
+ }
4260
+
4261
+ //#endregion
4262
+ //#region src/views/panel/RuleList.tsx
4210
4263
  function RuleList(props) {
4211
4264
  const { SelectComponent = _univerjs_design.Select } = props;
4212
4265
  const { onClick } = props;
@@ -4409,7 +4462,7 @@ function RuleList(props) {
4409
4462
  children: rule.ranges.map((range) => (0, _univerjs_engine_formula.serializeRange)(range)).join(",")
4410
4463
  })]
4411
4464
  }),
4412
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Preview, { rule: rule.rule }) }),
4465
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ConditionalFormattingRulePreview, { rule: rule.rule }) }),
4413
4466
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
4414
4467
  className: (0, _univerjs_design.clsx)("univer-absolute univer-right-1 univer-hidden univer-size-6 univer-cursor-pointer univer-items-center univer-justify-center univer-rounded univer-text-red-500 group-hover:univer-flex hover:univer-bg-gray-200 rtl:univer-left-1 rtl:univer-right-auto", { "univer-flex univer-items-center univer-justify-center": draggingId === rule.cfId }),
4415
4468
  onClick: (e) => {
@@ -4434,8 +4487,10 @@ const ConditionFormattingPanel = (props) => {
4434
4487
  setIsShowRuleEditor(true);
4435
4488
  };
4436
4489
  const handleCancel = () => {
4490
+ var _props$onEditorExit;
4437
4491
  setIsShowRuleEditor(false);
4438
4492
  setCurrentEditRule(void 0);
4493
+ (_props$onEditorExit = props.onEditorExit) === null || _props$onEditorExit === void 0 || _props$onEditorExit.call(props);
4439
4494
  };
4440
4495
  const handleRuleClick = (rule) => {
4441
4496
  setCurrentEditRule(rule);
@@ -5277,23 +5332,26 @@ exports.AddRankCfCommand = AddRankCfCommand;
5277
5332
  exports.AddTextCfCommand = AddTextCfCommand;
5278
5333
  exports.AddTimePeriodCfCommand = AddTimePeriodCfCommand;
5279
5334
  exports.AddUniqueValuesCfCommand = AddUniqueValuesCfCommand;
5280
- Object.defineProperty(exports, 'ConditionalFormattingClearController', {
5335
+ exports.CF_PANEL_KEY = CF_PANEL_KEY;
5336
+ Object.defineProperty(exports, "ConditionalFormattingClearController", {
5281
5337
  enumerable: true,
5282
5338
  get: function () {
5283
5339
  return ConditionalFormattingClearController;
5284
5340
  }
5285
5341
  });
5342
+ exports.ConditionalFormattingRulePreview = ConditionalFormattingRulePreview;
5286
5343
  exports.OpenConditionalFormattingOperator = OpenConditionalFormattingOperator;
5287
5344
  exports.SheetsConditionalFormattingUIMenuSchema = menuSchema;
5288
- Object.defineProperty(exports, 'UniverSheetsConditionalFormattingMobileUIPlugin', {
5345
+ Object.defineProperty(exports, "UniverSheetsConditionalFormattingMobileUIPlugin", {
5289
5346
  enumerable: true,
5290
5347
  get: function () {
5291
5348
  return UniverSheetsConditionalFormattingMobileUIPlugin;
5292
5349
  }
5293
5350
  });
5294
- Object.defineProperty(exports, 'UniverSheetsConditionalFormattingUIPlugin', {
5351
+ Object.defineProperty(exports, "UniverSheetsConditionalFormattingUIPlugin", {
5295
5352
  enumerable: true,
5296
5353
  get: function () {
5297
5354
  return UniverSheetsConditionalFormattingUIPlugin;
5298
5355
  }
5299
- });
5356
+ });
5357
+ exports.getRuleDescribe = getRuleDescribe;
package/lib/es/index.js CHANGED
@@ -388,7 +388,7 @@ const AddUniqueValuesCfCommand = {
388
388
  const CF_PANEL_KEY = "sheet.conditional.formatting.panel";
389
389
 
390
390
  //#endregion
391
- //#region \0@oxc-project+runtime@0.149.0/helpers/esm/typeof.js
391
+ //#region \0@oxc-project+runtime@0.153.0/helpers/esm/typeof.js
392
392
  function _typeof(o) {
393
393
  "@babel/helpers - typeof";
394
394
  return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
@@ -399,7 +399,7 @@ function _typeof(o) {
399
399
  }
400
400
 
401
401
  //#endregion
402
- //#region \0@oxc-project+runtime@0.149.0/helpers/esm/toPrimitive.js
402
+ //#region \0@oxc-project+runtime@0.153.0/helpers/esm/toPrimitive.js
403
403
  function toPrimitive(t, r) {
404
404
  if ("object" != _typeof(t) || !t) return t;
405
405
  var e = t[Symbol.toPrimitive];
@@ -412,14 +412,14 @@ function toPrimitive(t, r) {
412
412
  }
413
413
 
414
414
  //#endregion
415
- //#region \0@oxc-project+runtime@0.149.0/helpers/esm/toPropertyKey.js
415
+ //#region \0@oxc-project+runtime@0.153.0/helpers/esm/toPropertyKey.js
416
416
  function toPropertyKey(t) {
417
417
  var i = toPrimitive(t, "string");
418
418
  return "symbol" == _typeof(i) ? i : i + "";
419
419
  }
420
420
 
421
421
  //#endregion
422
- //#region \0@oxc-project+runtime@0.149.0/helpers/esm/defineProperty.js
422
+ //#region \0@oxc-project+runtime@0.153.0/helpers/esm/defineProperty.js
423
423
  function _defineProperty(e, r, t) {
424
424
  return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
425
425
  value: t,
@@ -430,7 +430,7 @@ function _defineProperty(e, r, t) {
430
430
  }
431
431
 
432
432
  //#endregion
433
- //#region \0@oxc-project+runtime@0.149.0/helpers/esm/decorateParam.js
433
+ //#region \0@oxc-project+runtime@0.153.0/helpers/esm/decorateParam.js
434
434
  function __decorateParam(paramIndex, decorator) {
435
435
  return function(target, key) {
436
436
  decorator(target, key, paramIndex);
@@ -438,7 +438,7 @@ function __decorateParam(paramIndex, decorator) {
438
438
  }
439
439
 
440
440
  //#endregion
441
- //#region \0@oxc-project+runtime@0.149.0/helpers/esm/decorate.js
441
+ //#region \0@oxc-project+runtime@0.153.0/helpers/esm/decorate.js
442
442
  function __decorate(decorators, target, key, desc) {
443
443
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
444
444
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -985,8 +985,7 @@ const conditionalFormattingRuleMenuSchema = { [RibbonDataGroup.RULES]: { [OpenCo
985
985
  order: 1,
986
986
  gridLayout: {
987
987
  row: 2,
988
- column: 1,
989
- showLabel: true
988
+ column: 1
990
989
  },
991
990
  menuItemFactory: FactoryManageConditionalFormattingRule
992
991
  } } };
@@ -1007,7 +1006,7 @@ const menuSchema = {
1007
1006
  //#endregion
1008
1007
  //#region package.json
1009
1008
  var name = "@univerjs/sheets-conditional-formatting-ui";
1010
- var version = "1.0.3";
1009
+ var version = "1.1.0";
1011
1010
 
1012
1011
  //#endregion
1013
1012
  //#region src/config/config.ts
@@ -1699,8 +1698,9 @@ const ColorPicker$1 = (props) => {
1699
1698
  };
1700
1699
 
1701
1700
  //#endregion
1702
- //#region src/views/Preview.tsx
1703
- function Preview(props) {
1701
+ //#region src/views/ConditionalFormattingRulePreview.tsx
1702
+ /** Shows a rule's configured appearance without evaluating worksheet values. */
1703
+ function ConditionalFormattingRulePreview(props) {
1704
1704
  const { rule } = props;
1705
1705
  const colorList = useMemo(() => {
1706
1706
  if ((rule === null || rule === void 0 ? void 0 : rule.type) === CFRuleType.colorScale) {
@@ -1786,6 +1786,56 @@ function Preview(props) {
1786
1786
  }
1787
1787
  }
1788
1788
 
1789
+ //#endregion
1790
+ //#region src/views/panel/rule-edit/RuleNumberInput.tsx
1791
+ /**
1792
+ * Copyright 2023-present DreamNum Co., Ltd.
1793
+ *
1794
+ * Licensed under the Apache License, Version 2.0 (the "License");
1795
+ * you may not use this file except in compliance with the License.
1796
+ * You may obtain a copy of the License at
1797
+ *
1798
+ * http://www.apache.org/licenses/LICENSE-2.0
1799
+ *
1800
+ * Unless required by applicable law or agreed to in writing, software
1801
+ * distributed under the License is distributed on an "AS IS" BASIS,
1802
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1803
+ * See the License for the specific language governing permissions and
1804
+ * limitations under the License.
1805
+ */
1806
+ function RuleNumberInput({ value, onChange, min = Number.MIN_SAFE_INTEGER, max = Number.MAX_SAFE_INTEGER, disabled, className }) {
1807
+ const [draftState, setDraftState] = useState({
1808
+ value,
1809
+ text: String(value)
1810
+ });
1811
+ if (!Object.is(draftState.value, value)) setDraftState({
1812
+ value,
1813
+ text: String(value)
1814
+ });
1815
+ const draft = draftState.text;
1816
+ const setDraft = (text) => setDraftState({
1817
+ value,
1818
+ text
1819
+ });
1820
+ return /* @__PURE__ */ jsx(Input, {
1821
+ className,
1822
+ disabled,
1823
+ inputMode: "decimal",
1824
+ value: draft,
1825
+ "aria-invalid": !Number.isFinite(Number(draft)),
1826
+ onChange: (next) => {
1827
+ setDraft(next);
1828
+ const number = Number(next);
1829
+ if (Number.isFinite(number)) {
1830
+ const bounded = Math.min(max, Math.max(min, number));
1831
+ if (bounded !== number) setDraft(String(bounded));
1832
+ onChange(bounded);
1833
+ }
1834
+ },
1835
+ onBlur: () => setDraft(String(value))
1836
+ });
1837
+ }
1838
+
1789
1839
  //#endregion
1790
1840
  //#region src/views/panel/rule-edit/styles.ts
1791
1841
  /**
@@ -1856,7 +1906,7 @@ const TextInput$1 = (props) => {
1856
1906
  onFocus: () => setIsFocusFormulaEditor(true)
1857
1907
  })
1858
1908
  });
1859
- else return /* @__PURE__ */ jsx(InputNumber, {
1909
+ else return /* @__PURE__ */ jsx(RuleNumberInput, {
1860
1910
  className,
1861
1911
  value: Number(props.value) || 0,
1862
1912
  onChange: (v) => props.onChange(v || 0),
@@ -2014,7 +2064,7 @@ const ColorScaleStyleEditor = (props) => {
2014
2064
  }),
2015
2065
  /* @__PURE__ */ jsx("div", {
2016
2066
  className: previewClassName,
2017
- children: /* @__PURE__ */ jsx(Preview, { rule: getResult({
2067
+ children: /* @__PURE__ */ jsx(ConditionalFormattingRulePreview, { rule: getResult({
2018
2068
  minType,
2019
2069
  medianType,
2020
2070
  maxType,
@@ -2280,7 +2330,7 @@ const InputText = (props) => {
2280
2330
  })
2281
2331
  });
2282
2332
  }
2283
- return /* @__PURE__ */ jsx(InputNumber, {
2333
+ return /* @__PURE__ */ jsx(RuleNumberInput, {
2284
2334
  className,
2285
2335
  value: Number(value) || 0,
2286
2336
  disabled,
@@ -2440,7 +2490,7 @@ const DataBarStyleEditor = (props) => {
2440
2490
  }),
2441
2491
  /* @__PURE__ */ jsx("div", {
2442
2492
  className: previewClassName,
2443
- children: /* @__PURE__ */ jsx(Preview, { rule: getResult({
2493
+ children: /* @__PURE__ */ jsx(ConditionalFormattingRulePreview, { rule: getResult({
2444
2494
  isGradient,
2445
2495
  minValue,
2446
2496
  minValueType,
@@ -2814,7 +2864,7 @@ const FormulaStyleEditor = (props) => {
2814
2864
  }),
2815
2865
  /* @__PURE__ */ jsx("div", {
2816
2866
  className: previewClassName,
2817
- children: /* @__PURE__ */ jsx(Preview, { rule: getResult({
2867
+ children: /* @__PURE__ */ jsx(ConditionalFormattingRulePreview, { rule: getResult({
2818
2868
  style,
2819
2869
  formula
2820
2870
  }) })
@@ -2967,7 +3017,7 @@ function HighlightCellInput(props) {
2967
3017
  className: "univer-mt-3",
2968
3018
  children: /* @__PURE__ */ jsx(WrapperError, {
2969
3019
  errorText: numberError,
2970
- children: /* @__PURE__ */ jsx(InputNumber, {
3020
+ children: /* @__PURE__ */ jsx(RuleNumberInput, {
2971
3021
  className: "univer-w-full",
2972
3022
  min: Number.MIN_SAFE_INTEGER,
2973
3023
  max: Number.MAX_SAFE_INTEGER,
@@ -2992,7 +3042,7 @@ function HighlightCellInput(props) {
2992
3042
  className: "univer-mt-3 univer-flex univer-items-center",
2993
3043
  children: [/* @__PURE__ */ jsx(WrapperError, {
2994
3044
  errorText: numberMinError,
2995
- children: /* @__PURE__ */ jsx(InputNumber, {
3045
+ children: /* @__PURE__ */ jsx(RuleNumberInput, {
2996
3046
  min: Number.MIN_SAFE_INTEGER,
2997
3047
  max: Number.MAX_SAFE_INTEGER,
2998
3048
  value: inputNumberMin,
@@ -3000,7 +3050,7 @@ function HighlightCellInput(props) {
3000
3050
  })
3001
3051
  }), /* @__PURE__ */ jsx(WrapperError, {
3002
3052
  errorText: numberMaxError,
3003
- children: /* @__PURE__ */ jsx(InputNumber, {
3053
+ children: /* @__PURE__ */ jsx(RuleNumberInput, {
3004
3054
  className: "univer-ml-3",
3005
3055
  min: Number.MIN_SAFE_INTEGER,
3006
3056
  max: Number.MAX_SAFE_INTEGER,
@@ -3221,7 +3271,7 @@ const HighlightCellStyleEditor = (props) => {
3221
3271
  }, `${subType}_${operator}`),
3222
3272
  /* @__PURE__ */ jsx("div", {
3223
3273
  className: previewClassName,
3224
- children: /* @__PURE__ */ jsx(Preview, { rule: getResult({}) })
3274
+ children: /* @__PURE__ */ jsx(ConditionalFormattingRulePreview, { rule: getResult({}) })
3225
3275
  }),
3226
3276
  /* @__PURE__ */ jsx(ConditionalStyleEditor, {
3227
3277
  ColorPickerComponent,
@@ -3254,7 +3304,7 @@ const TextInput = (props) => {
3254
3304
  });
3255
3305
  return /* @__PURE__ */ jsx("div", {
3256
3306
  className: "univer-relative",
3257
- children: type !== CFValueType.formula ? /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(InputNumber, {
3307
+ children: type !== CFValueType.formula ? /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(RuleNumberInput, {
3258
3308
  className: clsx({ "univer-border-red-500": error }),
3259
3309
  value: Number(props.value) || 0,
3260
3310
  onChange: (v) => onChange(v ?? 0)
@@ -3908,7 +3958,7 @@ const RankStyleEditor = (props) => {
3908
3958
  }),
3909
3959
  /* @__PURE__ */ jsx("div", {
3910
3960
  className: previewClassName,
3911
- children: /* @__PURE__ */ jsx(Preview, { rule: getResult({
3961
+ children: /* @__PURE__ */ jsx(ConditionalFormattingRulePreview, { rule: getResult({
3912
3962
  type,
3913
3963
  isPercent,
3914
3964
  value,
@@ -4171,8 +4221,9 @@ const RuleEdit = (props) => {
4171
4221
  };
4172
4222
 
4173
4223
  //#endregion
4174
- //#region src/views/panel/RuleList.tsx
4175
- const getRuleDescribe = (rule, localeService) => {
4224
+ //#region src/utils/get-rule-describe.ts
4225
+ /** Returns the localized description used by the built-in conditional formatting rule list. */
4226
+ function getRuleDescribe(rule, localeService) {
4176
4227
  const ruleConfig = rule.rule;
4177
4228
  switch (ruleConfig.type) {
4178
4229
  case CFRuleType.colorScale: return localeService.t("sheets-conditional-formatting-ui.ruleType.colorScale");
@@ -4187,7 +4238,8 @@ const getRuleDescribe = (rule, localeService) => {
4187
4238
  case CFSubRuleType.uniqueValues: return localeService.t("sheets-conditional-formatting-ui.subRuleType.uniqueValues");
4188
4239
  case CFSubRuleType.number: {
4189
4240
  const operator = ruleConfig.operator;
4190
- return localeService.t(`sheets-conditional-formatting-ui.preview.describe.${operator}`, ...Array.isArray(ruleConfig.value) ? ruleConfig.value.map((e) => String(e)) : [String(ruleConfig.value || "")]);
4241
+ const values = Array.isArray(ruleConfig.value) ? ruleConfig.value.map((value) => String(value)) : [String(ruleConfig.value ?? "")];
4242
+ return localeService.t(`sheets-conditional-formatting-ui.preview.describe.${operator}`, ...values);
4191
4243
  }
4192
4244
  case CFSubRuleType.text: {
4193
4245
  const operator = ruleConfig.operator;
@@ -4197,15 +4249,16 @@ const getRuleDescribe = (rule, localeService) => {
4197
4249
  const operator = ruleConfig.operator;
4198
4250
  return localeService.t(`sheets-conditional-formatting-ui.preview.describe.${operator}`);
4199
4251
  }
4200
- case CFSubRuleType.rank: if (ruleConfig.isPercent) {
4201
- if (ruleConfig.isBottom) return localeService.t("sheets-conditional-formatting-ui.preview.describe.bottomNPercent", String(ruleConfig.value));
4202
- else return localeService.t("sheets-conditional-formatting-ui.preview.describe.topNPercent", String(ruleConfig.value));
4203
- } else if (ruleConfig.isBottom) return localeService.t("sheets-conditional-formatting-ui.preview.describe.bottomN", String(ruleConfig.value));
4204
- else return localeService.t("sheets-conditional-formatting-ui.preview.describe.topN", String(ruleConfig.value));
4252
+ case CFSubRuleType.rank:
4253
+ if (ruleConfig.isPercent) return localeService.t(ruleConfig.isBottom ? "sheets-conditional-formatting-ui.preview.describe.bottomNPercent" : "sheets-conditional-formatting-ui.preview.describe.topNPercent", String(ruleConfig.value));
4254
+ return localeService.t(ruleConfig.isBottom ? "sheets-conditional-formatting-ui.preview.describe.bottomN" : "sheets-conditional-formatting-ui.preview.describe.topN", String(ruleConfig.value));
4205
4255
  case CFSubRuleType.formula: return localeService.t("sheets-conditional-formatting-ui.ruleType.formula");
4206
4256
  }
4207
4257
  }
4208
- };
4258
+ }
4259
+
4260
+ //#endregion
4261
+ //#region src/views/panel/RuleList.tsx
4209
4262
  function RuleList(props) {
4210
4263
  const { SelectComponent = Select } = props;
4211
4264
  const { onClick } = props;
@@ -4408,7 +4461,7 @@ function RuleList(props) {
4408
4461
  children: rule.ranges.map((range) => serializeRange(range)).join(",")
4409
4462
  })]
4410
4463
  }),
4411
- /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(Preview, { rule: rule.rule }) }),
4464
+ /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(ConditionalFormattingRulePreview, { rule: rule.rule }) }),
4412
4465
  /* @__PURE__ */ jsx("div", {
4413
4466
  className: clsx("univer-absolute univer-right-1 univer-hidden univer-size-6 univer-cursor-pointer univer-items-center univer-justify-center univer-rounded univer-text-red-500 group-hover:univer-flex hover:univer-bg-gray-200 rtl:univer-left-1 rtl:univer-right-auto", { "univer-flex univer-items-center univer-justify-center": draggingId === rule.cfId }),
4414
4467
  onClick: (e) => {
@@ -4433,8 +4486,10 @@ const ConditionFormattingPanel = (props) => {
4433
4486
  setIsShowRuleEditor(true);
4434
4487
  };
4435
4488
  const handleCancel = () => {
4489
+ var _props$onEditorExit;
4436
4490
  setIsShowRuleEditor(false);
4437
4491
  setCurrentEditRule(void 0);
4492
+ (_props$onEditorExit = props.onEditorExit) === null || _props$onEditorExit === void 0 || _props$onEditorExit.call(props);
4438
4493
  };
4439
4494
  const handleRuleClick = (rule) => {
4440
4495
  setCurrentEditRule(rule);
@@ -5266,4 +5321,4 @@ UniverSheetsConditionalFormattingUIPlugin = __decorate([
5266
5321
  ], UniverSheetsConditionalFormattingUIPlugin);
5267
5322
 
5268
5323
  //#endregion
5269
- export { AddAverageCfCommand, AddColorScaleConditionalRuleCommand, AddDataBarConditionalRuleCommand, AddDuplicateValuesCfCommand, AddIconSetConditionalRuleCommand, AddNumberCfCommand, AddRankCfCommand, AddTextCfCommand, AddTimePeriodCfCommand, AddUniqueValuesCfCommand, ConditionalFormattingClearController, OpenConditionalFormattingOperator, menuSchema as SheetsConditionalFormattingUIMenuSchema, UniverSheetsConditionalFormattingMobileUIPlugin, UniverSheetsConditionalFormattingUIPlugin };
5324
+ export { AddAverageCfCommand, AddColorScaleConditionalRuleCommand, AddDataBarConditionalRuleCommand, AddDuplicateValuesCfCommand, AddIconSetConditionalRuleCommand, AddNumberCfCommand, AddRankCfCommand, AddTextCfCommand, AddTimePeriodCfCommand, AddUniqueValuesCfCommand, CF_PANEL_KEY, ConditionalFormattingClearController, ConditionalFormattingRulePreview, OpenConditionalFormattingOperator, menuSchema as SheetsConditionalFormattingUIMenuSchema, UniverSheetsConditionalFormattingMobileUIPlugin, UniverSheetsConditionalFormattingUIPlugin, getRuleDescribe };