@univerjs/sheets-data-validation-ui 0.4.1-nightly.202410241606 → 0.4.1-nightly.202410261605

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
@@ -7,7 +7,7 @@ import { Inject, LocaleService, Disposable, DataValidationErrorStyle, useDepende
7
7
  import { Button, DatePanel, RectPopup, Scrollbar, FormLayout, RadioGroup, Radio, Checkbox, Input, Select, DraggableList } from "@univerjs/design";
8
8
  import { DeviceInputEventType, IRenderManagerService, fixLineWidthByScale, Transform, Checkbox as Checkbox$1, FontCache, Shape, Rect, getFontStyleString, getDocsSkeletonPageSize, DocumentViewModel, DocumentSkeleton, Documents } from "@univerjs/engine-render";
9
9
  import { SetRangeValuesCommand, SheetsSelectionsService, getSheetCommandTarget, WorkbookEditablePermission, RangeProtectionPermissionEditPoint, WorksheetEditPermission, checkRangesEditablePermission, WorksheetSetCellStylePermission, SheetInterceptorService, INTERCEPTOR_POINT, InterceptCellContentPriority } from "@univerjs/sheets";
10
- import { SheetDataValidationModel, getCellValueOrigin, getDataValidationCellValue, deserializeListOptions, serializeListOptions, UpdateSheetDataValidationRangeCommand, UpdateSheetDataValidationSettingCommand, RemoveSheetDataValidationCommand, UpdateSheetDataValidationOptionsCommand, createDefaultNewRule, AddSheetDataValidationCommand, RemoveSheetAllDataValidationCommand, DATA_VALIDATION_PLUGIN_NAME, getDataValidationDiffMutations, DataValidationCacheService, DataValidationFormulaController, DataValidationFormulaService, getFormulaResult, transformCheckboxValue, CHECKBOX_FORMULA_1, CHECKBOX_FORMULA_2 } from "@univerjs/sheets-data-validation";
10
+ import { SheetDataValidationModel, getCellValueOrigin, getDataValidationCellValue, deserializeListOptions, serializeListOptions, UpdateSheetDataValidationRangeCommand, UpdateSheetDataValidationSettingCommand, RemoveSheetDataValidationCommand, UpdateSheetDataValidationOptionsCommand, createDefaultNewRule, AddSheetDataValidationCommand, RemoveSheetAllDataValidationCommand, DATA_VALIDATION_PLUGIN_NAME, getDataValidationDiffMutations, DataValidationCacheService, DataValidationFormulaController, DataValidationFormulaService, getFormulaResult, isLegalFormulaResult, transformCheckboxValue, CHECKBOX_FORMULA_1, CHECKBOX_FORMULA_2 } from "@univerjs/sheets-data-validation";
11
11
  import { getPatternType } from "@univerjs/sheets-numfmt";
12
12
  import { IEditorBridgeService, SetCellEditVisibleOperation, SheetCanvasPopManagerService, SheetPermissionInterceptorBaseController, IMarkSelectionService, HoverManagerService, CellAlertManagerService, CellAlertType, IAutoFillService, APPLY_TYPE, virtualizeDiscreteRanges, getAutoFillRepeatRange, COPY_TYPE, rangeToDiscreteRange, PREDEFINED_HOOK_NAME, getRepeatRange, ISheetClipboardService, getCurrentRangeDisable$, AutoHeightController, SheetSkeletonManagerService } from "@univerjs/sheets-ui";
13
13
  import { IDialogService, KeyCode, ISidebarService, useObservable, ComponentManager, IZenZoneService, useEvent, MenuItemType, getMenuHiddenObservable, RibbonStartGroup, IMenuManagerService } from "@univerjs/ui";
@@ -1119,7 +1119,8 @@ function getSheetIdByName(univerInstanceService, unitId, name) {
1119
1119
  }
1120
1120
  __name(getSheetIdByName, "getSheetIdByName");
1121
1121
  function DataValidationDetail() {
1122
- const [key, setKey] = useState(0), dataValidationPanelService = useDependency(DataValidationPanelService), activeRuleInfo = useObservable(dataValidationPanelService.activeRule$, dataValidationPanelService.activeRule), { unitId, subUnitId, rule } = activeRuleInfo || {}, ruleId = rule.uid, validatorService = useDependency(DataValidatorRegistryService), univerInstanceService = useDependency(IUniverInstanceService), componentManager = useDependency(ComponentManager), commandService = useDependency(ICommandService), dataValidationModel = useDependency(DataValidationModel), localeService = useDependency(LocaleService), [localRule, setLocalRule] = useState(rule), validator = validatorService.getValidatorItem(localRule.type), [showError, setShowError] = useState(!1), validators = validatorService.getValidatorsByScope(DataValidatorRegistryScope.SHEET), [localRanges, setLocalRanges] = useState(() => localRule.ranges.map((i) => ({ unitId: "", sheetId: "", range: i }))), debounceExecute = useMemo(() => debounceExecuteFactory(commandService), [commandService]), rangeSelectorActionsRef = useRef({}), [isFocusRangeSelector, isFocusRangeSelectorSet] = useState(!1), sheetSelectionService = useDependency(SheetsSelectionsService);
1122
+ var _a18;
1123
+ const [key, setKey] = useState(0), dataValidationPanelService = useDependency(DataValidationPanelService), activeRuleInfo = useObservable(dataValidationPanelService.activeRule$, dataValidationPanelService.activeRule), { unitId, subUnitId, rule } = activeRuleInfo || {}, ruleId = rule.uid, validatorService = useDependency(DataValidatorRegistryService), univerInstanceService = useDependency(IUniverInstanceService), componentManager = useDependency(ComponentManager), commandService = useDependency(ICommandService), dataValidationModel = useDependency(DataValidationModel), localeService = useDependency(LocaleService), [localRule, setLocalRule] = useState(rule), validator = validatorService.getValidatorItem(localRule.type), [showError, setShowError] = useState(!1), validators = validatorService.getValidatorsByScope(DataValidatorRegistryScope.SHEET), [localRanges, setLocalRanges] = useState(() => localRule.ranges.map((i) => ({ unitId: "", sheetId: "", range: i }))), debounceExecute = useMemo(() => debounceExecuteFactory(commandService), [commandService]), [isRangeError, setIsRangeError] = useState(!1), rangeSelectorActionsRef = useRef({}), [isFocusRangeSelector, isFocusRangeSelectorSet] = useState(!1), sheetSelectionService = useDependency(SheetsSelectionsService);
1123
1124
  if (useEffect(() => () => {
1124
1125
  const currentSelection = sheetSelectionService.getCurrentLastSelection();
1125
1126
  currentSelection && sheetSelectionService.setSelections([currentSelection]);
@@ -1133,7 +1134,7 @@ function DataValidationDetail() {
1133
1134
  }, [commandService, dataValidationModel, ruleId, subUnitId, unitId]), !validator)
1134
1135
  return null;
1135
1136
  const operators = validator.operators, operatorNames = validator.operatorNames, isTwoFormula = localRule.operator ? TWO_FORMULA_OPERATOR_COUNT.includes(localRule.operator) : !1, handleOk = /* @__PURE__ */ __name(() => {
1136
- localRule.ranges.length && (validator.validatorFormula(localRule, unitId, subUnitId).success ? dataValidationPanelService.setActiveRule(null) : setShowError(!0));
1137
+ !localRule.ranges.length || isRangeError || (validator.validatorFormula(localRule, unitId, subUnitId).success ? dataValidationPanelService.setActiveRule(null) : setShowError(!0));
1137
1138
  }, "handleOk"), handleUpdateRuleRanges = useEvent((rangeText) => {
1138
1139
  const unitRanges = rangeText.split(",").map(deserializeRangeWithSheet).map((unitRange) => {
1139
1140
  const sheetName = unitRange.sheetName;
@@ -1226,8 +1227,8 @@ function DataValidationDetail() {
1226
1227
  }
1227
1228
  ));
1228
1229
  }, "handleUpdateRuleOptions"), handlePanelClick = /* @__PURE__ */ __name((e) => {
1229
- var _a18;
1230
- const handleOutClick = (_a18 = rangeSelectorActionsRef.current) == null ? void 0 : _a18.handleOutClick;
1230
+ var _a19;
1231
+ const handleOutClick = (_a19 = rangeSelectorActionsRef.current) == null ? void 0 : _a19.handleOutClick;
1231
1232
  handleOutClick && handleOutClick(e, isFocusRangeSelectorSet);
1232
1233
  }, "handlePanelClick");
1233
1234
  return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: styles$3.dataValidationDetail, onClick: handlePanelClick, children: [
@@ -1235,7 +1236,7 @@ function DataValidationDetail() {
1235
1236
  FormLayout,
1236
1237
  {
1237
1238
  label: localeService.t("dataValidation.panel.range"),
1238
- error: localRule.ranges.length ? "" : localeService.t("dataValidation.panel.rangeError"),
1239
+ error: !localRule.ranges.length || isRangeError ? localeService.t("dataValidation.panel.rangeError") : "",
1239
1240
  children: /* @__PURE__ */ jsxRuntimeExports.jsx(
1240
1241
  RangeSelector,
1241
1242
  {
@@ -1244,7 +1245,8 @@ function DataValidationDetail() {
1244
1245
  initValue: rangeStr,
1245
1246
  onChange: handleUpdateRuleRanges,
1246
1247
  isFocus: isFocusRangeSelector,
1247
- actions: rangeSelectorActionsRef.current
1248
+ actions: rangeSelectorActionsRef.current,
1249
+ onVerify: /* @__PURE__ */ __name((isValid) => setIsRangeError(!isValid), "onVerify")
1248
1250
  }
1249
1251
  )
1250
1252
  }
@@ -1300,6 +1302,20 @@ function DataValidationDetail() {
1300
1302
  },
1301
1303
  key + localRule.type
1302
1304
  ) : null,
1305
+ /* @__PURE__ */ jsxRuntimeExports.jsx(FormLayout, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(
1306
+ Checkbox,
1307
+ {
1308
+ checked: (_a18 = localRule.allowBlank) != null ? _a18 : !0,
1309
+ onChange: /* @__PURE__ */ __name(() => {
1310
+ var _a19;
1311
+ return handleUpdateRuleSetting({
1312
+ ...baseRule,
1313
+ allowBlank: !((_a19 = localRule.allowBlank) == null || _a19)
1314
+ });
1315
+ }, "onChange"),
1316
+ children: localeService.t("dataValidation.panel.allowBlank")
1317
+ }
1318
+ ) }),
1303
1319
  /* @__PURE__ */ jsxRuntimeExports.jsx(DataValidationOptions, { value: options, onChange: handleUpdateRuleOptions, extraComponent: validator.optionsInput }),
1304
1320
  /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: styles$3.dataValidationDetailButtons, children: [
1305
1321
  /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { className: styles$3.dataValidationDetailButton, onClick: handleDelete, children: localeService.t("dataValidation.panel.removeRule") }),
@@ -2611,11 +2627,12 @@ let CheckboxRender = (_a11 = class {
2611
2627
  return ((_a18 = style == null ? void 0 : style.fs) != null ? _a18 : 10) * 1.6;
2612
2628
  }
2613
2629
  async _parseFormula(rule, unitId, subUnitId) {
2614
- var _a18, _b;
2615
- const { formula1 = CHECKBOX_FORMULA_1, formula2 = CHECKBOX_FORMULA_2 } = rule, results = await this._formulaService.getRuleFormulaResult(unitId, subUnitId, rule.uid);
2630
+ var _a18, _b, _c;
2631
+ const { formula1 = CHECKBOX_FORMULA_1, formula2 = CHECKBOX_FORMULA_2 } = rule, results = await this._formulaService.getRuleFormulaResult(unitId, subUnitId, rule.uid), formulaResult1 = getFormulaResult((_a18 = results == null ? void 0 : results[0]) == null ? void 0 : _a18.result), formulaResult2 = getFormulaResult((_b = results == null ? void 0 : results[1]) == null ? void 0 : _b.result), isFormulaValid = isLegalFormulaResult(String(formulaResult1)) && isLegalFormulaResult(String(formulaResult2));
2616
2632
  return {
2617
- formula1: isFormulaString(formula1) ? getFormulaResult((_a18 = results == null ? void 0 : results[0]) == null ? void 0 : _a18.result) : formula1,
2618
- formula2: isFormulaString(formula2) ? getFormulaResult((_b = results == null ? void 0 : results[1]) == null ? void 0 : _b.result) : formula2
2633
+ formula1: isFormulaString(formula1) ? getFormulaResult((_c = results == null ? void 0 : results[0]) == null ? void 0 : _c.result) : formula1,
2634
+ formula2: isFormulaString(formula2) ? formulaResult2 : formula2,
2635
+ isFormulaValid
2619
2636
  };
2620
2637
  }
2621
2638
  drawWith(ctx, info) {
@@ -34,7 +34,8 @@
34
34
  "rejectInput": "Reject input",
35
35
  "messageInfo": "Helper message",
36
36
  "showInfo": "Show help text for a selected cell",
37
- "rangeError": "Ranges are not legal"
37
+ "rangeError": "Ranges are not legal",
38
+ "allowBlank": "Allow blank values"
38
39
  },
39
40
  "operators": {
40
41
  "between": "between",
@@ -66,6 +67,10 @@
66
67
  "notEqual": "Value must be not equal to {FORMULA1}",
67
68
  "notBetween": "Value must be not between {FORMULA1} and {FORMULA2}"
68
69
  },
70
+ "any": {
71
+ "title": "Any value",
72
+ "error": "The content of this cell violates the validation rule"
73
+ },
69
74
  "date": {
70
75
  "title": "Date",
71
76
  "operators": {
@@ -145,7 +150,8 @@
145
150
  "custom": {
146
151
  "title": "Custom formula",
147
152
  "error": "This cell's contents violate its validation rule",
148
- "validFail": "Please input a valid formula"
153
+ "validFail": "Please input a valid formula",
154
+ "ruleName": "Custom formula is {FORMULA1}"
149
155
  },
150
156
  "alert": {
151
157
  "title": "Error",
@@ -34,7 +34,8 @@
34
34
  "rejectInput": "رد ورودی",
35
35
  "messageInfo": "پیام راهنما",
36
36
  "showInfo": "نمایش متن راهنما برای یک سلول انتخاب شده",
37
- "rangeError": "محدوده‌ها نامعتبر هستند"
37
+ "rangeError": "محدوده‌ها نامعتبر هستند",
38
+ "allowBlank": "رد سلول خالی"
38
39
  },
39
40
  "operators": {
40
41
  "between": "بین",
@@ -66,6 +67,10 @@
66
67
  "notEqual": "مقدار باید برابر نیست با {FORMULA1}",
67
68
  "notBetween": "مقدار باید بین {FORMULA1} و {FORMULA2} نباشد"
68
69
  },
70
+ "any": {
71
+ "title": "هر مقدار",
72
+ "error": "محتوای این سلول نقض قانون اعتبارسنجی است"
73
+ },
69
74
  "date": {
70
75
  "title": "تاریخ",
71
76
  "operators": {
@@ -143,9 +148,10 @@
143
148
  "unchecked": "مقدار انتخاب نشده"
144
149
  },
145
150
  "custom": {
146
- "title": "فرمول سفارشی",
151
+ "title": "فرمول سفارشی ",
147
152
  "error": "محتوای این سلول با قانون اعتبارسنجی آن نقض می‌شود",
148
- "validFail": "لطفا یک فرمول معتبر وارد کنید"
153
+ "validFail": "لطفا یک فرمول معتبر وارد کنید",
154
+ "ruleName": "فرمول سفارشی {FORMULA1}"
149
155
  },
150
156
  "alert": {
151
157
  "title": "خطا",
@@ -34,7 +34,8 @@
34
34
  "showWarning": "Показать предупреждение",
35
35
  "rejectInput": "Отклонить ввод",
36
36
  "messageInfo": "Сообщение помощи",
37
- "showInfo": "Показать текст помощи для выбранной ячейки"
37
+ "showInfo": "Показать текст помощи для выбранной ячейки",
38
+ "allowBlank": "Игнорировать пустые значения"
38
39
  },
39
40
  "operators": {
40
41
  "between": "между",
@@ -66,6 +67,10 @@
66
67
  "notEqual": "Значение должно быть не равно {FORMULA1}",
67
68
  "notBetween": "Значение должно быть не между {FORMULA1} и {FORMULA2}"
68
69
  },
70
+ "any": {
71
+ "title": "Любое значение",
72
+ "error": "Содержимое этой ячейки нарушает правило проверки"
73
+ },
69
74
  "date": {
70
75
  "title": "Дата",
71
76
  "operators": {
@@ -145,7 +150,8 @@
145
150
  "custom": {
146
151
  "title": "Пользовательская формула",
147
152
  "error": "Содержимое этой ячейки нарушает правило проверки",
148
- "validFail": "Пожалуйста, введите допустимую формулу"
153
+ "validFail": "Пожалуйста, введите допустимую формулу",
154
+ "ruleName": "Пользовательская формула {FORMULA1}"
149
155
  },
150
156
  "alert": {
151
157
  "title": "Ошибка",
@@ -34,7 +34,8 @@
34
34
  "showWarning": "Hiển thị cảnh báo",
35
35
  "rejectInput": "Từ chối đầu vào",
36
36
  "messageInfo": "Thông báo",
37
- "showInfo": "Hiển thị thông báo cho ô đã chọn"
37
+ "showInfo": "Hiển thị thông báo cho ô đã chọn",
38
+ "allowBlank": "Bỏ qua giá trị rỗng"
38
39
  },
39
40
  "operators": {
40
41
  "between": "Giữa",
@@ -66,6 +67,10 @@
66
67
  "notEqual": "Giá trị phải không bằng {FORMULA1}",
67
68
  "notBetween": "Giá trị phải không nằm giữa {FORMULA1} và {FORMULA2}"
68
69
  },
70
+ "any": {
71
+ "title": "Bất kỳ giá trị",
72
+ "error": "Nội dung của ô này vi phạm quy tắc xác thực"
73
+ },
69
74
  "date": {
70
75
  "title": "Ngày",
71
76
  "operators": {
@@ -145,7 +150,8 @@
145
150
  "custom": {
146
151
  "title": "Công thức tùy chỉnh",
147
152
  "error": "Nội dung của ô này vi phạm quy tắc xác thực",
148
- "validFail": "Vui lòng nhập một công thức hợp lệ"
153
+ "validFail": "Vui lòng nhập một công thức hợp lệ",
154
+ "ruleName": "Công thức tùy chỉnh {FORMULA1}"
149
155
  },
150
156
  "alert": {
151
157
  "title": "Thông báo",
@@ -34,7 +34,8 @@
34
34
  "showWarning": "显示警告",
35
35
  "rejectInput": "拒绝输入",
36
36
  "messageInfo": "文字提示",
37
- "showInfo": "显示所选单元格的提示文字"
37
+ "showInfo": "显示所选单元格的提示文字",
38
+ "allowBlank": "忽略空值"
38
39
  },
39
40
  "operators": {
40
41
  "between": "介于",
@@ -66,6 +67,10 @@
66
67
  "notEqual": "值必须不等于 {FORMULA1}",
67
68
  "notBetween": "值必须在 {FORMULA1} 和 {FORMULA2} 范围之外"
68
69
  },
70
+ "any": {
71
+ "title": "任意值",
72
+ "error": "此单元格的内容违反了验证规则"
73
+ },
69
74
  "date": {
70
75
  "title": "日期",
71
76
  "operators": {
@@ -145,7 +150,8 @@
145
150
  "custom": {
146
151
  "title": "自定义公式",
147
152
  "error": "此单元格的内容违反了验证规则",
148
- "validFail": "请输入合法的公式"
153
+ "validFail": "请输入合法的公式",
154
+ "ruleName": "自定义公式 {FORMULA1}"
149
155
  },
150
156
  "alert": {
151
157
  "title": "提示",
@@ -34,7 +34,8 @@
34
34
  "showWarning": "顯示警告",
35
35
  "rejectInput": "拒絕輸入",
36
36
  "messageInfo": "文字提示",
37
- "showInfo": "顯示所選單元格的提示文字"
37
+ "showInfo": "顯示所選單元格的提示文字",
38
+ "allowBlank": "忽略空值"
38
39
  },
39
40
  "operators": {
40
41
  "between": "介於",
@@ -66,6 +67,10 @@
66
67
  "notEqual": "值必須不等於 {FORMULA1}",
67
68
  "notBetween": "值必須在 {FORMULA1} 和 {FORMULA2} 範圍之外"
68
69
  },
70
+ "any": {
71
+ "title": "任意值",
72
+ "error": "此儲存格的內容違反了驗證規則"
73
+ },
69
74
  "date": {
70
75
  "title": "日期",
71
76
  "operators": {
@@ -145,7 +150,8 @@
145
150
  "custom": {
146
151
  "title": "自訂公式",
147
152
  "error": "此儲存格的內容違反了驗證規則",
148
- "validFail": "請輸入合法的公式"
153
+ "validFail": "請輸入合法的公式",
154
+ "ruleName": "自訂公式 {FORMULA1}"
149
155
  },
150
156
  "alert": {
151
157
  "title": "提示",
@@ -50,6 +50,7 @@ declare const locale: {
50
50
  rejectInput: string;
51
51
  messageInfo: string;
52
52
  showInfo: string;
53
+ allowBlank: string;
53
54
  };
54
55
  operators: {
55
56
  between: string;
@@ -81,6 +82,10 @@ declare const locale: {
81
82
  notEqual: string;
82
83
  notBetween: string;
83
84
  };
85
+ any: {
86
+ title: string;
87
+ error: string;
88
+ };
84
89
  date: {
85
90
  title: string;
86
91
  operators: {
@@ -161,6 +166,7 @@ declare const locale: {
161
166
  title: string;
162
167
  error: string;
163
168
  validFail: string;
169
+ ruleName: string;
164
170
  };
165
171
  alert: {
166
172
  title: string;