@univerjs/sheets-formula-ui 0.4.0-alpha.0 → 0.4.0-alpha.2

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,18 +2,19 @@ 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 { CommandType, ICommandService, createIdentifier, IContextService, IUniverInstanceService, Rectangle, DEFAULT_EMPTY_DOCUMENT_VALUE, isRealNum, CellValueType, getCellValueType, isFormulaString, isFormulaId, FOCUSING_DOC, FOCUSING_UNIVER_EDITOR, FOCUSING_UNIVER_EDITOR_STANDALONE_SINGLE_MODE, Disposable, isICellData, Inject, LocaleService, Tools, Direction, UniverInstanceType, Injector, ObjectMatrix, ThemeService, toDisposable, ColorKit, ILogService, RxDisposable, InterceptorEffectEnum, useDependency, useInjector, connectInjector, DisposableCollection, RANGE_TYPE, FORMULA_EDITOR_ACTIVATED, FOCUSING_EDITOR_INPUT_FORMULA, AbsoluteRefType, DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY, DOCS_NORMAL_EDITOR_UNIT_ID_KEY, Plugin, DependentOn, IConfigService } from "@univerjs/core";
6
- import { SheetPasteCommand, PREDEFINED_HOOK_NAME, CellAlertType, HoverManagerService, CellAlertManagerService, DATA_TYPE, APPLY_TYPE, IAutoFillService, COPY_TYPE, ISheetClipboardService, IEditorBridgeService, SheetSkeletonManagerService, ISheetSelectionRenderService, SelectionShape, SELECTION_SHAPE_DEPTH, useActiveWorkbook, getCurrentRangeDisable$, PASTE_SPECIAL_MENU_ID, whenFormulaEditorActivated, BaseSelectionRenderService, getCoordByOffset, checkInHeaderRanges, getAllSelection, attachSelectionWithCoord, getSheetObject, getEditorObject, MoveSelectionCommand, JumpOver, ExpandSelectionCommand } from "@univerjs/sheets-ui";
7
- import { sequenceNodeType, serializeRange, ERROR_TYPE_SET, ErrorType, LexerTreeBuilder, FormulaDataModel, SetFormulaCalculationResultMutation, SetArrayFormulaDataMutation, FunctionType, matchRefDrawToken, matchToken, compareToken, deserializeRangeWithSheet, normalizeSheetName, serializeRangeToRefString, generateStringWithSequence, getAbsoluteRefTypeWitString, UniverFormulaEnginePlugin } from "@univerjs/engine-formula";
8
- import { Subject, throttleTime, combineLatestWith, map, switchMap, of, Observable, distinctUntilKeyChanged, distinctUntilChanged } from "rxjs";
9
- import { IEditorService, DocSelectionRenderService, ReplaceContentCommand, MoveCursorOperation } from "@univerjs/docs-ui";
10
- import { SheetsSelectionsService, getSheetCommandTarget, getCellAtRowCol, SetSelectionsOperation, SetRangeValuesMutation, SetRangeValuesUndoMutationFactory, SetWorksheetRowAutoHeightMutation, INTERCEPTOR_POINT, SheetInterceptorService, WorkbookEditablePermission, WorksheetEditPermission, WorksheetSetCellValuePermission, RangeProtectionPermissionEditPoint, SelectionMoveType, convertSelectionDataToRange, getNormalSelectionStyle, IRefSelectionsService, DISABLE_NORMAL_SELECTIONS, setEndForRange, getPrimaryForRange } from "@univerjs/sheets";
5
+ import { CommandType, ICommandService, createIdentifier, IContextService, IUniverInstanceService, Rectangle, DEFAULT_EMPTY_DOCUMENT_VALUE, isRealNum, CellValueType, getCellValueType, toDisposable, DisposableCollection, RANGE_TYPE, Inject, Injector, ThemeService, useDependency, ColorKit, UniverInstanceType, debounce, LocaleService, createInternalEditorID, generateRandomId, isFormulaString, isFormulaId, FOCUSING_DOC, FOCUSING_UNIVER_EDITOR, FOCUSING_UNIVER_EDITOR_STANDALONE_SINGLE_MODE, Disposable, isICellData, Tools, Direction, ObjectMatrix, ILogService, RxDisposable, InterceptorEffectEnum, useInjector, useObservable, connectInjector, FORMULA_EDITOR_ACTIVATED, FOCUSING_EDITOR_INPUT_FORMULA, AbsoluteRefType, DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY, DOCS_NORMAL_EDITOR_UNIT_ID_KEY, Plugin, DependentOn, IConfigService } from "@univerjs/core";
6
+ import { SheetPasteCommand, PREDEFINED_HOOK_NAME, BaseSelectionRenderService, getCoordByOffset, checkInHeaderRanges, getAllSelection, attachSelectionWithCoord, getSheetObject, SheetSkeletonManagerService, attachRangeWithCoord, IEditorBridgeService, RANGE_SELECTOR_SYMBOLS, SetCellEditVisibleOperation, CellAlertType, HoverManagerService, CellAlertManagerService, DATA_TYPE, APPLY_TYPE, IAutoFillService, COPY_TYPE, ISheetClipboardService, ISheetSelectionRenderService, SelectionShape, SELECTION_SHAPE_DEPTH, useActiveWorkbook, getCurrentRangeDisable$, PASTE_SPECIAL_MENU_ID, whenFormulaEditorActivated, isRangeSelector, getEditorObject, MoveSelectionCommand, JumpOver, ExpandSelectionCommand, RANGE_SELECTOR_COMPONENT_KEY } from "@univerjs/sheets-ui";
7
+ import { sequenceNodeType, serializeRange, matchToken, LexerTreeBuilder, deserializeRangeWithSheet, serializeRangeWithSheet, ERROR_TYPE_SET, ErrorType, FormulaDataModel, SetFormulaCalculationResultMutation, SetArrayFormulaDataMutation, FunctionType, matchRefDrawToken, compareToken, normalizeSheetName, serializeRangeToRefString, generateStringWithSequence, getAbsoluteRefTypeWitString, UniverFormulaEnginePlugin } from "@univerjs/engine-formula";
8
+ import { Subject, merge, map, distinctUntilChanged, throttleTime as throttleTime$1, combineLatestWith, switchMap, of, Observable, filter, distinctUntilKeyChanged } from "rxjs";
9
+ import { IEditorService, VIEWPORT_KEY, DocBackScrollRenderController, DocSelectionRenderService, ReplaceContentCommand, MoveCursorOperation } from "@univerjs/docs-ui";
10
+ import { SheetsSelectionsService, getSheetCommandTarget, getCellAtRowCol, SetSelectionsOperation, SelectionMoveType, convertSelectionDataToRange, getNormalSelectionStyle, IRefSelectionsService, setEndForRange, DISABLE_NORMAL_SELECTIONS, SetWorksheetActiveOperation, SetRangeValuesMutation, SetRangeValuesUndoMutationFactory, SetWorksheetRowAutoHeightMutation, INTERCEPTOR_POINT, SheetInterceptorService, WorkbookEditablePermission, WorksheetEditPermission, WorksheetSetCellValuePermission, RangeProtectionPermissionEditPoint, getPrimaryForRange } from "@univerjs/sheets";
11
11
  import { InsertFunctionCommand, IDescriptionService, UniverSheetsFormulaPlugin } from "@univerjs/sheets-formula";
12
- import { ISidebarService, IZenZoneService, ILayoutService, MenuItemType, getMenuHiddenObservable, IClipboardInterfaceService, RibbonStartGroup, KeyCode, MetaKeys, BuiltInUIPart, ComponentManager, IMenuManagerService, IShortcutService, IUIPartsService, UNI_DISABLE_CHANGING_FOCUS_KEY, SetEditorResizeOperation, IContextMenuService } from "@univerjs/ui";
13
- import { IRenderManagerService, DeviceInputEventType, ScrollTimerType, SHEET_VIEWPORT_KEY, Vector2 } from "@univerjs/engine-render";
14
- import require$$0, { forwardRef, useRef, createElement, useEffect, useState } from "react";
15
- import { Popup, Select, Input, Button } from "@univerjs/design";
12
+ import { ISidebarService, IShortcutService, IContextMenuService, IZenZoneService, ILayoutService, MenuItemType, getMenuHiddenObservable, IClipboardInterfaceService, RibbonStartGroup, KeyCode, MetaKeys, BuiltInUIPart, ComponentManager, IMenuManagerService, IUIPartsService, UNI_DISABLE_CHANGING_FOCUS_KEY, SetEditorResizeOperation } from "@univerjs/ui";
13
+ import require$$0, { forwardRef, useRef, createElement, useEffect, useState, useMemo, useLayoutEffect, useCallback } from "react";
14
+ import { Tooltip, Dialog, Button, Input, Popup, Select } from "@univerjs/design";
15
+ import { ScrollTimerType, SHEET_VIEWPORT_KEY, Vector2, IRenderManagerService, ScrollBar, DeviceInputEventType } from "@univerjs/engine-render";
16
16
  import { DocSkeletonManagerService, DocSelectionManagerService } from "@univerjs/docs";
