@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/cjs/index.js
CHANGED
|
@@ -15,7 +15,7 @@ let _univerjs_icons = require("@univerjs/icons");
|
|
|
15
15
|
let _univerjs_engine_formula = require("@univerjs/engine-formula");
|
|
16
16
|
let _univerjs_sheets_formula_ui = require("@univerjs/sheets-formula-ui");
|
|
17
17
|
|
|
18
|
-
//#region \0@oxc-project+runtime@0.
|
|
18
|
+
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/typeof.js
|
|
19
19
|
function _typeof(o) {
|
|
20
20
|
"@babel/helpers - typeof";
|
|
21
21
|
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
@@ -26,7 +26,7 @@ function _typeof(o) {
|
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
//#endregion
|
|
29
|
-
//#region \0@oxc-project+runtime@0.
|
|
29
|
+
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/toPrimitive.js
|
|
30
30
|
function toPrimitive(t, r) {
|
|
31
31
|
if ("object" != _typeof(t) || !t) return t;
|
|
32
32
|
var e = t[Symbol.toPrimitive];
|
|
@@ -39,14 +39,14 @@ function toPrimitive(t, r) {
|
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
//#endregion
|
|
42
|
-
//#region \0@oxc-project+runtime@0.
|
|
42
|
+
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/toPropertyKey.js
|
|
43
43
|
function toPropertyKey(t) {
|
|
44
44
|
var i = toPrimitive(t, "string");
|
|
45
45
|
return "symbol" == _typeof(i) ? i : i + "";
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
//#endregion
|
|
49
|
-
//#region \0@oxc-project+runtime@0.
|
|
49
|
+
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/defineProperty.js
|
|
50
50
|
function _defineProperty(e, r, t) {
|
|
51
51
|
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
52
52
|
value: t,
|
|
@@ -57,7 +57,7 @@ function _defineProperty(e, r, t) {
|
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
//#endregion
|
|
60
|
-
//#region \0@oxc-project+runtime@0.
|
|
60
|
+
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/decorateParam.js
|
|
61
61
|
function __decorateParam(paramIndex, decorator) {
|
|
62
62
|
return function(target, key) {
|
|
63
63
|
decorator(target, key, paramIndex);
|
|
@@ -65,7 +65,7 @@ function __decorateParam(paramIndex, decorator) {
|
|
|
65
65
|
}
|
|
66
66
|
|
|
67
67
|
//#endregion
|
|
68
|
-
//#region \0@oxc-project+runtime@0.
|
|
68
|
+
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/decorate.js
|
|
69
69
|
function __decorate(decorators, target, key, desc) {
|
|
70
70
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
71
71
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -1055,8 +1055,7 @@ const menuSchema = {
|
|
|
1055
1055
|
order: 0,
|
|
1056
1056
|
gridLayout: {
|
|
1057
1057
|
row: 1,
|
|
1058
|
-
column: 1
|
|
1059
|
-
showLabel: true
|
|
1058
|
+
column: 1
|
|
1060
1059
|
},
|
|
1061
1060
|
menuItemFactory: dataValidationMenuFactory,
|
|
1062
1061
|
[OpenValidationPanelOperation.id]: {
|
|
@@ -1073,80 +1072,132 @@ const menuSchema = {
|
|
|
1073
1072
|
//#endregion
|
|
1074
1073
|
//#region package.json
|
|
1075
1074
|
var name = "@univerjs/sheets-data-validation-ui";
|
|
1076
|
-
var version = "1.0
|
|
1075
|
+
var version = "1.2.0";
|
|
1077
1076
|
|
|
1078
1077
|
//#endregion
|
|
1079
1078
|
//#region src/controllers/dv-alert.controller.ts
|
|
1080
1079
|
const ALERT_KEY = "SHEET_DATA_VALIDATION_ALERT";
|
|
1081
1080
|
let DataValidationAlertController = class DataValidationAlertController extends _univerjs_core.Disposable {
|
|
1082
|
-
constructor(_hoverManagerService, _cellAlertManagerService, _univerInstanceService, _localeService, _dataValidationModel) {
|
|
1081
|
+
constructor(_hoverManagerService, _cellAlertManagerService, _univerInstanceService, _localeService, _dataValidationModel, _dataValidationCacheService) {
|
|
1083
1082
|
super();
|
|
1084
1083
|
this._hoverManagerService = _hoverManagerService;
|
|
1085
1084
|
this._cellAlertManagerService = _cellAlertManagerService;
|
|
1086
1085
|
this._univerInstanceService = _univerInstanceService;
|
|
1087
1086
|
this._localeService = _localeService;
|
|
1088
1087
|
this._dataValidationModel = _dataValidationModel;
|
|
1088
|
+
this._dataValidationCacheService = _dataValidationCacheService;
|
|
1089
|
+
_defineProperty(this, "_hoveredCell", null);
|
|
1089
1090
|
this._init();
|
|
1090
1091
|
}
|
|
1091
1092
|
_init() {
|
|
1092
1093
|
this._initCellAlertPopup();
|
|
1093
1094
|
}
|
|
1094
1095
|
_initCellAlertPopup() {
|
|
1095
|
-
this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(_univerjs_core.UniverInstanceType.UNIVER_SHEET).pipe((0, rxjs.switchMap)((workbook) => (workbook === null || workbook === void 0 ? void 0 : workbook.activeSheet$) ?? (0, rxjs.of)(null))).subscribe(() =>
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
}) === _univerjs_core.DataValidationStatus.INVALID) {
|
|
1116
|
-
var _currentAlert$alert;
|
|
1117
|
-
const currentAlert = this._cellAlertManagerService.currentAlert.get(ALERT_KEY);
|
|
1118
|
-
const currentLoc = currentAlert === null || currentAlert === void 0 || (_currentAlert$alert = currentAlert.alert) === null || _currentAlert$alert === void 0 ? void 0 : _currentAlert$alert.location;
|
|
1119
|
-
if (currentLoc && currentLoc.row === cellPos.location.row && currentLoc.col === cellPos.location.col && currentLoc.subUnitId === cellPos.location.subUnitId && currentLoc.unitId === cellPos.location.unitId) {
|
|
1120
|
-
this._cellAlertManagerService.removeAlert(ALERT_KEY);
|
|
1121
|
-
return;
|
|
1122
|
-
}
|
|
1123
|
-
const validator = this._dataValidationModel.getValidator(rule.type);
|
|
1124
|
-
if (!validator) {
|
|
1125
|
-
this._cellAlertManagerService.removeAlert(ALERT_KEY);
|
|
1126
|
-
return;
|
|
1127
|
-
}
|
|
1128
|
-
this._cellAlertManagerService.showAlert({
|
|
1129
|
-
type: _univerjs_sheets_ui.CellAlertType.ERROR,
|
|
1130
|
-
title: this._localeService.t("sheets-data-validation-ui.error.title"),
|
|
1131
|
-
message: validator === null || validator === void 0 ? void 0 : validator.getRuleFinalError(rule, cellPos.location),
|
|
1132
|
-
location: cellPos.location,
|
|
1133
|
-
width: 200,
|
|
1134
|
-
height: 74,
|
|
1135
|
-
key: ALERT_KEY
|
|
1136
|
-
});
|
|
1137
|
-
return;
|
|
1138
|
-
}
|
|
1096
|
+
this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(_univerjs_core.UniverInstanceType.UNIVER_SHEET).pipe((0, rxjs.switchMap)((workbook) => (workbook === null || workbook === void 0 ? void 0 : workbook.activeSheet$) ?? (0, rxjs.of)(null))).subscribe(() => {
|
|
1097
|
+
this._hoveredCell = null;
|
|
1098
|
+
this._cellAlertManagerService.removeAlert(ALERT_KEY);
|
|
1099
|
+
}));
|
|
1100
|
+
this.disposeWithMe(this._hoverManagerService.currentCell$.pipe((0, rxjs.tap)(() => {
|
|
1101
|
+
this._hoveredCell = null;
|
|
1102
|
+
this._cellAlertManagerService.removeAlert(ALERT_KEY);
|
|
1103
|
+
}), (0, rxjs.debounceTime)(100)).subscribe((cellPos) => {
|
|
1104
|
+
this._hoveredCell = cellPos;
|
|
1105
|
+
this._refreshAlert();
|
|
1106
|
+
}));
|
|
1107
|
+
this.disposeWithMe(this._dataValidationModel.ruleChange$.subscribe((change) => {
|
|
1108
|
+
var _change$oldRule;
|
|
1109
|
+
if (this._affectsHoveredCell(change, [...change.rule.ranges, ...((_change$oldRule = change.oldRule) === null || _change$oldRule === void 0 ? void 0 : _change$oldRule.ranges) ?? []])) this._refreshAlert();
|
|
1110
|
+
}));
|
|
1111
|
+
this.disposeWithMe(this._dataValidationCacheService.dirtyRanges$.pipe((0, rxjs.filter)((change) => this._affectsHoveredCell(change, change.ranges)), (0, rxjs.tap)(() => this._cellAlertManagerService.removeAlert(ALERT_KEY)), (0, rxjs.auditTime)(0)).subscribe(() => this._refreshAlert()));
|
|
1112
|
+
this.disposeWithMe(this._dataValidationModel.validStatusChange$.subscribe((change) => {
|
|
1113
|
+
if (this._isHoveredLocation(change)) {
|
|
1114
|
+
const rule = this._dataValidationModel.getRuleByLocation(change.unitId, change.subUnitId, change.row, change.col);
|
|
1115
|
+
if ((rule === null || rule === void 0 ? void 0 : rule.uid) === change.ruleId) this._updateAlert(change.status);
|
|
1139
1116
|
}
|
|
1117
|
+
}));
|
|
1118
|
+
this.disposeWithMe(() => {
|
|
1119
|
+
this._hoveredCell = null;
|
|
1140
1120
|
this._cellAlertManagerService.removeAlert(ALERT_KEY);
|
|
1121
|
+
});
|
|
1122
|
+
}
|
|
1123
|
+
_isHoveredLocation(location) {
|
|
1124
|
+
var _this$_hoveredCell;
|
|
1125
|
+
const current = (_this$_hoveredCell = this._hoveredCell) === null || _this$_hoveredCell === void 0 ? void 0 : _this$_hoveredCell.location;
|
|
1126
|
+
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;
|
|
1127
|
+
}
|
|
1128
|
+
_affectsHoveredCell(location, ranges) {
|
|
1129
|
+
var _this$_hoveredCell2;
|
|
1130
|
+
const current = (_this$_hoveredCell2 = this._hoveredCell) === null || _this$_hoveredCell2 === void 0 ? void 0 : _this$_hoveredCell2.location;
|
|
1131
|
+
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) => _univerjs_core.Rectangle.contains(range, {
|
|
1132
|
+
startRow: current.row,
|
|
1133
|
+
endRow: current.row,
|
|
1134
|
+
startColumn: current.col,
|
|
1135
|
+
endColumn: current.col
|
|
1141
1136
|
}));
|
|
1142
1137
|
}
|
|
1138
|
+
_getHoveredContext() {
|
|
1139
|
+
var _this$_hoveredCell3;
|
|
1140
|
+
const location = (_this$_hoveredCell3 = this._hoveredCell) === null || _this$_hoveredCell3 === void 0 ? void 0 : _this$_hoveredCell3.location;
|
|
1141
|
+
if (!location) return;
|
|
1142
|
+
const workbook = this._univerInstanceService.getUnit(location.unitId, _univerjs_core.UniverInstanceType.UNIVER_SHEET);
|
|
1143
|
+
const worksheet = workbook === null || workbook === void 0 ? void 0 : workbook.getActiveSheet();
|
|
1144
|
+
if (!workbook || !worksheet || worksheet.getSheetId() !== location.subUnitId) return;
|
|
1145
|
+
const rule = this._dataValidationModel.getRuleByLocation(location.unitId, location.subUnitId, location.row, location.col);
|
|
1146
|
+
if (rule) return {
|
|
1147
|
+
location,
|
|
1148
|
+
workbook,
|
|
1149
|
+
worksheet,
|
|
1150
|
+
rule
|
|
1151
|
+
};
|
|
1152
|
+
}
|
|
1153
|
+
_refreshAlert() {
|
|
1154
|
+
const context = this._getHoveredContext();
|
|
1155
|
+
if (!context) {
|
|
1156
|
+
this._cellAlertManagerService.removeAlert(ALERT_KEY);
|
|
1157
|
+
return;
|
|
1158
|
+
}
|
|
1159
|
+
const { location, workbook, worksheet, rule } = context;
|
|
1160
|
+
this._updateAlert(this._dataValidationModel.validator(rule, {
|
|
1161
|
+
...location,
|
|
1162
|
+
workbook,
|
|
1163
|
+
worksheet
|
|
1164
|
+
}));
|
|
1165
|
+
}
|
|
1166
|
+
_updateAlert(status) {
|
|
1167
|
+
var _this$_cellAlertManag;
|
|
1168
|
+
const context = this._getHoveredContext();
|
|
1169
|
+
if (!context || status !== _univerjs_core.DataValidationStatus.INVALID) {
|
|
1170
|
+
this._cellAlertManagerService.removeAlert(ALERT_KEY);
|
|
1171
|
+
return;
|
|
1172
|
+
}
|
|
1173
|
+
const { location, rule } = context;
|
|
1174
|
+
const validator = this._dataValidationModel.getValidator(rule.type);
|
|
1175
|
+
if (!validator) {
|
|
1176
|
+
this._cellAlertManagerService.removeAlert(ALERT_KEY);
|
|
1177
|
+
return;
|
|
1178
|
+
}
|
|
1179
|
+
const title = this._localeService.t("sheets-data-validation-ui.error.title");
|
|
1180
|
+
const message = validator.getRuleFinalError(rule, location);
|
|
1181
|
+
const currentAlert = (_this$_cellAlertManag = this._cellAlertManagerService.currentAlert.get(ALERT_KEY)) === null || _this$_cellAlertManag === void 0 ? void 0 : _this$_cellAlertManag.alert;
|
|
1182
|
+
if (currentAlert && this._isHoveredLocation(currentAlert.location) && currentAlert.title === title && currentAlert.message === message) return;
|
|
1183
|
+
this._cellAlertManagerService.showAlert({
|
|
1184
|
+
type: _univerjs_sheets_ui.CellAlertType.ERROR,
|
|
1185
|
+
title,
|
|
1186
|
+
message,
|
|
1187
|
+
location,
|
|
1188
|
+
width: 200,
|
|
1189
|
+
height: 74,
|
|
1190
|
+
key: ALERT_KEY
|
|
1191
|
+
});
|
|
1192
|
+
}
|
|
1143
1193
|
};
|
|
1144
1194
|
DataValidationAlertController = __decorate([
|
|
1145
1195
|
__decorateParam(0, (0, _univerjs_core.Inject)(_univerjs_sheets_ui.HoverManagerService)),
|
|
1146
1196
|
__decorateParam(1, (0, _univerjs_core.Inject)(_univerjs_sheets_ui.CellAlertManagerService)),
|
|
1147
1197
|
__decorateParam(2, _univerjs_core.IUniverInstanceService),
|
|
1148
1198
|
__decorateParam(3, (0, _univerjs_core.Inject)(_univerjs_core.LocaleService)),
|
|
1149
|
-
__decorateParam(4, (0, _univerjs_core.Inject)(_univerjs_sheets_data_validation.SheetDataValidationModel))
|
|
1199
|
+
__decorateParam(4, (0, _univerjs_core.Inject)(_univerjs_sheets_data_validation.SheetDataValidationModel)),
|
|
1200
|
+
__decorateParam(5, (0, _univerjs_core.Inject)(_univerjs_sheets_data_validation.DataValidationCacheService))
|
|
1150
1201
|
], DataValidationAlertController);
|
|
1151
1202
|
|
|
1152
1203
|
//#endregion
|
|
@@ -1488,6 +1539,7 @@ let SheetsDataValidationRenderController = class SheetsDataValidationRenderContr
|
|
|
1488
1539
|
this._dataValidationCacheService = _dataValidationCacheService;
|
|
1489
1540
|
this._editorBridgeService = _editorBridgeService;
|
|
1490
1541
|
this._initMenu();
|
|
1542
|
+
this._initEditor();
|
|
1491
1543
|
this._initDropdown();
|
|
1492
1544
|
this._initViewModelIntercept();
|
|
1493
1545
|
this._initAutoHeight();
|
|
@@ -1495,6 +1547,19 @@ let SheetsDataValidationRenderController = class SheetsDataValidationRenderContr
|
|
|
1495
1547
|
_initMenu() {
|
|
1496
1548
|
this._menuManagerService.mergeMenu(menuSchema);
|
|
1497
1549
|
}
|
|
1550
|
+
_initEditor() {
|
|
1551
|
+
this.disposeWithMe(this._commandService.beforeCommandExecuted((command) => {
|
|
1552
|
+
var _this$_editorBridgeSe;
|
|
1553
|
+
if (command.id !== _univerjs_sheets_ui.SetCellEditVisibleOperation.id) return;
|
|
1554
|
+
const params = command.params;
|
|
1555
|
+
if (!(params === null || params === void 0 ? void 0 : params.visible) || params.eventType !== _univerjs_engine_render.DeviceInputEventType.Dblclick || !params.pointerPosition) return;
|
|
1556
|
+
const location = (_this$_editorBridgeSe = this._editorBridgeService) === null || _this$_editorBridgeSe === void 0 ? void 0 : _this$_editorBridgeSe.getEditLocation();
|
|
1557
|
+
if (!location || params.unitId && params.unitId !== location.unitId) return;
|
|
1558
|
+
const { unitId, sheetId, row, column } = location;
|
|
1559
|
+
const rule = this._sheetDataValidationModel.getRuleByLocation(unitId, sheetId, row, column);
|
|
1560
|
+
if (rule && (rule.type === _univerjs_core.DataValidationType.LIST || rule.type === _univerjs_core.DataValidationType.LIST_MULTIPLE || rule.type === _univerjs_core.DataValidationType.CHECKBOX)) throw new _univerjs_core.CanceledError();
|
|
1561
|
+
}));
|
|
1562
|
+
}
|
|
1498
1563
|
_initDropdown() {
|
|
1499
1564
|
if (!this._editorBridgeService) return;
|
|
1500
1565
|
this.disposeWithMe(this._editorBridgeService.visible$.subscribe((visible) => {
|
|
@@ -3282,7 +3347,7 @@ const DataValidationItem = (props) => {
|
|
|
3282
3347
|
};
|
|
3283
3348
|
}, [markSelectionService]);
|
|
3284
3349
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3285
|
-
className: (0, _univerjs_design.clsx)("univer-
|
|
3350
|
+
className: (0, _univerjs_design.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", {
|
|
3286
3351
|
"hover:univer-bg-gray-50 dark:hover:!univer-bg-gray-700": !disable,
|
|
3287
3352
|
"univer-opacity-50": disable
|
|
3288
3353
|
}),
|
|
@@ -3310,7 +3375,7 @@ const DataValidationItem = (props) => {
|
|
|
3310
3375
|
children: validator === null || validator === void 0 ? void 0 : validator.generateRuleName(rule)
|
|
3311
3376
|
}),
|
|
3312
3377
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
3313
|
-
className: "univer-
|
|
3378
|
+
className: "univer-truncate univer-text-xs univer-leading-[18px] univer-text-gray-500 dark:!univer-text-gray-300",
|
|
3314
3379
|
children: rule.ranges.map((range) => (0, _univerjs_engine_formula.serializeRange)(range)).join(",")
|
|
3315
3380
|
}),
|
|
3316
3381
|
isHover && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
@@ -3681,9 +3746,8 @@ const Template = (props) => {
|
|
|
3681
3746
|
]
|
|
3682
3747
|
});
|
|
3683
3748
|
};
|
|
3684
|
-
const NOOP = () => {};
|
|
3685
3749
|
function ListFormulaInput(props) {
|
|
3686
|
-
const { value, onChange: _onChange =
|
|
3750
|
+
const { value, onChange: _onChange = rxjs.noop, unitId, subUnitId, validResult, showError, ruleId } = props;
|
|
3687
3751
|
const { formula1 = "", formula2 = "" } = value || {};
|
|
3688
3752
|
const [isFormulaStr, setIsFormulaStr] = (0, react.useState)(() => (0, _univerjs_core.isFormulaString)(formula1) ? "1" : "0");
|
|
3689
3753
|
const [formulaStr, setFormulaStr] = (0, react.useState)(isFormulaStr === "1" ? formula1 : "=");
|
|
@@ -3883,7 +3947,7 @@ function ListFormulaInput(props) {
|
|
|
3883
3947
|
}, item.id),
|
|
3884
3948
|
idKey: "id"
|
|
3885
3949
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("a", {
|
|
3886
|
-
className: "univer-
|
|
3950
|
+
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",
|
|
3887
3951
|
onClick: handleAdd,
|
|
3888
3952
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.IncreaseIcon, { className: "univer-mr-1" }), localeService.t("sheets-data-validation-ui.list.add")]
|
|
3889
3953
|
})] })
|
|
@@ -4016,20 +4080,20 @@ UniverSheetsDataValidationUIPlugin = __decorate([
|
|
|
4016
4080
|
|
|
4017
4081
|
//#endregion
|
|
4018
4082
|
exports.DATA_VALIDATION_PANEL = DATA_VALIDATION_PANEL;
|
|
4019
|
-
Object.defineProperty(exports,
|
|
4083
|
+
Object.defineProperty(exports, "DataValidationPanelService", {
|
|
4020
4084
|
enumerable: true,
|
|
4021
4085
|
get: function () {
|
|
4022
4086
|
return DataValidationPanelService;
|
|
4023
4087
|
}
|
|
4024
4088
|
});
|
|
4025
4089
|
exports.SheetsDataValidationUIMenuSchema = menuSchema;
|
|
4026
|
-
Object.defineProperty(exports,
|
|
4090
|
+
Object.defineProperty(exports, "UniverSheetsDataValidationMobileUIPlugin", {
|
|
4027
4091
|
enumerable: true,
|
|
4028
4092
|
get: function () {
|
|
4029
4093
|
return UniverSheetsDataValidationMobileUIPlugin;
|
|
4030
4094
|
}
|
|
4031
4095
|
});
|
|
4032
|
-
Object.defineProperty(exports,
|
|
4096
|
+
Object.defineProperty(exports, "UniverSheetsDataValidationUIPlugin", {
|
|
4033
4097
|
enumerable: true,
|
|
4034
4098
|
get: function () {
|
|
4035
4099
|
return UniverSheetsDataValidationUIPlugin;
|
package/lib/es/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
|
})] })
|