@univerjs/sheets-conditional-formatting-ui 0.4.0-alpha.1 → 0.4.0-experimental.20241017-da434a2

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
@@ -9,10 +9,11 @@ import { useObservable, ComponentManager, ILayoutService, useScrollYOverContaine
9
9
  import require$$0, { forwardRef, useRef, createElement, useMemo, useState, useEffect } from "react";
10
10
  import { Select, Tooltip, Dropdown, ColorPicker as ColorPicker$1, InputNumber, RadioGroup, Radio, Checkbox, Input, Button } from "@univerjs/design";
11
11
  import { useHighlightRange, SheetSkeletonManagerService, ISheetClipboardService, COPY_TYPE, rangeToDiscreteRange, PREDEFINED_HOOK_NAME, virtualizeDiscreteRanges, getRepeatRange, SheetPermissionInterceptorBaseController, IAutoFillService, APPLY_TYPE, getAutoFillRepeatRange, IEditorBridgeService, getCurrentRangeDisable$, IFormatPainterService, FormatPainterStatus } from "@univerjs/sheets-ui";
12
- import { serializeRange } from "@univerjs/engine-formula";
12
+ import { serializeRange, deserializeRangeWithSheet } from "@univerjs/engine-formula";
13
13
  import require$$2$1 from "react-dom";
14
14
  import { Observable, debounceTime, merge } from "rxjs";
15
- import { TextEditor, RangeSelector } from "@univerjs/docs-ui";
15
+ import { RangeSelector } from "@univerjs/sheets-formula-ui";
16
+ import { TextEditor } from "@univerjs/docs-ui";
16
17
  import { IRenderManagerService } from "@univerjs/engine-render";
17
18
  import { bufferTime, filter, debounceTime as debounceTime$1 } from "rxjs/operators";
18
19
  const AddAverageCfCommand = {
@@ -6068,7 +6069,10 @@ const cfStyleEdit = "univer-cf-style-edit", buttonItem = "univer-button-item", i
6068
6069
  return (_a15 = univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET).getActiveSheet()) == null ? void 0 : _a15.getSheetId();
6069
6070
  }, "getSubUnitId"), RuleEdit = /* @__PURE__ */ __name((props) => {
6070
6071
  var _a15, _b, _c;
6071
- const localeService = useDependency(LocaleService), commandService = useDependency(ICommandService), univerInstanceService = useDependency(IUniverInstanceService), conditionalFormattingRuleModel = useDependency(ConditionalFormattingRuleModel), selectionManagerService = useDependency(SheetsSelectionsService), unitId = getUnitId(univerInstanceService), subUnitId = getSubUnitId(univerInstanceService), rangeResult = useRef((_b = (_a15 = props.rule) == null ? void 0 : _a15.ranges) != null ? _b : []), rangeString = useMemo(() => {
6072
+ const localeService = useDependency(LocaleService), commandService = useDependency(ICommandService), univerInstanceService = useDependency(IUniverInstanceService), conditionalFormattingRuleModel = useDependency(ConditionalFormattingRuleModel), selectionManagerService = useDependency(SheetsSelectionsService), unitId = getUnitId(univerInstanceService), subUnitId = getSubUnitId(univerInstanceService), [isFocusRangeSelector, isFocusRangeSelectorSet] = useState(() => {
6073
+ const { rule } = props;
6074
+ return (rule == null ? void 0 : rule.rule.type) === CFRuleType.highlightCell ? rule.rule.subType !== CFSubRuleType.formula : !0;
6075
+ }), rangeSelectorActionsRef = useRef({}), [errorText2, errorTextSet] = useState(void 0), rangeResult = useRef((_b = (_a15 = props.rule) == null ? void 0 : _a15.ranges) != null ? _b : []), rangeString = useMemo(() => {
6072
6076
  var _a16, _b2, _c2;
6073
6077
  let ranges = (_a16 = props.rule) == null ? void 0 : _a16.ranges;
6074
6078
  return ranges != null && ranges.length || (ranges = (_c2 = (_b2 = selectionManagerService.getCurrentSelections()) == null ? void 0 : _b2.map((s) => s.range)) != null ? _c2 : []), rangeResult.current = ranges, ranges != null && ranges.length ? ranges.map((range) => {
@@ -6142,9 +6146,12 @@ const cfStyleEdit = "univer-cf-style-edit", buttonItem = "univer-button-item", i
6142
6146
  }, []);
6143
6147
  const onStyleChange = /* @__PURE__ */ __name((config) => {
6144
6148
  result.current = config;
6145
- }, "onStyleChange"), onRangeSelectorChange = /* @__PURE__ */ __name((ranges) => {
6146
- rangeResult.current = ranges.map((r2) => r2.range);
6149
+ }, "onStyleChange"), onRangeSelectorChange = /* @__PURE__ */ __name((rangeString2) => {
6150
+ const result2 = rangeString2.split(",").map(deserializeRangeWithSheet).map((item2) => item2.range);
6151
+ rangeResult.current = result2;
6147
6152
  }, "onRangeSelectorChange"), handleSubmit = /* @__PURE__ */ __name(() => {
6153
+ if (errorText2)
6154
+ return;
6148
6155
  const ranges = (/* @__PURE__ */ __name(() => {
6149
6156
  const worksheet = univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET).getActiveSheet();
6150
6157
  if (!worksheet)
@@ -6163,19 +6170,26 @@ const cfStyleEdit = "univer-cf-style-edit", buttonItem = "univer-button-item", i
6163
6170
  }
6164
6171
  }, "handleSubmit"), handleCancel = /* @__PURE__ */ __name(() => {
6165
6172
  props.onCancel();
6166
- }, "handleCancel");
6167
- return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: styles$1.cfRuleStyleEditor, children: [
6173
+ }, "handleCancel"), handleVerify = /* @__PURE__ */ __name((v, rangeText) => {
6174
+ v ? rangeText.length < 1 ? errorTextSet(localeService.t("sheet.cf.errorMessage.rangeError")) : errorTextSet(void 0) : errorTextSet(localeService.t("sheet.cf.errorMessage.rangeError"));
6175
+ }, "handleVerify"), handlePanelClick = /* @__PURE__ */ __name((e2) => {
6176
+ var _a16;
6177
+ const handleOutClick = (_a16 = rangeSelectorActionsRef.current) == null ? void 0 : _a16.handleOutClick;
6178
+ handleOutClick && handleOutClick(e2, isFocusRangeSelectorSet);
6179
+ }, "handlePanelClick");
6180
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: styles$1.cfRuleStyleEditor, onClick: handlePanelClick, children: [
6168
6181
  /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: styles$5.title, children: localeService.t("sheet.cf.panel.range") }),
6169
6182
  /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: `${styles$5.mTBase}`, children: /* @__PURE__ */ jsxRuntimeExports.jsx(
6170
6183
  RangeSelector,
6171
6184
  {
6172
- placeholder: localeService.t("sheet.cf.form.rangeSelector"),
6173
- width: "100%",
6174
- openForSheetSubUnitId: subUnitId,
6175
- openForSheetUnitId: unitId,
6176
- value: rangeString,
6177
- id: createInternalEditorID(`${SHEET_CONDITIONAL_FORMATTING_PLUGIN}_rangeSelector`),
6178
- onChange: onRangeSelectorChange
6185
+ unitId,
6186
+ errorText: errorText2,
6187
+ subUnitId,
6188
+ initValue: rangeString,
6189
+ onChange: onRangeSelectorChange,
6190
+ onVerify: handleVerify,
6191
+ isFocus: isFocusRangeSelector,
6192
+ actions: rangeSelectorActionsRef.current
6179
6193
  }
6180
6194
  ) }),
6181
6195
  /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: styles$5.title, children: localeService.t("sheet.cf.panel.styleType") }),
@@ -6212,10 +6226,15 @@ let ConditionalFormattingPanelController = (_a3 = class extends Disposable {
6212
6226
  var _a15;
6213
6227
  sheet || (_a15 = this._sidebarDisposable) == null || _a15.dispose();
6214
6228
  })
6215
- );
6229
+ ), this.disposeWithMe(this._sidebarService.sidebarOptions$.subscribe((info) => {
6230
+ info.id === CF_PANEL_KEY && (info.visible || setTimeout(() => {
6231
+ this._sidebarService.sidebarOptions$.next({ visible: !1 });
6232
+ }));
6233
+ }));
6216
6234
  }
