@univerjs/sheets-data-validation 0.2.15 → 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/es/index.js CHANGED
@@ -2,23 +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, getOriginCellValue, Rectangle, Tools, OnLifecycle, LifecycleStages, DataValidationStatus, DataValidationOperator, createInternalEditorID, useDependency, LocaleService, IPermissionService, ThemeService, ICommandService, VerticalAlign, HorizontalAlign, WrapStrategy, toDisposable, DataValidationErrorStyle, UndoCommand, RedoCommand, isUnitRangesEqual, isValidRange, debounce, shallowEqual, Injector, DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY, DisposableCollection, CommandType, BuildTextUtils, DataValidationRenderMode, numfmt, CellValueType, DEFAULT_STYLES, DocumentDataModel, DEFAULT_EMPTY_DOCUMENT_VALUE, BooleanNumber, IUndoRedoService, sequenceExecuteAsync, sequenceExecute, RxDisposable, queryObjectMatrix, isRangesEqual, Optional, DependentOn, Plugin, IConfigService } from "@univerjs/core";
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, checkRangesEditablePermission, getSheetCommandTarget, SetRangeValuesMutation, SetRangeValuesUndoMutationFactory, WorkbookEditablePermission, WorksheetSetCellStylePermission, WorksheetEditPermission, RangeProtectionPermissionEditPoint, SheetInterceptorService, ClearSelectionAllCommand, RefRangeService, handleCommonDefaultRangeChangeWithEffectRefCommands, INTERCEPTOR_POINT, InterceptCellContentPriority, UniverSheetsPlugin, RemoveSheetCommand } from "@univerjs/sheets";
9
- import { LexerTreeBuilder, isReferenceString, deserializeRangeWithSheet, serializeRange, sequenceNodeType, ERROR_TYPE_SET } from "@univerjs/engine-formula";
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, DatePanel } from "@univerjs/design";
14
- import { TextEditor, useObservable, useEvent, ISidebarService, ComponentManager, RangeSelector, IZenZoneService, KeyCode, IDialogService, MenuItemType, getMenuHiddenObservable, RibbonStartGroup, IMenuManagerService } from "@univerjs/ui";
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
20
  import { getPatternType, UniverSheetsNumfmtPlugin } from "@univerjs/sheets-numfmt";
21
- const _DataValidationCacheService = class _DataValidationCacheService {
21
+ import { RichTextEditingMutation } from "@univerjs/docs";
22
+ const DATA_VALIDATION_PLUGIN_NAME = "SHEET_DATA_VALIDATION_PLUGIN", DROP_DOWN_DEFAULT_COLOR = "#ECECEC", _DataValidationCacheService = class _DataValidationCacheService {
22
23
  constructor() {
23
24
  __publicField(this, "_cacheMatrix", /* @__PURE__ */ new Map());
24
25
  }
@@ -116,8 +117,8 @@ let DataValidationCustomFormulaService = (_a = class extends Disposable {
116
117
  for (const subUnitId in unitMap) {
117
118
  const results = unitMap[subUnitId], { formulaCellMap, ruleFormulaMap } = this._ensureMaps(unitId, subUnitId);
118
119
  results.forEach((result) => {
119
- var _a23, _b;
120
- const ruleInfo = ruleFormulaMap.get((_a23 = result.extra) == null ? void 0 : _a23.ruleId), cellInfo = formulaCellMap.get(result.formulaId), rule = this._dataValidationModel.getRuleById(unitId, subUnitId, (_b = result.extra) == null ? void 0 : _b.ruleId);
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);
121
122
  rule && ruleInfo && !ruleInfo.isTransformable && this._dataValidationCacheService.markRangeDirty(unitId, subUnitId, rule.ranges), cellInfo && this._dataValidationCacheService.markCellDirty(unitId, subUnitId, cellInfo.row, cellInfo.column);
122
123
  });
123
124
  }
@@ -195,8 +196,8 @@ let DataValidationCustomFormulaService = (_a = class extends Disposable {
195
196
  });
196
197
  }), newRanges.forEach((range) => {
197
198
  Range.foreach(range, (row, col) => {
198
- var _a23;
199
- const oldValue = (_a23 = formulaMap.getValue(row, col)) != null ? _a23 : {};
199
+ var _a24;
200
+ const oldValue = (_a24 = formulaMap.getValue(row, col)) != null ? _a24 : {};
200
201
  if (oldValue.ruleId !== ruleId) {
201
202
  const oldRuleFormula = ruleFormulaMap.get(oldValue.ruleId);
202
203
  if (oldRuleFormula != null && oldRuleFormula.isTransformable && deleteFormulaIdList.add(oldValue.formulaId), isTransformable) {
@@ -263,8 +264,8 @@ let DataValidationFormulaService = (_a2 = class extends Disposable {
263
264
  for (const subUnitId in unitMap) {
264
265
  const results = unitMap[subUnitId], formulaMap = this._ensureRuleFormulaMap(unitId, subUnitId);
265
266
  results.forEach((result) => {
266
- var _a23, _b;
267
- if (formulaMap.get((_a23 = result.extra) == null ? void 0 : _a23.ruleId)) {
267
+ var _a24, _b;
268
+ if (formulaMap.get((_a24 = result.extra) == null ? void 0 : _a24.ruleId)) {
268
269
  const rule = this._dataValidationModel.getRuleById(unitId, subUnitId, (_b = result.extra) == null ? void 0 : _b.ruleId);
269
270
  rule && this._dataValidationCacheService.markRangeDirty(unitId, subUnitId, rule.ranges);
270
271
  }
@@ -360,47 +361,489 @@ function getCellValueOrigin(cell) {
360
361
  }
361
362
  __name(getCellValueOrigin, "getCellValueOrigin");
362
363
  function getStringCellValue(cell) {
363
- var _a23;
364
- return String((_a23 = getCellValueOrigin(cell)) != null ? _a23 : "");
364
+ var _a24;
365
+ return String((_a24 = getCellValueOrigin(cell)) != null ? _a24 : "");
365
366
  }
366
367
  __name(getStringCellValue, "getStringCellValue");
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
+ );
435
+ }
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;
467
+ }
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;
367
760
  const _RuleMatrix = class _RuleMatrix {
368
- constructor(value, _worksheet) {
369
- __publicField(this, "_map", /* @__PURE__ */ new Map());
370
- this._worksheet = _worksheet, this._map = value;
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
+ });
780
+ });
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);
371
795
  }
372
796
  addRule(rule) {
797
+ if (!this._worksheet)
798
+ return;
373
799
  const ruleId = rule.uid, ranges = rule.ranges.map((range) => Range.transformRange(range, this._worksheet));
374
800
  this._map.forEach((value, key) => {
375
801
  const newRanges = Rectangle.subtractMulti(value, ranges);
376
802
  newRanges.length === 0 ? this._map.delete(key) : this._map.set(key, newRanges);
377
- }), this._map.set(ruleId, ranges);
803
+ }), this._dirty = !0, this._map.set(ruleId, ranges), this._debonceBuildTree();
378
804
  }
379
805
  removeRange(_ranges) {
806
+ if (!this._worksheet)
807
+ return;
380
808
  const ranges = _ranges.map((range) => Range.transformRange(range, this._worksheet));
381
809
  this._map.forEach((value, key) => {
382
810
  const newRanges = Rectangle.subtractMulti(value, ranges);
383
811
  newRanges.length === 0 ? this._map.delete(key) : this._map.set(key, newRanges);
384
- });
812
+ }), this._dirty = !0, this._debonceBuildTree();
385
813
  }
386
814
  removeRule(rule) {
387
- this._map.delete(rule.uid);
815
+ this._map.delete(rule.uid), this._dirty = !0, this._debonceBuildTree();
388
816
  }
389
817
  updateRange(ruleId, _newRanges) {
818
+ if (!this._worksheet)
819
+ return;
390
820
  this._map.delete(ruleId);
391
821
  const ranges = _newRanges.map((range) => Range.transformRange(range, this._worksheet));
392
822
  this._map.forEach((value, key) => {
393
823
  const newRanges = Rectangle.subtractMulti(value, ranges);
394
824
  newRanges.length === 0 ? this._map.delete(key) : this._map.set(key, newRanges);
395
- }), this._map.set(ruleId, ranges);
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);
837
+ });
838
+ }), this._dirty = !0, this._debonceBuildTree();
396
839
  }
