@univerjs/sheets-data-validation-ui 1.0.4 → 1.2.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 +127 -63
- package/lib/es/index.js +126 -62
- package/lib/index.css +16 -0
- package/lib/index.js +126 -62
- package/lib/types/controllers/dv-alert.controller.d.ts +9 -2
- package/lib/types/controllers/dv-render.controller.d.ts +1 -0
- package/lib/umd/index.js +1 -1
- package/package.json +19 -19
package/lib/index.css
CHANGED
|
@@ -297,10 +297,18 @@
|
|
|
297
297
|
color: var(--univer-gray-400);
|
|
298
298
|
}
|
|
299
299
|
|
|
300
|
+
.univer-text-gray-500 {
|
|
301
|
+
color: var(--univer-gray-500);
|
|
302
|
+
}
|
|
303
|
+
|
|
300
304
|
.univer-text-gray-900 {
|
|
301
305
|
color: var(--univer-gray-900);
|
|
302
306
|
}
|
|
303
307
|
|
|
308
|
+
.univer-text-primary-600 {
|
|
309
|
+
color: var(--univer-primary-600);
|
|
310
|
+
}
|
|
311
|
+
|
|
304
312
|
.univer-opacity-50 {
|
|
305
313
|
opacity: .5;
|
|
306
314
|
}
|
|
@@ -381,6 +389,10 @@
|
|
|
381
389
|
background-color: var(--univer-gray-800) !important;
|
|
382
390
|
}
|
|
383
391
|
|
|
392
|
+
.dark\:\!univer-bg-gray-900:where(.univer-dark, .univer-dark *) {
|
|
393
|
+
background-color: var(--univer-gray-900) !important;
|
|
394
|
+
}
|
|
395
|
+
|
|
384
396
|
.dark\:\!univer-text-gray-0:where(.univer-dark, .univer-dark *) {
|
|
385
397
|
color: var(--univer-gray-0) !important;
|
|
386
398
|
}
|
|
@@ -389,6 +401,10 @@
|
|
|
389
401
|
color: var(--univer-gray-300) !important;
|
|
390
402
|
}
|
|
391
403
|
|
|
404
|
+
.dark\:\!univer-text-primary-500:where(.univer-dark, .univer-dark *) {
|
|
405
|
+
color: var(--univer-primary-500) !important;
|
|
406
|
+
}
|
|
407
|
+
|
|
392
408
|
@media (hover: hover) and (pointer: fine) {
|
|
393
409
|
.dark\:hover\:\!univer-bg-gray-700:hover:where(.univer-dark, .univer-dark *) {
|
|
394
410
|
background-color: var(--univer-gray-700) !important;
|
package/lib/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { CellValueType, ColorKit, CommandType, DEFAULT_STYLES, DataValidationErrorStyle, DataValidationRenderMode, DataValidationStatus, DataValidationType, DateSystem, DependentOn, Disposable, DisposableCollection, HorizontalAlign, ICommandService, IConfigService, IUniverInstanceService, Inject, Injector, InterceptorEffectEnum, LocaleService, Optional, Plugin, Rectangle, RedoCommand, RxDisposable, ThemeService, UndoCommand, UniverInstanceType, VerticalAlign, WrapStrategy, bufferDebounceTime, dateKit, debounce, excelDateTimePartsToSerial, excelSerialToDateTimeParts, generateRandomId, getIntersectRange, isFormulaString, isUnitRangesEqual, merge, numfmt, sequenceExecute, shallowEqual, toDisposable } from "@univerjs/core";
|
|
1
|
+
import { CanceledError, CellValueType, ColorKit, CommandType, DEFAULT_STYLES, DataValidationErrorStyle, DataValidationRenderMode, DataValidationStatus, DataValidationType, DateSystem, DependentOn, Disposable, DisposableCollection, HorizontalAlign, ICommandService, IConfigService, IUniverInstanceService, Inject, Injector, InterceptorEffectEnum, LocaleService, Optional, Plugin, Rectangle, RedoCommand, RxDisposable, ThemeService, UndoCommand, UniverInstanceType, VerticalAlign, WrapStrategy, bufferDebounceTime, dateKit, debounce, excelDateTimePartsToSerial, excelSerialToDateTimeParts, generateRandomId, getIntersectRange, isFormulaString, isUnitRangesEqual, merge, numfmt, sequenceExecute, shallowEqual, toDisposable } from "@univerjs/core";
|
|
2
2
|
import { DataValidationModel, DataValidatorDropdownType, DataValidatorRegistryScope, DataValidatorRegistryService, TWO_FORMULA_OPERATOR_COUNT, UniverDataValidationPlugin, getRuleOptions, getRuleSetting } from "@univerjs/data-validation";
|
|
3
3
|
import { AUTO_FILL_APPLY_TYPE, AutoFillTools, IAutoFillService, INTERCEPTOR_POINT, InterceptCellContentPriority, RangeProtectionPermissionEditPoint, SetRangeValuesCommand, SetWorksheetActiveOperation, SheetInterceptorService, SheetPermissionCheckController, SheetsSelectionsService, UniverSheetsPlugin, VALIDATE_CELL, WorkbookEditablePermission, WorksheetEditPermission, WorksheetSetCellStylePermission, checkRangesEditablePermission, deserializeListOptions, getSheetCommandTarget, rangeToDiscreteRange, serializeListOptions } from "@univerjs/sheets";
|
|
4
4
|
import { ComponentManager, IDialogService, IMenuManagerService, ISidebarService, IconManager, KeyCode, MenuItemType, RibbonDataGroup, RibbonInsertGroup, UniverMobileUIPlugin, getMenuHiddenObservable, useDependency, useEvent, useObservable, useSidebarClick } from "@univerjs/ui";
|
|
5
|
-
import { BehaviorSubject, Subject, bufferTime, debounceTime, distinctUntilChanged, filter, map, of, startWith, switchMap, takeUntil } from "rxjs";
|
|
5
|
+
import { BehaviorSubject, Subject, auditTime, bufferTime, debounceTime, distinctUntilChanged, filter, map, noop, of, startWith, switchMap, takeUntil, tap } from "rxjs";
|
|
6
6
|
import { CURSOR_TYPE, CheckboxShape, DeviceInputEventType, DocSimpleSkeleton, FontCache, IRenderManagerService, Rect, Shape, Text, Transform, UniverRenderEnginePlugin, fixLineWidthByScale, getCurrentTypeOfRenderer, getFontStyleString } from "@univerjs/engine-render";
|
|
7
7
|
import { AddSheetDataValidationCommand, BASE_FORMULA_INPUT_NAME, CHECKBOX_FORMULA_1, CHECKBOX_FORMULA_2, CHECKBOX_FORMULA_INPUT_NAME, CUSTOM_FORMULA_INPUT_NAME, ClearRangeDataValidationCommand, DATA_VALIDATION_PLUGIN_NAME, DataValidationCacheService, DataValidationFormulaController, DataValidationFormulaService, LIST_FORMULA_INPUT_NAME, RemoveSheetAllDataValidationCommand, RemoveSheetDataValidationCommand, SheetDataValidationModel, SheetsDataValidationValidatorService, UniverSheetsDataValidationPlugin, UpdateSheetDataValidationOptionsCommand, UpdateSheetDataValidationRangeCommand, UpdateSheetDataValidationSettingCommand, createDefaultNewRule, getCellValueOrigin, getDataValidationCellValue, getDataValidationDiffMutations, getFormulaResult, isLegalFormulaResult, transformCheckboxValue } from "@univerjs/sheets-data-validation";
|
|
8
8
|
import { getPatternType } from "@univerjs/sheets-numfmt";
|
|
@@ -14,7 +14,7 @@ import { CheckboxIcon, DataValidationIcon, DatePickerIcon, DeleteIcon, DropdownL
|
|
|
14
14
|
import { deserializeRangeWithSheet, serializeRange } from "@univerjs/engine-formula";
|
|
15
15
|
import { FormulaEditor, RangeSelector } from "@univerjs/sheets-formula-ui";
|
|
16
16
|
|
|
17
|
-
//#region \0@oxc-project+runtime@0.
|
|
17
|
+
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/typeof.js
|
|
18
18
|
function _typeof(o) {
|
|
19
19
|
"@babel/helpers - typeof";
|
|
20
20
|
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
@@ -25,7 +25,7 @@ function _typeof(o) {
|
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
//#endregion
|
|
28
|
-
//#region \0@oxc-project+runtime@0.
|
|
28
|
+
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/toPrimitive.js
|
|
29
29
|
function toPrimitive(t, r) {
|
|
30
30
|
if ("object" != _typeof(t) || !t) return t;
|
|
31
31
|
var e = t[Symbol.toPrimitive];
|
|
@@ -38,14 +38,14 @@ function toPrimitive(t, r) {
|
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
//#endregion
|
|
41
|
-
//#region \0@oxc-project+runtime@0.
|
|
41
|
+
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/toPropertyKey.js
|
|
42
42
|
function toPropertyKey(t) {
|
|
43
43
|
var i = toPrimitive(t, "string");
|
|
44
44
|
return "symbol" == _typeof(i) ? i : i + "";
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
//#endregion
|
|
48
|
-
//#region \0@oxc-project+runtime@0.
|
|
48
|
+
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/defineProperty.js
|
|
49
49
|
function _defineProperty(e, r, t) {
|
|
50
50
|
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
51
51
|
value: t,
|
|
@@ -56,7 +56,7 @@ function _defineProperty(e, r, t) {
|
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
//#endregion
|
|
59
|
-
//#region \0@oxc-project+runtime@0.
|
|
59
|
+
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/decorateParam.js
|
|
60
60
|
function __decorateParam(paramIndex, decorator) {
|
|
61
61
|
return function(target, key) {
|
|
62
62
|
decorator(target, key, paramIndex);
|
|
@@ -64,7 +64,7 @@ function __decorateParam(paramIndex, decorator) {
|
|
|
64
64
|
}
|
|
65
65
|
|
|
66
66
|
//#endregion
|
|
67
|
-
//#region \0@oxc-project+runtime@0.
|
|
67
|
+
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/decorate.js
|
|
68
68
|
function __decorate(decorators, target, key, desc) {
|
|
69
69
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
70
70
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -1054,8 +1054,7 @@ const menuSchema = {
|
|
|
1054
1054
|
order: 0,
|
|
1055
1055
|
gridLayout: {
|
|
1056
1056
|
row: 1,
|
|
1057
|
-
column: 1
|
|
1058
|
-
showLabel: true
|
|
1057
|
+
column: 1
|
|
1059
1058
|
},
|
|
1060
1059
|
menuItemFactory: dataValidationMenuFactory,
|
|
1061
1060
|
[OpenValidationPanelOperation.id]: {
|
|
@@ -1072,80 +1071,132 @@ const menuSchema = {
|
|
|
1072
1071
|
//#endregion
|
|
1073
1072
|
//#region package.json
|
|
1074
1073
|
var name = "@univerjs/sheets-data-validation-ui";
|
|
1075
|
-
var version = "1.0
|
|
1074
|
+
var version = "1.2.0";
|
|
1076
1075
|
|
|
1077
1076
|
//#endregion
|
|
1078
1077
|
//#region src/controllers/dv-alert.controller.ts
|
|
1079
1078
|
const ALERT_KEY = "SHEET_DATA_VALIDATION_ALERT";
|
|
1080
1079
|
let DataValidationAlertController = class DataValidationAlertController extends Disposable {
|
|
1081
|
-
constructor(_hoverManagerService, _cellAlertManagerService, _univerInstanceService, _localeService, _dataValidationModel) {
|
|
1080
|
+
constructor(_hoverManagerService, _cellAlertManagerService, _univerInstanceService, _localeService, _dataValidationModel, _dataValidationCacheService) {
|
|
1082
1081
|
super();
|
|
1083
1082
|
this._hoverManagerService = _hoverManagerService;
|
|
1084
1083
|
this._cellAlertManagerService = _cellAlertManagerService;
|
|
1085
1084
|
this._univerInstanceService = _univerInstanceService;
|
|
1086
1085
|
this._localeService = _localeService;
|
|
1087
1086
|
this._dataValidationModel = _dataValidationModel;
|
|
1087
|
+
this._dataValidationCacheService = _dataValidationCacheService;
|
|
1088
|
+
_defineProperty(this, "_hoveredCell", null);
|
|
1088
1089
|
this._init();
|
|
1089
1090
|
}
|
|
1090
1091
|
_init() {
|
|
1091
1092
|
this._initCellAlertPopup();
|
|
1092
1093
|
}
|
|
1093
1094
|
_initCellAlertPopup() {
|
|
1094
|
-
this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(UniverInstanceType.UNIVER_SHEET).pipe(switchMap((workbook) => (workbook === null || workbook === void 0 ? void 0 : workbook.activeSheet$) ?? of(null))).subscribe(() =>
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
}) === DataValidationStatus.INVALID) {
|
|
1115
|
-
var _currentAlert$alert;
|
|
1116
|
-
const currentAlert = this._cellAlertManagerService.currentAlert.get(ALERT_KEY);
|
|
1117
|
-
const currentLoc = currentAlert === null || currentAlert === void 0 || (_currentAlert$alert = currentAlert.alert) === null || _currentAlert$alert === void 0 ? void 0 : _currentAlert$alert.location;
|
|
1118
|
-
if (currentLoc && currentLoc.row === cellPos.location.row && currentLoc.col === cellPos.location.col && currentLoc.subUnitId === cellPos.location.subUnitId && currentLoc.unitId === cellPos.location.unitId) {
|
|
1119
|
-
this._cellAlertManagerService.removeAlert(ALERT_KEY);
|
|
1120
|
-
return;
|
|
1121
|
-
}
|
|
1122
|
-
const validator = this._dataValidationModel.getValidator(rule.type);
|
|
1123
|
-
if (!validator) {
|
|
1124
|
-
this._cellAlertManagerService.removeAlert(ALERT_KEY);
|
|
1125
|
-
return;
|
|
1126
|
-
}
|
|
1127
|
-
this._cellAlertManagerService.showAlert({
|
|
1128
|
-
type: CellAlertType.ERROR,
|
|
1129
|
-
title: this._localeService.t("sheets-data-validation-ui.error.title"),
|
|
1130
|
-
message: validator === null || validator === void 0 ? void 0 : validator.getRuleFinalError(rule, cellPos.location),
|
|
1131
|
-
location: cellPos.location,
|
|
1132
|
-
width: 200,
|
|
1133
|
-
height: 74,
|
|
1134
|
-
key: ALERT_KEY
|
|
1135
|
-
});
|
|
1136
|
-
return;
|
|
1137
|
-
}
|
|
1095
|
+
this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(UniverInstanceType.UNIVER_SHEET).pipe(switchMap((workbook) => (workbook === null || workbook === void 0 ? void 0 : workbook.activeSheet$) ?? of(null))).subscribe(() => {
|
|
1096
|
+
this._hoveredCell = null;
|
|
1097
|
+
this._cellAlertManagerService.removeAlert(ALERT_KEY);
|
|
1098
|
+
}));
|
|
1099
|
+
this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(tap(() => {
|
|
1100
|
+
this._hoveredCell = null;
|
|
1101
|
+
this._cellAlertManagerService.removeAlert(ALERT_KEY);
|
|
1102
|
+
}), debounceTime(100)).subscribe((cellPos) => {
|
|
1103
|
+
this._hoveredCell = cellPos;
|
|
1104
|
+
this._refreshAlert();
|
|
1105
|
+
}));
|
|
1106
|
+
this.disposeWithMe(this._dataValidationModel.ruleChange$.subscribe((change) => {
|
|
1107
|
+
var _change$oldRule;
|
|
1108
|
+
if (this._affectsHoveredCell(change, [...change.rule.ranges, ...((_change$oldRule = change.oldRule) === null || _change$oldRule === void 0 ? void 0 : _change$oldRule.ranges) ?? []])) this._refreshAlert();
|
|
1109
|
+
}));
|
|
1110
|
+
this.disposeWithMe(this._dataValidationCacheService.dirtyRanges$.pipe(filter((change) => this._affectsHoveredCell(change, change.ranges)), tap(() => this._cellAlertManagerService.removeAlert(ALERT_KEY)), auditTime(0)).subscribe(() => this._refreshAlert()));
|
|
1111
|
+
this.disposeWithMe(this._dataValidationModel.validStatusChange$.subscribe((change) => {
|
|
1112
|
+
if (this._isHoveredLocation(change)) {
|
|
1113
|
+
const rule = this._dataValidationModel.getRuleByLocation(change.unitId, change.subUnitId, change.row, change.col);
|
|
1114
|
+
if ((rule === null || rule === void 0 ? void 0 : rule.uid) === change.ruleId) this._updateAlert(change.status);
|
|
1138
1115
|
}
|
|
1116
|
+
}));
|
|
1117
|
+
this.disposeWithMe(() => {
|
|
1118
|
+
this._hoveredCell = null;
|
|
1119
|
+
this._cellAlertManagerService.removeAlert(ALERT_KEY);
|
|
1120
|
+
});
|
|
1121
|
+
}
|
|
1122
|
+
_isHoveredLocation(location) {
|
|
1123
|
+
var _this$_hoveredCell;
|
|
1124
|
+
const current = (_this$_hoveredCell = this._hoveredCell) === null || _this$_hoveredCell === void 0 ? void 0 : _this$_hoveredCell.location;
|
|
1125
|
+
return (current === null || current === void 0 ? void 0 : current.unitId) === location.unitId && (current === null || current === void 0 ? void 0 : current.subUnitId) === location.subUnitId && (current === null || current === void 0 ? void 0 : current.row) === location.row && (current === null || current === void 0 ? void 0 : current.col) === location.col;
|
|
1126
|
+
}
|
|
1127
|
+
_affectsHoveredCell(location, ranges) {
|
|
1128
|
+
var _this$_hoveredCell2;
|
|
1129
|
+
const current = (_this$_hoveredCell2 = this._hoveredCell) === null || _this$_hoveredCell2 === void 0 ? void 0 : _this$_hoveredCell2.location;
|
|
1130
|
+
return (current === null || current === void 0 ? void 0 : current.unitId) === location.unitId && (current === null || current === void 0 ? void 0 : current.subUnitId) === location.subUnitId && ranges.some((range) => Rectangle.contains(range, {
|
|
1131
|
+
startRow: current.row,
|
|
1132
|
+
endRow: current.row,
|
|
1133
|
+
startColumn: current.col,
|
|
1134
|
+
endColumn: current.col
|
|
1135
|
+
}));
|
|
1136
|
+
}
|
|
1137
|
+
_getHoveredContext() {
|
|
1138
|
+
var _this$_hoveredCell3;
|
|
1139
|
+
const location = (_this$_hoveredCell3 = this._hoveredCell) === null || _this$_hoveredCell3 === void 0 ? void 0 : _this$_hoveredCell3.location;
|
|
1140
|
+
if (!location) return;
|
|
1141
|
+
const workbook = this._univerInstanceService.getUnit(location.unitId, UniverInstanceType.UNIVER_SHEET);
|
|
1142
|
+
const worksheet = workbook === null || workbook === void 0 ? void 0 : workbook.getActiveSheet();
|
|
1143
|
+
if (!workbook || !worksheet || worksheet.getSheetId() !== location.subUnitId) return;
|
|
1144
|
+
const rule = this._dataValidationModel.getRuleByLocation(location.unitId, location.subUnitId, location.row, location.col);
|
|
1145
|
+
if (rule) return {
|
|
1146
|
+
location,
|
|
1147
|
+
workbook,
|
|
1148
|
+
worksheet,
|
|
1149
|
+
rule
|
|
1150
|
+
};
|
|
1151
|
+
}
|
|
1152
|
+
_refreshAlert() {
|
|
1153
|
+
const context = this._getHoveredContext();
|
|
1154
|
+
if (!context) {
|
|
1139
1155
|
this._cellAlertManagerService.removeAlert(ALERT_KEY);
|
|
1156
|
+
return;
|
|
1157
|
+
}
|
|
1158
|
+
const { location, workbook, worksheet, rule } = context;
|
|
1159
|
+
this._updateAlert(this._dataValidationModel.validator(rule, {
|
|
1160
|
+
...location,
|
|
1161
|
+
workbook,
|
|
1162
|
+
worksheet
|
|
1140
1163
|
}));
|
|
1141
1164
|
}
|
|
1165
|
+
_updateAlert(status) {
|
|
1166
|
+
var _this$_cellAlertManag;
|
|
1167
|
+
const context = this._getHoveredContext();
|
|
1168
|
+
if (!context || status !== DataValidationStatus.INVALID) {
|
|
1169
|
+
this._cellAlertManagerService.removeAlert(ALERT_KEY);
|
|
1170
|
+
return;
|
|
1171
|
+
}
|
|
1172
|
+
const { location, rule } = context;
|
|
1173
|
+
const validator = this._dataValidationModel.getValidator(rule.type);
|
|
1174
|
+
if (!validator) {
|
|
1175
|
+
this._cellAlertManagerService.removeAlert(ALERT_KEY);
|
|
1176
|
+
return;
|
|
1177
|
+
}
|
|
1178
|
+
const title = this._localeService.t("sheets-data-validation-ui.error.title");
|
|
1179
|
+
const message = validator.getRuleFinalError(rule, location);
|
|
1180
|
+
const currentAlert = (_this$_cellAlertManag = this._cellAlertManagerService.currentAlert.get(ALERT_KEY)) === null || _this$_cellAlertManag === void 0 ? void 0 : _this$_cellAlertManag.alert;
|
|
1181
|
+
if (currentAlert && this._isHoveredLocation(currentAlert.location) && currentAlert.title === title && currentAlert.message === message) return;
|
|
1182
|
+
this._cellAlertManagerService.showAlert({
|
|
1183
|
+
type: CellAlertType.ERROR,
|
|
1184
|
+
title,
|
|
1185
|
+
message,
|
|
1186
|
+
location,
|
|
1187
|
+
width: 200,
|
|
1188
|
+
height: 74,
|
|
1189
|
+
key: ALERT_KEY
|
|
1190
|
+
});
|
|
1191
|
+
}
|
|
1142
1192
|
};
|
|
1143
1193
|
DataValidationAlertController = __decorate([
|
|
1144
1194
|
__decorateParam(0, Inject(HoverManagerService)),
|
|
1145
1195
|
__decorateParam(1, Inject(CellAlertManagerService)),
|
|
1146
1196
|
__decorateParam(2, IUniverInstanceService),
|
|
1147
1197
|
__decorateParam(3, Inject(LocaleService)),
|
|
1148
|
-
__decorateParam(4, Inject(SheetDataValidationModel))
|
|
1198
|
+
__decorateParam(4, Inject(SheetDataValidationModel)),
|
|
1199
|
+
__decorateParam(5, Inject(DataValidationCacheService))
|
|
1149
1200
|
], DataValidationAlertController);
|
|
1150
1201
|
|
|
1151
1202
|
//#endregion
|
|
@@ -1487,6 +1538,7 @@ let SheetsDataValidationRenderController = class SheetsDataValidationRenderContr
|
|
|
1487
1538
|
this._dataValidationCacheService = _dataValidationCacheService;
|
|
1488
1539
|
this._editorBridgeService = _editorBridgeService;
|
|
1489
1540
|
this._initMenu();
|
|
1541
|
+
this._initEditor();
|
|
1490
1542
|
this._initDropdown();
|
|
1491
1543
|
this._initViewModelIntercept();
|
|
1492
1544
|
this._initAutoHeight();
|
|
@@ -1494,6 +1546,19 @@ let SheetsDataValidationRenderController = class SheetsDataValidationRenderContr
|
|
|
1494
1546
|
_initMenu() {
|
|
1495
1547
|
this._menuManagerService.mergeMenu(menuSchema);
|
|
1496
1548
|
}
|
|
1549
|
+
_initEditor() {
|
|
1550
|
+
this.disposeWithMe(this._commandService.beforeCommandExecuted((command) => {
|
|
1551
|
+
var _this$_editorBridgeSe;
|
|
1552
|
+
if (command.id !== SetCellEditVisibleOperation.id) return;
|
|
1553
|
+
const params = command.params;
|
|
1554
|
+
if (!(params === null || params === void 0 ? void 0 : params.visible) || params.eventType !== DeviceInputEventType.Dblclick || !params.pointerPosition) return;
|
|
1555
|
+
const location = (_this$_editorBridgeSe = this._editorBridgeService) === null || _this$_editorBridgeSe === void 0 ? void 0 : _this$_editorBridgeSe.getEditLocation();
|
|
1556
|
+
if (!location || params.unitId && params.unitId !== location.unitId) return;
|
|
1557
|
+
const { unitId, sheetId, row, column } = location;
|
|
1558
|
+
const rule = this._sheetDataValidationModel.getRuleByLocation(unitId, sheetId, row, column);
|
|
1559
|
+
if (rule && (rule.type === DataValidationType.LIST || rule.type === DataValidationType.LIST_MULTIPLE || rule.type === DataValidationType.CHECKBOX)) throw new CanceledError();
|
|
1560
|
+
}));
|
|
1561
|
+
}
|
|
1497
1562
|
_initDropdown() {
|
|
1498
1563
|
if (!this._editorBridgeService) return;
|
|
1499
1564
|
this.disposeWithMe(this._editorBridgeService.visible$.subscribe((visible) => {
|
|
@@ -3281,7 +3346,7 @@ const DataValidationItem = (props) => {
|
|
|
3281
3346
|
};
|
|
3282
3347
|
}, [markSelectionService]);
|
|
3283
3348
|
return /* @__PURE__ */ jsxs("div", {
|
|
3284
|
-
className: clsx("univer-
|
|
3349
|
+
className: clsx("univer-relative univer--mx-2 univer-box-border univer-flex univer-w-[287px] univer-cursor-pointer univer-flex-col univer-justify-between univer-overflow-hidden univer-rounded-md univer-bg-gray-0 univer-p-2 univer-pr-9 rtl:univer-pl-9 rtl:univer-pr-2 dark:!univer-bg-gray-900", {
|
|
3285
3350
|
"hover:univer-bg-gray-50 dark:hover:!univer-bg-gray-700": !disable,
|
|
3286
3351
|
"univer-opacity-50": disable
|
|
3287
3352
|
}),
|
|
@@ -3309,7 +3374,7 @@ const DataValidationItem = (props) => {
|
|
|
3309
3374
|
children: validator === null || validator === void 0 ? void 0 : validator.generateRuleName(rule)
|
|
3310
3375
|
}),
|
|
3311
3376
|
/* @__PURE__ */ jsx("div", {
|
|
3312
|
-
className: "univer-
|
|
3377
|
+
className: "univer-truncate univer-text-xs univer-leading-[18px] univer-text-gray-500 dark:!univer-text-gray-300",
|
|
3313
3378
|
children: rule.ranges.map((range) => serializeRange(range)).join(",")
|
|
3314
3379
|
}),
|
|
3315
3380
|
isHover && /* @__PURE__ */ jsx("div", {
|
|
@@ -3680,9 +3745,8 @@ const Template = (props) => {
|
|
|
3680
3745
|
]
|
|
3681
3746
|
});
|
|
3682
3747
|
};
|
|
3683
|
-
const NOOP = () => {};
|
|
3684
3748
|
function ListFormulaInput(props) {
|
|
3685
|
-
const { value, onChange: _onChange =
|
|
3749
|
+
const { value, onChange: _onChange = noop, unitId, subUnitId, validResult, showError, ruleId } = props;
|
|
3686
3750
|
const { formula1 = "", formula2 = "" } = value || {};
|
|
3687
3751
|
const [isFormulaStr, setIsFormulaStr] = useState(() => isFormulaString(formula1) ? "1" : "0");
|
|
3688
3752
|
const [formulaStr, setFormulaStr] = useState(isFormulaStr === "1" ? formula1 : "=");
|
|
@@ -3882,7 +3946,7 @@ function ListFormulaInput(props) {
|
|
|
3882
3946
|
}, item.id),
|
|
3883
3947
|
idKey: "id"
|
|
3884
3948
|
}), /* @__PURE__ */ jsxs("a", {
|
|
3885
|
-
className: "univer-
|
|
3949
|
+
className: "univer-flex univer-w-fit univer-cursor-pointer univer-flex-row univer-items-center univer-rounded univer-p-1 univer-px-2 univer-text-sm univer-text-primary-600 hover:univer-bg-primary-50 dark:!univer-text-primary-500 dark:hover:!univer-bg-gray-800",
|
|
3886
3950
|
onClick: handleAdd,
|
|
3887
3951
|
children: [/* @__PURE__ */ jsx(IncreaseIcon, { className: "univer-mr-1" }), localeService.t("sheets-data-validation-ui.list.add")]
|
|
3888
3952
|
})] })
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
import { Disposable, IUniverInstanceService, LocaleService } from '@univerjs/core';
|
|
17
|
-
import { SheetDataValidationModel } from '@univerjs/sheets-data-validation';
|
|
17
|
+
import { DataValidationCacheService, SheetDataValidationModel } from '@univerjs/sheets-data-validation';
|
|
18
18
|
import { CellAlertManagerService, HoverManagerService } from '@univerjs/sheets-ui';
|
|
19
19
|
export declare class DataValidationAlertController extends Disposable {
|
|
20
20
|
private readonly _hoverManagerService;
|
|
@@ -22,7 +22,14 @@ export declare class DataValidationAlertController extends Disposable {
|
|
|
22
22
|
private readonly _univerInstanceService;
|
|
23
23
|
private readonly _localeService;
|
|
24
24
|
private readonly _dataValidationModel;
|
|
25
|
-
|
|
25
|
+
private readonly _dataValidationCacheService;
|
|
26
|
+
private _hoveredCell;
|
|
27
|
+
constructor(_hoverManagerService: HoverManagerService, _cellAlertManagerService: CellAlertManagerService, _univerInstanceService: IUniverInstanceService, _localeService: LocaleService, _dataValidationModel: SheetDataValidationModel, _dataValidationCacheService: DataValidationCacheService);
|
|
26
28
|
private _init;
|
|
27
29
|
private _initCellAlertPopup;
|
|
30
|
+
private _isHoveredLocation;
|
|
31
|
+
private _affectsHoveredCell;
|
|
32
|
+
private _getHoveredContext;
|
|
33
|
+
private _refreshAlert;
|
|
34
|
+
private _updateAlert;
|
|
28
35
|
}
|
|
@@ -36,6 +36,7 @@ export declare class SheetsDataValidationRenderController extends RxDisposable {
|
|
|
36
36
|
private readonly _editorBridgeService?;
|
|
37
37
|
constructor(_commandService: ICommandService, _menuManagerService: IMenuManagerService, _renderManagerService: IRenderManagerService, _univerInstanceService: IUniverInstanceService, _autoHeightController: AutoHeightController, _dropdownManagerService: DataValidationDropdownManagerService, _sheetDataValidationModel: SheetDataValidationModel, _dataValidatorRegistryService: DataValidatorRegistryService, _sheetInterceptorService: SheetInterceptorService, _dataValidationCacheService: DataValidationCacheService, _editorBridgeService?: IEditorBridgeService | undefined);
|
|
38
38
|
private _initMenu;
|
|
39
|
+
private _initEditor;
|
|
39
40
|
private _initDropdown;
|
|
40
41
|
private _initViewModelIntercept;
|
|
41
42
|
private _initAutoHeight;
|