17
+ import { throttleTime } from "rxjs/operators";
17
18
  const SheetOnlyPasteFormulaCommand = {
18
19
  id: "sheet.command.paste-formula",
19
20
  type: CommandType.COMMAND,
@@ -275,15 +276,15 @@ __name(findRefRange, "findRefRange");
275
276
  function findStartRow(cellMatrix, row, column) {
276
277
  let isFirstNumber = !1;
277
278
  if (row === 0) return row;
278
- for (let r = row - 1; r >= 0; r--) {
279
- const cell = cellMatrix.getValue(r, column);
279
+ for (let r2 = row - 1; r2 >= 0; r2--) {
280
+ const cell = cellMatrix.getValue(r2, column);
280
281
  if (isNumberCell(cell) && !isFirstNumber) {
281
- if (r === 0) return 0;
282
+ if (r2 === 0) return 0;
282
283
  isFirstNumber = !0;
283
284
  } else {
284
285
  if (isFirstNumber && !isNumberCell(cell))
285
- return r + 1;
286
- if (isFirstNumber && r === 0)
286
+ return r2 + 1;
287
+ if (isFirstNumber && r2 === 0)
287
288
  return 0;
288
289
  }
289
290
  }
@@ -342,7 +343,899 @@ const FORMULA_UI_PLUGIN_NAME = "SHEET_FORMULA_UI_PLUGIN", MORE_FUNCTIONS_COMPONE
342
343
  id: "formula-ui.operation.search-function",
343
344
  type: CommandType.OPERATION,
344
345
  handler: /* @__PURE__ */ __name(async (accessor, params) => (accessor.get(IFormulaPromptService).search(params), !0), "handler")
345
- }, PLUGIN_CONFIG_KEY_BASE = "sheets-formula.base.config", defaultPluginBaseConfig = {};
346
+ };
347
+ var jsxRuntime = { exports: {} }, reactJsxRuntime_production_min = {};
348
+ /**
349
+ * @license React
350
+ * react-jsx-runtime.production.min.js
351
+ *
352
+ * Copyright (c) Facebook, Inc. and its affiliates.
353
+ *
354
+ * This source code is licensed under the MIT license found in the
355
+ * LICENSE file in the root directory of this source tree.
356
+ */
357
+ var f = require$$0, k = Symbol.for("react.element"), l = Symbol.for("react.fragment"), m = Object.prototype.hasOwnProperty, n = f.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, p = { key: !0, ref: !0, __self: !0, __source: !0 };
358
+ function q(c, a, g) {
359
+ var b, d = {}, e = null, h = null;
360
+ g !== void 0 && (e = "" + g), a.key !== void 0 && (e = "" + a.key), a.ref !== void 0 && (h = a.ref);
361
+ for (b in a) m.call(a, b) && !p.hasOwnProperty(b) && (d[b] = a[b]);
362
+ if (c && c.defaultProps) for (b in a = c.defaultProps, a) d[b] === void 0 && (d[b] = a[b]);
363
+ return { $$typeof: k, type: c, key: e, ref: h, props: d, _owner: n.current };
364
+ }
365
+ __name(q, "q");
366
+ reactJsxRuntime_production_min.Fragment = l;
367
+ reactJsxRuntime_production_min.jsx = q;
368
+ reactJsxRuntime_production_min.jsxs = q;
369
+ jsxRuntime.exports = reactJsxRuntime_production_min;
370
+ var jsxRuntimeExports = jsxRuntime.exports, __assign = function() {
371
+ return __assign = Object.assign || function(t) {
372
+ for (var s, i = 1, n2 = arguments.length; i < n2; i++) {
373
+ s = arguments[i];
374
+ for (var p2 in s) Object.prototype.hasOwnProperty.call(s, p2) && (t[p2] = s[p2]);
375
+ }
376
+ return t;
377
+ }, __assign.apply(this, arguments);
378
+ }, __rest = function(s, e) {
379
+ var t = {};
380
+ for (var p2 in s) Object.prototype.hasOwnProperty.call(s, p2) && e.indexOf(p2) < 0 && (t[p2] = s[p2]);
381
+ if (s != null && typeof Object.getOwnPropertySymbols == "function")
382
+ for (var i = 0, p2 = Object.getOwnPropertySymbols(s); i < p2.length; i++)
383
+ e.indexOf(p2[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p2[i]) && (t[p2[i]] = s[p2[i]]);
384
+ return t;
385
+ }, IconBase = forwardRef(function(props, ref) {
386
+ var icon = props.icon, id = props.id, className = props.className, extend = props.extend, restProps = __rest(props, ["icon", "id", "className", "extend"]), cls = "univerjs-icon univerjs-icon-".concat(id, " ").concat(className || "").trim(), idSuffix = useRef("_".concat(generateShortUuid()));
387
+ return render(icon, "".concat(id), { defIds: icon.defIds, idSuffix: idSuffix.current }, __assign({ ref, className: cls }, restProps), extend);
388
+ });
389
+ function render(node, id, runtimeProps, rootProps, extend) {
390
+ return createElement(node.tag, __assign(__assign({ key: id }, replaceRuntimeIdsAndExtInAttrs(node, runtimeProps, extend)), rootProps), (replaceRuntimeIdsInDefs(node, runtimeProps).children || []).map(function(child, index) {
391
+ return render(child, "".concat(id, "-").concat(node.tag, "-").concat(index), runtimeProps, void 0, extend);
392
+ }));
393
+ }
394
+ __name(render, "render");
395
+ function replaceRuntimeIdsAndExtInAttrs(node, runtimeProps, extend) {
396
+ var attrs = __assign({}, node.attrs);
397
+ extend != null && extend.colorChannel1 && attrs.fill === "colorChannel1" && (attrs.fill = extend.colorChannel1);
398
+ var defIds = runtimeProps.defIds;
399
+ return !defIds || defIds.length === 0 || (node.tag === "use" && attrs["xlink:href"] && (attrs["xlink:href"] = attrs["xlink:href"] + runtimeProps.idSuffix), Object.entries(attrs).forEach(function(_a11) {
400
+ var key = _a11[0], value = _a11[1];
401
+ typeof value == "string" && (attrs[key] = value.replace(/url\(#(.*)\)/, "url(#$1".concat(runtimeProps.idSuffix, ")")));
402
+ })), attrs;
403
+ }
404
+ __name(replaceRuntimeIdsAndExtInAttrs, "replaceRuntimeIdsAndExtInAttrs");
405
+ function replaceRuntimeIdsInDefs(node, runtimeProps) {
406
+ var _a11, defIds = runtimeProps.defIds;
407
+ return !defIds || defIds.length === 0 ? node : node.tag === "defs" && (!((_a11 = node.children) === null || _a11 === void 0) && _a11.length) ? __assign(__assign({}, node), { children: node.children.map(function(child) {
408
+ 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;
409
+ }) }) : node;
410
+ }
411
+ __name(replaceRuntimeIdsInDefs, "replaceRuntimeIdsInDefs");
412
+ function generateShortUuid() {
413
+ return Math.random().toString(36).substring(2, 8);
414
+ }
415
+ __name(generateShortUuid, "generateShortUuid");
416
+ IconBase.displayName = "UniverIcon";
417
+ var element$6 = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M14.1544 3.75557C14.3887 3.98988 14.3887 4.36978 14.1544 4.6041L6.51409 12.2444C6.40157 12.3569 6.24896 12.4201 6.08983 12.4201C5.9307 12.4201 5.77808 12.3569 5.66556 12.2444L1.84541 8.42425C1.6111 8.18993 1.6111 7.81003 1.84541 7.57572C2.07973 7.34141 2.45963 7.34141 2.69394 7.57572L6.08983 10.9716L13.3059 3.75557C13.5402 3.52126 13.9201 3.52126 14.1544 3.75557Z", fillRule: "evenodd", clipRule: "evenodd" } }] }, CheckMarkSingle = forwardRef(function(props, ref) {
418
+ return createElement(IconBase, Object.assign({}, props, {
419
+ id: "check-mark-single",
420
+ ref,
421
+ icon: element$6
422
+ }));
423
+ });
424
+ CheckMarkSingle.displayName = "CheckMarkSingle";
425
+ var element$5 = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M3.71274 2.86421C3.47843 2.6299 3.09853 2.6299 2.86421 2.86421C2.6299 3.09853 2.6299 3.47843 2.86421 3.71274L7.15154 8.00007L2.86421 12.2874C2.6299 12.5217 2.6299 12.9016 2.86421 13.1359C3.09853 13.3702 3.47843 13.3702 3.71274 13.1359L8.00007 8.84859L12.2874 13.1359C12.5217 13.3702 12.9016 13.3702 13.1359 13.1359C13.3702 12.9016 13.3702 12.5217 13.1359 12.2874L8.84859 8.00007L13.1359 3.71274C13.3702 3.47843 13.3702 3.09853 13.1359 2.86421C12.9016 2.6299 12.5217 2.6299 12.2874 2.86421L8.00007 7.15154L3.71274 2.86421Z" } }] }, CloseSingle = forwardRef(function(props, ref) {
426
+ return createElement(IconBase, Object.assign({}, props, {
427
+ id: "close-single",
428
+ ref,
429
+ icon: element$5
430
+ }));
431
+ });
432
+ CloseSingle.displayName = "CloseSingle";
433
+ var element$4 = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M5.3313 1.4667C5.3313 1.13533 5.59993.866699 5.9313.866699H10.069C10.4004.866699 10.669 1.13533 10.669 1.4667 10.669 1.79807 10.4004 2.0667 10.069 2.0667H5.9313C5.59993 2.0667 5.3313 1.79807 5.3313 1.4667zM1.09985 3.64443C1.09985 3.31306 1.36848 3.04443 1.69985 3.04443H14.2999C14.6312 3.04443 14.8999 3.31306 14.8999 3.64443 14.8999 3.9758 14.6312 4.24443 14.2999 4.24443H1.69985C1.36848 4.24443 1.09985 3.9758 1.09985 3.64443zM6.12398 8.30171C6.35829 8.0674 6.73819 8.0674 6.97251 8.30171L8.00007 9.32928 9.02764 8.30171C9.26195 8.0674 9.64185 8.0674 9.87617 8.30171 10.1105 8.53603 10.1105 8.91593 9.87617 9.15024L8.8486 10.1778 9.87617 11.2054C10.1105 11.4397 10.1105 11.8196 9.87617 12.0539 9.64185 12.2882 9.26195 12.2882 9.02764 12.0539L8.00007 11.0263 6.97251 12.0539C6.73819 12.2882 6.35829 12.2882 6.12398 12.0539 5.88966 11.8196 5.88966 11.4397 6.12398 11.2054L7.15154 10.1778 6.12398 9.15024C5.88966 8.91593 5.88966 8.53603 6.12398 8.30171z" } }, { tag: "path", attrs: { fill: "currentColor", d: "M4.75332 5.22217C3.86966 5.22217 3.15332 5.93851 3.15332 6.82217V12.5331C3.15332 13.9691 4.31738 15.1332 5.75332 15.1332H10.2465C11.6825 15.1332 12.8465 13.9691 12.8465 12.5331V6.82217C12.8465 5.93851 12.1302 5.22217 11.2465 5.22217H4.75332ZM4.35332 6.82217C4.35332 6.60125 4.53241 6.42217 4.75332 6.42217H11.2465C11.4674 6.42217 11.6465 6.60125 11.6465 6.82217V12.5331C11.6465 13.3063 11.0197 13.9332 10.2465 13.9332H5.75332C4.98012 13.9332 4.35332 13.3063 4.35332 12.5331V6.82217Z", fillRule: "evenodd", clipRule: "evenodd" } }] }, DeleteSingle = forwardRef(function(props, ref) {
434
+ return createElement(IconBase, Object.assign({}, props, {
435
+ id: "delete-single",
436
+ ref,
437
+ icon: element$4
438
+ }));
439
+ });
440
+ DeleteSingle.displayName = "DeleteSingle";
441
+ var element$3 = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M8.75 5.32495C8.75 5.73916 8.41421 6.07495 8 6.07495 7.58579 6.07495 7.25 5.73916 7.25 5.32495 7.25 4.91074 7.58579 4.57495 8 4.57495 8.41421 4.57495 8.75 4.91074 8.75 5.32495zM8.5999 7.52505C8.5999 7.19368 8.33127 6.92505 7.9999 6.92505 7.66853 6.92505 7.3999 7.19368 7.3999 7.52505V11.425C7.3999 11.7564 7.66853 12.025 7.9999 12.025 8.33127 12.025 8.5999 11.7564 8.5999 11.425V7.52505z" } }, { tag: "path", attrs: { fill: "currentColor", d: "M0.899902 8.00002C0.899902 4.0788 4.07868 0.900024 7.9999 0.900024C11.9211 0.900024 15.0999 4.0788 15.0999 8.00002C15.0999 11.9212 11.9211 15.1 7.9999 15.1C4.07868 15.1 0.899902 11.9212 0.899902 8.00002ZM7.9999 2.10002C4.74142 2.10002 2.0999 4.74154 2.0999 8.00002C2.0999 11.2585 4.74142 13.9 7.9999 13.9C11.2584 13.9 13.8999 11.2585 13.8999 8.00002C13.8999 4.74154 11.2584 2.10002 7.9999 2.10002Z", fillRule: "evenodd", clipRule: "evenodd" } }] }, DetailsSingle = forwardRef(function(props, ref) {
442
+ return createElement(IconBase, Object.assign({}, props, {
443
+ id: "details-single",
444
+ ref,
445
+ icon: element$3
446
+ }));
447
+ });
448
+ DetailsSingle.displayName = "DetailsSingle";
449
+ var element$2 = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M8.6 1.99991C8.60001 1.66854 8.33138 1.39991 8.00001 1.3999C7.66864 1.3999 7.40001 1.66853 7.4 1.9999L7.39996 7.3999H1.9999C1.66853 7.3999 1.3999 7.66853 1.3999 7.9999C1.3999 8.33127 1.66853 8.5999 1.9999 8.5999H7.39995L7.3999 13.9999C7.3999 14.3313 7.66853 14.5999 7.9999 14.5999C8.33127 14.5999 8.5999 14.3313 8.5999 13.9999L8.59995 8.5999H13.9999C14.3313 8.5999 14.5999 8.33127 14.5999 7.9999C14.5999 7.66853 14.3313 7.3999 13.9999 7.3999H8.59996L8.6 1.99991Z" } }] }, IncreaseSingle = forwardRef(function(props, ref) {
450
+ return createElement(IconBase, Object.assign({}, props, {
451
+ id: "increase-single",
452
+ ref,
453
+ icon: element$2
454
+ }));
455
+ });
456
+ IncreaseSingle.displayName = "IncreaseSingle";
457
+ var element$1 = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M5.90913 3.57564C6.14345 3.34132 6.52335 3.34132 6.75766 3.57564L10.7577 7.57564C10.992 7.80995 10.992 8.18985 10.7577 8.42417L6.75766 12.4242C6.52335 12.6585 6.14345 12.6585 5.90913 12.4242C5.67482 12.1899 5.67482 11.81 5.90913 11.5756L9.48487 7.9999L5.90913 4.42417C5.67482 4.18985 5.67482 3.80995 5.90913 3.57564Z", fillRule: "evenodd", clipRule: "evenodd" } }] }, MoreSingle = forwardRef(function(props, ref) {
458
+ return createElement(IconBase, Object.assign({}, props, {
459
+ id: "more-single",
460
+ ref,
461
+ icon: element$1
462
+ }));
463
+ });
464
+ MoreSingle.displayName = "MoreSingle";
465
+ var element = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M12.6185 12.4423C12.5907 12.2749 12.7773 12.15 12.9343 12.2308L15.4242 13.5126C15.6102 13.6084 15.5544 13.8745 15.3439 13.8955L14.2456 14.184L13.4521 15.1286C13.3495 15.2939 13.085 15.2463 13.0534 15.0568L12.6185 12.4423Z" } }, { tag: "path", attrs: { fill: "currentColor", d: "M1 3.6C1 2.16406 2.16406 1 3.6 1H12.3C13.7359 1 14.9 2.16406 14.9 3.6V5.81156C14.9003 5.81881 14.9004 5.82609 14.9004 5.8334C14.9004 5.84071 14.9003 5.84799 14.9 5.85524V10.045C14.9003 10.0522 14.9004 10.0595 14.9004 10.0668C14.9004 10.3982 14.6318 10.6668 14.3004 10.6668H11.1668C10.8907 10.6668 10.6668 10.8907 10.6668 11.1668V14.3C10.6668 14.6314 10.3982 14.9 10.0668 14.9L10.05 14.8998L3.6 14.9C2.16406 14.9 1 13.7359 1 12.3V3.6ZM13.2 5.2334C13.4761 5.2334 13.7 5.00954 13.7 4.7334V3.6C13.7 2.8268 13.0732 2.2 12.3 2.2H11.1668C10.8907 2.2 10.6668 2.42386 10.6668 2.7V4.7334C10.6668 5.00954 10.8907 5.2334 11.1668 5.2334H13.2ZM10.6668 6.9334C10.6668 6.65726 10.8907 6.4334 11.1668 6.4334H13.2C13.4761 6.4334 13.7 6.65726 13.7 6.9334V8.9668C13.7 9.24294 13.4761 9.4668 13.2 9.4668H11.1668C10.8907 9.4668 10.6668 9.24294 10.6668 8.9668V6.9334ZM8.9668 5.2334C9.24294 5.2334 9.4668 5.00954 9.4668 4.7334V2.7C9.4668 2.42386 9.24294 2.2 8.9668 2.2H6.9334C6.65726 2.2 6.4334 2.42386 6.4334 2.7V4.7334C6.4334 5.00954 6.65726 5.2334 6.9334 5.2334L8.9668 5.2334ZM6.4334 6.9334C6.4334 6.65726 6.65726 6.4334 6.9334 6.4334L8.9668 6.4334C9.24294 6.4334 9.4668 6.65726 9.4668 6.9334V8.9668C9.4668 9.24294 9.24294 9.4668 8.9668 9.4668L6.9334 9.4668C6.65726 9.4668 6.4334 9.24294 6.4334 8.9668V6.9334ZM4.7334 5.2334C5.00954 5.2334 5.2334 5.00954 5.2334 4.7334V2.7C5.2334 2.42386 5.00954 2.2 4.7334 2.2H3.6C2.8268 2.2 2.2 2.8268 2.2 3.6V4.7334C2.2 5.00954 2.42386 5.2334 2.7 5.2334H4.7334ZM2.2 6.9334C2.2 6.65726 2.42386 6.4334 2.7 6.4334H4.7334C5.00954 6.4334 5.2334 6.65725 5.2334 6.9334V8.9668C5.2334 9.24294 5.00954 9.4668 4.7334 9.4668H2.7C2.42386 9.4668 2.2 9.24294 2.2 8.9668V6.9334ZM5.2334 11.1668C5.2334 10.8907 5.00954 10.6668 4.7334 10.6668H2.7C2.42386 10.6668 2.2 10.8907 2.2 11.1668V12.3C2.2 13.0732 2.8268 13.7 3.6 13.7H4.7334C5.00954 13.7 5.2334 13.4761 5.2334 13.2V11.1668ZM9.4668 11.1668C9.4668 10.8907 9.24294 10.6668 8.9668 10.6668H6.9334C6.65726 10.6668 6.4334 10.8907 6.4334 11.1668V13.2C6.4334 13.4761 6.65726 13.7 6.9334 13.7H8.9668C9.24294 13.7 9.4668 13.4761 9.4668 13.2V11.1668Z", fillRule: "evenodd", clipRule: "evenodd" } }] }, SelectRangeSingle = forwardRef(function(props, ref) {
466
+ return createElement(IconBase, Object.assign({}, props, {
467
+ id: "select-range-single",
468
+ ref,
469
+ icon: element
470
+ }));
471
+ });
472
+ SelectRangeSingle.displayName = "SelectRangeSingle";
473
+ function r(e) {
474
+ var t, f2, n2 = "";
475
+ if (typeof e == "string" || typeof e == "number") n2 += e;
476
+ else if (typeof e == "object") if (Array.isArray(e)) {
477
+ var o = e.length;
478
+ for (t = 0; t < o; t++) e[t] && (f2 = r(e[t])) && (n2 && (n2 += " "), n2 += f2);
479
+ } else for (f2 in e) e[f2] && (n2 && (n2 += " "), n2 += f2);
480
+ return n2;
481
+ }
482
+ __name(r, "r");
483
+ function clsx() {
484
+ for (var e, t, f2 = 0, n2 = "", o = arguments.length; f2 < o; f2++) (e = arguments[f2]) && (t = r(e)) && (n2 && (n2 += " "), n2 += t);
485
+ return n2;
486
+ }
487
+ __name(clsx, "clsx");
488
+ var __defProp$8 = Object.defineProperty, __getOwnPropDesc$8 = Object.getOwnPropertyDescriptor, __decorateClass$8 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
489
+ for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$8(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
490
+ (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
491
+ return kind && result && __defProp$8(target, key, result), result;
492
+ }, "__decorateClass$8"), __decorateParam$8 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$8"), _a2;
493
+ let RefSelectionsRenderService = (_a2 = class extends BaseSelectionRenderService {
494
+ constructor(_context, injector, themeService, shortcutService, sheetSkeletonManagerService, _refSelectionsService) {
495
+ super(
496
+ injector,
497
+ themeService,
498
+ shortcutService,
499
+ sheetSkeletonManagerService
500
+ );
501
+ __publicField(this, "_workbookSelections");
502
+ __publicField(this, "_eventDisposables");
503
+ this._context = _context, this._refSelectionsService = _refSelectionsService, this._workbookSelections = this._refSelectionsService.getWorkbookSelections(this._context.unitId), this._initSelectionChangeListener(), this._initSkeletonChangeListener(), this._initUserActionSyncListener(), this._setSelectionStyle(getDefaultRefSelectionStyle(this._themeService)), this._remainLastEnabled = !0;
504
+ }
505
+ getLocation() {
506
+ return this._skeleton.getLocation();
507
+ }
508
+ setRemainLastEnabled(enabled) {
509
+ this._remainLastEnabled = enabled;
510
+ }
511
+ /**
512
+ * This is set to true when you need to add a new selection.
513
+ * @param {boolean} enabled
514
+ * @memberof RefSelectionsRenderService
515
+ */
516
+ setSkipLastEnabled(enabled) {
517
+ this._skipLastEnabled = enabled;
518
+ }
519
+ clearLastSelection() {
520
+ const last = this._selectionControls[this._selectionControls.length - 1];
521
+ last && (last.dispose(), this._selectionControls.pop());
522
+ }
523
+ /**
524
+ * Call this method and user will be able to select on the canvas to update selections.
525
+ */
526
+ enableSelectionChanging() {
527
+ return this._disableSelectionChanging(), this._eventDisposables = this._initCanvasEventListeners(), toDisposable(() => this._disableSelectionChanging());
528
+ }
529
+ _disableSelectionChanging() {
530
+ var _a11;
531
+ (_a11 = this._eventDisposables) == null || _a11.dispose(), this._eventDisposables = null;
532
+ }
533
+ _initCanvasEventListeners() {
534
+ const sheetObject = this._getSheetObject(), { spreadsheetRowHeader, spreadsheetColumnHeader, spreadsheet, spreadsheetLeftTopPlaceholder } = sheetObject, { scene } = this._context, listenerDisposables = new DisposableCollection();
535
+ return listenerDisposables.add(spreadsheet == null ? void 0 : spreadsheet.onPointerDown$.subscribeEvent((evt, state) => {
536
+ this._onPointerDown(evt, spreadsheet.zIndex + 1, RANGE_TYPE.NORMAL, this._getActiveViewport(evt)), evt.button !== 2 && state.stopPropagation();
537
+ })), listenerDisposables.add(
538
+ spreadsheetRowHeader == null ? void 0 : spreadsheetRowHeader.onPointerDown$.subscribeEvent((evt, state) => {
539
+ const skeleton = this._sheetSkeletonManagerService.getCurrent().skeleton, { row } = getCoordByOffset(evt.offsetX, evt.offsetY, scene, skeleton);
540
+ checkInHeaderRanges(this._workbookSelections.getCurrentSelections(), row, RANGE_TYPE.ROW) || (this._onPointerDown(evt, (spreadsheet.zIndex || 1) + 1, RANGE_TYPE.ROW, this._getActiveViewport(evt), ScrollTimerType.Y), evt.button !== 2 && state.stopPropagation());
541
+ })
542
+ ), listenerDisposables.add(spreadsheetColumnHeader == null ? void 0 : spreadsheetColumnHeader.onPointerDown$.subscribeEvent((evt, state) => {
543
+ const skeleton = this._sheetSkeletonManagerService.getCurrent().skeleton, { column } = getCoordByOffset(evt.offsetX, evt.offsetY, scene, skeleton);
544
+ checkInHeaderRanges(this._workbookSelections.getCurrentSelections(), column, RANGE_TYPE.COLUMN) || (this._onPointerDown(evt, (spreadsheet.zIndex || 1) + 1, RANGE_TYPE.COLUMN, this._getActiveViewport(evt), ScrollTimerType.X), evt.button !== 2 && state.stopPropagation());
545
+ })), listenerDisposables.add(spreadsheetLeftTopPlaceholder == null ? void 0 : spreadsheetLeftTopPlaceholder.onPointerDown$.subscribeEvent((evt, state) => {
546
+ this._reset();
547
+ const skeleton = this._sheetSkeletonManagerService.getCurrent().skeleton, selectionWithStyle = getAllSelection(skeleton), selectionData = this.attachSelectionWithCoord(selectionWithStyle);
548
+ this._addSelectionControlBySelectionData(selectionData), this._selectionMoveStart$.next(this.getSelectionDataWithStyle());
549
+ const dispose = scene.onPointerUp$.subscribeEvent(() => {
550
+ dispose.unsubscribe(), this._selectionMoveEnd$.next(this.getSelectionDataWithStyle());
551
+ });
552
+ evt.button !== 2 && state.stopPropagation();
553
+ })), listenerDisposables;
554
+ }
555
+ /**
556
+ * Update selectionModel in this._workbookSelections by user action in spreadsheet area.
557
+ */
558
+ _initUserActionSyncListener() {
559
+ this.disposeWithMe(this.selectionMoveStart$.subscribe((selectionDataWithStyle) => {
560
+ this._updateSelections(selectionDataWithStyle, SelectionMoveType.MOVE_START);
561
+ })), this.disposeWithMe(this.selectionMoving$.subscribe((selectionDataWithStyle) => {
562
+ this._updateSelections(selectionDataWithStyle, SelectionMoveType.MOVING);
563
+ })), this.disposeWithMe(this.selectionMoveEnd$.subscribe((selectionDataWithStyle) => {
564
+ this._updateSelections(selectionDataWithStyle, SelectionMoveType.MOVE_END);
565
+ }));
566
+ }
567
+ _updateSelections(selectionDataWithStyleList, type) {
568
+ const sheetId = this._context.unit.getActiveSheet().getSheetId();
569
+ selectionDataWithStyleList.length !== 0 && this._workbookSelections.setSelections(
570
+ sheetId,
571
+ selectionDataWithStyleList.map((selectionDataWithStyle) => convertSelectionDataToRange(selectionDataWithStyle)),
572
+ type
573
+ );
574
+ }
575
+ _initSelectionChangeListener() {
576
+ this.disposeWithMe(merge(this._workbookSelections.selectionMoveEnd$, this._workbookSelections.selectionSet$).subscribe((selectionsWithStyles) => {
577
+ this._reset();
578
+ for (const selectionWithStyle of selectionsWithStyles) {
579
+ const selectionData = this.attachSelectionWithCoord(selectionWithStyle);
580
+ this._addSelectionControlBySelectionData(selectionData);
581
+ }
582
+ }));
583
+ }
584
+ _initSkeletonChangeListener() {
585
+ this.disposeWithMe(this._sheetSkeletonManagerService.currentSkeleton$.subscribe((param) => {
586
+ if (!param)
587
+ return;
588
+ const { skeleton } = param, { scene } = this._context, viewportMain = scene.getViewport(SHEET_VIEWPORT_KEY.VIEW_MAIN);
589
+ this._skeleton && this._skeleton.worksheet.getSheetId() !== skeleton.worksheet.getSheetId() && this._reset(), this._changeRuntime(skeleton, scene, viewportMain);
590
+ const currentSelections = this._workbookSelections.getCurrentSelections();
591
+ this._refreshSelectionControl(currentSelections || []);
592
+ }));
593
+ }
594
+ _refreshSelectionControl(selectionsData) {
595
+ const selections = selectionsData.map((selectionWithStyle) => attachSelectionWithCoord(selectionWithStyle, this._skeleton));
596
+ this.updateControlForCurrentByRangeData(selections);
597
+ }
598
+ _getActiveViewport(evt) {
599
+ const sheetObject = this._getSheetObject();
600
+ return sheetObject == null ? void 0 : sheetObject.scene.getActiveViewportByCoord(Vector2.FromArray([evt.offsetX, evt.offsetY]));
601
+ }
602
+ _getSheetObject() {
603
+ return getSheetObject(this._context.unit, this._context);
604
+ }
605
+ }, __name(_a2, "RefSelectionsRenderService"), _a2);
606
+ RefSelectionsRenderService = __decorateClass$8([
607
+ __decorateParam$8(1, Inject(Injector)),
608
+ __decorateParam$8(2, Inject(ThemeService)),
609
+ __decorateParam$8(3, IShortcutService),
610
+ __decorateParam$8(4, Inject(SheetSkeletonManagerService)),
611
+ __decorateParam$8(5, IRefSelectionsService)
612
+ ], RefSelectionsRenderService);
613
+ function getDefaultRefSelectionStyle(themeService) {
614
+ const style = getNormalSelectionStyle(themeService);
615
+ return style.hasAutoFill = !1, style.hasRowHeader = !1, style.hasColumnHeader = !1, style.widgets = { tl: !0, tc: !0, tr: !0, ml: !0, mr: !0, bl: !0, bc: !0, br: !0 }, style;
616
+ }
617
+ __name(getDefaultRefSelectionStyle, "getDefaultRefSelectionStyle");
618
+ const useEditorInput = /* @__PURE__ */ __name((unitId, rangeString, editor) => {
619
+ const render2 = useDependency(IRenderManagerService).getRenderById(unitId), refSelectionsRenderService = render2 == null ? void 0 : render2.with(RefSelectionsRenderService);
620
+ useEffect(() => {
621
+ if (editor && refSelectionsRenderService) {
622
+ const d = editor.input$.subscribe((e) => {
623
+ e.content === matchToken.COMMA ? refSelectionsRenderService.setSkipLastEnabled(!0) : refSelectionsRenderService.setSkipLastEnabled(!1);
624
+ });
625
+ return () => {
626
+ d.unsubscribe();
627
+ };
628
+ }
629
+ }, [editor, refSelectionsRenderService]), useEffect(() => {
630
+ refSelectionsRenderService && (rangeString.endsWith(matchToken.COMMA) || refSelectionsRenderService.setSkipLastEnabled(!1));
631
+ }, [rangeString, refSelectionsRenderService]);
632
+ }, "useEditorInput"), useFormulaToken = /* @__PURE__ */ __name((text) => {
633
+ const lexerTreeBuilder = useDependency(LexerTreeBuilder), [sequenceNodes, sequenceNodesSet] = useState([]);
634
+ return useEffect(() => {
635
+ var _a11;
636
+ sequenceNodesSet((_a11 = lexerTreeBuilder.sequenceNodesBuilder(text)) != null ? _a11 : []);
637
+ }, [text]), {
638
+ sequenceNodes,
639
+ sequenceNodesSet
640
+ };
641
+ }, "useFormulaToken");
642
+ function useSheetHighlight(isNeed, unitId, subUnitId, refSelections) {
643
+ const univerInstanceService = useDependency(IUniverInstanceService), themeService = useDependency(ThemeService), refSelectionsService = useDependency(IRefSelectionsService), render2 = useDependency(IRenderManagerService).getRenderById(unitId), refSelectionsRenderService = render2 == null ? void 0 : render2.with(RefSelectionsRenderService), sheetSkeletonManagerService = render2 == null ? void 0 : render2.with(SheetSkeletonManagerService), [ranges, rangesSet] = useState([]);
644
+ useEffect(() => {
645
+ const workbook = univerInstanceService.getUnit(unitId), worksheet = workbook == null ? void 0 : workbook.getActiveSheet(), selectionWithStyle = [];
646
+ if (!workbook || !worksheet || !isNeed) {
647
+ rangesSet(selectionWithStyle);
648
+ return;
649
+ }
650
+ const currentSheetId = worksheet == null ? void 0 : worksheet.getSheetId(), getSheetIdByName = /* @__PURE__ */ __name((name) => {
651
+ var _a11;
652
+ return (_a11 = workbook == null ? void 0 : workbook.getSheetBySheetName(name)) == null ? void 0 : _a11.getSheetId();
653
+ }, "getSheetIdByName");
654
+ for (let i = 0, len = refSelections.length; i < len; i++) {
655
+ const refSelection = refSelections[i], { themeColor, token, refIndex } = refSelection, unitRangeName = deserializeRangeWithSheet(token), { unitId: refUnitId, sheetName, range: rawRange } = unitRangeName;
656
+ if (refUnitId && unitId !== refUnitId)
657
+ continue;
658
+ const refSheetId = getSheetIdByName(sheetName);
659
+ if (refSheetId && refSheetId !== currentSheetId)
660
+ continue;
661
+ const range = setEndForRange(rawRange, worksheet.getRowCount(), worksheet.getColumnCount());
662
+ selectionWithStyle.push({
663
+ range,
664
+ primary: void 0,
665
+ style: getFormulaRefSelectionStyle$1(themeService, themeColor, refIndex.toString())
666
+ });
667
+ }
668
+ rangesSet(selectionWithStyle);
669
+ }, [unitId, subUnitId, refSelections, isNeed]), useEffect(() => {
670
+ const skeleton = sheetSkeletonManagerService == null ? void 0 : sheetSkeletonManagerService.getCurrentSkeleton();
671
+ if (skeleton) {
672
+ const allControls = (refSelectionsRenderService == null ? void 0 : refSelectionsRenderService.getSelectionControls()) || [];
673
+ allControls.length === ranges.length ? allControls.forEach((control, index) => {
674
+ const selection = ranges[index], primaryCell = skeleton.getCellByIndex(selection.range.startRow, selection.range.startColumn);
675
+ control.updateRange(attachRangeWithCoord(skeleton, selection.range), primaryCell), control.updateStyle(selection.style);
676
+ }) : refSelectionsService.setSelections(ranges);
677
+ }
678
+ }, [ranges, sheetSkeletonManagerService]), useEffect(() => () => {
679
+ refSelectionsService.setSelections([]);
680
+ }, []);
681
+ }
682
+ __name(useSheetHighlight, "useSheetHighlight");
683
+ function useDocHight(editorId, sequenceNodes) {
684
+ const editorService = useDependency(IEditorService), descriptionService = useDependency(IDescriptionService), colorMap = useColor(), [ranges, rangesSet] = useState([]);
685
+ return useEffect(() => {
686
+ const editor = editorService.getEditor(editorId);
687
+ if (!editor)
688
+ return;
689
+ const data = editor.getDocumentData();
690
+ if (!data || !data.body)
691
+ return;
692
+ const cloneBody = { dataStream: "", ...data.body };
693
+ if (sequenceNodes == null || sequenceNodes.length === 0)
694
+ cloneBody.textRuns = [], cloneBody.dataStream = `\r
695
+ `, rangesSet([]);
696
+ else {
697
+ const { textRuns, refSelections } = buildTextRuns(descriptionService, colorMap, sequenceNodes);
698
+ cloneBody.textRuns = textRuns;
699
+ const text = sequenceNodes.reduce((pre, cur) => typeof cur == "string" ? `${pre}${cur}` : `${pre}${cur.token}`, "");
700
+ cloneBody.dataStream = `${text}\r
701
+ `, rangesSet(refSelections);
702
+ }
703
+ const selection = editor.getSelectionRanges(), cloneData = { ...data, body: cloneBody };
704
+ editor.setDocumentData(cloneData, selection);
705
+ }, [editorId, sequenceNodes, colorMap]), ranges;
706
+ }
707
+ __name(useDocHight, "useDocHight");
708
+ function useColor() {
709
+ const style = useDependency(ThemeService).getCurrentTheme();
710
+ return useMemo(() => {
711
+ const formulaRefColors = [
712
+ style.loopColor1,
713
+ style.loopColor2,
714
+ style.loopColor3,
715
+ style.loopColor4,
716
+ style.loopColor5,
717
+ style.loopColor6,
718
+ style.loopColor7,
719
+ style.loopColor8,
720
+ style.loopColor9,
721
+ style.loopColor10,
722
+ style.loopColor11,
723
+ style.loopColor12
724
+ ], numberColor = style.hyacinth700, stringColor = style.verdancy800;
725
+ return { formulaRefColors, numberColor, stringColor };
726
+ }, [style]);
727
+ }
728
+ __name(useColor, "useColor");
729
+ function buildTextRuns(descriptionService, colorMap, sequenceNodes) {
730
+ const { formulaRefColors, numberColor, stringColor } = colorMap, textRuns = [], refSelections = [], themeColorMap = /* @__PURE__ */ new Map();
731
+ let refColorIndex = 0;
732
+ for (let i = 0, len = sequenceNodes.length; i < len; i++) {
733
+ const node = sequenceNodes[i];
734
+ if (typeof node == "string") {
735
+ const theLastItem = textRuns[textRuns.length - 1], start = theLastItem ? theLastItem.ed : 0, end = start + node.length;
736
+ textRuns.push({
737
+ st: start,
738
+ ed: end
739
+ });
740
+ continue;
741
+ }
742
+ if (descriptionService.hasDefinedNameDescription(node.token.trim()))
743
+ continue;
744
+ const { startIndex, endIndex, nodeType, token } = node;
745
+ let themeColor = "";
746
+ if (nodeType === sequenceNodeType.REFERENCE) {
747
+ if (themeColorMap.has(token))
748
+ themeColor = themeColorMap.get(token);
749
+ else {
750
+ const colorIndex = refColorIndex % formulaRefColors.length;
751
+ themeColor = formulaRefColors[colorIndex], themeColorMap.set(token, themeColor), refColorIndex++;
752
+ }
753
+ refSelections.push({
754
+ refIndex: i,
755
+ themeColor,
756
+ token
757
+ });
758
+ } else nodeType === sequenceNodeType.NUMBER ? themeColor = numberColor : (nodeType === sequenceNodeType.STRING || nodeType === sequenceNodeType.ARRAY) && (themeColor = stringColor);
759
+ themeColor && themeColor.length > 0 && textRuns.push({
760
+ st: startIndex,
761
+ ed: endIndex + 1,
762
+ ts: {
763
+ cl: {
764
+ rgb: themeColor
765
+ }
766
+ }
767
+ });
768
+ }
769
+ return { textRuns, refSelections };
770
+ }
771
+ __name(buildTextRuns, "buildTextRuns");
772
+ function getFormulaRefSelectionStyle$1(themeService, refColor, id) {
773
+ const style = themeService.getCurrentTheme(), fill = new ColorKit(refColor).setAlpha(0.05).toRgbString();
774
+ return {
775
+ id,
776
+ strokeWidth: 1,
777
+ stroke: refColor,
778
+ fill,
779
+ widgets: { tl: !0, tc: !0, tr: !0, ml: !0, mr: !0, bl: !0, bc: !0, br: !0 },
780
+ widgetSize: 6,
781
+ widgetStrokeWidth: 1,
782
+ widgetStroke: style.colorWhite,
783
+ hasAutoFill: !1,
784
+ hasRowHeader: !1,
785
+ hasColumnHeader: !1
786
+ };
787
+ }
788
+ __name(getFormulaRefSelectionStyle$1, "getFormulaRefSelectionStyle$1");
789
+ const useRefactorEffect = /* @__PURE__ */ __name((isNeed, unitId, isOnlyOneRange) => {
790
+ const renderManagerService = useDependency(IRenderManagerService), univerInstanceService = useDependency(IUniverInstanceService), contextService = useDependency(IContextService), editorBridgeService = useDependency(IEditorBridgeService), sheetsSelectionsService = useDependency(SheetsSelectionsService), contextMenuService = useDependency(IContextMenuService), render2 = renderManagerService.getRenderById(unitId), refSelectionsRenderService = render2 == null ? void 0 : render2.with(RefSelectionsRenderService);
791
+ useEffect(() => {
792
+ if (isNeed) {
793
+ const d1 = refSelectionsRenderService == null ? void 0 : refSelectionsRenderService.enableSelectionChanging();
794
+ return contextService.setContextValue(DISABLE_NORMAL_SELECTIONS, !0), editorBridgeService.enableForceKeepVisible(), () => {
795
+ d1 == null || d1.dispose(), contextService.setContextValue(DISABLE_NORMAL_SELECTIONS, !1), editorBridgeService.disableForceKeepVisible();
796
+ };
797
+ }
798
+ }, [isNeed]), useLayoutEffect(() => {
799
+ if (isNeed) {
800
+ const workbook = univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET), sheet = workbook == null ? void 0 : workbook.getActiveSheet(), selections = [...sheetsSelectionsService.getCurrentSelections()];
801
+ return () => {
802
+ const workbook2 = univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET), currentSheet = workbook2 == null ? void 0 : workbook2.getActiveSheet();
803
+ currentSheet && currentSheet === sheet && sheetsSelectionsService.setSelections(selections);
804
+ };
805
+ }
806
+ }, [isNeed]), useEffect(() => {
807
+ if (isNeed)
808
+ return contextMenuService.disable(), () => {
809
+ contextMenuService.enable();
810
+ };
811
+ }, [isNeed]), useEffect(() => {
812
+ isNeed && (refSelectionsRenderService == null || refSelectionsRenderService.setSkipLastEnabled(!1));
813
+ }, [isNeed]), useEffect(() => {
814
+ isOnlyOneRange ? refSelectionsRenderService == null || refSelectionsRenderService.setRemainLastEnabled(!1) : refSelectionsRenderService == null || refSelectionsRenderService.setRemainLastEnabled(!0);
815
+ }, [isOnlyOneRange]);
816
+ }, "useRefactorEffect"), useResize = /* @__PURE__ */ __name((editor) => {
817
+ const resize = /* @__PURE__ */ __name(() => {
818
+ if (editor) {
819
+ const { scene, mainComponent } = editor.render, docSkeletonManagerService = editor.render.with(DocSkeletonManagerService), { width, height } = editor.getBoundingClientRect();
820
+ docSkeletonManagerService.getViewModel().getDataModel().updateDocumentDataPageSize(1 / 0), scene.transformByState({
821
+ width,
822
+ height
823
+ }), mainComponent == null || mainComponent.resize(width, height);
824
+ }
825
+ }, "resize"), checkScrollBar = useMemo(() => debounce(() => {
826
+ var _a11;
827
+ if (!editor)
828
+ return;
829
+ const skeleton = editor.render.with(DocSkeletonManagerService).getSkeleton(), { scene, mainComponent } = editor.render, viewportMain = scene.getViewport(VIEWPORT_KEY.VIEW_MAIN), { actualWidth } = skeleton.getActualSize(), { width, height } = editor.getBoundingClientRect();
830
+ let scrollBar = viewportMain == null ? void 0 : viewportMain.getScrollBar();
831
+ const contentWidth = Math.max(actualWidth, width), contentHeight = height;
832
+ scene.transformByState({
833
+ width: contentWidth,
834
+ height: contentHeight
835
+ }), mainComponent == null || mainComponent.resize(contentWidth, contentHeight), actualWidth > width ? scrollBar == null ? viewportMain && new ScrollBar(viewportMain, { barSize: 8, enableVertical: !1 }) : viewportMain == null || viewportMain.resetCanvasSizeAndUpdateScroll() : (scrollBar = null, viewportMain == null || viewportMain.scrollToBarPos({ x: 0, y: 0 }), (_a11 = viewportMain == null ? void 0 : viewportMain.getScrollBar()) == null || _a11.dispose());
836
+ }, 30), [editor]);
837
+ return useEffect(() => {
838
+ if (editor) {
839
+ const time = setTimeout(() => {
840
+ resize(), checkScrollBar();
841
+ }, 500);
842
+ return () => {
843
+ clearTimeout(time);
844
+ };
845
+ }
846
+ }, [editor]), useEffect(() => {
847
+ if (editor) {
848
+ const d = editor.input$.subscribe(() => {
849
+ checkScrollBar();
850
+ });
851
+ return () => {
852
+ d.unsubscribe();
853
+ };
854
+ }
855
+ }, [editor]), { resize, checkScrollBar };
856
+ }, "useResize"), isComma = /* @__PURE__ */ __name((e) => typeof e == "string" ? e === matchToken.COMMA : !1, "isComma"), isReference = /* @__PURE__ */ __name((e) => {
857
+ if (typeof e == "object")
858
+ return e.nodeType === sequenceNodeType.REFERENCE;
859
+ }, "isReference"), filterReferenceNode = /* @__PURE__ */ __name((nodes) => nodes.filter((node) => isComma(node) || isReference(node)), "filterReferenceNode"), rangePreProcess = /* @__PURE__ */ __name((range) => {
860
+ if (range.endColumn < range.startColumn) {
861
+ const end = range.endColumn;
862
+ range.endColumn = range.startColumn, range.startColumn = end;
863
+ }
864
+ if (range.endRow < range.startRow) {
865
+ const end = range.endRow;
866
+ range.endRow = range.startRow, range.startRow = end;
867
+ }
868
+ return range;
869
+ }, "rangePreProcess"), sequenceNodeToText = /* @__PURE__ */ __name((sequenceNode) => sequenceNode.map((item) => typeof item == "string" ? item : item.token).join(""), "sequenceNodeToText");
870
+ function getSheetNameById(univerInstanceService, unitId, sheetId) {
871
+ var _a11, _b;
872
+ return ((_b = (_a11 = univerInstanceService.getUnit(unitId)) == null ? void 0 : _a11.getSheetBySheetId(sheetId)) == null ? void 0 : _b.getName()) || "";
873
+ }
874
+ __name(getSheetNameById, "getSheetNameById");
875
+ const unitRangesToText = /* @__PURE__ */ __name((ranges, isSupportAcrossSheet = !1) => isSupportAcrossSheet ? ranges.map((item) => item.sheetName !== "" ? serializeRangeWithSheet(item.sheetName, item.range) : serializeRange(item.range)) : ranges.map((item) => serializeRange(item.range)), "unitRangesToText"), useSheetSelectionChange = /* @__PURE__ */ __name((isNeed, unitId, _subUnitId, sequenceNodes, isSupportAcrossSheet, isOnlyOneRange, handleRangeChange) => {
876
+ const renderManagerService = useDependency(IRenderManagerService), univerInstanceService = useDependency(IUniverInstanceService), isScalingRef = useRef(!1), debounceReset = useMemo(() => debounce(() => {
877
+ isScalingRef.current = !1;
878
+ }, 300), []), setIsScaling = /* @__PURE__ */ __name(() => {
879
+ isScalingRef.current = !0, debounceReset();
880
+ }, "setIsScaling"), render2 = renderManagerService.getRenderById(unitId), refSelectionsRenderService = render2 == null ? void 0 : render2.with(RefSelectionsRenderService), oldFilterReferenceNodes = useRef([]), filterReferenceNodes = useMemo(() => {
881
+ const newFilterReferenceNodes = filterReferenceNode(sequenceNodes), old = oldFilterReferenceNodes.current;
882
+ return newFilterReferenceNodes.length === old.length ? (old.splice(0), old.push(...newFilterReferenceNodes), old) : newFilterReferenceNodes;
883
+ }, [sequenceNodes]);
884
+ oldFilterReferenceNodes.current = filterReferenceNodes, useEffect(() => {
885
+ if (isNeed && refSelectionsRenderService) {
886
+ let isFirst = !0;
887
+ const handleSelectionsChange = /* @__PURE__ */ __name((selections) => {
888
+ var _a11;
889
+ if (isFirst) {
890
+ isFirst = !1;
891
+ return;
892
+ }
893
+ const cloneSelectionList = [...selections], workbook = univerInstanceService.getUnit(unitId), currentSheetName = ((_a11 = workbook == null ? void 0 : workbook.getActiveSheet()) == null ? void 0 : _a11.getName()) || "", newSequenceNodes = filterReferenceNodes.map((node, index) => {
894
+ if (typeof node == "string") {
895
+ if (!filterReferenceNodes[index - 1])
896
+ return null;
897
+ const nextItem = filterReferenceNodes[index + 1];
898
+ return isComma(node) && (isComma(nextItem) || index === filterReferenceNodes.length - 1) ? null : node;
899
+ } else if (node.nodeType === sequenceNodeType.REFERENCE) {
900
+ const unitRange = deserializeRangeWithSheet(node.token);
901
+ unitRange.unitId = unitRange.unitId === "" ? unitId : unitRange.unitId, unitRange.sheetName = unitRange.sheetName === "" ? currentSheetName : unitRange.sheetName;
902
+ const { unitId: rangeUnitId, sheetName: rangeSubName } = unitRange;
903
+ if (isOnlyOneRange && (rangeUnitId !== unitId || currentSheetName !== rangeSubName))
904
+ return null;
905
+ if (rangeUnitId === unitId && currentSheetName === rangeSubName) {
906
+ const currentSelection = cloneSelectionList.shift();
907
+ if (currentSelection && getSheetNameById(univerInstanceService, unitId, currentSelection.rangeWithCoord.sheetId || "") === rangeSubName) {
908
+ const cloneNode = { ...node };
909
+ return rangePreProcess(currentSelection.rangeWithCoord), isSupportAcrossSheet ? cloneNode.token = serializeRangeWithSheet(currentSheetName, currentSelection.rangeWithCoord) : cloneNode.token = serializeRange(currentSelection.rangeWithCoord), cloneNode;
910
+ }
911
+ }
912
+ return node;
913
+ }
914
+ return null;
915
+ }).filter((e) => !!e), theLast = unitRangesToText(
916
+ cloneSelectionList.map((e) => {
917
+ var _a12, _b, _c;
918
+ return {
919
+ range: e.rangeWithCoord,
920
+ unitId: (_a12 = e.rangeWithCoord.unitId) != null ? _a12 : "",
921
+ sheetName: getSheetNameById(univerInstanceService, (_b = e.rangeWithCoord.unitId) != null ? _b : "", (_c = e.rangeWithCoord.sheetId) != null ? _c : "")
922
+ };
923
+ }),
924
+ isSupportAcrossSheet
925
+ ).join(matchToken.COMMA), thePre = sequenceNodeToText(newSequenceNodes), result = `${thePre}${thePre && theLast ? matchToken.COMMA : ""}${theLast}`, isScaling = isScalingRef.current;
926
+ handleRangeChange(result, isScaling ? -1 : result.length);
927
+ }, "handleSelectionsChange"), d1 = refSelectionsRenderService.selectionMoveEnd$.subscribe((selections) => {
928
+ handleSelectionsChange(selections);
929
+ }), d2 = refSelectionsRenderService.selectionMoving$.pipe(throttleTime(50)).subscribe((selections) => {
930
+ handleSelectionsChange(selections);
931
+ });
932
+ return () => {
933
+ d1.unsubscribe(), d2.unsubscribe();
934
+ };
935
+ }
936
+ }, [isNeed, filterReferenceNodes, refSelectionsRenderService, isSupportAcrossSheet, isOnlyOneRange]), useEffect(() => {
937
+ if (isNeed && refSelectionsRenderService) {
938
+ const disposableCollection = new DisposableCollection(), handleSequenceNodeReplace = /* @__PURE__ */ __name((token, index) => {
939
+ var _a11;
940
+ let currentIndex = 0, offset = 0, isFinish = !1;
941
+ const workbook = univerInstanceService.getUnit(unitId), currentSheetName = ((_a11 = workbook == null ? void 0 : workbook.getActiveSheet()) == null ? void 0 : _a11.getName()) || "", newSequenceNodes = filterReferenceNodes.map((node) => {
942
+ if (typeof node == "string")
943
+ return isFinish || (offset += node.length), node;
944
+ if (node.nodeType === sequenceNodeType.REFERENCE) {
945
+ isFinish || (offset += node.token.length);
946
+ const unitRange = deserializeRangeWithSheet(token);
947
+ if (unitRange.unitId = unitRange.unitId === "" ? unitId : unitRange.unitId, unitRange.sheetName = unitRange.sheetName === "" ? currentSheetName : unitRange.sheetName, currentIndex === index) {
948
+ isFinish = !0;
949
+ const cloneNode = { ...node, token };
950
+ return isSupportAcrossSheet ? cloneNode.token = serializeRangeWithSheet(unitRange.sheetName, unitRange.range) : cloneNode.token = serializeRange(unitRange.range), currentIndex++, cloneNode;
951
+ }
952
+ return currentIndex++, node;
953
+ }
954
+ return node;
955
+ }), result = sequenceNodeToText(newSequenceNodes);
956
+ handleRangeChange(result, offset || -1);
957
+ }, "handleSequenceNodeReplace");
958
+ let time = 0;
959
+ const dispose = refSelectionsRenderService.selectionMoveEnd$.subscribe(() => {
960
+ time = setTimeout(() => {
961
+ refSelectionsRenderService.getSelectionControls().forEach((control, index) => {
962
+ disposableCollection.add(control.selectionScaling$.subscribe((e) => {
963
+ const rangeText = serializeRange(e);
964
+ handleSequenceNodeReplace(rangeText, index), setIsScaling();
965
+ })), disposableCollection.add(control.selectionMoving$.pipe(map((e) => serializeRange(e)), distinctUntilChanged()).subscribe((rangeText) => {
966
+ handleSequenceNodeReplace(rangeText, index), setIsScaling();
967
+ }));
968
+ });
969
+ }, 30);
970
+ });
971
+ return () => {
972
+ dispose.unsubscribe(), disposableCollection.dispose(), clearTimeout(time);
973
+ };
974
+ }
975
+ }, [isNeed, refSelectionsRenderService, filterReferenceNodes]);
976
+ }, "useSheetSelectionChange"), verifyRange = /* @__PURE__ */ __name((sequenceNodes) => !sequenceNodes.some((item) => {
977
+ if (typeof item == "string") {
978
+ if (item !== matchToken.COMMA)
979
+ return !0;
980
+ } else if (item.nodeType !== sequenceNodeType.REFERENCE)
981
+ return !0;
982
+ return !1;
983
+ }), "verifyRange"), useVerify = /* @__PURE__ */ __name((onVerify, sequenceNodes) => {
984
+ const isInitRender = useRef(!0);
985
+ useEffect(() => {
986
+ const time = setTimeout(() => {
987
+ isInitRender.current = !1;
988
+ }, 500);
989
+ return () => {
990
+ clearTimeout(time);
991
+ };
992
+ }), useEffect(() => {
993
+ if (!isInitRender.current && onVerify) {
994
+ const result = verifyRange(sequenceNodes);
995
+ onVerify(result, sequenceNodeToText(sequenceNodes));
996
+ }
997
+ }, [sequenceNodes, onVerify]);
998
+ }, "useVerify"), sheetRangeSelectorTextWrap = "univer-sheet-range-selector-text-wrap", sheetRangeSelectorPlaceholder = "univer-sheet-range-selector-placeholder", sheetRangeSelectorError = "univer-sheet-range-selector-error", sheetRangeSelectorErrorWrap = "univer-sheet-range-selector-error-wrap", sheetRangeSelectorText = "univer-sheet-range-selector-text", sheetRangeSelectorActive = "univer-sheet-range-selector-active", sheetRangeSelectorIcon = "univer-sheet-range-selector-icon", sheetRangeSelectorDialogItem = "univer-sheet-range-selector-dialog-item", sheetRangeSelectorDialogItemDelete = "univer-sheet-range-selector-dialog-item-delete", styles$6 = {
999
+ sheetRangeSelectorTextWrap,
1000
+ sheetRangeSelectorPlaceholder,
1001
+ sheetRangeSelectorError,
1002
+ sheetRangeSelectorErrorWrap,
1003
+ sheetRangeSelectorText,
1004
+ sheetRangeSelectorActive,
1005
+ sheetRangeSelectorIcon,
1006
+ sheetRangeSelectorDialogItem,
1007
+ sheetRangeSelectorDialogItemDelete
1008
+ }, noopFunction = /* @__PURE__ */ __name(() => {
1009
+ }, "noopFunction");
1010
+ function RangeSelector(props) {
1011
+ const {
1012
+ initValue,
1013
+ unitId,
1014
+ subUnitId,
1015
+ errorText,
1016
+ placeholder,
1017
+ actions,
1018
+ onChange = noopFunction,
1019
+ onVerify = noopFunction,
1020
+ onRangeSelectorDialogVisibleChange = noopFunction,
1021
+ onBlur = noopFunction,
1022
+ isFocus: _isFocus = !0,
1023
+ isOnlyOneRange = !1,
1024
+ isSupportAcrossSheet = !1
1025
+ } = props, editorService = useDependency(IEditorService), localeService = useDependency(LocaleService), commandService = useDependency(ICommandService), lexerTreeBuilder = useDependency(LexerTreeBuilder), rangeSelectorWrapRef = useRef(null), [rangeDialogVisible, rangeDialogVisibleSet] = useState(!1), [isFocus, isFocusSet] = useState(_isFocus), editorId = useMemo(() => createInternalEditorID(`${RANGE_SELECTOR_SYMBOLS}-${generateRandomId(4)}`), []), [editor, editorSet] = useState(), containerRef = useRef(null), [rangeString, rangeStringSet] = useState(() => typeof initValue == "string" ? initValue : unitRangesToText(initValue, isSupportAcrossSheet).join(matchToken.COMMA));
1026
+ actions && (actions.handleOutClick = (e, cb) => {
1027
+ if (rangeSelectorWrapRef.current) {
1028
+ const isContain = rangeSelectorWrapRef.current.contains(e.target);
1029
+ cb(isContain);
1030
+ }
1031
+ });
1032
+ const ranges = useMemo(() => rangeString.split(matchToken.COMMA).filter((e) => !!e).map((text) => deserializeRangeWithSheet(text)), [rangeString]), isError = useMemo(() => errorText !== void 0, [errorText]), handleInputDebounce = useMemo(() => debounce((text) => {
1033
+ const nodes = lexerTreeBuilder.sequenceNodesBuilder(text);
1034
+ if (nodes) {
1035
+ if (verifyRange(nodes)) {
1036
+ const preNodes = nodes.map((node) => {
1037
+ if (typeof node == "string")
1038
+ return node;
1039
+ if (node.nodeType === sequenceNodeType.REFERENCE) {
1040
+ const unitRange = deserializeRangeWithSheet(node.token);
1041
+ unitRange.range = rangePreProcess(unitRange.range), isSupportAcrossSheet || (unitRange.sheetName = "", unitRange.unitId = ""), node.token = unitRangesToText([unitRange], isSupportAcrossSheet)[0];
1042
+ }
1043
+ return node;
1044
+ }), result = sequenceNodeToText(preNodes);
1045
+ onChange(result);
1046
+ }
1047
+ } else
1048
+ rangeStringSet("");
1049
+ }, 30), [isSupportAcrossSheet]), handleConfirm = /* @__PURE__ */ __name((ranges2) => {
1050
+ const text = unitRangesToText(ranges2, isSupportAcrossSheet).join(matchToken.COMMA);
1051
+ rangeStringSet(text), onChange(text), rangeDialogVisibleSet(!1), onRangeSelectorDialogVisibleChange(!1);
1052
+ }, "handleConfirm"), handleClose = /* @__PURE__ */ __name(() => {
1053
+ rangeDialogVisibleSet(!1), onRangeSelectorDialogVisibleChange(!1);
1054
+ }, "handleClose"), handleOpenModal = /* @__PURE__ */ __name(() => {
1055
+ isError || (rangeDialogVisibleSet(!0), onRangeSelectorDialogVisibleChange(!0));
1056
+ }, "handleOpenModal"), focus = useMemo(() => {
1057
+ let time = 0;
1058
+ return () => {
1059
+ clearTimeout(time), editor && (time = setTimeout(() => {
1060
+ editor.focus();
1061
+ }, 30));
1062
+ };
1063
+ }, [editor]), { checkScrollBar } = useResize(editor), handleSheetSelectionChange = useMemo(() => (text, offset) => {
1064
+ rangeStringSet(text), onChange(text), focus(), offset !== -1 && setTimeout(() => {
1065
+ const range = { startOffset: offset, endOffset: offset };
1066
+ editor == null || editor.setSelectionRanges([range]);
1067
+ const docBackScrollRenderController = editor == null ? void 0 : editor.render.with(DocBackScrollRenderController);
1068
+ docBackScrollRenderController == null || docBackScrollRenderController.scrollToRange({ ...range, collapsed: !0 });
1069
+ }, 50), checkScrollBar();
1070
+ }, [editor]), { sequenceNodes, sequenceNodesSet } = useFormulaToken(rangeString), sheetHighlightRanges = useDocHight(editorId, sequenceNodes);
1071
+ return useSheetHighlight(!rangeDialogVisible && isFocus, unitId, subUnitId, sheetHighlightRanges), useSheetSelectionChange(!rangeDialogVisible && isFocus, unitId, subUnitId, sequenceNodes, isSupportAcrossSheet, isOnlyOneRange, handleSheetSelectionChange), useRefactorEffect(!rangeDialogVisible && isFocus, unitId, isOnlyOneRange), useEditorInput(unitId, rangeString, editor), useVerify(onVerify, sequenceNodes), useEffect(() => {
1072
+ if (editor) {
1073
+ const dispose = editor.input$.subscribe((e) => {
1074
+ var _a11, _b;
1075
+ const text = ((_b = (_a11 = e.data.body) == null ? void 0 : _a11.dataStream) != null ? _b : "").replaceAll(/\n|\r/g, "").replaceAll(/,{2,}/g, ",").replaceAll(/(^,)/g, "");
1076
+ rangeStringSet(text), handleInputDebounce(text);
1077
+ });
1078
+ return () => {
1079
+ dispose.unsubscribe();
1080
+ };
1081
+ }
1082
+ }, [editor]), useEffect(() => {
1083
+ const d1 = commandService.beforeCommandExecuted((info) => {
1084
+ info.id === SetWorksheetActiveOperation.id && (isFocusSet(!1), onBlur(), sequenceNodesSet((pre) => [...pre]));
1085
+ }), d2 = commandService.onCommandExecuted((info) => {
1086
+ info.id === SetCellEditVisibleOperation.id && (rangeDialogVisibleSet(!1), onRangeSelectorDialogVisibleChange(!1), isFocusSet(!1), onBlur());
1087
+ });
1088
+ return () => {
1089
+ d1.dispose(), d2.dispose();
1090
+ };
1091
+ }, []), useEffect(() => {
1092
+ isFocusSet(_isFocus);
1093
+ }, [_isFocus]), useEffect(() => {
1094
+ if (editor && rangeDialogVisible) {
1095
+ editor.blur();
1096
+ const d = editor.focus$.subscribe(() => {
1097
+ editor.blur();
1098
+ });
1099
+ return () => {
1100
+ d.unsubscribe();
1101
+ };
1102
+ }
1103
+ }, [editor, rangeDialogVisible]), useLayoutEffect(() => {
1104
+ let dispose;
1105
+ if (containerRef.current) {
1106
+ dispose = editorService.register({
1107
+ autofocus: !0,
1108
+ editorUnitId: editorId,
1109
+ isSingle: !0,
1110
+ initialSnapshot: {
1111
+ id: editorId,
1112
+ body: { dataStream: `\r
1113
+ ` },
1114
+ documentStyle: {}
1115
+ }
1116
+ }, containerRef.current);
1117
+ const editor2 = editorService.getEditor(editorId);
1118
+ editorSet(editor2);
1119
+ }
1120
+ return () => {
1121
+ dispose == null || dispose.dispose();
1122
+ };
1123
+ }, [containerRef.current]), /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: styles$6.sheetRangeSelector, ref: rangeSelectorWrapRef, children: [
1124
+ /* @__PURE__ */ jsxRuntimeExports.jsxs(
1125
+ "div",
1126
+ {
1127
+ className: clsx(styles$6.sheetRangeSelectorTextWrap, {
1128
+ [styles$6.sheetRangeSelectorActive]: isFocus && !isError,
1129
+ [styles$6.sheetRangeSelectorError]: isError
1130
+ }),
1131
+ children: [
1132
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: styles$6.sheetRangeSelectorText, ref: containerRef }),
1133
+ /* @__PURE__ */ jsxRuntimeExports.jsx(Tooltip, { title: localeService.t("rangeSelector.buttonTooltip"), placement: "bottom", children: /* @__PURE__ */ jsxRuntimeExports.jsx(SelectRangeSingle, { className: styles$6.sheetRangeSelectorIcon, onClick: handleOpenModal }) }),
1134
+ errorText !== void 0 ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: styles$6.sheetRangeSelectorErrorWrap, children: errorText }) : null,
1135
+ placeholder !== void 0 && !rangeString ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: styles$6.sheetRangeSelectorPlaceholder, children: placeholder }) : null
1136
+ ]
1137
+ }
1138
+ ),
1139
+ rangeDialogVisible && /* @__PURE__ */ jsxRuntimeExports.jsx(
1140
+ RangeSelectorDialog,
1141
+ {
1142
+ handleConfirm,
1143
+ handleClose,
1144
+ unitId,
1145
+ subUnitId,
1146
+ initValue: ranges,
1147
+ visible: rangeDialogVisible,
1148
+ isOnlyOneRange,
1149
+ isSupportAcrossSheet
1150
+ }
1151
+ )
1152
+ ] });
1153
+ }
1154
+ __name(RangeSelector, "RangeSelector");
1155
+ function RangeSelectorDialog(props) {
1156
+ const { handleConfirm, handleClose: _handleClose, visible, initValue, unitId, subUnitId, isOnlyOneRange, isSupportAcrossSheet } = props, localeService = useDependency(LocaleService), descriptionService = useDependency(IDescriptionService), lexerTreeBuilder = useDependency(LexerTreeBuilder), render2 = useDependency(IRenderManagerService).getRenderById(unitId), refSelectionsRenderService = render2 == null ? void 0 : render2.with(RefSelectionsRenderService), [ranges, rangesSet] = useState(() => {
1157
+ if (isOnlyOneRange) {
1158
+ const firstRange = initValue[0];
1159
+ return firstRange ? unitRangesToText([firstRange], isSupportAcrossSheet) : [""];
1160
+ }
1161
+ return unitRangesToText(initValue, isSupportAcrossSheet);
1162
+ }), [focusIndex, focusIndexSet] = useState(() => ranges.length - 1), colorMap = useColor(), rangeText = useMemo(() => ranges.join(matchToken.COMMA), [ranges]), { sequenceNodes, sequenceNodesSet } = useFormulaToken(rangeText), refSelections = useMemo(() => buildTextRuns(descriptionService, colorMap, sequenceNodes).refSelections, [sequenceNodes]), handleClose = /* @__PURE__ */ __name(() => {
1163
+ sequenceNodesSet([]), setTimeout(() => {
1164
+ _handleClose();
1165
+ }, 30);
1166
+ }, "handleClose"), handleRangeInput = /* @__PURE__ */ __name((index, value) => {
1167
+ value ? refSelectionsRenderService == null || refSelectionsRenderService.setSkipLastEnabled(!1) : refSelectionsRenderService == null || refSelectionsRenderService.setSkipLastEnabled(!0), rangesSet((v) => {
1168
+ const result = [...v];
1169
+ return result[index] = value, result;
1170
+ });
1171
+ }, "handleRangeInput"), handleRangeRemove = /* @__PURE__ */ __name((index) => {
1172
+ refSelectionsRenderService == null || refSelectionsRenderService.setSkipLastEnabled(!1), rangesSet((v) => {
1173
+ if (v.length === 1)
1174
+ return v;
1175
+ const result = [];
1176
+ return v.forEach((r2, i) => {
1177
+ index !== i && result.push(r2);
1178
+ }), result;
1179
+ });
1180
+ }, "handleRangeRemove"), handleRangeAdd = /* @__PURE__ */ __name(() => {
1181
+ refSelectionsRenderService == null || refSelectionsRenderService.setSkipLastEnabled(!0), rangesSet((v) => (v.push(""), focusIndexSet(v.length - 1), [...v]));
1182
+ }, "handleRangeAdd"), handleSheetSelectionChange = useCallback((rangeText2) => {
1183
+ var _a11;
1184
+ refSelectionsRenderService == null || refSelectionsRenderService.setSkipLastEnabled(!1);
1185
+ const ranges2 = rangeText2.split(matchToken.COMMA).filter((e) => !!e);
1186
+ rangesSet(isOnlyOneRange ? [(_a11 = ranges2[0]) != null ? _a11 : ""] : ranges2);
1187
+ }, [focusIndex, isOnlyOneRange]);
1188
+ return useSheetHighlight(visible, unitId, subUnitId, refSelections), useSheetSelectionChange(focusIndex >= 0, unitId, subUnitId, sequenceNodes, isSupportAcrossSheet, isOnlyOneRange, handleSheetSelectionChange), useRefactorEffect(focusIndex >= 0, unitId, isOnlyOneRange), useEffect(() => {
1189
+ (ranges.length === 0 || ranges.length === 1 && !ranges[0]) && (refSelectionsRenderService == null || refSelectionsRenderService.setSkipLastEnabled(!0));
1190
+ }, [ranges]), /* @__PURE__ */ jsxRuntimeExports.jsx(
1191
+ Dialog,
1192
+ {
1193
+ width: "328px",
1194
+ visible,
1195
+ title: localeService.t("rangeSelector.title"),
1196
+ draggable: !0,
1197
+ closeIcon: /* @__PURE__ */ jsxRuntimeExports.jsx(CloseSingle, {}),
1198
+ footer: /* @__PURE__ */ jsxRuntimeExports.jsxs("footer", { children: [
1199
+ /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { onClick: handleClose, children: localeService.t("rangeSelector.cancel") }),
1200
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
1201
+ Button,
1202
+ {
1203
+ style: { marginLeft: 10 },
1204
+ onClick: /* @__PURE__ */ __name(() => handleConfirm(ranges.filter((text) => {
1205
+ const nodes = lexerTreeBuilder.sequenceNodesBuilder(text);
1206
+ return nodes && nodes.length === 1 && typeof nodes[0] != "string" && nodes[0].nodeType === sequenceNodeType.REFERENCE;
1207
+ }).map((text) => deserializeRangeWithSheet(text)).map((unitRange) => ({ ...unitRange, range: rangePreProcess(unitRange.range) }))), "onClick"),
1208
+ type: "primary",
1209
+ children: localeService.t("rangeSelector.confirm")
1210
+ }
1211
+ )
1212
+ ] }),
1213
+ onClose: handleClose,
1214
+ children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: styles$6.sheetRangeSelectorDialog, children: [
1215
+ ranges.map((text, index) => /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: styles$6.sheetRangeSelectorDialogItem, children: [
1216
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
1217
+ Input,
1218
+ {
1219
+ affixWrapperStyle: { width: "100%" },
1220
+ placeholder: localeService.t("rangeSelector.placeHolder"),
1221
+ onFocus: /* @__PURE__ */ __name(() => focusIndexSet(index), "onFocus"),
1222
+ value: text,
1223
+ onChange: /* @__PURE__ */ __name((value) => handleRangeInput(index, value), "onChange")
1224
+ },
1225
+ `input_${index}`
1226
+ ),
1227
+ ranges.length > 1 && !isOnlyOneRange && /* @__PURE__ */ jsxRuntimeExports.jsx(DeleteSingle, { className: styles$6.sheetRangeSelectorDialogItemDelete, onClick: /* @__PURE__ */ __name(() => handleRangeRemove(index), "onClick") })
1228
+ ] }, index)),
1229
+ !isOnlyOneRange && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { children: /* @__PURE__ */ jsxRuntimeExports.jsxs(Button, { type: "link", size: "small", onClick: handleRangeAdd, children: [
1230
+ /* @__PURE__ */ jsxRuntimeExports.jsx(IncreaseSingle, {}),
1231
+ /* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: localeService.t("rangeSelector.addAnotherRange") })
1232
+ ] }) })
1233
+ ] })
1234
+ }
1235
+ );
1236
+ }
1237
+ __name(RangeSelectorDialog, "RangeSelectorDialog");
1238
+ const PLUGIN_CONFIG_KEY_BASE = "sheets-formula.base.config", defaultPluginBaseConfig = {};
346
1239
  function whenEditorStandalone(contextService) {
347
1240
  return contextService.getContextValue(FOCUSING_DOC) && contextService.getContextValue(FOCUSING_UNIVER_EDITOR) && contextService.getContextValue(FOCUSING_UNIVER_EDITOR_STANDALONE_SINGLE_MODE);
348
1241
  }
@@ -351,11 +1244,11 @@ function extractFormulaError(cell) {
351
1244
  return (isFormulaString(cell == null ? void 0 : cell.f) || isFormulaId(cell == null ? void 0 : cell.si)) && typeof (cell == null ? void 0 : cell.v) == "string" && ERROR_TYPE_SET.has(cell.v) ? cell.v : null;
352
1245
  }
353
1246
  __name(extractFormulaError, "extractFormulaError");
354
- var __defProp$8 = Object.defineProperty, __getOwnPropDesc$8 = Object.getOwnPropertyDescriptor, __decorateClass$8 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
355
- for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$8(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
1247
+ var __defProp$7 = Object.defineProperty, __getOwnPropDesc$7 = Object.getOwnPropertyDescriptor, __decorateClass$7 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
1248
+ for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$7(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
356
1249
  (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
357
- return kind && result && __defProp$8(target, key, result), result;
358
- }, "__decorateClass$8"), __decorateParam$8 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$8");
1250
+ return kind && result && __defProp$7(target, key, result), result;
1251
+ }, "__decorateClass$7"), __decorateParam$7 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$7");
359
1252
  const ALERT_KEY = "SHEET_FORMULA_ALERT", ErrorTypeToMessageMap = {
360
1253
  [ErrorType.DIV_BY_ZERO]: "divByZero",
361
1254
  [ErrorType.NAME]: "name",
@@ -370,8 +1263,8 @@ const ALERT_KEY = "SHEET_FORMULA_ALERT", ErrorTypeToMessageMap = {
370
1263
  [ErrorType.CONNECT]: "connect",
371
1264
  [ErrorType.NULL]: "null"
372
1265
  };
373
- var _a2;
374
- let FormulaAlertRenderController = (_a2 = class extends Disposable {
1266
+ var _a3;
1267
+ let FormulaAlertRenderController = (_a3 = class extends Disposable {
375
1268
  constructor(_context, _hoverManagerService, _cellAlertManagerService, _localeService, _zenZoneService) {
376
1269
  super(), this._context = _context, this._hoverManagerService = _hoverManagerService, this._cellAlertManagerService = _cellAlertManagerService, this._localeService = _localeService, this._zenZoneService = _zenZoneService, this._init();
377
1270
  }
@@ -412,19 +1305,19 @@ let FormulaAlertRenderController = (_a2 = class extends Disposable {
412
1305
  visible && this._cellAlertManagerService.removeAlert(ALERT_KEY);
413
1306
  }));
414
1307
  }
415
- }, __name(_a2, "FormulaAlertRenderController"), _a2);
416
- FormulaAlertRenderController = __decorateClass$8([
417
- __decorateParam$8(1, Inject(HoverManagerService)),
418
- __decorateParam$8(2, Inject(CellAlertManagerService)),
419
- __decorateParam$8(3, Inject(LocaleService)),
420
- __decorateParam$8(4, IZenZoneService)
1308
+ }, __name(_a3, "FormulaAlertRenderController"), _a3);
1309
+ FormulaAlertRenderController = __decorateClass$7([
1310
+ __decorateParam$7(1, Inject(HoverManagerService)),
1311
+ __decorateParam$7(2, Inject(CellAlertManagerService)),
1312
+ __decorateParam$7(3, Inject(LocaleService)),
1313
+ __decorateParam$7(4, IZenZoneService)
421
1314
  ], FormulaAlertRenderController);
422
- var __defProp$7 = Object.defineProperty, __getOwnPropDesc$7 = Object.getOwnPropertyDescriptor, __decorateClass$7 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
423
- for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$7(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
1315
+ var __defProp$6 = Object.defineProperty, __getOwnPropDesc$6 = Object.getOwnPropertyDescriptor, __decorateClass$6 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
1316
+ for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$6(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
424
1317
  (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
425
- return kind && result && __defProp$7(target, key, result), result;
426
- }, "__decorateClass$7"), __decorateParam$7 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$7"), _a3;
427
- let FormulaAutoFillController = (_a3 = class extends Disposable {
1318
+ return kind && result && __defProp$6(target, key, result), result;
1319
+ }, "__decorateClass$6"), __decorateParam$6 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$6"), _a4;
1320
+ let FormulaAutoFillController = (_a4 = class extends Disposable {
428
1321
  constructor(_autoFillService, _lexerTreeBuilder) {
429
1322
  super(), this._autoFillService = _autoFillService, this._lexerTreeBuilder = _lexerTreeBuilder, this._registerAutoFill();
430
1323
  }
@@ -471,10 +1364,10 @@ let FormulaAutoFillController = (_a3 = class extends Disposable {
471
1364
  }
472
1365
  return applyData;
473
1366
  }
474
- }, __name(_a3, "FormulaAutoFillController"), _a3);
475
- FormulaAutoFillController = __decorateClass$7([
476
- __decorateParam$7(0, IAutoFillService),
477
- __decorateParam$7(1, Inject(LexerTreeBuilder))
1367
+ }, __name(_a4, "FormulaAutoFillController"), _a4);
1368
+ FormulaAutoFillController = __decorateClass$6([
1369
+ __decorateParam$6(0, IAutoFillService),
1370
+ __decorateParam$6(1, Inject(LexerTreeBuilder))
478
1371
  ], FormulaAutoFillController);
479
1372
  function directionToOffset(step, direction) {
480
1373
  let offsetX = 0, offsetY = 0;
@@ -504,14 +1397,14 @@ function getDataLength(copyDataPiece) {
504
1397
  return length;
505
1398
  }
506
1399
  __name(getDataLength, "getDataLength");
507
- var __defProp$6 = Object.defineProperty, __getOwnPropDesc$6 = Object.getOwnPropertyDescriptor, __decorateClass$6 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
508
- for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$6(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
1400
+ var __defProp$5 = Object.defineProperty, __getOwnPropDesc$5 = Object.getOwnPropertyDescriptor, __decorateClass$5 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
1401
+ for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$5(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
509
1402
  (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
510
- return kind && result && __defProp$6(target, key, result), result;
511
- }, "__decorateClass$6"), __decorateParam$6 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$6");
1403
+ return kind && result && __defProp$5(target, key, result), result;
1404
+ }, "__decorateClass$5"), __decorateParam$5 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$5");
512
1405
  const DEFAULT_PASTE_FORMULA = "default-paste-formula";
513
- var _a4;
514
- let FormulaClipboardController = (_a4 = class extends Disposable {
1406
+ var _a5;
1407
+ let FormulaClipboardController = (_a5 = class extends Disposable {
515
1408
  constructor(_currentUniverSheet, _lexerTreeBuilder, _sheetClipboardService, _injector, _formulaDataModel) {
516
1409
  super(), this._currentUniverSheet = _currentUniverSheet, this._lexerTreeBuilder = _lexerTreeBuilder, this._sheetClipboardService = _sheetClipboardService, this._injector = _injector, this._formulaDataModel = _formulaDataModel, this._initialize();
517
1410
  }
@@ -567,13 +1460,13 @@ let FormulaClipboardController = (_a4 = class extends Disposable {
567
1460
  pasteFrom
568
1461
  ));
569
1462
  }
570
- }, __name(_a4, "FormulaClipboardController"), _a4);
571
- FormulaClipboardController = __decorateClass$6([
572
- __decorateParam$6(0, IUniverInstanceService),
573
- __decorateParam$6(1, Inject(LexerTreeBuilder)),
574
- __decorateParam$6(2, ISheetClipboardService),
575
- __decorateParam$6(3, Inject(Injector)),
576
- __decorateParam$6(4, Inject(FormulaDataModel))
1463
+ }, __name(_a5, "FormulaClipboardController"), _a5);
1464
+ FormulaClipboardController = __decorateClass$5([
1465
+ __decorateParam$5(0, IUniverInstanceService),
1466
+ __decorateParam$5(1, Inject(LexerTreeBuilder)),
1467
+ __decorateParam$5(2, ISheetClipboardService),
1468
+ __decorateParam$5(3, Inject(Injector)),
1469
+ __decorateParam$5(4, Inject(FormulaDataModel))
577
1470
  ], FormulaClipboardController);
578
1471
  function getSetCellFormulaMutations(unitId, subUnitId, range, matrix, accessor, copyInfo, lexerTreeBuilder, formulaDataModel, isSpecialPaste = !1, pasteFrom) {
579
1472
  const redoMutationsInfo = [], undoMutationsInfo = [], valueMatrix = getValueMatrix(unitId, subUnitId, range, matrix, copyInfo, lexerTreeBuilder, formulaDataModel, pasteFrom), setValuesMutation = {
@@ -713,12 +1606,12 @@ function getCellRichText(cell) {
713
1606
  }
714
1607
  }
715
1608
  __name(getCellRichText, "getCellRichText");
716
- var __defProp$5 = Object.defineProperty, __getOwnPropDesc$5 = Object.getOwnPropertyDescriptor, __decorateClass$5 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
717
- for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$5(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
1609
+ var __defProp$4 = Object.defineProperty, __getOwnPropDesc$4 = Object.getOwnPropertyDescriptor, __decorateClass$4 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
1610
+ for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$4(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
718
1611
  (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
719
- return kind && result && __defProp$5(target, key, result), result;
720
- }, "__decorateClass$5"), __decorateParam$5 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$5"), _a5;
721
- let FormulaEditorShowController = (_a5 = class extends Disposable {
1612
+ return kind && result && __defProp$4(target, key, result), result;
1613
+ }, "__decorateClass$4"), __decorateParam$4 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$4"), _a6;
1614
+ let FormulaEditorShowController = (_a6 = class extends Disposable {
722
1615
  constructor(_context, _editorBridgeService, _formulaDataModel, _themeService, _renderManagerService, _sheetSkeletonManagerService, _commandService, _logService) {
723
1616
  super();
724
1617
  __publicField(this, "_previousShape");
@@ -860,29 +1753,29 @@ let FormulaEditorShowController = (_a5 = class extends Disposable {
860
1753
  }
861
1754
  }
862
1755
  }
863
- }, __name(_a5, "FormulaEditorShowController"), _a5);
864
- FormulaEditorShowController = __decorateClass$5([
865
- __decorateParam$5(1, Inject(IEditorBridgeService)),
866
- __decorateParam$5(2, Inject(FormulaDataModel)),
867
- __decorateParam$5(3, Inject(ThemeService)),
868
- __decorateParam$5(4, IRenderManagerService),
869
- __decorateParam$5(5, Inject(SheetSkeletonManagerService)),
870
- __decorateParam$5(6, ICommandService),
871
- __decorateParam$5(7, ILogService)
1756
+ }, __name(_a6, "FormulaEditorShowController"), _a6);
1757
+ FormulaEditorShowController = __decorateClass$4([
1758
+ __decorateParam$4(1, Inject(IEditorBridgeService)),
1759
+ __decorateParam$4(2, Inject(FormulaDataModel)),
1760
+ __decorateParam$4(3, Inject(ThemeService)),
1761
+ __decorateParam$4(4, IRenderManagerService),
1762
+ __decorateParam$4(5, Inject(SheetSkeletonManagerService)),
1763
+ __decorateParam$4(6, ICommandService),
1764
+ __decorateParam$4(7, ILogService)
872
1765
  ], FormulaEditorShowController);
873
- var __defProp$4 = Object.defineProperty, __getOwnPropDesc$4 = Object.getOwnPropertyDescriptor, __decorateClass$4 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
874
- for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$4(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
1766
+ var __defProp$3 = Object.defineProperty, __getOwnPropDesc$3 = Object.getOwnPropertyDescriptor, __decorateClass$3 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
1767
+ for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$3(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
875
1768
  (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
876
- return kind && result && __defProp$4(target, key, result), result;
877
- }, "__decorateClass$4"), __decorateParam$4 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$4");
1769
+ return kind && result && __defProp$3(target, key, result), result;
1770
+ }, "__decorateClass$3"), __decorateParam$3 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$3");
878
1771
  const FORMULA_ERROR_MARK = {
879
1772
  tl: {
880
1773
  size: 6,
881
1774
  color: "#409f11"
882
1775
  }
883
1776
  };
884
- var _a6;
885
- let FormulaRenderManagerController = (_a6 = class extends RxDisposable {
1777
+ var _a7;
1778
+ let FormulaRenderManagerController = (_a7 = class extends RxDisposable {
886
1779
  constructor(_sheetInterceptorService) {
887
1780
  super(), this._sheetInterceptorService = _sheetInterceptorService, this.disposeWithMe(this._sheetInterceptorService.intercept(
888
1781
  INTERCEPTOR_POINT.CELL_CONTENT,
@@ -899,112 +1792,10 @@ let FormulaRenderManagerController = (_a6 = class extends RxDisposable {
899
1792
  }
900
1793
  ));
901
1794
  }
902
- }, __name(_a6, "FormulaRenderManagerController"), _a6);
903
- FormulaRenderManagerController = __decorateClass$4([
904
- __decorateParam$4(0, Inject(SheetInterceptorService))
1795
+ }, __name(_a7, "FormulaRenderManagerController"), _a7);
1796
+ FormulaRenderManagerController = __decorateClass$3([
1797
+ __decorateParam$3(0, Inject(SheetInterceptorService))
905
1798
  ], FormulaRenderManagerController);
906
- var jsxRuntime = { exports: {} }, reactJsxRuntime_production_min = {};
907
- /**
908
- * @license React
909
- * react-jsx-runtime.production.min.js
910
- *
911
- * Copyright (c) Facebook, Inc. and its affiliates.
912
- *
913
- * This source code is licensed under the MIT license found in the
914
- * LICENSE file in the root directory of this source tree.
915
- */
916
- var f = require$$0, k = Symbol.for("react.element"), l = Symbol.for("react.fragment"), m = Object.prototype.hasOwnProperty, n = f.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, p = { key: !0, ref: !0, __self: !0, __source: !0 };
917
- function q(c, a, g) {
918
- var b, d = {}, e = null, h = null;
919
- g !== void 0 && (e = "" + g), a.key !== void 0 && (e = "" + a.key), a.ref !== void 0 && (h = a.ref);
920
- for (b in a) m.call(a, b) && !p.hasOwnProperty(b) && (d[b] = a[b]);
921
- if (c && c.defaultProps) for (b in a = c.defaultProps, a) d[b] === void 0 && (d[b] = a[b]);
922
- return { $$typeof: k, type: c, key: e, ref: h, props: d, _owner: n.current };
923
- }
924
- __name(q, "q");
925
- reactJsxRuntime_production_min.Fragment = l;
926
- reactJsxRuntime_production_min.jsx = q;
927
- reactJsxRuntime_production_min.jsxs = q;
928
- jsxRuntime.exports = reactJsxRuntime_production_min;
929
- var jsxRuntimeExports = jsxRuntime.exports, __assign = function() {
930
- return __assign = Object.assign || function(t) {
931
- for (var s, i = 1, n2 = arguments.length; i < n2; i++) {
932
- s = arguments[i];
933
- for (var p2 in s) Object.prototype.hasOwnProperty.call(s, p2) && (t[p2] = s[p2]);
934
- }
935
- return t;
936
- }, __assign.apply(this, arguments);
937
- }, __rest = function(s, e) {
938
- var t = {};
939
- for (var p2 in s) Object.prototype.hasOwnProperty.call(s, p2) && e.indexOf(p2) < 0 && (t[p2] = s[p2]);
940
- if (s != null && typeof Object.getOwnPropertySymbols == "function")
941
- for (var i = 0, p2 = Object.getOwnPropertySymbols(s); i < p2.length; i++)
942
- e.indexOf(p2[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p2[i]) && (t[p2[i]] = s[p2[i]]);
943
- return t;
944
- }, IconBase = forwardRef(function(props, ref) {
945
- var icon = props.icon, id = props.id, className = props.className, extend = props.extend, restProps = __rest(props, ["icon", "id", "className", "extend"]), cls = "univerjs-icon univerjs-icon-".concat(id, " ").concat(className || "").trim(), idSuffix = useRef("_".concat(generateShortUuid()));
946
- return render(icon, "".concat(id), { defIds: icon.defIds, idSuffix: idSuffix.current }, __assign({ ref, className: cls }, restProps), extend);
947
- });
948
- function render(node, id, runtimeProps, rootProps, extend) {
949
- return createElement(node.tag, __assign(__assign({ key: id }, replaceRuntimeIdsAndExtInAttrs(node, runtimeProps, extend)), rootProps), (replaceRuntimeIdsInDefs(node, runtimeProps).children || []).map(function(child, index) {
950
- return render(child, "".concat(id, "-").concat(node.tag, "-").concat(index), runtimeProps, void 0, extend);
951
- }));
952
- }
953
- __name(render, "render");
954
- function replaceRuntimeIdsAndExtInAttrs(node, runtimeProps, extend) {
955
- var attrs = __assign({}, node.attrs);
956
- extend != null && extend.colorChannel1 && attrs.fill === "colorChannel1" && (attrs.fill = extend.colorChannel1);
957
- var defIds = runtimeProps.defIds;
958
- return !defIds || defIds.length === 0 || (node.tag === "use" && attrs["xlink:href"] && (attrs["xlink:href"] = attrs["xlink:href"] + runtimeProps.idSuffix), Object.entries(attrs).forEach(function(_a11) {
959
- var key = _a11[0], value = _a11[1];
960
- typeof value == "string" && (attrs[key] = value.replace(/url\(#(.*)\)/, "url(#$1".concat(runtimeProps.idSuffix, ")")));
961
- })), attrs;
962
- }
963
- __name(replaceRuntimeIdsAndExtInAttrs, "replaceRuntimeIdsAndExtInAttrs");
964
- function replaceRuntimeIdsInDefs(node, runtimeProps) {
965
- var _a11, defIds = runtimeProps.defIds;
966
- return !defIds || defIds.length === 0 ? node : node.tag === "defs" && (!((_a11 = node.children) === null || _a11 === void 0) && _a11.length) ? __assign(__assign({}, node), { children: node.children.map(function(child) {
967
- 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;
968
- }) }) : node;
969
- }
970
- __name(replaceRuntimeIdsInDefs, "replaceRuntimeIdsInDefs");
971
- function generateShortUuid() {
972
- return Math.random().toString(36).substring(2, 8);
973
- }
974
- __name(generateShortUuid, "generateShortUuid");
975
- IconBase.displayName = "UniverIcon";
976
- var element$3 = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M14.1544 3.75557C14.3887 3.98988 14.3887 4.36978 14.1544 4.6041L6.51409 12.2444C6.40157 12.3569 6.24896 12.4201 6.08983 12.4201C5.9307 12.4201 5.77808 12.3569 5.66556 12.2444L1.84541 8.42425C1.6111 8.18993 1.6111 7.81003 1.84541 7.57572C2.07973 7.34141 2.45963 7.34141 2.69394 7.57572L6.08983 10.9716L13.3059 3.75557C13.5402 3.52126 13.9201 3.52126 14.1544 3.75557Z", fillRule: "evenodd", clipRule: "evenodd" } }] }, CheckMarkSingle = forwardRef(function(props, ref) {
977
- return createElement(IconBase, Object.assign({}, props, {
978
- id: "check-mark-single",
979
- ref,
980
- icon: element$3
981
- }));
982
- });
983
- CheckMarkSingle.displayName = "CheckMarkSingle";
984
- var element$2 = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M3.71274 2.86421C3.47843 2.6299 3.09853 2.6299 2.86421 2.86421C2.6299 3.09853 2.6299 3.47843 2.86421 3.71274L7.15154 8.00007L2.86421 12.2874C2.6299 12.5217 2.6299 12.9016 2.86421 13.1359C3.09853 13.3702 3.47843 13.3702 3.71274 13.1359L8.00007 8.84859L12.2874 13.1359C12.5217 13.3702 12.9016 13.3702 13.1359 13.1359C13.3702 12.9016 13.3702 12.5217 13.1359 12.2874L8.84859 8.00007L13.1359 3.71274C13.3702 3.47843 13.3702 3.09853 13.1359 2.86421C12.9016 2.6299 12.5217 2.6299 12.2874 2.86421L8.00007 7.15154L3.71274 2.86421Z" } }] }, CloseSingle = forwardRef(function(props, ref) {
985
- return createElement(IconBase, Object.assign({}, props, {
986
- id: "close-single",
987
- ref,
988
- icon: element$2
989
- }));
990
- });
991
- CloseSingle.displayName = "CloseSingle";
992
- var element$1 = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M8.75 5.32495C8.75 5.73916 8.41421 6.07495 8 6.07495 7.58579 6.07495 7.25 5.73916 7.25 5.32495 7.25 4.91074 7.58579 4.57495 8 4.57495 8.41421 4.57495 8.75 4.91074 8.75 5.32495zM8.5999 7.52505C8.5999 7.19368 8.33127 6.92505 7.9999 6.92505 7.66853 6.92505 7.3999 7.19368 7.3999 7.52505V11.425C7.3999 11.7564 7.66853 12.025 7.9999 12.025 8.33127 12.025 8.5999 11.7564 8.5999 11.425V7.52505z" } }, { tag: "path", attrs: { fill: "currentColor", d: "M0.899902 8.00002C0.899902 4.0788 4.07868 0.900024 7.9999 0.900024C11.9211 0.900024 15.0999 4.0788 15.0999 8.00002C15.0999 11.9212 11.9211 15.1 7.9999 15.1C4.07868 15.1 0.899902 11.9212 0.899902 8.00002ZM7.9999 2.10002C4.74142 2.10002 2.0999 4.74154 2.0999 8.00002C2.0999 11.2585 4.74142 13.9 7.9999 13.9C11.2584 13.9 13.8999 11.2585 13.8999 8.00002C13.8999 4.74154 11.2584 2.10002 7.9999 2.10002Z", fillRule: "evenodd", clipRule: "evenodd" } }] }, DetailsSingle = forwardRef(function(props, ref) {
993
- return createElement(IconBase, Object.assign({}, props, {
994
- id: "details-single",
995
- ref,
996
- icon: element$1
997
- }));
998
- });
999
- DetailsSingle.displayName = "DetailsSingle";
1000
- var element = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M5.90913 3.57564C6.14345 3.34132 6.52335 3.34132 6.75766 3.57564L10.7577 7.57564C10.992 7.80995 10.992 8.18985 10.7577 8.42417L6.75766 12.4242C6.52335 12.6585 6.14345 12.6585 5.90913 12.4242C5.67482 12.1899 5.67482 11.81 5.90913 11.5756L9.48487 7.9999L5.90913 4.42417C5.67482 4.18985 5.67482 3.80995 5.90913 3.57564Z", fillRule: "evenodd", clipRule: "evenodd" } }] }, MoreSingle = forwardRef(function(props, ref) {
1001
- return createElement(IconBase, Object.assign({}, props, {
1002
- id: "more-single",
1003
- ref,
1004
- icon: element
1005
- }));
1006
- });
1007
- MoreSingle.displayName = "MoreSingle";
1008
1799
  function getFunctionTypeValues(enumObj, localeService) {
1009
1800
  return Object.keys(enumObj).filter((key) => isNaN(Number(key)) && key !== "DefinedName").map((key) => ({
1010
1801
  label: localeService.t(`formula.functionType.${key.toLocaleLowerCase()}`),
@@ -1066,7 +1857,7 @@ function HelpFunction() {
1066
1857
  return;
1067
1858
  const { left, top, height } = position;
1068
1859
  functionInfo2.description === "" && functionInfo2.functionParameter.length === 0 || (setOffset([left, top + height]), setParamIndex(paramIndex2), setFunctionInfo(functionInfo2), setDecoratorPosition({ left, top }), setVisible(visible2));
1069
- }), sidebarSubscription = sidebarService.scrollEvent$.pipe(throttleTime(100)).subscribe(updatePosition);
1860
+ }), sidebarSubscription = sidebarService.scrollEvent$.pipe(throttleTime$1(100)).subscribe(updatePosition);
1070
1861
  return () => {
1071
1862
  subscription == null || subscription.unsubscribe(), sidebarSubscription.unsubscribe();
1072
1863
  };
@@ -1367,7 +2158,7 @@ const formulaSelectFunctionSelect = "univer-formula-select-function-select", for
1367
2158
  formulaSelectFunctionContent
1368
2159
  };
