@univerjs/sheets-ui 0.21.0 → 0.21.1

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/index.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import { BreakLineCommand, CoverContentCommand, DOCS_COMPONENT_MAIN_LAYER_INDEX, DOCS_VIEW_KEY, DOC_VERTICAL_PADDING, DeleteLeftCommand, DeleteRightCommand, DocSelectionRenderService, IEditorService, IMEInputCommand, InsertCommand, MoveCursorOperation, MoveSelectionOperation, NodePositionConvertToCursor, ReplaceSnapshotCommand, SetInlineFormatBoldCommand, SetInlineFormatCommand, SetInlineFormatFontFamilyCommand, SetInlineFormatFontSizeCommand, SetInlineFormatItalicCommand, SetInlineFormatStrikethroughCommand, SetInlineFormatSubscriptCommand, SetInlineFormatSuperscriptCommand, SetInlineFormatTextColorCommand, SetInlineFormatUnderlineCommand, VIEWPORT_KEY, convertBodyToHtml, getCanvasOffsetByEngine, getLineBounding } from "@univerjs/docs-ui";
2
2
  import { AbsoluteRefType, BaselineOffset, BooleanNumber, BorderStyleTypes, CellModeEnum, CellValueType, ColorKit, CommandType, CustomRangeType, DEFAULT_EMPTY_DOCUMENT_VALUE, DEFAULT_STYLES, DEFAULT_WORKSHEET_COLUMN_WIDTH, DEFAULT_WORKSHEET_COLUMN_WIDTH_KEY, DEFAULT_WORKSHEET_ROW_HEIGHT, DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY, DOCS_NORMAL_EDITOR_UNIT_ID_KEY, DataStreamTreeTokenType, DependentOn, Direction, Disposable, DisposableCollection, DocumentFlavor, EDITOR_ACTIVATED, ErrorService, FOCUSING_COMMENT_EDITOR, FOCUSING_COMMON_DRAWINGS, FOCUSING_EDITOR_BUT_HIDDEN, FOCUSING_EDITOR_INPUT_FORMULA, FOCUSING_EDITOR_STANDALONE, FOCUSING_FX_BAR_EDITOR, FOCUSING_SHAPE_TEXT_EDITOR, FOCUSING_SHEET, FOCUSING_UNIVER_EDITOR, FontItalic, FontWeight, HorizontalAlign, IAuthzIoService, ICommandService, IConfigService, IConfirmService, IContextService, ILogService, IPermissionService, IUndoRedoService, IUniverInstanceService, Inject, Injector, InterceptorEffectEnum, InterceptorManager, LRUMap, LocaleService, LocaleType, NilCommand, ObjectMatrix, Optional, Plugin, PresetListType, Quantity, RANGE_TYPE, Range, Rectangle, RxDisposable, ThemeService, Tools, UndoCommandId, UniverInstanceType, UserManagerService, VerticalAlign, Workbook, WrapStrategy, cloneCellData, cloneCellDataMatrix, cloneCellDataWithSpanAndDisplay, cloneValue, composeStyles, convertCellToRange, createIdentifier, createInterceptorKey, dateKit, debounce, extractPureTextFromCell, fromEventSubject, generateRandomId, get, getEmptyCell, getNumfmtParseValueFilter, getReverseDirection, handleStyleToString, isFormulaString, isNotNullOrUndefined, isRealNum, isTextFormat, isValidRange, merge, mergeOverrideWithDependencies, nameCharacterCheck, numfmt, registerDependencies, sequenceExecute, set, skipParseTagNames, sortRules, splitIntoGrid, throttle, toDisposable, touchDependencies, willLoseNumericPrecision } from "@univerjs/core";