397
840
  diff(rules) {
398
841
  const mutations = [];
399
842
  let deleteIndex = 0;
400
843
  return rules.forEach((rule, index) => {
401
- var _a23;
402
- const newRanges = (_a23 = this._map.get(rule.uid)) != null ? _a23 : [], oldRanges = rule.ranges;
403
- (newRanges.length !== oldRanges.length || newRanges.some((range, i) => !Rectangle.equals(range, oldRanges[i]))) && mutations.push({
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({
404
847
  type: "update",
405
848
  ruleId: rule.uid,
406
849
  oldRanges,
@@ -416,9 +859,9 @@ const _RuleMatrix = class _RuleMatrix {
416
859
  const mutations = [];
417
860
  let deleteIndex = 0;
418
861
  return rules.forEach((rule, index) => {
419
- var _a23;
420
- const newRanges = (_a23 = this._map.get(rule.uid)) != null ? _a23 : [], oldRanges = rule.ranges;
421
- (newRanges.length !== oldRanges.length || newRanges.some((range, i) => !Rectangle.equals(range, oldRanges[i]))) && mutations.push({
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({
422
865
  type: "update",
423
866
  ruleId: rule.uid,
424
867
  oldRanges,
@@ -429,8 +872,8 @@ const _RuleMatrix = class _RuleMatrix {
429
872
  index: index - deleteIndex
430
873
  }), deleteIndex++);
431
874
  }), Array.from(additionRules).forEach((rule) => {
432
- var _a23;
433
- const newRanges = (_a23 = this._map.get(rule.uid)) != null ? _a23 : [];
875
+ var _a24;
876
+ const newRanges = (_a24 = this._map.get(rule.uid)) != null ? _a24 : [];
434
877
  mutations.push({
435
878
  type: "add",
436
879
  rule: {
@@ -441,27 +884,22 @@ const _RuleMatrix = class _RuleMatrix {
441
884
  }), mutations;
442
885
  }
443
886
  clone() {
444
- return new _RuleMatrix(new Map(Tools.deepClone(Array.from(this._map.entries()))), this._worksheet);
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
+ );
445
895
  }
446
896
  getValue(row, col) {
447
- var _a23;
448
- const keys = Array.from(this._map.keys());
449
- for (const id of keys)
450
- if (((_a23 = this._map.get(id)) != null ? _a23 : []).find((range) => range.startRow <= row && range.endRow >= row && range.startColumn <= col && range.endColumn >= col))
451
- return id;
452
- }
453
- addRangeRules(rules) {
454
- rules.forEach(({ id: ruleId, ranges }) => {
455
- if (!ranges.length)
456
- return;
457
- let current = this._map.get(ruleId);
458
- 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) => {
459
- if (key === ruleId)
460
- return;
461
- const newRanges = Rectangle.subtractMulti(value, ranges);
462
- newRanges.length === 0 ? this._map.delete(key) : this._map.set(key, newRanges);
463
- });
464
- });
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;
465
903
  }
466
904
  };
467
905
  __name(_RuleMatrix, "RuleMatrix");
@@ -470,18 +908,32 @@ var __defProp$i = Object.defineProperty, __getOwnPropDesc$i = Object.getOwnPrope
470
908
  for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$i(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
471
909
  (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
472
910
  return kind && result && __defProp$i(target, key, result), result;
473
- }, "__decorateClass$i"), __decorateParam$i = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$i"), _a3;
474
- let SheetDataValidationModel = (_a3 = class extends Disposable {
475
- 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) {
476
914
  super();
477
915
  __publicField(this, "_ruleMatrixMap", /* @__PURE__ */ new Map());
478
916
  __publicField(this, "_validStatusChange$", new Subject());
479
917
  __publicField(this, "_ruleChange$", new Subject());
480
918
  __publicField(this, "ruleChange$", this._ruleChange$.asObservable());
481
919
  __publicField(this, "validStatusChange$", this._validStatusChange$.asObservable());
482
- 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(() => {
483
921
  this._ruleChange$.complete(), this._validStatusChange$.complete();
484
- });
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
+ );
485
937
  }
486
938
  _initRuleUpdateListener() {
487
939
  const allRules = this._dataValidationModel.getAll();
@@ -513,22 +965,12 @@ let SheetDataValidationModel = (_a3 = class extends Disposable {
513
965
  }
514
966
  _ensureRuleMatrix(unitId, subUnitId) {
515
967
  let unitMap = this._ruleMatrixMap.get(unitId);
516
- const workbook = this._univerInstanceService.getUnit(unitId, UniverInstanceType.UNIVER_SHEET);
517
- if (!workbook)
518
- throw new Error(`workbook not found, unitId: ${unitId}`);
519
968
  unitMap || (unitMap = /* @__PURE__ */ new Map(), this._ruleMatrixMap.set(unitId, unitMap));
520
969
  let matrix = unitMap.get(subUnitId);
521
- if (!matrix) {
522
- const worksheet = workbook.getSheetBySheetId(subUnitId);
523
- if (!worksheet)
524
- throw new Error(`worksheet not found, unitId: ${unitId}, subUnitId: ${subUnitId}`);
525
- matrix = new RuleMatrix(/* @__PURE__ */ new Map(), worksheet), unitMap.set(subUnitId, matrix);
526
- }
527
- return matrix;
970
+ return matrix || (matrix = new RuleMatrix(/* @__PURE__ */ new Map(), unitId, subUnitId, this._univerInstanceService), unitMap.set(subUnitId, matrix)), matrix;
528
971
  }
529
972
  _addRuleSideEffect(unitId, subUnitId, rule) {
530
- var _a23;
531
- (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);
532
974
  }
533
975
  _addRule(unitId, subUnitId, rule) {
534
976
  (Array.isArray(rule) ? rule : [rule]).forEach((item) => {
@@ -625,7 +1067,7 @@ let SheetDataValidationModel = (_a3 = class extends Disposable {
625
1067
  getAll() {
626
1068
  return this._dataValidationModel.getAll();
627
1069
  }
628
- }, __name(_a3, "SheetDataValidationModel"), _a3);
1070
+ }, __name(_a4, "SheetDataValidationModel"), _a4);
629
1071
  SheetDataValidationModel = __decorateClass$i([
630
1072
  OnLifecycle(LifecycleStages.Starting, SheetDataValidationModel),
631
1073
  __decorateParam$i(0, Inject(DataValidationModel)),
@@ -633,7 +1075,8 @@ SheetDataValidationModel = __decorateClass$i([
633
1075
  __decorateParam$i(2, Inject(DataValidatorRegistryService)),
634
1076
  __decorateParam$i(3, Inject(DataValidationCacheService)),
635
1077
  __decorateParam$i(4, Inject(DataValidationFormulaService)),
636
- __decorateParam$i(5, Inject(DataValidationCustomFormulaService))
1078
+ __decorateParam$i(5, Inject(DataValidationCustomFormulaService)),
1079
+ __decorateParam$i(6, ICommandService)
637
1080
  ], SheetDataValidationModel);
638
1081
  function createDefaultNewRule(accessor) {
639
1082
  const currentRanges = accessor.get(SheetsSelectionsService).getCurrentSelections().map((s) => s.range);
@@ -647,13 +1090,13 @@ function createDefaultNewRule(accessor) {
647
1090
  }
648
1091
  __name(createDefaultNewRule, "createDefaultNewRule");
649
1092
  function getFormulaResult(result) {
650
- var _a23, _b;
651
- return (_b = (_a23 = result == null ? void 0 : result[0]) == null ? void 0 : _a23[0]) == null ? void 0 : _b.v;
1093
+ var _a24, _b;
1094
+ return (_b = (_a24 = result == null ? void 0 : result[0]) == null ? void 0 : _a24[0]) == null ? void 0 : _b.v;
652
1095
  }
653
1096
  __name(getFormulaResult, "getFormulaResult");
654
1097
  function getFormulaCellData(result) {
655
- var _a23;
656
- return (_a23 = result == null ? void 0 : result[0]) == null ? void 0 : _a23[0];
1098
+ var _a24;
1099
+ return (_a24 = result == null ? void 0 : result[0]) == null ? void 0 : _a24[0];
657
1100
  }
658
1101
  __name(getFormulaCellData, "getFormulaCellData");
659
1102
  var commonjsGlobal = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
@@ -686,12 +1129,12 @@ reactJsxRuntime_production_min.jsxs = q;
686
1129
  jsxRuntime.exports = reactJsxRuntime_production_min;
687
1130
  var jsxRuntimeExports = jsxRuntime.exports;
688
1131
  function CustomFormulaInput(props) {
689
- var _a23;
1132
+ var _a24;
690
1133
  const { unitId, subUnitId, value, onChange, showError, validResult } = props, formula1Res = showError ? validResult == null ? void 0 : validResult.formula1 : "";
691
1134
  return /* @__PURE__ */ jsxRuntimeExports.jsx(FormLayout, { error: formula1Res, children: /* @__PURE__ */ jsxRuntimeExports.jsx(
692
1135
  TextEditor,
693
1136
  {
694
- value: (_a23 = value == null ? void 0 : value.formula1) != null ? _a23 : "",
1137
+ value: (_a24 = value == null ? void 0 : value.formula1) != null ? _a24 : "",
695
1138
  id: createInternalEditorID(`dataValidation-custom-formula-${unitId}-${subUnitId}`),
696
1139
  onChange: /* @__PURE__ */ __name((newValue) => {
697
1140
  onChange == null || onChange({
@@ -789,15 +1232,15 @@ function replaceRuntimeIdsAndExtInAttrs(node, runtimeProps, extend) {
789
1232
  var attrs = __assign({}, node.attrs);
790
1233
  extend != null && extend.colorChannel1 && attrs.fill === "colorChannel1" && (attrs.fill = extend.colorChannel1);
791
1234
  var defIds = runtimeProps.defIds;
792
- return !defIds || defIds.length === 0 || (node.tag === "use" && attrs["xlink:href"] && (attrs["xlink:href"] = attrs["xlink:href"] + runtimeProps.idSuffix), Object.entries(attrs).forEach(function(_a23) {
793
- var key = _a23[0], value = _a23[1];
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];
794
1237
  typeof value == "string" && (attrs[key] = value.replace(/url\(#(.*)\)/, "url(#$1".concat(runtimeProps.idSuffix, ")")));
795
1238
  })), attrs;
796
1239
  }
797
1240
  __name(replaceRuntimeIdsAndExtInAttrs, "replaceRuntimeIdsAndExtInAttrs");
798
1241
  function replaceRuntimeIdsInDefs(node, runtimeProps) {
799
- var _a23, defIds = runtimeProps.defIds;
800
- return !defIds || defIds.length === 0 ? node : node.tag === "defs" && (!((_a23 = node.children) === null || _a23 === void 0) && _a23.length) ? __assign(__assign({}, node), { children: node.children.map(function(child) {
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) {
801
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;
802
1245
  }) }) : node;
803
1246
  }
@@ -863,31 +1306,17 @@ var element = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width:
863
1306
  }));
864
1307
  });
865
1308
  SequenceSingle.displayName = "SequenceSingle";
866
- function serializeListOptions(options) {
867
- return options.filter(Boolean).join(",");
868
- }
869
- __name(serializeListOptions, "serializeListOptions");
870
- function deserializeListOptions(optionsStr) {
871
- return optionsStr.split(",").filter(Boolean);
872
- }
873
- __name(deserializeListOptions, "deserializeListOptions");
874
- function getDataValidationCellValue(cellData) {
875
- const cellValue = getCellValueOrigin(cellData);
876
- return cellValue == null ? "" : cellValue.toString();
877
- }
878
- __name(getDataValidationCellValue, "getDataValidationCellValue");
879
- const DATA_VALIDATION_PLUGIN_NAME = "SHEET_DATA_VALIDATION_PLUGIN", DROP_DOWN_DEFAULT_COLOR = "#ECECEC";
880
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) => {
881
1310
  for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$h(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
882
1311
  (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
883
1312
  return kind && result && __defProp$h(target, key, result), result;
884
- }, "__decorateClass$h"), __decorateParam$h = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$h"), _a4;
885
- let DataValidationFormulaController = (_a4 = class extends Disposable {
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 {
886
1315
  constructor(_univerInstanceService, _permissionService, _lexerTreeBuilder) {
887
1316
  super(), this._univerInstanceService = _univerInstanceService, this._permissionService = _permissionService, this._lexerTreeBuilder = _lexerTreeBuilder;
888
1317
  }
889
1318
  getFormulaRefCheck(formulaString) {
890
- var _a23, _b;
1319
+ var _a24, _b;
891
1320
  const sequenceNodes = this._lexerTreeBuilder.sequenceNodesBuilder(formulaString);
892
1321
  if (!sequenceNodes)
893
1322
  return !0;
@@ -909,20 +1338,33 @@ let DataValidationFormulaController = (_a4 = class extends Disposable {
909
1338
  const { startRow, endRow, startColumn, endColumn } = sequenceGrid.range;
910
1339
  for (let i2 = startRow; i2 <= endRow; i2++)
911
1340
  for (let j = startColumn; j <= endColumn; j++) {
912
- const permission = (_b = (_a23 = targetSheet.getCell(i2, j)) == null ? void 0 : _a23.selectionProtection) == null ? void 0 : _b[0];
1341
+ const permission = (_b = (_a24 = targetSheet.getCell(i2, j)) == null ? void 0 : _a24.selectionProtection) == null ? void 0 : _b[0];
913
1342
  if ((permission == null ? void 0 : permission[P.View]) === !1)
914
1343
  return !1;
915
1344
  }
916
1345
  }
917
1346
  return !0;
918
1347
  }
919
- }, __name(_a4, "DataValidationFormulaController"), _a4);
1348
+ }, __name(_a5, "DataValidationFormulaController"), _a5);
920
1349
  DataValidationFormulaController = __decorateClass$h([
921
1350
  OnLifecycle(LifecycleStages.Rendered, DataValidationFormulaController),
922
1351
  __decorateParam$h(0, IUniverInstanceService),
923
1352
  __decorateParam$h(1, IPermissionService),
924
1353
  __decorateParam$h(2, Inject(LexerTreeBuilder))
925
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");
926
1368
  const DEFAULT_COLOR_PRESET = [
927
1369
  "#FFFFFF",
928
1370
  "#FEE7E7",
@@ -1235,14 +1677,14 @@ var __defProp$g = Object.defineProperty, __getOwnPropDesc$g = Object.getOwnPrope
1235
1677
  return kind && result && __defProp$g(target, key, result), result;
1236
1678
  }, "__decorateClass$g"), __decorateParam$g = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$g");
1237
1679
  const MARGIN_H$2 = 6;
1238
- var _a5;
1239
- let CheckboxRender = (_a5 = class {
1680
+ var _a6;
1681
+ let CheckboxRender = (_a6 = class {
1240
1682
  constructor(_commandService, _formulaService, _themeService) {
1241
1683
  this._commandService = _commandService, this._formulaService = _formulaService, this._themeService = _themeService;
1242
1684
  }
1243
1685
  _calc(cellInfo, style) {
1244
- var _a23, _b, _c;
1245
- const { vt, ht } = style || {}, width = cellInfo.endX - cellInfo.startX - MARGIN_H$2 * 2, height = cellInfo.endY - cellInfo.startY, size = ((_a23 = style == null ? void 0 : style.fs) != null ? _a23 : 10) * 1.6;
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;
1246
1688
  let widgetLeft = 0, widgetTop = 0;
1247
1689
  switch (vt) {
1248
1690
  case VerticalAlign.TOP:
@@ -1274,25 +1716,25 @@ let CheckboxRender = (_a5 = class {
1274
1716
  };
1275
1717
  }
1276
1718
  calcCellAutoHeight(info) {
1277
- var _a23;
1719
+ var _a24;
1278
1720
  const { style } = info;
1279
- return ((_a23 = style == null ? void 0 : style.fs) != null ? _a23 : 10) * 1.6;
1721
+ return ((_a24 = style == null ? void 0 : style.fs) != null ? _a24 : 10) * 1.6;
1280
1722
  }
1281
1723
  async _parseFormula(rule, unitId, subUnitId) {
1282
- var _a23, _b;
1724
+ var _a24, _b;
1283
1725
  const { formula1 = CHECKBOX_FORMULA_1, formula2 = CHECKBOX_FORMULA_2 } = rule, results = await this._formulaService.getRuleFormulaResult(unitId, subUnitId, rule.uid);
1284
1726
  return {
1285
- formula1: isFormulaString(formula1) ? getFormulaResult((_a23 = results == null ? void 0 : results[0]) == null ? void 0 : _a23.result) : formula1,
1727
+ formula1: isFormulaString(formula1) ? getFormulaResult((_a24 = results == null ? void 0 : results[0]) == null ? void 0 : _a24.result) : formula1,
1286
1728
  formula2: isFormulaString(formula2) ? getFormulaResult((_b = results == null ? void 0 : results[1]) == null ? void 0 : _b.result) : formula2
1287
1729
  };
1288
1730
  }
1289
1731
  drawWith(ctx, info) {
1290
- var _a23, _b, _c, _d, _e;
1291
- const { style, data, primaryWithCoord, unitId, subUnitId, worksheet, row, col } = info, cellBounding = primaryWithCoord.isMergedMainCell ? primaryWithCoord.mergeInfo : primaryWithCoord, value = getCellValueOrigin(worksheet.getCellRaw(row, col)), rule = (_a23 = data.dataValidation) == null ? void 0 : _a23.rule, validator = (_b = data.dataValidation) == null ? void 0 : _b.validator;
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;
1292
1734
  if (!rule || !validator)
1293
1735
  return;
1294
1736
  const colors = this._themeService.getCurrentTheme();
1295
- if (!validator.skipDefaultFontRender(rule, value, { unitId, subUnitId }))
1737
+ if (!((_c = validator.skipDefaultFontRender) != null && _c.call(validator, rule, value, { unitId, subUnitId })))
1296
1738
  return;
1297
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({
1298
1740
  left,
@@ -1308,12 +1750,12 @@ let CheckboxRender = (_a5 = class {
1308
1750
  ctx.save(), ctx.beginPath(), ctx.rect(cellBounding.startX, cellBounding.startY, cellWidth, cellHeight), ctx.clip();
1309
1751
  const m2 = transform.getMatrix();
1310
1752
  ctx.transform(m2[0], m2[1], m2[2], m2[3], m2[4], m2[5]);
1311
- const size = ((_c = style == null ? void 0 : style.fs) != null ? _c : 10) * 1.6, checked = String(value) === String(formula1), defaultColor = colors.hyacinth500;
1753
+ const size = ((_d = style == null ? void 0 : style.fs) != null ? _d : 10) * 1.6, checked = String(value) === String(formula1), defaultColor = colors.hyacinth500;
1312
1754
  Checkbox$1.drawWith(ctx, {
1313
1755
  checked,
1314
1756
  width: size,
1315
1757
  height: size,
1316
- fill: (_e = (_d = style == null ? void 0 : style.cl) == null ? void 0 : _d.rgb) != null ? _e : defaultColor
1758
+ fill: (_f = (_e = style == null ? void 0 : style.cl) == null ? void 0 : _e.rgb) != null ? _f : defaultColor
1317
1759
  }), ctx.restore();
1318
1760
  }
1319
1761
  isHit(evt, info) {
@@ -1321,11 +1763,11 @@ let CheckboxRender = (_a5 = class {
1321
1763
  return offsetX <= endX && offsetX >= startX && offsetY <= endY && offsetY >= startY;
1322
1764
  }
1323
1765
  async onPointerDown(info, evt) {
1324
- var _a23, _b;
1766
+ var _a24, _b, _c;
1325
1767
  if (evt.button === 2)
1326
1768
  return;
1327
- const { primaryWithCoord, unitId, subUnitId, data, worksheet, row, col } = info, value = getCellValueOrigin(worksheet.getCellRaw(row, col)), rule = (_a23 = data.dataValidation) == null ? void 0 : _a23.rule, validator = (_b = data.dataValidation) == null ? void 0 : _b.validator;
1328
- 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 })))
1329
1771
  return;
1330
1772
  const { formula1, formula2 } = await this._parseFormula(rule, unitId, subUnitId), params = {
1331
1773
  range: {
@@ -1344,7 +1786,7 @@ let CheckboxRender = (_a5 = class {
1344
1786
  params
1345
1787
  );
1346
1788
  }
1347
- }, __name(_a5, "CheckboxRender"), _a5);
1789
+ }, __name(_a6, "CheckboxRender"), _a6);
1348
1790
  CheckboxRender = __decorateClass$g([
1349
1791
  __decorateParam$g(0, ICommandService),
1350
1792
  __decorateParam$g(1, Inject(DataValidationFormulaService)),
@@ -1365,10 +1807,10 @@ const transformCheckboxValue = /* @__PURE__ */ __name((value) => Tools.isDefine(
1365
1807
  __publicField(this, "formulaInput", CHECKBOX_FORMULA_INPUT_NAME);
1366
1808
  __publicField(this, "canvasRender", this.injector.createInstance(CheckboxRender));
1367
1809
  __publicField(this, "_formulaService", this.injector.get(DataValidationFormulaService));
1368
- }
1369
- skipDefaultFontRender(rule, cellValue, pos) {
1370
- const { formula1, formula2 } = this.parseFormulaSync(rule, pos.unitId, pos.subUnitId), valueStr = `${cellValue != null ? cellValue : ""}`;
1371
- return !valueStr || valueStr === `${formula1}` || valueStr === `${formula2}`;
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"));
1372
1814
  }
1373
1815
  validatorFormula(rule, unitId, subUnitId) {
1374
1816
  const { formula1, formula2 } = rule, isEqual = formula1 === formula2;
@@ -1390,8 +1832,8 @@ const transformCheckboxValue = /* @__PURE__ */ __name((value) => Tools.isDefine(
1390
1832
  };
1391
1833
  }
1392
1834
  async parseFormula(rule, unitId, subUnitId) {
1393
- var _a23, _b;
1394
- const { formula1 = CHECKBOX_FORMULA_1, formula2 = CHECKBOX_FORMULA_2 } = rule, results = await this._formulaService.getRuleFormulaResult(unitId, subUnitId, rule.uid), originFormula1 = isFormulaString(formula1) ? getFormulaResult((_a23 = results == null ? void 0 : results[0]) == null ? void 0 : _a23.result) : formula1, originFormula2 = isFormulaString(formula2) ? getFormulaResult((_b = results == null ? void 0 : results[1]) == null ? void 0 : _b.result) : formula2;
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;
1395
1837
  return {
1396
1838
  formula1: transformCheckboxValue(originFormula1),
1397
1839
  formula2: transformCheckboxValue(originFormula2),
@@ -1405,8 +1847,8 @@ const transformCheckboxValue = /* @__PURE__ */ __name((value) => Tools.isDefine(
1405
1847
  };
1406
1848
  }
1407
1849
  parseFormulaSync(rule, unitId, subUnitId) {
1408
- var _a23, _b;
1409
- const { formula1 = CHECKBOX_FORMULA_1, formula2 = CHECKBOX_FORMULA_2 } = rule, results = this._formulaService.getRuleFormulaResultSync(unitId, subUnitId, rule.uid), originFormula1 = isFormulaString(formula1) ? getFormulaResult((_a23 = results == null ? void 0 : results[0]) == null ? void 0 : _a23.result) : formula1, originFormula2 = isFormulaString(formula2) ? getFormulaResult((_b = results == null ? void 0 : results[1]) == null ? void 0 : _b.result) : formula2;
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;
1410
1852
  return {
1411
1853
  formula1: transformCheckboxValue(originFormula1),
1412
1854
  formula2: transformCheckboxValue(originFormula2),
@@ -1457,430 +1899,255 @@ const DateOperatorTitleMap = {
1457
1899
  DataValidationOperator.BETWEEN,
1458
1900
  DataValidationOperator.NOT_BETWEEN
1459
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);
1460
1978
  var __defProp$f = Object.defineProperty, __getOwnPropDesc$f = Object.getOwnPropertyDescriptor, __decorateClass$f = /* @__PURE__ */ __name((decorators, target, key, kind) => {
1461
1979
  for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$f(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
1462
1980
  (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
1463
1981
  return kind && result && __defProp$f(target, key, result), result;
1464
- }, "__decorateClass$f"), __decorateParam$f = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$f"), _a6;
1465
- let DataValidationPanelService = (_a6 = class extends Disposable {
1466
- constructor(_univerInstanceService, _sidebarService) {
1467
- super();
1468
- __publicField(this, "_open$", new BehaviorSubject(!1));
1469
- __publicField(this, "open$", this._open$.pipe(distinctUntilChanged()));
1470
- __publicField(this, "_activeRule");
1471
- __publicField(this, "_activeRule$", new BehaviorSubject(void 0));
1472
- __publicField(this, "activeRule$", this._activeRule$.asObservable());
1473
- __publicField(this, "_closeDisposable", null);
1474
- this._univerInstanceService = _univerInstanceService, this._sidebarService = _sidebarService, this.disposeWithMe(
1475
- this._univerInstanceService.getCurrentTypeOfUnit$(UniverInstanceType.UNIVER_SHEET).pipe(filter((sheet) => !sheet)).subscribe(() => {
1476
- this.close();
1477
- })
1478
- );
1479
- }
1480
- get activeRule() {
1481
- return this._activeRule;
1482
- }
1483
- get isOpen() {
1484
- return this._open$.getValue();
1485
- }
1486
- dispose() {
1487
- var _a23;
1488
- super.dispose(), this._open$.next(!1), this._open$.complete(), this._activeRule$.complete(), (_a23 = this._closeDisposable) == null || _a23.dispose();
1489
- }
1490
- open() {
1491
- this._open$.next(!0);
1492
- }
1493
- close() {
1494
- var _a23;
1495
- this._open$.next(!1), (_a23 = this._closeDisposable) == null || _a23.dispose();
1496
- }
1497
- setCloseDisposable(disposable) {
1498
- this._closeDisposable = toDisposable(() => {
1499
- disposable.dispose(), this._closeDisposable = null;
1500
- });
1501
- }
1502
- setActiveRule(rule) {
1503
- 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();
1504
1986
  }
1505
- }, __name(_a6, "DataValidationPanelService"), _a6);
1506
- DataValidationPanelService = __decorateClass$f([
1507
- __decorateParam$f(0, IUniverInstanceService),
1508
- __decorateParam$f(1, ISidebarService)
1509
- ], DataValidationPanelService);
1510
- const dataValidationOptionsButton = "univer-data-validation-options-button", dataValidationOptionsButtonIcon = "univer-data-validation-options-button-icon", styles$5 = {
1511
- dataValidationOptionsButton,
1512
- dataValidationOptionsButtonIcon
1513
- };
1514
- function DataValidationOptions(props) {
1515
- var _a23;
1516
- const localeService = useDependency(LocaleService), componentManager = useDependency(ComponentManager), { value, onChange, extraComponent } = props, [show, setShow] = useState(!1), ExtraOptions = extraComponent ? componentManager.get(extraComponent) : null;
1517
- return /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
1518
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: styles$5.dataValidationOptionsButton, onClick: /* @__PURE__ */ __name(() => setShow(!show), "onClick"), children: [
1519
- localeService.t("dataValidation.panel.options"),
1520
- show ? /* @__PURE__ */ jsxRuntimeExports.jsx(MoreUpSingle, { className: styles$5.dataValidationOptionsButtonIcon }) : /* @__PURE__ */ jsxRuntimeExports.jsx(MoreDownSingle, { className: styles$5.dataValidationOptionsButtonIcon })
1521
- ] }),
1522
- show && /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
1523
- ExtraOptions ? /* @__PURE__ */ jsxRuntimeExports.jsx(ExtraOptions, { value, onChange }) : null,
1524
- /* @__PURE__ */ jsxRuntimeExports.jsx(
1525
- FormLayout,
1526
- {
1527
- label: localeService.t("dataValidation.panel.invalid"),
1528
- children: /* @__PURE__ */ jsxRuntimeExports.jsxs(
1529
- RadioGroup,
1530
- {
1531
- value: `${(_a23 = value.errorStyle) != null ? _a23 : DataValidationErrorStyle.WARNING}`,
1532
- onChange: /* @__PURE__ */ __name((errorStyle) => onChange({ ...value, errorStyle: +errorStyle }), "onChange"),
1533
- children: [
1534
- /* @__PURE__ */ jsxRuntimeExports.jsx(Radio, { value: `${DataValidationErrorStyle.WARNING}`, children: localeService.t("dataValidation.panel.showWarning") }),
1535
- /* @__PURE__ */ jsxRuntimeExports.jsx(Radio, { value: `${DataValidationErrorStyle.STOP}`, children: localeService.t("dataValidation.panel.rejectInput") })
1536
- ]
1537
- }
1538
- )
1539
- }
1540
- ),
1541
- /* @__PURE__ */ jsxRuntimeExports.jsx(
1542
- FormLayout,
1543
- {
1544
- label: localeService.t("dataValidation.panel.messageInfo"),
1545
- children: /* @__PURE__ */ jsxRuntimeExports.jsx(
1546
- Checkbox,
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(
1547
1998
  {
1548
- checked: value.showErrorMessage,
1549
- onChange: /* @__PURE__ */ __name(() => onChange({
1550
- ...value,
1551
- showErrorMessage: !value.showErrorMessage
1552
- }), "onChange"),
1553
- children: localeService.t("dataValidation.panel.showInfo")
1554
- }
1555
- )
1556
- }
1557
- ),
1558
- value.showErrorMessage ? /* @__PURE__ */ jsxRuntimeExports.jsx(FormLayout, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(Input, { value: value.error, onChange: /* @__PURE__ */ __name((error) => onChange({ ...value, error }), "onChange") }) }) : null
1559
- ] })
1560
- ] });
1561
- }
1562
- __name(DataValidationOptions, "DataValidationOptions");
1563
- const dataValidationDetailFormItem = "univer-data-validation-detail-form-item", dataValidationDetailButtons = "univer-data-validation-detail-buttons", dataValidationDetailButton = "univer-data-validation-detail-button", styles$4 = {
1564
- dataValidationDetailFormItem,
1565
- dataValidationDetailButtons,
1566
- dataValidationDetailButton
1567
- }, debounceExecuteFactory = /* @__PURE__ */ __name((commandService) => debounce(
1568
- async (id, params, options, callback) => {
1569
- const res = await commandService.executeCommand(id, params, options);
1570
- callback == null || callback(res);
1571
- },
1572
- 1e3
1573
- ), "debounceExecuteFactory");
1574
- function DataValidationDetail() {
1575
- 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]);
1576
- if (useEffect(() => {
1577
- commandService.onCommandExecuted((commandInfo) => {
1578
- (commandInfo.id === UndoCommand.id || commandInfo.id === RedoCommand.id) && setTimeout(() => {
1579
- const activeRule = dataValidationModel.getRuleById(unitId, subUnitId, ruleId);
1580
- setKey((k2) => k2 + 1), activeRule && (setLocalRule(activeRule), setLocalRanges(activeRule.ranges.map((i) => ({ unitId: "", sheetId: "", range: i }))));
1581
- }, 20);
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")
1582
2063
  });
1583
- }, [commandService, dataValidationModel, ruleId, subUnitId, unitId]), !validator)
1584
- return null;
1585
- const operators = validator.operators, operatorNames = validator.operatorNames, isTwoFormula = localRule.operator ? TWO_FORMULA_OPERATOR_COUNT$1.includes(localRule.operator) : !1, handleOk = /* @__PURE__ */ __name(() => {
1586
- localRule.ranges.length && (validator.validatorFormula(localRule, unitId, subUnitId).success ? dataValidationPanelService.setActiveRule(null) : setShowError(!0));
1587
- }, "handleOk"), handleUpdateRuleRanges = useEvent((unitRanges) => {
1588
- if (isUnitRangesEqual(unitRanges, localRanges))
1589
- return;
1590
- setLocalRanges(unitRanges);
1591
- const ranges = unitRanges.filter((i) => (!i.unitId || i.unitId === unitId) && (!i.sheetId || i.sheetId === subUnitId)).map((i) => i.range);
1592
- if (setLocalRule({
1593
- ...localRule,
1594
- ranges
1595
- }), ranges.length === 0)
1596
- return;
1597
- const params = {
1598
- unitId,
1599
- subUnitId,
1600
- ruleId,
1601
- ranges
1602
- };
1603
- debounceExecute(UpdateSheetDataValidationRangeCommand.id, params);
1604
- }), handleUpdateRuleSetting = /* @__PURE__ */ __name((setting) => {
1605
- if (shallowEqual(setting, getRuleSetting(localRule)))
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)
1606
2096
  return;
1607
- setLocalRule({
1608
- ...localRule,
1609
- ...setting
1610
- });
1611
- 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,
1612
2100
  unitId,
1613
2101
  subUnitId,
1614
- ruleId,
1615
- setting
1616
- };
1617
- debounceExecute(
1618
- UpdateSheetDataValidationSettingCommand.id,
1619
- params,
1620
- void 0
1621
- );
1622
- }, "handleUpdateRuleSetting"), handleDelete = /* @__PURE__ */ __name(async () => {
1623
- await commandService.executeCommand(RemoveSheetDataValidationCommand.id, {
1624
- ruleId,
1625
- unitId,
1626
- subUnitId
1627
- }), dataValidationPanelService.setActiveRule(null);
1628
- }, "handleDelete"), baseRule = {
1629
- type: localRule.type,
1630
- operator: localRule.operator,
1631
- formula1: localRule.formula1,
1632
- formula2: localRule.formula2,
1633
- allowBlank: localRule.allowBlank
1634
- }, handleChangeType = /* @__PURE__ */ __name((newType) => {
1635
- const validator2 = validatorService.getValidatorItem(newType);
1636
- if (!validator2)
1637
- return;
1638
- 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")) ? {
1639
- ...rule2,
1640
- type: newType
1641
- } : {
1642
- ...localRule,
1643
- type: newType,
1644
- operator: operators2[0],
1645
- formula1: void 0,
1646
- formula2: void 0
1647
- };
1648
- 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, {
1649
2109
  unitId,
1650
2110
  subUnitId,
1651
- ruleId: localRule.uid,
1652
- setting: getRuleSetting(newRule)
1653
- });
1654
- }, "handleChangeType"), FormulaInput = componentManager.get(validator.formulaInput), rangeStr = useMemo(() => localRanges.map((i) => serializeRange(i.range)).join(","), []), options = getRuleOptions(localRule), handleUpdateRuleOptions = /* @__PURE__ */ __name((newOptions) => {
1655
- shallowEqual(newOptions, getRuleOptions(localRule)) || (setLocalRule({
1656
- ...localRule,
1657
- ...newOptions
1658
- }), debounceExecute(
1659
- UpdateSheetDataValidationOptionsCommand.id,
1660
- {
1661
- unitId,
1662
- subUnitId,
1663
- ruleId,
1664
- options: newOptions
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
+ }
1665
2128
  }
1666
- ));
1667
- }, "handleUpdateRuleOptions");
1668
- 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: [
1669
2132
  /* @__PURE__ */ jsxRuntimeExports.jsx(
1670
- FormLayout,
2133
+ DatePanel,
1671
2134
  {
1672
- label: localeService.t("dataValidation.panel.range"),
1673
- error: localRule.ranges.length ? "" : localeService.t("dataValidation.panel.rangeError"),
1674
- children: /* @__PURE__ */ jsxRuntimeExports.jsx(
1675
- RangeSelector,
1676
- {
1677
- className: styles$4.dataValidationDetailFormItem,
1678
- value: rangeStr,
1679
- id: createInternalEditorID("data-validation-detail"),
1680
- openForSheetUnitId: unitId,
1681
- openForSheetSubUnitId: subUnitId,
1682
- onChange: /* @__PURE__ */ __name((newRange) => {
1683
- newRange.some((i) => !isValidRange(i.range) || i.range.endColumn < i.range.startColumn || i.range.endRow < i.range.startRow) || handleUpdateRuleRanges(newRange);
1684
- }, "onChange")
1685
- },
1686
- key
1687
- )
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")
1688
2145
  }
1689
2146
  ),
1690
- /* @__PURE__ */ jsxRuntimeExports.jsx(FormLayout, { label: localeService.t("dataValidation.panel.type"), children: /* @__PURE__ */ jsxRuntimeExports.jsx(
1691
- Select,
1692
- {
1693
- options: validators == null ? void 0 : validators.map((validator2) => ({
1694
- label: localeService.t(validator2.title),
1695
- value: validator2.id
1696
- })),
1697
- value: localRule.type,
1698
- onChange: handleChangeType,
1699
- className: styles$4.dataValidationDetailFormItem
1700
- }
1701
- ) }),
1702
- operators != null && operators.length ? /* @__PURE__ */ jsxRuntimeExports.jsx(FormLayout, { label: localeService.t("dataValidation.panel.operator"), children: /* @__PURE__ */ jsxRuntimeExports.jsx(
1703
- Select,
1704
- {
1705
- options: operators.map((op, i) => ({
1706
- value: `${op}`,
1707
- label: operatorNames[i]
1708
- })),
1709
- value: `${localRule.operator}`,
1710
- onChange: /* @__PURE__ */ __name((operator) => {
1711
- handleUpdateRuleSetting({
1712
- ...baseRule,
1713
- operator
1714
- });
1715
- }, "onChange"),
1716
- className: styles$4.dataValidationDetailFormItem
1717
- }
1718
- ) }) : null,
1719
- FormulaInput ? /* @__PURE__ */ jsxRuntimeExports.jsx(
1720
- FormulaInput,
1721
- {
1722
- isTwoFormula,
1723
- value: {
1724
- formula1: localRule.formula1,
1725
- formula2: localRule.formula2
1726
- },
1727
- onChange: /* @__PURE__ */ __name((value) => {
1728
- handleUpdateRuleSetting({
1729
- ...baseRule,
1730
- ...value
1731
- });
1732
- }, "onChange"),
1733
- showError,
1734
- validResult: validator.validatorFormula(localRule, unitId, subUnitId),
1735
- unitId,
1736
- subUnitId,
1737
- ruleId
1738
- },
1739
- key + localRule.type
1740
- ) : null,
1741
- /* @__PURE__ */ jsxRuntimeExports.jsx(DataValidationOptions, { value: options, onChange: handleUpdateRuleOptions, extraComponent: validator.optionsInput }),
1742
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: styles$4.dataValidationDetailButtons, children: [
1743
- /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { className: styles$4.dataValidationDetailButton, onClick: handleDelete, children: localeService.t("dataValidation.panel.removeRule") }),
1744
- /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { className: styles$4.dataValidationDetailButton, type: "primary", onClick: handleOk, children: localeService.t("dataValidation.panel.done") })
1745
- ] })
1746
- ] });
1747
- }
1748
- __name(DataValidationDetail, "DataValidationDetail");
1749
- 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 = {
1750
- dataValidationItemContainer,
1751
- dataValidationItemTitle,
1752
- dataValidationItemContent,
1753
- dataValidationItemIcon
1754
- }, DataValidationItem = /* @__PURE__ */ __name((props) => {
1755
- 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) => {
1756
- commandService.executeCommand(RemoveSheetDataValidationCommand.id, {
1757
- ruleId: rule.uid,
1758
- unitId,
1759
- subUnitId
1760
- }), e.stopPropagation();
1761
- }, "handleDelete");
1762
- return useEffect(() => () => {
1763
- var _a23;
1764
- ids.current && ((_a23 = ids.current) == null || _a23.forEach((id) => {
1765
- id && markSelectionService.removeShape(id);
1766
- }));
1767
- }, [markSelectionService]), /* @__PURE__ */ jsxRuntimeExports.jsxs(
1768
- "div",
1769
- {
1770
- className: styles$3.dataValidationItemContainer,
1771
- onClick,
1772
- onMouseEnter: /* @__PURE__ */ __name(() => {
1773
- disable || (setIsHover(!0), ids.current = rule.ranges.map((range) => markSelectionService.addShape({
1774
- range,
1775
- style: {
1776
- hasAutoFill: !1,
1777
- fill: "rgba(73, 184, 17, 0.05)",
1778
- strokeWidth: 1,
1779
- stroke: "#49B811",
1780
- widgets: {}
1781
- },
1782
- primary: {
1783
- startColumn: range.startColumn,
1784
- endColumn: range.endColumn,
1785
- startRow: range.startRow,
1786
- endRow: range.endRow,
1787
- actualRow: range.startRow,
1788
- actualColumn: range.startColumn,
1789
- isMerged: !1,
1790
- isMergedMainCell: !1
1791
- }
1792
- })));
1793
- }, "onMouseEnter"),
1794
- onMouseLeave: /* @__PURE__ */ __name(() => {
1795
- var _a23;
1796
- setIsHover(!1), (_a23 = ids.current) == null || _a23.forEach((id) => {
1797
- id && markSelectionService.removeShape(id);
1798
- }), ids.current = void 0;
1799
- }, "onMouseLeave"),
1800
- children: [
1801
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: styles$3.dataValidationItemTitle, children: validator == null ? void 0 : validator.generateRuleName(rule) }),
1802
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: styles$3.dataValidationItemContent, children: rule.ranges.map((range) => serializeRange(range)).join(",") }),
1803
- isHover ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: styles$3.dataValidationItemIcon, onClick: handleDelete, children: /* @__PURE__ */ jsxRuntimeExports.jsx(DeleteSingle, {}) }) : null
1804
- ]
1805
- }
1806
- );
1807
- }, "DataValidationItem"), dataValidationListButtons = "univer-data-validation-list-buttons", dataValidationListButton = "univer-data-validation-list-button", styles$2 = {
1808
- dataValidationListButtons,
1809
- dataValidationListButton
1810
- };
1811
- function DataValidationList() {
1812
- const univerInstanceService = useDependency(IUniverInstanceService), workbook = useObservable(
1813
- () => univerInstanceService.getCurrentTypeOfUnit$(UniverInstanceType.UNIVER_SHEET),
1814
- void 0,
1815
- void 0,
1816
- []
1817
- );
1818
- return workbook ? /* @__PURE__ */ jsxRuntimeExports.jsx(DataValidationListWithWorkbook, { workbook }) : null;
1819
- }
1820
- __name(DataValidationList, "DataValidationList");
1821
- function DataValidationListWithWorkbook(props) {
1822
- 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();
1823
- useEffect(() => {
1824
- setRules(sheetDataValidationModel.getRules(unitId, subUnitId));
1825
- const subscription = sheetDataValidationModel.ruleChange$.subscribe((change) => {
1826
- change.unitId === unitId && change.subUnitId === subUnitId && setRules(sheetDataValidationModel.getRules(unitId, subUnitId));
1827
- });
1828
- return () => {
1829
- subscription.unsubscribe();
1830
- };
1831
- }, [unitId, subUnitId, sheetDataValidationModel]);
1832
- const handleAddRule = /* @__PURE__ */ __name(async () => {
1833
- const rule = createDefaultNewRule(injector), params = {
1834
- unitId,
1835
- subUnitId,
1836
- rule
1837
- };
1838
- await commandService.executeCommand(AddSheetDataValidationCommand.id, params), dataValidationPanelService.setActiveRule({
1839
- unitId,
1840
- subUnitId,
1841
- rule
1842
- });
1843
- }, "handleAddRule"), handleRemoveAll = /* @__PURE__ */ __name(() => {
1844
- commandService.executeCommand(RemoveSheetAllDataValidationCommand.id, {
1845
- unitId,
1846
- subUnitId
1847
- });
1848
- }, "handleRemoveAll"), rulesByPermissionCheck = (/* @__PURE__ */ __name((rules2) => {
1849
- const workbook2 = univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET), worksheet2 = workbook2.getActiveSheet(), unitId2 = workbook2.getUnitId(), subUnitId2 = worksheet2.getSheetId();
1850
- return rules2.map((rule) => checkRangesEditablePermission(injector, unitId2, subUnitId2, rule.ranges) ? { ...rule } : { ...rule, disable: !0 });
1851
- }, "getDvRulesByPermissionCorrect"))(rules), hasDisableRule = rulesByPermissionCheck == null ? void 0 : rulesByPermissionCheck.some((rule) => rule.disable);
1852
- return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
1853
- rulesByPermissionCheck == null ? void 0 : rulesByPermissionCheck.map((rule) => {
1854
- var _a23;
1855
- return /* @__PURE__ */ jsxRuntimeExports.jsx(
1856
- DataValidationItem,
1857
- {
1858
- unitId,
1859
- subUnitId,
1860
- onClick: /* @__PURE__ */ __name(() => {
1861
- rule.disable || dataValidationPanelService.setActiveRule({
1862
- unitId,
1863
- subUnitId,
1864
- rule
1865
- });
1866
- }, "onClick"),
1867
- rule,
1868
- disable: (_a23 = rule.disable) != null ? _a23 : !1
1869
- },
1870
- rule.uid
1871
- );
1872
- }),
1873
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: styles$2.dataValidationListButtons, children: [
1874
- rules.length && !hasDisableRule ? /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { className: styles$2.dataValidationListButton, onClick: handleRemoveAll, children: localeService.t("dataValidation.panel.removeAll") }) : null,
1875
- /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { className: styles$2.dataValidationListButton, type: "primary", onClick: handleAddRule, children: localeService.t("dataValidation.panel.add") })
1876
- ] })
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") }) })
1877
2148
  ] });
1878
2149
  }
1879
- __name(DataValidationListWithWorkbook, "DataValidationListWithWorkbook");
1880
- const DataValidationPanel = /* @__PURE__ */ __name(() => {
1881
- const dataValidationPanelService = useDependency(DataValidationPanelService), activeRule = useObservable(dataValidationPanelService.activeRule$, dataValidationPanelService.activeRule);
1882
- return activeRule ? /* @__PURE__ */ jsxRuntimeExports.jsx(DataValidationDetail, {}, activeRule.rule.uid) : /* @__PURE__ */ jsxRuntimeExports.jsx(DataValidationList, {});
1883
- }, "DataValidationPanel");
2150
+ __name(DateDropdown, "DateDropdown");
1884
2151
  function CellDropdown() {
1885
2152
  const dropdownManagerService = useDependency(DataValidationDropdownManagerService), activeDropdown = useObservable(dropdownManagerService.activeDropdown$, dropdownManagerService.activeDropdown), componentManager = useDependency(ComponentManager);
1886
2153
  if (!activeDropdown)
@@ -1906,8 +2173,8 @@ var __defProp$e = Object.defineProperty, __getOwnPropDesc$e = Object.getOwnPrope
1906
2173
  for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$e(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
1907
2174
  (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
1908
2175
  return kind && result && __defProp$e(target, key, result), result;
1909
- }, "__decorateClass$e"), __decorateParam$e = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$e"), _a7;
1910
- let DataValidationDropdownManagerService = (_a7 = class extends Disposable {
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 {
1911
2178
  constructor(_canvasPopupManagerService, _univerInstanceService, _dataValidatorRegistryService, _zenZoneService, _renderManagerService, _dataValidationModel, _sheetsSelectionsService) {
1912
2179
  super();
1913
2180
  __publicField(this, "_activeDropdown");
@@ -1969,8 +2236,8 @@ let DataValidationDropdownManagerService = (_a7 = class extends Disposable {
1969
2236
  const disposableCollection = new DisposableCollection();
1970
2237
  disposableCollection.add(popupDisposable), disposableCollection.add({
1971
2238
  dispose: /* @__PURE__ */ __name(() => {
1972
- var _a23, _b;
1973
- (_b = (_a23 = this._activeDropdown) == null ? void 0 : _a23.onHide) == null || _b.call(_a23);
2239
+ var _a24, _b;
2240
+ (_b = (_a24 = this._activeDropdown) == null ? void 0 : _a24.onHide) == null || _b.call(_a24);
1974
2241
  }, "dispose")
1975
2242
  }), this._currentPopup = disposableCollection;
1976
2243
  }
@@ -2005,7 +2272,7 @@ let DataValidationDropdownManagerService = (_a7 = class extends Disposable {
2005
2272
  onHide
2006
2273
  });
2007
2274
  }
2008
- }, __name(_a7, "DataValidationDropdownManagerService"), _a7);
2275
+ }, __name(_a8, "DataValidationDropdownManagerService"), _a8);
2009
2276
  DataValidationDropdownManagerService = __decorateClass$e([
2010
2277
  __decorateParam$e(0, Inject(SheetCanvasPopManagerService)),
2011
2278
  __decorateParam$e(1, IUniverInstanceService),
@@ -2015,6 +2282,56 @@ DataValidationDropdownManagerService = __decorateClass$e([
2015
2282
  __decorateParam$e(5, Inject(SheetDataValidationModel)),
2016
2283
  __decorateParam$e(6, Inject(SheetsSelectionsService))
2017
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);
2018
2335
  const DATA_VALIDATION_PANEL = "DataValidationPanel", OpenValidationPanelOperation = {
2019
2336
  id: "data-validation.operation.open-validation-panel",
2020
2337
  type: CommandType.OPERATION,
@@ -2070,7 +2387,7 @@ const DATA_VALIDATION_PANEL = "DataValidationPanel", OpenValidationPanelOperatio
2070
2387
  handler(accessor, params) {
2071
2388
  return params ? (accessor.get(DataValidationDropdownManagerService).hideDropdown(), !0) : !1;
2072
2389
  }
2073
- }, 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$1 = {
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 = {
2074
2391
  dvListDropdown,
2075
2392
  dvListDropdownTitle,
2076
2393
  dvListDropdownList,
@@ -2081,10 +2398,20 @@ const DATA_VALIDATION_PANEL = "DataValidationPanel", OpenValidationPanelOperatio
2081
2398
  dvListDropdownSplit,
2082
2399
  dvListDropdownEdit
2083
2400
  }, SelectList = /* @__PURE__ */ __name((props) => {
2084
- const { value, onChange, multiple, options, title, onEdit, style, filter: filter2 } = props, localeService = useDependency(LocaleService), lowerFilter = filter2 == null ? void 0 : filter2.toLowerCase(), filteredOptions = options.filter((item) => lowerFilter ? item.label.toLowerCase().includes(lowerFilter) : !0);
2085
- return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: styles$1.dvListDropdown, style, children: [
2086
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: styles$1.dvListDropdownTitle, children: title }),
2087
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: styles$1.dvListDropdownList, children: /* @__PURE__ */ jsxRuntimeExports.jsx(Scrollbar, { children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: styles$1.dvListDropdownListContainer, children: filteredOptions.map((item, i) => {
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) => {
2088
2415
  const selected = value.indexOf(item.value) > -1, handleClick = /* @__PURE__ */ __name(() => {
2089
2416
  let set;
2090
2417
  selected ? set = new Set(value.filter((sub) => sub !== item.value)) : set = new Set(multiple ? [...value, item.value] : [item.value]);
@@ -2093,32 +2420,34 @@ const DATA_VALIDATION_PANEL = "DataValidationPanel", OpenValidationPanelOperatio
2093
2420
  set.has(opt.value) && newValue.push(opt.value);
2094
2421
  }), onChange(newValue);
2095
2422
  }, "handleClick"), index = item.label.toLocaleLowerCase().indexOf(lowerFilter);
2096
- return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: styles$1.dvListDropdownItemContainer, onClick: handleClick, children: [
2097
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: styles$1.dvListDropdownItem, style: { background: item.color || DROP_DOWN_DEFAULT_COLOR }, children: lowerFilter && item.label.toLowerCase().includes(lowerFilter) ? /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
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: [
2098
2425
  /* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: item.label.substring(0, index) }),
2099
2426
  /* @__PURE__ */ jsxRuntimeExports.jsx("span", { style: { fontWeight: "bold" }, children: item.label.substring(index, index + lowerFilter.length) }),
2100
2427
  /* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: item.label.substring(index + lowerFilter.length) })
2101
2428
  ] }) : item.label }),
2102
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: styles$1.dvListDropdownSelectedIcon, children: selected ? /* @__PURE__ */ jsxRuntimeExports.jsx(CheckMarkSingle, {}) : null })
2429
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: styles$4.dvListDropdownSelectedIcon, children: selected ? /* @__PURE__ */ jsxRuntimeExports.jsx(CheckMarkSingle, {}) : null })
2103
2430
  ] }, i);
2104
2431
  }) }) }, filter2) }),