6217
6235
  openPanel(rule) {
6218
6236
  const props = {
6237
+ id: CF_PANEL_KEY,
6219
6238
  header: { title: this._localeService.t("sheet.cf.title") },
6220
6239
  children: {
6221
6240
  label: CF_PANEL_KEY,
@@ -151,7 +151,8 @@
151
151
  },
152
152
  "errorMessage": {
153
153
  "notBlank": "Condition can not be empty",
154
- "formulaError": "Wrong formula"
154
+ "formulaError": "Wrong formula",
155
+ "rangeError": "Bad selection"
155
156
  }
156
157
  }
157
158
  }
@@ -151,7 +151,8 @@
151
151
  },
152
152
  "errorMessage": {
153
153
  "notBlank": "شرط نمی‌تواند خالی باشد",
154
- "formulaError": "فرمول اشتباه"
154
+ "formulaError": "فرمول اشتباه",
155
+ "rangeError": "Bad selection"
155
156
  }
156
157
  }
157
158
  }
@@ -151,7 +151,8 @@
151
151
  },
152
152
  "errorMessage": {
153
153
  "notBlank": "Условие не может быть пустым",
154
- "formulaError": "Ошибка формулы"
154
+ "formulaError": "Ошибка формулы",
155
+ "rangeError": "Bad selection"
155
156
  }
156
157
  }
157
158
  }
@@ -151,7 +151,8 @@
151
151
  },
152
152
  "errorMessage": {
153
153
  "notBlank": "Điều kiện không được để trống",
154
- "formulaError": "Lỗi công thức"
154
+ "formulaError": "Lỗi công thức",
155
+ "rangeError": "Bad selection"
155
156
  }
156
157
  }
157
158
  }
@@ -151,6 +151,7 @@
151
151
  },
152
152
  "errorMessage": {
153
153
  "notBlank": "条件不能为空",
154
+ "rangeError": "选区错误",
154
155
  "formulaError": "公式错误"
155
156
  }
156
157
  }
@@ -151,6 +151,7 @@
151
151
  },
152
152
  "errorMessage": {
153
153
  "notBlank": "條件不能為空",
154
+ "rangeError": "選區錯誤",
154
155
  "formulaError": "公式錯誤"
155
156
  }
156
157
  }
@@ -1,5 +1,5 @@
1
- import { default as React } from 'react';
2
1
  import { IConditionFormattingRule } from '@univerjs/sheets-conditional-formatting';
2
+ import { default as React } from 'react';
3
3
  interface IRuleEditProps {
4
4
  rule?: IConditionFormattingRule;
5
5
  onCancel: () => void;
@@ -166,6 +166,7 @@ declare const locale: {
166
166
  };
167
167
  errorMessage: {
168
168
  notBlank: string;
169
+ rangeError: string;
169
170
  formulaError: string;
170
171
  };
171
172
  };