1369
2160
  function SelectFunction(props) {
1370
- const { onChange } = props, allTypeValue = "-1", [searchText, setSearchText] = useState(""), [selectList, setSelectList] = useState([]), [active, setActive] = useState(0), [typeSelected, setTypeSelected] = useState(allTypeValue), [nameSelected, setNameSelected] = useState(0), [functionInfo, setFunctionInfo] = useState(null), descriptionService = useDependency(IDescriptionService), localeService = useDependency(LocaleService), options = getFunctionTypeValues(FunctionType, localeService);
2161
+ const { onChange } = props, allTypeValue = "-1", [searchText, setSearchText] = useState(""), [selectList, setSelectList] = useState([]), [active, setActive] = useState(0), [typeSelected, setTypeSelected] = useState(allTypeValue), [nameSelected, setNameSelected] = useState(0), [functionInfo, setFunctionInfo] = useState(null), descriptionService = useDependency(IDescriptionService), localeService = useDependency(LocaleService), sidebarService = useDependency(ISidebarService), sidebarOptions = useObservable(sidebarService.sidebarOptions$), options = getFunctionTypeValues(FunctionType, localeService);
1371
2162
  options.unshift({
1372
2163
  label: localeService.t("formula.moreFunctions.allFunctions"),
1373
2164
  value: allTypeValue
@@ -1377,7 +2168,9 @@ function SelectFunction(props) {
1377
2168
  handleSelectChange(allTypeValue);
1378
2169
  }, []), useEffect(() => {
1379
2170
  setCurrentFunctionInfo(0);
1380
- }, [selectList]);
2171
+ }, [selectList]), useEffect(() => {
2172
+ sidebarOptions != null && sidebarOptions.visible && (setSearchText(""), setSelectList([]), setActive(0), setTypeSelected(allTypeValue), setNameSelected(0), setFunctionInfo(null), handleSelectChange(allTypeValue));
2173
+ }, [sidebarOptions]);
1381
2174
  const highlightSearchText = /* @__PURE__ */ __name((text) => {
1382
2175
  if (searchText.trim() === "") return text;
1383
2176
  const regex = new RegExp(`(${searchText.toLocaleUpperCase()})`);
@@ -1671,12 +2464,12 @@ function singleEditorPromptSelectionShortcutItem() {
1671
2464
  return shortcutList;
1672
2465
  }
1673
2466
  __name(singleEditorPromptSelectionShortcutItem, "singleEditorPromptSelectionShortcutItem");
1674
- var __defProp$3 = Object.defineProperty, __getOwnPropDesc$3 = Object.getOwnPropertyDescriptor, __decorateClass$3 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
1675
- for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$3(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
2467
+ var __defProp$2 = Object.defineProperty, __getOwnPropDesc$2 = Object.getOwnPropertyDescriptor, __decorateClass$2 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
2468
+ for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$2(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
1676
2469
  (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
1677
- return kind && result && __defProp$3(target, key, result), result;
1678
- }, "__decorateClass$3"), __decorateParam$3 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$3"), _a7;
1679
- let FormulaUIController = (_a7 = class extends Disposable {
2470
+ return kind && result && __defProp$2(target, key, result), result;
2471
+ }, "__decorateClass$2"), __decorateParam$2 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$2"), _a8;
2472
+ let FormulaUIController = (_a8 = class extends Disposable {
1680
2473
  constructor(_injector, _menuManagerService, _commandService, _shortcutService, _uiPartsService, _renderManagerService, _componentManager) {
1681
2474
  super(), this._injector = _injector, this._menuManagerService = _menuManagerService, this._commandService = _commandService, this._shortcutService = _shortcutService, this._uiPartsService = _uiPartsService, this._renderManagerService = _renderManagerService, this._componentManager = _componentManager, this._initialize();
1682
2475
  }
@@ -1717,15 +2510,15 @@ let FormulaUIController = (_a7 = class extends Disposable {
1717
2510
  _registerRenderModules() {
1718
2511
  this.disposeWithMe(this._renderManagerService.registerRenderModule(UniverInstanceType.UNIVER_SHEET, [FormulaEditorShowController]));
1719
2512
  }
1720
- }, __name(_a7, "FormulaUIController"), _a7);
1721
- FormulaUIController = __decorateClass$3([
1722
- __decorateParam$3(0, Inject(Injector)),
1723
- __decorateParam$3(1, IMenuManagerService),
1724
- __decorateParam$3(2, ICommandService),
1725
- __decorateParam$3(3, IShortcutService),
1726
- __decorateParam$3(4, IUIPartsService),
1727
- __decorateParam$3(5, IRenderManagerService),
1728
- __decorateParam$3(6, Inject(ComponentManager))
2513
+ }, __name(_a8, "FormulaUIController"), _a8);
2514
+ FormulaUIController = __decorateClass$2([
2515
+ __decorateParam$2(0, Inject(Injector)),
2516
+ __decorateParam$2(1, IMenuManagerService),
2517
+ __decorateParam$2(2, ICommandService),
2518
+ __decorateParam$2(3, IShortcutService),
2519
+ __decorateParam$2(4, IUIPartsService),
2520
+ __decorateParam$2(5, IRenderManagerService),
2521
+ __decorateParam$2(6, Inject(ComponentManager))
1729
2522
  ], FormulaUIController);
1730
2523
  function getFormulaRefSelectionStyle(themeService, refColor, id) {
1731
2524
  const style = themeService.getCurrentTheme(), fill = new ColorKit(refColor).setAlpha(0.05).toRgbString();
@@ -1744,127 +2537,6 @@ function getFormulaRefSelectionStyle(themeService, refColor, id) {
1744
2537
  };
1745
2538
  }
1746
2539
  __name(getFormulaRefSelectionStyle, "getFormulaRefSelectionStyle");
1747
- var __defProp$2 = Object.defineProperty, __getOwnPropDesc$2 = Object.getOwnPropertyDescriptor, __decorateClass$2 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
1748
- for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$2(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
1749
- (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
1750
- return kind && result && __defProp$2(target, key, result), result;
1751
- }, "__decorateClass$2"), __decorateParam$2 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$2"), _a8;
1752
- let RefSelectionsRenderService = (_a8 = class extends BaseSelectionRenderService {
1753
- constructor(_context, injector, themeService, shortcutService, sheetSkeletonManagerService, _refSelectionsService) {
1754
- super(
1755
- injector,
1756
- themeService,
1757
- shortcutService,
1758
- sheetSkeletonManagerService
1759
- );
1760
- __publicField(this, "_workbookSelections");
1761
- __publicField(this, "_eventDisposables");
1762
- this._context = _context, this._refSelectionsService = _refSelectionsService, this._workbookSelections = this._refSelectionsService.getWorkbookSelections(this._context.unitId), this._initSelectionChangeListener(), this._initSkeletonChangeListener(), this._initUserActionSyncListener(), this._setSelectionStyle(getDefaultRefSelectionStyle(this._themeService)), this._remainLastEnabled = !0;
1763
- }
1764
- getLocation() {
1765
- return this._skeleton.getLocation();
1766
- }
1767
- setRemainLastEnabled(enabled) {
1768
- this._remainLastEnabled = enabled;
1769
- }
1770
- setSkipLastEnabled(enabled) {
1771
- this._skipLastEnabled = enabled;
1772
- }
1773
- clearLastSelection() {
1774
- const last = this._selectionControls[this._selectionControls.length - 1];
1775
- last && (last.dispose(), this._selectionControls.pop());
1776
- }
1777
- /**
1778
- * Call this method and user will be able to select on the canvas to update selections.
1779
- */
1780
- enableSelectionChanging() {
1781
- return this._disableSelectionChanging(), this._eventDisposables = this._initCanvasEventListeners(), toDisposable(() => this._disableSelectionChanging());
1782
- }
1783
- _disableSelectionChanging() {
1784
- var _a11;
1785
- (_a11 = this._eventDisposables) == null || _a11.dispose(), this._eventDisposables = null;
1786
- }
1787
- _initCanvasEventListeners() {
1788
- const sheetObject = this._getSheetObject(), { spreadsheetRowHeader, spreadsheetColumnHeader, spreadsheet, spreadsheetLeftTopPlaceholder } = sheetObject, { scene } = this._context, listenerDisposables = new DisposableCollection();
1789
- return listenerDisposables.add(spreadsheet == null ? void 0 : spreadsheet.onPointerDown$.subscribeEvent((evt, state) => {
1790
- this._onPointerDown(evt, spreadsheet.zIndex + 1, RANGE_TYPE.NORMAL, this._getActiveViewport(evt)), evt.button !== 2 && state.stopPropagation();
1791
- })), listenerDisposables.add(
1792
- spreadsheetRowHeader == null ? void 0 : spreadsheetRowHeader.onPointerDown$.subscribeEvent((evt, state) => {
1793
- const skeleton = this._sheetSkeletonManagerService.getCurrent().skeleton, { row } = getCoordByOffset(evt.offsetX, evt.offsetY, scene, skeleton);
1794
- checkInHeaderRanges(this._workbookSelections.getCurrentSelections(), row, RANGE_TYPE.ROW) || (this._onPointerDown(evt, (spreadsheet.zIndex || 1) + 1, RANGE_TYPE.ROW, this._getActiveViewport(evt), ScrollTimerType.Y), evt.button !== 2 && state.stopPropagation());
1795
- })
1796
- ), listenerDisposables.add(spreadsheetColumnHeader == null ? void 0 : spreadsheetColumnHeader.onPointerDown$.subscribeEvent((evt, state) => {
1797
- const skeleton = this._sheetSkeletonManagerService.getCurrent().skeleton, { column } = getCoordByOffset(evt.offsetX, evt.offsetY, scene, skeleton);
1798
- checkInHeaderRanges(this._workbookSelections.getCurrentSelections(), column, RANGE_TYPE.COLUMN) || (this._onPointerDown(evt, (spreadsheet.zIndex || 1) + 1, RANGE_TYPE.COLUMN, this._getActiveViewport(evt), ScrollTimerType.X), evt.button !== 2 && state.stopPropagation());
1799
- })), listenerDisposables.add(spreadsheetLeftTopPlaceholder == null ? void 0 : spreadsheetLeftTopPlaceholder.onPointerDown$.subscribeEvent((evt, state) => {
1800
- this._reset();
1801
- const skeleton = this._sheetSkeletonManagerService.getCurrent().skeleton, selectionWithStyle = getAllSelection(skeleton), selectionData = this.attachSelectionWithCoord(selectionWithStyle);
1802
- this._addSelectionControlBySelectionData(selectionData), this._selectionMoveStart$.next(this.getSelectionDataWithStyle()), evt.button !== 2 && state.stopPropagation();
1803
- })), listenerDisposables;
1804
- }
1805
- /**
1806
- * Update selectionModel in this._workbookSelections by user action in spreadsheet area.
1807
- */
1808
- _initUserActionSyncListener() {
1809
- this.disposeWithMe(this.selectionMoveStart$.subscribe((selectionDataWithStyle) => {
1810
- this._updateSelections(selectionDataWithStyle, SelectionMoveType.MOVE_START);
1811
- })), this.disposeWithMe(this.selectionMoving$.subscribe((selectionDataWithStyle) => {
1812
- this._updateSelections(selectionDataWithStyle, SelectionMoveType.MOVING);
1813
- })), this.disposeWithMe(this.selectionMoveEnd$.subscribe((selectionDataWithStyle) => {
1814
- this._updateSelections(selectionDataWithStyle, SelectionMoveType.MOVE_END);
1815
- }));
1816
- }
1817
- _updateSelections(selectionDataWithStyleList, type) {
1818
- const sheetId = this._context.unit.getActiveSheet().getSheetId();
1819
- selectionDataWithStyleList.length !== 0 && this._workbookSelections.setSelections(
1820
- sheetId,
1821
- selectionDataWithStyleList.map((selectionDataWithStyle) => convertSelectionDataToRange(selectionDataWithStyle)),
1822
- type
1823
- );
1824
- }
1825
- _initSelectionChangeListener() {
1826
- this.disposeWithMe(this._workbookSelections.selectionMoveEnd$.subscribe((selectionsWithStyles) => {
1827
- this._reset();
1828
- for (const selectionWithStyle of selectionsWithStyles) {
1829
- const selectionData = this.attachSelectionWithCoord(selectionWithStyle);
1830
- this._addSelectionControlBySelectionData(selectionData);
1831
- }
1832
- }));
1833
- }
1834
- _initSkeletonChangeListener() {
1835
- this.disposeWithMe(this._sheetSkeletonManagerService.currentSkeleton$.subscribe((param) => {
1836
- if (!param)
1837
- return;
1838
- const { skeleton } = param, { scene } = this._context, viewportMain = scene.getViewport(SHEET_VIEWPORT_KEY.VIEW_MAIN);
1839
- this._skeleton && this._skeleton.worksheet.getSheetId() !== skeleton.worksheet.getSheetId() && this._reset(), this._changeRuntime(skeleton, scene, viewportMain);
1840
- const currentSelections = this._workbookSelections.getCurrentSelections();
1841
- this._refreshSelectionControl(currentSelections || []);
1842
- }));
1843
- }
1844
- _refreshSelectionControl(selectionsData) {
1845
- const selections = selectionsData.map((selectionWithStyle) => attachSelectionWithCoord(selectionWithStyle, this._skeleton));
1846
- this.updateControlForCurrentByRangeData(selections);
1847
- }
1848
- _getActiveViewport(evt) {
1849
- const sheetObject = this._getSheetObject();
1850
- return sheetObject == null ? void 0 : sheetObject.scene.getActiveViewportByCoord(Vector2.FromArray([evt.offsetX, evt.offsetY]));
1851
- }
1852
- _getSheetObject() {
1853
- return getSheetObject(this._context.unit, this._context);
1854
- }
1855
- }, __name(_a8, "RefSelectionsRenderService"), _a8);
1856
- RefSelectionsRenderService = __decorateClass$2([
1857
- __decorateParam$2(1, Inject(Injector)),
1858
- __decorateParam$2(2, Inject(ThemeService)),
1859
- __decorateParam$2(3, IShortcutService),
1860
- __decorateParam$2(4, Inject(SheetSkeletonManagerService)),
1861
- __decorateParam$2(5, IRefSelectionsService)
1862
- ], RefSelectionsRenderService);
1863
- function getDefaultRefSelectionStyle(themeService) {
1864
- const style = getNormalSelectionStyle(themeService);
1865
- return style.hasAutoFill = !1, style.hasRowHeader = !1, style.hasColumnHeader = !1, style.widgets = { tl: !0, tc: !0, tr: !0, ml: !0, mr: !0, bl: !0, bc: !0, br: !0 }, style;
1866
- }
1867
- __name(getDefaultRefSelectionStyle, "getDefaultRefSelectionStyle");
1868
2540
  var __defProp$1 = Object.defineProperty, __getOwnPropDesc$1 = Object.getOwnPropertyDescriptor, __decorateClass$1 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
1869
2541
  for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$1(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
1870
2542
  (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
@@ -1936,7 +2608,9 @@ let PromptController = (_a9 = class extends Disposable {
1936
2608
  }
1937
2609
  _initialCursorSync() {
1938
2610
  this.disposeWithMe(
1939
- this._docSelectionManagerService.textSelection$.subscribe((params) => {
2611
+ this._docSelectionManagerService.textSelection$.pipe(
2612
+ filter((item) => !isRangeSelector(item.unitId))
2613
+ ).subscribe((params) => {
1940
2614
  var _a11;
1941
2615
  if ((params == null ? void 0 : params.unitId) == null)
1942
2616
  return;
@@ -1953,7 +2627,7 @@ let PromptController = (_a9 = class extends Disposable {
1953
2627
  this._univerInstanceService.getCurrentTypeOfUnit$(UniverInstanceType.UNIVER_DOC).subscribe((documentDataModel) => {
1954
2628
  var _a11;
1955
2629
  const unitId = documentDataModel == null ? void 0 : documentDataModel.getUnitId();
1956
- if (unitId == null || this._listenInputCache.has(unitId) || this._editorService.getEditor(unitId) == null)
2630
+ if (unitId == null || isRangeSelector(unitId) || this._listenInputCache.has(unitId) || this._editorService.getEditor(unitId) == null)
1957
2631
  return;
1958
2632
  const docSelectionRenderService = (_a11 = this._renderManagerService.getRenderById(unitId)) == null ? void 0 : _a11.with(DocSelectionRenderService);
1959
2633
  docSelectionRenderService && this.disposeWithMe(
@@ -1980,7 +2654,7 @@ let PromptController = (_a9 = class extends Disposable {
1980
2654
  if (documentDataModel == null)
1981
2655
  return;
1982
2656
  const editorId = documentDataModel.getUnitId();
1983
- !this._editorService.isEditor(editorId) || this._previousEditorUnitId === editorId || this._editorService.isSheetEditor(editorId) || (this._closeRangePrompt(editorId), this._previousEditorUnitId = editorId);
2657
+ isRangeSelector(editorId) || !this._editorService.isEditor(editorId) || this._previousEditorUnitId === editorId || this._editorService.isSheetEditor(editorId) || (this._closeRangePrompt(editorId), this._previousEditorUnitId = editorId);
1984
2658
  })
1985
2659
  ), this.disposeWithMe(
1986
2660
  this._editorService.closeRangePrompt$.subscribe(() => {
@@ -2208,7 +2882,7 @@ let PromptController = (_a9 = class extends Disposable {
2208
2882
  else {
2209
2883
  this._existsSequenceNode = !0;
2210
2884
  const { textRuns, refSelections } = this._buildTextRuns(sequenceNodes);
2211
- bodyList.forEach((body) => body.textRuns = textRuns), this._allSelectionRenderServices.forEach((r) => this._refreshSelectionForReference(r, refSelections));
2885
+ bodyList.forEach((body) => body.textRuns = textRuns), this._allSelectionRenderServices.forEach((r2) => this._refreshSelectionForReference(r2, refSelections));
2212
2886
  }
2213
2887
  this._refreshFormulaAndCellEditor(unitIds);
2214
2888
  }
@@ -2254,8 +2928,8 @@ let PromptController = (_a9 = class extends Disposable {
2254
2928
  return { textRuns, refSelections };
2255
2929
  }
2256
2930
  _exceedCurrentRange(range, rowCount, columnCount) {
2257
- const { endRow, endColumn } = range;
2258
- return endRow > rowCount || endColumn > columnCount;
2931
+ const { startRow, startColumn } = range;
2932
+ return startRow > rowCount - 1 || startColumn > columnCount - 1;
2259
2933
  }
2260
2934
  /**
2261
2935
  * Draw the referenced selection text based on the style and token.
@@ -2386,7 +3060,7 @@ let PromptController = (_a9 = class extends Disposable {
2386
3060
  _syncToEditor(sequenceNodes, textSelectionOffset, editorUnitId, canUndo = !0, fromSelection = !0) {
2387
3061
  let dataStream = generateStringWithSequence(sequenceNodes);
2388
3062
  const { textRuns, refSelections } = this._buildTextRuns(sequenceNodes);
2389
- this._isSelectionMovingRefSelections = refSelections, this._allSelectionRenderServices.forEach((r) => this._updateRefSelectionStyle(r, this._isSelectionMovingRefSelections));
3063
+ this._isSelectionMovingRefSelections = refSelections, this._allSelectionRenderServices.forEach((r2) => this._updateRefSelectionStyle(r2, this._isSelectionMovingRefSelections));
2390
3064
  const activeRange = this._docSelectionManagerService.getActiveTextRange();
2391
3065
  if (activeRange == null)
2392
3066
  return;
@@ -2534,6 +3208,8 @@ let PromptController = (_a9 = class extends Disposable {
2534
3208
  (isMerged || isMergedMainCell) && mergeStartRow === startRow && mergeStartColumn === startColumn && mergeEndRow === endRow && mergeEndColumn === endColumn && (startRow = mergeStartRow, startColumn = mergeStartColumn, endRow = mergeStartRow, endColumn = mergeStartColumn);
2535
3209
  }
2536
3210
  const nodeIndex = Number(id), currentNode = this._formulaPromptService.getCurrentSequenceNodeByIndex(nodeIndex);
3211
+ if (!currentNode)
3212
+ return;
2537
3213
  let refType = { startAbsoluteRefType: AbsoluteRefType.NONE };
2538
3214
  if (typeof currentNode != "string") {
2539
3215
  const token = currentNode.token;
@@ -2816,7 +3492,7 @@ let UniverSheetsFormulaUIPlugin = (_a10 = class extends Plugin {
2816
3492
  [FormulaAlertRenderController]
2817
3493
  ].forEach((dep) => {
2818
3494
  this.disposeWithMe(this._renderManagerService.registerRenderModule(UniverInstanceType.UNIVER_SHEET, dep));
2819
- }), this._injector.get(FormulaClipboardController), this._injector.get(FormulaRenderManagerController);
3495
+ }), this._injector.get(FormulaClipboardController), this._injector.get(FormulaRenderManagerController), this._injector.get(ComponentManager).register(RANGE_SELECTOR_COMPONENT_KEY, RangeSelector);
2820
3496
  }
2821
3497
  onSteady() {
2822
3498
  this._injector.get(FormulaAutoFillController), this._injector.get(PromptController);
@@ -2835,6 +3511,8 @@ export {
2835
3511
  HelpFunctionOperation,
2836
3512
  InsertFunctionOperation,
2837
3513
  MoreFunctionsOperation,
3514
+ RangeSelector,
3515
+ RefSelectionsRenderService,
2838
3516
  ReferenceAbsoluteOperation,
2839
3517
  SearchFunctionOperation,
2840
3518
  SelectEditorFormulaOperation,