3
- import { AnchoredContextMenu, BuiltInUIPart, COLOR_PICKER_COMPONENT, ComponentContainer, ComponentManager, ContextMenuGroup, ContextMenuPosition, CopyCommand, CutCommand, DISABLE_AUTO_FOCUS_KEY, FILE_PNG_CLIPBOARD_MIME_TYPE, FILE__BMP_CLIPBOARD_MIME_TYPE, FILE__JPEG_CLIPBOARD_MIME_TYPE, FILE__WEBP_CLIPBOARD_MIME_TYPE, FONT_FAMILY_COMPONENT, FONT_FAMILY_ITEM_COMPONENT, FONT_SIZE_COMPONENT, FONT_SIZE_LIST, HTML_CLIPBOARD_MIME_TYPE, ICanvasPopupService, IClipboardInterfaceService, IContextMenuService, IDialogService, ILayoutService, IMenuManagerService, IMessageService, INotificationService, IPlatformService, IShortcutService, ISidebarService, IUIPartsService, IZenZoneService, KeyCode, MenuItemType, MetaKeys, PLAIN_TEXT_CLIPBOARD_MIME_TYPE, PasteCommand, RibbonDataGroup, RibbonPosition, RibbonStartGroup, SheetPasteShortKeyCommandName, Slider, ToolbarItem, UI_PLUGIN_CONFIG_KEY, UniverMobileUIPlugin, connectInjector, getMenuHiddenObservable, handleStringToStyle, imageMimeTypeSet, sanitizeParsedHtml, textTrim, useComponentsOfPart, useConfigValue, useDependency, useEvent, useObservable, useSidebarClick } from "@univerjs/ui";
4
- import { CURSOR_TYPE, DEFAULT_PADDING_DATA, DashedRect, DeviceInputEventType, FIX_ONE_PIXEL_BLUR_OFFSET, Group, IRenderManagerService, Layer, RENDER_CLASS_TYPE, RENDER_RAW_FORMULA_KEY, Rect, RegularPolygon, SHEET_EXTENSION_PREFIX, SHEET_VIEWPORT_KEY, ScrollBar, ScrollTimer, ScrollTimerType, Shape, SheetExtension, Spreadsheet, SpreadsheetColumnHeader, SpreadsheetRowHeader, TRANSFORM_CHANGE_OBSERVABLE_TYPE, Vector2, Viewport, cancelRequestFrame, convertTextRotation, convertTransformToOffsetX, convertTransformToOffsetY, fixLineWidthByScale, getCurrentTypeOfRenderer, hasCJKText, ptToPixel, requestNewFrame, withCurrentTypeOfRenderer } from "@univerjs/engine-render";
5
- import { AUTO_FILL_APPLY_TYPE, AUTO_FILL_HOOK_TYPE, AddMergeUndoMutationFactory, AddRangeProtectionCommand, AddRangeProtectionMutation, AddWorksheetMergeAllCommand, AddWorksheetMergeCommand, AddWorksheetMergeHorizontalCommand, AddWorksheetMergeMutation, AddWorksheetMergeVerticalCommand, AddWorksheetProtectionCommand, AutoClearContentCommand, AutoFillCommand, AutoFillController, BEFORE_CELL_EDIT, BorderStyleManagerService, COMMAND_LISTENER_SKELETON_CHANGE, COMMAND_LISTENER_VALUE_CHANGE, CancelFrozenCommand, CancelMarkDirtyRowAutoHeightOperation, ClearSelectionAllCommand, ClearSelectionContentCommand, ClearSelectionFormatCommand, CopySheetCommand, DeleteRangeMoveLeftCommand, DeleteRangeMoveUpCommand, DeleteRangeProtectionCommand, DeleteRangeProtectionMutation, DeleteWorksheetProtectionCommand, DeltaColumnWidthCommand, DeltaRowHeightCommand, EditStateEnum, IAutoFillService, IExclusiveRangeService, INTERCEPTOR_POINT, INumfmtService, IRefSelectionsService, InsertColBeforeCommand, InsertColCommand, InsertColMutation, InsertDefinedNameCommand, InsertMultiColsLeftCommand, InsertMultiColsRightCommand, InsertMultiRowsAboveCommand, InsertMultiRowsAfterCommand, InsertRangeMoveDownCommand, InsertRangeMoveRightCommand, InsertRowBeforeCommand, InsertRowCommand, InsertRowMutation, InsertSheetCommand, InsertSheetMutation, MAX_CELL_PER_SHEET_KEY, MERGE_CELL_INTERCEPTOR_CHECK, MarkDirtyRowAutoHeightOperation, MergeCellController, MoveColsCommand, MoveColsMutation, MoveRangeCommand, MoveRangeMutation, MoveRowsCommand, MoveRowsMutation, REF_SELECTIONS_ENABLED, RangeProtectionCache, RangeProtectionPermissionEditPoint, RangeProtectionPermissionViewPoint, RangeProtectionRuleModel, RefRangeService, RefSelectionsService, RefillCommand, RemoveColCommand, RemoveColMutation, RemoveDefinedNameCommand, RemoveMergeUndoMutationFactory, RemoveRowCommand, RemoveRowMutation, RemoveSheetCommand, RemoveSheetMutation, RemoveWorksheetMergeCommand, RemoveWorksheetMergeMutation, ResetBackgroundColorCommand, ResetTextColorCommand, SCOPE_WORKBOOK_VALUE_DEFINED_NAME, SELECTIONS_ENABLED, SELECTION_CONTROL_BORDER_BUFFER_COLOR, SELECTION_CONTROL_BORDER_BUFFER_WIDTH, SHEETS_PLUGIN_CONFIG_KEY, ScrollToCellOperation, SelectionMoveType, SetBackgroundColorCommand, SetBoldCommand, SetBorderBasicCommand, SetBorderCommand, SetColHiddenCommand, SetColHiddenMutation, SetColVisibleMutation, SetColWidthCommand, SetDefinedNameCommand, SetFontFamilyCommand, SetFontSizeCommand, SetFrozenCommand, SetFrozenMutation, SetFrozenMutationFactory, SetHorizontalTextAlignCommand, SetItalicCommand, SetProtectionCommand, SetRangeValuesCommand, SetRangeValuesMutation, SetRangeValuesUndoMutationFactory, SetRowHeightCommand, SetRowHiddenCommand, SetRowHiddenMutation, SetRowVisibleMutation, SetSelectedColsVisibleCommand, SetSelectedRowsVisibleCommand, SetSelectionsOperation, SetSpecificColsVisibleCommand, SetSpecificRowsVisibleCommand, SetStrikeThroughCommand, SetStyleCommand, SetTabColorCommand, SetTabColorMutation, SetTextColorCommand, SetTextRotationCommand, SetTextWrapCommand, SetUnderlineCommand, SetVerticalTextAlignCommand, SetWorksheetActivateCommand, SetWorksheetActiveOperation, SetWorksheetColWidthMutation, SetWorksheetColWidthMutationFactory, SetWorksheetHideCommand, SetWorksheetHideMutation, SetWorksheetNameCommand, SetWorksheetNameMutation, SetWorksheetOrderCommand, SetWorksheetOrderMutation, SetWorksheetPermissionPointsCommand, SetWorksheetRowAutoHeightMutation, SetWorksheetRowAutoHeightMutationFactory, SetWorksheetRowHeightMutation, SetWorksheetRowIsAutoHeightCommand, SetWorksheetRowIsAutoHeightMutation, SetWorksheetShowCommand, SheetCopyDownCommand, SheetCopyDownCommand as SheetCopyDownCommand$1, SheetCopyRightCommand, SheetCopyRightCommand as SheetCopyRightCommand$1, SheetInterceptorService, SheetPermissionCheckController, SheetPermissionInitController, SheetSkeletonService, SheetsSelectionsService, TextToNumberCommand, ToggleCellCheckboxCommand, ToggleGridlinesCommand, ToggleGridlinesMutation, UnitAction, UnitObject, UniverSheetsPlugin, ViewStateEnum, WorkbookCopyPermission, WorkbookCreateProtectPermission, WorkbookCreateSheetPermission, WorkbookDeleteColumnPermission, WorkbookDeleteRowPermission, WorkbookDeleteSheetPermission, WorkbookEditablePermission, WorkbookHideSheetPermission, WorkbookInsertColumnPermission, WorkbookInsertRowPermission, WorkbookManageCollaboratorPermission, WorkbookRenameSheetPermission, WorksheetCopyPermission, WorksheetDeleteColumnPermission, WorksheetDeleteProtectionPermission, WorksheetDeleteRowPermission, WorksheetEditPermission, WorksheetInsertColumnPermission, WorksheetInsertRowPermission, WorksheetManageCollaboratorPermission, WorksheetProtectionPointModel, WorksheetProtectionRuleModel, WorksheetSetCellStylePermission, WorksheetSetCellValuePermission, WorksheetSetColumnStylePermission, WorksheetSetRowStylePermission, WorksheetViewPermission, adjustRangeOnMutation, alignToMergedCellsBorders, attachPrimaryWithCoord, attachRangeWithCoord, attachSelectionWithCoord, baseProtectionActions, convertPrimaryWithCoordToPrimary, convertSelectionDataToRange, countCells, defaultLargeSheetOperationConfig, discreteRangeToRange, expandToContinuousRange, getAddMergeMutationRangeByType, getAllWorksheetPermissionPoint, getCellAtRowCol, getClearContentMutationParamsForRanges, getMoveRangeCommandMutations, getPrimaryForRange, getSelectionsService, getSheetCommandTarget, rangeToDiscreteRange, setEndForRange } from "@univerjs/sheets";
3
+ import { AnchoredContextMenu, BuiltInUIPart, COLOR_PICKER_COMPONENT, ComponentContainer, ComponentManager, ContextMenuGroup, ContextMenuPosition, CopyCommand, CutCommand, DISABLE_AUTO_FOCUS_KEY, FILE_PNG_CLIPBOARD_MIME_TYPE, FILE__BMP_CLIPBOARD_MIME_TYPE, FILE__JPEG_CLIPBOARD_MIME_TYPE, FILE__WEBP_CLIPBOARD_MIME_TYPE, FONT_FAMILY_COMPONENT, FONT_FAMILY_ITEM_COMPONENT, FONT_SIZE_COMPONENT, FONT_SIZE_LIST, HTML_CLIPBOARD_MIME_TYPE, ICanvasPopupService, IClipboardInterfaceService, IContextMenuService, IDialogService, ILayoutService, IMenuManagerService, IMessageService, INotificationService, IPlatformService, IShortcutService, ISidebarService, IUIPartsService, IZenZoneService, KeyCode, MenuItemType, MetaKeys, PLAIN_TEXT_CLIPBOARD_MIME_TYPE, PasteCommand, RibbonDataGroup, RibbonPosition, RibbonStartGroup, SheetPasteShortKeyCommandName, Slider, ToolbarItem, UI_PLUGIN_CONFIG_KEY, UniverMobileUIPlugin, connectInjector, getMenuHiddenObservable, handleStringToStyle, imageMimeTypeSet, sanitizeParsedHtml, textTrim, useComponentsOfPart, useConfigValue, useDependency, useEvent, useObservable, useSidebarClick, useVirtualList } from "@univerjs/ui";
4
+ import { CURSOR_TYPE, DEFAULT_PADDING_DATA, DashedRect, DeviceInputEventType, FIX_ONE_PIXEL_BLUR_OFFSET, Group, IRenderManagerService, Layer, RENDER_CLASS_TYPE, RENDER_RAW_FORMULA_KEY, Rect, RegularPolygon, SHEET_EXTENSION_PREFIX, SHEET_VIEWPORT_KEY, ScrollBar, ScrollTimer, ScrollTimerType, Shape, SheetExtension, Spreadsheet, SpreadsheetColumnHeader, SpreadsheetRowHeader, TRANSFORM_CHANGE_OBSERVABLE_TYPE, Vector2, Viewport, cancelRequestFrame, convertTextRotation, convertTransformToOffsetX, convertTransformToOffsetY, fixLineWidthByScale, getCurrentTypeOfRenderer, ptToPixel, requestNewFrame, withCurrentTypeOfRenderer } from "@univerjs/engine-render";
5
+ import { AUTO_FILL_APPLY_TYPE, AUTO_FILL_HOOK_TYPE, AddMergeUndoMutationFactory, AddRangeProtectionCommand, AddRangeProtectionMutation, AddWorksheetMergeAllCommand, AddWorksheetMergeCommand, AddWorksheetMergeHorizontalCommand, AddWorksheetMergeMutation, AddWorksheetMergeVerticalCommand, AddWorksheetProtectionCommand, AutoClearContentCommand, AutoFillCommand, AutoFillController, BEFORE_CELL_EDIT, BorderStyleManagerService, COMMAND_LISTENER_SKELETON_CHANGE, COMMAND_LISTENER_VALUE_CHANGE, CancelFrozenCommand, CancelMarkDirtyRowAutoHeightOperation, ClearSelectionAllCommand, ClearSelectionContentCommand, ClearSelectionFormatCommand, CopySheetCommand, DeleteRangeMoveLeftCommand, DeleteRangeMoveUpCommand, DeleteRangeProtectionCommand, DeleteRangeProtectionMutation, DeleteWorksheetProtectionCommand, DeltaColumnWidthCommand, DeltaRowHeightCommand, EditStateEnum, IAutoFillService, IExclusiveRangeService, INTERCEPTOR_POINT, INumfmtService, IRefSelectionsService, InsertColBeforeCommand, InsertColCommand, InsertColMutation, InsertDefinedNameCommand, InsertMultiColsLeftCommand, InsertMultiColsRightCommand, InsertMultiRowsAboveCommand, InsertMultiRowsAfterCommand, InsertRangeMoveDownCommand, InsertRangeMoveRightCommand, InsertRowBeforeCommand, InsertRowCommand, InsertRowMutation, InsertSheetCommand, InsertSheetMutation, MAX_CELL_PER_SHEET_KEY, MERGE_CELL_INTERCEPTOR_CHECK, MarkDirtyRowAutoHeightOperation, MergeCellController, MoveColsCommand, MoveColsMutation, MoveRangeCommand, MoveRangeMutation, MoveRowsCommand, MoveRowsMutation, REF_SELECTIONS_ENABLED, RangeProtectionCache, RangeProtectionPermissionEditPoint, RangeProtectionPermissionViewPoint, RangeProtectionRuleModel, RefRangeService, RefSelectionsService, RefillCommand, RemoveColCommand, RemoveColMutation, RemoveDefinedNameCommand, RemoveMergeUndoMutationFactory, RemoveRowCommand, RemoveRowMutation, RemoveSheetCommand, RemoveSheetMutation, RemoveWorksheetMergeCommand, RemoveWorksheetMergeMutation, ResetBackgroundColorCommand, ResetTextColorCommand, SCOPE_WORKBOOK_VALUE_DEFINED_NAME, SELECTIONS_ENABLED, SELECTION_CONTROL_BORDER_BUFFER_COLOR, SELECTION_CONTROL_BORDER_BUFFER_WIDTH, SHEETS_PLUGIN_CONFIG_KEY, ScrollToCellOperation, SelectionMoveType, SetBackgroundColorCommand, SetBoldCommand, SetBorderBasicCommand, SetBorderCommand, SetColHiddenCommand, SetColHiddenMutation, SetColVisibleMutation, SetColWidthCommand, SetDefinedNameCommand, SetFontFamilyCommand, SetFontSizeCommand, SetFrozenCommand, SetFrozenMutation, SetFrozenMutationFactory, SetHorizontalTextAlignCommand, SetItalicCommand, SetProtectionCommand, SetRangeValuesCommand, SetRangeValuesMutation, SetRangeValuesUndoMutationFactory, SetRowHeightCommand, SetRowHiddenCommand, SetRowHiddenMutation, SetRowVisibleMutation, SetSelectedColsVisibleCommand, SetSelectedRowsVisibleCommand, SetSelectionsOperation, SetSpecificColsVisibleCommand, SetSpecificRowsVisibleCommand, SetStrikeThroughCommand, SetStyleCommand, SetTabColorCommand, SetTabColorMutation, SetTextColorCommand, SetTextRotationCommand, SetTextWrapCommand, SetUnderlineCommand, SetVerticalTextAlignCommand, SetWorksheetActivateCommand, SetWorksheetActiveOperation, SetWorksheetColWidthMutation, SetWorksheetColWidthMutationFactory, SetWorksheetHideCommand, SetWorksheetHideMutation, SetWorksheetNameCommand, SetWorksheetNameMutation, SetWorksheetOrderCommand, SetWorksheetOrderMutation, SetWorksheetPermissionPointsCommand, SetWorksheetRowAutoHeightMutation, SetWorksheetRowAutoHeightMutationFactory, SetWorksheetRowHeightMutation, SetWorksheetRowIsAutoHeightCommand, SetWorksheetRowIsAutoHeightMutation, SetWorksheetShowCommand, SheetCopyDownCommand, SheetCopyDownCommand as SheetCopyDownCommand$1, SheetCopyRightCommand, SheetCopyRightCommand as SheetCopyRightCommand$1, SheetInterceptorService, SheetPermissionCheckController, SheetPermissionInitController, SheetSkeletonService, SheetsSelectionsService, TextToNumberCommand, ToggleCellCheckboxCommand, ToggleGridlinesCommand, ToggleGridlinesMutation, UnitAction, UnitObject, UniverSheetsPlugin, ViewStateEnum, WorkbookCopyPermission, WorkbookCreateProtectPermission, WorkbookCreateSheetPermission, WorkbookDeleteColumnPermission, WorkbookDeleteRowPermission, WorkbookDeleteSheetPermission, WorkbookEditablePermission, WorkbookHideSheetPermission, WorkbookInsertColumnPermission, WorkbookInsertRowPermission, WorkbookManageCollaboratorPermission, WorkbookRenameSheetPermission, WorksheetCopyPermission, WorksheetDeleteColumnPermission, WorksheetDeleteProtectionPermission, WorksheetDeleteRowPermission, WorksheetEditPermission, WorksheetInsertColumnPermission, WorksheetInsertRowPermission, WorksheetManageCollaboratorPermission, WorksheetProtectionPointModel, WorksheetProtectionRuleModel, WorksheetSetCellStylePermission, WorksheetSetCellValuePermission, WorksheetSetColumnStylePermission, WorksheetSetRowStylePermission, WorksheetViewPermission, adjustRangeOnMutation, alignToMergedCellsBorders, attachPrimaryWithCoord, attachRangeWithCoord, attachSelectionWithCoord, baseProtectionActions, convertPrimaryWithCoordToPrimary, convertSelectionDataToRange, countCells, defaultLargeSheetOperationConfig, discreteRangeToRange, expandToContinuousRange, getAddMergeMutationRangeByType, getAllWorksheetPermissionPoint, getCellAtRowCol, getClearContentMutationParamsForRanges, getMoveRangeCommandMutations, getPrimaryForRange, getSelectionsService, getSheetCommandTarget, rangeToDiscreteRange, setEndForRange, validateDefinedName } from "@univerjs/sheets";
6
6
  import { BehaviorSubject, EMPTY, Observable, Subject, Subscription, combineLatest, combineLatestWith, distinctUntilChanged, filter, map, merge as merge$1, of, shareReplay, startWith, switchMap, takeUntil, throttleTime, withLatestFrom } from "rxjs";
