@univerjs/sheets-data-validation 0.2.14 → 0.3.0-alpha.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 +2 -2
- package/lib/es/index.js +1655 -1205
- package/lib/index.css +1 -1
- package/lib/types/controllers/config.schema.d.ts +1 -0
- package/lib/types/controllers/dv-ref-range.controller.d.ts +2 -2
- package/lib/types/index.d.ts +2 -2
- package/lib/types/models/rule-matrix.d.ts +19 -8
- package/lib/types/models/sheet-data-validation-model.d.ts +5 -3
- package/lib/types/services/dv-cache.service.d.ts +1 -1
- package/lib/types/types/index.d.ts +1 -1
- package/lib/types/validators/checkbox-validator.d.ts +6 -3
- package/lib/types/validators/index.d.ts +2 -2
- package/lib/types/validators/list-multiple-validator.d.ts +1 -1
- package/lib/types/validators/list-validator.d.ts +6 -3
- package/lib/types/views/formula-input/list-formula-input.d.ts +1 -1
- package/lib/types/views/index.d.ts +2 -2
- package/lib/types/widgets/dropdown-widget.d.ts +2 -2
- package/lib/umd/index.js +2 -2
- package/package.json +29 -28
package/lib/es/index.js
CHANGED
|
@@ -2,24 +2,24 @@ var __defProp = Object.defineProperty;
|
|
|
2
2
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value;
|
|
3
3
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: !0 });
|
|
4
4
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key != "symbol" ? key + "" : key, value);
|
|
5
|
-
import { ObjectMatrix, Range, Inject, Disposable, UniverInstanceType, DataValidationType, isFormulaString, IUniverInstanceService, ILogService,
|
|
5
|
+
import { ObjectMatrix, Range, Inject, Disposable, UniverInstanceType, DataValidationType, isFormulaString, IUniverInstanceService, ILogService, getOriginCellValue, debounce, Rectangle, Tools, OnLifecycle, LifecycleStages, DataValidationStatus, ICommandService, DataValidationOperator, createInternalEditorID, useDependency, LocaleService, IPermissionService, ThemeService, VerticalAlign, HorizontalAlign, WrapStrategy, DataValidationErrorStyle, numfmt, CellValueType, DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY, DisposableCollection, toDisposable, CommandType, BuildTextUtils, DataValidationRenderMode, IConfigService, UndoCommand, RedoCommand, isUnitRangesEqual, isValidRange, shallowEqual, Injector, DEFAULT_STYLES, DocumentDataModel, DEFAULT_EMPTY_DOCUMENT_VALUE, BooleanNumber, IUndoRedoService, sequenceExecuteAsync, sequenceExecute, RxDisposable, queryObjectMatrix, isRangesEqual, Optional, InterceptorEffectEnum, DependentOn, Plugin } from "@univerjs/core";
|
|
6
6
|
import { DataValidationModel, DataValidatorRegistryService, UpdateRuleType, BaseDataValidator, DataValidatorRegistryScope, TWO_FORMULA_OPERATOR_COUNT as TWO_FORMULA_OPERATOR_COUNT$1, getRuleOptions, getRuleSetting, TextLengthErrorTitleMap, AddDataValidationMutation, RemoveDataValidationMutation, UpdateDataValidationMutation, UniverDataValidationPlugin } from "@univerjs/data-validation";
|
|
7
7
|
import { DataValidationModel as DataValidationModel2 } from "@univerjs/data-validation";
|
|
8
|
-
import { SheetsSelectionsService, WorksheetViewPermission, SetRangeValuesCommand,
|
|
9
|
-
import {
|
|
8
|
+
import { RemoveSheetMutation, SheetsSelectionsService, WorksheetViewPermission, SetRangeValuesCommand, getSheetCommandTarget, WorkbookEditablePermission, RangeProtectionPermissionEditPoint, WorksheetEditPermission, checkRangesEditablePermission, SetRangeValuesMutation, SetRangeValuesUndoMutationFactory, WorksheetSetCellStylePermission, SheetInterceptorService, ClearSelectionAllCommand, RefRangeService, handleCommonDefaultRangeChangeWithEffectRefCommands, INTERCEPTOR_POINT, InterceptCellContentPriority, UniverSheetsPlugin, RemoveSheetCommand } from "@univerjs/sheets";
|
|
9
|
+
import { IEditorBridgeService, SheetCanvasPopManagerService, SheetPermissionInterceptorBaseController, IMarkSelectionService, getCurrentRangeDisable$, HoverManagerService, CellAlertManagerService, CellAlertType, COPY_TYPE, rangeToDiscreteRange, PREDEFINED_HOOK_NAME, virtualizeDiscreteRanges, getRepeatRange, ISheetClipboardService, AutoHeightController, SheetSkeletonManagerService, UniverSheetsUIPlugin, IAutoFillService, APPLY_TYPE, getAutoFillRepeatRange } from "@univerjs/sheets-ui";
|
|
10
10
|
import { Subject, debounceTime, filter, BehaviorSubject, distinctUntilChanged, bufferTime } from "rxjs";
|
|
11
|
+
import { LexerTreeBuilder, deserializeRangeWithSheet, serializeRange, isReferenceString, sequenceNodeType, ERROR_TYPE_SET } from "@univerjs/engine-formula";
|
|
11
12
|
import { RegisterOtherFormulaService, FormulaRefRangeService } from "@univerjs/sheets-formula";
|
|
12
13
|
import React, { forwardRef, useRef, createElement, useState, useMemo, useEffect } from "react";
|
|
13
|
-
import { FormLayout, Input, RadioGroup, Radio, DraggableList, Select, Checkbox, Button, RectPopup, Scrollbar
|
|
14
|
-
import { TextEditor,
|
|
14
|
+
import { FormLayout, Input, RadioGroup, Radio, DraggableList, Select, Checkbox, Button, DatePanel, RectPopup, Scrollbar } from "@univerjs/design";
|
|
15
|
+
import { TextEditor, RangeSelector } from "@univerjs/docs-ui";
|
|
16
|
+
import { useObservable, useEvent, IDialogService, ComponentManager, IZenZoneService, ISidebarService, KeyCode, MenuItemType, getMenuHiddenObservable, RibbonStartGroup, IMenuManagerService } from "@univerjs/ui";
|
|
15
17
|
import cs from "clsx";
|
|
16
18
|
import { fixLineWidthByScale, Transform, Checkbox as Checkbox$1, IRenderManagerService, DeviceInputEventType, getDocsSkeletonPageSize, Rect, DocumentViewModel, DocumentSkeleton, Documents, FontCache, Shape, getFontStyleString } from "@univerjs/engine-render";
|
|
17
19
|
import dayjs from "dayjs";
|
|
18
|
-
import { IMarkSelectionService, SheetCanvasPopManagerService, IEditorBridgeService, getCurrentRangeDisable$, HoverManagerService, CellAlertManagerService, CellAlertType, COPY_TYPE, rangeToDiscreteRange, PREDEFINED_HOOK_NAME, virtualizeDiscreteRanges, getRepeatRange, ISheetClipboardService, SheetPermissionInterceptorBaseController, AutoHeightController, SheetSkeletonManagerService, UniverSheetsUIPlugin, IAutoFillService, APPLY_TYPE, getAutoFillRepeatRange } from "@univerjs/sheets-ui";
|
|
19
|
-
import { RichTextEditingMutation } from "@univerjs/docs";
|
|
20
|
-
import { getPlainTextFormDocument } from "@univerjs/docs-ui";
|
|
21
20
|
import { getPatternType, UniverSheetsNumfmtPlugin } from "@univerjs/sheets-numfmt";
|
|
22
|
-
|
|
21
|
+
import { RichTextEditingMutation } from "@univerjs/docs";
|
|
22
|
+
const DATA_VALIDATION_PLUGIN_NAME = "SHEET_DATA_VALIDATION_PLUGIN", DROP_DOWN_DEFAULT_COLOR = "#ECECEC", _DataValidationCacheService = class _DataValidationCacheService {
|
|
23
23
|
constructor() {
|
|
24
24
|
__publicField(this, "_cacheMatrix", /* @__PURE__ */ new Map());
|
|
25
25
|
}
|
|
@@ -117,8 +117,8 @@ let DataValidationCustomFormulaService = (_a = class extends Disposable {
|
|
|
117
117
|
for (const subUnitId in unitMap) {
|
|
118
118
|
const results = unitMap[subUnitId], { formulaCellMap, ruleFormulaMap } = this._ensureMaps(unitId, subUnitId);
|
|
119
119
|
results.forEach((result) => {
|
|
120
|
-
var
|
|
121
|
-
const ruleInfo = ruleFormulaMap.get((
|
|
120
|
+
var _a24, _b;
|
|
121
|
+
const ruleInfo = ruleFormulaMap.get((_a24 = result.extra) == null ? void 0 : _a24.ruleId), cellInfo = formulaCellMap.get(result.formulaId), rule = this._dataValidationModel.getRuleById(unitId, subUnitId, (_b = result.extra) == null ? void 0 : _b.ruleId);
|
|
122
122
|
rule && ruleInfo && !ruleInfo.isTransformable && this._dataValidationCacheService.markRangeDirty(unitId, subUnitId, rule.ranges), cellInfo && this._dataValidationCacheService.markCellDirty(unitId, subUnitId, cellInfo.row, cellInfo.column);
|
|
123
123
|
});
|
|
124
124
|
}
|
|
@@ -196,8 +196,8 @@ let DataValidationCustomFormulaService = (_a = class extends Disposable {
|
|
|
196
196
|
});
|
|
197
197
|
}), newRanges.forEach((range) => {
|
|
198
198
|
Range.foreach(range, (row, col) => {
|
|
199
|
-
var
|
|
200
|
-
const oldValue = (
|
|
199
|
+
var _a24;
|
|
200
|
+
const oldValue = (_a24 = formulaMap.getValue(row, col)) != null ? _a24 : {};
|
|
201
201
|
if (oldValue.ruleId !== ruleId) {
|
|
202
202
|
const oldRuleFormula = ruleFormulaMap.get(oldValue.ruleId);
|
|
203
203
|
if (oldRuleFormula != null && oldRuleFormula.isTransformable && deleteFormulaIdList.add(oldValue.formulaId), isTransformable) {
|
|
@@ -264,8 +264,8 @@ let DataValidationFormulaService = (_a2 = class extends Disposable {
|
|
|
264
264
|
for (const subUnitId in unitMap) {
|
|
265
265
|
const results = unitMap[subUnitId], formulaMap = this._ensureRuleFormulaMap(unitId, subUnitId);
|
|
266
266
|
results.forEach((result) => {
|
|
267
|
-
var
|
|
268
|
-
if (formulaMap.get((
|
|
267
|
+
var _a24, _b;
|
|
268
|
+
if (formulaMap.get((_a24 = result.extra) == null ? void 0 : _a24.ruleId)) {
|
|
269
269
|
const rule = this._dataValidationModel.getRuleById(unitId, subUnitId, (_b = result.extra) == null ? void 0 : _b.ruleId);
|
|
270
270
|
rule && this._dataValidationCacheService.markRangeDirty(unitId, subUnitId, rule.ranges);
|
|
271
271
|
}
|
|
@@ -357,75 +357,493 @@ DataValidationFormulaService = __decorateClass$j([
|
|
|
357
357
|
__decorateParam$j(3, Inject(DataValidationModel))
|
|
358
358
|
], DataValidationFormulaService);
|
|
359
359
|
function getCellValueOrigin(cell) {
|
|
360
|
-
|
|
361
|
-
return "";
|
|
362
|
-
if (cell != null && cell.p) {
|
|
363
|
-
const body = cell == null ? void 0 : cell.p.body;
|
|
364
|
-
if (body == null)
|
|
365
|
-
return "";
|
|
366
|
-
const data = body.dataStream;
|
|
367
|
-
return (data.substring(data.length - 2, data.length) === DEFAULT_EMPTY_DOCUMENT_VALUE ? data.substring(0, data.length - 2) : data).replaceAll(DataStreamTreeTokenType.CUSTOM_RANGE_START, "").replaceAll(DataStreamTreeTokenType.CUSTOM_RANGE_END, "");
|
|
368
|
-
}
|
|
369
|
-
return cell == null ? void 0 : cell.v;
|
|
360
|
+
return getOriginCellValue(cell);
|
|
370
361
|
}
|
|
371
362
|
__name(getCellValueOrigin, "getCellValueOrigin");
|
|
372
363
|
function getStringCellValue(cell) {
|
|
373
|
-
var
|
|
374
|
-
return String((
|
|
364
|
+
var _a24;
|
|
365
|
+
return String((_a24 = getCellValueOrigin(cell)) != null ? _a24 : "");
|
|
375
366
|
}
|
|
376
367
|
__name(getStringCellValue, "getStringCellValue");
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
368
|
+
var _a3;
|
|
369
|
+
const Interval = (_a3 = class {
|
|
370
|
+
/**
|
|
371
|
+
* Accept two comparable values and creates new instance of interval
|
|
372
|
+
* Predicate Interval.comparable_less(low, high) supposed to return true on these values
|
|
373
|
+
* @param low
|
|
374
|
+
* @param high
|
|
375
|
+
*/
|
|
376
|
+
constructor(low, high) {
|
|
377
|
+
this.low = low, this.high = high;
|
|
378
|
+
}
|
|
379
|
+
/**
|
|
380
|
+
* Clone interval
|
|
381
|
+
* @returns {Interval}
|
|
382
|
+
*/
|
|
383
|
+
clone() {
|
|
384
|
+
return new _a3(this.low, this.high);
|
|
385
|
+
}
|
|
386
|
+
/**
|
|
387
|
+
* Propery max returns clone of this interval
|
|
388
|
+
* @returns {Interval}
|
|
389
|
+
*/
|
|
390
|
+
get max() {
|
|
391
|
+
return this.clone();
|
|
392
|
+
}
|
|
393
|
+
/**
|
|
394
|
+
* Predicate returns true is this interval less than other interval
|
|
395
|
+
* @param other_interval
|
|
396
|
+
* @returns {boolean}
|
|
397
|
+
*/
|
|
398
|
+
less_than(other_interval) {
|
|
399
|
+
return this.low < other_interval.low || this.low === other_interval.low && this.high < other_interval.high;
|
|
400
|
+
}
|
|
401
|
+
/**
|
|
402
|
+
* Predicate returns true is this interval equals to other interval
|
|
403
|
+
* @param other_interval
|
|
404
|
+
* @returns {boolean}
|
|
405
|
+
*/
|
|
406
|
+
equal_to(other_interval) {
|
|
407
|
+
return this.low === other_interval.low && this.high === other_interval.high;
|
|
408
|
+
}
|
|
409
|
+
/**
|
|
410
|
+
* Predicate returns true if this interval intersects other interval
|
|
411
|
+
* @param other_interval
|
|
412
|
+
* @returns {boolean}
|
|
413
|
+
*/
|
|
414
|
+
intersect(other_interval) {
|
|
415
|
+
return !this.not_intersect(other_interval);
|
|
416
|
+
}
|
|
417
|
+
/**
|
|
418
|
+
* Predicate returns true if this interval does not intersect other interval
|
|
419
|
+
* @param other_interval
|
|
420
|
+
* @returns {boolean}
|
|
421
|
+
*/
|
|
422
|
+
not_intersect(other_interval) {
|
|
423
|
+
return this.high < other_interval.low || other_interval.high < this.low;
|
|
424
|
+
}
|
|
425
|
+
/**
|
|
426
|
+
* Returns new interval merged with other interval
|
|
427
|
+
* @param {Interval} other_interval - Other interval to merge with
|
|
428
|
+
* @returns {Interval}
|
|
429
|
+
*/
|
|
430
|
+
merge(other_interval) {
|
|
431
|
+
return new _a3(
|
|
432
|
+
this.low === void 0 ? other_interval.low : this.low < other_interval.low ? this.low : other_interval.low,
|
|
433
|
+
this.high === void 0 ? other_interval.high : this.high > other_interval.high ? this.high : other_interval.high
|
|
434
|
+
);
|
|
381
435
|
}
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
436
|
+
/**
|
|
437
|
+
* Returns how key should return
|
|
438
|
+
*/
|
|
439
|
+
output() {
|
|
440
|
+
return [this.low, this.high];
|
|
441
|
+
}
|
|
442
|
+
/**
|
|
443
|
+
* Function returns maximum between two comparable values
|
|
444
|
+
* @param interval1
|
|
445
|
+
* @param interval2
|
|
446
|
+
* @returns {Interval}
|
|
447
|
+
*/
|
|
448
|
+
static comparable_max(interval1, interval2) {
|
|
449
|
+
return interval1.merge(interval2);
|
|
450
|
+
}
|
|
451
|
+
/**
|
|
452
|
+
* Predicate returns true if first value less than second value
|
|
453
|
+
* @param val1
|
|
454
|
+
* @param val2
|
|
455
|
+
* @returns {boolean}
|
|
456
|
+
*/
|
|
457
|
+
static comparable_less_than(val1, val2) {
|
|
458
|
+
return val1 < val2;
|
|
459
|
+
}
|
|
460
|
+
}, __name(_a3, "Interval"), _a3), RB_TREE_COLOR_RED = 0, RB_TREE_COLOR_BLACK = 1, _Node = class _Node {
|
|
461
|
+
constructor(key = void 0, value = void 0, left = null, right = null, parent = null, color = RB_TREE_COLOR_BLACK) {
|
|
462
|
+
if (this.left = left, this.right = right, this.parent = parent, this.color = color, this.item = { key, value }, key && key instanceof Array && key.length === 2 && !Number.isNaN(key[0]) && !Number.isNaN(key[1])) {
|
|
463
|
+
let [low, high] = key;
|
|
464
|
+
low > high && ([low, high] = [high, low]), this.item.key = new Interval(low, high);
|
|
465
|
+
}
|
|
466
|
+
this.max = this.item.key ? this.item.key.max : void 0;
|
|
392
467
|
}
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
468
|
+
isNil() {
|
|
469
|
+
return this.item.key === void 0 && this.item.value === void 0 && this.left === null && this.right === null && this.color === RB_TREE_COLOR_BLACK;
|
|
470
|
+
}
|
|
471
|
+
_value_less_than(other_node) {
|
|
472
|
+
return this.item.value && other_node.item.value && this.item.value.less_than ? this.item.value.less_than(other_node.item.value) : this.item.value < other_node.item.value;
|
|
473
|
+
}
|
|
474
|
+
less_than(other_node) {
|
|
475
|
+
return this.item.value === this.item.key && other_node.item.value === other_node.item.key ? this.item.key.less_than(other_node.item.key) : this.item.key.less_than(other_node.item.key) || this.item.key.equal_to(other_node.item.key) && this._value_less_than(other_node);
|
|
476
|
+
}
|
|
477
|
+
_value_equal(other_node) {
|
|
478
|
+
return this.item.value && other_node.item.value && this.item.value.equal_to ? this.item.value.equal_to(other_node.item.value) : this.item.value === other_node.item.value;
|
|
479
|
+
}
|
|
480
|
+
equal_to(other_node) {
|
|
481
|
+
return this.item.value === this.item.key && other_node.item.value === other_node.item.key ? this.item.key.equal_to(other_node.item.key) : this.item.key.equal_to(other_node.item.key) && this._value_equal(other_node);
|
|
482
|
+
}
|
|
483
|
+
intersect(other_node) {
|
|
484
|
+
return this.item.key.intersect(other_node.item.key);
|
|
485
|
+
}
|
|
486
|
+
copy_data(other_node) {
|
|
487
|
+
this.item.key = other_node.item.key, this.item.value = other_node.item.value;
|
|
488
|
+
}
|
|
489
|
+
update_max() {
|
|
490
|
+
if (this.max = this.item.key ? this.item.key.max : void 0, this.right && this.right.max) {
|
|
491
|
+
const comparable_max = this.item.key.constructor.comparable_max;
|
|
492
|
+
this.max = comparable_max(this.max, this.right.max);
|
|
493
|
+
}
|
|
494
|
+
if (this.left && this.left.max) {
|
|
495
|
+
const comparable_max = this.item.key.constructor.comparable_max;
|
|
496
|
+
this.max = comparable_max(this.max, this.left.max);
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
// Other_node does not intersect any node of left subtree, if this.left.max < other_node.item.key.low
|
|
500
|
+
not_intersect_left_subtree(search_node) {
|
|
501
|
+
const comparable_less_than = this.item.key.constructor.comparable_less_than;
|
|
502
|
+
let high = this.left.max.high !== void 0 ? this.left.max.high : this.left.max;
|
|
503
|
+
return comparable_less_than(high, search_node.item.key.low);
|
|
504
|
+
}
|
|
505
|
+
// Other_node does not intersect right subtree if other_node.item.key.high < this.right.key.low
|
|
506
|
+
not_intersect_right_subtree(search_node) {
|
|
507
|
+
const comparable_less_than = this.item.key.constructor.comparable_less_than;
|
|
508
|
+
let low = this.right.max.low !== void 0 ? this.right.max.low : this.right.item.key.low;
|
|
509
|
+
return comparable_less_than(search_node.item.key.high, low);
|
|
510
|
+
}
|
|
511
|
+
};
|
|
512
|
+
__name(_Node, "Node");
|
|
513
|
+
let Node = _Node;
|
|
514
|
+
const _IntervalTree = class _IntervalTree {
|
|
515
|
+
/**
|
|
516
|
+
* Construct new empty instance of IntervalTree
|
|
517
|
+
*/
|
|
518
|
+
constructor() {
|
|
519
|
+
this.root = null, this.nil_node = new Node();
|
|
520
|
+
}
|
|
521
|
+
/**
|
|
522
|
+
* Returns number of items stored in the interval tree
|
|
523
|
+
* @returns {number}
|
|
524
|
+
*/
|
|
525
|
+
get size() {
|
|
526
|
+
let count = 0;
|
|
527
|
+
return this.tree_walk(this.root, () => count++), count;
|
|
528
|
+
}
|
|
529
|
+
/**
|
|
530
|
+
* Returns array of sorted keys in the ascending order
|
|
531
|
+
* @returns {Array}
|
|
532
|
+
*/
|
|
533
|
+
get keys() {
|
|
534
|
+
let res = [];
|
|
535
|
+
return this.tree_walk(this.root, (node) => res.push(
|
|
536
|
+
node.item.key.output ? node.item.key.output() : node.item.key
|
|
537
|
+
)), res;
|
|
538
|
+
}
|
|
539
|
+
/**
|
|
540
|
+
* Return array of values in the ascending keys order
|
|
541
|
+
* @returns {Array}
|
|
542
|
+
*/
|
|
543
|
+
get values() {
|
|
544
|
+
let res = [];
|
|
545
|
+
return this.tree_walk(this.root, (node) => res.push(node.item.value)), res;
|
|
546
|
+
}
|
|
547
|
+
/**
|
|
548
|
+
* Returns array of items (<key,value> pairs) in the ascended keys order
|
|
549
|
+
* @returns {Array}
|
|
550
|
+
*/
|
|
551
|
+
get items() {
|
|
552
|
+
let res = [];
|
|
553
|
+
return this.tree_walk(this.root, (node) => res.push({
|
|
554
|
+
key: node.item.key.output ? node.item.key.output() : node.item.key,
|
|
555
|
+
value: node.item.value
|
|
556
|
+
})), res;
|
|
557
|
+
}
|
|
558
|
+
/**
|
|
559
|
+
* Returns true if tree is empty
|
|
560
|
+
* @returns {boolean}
|
|
561
|
+
*/
|
|
562
|
+
isEmpty() {
|
|
563
|
+
return this.root == null || this.root === this.nil_node;
|
|
564
|
+
}
|
|
565
|
+
/**
|
|
566
|
+
* Clear tree
|
|
567
|
+
*/
|
|
568
|
+
clear() {
|
|
569
|
+
this.root = null;
|
|
570
|
+
}
|
|
571
|
+
/**
|
|
572
|
+
* Insert new item into interval tree
|
|
573
|
+
* @param {Interval} key - interval object or array of two numbers [low, high]
|
|
574
|
+
* @param {any} value - value representing any object (optional)
|
|
575
|
+
* @returns {Node} returns reference to inserted node as an object {key:interval, value: value}
|
|
576
|
+
*/
|
|
577
|
+
insert(key, value = key) {
|
|
578
|
+
if (key === void 0) return;
|
|
579
|
+
let insert_node = new Node(key, value, this.nil_node, this.nil_node, null, RB_TREE_COLOR_RED);
|
|
580
|
+
return this.tree_insert(insert_node), this.recalc_max(insert_node), insert_node;
|
|
581
|
+
}
|
|
582
|
+
/**
|
|
583
|
+
* Returns true if item {key,value} exist in the tree
|
|
584
|
+
* @param {Interval} key - interval correspondent to keys stored in the tree
|
|
585
|
+
* @param {any} value - value object to be checked
|
|
586
|
+
* @returns {boolean} true if item {key, value} exist in the tree, false otherwise
|
|
587
|
+
*/
|
|
588
|
+
exist(key, value = key) {
|
|
589
|
+
let search_node = new Node(key, value);
|
|
590
|
+
return !!this.tree_search(this.root, search_node);
|
|
591
|
+
}
|
|
592
|
+
/**
|
|
593
|
+
* Remove entry {key, value} from the tree
|
|
594
|
+
* @param {Interval} key - interval correspondent to keys stored in the tree
|
|
595
|
+
* @param {any} value - value object
|
|
596
|
+
* @returns {boolean} true if item {key, value} deleted, false if not found
|
|
597
|
+
*/
|
|
598
|
+
remove(key, value = key) {
|
|
599
|
+
let search_node = new Node(key, value), delete_node = this.tree_search(this.root, search_node);
|
|
600
|
+
return delete_node && this.tree_delete(delete_node), delete_node;
|
|
601
|
+
}
|
|
602
|
+
/**
|
|
603
|
+
* Returns array of entry values which keys intersect with given interval <br/>
|
|
604
|
+
* If no values stored in the tree, returns array of keys which intersect given interval
|
|
605
|
+
* @param {Interval} interval - search interval, or tuple [low, high]
|
|
606
|
+
* @param outputMapperFn(value,key) - optional function that maps (value, key) to custom output
|
|
607
|
+
* @returns {Array}
|
|
608
|
+
*/
|
|
609
|
+
search(interval, outputMapperFn = (value, key) => value === key ? key.output() : value) {
|
|
610
|
+
let search_node = new Node(interval), resp_nodes = [];
|
|
611
|
+
return this.tree_search_interval(this.root, search_node, resp_nodes), resp_nodes.map((node) => outputMapperFn(node.item.value, node.item.key));
|
|
612
|
+
}
|
|
613
|
+
/**
|
|
614
|
+
* Returns true if intersection between given and any interval stored in the tree found
|
|
615
|
+
* @param {Interval} interval - search interval or tuple [low, high]
|
|
616
|
+
* @returns {boolean}
|
|
617
|
+
*/
|
|
618
|
+
intersect_any(interval) {
|
|
619
|
+
let search_node = new Node(interval);
|
|
620
|
+
return this.tree_find_any_interval(this.root, search_node);
|
|
621
|
+
}
|
|
622
|
+
/**
|
|
623
|
+
* Tree visitor. For each node implement a callback function. <br/>
|
|
624
|
+
* Method calls a callback function with two parameters (key, value)
|
|
625
|
+
* @param visitor(key,value) - function to be called for each tree item
|
|
626
|
+
*/
|
|
627
|
+
forEach(visitor) {
|
|
628
|
+
this.tree_walk(this.root, (node) => visitor(node.item.key, node.item.value));
|
|
629
|
+
}
|
|
630
|
+
/**
|
|
631
|
+
* Value Mapper. Walk through every node and map node value to another value
|
|
632
|
+
* @param callback(value,key) - function to be called for each tree item
|
|
633
|
+
*/
|
|
634
|
+
map(callback) {
|
|
635
|
+
const tree = new _IntervalTree();
|
|
636
|
+
return this.tree_walk(this.root, (node) => tree.insert(node.item.key, callback(node.item.value, node.item.key))), tree;
|
|
637
|
+
}
|
|
638
|
+
/**
|
|
639
|
+
* @param {Interval} interval - optional if the iterator is intended to start from the beginning
|
|
640
|
+
* @param outputMapperFn(value,key) - optional function that maps (value, key) to custom output
|
|
641
|
+
* @returns {Iterator}
|
|
642
|
+
*/
|
|
643
|
+
*iterate(interval, outputMapperFn = (value, key) => value === key ? key.output() : value) {
|
|
644
|
+
let node;
|
|
645
|
+
for (interval ? node = this.tree_search_nearest_forward(this.root, new Node(interval)) : this.root && (node = this.local_minimum(this.root)); node; )
|
|
646
|
+
yield outputMapperFn(node.item.value, node.item.key), node = this.tree_successor(node);
|
|
647
|
+
}
|
|
648
|
+
recalc_max(node) {
|
|
649
|
+
let node_current = node;
|
|
650
|
+
for (; node_current.parent != null; )
|
|
651
|
+
node_current.parent.update_max(), node_current = node_current.parent;
|
|
652
|
+
}
|
|
653
|
+
tree_insert(insert_node) {
|
|
654
|
+
let current_node = this.root, parent_node = null;
|
|
655
|
+
if (this.root == null || this.root === this.nil_node)
|
|
656
|
+
this.root = insert_node;
|
|
657
|
+
else {
|
|
658
|
+
for (; current_node !== this.nil_node; )
|
|
659
|
+
parent_node = current_node, insert_node.less_than(current_node) ? current_node = current_node.left : current_node = current_node.right;
|
|
660
|
+
insert_node.parent = parent_node, insert_node.less_than(parent_node) ? parent_node.left = insert_node : parent_node.right = insert_node;
|
|
661
|
+
}
|
|
662
|
+
this.insert_fixup(insert_node);
|
|
663
|
+
}
|
|
664
|
+
// After insertion insert_node may have red-colored parent, and this is a single possible violation
|
|
665
|
+
// Go upwords to the root and re-color until violation will be resolved
|
|
666
|
+
insert_fixup(insert_node) {
|
|
667
|
+
let current_node, uncle_node;
|
|
668
|
+
for (current_node = insert_node; current_node !== this.root && current_node.parent.color === RB_TREE_COLOR_RED; )
|
|
669
|
+
current_node.parent === current_node.parent.parent.left ? (uncle_node = current_node.parent.parent.right, uncle_node.color === RB_TREE_COLOR_RED ? (current_node.parent.color = RB_TREE_COLOR_BLACK, uncle_node.color = RB_TREE_COLOR_BLACK, current_node.parent.parent.color = RB_TREE_COLOR_RED, current_node = current_node.parent.parent) : (current_node === current_node.parent.right && (current_node = current_node.parent, this.rotate_left(current_node)), current_node.parent.color = RB_TREE_COLOR_BLACK, current_node.parent.parent.color = RB_TREE_COLOR_RED, this.rotate_right(current_node.parent.parent))) : (uncle_node = current_node.parent.parent.left, uncle_node.color === RB_TREE_COLOR_RED ? (current_node.parent.color = RB_TREE_COLOR_BLACK, uncle_node.color = RB_TREE_COLOR_BLACK, current_node.parent.parent.color = RB_TREE_COLOR_RED, current_node = current_node.parent.parent) : (current_node === current_node.parent.left && (current_node = current_node.parent, this.rotate_right(current_node)), current_node.parent.color = RB_TREE_COLOR_BLACK, current_node.parent.parent.color = RB_TREE_COLOR_RED, this.rotate_left(current_node.parent.parent)));
|
|
670
|
+
this.root.color = RB_TREE_COLOR_BLACK;
|
|
671
|
+
}
|
|
672
|
+
tree_delete(delete_node) {
|
|
673
|
+
let cut_node, fix_node;
|
|
674
|
+
delete_node.left === this.nil_node || delete_node.right === this.nil_node ? cut_node = delete_node : cut_node = this.tree_successor(delete_node), cut_node.left !== this.nil_node ? fix_node = cut_node.left : fix_node = cut_node.right, fix_node.parent = cut_node.parent, cut_node === this.root ? this.root = fix_node : (cut_node === cut_node.parent.left ? cut_node.parent.left = fix_node : cut_node.parent.right = fix_node, cut_node.parent.update_max()), this.recalc_max(fix_node), cut_node !== delete_node && (delete_node.copy_data(cut_node), delete_node.update_max(), this.recalc_max(delete_node)), /*fix_node != this.nil_node && */
|
|
675
|
+
cut_node.color === RB_TREE_COLOR_BLACK && this.delete_fixup(fix_node);
|
|
676
|
+
}
|
|
677
|
+
delete_fixup(fix_node) {
|
|
678
|
+
let current_node = fix_node, brother_node;
|
|
679
|
+
for (; current_node !== this.root && current_node.parent != null && current_node.color === RB_TREE_COLOR_BLACK; )
|
|
680
|
+
current_node === current_node.parent.left ? (brother_node = current_node.parent.right, brother_node.color === RB_TREE_COLOR_RED && (brother_node.color = RB_TREE_COLOR_BLACK, current_node.parent.color = RB_TREE_COLOR_RED, this.rotate_left(current_node.parent), brother_node = current_node.parent.right), brother_node.left.color === RB_TREE_COLOR_BLACK && brother_node.right.color === RB_TREE_COLOR_BLACK ? (brother_node.color = RB_TREE_COLOR_RED, current_node = current_node.parent) : (brother_node.right.color === RB_TREE_COLOR_BLACK && (brother_node.color = RB_TREE_COLOR_RED, brother_node.left.color = RB_TREE_COLOR_BLACK, this.rotate_right(brother_node), brother_node = current_node.parent.right), brother_node.color = current_node.parent.color, current_node.parent.color = RB_TREE_COLOR_BLACK, brother_node.right.color = RB_TREE_COLOR_BLACK, this.rotate_left(current_node.parent), current_node = this.root)) : (brother_node = current_node.parent.left, brother_node.color === RB_TREE_COLOR_RED && (brother_node.color = RB_TREE_COLOR_BLACK, current_node.parent.color = RB_TREE_COLOR_RED, this.rotate_right(current_node.parent), brother_node = current_node.parent.left), brother_node.left.color === RB_TREE_COLOR_BLACK && brother_node.right.color === RB_TREE_COLOR_BLACK ? (brother_node.color = RB_TREE_COLOR_RED, current_node = current_node.parent) : (brother_node.left.color === RB_TREE_COLOR_BLACK && (brother_node.color = RB_TREE_COLOR_RED, brother_node.right.color = RB_TREE_COLOR_BLACK, this.rotate_left(brother_node), brother_node = current_node.parent.left), brother_node.color = current_node.parent.color, current_node.parent.color = RB_TREE_COLOR_BLACK, brother_node.left.color = RB_TREE_COLOR_BLACK, this.rotate_right(current_node.parent), current_node = this.root));
|
|
681
|
+
current_node.color = RB_TREE_COLOR_BLACK;
|
|
682
|
+
}
|
|
683
|
+
tree_search(node, search_node) {
|
|
684
|
+
if (!(node == null || node === this.nil_node))
|
|
685
|
+
return search_node.equal_to(node) ? node : search_node.less_than(node) ? this.tree_search(node.left, search_node) : this.tree_search(node.right, search_node);
|
|
686
|
+
}
|
|
687
|
+
tree_search_nearest_forward(node, search_node) {
|
|
688
|
+
let best, curr = node;
|
|
689
|
+
for (; curr && curr !== this.nil_node; )
|
|
690
|
+
curr.less_than(search_node) ? curr.intersect(search_node) ? (best = curr, curr = curr.left) : curr = curr.right : ((!best || curr.less_than(best)) && (best = curr), curr = curr.left);
|
|
691
|
+
return best || null;
|
|
692
|
+
}
|
|
693
|
+
// Original search_interval method; container res support push() insertion
|
|
694
|
+
// Search all intervals intersecting given one
|
|
695
|
+
tree_search_interval(node, search_node, res) {
|
|
696
|
+
node != null && node !== this.nil_node && (node.left !== this.nil_node && !node.not_intersect_left_subtree(search_node) && this.tree_search_interval(node.left, search_node, res), node.intersect(search_node) && res.push(node), node.right !== this.nil_node && !node.not_intersect_right_subtree(search_node) && this.tree_search_interval(node.right, search_node, res));
|
|
697
|
+
}
|
|
698
|
+
tree_find_any_interval(node, search_node) {
|
|
699
|
+
let found = !1;
|
|
700
|
+
return node != null && node !== this.nil_node && (node.left !== this.nil_node && !node.not_intersect_left_subtree(search_node) && (found = this.tree_find_any_interval(node.left, search_node)), found || (found = node.intersect(search_node)), !found && node.right !== this.nil_node && !node.not_intersect_right_subtree(search_node) && (found = this.tree_find_any_interval(node.right, search_node))), found;
|
|
701
|
+
}
|
|
702
|
+
local_minimum(node) {
|
|
703
|
+
let node_min = node;
|
|
704
|
+
for (; node_min.left != null && node_min.left !== this.nil_node; )
|
|
705
|
+
node_min = node_min.left;
|
|
706
|
+
return node_min;
|
|
707
|
+
}
|
|
708
|
+
// not in use
|
|
709
|
+
local_maximum(node) {
|
|
710
|
+
let node_max = node;
|
|
711
|
+
for (; node_max.right != null && node_max.right !== this.nil_node; )
|
|
712
|
+
node_max = node_max.right;
|
|
713
|
+
return node_max;
|
|
714
|
+
}
|
|
715
|
+
tree_successor(node) {
|
|
716
|
+
let node_successor, current_node, parent_node;
|
|
717
|
+
if (node.right !== this.nil_node)
|
|
718
|
+
node_successor = this.local_minimum(node.right);
|
|
719
|
+
else {
|
|
720
|
+
for (current_node = node, parent_node = node.parent; parent_node != null && parent_node.right === current_node; )
|
|
721
|
+
current_node = parent_node, parent_node = parent_node.parent;
|
|
722
|
+
node_successor = parent_node;
|
|
723
|
+
}
|
|
724
|
+
return node_successor;
|
|
725
|
+
}
|
|
726
|
+
// | right-rotate(T,y) |
|
|
727
|
+
// y ---------------. x
|
|
728
|
+
// / \ / \
|
|
729
|
+
// x c left-rotate(T,x) a y
|
|
730
|
+
// / \ <--------------- / \
|
|
731
|
+
// a b b c
|
|
732
|
+
rotate_left(x) {
|
|
733
|
+
let y = x.right;
|
|
734
|
+
x.right = y.left, y.left !== this.nil_node && (y.left.parent = x), y.parent = x.parent, x === this.root ? this.root = y : x === x.parent.left ? x.parent.left = y : x.parent.right = y, y.left = x, x.parent = y, x != null && x !== this.nil_node && x.update_max(), y = x.parent, y != null && y !== this.nil_node && y.update_max();
|
|
735
|
+
}
|
|
736
|
+
rotate_right(y) {
|
|
737
|
+
let x = y.left;
|
|
738
|
+
y.left = x.right, x.right !== this.nil_node && (x.right.parent = y), x.parent = y.parent, y === this.root ? this.root = x : y === y.parent.left ? y.parent.left = x : y.parent.right = x, x.right = y, y.parent = x, y !== null && y !== this.nil_node && y.update_max(), x = y.parent, x != null && x !== this.nil_node && x.update_max();
|
|
739
|
+
}
|
|
740
|
+
tree_walk(node, action) {
|
|
741
|
+
node != null && node !== this.nil_node && (this.tree_walk(node.left, action), action(node), this.tree_walk(node.right, action));
|
|
742
|
+
}
|
|
743
|
+
/* Return true if all red nodes have exactly two black child nodes */
|
|
744
|
+
testRedBlackProperty() {
|
|
745
|
+
let res = !0;
|
|
746
|
+
return this.tree_walk(this.root, function(node) {
|
|
747
|
+
node.color === RB_TREE_COLOR_RED && (node.left.color === RB_TREE_COLOR_BLACK && node.right.color === RB_TREE_COLOR_BLACK || (res = !1));
|
|
748
|
+
}), res;
|
|
749
|
+
}
|
|
750
|
+
/* Throw error if not every path from root to bottom has same black height */
|
|
751
|
+
testBlackHeightProperty(node) {
|
|
752
|
+
let height = 0, heightLeft = 0, heightRight = 0;
|
|
753
|
+
if (node.color === RB_TREE_COLOR_BLACK && height++, node.left !== this.nil_node ? heightLeft = this.testBlackHeightProperty(node.left) : heightLeft = 1, node.right !== this.nil_node ? heightRight = this.testBlackHeightProperty(node.right) : heightRight = 1, heightLeft !== heightRight)
|
|
754
|
+
throw new Error("Red-black height property violated");
|
|
755
|
+
return height += heightLeft, height;
|
|
756
|
+
}
|
|
757
|
+
};
|
|
758
|
+
__name(_IntervalTree, "IntervalTree");
|
|
759
|
+
let IntervalTree = _IntervalTree;
|
|
760
|
+
const _RuleMatrix = class _RuleMatrix {
|
|
761
|
+
constructor(value, _unitId, _subUnitId, _univerInstanceService, _disableTree = !1) {
|
|
762
|
+
__publicField(this, "_map");
|
|
763
|
+
__publicField(this, "_tree", /* @__PURE__ */ new Map());
|
|
764
|
+
__publicField(this, "_dirty", !0);
|
|
765
|
+
__publicField(this, "_buildTree", /* @__PURE__ */ __name(() => {
|
|
766
|
+
if (!this._dirty || this._disableTree)
|
|
767
|
+
return;
|
|
768
|
+
const map = /* @__PURE__ */ new Map();
|
|
769
|
+
this._map.forEach((ranges, ruleId) => {
|
|
770
|
+
ranges.forEach((range) => {
|
|
771
|
+
for (let col = range.startColumn; col <= range.endColumn; col++) {
|
|
772
|
+
let items = map.get(col);
|
|
773
|
+
items || (items = [], map.set(col, items)), items.push({
|
|
774
|
+
startRow: range.startRow,
|
|
775
|
+
endRow: range.endRow,
|
|
776
|
+
ruleId
|
|
777
|
+
});
|
|
778
|
+
}
|
|
779
|
+
});
|
|
397
780
|
});
|
|
398
|
-
|
|
781
|
+
const treeMap = /* @__PURE__ */ new Map();
|
|
782
|
+
map.forEach((items, col) => {
|
|
783
|
+
const tree = new IntervalTree();
|
|
784
|
+
items.forEach((item) => {
|
|
785
|
+
tree.insert([item.startRow, item.endRow], item.ruleId);
|
|
786
|
+
}), treeMap.set(col, tree);
|
|
787
|
+
}), this._tree = treeMap, this._dirty = !1;
|
|
788
|
+
}, "_buildTree"));
|
|
789
|
+
__publicField(this, "_debonceBuildTree", debounce(this._buildTree, 0));
|
|
790
|
+
this._unitId = _unitId, this._subUnitId = _subUnitId, this._univerInstanceService = _univerInstanceService, this._disableTree = _disableTree, this._map = value, this._buildTree();
|
|
791
|
+
}
|
|
792
|
+
get _worksheet() {
|
|
793
|
+
var _a24;
|
|
794
|
+
return (_a24 = this._univerInstanceService.getUnit(this._unitId, UniverInstanceType.UNIVER_SHEET)) == null ? void 0 : _a24.getSheetBySheetId(this._subUnitId);
|
|
795
|
+
}
|
|
796
|
+
addRule(rule) {
|
|
797
|
+
if (!this._worksheet)
|
|
798
|
+
return;
|
|
799
|
+
const ruleId = rule.uid, ranges = rule.ranges.map((range) => Range.transformRange(range, this._worksheet));
|
|
800
|
+
this._map.forEach((value, key) => {
|
|
801
|
+
const newRanges = Rectangle.subtractMulti(value, ranges);
|
|
802
|
+
newRanges.length === 0 ? this._map.delete(key) : this._map.set(key, newRanges);
|
|
803
|
+
}), this._dirty = !0, this._map.set(ruleId, ranges), this._debonceBuildTree();
|
|
804
|
+
}
|
|
805
|
+
removeRange(_ranges) {
|
|
806
|
+
if (!this._worksheet)
|
|
807
|
+
return;
|
|
808
|
+
const ranges = _ranges.map((range) => Range.transformRange(range, this._worksheet));
|
|
809
|
+
this._map.forEach((value, key) => {
|
|
810
|
+
const newRanges = Rectangle.subtractMulti(value, ranges);
|
|
811
|
+
newRanges.length === 0 ? this._map.delete(key) : this._map.set(key, newRanges);
|
|
812
|
+
}), this._dirty = !0, this._debonceBuildTree();
|
|
399
813
|
}
|
|
400
814
|
removeRule(rule) {
|
|
401
|
-
|
|
402
|
-
Range.foreach(Range.transformRange(range, this._worksheet), (row, col) => {
|
|
403
|
-
this.value.setValue(row, col, "");
|
|
404
|
-
});
|
|
405
|
-
});
|
|
815
|
+
this._map.delete(rule.uid), this._dirty = !0, this._debonceBuildTree();
|
|
406
816
|
}
|
|
407
|
-
updateRange(ruleId,
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
817
|
+
updateRange(ruleId, _newRanges) {
|
|
818
|
+
if (!this._worksheet)
|
|
819
|
+
return;
|
|
820
|
+
this._map.delete(ruleId);
|
|
821
|
+
const ranges = _newRanges.map((range) => Range.transformRange(range, this._worksheet));
|
|
822
|
+
this._map.forEach((value, key) => {
|
|
823
|
+
const newRanges = Rectangle.subtractMulti(value, ranges);
|
|
824
|
+
newRanges.length === 0 ? this._map.delete(key) : this._map.set(key, newRanges);
|
|
825
|
+
}), this._map.set(ruleId, ranges), this._dirty = !0, this._debonceBuildTree();
|
|
826
|
+
}
|
|
827
|
+
addRangeRules(rules) {
|
|
828
|
+
rules.forEach(({ id: ruleId, ranges }) => {
|
|
829
|
+
if (!ranges.length)
|
|
830
|
+
return;
|
|
831
|
+
let current = this._map.get(ruleId);
|
|
832
|
+
current ? (this._map.set(ruleId, Rectangle.mergeRanges([...current, ...ranges])), current = this._map.get(ruleId)) : (current = ranges, this._map.set(ruleId, current)), this._map.forEach((value, key) => {
|
|
833
|
+
if (key === ruleId)
|
|
834
|
+
return;
|
|
835
|
+
const newRanges = Rectangle.subtractMulti(value, ranges);
|
|
836
|
+
newRanges.length === 0 ? this._map.delete(key) : this._map.set(key, newRanges);
|
|
420
837
|
});
|
|
421
|
-
});
|
|
838
|
+
}), this._dirty = !0, this._debonceBuildTree();
|
|
422
839
|
}
|
|
423
840
|
diff(rules) {
|
|
424
841
|
const mutations = [];
|
|
425
842
|
let deleteIndex = 0;
|
|
426
843
|
return rules.forEach((rule, index) => {
|
|
427
|
-
|
|
428
|
-
|
|
844
|
+
var _a24;
|
|
845
|
+
const newRanges = (_a24 = this._map.get(rule.uid)) != null ? _a24 : [], oldRanges = rule.ranges;
|
|
846
|
+
newRanges.length !== 0 && (newRanges.length !== oldRanges.length || newRanges.some((range, i) => !Rectangle.equals(range, oldRanges[i]))) && mutations.push({
|
|
429
847
|
type: "update",
|
|
430
848
|
ruleId: rule.uid,
|
|
431
849
|
oldRanges,
|
|
@@ -441,8 +859,9 @@ const _RuleMatrix = class _RuleMatrix {
|
|
|
441
859
|
const mutations = [];
|
|
442
860
|
let deleteIndex = 0;
|
|
443
861
|
return rules.forEach((rule, index) => {
|
|
444
|
-
|
|
445
|
-
|
|
862
|
+
var _a24;
|
|
863
|
+
const newRanges = (_a24 = this._map.get(rule.uid)) != null ? _a24 : [], oldRanges = rule.ranges;
|
|
864
|
+
newRanges.length !== 0 && (newRanges.length !== oldRanges.length || newRanges.some((range, i) => !Rectangle.equals(range, oldRanges[i]))) && mutations.push({
|
|
446
865
|
type: "update",
|
|
447
866
|
ruleId: rule.uid,
|
|
448
867
|
oldRanges,
|
|
@@ -453,7 +872,8 @@ const _RuleMatrix = class _RuleMatrix {
|
|
|
453
872
|
index: index - deleteIndex
|
|
454
873
|
}), deleteIndex++);
|
|
455
874
|
}), Array.from(additionRules).forEach((rule) => {
|
|
456
|
-
|
|
875
|
+
var _a24;
|
|
876
|
+
const newRanges = (_a24 = this._map.get(rule.uid)) != null ? _a24 : [];
|
|
457
877
|
mutations.push({
|
|
458
878
|
type: "add",
|
|
459
879
|
rule: {
|
|
@@ -464,13 +884,22 @@ const _RuleMatrix = class _RuleMatrix {
|
|
|
464
884
|
}), mutations;
|
|
465
885
|
}
|
|
466
886
|
clone() {
|
|
467
|
-
return new _RuleMatrix(
|
|
887
|
+
return new _RuleMatrix(
|
|
888
|
+
new Map(Tools.deepClone(Array.from(this._map.entries()))),
|
|
889
|
+
this._unitId,
|
|
890
|
+
this._subUnitId,
|
|
891
|
+
this._univerInstanceService,
|
|
892
|
+
// disable tree on cloned matrix, cause there is no need to search
|
|
893
|
+
!0
|
|
894
|
+
);
|
|
468
895
|
}
|
|
469
896
|
getValue(row, col) {
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
897
|
+
this._dirty && this._buildTree();
|
|
898
|
+
const tree = this._tree.get(col);
|
|
899
|
+
if (!tree)
|
|
900
|
+
return;
|
|
901
|
+
const result = tree.search([row, row]);
|
|
902
|
+
return result.length > 0 ? result[0] : void 0;
|
|
474
903
|
}
|
|
475
904
|
};
|
|
476
905
|
__name(_RuleMatrix, "RuleMatrix");
|
|
@@ -479,18 +908,32 @@ var __defProp$i = Object.defineProperty, __getOwnPropDesc$i = Object.getOwnPrope
|
|
|
479
908
|
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$i(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
480
909
|
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
481
910
|
return kind && result && __defProp$i(target, key, result), result;
|
|
482
|
-
}, "__decorateClass$i"), __decorateParam$i = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$i"),
|
|
483
|
-
let SheetDataValidationModel = (
|
|
484
|
-
constructor(_dataValidationModel, _univerInstanceService, _dataValidatorRegistryService, _dataValidationCacheService, _dataValidationFormulaService, _dataValidationCustomFormulaService) {
|
|
911
|
+
}, "__decorateClass$i"), __decorateParam$i = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$i"), _a4;
|
|
912
|
+
let SheetDataValidationModel = (_a4 = class extends Disposable {
|
|
913
|
+
constructor(_dataValidationModel, _univerInstanceService, _dataValidatorRegistryService, _dataValidationCacheService, _dataValidationFormulaService, _dataValidationCustomFormulaService, _commandService) {
|
|
485
914
|
super();
|
|
486
915
|
__publicField(this, "_ruleMatrixMap", /* @__PURE__ */ new Map());
|
|
487
916
|
__publicField(this, "_validStatusChange$", new Subject());
|
|
488
917
|
__publicField(this, "_ruleChange$", new Subject());
|
|
489
918
|
__publicField(this, "ruleChange$", this._ruleChange$.asObservable());
|
|
490
919
|
__publicField(this, "validStatusChange$", this._validStatusChange$.asObservable());
|
|
491
|
-
this._dataValidationModel = _dataValidationModel, this._univerInstanceService = _univerInstanceService, this._dataValidatorRegistryService = _dataValidatorRegistryService, this._dataValidationCacheService = _dataValidationCacheService, this._dataValidationFormulaService = _dataValidationFormulaService, this._dataValidationCustomFormulaService = _dataValidationCustomFormulaService, this._initRuleUpdateListener(), this.disposeWithMe(() => {
|
|
920
|
+
this._dataValidationModel = _dataValidationModel, this._univerInstanceService = _univerInstanceService, this._dataValidatorRegistryService = _dataValidatorRegistryService, this._dataValidationCacheService = _dataValidationCacheService, this._dataValidationFormulaService = _dataValidationFormulaService, this._dataValidationCustomFormulaService = _dataValidationCustomFormulaService, this._commandService = _commandService, this._initRuleUpdateListener(), this.disposeWithMe(() => {
|
|
492
921
|
this._ruleChange$.complete(), this._validStatusChange$.complete();
|
|
493
|
-
});
|
|
922
|
+
}), this._initUniverInstanceListener();
|
|
923
|
+
}
|
|
924
|
+
_initUniverInstanceListener() {
|
|
925
|
+
this.disposeWithMe(
|
|
926
|
+
this._univerInstanceService.unitDisposed$.subscribe((unit) => {
|
|
927
|
+
this._ruleMatrixMap.delete(unit.getUnitId());
|
|
928
|
+
})
|
|
929
|
+
), this.disposeWithMe(
|
|
930
|
+
this._commandService.onCommandExecuted((command) => {
|
|
931
|
+
if (command.id === RemoveSheetMutation.id) {
|
|
932
|
+
const { unitId, subUnitId } = command.params, subUnitMap = this._ruleMatrixMap.get(unitId);
|
|
933
|
+
subUnitMap && subUnitMap.delete(subUnitId);
|
|
934
|
+
}
|
|
935
|
+
})
|
|
936
|
+
);
|
|
494
937
|
}
|
|
495
938
|
_initRuleUpdateListener() {
|
|
496
939
|
const allRules = this._dataValidationModel.getAll();
|
|
@@ -522,28 +965,21 @@ let SheetDataValidationModel = (_a3 = class extends Disposable {
|
|
|
522
965
|
}
|
|
523
966
|
_ensureRuleMatrix(unitId, subUnitId) {
|
|
524
967
|
let unitMap = this._ruleMatrixMap.get(unitId);
|
|
525
|
-
const workbook = this._univerInstanceService.getUnit(unitId, UniverInstanceType.UNIVER_SHEET);
|
|
526
|
-
if (!workbook)
|
|
527
|
-
throw new Error(`workbook not found, unitId: ${unitId}`);
|
|
528
968
|
unitMap || (unitMap = /* @__PURE__ */ new Map(), this._ruleMatrixMap.set(unitId, unitMap));
|
|
529
|
-
const worksheet = workbook.getSheetBySheetId(subUnitId);
|
|
530
|
-
if (!worksheet)
|
|
531
|
-
throw new Error(`worksheet not found, unitId: ${unitId}, subUnitId: ${subUnitId}`);
|
|
532
969
|
let matrix = unitMap.get(subUnitId);
|
|
533
|
-
return matrix || (matrix = new RuleMatrix(new
|
|
970
|
+
return matrix || (matrix = new RuleMatrix(/* @__PURE__ */ new Map(), unitId, subUnitId, this._univerInstanceService), unitMap.set(subUnitId, matrix)), matrix;
|
|
534
971
|
}
|
|
535
972
|
_addRuleSideEffect(unitId, subUnitId, rule) {
|
|
536
|
-
|
|
537
|
-
(rule.type === DataValidationType.LIST || rule.type === DataValidationType.LIST_MULTIPLE) && isReferenceString((_a23 = rule.formula1) != null ? _a23 : "") && (rule.formula1 = `=${rule.formula1}`), this._ensureRuleMatrix(unitId, subUnitId).addRule(rule), this._dataValidationCacheService.addRule(unitId, subUnitId, rule), this._dataValidationFormulaService.addRule(unitId, subUnitId, rule.uid, rule.formula1, rule.formula2), this._dataValidationCustomFormulaService.addRule(unitId, subUnitId, rule);
|
|
973
|
+
this._ensureRuleMatrix(unitId, subUnitId).addRule(rule), this._dataValidationCacheService.addRule(unitId, subUnitId, rule), this._dataValidationFormulaService.addRule(unitId, subUnitId, rule.uid, rule.formula1, rule.formula2), this._dataValidationCustomFormulaService.addRule(unitId, subUnitId, rule);
|
|
538
974
|
}
|
|
539
|
-
_addRule(unitId, subUnitId, rule
|
|
975
|
+
_addRule(unitId, subUnitId, rule) {
|
|
540
976
|
(Array.isArray(rule) ? rule : [rule]).forEach((item) => {
|
|
541
977
|
this._addRuleSideEffect(unitId, subUnitId, item);
|
|
542
978
|
});
|
|
543
979
|
}
|
|
544
980
|
_updateRule(unitId, subUnitId, ruleId, oldRule, payload) {
|
|
545
981
|
const ruleMatrix = this._ensureRuleMatrix(unitId, subUnitId);
|
|
546
|
-
payload.type === UpdateRuleType.RANGE ? (ruleMatrix.updateRange(ruleId,
|
|
982
|
+
payload.type === UpdateRuleType.RANGE ? (ruleMatrix.updateRange(ruleId, payload.payload), this._dataValidationCacheService.updateRuleRanges(unitId, subUnitId, ruleId, payload.payload, oldRule.ranges), this._dataValidationCustomFormulaService.updateRuleRanges(unitId, subUnitId, ruleId, oldRule.ranges, payload.payload)) : payload.type === UpdateRuleType.SETTING && (this._dataValidationCacheService.markRangeDirty(unitId, subUnitId, oldRule.ranges), this._dataValidationFormulaService.updateRuleFormulaText(unitId, subUnitId, ruleId, payload.payload.formula1, payload.payload.formula2), this._dataValidationCustomFormulaService.updateRuleFormula(unitId, subUnitId, ruleId, oldRule.ranges, payload.payload.formula1));
|
|
547
983
|
}
|
|
548
984
|
_removeRule(unitId, subUnitId, oldRule) {
|
|
549
985
|
this._ensureRuleMatrix(unitId, subUnitId).removeRule(oldRule), this._dataValidationCacheService.removeRule(unitId, subUnitId, oldRule);
|
|
@@ -631,7 +1067,7 @@ let SheetDataValidationModel = (_a3 = class extends Disposable {
|
|
|
631
1067
|
getAll() {
|
|
632
1068
|
return this._dataValidationModel.getAll();
|
|
633
1069
|
}
|
|
634
|
-
}, __name(
|
|
1070
|
+
}, __name(_a4, "SheetDataValidationModel"), _a4);
|
|
635
1071
|
SheetDataValidationModel = __decorateClass$i([
|
|
636
1072
|
OnLifecycle(LifecycleStages.Starting, SheetDataValidationModel),
|
|
637
1073
|
__decorateParam$i(0, Inject(DataValidationModel)),
|
|
@@ -639,7 +1075,8 @@ SheetDataValidationModel = __decorateClass$i([
|
|
|
639
1075
|
__decorateParam$i(2, Inject(DataValidatorRegistryService)),
|
|
640
1076
|
__decorateParam$i(3, Inject(DataValidationCacheService)),
|
|
641
1077
|
__decorateParam$i(4, Inject(DataValidationFormulaService)),
|
|
642
|
-
__decorateParam$i(5, Inject(DataValidationCustomFormulaService))
|
|
1078
|
+
__decorateParam$i(5, Inject(DataValidationCustomFormulaService)),
|
|
1079
|
+
__decorateParam$i(6, ICommandService)
|
|
643
1080
|
], SheetDataValidationModel);
|
|
644
1081
|
function createDefaultNewRule(accessor) {
|
|
645
1082
|
const currentRanges = accessor.get(SheetsSelectionsService).getCurrentSelections().map((s) => s.range);
|
|
@@ -653,13 +1090,13 @@ function createDefaultNewRule(accessor) {
|
|
|
653
1090
|
}
|
|
654
1091
|
__name(createDefaultNewRule, "createDefaultNewRule");
|
|
655
1092
|
function getFormulaResult(result) {
|
|
656
|
-
var
|
|
657
|
-
return (_b = (
|
|
1093
|
+
var _a24, _b;
|
|
1094
|
+
return (_b = (_a24 = result == null ? void 0 : result[0]) == null ? void 0 : _a24[0]) == null ? void 0 : _b.v;
|
|
658
1095
|
}
|
|
659
1096
|
__name(getFormulaResult, "getFormulaResult");
|
|
660
1097
|
function getFormulaCellData(result) {
|
|
661
|
-
var
|
|
662
|
-
return (
|
|
1098
|
+
var _a24;
|
|
1099
|
+
return (_a24 = result == null ? void 0 : result[0]) == null ? void 0 : _a24[0];
|
|
663
1100
|
}
|
|
664
1101
|
__name(getFormulaCellData, "getFormulaCellData");
|
|
665
1102
|
var commonjsGlobal = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
|
|
@@ -692,12 +1129,12 @@ reactJsxRuntime_production_min.jsxs = q;
|
|
|
692
1129
|
jsxRuntime.exports = reactJsxRuntime_production_min;
|
|
693
1130
|
var jsxRuntimeExports = jsxRuntime.exports;
|
|
694
1131
|
function CustomFormulaInput(props) {
|
|
695
|
-
var
|
|
1132
|
+
var _a24;
|
|
696
1133
|
const { unitId, subUnitId, value, onChange, showError, validResult } = props, formula1Res = showError ? validResult == null ? void 0 : validResult.formula1 : "";
|
|
697
1134
|
return /* @__PURE__ */ jsxRuntimeExports.jsx(FormLayout, { error: formula1Res, children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
698
1135
|
TextEditor,
|
|
699
1136
|
{
|
|
700
|
-
value: (
|
|
1137
|
+
value: (_a24 = value == null ? void 0 : value.formula1) != null ? _a24 : "",
|
|
701
1138
|
id: createInternalEditorID(`dataValidation-custom-formula-${unitId}-${subUnitId}`),
|
|
702
1139
|
onChange: /* @__PURE__ */ __name((newValue) => {
|
|
703
1140
|
onChange == null || onChange({
|
|
@@ -795,15 +1232,15 @@ function replaceRuntimeIdsAndExtInAttrs(node, runtimeProps, extend) {
|
|
|
795
1232
|
var attrs = __assign({}, node.attrs);
|
|
796
1233
|
extend != null && extend.colorChannel1 && attrs.fill === "colorChannel1" && (attrs.fill = extend.colorChannel1);
|
|
797
1234
|
var defIds = runtimeProps.defIds;
|
|
798
|
-
return !defIds || defIds.length === 0 || (node.tag === "use" && attrs["xlink:href"] && (attrs["xlink:href"] = attrs["xlink:href"] + runtimeProps.idSuffix), Object.entries(attrs).forEach(function(
|
|
799
|
-
var key =
|
|
1235
|
+
return !defIds || defIds.length === 0 || (node.tag === "use" && attrs["xlink:href"] && (attrs["xlink:href"] = attrs["xlink:href"] + runtimeProps.idSuffix), Object.entries(attrs).forEach(function(_a24) {
|
|
1236
|
+
var key = _a24[0], value = _a24[1];
|
|
800
1237
|
typeof value == "string" && (attrs[key] = value.replace(/url\(#(.*)\)/, "url(#$1".concat(runtimeProps.idSuffix, ")")));
|
|
801
1238
|
})), attrs;
|
|
802
1239
|
}
|
|
803
1240
|
__name(replaceRuntimeIdsAndExtInAttrs, "replaceRuntimeIdsAndExtInAttrs");
|
|
804
1241
|
function replaceRuntimeIdsInDefs(node, runtimeProps) {
|
|
805
|
-
var
|
|
806
|
-
return !defIds || defIds.length === 0 ? node : node.tag === "defs" && (!((
|
|
1242
|
+
var _a24, defIds = runtimeProps.defIds;
|
|
1243
|
+
return !defIds || defIds.length === 0 ? node : node.tag === "defs" && (!((_a24 = node.children) === null || _a24 === void 0) && _a24.length) ? __assign(__assign({}, node), { children: node.children.map(function(child) {
|
|
807
1244
|
return typeof child.attrs.id == "string" && defIds && defIds.indexOf(child.attrs.id) > -1 ? __assign(__assign({}, child), { attrs: __assign(__assign({}, child.attrs), { id: child.attrs.id + runtimeProps.idSuffix }) }) : child;
|
|
808
1245
|
}) }) : node;
|
|
809
1246
|
}
|
|
@@ -869,31 +1306,17 @@ var element = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width:
|
|
|
869
1306
|
}));
|
|
870
1307
|
});
|
|
871
1308
|
SequenceSingle.displayName = "SequenceSingle";
|
|
872
|
-
function serializeListOptions(options) {
|
|
873
|
-
return options.filter(Boolean).join(",");
|
|
874
|
-
}
|
|
875
|
-
__name(serializeListOptions, "serializeListOptions");
|
|
876
|
-
function deserializeListOptions(optionsStr) {
|
|
877
|
-
return optionsStr.split(",").filter(Boolean);
|
|
878
|
-
}
|
|
879
|
-
__name(deserializeListOptions, "deserializeListOptions");
|
|
880
|
-
function getDataValidationCellValue(cellData) {
|
|
881
|
-
const cellValue = getCellValueOrigin(cellData);
|
|
882
|
-
return cellValue == null ? "" : cellValue.toString();
|
|
883
|
-
}
|
|
884
|
-
__name(getDataValidationCellValue, "getDataValidationCellValue");
|
|
885
|
-
const DATA_VALIDATION_PLUGIN_NAME = "SHEET_DATA_VALIDATION_PLUGIN", DROP_DOWN_DEFAULT_COLOR = "#ECECEC";
|
|
886
1309
|
var P = /* @__PURE__ */ ((E) => (E[E.View = 0] = "View", E[E.Edit = 1] = "Edit", E[E.ManageCollaborator = 2] = "ManageCollaborator", E[E.Print = 3] = "Print", E[E.Duplicate = 4] = "Duplicate", E[E.Comment = 5] = "Comment", E[E.Copy = 6] = "Copy", E[E.Share = 7] = "Share", E[E.Export = 8] = "Export", E[E.MoveWorksheet = 9] = "MoveWorksheet", E[E.DeleteWorksheet = 10] = "DeleteWorksheet", E[E.HideWorksheet = 11] = "HideWorksheet", E[E.RenameWorksheet = 12] = "RenameWorksheet", E[E.CreateWorksheet = 13] = "CreateWorksheet", E[E.SetWorksheetStyle = 14] = "SetWorksheetStyle", E[E.EditWorksheetCell = 15] = "EditWorksheetCell", E[E.InsertHyperlink = 16] = "InsertHyperlink", E[E.Sort = 17] = "Sort", E[E.Filter = 18] = "Filter", E[E.PivotTable = 19] = "PivotTable", E[E.FloatImg = 20] = "FloatImg", E[E.History = 21] = "History", E[E.RwHgtClWdt = 22] = "RwHgtClWdt", E[E.ViemRwHgtClWdt = 23] = "ViemRwHgtClWdt", E[E.ViewFilter = 24] = "ViewFilter", E[E.MoveSheet = 25] = "MoveSheet", E[E.DeleteSheet = 26] = "DeleteSheet", E[E.HideSheet = 27] = "HideSheet", E[E.CopySheet = 28] = "CopySheet", E[E.RenameSheet = 29] = "RenameSheet", E[E.CreateSheet = 30] = "CreateSheet", E[E.SelectProtectedCells = 31] = "SelectProtectedCells", E[E.SelectUnProtectedCells = 32] = "SelectUnProtectedCells", E[E.SetCellStyle = 33] = "SetCellStyle", E[E.SetCellValue = 34] = "SetCellValue", E[E.SetRowStyle = 35] = "SetRowStyle", E[E.SetColumnStyle = 36] = "SetColumnStyle", E[E.InsertRow = 37] = "InsertRow", E[E.InsertColumn = 38] = "InsertColumn", E[E.DeleteRow = 39] = "DeleteRow", E[E.DeleteColumn = 40] = "DeleteColumn", E[E.EditExtraObject = 41] = "EditExtraObject", E[E.Delete = 42] = "Delete", E[E.RecoverHistory = 43] = "RecoverHistory", E[E.ViewHistory = 44] = "ViewHistory", E[E.UNRECOGNIZED = -1] = "UNRECOGNIZED", E))(P || {}), __defProp$h = Object.defineProperty, __getOwnPropDesc$h = Object.getOwnPropertyDescriptor, __decorateClass$h = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
887
1310
|
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$h(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
888
1311
|
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
889
1312
|
return kind && result && __defProp$h(target, key, result), result;
|
|
890
|
-
}, "__decorateClass$h"), __decorateParam$h = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$h"),
|
|
891
|
-
let DataValidationFormulaController = (
|
|
1313
|
+
}, "__decorateClass$h"), __decorateParam$h = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$h"), _a5;
|
|
1314
|
+
let DataValidationFormulaController = (_a5 = class extends Disposable {
|
|
892
1315
|
constructor(_univerInstanceService, _permissionService, _lexerTreeBuilder) {
|
|
893
1316
|
super(), this._univerInstanceService = _univerInstanceService, this._permissionService = _permissionService, this._lexerTreeBuilder = _lexerTreeBuilder;
|
|
894
1317
|
}
|
|
895
1318
|
getFormulaRefCheck(formulaString) {
|
|
896
|
-
var
|
|
1319
|
+
var _a24, _b;
|
|
897
1320
|
const sequenceNodes = this._lexerTreeBuilder.sequenceNodesBuilder(formulaString);
|
|
898
1321
|
if (!sequenceNodes)
|
|
899
1322
|
return !0;
|
|
@@ -915,20 +1338,33 @@ let DataValidationFormulaController = (_a4 = class extends Disposable {
|
|
|
915
1338
|
const { startRow, endRow, startColumn, endColumn } = sequenceGrid.range;
|
|
916
1339
|
for (let i2 = startRow; i2 <= endRow; i2++)
|
|
917
1340
|
for (let j = startColumn; j <= endColumn; j++) {
|
|
918
|
-
const permission = (_b = (
|
|
1341
|
+
const permission = (_b = (_a24 = targetSheet.getCell(i2, j)) == null ? void 0 : _a24.selectionProtection) == null ? void 0 : _b[0];
|
|
919
1342
|
if ((permission == null ? void 0 : permission[P.View]) === !1)
|
|
920
1343
|
return !1;
|
|
921
1344
|
}
|
|
922
1345
|
}
|
|
923
1346
|
return !0;
|
|
924
1347
|
}
|
|
925
|
-
}, __name(
|
|
1348
|
+
}, __name(_a5, "DataValidationFormulaController"), _a5);
|
|
926
1349
|
DataValidationFormulaController = __decorateClass$h([
|
|
927
1350
|
OnLifecycle(LifecycleStages.Rendered, DataValidationFormulaController),
|
|
928
1351
|
__decorateParam$h(0, IUniverInstanceService),
|
|
929
1352
|
__decorateParam$h(1, IPermissionService),
|
|
930
1353
|
__decorateParam$h(2, Inject(LexerTreeBuilder))
|
|
931
1354
|
], DataValidationFormulaController);
|
|
1355
|
+
function serializeListOptions(options) {
|
|
1356
|
+
return options.filter(Boolean).join(",");
|
|
1357
|
+
}
|
|
1358
|
+
__name(serializeListOptions, "serializeListOptions");
|
|
1359
|
+
function deserializeListOptions(optionsStr) {
|
|
1360
|
+
return optionsStr.split(",").filter(Boolean);
|
|
1361
|
+
}
|
|
1362
|
+
__name(deserializeListOptions, "deserializeListOptions");
|
|
1363
|
+
function getDataValidationCellValue(cellData) {
|
|
1364
|
+
const cellValue = getCellValueOrigin(cellData);
|
|
1365
|
+
return cellValue == null ? "" : cellValue.toString();
|
|
1366
|
+
}
|
|
1367
|
+
__name(getDataValidationCellValue, "getDataValidationCellValue");
|
|
932
1368
|
const DEFAULT_COLOR_PRESET = [
|
|
933
1369
|
"#FFFFFF",
|
|
934
1370
|
"#FEE7E7",
|
|
@@ -1241,14 +1677,14 @@ var __defProp$g = Object.defineProperty, __getOwnPropDesc$g = Object.getOwnPrope
|
|
|
1241
1677
|
return kind && result && __defProp$g(target, key, result), result;
|
|
1242
1678
|
}, "__decorateClass$g"), __decorateParam$g = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$g");
|
|
1243
1679
|
const MARGIN_H$2 = 6;
|
|
1244
|
-
var
|
|
1245
|
-
let CheckboxRender = (
|
|
1680
|
+
var _a6;
|
|
1681
|
+
let CheckboxRender = (_a6 = class {
|
|
1246
1682
|
constructor(_commandService, _formulaService, _themeService) {
|
|
1247
1683
|
this._commandService = _commandService, this._formulaService = _formulaService, this._themeService = _themeService;
|
|
1248
1684
|
}
|
|
1249
1685
|
_calc(cellInfo, style) {
|
|
1250
|
-
var
|
|
1251
|
-
const { vt, ht } = style || {}, width = cellInfo.endX - cellInfo.startX - MARGIN_H$2 * 2, height = cellInfo.endY - cellInfo.startY, size = ((
|
|
1686
|
+
var _a24, _b, _c;
|
|
1687
|
+
const { vt, ht } = style || {}, width = cellInfo.endX - cellInfo.startX - MARGIN_H$2 * 2, height = cellInfo.endY - cellInfo.startY, size = ((_a24 = style == null ? void 0 : style.fs) != null ? _a24 : 10) * 1.6;
|
|
1252
1688
|
let widgetLeft = 0, widgetTop = 0;
|
|
1253
1689
|
switch (vt) {
|
|
1254
1690
|
case VerticalAlign.TOP:
|
|
@@ -1280,25 +1716,25 @@ let CheckboxRender = (_a5 = class {
|
|
|
1280
1716
|
};
|
|
1281
1717
|
}
|
|
1282
1718
|
calcCellAutoHeight(info) {
|
|
1283
|
-
var
|
|
1719
|
+
var _a24;
|
|
1284
1720
|
const { style } = info;
|
|
1285
|
-
return ((
|
|
1721
|
+
return ((_a24 = style == null ? void 0 : style.fs) != null ? _a24 : 10) * 1.6;
|
|
1286
1722
|
}
|
|
1287
1723
|
async _parseFormula(rule, unitId, subUnitId) {
|
|
1288
|
-
var
|
|
1724
|
+
var _a24, _b;
|
|
1289
1725
|
const { formula1 = CHECKBOX_FORMULA_1, formula2 = CHECKBOX_FORMULA_2 } = rule, results = await this._formulaService.getRuleFormulaResult(unitId, subUnitId, rule.uid);
|
|
1290
1726
|
return {
|
|
1291
|
-
formula1: isFormulaString(formula1) ? getFormulaResult((
|
|
1727
|
+
formula1: isFormulaString(formula1) ? getFormulaResult((_a24 = results == null ? void 0 : results[0]) == null ? void 0 : _a24.result) : formula1,
|
|
1292
1728
|
formula2: isFormulaString(formula2) ? getFormulaResult((_b = results == null ? void 0 : results[1]) == null ? void 0 : _b.result) : formula2
|
|
1293
1729
|
};
|
|
1294
1730
|
}
|
|
1295
1731
|
drawWith(ctx, info) {
|
|
1296
|
-
var
|
|
1297
|
-
const { style, data, primaryWithCoord, unitId, subUnitId, worksheet, row, col } = info, cellBounding = primaryWithCoord.isMergedMainCell ? primaryWithCoord.mergeInfo : primaryWithCoord, value = getCellValueOrigin(worksheet.getCellRaw(row, col)), rule = (
|
|
1732
|
+
var _a24, _b, _c, _d, _e, _f;
|
|
1733
|
+
const { style, data, primaryWithCoord, unitId, subUnitId, worksheet, row, col } = info, cellBounding = primaryWithCoord.isMergedMainCell ? primaryWithCoord.mergeInfo : primaryWithCoord, value = getCellValueOrigin(worksheet.getCellRaw(row, col)), rule = (_a24 = data.dataValidation) == null ? void 0 : _a24.rule, validator = (_b = data.dataValidation) == null ? void 0 : _b.validator;
|
|
1298
1734
|
if (!rule || !validator)
|
|
1299
1735
|
return;
|
|
1300
1736
|
const colors = this._themeService.getCurrentTheme();
|
|
1301
|
-
if (!validator.skipDefaultFontRender(rule, value, { unitId, subUnitId }))
|
|
1737
|
+
if (!((_c = validator.skipDefaultFontRender) != null && _c.call(validator, rule, value, { unitId, subUnitId })))
|
|
1302
1738
|
return;
|
|
1303
1739
|
const result = validator.parseFormulaSync(rule, unitId, subUnitId), { formula1 } = result, layout = this._calc(cellBounding, style), { a: scaleX, d: scaleY } = ctx.getTransform(), left = fixLineWidthByScale(layout.left, scaleX), top = fixLineWidthByScale(layout.top, scaleY), transform = Transform.create().composeMatrix({
|
|
1304
1740
|
left,
|
|
@@ -1314,12 +1750,12 @@ let CheckboxRender = (_a5 = class {
|
|
|
1314
1750
|
ctx.save(), ctx.beginPath(), ctx.rect(cellBounding.startX, cellBounding.startY, cellWidth, cellHeight), ctx.clip();
|
|
1315
1751
|
const m2 = transform.getMatrix();
|
|
1316
1752
|
ctx.transform(m2[0], m2[1], m2[2], m2[3], m2[4], m2[5]);
|
|
1317
|
-
const size = ((
|
|
1753
|
+
const size = ((_d = style == null ? void 0 : style.fs) != null ? _d : 10) * 1.6, checked = String(value) === String(formula1), defaultColor = colors.hyacinth500;
|
|
1318
1754
|
Checkbox$1.drawWith(ctx, {
|
|
1319
1755
|
checked,
|
|
1320
1756
|
width: size,
|
|
1321
1757
|
height: size,
|
|
1322
|
-
fill: (
|
|
1758
|
+
fill: (_f = (_e = style == null ? void 0 : style.cl) == null ? void 0 : _e.rgb) != null ? _f : defaultColor
|
|
1323
1759
|
}), ctx.restore();
|
|
1324
1760
|
}
|
|
1325
1761
|
isHit(evt, info) {
|
|
@@ -1327,11 +1763,11 @@ let CheckboxRender = (_a5 = class {
|
|
|
1327
1763
|
return offsetX <= endX && offsetX >= startX && offsetY <= endY && offsetY >= startY;
|
|
1328
1764
|
}
|
|
1329
1765
|
async onPointerDown(info, evt) {
|
|
1330
|
-
var
|
|
1766
|
+
var _a24, _b, _c;
|
|
1331
1767
|
if (evt.button === 2)
|
|
1332
1768
|
return;
|
|
1333
|
-
const { primaryWithCoord, unitId, subUnitId, data, worksheet, row, col } = info, value = getCellValueOrigin(worksheet.getCellRaw(row, col)), rule = (
|
|
1334
|
-
if (!rule || !validator || !validator.skipDefaultFontRender(rule, value, { unitId, subUnitId }))
|
|
1769
|
+
const { primaryWithCoord, unitId, subUnitId, data, worksheet, row, col } = info, value = getCellValueOrigin(worksheet.getCellRaw(row, col)), rule = (_a24 = data.dataValidation) == null ? void 0 : _a24.rule, validator = (_b = data.dataValidation) == null ? void 0 : _b.validator;
|
|
1770
|
+
if (!rule || !validator || !((_c = validator.skipDefaultFontRender) != null && _c.call(validator, rule, value, { unitId, subUnitId })))
|
|
1335
1771
|
return;
|
|
1336
1772
|
const { formula1, formula2 } = await this._parseFormula(rule, unitId, subUnitId), params = {
|
|
1337
1773
|
range: {
|
|
@@ -1350,7 +1786,7 @@ let CheckboxRender = (_a5 = class {
|
|
|
1350
1786
|
params
|
|
1351
1787
|
);
|
|
1352
1788
|
}
|
|
1353
|
-
}, __name(
|
|
1789
|
+
}, __name(_a6, "CheckboxRender"), _a6);
|
|
1354
1790
|
CheckboxRender = __decorateClass$g([
|
|
1355
1791
|
__decorateParam$g(0, ICommandService),
|
|
1356
1792
|
__decorateParam$g(1, Inject(DataValidationFormulaService)),
|
|
@@ -1371,10 +1807,10 @@ const transformCheckboxValue = /* @__PURE__ */ __name((value) => Tools.isDefine(
|
|
|
1371
1807
|
__publicField(this, "formulaInput", CHECKBOX_FORMULA_INPUT_NAME);
|
|
1372
1808
|
__publicField(this, "canvasRender", this.injector.createInstance(CheckboxRender));
|
|
1373
1809
|
__publicField(this, "_formulaService", this.injector.get(DataValidationFormulaService));
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1810
|
+
__publicField(this, "skipDefaultFontRender", /* @__PURE__ */ __name((rule, cellValue, pos) => {
|
|
1811
|
+
const { formula1, formula2 } = this.parseFormulaSync(rule, pos.unitId, pos.subUnitId), valueStr = `${cellValue != null ? cellValue : ""}`;
|
|
1812
|
+
return !valueStr || valueStr === `${formula1}` || valueStr === `${formula2}`;
|
|
1813
|
+
}, "skipDefaultFontRender"));
|
|
1378
1814
|
}
|
|
1379
1815
|
validatorFormula(rule, unitId, subUnitId) {
|
|
1380
1816
|
const { formula1, formula2 } = rule, isEqual = formula1 === formula2;
|
|
@@ -1396,8 +1832,8 @@ const transformCheckboxValue = /* @__PURE__ */ __name((value) => Tools.isDefine(
|
|
|
1396
1832
|
};
|
|
1397
1833
|
}
|
|
1398
1834
|
async parseFormula(rule, unitId, subUnitId) {
|
|
1399
|
-
var
|
|
1400
|
-
const { formula1 = CHECKBOX_FORMULA_1, formula2 = CHECKBOX_FORMULA_2 } = rule, results = await this._formulaService.getRuleFormulaResult(unitId, subUnitId, rule.uid), originFormula1 = isFormulaString(formula1) ? getFormulaResult((
|
|
1835
|
+
var _a24, _b;
|
|
1836
|
+
const { formula1 = CHECKBOX_FORMULA_1, formula2 = CHECKBOX_FORMULA_2 } = rule, results = await this._formulaService.getRuleFormulaResult(unitId, subUnitId, rule.uid), originFormula1 = isFormulaString(formula1) ? getFormulaResult((_a24 = results == null ? void 0 : results[0]) == null ? void 0 : _a24.result) : formula1, originFormula2 = isFormulaString(formula2) ? getFormulaResult((_b = results == null ? void 0 : results[1]) == null ? void 0 : _b.result) : formula2;
|
|
1401
1837
|
return {
|
|
1402
1838
|
formula1: transformCheckboxValue(originFormula1),
|
|
1403
1839
|
formula2: transformCheckboxValue(originFormula2),
|
|
@@ -1405,9 +1841,14 @@ const transformCheckboxValue = /* @__PURE__ */ __name((value) => Tools.isDefine(
|
|
|
1405
1841
|
originFormula2
|
|
1406
1842
|
};
|
|
1407
1843
|
}
|
|
1844
|
+
getExtraStyle(rule, value) {
|
|
1845
|
+
return {
|
|
1846
|
+
tb: WrapStrategy.CLIP
|
|
1847
|
+
};
|
|
1848
|
+
}
|
|
1408
1849
|
parseFormulaSync(rule, unitId, subUnitId) {
|
|
1409
|
-
var
|
|
1410
|
-
const { formula1 = CHECKBOX_FORMULA_1, formula2 = CHECKBOX_FORMULA_2 } = rule, results = this._formulaService.getRuleFormulaResultSync(unitId, subUnitId, rule.uid), originFormula1 = isFormulaString(formula1) ? getFormulaResult((
|
|
1850
|
+
var _a24, _b;
|
|
1851
|
+
const { formula1 = CHECKBOX_FORMULA_1, formula2 = CHECKBOX_FORMULA_2 } = rule, results = this._formulaService.getRuleFormulaResultSync(unitId, subUnitId, rule.uid), originFormula1 = isFormulaString(formula1) ? getFormulaResult((_a24 = results == null ? void 0 : results[0]) == null ? void 0 : _a24.result) : formula1, originFormula2 = isFormulaString(formula2) ? getFormulaResult((_b = results == null ? void 0 : results[1]) == null ? void 0 : _b.result) : formula2;
|
|
1411
1852
|
return {
|
|
1412
1853
|
formula1: transformCheckboxValue(originFormula1),
|
|
1413
1854
|
formula2: transformCheckboxValue(originFormula2),
|
|
@@ -1458,430 +1899,255 @@ const DateOperatorTitleMap = {
|
|
|
1458
1899
|
DataValidationOperator.BETWEEN,
|
|
1459
1900
|
DataValidationOperator.NOT_BETWEEN
|
|
1460
1901
|
];
|
|
1902
|
+
var utc$1 = { exports: {} };
|
|
1903
|
+
(function(module, exports) {
|
|
1904
|
+
(function(t, i) {
|
|
1905
|
+
module.exports = i();
|
|
1906
|
+
})(commonjsGlobal, function() {
|
|
1907
|
+
var t = "minute", i = /[+-]\d\d(?::?\d\d)?/g, e = /([+-]|\d\d)/g;
|
|
1908
|
+
return function(s, f2, n2) {
|
|
1909
|
+
var u = f2.prototype;
|
|
1910
|
+
n2.utc = function(t2) {
|
|
1911
|
+
var i2 = { date: t2, utc: !0, args: arguments };
|
|
1912
|
+
return new f2(i2);
|
|
1913
|
+
}, u.utc = function(i2) {
|
|
1914
|
+
var e2 = n2(this.toDate(), { locale: this.$L, utc: !0 });
|
|
1915
|
+
return i2 ? e2.add(this.utcOffset(), t) : e2;
|
|
1916
|
+
}, u.local = function() {
|
|
1917
|
+
return n2(this.toDate(), { locale: this.$L, utc: !1 });
|
|
1918
|
+
};
|
|
1919
|
+
var o = u.parse;
|
|
1920
|
+
u.parse = function(t2) {
|
|
1921
|
+
t2.utc && (this.$u = !0), this.$utils().u(t2.$offset) || (this.$offset = t2.$offset), o.call(this, t2);
|
|
1922
|
+
};
|
|
1923
|
+
var r = u.init;
|
|
1924
|
+
u.init = function() {
|
|
1925
|
+
if (this.$u) {
|
|
1926
|
+
var t2 = this.$d;
|
|
1927
|
+
this.$y = t2.getUTCFullYear(), this.$M = t2.getUTCMonth(), this.$D = t2.getUTCDate(), this.$W = t2.getUTCDay(), this.$H = t2.getUTCHours(), this.$m = t2.getUTCMinutes(), this.$s = t2.getUTCSeconds(), this.$ms = t2.getUTCMilliseconds();
|
|
1928
|
+
} else r.call(this);
|
|
1929
|
+
};
|
|
1930
|
+
var a = u.utcOffset;
|
|
1931
|
+
u.utcOffset = function(s2, f3) {
|
|
1932
|
+
var n3 = this.$utils().u;
|
|
1933
|
+
if (n3(s2)) return this.$u ? 0 : n3(this.$offset) ? a.call(this) : this.$offset;
|
|
1934
|
+
if (typeof s2 == "string" && (s2 = function(t2) {
|
|
1935
|
+
t2 === void 0 && (t2 = "");
|
|
1936
|
+
var s3 = t2.match(i);
|
|
1937
|
+
if (!s3) return null;
|
|
1938
|
+
var f4 = ("" + s3[0]).match(e) || ["-", 0, 0], n4 = f4[0], u3 = 60 * +f4[1] + +f4[2];
|
|
1939
|
+
return u3 === 0 ? 0 : n4 === "+" ? u3 : -u3;
|
|
1940
|
+
}(s2), s2 === null)) return this;
|
|
1941
|
+
var u2 = Math.abs(s2) <= 16 ? 60 * s2 : s2, o2 = this;
|
|
1942
|
+
if (f3) return o2.$offset = u2, o2.$u = s2 === 0, o2;
|
|
1943
|
+
if (s2 !== 0) {
|
|
1944
|
+
var r2 = this.$u ? this.toDate().getTimezoneOffset() : -1 * this.utcOffset();
|
|
1945
|
+
(o2 = this.local().add(u2 + r2, t)).$offset = u2, o2.$x.$localOffset = r2;
|
|
1946
|
+
} else o2 = this.utc();
|
|
1947
|
+
return o2;
|
|
1948
|
+
};
|
|
1949
|
+
var h = u.format;
|
|
1950
|
+
u.format = function(t2) {
|
|
1951
|
+
var i2 = t2 || (this.$u ? "YYYY-MM-DDTHH:mm:ss[Z]" : "");
|
|
1952
|
+
return h.call(this, i2);
|
|
1953
|
+
}, u.valueOf = function() {
|
|
1954
|
+
var t2 = this.$utils().u(this.$offset) ? 0 : this.$offset + (this.$x.$localOffset || this.$d.getTimezoneOffset());
|
|
1955
|
+
return this.$d.valueOf() - 6e4 * t2;
|
|
1956
|
+
}, u.isUTC = function() {
|
|
1957
|
+
return !!this.$u;
|
|
1958
|
+
}, u.toISOString = function() {
|
|
1959
|
+
return this.toDate().toISOString();
|
|
1960
|
+
}, u.toString = function() {
|
|
1961
|
+
return this.toDate().toUTCString();
|
|
1962
|
+
};
|
|
1963
|
+
var l2 = u.toDate;
|
|
1964
|
+
u.toDate = function(t2) {
|
|
1965
|
+
return t2 === "s" && this.$offset ? n2(this.format("YYYY-MM-DD HH:mm:ss:SSS")).toDate() : l2.call(this);
|
|
1966
|
+
};
|
|
1967
|
+
var c = u.diff;
|
|
1968
|
+
u.diff = function(t2, i2, e2) {
|
|
1969
|
+
if (t2 && this.$u === t2.$u) return c.call(this, t2, i2, e2);
|
|
1970
|
+
var s2 = this.local(), f3 = n2(t2).local();
|
|
1971
|
+
return c.call(s2, f3, i2, e2);
|
|
1972
|
+
};
|
|
1973
|
+
};
|
|
1974
|
+
});
|
|
1975
|
+
})(utc$1);
|
|
1976
|
+
var utcExports = utc$1.exports;
|
|
1977
|
+
const utc = /* @__PURE__ */ getDefaultExportFromCjs(utcExports);
|
|
1461
1978
|
var __defProp$f = Object.defineProperty, __getOwnPropDesc$f = Object.getOwnPropertyDescriptor, __decorateClass$f = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
1462
1979
|
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$f(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
1463
1980
|
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
1464
1981
|
return kind && result && __defProp$f(target, key, result), result;
|
|
1465
|
-
}, "__decorateClass$f"), __decorateParam$f = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$f"),
|
|
1466
|
-
let
|
|
1467
|
-
constructor(
|
|
1468
|
-
super();
|
|
1469
|
-
__publicField(this, "_open$", new BehaviorSubject(!1));
|
|
1470
|
-
__publicField(this, "open$", this._open$.pipe(distinctUntilChanged()));
|
|
1471
|
-
__publicField(this, "_activeRule");
|
|
1472
|
-
__publicField(this, "_activeRule$", new BehaviorSubject(void 0));
|
|
1473
|
-
__publicField(this, "activeRule$", this._activeRule$.asObservable());
|
|
1474
|
-
__publicField(this, "_closeDisposable", null);
|
|
1475
|
-
this._univerInstanceService = _univerInstanceService, this._sidebarService = _sidebarService, this.disposeWithMe(
|
|
1476
|
-
this._univerInstanceService.getCurrentTypeOfUnit$(UniverInstanceType.UNIVER_SHEET).pipe(filter((sheet) => !sheet)).subscribe(() => {
|
|
1477
|
-
this.close();
|
|
1478
|
-
})
|
|
1479
|
-
);
|
|
1480
|
-
}
|
|
1481
|
-
get activeRule() {
|
|
1482
|
-
return this._activeRule;
|
|
1483
|
-
}
|
|
1484
|
-
get isOpen() {
|
|
1485
|
-
return this._open$.getValue();
|
|
1486
|
-
}
|
|
1487
|
-
dispose() {
|
|
1488
|
-
var _a23;
|
|
1489
|
-
super.dispose(), this._open$.next(!1), this._open$.complete(), this._activeRule$.complete(), (_a23 = this._closeDisposable) == null || _a23.dispose();
|
|
1490
|
-
}
|
|
1491
|
-
open() {
|
|
1492
|
-
this._open$.next(!0);
|
|
1493
|
-
}
|
|
1494
|
-
close() {
|
|
1495
|
-
var _a23;
|
|
1496
|
-
this._open$.next(!1), (_a23 = this._closeDisposable) == null || _a23.dispose();
|
|
1497
|
-
}
|
|
1498
|
-
setCloseDisposable(disposable) {
|
|
1499
|
-
this._closeDisposable = toDisposable(() => {
|
|
1500
|
-
disposable.dispose(), this._closeDisposable = null;
|
|
1501
|
-
});
|
|
1502
|
-
}
|
|
1503
|
-
setActiveRule(rule) {
|
|
1504
|
-
this._activeRule = rule, this._activeRule$.next(rule);
|
|
1982
|
+
}, "__decorateClass$f"), __decorateParam$f = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$f"), _a7;
|
|
1983
|
+
let DataValidationRejectInputController = (_a7 = class extends Disposable {
|
|
1984
|
+
constructor(_editorBridgeService, _dataValidationModel, _dataValidatorRegistryService, _dialogService, _localeService) {
|
|
1985
|
+
super(), this._editorBridgeService = _editorBridgeService, this._dataValidationModel = _dataValidationModel, this._dataValidatorRegistryService = _dataValidatorRegistryService, this._dialogService = _dialogService, this._localeService = _localeService, this._initEditorBridgeInterceptor();
|
|
1505
1986
|
}
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
const localeService = useDependency(LocaleService), componentManager = useDependency(ComponentManager), { value, onChange, extraComponent } = props, [show, setShow] = useState(!1), ExtraOptions = extraComponent ? componentManager.get(extraComponent) : null;
|
|
1518
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
|
|
1519
|
-
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: styles$5.dataValidationOptionsButton, onClick: /* @__PURE__ */ __name(() => setShow(!show), "onClick"), children: [
|
|
1520
|
-
localeService.t("dataValidation.panel.options"),
|
|
1521
|
-
show ? /* @__PURE__ */ jsxRuntimeExports.jsx(MoreUpSingle, { className: styles$5.dataValidationOptionsButtonIcon }) : /* @__PURE__ */ jsxRuntimeExports.jsx(MoreDownSingle, { className: styles$5.dataValidationOptionsButtonIcon })
|
|
1522
|
-
] }),
|
|
1523
|
-
show && /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
|
|
1524
|
-
ExtraOptions ? /* @__PURE__ */ jsxRuntimeExports.jsx(ExtraOptions, { value, onChange }) : null,
|
|
1525
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
1526
|
-
FormLayout,
|
|
1527
|
-
{
|
|
1528
|
-
label: localeService.t("dataValidation.panel.invalid"),
|
|
1529
|
-
children: /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
1530
|
-
RadioGroup,
|
|
1987
|
+
_initEditorBridgeInterceptor() {
|
|
1988
|
+
this._editorBridgeService.interceptor.intercept(
|
|
1989
|
+
this._editorBridgeService.interceptor.getInterceptPoints().AFTER_CELL_EDIT_ASYNC,
|
|
1990
|
+
{
|
|
1991
|
+
handler: /* @__PURE__ */ __name(async (cellPromise, context, next) => {
|
|
1992
|
+
var _a24;
|
|
1993
|
+
const cell = await cellPromise, { worksheet, row, col, unitId, subUnitId, workbook } = context, ruleId = this._dataValidationModel.getRuleIdByLocation(unitId, subUnitId, row, col), rule = ruleId ? this._dataValidationModel.getRuleById(unitId, subUnitId, ruleId) : void 0;
|
|
1994
|
+
if (!rule || rule.errorStyle !== DataValidationErrorStyle.STOP)
|
|
1995
|
+
return next(Promise.resolve(cell));
|
|
1996
|
+
const validator = await this._dataValidatorRegistryService.getValidatorItem(rule.type);
|
|
1997
|
+
if (!validator || await validator.validator(
|
|
1531
1998
|
{
|
|
1532
|
-
value:
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
{
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
},
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
}
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
},
|
|
1999
|
+
value: getCellValueOrigin(cell),
|
|
2000
|
+
interceptValue: getCellValueOrigin((_a24 = context == null ? void 0 : context.origin) != null ? _a24 : cell),
|
|
2001
|
+
row,
|
|
2002
|
+
column: col,
|
|
2003
|
+
unitId,
|
|
2004
|
+
subUnitId,
|
|
2005
|
+
worksheet,
|
|
2006
|
+
workbook,
|
|
2007
|
+
t: cell == null ? void 0 : cell.t
|
|
2008
|
+
},
|
|
2009
|
+
rule
|
|
2010
|
+
))
|
|
2011
|
+
return next(Promise.resolve(cell));
|
|
2012
|
+
const oldCell = worksheet.getCellRaw(row, col);
|
|
2013
|
+
return this._dialogService.open({
|
|
2014
|
+
width: 368,
|
|
2015
|
+
title: {
|
|
2016
|
+
title: this._localeService.t("dataValidation.alert.title")
|
|
2017
|
+
},
|
|
2018
|
+
id: "reject-input-dialog",
|
|
2019
|
+
children: {
|
|
2020
|
+
title: validator.getRuleFinalError(rule)
|
|
2021
|
+
},
|
|
2022
|
+
footer: {
|
|
2023
|
+
title: React.createElement(
|
|
2024
|
+
Button,
|
|
2025
|
+
{
|
|
2026
|
+
type: "primary",
|
|
2027
|
+
onClick: /* @__PURE__ */ __name(() => this._dialogService.close("reject-input-dialog"), "onClick")
|
|
2028
|
+
},
|
|
2029
|
+
this._localeService.t("dataValidation.alert.ok")
|
|
2030
|
+
)
|
|
2031
|
+
},
|
|
2032
|
+
onClose: /* @__PURE__ */ __name(() => {
|
|
2033
|
+
this._dialogService.close("reject-input-dialog");
|
|
2034
|
+
}, "onClose")
|
|
2035
|
+
}), next(Promise.resolve(oldCell));
|
|
2036
|
+
}, "handler")
|
|
2037
|
+
}
|
|
2038
|
+
);
|
|
2039
|
+
}
|
|
2040
|
+
showReject(title) {
|
|
2041
|
+
this._dialogService.open({
|
|
2042
|
+
width: 368,
|
|
2043
|
+
title: {
|
|
2044
|
+
title: this._localeService.t("dataValidation.alert.title")
|
|
2045
|
+
},
|
|
2046
|
+
id: "reject-input-dialog",
|
|
2047
|
+
children: {
|
|
2048
|
+
title
|
|
2049
|
+
},
|
|
2050
|
+
footer: {
|
|
2051
|
+
title: React.createElement(
|
|
2052
|
+
Button,
|
|
2053
|
+
{
|
|
2054
|
+
type: "primary",
|
|
2055
|
+
onClick: /* @__PURE__ */ __name(() => this._dialogService.close("reject-input-dialog"), "onClick")
|
|
2056
|
+
},
|
|
2057
|
+
this._localeService.t("dataValidation.alert.ok")
|
|
2058
|
+
)
|
|
2059
|
+
},
|
|
2060
|
+
onClose: /* @__PURE__ */ __name(() => {
|
|
2061
|
+
this._dialogService.close("reject-input-dialog");
|
|
2062
|
+
}, "onClose")
|
|
1583
2063
|
});
|
|
1584
|
-
}
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
2064
|
+
}
|
|
2065
|
+
}, __name(_a7, "DataValidationRejectInputController"), _a7);
|
|
2066
|
+
DataValidationRejectInputController = __decorateClass$f([
|
|
2067
|
+
OnLifecycle(LifecycleStages.Ready, DataValidationRejectInputController),
|
|
2068
|
+
__decorateParam$f(0, IEditorBridgeService),
|
|
2069
|
+
__decorateParam$f(1, Inject(SheetDataValidationModel)),
|
|
2070
|
+
__decorateParam$f(2, Inject(DataValidatorRegistryService)),
|
|
2071
|
+
__decorateParam$f(3, IDialogService),
|
|
2072
|
+
__decorateParam$f(4, Inject(LocaleService))
|
|
2073
|
+
], DataValidationRejectInputController);
|
|
2074
|
+
const dvDateDropdown = "univer-dv-date-dropdown", dvDateDropdownBtns = "univer-dv-date-dropdown-btns", styles$5 = {
|
|
2075
|
+
dvDateDropdown,
|
|
2076
|
+
dvDateDropdownBtns
|
|
2077
|
+
};
|
|
2078
|
+
dayjs.extend(utc);
|
|
2079
|
+
const transformDate = /* @__PURE__ */ __name((value) => {
|
|
2080
|
+
if (value == null || typeof value == "boolean")
|
|
2081
|
+
return;
|
|
2082
|
+
if (typeof value == "number" || !Number.isNaN(+value))
|
|
2083
|
+
return dayjs(numfmt.format("yyyy-MM-dd HH:mm:ss", Number(value)));
|
|
2084
|
+
const date = dayjs(value);
|
|
2085
|
+
if (date.isValid())
|
|
2086
|
+
return date;
|
|
2087
|
+
}, "transformDate");
|
|
2088
|
+
function DateDropdown(props) {
|
|
2089
|
+
var _a24, _b, _c;
|
|
2090
|
+
const { location, hideFn } = props, { worksheet, row, col, unitId, subUnitId, workbook } = location, commandService = useDependency(ICommandService), rejectInputController = useDependency(DataValidationRejectInputController), cellData = worksheet.getCell(row, col), rule = (_a24 = cellData == null ? void 0 : cellData.dataValidation) == null ? void 0 : _a24.rule, validator = (_b = cellData == null ? void 0 : cellData.dataValidation) == null ? void 0 : _b.validator, cellStr = getCellValueOrigin(worksheet.getCellRaw(row, col)), originDate = transformDate(cellStr), [localDate, setLocalDate] = useState(originDate), showTime = !!((_c = rule == null ? void 0 : rule.bizInfo) != null && _c.showTime), date = localDate && localDate.isValid() ? localDate : dayjs(), localeService = useDependency(LocaleService);
|
|
2091
|
+
if (!cellData || !rule || !validator)
|
|
2092
|
+
return;
|
|
2093
|
+
const handleSave = /* @__PURE__ */ __name(async () => {
|
|
2094
|
+
var _a25, _b2, _c2;
|
|
2095
|
+
if (!date)
|
|
1607
2096
|
return;
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
});
|
|
1612
|
-
const params = {
|
|
2097
|
+
const dateStr = date.format(showTime ? "YYYY-MM-DD HH:mm:ss" : "YYYY-MM-DD 00:00:00"), serialTime = (_a25 = numfmt.parseDate(dateStr)) == null ? void 0 : _a25.v, cellStyle = workbook.getStyles().getStyleByCell(cellData), format = (_c2 = (_b2 = cellStyle == null ? void 0 : cellStyle.n) == null ? void 0 : _b2.pattern) != null ? _c2 : "", patternType = getPatternType(format);
|
|
2098
|
+
rule.errorStyle !== DataValidationErrorStyle.STOP || await validator.validator({
|
|
2099
|
+
value: serialTime,
|
|
1613
2100
|
unitId,
|
|
1614
2101
|
subUnitId,
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
);
|
|
1623
|
-
}, "handleUpdateRuleSetting"), handleDelete = /* @__PURE__ */ __name(async () => {
|
|
1624
|
-
await commandService.executeCommand(RemoveSheetDataValidationCommand.id, {
|
|
1625
|
-
ruleId,
|
|
1626
|
-
unitId,
|
|
1627
|
-
subUnitId
|
|
1628
|
-
}), dataValidationPanelService.setActiveRule(null);
|
|
1629
|
-
}, "handleDelete"), baseRule = {
|
|
1630
|
-
type: localRule.type,
|
|
1631
|
-
operator: localRule.operator,
|
|
1632
|
-
formula1: localRule.formula1,
|
|
1633
|
-
formula2: localRule.formula2,
|
|
1634
|
-
allowBlank: localRule.allowBlank
|
|
1635
|
-
}, handleChangeType = /* @__PURE__ */ __name((newType) => {
|
|
1636
|
-
const validator2 = validatorService.getValidatorItem(newType);
|
|
1637
|
-
if (!validator2)
|
|
1638
|
-
return;
|
|
1639
|
-
const operators2 = validator2.operators, rule2 = dataValidationModel.getRuleById(unitId, subUnitId, ruleId), newRule = newType === (rule2 == null ? void 0 : rule2.type) || newType.includes("list") && (rule2 != null && rule2.type.includes("list")) ? {
|
|
1640
|
-
...rule2,
|
|
1641
|
-
type: newType
|
|
1642
|
-
} : {
|
|
1643
|
-
...localRule,
|
|
1644
|
-
type: newType,
|
|
1645
|
-
operator: operators2[0],
|
|
1646
|
-
formula1: void 0,
|
|
1647
|
-
formula2: void 0
|
|
1648
|
-
};
|
|
1649
|
-
setLocalRule(newRule), commandService.executeCommand(UpdateSheetDataValidationSettingCommand.id, {
|
|
2102
|
+
row,
|
|
2103
|
+
column: col,
|
|
2104
|
+
worksheet,
|
|
2105
|
+
workbook,
|
|
2106
|
+
interceptValue: dateStr.replace("Z", "").replace("T", " "),
|
|
2107
|
+
t: CellValueType.NUMBER
|
|
2108
|
+
}, rule) ? (commandService.executeCommand(SetRangeValuesCommand.id, {
|
|
1650
2109
|
unitId,
|
|
1651
2110
|
subUnitId,
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
2111
|
+
range: {
|
|
2112
|
+
startColumn: col,
|
|
2113
|
+
endColumn: col,
|
|
2114
|
+
startRow: row,
|
|
2115
|
+
endRow: row
|
|
2116
|
+
},
|
|
2117
|
+
value: {
|
|
2118
|
+
v: serialTime,
|
|
2119
|
+
t: 2,
|
|
2120
|
+
p: null,
|
|
2121
|
+
f: null,
|
|
2122
|
+
si: null,
|
|
2123
|
+
s: {
|
|
2124
|
+
n: {
|
|
2125
|
+
pattern: showTime ? patternType === "datetime" ? format : "yyyy-MM-dd hh:mm:ss" : patternType === "date" ? format : "yyyy-MM-dd"
|
|
2126
|
+
}
|
|
2127
|
+
}
|
|
1666
2128
|
}
|
|
1667
|
-
));
|
|
1668
|
-
}, "
|
|
1669
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
|
|
2129
|
+
}), hideFn()) : rejectInputController.showReject(validator.getRuleFinalError(rule));
|
|
2130
|
+
}, "handleSave");
|
|
2131
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: styles$5.dvDateDropdown, children: [
|
|
1670
2132
|
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
1671
|
-
|
|
2133
|
+
DatePanel,
|
|
1672
2134
|
{
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
onChange: /* @__PURE__ */ __name((newRange) => {
|
|
1684
|
-
newRange.some((i) => !isValidRange(i.range) || i.range.endColumn < i.range.startColumn || i.range.endRow < i.range.startRow) || handleUpdateRuleRanges(newRange);
|
|
1685
|
-
}, "onChange")
|
|
1686
|
-
},
|
|
1687
|
-
key
|
|
1688
|
-
)
|
|
2135
|
+
defaultValue: date,
|
|
2136
|
+
pickerValue: date,
|
|
2137
|
+
showTime: showTime || void 0,
|
|
2138
|
+
onSelect: /* @__PURE__ */ __name(async (newValue) => {
|
|
2139
|
+
setLocalDate(newValue);
|
|
2140
|
+
}, "onSelect"),
|
|
2141
|
+
onPanelChange: /* @__PURE__ */ __name((value) => {
|
|
2142
|
+
setLocalDate(value);
|
|
2143
|
+
}, "onPanelChange"),
|
|
2144
|
+
disabledDate: /* @__PURE__ */ __name((current) => !numfmt.parseDate(current.format("YYYY-MM-DD")), "disabledDate")
|
|
1689
2145
|
}
|
|
1690
2146
|
),
|
|
1691
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
1692
|
-
Select,
|
|
1693
|
-
{
|
|
1694
|
-
options: validators == null ? void 0 : validators.map((validator2) => ({
|
|
1695
|
-
label: localeService.t(validator2.title),
|
|
1696
|
-
value: validator2.id
|
|
1697
|
-
})),
|
|
1698
|
-
value: localRule.type,
|
|
1699
|
-
onChange: handleChangeType,
|
|
1700
|
-
className: styles$4.dataValidationDetailFormItem
|
|
1701
|
-
}
|
|
1702
|
-
) }),
|
|
1703
|
-
operators != null && operators.length ? /* @__PURE__ */ jsxRuntimeExports.jsx(FormLayout, { label: localeService.t("dataValidation.panel.operator"), children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
1704
|
-
Select,
|
|
1705
|
-
{
|
|
1706
|
-
options: operators.map((op, i) => ({
|
|
1707
|
-
value: `${op}`,
|
|
1708
|
-
label: operatorNames[i]
|
|
1709
|
-
})),
|
|
1710
|
-
value: `${localRule.operator}`,
|
|
1711
|
-
onChange: /* @__PURE__ */ __name((operator) => {
|
|
1712
|
-
handleUpdateRuleSetting({
|
|
1713
|
-
...baseRule,
|
|
1714
|
-
operator
|
|
1715
|
-
});
|
|
1716
|
-
}, "onChange"),
|
|
1717
|
-
className: styles$4.dataValidationDetailFormItem
|
|
1718
|
-
}
|
|
1719
|
-
) }) : null,
|
|
1720
|
-
FormulaInput ? /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
1721
|
-
FormulaInput,
|
|
1722
|
-
{
|
|
1723
|
-
isTwoFormula,
|
|
1724
|
-
value: {
|
|
1725
|
-
formula1: localRule.formula1,
|
|
1726
|
-
formula2: localRule.formula2
|
|
1727
|
-
},
|
|
1728
|
-
onChange: /* @__PURE__ */ __name((value) => {
|
|
1729
|
-
handleUpdateRuleSetting({
|
|
1730
|
-
...baseRule,
|
|
1731
|
-
...value
|
|
1732
|
-
});
|
|
1733
|
-
}, "onChange"),
|
|
1734
|
-
showError,
|
|
1735
|
-
validResult: validator.validatorFormula(localRule, unitId, subUnitId),
|
|
1736
|
-
unitId,
|
|
1737
|
-
subUnitId,
|
|
1738
|
-
ruleId
|
|
1739
|
-
},
|
|
1740
|
-
key + localRule.type
|
|
1741
|
-
) : null,
|
|
1742
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(DataValidationOptions, { value: options, onChange: handleUpdateRuleOptions, extraComponent: validator.optionsInput }),
|
|
1743
|
-
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: styles$4.dataValidationDetailButtons, children: [
|
|
1744
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(Button, { className: styles$4.dataValidationDetailButton, onClick: handleDelete, children: localeService.t("dataValidation.panel.removeRule") }),
|
|
1745
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(Button, { className: styles$4.dataValidationDetailButton, type: "primary", onClick: handleOk, children: localeService.t("dataValidation.panel.done") })
|
|
1746
|
-
] })
|
|
1747
|
-
] });
|
|
1748
|
-
}
|
|
1749
|
-
__name(DataValidationDetail, "DataValidationDetail");
|
|
1750
|
-
const dataValidationItemContainer = "univer-data-validation-item-container", dataValidationItemTitle = "univer-data-validation-item-title", dataValidationItemContent = "univer-data-validation-item-content", dataValidationItemIcon = "univer-data-validation-item-icon", styles$3 = {
|
|
1751
|
-
dataValidationItemContainer,
|
|
1752
|
-
dataValidationItemTitle,
|
|
1753
|
-
dataValidationItemContent,
|
|
1754
|
-
dataValidationItemIcon
|
|
1755
|
-
}, DataValidationItem = /* @__PURE__ */ __name((props) => {
|
|
1756
|
-
const { rule, onClick, unitId, subUnitId, disable } = props, validatorRegistry = useDependency(DataValidatorRegistryService), commandService = useDependency(ICommandService), markSelectionService = useDependency(IMarkSelectionService), validator = validatorRegistry.getValidatorItem(rule.type), ids = useRef(), [isHover, setIsHover] = useState(!1), handleDelete = /* @__PURE__ */ __name((e) => {
|
|
1757
|
-
commandService.executeCommand(RemoveSheetDataValidationCommand.id, {
|
|
1758
|
-
ruleId: rule.uid,
|
|
1759
|
-
unitId,
|
|
1760
|
-
subUnitId
|
|
1761
|
-
}), e.stopPropagation();
|
|
1762
|
-
}, "handleDelete");
|
|
1763
|
-
return useEffect(() => () => {
|
|
1764
|
-
var _a23;
|
|
1765
|
-
ids.current && ((_a23 = ids.current) == null || _a23.forEach((id) => {
|
|
1766
|
-
id && markSelectionService.removeShape(id);
|
|
1767
|
-
}));
|
|
1768
|
-
}, [markSelectionService]), /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
1769
|
-
"div",
|
|
1770
|
-
{
|
|
1771
|
-
className: styles$3.dataValidationItemContainer,
|
|
1772
|
-
onClick,
|
|
1773
|
-
onMouseEnter: /* @__PURE__ */ __name(() => {
|
|
1774
|
-
disable || (setIsHover(!0), ids.current = rule.ranges.map((range) => markSelectionService.addShape({
|
|
1775
|
-
range,
|
|
1776
|
-
style: {
|
|
1777
|
-
hasAutoFill: !1,
|
|
1778
|
-
fill: "rgba(73, 184, 17, 0.05)",
|
|
1779
|
-
strokeWidth: 1,
|
|
1780
|
-
stroke: "#49B811",
|
|
1781
|
-
widgets: {}
|
|
1782
|
-
},
|
|
1783
|
-
primary: {
|
|
1784
|
-
startColumn: range.startColumn,
|
|
1785
|
-
endColumn: range.endColumn,
|
|
1786
|
-
startRow: range.startRow,
|
|
1787
|
-
endRow: range.endRow,
|
|
1788
|
-
actualRow: range.startRow,
|
|
1789
|
-
actualColumn: range.startColumn,
|
|
1790
|
-
isMerged: !1,
|
|
1791
|
-
isMergedMainCell: !1
|
|
1792
|
-
}
|
|
1793
|
-
})));
|
|
1794
|
-
}, "onMouseEnter"),
|
|
1795
|
-
onMouseLeave: /* @__PURE__ */ __name(() => {
|
|
1796
|
-
var _a23;
|
|
1797
|
-
setIsHover(!1), (_a23 = ids.current) == null || _a23.forEach((id) => {
|
|
1798
|
-
id && markSelectionService.removeShape(id);
|
|
1799
|
-
}), ids.current = void 0;
|
|
1800
|
-
}, "onMouseLeave"),
|
|
1801
|
-
children: [
|
|
1802
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: styles$3.dataValidationItemTitle, children: validator == null ? void 0 : validator.generateRuleName(rule) }),
|
|
1803
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: styles$3.dataValidationItemContent, children: rule.ranges.map((range) => serializeRange(range)).join(",") }),
|
|
1804
|
-
isHover ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: styles$3.dataValidationItemIcon, onClick: handleDelete, children: /* @__PURE__ */ jsxRuntimeExports.jsx(DeleteSingle, {}) }) : null
|
|
1805
|
-
]
|
|
1806
|
-
}
|
|
1807
|
-
);
|
|
1808
|
-
}, "DataValidationItem"), dataValidationListButtons = "univer-data-validation-list-buttons", dataValidationListButton = "univer-data-validation-list-button", styles$2 = {
|
|
1809
|
-
dataValidationListButtons,
|
|
1810
|
-
dataValidationListButton
|
|
1811
|
-
};
|
|
1812
|
-
function DataValidationList() {
|
|
1813
|
-
const univerInstanceService = useDependency(IUniverInstanceService), workbook = useObservable(
|
|
1814
|
-
() => univerInstanceService.getCurrentTypeOfUnit$(UniverInstanceType.UNIVER_SHEET),
|
|
1815
|
-
void 0,
|
|
1816
|
-
void 0,
|
|
1817
|
-
[]
|
|
1818
|
-
);
|
|
1819
|
-
return workbook ? /* @__PURE__ */ jsxRuntimeExports.jsx(DataValidationListWithWorkbook, { workbook }) : null;
|
|
1820
|
-
}
|
|
1821
|
-
__name(DataValidationList, "DataValidationList");
|
|
1822
|
-
function DataValidationListWithWorkbook(props) {
|
|
1823
|
-
const sheetDataValidationModel = useDependency(SheetDataValidationModel), univerInstanceService = useDependency(IUniverInstanceService), commandService = useDependency(ICommandService), injector = useDependency(Injector), dataValidationPanelService = useDependency(DataValidationPanelService), localeService = useDependency(LocaleService), [rules, setRules] = useState([]), { workbook } = props, worksheet = useObservable(workbook.activeSheet$, void 0, !0), unitId = workbook.getUnitId(), subUnitId = worksheet == null ? void 0 : worksheet.getSheetId();
|
|
1824
|
-
useEffect(() => {
|
|
1825
|
-
setRules(sheetDataValidationModel.getRules(unitId, subUnitId));
|
|
1826
|
-
const subscription = sheetDataValidationModel.ruleChange$.subscribe((change) => {
|
|
1827
|
-
change.unitId === unitId && change.subUnitId === subUnitId && setRules(sheetDataValidationModel.getRules(unitId, subUnitId));
|
|
1828
|
-
});
|
|
1829
|
-
return () => {
|
|
1830
|
-
subscription.unsubscribe();
|
|
1831
|
-
};
|
|
1832
|
-
}, [unitId, subUnitId, sheetDataValidationModel]);
|
|
1833
|
-
const handleAddRule = /* @__PURE__ */ __name(async () => {
|
|
1834
|
-
const rule = createDefaultNewRule(injector), params = {
|
|
1835
|
-
unitId,
|
|
1836
|
-
subUnitId,
|
|
1837
|
-
rule
|
|
1838
|
-
};
|
|
1839
|
-
await commandService.executeCommand(AddSheetDataValidationCommand.id, params), dataValidationPanelService.setActiveRule({
|
|
1840
|
-
unitId,
|
|
1841
|
-
subUnitId,
|
|
1842
|
-
rule
|
|
1843
|
-
});
|
|
1844
|
-
}, "handleAddRule"), handleRemoveAll = /* @__PURE__ */ __name(() => {
|
|
1845
|
-
commandService.executeCommand(RemoveSheetAllDataValidationCommand.id, {
|
|
1846
|
-
unitId,
|
|
1847
|
-
subUnitId
|
|
1848
|
-
});
|
|
1849
|
-
}, "handleRemoveAll"), rulesByPermissionCheck = (/* @__PURE__ */ __name((rules2) => {
|
|
1850
|
-
const workbook2 = univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET), worksheet2 = workbook2.getActiveSheet(), unitId2 = workbook2.getUnitId(), subUnitId2 = worksheet2.getSheetId();
|
|
1851
|
-
return rules2.map((rule) => checkRangesEditablePermission(injector, unitId2, subUnitId2, rule.ranges) ? { ...rule } : { ...rule, disable: !0 });
|
|
1852
|
-
}, "getDvRulesByPermissionCorrect"))(rules), hasDisableRule = rulesByPermissionCheck == null ? void 0 : rulesByPermissionCheck.some((rule) => rule.disable);
|
|
1853
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
|
|
1854
|
-
rulesByPermissionCheck == null ? void 0 : rulesByPermissionCheck.map((rule) => {
|
|
1855
|
-
var _a23;
|
|
1856
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
1857
|
-
DataValidationItem,
|
|
1858
|
-
{
|
|
1859
|
-
unitId,
|
|
1860
|
-
subUnitId,
|
|
1861
|
-
onClick: /* @__PURE__ */ __name(() => {
|
|
1862
|
-
rule.disable || dataValidationPanelService.setActiveRule({
|
|
1863
|
-
unitId,
|
|
1864
|
-
subUnitId,
|
|
1865
|
-
rule
|
|
1866
|
-
});
|
|
1867
|
-
}, "onClick"),
|
|
1868
|
-
rule,
|
|
1869
|
-
disable: (_a23 = rule.disable) != null ? _a23 : !1
|
|
1870
|
-
},
|
|
1871
|
-
rule.uid
|
|
1872
|
-
);
|
|
1873
|
-
}),
|
|
1874
|
-
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: styles$2.dataValidationListButtons, children: [
|
|
1875
|
-
rules.length && !hasDisableRule ? /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { className: styles$2.dataValidationListButton, onClick: handleRemoveAll, children: localeService.t("dataValidation.panel.removeAll") }) : null,
|
|
1876
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(Button, { className: styles$2.dataValidationListButton, type: "primary", onClick: handleAddRule, children: localeService.t("dataValidation.panel.add") })
|
|
1877
|
-
] })
|
|
2147
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: styles$5.dvDateDropdownBtns, children: /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { size: "small", type: "primary", onClick: handleSave, disabled: !date.isValid(), children: localeService.t("dataValidation.alert.ok") }) })
|
|
1878
2148
|
] });
|
|
1879
2149
|
}
|
|
1880
|
-
__name(
|
|
1881
|
-
const DataValidationPanel = /* @__PURE__ */ __name(() => {
|
|
1882
|
-
const dataValidationPanelService = useDependency(DataValidationPanelService), activeRule = useObservable(dataValidationPanelService.activeRule$, dataValidationPanelService.activeRule);
|
|
1883
|
-
return activeRule ? /* @__PURE__ */ jsxRuntimeExports.jsx(DataValidationDetail, {}, activeRule.rule.uid) : /* @__PURE__ */ jsxRuntimeExports.jsx(DataValidationList, {});
|
|
1884
|
-
}, "DataValidationPanel");
|
|
2150
|
+
__name(DateDropdown, "DateDropdown");
|
|
1885
2151
|
function CellDropdown() {
|
|
1886
2152
|
const dropdownManagerService = useDependency(DataValidationDropdownManagerService), activeDropdown = useObservable(dropdownManagerService.activeDropdown$, dropdownManagerService.activeDropdown), componentManager = useDependency(ComponentManager);
|
|
1887
2153
|
if (!activeDropdown)
|
|
@@ -1907,8 +2173,8 @@ var __defProp$e = Object.defineProperty, __getOwnPropDesc$e = Object.getOwnPrope
|
|
|
1907
2173
|
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$e(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
1908
2174
|
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
1909
2175
|
return kind && result && __defProp$e(target, key, result), result;
|
|
1910
|
-
}, "__decorateClass$e"), __decorateParam$e = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$e"),
|
|
1911
|
-
let DataValidationDropdownManagerService = (
|
|
2176
|
+
}, "__decorateClass$e"), __decorateParam$e = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$e"), _a8;
|
|
2177
|
+
let DataValidationDropdownManagerService = (_a8 = class extends Disposable {
|
|
1912
2178
|
constructor(_canvasPopupManagerService, _univerInstanceService, _dataValidatorRegistryService, _zenZoneService, _renderManagerService, _dataValidationModel, _sheetsSelectionsService) {
|
|
1913
2179
|
super();
|
|
1914
2180
|
__publicField(this, "_activeDropdown");
|
|
@@ -1970,8 +2236,8 @@ let DataValidationDropdownManagerService = (_a7 = class extends Disposable {
|
|
|
1970
2236
|
const disposableCollection = new DisposableCollection();
|
|
1971
2237
|
disposableCollection.add(popupDisposable), disposableCollection.add({
|
|
1972
2238
|
dispose: /* @__PURE__ */ __name(() => {
|
|
1973
|
-
var
|
|
1974
|
-
(_b = (
|
|
2239
|
+
var _a24, _b;
|
|
2240
|
+
(_b = (_a24 = this._activeDropdown) == null ? void 0 : _a24.onHide) == null || _b.call(_a24);
|
|
1975
2241
|
}, "dispose")
|
|
1976
2242
|
}), this._currentPopup = disposableCollection;
|
|
1977
2243
|
}
|
|
@@ -2006,7 +2272,7 @@ let DataValidationDropdownManagerService = (_a7 = class extends Disposable {
|
|
|
2006
2272
|
onHide
|
|
2007
2273
|
});
|
|
2008
2274
|
}
|
|
2009
|
-
}, __name(
|
|
2275
|
+
}, __name(_a8, "DataValidationDropdownManagerService"), _a8);
|
|
2010
2276
|
DataValidationDropdownManagerService = __decorateClass$e([
|
|
2011
2277
|
__decorateParam$e(0, Inject(SheetCanvasPopManagerService)),
|
|
2012
2278
|
__decorateParam$e(1, IUniverInstanceService),
|
|
@@ -2016,6 +2282,56 @@ DataValidationDropdownManagerService = __decorateClass$e([
|
|
|
2016
2282
|
__decorateParam$e(5, Inject(SheetDataValidationModel)),
|
|
2017
2283
|
__decorateParam$e(6, Inject(SheetsSelectionsService))
|
|
2018
2284
|
], DataValidationDropdownManagerService);
|
|
2285
|
+
var __defProp$d = Object.defineProperty, __getOwnPropDesc$d = Object.getOwnPropertyDescriptor, __decorateClass$d = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
2286
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$d(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
2287
|
+
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
2288
|
+
return kind && result && __defProp$d(target, key, result), result;
|
|
2289
|
+
}, "__decorateClass$d"), __decorateParam$d = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$d"), _a9;
|
|
2290
|
+
let DataValidationPanelService = (_a9 = class extends Disposable {
|
|
2291
|
+
constructor(_univerInstanceService, _sidebarService) {
|
|
2292
|
+
super();
|
|
2293
|
+
__publicField(this, "_open$", new BehaviorSubject(!1));
|
|
2294
|
+
__publicField(this, "open$", this._open$.pipe(distinctUntilChanged()));
|
|
2295
|
+
__publicField(this, "_activeRule");
|
|
2296
|
+
__publicField(this, "_activeRule$", new BehaviorSubject(void 0));
|
|
2297
|
+
__publicField(this, "activeRule$", this._activeRule$.asObservable());
|
|
2298
|
+
__publicField(this, "_closeDisposable", null);
|
|
2299
|
+
this._univerInstanceService = _univerInstanceService, this._sidebarService = _sidebarService, this.disposeWithMe(
|
|
2300
|
+
this._univerInstanceService.getCurrentTypeOfUnit$(UniverInstanceType.UNIVER_SHEET).pipe(filter((sheet) => !sheet)).subscribe(() => {
|
|
2301
|
+
this.close();
|
|
2302
|
+
})
|
|
2303
|
+
);
|
|
2304
|
+
}
|
|
2305
|
+
get activeRule() {
|
|
2306
|
+
return this._activeRule;
|
|
2307
|
+
}
|
|
2308
|
+
get isOpen() {
|
|
2309
|
+
return this._open$.getValue();
|
|
2310
|
+
}
|
|
2311
|
+
dispose() {
|
|
2312
|
+
var _a24;
|
|
2313
|
+
super.dispose(), this._open$.next(!1), this._open$.complete(), this._activeRule$.complete(), (_a24 = this._closeDisposable) == null || _a24.dispose();
|
|
2314
|
+
}
|
|
2315
|
+
open() {
|
|
2316
|
+
this._open$.next(!0);
|
|
2317
|
+
}
|
|
2318
|
+
close() {
|
|
2319
|
+
var _a24;
|
|
2320
|
+
this._open$.next(!1), (_a24 = this._closeDisposable) == null || _a24.dispose();
|
|
2321
|
+
}
|
|
2322
|
+
setCloseDisposable(disposable) {
|
|
2323
|
+
this._closeDisposable = toDisposable(() => {
|
|
2324
|
+
disposable.dispose(), this._closeDisposable = null;
|
|
2325
|
+
});
|
|
2326
|
+
}
|
|
2327
|
+
setActiveRule(rule) {
|
|
2328
|
+
this._activeRule = rule, this._activeRule$.next(rule);
|
|
2329
|
+
}
|
|
2330
|
+
}, __name(_a9, "DataValidationPanelService"), _a9);
|
|
2331
|
+
DataValidationPanelService = __decorateClass$d([
|
|
2332
|
+
__decorateParam$d(0, IUniverInstanceService),
|
|
2333
|
+
__decorateParam$d(1, ISidebarService)
|
|
2334
|
+
], DataValidationPanelService);
|
|
2019
2335
|
const DATA_VALIDATION_PANEL = "DataValidationPanel", OpenValidationPanelOperation = {
|
|
2020
2336
|
id: "data-validation.operation.open-validation-panel",
|
|
2021
2337
|
type: CommandType.OPERATION,
|
|
@@ -2071,7 +2387,7 @@ const DATA_VALIDATION_PANEL = "DataValidationPanel", OpenValidationPanelOperatio
|
|
|
2071
2387
|
handler(accessor, params) {
|
|
2072
2388
|
return params ? (accessor.get(DataValidationDropdownManagerService).hideDropdown(), !0) : !1;
|
|
2073
2389
|
}
|
|
2074
|
-
}, dvListDropdown = "univer-dv-list-dropdown", dvListDropdownTitle = "univer-dv-list-dropdown-title", dvListDropdownList = "univer-dv-list-dropdown-list", dvListDropdownListContainer = "univer-dv-list-dropdown-list-container", dvListDropdownSelectedIcon = "univer-dv-list-dropdown-selected-icon", dvListDropdownItemContainer = "univer-dv-list-dropdown-item-container", dvListDropdownItem = "univer-dv-list-dropdown-item", dvListDropdownSplit = "univer-dv-list-dropdown-split", dvListDropdownEdit = "univer-dv-list-dropdown-edit", styles$
|
|
2390
|
+
}, PLUGIN_CONFIG_KEY = "sheets-data-validation.config", defaultPluginConfig = {}, dvListDropdown = "univer-dv-list-dropdown", dvListDropdownTitle = "univer-dv-list-dropdown-title", dvListDropdownList = "univer-dv-list-dropdown-list", dvListDropdownListContainer = "univer-dv-list-dropdown-list-container", dvListDropdownSelectedIcon = "univer-dv-list-dropdown-selected-icon", dvListDropdownItemContainer = "univer-dv-list-dropdown-item-container", dvListDropdownItem = "univer-dv-list-dropdown-item", dvListDropdownSplit = "univer-dv-list-dropdown-split", dvListDropdownEdit = "univer-dv-list-dropdown-edit", styles$4 = {
|
|
2075
2391
|
dvListDropdown,
|
|
2076
2392
|
dvListDropdownTitle,
|
|
2077
2393
|
dvListDropdownList,
|
|
@@ -2082,10 +2398,20 @@ const DATA_VALIDATION_PANEL = "DataValidationPanel", OpenValidationPanelOperatio
|
|
|
2082
2398
|
dvListDropdownSplit,
|
|
2083
2399
|
dvListDropdownEdit
|
|
2084
2400
|
}, SelectList = /* @__PURE__ */ __name((props) => {
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2401
|
+
var _a24, _b;
|
|
2402
|
+
const { value, onChange, multiple, options, title, onEdit, style, filter: filter2, location } = props, localeService = useDependency(LocaleService), configService = useDependency(IConfigService), lowerFilter = filter2 == null ? void 0 : filter2.toLowerCase(), { row, col, unitId, subUnitId } = location, filteredOptions = options.filter((item) => lowerFilter ? item.label.toLowerCase().includes(lowerFilter) : !0), showEditOnDropdown = (_b = (_a24 = configService.getConfig(PLUGIN_CONFIG_KEY)) == null ? void 0 : _a24.showEditOnDropdown) != null ? _b : !0, sheetPermissionInterceptorBaseController = useDependency(SheetPermissionInterceptorBaseController), hasPermission = useMemo(() => sheetPermissionInterceptorBaseController.permissionCheckWithRanges(
|
|
2403
|
+
{
|
|
2404
|
+
workbookTypes: [WorkbookEditablePermission],
|
|
2405
|
+
rangeTypes: [RangeProtectionPermissionEditPoint],
|
|
2406
|
+
worksheetTypes: [WorksheetEditPermission]
|
|
2407
|
+
},
|
|
2408
|
+
[{ startColumn: col, startRow: row, endColumn: col, endRow: row }],
|
|
2409
|
+
unitId,
|
|
2410
|
+
subUnitId
|
|
2411
|
+
), [sheetPermissionInterceptorBaseController, col, row, unitId, subUnitId]);
|
|
2412
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: styles$4.dvListDropdown, style, children: [
|
|
2413
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: styles$4.dvListDropdownTitle, children: title }),
|
|
2414
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: styles$4.dvListDropdownList, children: /* @__PURE__ */ jsxRuntimeExports.jsx(Scrollbar, { children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: styles$4.dvListDropdownListContainer, children: filteredOptions.map((item, i) => {
|
|
2089
2415
|
const selected = value.indexOf(item.value) > -1, handleClick = /* @__PURE__ */ __name(() => {
|
|
2090
2416
|
let set;
|
|
2091
2417
|
selected ? set = new Set(value.filter((sub) => sub !== item.value)) : set = new Set(multiple ? [...value, item.value] : [item.value]);
|
|
@@ -2094,31 +2420,34 @@ const DATA_VALIDATION_PANEL = "DataValidationPanel", OpenValidationPanelOperatio
|
|
|
2094
2420
|
set.has(opt.value) && newValue.push(opt.value);
|
|
2095
2421
|
}), onChange(newValue);
|
|
2096
2422
|
}, "handleClick"), index = item.label.toLocaleLowerCase().indexOf(lowerFilter);
|
|
2097
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: styles$
|
|
2098
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: styles$
|
|
2423
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: styles$4.dvListDropdownItemContainer, onClick: handleClick, children: [
|
|
2424
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: styles$4.dvListDropdownItem, style: { background: item.color || DROP_DOWN_DEFAULT_COLOR }, children: lowerFilter && item.label.toLowerCase().includes(lowerFilter) ? /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
|
|
2099
2425
|
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: item.label.substring(0, index) }),
|
|
2100
2426
|
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { style: { fontWeight: "bold" }, children: item.label.substring(index, index + lowerFilter.length) }),
|
|
2101
2427
|
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: item.label.substring(index + lowerFilter.length) })
|
|
2102
2428
|
] }) : item.label }),
|
|
2103
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: styles$
|
|
2429
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: styles$4.dvListDropdownSelectedIcon, children: selected ? /* @__PURE__ */ jsxRuntimeExports.jsx(CheckMarkSingle, {}) : null })
|
|
2104
2430
|
] }, i);
|
|
2105
2431
|
}) }) }, filter2) }),
|
|
2106
|
-
/* @__PURE__ */ jsxRuntimeExports.
|
|
2107
|
-
|
|
2432
|
+
showEditOnDropdown && hasPermission ? /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
|
|
2433
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: styles$4.dvListDropdownSplit }),
|
|
2434
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: styles$4.dvListDropdownEdit, children: /* @__PURE__ */ jsxRuntimeExports.jsx("a", { onClick: onEdit, children: localeService.t("dataValidation.list.edit") }) })
|
|
2435
|
+
] }) : null
|
|
2108
2436
|
] });
|
|
2109
2437
|
}, "SelectList");
|
|
2110
2438
|
function ListDropDown(props) {
|
|
2111
|
-
var
|
|
2439
|
+
var _a24, _b;
|
|
2112
2440
|
const { location, hideFn } = props, { worksheet, row, col, unitId, subUnitId } = location, dataValidationModel = useDependency(DataValidationModel), [editingText, setEditingText] = useState(""), commandService = useDependency(ICommandService), localeService = useDependency(LocaleService), [localValue, setLocalValue] = useState(""), editorBridgeService = useDependency(IEditorBridgeService), instanceService = useDependency(IUniverInstanceService), ruleChange$ = useMemo(() => dataValidationModel.ruleChange$.pipe(debounceTime(16)), []);
|
|
2113
2441
|
useObservable(ruleChange$);
|
|
2114
2442
|
const anchorRect = RectPopup.useContext(), cellWidth = anchorRect.right - anchorRect.left;
|
|
2115
2443
|
if (useEffect(() => {
|
|
2116
2444
|
const dispose = commandService.onCommandExecuted((command) => {
|
|
2445
|
+
var _a25, _b2;
|
|
2117
2446
|
if (command.id === RichTextEditingMutation.id) {
|
|
2118
2447
|
const params = command.params, { unitId: unitId2 } = params, unit = instanceService.getUnit(unitId2, UniverInstanceType.UNIVER_DOC);
|
|
2119
2448
|
if (!unit)
|
|
2120
2449
|
return;
|
|
2121
|
-
const text =
|
|
2450
|
+
const text = BuildTextUtils.transform.getPlainText((_b2 = (_a25 = unit.getSnapshot().body) == null ? void 0 : _a25.dataStream) != null ? _b2 : "");
|
|
2122
2451
|
setEditingText(text);
|
|
2123
2452
|
}
|
|
2124
2453
|
});
|
|
@@ -2127,7 +2456,7 @@ function ListDropDown(props) {
|
|
|
2127
2456
|
};
|
|
2128
2457
|
}, [commandService, instanceService]), !worksheet)
|
|
2129
2458
|
return null;
|
|
2130
|
-
const cellData = worksheet.getCell(row, col), rule = (
|
|
2459
|
+
const cellData = worksheet.getCell(row, col), rule = (_a24 = cellData == null ? void 0 : cellData.dataValidation) == null ? void 0 : _a24.rule, validator = (_b = cellData == null ? void 0 : cellData.dataValidation) == null ? void 0 : _b.validator, showColor = (rule == null ? void 0 : rule.renderMode) === DataValidationRenderMode.CUSTOM || (rule == null ? void 0 : rule.renderMode) === void 0;
|
|
2131
2460
|
if (!cellData || !rule || !validator || validator.id.indexOf(DataValidationType.LIST) !== 0)
|
|
2132
2461
|
return;
|
|
2133
2462
|
const multiple = rule.type === DataValidationType.LIST_MULTIPLE, list = validator.getListWithColor(rule, unitId, subUnitId), cellStr = localValue || getDataValidationCellValue(worksheet.getCellRaw(row, col)), value = deserializeListOptions(cellStr), handleEdit = /* @__PURE__ */ __name(() => {
|
|
@@ -2172,268 +2501,395 @@ function ListDropDown(props) {
|
|
|
2172
2501
|
}, "onChange"),
|
|
2173
2502
|
options,
|
|
2174
2503
|
onEdit: handleEdit,
|
|
2175
|
-
filter: editingText
|
|
2504
|
+
filter: editingText,
|
|
2505
|
+
location
|
|
2176
2506
|
}
|
|
2177
2507
|
);
|
|
2178
2508
|
}
|
|
2179
2509
|
__name(ListDropDown, "ListDropDown");
|
|
2180
|
-
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
|
|
2184
|
-
|
|
2185
|
-
|
|
2186
|
-
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
|
|
2190
|
-
|
|
2191
|
-
|
|
2192
|
-
|
|
2193
|
-
|
|
2194
|
-
|
|
2195
|
-
|
|
2196
|
-
|
|
2197
|
-
|
|
2198
|
-
|
|
2199
|
-
|
|
2200
|
-
|
|
2201
|
-
|
|
2202
|
-
|
|
2203
|
-
|
|
2204
|
-
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
|
|
2245
|
-
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
|
|
2510
|
+
const dataValidationOptionsButton = "univer-data-validation-options-button", dataValidationOptionsButtonIcon = "univer-data-validation-options-button-icon", styles$3 = {
|
|
2511
|
+
dataValidationOptionsButton,
|
|
2512
|
+
dataValidationOptionsButtonIcon
|
|
2513
|
+
};
|
|
2514
|
+
function DataValidationOptions(props) {
|
|
2515
|
+
var _a24;
|
|
2516
|
+
const localeService = useDependency(LocaleService), componentManager = useDependency(ComponentManager), { value, onChange, extraComponent } = props, [show, setShow] = useState(!1), ExtraOptions = extraComponent ? componentManager.get(extraComponent) : null;
|
|
2517
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
|
|
2518
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: styles$3.dataValidationOptionsButton, onClick: /* @__PURE__ */ __name(() => setShow(!show), "onClick"), children: [
|
|
2519
|
+
localeService.t("dataValidation.panel.options"),
|
|
2520
|
+
show ? /* @__PURE__ */ jsxRuntimeExports.jsx(MoreUpSingle, { className: styles$3.dataValidationOptionsButtonIcon }) : /* @__PURE__ */ jsxRuntimeExports.jsx(MoreDownSingle, { className: styles$3.dataValidationOptionsButtonIcon })
|
|
2521
|
+
] }),
|
|
2522
|
+
show && /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
|
|
2523
|
+
ExtraOptions ? /* @__PURE__ */ jsxRuntimeExports.jsx(ExtraOptions, { value, onChange }) : null,
|
|
2524
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
2525
|
+
FormLayout,
|
|
2526
|
+
{
|
|
2527
|
+
label: localeService.t("dataValidation.panel.invalid"),
|
|
2528
|
+
children: /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
2529
|
+
RadioGroup,
|
|
2530
|
+
{
|
|
2531
|
+
value: `${(_a24 = value.errorStyle) != null ? _a24 : DataValidationErrorStyle.WARNING}`,
|
|
2532
|
+
onChange: /* @__PURE__ */ __name((errorStyle) => onChange({ ...value, errorStyle: +errorStyle }), "onChange"),
|
|
2533
|
+
children: [
|
|
2534
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(Radio, { value: `${DataValidationErrorStyle.WARNING}`, children: localeService.t("dataValidation.panel.showWarning") }),
|
|
2535
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(Radio, { value: `${DataValidationErrorStyle.STOP}`, children: localeService.t("dataValidation.panel.rejectInput") })
|
|
2536
|
+
]
|
|
2537
|
+
}
|
|
2538
|
+
)
|
|
2539
|
+
}
|
|
2540
|
+
),
|
|
2541
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
2542
|
+
FormLayout,
|
|
2543
|
+
{
|
|
2544
|
+
label: localeService.t("dataValidation.panel.messageInfo"),
|
|
2545
|
+
children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
2546
|
+
Checkbox,
|
|
2547
|
+
{
|
|
2548
|
+
checked: value.showErrorMessage,
|
|
2549
|
+
onChange: /* @__PURE__ */ __name(() => onChange({
|
|
2550
|
+
...value,
|
|
2551
|
+
showErrorMessage: !value.showErrorMessage
|
|
2552
|
+
}), "onChange"),
|
|
2553
|
+
children: localeService.t("dataValidation.panel.showInfo")
|
|
2554
|
+
}
|
|
2555
|
+
)
|
|
2556
|
+
}
|
|
2557
|
+
),
|
|
2558
|
+
value.showErrorMessage ? /* @__PURE__ */ jsxRuntimeExports.jsx(FormLayout, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(Input, { value: value.error, onChange: /* @__PURE__ */ __name((error) => onChange({ ...value, error }), "onChange") }) }) : null
|
|
2559
|
+
] })
|
|
2560
|
+
] });
|
|
2561
|
+
}
|
|
2562
|
+
__name(DataValidationOptions, "DataValidationOptions");
|
|
2563
|
+
const dataValidationDetail = "univer-data-validation-detail", dataValidationDetailFormItem = "univer-data-validation-detail-form-item", dataValidationDetailButtons = "univer-data-validation-detail-buttons", dataValidationDetailButton = "univer-data-validation-detail-button", styles$2 = {
|
|
2564
|
+
dataValidationDetail,
|
|
2565
|
+
dataValidationDetailFormItem,
|
|
2566
|
+
dataValidationDetailButtons,
|
|
2567
|
+
dataValidationDetailButton
|
|
2568
|
+
}, debounceExecuteFactory = /* @__PURE__ */ __name((commandService) => debounce(
|
|
2569
|
+
async (id, params, options, callback) => {
|
|
2570
|
+
const res = await commandService.executeCommand(id, params, options);
|
|
2571
|
+
callback == null || callback(res);
|
|
2572
|
+
},
|
|
2573
|
+
1e3
|
|
2574
|
+
), "debounceExecuteFactory");
|
|
2575
|
+
function DataValidationDetail() {
|
|
2576
|
+
const [key, setKey] = useState(0), dataValidationPanelService = useDependency(DataValidationPanelService), activeRuleInfo = useObservable(dataValidationPanelService.activeRule$, dataValidationPanelService.activeRule), { unitId, subUnitId, rule } = activeRuleInfo || {}, ruleId = rule.uid, validatorService = useDependency(DataValidatorRegistryService), 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]);
|
|
2577
|
+
if (useEffect(() => {
|
|
2578
|
+
commandService.onCommandExecuted((commandInfo) => {
|
|
2579
|
+
(commandInfo.id === UndoCommand.id || commandInfo.id === RedoCommand.id) && setTimeout(() => {
|
|
2580
|
+
const activeRule = dataValidationModel.getRuleById(unitId, subUnitId, ruleId);
|
|
2581
|
+
setKey((k2) => k2 + 1), activeRule && (setLocalRule(activeRule), setLocalRanges(activeRule.ranges.map((i) => ({ unitId: "", sheetId: "", range: i }))));
|
|
2582
|
+
}, 20);
|
|
2583
|
+
});
|
|
2584
|
+
}, [commandService, dataValidationModel, ruleId, subUnitId, unitId]), !validator)
|
|
2585
|
+
return null;
|
|
2586
|
+
const operators = validator.operators, operatorNames = validator.operatorNames, isTwoFormula = localRule.operator ? TWO_FORMULA_OPERATOR_COUNT$1.includes(localRule.operator) : !1, handleOk = /* @__PURE__ */ __name(() => {
|
|
2587
|
+
localRule.ranges.length && (validator.validatorFormula(localRule, unitId, subUnitId).success ? dataValidationPanelService.setActiveRule(null) : setShowError(!0));
|
|
2588
|
+
}, "handleOk"), handleUpdateRuleRanges = useEvent((unitRanges) => {
|
|
2589
|
+
if (isUnitRangesEqual(unitRanges, localRanges))
|
|
2590
|
+
return;
|
|
2591
|
+
setLocalRanges(unitRanges);
|
|
2592
|
+
const ranges = unitRanges.filter((i) => (!i.unitId || i.unitId === unitId) && (!i.sheetId || i.sheetId === subUnitId)).map((i) => i.range);
|
|
2593
|
+
if (setLocalRule({
|
|
2594
|
+
...localRule,
|
|
2595
|
+
ranges
|
|
2596
|
+
}), ranges.length === 0)
|
|
2597
|
+
return;
|
|
2598
|
+
const params = {
|
|
2599
|
+
unitId,
|
|
2600
|
+
subUnitId,
|
|
2601
|
+
ruleId,
|
|
2602
|
+
ranges
|
|
2251
2603
|
};
|
|
2252
|
-
|
|
2253
|
-
})(
|
|
2254
|
-
|
|
2255
|
-
|
|
2256
|
-
|
|
2257
|
-
|
|
2258
|
-
|
|
2259
|
-
|
|
2260
|
-
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
|
|
2267
|
-
|
|
2604
|
+
debounceExecute(UpdateSheetDataValidationRangeCommand.id, params);
|
|
2605
|
+
}), handleUpdateRuleSetting = /* @__PURE__ */ __name((setting) => {
|
|
2606
|
+
if (shallowEqual(setting, getRuleSetting(localRule)))
|
|
2607
|
+
return;
|
|
2608
|
+
setLocalRule({
|
|
2609
|
+
...localRule,
|
|
2610
|
+
...setting
|
|
2611
|
+
});
|
|
2612
|
+
const params = {
|
|
2613
|
+
unitId,
|
|
2614
|
+
subUnitId,
|
|
2615
|
+
ruleId,
|
|
2616
|
+
setting
|
|
2617
|
+
};
|
|
2618
|
+
debounceExecute(
|
|
2619
|
+
UpdateSheetDataValidationSettingCommand.id,
|
|
2620
|
+
params,
|
|
2621
|
+
void 0
|
|
2622
|
+
);
|
|
2623
|
+
}, "handleUpdateRuleSetting"), handleDelete = /* @__PURE__ */ __name(async () => {
|
|
2624
|
+
await commandService.executeCommand(RemoveSheetDataValidationCommand.id, {
|
|
2625
|
+
ruleId,
|
|
2626
|
+
unitId,
|
|
2627
|
+
subUnitId
|
|
2628
|
+
}), dataValidationPanelService.setActiveRule(null);
|
|
2629
|
+
}, "handleDelete"), baseRule = {
|
|
2630
|
+
type: localRule.type,
|
|
2631
|
+
operator: localRule.operator,
|
|
2632
|
+
formula1: localRule.formula1,
|
|
2633
|
+
formula2: localRule.formula2,
|
|
2634
|
+
allowBlank: localRule.allowBlank
|
|
2635
|
+
}, handleChangeType = /* @__PURE__ */ __name((newType) => {
|
|
2636
|
+
const validator2 = validatorService.getValidatorItem(newType);
|
|
2637
|
+
if (!validator2)
|
|
2638
|
+
return;
|
|
2639
|
+
const operators2 = validator2.operators, rule2 = dataValidationModel.getRuleById(unitId, subUnitId, ruleId), newRule = newType === (rule2 == null ? void 0 : rule2.type) || newType.includes("list") && (rule2 != null && rule2.type.includes("list")) ? {
|
|
2640
|
+
...rule2,
|
|
2641
|
+
type: newType
|
|
2642
|
+
} : {
|
|
2643
|
+
...localRule,
|
|
2644
|
+
type: newType,
|
|
2645
|
+
operator: operators2[0],
|
|
2646
|
+
formula1: void 0,
|
|
2647
|
+
formula2: void 0
|
|
2648
|
+
};
|
|
2649
|
+
setLocalRule(newRule), commandService.executeCommand(UpdateSheetDataValidationSettingCommand.id, {
|
|
2650
|
+
unitId,
|
|
2651
|
+
subUnitId,
|
|
2652
|
+
ruleId: localRule.uid,
|
|
2653
|
+
setting: getRuleSetting(newRule)
|
|
2654
|
+
});
|
|
2655
|
+
}, "handleChangeType"), FormulaInput = componentManager.get(validator.formulaInput), rangeStr = useMemo(() => localRanges.map((i) => serializeRange(i.range)).join(","), []), options = getRuleOptions(localRule), handleUpdateRuleOptions = /* @__PURE__ */ __name((newOptions) => {
|
|
2656
|
+
shallowEqual(newOptions, getRuleOptions(localRule)) || (setLocalRule({
|
|
2657
|
+
...localRule,
|
|
2658
|
+
...newOptions
|
|
2659
|
+
}), debounceExecute(
|
|
2660
|
+
UpdateSheetDataValidationOptionsCommand.id,
|
|
2268
2661
|
{
|
|
2269
|
-
|
|
2270
|
-
|
|
2271
|
-
|
|
2272
|
-
|
|
2273
|
-
return next(Promise.resolve(cell));
|
|
2274
|
-
const validator = await this._dataValidatorRegistryService.getValidatorItem(rule.type);
|
|
2275
|
-
if (!validator || await validator.validator(
|
|
2276
|
-
{
|
|
2277
|
-
value: getCellValueOrigin(cell),
|
|
2278
|
-
interceptValue: getCellValueOrigin((_a23 = context == null ? void 0 : context.origin) != null ? _a23 : cell),
|
|
2279
|
-
row,
|
|
2280
|
-
column: col,
|
|
2281
|
-
unitId,
|
|
2282
|
-
subUnitId,
|
|
2283
|
-
worksheet,
|
|
2284
|
-
workbook,
|
|
2285
|
-
t: cell == null ? void 0 : cell.t
|
|
2286
|
-
},
|
|
2287
|
-
rule
|
|
2288
|
-
))
|
|
2289
|
-
return next(Promise.resolve(cell));
|
|
2290
|
-
const oldCell = worksheet.getCellRaw(row, col);
|
|
2291
|
-
return this._dialogService.open({
|
|
2292
|
-
width: 368,
|
|
2293
|
-
title: {
|
|
2294
|
-
title: this._localeService.t("dataValidation.alert.title")
|
|
2295
|
-
},
|
|
2296
|
-
id: "reject-input-dialog",
|
|
2297
|
-
children: {
|
|
2298
|
-
title: validator.getRuleFinalError(rule)
|
|
2299
|
-
},
|
|
2300
|
-
footer: {
|
|
2301
|
-
title: React.createElement(
|
|
2302
|
-
Button,
|
|
2303
|
-
{
|
|
2304
|
-
type: "primary",
|
|
2305
|
-
onClick: /* @__PURE__ */ __name(() => this._dialogService.close("reject-input-dialog"), "onClick")
|
|
2306
|
-
},
|
|
2307
|
-
this._localeService.t("dataValidation.alert.ok")
|
|
2308
|
-
)
|
|
2309
|
-
},
|
|
2310
|
-
onClose: /* @__PURE__ */ __name(() => {
|
|
2311
|
-
this._dialogService.close("reject-input-dialog");
|
|
2312
|
-
}, "onClose")
|
|
2313
|
-
}), next(Promise.resolve(oldCell));
|
|
2314
|
-
}, "handler")
|
|
2662
|
+
unitId,
|
|
2663
|
+
subUnitId,
|
|
2664
|
+
ruleId,
|
|
2665
|
+
options: newOptions
|
|
2315
2666
|
}
|
|
2316
|
-
);
|
|
2317
|
-
}
|
|
2318
|
-
|
|
2319
|
-
|
|
2320
|
-
|
|
2321
|
-
|
|
2322
|
-
|
|
2323
|
-
|
|
2324
|
-
|
|
2325
|
-
|
|
2326
|
-
title
|
|
2327
|
-
},
|
|
2328
|
-
footer: {
|
|
2329
|
-
title: React.createElement(
|
|
2330
|
-
Button,
|
|
2667
|
+
));
|
|
2668
|
+
}, "handleUpdateRuleOptions");
|
|
2669
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: styles$2.dataValidationDetail, children: [
|
|
2670
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
2671
|
+
FormLayout,
|
|
2672
|
+
{
|
|
2673
|
+
label: localeService.t("dataValidation.panel.range"),
|
|
2674
|
+
error: localRule.ranges.length ? "" : localeService.t("dataValidation.panel.rangeError"),
|
|
2675
|
+
children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
2676
|
+
RangeSelector,
|
|
2331
2677
|
{
|
|
2332
|
-
|
|
2333
|
-
|
|
2678
|
+
className: styles$2.dataValidationDetailFormItem,
|
|
2679
|
+
value: rangeStr,
|
|
2680
|
+
id: createInternalEditorID("data-validation-detail"),
|
|
2681
|
+
openForSheetUnitId: unitId,
|
|
2682
|
+
openForSheetSubUnitId: subUnitId,
|
|
2683
|
+
onChange: /* @__PURE__ */ __name((newRange) => {
|
|
2684
|
+
newRange.some((i) => !isValidRange(i.range) || i.range.endColumn < i.range.startColumn || i.range.endRow < i.range.startRow) || handleUpdateRuleRanges(newRange);
|
|
2685
|
+
}, "onChange")
|
|
2334
2686
|
},
|
|
2335
|
-
|
|
2687
|
+
key
|
|
2336
2688
|
)
|
|
2689
|
+
}
|
|
2690
|
+
),
|
|
2691
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(FormLayout, { label: localeService.t("dataValidation.panel.type"), children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
2692
|
+
Select,
|
|
2693
|
+
{
|
|
2694
|
+
options: validators == null ? void 0 : validators.map((validator2) => ({
|
|
2695
|
+
label: localeService.t(validator2.title),
|
|
2696
|
+
value: validator2.id
|
|
2697
|
+
})),
|
|
2698
|
+
value: localRule.type,
|
|
2699
|
+
onChange: handleChangeType,
|
|
2700
|
+
className: styles$2.dataValidationDetailFormItem
|
|
2701
|
+
}
|
|
2702
|
+
) }),
|
|
2703
|
+
operators != null && operators.length ? /* @__PURE__ */ jsxRuntimeExports.jsx(FormLayout, { label: localeService.t("dataValidation.panel.operator"), children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
2704
|
+
Select,
|
|
2705
|
+
{
|
|
2706
|
+
options: operators.map((op, i) => ({
|
|
2707
|
+
value: `${op}`,
|
|
2708
|
+
label: operatorNames[i]
|
|
2709
|
+
})),
|
|
2710
|
+
value: `${localRule.operator}`,
|
|
2711
|
+
onChange: /* @__PURE__ */ __name((operator) => {
|
|
2712
|
+
handleUpdateRuleSetting({
|
|
2713
|
+
...baseRule,
|
|
2714
|
+
operator
|
|
2715
|
+
});
|
|
2716
|
+
}, "onChange"),
|
|
2717
|
+
className: styles$2.dataValidationDetailFormItem
|
|
2718
|
+
}
|
|
2719
|
+
) }) : null,
|
|
2720
|
+
FormulaInput ? /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
2721
|
+
FormulaInput,
|
|
2722
|
+
{
|
|
2723
|
+
isTwoFormula,
|
|
2724
|
+
value: {
|
|
2725
|
+
formula1: localRule.formula1,
|
|
2726
|
+
formula2: localRule.formula2
|
|
2727
|
+
},
|
|
2728
|
+
onChange: /* @__PURE__ */ __name((value) => {
|
|
2729
|
+
handleUpdateRuleSetting({
|
|
2730
|
+
...baseRule,
|
|
2731
|
+
...value
|
|
2732
|
+
});
|
|
2733
|
+
}, "onChange"),
|
|
2734
|
+
showError,
|
|
2735
|
+
validResult: validator.validatorFormula(localRule, unitId, subUnitId),
|
|
2736
|
+
unitId,
|
|
2737
|
+
subUnitId,
|
|
2738
|
+
ruleId
|
|
2337
2739
|
},
|
|
2338
|
-
|
|
2339
|
-
|
|
2340
|
-
|
|
2740
|
+
key + localRule.type
|
|
2741
|
+
) : null,
|
|
2742
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(DataValidationOptions, { value: options, onChange: handleUpdateRuleOptions, extraComponent: validator.optionsInput }),
|
|
2743
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: styles$2.dataValidationDetailButtons, children: [
|
|
2744
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(Button, { className: styles$2.dataValidationDetailButton, onClick: handleDelete, children: localeService.t("dataValidation.panel.removeRule") }),
|
|
2745
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(Button, { className: styles$2.dataValidationDetailButton, type: "primary", onClick: handleOk, children: localeService.t("dataValidation.panel.done") })
|
|
2746
|
+
] })
|
|
2747
|
+
] });
|
|
2748
|
+
}
|
|
2749
|
+
__name(DataValidationDetail, "DataValidationDetail");
|
|
2750
|
+
const dataValidationItemContainer = "univer-data-validation-item-container", dataValidationItemTitle = "univer-data-validation-item-title", dataValidationItemContent = "univer-data-validation-item-content", dataValidationItemIcon = "univer-data-validation-item-icon", styles$1 = {
|
|
2751
|
+
dataValidationItemContainer,
|
|
2752
|
+
dataValidationItemTitle,
|
|
2753
|
+
dataValidationItemContent,
|
|
2754
|
+
dataValidationItemIcon
|
|
2755
|
+
}, DataValidationItem = /* @__PURE__ */ __name((props) => {
|
|
2756
|
+
const { rule, onClick, unitId, subUnitId, disable } = props, validatorRegistry = useDependency(DataValidatorRegistryService), commandService = useDependency(ICommandService), markSelectionService = useDependency(IMarkSelectionService), validator = validatorRegistry.getValidatorItem(rule.type), ids = useRef(), [isHover, setIsHover] = useState(!1), handleDelete = /* @__PURE__ */ __name((e) => {
|
|
2757
|
+
commandService.executeCommand(RemoveSheetDataValidationCommand.id, {
|
|
2758
|
+
ruleId: rule.uid,
|
|
2759
|
+
unitId,
|
|
2760
|
+
subUnitId
|
|
2761
|
+
}), e.stopPropagation();
|
|
2762
|
+
}, "handleDelete");
|
|
2763
|
+
return useEffect(() => () => {
|
|
2764
|
+
var _a24;
|
|
2765
|
+
ids.current && ((_a24 = ids.current) == null || _a24.forEach((id) => {
|
|
2766
|
+
id && markSelectionService.removeShape(id);
|
|
2767
|
+
}));
|
|
2768
|
+
}, [markSelectionService]), /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
2769
|
+
"div",
|
|
2770
|
+
{
|
|
2771
|
+
className: styles$1.dataValidationItemContainer,
|
|
2772
|
+
onClick,
|
|
2773
|
+
onMouseEnter: /* @__PURE__ */ __name(() => {
|
|
2774
|
+
disable || (setIsHover(!0), ids.current = rule.ranges.map((range) => markSelectionService.addShape({
|
|
2775
|
+
range,
|
|
2776
|
+
style: {
|
|
2777
|
+
hasAutoFill: !1,
|
|
2778
|
+
fill: "rgba(73, 184, 17, 0.05)",
|
|
2779
|
+
strokeWidth: 1,
|
|
2780
|
+
stroke: "#49B811",
|
|
2781
|
+
widgets: {}
|
|
2782
|
+
},
|
|
2783
|
+
primary: {
|
|
2784
|
+
startColumn: range.startColumn,
|
|
2785
|
+
endColumn: range.endColumn,
|
|
2786
|
+
startRow: range.startRow,
|
|
2787
|
+
endRow: range.endRow,
|
|
2788
|
+
actualRow: range.startRow,
|
|
2789
|
+
actualColumn: range.startColumn,
|
|
2790
|
+
isMerged: !1,
|
|
2791
|
+
isMergedMainCell: !1
|
|
2792
|
+
}
|
|
2793
|
+
})));
|
|
2794
|
+
}, "onMouseEnter"),
|
|
2795
|
+
onMouseLeave: /* @__PURE__ */ __name(() => {
|
|
2796
|
+
var _a24;
|
|
2797
|
+
setIsHover(!1), (_a24 = ids.current) == null || _a24.forEach((id) => {
|
|
2798
|
+
id && markSelectionService.removeShape(id);
|
|
2799
|
+
}), ids.current = void 0;
|
|
2800
|
+
}, "onMouseLeave"),
|
|
2801
|
+
children: [
|
|
2802
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: styles$1.dataValidationItemTitle, children: validator == null ? void 0 : validator.generateRuleName(rule) }),
|
|
2803
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: styles$1.dataValidationItemContent, children: rule.ranges.map((range) => serializeRange(range)).join(",") }),
|
|
2804
|
+
isHover ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: styles$1.dataValidationItemIcon, onClick: handleDelete, children: /* @__PURE__ */ jsxRuntimeExports.jsx(DeleteSingle, {}) }) : null
|
|
2805
|
+
]
|
|
2806
|
+
}
|
|
2807
|
+
);
|
|
2808
|
+
}, "DataValidationItem"), dataValidationList = "univer-data-validation-list", dataValidationListButtons = "univer-data-validation-list-buttons", dataValidationListButton = "univer-data-validation-list-button", styles = {
|
|
2809
|
+
dataValidationList,
|
|
2810
|
+
dataValidationListButtons,
|
|
2811
|
+
dataValidationListButton
|
|
2812
|
+
};
|
|
2813
|
+
function DataValidationList() {
|
|
2814
|
+
const univerInstanceService = useDependency(IUniverInstanceService), workbook = useObservable(
|
|
2815
|
+
() => univerInstanceService.getCurrentTypeOfUnit$(UniverInstanceType.UNIVER_SHEET),
|
|
2816
|
+
void 0,
|
|
2817
|
+
void 0,
|
|
2818
|
+
[]
|
|
2819
|
+
);
|
|
2820
|
+
return workbook ? /* @__PURE__ */ jsxRuntimeExports.jsx(DataValidationListWithWorkbook, { workbook }) : null;
|
|
2821
|
+
}
|
|
2822
|
+
__name(DataValidationList, "DataValidationList");
|
|
2823
|
+
function DataValidationListWithWorkbook(props) {
|
|
2824
|
+
const sheetDataValidationModel = useDependency(SheetDataValidationModel), univerInstanceService = useDependency(IUniverInstanceService), commandService = useDependency(ICommandService), injector = useDependency(Injector), dataValidationPanelService = useDependency(DataValidationPanelService), localeService = useDependency(LocaleService), [rules, setRules] = useState([]), { workbook } = props, worksheet = useObservable(workbook.activeSheet$, void 0, !0), unitId = workbook.getUnitId(), subUnitId = worksheet == null ? void 0 : worksheet.getSheetId();
|
|
2825
|
+
useEffect(() => {
|
|
2826
|
+
setRules(sheetDataValidationModel.getRules(unitId, subUnitId));
|
|
2827
|
+
const subscription = sheetDataValidationModel.ruleChange$.subscribe((change) => {
|
|
2828
|
+
change.unitId === unitId && change.subUnitId === subUnitId && setRules(sheetDataValidationModel.getRules(unitId, subUnitId));
|
|
2341
2829
|
});
|
|
2342
|
-
|
|
2343
|
-
|
|
2344
|
-
|
|
2345
|
-
|
|
2346
|
-
|
|
2347
|
-
|
|
2348
|
-
__decorateParam$d(2, Inject(DataValidatorRegistryService)),
|
|
2349
|
-
__decorateParam$d(3, IDialogService),
|
|
2350
|
-
__decorateParam$d(4, Inject(LocaleService))
|
|
2351
|
-
], DataValidationRejectInputController);
|
|
2352
|
-
const dvDateDropdown = "univer-dv-date-dropdown", dvDateDropdownBtns = "univer-dv-date-dropdown-btns", styles = {
|
|
2353
|
-
dvDateDropdown,
|
|
2354
|
-
dvDateDropdownBtns
|
|
2355
|
-
};
|
|
2356
|
-
dayjs.extend(utc);
|
|
2357
|
-
const transformDate = /* @__PURE__ */ __name((value) => {
|
|
2358
|
-
if (value == null || typeof value == "boolean")
|
|
2359
|
-
return;
|
|
2360
|
-
if (typeof value == "number" || !Number.isNaN(+value))
|
|
2361
|
-
return dayjs(numfmt.format("yyyy-MM-dd HH:mm:ss", Number(value)));
|
|
2362
|
-
const date = dayjs(value);
|
|
2363
|
-
if (date.isValid())
|
|
2364
|
-
return date;
|
|
2365
|
-
}, "transformDate");
|
|
2366
|
-
function DateDropdown(props) {
|
|
2367
|
-
var _a23, _b, _c;
|
|
2368
|
-
const { location, hideFn } = props, { worksheet, row, col, unitId, subUnitId, workbook } = location, commandService = useDependency(ICommandService), rejectInputController = useDependency(DataValidationRejectInputController), cellData = worksheet.getCell(row, col), rule = (_a23 = cellData == null ? void 0 : cellData.dataValidation) == null ? void 0 : _a23.rule, validator = (_b = cellData == null ? void 0 : cellData.dataValidation) == null ? void 0 : _b.validator, cellStr = getCellValueOrigin(worksheet.getCellRaw(row, col)), originDate = transformDate(cellStr), [localDate, setLocalDate] = useState(originDate), showTime = !!((_c = rule == null ? void 0 : rule.bizInfo) != null && _c.showTime), date = localDate && localDate.isValid() ? localDate : dayjs(), localeService = useDependency(LocaleService);
|
|
2369
|
-
if (!cellData || !rule || !validator)
|
|
2370
|
-
return;
|
|
2371
|
-
const handleSave = /* @__PURE__ */ __name(async () => {
|
|
2372
|
-
var _a24, _b2, _c2;
|
|
2373
|
-
if (!date)
|
|
2374
|
-
return;
|
|
2375
|
-
const dateStr = date.format(showTime ? "YYYY-MM-DD HH:mm:ss" : "YYYY-MM-DD 00:00:00"), serialTime = (_a24 = numfmt.parseDate(dateStr)) == null ? void 0 : _a24.v, cellStyle = workbook.getStyles().getStyleByCell(cellData), format = (_c2 = (_b2 = cellStyle == null ? void 0 : cellStyle.n) == null ? void 0 : _b2.pattern) != null ? _c2 : "", patternType = getPatternType(format);
|
|
2376
|
-
rule.errorStyle !== DataValidationErrorStyle.STOP || await validator.validator({
|
|
2377
|
-
value: serialTime,
|
|
2830
|
+
return () => {
|
|
2831
|
+
subscription.unsubscribe();
|
|
2832
|
+
};
|
|
2833
|
+
}, [unitId, subUnitId, sheetDataValidationModel]);
|
|
2834
|
+
const handleAddRule = /* @__PURE__ */ __name(async () => {
|
|
2835
|
+
const rule = createDefaultNewRule(injector), params = {
|
|
2378
2836
|
unitId,
|
|
2379
2837
|
subUnitId,
|
|
2380
|
-
|
|
2381
|
-
|
|
2382
|
-
|
|
2383
|
-
workbook,
|
|
2384
|
-
interceptValue: dateStr.replace("Z", "").replace("T", " "),
|
|
2385
|
-
t: CellValueType.NUMBER
|
|
2386
|
-
}, rule) ? (commandService.executeCommand(SetRangeValuesCommand.id, {
|
|
2838
|
+
rule
|
|
2839
|
+
};
|
|
2840
|
+
await commandService.executeCommand(AddSheetDataValidationCommand.id, params), dataValidationPanelService.setActiveRule({
|
|
2387
2841
|
unitId,
|
|
2388
2842
|
subUnitId,
|
|
2389
|
-
|
|
2390
|
-
|
|
2391
|
-
|
|
2392
|
-
|
|
2393
|
-
|
|
2394
|
-
|
|
2395
|
-
|
|
2396
|
-
|
|
2397
|
-
|
|
2398
|
-
|
|
2399
|
-
|
|
2400
|
-
|
|
2401
|
-
|
|
2402
|
-
|
|
2403
|
-
|
|
2404
|
-
|
|
2405
|
-
|
|
2406
|
-
|
|
2407
|
-
|
|
2408
|
-
|
|
2409
|
-
|
|
2410
|
-
|
|
2411
|
-
|
|
2412
|
-
|
|
2413
|
-
|
|
2414
|
-
|
|
2415
|
-
|
|
2416
|
-
|
|
2417
|
-
|
|
2418
|
-
|
|
2419
|
-
|
|
2420
|
-
|
|
2421
|
-
|
|
2422
|
-
|
|
2423
|
-
}
|
|
2424
|
-
)
|
|
2425
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: styles.dvDateDropdownBtns, children: /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { size: "small", type: "primary", onClick: handleSave, disabled: !date.isValid(), children: localeService.t("dataValidation.alert.ok") }) })
|
|
2843
|
+
rule
|
|
2844
|
+
});
|
|
2845
|
+
}, "handleAddRule"), handleRemoveAll = /* @__PURE__ */ __name(() => {
|
|
2846
|
+
commandService.executeCommand(RemoveSheetAllDataValidationCommand.id, {
|
|
2847
|
+
unitId,
|
|
2848
|
+
subUnitId
|
|
2849
|
+
});
|
|
2850
|
+
}, "handleRemoveAll"), rulesByPermissionCheck = (/* @__PURE__ */ __name((rules2) => {
|
|
2851
|
+
const workbook2 = univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET), worksheet2 = workbook2.getActiveSheet(), unitId2 = workbook2.getUnitId(), subUnitId2 = worksheet2.getSheetId();
|
|
2852
|
+
return rules2.map((rule) => checkRangesEditablePermission(injector, unitId2, subUnitId2, rule.ranges) ? { ...rule } : { ...rule, disable: !0 });
|
|
2853
|
+
}, "getDvRulesByPermissionCorrect"))(rules), hasDisableRule = rulesByPermissionCheck == null ? void 0 : rulesByPermissionCheck.some((rule) => rule.disable);
|
|
2854
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: styles.dataValidationList, children: [
|
|
2855
|
+
rulesByPermissionCheck == null ? void 0 : rulesByPermissionCheck.map((rule) => {
|
|
2856
|
+
var _a24;
|
|
2857
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
2858
|
+
DataValidationItem,
|
|
2859
|
+
{
|
|
2860
|
+
unitId,
|
|
2861
|
+
subUnitId,
|
|
2862
|
+
onClick: /* @__PURE__ */ __name(() => {
|
|
2863
|
+
rule.disable || dataValidationPanelService.setActiveRule({
|
|
2864
|
+
unitId,
|
|
2865
|
+
subUnitId,
|
|
2866
|
+
rule
|
|
2867
|
+
});
|
|
2868
|
+
}, "onClick"),
|
|
2869
|
+
rule,
|
|
2870
|
+
disable: (_a24 = rule.disable) != null ? _a24 : !1
|
|
2871
|
+
},
|
|
2872
|
+
rule.uid
|
|
2873
|
+
);
|
|
2874
|
+
}),
|
|
2875
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: styles.dataValidationListButtons, children: [
|
|
2876
|
+
rules.length && !hasDisableRule ? /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { className: styles.dataValidationListButton, onClick: handleRemoveAll, children: localeService.t("dataValidation.panel.removeAll") }) : null,
|
|
2877
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(Button, { className: styles.dataValidationListButton, type: "primary", onClick: handleAddRule, children: localeService.t("dataValidation.panel.add") })
|
|
2878
|
+
] })
|
|
2426
2879
|
] });
|
|
2427
2880
|
}
|
|
2428
|
-
__name(
|
|
2429
|
-
const
|
|
2881
|
+
__name(DataValidationListWithWorkbook, "DataValidationListWithWorkbook");
|
|
2882
|
+
const DataValidationPanel = /* @__PURE__ */ __name(() => {
|
|
2883
|
+
const dataValidationPanelService = useDependency(DataValidationPanelService), activeRule = useObservable(dataValidationPanelService.activeRule$, dataValidationPanelService.activeRule);
|
|
2884
|
+
return activeRule ? /* @__PURE__ */ jsxRuntimeExports.jsx(DataValidationDetail, {}, activeRule.rule.uid) : /* @__PURE__ */ jsxRuntimeExports.jsx(DataValidationList, {});
|
|
2885
|
+
}, "DataValidationPanel"), LIST_DROPDOWN_KEY = "data-validation.list.dropdown", DATE_DROPDOWN_KEY = "data-validation.date.dropdown", DATE_SHOW_TIME_OPTION = "DATE_SHOW_TIME_OPTION";
|
|
2430
2886
|
function DateShowTimeOption(props) {
|
|
2431
|
-
var
|
|
2887
|
+
var _a24;
|
|
2432
2888
|
const { value, onChange } = props, localeService = useDependency(LocaleService);
|
|
2433
2889
|
return /* @__PURE__ */ jsxRuntimeExports.jsx(FormLayout, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
2434
2890
|
Checkbox,
|
|
2435
2891
|
{
|
|
2436
|
-
checked: (
|
|
2892
|
+
checked: (_a24 = value.bizInfo) == null ? void 0 : _a24.showTime,
|
|
2437
2893
|
onChange: /* @__PURE__ */ __name((showTime) => {
|
|
2438
2894
|
onChange({
|
|
2439
2895
|
...value,
|
|
@@ -2450,12 +2906,12 @@ function DateShowTimeOption(props) {
|
|
|
2450
2906
|
__name(DateShowTimeOption, "DateShowTimeOption");
|
|
2451
2907
|
DateShowTimeOption.componentKey = DATE_SHOW_TIME_OPTION;
|
|
2452
2908
|
const FORMULA1$1 = "{FORMULA1}", FORMULA2$1 = "{FORMULA2}", transformDate2SerialNumber = /* @__PURE__ */ __name((value) => {
|
|
2453
|
-
var
|
|
2909
|
+
var _a24, _b;
|
|
2454
2910
|
if (value == null || typeof value == "boolean")
|
|
2455
2911
|
return;
|
|
2456
2912
|
if (typeof value == "number" || !Number.isNaN(+value))
|
|
2457
2913
|
return +value;
|
|
2458
|
-
const v = (
|
|
2914
|
+
const v = (_a24 = numfmt.parseDate(value)) == null ? void 0 : _a24.v;
|
|
2459
2915
|
return Tools.isDefine(v) ? v : (_b = numfmt.parseDate(dayjs(value).format("YYYY-MM-DD HH:mm:ss"))) == null ? void 0 : _b.v;
|
|
2460
2916
|
}, "transformDate2SerialNumber"), _DateValidator = class _DateValidator extends BaseDataValidator {
|
|
2461
2917
|
constructor() {
|
|
@@ -2478,28 +2934,181 @@ const FORMULA1$1 = "{FORMULA1}", FORMULA2$1 = "{FORMULA2}", transformDate2Serial
|
|
|
2478
2934
|
__publicField(this, "dropdown", DATE_DROPDOWN_KEY);
|
|
2479
2935
|
__publicField(this, "_formulaService", this.injector.get(DataValidationFormulaService));
|
|
2480
2936
|
}
|
|
2481
|
-
async parseFormula(rule, unitId, subUnitId) {
|
|
2482
|
-
var
|
|
2483
|
-
const results = await this._formulaService.getRuleFormulaResult(unitId, subUnitId, rule.uid), { formula1, formula2 } = rule;
|
|
2484
|
-
return {
|
|
2485
|
-
formula1: transformDate2SerialNumber(isFormulaString(formula1) ? getFormulaResult((
|
|
2486
|
-
formula2: transformDate2SerialNumber(isFormulaString(formula2) ? getFormulaResult((_b = results == null ? void 0 : results[1]) == null ? void 0 : _b.result) : formula2)
|
|
2487
|
-
};
|
|
2937
|
+
async parseFormula(rule, unitId, subUnitId) {
|
|
2938
|
+
var _a24, _b;
|
|
2939
|
+
const results = await this._formulaService.getRuleFormulaResult(unitId, subUnitId, rule.uid), { formula1, formula2 } = rule;
|
|
2940
|
+
return {
|
|
2941
|
+
formula1: transformDate2SerialNumber(isFormulaString(formula1) ? getFormulaResult((_a24 = results == null ? void 0 : results[0]) == null ? void 0 : _a24.result) : formula1),
|
|
2942
|
+
formula2: transformDate2SerialNumber(isFormulaString(formula2) ? getFormulaResult((_b = results == null ? void 0 : results[1]) == null ? void 0 : _b.result) : formula2)
|
|
2943
|
+
};
|
|
2944
|
+
}
|
|
2945
|
+
parseFormulaSync(rule, unitId, subUnitId) {
|
|
2946
|
+
var _a24, _b;
|
|
2947
|
+
const results = this._formulaService.getRuleFormulaResultSync(unitId, subUnitId, rule.uid), { formula1, formula2 } = rule;
|
|
2948
|
+
return {
|
|
2949
|
+
formula1: transformDate2SerialNumber(isFormulaString(formula1) ? getFormulaResult((_a24 = results == null ? void 0 : results[0]) == null ? void 0 : _a24.result) : formula1),
|
|
2950
|
+
formula2: transformDate2SerialNumber(isFormulaString(formula2) ? getFormulaResult((_b = results == null ? void 0 : results[1]) == null ? void 0 : _b.result) : formula2)
|
|
2951
|
+
};
|
|
2952
|
+
}
|
|
2953
|
+
async isValidType(info) {
|
|
2954
|
+
const { interceptValue, value } = info;
|
|
2955
|
+
return typeof value == "number" && typeof interceptValue == "string" ? !0 : typeof interceptValue == "string" ? !!numfmt.parseDate(interceptValue) : !1;
|
|
2956
|
+
}
|
|
2957
|
+
_validatorSingleFormula(formula) {
|
|
2958
|
+
return !Tools.isBlank(formula) && (isFormulaString(formula) || !Number.isNaN(+formula) || !!(formula && numfmt.parseDate(formula)));
|
|
2959
|
+
}
|
|
2960
|
+
validatorFormula(rule, unitId, subUnitId) {
|
|
2961
|
+
const operator = rule.operator;
|
|
2962
|
+
if (!operator)
|
|
2963
|
+
return {
|
|
2964
|
+
success: !1
|
|
2965
|
+
};
|
|
2966
|
+
const formula1Success = this._validatorSingleFormula(rule.formula1), errorMsg = this.localeService.t("dataValidation.validFail.date");
|
|
2967
|
+
if (TWO_FORMULA_OPERATOR_COUNT.includes(operator)) {
|
|
2968
|
+
const formula2Success = this._validatorSingleFormula(rule.formula2);
|
|
2969
|
+
return {
|
|
2970
|
+
success: formula1Success && formula2Success,
|
|
2971
|
+
formula1: formula1Success ? void 0 : errorMsg,
|
|
2972
|
+
formula2: formula2Success ? void 0 : errorMsg
|
|
2973
|
+
};
|
|
2974
|
+
}
|
|
2975
|
+
return {
|
|
2976
|
+
success: formula1Success,
|
|
2977
|
+
formula1: formula1Success ? void 0 : errorMsg
|
|
2978
|
+
};
|
|
2979
|
+
}
|
|
2980
|
+
normalizeFormula(rule, _unitId, _subUnitId) {
|
|
2981
|
+
const { formula1, formula2, bizInfo } = rule, normlizeSingleFormula = /* @__PURE__ */ __name((formula) => {
|
|
2982
|
+
var _a24;
|
|
2983
|
+
if (!formula)
|
|
2984
|
+
return formula;
|
|
2985
|
+
let date;
|
|
2986
|
+
if (!Number.isNaN(+formula))
|
|
2987
|
+
date = numfmt.dateFromSerial(+formula);
|
|
2988
|
+
else {
|
|
2989
|
+
const res = (_a24 = numfmt.parseDate(formula)) == null ? void 0 : _a24.v;
|
|
2990
|
+
if (res == null)
|
|
2991
|
+
return "";
|
|
2992
|
+
date = numfmt.dateFromSerial(res);
|
|
2993
|
+
}
|
|
2994
|
+
return dayjs(`${date[0]}/${date[1]}/${date[2]} ${date[3]}:${date[4]}:${date[5]}`).format(bizInfo != null && bizInfo.showTime ? "YYYY-MM-DD HH:mm:ss" : "YYYY-MM-DD");
|
|
2995
|
+
}, "normlizeSingleFormula");
|
|
2996
|
+
return {
|
|
2997
|
+
formula1: isFormulaString(formula1) ? formula1 : normlizeSingleFormula(`${formula1}`),
|
|
2998
|
+
formula2: isFormulaString(formula2) ? formula2 : normlizeSingleFormula(`${formula2}`)
|
|
2999
|
+
};
|
|
3000
|
+
}
|
|
3001
|
+
transform(cellInfo, _formula, _rule) {
|
|
3002
|
+
const { value } = cellInfo;
|
|
3003
|
+
return {
|
|
3004
|
+
...cellInfo,
|
|
3005
|
+
value: transformDate2SerialNumber(value)
|
|
3006
|
+
};
|
|
3007
|
+
}
|
|
3008
|
+
async validatorIsEqual(cellInfo, formula, rule) {
|
|
3009
|
+
const { formula1 } = formula, { value: cellValue } = cellInfo;
|
|
3010
|
+
return Number.isNaN(formula1) ? !0 : cellValue === formula1;
|
|
3011
|
+
}
|
|
3012
|
+
async validatorIsNotEqual(cellInfo, formula, _rule) {
|
|
3013
|
+
const { formula1 } = formula;
|
|
3014
|
+
return Number.isNaN(formula1) ? !0 : cellInfo.value !== formula1;
|
|
3015
|
+
}
|
|
3016
|
+
async validatorIsBetween(cellInfo, formula, _rule) {
|
|
3017
|
+
const { formula1, formula2 } = formula;
|
|
3018
|
+
if (Number.isNaN(formula1) || Number.isNaN(formula2))
|
|
3019
|
+
return !0;
|
|
3020
|
+
const start = Math.min(formula1, formula2), end = Math.max(formula1, formula2);
|
|
3021
|
+
return cellInfo.value >= start && cellInfo.value <= end;
|
|
3022
|
+
}
|
|
3023
|
+
async validatorIsNotBetween(cellInfo, formula, _rule) {
|
|
3024
|
+
const { formula1, formula2 } = formula;
|
|
3025
|
+
if (Number.isNaN(formula1) || Number.isNaN(formula2))
|
|
3026
|
+
return !0;
|
|
3027
|
+
const start = Math.min(formula1, formula2), end = Math.max(formula1, formula2);
|
|
3028
|
+
return cellInfo.value < start || cellInfo.value > end;
|
|
3029
|
+
}
|
|
3030
|
+
async validatorIsGreaterThan(cellInfo, formula, _rule) {
|
|
3031
|
+
const { formula1 } = formula;
|
|
3032
|
+
return Number.isNaN(formula1) ? !0 : cellInfo.value > formula1;
|
|
3033
|
+
}
|
|
3034
|
+
async validatorIsGreaterThanOrEqual(cellInfo, formula, _rule) {
|
|
3035
|
+
const { formula1 } = formula;
|
|
3036
|
+
return Number.isNaN(formula1) ? !0 : cellInfo.value >= formula1;
|
|
3037
|
+
}
|
|
3038
|
+
async validatorIsLessThan(cellInfo, formula, _rule) {
|
|
3039
|
+
const { formula1 } = formula;
|
|
3040
|
+
return Number.isNaN(formula1) ? !0 : cellInfo.value < formula1;
|
|
3041
|
+
}
|
|
3042
|
+
async validatorIsLessThanOrEqual(cellInfo, formula, _rule) {
|
|
3043
|
+
const { formula1 } = formula;
|
|
3044
|
+
return Number.isNaN(formula1) ? !0 : cellInfo.value <= formula1;
|
|
3045
|
+
}
|
|
3046
|
+
get operatorNames() {
|
|
3047
|
+
return this.operators.map((operator) => this.localeService.t(DateOperatorNameMap[operator]));
|
|
3048
|
+
}
|
|
3049
|
+
generateRuleName(rule) {
|
|
3050
|
+
var _a24, _b;
|
|
3051
|
+
if (!rule.operator)
|
|
3052
|
+
return this.titleStr;
|
|
3053
|
+
const ruleName = this.localeService.t(DateOperatorTitleMap[rule.operator]).replace(FORMULA1$1, (_a24 = rule.formula1) != null ? _a24 : "").replace(FORMULA2$1, (_b = rule.formula2) != null ? _b : "");
|
|
3054
|
+
return `${this.titleStr} ${ruleName}`;
|
|
3055
|
+
}
|
|
3056
|
+
generateRuleErrorMessage(rule) {
|
|
3057
|
+
var _a24, _b;
|
|
3058
|
+
return rule.operator ? `${this.localeService.t(DateOperatorErrorTitleMap[rule.operator]).replace(FORMULA1$1, (_a24 = rule.formula1) != null ? _a24 : "").replace(FORMULA2$1, (_b = rule.formula2) != null ? _b : "")}` : this.titleStr;
|
|
3059
|
+
}
|
|
3060
|
+
};
|
|
3061
|
+
__name(_DateValidator, "DateValidator");
|
|
3062
|
+
let DateValidator = _DateValidator;
|
|
3063
|
+
function getCellValueNumber(cellValue) {
|
|
3064
|
+
let str = cellValue;
|
|
3065
|
+
return typeof cellValue == "string" ? ((cellValue.startsWith("¥") || cellValue.startsWith("$")) && (str = cellValue.slice(1)), +str) : +cellValue;
|
|
3066
|
+
}
|
|
3067
|
+
__name(getCellValueNumber, "getCellValueNumber");
|
|
3068
|
+
const _DecimalValidator = class _DecimalValidator extends BaseDataValidator {
|
|
3069
|
+
constructor() {
|
|
3070
|
+
super(...arguments);
|
|
3071
|
+
__publicField(this, "_formulaService", this.injector.get(DataValidationFormulaService));
|
|
3072
|
+
__publicField(this, "id", DataValidationType.DECIMAL);
|
|
3073
|
+
__publicField(this, "title", "dataValidation.decimal.title");
|
|
3074
|
+
__publicField(this, "operators", [
|
|
3075
|
+
DataValidationOperator.BETWEEN,
|
|
3076
|
+
DataValidationOperator.EQUAL,
|
|
3077
|
+
DataValidationOperator.GREATER_THAN,
|
|
3078
|
+
DataValidationOperator.GREATER_THAN_OR_EQUAL,
|
|
3079
|
+
DataValidationOperator.LESS_THAN,
|
|
3080
|
+
DataValidationOperator.LESS_THAN_OR_EQUAL,
|
|
3081
|
+
DataValidationOperator.NOT_BETWEEN,
|
|
3082
|
+
DataValidationOperator.NOT_EQUAL
|
|
3083
|
+
]);
|
|
3084
|
+
__publicField(this, "scopes", ["sheet"]);
|
|
3085
|
+
__publicField(this, "formulaInput", BASE_FORMULA_INPUT_NAME);
|
|
3086
|
+
__publicField(this, "dropDownInput");
|
|
3087
|
+
}
|
|
3088
|
+
_isFormulaOrNumber(formula) {
|
|
3089
|
+
return !Tools.isBlank(formula) && (isFormulaString(formula) || !Number.isNaN(+formula));
|
|
3090
|
+
}
|
|
3091
|
+
async isValidType(cellInfo, formula, rule) {
|
|
3092
|
+
const { value: cellValue } = cellInfo;
|
|
3093
|
+
return !Number.isNaN(getCellValueNumber(cellValue));
|
|
2488
3094
|
}
|
|
2489
|
-
|
|
2490
|
-
|
|
2491
|
-
const results = this._formulaService.getRuleFormulaResultSync(unitId, subUnitId, rule.uid), { formula1, formula2 } = rule;
|
|
3095
|
+
transform(cellInfo, formula, rule) {
|
|
3096
|
+
const { value: cellValue } = cellInfo;
|
|
2492
3097
|
return {
|
|
2493
|
-
|
|
2494
|
-
|
|
3098
|
+
...cellInfo,
|
|
3099
|
+
value: getCellValueNumber(cellValue)
|
|
2495
3100
|
};
|
|
2496
3101
|
}
|
|
2497
|
-
|
|
2498
|
-
|
|
2499
|
-
return typeof value == "number" && typeof interceptValue == "string" ? !0 : typeof interceptValue == "string" ? !!numfmt.parseDate(interceptValue) : !1;
|
|
3102
|
+
_parseNumber(formula) {
|
|
3103
|
+
return formula == null ? Number.NaN : +formula;
|
|
2500
3104
|
}
|
|
2501
|
-
|
|
2502
|
-
|
|
3105
|
+
async parseFormula(rule, unitId, subUnitId) {
|
|
3106
|
+
var _a24, _b, _c, _d, _e, _f, _g, _h;
|
|
3107
|
+
const formulaInfo = await this._formulaService.getRuleFormulaResult(unitId, subUnitId, rule.uid), { formula1, formula2 } = rule;
|
|
3108
|
+
return {
|
|
3109
|
+
formula1: this._parseNumber(isFormulaString(formula1) ? (_d = (_c = (_b = (_a24 = formulaInfo == null ? void 0 : formulaInfo[0]) == null ? void 0 : _a24.result) == null ? void 0 : _b[0]) == null ? void 0 : _c[0]) == null ? void 0 : _d.v : formula1),
|
|
3110
|
+
formula2: this._parseNumber(isFormulaString(formula2) ? (_h = (_g = (_f = (_e = formulaInfo == null ? void 0 : formulaInfo[1]) == null ? void 0 : _e.result) == null ? void 0 : _f[0]) == null ? void 0 : _g[0]) == null ? void 0 : _h.v : formula2)
|
|
3111
|
+
};
|
|
2503
3112
|
}
|
|
2504
3113
|
validatorFormula(rule, unitId, subUnitId) {
|
|
2505
3114
|
const operator = rule.operator;
|
|
@@ -2507,46 +3116,14 @@ const FORMULA1$1 = "{FORMULA1}", FORMULA2$1 = "{FORMULA2}", transformDate2Serial
|
|
|
2507
3116
|
return {
|
|
2508
3117
|
success: !1
|
|
2509
3118
|
};
|
|
2510
|
-
const formula1Success = this.
|
|
2511
|
-
|
|
2512
|
-
|
|
2513
|
-
|
|
2514
|
-
|
|
2515
|
-
|
|
2516
|
-
formula2: formula2Success ? void 0 : errorMsg
|
|
2517
|
-
};
|
|
2518
|
-
}
|
|
2519
|
-
return {
|
|
3119
|
+
const formula1Success = Tools.isDefine(rule.formula1) && this._isFormulaOrNumber(rule.formula1), formula2Success = Tools.isDefine(rule.formula2) && this._isFormulaOrNumber(rule.formula2), isTwoFormula = TWO_FORMULA_OPERATOR_COUNT.includes(operator), errorMsg = this.localeService.t("dataValidation.validFail.number");
|
|
3120
|
+
return isTwoFormula ? {
|
|
3121
|
+
success: formula1Success && formula2Success,
|
|
3122
|
+
formula1: formula1Success ? void 0 : errorMsg,
|
|
3123
|
+
formula2: formula2Success ? void 0 : errorMsg
|
|
3124
|
+
} : {
|
|
2520
3125
|
success: formula1Success,
|
|
2521
|
-
formula1: formula1Success ?
|
|
2522
|
-
};
|
|
2523
|
-
}
|
|
2524
|
-
normalizeFormula(rule, _unitId, _subUnitId) {
|
|
2525
|
-
const { formula1, formula2, bizInfo } = rule, normlizeSingleFormula = /* @__PURE__ */ __name((formula) => {
|
|
2526
|
-
var _a23;
|
|
2527
|
-
if (!formula)
|
|
2528
|
-
return formula;
|
|
2529
|
-
let date;
|
|
2530
|
-
if (!Number.isNaN(+formula))
|
|
2531
|
-
date = numfmt.dateFromSerial(+formula);
|
|
2532
|
-
else {
|
|
2533
|
-
const res = (_a23 = numfmt.parseDate(formula)) == null ? void 0 : _a23.v;
|
|
2534
|
-
if (res == null)
|
|
2535
|
-
return "";
|
|
2536
|
-
date = numfmt.dateFromSerial(res);
|
|
2537
|
-
}
|
|
2538
|
-
return dayjs(`${date[0]}/${date[1]}/${date[2]} ${date[3]}:${date[4]}:${date[5]}`).format(bizInfo != null && bizInfo.showTime ? "YYYY-MM-DD HH:mm:ss" : "YYYY-MM-DD");
|
|
2539
|
-
}, "normlizeSingleFormula");
|
|
2540
|
-
return {
|
|
2541
|
-
formula1: isFormulaString(formula1) ? formula1 : normlizeSingleFormula(`${formula1}`),
|
|
2542
|
-
formula2: isFormulaString(formula2) ? formula2 : normlizeSingleFormula(`${formula2}`)
|
|
2543
|
-
};
|
|
2544
|
-
}
|
|
2545
|
-
transform(cellInfo, _formula, _rule) {
|
|
2546
|
-
const { value } = cellInfo;
|
|
2547
|
-
return {
|
|
2548
|
-
...cellInfo,
|
|
2549
|
-
value: transformDate2SerialNumber(value)
|
|
3126
|
+
formula1: formula1Success ? "" : errorMsg
|
|
2550
3127
|
};
|
|
2551
3128
|
}
|
|
2552
3129
|
async validatorIsEqual(cellInfo, formula, rule) {
|
|
@@ -2587,23 +3164,21 @@ const FORMULA1$1 = "{FORMULA1}", FORMULA2$1 = "{FORMULA2}", transformDate2Serial
|
|
|
2587
3164
|
const { formula1 } = formula;
|
|
2588
3165
|
return Number.isNaN(formula1) ? !0 : cellInfo.value <= formula1;
|
|
2589
3166
|
}
|
|
2590
|
-
get operatorNames() {
|
|
2591
|
-
return this.operators.map((operator) => this.localeService.t(DateOperatorNameMap[operator]));
|
|
2592
|
-
}
|
|
2593
|
-
generateRuleName(rule) {
|
|
2594
|
-
var _a23, _b;
|
|
2595
|
-
if (!rule.operator)
|
|
2596
|
-
return this.titleStr;
|
|
2597
|
-
const ruleName = this.localeService.t(DateOperatorTitleMap[rule.operator]).replace(FORMULA1$1, (_a23 = rule.formula1) != null ? _a23 : "").replace(FORMULA2$1, (_b = rule.formula2) != null ? _b : "");
|
|
2598
|
-
return `${this.titleStr} ${ruleName}`;
|
|
2599
|
-
}
|
|
2600
|
-
generateRuleErrorMessage(rule) {
|
|
2601
|
-
var _a23, _b;
|
|
2602
|
-
return rule.operator ? `${this.localeService.t(DateOperatorErrorTitleMap[rule.operator]).replace(FORMULA1$1, (_a23 = rule.formula1) != null ? _a23 : "").replace(FORMULA2$1, (_b = rule.formula2) != null ? _b : "")}` : this.titleStr;
|
|
2603
|
-
}
|
|
2604
3167
|
};
|
|
2605
|
-
__name(
|
|
2606
|
-
let
|
|
3168
|
+
__name(_DecimalValidator, "DecimalValidator");
|
|
3169
|
+
let DecimalValidator = _DecimalValidator;
|
|
3170
|
+
const LIST_RENDER_MODE_OPTION_INPUT = "LIST_RENDER_MODE_OPTION_INPUT";
|
|
3171
|
+
function ListRenderModeInput(props) {
|
|
3172
|
+
var _a24;
|
|
3173
|
+
const { value, onChange } = props, localeService = useDependency(LocaleService);
|
|
3174
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(FormLayout, { label: localeService.t("dataValidation.renderMode.label"), children: /* @__PURE__ */ jsxRuntimeExports.jsxs(RadioGroup, { value: `${(_a24 = value.renderMode) != null ? _a24 : DataValidationRenderMode.CUSTOM}`, onChange: /* @__PURE__ */ __name((renderMode) => onChange({ ...value, renderMode: +renderMode }), "onChange"), children: [
|
|
3175
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(Radio, { value: `${DataValidationRenderMode.CUSTOM}`, children: localeService.t("dataValidation.renderMode.chip") }),
|
|
3176
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(Radio, { value: `${DataValidationRenderMode.ARROW}`, children: localeService.t("dataValidation.renderMode.arrow") }),
|
|
3177
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(Radio, { value: `${DataValidationRenderMode.TEXT}`, children: localeService.t("dataValidation.renderMode.text") })
|
|
3178
|
+
] }) });
|
|
3179
|
+
}
|
|
3180
|
+
__name(ListRenderModeInput, "ListRenderModeInput");
|
|
3181
|
+
ListRenderModeInput.componentKey = LIST_RENDER_MODE_OPTION_INPUT;
|
|
2607
3182
|
var __defProp$c = Object.defineProperty, __getOwnPropDesc$c = Object.getOwnPropertyDescriptor, __decorateClass$c = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
2608
3183
|
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$c(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
2609
3184
|
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
@@ -2682,10 +3257,10 @@ function calcPadding(cellWidth, cellHeight, fontWidth, fontHeight, vt, ht, margi
|
|
|
2682
3257
|
const realMargin = margin ? MARGIN_V$1 : 0;
|
|
2683
3258
|
switch (vt) {
|
|
2684
3259
|
case VerticalAlign.BOTTOM:
|
|
2685
|
-
paddingTop = cellHeight -
|
|
3260
|
+
paddingTop = cellHeight - fontHeight - realMargin;
|
|
2686
3261
|
break;
|
|
2687
3262
|
case VerticalAlign.MIDDLE:
|
|
2688
|
-
paddingTop = (cellHeight -
|
|
3263
|
+
paddingTop = (cellHeight - fontHeight) / 2;
|
|
2689
3264
|
break;
|
|
2690
3265
|
default:
|
|
2691
3266
|
paddingTop = realMargin;
|
|
@@ -2707,8 +3282,8 @@ function calcPadding(cellWidth, cellHeight, fontWidth, fontHeight, vt, ht, margi
|
|
|
2707
3282
|
};
|
|
2708
3283
|
}
|
|
2709
3284
|
__name(calcPadding, "calcPadding");
|
|
2710
|
-
var
|
|
2711
|
-
let DropdownWidget = (
|
|
3285
|
+
var _a10;
|
|
3286
|
+
let DropdownWidget = (_a10 = class {
|
|
2712
3287
|
constructor(_localeService, _commandService) {
|
|
2713
3288
|
__publicField(this, "_dropdownInfoMap", /* @__PURE__ */ new Map());
|
|
2714
3289
|
__publicField(this, "zIndex");
|
|
@@ -2731,18 +3306,18 @@ let DropdownWidget = (_a9 = class {
|
|
|
2731
3306
|
top = (cellHeight - ICON_SIZE) / 2;
|
|
2732
3307
|
break;
|
|
2733
3308
|
case VerticalAlign.BOTTOM:
|
|
2734
|
-
top = cellHeight -
|
|
3309
|
+
top = cellHeight - b - fontHeight - MARGIN_V$1 + (fontHeight / 2 - ICON_SIZE / 2);
|
|
2735
3310
|
break;
|
|
2736
3311
|
default:
|
|
2737
|
-
top = t + fontHeight / 2 - ICON_SIZE / 2;
|
|
3312
|
+
top = t + MARGIN_V$1 + (fontHeight / 2 - ICON_SIZE / 2);
|
|
2738
3313
|
break;
|
|
2739
3314
|
}
|
|
2740
3315
|
ctx.save(), ctx.translateWithPrecision(cellBounding.startX + left, cellBounding.startY + top), ctx.fillStyle = "#565656", ctx.fill(downPath$1), ctx.restore();
|
|
2741
3316
|
}
|
|
2742
3317
|
// eslint-disable-next-line max-lines-per-function, complexity
|
|
2743
3318
|
drawWith(ctx, info, skeleton) {
|
|
2744
|
-
var
|
|
2745
|
-
const { primaryWithCoord, row, col, style, data, subUnitId } = info, _cellBounding = primaryWithCoord.isMergedMainCell ? primaryWithCoord.mergeInfo : primaryWithCoord, rule = (
|
|
3319
|
+
var _a24, _b;
|
|
3320
|
+
const { primaryWithCoord, row, col, style, data, subUnitId } = info, _cellBounding = primaryWithCoord.isMergedMainCell ? primaryWithCoord.mergeInfo : primaryWithCoord, rule = (_a24 = data.dataValidation) == null ? void 0 : _a24.rule, validator = (_b = data.dataValidation) == null ? void 0 : _b.validator, fontRenderExtension = data.fontRenderExtension, { leftOffset = 0, rightOffset = 0, topOffset = 0, downOffset = 0 } = fontRenderExtension || {};
|
|
2746
3321
|
if (!rule || !validator || !validator || validator.id.indexOf(DataValidationType.LIST) !== 0 || !validator.skipDefaultFontRender(rule))
|
|
2747
3322
|
return;
|
|
2748
3323
|
const cellBounding = {
|
|
@@ -2755,7 +3330,7 @@ let DropdownWidget = (_a9 = class {
|
|
|
2755
3330
|
if (tb = tb != null ? tb : WrapStrategy.WRAP, vt = vt != null ? vt : VerticalAlign.BOTTOM, ht = ht != null ? ht : DEFAULT_STYLES.ht, pd = pd != null ? pd : DEFAULT_STYLES.pd, rule.renderMode === DataValidationRenderMode.ARROW) {
|
|
2756
3331
|
const { l: l2 = DEFAULT_STYLES.pd.l, t = DEFAULT_STYLES.pd.t, r = DEFAULT_STYLES.pd.r, b = DEFAULT_STYLES.pd.b } = pd, realWidth = cellWidth - l2 - r - ICON_PLACE$1, { documentSkeleton, documents, docModel } = createDocuments(valueStr, this._localeService, style);
|
|
2757
3332
|
tb === WrapStrategy.WRAP && docModel.updateDocumentDataPageSize(Math.max(realWidth, 1)), documentSkeleton.calculate(), documentSkeleton.getActualSize();
|
|
2758
|
-
const textLayout = getDocsSkeletonPageSize(documentSkeleton), { height: fontHeight, width: fontWidth } = textLayout, { paddingTop, paddingLeft } = calcPadding(realWidth, cellHeight - t - b, fontWidth, fontHeight, vt, ht, !
|
|
3333
|
+
const textLayout = getDocsSkeletonPageSize(documentSkeleton), { height: fontHeight, width: fontWidth } = textLayout, { paddingTop, paddingLeft } = calcPadding(realWidth, cellHeight - t - b, fontWidth, fontHeight, vt, ht, !0);
|
|
2759
3334
|
this._drawDownIcon(ctx, cellBounding, cellWidth, cellHeight, fontHeight, vt, pd), ctx.save(), ctx.translateWithPrecision(cellBounding.startX + l2, cellBounding.startY + t), ctx.beginPath(), ctx.rect(0, 0, cellWidth - l2 - r, cellHeight - t - b), ctx.clip(), ctx.translateWithPrecision(0, paddingTop), ctx.save(), ctx.translateWithPrecision(PADDING_H$1, 0), ctx.beginPath(), ctx.rect(0, 0, realWidth, fontHeight), ctx.clip(), documents.render(ctx), ctx.translateWithPrecision(paddingLeft, 0), ctx.restore(), ctx.restore(), map.set(key, {
|
|
2760
3335
|
left: cellBounding.endX + l2 + skeleton.rowHeaderWidth - ICON_PLACE$1,
|
|
2761
3336
|
top: cellBounding.startY + t + skeleton.columnHeaderHeight,
|
|
@@ -2783,8 +3358,8 @@ let DropdownWidget = (_a9 = class {
|
|
|
2783
3358
|
}
|
|
2784
3359
|
}
|
|
2785
3360
|
calcCellAutoHeight(info) {
|
|
2786
|
-
var
|
|
2787
|
-
const { primaryWithCoord, style, data } = info, _cellBounding = primaryWithCoord.isMergedMainCell ? primaryWithCoord.mergeInfo : primaryWithCoord, fontRenderExtension = data.fontRenderExtension, { leftOffset = 0, rightOffset = 0, topOffset = 0, downOffset = 0 } = fontRenderExtension || {}, rule = (
|
|
3361
|
+
var _a24;
|
|
3362
|
+
const { primaryWithCoord, style, data } = info, _cellBounding = primaryWithCoord.isMergedMainCell ? primaryWithCoord.mergeInfo : primaryWithCoord, fontRenderExtension = data.fontRenderExtension, { leftOffset = 0, rightOffset = 0, topOffset = 0, downOffset = 0 } = fontRenderExtension || {}, rule = (_a24 = data.dataValidation) == null ? void 0 : _a24.rule;
|
|
2788
3363
|
if (!rule || rule.renderMode === DataValidationRenderMode.TEXT)
|
|
2789
3364
|
return;
|
|
2790
3365
|
const cellBounding = {
|
|
@@ -2799,7 +3374,7 @@ let DropdownWidget = (_a9 = class {
|
|
|
2799
3374
|
const realWidth = cellWidth - ICON_PLACE$1, { documentSkeleton, docModel } = createDocuments(valueStr, this._localeService, style);
|
|
2800
3375
|
tb === WrapStrategy.WRAP && docModel.updateDocumentDataPageSize(Math.max(realWidth, 1)), documentSkeleton.calculate(), documentSkeleton.getActualSize();
|
|
2801
3376
|
const textLayout = getDocsSkeletonPageSize(documentSkeleton), { height: fontHeight } = textLayout;
|
|
2802
|
-
return fontHeight + t + b;
|
|
3377
|
+
return fontHeight + t + b + MARGIN_V$1 * 2;
|
|
2803
3378
|
} else {
|
|
2804
3379
|
const realWidth = cellWidth - MARGIN_H$1 * 2 - PADDING_H$1 - ICON_PLACE$1, { documentSkeleton, docModel } = createDocSkeleton(valueStr, this._localeService, style);
|
|
2805
3380
|
tb === WrapStrategy.WRAP && docModel.updateDocumentDataPageSize(Math.max(realWidth, 1)), documentSkeleton.calculate();
|
|
@@ -2827,23 +3402,11 @@ let DropdownWidget = (_a9 = class {
|
|
|
2827
3402
|
};
|
|
2828
3403
|
this._commandService.executeCommand(ShowDataValidationDropdown.id, params);
|
|
2829
3404
|
}
|
|
2830
|
-
}, __name(
|
|
3405
|
+
}, __name(_a10, "DropdownWidget"), _a10);
|
|
2831
3406
|
DropdownWidget = __decorateClass$c([
|
|
2832
3407
|
__decorateParam$c(0, Inject(LocaleService)),
|
|
2833
3408
|
__decorateParam$c(1, ICommandService)
|
|
2834
3409
|
], DropdownWidget);
|
|
2835
|
-
const LIST_RENDER_MODE_OPTION_INPUT = "LIST_RENDER_MODE_OPTION_INPUT";
|
|
2836
|
-
function ListRenderModeInput(props) {
|
|
2837
|
-
var _a23;
|
|
2838
|
-
const { value, onChange } = props, localeService = useDependency(LocaleService);
|
|
2839
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsx(FormLayout, { label: localeService.t("dataValidation.renderMode.label"), children: /* @__PURE__ */ jsxRuntimeExports.jsxs(RadioGroup, { value: `${(_a23 = value.renderMode) != null ? _a23 : DataValidationRenderMode.CUSTOM}`, onChange: /* @__PURE__ */ __name((renderMode) => onChange({ ...value, renderMode: +renderMode }), "onChange"), children: [
|
|
2840
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(Radio, { value: `${DataValidationRenderMode.CUSTOM}`, children: localeService.t("dataValidation.renderMode.chip") }),
|
|
2841
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(Radio, { value: `${DataValidationRenderMode.ARROW}`, children: localeService.t("dataValidation.renderMode.arrow") }),
|
|
2842
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(Radio, { value: `${DataValidationRenderMode.TEXT}`, children: localeService.t("dataValidation.renderMode.text") })
|
|
2843
|
-
] }) });
|
|
2844
|
-
}
|
|
2845
|
-
__name(ListRenderModeInput, "ListRenderModeInput");
|
|
2846
|
-
ListRenderModeInput.componentKey = LIST_RENDER_MODE_OPTION_INPUT;
|
|
2847
3410
|
function getRuleFormulaResultSet(result) {
|
|
2848
3411
|
if (!result)
|
|
2849
3412
|
return [];
|
|
@@ -2851,11 +3414,11 @@ function getRuleFormulaResultSet(result) {
|
|
|
2851
3414
|
return result.forEach(
|
|
2852
3415
|
(row) => {
|
|
2853
3416
|
row.forEach((cell) => {
|
|
2854
|
-
var
|
|
3417
|
+
var _a24, _b;
|
|
2855
3418
|
const value = getCellValueOrigin(cell);
|
|
2856
3419
|
if (value != null) {
|
|
2857
|
-
if (typeof value != "string" && typeof (cell == null ? void 0 : cell.s) == "object" && ((_b = (
|
|
2858
|
-
resultSet.add(numfmt.format(cell.s.n.pattern, value));
|
|
3420
|
+
if (typeof value != "string" && typeof (cell == null ? void 0 : cell.s) == "object" && ((_b = (_a24 = cell.s) == null ? void 0 : _a24.n) != null && _b.pattern)) {
|
|
3421
|
+
resultSet.add(numfmt.format(cell.s.n.pattern, value, { throws: !1 }));
|
|
2859
3422
|
return;
|
|
2860
3423
|
}
|
|
2861
3424
|
resultSet.add(value.toString());
|
|
@@ -2902,27 +3465,42 @@ const _ListValidator = class _ListValidator extends BaseDataValidator {
|
|
|
2902
3465
|
__publicField(this, "canvasRender", this.injector.createInstance(DropdownWidget));
|
|
2903
3466
|
__publicField(this, "dropdown", LIST_DROPDOWN_KEY);
|
|
2904
3467
|
__publicField(this, "optionsInput", ListRenderModeInput.componentKey);
|
|
2905
|
-
|
|
2906
|
-
skipDefaultFontRender(rule) {
|
|
2907
|
-
return rule.renderMode !== DataValidationRenderMode.TEXT;
|
|
3468
|
+
__publicField(this, "skipDefaultFontRender", /* @__PURE__ */ __name((rule) => rule.renderMode !== DataValidationRenderMode.TEXT, "skipDefaultFontRender"));
|
|
2908
3469
|
}
|
|
2909
3470
|
validatorFormula(rule, unitId, subUnitId) {
|
|
2910
|
-
var
|
|
2911
|
-
const success = !Tools.isBlank(rule.formula1), valid = isValidListFormula((
|
|
3471
|
+
var _a24, _b, _c;
|
|
3472
|
+
const success = !Tools.isBlank(rule.formula1), valid = isValidListFormula((_a24 = rule.formula1) != null ? _a24 : "", this._lexer), sheetName = (_c = (_b = this._univerInstanceService.getUnit(unitId, UniverInstanceType.UNIVER_SHEET)) == null ? void 0 : _b.getSheetBySheetId(subUnitId)) == null ? void 0 : _c.getName(), isIntersects = isRuleIntersects(rule, sheetName != null ? sheetName : "");
|
|
2912
3473
|
return {
|
|
2913
3474
|
success: !!(success && valid && !isIntersects),
|
|
2914
3475
|
formula1: success ? valid ? isIntersects ? this.localeService.t("dataValidation.validFail.listIntersects") : void 0 : this.localeService.t("dataValidation.validFail.listInvalid") : this.localeService.t("dataValidation.validFail.list")
|
|
2915
3476
|
};
|
|
2916
3477
|
}
|
|
3478
|
+
getExtraStyle(rule, value, { style: defaultStyle }) {
|
|
3479
|
+
var _a24;
|
|
3480
|
+
const tb = (_a24 = defaultStyle.tb !== WrapStrategy.OVERFLOW ? defaultStyle.tb : WrapStrategy.CLIP) != null ? _a24 : WrapStrategy.WRAP;
|
|
3481
|
+
if (rule.type === DataValidationType.LIST && (rule.renderMode === DataValidationRenderMode.ARROW || rule.renderMode === DataValidationRenderMode.TEXT)) {
|
|
3482
|
+
const colorMap = this.getListWithColorMap(rule), valueStr = `${value != null ? value : ""}`, color = colorMap[valueStr];
|
|
3483
|
+
if (color)
|
|
3484
|
+
return {
|
|
3485
|
+
bg: {
|
|
3486
|
+
rgb: color
|
|
3487
|
+
},
|
|
3488
|
+
tb
|
|
3489
|
+
};
|
|
3490
|
+
}
|
|
3491
|
+
return {
|
|
3492
|
+
tb
|
|
3493
|
+
};
|
|
3494
|
+
}
|
|
2917
3495
|
parseCellValue(cellValue) {
|
|
2918
3496
|
const cellString = cellValue.toString();
|
|
2919
3497
|
return deserializeListOptions(cellString);
|
|
2920
3498
|
}
|
|
2921
3499
|
async parseFormula(rule, unitId, subUnitId) {
|
|
2922
|
-
var
|
|
3500
|
+
var _a24;
|
|
2923
3501
|
const { formula1 = "" } = rule, results = await this.formulaService.getRuleFormulaResult(unitId, subUnitId, rule.uid);
|
|
2924
3502
|
return {
|
|
2925
|
-
formula1: isFormulaString(formula1) ? getRuleFormulaResultSet((
|
|
3503
|
+
formula1: isFormulaString(formula1) ? getRuleFormulaResultSet((_a24 = results == null ? void 0 : results[0]) == null ? void 0 : _a24.result) : deserializeListOptions(formula1),
|
|
2926
3504
|
formula2: void 0
|
|
2927
3505
|
};
|
|
2928
3506
|
}
|
|
@@ -2937,8 +3515,8 @@ const _ListValidator = class _ListValidator extends BaseDataValidator {
|
|
|
2937
3515
|
return this.localeService.t("dataValidation.list.error");
|
|
2938
3516
|
}
|
|
2939
3517
|
getList(rule, currentUnitId, currentSubUnitId) {
|
|
2940
|
-
var
|
|
2941
|
-
const { formula1 = "" } = rule, univerInstanceService = this.injector.get(IUniverInstanceService), workbook = (
|
|
3518
|
+
var _a24, _b, _c;
|
|
3519
|
+
const { formula1 = "" } = rule, univerInstanceService = this.injector.get(IUniverInstanceService), workbook = (_a24 = currentUnitId ? univerInstanceService.getUniverSheetInstance(currentUnitId) : void 0) != null ? _a24 : univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET);
|
|
2942
3520
|
if (!workbook) return [];
|
|
2943
3521
|
const worksheet = (_b = currentSubUnitId ? workbook.getSheetBySheetId(currentSubUnitId) : void 0) != null ? _b : workbook.getActiveSheet();
|
|
2944
3522
|
if (!worksheet) return [];
|
|
@@ -2946,8 +3524,8 @@ const _ListValidator = class _ListValidator extends BaseDataValidator {
|
|
|
2946
3524
|
return isFormulaString(formula1) ? getRuleFormulaResultSet((_c = results == null ? void 0 : results[0]) == null ? void 0 : _c.result) : deserializeListOptions(formula1);
|
|
2947
3525
|
}
|
|
2948
3526
|
async getListAsync(rule, currentUnitId, currentSubUnitId) {
|
|
2949
|
-
var
|
|
2950
|
-
const { formula1 = "" } = rule, univerInstanceService = this.injector.get(IUniverInstanceService), workbook = (
|
|
3527
|
+
var _a24, _b, _c;
|
|
3528
|
+
const { formula1 = "" } = rule, univerInstanceService = this.injector.get(IUniverInstanceService), workbook = (_a24 = currentUnitId ? univerInstanceService.getUniverSheetInstance(currentUnitId) : void 0) != null ? _a24 : univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET);
|
|
2951
3529
|
if (!workbook) return [];
|
|
2952
3530
|
const worksheet = (_b = currentSubUnitId ? workbook.getSheetBySheetId(currentSubUnitId) : void 0) != null ? _b : workbook.getActiveSheet();
|
|
2953
3531
|
if (!worksheet) return [];
|
|
@@ -2967,113 +3545,6 @@ const _ListValidator = class _ListValidator extends BaseDataValidator {
|
|
|
2967
3545
|
};
|
|
2968
3546
|
__name(_ListValidator, "ListValidator");
|
|
2969
3547
|
let ListValidator = _ListValidator;
|
|
2970
|
-
function getCellValueNumber(cellValue) {
|
|
2971
|
-
let str = cellValue;
|
|
2972
|
-
return typeof cellValue == "string" ? ((cellValue.startsWith("¥") || cellValue.startsWith("$")) && (str = cellValue.slice(1)), +str) : +cellValue;
|
|
2973
|
-
}
|
|
2974
|
-
__name(getCellValueNumber, "getCellValueNumber");
|
|
2975
|
-
const _DecimalValidator = class _DecimalValidator extends BaseDataValidator {
|
|
2976
|
-
constructor() {
|
|
2977
|
-
super(...arguments);
|
|
2978
|
-
__publicField(this, "_formulaService", this.injector.get(DataValidationFormulaService));
|
|
2979
|
-
__publicField(this, "id", DataValidationType.DECIMAL);
|
|
2980
|
-
__publicField(this, "title", "dataValidation.decimal.title");
|
|
2981
|
-
__publicField(this, "operators", [
|
|
2982
|
-
DataValidationOperator.BETWEEN,
|
|
2983
|
-
DataValidationOperator.EQUAL,
|
|
2984
|
-
DataValidationOperator.GREATER_THAN,
|
|
2985
|
-
DataValidationOperator.GREATER_THAN_OR_EQUAL,
|
|
2986
|
-
DataValidationOperator.LESS_THAN,
|
|
2987
|
-
DataValidationOperator.LESS_THAN_OR_EQUAL,
|
|
2988
|
-
DataValidationOperator.NOT_BETWEEN,
|
|
2989
|
-
DataValidationOperator.NOT_EQUAL
|
|
2990
|
-
]);
|
|
2991
|
-
__publicField(this, "scopes", ["sheet"]);
|
|
2992
|
-
__publicField(this, "formulaInput", BASE_FORMULA_INPUT_NAME);
|
|
2993
|
-
__publicField(this, "dropDownInput");
|
|
2994
|
-
}
|
|
2995
|
-
_isFormulaOrNumber(formula) {
|
|
2996
|
-
return !Tools.isBlank(formula) && (isFormulaString(formula) || !Number.isNaN(+formula));
|
|
2997
|
-
}
|
|
2998
|
-
async isValidType(cellInfo, formula, rule) {
|
|
2999
|
-
const { value: cellValue } = cellInfo;
|
|
3000
|
-
return !Number.isNaN(getCellValueNumber(cellValue));
|
|
3001
|
-
}
|
|
3002
|
-
transform(cellInfo, formula, rule) {
|
|
3003
|
-
const { value: cellValue } = cellInfo;
|
|
3004
|
-
return {
|
|
3005
|
-
...cellInfo,
|
|
3006
|
-
value: getCellValueNumber(cellValue)
|
|
3007
|
-
};
|
|
3008
|
-
}
|
|
3009
|
-
_parseNumber(formula) {
|
|
3010
|
-
return formula == null ? Number.NaN : +formula;
|
|
3011
|
-
}
|
|
3012
|
-
async parseFormula(rule, unitId, subUnitId) {
|
|
3013
|
-
var _a23, _b, _c, _d, _e, _f, _g, _h;
|
|
3014
|
-
const formulaInfo = await this._formulaService.getRuleFormulaResult(unitId, subUnitId, rule.uid), { formula1, formula2 } = rule;
|
|
3015
|
-
return {
|
|
3016
|
-
formula1: this._parseNumber(isFormulaString(formula1) ? (_d = (_c = (_b = (_a23 = formulaInfo == null ? void 0 : formulaInfo[0]) == null ? void 0 : _a23.result) == null ? void 0 : _b[0]) == null ? void 0 : _c[0]) == null ? void 0 : _d.v : formula1),
|
|
3017
|
-
formula2: this._parseNumber(isFormulaString(formula2) ? (_h = (_g = (_f = (_e = formulaInfo == null ? void 0 : formulaInfo[1]) == null ? void 0 : _e.result) == null ? void 0 : _f[0]) == null ? void 0 : _g[0]) == null ? void 0 : _h.v : formula2)
|
|
3018
|
-
};
|
|
3019
|
-
}
|
|
3020
|
-
validatorFormula(rule, unitId, subUnitId) {
|
|
3021
|
-
const operator = rule.operator;
|
|
3022
|
-
if (!operator)
|
|
3023
|
-
return {
|
|
3024
|
-
success: !1
|
|
3025
|
-
};
|
|
3026
|
-
const formula1Success = Tools.isDefine(rule.formula1) && this._isFormulaOrNumber(rule.formula1), formula2Success = Tools.isDefine(rule.formula2) && this._isFormulaOrNumber(rule.formula2), isTwoFormula = TWO_FORMULA_OPERATOR_COUNT.includes(operator), errorMsg = this.localeService.t("dataValidation.validFail.number");
|
|
3027
|
-
return isTwoFormula ? {
|
|
3028
|
-
success: formula1Success && formula2Success,
|
|
3029
|
-
formula1: formula1Success ? void 0 : errorMsg,
|
|
3030
|
-
formula2: formula2Success ? void 0 : errorMsg
|
|
3031
|
-
} : {
|
|
3032
|
-
success: formula1Success,
|
|
3033
|
-
formula1: formula1Success ? "" : errorMsg
|
|
3034
|
-
};
|
|
3035
|
-
}
|
|
3036
|
-
async validatorIsEqual(cellInfo, formula, rule) {
|
|
3037
|
-
const { formula1 } = formula, { value: cellValue } = cellInfo;
|
|
3038
|
-
return Number.isNaN(formula1) ? !0 : cellValue === formula1;
|
|
3039
|
-
}
|
|
3040
|
-
async validatorIsNotEqual(cellInfo, formula, _rule) {
|
|
3041
|
-
const { formula1 } = formula;
|
|
3042
|
-
return Number.isNaN(formula1) ? !0 : cellInfo.value !== formula1;
|
|
3043
|
-
}
|
|
3044
|
-
async validatorIsBetween(cellInfo, formula, _rule) {
|
|
3045
|
-
const { formula1, formula2 } = formula;
|
|
3046
|
-
if (Number.isNaN(formula1) || Number.isNaN(formula2))
|
|
3047
|
-
return !0;
|
|
3048
|
-
const start = Math.min(formula1, formula2), end = Math.max(formula1, formula2);
|
|
3049
|
-
return cellInfo.value >= start && cellInfo.value <= end;
|
|
3050
|
-
}
|
|
3051
|
-
async validatorIsNotBetween(cellInfo, formula, _rule) {
|
|
3052
|
-
const { formula1, formula2 } = formula;
|
|
3053
|
-
if (Number.isNaN(formula1) || Number.isNaN(formula2))
|
|
3054
|
-
return !0;
|
|
3055
|
-
const start = Math.min(formula1, formula2), end = Math.max(formula1, formula2);
|
|
3056
|
-
return cellInfo.value < start || cellInfo.value > end;
|
|
3057
|
-
}
|
|
3058
|
-
async validatorIsGreaterThan(cellInfo, formula, _rule) {
|
|
3059
|
-
const { formula1 } = formula;
|
|
3060
|
-
return Number.isNaN(formula1) ? !0 : cellInfo.value > formula1;
|
|
3061
|
-
}
|
|
3062
|
-
async validatorIsGreaterThanOrEqual(cellInfo, formula, _rule) {
|
|
3063
|
-
const { formula1 } = formula;
|
|
3064
|
-
return Number.isNaN(formula1) ? !0 : cellInfo.value >= formula1;
|
|
3065
|
-
}
|
|
3066
|
-
async validatorIsLessThan(cellInfo, formula, _rule) {
|
|
3067
|
-
const { formula1 } = formula;
|
|
3068
|
-
return Number.isNaN(formula1) ? !0 : cellInfo.value < formula1;
|
|
3069
|
-
}
|
|
3070
|
-
async validatorIsLessThanOrEqual(cellInfo, formula, _rule) {
|
|
3071
|
-
const { formula1 } = formula;
|
|
3072
|
-
return Number.isNaN(formula1) ? !0 : cellInfo.value <= formula1;
|
|
3073
|
-
}
|
|
3074
|
-
};
|
|
3075
|
-
__name(_DecimalValidator, "DecimalValidator");
|
|
3076
|
-
let DecimalValidator = _DecimalValidator;
|
|
3077
3548
|
const FORMULA1 = "{FORMULA1}", FORMULA2 = "{FORMULA2}", _TextLengthValidator = class _TextLengthValidator extends BaseDataValidator {
|
|
3078
3549
|
constructor() {
|
|
3079
3550
|
super(...arguments);
|
|
@@ -3119,10 +3590,10 @@ const FORMULA1 = "{FORMULA1}", FORMULA2 = "{FORMULA2}", _TextLengthValidator = c
|
|
|
3119
3590
|
return !Number.isNaN(formula);
|
|
3120
3591
|
}
|
|
3121
3592
|
async parseFormula(rule, unitId, subUnitId) {
|
|
3122
|
-
var
|
|
3593
|
+
var _a24, _b, _c, _d, _e, _f, _g, _h;
|
|
3123
3594
|
const formulaInfo = await this._formulaService.getRuleFormulaResult(unitId, subUnitId, rule.uid), { formula1, formula2 } = rule;
|
|
3124
3595
|
return {
|
|
3125
|
-
formula1: this._parseNumber(isFormulaString(formula1) ? (_d = (_c = (_b = (
|
|
3596
|
+
formula1: this._parseNumber(isFormulaString(formula1) ? (_d = (_c = (_b = (_a24 = formulaInfo == null ? void 0 : formulaInfo[0]) == null ? void 0 : _a24.result) == null ? void 0 : _b[0]) == null ? void 0 : _c[0]) == null ? void 0 : _d.v : formula1),
|
|
3126
3597
|
formula2: this._parseNumber(isFormulaString(formula2) ? (_h = (_g = (_f = (_e = formulaInfo == null ? void 0 : formulaInfo[1]) == null ? void 0 : _e.result) == null ? void 0 : _f[0]) == null ? void 0 : _g[0]) == null ? void 0 : _h.v : formula2)
|
|
3127
3598
|
};
|
|
3128
3599
|
}
|
|
@@ -3175,15 +3646,15 @@ const FORMULA1 = "{FORMULA1}", FORMULA2 = "{FORMULA2}", _TextLengthValidator = c
|
|
|
3175
3646
|
return this._isValidFormula(formula1) ? cellValue <= formula1 : !1;
|
|
3176
3647
|
}
|
|
3177
3648
|
generateRuleErrorMessage(rule) {
|
|
3178
|
-
var
|
|
3179
|
-
return rule.operator ? `${this.localeService.t(TextLengthErrorTitleMap[rule.operator]).replace(FORMULA1, (
|
|
3649
|
+
var _a24, _b;
|
|
3650
|
+
return rule.operator ? `${this.localeService.t(TextLengthErrorTitleMap[rule.operator]).replace(FORMULA1, (_a24 = rule.formula1) != null ? _a24 : "").replace(FORMULA2, (_b = rule.formula2) != null ? _b : "")}` : this.titleStr;
|
|
3180
3651
|
}
|
|
3181
3652
|
};
|
|
3182
3653
|
__name(_TextLengthValidator, "TextLengthValidator");
|
|
3183
3654
|
let TextLengthValidator = _TextLengthValidator;
|
|
3184
3655
|
function isBlankCell(cellData) {
|
|
3185
|
-
var
|
|
3186
|
-
return cellData ? cellData.p ? !((_b = (
|
|
3656
|
+
var _a24, _b;
|
|
3657
|
+
return cellData ? cellData.p ? !((_b = (_a24 = cellData.p.body) == null ? void 0 : _a24.dataStream) != null ? _b : "").slice(0, -2).trim() : Tools.isBlank(cellData.v) : !0;
|
|
3187
3658
|
}
|
|
3188
3659
|
__name(isBlankCell, "isBlankCell");
|
|
3189
3660
|
function getDataValidationDiffMutations(unitId, subUnitId, diffs, accessor, source = "command", fillDefaultValue = !0) {
|
|
@@ -3308,11 +3779,11 @@ const UpdateSheetDataValidationRangeCommand = {
|
|
|
3308
3779
|
async handler(accessor, params) {
|
|
3309
3780
|
if (!params)
|
|
3310
3781
|
return !1;
|
|
3311
|
-
const { unitId, subUnitId, ranges, ruleId } = params, sheetDataValidationModel = accessor.get(SheetDataValidationModel), commandService = accessor.get(ICommandService), undoRedoService = accessor.get(IUndoRedoService)
|
|
3312
|
-
if (!
|
|
3782
|
+
const { unitId, subUnitId, ranges, ruleId } = params, sheetDataValidationModel = accessor.get(SheetDataValidationModel), commandService = accessor.get(ICommandService), undoRedoService = accessor.get(IUndoRedoService);
|
|
3783
|
+
if (!sheetDataValidationModel.getRuleById(unitId, subUnitId, ruleId))
|
|
3313
3784
|
return !1;
|
|
3314
|
-
const
|
|
3315
|
-
matrix.updateRange(ruleId,
|
|
3785
|
+
const matrix = sheetDataValidationModel.getRuleObjectMatrix(unitId, subUnitId).clone();
|
|
3786
|
+
matrix.updateRange(ruleId, ranges);
|
|
3316
3787
|
const diffs = matrix.diff(sheetDataValidationModel.getRules(unitId, subUnitId)), { redoMutations, undoMutations } = getDataValidationDiffMutations(unitId, subUnitId, diffs, accessor);
|
|
3317
3788
|
return undoRedoService.pushUndoRedo({
|
|
3318
3789
|
undoMutations,
|
|
@@ -3576,7 +4047,7 @@ const UpdateSheetDataValidationRangeCommand = {
|
|
|
3576
4047
|
unitID: params.unitId
|
|
3577
4048
|
}), commandService.executeCommand(RemoveDataValidationMutation.id, params), !0;
|
|
3578
4049
|
}
|
|
3579
|
-
}
|
|
4050
|
+
};
|
|
3580
4051
|
function isLegalFormulaResult(res) {
|
|
3581
4052
|
return !ERROR_TYPE_SET.has(res);
|
|
3582
4053
|
}
|
|
@@ -3676,8 +4147,8 @@ var __defProp$b = Object.defineProperty, __getOwnPropDesc$b = Object.getOwnPrope
|
|
|
3676
4147
|
return kind && result && __defProp$b(target, key, result), result;
|
|
3677
4148
|
}, "__decorateClass$b"), __decorateParam$b = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$b");
|
|
3678
4149
|
const downPath = new Path2D("M3.32201 4.84556C3.14417 5.05148 2.85583 5.05148 2.67799 4.84556L0.134292 1.90016C-0.152586 1.56798 0.0505937 1 0.456301 1L5.5437 1C5.94941 1 6.15259 1.56798 5.86571 1.90016L3.32201 4.84556Z");
|
|
3679
|
-
var
|
|
3680
|
-
let DropdownMultipleWidget = (
|
|
4150
|
+
var _a11;
|
|
4151
|
+
let DropdownMultipleWidget = (_a11 = class {
|
|
3681
4152
|
constructor(_commandService) {
|
|
3682
4153
|
__publicField(this, "zIndex");
|
|
3683
4154
|
__publicField(this, "_dropdownInfoMap", /* @__PURE__ */ new Map());
|
|
@@ -3705,7 +4176,7 @@ let DropdownMultipleWidget = (_a10 = class {
|
|
|
3705
4176
|
}
|
|
3706
4177
|
// eslint-disable-next-line max-lines-per-function
|
|
3707
4178
|
drawWith(ctx, info, skeleton, spreadsheets) {
|
|
3708
|
-
var
|
|
4179
|
+
var _a24, _b;
|
|
3709
4180
|
const { primaryWithCoord, row, col, style, data, subUnitId } = info, _cellBounding = primaryWithCoord.isMergedMainCell ? primaryWithCoord.mergeInfo : primaryWithCoord, fontRenderExtension = data.fontRenderExtension, { leftOffset = 0, rightOffset = 0, topOffset = 0, downOffset = 0 } = fontRenderExtension || {}, validation = data.dataValidation, map = this._ensureMap(subUnitId), key = this._generateKey(row, col);
|
|
3710
4181
|
if (!validation)
|
|
3711
4182
|
return;
|
|
@@ -3714,7 +4185,7 @@ let DropdownMultipleWidget = (_a10 = class {
|
|
|
3714
4185
|
endX: _cellBounding.endX - rightOffset,
|
|
3715
4186
|
startY: _cellBounding.startY + topOffset,
|
|
3716
4187
|
endY: _cellBounding.endY - downOffset
|
|
3717
|
-
}, cellWidth = cellBounding.endX - cellBounding.startX, cellHeight = cellBounding.endY - cellBounding.startY, { cl } = style || {}, color = (
|
|
4188
|
+
}, cellWidth = cellBounding.endX - cellBounding.startX, cellHeight = cellBounding.endY - cellBounding.startY, { cl } = style || {}, color = (_a24 = typeof cl == "object" ? cl == null ? void 0 : cl.rgb : cl) != null ? _a24 : "#000", fontStyle = getFontStyleString(style != null ? style : void 0), { rule, validator: _validator } = validation, validator = _validator, { vt: _vt, ht } = style || {}, vt = _vt != null ? _vt : VerticalAlign.MIDDLE, cellValue = (_b = getCellValueOrigin(data)) != null ? _b : "", items = validator.parseCellValue(cellValue), labelColorMap = validator.getListWithColorMap(rule), layout = layoutDropdowns(items, fontStyle, cellWidth, cellHeight);
|
|
3718
4189
|
this._drawDownIcon(ctx, cellBounding, cellWidth, cellHeight, vt), ctx.save(), ctx.translateWithPrecision(cellBounding.startX, cellBounding.startY), ctx.beginPath(), ctx.rect(0, 0, cellWidth - ICON_PLACE, cellHeight), ctx.clip(), ctx.translateWithPrecision(CELL_PADDING_H, CELL_PADDING_V);
|
|
3719
4190
|
let top = 0;
|
|
3720
4191
|
switch (vt) {
|
|
@@ -3753,7 +4224,7 @@ let DropdownMultipleWidget = (_a10 = class {
|
|
|
3753
4224
|
});
|
|
3754
4225
|
}
|
|
3755
4226
|
calcCellAutoHeight(info) {
|
|
3756
|
-
var
|
|
4227
|
+
var _a24;
|
|
3757
4228
|
const { primaryWithCoord, style, data } = info, fontRenderExtension = data.fontRenderExtension, { leftOffset = 0, rightOffset = 0, topOffset = 0, downOffset = 0 } = fontRenderExtension || {}, _cellBounding = primaryWithCoord.isMergedMainCell ? primaryWithCoord.mergeInfo : primaryWithCoord, cellBounding = {
|
|
3758
4229
|
startX: _cellBounding.startX + leftOffset,
|
|
3759
4230
|
endX: _cellBounding.endX - rightOffset,
|
|
@@ -3762,7 +4233,7 @@ let DropdownMultipleWidget = (_a10 = class {
|
|
|
3762
4233
|
}, validation = data.dataValidation;
|
|
3763
4234
|
if (!validation)
|
|
3764
4235
|
return;
|
|
3765
|
-
const cellWidth = cellBounding.endX - cellBounding.startX, cellHeight = cellBounding.endY - cellBounding.startY, cellValue = (
|
|
4236
|
+
const cellWidth = cellBounding.endX - cellBounding.startX, cellHeight = cellBounding.endY - cellBounding.startY, cellValue = (_a24 = getCellValueOrigin(data)) != null ? _a24 : "", { validator: _validator } = validation, items = _validator.parseCellValue(cellValue), fontStyle = getFontStyleString(style != null ? style : void 0);
|
|
3766
4237
|
return layoutDropdowns(items, fontStyle, cellWidth, cellHeight).cellAutoHeight;
|
|
3767
4238
|
}
|
|
3768
4239
|
isHit(position, info) {
|
|
@@ -3780,7 +4251,7 @@ let DropdownMultipleWidget = (_a10 = class {
|
|
|
3780
4251
|
};
|
|
3781
4252
|
this._commandService.executeCommand(ShowDataValidationDropdown.id, params);
|
|
3782
4253
|
}
|
|
3783
|
-
}, __name(
|
|
4254
|
+
}, __name(_a11, "DropdownMultipleWidget"), _a11);
|
|
3784
4255
|
DropdownMultipleWidget = __decorateClass$b([
|
|
3785
4256
|
__decorateParam$b(0, ICommandService)
|
|
3786
4257
|
], DropdownMultipleWidget);
|
|
@@ -3790,9 +4261,7 @@ const _ListMultipleValidator = class _ListMultipleValidator extends ListValidato
|
|
|
3790
4261
|
__publicField(this, "id", DataValidationType.LIST_MULTIPLE);
|
|
3791
4262
|
__publicField(this, "title", "dataValidation.listMultiple.title");
|
|
3792
4263
|
__publicField(this, "canvasRender", this.injector.createInstance(DropdownMultipleWidget));
|
|
3793
|
-
|
|
3794
|
-
skipDefaultFontRender() {
|
|
3795
|
-
return !0;
|
|
4264
|
+
__publicField(this, "skipDefaultFontRender", /* @__PURE__ */ __name(() => !0, "skipDefaultFontRender"));
|
|
3796
4265
|
}
|
|
3797
4266
|
};
|
|
3798
4267
|
__name(_ListMultipleValidator, "ListMultipleValidator");
|
|
@@ -3835,10 +4304,10 @@ const _WholeValidator = class _WholeValidator extends BaseDataValidator {
|
|
|
3835
4304
|
return formula == null ? Number.NaN : +formula;
|
|
3836
4305
|
}
|
|
3837
4306
|
async parseFormula(rule, unitId, subUnitId) {
|
|
3838
|
-
var
|
|
4307
|
+
var _a24, _b, _c, _d, _e, _f, _g, _h;
|
|
3839
4308
|
const formulaInfo = await this._formulaService.getRuleFormulaResult(unitId, subUnitId, rule.uid), { formula1, formula2 } = rule;
|
|
3840
4309
|
return {
|
|
3841
|
-
formula1: this._parseNumber(isFormulaString(formula1) ? (_d = (_c = (_b = (
|
|
4310
|
+
formula1: this._parseNumber(isFormulaString(formula1) ? (_d = (_c = (_b = (_a24 = formulaInfo == null ? void 0 : formulaInfo[0]) == null ? void 0 : _a24.result) == null ? void 0 : _b[0]) == null ? void 0 : _c[0]) == null ? void 0 : _d.v : formula1),
|
|
3842
4311
|
formula2: this._parseNumber(isFormulaString(formula2) ? (_h = (_g = (_f = (_e = formulaInfo == null ? void 0 : formulaInfo[1]) == null ? void 0 : _e.result) == null ? void 0 : _f[0]) == null ? void 0 : _g[0]) == null ? void 0 : _h.v : formula2)
|
|
3843
4312
|
};
|
|
3844
4313
|
}
|
|
@@ -3931,8 +4400,8 @@ var __defProp$a = Object.defineProperty, __getOwnPropDesc$a = Object.getOwnPrope
|
|
|
3931
4400
|
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$a(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
3932
4401
|
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
3933
4402
|
return kind && result && __defProp$a(target, key, result), result;
|
|
3934
|
-
}, "__decorateClass$a"), __decorateParam$a = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$a"),
|
|
3935
|
-
let DataValidationController = (
|
|
4403
|
+
}, "__decorateClass$a"), __decorateParam$a = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$a"), _a12;
|
|
4404
|
+
let DataValidationController = (_a12 = class extends RxDisposable {
|
|
3936
4405
|
constructor(_univerInstanceService, _dataValidatorRegistryService, _injector, _componentManger, _selectionManagerService, _sheetInterceptorService, _sheetDataValidationModel) {
|
|
3937
4406
|
super(), this._univerInstanceService = _univerInstanceService, this._dataValidatorRegistryService = _dataValidatorRegistryService, this._injector = _injector, this._componentManger = _componentManger, this._selectionManagerService = _selectionManagerService, this._sheetInterceptorService = _sheetInterceptorService, this._sheetDataValidationModel = _sheetDataValidationModel, this._init();
|
|
3938
4407
|
}
|
|
@@ -3963,12 +4432,12 @@ let DataValidationController = (_a11 = class extends RxDisposable {
|
|
|
3963
4432
|
_initCommandInterceptor() {
|
|
3964
4433
|
this._sheetInterceptorService.interceptCommand({
|
|
3965
4434
|
getMutations: /* @__PURE__ */ __name((commandInfo) => {
|
|
3966
|
-
var
|
|
4435
|
+
var _a24;
|
|
3967
4436
|
if (commandInfo.id === ClearSelectionAllCommand.id) {
|
|
3968
4437
|
const workbook = this._univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET), unitId = workbook.getUnitId(), worksheet = workbook.getActiveSheet();
|
|
3969
4438
|
if (!worksheet)
|
|
3970
4439
|
throw new Error("No active sheet found");
|
|
3971
|
-
const subUnitId = worksheet.getSheetId(), selections = (
|
|
4440
|
+
const subUnitId = worksheet.getSheetId(), selections = (_a24 = this._selectionManagerService.getCurrentSelections()) == null ? void 0 : _a24.map((s) => s.range), ruleMatrix = this._sheetDataValidationModel.getRuleObjectMatrix(unitId, subUnitId).clone();
|
|
3972
4441
|
selections && ruleMatrix.removeRange(selections);
|
|
3973
4442
|
const diffs = ruleMatrix.diff(this._sheetDataValidationModel.getRules(unitId, subUnitId)), { redoMutations, undoMutations } = getDataValidationDiffMutations(unitId, subUnitId, diffs, this._injector, "patched");
|
|
3974
4443
|
return {
|
|
@@ -4000,7 +4469,7 @@ let DataValidationController = (_a11 = class extends RxDisposable {
|
|
|
4000
4469
|
));
|
|
4001
4470
|
});
|
|
4002
4471
|
}
|
|
4003
|
-
}, __name(
|
|
4472
|
+
}, __name(_a12, "DataValidationController"), _a12);
|
|
4004
4473
|
DataValidationController = __decorateClass$a([
|
|
4005
4474
|
OnLifecycle(LifecycleStages.Rendered, DataValidationController),
|
|
4006
4475
|
__decorateParam$a(0, IUniverInstanceService),
|
|
@@ -4017,8 +4486,8 @@ var __defProp$9 = Object.defineProperty, __getOwnPropDesc$9 = Object.getOwnPrope
|
|
|
4017
4486
|
return kind && result && __defProp$9(target, key, result), result;
|
|
4018
4487
|
}, "__decorateClass$9"), __decorateParam$9 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$9");
|
|
4019
4488
|
const ALERT_KEY = "SHEET_DATA_VALIDATION_ALERT";
|
|
4020
|
-
var
|
|
4021
|
-
let DataValidationAlertController = (
|
|
4489
|
+
var _a13;
|
|
4490
|
+
let DataValidationAlertController = (_a13 = class extends Disposable {
|
|
4022
4491
|
constructor(_hoverManagerService, _cellAlertManagerService, _univerInstanceService, _localeService, _zenZoneService) {
|
|
4023
4492
|
super(), this._hoverManagerService = _hoverManagerService, this._cellAlertManagerService = _cellAlertManagerService, this._univerInstanceService = _univerInstanceService, this._localeService = _localeService, this._zenZoneService = _zenZoneService, this._init();
|
|
4024
4493
|
}
|
|
@@ -4027,12 +4496,12 @@ let DataValidationAlertController = (_a12 = class extends Disposable {
|
|
|
4027
4496
|
}
|
|
4028
4497
|
_initCellAlertPopup() {
|
|
4029
4498
|
this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(debounceTime(100)).subscribe((cellPos) => {
|
|
4030
|
-
var
|
|
4499
|
+
var _a24, _b;
|
|
4031
4500
|
if (cellPos) {
|
|
4032
4501
|
const worksheet = this._univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET).getActiveSheet();
|
|
4033
4502
|
if (!worksheet) return;
|
|
4034
4503
|
const cellData = worksheet.getCell(cellPos.location.row, cellPos.location.col);
|
|
4035
|
-
if (((
|
|
4504
|
+
if (((_a24 = cellData == null ? void 0 : cellData.dataValidation) == null ? void 0 : _a24.validStatus) === DataValidationStatus.INVALID) {
|
|
4036
4505
|
const currentAlert = this._cellAlertManagerService.currentAlert.get(ALERT_KEY), currentLoc = (_b = currentAlert == null ? void 0 : currentAlert.alert) == null ? void 0 : _b.location;
|
|
4037
4506
|
if (currentLoc && currentLoc.row === cellPos.location.row && currentLoc.col === cellPos.location.col && currentLoc.subUnitId === cellPos.location.subUnitId && currentLoc.unitId === cellPos.location.unitId)
|
|
4038
4507
|
return;
|
|
@@ -4059,7 +4528,7 @@ let DataValidationAlertController = (_a12 = class extends Disposable {
|
|
|
4059
4528
|
visible && this._cellAlertManagerService.removeAlert(ALERT_KEY);
|
|
4060
4529
|
}));
|
|
4061
4530
|
}
|
|
4062
|
-
}, __name(
|
|
4531
|
+
}, __name(_a13, "DataValidationAlertController"), _a13);
|
|
4063
4532
|
DataValidationAlertController = __decorateClass$9([
|
|
4064
4533
|
OnLifecycle(LifecycleStages.Rendered, DataValidationAlertController),
|
|
4065
4534
|
__decorateParam$9(0, Inject(HoverManagerService)),
|
|
@@ -4072,8 +4541,8 @@ var __defProp$8 = Object.defineProperty, __getOwnPropDesc$8 = Object.getOwnPrope
|
|
|
4072
4541
|
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$8(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
4073
4542
|
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
4074
4543
|
return kind && result && __defProp$8(target, key, result), result;
|
|
4075
|
-
}, "__decorateClass$8"), __decorateParam$8 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$8"),
|
|
4076
|
-
let DataValidationCopyPasteController = (
|
|
4544
|
+
}, "__decorateClass$8"), __decorateParam$8 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$8"), _a14;
|
|
4545
|
+
let DataValidationCopyPasteController = (_a14 = class extends Disposable {
|
|
4077
4546
|
constructor(_sheetClipboardService, _sheetDataValidationModel, _injector) {
|
|
4078
4547
|
super();
|
|
4079
4548
|
__publicField(this, "_copyInfo");
|
|
@@ -4126,10 +4595,10 @@ let DataValidationCopyPasteController = (_a13 = class extends Disposable {
|
|
|
4126
4595
|
return { redos: [], undos: [] };
|
|
4127
4596
|
const { unitId, subUnitId } = this._copyInfo;
|
|
4128
4597
|
if (copyInfo.unitId !== unitId || subUnitId !== copyInfo.subUnitId) {
|
|
4129
|
-
const ruleMatrix = this._sheetDataValidationModel.getRuleObjectMatrix(copyInfo.unitId, copyInfo.subUnitId).clone(), { ranges: [vCopyRange, vPastedRange], mapFunc } = virtualizeDiscreteRanges([copyInfo.copyRange, pastedRange]), repeatRange = getRepeatRange(vCopyRange, vPastedRange, !0), additionRules = /* @__PURE__ */ new Map();
|
|
4598
|
+
const ruleMatrix = this._sheetDataValidationModel.getRuleObjectMatrix(copyInfo.unitId, copyInfo.subUnitId).clone(), additionMatrix = new ObjectMatrix(), addRules = /* @__PURE__ */ new Set(), { ranges: [vCopyRange, vPastedRange], mapFunc } = virtualizeDiscreteRanges([copyInfo.copyRange, pastedRange]), repeatRange = getRepeatRange(vCopyRange, vPastedRange, !0), additionRules = /* @__PURE__ */ new Map();
|
|
4130
4599
|
repeatRange.forEach(({ startRange }) => {
|
|
4131
|
-
var
|
|
4132
|
-
(
|
|
4600
|
+
var _a24;
|
|
4601
|
+
(_a24 = this._copyInfo) == null || _a24.matrix.forValue((row, col, ruleId) => {
|
|
4133
4602
|
const range = Rectangle.getPositionRange(
|
|
4134
4603
|
{
|
|
4135
4604
|
startRow: row,
|
|
@@ -4141,9 +4610,11 @@ let DataValidationCopyPasteController = (_a13 = class extends Disposable {
|
|
|
4141
4610
|
), transformedRuleId = `${subUnitId}-${ruleId}`, oldRule = this._sheetDataValidationModel.getRuleById(unitId, subUnitId, ruleId);
|
|
4142
4611
|
!this._sheetDataValidationModel.getRuleById(copyInfo.unitId, copyInfo.subUnitId, transformedRuleId) && oldRule && additionRules.set(transformedRuleId, { ...oldRule, uid: transformedRuleId });
|
|
4143
4612
|
const { row: startRow, col: startColumn } = mapFunc(range.startRow, range.startColumn);
|
|
4144
|
-
|
|
4613
|
+
addRules.add(transformedRuleId), additionMatrix.setValue(startRow, startColumn, transformedRuleId);
|
|
4145
4614
|
});
|
|
4146
4615
|
});
|
|
4616
|
+
const additions = Array.from(addRules).map((id) => ({ id, ranges: queryObjectMatrix(additionMatrix, (value) => value === id) }));
|
|
4617
|
+
ruleMatrix.addRangeRules(additions);
|
|
4147
4618
|
const { redoMutations, undoMutations } = getDataValidationDiffMutations(
|
|
4148
4619
|
copyInfo.unitId,
|
|
4149
4620
|
copyInfo.subUnitId,
|
|
@@ -4156,10 +4627,10 @@ let DataValidationCopyPasteController = (_a13 = class extends Disposable {
|
|
|
4156
4627
|
undos: undoMutations
|
|
4157
4628
|
};
|
|
4158
4629
|
} else {
|
|
4159
|
-
const ruleMatrix = this._sheetDataValidationModel.getRuleObjectMatrix(unitId, subUnitId).clone(), { ranges: [vCopyRange, vPastedRange], mapFunc } = virtualizeDiscreteRanges([copyInfo.copyRange, pastedRange]);
|
|
4630
|
+
const ruleMatrix = this._sheetDataValidationModel.getRuleObjectMatrix(unitId, subUnitId).clone(), additionMatrix = new ObjectMatrix(), additionRules = /* @__PURE__ */ new Set(), { ranges: [vCopyRange, vPastedRange], mapFunc } = virtualizeDiscreteRanges([copyInfo.copyRange, pastedRange]);
|
|
4160
4631
|
getRepeatRange(vCopyRange, vPastedRange, !0).forEach(({ startRange }) => {
|
|
4161
|
-
var
|
|
4162
|
-
(
|
|
4632
|
+
var _a24;
|
|
4633
|
+
(_a24 = this._copyInfo) == null || _a24.matrix.forValue((row, col, ruleId) => {
|
|
4163
4634
|
const range = Rectangle.getPositionRange(
|
|
4164
4635
|
{
|
|
4165
4636
|
startRow: row,
|
|
@@ -4169,9 +4640,11 @@ let DataValidationCopyPasteController = (_a13 = class extends Disposable {
|
|
|
4169
4640
|
},
|
|
4170
4641
|
startRange
|
|
4171
4642
|
), { row: startRow, col: startColumn } = mapFunc(range.startRow, range.startColumn);
|
|
4172
|
-
|
|
4643
|
+
additionMatrix.setValue(startRow, startColumn, ruleId), additionRules.add(ruleId);
|
|
4173
4644
|
});
|
|
4174
4645
|
});
|
|
4646
|
+
const additions = Array.from(additionRules).map((id) => ({ id, ranges: queryObjectMatrix(additionMatrix, (value) => value === id) }));
|
|
4647
|
+
ruleMatrix.addRangeRules(additions);
|
|
4175
4648
|
const { redoMutations, undoMutations } = getDataValidationDiffMutations(
|
|
4176
4649
|
unitId,
|
|
4177
4650
|
subUnitId,
|
|
@@ -4185,7 +4658,7 @@ let DataValidationCopyPasteController = (_a13 = class extends Disposable {
|
|
|
4185
4658
|
};
|
|
4186
4659
|
}
|
|
4187
4660
|
}
|
|
4188
|
-
}, __name(
|
|
4661
|
+
}, __name(_a14, "DataValidationCopyPasteController"), _a14);
|
|
4189
4662
|
DataValidationCopyPasteController = __decorateClass$8([
|
|
4190
4663
|
OnLifecycle(LifecycleStages.Ready, DataValidationCopyPasteController),
|
|
4191
4664
|
__decorateParam$8(0, ISheetClipboardService),
|
|
@@ -4196,8 +4669,8 @@ var __defProp$7 = Object.defineProperty, __getOwnPropDesc$7 = Object.getOwnPrope
|
|
|
4196
4669
|
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$7(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
4197
4670
|
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
4198
4671
|
return kind && result && __defProp$7(target, key, result), result;
|
|
4199
|
-
}, "__decorateClass$7"), __decorateParam$7 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$7"),
|
|
4200
|
-
let DataValidationPermissionController = (
|
|
4672
|
+
}, "__decorateClass$7"), __decorateParam$7 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$7"), _a15;
|
|
4673
|
+
let DataValidationPermissionController = (_a15 = class extends Disposable {
|
|
4201
4674
|
constructor(_localeService, _commandService, _sheetPermissionInterceptorBaseController) {
|
|
4202
4675
|
super(), this._localeService = _localeService, this._commandService = _commandService, this._sheetPermissionInterceptorBaseController = _sheetPermissionInterceptorBaseController, this._commandExecutedListener();
|
|
4203
4676
|
}
|
|
@@ -4216,7 +4689,7 @@ let DataValidationPermissionController = (_a14 = class extends Disposable {
|
|
|
4216
4689
|
})
|
|
4217
4690
|
);
|
|
4218
4691
|
}
|
|
4219
|
-
}, __name(
|
|
4692
|
+
}, __name(_a15, "DataValidationPermissionController"), _a15);
|
|
4220
4693
|
DataValidationPermissionController = __decorateClass$7([
|
|
4221
4694
|
OnLifecycle(LifecycleStages.Ready, DataValidationPermissionController),
|
|
4222
4695
|
__decorateParam$7(0, Inject(LocaleService)),
|
|
@@ -4227,8 +4700,8 @@ var __defProp$6 = Object.defineProperty, __getOwnPropDesc$6 = Object.getOwnPrope
|
|
|
4227
4700
|
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$6(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
4228
4701
|
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
4229
4702
|
return kind && result && __defProp$6(target, key, result), result;
|
|
4230
|
-
}, "__decorateClass$6"), __decorateParam$6 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$6"),
|
|
4231
|
-
let DataValidationRefRangeController = (
|
|
4703
|
+
}, "__decorateClass$6"), __decorateParam$6 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$6"), _a16;
|
|
4704
|
+
let DataValidationRefRangeController = (_a16 = class extends Disposable {
|
|
4232
4705
|
constructor(_dataValidationModel, _injector, _refRangeService, _dataValidationCustomFormulaService, _dataValidationFormulaService, _formulaRefRangeService) {
|
|
4233
4706
|
super();
|
|
4234
4707
|
__publicField(this, "_disposableMap", /* @__PURE__ */ new Map());
|
|
@@ -4242,8 +4715,8 @@ let DataValidationRefRangeController = (_a15 = class extends Disposable {
|
|
|
4242
4715
|
}
|
|
4243
4716
|
// eslint-disable-next-line max-lines-per-function
|
|
4244
4717
|
registerFormula(unitId, subUnitId, rule) {
|
|
4245
|
-
var
|
|
4246
|
-
const ruleId = rule.uid, id = this._getIdWithUnitId(unitId, subUnitId, ruleId), disposeSet = (
|
|
4718
|
+
var _a24;
|
|
4719
|
+
const ruleId = rule.uid, id = this._getIdWithUnitId(unitId, subUnitId, ruleId), disposeSet = (_a24 = this._disposableMap.get(id)) != null ? _a24 : /* @__PURE__ */ new Set(), handleFormulaChange = /* @__PURE__ */ __name((type, formulaString) => {
|
|
4247
4720
|
const oldRule = this._dataValidationModel.getRuleById(unitId, subUnitId, ruleId);
|
|
4248
4721
|
if (!oldRule)
|
|
4249
4722
|
return { redos: [], undos: [] };
|
|
@@ -4320,7 +4793,7 @@ let DataValidationRefRangeController = (_a15 = class extends Disposable {
|
|
|
4320
4793
|
}
|
|
4321
4794
|
}
|
|
4322
4795
|
register(unitId, subUnitId, rule) {
|
|
4323
|
-
var
|
|
4796
|
+
var _a24;
|
|
4324
4797
|
const handleRangeChange = /* @__PURE__ */ __name((commandInfo) => {
|
|
4325
4798
|
const oldRanges = [...rule.ranges], resultRanges = oldRanges.map((range) => handleCommonDefaultRangeChangeWithEffectRefCommands(range, commandInfo)).filter((range) => !!range).flat();
|
|
4326
4799
|
if (isRangesEqual(resultRanges, oldRanges))
|
|
@@ -4358,10 +4831,15 @@ let DataValidationRefRangeController = (_a15 = class extends Disposable {
|
|
|
4358
4831
|
const disposable = this._refRangeService.registerRefRange(range, handleRangeChange, unitId, subUnitId);
|
|
4359
4832
|
disposeList.push(() => disposable.dispose());
|
|
4360
4833
|
});
|
|
4361
|
-
const id = this._getIdWithUnitId(unitId, subUnitId, rule.uid), current = (
|
|
4834
|
+
const id = this._getIdWithUnitId(unitId, subUnitId, rule.uid), current = (_a24 = this._disposableMap.get(id)) != null ? _a24 : /* @__PURE__ */ new Set();
|
|
4362
4835
|
current.add(() => disposeList.forEach((dispose) => dispose())), this._disposableMap.set(id, current);
|
|
4363
4836
|
}
|
|
4364
4837
|
_initRefRange() {
|
|
4838
|
+
const allRules = this._dataValidationModel.getAll();
|
|
4839
|
+
for (const [unitId, subUnitMap] of allRules)
|
|
4840
|
+
for (const [subUnitId, rules] of subUnitMap)
|
|
4841
|
+
for (const rule of rules)
|
|
4842
|
+
this.registerRule(unitId, subUnitId, rule);
|
|
4365
4843
|
this.disposeWithMe(
|
|
4366
4844
|
this._dataValidationModel.ruleChange$.subscribe((option) => {
|
|
4367
4845
|
const { unitId, subUnitId, rule } = option;
|
|
@@ -4389,10 +4867,10 @@ let DataValidationRefRangeController = (_a15 = class extends Disposable {
|
|
|
4389
4867
|
}), this._disposableMap.clear();
|
|
4390
4868
|
}));
|
|
4391
4869
|
}
|
|
4392
|
-
}, __name(
|
|
4870
|
+
}, __name(_a16, "DataValidationRefRangeController"), _a16);
|
|
4393
4871
|
DataValidationRefRangeController = __decorateClass$6([
|
|
4394
4872
|
OnLifecycle(LifecycleStages.Starting, DataValidationRefRangeController),
|
|
4395
|
-
__decorateParam$6(0, Inject(
|
|
4873
|
+
__decorateParam$6(0, Inject(SheetDataValidationModel)),
|
|
4396
4874
|
__decorateParam$6(1, Inject(Injector)),
|
|
4397
4875
|
__decorateParam$6(2, Inject(RefRangeService)),
|
|
4398
4876
|
__decorateParam$6(3, Inject(DataValidationCustomFormulaService)),
|
|
@@ -4426,8 +4904,8 @@ const INVALID_MARK = {
|
|
|
4426
4904
|
color: "#fe4b4b"
|
|
4427
4905
|
}
|
|
4428
4906
|
};
|
|
4429
|
-
var
|
|
4430
|
-
let SheetsDataValidationRenderController = (
|
|
4907
|
+
var _a17;
|
|
4908
|
+
let SheetsDataValidationRenderController = (_a17 = class extends RxDisposable {
|
|
4431
4909
|
constructor(_commandService, _menuManagerService, _renderManagerService, _univerInstanceService, _autoHeightController, _dropdownManagerService, _sheetDataValidationModel, _dataValidatorRegistryService, _sheetInterceptorService, _editorBridgeService) {
|
|
4432
4910
|
super(), this._commandService = _commandService, this._menuManagerService = _menuManagerService, this._renderManagerService = _renderManagerService, this._univerInstanceService = _univerInstanceService, this._autoHeightController = _autoHeightController, this._dropdownManagerService = _dropdownManagerService, this._sheetDataValidationModel = _sheetDataValidationModel, this._dataValidatorRegistryService = _dataValidatorRegistryService, this._sheetInterceptorService = _sheetInterceptorService, this._editorBridgeService = _editorBridgeService, this._initMenu(), this._initSkeletonChange(), this._initDropdown(), this._initViewModelIntercept(), this._initAutoHeight();
|
|
4433
4911
|
}
|
|
@@ -4436,9 +4914,9 @@ let SheetsDataValidationRenderController = (_a16 = class extends RxDisposable {
|
|
|
4436
4914
|
}
|
|
4437
4915
|
_initDropdown() {
|
|
4438
4916
|
this._editorBridgeService && this.disposeWithMe(this._editorBridgeService.visible$.subscribe((visible) => {
|
|
4439
|
-
var
|
|
4917
|
+
var _a24;
|
|
4440
4918
|
if (!visible.visible) {
|
|
4441
|
-
((
|
|
4919
|
+
((_a24 = this._dropdownManagerService.activeDropdown) == null ? void 0 : _a24.trigger) === "editor-bridge" && this._dropdownManagerService.hideDropdown();
|
|
4442
4920
|
return;
|
|
4443
4921
|
}
|
|
4444
4922
|
const state = this._editorBridgeService.getEditCellState();
|
|
@@ -4479,10 +4957,10 @@ let SheetsDataValidationRenderController = (_a16 = class extends RxDisposable {
|
|
|
4479
4957
|
}
|
|
4480
4958
|
_initSkeletonChange() {
|
|
4481
4959
|
const markSkeletonDirty = /* @__PURE__ */ __name(() => {
|
|
4482
|
-
var
|
|
4960
|
+
var _a24, _b, _c;
|
|
4483
4961
|
const workbook = this._univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET);
|
|
4484
4962
|
if (!workbook) return;
|
|
4485
|
-
const unitId = workbook.getUnitId(), subUnitId = (
|
|
4963
|
+
const unitId = workbook.getUnitId(), subUnitId = (_a24 = workbook.getActiveSheet()) == null ? void 0 : _a24.getSheetId();
|
|
4486
4964
|
if (!subUnitId) return;
|
|
4487
4965
|
const skeleton = (_c = (_b = this._renderManagerService.getRenderById(unitId)) == null ? void 0 : _b.with(SheetSkeletonManagerService).getWorksheetSkeleton(subUnitId)) == null ? void 0 : _c.skeleton, currentRender = this._renderManagerService.getRenderById(unitId);
|
|
4488
4966
|
skeleton == null || skeleton.makeDirty(!0), skeleton == null || skeleton.calculate(), currentRender && currentRender.mainComponent.makeForceDirty();
|
|
@@ -4495,47 +4973,33 @@ let SheetsDataValidationRenderController = (_a16 = class extends RxDisposable {
|
|
|
4495
4973
|
this._sheetInterceptorService.intercept(
|
|
4496
4974
|
INTERCEPTOR_POINT.CELL_CONTENT,
|
|
4497
4975
|
{
|
|
4976
|
+
effect: InterceptorEffectEnum.Style,
|
|
4498
4977
|
// must be after numfmt
|
|
4499
4978
|
priority: InterceptCellContentPriority.DATA_VALIDATION,
|
|
4500
4979
|
// eslint-disable-next-line max-lines-per-function, complexity
|
|
4501
4980
|
handler: /* @__PURE__ */ __name((cell, pos, next) => {
|
|
4502
|
-
var
|
|
4503
|
-
const { row, col, unitId, subUnitId, workbook, worksheet } = pos,
|
|
4504
|
-
if (!skeleton)
|
|
4505
|
-
return next(cell);
|
|
4506
|
-
const styleMap = pos.workbook.getStyles(), defaultStyle = (typeof (cell == null ? void 0 : cell.s) == "string" ? styleMap.get(cell == null ? void 0 : cell.s) : cell == null ? void 0 : cell.s) || {}, ruleId = this._sheetDataValidationModel.getRuleIdByLocation(unitId, subUnitId, row, col);
|
|
4981
|
+
var _a24, _b, _c, _d;
|
|
4982
|
+
const { row, col, unitId, subUnitId, workbook, worksheet } = pos, ruleId = this._sheetDataValidationModel.getRuleIdByLocation(unitId, subUnitId, row, col);
|
|
4507
4983
|
if (!ruleId)
|
|
4508
4984
|
return next(cell);
|
|
4509
4985
|
const rule = this._sheetDataValidationModel.getRuleById(unitId, subUnitId, ruleId);
|
|
4510
4986
|
if (!rule)
|
|
4511
4987
|
return next(cell);
|
|
4512
|
-
const validStatus = this._sheetDataValidationModel.validator(cell, rule, pos), validator = this._dataValidatorRegistryService.getValidatorItem(rule.type), cellOrigin =
|
|
4513
|
-
let
|
|
4514
|
-
|
|
4515
|
-
|
|
4516
|
-
|
|
4517
|
-
|
|
4988
|
+
const validStatus = this._sheetDataValidationModel.validator(cell, rule, pos), validator = this._dataValidatorRegistryService.getValidatorItem(rule.type), cellOrigin = pos.rawData;
|
|
4989
|
+
let cache;
|
|
4990
|
+
const cellValue = {
|
|
4991
|
+
get value() {
|
|
4992
|
+
var _a25;
|
|
4993
|
+
return cache !== void 0 || (cache = (_a25 = getCellValueOrigin(cellOrigin)) != null ? _a25 : null), cache;
|
|
4518
4994
|
}
|
|
4519
|
-
}
|
|
4520
|
-
|
|
4521
|
-
|
|
4522
|
-
|
|
4995
|
+
}, valueStr = {
|
|
4996
|
+
get value() {
|
|
4997
|
+
var _a25;
|
|
4998
|
+
return `${(_a25 = cellValue.value) != null ? _a25 : ""}`;
|
|
4523
4999
|
}
|
|
4524
|
-
}
|
|
4525
|
-
const colorMap = validator.getListWithColorMap(rule), valueStr = `${(_d = getCellValueOrigin(cellOrigin)) != null ? _d : ""}`, color = colorMap[valueStr];
|
|
4526
|
-
color && (extra = {
|
|
4527
|
-
...extra,
|
|
4528
|
-
interceptorStyle: {
|
|
4529
|
-
...extra.interceptorStyle,
|
|
4530
|
-
bg: {
|
|
4531
|
-
rgb: color
|
|
4532
|
-
}
|
|
4533
|
-
}
|
|
4534
|
-
});
|
|
4535
|
-
}
|
|
5000
|
+
};
|
|
4536
5001
|
return next({
|
|
4537
5002
|
...cell,
|
|
4538
|
-
...extra,
|
|
4539
5003
|
dataValidation: {
|
|
4540
5004
|
ruleId,
|
|
4541
5005
|
validStatus,
|
|
@@ -4547,23 +5011,28 @@ let SheetsDataValidationRenderController = (_a16 = class extends RxDisposable {
|
|
|
4547
5011
|
...validStatus === DataValidationStatus.INVALID ? INVALID_MARK : null
|
|
4548
5012
|
},
|
|
4549
5013
|
customRender: [
|
|
4550
|
-
...(
|
|
5014
|
+
...(_a24 = cell == null ? void 0 : cell.customRender) != null ? _a24 : [],
|
|
4551
5015
|
...validator != null && validator.canvasRender ? [validator.canvasRender] : []
|
|
4552
5016
|
],
|
|
4553
5017
|
fontRenderExtension: {
|
|
4554
5018
|
...cell == null ? void 0 : cell.fontRenderExtension,
|
|
4555
|
-
isSkip: ((
|
|
5019
|
+
isSkip: ((_b = cell == null ? void 0 : cell.fontRenderExtension) == null ? void 0 : _b.isSkip) || ((_c = validator == null ? void 0 : validator.skipDefaultFontRender) == null ? void 0 : _c.call(validator, rule, cellValue.value, pos))
|
|
4556
5020
|
},
|
|
4557
5021
|
interceptorStyle: {
|
|
4558
5022
|
...cell == null ? void 0 : cell.interceptorStyle,
|
|
4559
|
-
...
|
|
5023
|
+
...validator == null ? void 0 : validator.getExtraStyle(rule, valueStr.value, {
|
|
5024
|
+
get style() {
|
|
5025
|
+
const styleMap = workbook.getStyles();
|
|
5026
|
+
return (typeof (cell == null ? void 0 : cell.s) == "string" ? styleMap.get(cell == null ? void 0 : cell.s) : cell == null ? void 0 : cell.s) || {};
|
|
5027
|
+
}
|
|
5028
|
+
})
|
|
4560
5029
|
},
|
|
4561
5030
|
interceptorAutoHeight: /* @__PURE__ */ __name(() => {
|
|
4562
|
-
var
|
|
4563
|
-
const
|
|
4564
|
-
|
|
4565
|
-
return
|
|
4566
|
-
|
|
5031
|
+
var _a25, _b2, _c2, _d2, _e, _f;
|
|
5032
|
+
const skeleton = (_b2 = (_a25 = this._renderManagerService.getRenderById(unitId)) == null ? void 0 : _a25.with(SheetSkeletonManagerService).getWorksheetSkeleton(subUnitId)) == null ? void 0 : _b2.skeleton;
|
|
5033
|
+
if (!skeleton)
|
|
5034
|
+
return;
|
|
5035
|
+
const mergeCell = skeleton.worksheet.getMergedCell(row, col), info = {
|
|
4567
5036
|
data: {
|
|
4568
5037
|
...cell,
|
|
4569
5038
|
dataValidation: {
|
|
@@ -4574,7 +5043,7 @@ let SheetsDataValidationRenderController = (_a16 = class extends RxDisposable {
|
|
|
4574
5043
|
}
|
|
4575
5044
|
},
|
|
4576
5045
|
style: skeleton.getsStyles().getStyleByCell(cell),
|
|
4577
|
-
primaryWithCoord: skeleton.getCellByIndex((
|
|
5046
|
+
primaryWithCoord: skeleton.getCellByIndex((_c2 = mergeCell == null ? void 0 : mergeCell.startRow) != null ? _c2 : row, (_d2 = mergeCell == null ? void 0 : mergeCell.startColumn) != null ? _d2 : col),
|
|
4578
5047
|
unitId,
|
|
4579
5048
|
subUnitId,
|
|
4580
5049
|
row,
|
|
@@ -4582,9 +5051,9 @@ let SheetsDataValidationRenderController = (_a16 = class extends RxDisposable {
|
|
|
4582
5051
|
workbook,
|
|
4583
5052
|
worksheet
|
|
4584
5053
|
};
|
|
4585
|
-
return (
|
|
5054
|
+
return (_f = (_e = validator == null ? void 0 : validator.canvasRender) == null ? void 0 : _e.calcCellAutoHeight) == null ? void 0 : _f.call(_e, info);
|
|
4586
5055
|
}, "interceptorAutoHeight"),
|
|
4587
|
-
coverable: ((
|
|
5056
|
+
coverable: ((_d = cell == null ? void 0 : cell.coverable) != null ? _d : !0) && !(rule.type === DataValidationType.LIST || rule.type === DataValidationType.LIST_MULTIPLE)
|
|
4588
5057
|
});
|
|
4589
5058
|
}, "handler")
|
|
4590
5059
|
}
|
|
@@ -4600,15 +5069,15 @@ let SheetsDataValidationRenderController = (_a16 = class extends RxDisposable {
|
|
|
4600
5069
|
).subscribe((infos) => {
|
|
4601
5070
|
const ranges = [];
|
|
4602
5071
|
if (infos.forEach((info) => {
|
|
4603
|
-
var
|
|
4604
|
-
(
|
|
5072
|
+
var _a24;
|
|
5073
|
+
(_a24 = info.rule) != null && _a24.ranges && ranges.push(...info.rule.ranges);
|
|
4605
5074
|
}), ranges.length) {
|
|
4606
5075
|
const mutations = this._autoHeightController.getUndoRedoParamsOfAutoHeight(ranges);
|
|
4607
5076
|
sequenceExecute(mutations.redos, this._commandService);
|
|
4608
5077
|
}
|
|
4609
5078
|
});
|
|
4610
5079
|
}
|
|
4611
|
-
}, __name(
|
|
5080
|
+
}, __name(_a17, "SheetsDataValidationRenderController"), _a17);
|
|
4612
5081
|
SheetsDataValidationRenderController = __decorateClass$5([
|
|
4613
5082
|
OnLifecycle(LifecycleStages.Rendered, SheetsDataValidationRenderController),
|
|
4614
5083
|
__decorateParam$5(0, ICommandService),
|
|
@@ -4622,17 +5091,17 @@ SheetsDataValidationRenderController = __decorateClass$5([
|
|
|
4622
5091
|
__decorateParam$5(8, Inject(SheetInterceptorService)),
|
|
4623
5092
|
__decorateParam$5(9, Optional(IEditorBridgeService))
|
|
4624
5093
|
], SheetsDataValidationRenderController);
|
|
4625
|
-
var
|
|
4626
|
-
let SheetsDataValidationMobileRenderController = (
|
|
5094
|
+
var _a18;
|
|
5095
|
+
let SheetsDataValidationMobileRenderController = (_a18 = class extends RxDisposable {
|
|
4627
5096
|
constructor(_commandService, _renderManagerService, _univerInstanceService, _autoHeightController, _dataValidatorRegistryService, _sheetInterceptorService, _sheetDataValidationModel) {
|
|
4628
5097
|
super(), this._commandService = _commandService, this._renderManagerService = _renderManagerService, this._univerInstanceService = _univerInstanceService, this._autoHeightController = _autoHeightController, this._dataValidatorRegistryService = _dataValidatorRegistryService, this._sheetInterceptorService = _sheetInterceptorService, this._sheetDataValidationModel = _sheetDataValidationModel, this._initSkeletonChange(), this._initViewModelIntercept(), this._initAutoHeight();
|
|
4629
5098
|
}
|
|
4630
5099
|
_initSkeletonChange() {
|
|
4631
5100
|
const markSkeletonDirty = /* @__PURE__ */ __name(() => {
|
|
4632
|
-
var
|
|
5101
|
+
var _a24, _b, _c;
|
|
4633
5102
|
const workbook = this._univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET);
|
|
4634
5103
|
if (!workbook) return;
|
|
4635
|
-
const unitId = workbook.getUnitId(), subUnitId = (
|
|
5104
|
+
const unitId = workbook.getUnitId(), subUnitId = (_a24 = workbook.getActiveSheet()) == null ? void 0 : _a24.getSheetId();
|
|
4636
5105
|
if (!subUnitId) return;
|
|
4637
5106
|
const skeleton = (_c = (_b = this._renderManagerService.getRenderById(unitId)) == null ? void 0 : _b.with(SheetSkeletonManagerService).getWorksheetSkeleton(subUnitId)) == null ? void 0 : _c.skeleton, currentRender = this._renderManagerService.getRenderById(unitId);
|
|
4638
5107
|
skeleton == null || skeleton.makeDirty(!0), skeleton == null || skeleton.calculate(), currentRender && currentRender.mainComponent.makeForceDirty();
|
|
@@ -4645,46 +5114,21 @@ let SheetsDataValidationMobileRenderController = (_a17 = class extends RxDisposa
|
|
|
4645
5114
|
this._sheetInterceptorService.intercept(
|
|
4646
5115
|
INTERCEPTOR_POINT.CELL_CONTENT,
|
|
4647
5116
|
{
|
|
5117
|
+
effect: InterceptorEffectEnum.Style,
|
|
5118
|
+
// must be after numfmt
|
|
4648
5119
|
priority: InterceptCellContentPriority.DATA_VALIDATION,
|
|
4649
|
-
// eslint-disable-next-line
|
|
5120
|
+
// eslint-disable-next-line complexity
|
|
4650
5121
|
handler: /* @__PURE__ */ __name((cell, pos, next) => {
|
|
4651
|
-
var
|
|
4652
|
-
const { row, col, unitId, subUnitId, workbook, worksheet } = pos,
|
|
4653
|
-
if (!skeleton)
|
|
4654
|
-
return next(cell);
|
|
4655
|
-
const styleMap = pos.workbook.getStyles(), defaultStyle = (typeof (cell == null ? void 0 : cell.s) == "string" ? styleMap.get(cell == null ? void 0 : cell.s) : cell == null ? void 0 : cell.s) || {}, ruleId = this._sheetDataValidationModel.getRuleIdByLocation(unitId, subUnitId, row, col);
|
|
5122
|
+
var _a24, _b, _c, _d;
|
|
5123
|
+
const { row, col, unitId, subUnitId, workbook, worksheet } = pos, ruleId = this._sheetDataValidationModel.getRuleIdByLocation(unitId, subUnitId, row, col);
|
|
4656
5124
|
if (!ruleId)
|
|
4657
5125
|
return next(cell);
|
|
4658
5126
|
const rule = this._sheetDataValidationModel.getRuleById(unitId, subUnitId, ruleId);
|
|
4659
5127
|
if (!rule)
|
|
4660
5128
|
return next(cell);
|
|
4661
|
-
const validStatus = this._sheetDataValidationModel.validator(cell, rule, pos), validator = this._dataValidatorRegistryService.getValidatorItem(rule.type), cellOrigin = worksheet.getCellRaw(row, col), cellValue = getCellValueOrigin(cellOrigin)
|
|
4662
|
-
let extra = {};
|
|
4663
|
-
if ((rule.type === DataValidationType.LIST || rule.type === DataValidationType.LIST_MULTIPLE) && (extra = {
|
|
4664
|
-
interceptorStyle: {
|
|
4665
|
-
...cell == null ? void 0 : cell.interceptorStyle,
|
|
4666
|
-
tb: (_c = defaultStyle.tb !== WrapStrategy.OVERFLOW ? defaultStyle.tb : WrapStrategy.CLIP) != null ? _c : WrapStrategy.WRAP
|
|
4667
|
-
}
|
|
4668
|
-
}), rule.type === DataValidationType.CHECKBOX && (extra = {
|
|
4669
|
-
interceptorStyle: {
|
|
4670
|
-
...cell == null ? void 0 : cell.interceptorStyle,
|
|
4671
|
-
tb: WrapStrategy.CLIP
|
|
4672
|
-
}
|
|
4673
|
-
}), rule.type === DataValidationType.LIST && (rule.renderMode === DataValidationRenderMode.ARROW || rule.renderMode === DataValidationRenderMode.TEXT)) {
|
|
4674
|
-
const colorMap = validator.getListWithColorMap(rule), valueStr = `${(_d = getCellValueOrigin(cellOrigin)) != null ? _d : ""}`, color = colorMap[valueStr];
|
|
4675
|
-
color && (extra = {
|
|
4676
|
-
...extra,
|
|
4677
|
-
interceptorStyle: {
|
|
4678
|
-
...extra.interceptorStyle,
|
|
4679
|
-
bg: {
|
|
4680
|
-
rgb: color
|
|
4681
|
-
}
|
|
4682
|
-
}
|
|
4683
|
-
});
|
|
4684
|
-
}
|
|
5129
|
+
const validStatus = this._sheetDataValidationModel.validator(cell, rule, pos), validator = this._dataValidatorRegistryService.getValidatorItem(rule.type), cellOrigin = worksheet.getCellRaw(row, col), cellValue = getCellValueOrigin(cellOrigin), valueStr = `${cellValue != null ? cellValue : ""}`;
|
|
4685
5130
|
return next({
|
|
4686
5131
|
...cell,
|
|
4687
|
-
...extra,
|
|
4688
5132
|
dataValidation: {
|
|
4689
5133
|
ruleId,
|
|
4690
5134
|
validStatus,
|
|
@@ -4696,25 +5140,28 @@ let SheetsDataValidationMobileRenderController = (_a17 = class extends RxDisposa
|
|
|
4696
5140
|
...validStatus === DataValidationStatus.INVALID ? INVALID_MARK : null
|
|
4697
5141
|
},
|
|
4698
5142
|
customRender: [
|
|
4699
|
-
...(
|
|
5143
|
+
...(_a24 = cell == null ? void 0 : cell.customRender) != null ? _a24 : [],
|
|
4700
5144
|
...validator != null && validator.canvasRender ? [validator.canvasRender] : []
|
|
4701
5145
|
],
|
|
4702
|
-
// @ts-ignore
|
|
4703
5146
|
fontRenderExtension: {
|
|
4704
|
-
// @ts-ignore
|
|
4705
5147
|
...cell == null ? void 0 : cell.fontRenderExtension,
|
|
4706
|
-
isSkip: validator == null ? void 0 : validator.skipDefaultFontRender(rule, cellValue, pos)
|
|
5148
|
+
isSkip: ((_b = cell == null ? void 0 : cell.fontRenderExtension) == null ? void 0 : _b.isSkip) || ((_c = validator == null ? void 0 : validator.skipDefaultFontRender) == null ? void 0 : _c.call(validator, rule, cellValue, pos))
|
|
4707
5149
|
},
|
|
4708
5150
|
interceptorStyle: {
|
|
4709
5151
|
...cell == null ? void 0 : cell.interceptorStyle,
|
|
4710
|
-
...
|
|
5152
|
+
...validator == null ? void 0 : validator.getExtraStyle(rule, valueStr, {
|
|
5153
|
+
get style() {
|
|
5154
|
+
const styleMap = workbook.getStyles();
|
|
5155
|
+
return (typeof (cell == null ? void 0 : cell.s) == "string" ? styleMap.get(cell == null ? void 0 : cell.s) : cell == null ? void 0 : cell.s) || {};
|
|
5156
|
+
}
|
|
5157
|
+
})
|
|
4711
5158
|
},
|
|
4712
5159
|
interceptorAutoHeight: /* @__PURE__ */ __name(() => {
|
|
4713
|
-
var
|
|
4714
|
-
const
|
|
4715
|
-
|
|
4716
|
-
return
|
|
4717
|
-
|
|
5160
|
+
var _a25, _b2, _c2, _d2, _e, _f;
|
|
5161
|
+
const skeleton = (_b2 = (_a25 = this._renderManagerService.getRenderById(unitId)) == null ? void 0 : _a25.with(SheetSkeletonManagerService).getWorksheetSkeleton(subUnitId)) == null ? void 0 : _b2.skeleton;
|
|
5162
|
+
if (!skeleton)
|
|
5163
|
+
return;
|
|
5164
|
+
const mergeCell = skeleton.worksheet.getMergedCell(row, col), info = {
|
|
4718
5165
|
data: {
|
|
4719
5166
|
...cell,
|
|
4720
5167
|
dataValidation: {
|
|
@@ -4725,16 +5172,17 @@ let SheetsDataValidationMobileRenderController = (_a17 = class extends RxDisposa
|
|
|
4725
5172
|
}
|
|
4726
5173
|
},
|
|
4727
5174
|
style: skeleton.getsStyles().getStyleByCell(cell),
|
|
4728
|
-
primaryWithCoord: skeleton.getCellByIndex((
|
|
5175
|
+
primaryWithCoord: skeleton.getCellByIndex((_c2 = mergeCell == null ? void 0 : mergeCell.startRow) != null ? _c2 : row, (_d2 = mergeCell == null ? void 0 : mergeCell.startColumn) != null ? _d2 : col),
|
|
4729
5176
|
unitId,
|
|
4730
5177
|
subUnitId,
|
|
4731
5178
|
row,
|
|
4732
5179
|
col,
|
|
4733
|
-
|
|
4734
|
-
|
|
5180
|
+
workbook,
|
|
5181
|
+
worksheet
|
|
4735
5182
|
};
|
|
4736
|
-
return (
|
|
4737
|
-
}, "interceptorAutoHeight")
|
|
5183
|
+
return (_f = (_e = validator == null ? void 0 : validator.canvasRender) == null ? void 0 : _e.calcCellAutoHeight) == null ? void 0 : _f.call(_e, info);
|
|
5184
|
+
}, "interceptorAutoHeight"),
|
|
5185
|
+
coverable: ((_d = cell == null ? void 0 : cell.coverable) != null ? _d : !0) && !(rule.type === DataValidationType.LIST || rule.type === DataValidationType.LIST_MULTIPLE)
|
|
4738
5186
|
});
|
|
4739
5187
|
}, "handler")
|
|
4740
5188
|
}
|
|
@@ -4748,15 +5196,15 @@ let SheetsDataValidationMobileRenderController = (_a17 = class extends RxDisposa
|
|
|
4748
5196
|
).subscribe((infos) => {
|
|
4749
5197
|
const ranges = [];
|
|
4750
5198
|
if (infos.forEach((info) => {
|
|
4751
|
-
var
|
|
4752
|
-
(
|
|
5199
|
+
var _a24;
|
|
5200
|
+
(_a24 = info.rule) != null && _a24.ranges && ranges.push(...info.rule.ranges);
|
|
4753
5201
|
}), ranges.length) {
|
|
4754
5202
|
const mutations = this._autoHeightController.getUndoRedoParamsOfAutoHeight(ranges);
|
|
4755
5203
|
sequenceExecute(mutations.redos, this._commandService);
|
|
4756
5204
|
}
|
|
4757
5205
|
});
|
|
4758
5206
|
}
|
|
4759
|
-
}, __name(
|
|
5207
|
+
}, __name(_a18, "SheetsDataValidationMobileRenderController"), _a18);
|
|
4760
5208
|
SheetsDataValidationMobileRenderController = __decorateClass$5([
|
|
4761
5209
|
OnLifecycle(LifecycleStages.Rendered, SheetsDataValidationMobileRenderController),
|
|
4762
5210
|
__decorateParam$5(0, ICommandService),
|
|
@@ -4771,8 +5219,8 @@ var __defProp$4 = Object.defineProperty, __getOwnPropDesc$4 = Object.getOwnPrope
|
|
|
4771
5219
|
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$4(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
4772
5220
|
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
4773
5221
|
return kind && result && __defProp$4(target, key, result), result;
|
|
4774
|
-
}, "__decorateClass$4"), __decorateParam$4 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$4"),
|
|
4775
|
-
let SheetsDataValidationValidatorService = (
|
|
5222
|
+
}, "__decorateClass$4"), __decorateParam$4 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$4"), _a19;
|
|
5223
|
+
let SheetsDataValidationValidatorService = (_a19 = class {
|
|
4776
5224
|
constructor(_univerInstanceService, _sheetDataValidationModel, _dataValidationCacheService) {
|
|
4777
5225
|
this._univerInstanceService = _univerInstanceService, this._sheetDataValidationModel = _sheetDataValidationModel, this._dataValidationCacheService = _dataValidationCacheService;
|
|
4778
5226
|
}
|
|
@@ -4825,7 +5273,7 @@ let SheetsDataValidationValidatorService = (_a18 = class {
|
|
|
4825
5273
|
getDataValidation(unitId, subUnitId, ranges) {
|
|
4826
5274
|
return this.getDataValidations(unitId, subUnitId, ranges)[0];
|
|
4827
5275
|
}
|
|
4828
|
-
}, __name(
|
|
5276
|
+
}, __name(_a19, "SheetsDataValidationValidatorService"), _a19);
|
|
4829
5277
|
SheetsDataValidationValidatorService = __decorateClass$4([
|
|
4830
5278
|
__decorateParam$4(0, IUniverInstanceService),
|
|
4831
5279
|
__decorateParam$4(1, Inject(SheetDataValidationModel)),
|
|
@@ -4835,8 +5283,8 @@ var __defProp$3 = Object.defineProperty, __getOwnPropDesc$3 = Object.getOwnPrope
|
|
|
4835
5283
|
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$3(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
4836
5284
|
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
4837
5285
|
return kind && result && __defProp$3(target, key, result), result;
|
|
4838
|
-
}, "__decorateClass$3"), __decorateParam$3 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$3"), __publicField$1 = /* @__PURE__ */ __name((obj, key, value) => __defNormalProp$1(obj, typeof key != "symbol" ? key + "" : key, value), "__publicField$1"),
|
|
4839
|
-
let UniverSheetsDataValidationMobilePlugin = (
|
|
5286
|
+
}, "__decorateClass$3"), __decorateParam$3 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$3"), __publicField$1 = /* @__PURE__ */ __name((obj, key, value) => __defNormalProp$1(obj, typeof key != "symbol" ? key + "" : key, value), "__publicField$1"), _a20;
|
|
5287
|
+
let UniverSheetsDataValidationMobilePlugin = (_a20 = class extends Plugin {
|
|
4840
5288
|
constructor(_config = defaultPluginConfig, _injector, _commandService, _configService) {
|
|
4841
5289
|
super(), this._config = _config, this._injector = _injector, this._commandService = _commandService, this._configService = _configService;
|
|
4842
5290
|
const { menu, ...rest } = this._config;
|
|
@@ -4880,7 +5328,7 @@ let UniverSheetsDataValidationMobilePlugin = (_a19 = class extends Plugin {
|
|
|
4880
5328
|
this._commandService.registerCommand(command);
|
|
4881
5329
|
});
|
|
4882
5330
|
}
|
|
4883
|
-
}, __name(
|
|
5331
|
+
}, __name(_a20, "UniverSheetsDataValidationMobilePlugin"), _a20);
|
|
4884
5332
|
__publicField$1(UniverSheetsDataValidationMobilePlugin, "pluginName", DATA_VALIDATION_PLUGIN_NAME);
|
|
4885
5333
|
__publicField$1(UniverSheetsDataValidationMobilePlugin, "type", UniverInstanceType.UNIVER_SHEET);
|
|
4886
5334
|
UniverSheetsDataValidationMobilePlugin = __decorateClass$3([
|
|
@@ -4893,8 +5341,8 @@ var __defProp$2 = Object.defineProperty, __getOwnPropDesc$2 = Object.getOwnPrope
|
|
|
4893
5341
|
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$2(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
4894
5342
|
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
4895
5343
|
return kind && result && __defProp$2(target, key, result), result;
|
|
4896
|
-
}, "__decorateClass$2"), __decorateParam$2 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$2"),
|
|
4897
|
-
let DataValidationAutoFillController = (
|
|
5344
|
+
}, "__decorateClass$2"), __decorateParam$2 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$2"), _a21;
|
|
5345
|
+
let DataValidationAutoFillController = (_a21 = class extends Disposable {
|
|
4898
5346
|
constructor(_autoFillService, _dataValidationModel, _injector) {
|
|
4899
5347
|
super(), this._autoFillService = _autoFillService, this._dataValidationModel = _dataValidationModel, this._injector = _injector, this._initAutoFill();
|
|
4900
5348
|
}
|
|
@@ -4904,8 +5352,8 @@ let DataValidationAutoFillController = (_a20 = class extends Disposable {
|
|
|
4904
5352
|
const { source: sourceRange, target: targetRange, unitId, subUnitId } = location, ruleMatrixCopy = this._dataValidationModel.getRuleObjectMatrix(unitId, subUnitId).clone(), virtualRange = virtualizeDiscreteRanges([sourceRange, targetRange]), [vSourceRange, vTargetRange] = virtualRange.ranges, { mapFunc } = virtualRange, sourceStartCell = {
|
|
4905
5353
|
row: vSourceRange.startRow,
|
|
4906
5354
|
col: vSourceRange.startColumn
|
|
4907
|
-
};
|
|
4908
|
-
|
|
5355
|
+
}, repeats = getAutoFillRepeatRange(vSourceRange, vTargetRange), additionMatrix = new ObjectMatrix(), additionRules = /* @__PURE__ */ new Set();
|
|
5356
|
+
repeats.forEach((repeat) => {
|
|
4909
5357
|
const targetStartCell = repeat.repeatStartCell, relativeRange = repeat.relativeRange, sourceRange2 = {
|
|
4910
5358
|
startRow: sourceStartCell.row,
|
|
4911
5359
|
startColumn: sourceStartCell.col,
|
|
@@ -4937,10 +5385,12 @@ let DataValidationAutoFillController = (_a20 = class extends Disposable {
|
|
|
4937
5385
|
},
|
|
4938
5386
|
targetRange2
|
|
4939
5387
|
), { row: targetRow, col: targetCol } = mapFunc(targetPositionRange.startRow, targetPositionRange.startColumn);
|
|
4940
|
-
|
|
5388
|
+
additionMatrix.setValue(targetRow, targetCol, ruleId), additionRules.add(ruleId);
|
|
4941
5389
|
}
|
|
4942
5390
|
});
|
|
4943
5391
|
});
|
|
5392
|
+
const additions = Array.from(additionRules).map((id) => ({ id, ranges: queryObjectMatrix(additionMatrix, (value) => value === id) }));
|
|
5393
|
+
ruleMatrixCopy.addRangeRules(additions);
|
|
4944
5394
|
const diffs = ruleMatrixCopy.diff(this._dataValidationModel.getRules(unitId, subUnitId)), { redoMutations, undoMutations } = getDataValidationDiffMutations(unitId, subUnitId, diffs, this._injector, "patched", applyType === APPLY_TYPE.ONLY_FORMAT);
|
|
4945
5395
|
return {
|
|
4946
5396
|
undos: undoMutations,
|
|
@@ -4967,7 +5417,7 @@ let DataValidationAutoFillController = (_a20 = class extends Disposable {
|
|
|
4967
5417
|
};
|
|
4968
5418
|
this.disposeWithMe(this._autoFillService.addHook(hook));
|
|
4969
5419
|
}
|
|
4970
|
-
}, __name(
|
|
5420
|
+
}, __name(_a21, "DataValidationAutoFillController"), _a21);
|
|
4971
5421
|
DataValidationAutoFillController = __decorateClass$2([
|
|
4972
5422
|
OnLifecycle(LifecycleStages.Ready, DataValidationAutoFillController),
|
|
4973
5423
|
__decorateParam$2(0, IAutoFillService),
|
|
@@ -4978,8 +5428,8 @@ var __defProp$1 = Object.defineProperty, __getOwnPropDesc$1 = Object.getOwnPrope
|
|
|
4978
5428
|
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$1(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
4979
5429
|
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
4980
5430
|
return kind && result && __defProp$1(target, key, result), result;
|
|
4981
|
-
}, "__decorateClass$1"), __decorateParam$1 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$1"),
|
|
4982
|
-
let SheetDataValidationSheetController = (
|
|
5431
|
+
}, "__decorateClass$1"), __decorateParam$1 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$1"), _a22;
|
|
5432
|
+
let SheetDataValidationSheetController = (_a22 = class extends Disposable {
|
|
4983
5433
|
constructor(_sheetInterceptorService, _univerInstanceService, _sheetDataValidationModel) {
|
|
4984
5434
|
super(), this._sheetInterceptorService = _sheetInterceptorService, this._univerInstanceService = _univerInstanceService, this._sheetDataValidationModel = _sheetDataValidationModel, this._initSheetChange();
|
|
4985
5435
|
}
|
|
@@ -4987,12 +5437,12 @@ let SheetDataValidationSheetController = (_a21 = class extends Disposable {
|
|
|
4987
5437
|
this.disposeWithMe(
|
|
4988
5438
|
this._sheetInterceptorService.interceptCommand({
|
|
4989
5439
|
getMutations: /* @__PURE__ */ __name((commandInfo) => {
|
|
4990
|
-
var
|
|
5440
|
+
var _a24;
|
|
4991
5441
|
if (commandInfo.id === RemoveSheetCommand.id) {
|
|
4992
5442
|
const params = commandInfo.params, unitId = params.unitId || this._univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET).getUnitId(), workbook = this._univerInstanceService.getUniverSheetInstance(unitId);
|
|
4993
5443
|
if (!workbook)
|
|
4994
5444
|
return { redos: [], undos: [] };
|
|
4995
|
-
const subUnitId = params.subUnitId || ((
|
|
5445
|
+
const subUnitId = params.subUnitId || ((_a24 = workbook.getActiveSheet()) == null ? void 0 : _a24.getSheetId());
|
|
4996
5446
|
if (!subUnitId)
|
|
4997
5447
|
return { redos: [], undos: [] };
|
|
4998
5448
|
const rules = this._sheetDataValidationModel.getRules(unitId, subUnitId), ids = rules.map((i) => i.uid), redoParams = {
|
|
@@ -5022,7 +5472,7 @@ let SheetDataValidationSheetController = (_a21 = class extends Disposable {
|
|
|
5022
5472
|
})
|
|
5023
5473
|
);
|
|
5024
5474
|
}
|
|
5025
|
-
}, __name(
|
|
5475
|
+
}, __name(_a22, "SheetDataValidationSheetController"), _a22);
|
|
5026
5476
|
SheetDataValidationSheetController = __decorateClass$1([
|
|
5027
5477
|
OnLifecycle(LifecycleStages.Ready, SheetDataValidationSheetController),
|
|
5028
5478
|
__decorateParam$1(0, Inject(SheetInterceptorService)),
|
|
@@ -5033,8 +5483,8 @@ var __defProp2 = Object.defineProperty, __getOwnPropDesc = Object.getOwnProperty
|
|
|
5033
5483
|
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
5034
5484
|
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
5035
5485
|
return kind && result && __defProp2(target, key, result), result;
|
|
5036
|
-
}, "__decorateClass"), __decorateParam = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam"), __publicField2 = /* @__PURE__ */ __name((obj, key, value) => __defNormalProp2(obj, typeof key != "symbol" ? key + "" : key, value), "__publicField"),
|
|
5037
|
-
let UniverSheetsDataValidationPlugin = (
|
|
5486
|
+
}, "__decorateClass"), __decorateParam = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam"), __publicField2 = /* @__PURE__ */ __name((obj, key, value) => __defNormalProp2(obj, typeof key != "symbol" ? key + "" : key, value), "__publicField"), _a23;
|
|
5487
|
+
let UniverSheetsDataValidationPlugin = (_a23 = class extends Plugin {
|
|
5038
5488
|
constructor(_config = defaultPluginConfig, _injector, _commandService, _configService) {
|
|
5039
5489
|
super(), this._config = _config, this._injector = _injector, this._commandService = _commandService, this._configService = _configService;
|
|
5040
5490
|
const { menu, ...rest } = this._config;
|
|
@@ -5081,7 +5531,7 @@ let UniverSheetsDataValidationPlugin = (_a22 = class extends Plugin {
|
|
|
5081
5531
|
this._commandService.registerCommand(command);
|
|
5082
5532
|
});
|
|
5083
5533
|
}
|
|
5084
|
-
}, __name(
|
|
5534
|
+
}, __name(_a23, "UniverSheetsDataValidationPlugin"), _a23);
|
|
5085
5535
|
__publicField2(UniverSheetsDataValidationPlugin, "pluginName", DATA_VALIDATION_PLUGIN_NAME);
|
|
5086
5536
|
__publicField2(UniverSheetsDataValidationPlugin, "type", UniverInstanceType.UNIVER_SHEET);
|
|
5087
5537
|
UniverSheetsDataValidationPlugin = __decorateClass([
|