2105
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: styles$1.dvListDropdownSplit }),
2106
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: styles$1.dvListDropdownEdit, children: /* @__PURE__ */ jsxRuntimeExports.jsx("a", { onClick: onEdit, children: localeService.t("dataValidation.list.edit") }) })
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
2107
2436
  ] });
2108
2437
  }, "SelectList");
2109
2438
  function ListDropDown(props) {
2110
- var _a23, _b;
2439
+ var _a24, _b;
2111
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)), []);
2112
2441
  useObservable(ruleChange$);
2113
2442
  const anchorRect = RectPopup.useContext(), cellWidth = anchorRect.right - anchorRect.left;
2114
2443
  if (useEffect(() => {
2115
2444
  const dispose = commandService.onCommandExecuted((command) => {
2116
- var _a24, _b2;
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 = BuildTextUtils.transform.getPlainText((_b2 = (_a24 = unit.getSnapshot().body) == null ? void 0 : _a24.dataStream) != null ? _b2 : "");
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 = (_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, showColor = (rule == null ? void 0 : rule.renderMode) === DataValidationRenderMode.CUSTOM || (rule == null ? void 0 : rule.renderMode) === void 0;
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
- var utc$1 = { exports: {} };
2181
- (function(module, exports) {
2182
- (function(t, i) {
2183
- module.exports = i();
2184
- })(commonjsGlobal, function() {
2185
- var t = "minute", i = /[+-]\d\d(?::?\d\d)?/g, e = /([+-]|\d\d)/g;
2186
- return function(s, f2, n2) {
2187
- var u = f2.prototype;
2188
- n2.utc = function(t2) {
2189
- var i2 = { date: t2, utc: !0, args: arguments };
2190
- return new f2(i2);
2191
- }, u.utc = function(i2) {
2192
- var e2 = n2(this.toDate(), { locale: this.$L, utc: !0 });
2193
- return i2 ? e2.add(this.utcOffset(), t) : e2;
2194
- }, u.local = function() {
2195
- return n2(this.toDate(), { locale: this.$L, utc: !1 });
2196
- };
2197
- var o = u.parse;
2198
- u.parse = function(t2) {
2199
- t2.utc && (this.$u = !0), this.$utils().u(t2.$offset) || (this.$offset = t2.$offset), o.call(this, t2);
2200
- };
2201
- var r = u.init;
2202
- u.init = function() {
2203
- if (this.$u) {
2204
- var t2 = this.$d;
2205
- 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();
2206
- } else r.call(this);
2207
- };
2208
- var a = u.utcOffset;
2209
- u.utcOffset = function(s2, f3) {
2210
- var n3 = this.$utils().u;
2211
- if (n3(s2)) return this.$u ? 0 : n3(this.$offset) ? a.call(this) : this.$offset;
2212
- if (typeof s2 == "string" && (s2 = function(t2) {
2213
- t2 === void 0 && (t2 = "");
2214
- var s3 = t2.match(i);
2215
- if (!s3) return null;
2216
- var f4 = ("" + s3[0]).match(e) || ["-", 0, 0], n4 = f4[0], u3 = 60 * +f4[1] + +f4[2];
2217
- return u3 === 0 ? 0 : n4 === "+" ? u3 : -u3;
2218
- }(s2), s2 === null)) return this;
2219
- var u2 = Math.abs(s2) <= 16 ? 60 * s2 : s2, o2 = this;
2220
- if (f3) return o2.$offset = u2, o2.$u = s2 === 0, o2;
2221
- if (s2 !== 0) {
2222
- var r2 = this.$u ? this.toDate().getTimezoneOffset() : -1 * this.utcOffset();
2223
- (o2 = this.local().add(u2 + r2, t)).$offset = u2, o2.$x.$localOffset = r2;
2224
- } else o2 = this.utc();
2225
- return o2;
2226
- };
2227
- var h = u.format;
2228
- u.format = function(t2) {
2229
- var i2 = t2 || (this.$u ? "YYYY-MM-DDTHH:mm:ss[Z]" : "");
2230
- return h.call(this, i2);
2231
- }, u.valueOf = function() {
2232
- var t2 = this.$utils().u(this.$offset) ? 0 : this.$offset + (this.$x.$localOffset || this.$d.getTimezoneOffset());
2233
- return this.$d.valueOf() - 6e4 * t2;
2234
- }, u.isUTC = function() {
2235
- return !!this.$u;
2236
- }, u.toISOString = function() {
2237
- return this.toDate().toISOString();
2238
- }, u.toString = function() {
2239
- return this.toDate().toUTCString();
2240
- };
2241
- var l2 = u.toDate;
2242
- u.toDate = function(t2) {
2243
- return t2 === "s" && this.$offset ? n2(this.format("YYYY-MM-DD HH:mm:ss:SSS")).toDate() : l2.call(this);
2244
- };
2245
- var c = u.diff;
2246
- u.diff = function(t2, i2, e2) {
2247
- if (t2 && this.$u === t2.$u) return c.call(this, t2, i2, e2);
2248
- var s2 = this.local(), f3 = n2(t2).local();
2249
- return c.call(s2, f3, i2, e2);
2250
- };
2251
- };
2252
- });
2253
- })(utc$1);
2254
- var utcExports = utc$1.exports;
2255
- const utc = /* @__PURE__ */ getDefaultExportFromCjs(utcExports);
2256
- var __defProp$d = Object.defineProperty, __getOwnPropDesc$d = Object.getOwnPropertyDescriptor, __decorateClass$d = /* @__PURE__ */ __name((decorators, target, key, kind) => {
2257
- for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$d(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
2258
- (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
2259
- return kind && result && __defProp$d(target, key, result), result;
2260
- }, "__decorateClass$d"), __decorateParam$d = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$d"), _a8;
2261
- let DataValidationRejectInputController = (_a8 = class extends Disposable {
2262
- constructor(_editorBridgeService, _dataValidationModel, _dataValidatorRegistryService, _dialogService, _localeService) {
2263
- super(), this._editorBridgeService = _editorBridgeService, this._dataValidationModel = _dataValidationModel, this._dataValidatorRegistryService = _dataValidatorRegistryService, this._dialogService = _dialogService, this._localeService = _localeService, this._initEditorBridgeInterceptor();
2264
- }
2265
- _initEditorBridgeInterceptor() {
2266
- this._editorBridgeService.interceptor.intercept(
2267
- this._editorBridgeService.interceptor.getInterceptPoints().AFTER_CELL_EDIT_ASYNC,
2268
- {
2269
- handler: /* @__PURE__ */ __name(async (cellPromise, context, next) => {
2270
- var _a23;
2271
- 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;
2272
- if (!rule || rule.errorStyle !== DataValidationErrorStyle.STOP)
2273
- return next(Promise.resolve(cell));
2274
- const validator = await this._dataValidatorRegistryService.getValidatorItem(rule.type);
2275
- if (!validator || await validator.validator(
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,
2276
2530
  {
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")
2315
- }
2316
- );
2317
- }
2318
- showReject(title) {
2319
- this._dialogService.open({
2320
- width: 368,
2321
- title: {
2322
- title: this._localeService.t("dataValidation.alert.title")
2323
- },
2324
- id: "reject-input-dialog",
2325
- children: {
2326
- title
2327
- },
2328
- footer: {
2329
- title: React.createElement(
2330
- Button,
2331
- {
2332
- type: "primary",
2333
- onClick: /* @__PURE__ */ __name(() => this._dialogService.close("reject-input-dialog"), "onClick")
2334
- },
2335
- this._localeService.t("dataValidation.alert.ok")
2336
- )
2337
- },
2338
- onClose: /* @__PURE__ */ __name(() => {
2339
- this._dialogService.close("reject-input-dialog");
2340
- }, "onClose")
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);
2341
2583
  });
2342
- }
2343
- }, __name(_a8, "DataValidationRejectInputController"), _a8);
2344
- DataValidationRejectInputController = __decorateClass$d([
2345
- OnLifecycle(LifecycleStages.Ready, DataValidationRejectInputController),
2346
- __decorateParam$d(0, IEditorBridgeService),
2347
- __decorateParam$d(1, Inject(SheetDataValidationModel)),
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)
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))
2374
2590
  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,
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 = {
2378
2599
  unitId,
2379
2600
  subUnitId,
2380
- row,
2381
- column: col,
2382
- worksheet,
2383
- workbook,
2384
- interceptValue: dateStr.replace("Z", "").replace("T", " "),
2385
- t: CellValueType.NUMBER
2386
- }, rule) ? (commandService.executeCommand(SetRangeValuesCommand.id, {
2601
+ ruleId,
2602
+ ranges
2603
+ };
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 = {
2387
2613
  unitId,
2388
2614
  subUnitId,
2389
- range: {
2390
- startColumn: col,
2391
- endColumn: col,
2392
- startRow: row,
2393
- endRow: row
2394
- },
2395
- value: {
2396
- v: serialTime,
2397
- t: 2,
2398
- p: null,
2399
- f: null,
2400
- si: null,
2401
- s: {
2402
- n: {
2403
- pattern: showTime ? patternType === "datetime" ? format : "yyyy-MM-dd hh:mm:ss" : patternType === "date" ? format : "yyyy-MM-dd"
2404
- }
2405
- }
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,
2661
+ {
2662
+ unitId,
2663
+ subUnitId,
2664
+ ruleId,
2665
+ options: newOptions
2406
2666
  }
2407
- }), hideFn()) : rejectInputController.showReject(validator.getRuleFinalError(rule));
2408
- }, "handleSave");
2409
- return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: styles.dvDateDropdown, children: [
2667
+ ));
2668
+ }, "handleUpdateRuleOptions");
2669
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: styles$2.dataValidationDetail, children: [
2410
2670
  /* @__PURE__ */ jsxRuntimeExports.jsx(
2411
- DatePanel,
2671
+ FormLayout,
2412
2672
  {
2413
- defaultValue: date,
2414
- pickerValue: date,
2415
- showTime: showTime || void 0,
2416
- onSelect: /* @__PURE__ */ __name(async (newValue) => {
2417
- setLocalDate(newValue);
2418
- }, "onSelect"),
2419
- onPanelChange: /* @__PURE__ */ __name((value) => {
2420
- setLocalDate(value);
2421
- }, "onPanelChange"),
2422
- disabledDate: /* @__PURE__ */ __name((current) => !numfmt.parseDate(current.format("YYYY-MM-DD")), "disabledDate")
2673
+ label: localeService.t("dataValidation.panel.range"),
2674
+ error: localRule.ranges.length ? "" : localeService.t("dataValidation.panel.rangeError"),
2675
+ children: /* @__PURE__ */ jsxRuntimeExports.jsx(
2676
+ RangeSelector,
2677
+ {
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")
2686
+ },
2687
+ key
2688
+ )
2423
2689
  }
2424
2690
  ),
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") }) })
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
2739
+ },
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));
2829
+ });
2830
+ return () => {
2831
+ subscription.unsubscribe();
2832
+ };
2833
+ }, [unitId, subUnitId, sheetDataValidationModel]);
2834
+ const handleAddRule = /* @__PURE__ */ __name(async () => {
2835
+ const rule = createDefaultNewRule(injector), params = {
2836
+ unitId,
2837
+ subUnitId,
2838
+ rule
2839
+ };
2840
+ await commandService.executeCommand(AddSheetDataValidationCommand.id, params), dataValidationPanelService.setActiveRule({
2841
+ unitId,
2842
+ subUnitId,
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(DateDropdown, "DateDropdown");
2429
- const LIST_DROPDOWN_KEY = "data-validation.list.dropdown", DATE_DROPDOWN_KEY = "data-validation.date.dropdown", DATE_SHOW_TIME_OPTION = "DATE_SHOW_TIME_OPTION";
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 _a23;
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: (_a23 = value.bizInfo) == null ? void 0 : _a23.showTime,
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 _a23, _b;
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 = (_a23 = numfmt.parseDate(value)) == null ? void 0 : _a23.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() {
@@ -2479,18 +2935,18 @@ const FORMULA1$1 = "{FORMULA1}", FORMULA2$1 = "{FORMULA2}", transformDate2Serial
2479
2935
  __publicField(this, "_formulaService", this.injector.get(DataValidationFormulaService));
2480
2936
  }
2481
2937
  async parseFormula(rule, unitId, subUnitId) {
2482
- var _a23, _b;
2938
+ var _a24, _b;
2483
2939
  const results = await this._formulaService.getRuleFormulaResult(unitId, subUnitId, rule.uid), { formula1, formula2 } = rule;
2484
2940
  return {
2485
- formula1: transformDate2SerialNumber(isFormulaString(formula1) ? getFormulaResult((_a23 = results == null ? void 0 : results[0]) == null ? void 0 : _a23.result) : formula1),
2941
+ formula1: transformDate2SerialNumber(isFormulaString(formula1) ? getFormulaResult((_a24 = results == null ? void 0 : results[0]) == null ? void 0 : _a24.result) : formula1),
2486
2942
  formula2: transformDate2SerialNumber(isFormulaString(formula2) ? getFormulaResult((_b = results == null ? void 0 : results[1]) == null ? void 0 : _b.result) : formula2)
2487
2943
  };
2488
2944
  }
2489
2945
  parseFormulaSync(rule, unitId, subUnitId) {
2490
- var _a23, _b;
2946
+ var _a24, _b;
2491
2947
  const results = this._formulaService.getRuleFormulaResultSync(unitId, subUnitId, rule.uid), { formula1, formula2 } = rule;
2492
2948
  return {
2493
- formula1: transformDate2SerialNumber(isFormulaString(formula1) ? getFormulaResult((_a23 = results == null ? void 0 : results[0]) == null ? void 0 : _a23.result) : formula1),
2949
+ formula1: transformDate2SerialNumber(isFormulaString(formula1) ? getFormulaResult((_a24 = results == null ? void 0 : results[0]) == null ? void 0 : _a24.result) : formula1),
2494
2950
  formula2: transformDate2SerialNumber(isFormulaString(formula2) ? getFormulaResult((_b = results == null ? void 0 : results[1]) == null ? void 0 : _b.result) : formula2)
2495
2951
  };
2496
2952
  }
@@ -2523,14 +2979,14 @@ const FORMULA1$1 = "{FORMULA1}", FORMULA2$1 = "{FORMULA2}", transformDate2Serial
2523
2979
  }
2524
2980
  normalizeFormula(rule, _unitId, _subUnitId) {
2525
2981
  const { formula1, formula2, bizInfo } = rule, normlizeSingleFormula = /* @__PURE__ */ __name((formula) => {
2526
- var _a23;
2982
+ var _a24;
2527
2983
  if (!formula)
2528
2984
  return formula;
2529
2985
  let date;
2530
2986
  if (!Number.isNaN(+formula))
2531
2987
  date = numfmt.dateFromSerial(+formula);
2532
2988
  else {
2533
- const res = (_a23 = numfmt.parseDate(formula)) == null ? void 0 : _a23.v;
2989
+ const res = (_a24 = numfmt.parseDate(formula)) == null ? void 0 : _a24.v;
2534
2990
  if (res == null)
2535
2991
  return "";
2536
2992
  date = numfmt.dateFromSerial(res);
@@ -2591,24 +3047,131 @@ const FORMULA1$1 = "{FORMULA1}", FORMULA2$1 = "{FORMULA2}", transformDate2Serial
2591
3047
  return this.operators.map((operator) => this.localeService.t(DateOperatorNameMap[operator]));
2592
3048
  }
2593
3049
  generateRuleName(rule) {
2594
- var _a23, _b;
3050
+ var _a24, _b;
2595
3051
  if (!rule.operator)
2596
3052
  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 : "");
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 : "");
2598
3054
  return `${this.titleStr} ${ruleName}`;
2599
3055
  }
2600
3056
  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;
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;
2603
3059
  }
2604
3060
  };
2605
3061
  __name(_DateValidator, "DateValidator");
2606
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));
3094
+ }
3095
+ transform(cellInfo, formula, rule) {
3096
+ const { value: cellValue } = cellInfo;
3097
+ return {
3098
+ ...cellInfo,
3099
+ value: getCellValueNumber(cellValue)
3100
+ };
3101
+ }
3102
+ _parseNumber(formula) {
3103
+ return formula == null ? Number.NaN : +formula;
3104
+ }
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
+ };
3112
+ }
3113
+ validatorFormula(rule, unitId, subUnitId) {
3114
+ const operator = rule.operator;
3115
+ if (!operator)
3116
+ return {
3117
+ success: !1
3118
+ };
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
+ } : {
3125
+ success: formula1Success,
3126
+ formula1: formula1Success ? "" : errorMsg
3127
+ };
3128
+ }
3129
+ async validatorIsEqual(cellInfo, formula, rule) {
3130
+ const { formula1 } = formula, { value: cellValue } = cellInfo;
3131
+ return Number.isNaN(formula1) ? !0 : cellValue === formula1;
3132
+ }
3133
+ async validatorIsNotEqual(cellInfo, formula, _rule) {
3134
+ const { formula1 } = formula;
3135
+ return Number.isNaN(formula1) ? !0 : cellInfo.value !== formula1;
3136
+ }
3137
+ async validatorIsBetween(cellInfo, formula, _rule) {
3138
+ const { formula1, formula2 } = formula;
3139
+ if (Number.isNaN(formula1) || Number.isNaN(formula2))
3140
+ return !0;
3141
+ const start = Math.min(formula1, formula2), end = Math.max(formula1, formula2);
3142
+ return cellInfo.value >= start && cellInfo.value <= end;
3143
+ }
3144
+ async validatorIsNotBetween(cellInfo, formula, _rule) {
3145
+ const { formula1, formula2 } = formula;
3146
+ if (Number.isNaN(formula1) || Number.isNaN(formula2))
3147
+ return !0;
3148
+ const start = Math.min(formula1, formula2), end = Math.max(formula1, formula2);
3149
+ return cellInfo.value < start || cellInfo.value > end;
3150
+ }
3151
+ async validatorIsGreaterThan(cellInfo, formula, _rule) {
3152
+ const { formula1 } = formula;
3153
+ return Number.isNaN(formula1) ? !0 : cellInfo.value > formula1;
3154
+ }
3155
+ async validatorIsGreaterThanOrEqual(cellInfo, formula, _rule) {
3156
+ const { formula1 } = formula;
3157
+ return Number.isNaN(formula1) ? !0 : cellInfo.value >= formula1;
3158
+ }
3159
+ async validatorIsLessThan(cellInfo, formula, _rule) {
3160
+ const { formula1 } = formula;
3161
+ return Number.isNaN(formula1) ? !0 : cellInfo.value < formula1;
3162
+ }
3163
+ async validatorIsLessThanOrEqual(cellInfo, formula, _rule) {
3164
+ const { formula1 } = formula;
3165
+ return Number.isNaN(formula1) ? !0 : cellInfo.value <= formula1;
3166
+ }
3167
+ };
3168
+ __name(_DecimalValidator, "DecimalValidator");
3169
+ let DecimalValidator = _DecimalValidator;
2607
3170
  const LIST_RENDER_MODE_OPTION_INPUT = "LIST_RENDER_MODE_OPTION_INPUT";