7
7
  import { DocSelectionManagerService, DocSkeletonManagerService, RichTextEditingMutation, SetTextSelectionsOperation } from "@univerjs/docs";
8
8
  import { ObjectScope, UnitAction as UnitAction$1, UnitObject as UnitObject$1, UnitRole } from "@univerjs/protocol";
@@ -984,6 +984,11 @@ let SheetSkeletonManagerService = class SheetSkeletonManagerService extends Disp
984
984
  _defineProperty(this, "currentSkeletonBefore$", this._currentSkeletonBefore$.asObservable());
985
985
  const { unitId, scene } = this._context;
986
986
  this._sheetSkeletonService.setScene(unitId, scene);
987
+ this._initSkeletonsRegisterGetCellHeight(unitId);
988
+ }
989
+ _initSkeletonsRegisterGetCellHeight(unitId) {
990
+ this._sheetSkeletonService.getSkeletonsByUnitId(unitId).forEach((skeleton) => skeleton.registerGetCellHeight());
991
+ this.disposeWithMe(this._sheetSkeletonService.buildSkeleton$.subscribe((skeleton) => skeleton.registerGetCellHeight()));
987
992
  }
988
993
  dispose() {
989
994
  super.dispose();
@@ -6289,6 +6294,7 @@ let SheetScrollManagerService = class SheetScrollManagerService {
6289
6294
  this._rawScrollInfo$.complete();
6290
6295
  }
6291
6296
  calcViewportScrollFromRowColOffset(scrollInfo) {
6297
+ var _skeleton$getCellWith, _skeleton$getCellWith2;
6292
6298
  if (!scrollInfo) return {
6293
6299
  viewportScrollX: 0,
6294
6300
  viewportScrollY: 0
@@ -6297,10 +6303,10 @@ let SheetScrollManagerService = class SheetScrollManagerService {
6297
6303
  sheetViewStartRow = sheetViewStartRow || 0;
6298
6304
  offsetY = offsetY || 0;
6299
6305
  const skeleton = this._sheetSkeletonManagerService.getCurrentSkeleton();
6300
- const rowAcc = (skeleton === null || skeleton === void 0 ? void 0 : skeleton.rowHeightAccumulation[sheetViewStartRow - 1]) || 0;
6306
+ const { startX: colStart = (skeleton === null || skeleton === void 0 ? void 0 : skeleton.columnWidthAccumulation[sheetViewStartColumn - 1]) || 0, startY: rowStart = (skeleton === null || skeleton === void 0 ? void 0 : skeleton.rowHeightAccumulation[sheetViewStartRow - 1]) || 0 } = (_skeleton$getCellWith = skeleton === null || skeleton === void 0 || (_skeleton$getCellWith2 = skeleton.getCellWithCoordByIndex) === null || _skeleton$getCellWith2 === void 0 ? void 0 : _skeleton$getCellWith2.call(skeleton, sheetViewStartRow, sheetViewStartColumn, false)) !== null && _skeleton$getCellWith !== void 0 ? _skeleton$getCellWith : {};
6301
6307
  return {
6302
- viewportScrollX: ((skeleton === null || skeleton === void 0 ? void 0 : skeleton.columnWidthAccumulation[sheetViewStartColumn - 1]) || 0) + offsetX,
6303
- viewportScrollY: rowAcc + offsetY
6308
+ viewportScrollX: colStart + offsetX,
6309
+ viewportScrollY: rowStart + offsetY
6304
6310
  };
6305
6311
  }
6306
6312
  setSearchParam(param) {
@@ -6358,19 +6364,12 @@ let SheetScrollManagerService = class SheetScrollManagerService {
6358
6364
  worksheetScrollInfoMap.set(sheetId, newScrollInfo);
6359
6365
  }
6360
6366
  _clearByParamAndNotify(param) {
6367
+ const defaultScrollState = this._getDefaultScrollState(param);
6361
6368
  this._setScrollState({
6362
6369
  ...param,
6363
- sheetViewStartRow: 0,
6364
- sheetViewStartColumn: 0,
6365
- offsetX: 0,
6366
- offsetY: 0
6367
- });
6368
- this._emitRawScroll({
6369
- sheetViewStartRow: 0,
6370
- sheetViewStartColumn: 0,
6371
- offsetX: 0,
6372
- offsetY: 0
6370
+ ...defaultScrollState
6373
6371
  });
6372
+ this._emitRawScroll(defaultScrollState);
6374
6373
  }
6375
6374
  _getCurrentScroll(param) {
6376
6375
  var _this$_scrollStateMap;
@@ -6382,7 +6381,19 @@ let SheetScrollManagerService = class SheetScrollManagerService {
6382
6381
  };
6383
6382
  if (param == null) return emptyState;
6384
6383
  const { unitId, sheetId } = param;
6385
- return ((_this$_scrollStateMap = this._scrollStateMap.get(unitId)) === null || _this$_scrollStateMap === void 0 ? void 0 : _this$_scrollStateMap.get(sheetId)) || emptyState;
6384
+ return ((_this$_scrollStateMap = this._scrollStateMap.get(unitId)) === null || _this$_scrollStateMap === void 0 ? void 0 : _this$_scrollStateMap.get(sheetId)) || this._getDefaultScrollState(param);
6385
+ }
6386
+ _getDefaultScrollState(param) {
6387
+ var _this$_sheetSkeletonM, _this$_sheetSkeletonM2, _this$_sheetSkeletonM3, _this$_sheetSkeletonM4, _this$_sheetSkeletonM5, _skeleton$getColGapSi, _skeleton$getRowGapSi;
6388
+ const skeleton = (_this$_sheetSkeletonM = (_this$_sheetSkeletonM2 = (_this$_sheetSkeletonM3 = this._sheetSkeletonManagerService).getSkeleton) === null || _this$_sheetSkeletonM2 === void 0 ? void 0 : _this$_sheetSkeletonM2.call(_this$_sheetSkeletonM3, param.sheetId)) !== null && _this$_sheetSkeletonM !== void 0 ? _this$_sheetSkeletonM : (_this$_sheetSkeletonM4 = (_this$_sheetSkeletonM5 = this._sheetSkeletonManagerService).getCurrentSkeleton) === null || _this$_sheetSkeletonM4 === void 0 ? void 0 : _this$_sheetSkeletonM4.call(_this$_sheetSkeletonM5);
6389
+ const colGapSize = (_skeleton$getColGapSi = skeleton === null || skeleton === void 0 ? void 0 : skeleton.getColGapSize(0)) !== null && _skeleton$getColGapSi !== void 0 ? _skeleton$getColGapSi : 0;
6390
+ const rowGapSize = (_skeleton$getRowGapSi = skeleton === null || skeleton === void 0 ? void 0 : skeleton.getRowGapSize(0)) !== null && _skeleton$getRowGapSi !== void 0 ? _skeleton$getRowGapSi : 0;
6391
+ return {
6392
+ sheetViewStartRow: 0,
6393
+ sheetViewStartColumn: 0,
6394
+ offsetX: colGapSize === 0 ? 0 : -colGapSize,
6395
+ offsetY: rowGapSize === 0 ? 0 : -rowGapSize
6396
+ };
6386
6397
  }
6387
6398
  _emitRawScroll(param) {
6388
6399
  this._rawScrollInfo$.next(param);
@@ -8258,7 +8269,11 @@ const SidebarDefinedNameOperation = {
8258
8269
  header: { title: localeService.t("definedName.featureTitle") },
8259
8270
  children: { label: DEFINED_NAME_CONTAINER },
8260
8271
  onClose: () => {},
8261
- width: 333
8272
+ width: 333,
8273
+ bodyStyle: {
8274
+ height: "100%",
8275
+ overflow: "hidden"
8276
+ }
8262
8277
  });
8263
8278
  break;
8264
8279
  default:
@@ -8523,11 +8538,11 @@ let SheetsRenderService = class SheetsRenderService extends RxDisposable {
8523
8538
  this._initContextListener();
8524
8539
  }
8525
8540
  _initWorkbookListener() {
8526
- this._instanceSrv.getTypeOfUnitAdded$(UniverInstanceType.UNIVER_SHEET).pipe(takeUntil(this.dispose$)).subscribe((workbook) => this._createRenderer(workbook));
8541
+ this._instanceSrv.getTypeOfUnitAdded$(UniverInstanceType.UNIVER_SHEET).pipe(takeUntil(this.dispose$)).subscribe((event) => this._createRenderer(event.unit, event.options));
8527
8542
  this._instanceSrv.getAllUnitsForType(UniverInstanceType.UNIVER_SHEET).forEach((workbook) => this._createRenderer(workbook));
8528
8543
  this._instanceSrv.getTypeOfUnitDisposed$(UniverInstanceType.UNIVER_SHEET).pipe(takeUntil(this.dispose$)).subscribe((workbook) => this._disposeRenderer(workbook));
8529
8544
  }
8530
- _createRenderer(workbook) {
8545
+ _createRenderer(workbook, createUnitOptions) {
8531
8546
  const unitId = workbook.getUnitId();
8532
8547
  this._renderManagerService.created$.subscribe((renderer) => {
8533
8548
  if (renderer.unitId === unitId) {
@@ -8535,7 +8550,7 @@ let SheetsRenderService = class SheetsRenderService extends RxDisposable {
8535
8550
  renderer.engine.getCanvas().getContext().setId(`${SHEET_MAIN_CANVAS_ID}_${unitId}`);
8536
8551
  }
8537
8552
  });
8538
- this._renderManagerService.createRender(unitId);
8553
+ this._renderManagerService.createRender(unitId, createUnitOptions);
8539
8554
  }
8540
8555
  _disposeRenderer(workbook) {
8541
8556
  const unitId = workbook.getUnitId();
@@ -12019,8 +12034,8 @@ let FormulaEditorController = class FormulaEditorController extends RxDisposable
12019
12034
  });
12020
12035
  }
12021
12036
  _syncEditorSize() {
12022
- const addFOrmulaBar$ = this._univerInstanceService.unitAdded$.pipe(filter((unit) => unit.getUnitId() === DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY));
12023
- this.disposeWithMe(combineLatest([this._formulaEditorManagerService.position$, addFOrmulaBar$]).subscribe(([position]) => {
12037
+ const addFormulaBar$ = this._univerInstanceService.unitAdded$.pipe(filter((event) => event.unit.getUnitId() === DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY));
12038
+ this.disposeWithMe(combineLatest([this._formulaEditorManagerService.position$, addFormulaBar$]).subscribe(([position]) => {
12024
12039
  if (!position) return this._clearScheduledCallback();
12025
12040
  const editorObject = getEditorObject(DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY, this._renderManagerService);
12026
12041
  const formulaEditorDataModel = this._univerInstanceService.getUniverDocInstance(DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY);
@@ -19846,7 +19861,8 @@ const CellPopup = (props) => {
19846
19861
  //#region src/views/defined-name/DefinedNameInput.tsx
19847
19862
  const DefinedNameInput = (props) => {
19848
19863
  const { inputId, state = false, type = "range", confirm, cancel, name, formulaOrRefString, comment = "", localSheetId = SCOPE_WORKBOOK_VALUE_DEFINED_NAME, hidden = false, id } = props;
19849
- const workbook = useDependency(IUniverInstanceService).getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET);
19864
+ const univerInstanceService = useDependency(IUniverInstanceService);
19865
+ const workbook = univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET);
19850
19866
  const localeService = useDependency(LocaleService);
19851
19867
  const definedNamesService = useDependency(IDefinedNamesService);
19852
19868
  const superTableService = useDependency(ISuperTableService);
@@ -19900,37 +19916,23 @@ const DefinedNameInput = (props) => {
19900
19916
  setFormulaOrRefStringValue(value || "");
19901
19917
  };
19902
19918
  const confirmChange = () => {
19903
- if (nameValue.length === 0) {
19904
- setValidString(localeService.t("definedName.nameEmpty"));
19905
- return;
19906
- }
19907
- if ((definedNamesService.getValueByName(unitId, nameValue) || superTableService.hasTable(unitId, nameValue)) && (id === null || id === void 0 || id.length === 0)) {
19908
- setValidString(localeService.t("definedName.nameDuplicate"));
19909
- return;
19910
- }
19911
- if (!Tools.isValidParameter(nameValue) || isReferenceStringWithEffectiveColumn(nameValue) || !Tools.isStartValidPosition(nameValue) && !hasCJKText(nameValue.substring(0, 1))) {
19912
- setValidString(localeService.t("definedName.nameInvalid"));
19913
- return;
19914
- }
19915
- if (workbook.getSheetOrders().map((sheetId) => {
19916
- var _workbook$getSheetByS;
19917
- return ((_workbook$getSheetByS = workbook.getSheetBySheetId(sheetId)) === null || _workbook$getSheetByS === void 0 ? void 0 : _workbook$getSheetByS.getName()) || "";
19918
- }).includes(nameValue)) {
19919
- setValidString(localeService.t("definedName.nameSheetConflict"));
19920
- return;
19921
- }
19922
- if (formulaOrRefStringValue.length === 0) {
19923
- setValidString(localeService.t("definedName.formulaOrRefStringEmpty"));
19919
+ const validationResult = validateDefinedName(nameValue, {
19920
+ unitId,
19921
+ formulaOrRefString: formulaOrRefStringValue,
19922
+ univerInstanceService,
19923
+ definedNamesService,
19924
+ superTableService,
19925
+ functionService,
19926
+ id
19927
+ });
19928
+ if (typeof validationResult === "string") {
19929
+ setValidString(localeService.t(validationResult));
19924
19930
  return;
19925
19931
  }
19926
19932
  if (!validFormulaOrRange) {
19927
19933
  setValidString(localeService.t("definedName.formulaOrRefStringInvalid"));
19928
19934
  return;
19929
19935
  }
19930
- if (functionService.hasExecutor(nameValue.toUpperCase())) {
19931
- setValidString(localeService.t("definedName.nameConflict"));
19932
- return;
19933
- }
19934
19936
  const currentSheetName = workbook.getActiveSheet().getName();
19935
19937
  confirm && confirm({
19936
19938
  id: id || "",
@@ -20060,6 +20062,15 @@ const DefinedNameContainer = () => {
20060
20062
  const [definedNames, setDefinedNames] = useState([]);
20061
20063
  const [editorKey, setEditorKey] = useState(null);
20062
20064
  const [deleteConformKey, setDeleteConformKey] = useState();
20065
+ const listContainerRef = useRef(void 0);
20066
+ const [virtualDefinedNames, virtualActions] = useVirtualList(definedNames, {
20067
+ containerTarget: listContainerRef,
20068
+ itemHeight: (index, item) => {
20069
+ if (item.id === editorKey) return 240;
20070
+ return 72;
20071
+ },
20072
+ overscan: 6
20073
+ });
20063
20074
  useEffect(() => {
20064
20075
  setDefinedNames(getDefinedNameMap());
20065
20076
  const definedNamesSubscription = definedNamesService.update$.subscribe(() => {
@@ -20162,100 +20173,105 @@ const DefinedNameContainer = () => {
20162
20173
  if (sheet == null) return "";
20163
20174
  return sheet.getName();
20164
20175
  };
20165
- return /* @__PURE__ */ jsx("div", {
20176
+ return /* @__PURE__ */ jsxs("div", {
20166
20177
  "data-u-comp": "defined-name-container",
20167
- className: "univer-relative univer-box-border univer-w-full",
20168
- children: /* @__PURE__ */ jsxs("div", {
20169
- className: clsx("univer-w-full univer-overflow-hidden univer-overflow-y-auto", scrollbarClassName),
20170
- children: [/* @__PURE__ */ jsxs("div", {
20171
- className: "univer-mb-4",
20172
- children: [/* @__PURE__ */ jsxs(Button, {
20173
- className: clsx("univer-w-full", { "univer-hidden": editState }),
20174
- onClick: openInsertCloseKeyEditor,
20175
- children: [/* @__PURE__ */ jsx(IncreaseIcon, {}), /* @__PURE__ */ jsx("span", {
20176
- className: "univer-ml-1",
20177
- children: localeService.t("definedName.addButton")
20178
- })]
20179
- }), editState && /* @__PURE__ */ jsx(DefinedNameInput, {
20180
- confirm: insertConfirm,
20181
- cancel: closeInput,
20182
- state: editState,
20183
- inputId: "insertDefinedName",
20184
- name: getInsertDefinedName(),
20185
- formulaOrRefString: getInertFormulaOrRefString()
20178
+ className: "univer-relative univer-box-border univer-flex univer-h-full univer-w-full univer-flex-col",
20179
+ children: [/* @__PURE__ */ jsxs("div", {
20180
+ className: "univer-mb-4",
20181
+ children: [/* @__PURE__ */ jsxs(Button, {
20182
+ className: clsx("univer-w-full", { "univer-hidden": editState }),
20183
+ onClick: openInsertCloseKeyEditor,
20184
+ children: [/* @__PURE__ */ jsx(IncreaseIcon, {}), /* @__PURE__ */ jsx("span", {
20185
+ className: "univer-ml-1",
20186
+ children: localeService.t("definedName.addButton")
20186
20187
  })]
20187
- }, "insertDefinedName"), definedNames.map((definedName, index) => {
20188
- return /* @__PURE__ */ jsxs("div", {
20189
- className: "univer-relative univer-w-full univer-divide-x-0 univer-divide-y univer-divide-solid univer-divide-gray-200 dark:!univer-divide-gray-600",
20190
- children: [
20191
- /* @__PURE__ */ jsxs("div", {
20192
- className: clsx("univer-group univer-relative univer-flex univer-w-full univer-cursor-default univer-select-none univer-items-center univer-justify-between univer-rounded-md univer-p-2 hover:univer-bg-gray-50 dark:hover:!univer-bg-gray-700", { "univer-hidden": definedName.id === editorKey }),
20193
- onClick: () => {
20194
- focusDefinedName(definedName);
20195
- },
20196
- children: [/* @__PURE__ */ jsxs("div", {
20197
- title: definedName.comment,
20188
+ }), editState && /* @__PURE__ */ jsx(DefinedNameInput, {
20189
+ confirm: insertConfirm,
20190
+ cancel: closeInput,
20191
+ state: editState,
20192
+ inputId: "insertDefinedName",
20193
+ name: getInsertDefinedName(),
20194
+ formulaOrRefString: getInertFormulaOrRefString()
20195
+ })]
20196
+ }, "insertDefinedName"), /* @__PURE__ */ jsx("div", {
20197
+ ref: listContainerRef,
20198
+ className: clsx("univer-min-h-0 univer-flex-1 univer-overflow-y-auto", scrollbarClassName),
20199
+ ...virtualActions.containerProps,
20200
+ children: /* @__PURE__ */ jsx("div", {
20201
+ style: virtualActions.wrapperStyle,
20202
+ children: virtualDefinedNames.map(({ data: definedName, index }) => {
20203
+ return /* @__PURE__ */ jsxs("div", {
20204
+ className: "univer-relative univer-w-full univer-divide-x-0 univer-divide-y univer-divide-solid univer-divide-gray-200 dark:!univer-divide-gray-600",
20205
+ children: [
20206
+ /* @__PURE__ */ jsxs("div", {
20207
+ className: clsx("univer-group univer-relative univer-flex univer-w-full univer-cursor-default univer-select-none univer-items-center univer-justify-between univer-rounded-md univer-p-2 hover:univer-bg-gray-50 dark:hover:!univer-bg-gray-700", { "univer-hidden": definedName.id === editorKey }),
20208
+ onClick: () => {
20209
+ focusDefinedName(definedName);
20210
+ },
20198
20211
  children: [/* @__PURE__ */ jsxs("div", {
20199
- className: "univer-my-1 univer-max-h-[100px] univer-max-w-[190px] univer-truncate univer-text-sm univer-font-medium univer-text-gray-900 dark:!univer-text-white",
20200
- children: [definedName.name, /* @__PURE__ */ jsx("span", {
20201
- className: "univer-text-xxs univer-ml-1 univer-text-gray-400",
20202
- children: definedName.localSheetId === SCOPE_WORKBOOK_VALUE_DEFINED_NAME || definedName.localSheetId == null ? "" : getSheetNameBySheetId(definedName.localSheetId)
20212
+ title: definedName.comment,
20213
+ children: [/* @__PURE__ */ jsxs("div", {
20214
+ className: "univer-my-1 univer-max-h-[100px] univer-max-w-[190px] univer-truncate univer-text-sm univer-font-medium univer-text-gray-900 dark:!univer-text-white",
20215
+ children: [definedName.name, /* @__PURE__ */ jsx("span", {
20216
+ className: "univer-text-xxs univer-ml-1 univer-text-gray-400",
20217
+ children: definedName.localSheetId === SCOPE_WORKBOOK_VALUE_DEFINED_NAME || definedName.localSheetId == null ? "" : getSheetNameBySheetId(definedName.localSheetId)
20218
+ })]
20219
+ }), /* @__PURE__ */ jsx("div", {
20220
+ className: "univer-my-1 univer-max-h-[100px] univer-w-full univer-max-w-[190px] univer-truncate univer-text-xs univer-text-gray-500",
20221
+ title: definedName.formulaOrRefString,
20222
+ children: definedName.formulaOrRefString
20223
+ })]
20224
+ }), /* @__PURE__ */ jsxs("div", {
20225
+ className: "univer-absolute univer-right-5 univer-top-1/2 univer-hidden -univer-translate-y-1/2 univer-cursor-pointer univer-items-center univer-justify-end univer-gap-7 univer-text-xs univer-text-primary-600 group-hover:univer-flex dark:hover:!univer-bg-gray-600",
20226
+ children: [/* @__PURE__ */ jsx(Tooltip, {
20227
+ title: localeService.t("definedName.updateButton"),
20228
+ placement: "top",
20229
+ children: /* @__PURE__ */ jsx("a", {
20230
+ className: "univer-rounded univer-p-1 hover:univer-bg-gray-100",
20231
+ onClick: (e) => {
20232
+ e.stopPropagation();
20233
+ closeInsertOpenKeyEditor(definedName.id);
20234
+ },
20235
+ children: /* @__PURE__ */ jsx(PenIcon, {})
20236
+ })
20237
+ }), /* @__PURE__ */ jsx(Tooltip, {
20238
+ title: localeService.t("definedName.deleteButton"),
20239
+ placement: "top",
20240
+ children: /* @__PURE__ */ jsx("a", {
20241
+ className: "univer-rounded univer-p-1 univer-text-red-600 hover:univer-bg-gray-100",
20242
+ onClick: (e) => {
20243
+ e.stopPropagation();
20244
+ deleteDefinedName(definedName.id);
20245
+ },
20246
+ children: /* @__PURE__ */ jsx(DeleteIcon, {})
20247
+ })
20203
20248
  })]
20204
- }), /* @__PURE__ */ jsx("div", {
20205
- className: "univer-my-1 univer-max-h-[100px] univer-w-full univer-max-w-[190px] univer-truncate univer-text-xs univer-text-gray-500",
20206
- title: definedName.formulaOrRefString,
20207
- children: definedName.formulaOrRefString
20208
- })]
20209
- }), /* @__PURE__ */ jsxs("div", {
20210
- className: "univer-absolute univer-right-5 univer-top-1/2 univer-hidden -univer-translate-y-1/2 univer-cursor-pointer univer-items-center univer-justify-end univer-gap-7 univer-text-xs univer-text-primary-600 group-hover:univer-flex dark:hover:!univer-bg-gray-600",
20211
- children: [/* @__PURE__ */ jsx(Tooltip, {
20212
- title: localeService.t("definedName.updateButton"),
20213
- placement: "top",
20214
- children: /* @__PURE__ */ jsx("a", {
20215
- className: "univer-rounded univer-p-1 hover:univer-bg-gray-100",
20216
- onClick: (e) => {
20217
- e.stopPropagation();
20218
- closeInsertOpenKeyEditor(definedName.id);
20219
- },
20220
- children: /* @__PURE__ */ jsx(PenIcon, {})
20221
- })
20222
- }), /* @__PURE__ */ jsx(Tooltip, {
20223
- title: localeService.t("definedName.deleteButton"),
20224
- placement: "top",
20225
- children: /* @__PURE__ */ jsx("a", {
20226
- className: "univer-rounded univer-p-1 univer-text-red-600 hover:univer-bg-gray-100",
20227
- onClick: (e) => {
20228
- e.stopPropagation();
20229
- deleteDefinedName(definedName.id);
20230
- },
20231
- children: /* @__PURE__ */ jsx(DeleteIcon, {})
20232
- })
20233
20249
  })]
20234
- })]
20235
- }),
20236
- /* @__PURE__ */ jsx(Confirm, {
20237
- visible: deleteConformKey === definedName.id,
20238
- onClose: handleDeleteClose,
20239
- onConfirm: () => {
20240
- handleDeleteConfirm(definedName.id);
20241
- },
20242
- children: localeService.t("definedName.deleteConfirmText")
20243
- }),
20244
- definedName.id === editorKey && /* @__PURE__ */ jsx(DefinedNameInput, {
20245
- confirm: insertConfirm,
20246
- cancel: closeInput,
20247
- state: definedName.id === editorKey,
20248
- id: definedName.id,
20249
- inputId: definedName.id + index,
20250
- name: definedName.name,
20251
- formulaOrRefString: definedName.formulaOrRefString,
20252
- comment: definedName.comment,
20253
- localSheetId: definedName.localSheetId
20254
- })
20255
- ]
20256
- }, index);
20257
- })]
20258
- })
20250
+ }),
20251
+ /* @__PURE__ */ jsx(Confirm, {
20252
+ visible: deleteConformKey === definedName.id,
20253
+ onClose: handleDeleteClose,
20254
+ onConfirm: () => {
20255
+ handleDeleteConfirm(definedName.id);
20256
+ },
20257
+ children: localeService.t("definedName.deleteConfirmText")
20258
+ }),
20259
+ definedName.id === editorKey && /* @__PURE__ */ jsx(DefinedNameInput, {
20260
+ confirm: insertConfirm,
20261
+ cancel: closeInput,
20262
+ state: definedName.id === editorKey,
20263
+ id: definedName.id,
20264
+ inputId: definedName.id + index,
20265
+ name: definedName.name,
20266
+ formulaOrRefString: definedName.formulaOrRefString,
20267
+ comment: definedName.comment,
20268
+ localSheetId: definedName.localSheetId
20269
+ })
20270
+ ]
20271
+ }, index);
20272
+ })
20273
+ })
20274
+ })]
20259
20275
  });
20260
20276
  };
20261
20277
 
@@ -20579,6 +20595,49 @@ const EditorContainer = () => {
20579
20595
  });
20580
20596
  };
20581
20597
 
20598
+ //#endregion
20599
+ //#region src/services/utils/defined-name-utils.ts
20600
+ let DefinedNameBoxActionType = /* @__PURE__ */ function(DefinedNameBoxActionType) {
20601
+ DefinedNameBoxActionType["Noop"] = "noop";
20602
+ DefinedNameBoxActionType["FocusDefinedName"] = "focusDefinedName";
20603
+ DefinedNameBoxActionType["FocusSelection"] = "focusSelection";
20604
+ DefinedNameBoxActionType["CreateDefinedName"] = "createDefinedName";
20605
+ DefinedNameBoxActionType["Reset"] = "reset";
20606
+ return DefinedNameBoxActionType;
20607
+ }({});
20608
+ function resolveDefinedNameBoxAction(params) {
20609
+ const { inputValue, rangeString, unitId, formulaOrRefString, univerInstanceService, definedNamesService, superTableService, functionService } = params;
20610
+ if (inputValue === rangeString) return { type: DefinedNameBoxActionType.Noop };
20611
+ const definedName = definedNamesService.getValueByName(unitId, inputValue);
20612
+ if (definedName) return {
20613
+ type: DefinedNameBoxActionType.FocusDefinedName,
20614
+ definedName
20615
+ };
20616
+ if (isReferenceStringWithEffectiveColumn(inputValue)) return {
20617
+ type: DefinedNameBoxActionType.FocusSelection,
20618
+ refString: inputValue
20619
+ };
20620
+ if (validateDefinedName(inputValue, {
20621
+ unitId,
20622
+ formulaOrRefString,
20623
+ univerInstanceService,
20624
+ definedNamesService,
20625
+ superTableService,
20626
+ functionService
20627
+ }) === true) return {
20628
+ type: DefinedNameBoxActionType.CreateDefinedName,
20629
+ name: inputValue
20630
+ };
20631
+ return { type: DefinedNameBoxActionType.Reset };
20632
+ }
20633
+ function getAbsoluteRefStringFromSelection(workbook, selections, lexerTreeBuilder) {
20634
+ var _workbook$getActiveSh;
20635
+ const sheetName = (_workbook$getActiveSh = workbook.getActiveSheet()) === null || _workbook$getActiveSh === void 0 ? void 0 : _workbook$getActiveSh.getName();
20636
+ if (!sheetName || selections == null || selections.length === 0) return "";
20637
+ const formulaOrRefs = selections.map((selection) => serializeRangeWithSheet(sheetName, selection.range)).join(",");
20638
+ return lexerTreeBuilder.convertRefersToAbsolute(formulaOrRefs, AbsoluteRefType.ALL, AbsoluteRefType.ALL, sheetName);
20639
+ }
20640
+
20582
20641
  //#endregion
20583
20642
  //#region src/views/defined-name/DefinedNameOverlay.tsx
20584
20643
  function DefinedNameOverlay({ search, isInputEvent }) {
@@ -20621,6 +20680,12 @@ function DefinedNameOverlay({ search, isInputEvent }) {
20621
20680
  isInputEvent,
20622
20681
  definedNames
20623
20682
  ]);
20683
+ const listContainerRef = useRef(void 0);
20684
+ const [virtualDefinedNames, virtualActions] = useVirtualList(filteredDefinedNames, {
20685
+ containerTarget: listContainerRef,
20686
+ itemHeight: 30,
20687
+ overscan: 6
20688
+ });
20624
20689
  const openSlider = () => {
20625
20690
  commandService.executeCommand(SidebarDefinedNameOperation.id, { value: "open" });
20626
20691
  };
@@ -20636,27 +20701,32 @@ function DefinedNameOverlay({ search, isInputEvent }) {
20636
20701
  };
20637
20702
  return /* @__PURE__ */ jsxs("div", {
20638
20703
  className: "univer-w-[300px]",
20639
- children: [/* @__PURE__ */ jsx("ul", {
20640
- className: clsx("univer-m-0 univer-max-h-[360px] univer-list-none univer-overflow-y-auto univer-p-0", scrollbarClassName),
20641
- children: filteredDefinedNames.map((definedName, index) => {
20642
- return /* @__PURE__ */ jsx("li", {
20643
- className: "univer-cursor-pointer univer-px-2 univer-transition-colors univer-duration-200 hover:univer-bg-gray-100 dark:hover:!univer-bg-gray-600",
20644
- onClick: () => {
20645
- focusDefinedName(definedName);
20646
- },
20647
- children: /* @__PURE__ */ jsxs("div", {
20648
- className: clsx("univer-flex univer-items-center univer-justify-between univer-gap-2 univer-py-1", borderBottomClassName),
20649
- children: [/* @__PURE__ */ jsx("div", {
20650
- className: "univer-w-[50%] univer-flex-shrink-0 univer-truncate univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",
20651
- title: definedName.name,
20652
- children: definedName.name
20653
- }), /* @__PURE__ */ jsx("div", {
20654
- className: "univer-w-[50%] univer-flex-shrink-0 univer-truncate univer-text-xs univer-text-gray-400",
20655
- title: definedName.formulaOrRefString,
20656
- children: definedName.formulaOrRefString
20657
- })]
20658
- })
20659
- }, index);
20704
+ children: [/* @__PURE__ */ jsx("div", {
20705
+ ref: listContainerRef,
20706
+ className: clsx("univer-max-h-[360px] univer-min-h-0 univer-overflow-y-auto", scrollbarClassName, { "univer-min-h-[30px]": filteredDefinedNames.length > 0 }),
20707
+ ...virtualActions.containerProps,
20708
+ children: /* @__PURE__ */ jsx("div", {
20709
+ style: virtualActions.wrapperStyle,
20710
+ children: virtualDefinedNames.map(({ data: definedName, index }) => {
20711
+ return /* @__PURE__ */ jsx("li", {
20712
+ className: "univer-cursor-pointer univer-px-2 univer-transition-colors univer-duration-200 hover:univer-bg-gray-100 dark:hover:!univer-bg-gray-600",
20713
+ onClick: () => {
20714
+ focusDefinedName(definedName);
20715
+ },
20716
+ children: /* @__PURE__ */ jsxs("div", {
20717
+ className: clsx("univer-flex univer-items-center univer-justify-between univer-gap-2 univer-py-1", borderBottomClassName),
20718
+ children: [/* @__PURE__ */ jsx("div", {
20719
+ className: "univer-w-[50%] univer-flex-shrink-0 univer-truncate univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",
20720
+ title: definedName.name,
20721
+ children: definedName.name
20722
+ }), /* @__PURE__ */ jsx("div", {
20723
+ className: "univer-w-[50%] univer-flex-shrink-0 univer-truncate univer-text-xs univer-text-gray-400",
20724
+ title: definedName.formulaOrRefString,
20725
+ children: definedName.formulaOrRefString
20726
+ })]
20727
+ })
20728
+ }, index);
20729
+ })
20660
20730
  })
20661
20731
  }), /* @__PURE__ */ jsxs("div", {
20662
20732
  className: "univer-cursor-pointer univer-p-2 univer-transition-colors univer-duration-200 hover:univer-bg-gray-100 dark:hover:!univer-bg-gray-600",
@@ -20682,11 +20752,15 @@ function DefinedName({ disable }) {
20682
20752
  const univerInstanceService = useDependency(IUniverInstanceService);
20683
20753
  const selectionManagerService = useDependency(SheetsSelectionsService);
20684
20754
  const lexerTreeBuilder = useDependency(LexerTreeBuilder);
20755
+ const superTableService = useDependency(ISuperTableService);
20756
+ const functionService = useDependency(IFunctionService);
20757
+ const layoutService = useDependency(ILayoutService);
20685
20758
  const workbook = univerInstanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_SHEET);
20686
20759
  const unitId = workbook === null || workbook === void 0 ? void 0 : workbook.getUnitId();
20687
20760
  const themeService = useDependency(ThemeService);
20688
20761
  const [open, setOpen] = useState(false);
20689
20762
  const [isInputEvent, setIsInputEvent] = useState(false);
20763
+ const inputRef = useRef(null);
20690
20764
  const getDefinedNameMap = () => {
20691
20765
  const definedNameMap = definedNamesService.getDefinedNameMap(unitId);
20692
20766
  if (definedNameMap) return Array.from(Object.values(definedNameMap));
@@ -20715,7 +20789,7 @@ function DefinedName({ disable }) {
20715
20789
  commandService.executeCommand(ScrollToCellCommand.id, { range: selections[0].range });
20716
20790
  });
20717
20791
  };
20718
- const [definedNames, setDefinedNames] = useState(getDefinedNameMap());
20792
+ const [definedNames, setDefinedNames] = useState(() => getDefinedNameMap());
20719
20793
  useEffect(() => {
20720
20794
  const definedNamesSubscription = definedNamesService.update$.subscribe(() => {
20721
20795
  setDefinedNames(getDefinedNameMap());
@@ -20726,13 +20800,7 @@ function DefinedName({ disable }) {
20726
20800
  }, []);
20727
20801
  useEffect(() => {
20728
20802
  const subscription = definedNamesService.currentRange$.subscribe(() => {
20729
- var _selections$map;
20730
- const selections = selectionManagerService.getCurrentSelections();
20731
- const worksheet = workbook.getActiveSheet();
20732
- const formulaOrRefs = selections === null || selections === void 0 || (_selections$map = selections.map((selection) => {
20733
- return serializeRangeWithSheet(worksheet.getName(), selection.range);
20734
- })) === null || _selections$map === void 0 ? void 0 : _selections$map.join(",");
20735
- const absoluteRef = lexerTreeBuilder.convertRefersToAbsolute(formulaOrRefs, AbsoluteRefType.ALL, AbsoluteRefType.ALL, worksheet.getName());
20803
+ const absoluteRef = getAbsoluteRefStringFromSelection(workbook, selectionManagerService.getCurrentSelections(), lexerTreeBuilder);
20736
20804
  const definedName = definedNamesService.getDefinedNameByRefString(unitId, absoluteRef);
20737
20805
  if (definedName) {
20738
20806
  setRangeString(definedName.name);
@@ -20763,22 +20831,59 @@ function DefinedName({ disable }) {
20763
20831
  handleDefinedNamesList(value);
20764
20832
  }
20765
20833
  function confirm() {
20766
- if (inputValue === rangeString) return;
20767
- const definedName = definedNames.find((i) => i.name === inputValue);
20768
- if (definedName) {
20769
- setRangeString(inputValue);
20770
- focusDefinedName(definedName);
20771
- } else if (isReferenceStringWithEffectiveColumn(inputValue)) {
20772
- setRangeString(inputValue);
20773
- focusSelection(inputValue);
20774
- } else resetValue();
20834
+ const formulaOrRefString = getAbsoluteRefStringFromSelection(workbook, selectionManagerService.getCurrentSelections(), lexerTreeBuilder);
20835
+ const action = resolveDefinedNameBoxAction({
20836
+ inputValue,
20837
+ rangeString,
20838
+ unitId,
20839
+ formulaOrRefString,
20840
+ univerInstanceService,
20841
+ definedNamesService,
20842
+ superTableService,
20843
+ functionService
20844
+ });
20845
+ switch (action.type) {
20846
+ case DefinedNameBoxActionType.Noop: return true;
20847
+ case DefinedNameBoxActionType.FocusDefinedName:
20848
+ setRangeString(action.definedName.name);
20849
+ setInputValue(action.definedName.name);
20850
+ focusDefinedName(action.definedName);
20851
+ return true;
20852
+ case DefinedNameBoxActionType.FocusSelection:
20853
+ setRangeString(action.refString);
20854
+ setInputValue(action.refString);
20855
+ focusSelection(action.refString);
20856
+ return true;
20857
+ case DefinedNameBoxActionType.CreateDefinedName: {
20858
+ if (!formulaOrRefString) {
20859
+ resetValue();
20860
+ return false;
20861
+ }
20862
+ const result = commandService.syncExecuteCommand(InsertDefinedNameCommand.id, {
20863
+ id: generateRandomId(10),
20864
+ unitId,
20865
+ name: action.name,
20866
+ formulaOrRefString,
20867
+ localSheetId: SCOPE_WORKBOOK_VALUE_DEFINED_NAME
20868
+ });
20869
+ if (result) {
20870
+ setRangeString(action.name);
20871
+ setInputValue(action.name);
20872
+ } else resetValue();
20873
+ return !!result;
20874
+ }
20875
+ case DefinedNameBoxActionType.Reset:
20876
+ resetValue();
20877
+ return false;
20878
+ }
20775
20879
  }
20776
20880
  function handleKeyDown(e) {
20777
20881
  if (disable) return;
20778
20882
  if (e.key === "Enter") {
20779
- confirm();
20883
+ const handled = confirm();
20780
20884
  setIsInputEvent(false);
20781
20885
  setOpen(false);
20886
+ if (handled) layoutService.focus();
20782
20887
  } else if (e.key === "Escape") {
20783
20888
  e.preventDefault();
20784
20889
  setIsInputEvent(false);
@@ -20810,6 +20915,7 @@ function DefinedName({ disable }) {
20810
20915
  "data-u-comp": "defined-name",
20811
20916
  className: "univer-relative univer-box-border univer-flex univer-h-full univer-w-24 univer-border-r-gray-200 univer-py-1.5 univer-transition-all",
20812
20917
  children: [/* @__PURE__ */ jsx("input", {
20918
+ ref: inputRef,
20813
20919
  className: clsx("univer-box-border univer-size-full univer-appearance-none univer-pl-1.5 univer-pr-5 univer-text-gray-900 focus:univer-outline-none dark:!univer-border-r-gray-700 dark:!univer-bg-gray-900 dark:!univer-text-white", borderRightClassName, { "univer-cursor-not-allowed": disable }),
20814
20920
  type: "text",
20815
20921
  value: inputValue,
@@ -23786,7 +23892,7 @@ const useHighlightRange = (ranges = []) => {
23786
23892
  //#endregion
23787
23893
  //#region package.json
23788
23894
  var name = "@univerjs/sheets-ui";
23789
- var version = "0.21.0";
23895
+ var version = "0.21.1";
23790
23896
 
23791
23897
  //#endregion
23792
23898
  //#region src/services/cell-alert-manager.service.ts