2608
3171
  function ListRenderModeInput(props) {
2609
- var _a23;
3172
+ var _a24;
2610
3173
  const { value, onChange } = props, localeService = useDependency(LocaleService);
2611
- 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: [
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: [
2612
3175
  /* @__PURE__ */ jsxRuntimeExports.jsx(Radio, { value: `${DataValidationRenderMode.CUSTOM}`, children: localeService.t("dataValidation.renderMode.chip") }),
2613
3176
  /* @__PURE__ */ jsxRuntimeExports.jsx(Radio, { value: `${DataValidationRenderMode.ARROW}`, children: localeService.t("dataValidation.renderMode.arrow") }),
2614
3177
  /* @__PURE__ */ jsxRuntimeExports.jsx(Radio, { value: `${DataValidationRenderMode.TEXT}`, children: localeService.t("dataValidation.renderMode.text") })
@@ -2694,10 +3257,10 @@ function calcPadding(cellWidth, cellHeight, fontWidth, fontHeight, vt, ht, margi
2694
3257
  const realMargin = margin ? MARGIN_V$1 : 0;
2695
3258
  switch (vt) {
2696
3259
  case VerticalAlign.BOTTOM:
2697
- paddingTop = cellHeight - realMargin * 2 - fontHeight + realMargin;
3260
+ paddingTop = cellHeight - fontHeight - realMargin;
2698
3261
  break;
2699
3262
  case VerticalAlign.MIDDLE:
2700
- paddingTop = (cellHeight - realMargin * 2 - fontHeight) / 2 + realMargin;
3263
+ paddingTop = (cellHeight - fontHeight) / 2;
2701
3264
  break;
2702
3265
  default:
2703
3266
  paddingTop = realMargin;
@@ -2719,8 +3282,8 @@ function calcPadding(cellWidth, cellHeight, fontWidth, fontHeight, vt, ht, margi
2719
3282
  };
2720
3283
  }
2721
3284
  __name(calcPadding, "calcPadding");
2722
- var _a9;
2723
- let DropdownWidget = (_a9 = class {
3285
+ var _a10;
3286
+ let DropdownWidget = (_a10 = class {
2724
3287
  constructor(_localeService, _commandService) {
2725
3288
  __publicField(this, "_dropdownInfoMap", /* @__PURE__ */ new Map());
2726
3289
  __publicField(this, "zIndex");
@@ -2743,18 +3306,18 @@ let DropdownWidget = (_a9 = class {
2743
3306
  top = (cellHeight - ICON_SIZE) / 2;
2744
3307
  break;
2745
3308
  case VerticalAlign.BOTTOM:
2746
- top = cellHeight - ICON_SIZE / 2 - b - fontHeight / 2;
3309
+ top = cellHeight - b - fontHeight - MARGIN_V$1 + (fontHeight / 2 - ICON_SIZE / 2);
2747
3310
  break;
2748
3311
  default:
2749
- top = t + fontHeight / 2 - ICON_SIZE / 2;
3312
+ top = t + MARGIN_V$1 + (fontHeight / 2 - ICON_SIZE / 2);
2750
3313
  break;
2751
3314
  }
2752
3315
  ctx.save(), ctx.translateWithPrecision(cellBounding.startX + left, cellBounding.startY + top), ctx.fillStyle = "#565656", ctx.fill(downPath$1), ctx.restore();
2753
3316
  }
2754
3317
  // eslint-disable-next-line max-lines-per-function, complexity
2755
3318
  drawWith(ctx, info, skeleton) {
2756
- var _a23, _b;
2757
- const { primaryWithCoord, row, col, style, data, subUnitId } = info, _cellBounding = primaryWithCoord.isMergedMainCell ? primaryWithCoord.mergeInfo : primaryWithCoord, rule = (_a23 = data.dataValidation) == null ? void 0 : _a23.rule, validator = (_b = data.dataValidation) == null ? void 0 : _b.validator, fontRenderExtension = data.fontRenderExtension, { leftOffset = 0, rightOffset = 0, topOffset = 0, downOffset = 0 } = fontRenderExtension || {};
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 || {};
2758
3321
  if (!rule || !validator || !validator || validator.id.indexOf(DataValidationType.LIST) !== 0 || !validator.skipDefaultFontRender(rule))
2759
3322
  return;
2760
3323
  const cellBounding = {
@@ -2767,7 +3330,7 @@ let DropdownWidget = (_a9 = class {
2767
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) {
2768
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);
2769
3332
  tb === WrapStrategy.WRAP && docModel.updateDocumentDataPageSize(Math.max(realWidth, 1)), documentSkeleton.calculate(), documentSkeleton.getActualSize();
2770
- const textLayout = getDocsSkeletonPageSize(documentSkeleton), { height: fontHeight, width: fontWidth } = textLayout, { paddingTop, paddingLeft } = calcPadding(realWidth, cellHeight - t - b, fontWidth, fontHeight, vt, ht, !1);
3333
+ const textLayout = getDocsSkeletonPageSize(documentSkeleton), { height: fontHeight, width: fontWidth } = textLayout, { paddingTop, paddingLeft } = calcPadding(realWidth, cellHeight - t - b, fontWidth, fontHeight, vt, ht, !0);
2771
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, {
2772
3335
  left: cellBounding.endX + l2 + skeleton.rowHeaderWidth - ICON_PLACE$1,
2773
3336
  top: cellBounding.startY + t + skeleton.columnHeaderHeight,
@@ -2795,8 +3358,8 @@ let DropdownWidget = (_a9 = class {
2795
3358
  }
2796
3359
  }
2797
3360
  calcCellAutoHeight(info) {
2798
- var _a23;
2799
- const { primaryWithCoord, style, data } = info, _cellBounding = primaryWithCoord.isMergedMainCell ? primaryWithCoord.mergeInfo : primaryWithCoord, fontRenderExtension = data.fontRenderExtension, { leftOffset = 0, rightOffset = 0, topOffset = 0, downOffset = 0 } = fontRenderExtension || {}, rule = (_a23 = data.dataValidation) == null ? void 0 : _a23.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;
2800
3363
  if (!rule || rule.renderMode === DataValidationRenderMode.TEXT)
2801
3364
  return;
2802
3365
  const cellBounding = {
@@ -2811,7 +3374,7 @@ let DropdownWidget = (_a9 = class {
2811
3374
  const realWidth = cellWidth - ICON_PLACE$1, { documentSkeleton, docModel } = createDocuments(valueStr, this._localeService, style);
2812
3375
  tb === WrapStrategy.WRAP && docModel.updateDocumentDataPageSize(Math.max(realWidth, 1)), documentSkeleton.calculate(), documentSkeleton.getActualSize();
2813
3376
  const textLayout = getDocsSkeletonPageSize(documentSkeleton), { height: fontHeight } = textLayout;
2814
- return fontHeight + t + b;
3377
+ return fontHeight + t + b + MARGIN_V$1 * 2;
2815
3378
  } else {
2816
3379
  const realWidth = cellWidth - MARGIN_H$1 * 2 - PADDING_H$1 - ICON_PLACE$1, { documentSkeleton, docModel } = createDocSkeleton(valueStr, this._localeService, style);
2817
3380
  tb === WrapStrategy.WRAP && docModel.updateDocumentDataPageSize(Math.max(realWidth, 1)), documentSkeleton.calculate();
@@ -2839,7 +3402,7 @@ let DropdownWidget = (_a9 = class {
2839
3402
  };
2840
3403
  this._commandService.executeCommand(ShowDataValidationDropdown.id, params);
2841
3404
  }
2842
- }, __name(_a9, "DropdownWidget"), _a9);
3405
+ }, __name(_a10, "DropdownWidget"), _a10);
2843
3406
  DropdownWidget = __decorateClass$c([
2844
3407
  __decorateParam$c(0, Inject(LocaleService)),
2845
3408
  __decorateParam$c(1, ICommandService)
@@ -2851,10 +3414,10 @@ function getRuleFormulaResultSet(result) {
2851
3414
  return result.forEach(
2852
3415
  (row) => {
2853
3416
  row.forEach((cell) => {
2854
- var _a23, _b;
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 = (_a23 = cell.s) == null ? void 0 : _a23.n) != null && _b.pattern)) {
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)) {
2858
3421
  resultSet.add(numfmt.format(cell.s.n.pattern, value, { throws: !1 }));
2859
3422
  return;
2860
3423
  }
@@ -2902,21 +3465,19 @@ 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 _a23, _b, _c;
2911
- const success = !Tools.isBlank(rule.formula1), valid = isValidListFormula((_a23 = rule.formula1) != null ? _a23 : "", 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 : "");
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
  }
2917
3478
  getExtraStyle(rule, value, { style: defaultStyle }) {
2918
- var _a23;
2919
- const tb = (_a23 = defaultStyle.tb !== WrapStrategy.OVERFLOW ? defaultStyle.tb : WrapStrategy.CLIP) != null ? _a23 : WrapStrategy.WRAP;
3479
+ var _a24;
3480
+ const tb = (_a24 = defaultStyle.tb !== WrapStrategy.OVERFLOW ? defaultStyle.tb : WrapStrategy.CLIP) != null ? _a24 : WrapStrategy.WRAP;
2920
3481
  if (rule.type === DataValidationType.LIST && (rule.renderMode === DataValidationRenderMode.ARROW || rule.renderMode === DataValidationRenderMode.TEXT)) {
2921
3482
  const colorMap = this.getListWithColorMap(rule), valueStr = `${value != null ? value : ""}`, color = colorMap[valueStr];
2922
3483
  if (color)
@@ -2936,10 +3497,10 @@ const _ListValidator = class _ListValidator extends BaseDataValidator {
2936
3497
  return deserializeListOptions(cellString);
2937
3498
  }
2938
3499
  async parseFormula(rule, unitId, subUnitId) {
2939
- var _a23;
3500
+ var _a24;
2940
3501
  const { formula1 = "" } = rule, results = await this.formulaService.getRuleFormulaResult(unitId, subUnitId, rule.uid);
2941
3502
  return {
2942
- formula1: isFormulaString(formula1) ? getRuleFormulaResultSet((_a23 = results == null ? void 0 : results[0]) == null ? void 0 : _a23.result) : deserializeListOptions(formula1),
3503
+ formula1: isFormulaString(formula1) ? getRuleFormulaResultSet((_a24 = results == null ? void 0 : results[0]) == null ? void 0 : _a24.result) : deserializeListOptions(formula1),
2943
3504
  formula2: void 0
2944
3505
  };
2945
3506
  }
@@ -2954,8 +3515,8 @@ const _ListValidator = class _ListValidator extends BaseDataValidator {
2954
3515
  return this.localeService.t("dataValidation.list.error");
2955
3516
  }
2956
3517
  getList(rule, currentUnitId, currentSubUnitId) {
2957
- var _a23, _b, _c;
2958
- const { formula1 = "" } = rule, univerInstanceService = this.injector.get(IUniverInstanceService), workbook = (_a23 = currentUnitId ? univerInstanceService.getUniverSheetInstance(currentUnitId) : void 0) != null ? _a23 : univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET);
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);
2959
3520
  if (!workbook) return [];
2960
3521
  const worksheet = (_b = currentSubUnitId ? workbook.getSheetBySheetId(currentSubUnitId) : void 0) != null ? _b : workbook.getActiveSheet();
2961
3522
  if (!worksheet) return [];
@@ -2963,8 +3524,8 @@ const _ListValidator = class _ListValidator extends BaseDataValidator {
2963
3524
  return isFormulaString(formula1) ? getRuleFormulaResultSet((_c = results == null ? void 0 : results[0]) == null ? void 0 : _c.result) : deserializeListOptions(formula1);
2964
3525
  }
2965
3526
  async getListAsync(rule, currentUnitId, currentSubUnitId) {
2966
- var _a23, _b, _c;
2967
- const { formula1 = "" } = rule, univerInstanceService = this.injector.get(IUniverInstanceService), workbook = (_a23 = currentUnitId ? univerInstanceService.getUniverSheetInstance(currentUnitId) : void 0) != null ? _a23 : univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET);
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);
2968
3529
  if (!workbook) return [];
2969
3530
  const worksheet = (_b = currentSubUnitId ? workbook.getSheetBySheetId(currentSubUnitId) : void 0) != null ? _b : workbook.getActiveSheet();
2970
3531
  if (!worksheet) return [];
@@ -2984,113 +3545,6 @@ const _ListValidator = class _ListValidator extends BaseDataValidator {
2984
3545
  };
2985
3546
  __name(_ListValidator, "ListValidator");
2986
3547
  let ListValidator = _ListValidator;
2987
- function getCellValueNumber(cellValue) {
2988
- let str = cellValue;
2989
- return typeof cellValue == "string" ? ((cellValue.startsWith("¥") || cellValue.startsWith("$")) && (str = cellValue.slice(1)), +str) : +cellValue;
2990
- }
2991
- __name(getCellValueNumber, "getCellValueNumber");
2992
- const _DecimalValidator = class _DecimalValidator extends BaseDataValidator {
2993
- constructor() {
2994
- super(...arguments);
2995
- __publicField(this, "_formulaService", this.injector.get(DataValidationFormulaService));
2996
- __publicField(this, "id", DataValidationType.DECIMAL);
2997
- __publicField(this, "title", "dataValidation.decimal.title");
2998
- __publicField(this, "operators", [
2999
- DataValidationOperator.BETWEEN,
3000
- DataValidationOperator.EQUAL,
3001
- DataValidationOperator.GREATER_THAN,
3002
- DataValidationOperator.GREATER_THAN_OR_EQUAL,
3003
- DataValidationOperator.LESS_THAN,
3004
- DataValidationOperator.LESS_THAN_OR_EQUAL,
3005
- DataValidationOperator.NOT_BETWEEN,
3006
- DataValidationOperator.NOT_EQUAL
3007
- ]);
3008
- __publicField(this, "scopes", ["sheet"]);
3009
- __publicField(this, "formulaInput", BASE_FORMULA_INPUT_NAME);
3010
- __publicField(this, "dropDownInput");
3011
- }
3012
- _isFormulaOrNumber(formula) {
3013
- return !Tools.isBlank(formula) && (isFormulaString(formula) || !Number.isNaN(+formula));
3014
- }
3015
- async isValidType(cellInfo, formula, rule) {
3016
- const { value: cellValue } = cellInfo;
3017
- return !Number.isNaN(getCellValueNumber(cellValue));
3018
- }
3019
- transform(cellInfo, formula, rule) {
3020
- const { value: cellValue } = cellInfo;
3021
- return {
3022
- ...cellInfo,
3023
- value: getCellValueNumber(cellValue)
3024
- };
3025
- }
3026
- _parseNumber(formula) {
3027
- return formula == null ? Number.NaN : +formula;
3028
- }
3029
- async parseFormula(rule, unitId, subUnitId) {
3030
- var _a23, _b, _c, _d, _e, _f, _g, _h;
3031
- const formulaInfo = await this._formulaService.getRuleFormulaResult(unitId, subUnitId, rule.uid), { formula1, formula2 } = rule;
3032
- return {
3033
- 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),
3034
- 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)
3035
- };
3036
- }
3037
- validatorFormula(rule, unitId, subUnitId) {
3038
- const operator = rule.operator;
3039
- if (!operator)
3040
- return {
3041
- success: !1
3042
- };
3043
- 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");
3044
- return isTwoFormula ? {
3045
- success: formula1Success && formula2Success,
3046
- formula1: formula1Success ? void 0 : errorMsg,
3047
- formula2: formula2Success ? void 0 : errorMsg
3048
- } : {
3049
- success: formula1Success,
3050
- formula1: formula1Success ? "" : errorMsg
3051
- };
3052
- }
3053
- async validatorIsEqual(cellInfo, formula, rule) {
3054
- const { formula1 } = formula, { value: cellValue } = cellInfo;
3055
- return Number.isNaN(formula1) ? !0 : cellValue === formula1;
3056
- }
3057
- async validatorIsNotEqual(cellInfo, formula, _rule) {
3058
- const { formula1 } = formula;
3059
- return Number.isNaN(formula1) ? !0 : cellInfo.value !== formula1;
3060
- }
3061
- async validatorIsBetween(cellInfo, formula, _rule) {
3062
- const { formula1, formula2 } = formula;
3063
- if (Number.isNaN(formula1) || Number.isNaN(formula2))
3064
- return !0;
3065
- const start = Math.min(formula1, formula2), end = Math.max(formula1, formula2);
3066
- return cellInfo.value >= start && cellInfo.value <= end;
3067
- }
3068
- async validatorIsNotBetween(cellInfo, formula, _rule) {
3069
- const { formula1, formula2 } = formula;
3070
- if (Number.isNaN(formula1) || Number.isNaN(formula2))
3071
- return !0;
3072
- const start = Math.min(formula1, formula2), end = Math.max(formula1, formula2);
3073
- return cellInfo.value < start || cellInfo.value > end;
3074
- }
3075
- async validatorIsGreaterThan(cellInfo, formula, _rule) {
3076
- const { formula1 } = formula;
3077
- return Number.isNaN(formula1) ? !0 : cellInfo.value > formula1;
3078
- }
3079
- async validatorIsGreaterThanOrEqual(cellInfo, formula, _rule) {
3080
- const { formula1 } = formula;
3081
- return Number.isNaN(formula1) ? !0 : cellInfo.value >= formula1;
3082
- }
3083
- async validatorIsLessThan(cellInfo, formula, _rule) {
3084
- const { formula1 } = formula;
3085
- return Number.isNaN(formula1) ? !0 : cellInfo.value < formula1;
3086
- }
3087
- async validatorIsLessThanOrEqual(cellInfo, formula, _rule) {
3088
- const { formula1 } = formula;
3089
- return Number.isNaN(formula1) ? !0 : cellInfo.value <= formula1;
3090
- }
3091
- };
3092
- __name(_DecimalValidator, "DecimalValidator");
3093
- let DecimalValidator = _DecimalValidator;
3094
3548
  const FORMULA1 = "{FORMULA1}", FORMULA2 = "{FORMULA2}", _TextLengthValidator = class _TextLengthValidator extends BaseDataValidator {
3095
3549
  constructor() {
3096
3550
  super(...arguments);
@@ -3136,10 +3590,10 @@ const FORMULA1 = "{FORMULA1}", FORMULA2 = "{FORMULA2}", _TextLengthValidator = c
3136
3590
  return !Number.isNaN(formula);
3137
3591
  }
3138
3592
  async parseFormula(rule, unitId, subUnitId) {
3139
- var _a23, _b, _c, _d, _e, _f, _g, _h;
3593
+ var _a24, _b, _c, _d, _e, _f, _g, _h;
3140
3594
  const formulaInfo = await this._formulaService.getRuleFormulaResult(unitId, subUnitId, rule.uid), { formula1, formula2 } = rule;
3141
3595
  return {
3142
- 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),
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),
3143
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)
3144
3598
  };
3145
3599
  }
@@ -3192,15 +3646,15 @@ const FORMULA1 = "{FORMULA1}", FORMULA2 = "{FORMULA2}", _TextLengthValidator = c
3192
3646
  return this._isValidFormula(formula1) ? cellValue <= formula1 : !1;
3193
3647
  }
3194
3648
  generateRuleErrorMessage(rule) {
3195
- var _a23, _b;
3196
- return rule.operator ? `${this.localeService.t(TextLengthErrorTitleMap[rule.operator]).replace(FORMULA1, (_a23 = rule.formula1) != null ? _a23 : "").replace(FORMULA2, (_b = rule.formula2) != null ? _b : "")}` : this.titleStr;
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;
3197
3651
  }
3198
3652
  };
3199
3653
  __name(_TextLengthValidator, "TextLengthValidator");
3200
3654
  let TextLengthValidator = _TextLengthValidator;
3201
3655
  function isBlankCell(cellData) {
3202
- var _a23, _b;
3203
- return cellData ? cellData.p ? !((_b = (_a23 = cellData.p.body) == null ? void 0 : _a23.dataStream) != null ? _b : "").slice(0, -2).trim() : Tools.isBlank(cellData.v) : !0;
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;
3204
3658
  }
3205
3659
  __name(isBlankCell, "isBlankCell");
3206
3660
  function getDataValidationDiffMutations(unitId, subUnitId, diffs, accessor, source = "command", fillDefaultValue = !0) {
@@ -3593,7 +4047,7 @@ const UpdateSheetDataValidationRangeCommand = {
3593
4047
  unitID: params.unitId
3594
4048
  }), commandService.executeCommand(RemoveDataValidationMutation.id, params), !0;
3595
4049
  }
3596
- }, PLUGIN_CONFIG_KEY = "sheets-data-validation.config", defaultPluginConfig = {};
4050
+ };
3597
4051
  function isLegalFormulaResult(res) {
3598
4052
  return !ERROR_TYPE_SET.has(res);
3599
4053
  }
@@ -3693,8 +4147,8 @@ var __defProp$b = Object.defineProperty, __getOwnPropDesc$b = Object.getOwnPrope
3693
4147
  return kind && result && __defProp$b(target, key, result), result;
3694
4148
  }, "__decorateClass$b"), __decorateParam$b = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$b");
3695
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");
3696
- var _a10;
3697
- let DropdownMultipleWidget = (_a10 = class {
4150
+ var _a11;
4151
+ let DropdownMultipleWidget = (_a11 = class {
3698
4152
  constructor(_commandService) {
3699
4153
  __publicField(this, "zIndex");
3700
4154
  __publicField(this, "_dropdownInfoMap", /* @__PURE__ */ new Map());
@@ -3722,7 +4176,7 @@ let DropdownMultipleWidget = (_a10 = class {
3722
4176
  }
3723
4177
  // eslint-disable-next-line max-lines-per-function
3724
4178
  drawWith(ctx, info, skeleton, spreadsheets) {
3725
- var _a23, _b;
4179
+ var _a24, _b;
3726
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);
3727
4181
  if (!validation)
3728
4182
  return;
@@ -3731,7 +4185,7 @@ let DropdownMultipleWidget = (_a10 = class {
3731
4185
  endX: _cellBounding.endX - rightOffset,
3732
4186
  startY: _cellBounding.startY + topOffset,
3733
4187
  endY: _cellBounding.endY - downOffset
3734
- }, cellWidth = cellBounding.endX - cellBounding.startX, cellHeight = cellBounding.endY - cellBounding.startY, { cl } = style || {}, color = (_a23 = typeof cl == "object" ? cl == null ? void 0 : cl.rgb : cl) != null ? _a23 : "#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);
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);
3735
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);
3736
4190
  let top = 0;
3737
4191
  switch (vt) {
@@ -3770,7 +4224,7 @@ let DropdownMultipleWidget = (_a10 = class {
3770
4224
  });
3771
4225
  }
3772
4226
  calcCellAutoHeight(info) {
3773
- var _a23;
4227
+ var _a24;
3774
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 = {
3775
4229
  startX: _cellBounding.startX + leftOffset,
3776
4230
  endX: _cellBounding.endX - rightOffset,
@@ -3779,7 +4233,7 @@ let DropdownMultipleWidget = (_a10 = class {
3779
4233
  }, validation = data.dataValidation;
3780
4234
  if (!validation)
3781
4235
  return;
3782
- const cellWidth = cellBounding.endX - cellBounding.startX, cellHeight = cellBounding.endY - cellBounding.startY, cellValue = (_a23 = getCellValueOrigin(data)) != null ? _a23 : "", { validator: _validator } = validation, items = _validator.parseCellValue(cellValue), fontStyle = getFontStyleString(style != null ? style : void 0);
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);
3783
4237
  return layoutDropdowns(items, fontStyle, cellWidth, cellHeight).cellAutoHeight;
3784
4238
  }
3785
4239
  isHit(position, info) {
@@ -3797,7 +4251,7 @@ let DropdownMultipleWidget = (_a10 = class {
3797
4251
  };
3798
4252
  this._commandService.executeCommand(ShowDataValidationDropdown.id, params);
3799
4253
  }
3800
- }, __name(_a10, "DropdownMultipleWidget"), _a10);
4254
+ }, __name(_a11, "DropdownMultipleWidget"), _a11);
3801
4255
  DropdownMultipleWidget = __decorateClass$b([
3802
4256
  __decorateParam$b(0, ICommandService)
3803
4257
  ], DropdownMultipleWidget);
@@ -3807,9 +4261,7 @@ const _ListMultipleValidator = class _ListMultipleValidator extends ListValidato
3807
4261
  __publicField(this, "id", DataValidationType.LIST_MULTIPLE);
3808
4262
  __publicField(this, "title", "dataValidation.listMultiple.title");
3809
4263
  __publicField(this, "canvasRender", this.injector.createInstance(DropdownMultipleWidget));
3810
- }
3811
- skipDefaultFontRender() {
3812
- return !0;
4264
+ __publicField(this, "skipDefaultFontRender", /* @__PURE__ */ __name(() => !0, "skipDefaultFontRender"));
3813
4265
  }
3814
4266
  };
3815
4267
  __name(_ListMultipleValidator, "ListMultipleValidator");
@@ -3852,10 +4304,10 @@ const _WholeValidator = class _WholeValidator extends BaseDataValidator {
3852
4304
  return formula == null ? Number.NaN : +formula;
3853
4305
  }
3854
4306
  async parseFormula(rule, unitId, subUnitId) {
3855
- var _a23, _b, _c, _d, _e, _f, _g, _h;
4307
+ var _a24, _b, _c, _d, _e, _f, _g, _h;
3856
4308
  const formulaInfo = await this._formulaService.getRuleFormulaResult(unitId, subUnitId, rule.uid), { formula1, formula2 } = rule;
3857
4309
  return {
3858
- 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),
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),
3859
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)
3860
4312
  };
3861
4313
  }
@@ -3948,8 +4400,8 @@ var __defProp$a = Object.defineProperty, __getOwnPropDesc$a = Object.getOwnPrope
3948
4400
  for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$a(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
3949
4401
  (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
3950
4402
  return kind && result && __defProp$a(target, key, result), result;
3951
- }, "__decorateClass$a"), __decorateParam$a = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$a"), _a11;
3952
- let DataValidationController = (_a11 = class extends RxDisposable {
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 {
3953
4405
  constructor(_univerInstanceService, _dataValidatorRegistryService, _injector, _componentManger, _selectionManagerService, _sheetInterceptorService, _sheetDataValidationModel) {
3954
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();
3955
4407
  }
@@ -3980,12 +4432,12 @@ let DataValidationController = (_a11 = class extends RxDisposable {
3980
4432
  _initCommandInterceptor() {
3981
4433
  this._sheetInterceptorService.interceptCommand({
3982
4434
  getMutations: /* @__PURE__ */ __name((commandInfo) => {
3983
- var _a23;
4435
+ var _a24;
3984
4436
  if (commandInfo.id === ClearSelectionAllCommand.id) {
3985
4437
  const workbook = this._univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET), unitId = workbook.getUnitId(), worksheet = workbook.getActiveSheet();
3986
4438
  if (!worksheet)
3987
4439
  throw new Error("No active sheet found");
3988
- const subUnitId = worksheet.getSheetId(), selections = (_a23 = this._selectionManagerService.getCurrentSelections()) == null ? void 0 : _a23.map((s) => s.range), ruleMatrix = this._sheetDataValidationModel.getRuleObjectMatrix(unitId, subUnitId).clone();
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();
3989
4441
  selections && ruleMatrix.removeRange(selections);
3990
4442
  const diffs = ruleMatrix.diff(this._sheetDataValidationModel.getRules(unitId, subUnitId)), { redoMutations, undoMutations } = getDataValidationDiffMutations(unitId, subUnitId, diffs, this._injector, "patched");
3991
4443
  return {
@@ -4017,7 +4469,7 @@ let DataValidationController = (_a11 = class extends RxDisposable {
4017
4469
  ));
4018
4470
  });
4019
4471
  }
4020
- }, __name(_a11, "DataValidationController"), _a11);
4472
+ }, __name(_a12, "DataValidationController"), _a12);
4021
4473
  DataValidationController = __decorateClass$a([
4022
4474
  OnLifecycle(LifecycleStages.Rendered, DataValidationController),
4023
4475
  __decorateParam$a(0, IUniverInstanceService),
@@ -4034,8 +4486,8 @@ var __defProp$9 = Object.defineProperty, __getOwnPropDesc$9 = Object.getOwnPrope
4034
4486
  return kind && result && __defProp$9(target, key, result), result;
4035
4487
  }, "__decorateClass$9"), __decorateParam$9 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$9");
4036
4488
  const ALERT_KEY = "SHEET_DATA_VALIDATION_ALERT";
4037
- var _a12;
4038
- let DataValidationAlertController = (_a12 = class extends Disposable {
4489
+ var _a13;
4490
+ let DataValidationAlertController = (_a13 = class extends Disposable {
4039
4491
  constructor(_hoverManagerService, _cellAlertManagerService, _univerInstanceService, _localeService, _zenZoneService) {
4040
4492
  super(), this._hoverManagerService = _hoverManagerService, this._cellAlertManagerService = _cellAlertManagerService, this._univerInstanceService = _univerInstanceService, this._localeService = _localeService, this._zenZoneService = _zenZoneService, this._init();
4041
4493
  }
@@ -4044,12 +4496,12 @@ let DataValidationAlertController = (_a12 = class extends Disposable {
4044
4496
  }
4045
4497
  _initCellAlertPopup() {
4046
4498
  this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(debounceTime(100)).subscribe((cellPos) => {
4047
- var _a23, _b;
4499
+ var _a24, _b;
4048
4500
  if (cellPos) {
4049
4501
  const worksheet = this._univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET).getActiveSheet();
4050
4502
  if (!worksheet) return;
4051
4503
  const cellData = worksheet.getCell(cellPos.location.row, cellPos.location.col);
4052
- if (((_a23 = cellData == null ? void 0 : cellData.dataValidation) == null ? void 0 : _a23.validStatus) === DataValidationStatus.INVALID) {
4504
+ if (((_a24 = cellData == null ? void 0 : cellData.dataValidation) == null ? void 0 : _a24.validStatus) === DataValidationStatus.INVALID) {
4053
4505
  const currentAlert = this._cellAlertManagerService.currentAlert.get(ALERT_KEY), currentLoc = (_b = currentAlert == null ? void 0 : currentAlert.alert) == null ? void 0 : _b.location;
4054
4506
  if (currentLoc && currentLoc.row === cellPos.location.row && currentLoc.col === cellPos.location.col && currentLoc.subUnitId === cellPos.location.subUnitId && currentLoc.unitId === cellPos.location.unitId)
4055
4507
  return;
@@ -4076,7 +4528,7 @@ let DataValidationAlertController = (_a12 = class extends Disposable {
4076
4528
  visible && this._cellAlertManagerService.removeAlert(ALERT_KEY);
4077
4529
  }));
4078
4530
  }
4079
- }, __name(_a12, "DataValidationAlertController"), _a12);
4531
+ }, __name(_a13, "DataValidationAlertController"), _a13);
4080
4532
  DataValidationAlertController = __decorateClass$9([
4081
4533
  OnLifecycle(LifecycleStages.Rendered, DataValidationAlertController),
4082
4534
  __decorateParam$9(0, Inject(HoverManagerService)),
@@ -4089,8 +4541,8 @@ var __defProp$8 = Object.defineProperty, __getOwnPropDesc$8 = Object.getOwnPrope
4089
4541
  for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$8(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
4090
4542
  (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
4091
4543
  return kind && result && __defProp$8(target, key, result), result;
4092
- }, "__decorateClass$8"), __decorateParam$8 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$8"), _a13;
4093
- let DataValidationCopyPasteController = (_a13 = class extends Disposable {
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 {
4094
4546
  constructor(_sheetClipboardService, _sheetDataValidationModel, _injector) {
4095
4547
  super();
4096
4548
  __publicField(this, "_copyInfo");
@@ -4145,8 +4597,8 @@ let DataValidationCopyPasteController = (_a13 = class extends Disposable {
4145
4597
  if (copyInfo.unitId !== unitId || subUnitId !== copyInfo.subUnitId) {
4146
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();
4147
4599
  repeatRange.forEach(({ startRange }) => {
4148
- var _a23;
4149
- (_a23 = this._copyInfo) == null || _a23.matrix.forValue((row, col, ruleId) => {
4600
+ var _a24;
4601
+ (_a24 = this._copyInfo) == null || _a24.matrix.forValue((row, col, ruleId) => {
4150
4602
  const range = Rectangle.getPositionRange(
4151
4603
  {
4152
4604
  startRow: row,
@@ -4177,8 +4629,8 @@ let DataValidationCopyPasteController = (_a13 = class extends Disposable {
4177
4629
  } else {
4178
4630
  const ruleMatrix = this._sheetDataValidationModel.getRuleObjectMatrix(unitId, subUnitId).clone(), additionMatrix = new ObjectMatrix(), additionRules = /* @__PURE__ */ new Set(), { ranges: [vCopyRange, vPastedRange], mapFunc } = virtualizeDiscreteRanges([copyInfo.copyRange, pastedRange]);
4179
4631
  getRepeatRange(vCopyRange, vPastedRange, !0).forEach(({ startRange }) => {
4180
- var _a23;
4181
- (_a23 = this._copyInfo) == null || _a23.matrix.forValue((row, col, ruleId) => {
4632
+ var _a24;
4633
+ (_a24 = this._copyInfo) == null || _a24.matrix.forValue((row, col, ruleId) => {
4182
4634
  const range = Rectangle.getPositionRange(
4183
4635
  {
4184
4636
  startRow: row,
@@ -4206,7 +4658,7 @@ let DataValidationCopyPasteController = (_a13 = class extends Disposable {
4206
4658
  };
4207
4659
  }
4208
4660
  }
4209
- }, __name(_a13, "DataValidationCopyPasteController"), _a13);
4661
+ }, __name(_a14, "DataValidationCopyPasteController"), _a14);
4210
4662
  DataValidationCopyPasteController = __decorateClass$8([
4211
4663
  OnLifecycle(LifecycleStages.Ready, DataValidationCopyPasteController),
4212
4664
  __decorateParam$8(0, ISheetClipboardService),
@@ -4217,8 +4669,8 @@ var __defProp$7 = Object.defineProperty, __getOwnPropDesc$7 = Object.getOwnPrope
4217
4669
  for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$7(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
4218
4670
  (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
4219
4671
  return kind && result && __defProp$7(target, key, result), result;
4220
- }, "__decorateClass$7"), __decorateParam$7 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$7"), _a14;
4221
- let DataValidationPermissionController = (_a14 = class extends Disposable {
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 {
4222
4674
  constructor(_localeService, _commandService, _sheetPermissionInterceptorBaseController) {
4223
4675
  super(), this._localeService = _localeService, this._commandService = _commandService, this._sheetPermissionInterceptorBaseController = _sheetPermissionInterceptorBaseController, this._commandExecutedListener();
4224
4676
  }
@@ -4237,7 +4689,7 @@ let DataValidationPermissionController = (_a14 = class extends Disposable {
4237
4689
  })
4238
4690
  );
4239
4691
  }
4240
- }, __name(_a14, "DataValidationPermissionController"), _a14);
4692
+ }, __name(_a15, "DataValidationPermissionController"), _a15);
4241
4693
  DataValidationPermissionController = __decorateClass$7([
4242
4694
  OnLifecycle(LifecycleStages.Ready, DataValidationPermissionController),
4243
4695
  __decorateParam$7(0, Inject(LocaleService)),
@@ -4248,8 +4700,8 @@ var __defProp$6 = Object.defineProperty, __getOwnPropDesc$6 = Object.getOwnPrope
4248
4700
  for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$6(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
4249
4701
  (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
4250
4702
  return kind && result && __defProp$6(target, key, result), result;
4251
- }, "__decorateClass$6"), __decorateParam$6 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$6"), _a15;
4252
- let DataValidationRefRangeController = (_a15 = class extends Disposable {
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 {
4253
4705
  constructor(_dataValidationModel, _injector, _refRangeService, _dataValidationCustomFormulaService, _dataValidationFormulaService, _formulaRefRangeService) {
4254
4706
  super();
4255
4707
  __publicField(this, "_disposableMap", /* @__PURE__ */ new Map());
@@ -4263,8 +4715,8 @@ let DataValidationRefRangeController = (_a15 = class extends Disposable {
4263
4715
  }
4264
4716
  // eslint-disable-next-line max-lines-per-function
4265
4717
  registerFormula(unitId, subUnitId, rule) {
4266
- var _a23;
4267
- const ruleId = rule.uid, id = this._getIdWithUnitId(unitId, subUnitId, ruleId), disposeSet = (_a23 = this._disposableMap.get(id)) != null ? _a23 : /* @__PURE__ */ new Set(), handleFormulaChange = /* @__PURE__ */ __name((type, formulaString) => {
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) => {
4268
4720
  const oldRule = this._dataValidationModel.getRuleById(unitId, subUnitId, ruleId);
4269
4721
  if (!oldRule)
4270
4722
  return { redos: [], undos: [] };
@@ -4341,7 +4793,7 @@ let DataValidationRefRangeController = (_a15 = class extends Disposable {
4341
4793
  }
4342
4794
  }
4343
4795
  register(unitId, subUnitId, rule) {
4344
- var _a23;
4796
+ var _a24;
4345
4797
  const handleRangeChange = /* @__PURE__ */ __name((commandInfo) => {
4346
4798
  const oldRanges = [...rule.ranges], resultRanges = oldRanges.map((range) => handleCommonDefaultRangeChangeWithEffectRefCommands(range, commandInfo)).filter((range) => !!range).flat();
4347
4799
  if (isRangesEqual(resultRanges, oldRanges))
@@ -4379,10 +4831,15 @@ let DataValidationRefRangeController = (_a15 = class extends Disposable {
4379
4831
  const disposable = this._refRangeService.registerRefRange(range, handleRangeChange, unitId, subUnitId);
4380
4832
  disposeList.push(() => disposable.dispose());
4381
4833
  });
4382
- const id = this._getIdWithUnitId(unitId, subUnitId, rule.uid), current = (_a23 = this._disposableMap.get(id)) != null ? _a23 : /* @__PURE__ */ new Set();
4834
+ const id = this._getIdWithUnitId(unitId, subUnitId, rule.uid), current = (_a24 = this._disposableMap.get(id)) != null ? _a24 : /* @__PURE__ */ new Set();
4383
4835
  current.add(() => disposeList.forEach((dispose) => dispose())), this._disposableMap.set(id, current);
4384
4836
  }
4385
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);
4386
4843
  this.disposeWithMe(
4387
4844
  this._dataValidationModel.ruleChange$.subscribe((option) => {
4388
4845
  const { unitId, subUnitId, rule } = option;
@@ -4410,7 +4867,7 @@ let DataValidationRefRangeController = (_a15 = class extends Disposable {
4410
4867
  }), this._disposableMap.clear();
4411
4868
  }));
4412
4869
  }
4413
- }, __name(_a15, "DataValidationRefRangeController"), _a15);
4870
+ }, __name(_a16, "DataValidationRefRangeController"), _a16);
4414
4871
  DataValidationRefRangeController = __decorateClass$6([
4415
4872
  OnLifecycle(LifecycleStages.Starting, DataValidationRefRangeController),
4416
4873
  __decorateParam$6(0, Inject(SheetDataValidationModel)),
@@ -4447,8 +4904,8 @@ const INVALID_MARK = {
4447
4904
  color: "#fe4b4b"
4448
4905
  }
4449
4906
  };
4450
- var _a16;
4451
- let SheetsDataValidationRenderController = (_a16 = class extends RxDisposable {
4907
+ var _a17;
4908
+ let SheetsDataValidationRenderController = (_a17 = class extends RxDisposable {
4452
4909
  constructor(_commandService, _menuManagerService, _renderManagerService, _univerInstanceService, _autoHeightController, _dropdownManagerService, _sheetDataValidationModel, _dataValidatorRegistryService, _sheetInterceptorService, _editorBridgeService) {
4453
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();
4454
4911
  }
@@ -4457,9 +4914,9 @@ let SheetsDataValidationRenderController = (_a16 = class extends RxDisposable {
4457
4914
  }
4458
4915
  _initDropdown() {
4459
4916
  this._editorBridgeService && this.disposeWithMe(this._editorBridgeService.visible$.subscribe((visible) => {
4460
- var _a23;
4917
+ var _a24;
4461
4918
  if (!visible.visible) {
4462
- ((_a23 = this._dropdownManagerService.activeDropdown) == null ? void 0 : _a23.trigger) === "editor-bridge" && this._dropdownManagerService.hideDropdown();
4919
+ ((_a24 = this._dropdownManagerService.activeDropdown) == null ? void 0 : _a24.trigger) === "editor-bridge" && this._dropdownManagerService.hideDropdown();
4463
4920
  return;
4464
4921
  }
4465
4922
  const state = this._editorBridgeService.getEditCellState();
@@ -4500,10 +4957,10 @@ let SheetsDataValidationRenderController = (_a16 = class extends RxDisposable {
4500
4957
  }
4501
4958
  _initSkeletonChange() {
4502
4959
  const markSkeletonDirty = /* @__PURE__ */ __name(() => {
4503
- var _a23, _b, _c;
4960
+ var _a24, _b, _c;
4504
4961
  const workbook = this._univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET);
4505
4962
  if (!workbook) return;
4506
- const unitId = workbook.getUnitId(), subUnitId = (_a23 = workbook.getActiveSheet()) == null ? void 0 : _a23.getSheetId();
4963
+ const unitId = workbook.getUnitId(), subUnitId = (_a24 = workbook.getActiveSheet()) == null ? void 0 : _a24.getSheetId();
4507
4964
  if (!subUnitId) return;
4508
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);
4509
4966
  skeleton == null || skeleton.makeDirty(!0), skeleton == null || skeleton.calculate(), currentRender && currentRender.mainComponent.makeForceDirty();
@@ -4516,18 +4973,31 @@ let SheetsDataValidationRenderController = (_a16 = class extends RxDisposable {
4516
4973
  this._sheetInterceptorService.intercept(
4517
4974
  INTERCEPTOR_POINT.CELL_CONTENT,
4518
4975
  {
4976
+ effect: InterceptorEffectEnum.Style,
4519
4977
  // must be after numfmt
4520
4978
  priority: InterceptCellContentPriority.DATA_VALIDATION,
4521
- // eslint-disable-next-line complexity
4979
+ // eslint-disable-next-line max-lines-per-function, complexity
4522
4980
  handler: /* @__PURE__ */ __name((cell, pos, next) => {
4523
- var _a23, _b, _c, _d;
4524
- const { row, col, unitId, subUnitId, workbook, worksheet } = pos, styleMap = 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);
4525
4983
  if (!ruleId)
4526
4984
  return next(cell);
4527
4985
  const rule = this._sheetDataValidationModel.getRuleById(unitId, subUnitId, ruleId);
4528
4986
  if (!rule)
4529
4987
  return next(cell);
4530
- const validStatus = this._sheetDataValidationModel.validator(cell, rule, pos), validator = this._dataValidatorRegistryService.getValidatorItem(rule.type), cellOrigin = worksheet.getCellRaw(row, col), cellValue = getCellValueOrigin(cellOrigin), valueStr = `${(_a23 = getCellValueOrigin(cellOrigin)) != null ? _a23 : ""}`;
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;
4994
+ }
4995
+ }, valueStr = {
4996
+ get value() {
4997
+ var _a25;
4998
+ return `${(_a25 = cellValue.value) != null ? _a25 : ""}`;
4999
+ }
5000
+ };
4531
5001
  return next({
4532
5002
  ...cell,
4533
5003
  dataValidation: {
@@ -4541,20 +5011,25 @@ let SheetsDataValidationRenderController = (_a16 = class extends RxDisposable {
4541
5011
  ...validStatus === DataValidationStatus.INVALID ? INVALID_MARK : null
4542
5012
  },
4543
5013
  customRender: [
4544
- ...(_b = cell == null ? void 0 : cell.customRender) != null ? _b : [],
5014
+ ...(_a24 = cell == null ? void 0 : cell.customRender) != null ? _a24 : [],
4545
5015
  ...validator != null && validator.canvasRender ? [validator.canvasRender] : []
4546
5016
  ],
4547
5017
  fontRenderExtension: {
4548
5018
  ...cell == null ? void 0 : cell.fontRenderExtension,
4549
- isSkip: ((_c = cell == null ? void 0 : cell.fontRenderExtension) == null ? void 0 : _c.isSkip) || (validator == null ? void 0 : validator.skipDefaultFontRender(rule, cellValue, pos))
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))
4550
5020
  },
4551
5021
  interceptorStyle: {
4552
5022
  ...cell == null ? void 0 : cell.interceptorStyle,
4553
- ...validator == null ? void 0 : validator.getExtraStyle(rule, valueStr, { style: defaultStyle })
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
+ })
4554
5029
  },
4555
5030
  interceptorAutoHeight: /* @__PURE__ */ __name(() => {
4556
- var _a24, _b2, _c2, _d2, _e, _f;
4557
- const skeleton = (_b2 = (_a24 = this._renderManagerService.getRenderById(unitId)) == null ? void 0 : _a24.with(SheetSkeletonManagerService).getWorksheetSkeleton(subUnitId)) == null ? void 0 : _b2.skeleton;
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;
4558
5033
  if (!skeleton)
4559
5034
  return;
4560
5035
  const mergeCell = skeleton.worksheet.getMergedCell(row, col), info = {
@@ -4594,15 +5069,15 @@ let SheetsDataValidationRenderController = (_a16 = class extends RxDisposable {
4594
5069
  ).subscribe((infos) => {
4595
5070
  const ranges = [];
4596
5071
  if (infos.forEach((info) => {
4597
- var _a23;
4598
- (_a23 = info.rule) != null && _a23.ranges && ranges.push(...info.rule.ranges);
5072
+ var _a24;
5073
+ (_a24 = info.rule) != null && _a24.ranges && ranges.push(...info.rule.ranges);
4599
5074
  }), ranges.length) {
4600
5075
  const mutations = this._autoHeightController.getUndoRedoParamsOfAutoHeight(ranges);
4601
5076
  sequenceExecute(mutations.redos, this._commandService);
4602
5077
  }
4603
5078
  });
4604
5079
  }
4605
- }, __name(_a16, "SheetsDataValidationRenderController"), _a16);
5080
+ }, __name(_a17, "SheetsDataValidationRenderController"), _a17);
4606
5081
  SheetsDataValidationRenderController = __decorateClass$5([
4607
5082
  OnLifecycle(LifecycleStages.Rendered, SheetsDataValidationRenderController),
4608
5083
  __decorateParam$5(0, ICommandService),
@@ -4616,17 +5091,17 @@ SheetsDataValidationRenderController = __decorateClass$5([
4616
5091
  __decorateParam$5(8, Inject(SheetInterceptorService)),
4617
5092
  __decorateParam$5(9, Optional(IEditorBridgeService))
4618
5093
  ], SheetsDataValidationRenderController);
4619
- var _a17;
4620
- let SheetsDataValidationMobileRenderController = (_a17 = class extends RxDisposable {
5094
+ var _a18;
5095
+ let SheetsDataValidationMobileRenderController = (_a18 = class extends RxDisposable {
4621
5096
  constructor(_commandService, _renderManagerService, _univerInstanceService, _autoHeightController, _dataValidatorRegistryService, _sheetInterceptorService, _sheetDataValidationModel) {
4622
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();
4623
5098
  }
4624
5099
  _initSkeletonChange() {
4625
5100
  const markSkeletonDirty = /* @__PURE__ */ __name(() => {
4626
- var _a23, _b, _c;
5101
+ var _a24, _b, _c;
4627
5102
  const workbook = this._univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET);
4628
5103
  if (!workbook) return;
4629
- const unitId = workbook.getUnitId(), subUnitId = (_a23 = workbook.getActiveSheet()) == null ? void 0 : _a23.getSheetId();
5104
+ const unitId = workbook.getUnitId(), subUnitId = (_a24 = workbook.getActiveSheet()) == null ? void 0 : _a24.getSheetId();
4630
5105
  if (!subUnitId) return;
4631
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);
4632
5107
  skeleton == null || skeleton.makeDirty(!0), skeleton == null || skeleton.calculate(), currentRender && currentRender.mainComponent.makeForceDirty();
@@ -4639,46 +5114,21 @@ let SheetsDataValidationMobileRenderController = (_a17 = class extends RxDisposa
4639
5114
  this._sheetInterceptorService.intercept(
4640
5115
  INTERCEPTOR_POINT.CELL_CONTENT,
4641
5116
  {
5117
+ effect: InterceptorEffectEnum.Style,
5118
+ // must be after numfmt
4642
5119
  priority: InterceptCellContentPriority.DATA_VALIDATION,
4643
- // eslint-disable-next-line max-lines-per-function, complexity
5120
+ // eslint-disable-next-line complexity
4644
5121
  handler: /* @__PURE__ */ __name((cell, pos, next) => {
4645
- var _a23, _b, _c, _d, _e;
4646
- const { row, col, unitId, subUnitId, workbook, worksheet } = pos, skeleton = (_b = (_a23 = this._renderManagerService.getRenderById(unitId)) == null ? void 0 : _a23.with(SheetSkeletonManagerService).getWorksheetSkeleton(subUnitId)) == null ? void 0 : _b.skeleton;
4647
- if (!skeleton)
4648
- return next(cell);
4649
- 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);
4650
5124
  if (!ruleId)
4651
5125
  return next(cell);
4652
5126
  const rule = this._sheetDataValidationModel.getRuleById(unitId, subUnitId, ruleId);
4653
5127
  if (!rule)
4654
5128
  return next(cell);
4655
- const validStatus = this._sheetDataValidationModel.validator(cell, rule, pos), validator = this._dataValidatorRegistryService.getValidatorItem(rule.type), cellOrigin = worksheet.getCellRaw(row, col), cellValue = getCellValueOrigin(cellOrigin);
4656
- let extra = {};
4657
- if ((rule.type === DataValidationType.LIST || rule.type === DataValidationType.LIST_MULTIPLE) && (extra = {
4658
- interceptorStyle: {
4659
- ...cell == null ? void 0 : cell.interceptorStyle,
4660
- tb: (_c = defaultStyle.tb !== WrapStrategy.OVERFLOW ? defaultStyle.tb : WrapStrategy.CLIP) != null ? _c : WrapStrategy.WRAP
4661
- }
4662
- }), rule.type === DataValidationType.CHECKBOX && (extra = {
4663
- interceptorStyle: {
4664
- ...cell == null ? void 0 : cell.interceptorStyle,
4665
- tb: WrapStrategy.CLIP
4666
- }
4667
- }), rule.type === DataValidationType.LIST && (rule.renderMode === DataValidationRenderMode.ARROW || rule.renderMode === DataValidationRenderMode.TEXT)) {
4668
- const colorMap = validator.getListWithColorMap(rule), valueStr = `${(_d = getCellValueOrigin(cellOrigin)) != null ? _d : ""}`, color = colorMap[valueStr];
4669
- color && (extra = {
4670
- ...extra,
4671
- interceptorStyle: {
4672
- ...extra.interceptorStyle,
4673
- bg: {
4674
- rgb: color
4675
- }
4676
- }
4677
- });
4678
- }
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 : ""}`;
4679
5130
  return next({
4680
5131
  ...cell,
4681
- ...extra,
4682
5132
  dataValidation: {
4683
5133
  ruleId,
4684
5134
  validStatus,
@@ -4690,21 +5140,27 @@ let SheetsDataValidationMobileRenderController = (_a17 = class extends RxDisposa
4690
5140
  ...validStatus === DataValidationStatus.INVALID ? INVALID_MARK : null
4691
5141
  },
4692
5142
  customRender: [
4693
- ...(_e = cell == null ? void 0 : cell.customRender) != null ? _e : [],
5143
+ ...(_a24 = cell == null ? void 0 : cell.customRender) != null ? _a24 : [],
4694
5144
  ...validator != null && validator.canvasRender ? [validator.canvasRender] : []
4695
5145
  ],
4696
- // @ts-ignore
4697
5146
  fontRenderExtension: {
4698
- // @ts-ignore
4699
5147
  ...cell == null ? void 0 : cell.fontRenderExtension,
4700
- 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))
4701
5149
  },
4702
5150
  interceptorStyle: {
4703
5151
  ...cell == null ? void 0 : cell.interceptorStyle,
4704
- ...extra.interceptorStyle
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
+ })
4705
5158
  },
4706
5159
  interceptorAutoHeight: /* @__PURE__ */ __name(() => {
4707
- var _a24, _b2, _c2, _d2;
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;
4708
5164
  const mergeCell = skeleton.worksheet.getMergedCell(row, col), info = {
4709
5165
  data: {
4710
5166
  ...cell,
@@ -4716,16 +5172,17 @@ let SheetsDataValidationMobileRenderController = (_a17 = class extends RxDisposa
4716
5172
  }
4717
5173
  },
4718
5174
  style: skeleton.getsStyles().getStyleByCell(cell),
4719
- primaryWithCoord: skeleton.getCellByIndex((_a24 = mergeCell == null ? void 0 : mergeCell.startRow) != null ? _a24 : row, (_b2 = mergeCell == null ? void 0 : mergeCell.startColumn) != null ? _b2 : col),
5175
+ primaryWithCoord: skeleton.getCellByIndex((_c2 = mergeCell == null ? void 0 : mergeCell.startRow) != null ? _c2 : row, (_d2 = mergeCell == null ? void 0 : mergeCell.startColumn) != null ? _d2 : col),
4720
5176
  unitId,
4721
5177
  subUnitId,
4722
5178
  row,
4723
5179
  col,
4724
- worksheet,
4725
- workbook
5180
+ workbook,
5181
+ worksheet
4726
5182
  };
4727
- return (_d2 = (_c2 = validator == null ? void 0 : validator.canvasRender) == null ? void 0 : _c2.calcCellAutoHeight) == null ? void 0 : _d2.call(_c2, info);
4728
- }, "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)
4729
5186
  });
4730
5187
  }, "handler")
4731
5188
  }
@@ -4739,15 +5196,15 @@ let SheetsDataValidationMobileRenderController = (_a17 = class extends RxDisposa
4739
5196
  ).subscribe((infos) => {
4740
5197
  const ranges = [];
4741
5198
  if (infos.forEach((info) => {
4742
- var _a23;
4743
- (_a23 = info.rule) != null && _a23.ranges && ranges.push(...info.rule.ranges);
5199
+ var _a24;
5200
+ (_a24 = info.rule) != null && _a24.ranges && ranges.push(...info.rule.ranges);
4744
5201
  }), ranges.length) {
4745
5202
  const mutations = this._autoHeightController.getUndoRedoParamsOfAutoHeight(ranges);
4746
5203
  sequenceExecute(mutations.redos, this._commandService);
4747
5204
  }
4748
5205
  });
4749
5206
  }
4750
- }, __name(_a17, "SheetsDataValidationMobileRenderController"), _a17);
5207
+ }, __name(_a18, "SheetsDataValidationMobileRenderController"), _a18);
4751
5208
  SheetsDataValidationMobileRenderController = __decorateClass$5([
4752
5209
  OnLifecycle(LifecycleStages.Rendered, SheetsDataValidationMobileRenderController),
4753
5210
  __decorateParam$5(0, ICommandService),
@@ -4762,8 +5219,8 @@ var __defProp$4 = Object.defineProperty, __getOwnPropDesc$4 = Object.getOwnPrope
4762
5219
  for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$4(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
4763
5220
  (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
4764
5221
  return kind && result && __defProp$4(target, key, result), result;
4765
- }, "__decorateClass$4"), __decorateParam$4 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$4"), _a18;
4766
- let SheetsDataValidationValidatorService = (_a18 = class {
5222
+ }, "__decorateClass$4"), __decorateParam$4 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$4"), _a19;
5223
+ let SheetsDataValidationValidatorService = (_a19 = class {
4767
5224
  constructor(_univerInstanceService, _sheetDataValidationModel, _dataValidationCacheService) {
4768
5225
  this._univerInstanceService = _univerInstanceService, this._sheetDataValidationModel = _sheetDataValidationModel, this._dataValidationCacheService = _dataValidationCacheService;
4769
5226
  }
@@ -4816,7 +5273,7 @@ let SheetsDataValidationValidatorService = (_a18 = class {
4816
5273
  getDataValidation(unitId, subUnitId, ranges) {
4817
5274
  return this.getDataValidations(unitId, subUnitId, ranges)[0];
4818
5275
  }
4819
- }, __name(_a18, "SheetsDataValidationValidatorService"), _a18);
5276
+ }, __name(_a19, "SheetsDataValidationValidatorService"), _a19);
4820
5277
  SheetsDataValidationValidatorService = __decorateClass$4([
4821
5278
  __decorateParam$4(0, IUniverInstanceService),
4822
5279
  __decorateParam$4(1, Inject(SheetDataValidationModel)),
@@ -4826,8 +5283,8 @@ var __defProp$3 = Object.defineProperty, __getOwnPropDesc$3 = Object.getOwnPrope
4826
5283
  for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$3(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
4827
5284
  (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
4828
5285
  return kind && result && __defProp$3(target, key, result), result;
4829
- }, "__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"), _a19;
4830
- let UniverSheetsDataValidationMobilePlugin = (_a19 = class extends Plugin {
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 {
4831
5288
  constructor(_config = defaultPluginConfig, _injector, _commandService, _configService) {
4832
5289
  super(), this._config = _config, this._injector = _injector, this._commandService = _commandService, this._configService = _configService;
4833
5290
  const { menu, ...rest } = this._config;
@@ -4871,7 +5328,7 @@ let UniverSheetsDataValidationMobilePlugin = (_a19 = class extends Plugin {
4871
5328
  this._commandService.registerCommand(command);
4872
5329
  });
4873
5330
  }
4874
- }, __name(_a19, "UniverSheetsDataValidationMobilePlugin"), _a19);
5331
+ }, __name(_a20, "UniverSheetsDataValidationMobilePlugin"), _a20);
4875
5332
  __publicField$1(UniverSheetsDataValidationMobilePlugin, "pluginName", DATA_VALIDATION_PLUGIN_NAME);
4876
5333
  __publicField$1(UniverSheetsDataValidationMobilePlugin, "type", UniverInstanceType.UNIVER_SHEET);
4877
5334
  UniverSheetsDataValidationMobilePlugin = __decorateClass$3([
@@ -4884,8 +5341,8 @@ var __defProp$2 = Object.defineProperty, __getOwnPropDesc$2 = Object.getOwnPrope
4884
5341
  for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$2(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
4885
5342
  (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
4886
5343
  return kind && result && __defProp$2(target, key, result), result;
4887
- }, "__decorateClass$2"), __decorateParam$2 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$2"), _a20;
4888
- let DataValidationAutoFillController = (_a20 = class extends Disposable {
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 {
4889
5346
  constructor(_autoFillService, _dataValidationModel, _injector) {
4890
5347
  super(), this._autoFillService = _autoFillService, this._dataValidationModel = _dataValidationModel, this._injector = _injector, this._initAutoFill();
4891
5348
  }
@@ -4960,7 +5417,7 @@ let DataValidationAutoFillController = (_a20 = class extends Disposable {
4960
5417
  };
4961
5418
  this.disposeWithMe(this._autoFillService.addHook(hook));
4962
5419
  }
4963
- }, __name(_a20, "DataValidationAutoFillController"), _a20);
5420
+ }, __name(_a21, "DataValidationAutoFillController"), _a21);
4964
5421
  DataValidationAutoFillController = __decorateClass$2([
4965
5422
  OnLifecycle(LifecycleStages.Ready, DataValidationAutoFillController),
4966
5423
  __decorateParam$2(0, IAutoFillService),
@@ -4971,8 +5428,8 @@ var __defProp$1 = Object.defineProperty, __getOwnPropDesc$1 = Object.getOwnPrope
4971
5428
  for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$1(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
4972
5429
  (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
4973
5430
  return kind && result && __defProp$1(target, key, result), result;
4974
- }, "__decorateClass$1"), __decorateParam$1 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$1"), _a21;
4975
- let SheetDataValidationSheetController = (_a21 = class extends Disposable {
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 {
4976
5433
  constructor(_sheetInterceptorService, _univerInstanceService, _sheetDataValidationModel) {
4977
5434
  super(), this._sheetInterceptorService = _sheetInterceptorService, this._univerInstanceService = _univerInstanceService, this._sheetDataValidationModel = _sheetDataValidationModel, this._initSheetChange();
4978
5435
  }
@@ -4980,12 +5437,12 @@ let SheetDataValidationSheetController = (_a21 = class extends Disposable {
4980
5437
  this.disposeWithMe(
4981
5438
  this._sheetInterceptorService.interceptCommand({
4982
5439
  getMutations: /* @__PURE__ */ __name((commandInfo) => {
4983
- var _a23;
5440
+ var _a24;
4984
5441
  if (commandInfo.id === RemoveSheetCommand.id) {
4985
5442
  const params = commandInfo.params, unitId = params.unitId || this._univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET).getUnitId(), workbook = this._univerInstanceService.getUniverSheetInstance(unitId);
4986
5443
  if (!workbook)
4987
5444
  return { redos: [], undos: [] };
4988
- const subUnitId = params.subUnitId || ((_a23 = workbook.getActiveSheet()) == null ? void 0 : _a23.getSheetId());
5445
+ const subUnitId = params.subUnitId || ((_a24 = workbook.getActiveSheet()) == null ? void 0 : _a24.getSheetId());
4989
5446
  if (!subUnitId)
4990
5447
  return { redos: [], undos: [] };
4991
5448
  const rules = this._sheetDataValidationModel.getRules(unitId, subUnitId), ids = rules.map((i) => i.uid), redoParams = {
@@ -5015,7 +5472,7 @@ let SheetDataValidationSheetController = (_a21 = class extends Disposable {
5015
5472
  })
5016
5473
  );
5017
5474
  }
5018
- }, __name(_a21, "SheetDataValidationSheetController"), _a21);
5475
+ }, __name(_a22, "SheetDataValidationSheetController"), _a22);
5019
5476
  SheetDataValidationSheetController = __decorateClass$1([
5020
5477
  OnLifecycle(LifecycleStages.Ready, SheetDataValidationSheetController),
5021
5478
  __decorateParam$1(0, Inject(SheetInterceptorService)),
@@ -5026,8 +5483,8 @@ var __defProp2 = Object.defineProperty, __getOwnPropDesc = Object.getOwnProperty
5026
5483
  for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
5027
5484
  (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
5028
5485
  return kind && result && __defProp2(target, key, result), result;
5029
- }, "__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"), _a22;
5030
- let UniverSheetsDataValidationPlugin = (_a22 = class extends Plugin {
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 {
5031
5488
  constructor(_config = defaultPluginConfig, _injector, _commandService, _configService) {
5032
5489
  super(), this._config = _config, this._injector = _injector, this._commandService = _commandService, this._configService = _configService;
5033
5490
  const { menu, ...rest } = this._config;
@@ -5074,7 +5531,7 @@ let UniverSheetsDataValidationPlugin = (_a22 = class extends Plugin {
5074
5531
  this._commandService.registerCommand(command);
5075
5532
  });
5076
5533
  }
5077
- }, __name(_a22, "UniverSheetsDataValidationPlugin"), _a22);
5534
+ }, __name(_a23, "UniverSheetsDataValidationPlugin"), _a23);
5078
5535
  __publicField2(UniverSheetsDataValidationPlugin, "pluginName", DATA_VALIDATION_PLUGIN_NAME);
5079
5536
  __publicField2(UniverSheetsDataValidationPlugin, "type", UniverInstanceType.UNIVER_SHEET);
5080
5537
  UniverSheetsDataValidationPlugin = __decorateClass([