UNPKG

@univerjs/sheets-ui

Version:

UniverSheet normal ui-plugin-sheets

885 lines • 1.08 MB
var Mp = Object.defineProperty; var Ep = (r, e, t) => e in r ? Mp(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t; var b = (r, e, t) => Ep(r, typeof e != "symbol" ? e + "" : e, t); import { DOCS_VIEW_KEY as Tp, IEditorService as Si, getCanvasOffsetByEngine as su, VIEWPORT_KEY as _s, DOCS_COMPONENT_MAIN_LAYER_INDEX as Pp, DocSelectionRenderService as gr, BreakLineCommand as xp, DeleteLeftCommand as Vh, DeleteRightCommand as Op, ReplaceSnapshotCommand as kh, MoveSelectionOperation as Ap, MoveCursorOperation as Hp, SetInlineFormatBoldCommand as Vp, SetInlineFormatItalicCommand as kp, SetInlineFormatUnderlineCommand as Np, SetInlineFormatStrikethroughCommand as Dp, SetInlineFormatSubscriptCommand as Lp, SetInlineFormatSuperscriptCommand as Wp, SetInlineFormatFontSizeCommand as Bp, SetInlineFormatFontFamilyCommand as Fp, SetInlineFormatTextColorCommand as Nh, SetInlineFormatCommand as Po, convertBodyToHtml as Up, NodePositionConvertToCursor as Dh, getLineBounding as Lh, DOC_VERTICAL_PADDING as Xp, IMEInputCommand as zp, InsertCommand as jp, CoverContentCommand as Yp } from "@univerjs/docs-ui"; import { CommandType as Q, createInterceptorKey as kn, ColorKit as xn, RANGE_TYPE as X, convertCellToRange as bs, UniverInstanceType as x, IUniverInstanceService as N, Quantity as uc, Disposable as oe, toDisposable as We, Tools as le, createIdentifier as jt, InterceptorManager as Ci, ThemeService as At, Inject as k, Injector as bt, IConfigService as nn, generateRandomId as xo, ObjectMatrix as Ge, Direction as F, isFormulaString as ed, isFormulaId as Zp, CellValueType as Mt, numfmt as $t, ICommandService as L, IUndoRedoService as Yt, Rectangle as ae, sequenceExecute as Oo, IContextService as ke, DOCS_NORMAL_EDITOR_UNIT_ID_KEY as Le, EDITOR_ACTIVATED as Je, FOCUSING_EDITOR_STANDALONE as yl, DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY as De, Workbook as Gp, Optional as td, FOCUSING_SHEET as Ht, RxDisposable as Nn, DisposableCollection as gt, IPermissionService as rt, fromEventSubject as Rs, sortRules as qp, LocaleService as Pe, getReverseDirection as Wh, FOCUSING_FX_BAR_EDITOR as Ot, BooleanNumber as Qe, nameCharacterCheck as Kp, throttle as Qp, debounce as hc, VerticalAlign as dn, HorizontalAlign as Rt, WrapStrategy as mr, FOCUSING_UNIVER_EDITOR as yr, FOCUSING_COMMON_DRAWINGS as Ml, FOCUSING_EDITOR_INPUT_FORMULA as Is, LocaleType as lu, FOCUSING_EDITOR_BUT_HIDDEN as gc, DEFAULT_EMPTY_DOCUMENT_VALUE as Bh, LRUMap as Jp, BaselineOffset as au, DataStreamTreeTokenType as $p, skipParseTagNames as ev, CustomRangeType as nd, DEFAULT_WORKSHEET_ROW_HEIGHT as mc, ILogService as El, ErrorService as tv, CellModeEnum as Fh, isNotNullOrUndefined as nv, extractPureTextFromCell as Uh, UserManagerService as Dt, DEFAULT_STYLES as rd, FontWeight as $o, FontItalic as es, composeStyles as rv, get as wa, Dimension as Xh, BorderStyleTypes as Ae, AbsoluteRefType as cu, NilCommand as id, UndoCommandId as iv, willLoseNumericPrecision as ov, Range as gs, cellToRange as sv, handleStyleToString as du, DEFAULT_WORKSHEET_COLUMN_WIDTH_KEY as uu, DEFAULT_WORKSHEET_COLUMN_WIDTH as hu, PresetListType as lv, isRealNum as zh, InterceptorEffectEnum as av, splitIntoGrid as cv, IAuthzIoService as Tl, isValidRange as dv, dayjs as gu, BuildTextUtils as uv, DependentOn as jh, Plugin as Yh, DocumentFlavor as hv, set as gv, merge as mv, registerDependencies as mu, mergeOverrideWithDependencies as fv, touchDependencies as _a } from "@univerjs/core"; import { IRenderManagerService as Ce, withCurrentTypeOfRenderer as od, SHEET_VIEWPORT_KEY as U, CURSOR_TYPE as ye, Vector2 as Ve, Rect as we, ScrollTimer as Gr, ScrollTimerType as yt, DashedRect as pv, Group as ba, TRANSFORM_CHANGE_OBSERVABLE_TYPE as fc, cancelRequestFrame as vv, requestNewFrame as Sv, FIX_ONE_PIXEL_BLUR_OFFSET as Cv, Layer as wv, SpreadsheetSkeleton as _v, DeviceInputEventType as ze, convertTransformToOffsetX as Ur, convertTransformToOffsetY as Xr, convertTextRotation as sd, RENDER_RAW_FORMULA_KEY as bv, Spreadsheet as Zh, getCurrentTypeOfRenderer as Pl, RENDER_CLASS_TYPE as Rv, ScrollBar as ld, fixLineWidthByScale as fu, ptToPixel as pu, Shape as ad, SHEET_EXTENSION_PREFIX as vu, SpreadsheetRowHeader as Iv, SpreadsheetColumnHeader as yv, Viewport as Cn, hasCJKText as Mv, DEFAULT_PADDING_DATA as Ev, SheetExtension as Gh, RegularPolygon as Ui, precisionTo as Zn } from "@univerjs/engine-render"; import { useDependency as D, useObservable as ht, KeyCode as Y, ComponentManager as Zt, DISABLE_AUTO_FOCUS_KEY as Su, useEvent as Cu, useSidebarClick as qh, MetaKeys as Se, ISidebarService as wi, useComponentsOfPart as Kh, ComponentContainer as Qh, IConfirmService as rn, useConfigValue as xl, UI_PLUGIN_CONFIG_KEY as cd, UIMenu as Tv, ContextMenuPosition as Ct, Slider as Pv, IMessageService as Jh, IClipboardInterfaceService as Ol, IMenuManagerService as dd, ToolbarItem as xv, ILayoutService as Al, DEFAULT_BACKGROUND_COLOR_RGB as Ov, DEFAULT_BACKGROUND_COLOR_RGBA as Av, handleStringToStyle as Hv, textTrim as wu, INotificationService as Vv, IPlatformService as kv, PLAIN_TEXT_CLIPBOARD_MIME_TYPE as _u, HTML_CLIPBOARD_MIME_TYPE as bu, imageMimeTypeSet as Nv, FILE__BMP_CLIPBOARD_MIME_TYPE as Dv, FILE__WEBP_CLIPBOARD_MIME_TYPE as Lv, FILE__JPEG_CLIPBOARD_MIME_TYPE as Wv, FILE_PNG_CLIPBOARD_MIME_TYPE as Bv, CopyCommand as Fv, CutCommand as Uv, PasteCommand as Xv, SheetPasteShortKeyCommandName as zv, IContextMenuService as Hl, getMenuHiddenObservable as ue, MenuItemType as J, COLOR_PICKER_COMPONENT as ud, FONT_SIZE_LIST as jv, FONT_SIZE_COMPONENT as Yv, FONT_FAMILY_LIST as Zv, FONT_FAMILY_COMPONENT as Gv, FONT_FAMILY_ITEM_COMPONENT as qv, IDialogService as Ao, ICanvasPopupService as Kv, ContextMenuGroup as Ke, RibbonPosition as Qv, RibbonStartGroup as ts, IShortcutService as Vl, IUIPartsService as kl, BuiltInUIPart as Zi, connectInjector as qr, IZenZoneService as $h, RectPopup as Jv, UniverMobileUIPlugin as $v } from "@univerjs/ui"; import { forwardRef as dt, useRef as Tn, createElement as st, useState as re, useMemo as wt, useEffect as Me, useCallback as On, useLayoutEffect as eS } from "react"; import { BehaviorSubject as Ee, Subject as xe, of as Ie, merge as St, map as Be, startWith as xt, switchMap as at, takeUntil as ri, distinctUntilChanged as un, throttleTime as ys, EMPTY as Ru, filter as Ho, combineLatest as ct, combineLatestWith as rr, Observable as je, Subscription as qn, withLatestFrom as tS, shareReplay as Iu } from "rxjs"; import { SELECTION_CONTROL_BORDER_BUFFER_WIDTH as Ms, SELECTION_CONTROL_BORDER_BUFFER_COLOR as ns, SELECTIONS_ENABLED as zr, REF_SELECTIONS_ENABLED as to, SheetSkeletonService as nS, SheetsSelectionsService as $, SheetInterceptorService as vn, MarkDirtyRowAutoHeightMutation as eg, CancelMarkDirtyRowAutoHeightMutation as tg, getSheetCommandTarget as Ue, SetWorksheetRowAutoHeightMutationFactory as ng, SetWorksheetRowAutoHeightMutation as Jn, rangeToDiscreteRange as Gi, SetSelectionsOperation as Te, SetRangeValuesMutation as be, generateNullCellValue as rS, SetRangeValuesUndoMutationFactory as en, BEFORE_CELL_EDIT as iS, SetRangeValuesCommand as Nl, SetWorksheetActiveOperation as nt, MoveRangeMutation as $n, RemoveRowMutation as Vo, RemoveColMutation as ko, InsertRowMutation as No, InsertColMutation as Do, MoveRowsMutation as Dl, MoveColsMutation as Ll, SetWorksheetColWidthMutation as an, SetWorksheetRowHeightMutation as no, RemoveSheetMutation as An, RemoveMergeUndoMutationFactory as Wl, RemoveWorksheetMergeMutation as Kt, AddWorksheetMergeMutation as Qt, getAddMergeMutationRangeByType as Bl, AddMergeUndoMutationFactory as Fl, WorkbookEditablePermission as K, WorksheetEditPermission as te, UnitAction as ro, alignToMergedCellsBorders as En, getSelectionsService as Lo, SelectionMoveType as Ut, getCellAtRowCol as ms, expandToContinuousRange as oS, ScrollToCellOperation as hd, SetWorksheetShowCommand as gd, WorksheetProtectionRuleModel as ft, RangeProtectionRuleModel as $e, RangeProtectionCache as Wo, WorksheetViewPermission as rg, SetWorksheetOrderMutation as md, InsertSheetMutation as Mr, SetWorksheetNameMutation as fd, SetWorksheetHideMutation as er, SetWorksheetActivateCommand as pd, WorkbookManageCollaboratorPermission as ig, WorkbookRenameSheetPermission as og, SetWorksheetOrderCommand as sS, SetWorksheetNameCommand as lS, SetTabColorMutation as aS, WorkbookCreateSheetPermission as sg, InsertSheetCommand as cS, ClearSelectionFormatCommand as qi, COMMAND_LISTENER_SKELETON_CHANGE as Es, adjustRangeOnMutation as dS, getPrimaryForRange as lg, SetRowHiddenCommand as ag, SetColHiddenCommand as cg, SetBoldCommand as vd, SetItalicCommand as Sd, SetUnderlineCommand as Cd, SetStrikeThroughCommand as wd, SetFontSizeCommand as _d, SetFontFamilyCommand as bd, SetTextColorCommand as dg, SetFrozenMutationFactory as ug, SetFrozenMutation as fr, RangeProtectionPermissionEditPoint as ie, IExclusiveRangeService as uS, CancelFrozenCommand as fs, SetWorksheetRowIsAutoHeightCommand as Rd, WorksheetSetRowStylePermission as Er, SetRowHeightCommand as hg, SetRowHiddenMutation as gg, SetRowVisibleMutation as mg, SetSelectedRowsVisibleCommand as fg, WorksheetSetCellStylePermission as Ze, WorksheetSetCellValuePermission as qt, WorksheetSetColumnStylePermission as Tr, SetColWidthCommand as pg, SetColHiddenMutation as vg, SetColVisibleMutation as Sg, SetSelectedColsVisibleCommand as Cg, SetTextRotationCommand as pc, SetTextWrapCommand as vc, SetVerticalTextAlignCommand as Sc, SetHorizontalTextAlignCommand as Cc, ResetBackgroundColorCommand as wg, SetBackgroundColorCommand as Ts, WorksheetCopyPermission as Ps, RangeProtectionPermissionViewPoint as wc, WorkbookCopyPermission as Xi, SetWorksheetRowIsAutoHeightMutation as hS, SetFrozenCommand as gS, InsertRangeMoveDownCommand as _c, InsertRangeMoveRightCommand as bc, InsertRowCommand as mS, InsertColCommand as fS, MoveColsCommand as _g, MoveRowsCommand as bg, RemoveColCommand as Rg, RemoveRowCommand as Ig, MergeCellController as pS, MERGE_CELL_INTERCEPTOR_CHECK as vS, DeltaRowHeightCommand as SS, DeltaColumnWidthCommand as CS, COMMAND_LISTENER_VALUE_CHANGE as wS, AddMergeRedoSelectionsOperationFactory as _S, AddMergeUndoSelectionsOperationFactory as bS, DeleteRangeMoveLeftCommand as yu, DeleteRangeMoveUpCommand as Mu, EditStateEnum as cn, ViewStateEnum as ii, UnitObject as Vt, DeleteWorksheetProtectionCommand as xs, DeleteRangeProtectionMutation as Eu, AddRangeProtectionMutation as RS, RemoveSheetCommand as IS, AddWorksheetProtectionCommand as yg, BorderStyleManagerService as Rc, RefRangeService as yS, IRefSelectionsService as Id, SCOPE_WORKBOOK_VALUE_DEFINED_NAME as Ic, InsertDefinedNameCommand as MS, SetDefinedNameCommand as ES, RemoveDefinedNameCommand as TS, SetBorderBasicCommand as yc, ClearSelectionAllCommand as zi, ClearSelectionContentCommand as pr, WorksheetDeleteRowPermission as PS, WorksheetDeleteColumnPermission as xS, ToggleGridlinesCommand as Mg, ToggleGridlinesMutation as OS, InsertMultiRowsAfterCommand as Eg, WorksheetInsertRowPermission as Bo, InsertMultiRowsAboveCommand as Tg, InsertMultiColsRightCommand as Pg, InsertMultiColsLeftCommand as xg, InsertColBeforeCommand as Og, WorksheetInsertColumnPermission as Ag, InsertRowBeforeCommand as Hg, RemoveWorksheetMergeCommand as Vg, WorkbookCreateProtectPermission as Ul, WorksheetDeleteProtectionPermission as kg, WorksheetManageCollaboratorPermission as AS, SetWorksheetHideCommand as Ng, SetTabColorCommand as Dg, CopySheetCommand as Lg, WorkbookDeleteSheetPermission as HS, WorkbookHideSheetPermission as Wg, AddWorksheetMergeCommand as VS, AddWorksheetMergeHorizontalCommand as kS, AddWorksheetMergeVerticalCommand as NS, AddWorksheetMergeAllCommand as DS, ResetTextColorCommand as LS, MoveRangeCommand as Bg, MAX_CELL_PER_SHEET_KEY as WS, INTERCEPTOR_POINT as BS, SheetPermissionCheckController as yd, INumfmtService as FS, SetProtectionCommand as US, AddRangeProtectionCommand as XS, setEndForRange as zS, baseProtectionActions as jS, DeleteRangeProtectionCommand as YS, WorksheetProtectionPointModel as ZS, SetWorksheetPermissionPointsCommand as GS, getAllWorksheetPermissionPoint as qS, convertSelectionDataToRange as Fg, UniverSheetsPlugin as Ug, RefSelectionsService as Xg, ToggleCellCheckboxCommand as KS, SheetPermissionInitController as QS, SetSpecificRowsVisibleCommand as JS, SetSpecificColsVisibleCommand as $S } from "@univerjs/sheets"; import { DocSkeletonManagerService as Kn, DocSelectionManagerService as Md, RichTextEditingMutation as io, SetTextSelectionsOperation as Fo } from "@univerjs/docs"; import { IDefinedNamesService as Uo, FUNCTION_NAMES_STATISTICAL as Xe, FUNCTION_NAMES_MATH as Xl, FUNCTION_NAMES_TEXT as eC, sequenceNodeType as Ra, matchToken as zg, LexerTreeBuilder as jg, IFunctionService as Yg, SetFormulaCalculationNotificationMutation as tC, operatorToken as Fr, isReferenceStrings as Zg, isReferenceStringWithEffectiveColumn as nC, serializeRangeWithSheet as Gg, NullValueObject as Tu, serializeRange as qg, deserializeRangeWithSheet as Kg } from "@univerjs/engine-formula"; import { isTextFormat as zl } from "@univerjs/engine-numfmt"; import { jsx as w, jsxs as q, Fragment as tr } from "react/jsx-runtime"; import { DropdownMenu as Ed, clsx as He, borderClassName as _i, borderBottomClassName as Td, scrollbarClassName as jl, borderRightClassName as Pd, Dropdown as Mc, Button as zt, DropdownLegacy as rC, Tooltip as Yn, MessageType as Qg, InputNumber as iC, Separator as oC, ColorPicker as Jg, Input as Os, RadioGroup as Ec, Radio as jr, Select as $g, Confirm as sC, FormLayout as As, Avatar as xd, Switch as lC, CascaderList as aC, DatePanel as cC, borderTopClassName as dC } from "@univerjs/design"; import { startWith as Ia, shareReplay as Pu, switchMap as Pn, map as pn, debounceTime as Yl, filter as em } from "rxjs/operators"; import { ITelemetryService as uC } from "@univerjs/telemetry"; function Od(r, e) { if (r == null) return; const t = e.getRenderById(r); if (t == null) return; const { mainComponent: n, scene: i, engine: o, components: s } = t, l = n, a = s.get(Tp.BACKGROUND); return { document: l, docBackground: a, scene: i, engine: o }; } const Tc = [10, 400], tm = "RANGE_SELECTOR_COMPONENT_KEY", Ad = "EMBEDDING_FORMULA_EDITOR_COMPONENT_KEY"; var Ye = /* @__PURE__ */ ((r) => (r.MAIN = "__SpreadsheetRender__", r.ROW = "__SpreadsheetRowHeader__", r.COLUMN = "__SpreadsheetColumnHeader__", r.LEFT_TOP = "__SpreadsheetLeftTopPlaceholder__", r))(Ye || {}); const xu = 0, Hs = 1, nr = 10, hC = 11, Ou = 12, Hd = { id: "sheet.command.set-row-header-width", type: Q.COMMAND, handler: async (r, e) => { if (!e) return !1; const t = r.get(Ce); if (!t) return !1; const { unitId: n, subUnitId: i, size: o } = e, s = t.getRenderById(n); if (s) { t.getRenderById(n).with(he).setRowHeaderSize(s, i, o); const { components: a } = s, c = a.get(Ye.ROW); c && c.setCustomHeader({ headerStyle: { size: o } }); } return !0; } }, Vd = { id: "sheet.command.set-col-header-height", type: Q.COMMAND, handler: async (r, e) => { if (!e) return !1; const t = r.get(Ce); if (!t) return !1; const { unitId: n, subUnitId: i, size: o } = e, s = t.getRenderById(n); if (s) { t.getRenderById(n).with(he).setColumnHeaderSize(s, i, o); const { components: a } = s, c = a.get(Ye.COLUMN); c && c.setCustomHeader({ headerStyle: { size: o } }); } return !0; } }, Pc = kn("rangeMovePermissionCheck"), xc = kn("rangeFillPermissionCheck"); var nm = /* @__PURE__ */ ((r) => (r[r.FORMULA_EDITOR_SHOW = 100] = "FORMULA_EDITOR_SHOW", r[r.MARK_SELECTION = 1e4] = "MARK_SELECTION", r))(nm || {}); function Sr(r) { const e = r.getColorFromTheme("primary.600"), t = r.getColorFromTheme("white"), n = new xn(e).setAlpha(0.07).toRgbString(); return { strokeWidth: 1, stroke: e, fill: n, // widgets: { tl: true, tc: true, tr: true, ml: true, mr: true, bl: true, bc: true, br: true }, widgets: {}, widgetSize: 6, widgetStrokeWidth: 1, widgetStroke: t, autofillSize: 6, autofillStrokeWidth: 1, autofillStroke: t, rowHeaderFill: n, rowHeaderStroke: e, rowHeaderStrokeWidth: 1, columnHeaderFill: n, columnHeaderStroke: e, columnHeaderStrokeWidth: 1, expandCornerSize: 40 }; } class gC { constructor() { b(this, "_startColumn", -1); b(this, "_startRow", -1); b(this, "_endColumn", -1); b(this, "_endRow", -1); b(this, "_startX", 0); b(this, "_startY", 0); b(this, "_endX", 0); b(this, "_endY", 0); /** * The highlight cell of a selection. aka: current cell */ b(this, "_primary"); b(this, "_rangeType", X.NORMAL); } get startColumn() { return this._startColumn; } get startRow() { return this._startRow; } get endColumn() { return this._endColumn; } get endRow() { return this._endRow; } get startX() { return this._startX; } get startY() { return this._startY; } get endX() { return this._endX; } get endY() { return this._endY; } get currentCell() { return this._primary; } get rangeType() { return this._rangeType; } /** * @deprecated, Duplicate with `Rectangle` */ isEqual(e) { const { startColumn: t, startRow: n, endColumn: i, endRow: o } = this, { startColumn: s, startRow: l, endColumn: a, endRow: c } = e; return t === s && n === l && i === a && o === c; } highlightToSelection() { if (this._primary) return bs(this._primary); } getRange() { return { startColumn: this._startColumn, startRow: this._startRow, endColumn: this._endColumn, endRow: this._endRow, startX: this._startX, startY: this._startY, endX: this._endX, endY: this._endY, rangeType: this.rangeType }; } getCell() { return this._primary; } getRangeType() { return this._rangeType; } setRangeType(e) { this._rangeType = e; } getValue() { return { rangeWithCoord: this.getRange(), primaryWithCoord: this._primary }; } setValue(e, t) { const { startColumn: n, startRow: i, endColumn: o, endRow: s, startX: l, startY: a, endX: c, endY: d, rangeType: u } = e; this._startColumn = n, this._startRow = i, this._endColumn = o, this._endRow = s, this._startX = l, this._startY = a, this._endX = c, this._endY = d, u !== void 0 && (this._rangeType = u), t !== void 0 && this.setCurrentCell(t); } /** * Set primary cell. * @TODO lumixraku there are 3 concepts for same thing, primary and current and highlight * highlight is best. primary sometimes means the actual cell(actual means ignore merge) * @param currentCell */ setCurrentCell(e) { this._primary = e; } clearCurrentCell() { this._primary = null; } } function oo(r, e) { const { startRow: t, startColumn: n, endRow: i, endColumn: o, rangeType: s } = e, l = i < t ? i : t, a = i < t ? t : i, c = o < n ? o : n, d = o < n ? n : o, u = r.getNoMergeCellWithCoordByIndex(l, c), h = r.getNoMergeCellWithCoordByIndex(a, d); return { startRow: t, startColumn: n, endRow: i, endColumn: o, rangeType: s, startY: (u == null ? void 0 : u.startY) || 0, endY: (h == null ? void 0 : h.endY) || 0, startX: (u == null ? void 0 : u.startX) || 0, endX: (h == null ? void 0 : h.endX) || 0 }; } function Pt(r, e) { const { range: t, primary: n, style: i } = r, o = oo(e, t), s = n && Vs(e, n); return { rangeWithCoord: o, primaryWithCoord: s, style: i }; } function Vs(r, e) { const { actualRow: t, actualColumn: n, isMerged: i, isMergedMainCell: o, startRow: s, startColumn: l, endRow: a, endColumn: c } = e, d = r.getNoMergeCellWithCoordByIndex(t, n), u = r.getNoMergeCellWithCoordByIndex(s, l), h = r.getNoMergeCellWithCoordByIndex(a, c); return { actualRow: t, actualColumn: n, isMerged: i, isMergedMainCell: o, startX: d.startX, startY: d.startY, endX: d.endX, endY: d.endY, mergeInfo: { startRow: s, startColumn: l, endRow: a, endColumn: c, startY: (u == null ? void 0 : u.startY) || 0, endY: (h == null ? void 0 : h.endY) || 0, startX: (u == null ? void 0 : u.startX) || 0, endX: (h == null ? void 0 : h.endX) || 0 } }; } const Au = "__SpreadsheetHelperSelectionTempRect", mC = 35; class fC { constructor(e, t) { b(this, "_startOffsetX", 0); b(this, "_startOffsetY", 0); b(this, "_relativeSelectionPositionRow", 0); b(this, "_relativeSelectionPositionColumn", 0); b(this, "_relativeSelectionRowLength", 0); b(this, "_relativeSelectionColumnLength", 0); b(this, "_scenePointerMoveSub"); b(this, "_scenePointerUpSub"); b(this, "_disabled", !1); /** * The shadow selection under cursor when move whole selection control(for moving normal selection) */ b(this, "_helperSelection"); b(this, "_scrollTimer"); b(this, "_activeViewport"); b(this, "_targetSelection", { startY: 0, endY: 0, startX: 0, endX: 0, startRow: -1, endRow: -1, startColumn: -1, endColumn: -1 }); b(this, "_isInMergeState", !1); b(this, "_fillControlColors", []); b(this, "_skeleton"); b(this, "_scene"); b(this, "_themeService"); b(this, "_injector"); b(this, "_selectionHooks"); this._control = e, this._skeleton = t.skeleton, this._scene = t.scene, this._themeService = t.themeService, this._injector = t.injector, this._selectionHooks = t.selectionHooks, this._initialControl(), this._initialWidget(), this._initialAutoFill(), this._control.dispose$.subscribe(() => { this.dispose(); }); } get isHelperSelection() { return this._control.isHelperSelection; } dispose() { var e, t; (e = this._scrollTimer) == null || e.dispose(), this._fillControlColors = [], this._clearObserverEvent(), (t = this._helperSelection) == null || t.dispose(); } setDisabled(e) { this._disabled = e; } _getFreeze() { var t, n; return (n = (t = od( x.UNIVER_SHEET, he, this._injector.get(N), this._injector.get(Ce) )) == null ? void 0 : t.getCurrentParam()) == null ? void 0 : n.skeleton.getWorksheetConfig().freeze; } _isSelectionInViewport(e, t) { const n = this._getFreeze() || { startRow: -1, startColumn: -1 }; switch (t.viewportKey) { case U.VIEW_MAIN: return e.endRow >= n.startRow && e.endColumn >= n.startColumn; case U.VIEW_MAIN_TOP: case U.VIEW_COLUMN_RIGHT: return e.endColumn >= n.startColumn && e.startRow < n.startRow; case U.VIEW_MAIN_LEFT: case U.VIEW_ROW_BOTTOM: return e.endRow >= n.startRow && e.startColumn < n.startColumn; case U.VIEW_MAIN_LEFT_TOP: case U.VIEW_COLUMN_LEFT: case U.VIEW_ROW_TOP: case U.VIEW_LEFT_TOP: return e.startRow < n.startRow && e.startColumn < n.startColumn; } } _clearObserverEvent() { var e, t; (e = this._scenePointerMoveSub) == null || e.unsubscribe(), (t = this._scenePointerUpSub) == null || t.unsubscribe(), this._scenePointerMoveSub = null, this._scenePointerUpSub = null; } _initialControl() { const { leftControl: e, rightControl: t, topControl: n, bottomControl: i } = this._control; [e, t, n, i].forEach((o) => { o.onPointerEnter$.subscribeEvent(() => { var l; ((l = this._injector.get(lt, uc.OPTIONAL)) == null ? void 0 : l.interceptor.fetchThroughInterceptors(Pc)(!1, null)) !== !1 && o.setCursor(ye.MOVE); }), o.onPointerLeave$.subscribeEvent(() => { o.resetCursor(); }), o.onPointerDown$.subscribeEvent(this._controlPointerDownHandler.bind(this)); }); } /** * Move the whole selection control after cursor turn into move state. * NOT same as widgetMoving, that's for 8 control points. * @param moveOffsetX * @param moveOffsetY */ _controlMoving(e, t) { var E; const n = this._scene, i = n.getScrollXYInfoByViewport(Ve.FromArray([e, t])), { scaleX: o, scaleY: s } = n.getAncestorScale(), l = this._skeleton.getCellIndexByOffset( e, t, o, s, i ), { row: a, column: c } = l, d = this._skeleton.getRowCount() - 1, u = this._skeleton.getColumnCount() - 1; let h = Math.max(0, a + this._relativeSelectionPositionRow), g = h + this._relativeSelectionRowLength; g > d && (g = d, g - h < this._relativeSelectionRowLength && (h = g - this._relativeSelectionRowLength)); let m = Math.max(0, c + this._relativeSelectionPositionColumn), f = m + this._relativeSelectionColumnLength; f > u && (f = u, f - m < this._relativeSelectionColumnLength && (m = f - this._relativeSelectionColumnLength)); const v = this._skeleton.worksheet.getCellInfoInMergeData(h, m), C = Pt({ range: { startRow: h, endRow: g, startColumn: m, endColumn: f }, primary: v, style: null }, this._skeleton), _ = this._skeleton.getNoMergeCellWithCoordByIndex(h, m), S = this._skeleton.getNoMergeCellWithCoordByIndex(g, f), I = (_ == null ? void 0 : _.startY) || 0, R = (S == null ? void 0 : S.endY) || 0, y = (_ == null ? void 0 : _.startX) || 0, M = (S == null ? void 0 : S.endX) || 0; (E = this._helperSelection) == null || E.transformByState({ left: y, top: I, width: M - y, height: R - I }), this._targetSelection = { ...C.rangeWithCoord }, this._control.selectionMoving$.next(C.rangeWithCoord); } /** * Drag move whole selectionControl when cursor turns to crosshair. Not for dragging 8 control points. * @param evt */ _controlPointerDownHandler(e) { const { offsetX: t, offsetY: n } = e, i = this._scene, o = i.getCoordRelativeToViewport(Ve.FromArray([t, n])), { x: s, y: l } = o, a = i.getScrollXYInfoByViewport(o), { scaleX: c, scaleY: d } = i.getAncestorScale(), u = this._skeleton.getCellIndexByOffset( s, l, c, d, a ); this._startOffsetX = s, this._startOffsetY = l; const { row: h, column: g } = u, { startRow: m, startColumn: f, endRow: v, endColumn: p } = this._control.model; let C = 0, _ = 0; h < m ? C -= 1 : h > v && (C += 1), g < f ? _ -= 1 : g > p && (_ += 1), this._relativeSelectionPositionRow = m - h + C, this._relativeSelectionPositionColumn = f - g + _, this._relativeSelectionRowLength = v - m, this._relativeSelectionColumnLength = p - f; const S = this._control.currentStyle, I = this._getScale(); this.isHelperSelection && (this._helperSelection = new we(Au, { stroke: S.stroke, strokeWidth: S.strokeWidth / I }), i.addObject(this._helperSelection)); const R = i.getViewport(U.VIEW_MAIN), y = Gr.create(i); this._scrollTimer = y, y.startScroll(s, l, R), i.disableObjectsEvent(), this._scenePointerMoveSub = i.onPointerMove$.subscribeEvent((M) => { var O; if (this._disabled) return; const { offsetX: E, offsetY: T } = M; if (((O = this._injector.get(lt, uc.OPTIONAL)) == null ? void 0 : O.interceptor.fetchThroughInterceptors(Pc)(!1, null)) === !1) return; const { x: A, y: H } = i.getCoordRelativeToViewport( Ve.FromArray([E, T]) ); this._controlMoving(A, H), i.setCursor(ye.MOVE), y.scrolling(A, H, () => { this._controlMoving(A, H); }); }), this._scenePointerUpSub = i.onPointerUp$.subscribeEvent(() => { var E, T, P, A; (E = this._helperSelection) == null || E.dispose(); const M = this._scene; M.resetCursor(), this._clearObserverEvent(), M.enableObjectsEvent(), (T = this._scrollTimer) == null || T.dispose(), this._control.selectionMoveEnd$.next(this._targetSelection), (A = (P = this._selectionHooks).selectionMoveEnd) == null || A.call(P); }); } _initialWidget() { const { topLeftWidget: e, topCenterWidget: t, topRightWidget: n, middleLeftWidget: i, middleRightWidget: o, bottomLeftWidget: s, bottomCenterWidget: l, bottomRightWidget: a } = this._control, c = [ ye.NORTH_WEST_RESIZE, ye.NORTH_RESIZE, ye.NORTH_EAST_RESIZE, ye.WEST_RESIZE, ye.EAST_RESIZE, ye.SOUTH_WEST_RESIZE, ye.SOUTH_RESIZE, ye.SOUTH_EAST_RESIZE ]; [ e, t, n, i, o, s, l, a ].forEach((d, u) => { d.onPointerEnter$.subscribeEvent(() => { d.setCursor(c[u]); }), d.onPointerLeave$.subscribeEvent(() => { d.resetCursor(); }), d.onPointerDown$.subscribeEvent((h) => { this._widgetPointerDownEvent(h, c[u]); }); }); } /** * Pointer down Events for 8 control point. * @param evt * @param cursor */ _widgetPointerDownEvent(e, t) { const n = this._scene, { offsetX: i, offsetY: o } = e, s = n.getCoordRelativeToViewport(Ve.FromArray([i, o])), { x: l, y: a } = s; this._startOffsetX = i, this._startOffsetY = o; const { startRow: c, startColumn: d, endRow: u, endColumn: h } = this._control.model, g = Math.min(c, u), m = Math.min(d, h), f = Math.max(c, u), v = Math.max(d, h); this._relativeSelectionPositionRow = g, this._relativeSelectionPositionColumn = m, this._relativeSelectionRowLength = f - g, this._relativeSelectionColumnLength = v - m, t === ye.NORTH_WEST_RESIZE ? (this._relativeSelectionPositionRow = f, this._relativeSelectionPositionColumn = v) : t === ye.NORTH_RESIZE ? this._relativeSelectionPositionRow = f : t === ye.NORTH_EAST_RESIZE ? this._relativeSelectionPositionRow = f : t === ye.WEST_RESIZE ? this._relativeSelectionPositionColumn = v : t === ye.SOUTH_WEST_RESIZE ? this._relativeSelectionPositionColumn = v : t === ye.SOUTH_RESIZE && (this._relativeSelectionPositionRow = g); const p = Gr.create(n), C = n.getViewport(U.VIEW_MAIN); p.startScroll(l, a, C), this._scrollTimer = p, n.disableObjectsEvent(), this._scenePointerMoveSub = n.onPointerMove$.subscribeEvent((_) => { const { offsetX: S, offsetY: I } = _, { x: R, y } = n.getCoordRelativeToViewport( Ve.FromArray([S, I]) ); this._widgetMoving(R, y, t), n.setCursor(t), p.scrolling(R, y, () => { this._widgetMoving(R, y, t); }); }), this._scenePointerUpSub = n.onPointerUp$.subscribeEvent(() => { var S, I, R; const _ = this._scene; _.resetCursor(), this._clearObserverEvent(), _.enableObjectsEvent(), (S = this._scrollTimer) == null || S.dispose(), this._control.selectionScaled$.next(this._targetSelection), (R = (I = this._selectionHooks).selectionMoveEnd) == null || R.call(I); }); } /** * Pointer move Events for 8 control point. * @param moveOffsetX * @param moveOffsetY * @param cursor */ _widgetMoving(e, t, n) { const i = this._scene, o = i.getScrollXYInfoByViewport(Ve.FromArray([this._startOffsetX, this._startOffsetY])), { scaleX: s, scaleY: l } = i.getAncestorScale(), a = this._skeleton.getCellIndexByOffset( e, t, s, l, o ), { row: c, column: d } = a; let u = this._relativeSelectionPositionRow, h = this._relativeSelectionPositionColumn, g = c, m = d; n === ye.NORTH_WEST_RESIZE ? (u = c, h = d, g = this._relativeSelectionPositionRow, m = this._relativeSelectionPositionColumn) : n === ye.NORTH_RESIZE ? (u = c, h = this._relativeSelectionPositionColumn, g = this._relativeSelectionPositionRow, m = this._relativeSelectionPositionColumn + this._relativeSelectionColumnLength) : n === ye.NORTH_EAST_RESIZE ? (u = c, h = this._relativeSelectionPositionColumn, g = this._relativeSelectionPositionRow, m = d) : n === ye.WEST_RESIZE ? (u = this._relativeSelectionPositionRow, h = d, g = this._relativeSelectionPositionRow + this._relativeSelectionRowLength, m = this._relativeSelectionPositionColumn) : n === ye.EAST_RESIZE ? g = this._relativeSelectionPositionRow + this._relativeSelectionRowLength : n === ye.SOUTH_WEST_RESIZE ? (u = this._relativeSelectionPositionRow, h = d, g = c, m = this._relativeSelectionPositionColumn) : n === ye.SOUTH_RESIZE && (u = this._relativeSelectionPositionRow, h = this._relativeSelectionPositionColumn, g = c, m = this._relativeSelectionPositionColumn + this._relativeSelectionColumnLength); const f = this._swapPositions(u, h, g, m), v = this._skeleton.getCellWithMergeInfoByIndex(u, h), C = Pt({ range: f, primary: v, style: null }, this._skeleton); this._targetSelection = { ...C.rangeWithCoord }, this._control.updateRangeBySelectionWithCoord(C), this._control.selectionScaling$.next(this._targetSelection); } _initialAutoFill() { const { fillControl: e } = this._control; e.onPointerEnter$.subscribeEvent((t) => { this._injector.get(lt).interceptor.fetchThroughInterceptors(xc)(!1, { x: t.offsetX, y: t.offsetY, skeleton: this._skeleton, scene: this._scene }) && e.setCursor(ye.CROSSHAIR); }), e.onPointerLeave$.subscribeEvent(() => { e.resetCursor(); }), e.onPointerDown$.subscribeEvent(this._autoFillForPointerdown.bind(this)); } // eslint-disable-next-line complexity _autoFillMoving(e, t) { var T, P, A; const n = this._scene, i = n.getViewportScrollXY(this._activeViewport), { scaleX: o, scaleY: s } = n.getAncestorScale(), l = this._skeleton.getCellIndexByOffset( e, t, o, s, i ), { row: a, column: c } = l, d = n.getCoordRelativeToViewport(Ve.FromArray([e, t])), u = this._skeleton.getRowCount() - 1, h = this._skeleton.getColumnCount() - 1; let g = this._relativeSelectionPositionRow, m = this._relativeSelectionPositionColumn, f = this._relativeSelectionPositionRow + this._relativeSelectionRowLength, v = this._relativeSelectionPositionColumn + this._relativeSelectionColumnLength, p = !1, C = !0; if ((c < m || c > v) && a >= g && a <= f) { const H = this._fillRuler( c, m, v, this._relativeSelectionColumnLength, h ); m = H.startRowOrColumn, v = H.endRowOrColumn, p = H.isLighten, C = !1; } else if ((a < g || a > f) && c >= m && c <= v) { const H = this._fillRuler(a, g, f, this._relativeSelectionRowLength, u); g = H.startRowOrColumn, f = H.endRowOrColumn, p = H.isLighten; } else if (Math.abs(this._startOffsetX - d.x - i.x) / 2 > Math.abs(this._startOffsetY - d.y - i.y)) { const H = this._fillRuler( c, m, v, this._relativeSelectionColumnLength, h ); m = H.startRowOrColumn, v = H.endRowOrColumn, p = H.isLighten, C = !1; } else { const H = this._fillRuler(a, g, f, this._relativeSelectionRowLength, u); g = H.startRowOrColumn, f = H.endRowOrColumn, p = H.isLighten; } const _ = this._skeleton.getNoMergeCellWithCoordByIndex(g, m), S = this._skeleton.getNoMergeCellWithCoordByIndex(f, v), I = (_ == null ? void 0 : _.startY) || 0, R = (S == null ? void 0 : S.endY) || 0, y = (_ == null ? void 0 : _.startX) || 0, M = (S == null ? void 0 : S.endX) || 0; p ? this._controlHandler((H, O) => { const V = new xn(this._fillControlColors[O]).lighten(mC).toRgbString(); H.setProps({ fill: V }); }) : this._controlHandler((H, O) => { H.setProps({ fill: this._fillControlColors[O] }); }); const E = Ms / this._getScale(); g === f && C === !0 || m === v && C === !1 ? (T = this._helperSelection) == null || T.hide() : ((P = this._helperSelection) == null || P.transformByState({ left: y - E / 2, top: I - E / 2, width: M - y, height: R - I }), (A = this._helperSelection) == null || A.show()), this._targetSelection = { startY: I, endY: R, startX: y, endX: M, startRow: g, endRow: f, startColumn: m, endColumn: v }, this._control.selectionFilling$.next(this._targetSelection); } _autoFillForPointerdown(e) { const { offsetX: t, offsetY: n } = e, i = this._scene, o = i.getCoordRelativeToViewport(Ve.FromArray([t, n])), { x: s, y: l } = o; this._startOffsetX = s, this._startOffsetY = l; const { startRow: a, startColumn: c, endRow: d, endColumn: u } = this._control.model; this._isInMergeState = this._hasMergeInRange(a, c, d, u), this._relativeSelectionPositionRow = a, this._relativeSelectionPositionColumn = c, this._relativeSelectionRowLength = d - a, this._relativeSelectionColumnLength = u - c; const h = this._control.currentStyle; let g = h == null ? void 0 : h.stroke, m = h == null ? void 0 : h.strokeWidth; const f = Sr(this._themeService); g == null && (g = f.stroke), m == null && (m = f.strokeWidth); const v = this._getScale(); m /= v; const p = Ms / v, C = new xn(g).darken(2).toRgbString(); this.isHelperSelection && (this._helperSelection = new we(Au, { stroke: C, strokeWidth: m + p / 2 }), i.addObject(this._helperSelection)), this._activeViewport = i.getActiveViewportByCoord(Ve.FromArray([t, n])); const _ = i.getViewport(U.VIEW_MAIN), S = Gr.create( i, this._activeViewport.viewportKey === U.VIEW_MAIN ? yt.ALL : yt.NONE ); S.startScroll(s, l, _), this._scrollTimer = S, i.disableObjectsEvent(), this._controlHandler((I) => { this._fillControlColors.push(I.fill); }), this._scenePointerMoveSub = i.onPointerMove$.subscribeEvent((I) => { var H; const { offsetX: R, offsetY: y } = I, M = i.getActiveViewportByCoord(Ve.FromArray([R, y])); if (!this._injector.get(lt).interceptor.fetchThroughInterceptors(xc)(!1, { x: e.offsetX, y: e.offsetY, skeleton: this._skeleton, scene: this._scene })) return; const { x: T, y: P } = i.getCoordRelativeToViewport( Ve.FromArray([R, y]) ); this._autoFillMoving(T, P), i.setCursor(ye.CROSSHAIR); const A = this._targetSelection; if (_ && M && ((H = this._activeViewport) == null ? void 0 : H.viewportKey) !== (M == null ? void 0 : M.viewportKey)) { let O; A.startRow !== a ? (S.scrollTimerType = yt.Y, O = { ...A, endRow: A.startRow }) : A.endRow !== d ? (S.scrollTimerType = yt.Y, O = { ...A, startRow: A.endRow }) : A.startColumn !== c ? (S.scrollTimerType = yt.X, O = { ...A, endColumn: A.startColumn }) : (S.scrollTimerType = yt.X, O = { ...A, startColumn: A.endColumn }), this._isSelectionInViewport(O, M) && (_.scrollToBarPos({ x: S.scrollTimerType === yt.X ? 0 : void 0, y: S.scrollTimerType === yt.Y ? 0 : void 0 }), this._activeViewport = M); } S.scrolling(T, P, () => { this._autoFillMoving(T, P); }); }), this._scenePointerUpSub = i.onPointerUp$.subscribeEvent(() => { var R, y; (R = this._helperSelection) == null || R.dispose(); const I = this._scene; I.resetCursor(), this._clearObserverEvent(), I.enableObjectsEvent(), (y = this._scrollTimer) == null || y.dispose(), this._control.refreshSelectionFilled(this._targetSelection), this._isInMergeState = !1, this._controlHandler((M, E) => { M.setProps({ fill: this._fillControlColors[E] }); }), this._fillControlColors = []; }); } _hasMergeInRange(e, t, n, i) { return this._skeleton.worksheet.getMergedCellRange(e, t, n, i).length > 0; } /** * Make sure startRow < endRow and startColumn < endColumn * * @param startRow * @param startColumn * @param endRow * @param endColumn * @returns {IRange} range */ _swapPositions(e, t, n, i) { const o = Math.min(e, n), s = Math.min(t, i), l = Math.max(e, n), a = Math.max(t, i); return { startRow: o, startColumn: s, endRow: l, endColumn: a }; } _controlHandler(e) { const { leftControl: t, rightControl: n, topControl: i, bottomControl: o, backgroundControlTop: s, backgroundControlMiddleLeft: l, backgroundControlMiddleRight: a, backgroundControlBottom: c, fillControl: d } = this._control, u = [ t, n, i, o, s, l, a, c, d ]; for (let h = 0, g = u.length; h < g; h++) { const m = u[h]; e(m, h); } } _fillRuler(e, t, n, i, o) { let s = !1; if (e < t) if (this._isInMergeState && e < t) { const l = t - e, a = i + 1, c = Math.ceil(l / a); let d = t - c * a; d < 0 && (d = t - (c - 1) * a), t = d; } else t = e; else if (e >= t && e <= n) s = !0, this._isInMergeState || (n = e); else if (this._isInMergeState && e > n) { const l = e - n, a = i + 1, c = Math.ceil(l / a); let d = n + c * a; d > o && (d = n + (c - 1) * a), n = d; } else n = e; return { rowOrColumn: e, startRowOrColumn: t, endRowOrColumn: n, isLighten: s }; } _getScale() { const { scaleX: e, scaleY: t } = this._scene.getAncestorScale(); return Math.max(e, t); } } var Oc = /* @__PURE__ */ ((r) => (r.Selection = "__SpreadsheetSelectionShape__", r.top = "__SpreadsheetSelectionTopControl__", r.bottom = "__SpreadsheetSelectionBottomControl__", r.left = "__SpreadsheetSelectionShapeLeftControl__", r.right = "__SpreadsheetSelectionShapeRightControl__", r.backgroundTop = "__SpreadsheetSelectionBackgroundControlTop__", r.backgroundMiddleLeft = "__SpreadsheetSelectionBackgroundControlMiddleLeft__", r.backgroundMiddleRight = "__SpreadsheetSelectionBackgroundControlMiddleRight__", r.backgroundBottom = "__SpreadsheetSelectionBackgroundControlBottom__", r.fill = "__SpreadsheetSelectionFillControl__", r.fillTopLeft = "__SpreadsheetSelectionFillControlTopLeft__", r.fillBottomRight = "__SpreadsheetSelectionFillControlBottomRight__", r.fillTopLeftInner = "__SpreadsheetSelectionFillControlTopLeftInner__", r.fillBottomRightInner = "__SpreadsheetSelectionFillControlBottomRightInner__", r.lineMain = "__SpreadsheetDragLineMainControl__", r.lineContent = "__SpreadsheetDragLineContentControl__", r.line = "__SpreadsheetDragLineControl__", r.dash = "__SpreadsheetDragDashControl__", r.rowHeaderBackground = "__SpreadSheetSelectionRowHeaderBackground__", r.rowHeaderBorder = "__SpreadSheetSelectionRowHeaderBorder__", r.rowHeaderGroup = "__SpreadSheetSelectionRowHeaderGroup__", r.columnHeaderBackground = "__SpreadSheetSelectionColumnHeaderBackground__", r.columnHeaderBorder = "__SpreadSheetSelectionColumnHeaderBorder__", r.columnHeaderGroup = "__SpreadSheetSelectionColumnHeaderGroup__", r.topLeftWidget = "__SpreadSheetSelectionTopLeftWidget__", r.topCenterWidget = "__SpreadSheetSelectionTopCenterWidget__", r.topRightWidget = "__SpreadSheetSelectionTopRightWidget__", r.middleLeftWidget = "__SpreadSheetSelectionMiddleLeftWidget__", r.middleRightWidget = "__SpreadSheetSelectionMiddleRightWidget__", r.bottomLeftWidget = "__SpreadSheetSelectionBottomLeftWidget__", r.bottomCenterWidget = "__SpreadSheetSelectionBottomCenterWidget__", r.bottomRightWidget = "__SpreadSheetSelectionBottomRightWidget__", r))(Oc || {}); const Hu = 0.3; class kd extends oe { constructor(t, n, i, o) { var s, l, a, c; super(); b(this, "_isHelperSelection", !0); /** * For ref selections, there is no auto fill. */ b(this, "_enableAutoFill", !0); /** * Only normal selections with primary cell has auto fill. * This works for multiple normal selections. Only last selection has primary cell and auto fill. */ b(this, "_showAutoFill", !1); /** * If rowHeader & col Header would be highlighted with selection. */ b(this, "_highlightHeader", !0); b(this, "_selectionRenderModel"); b(this, "_leftBorder"); b(this, "_rightBorder"); b(this, "_topBorder"); b(this, "_bottomBorder"); b(this, "_backgroundControlTop"); b(this, "_backgroundControlBottom"); b(this, "_backgroundControlMiddleLeft"); b(this, "_backgroundControlMiddleRight"); b(this, "_autoFillControl"); b(this, "_selectionShapeGroup"); b(this, "_rowHeaderBackground"); b(this, "_rowHeaderBorder"); b(this, "_rowHeaderGroup"); b(this, "_columnHeaderBackground"); b(this, "_columnHeaderBorder"); b(this, "_columnHeaderGroup"); b(this, "_dashedRect"); // for ref selection b(this, "_topLeftWidget"); b(this, "_topCenterWidget"); b(this, "_topRightWidget"); b(this, "_middleLeftWidget"); b(this, "_middleRightWidget"); b(this, "_bottomLeftWidget"); b(this, "_bottomCenterWidget"); b(this, "_bottomRightWidget"); // why three style prop? what's diff between _selectionStyle & _currentStyle? // protected _selectionStyle: Nullable<ISelectionStyle>; b(this, "_defaultStyle"); b(this, "_currentStyle"); b(this, "_rowHeaderWidth", 0); b(this, "_columnHeaderHeight", 0); b(this, "_widgetRects", []); b(this, "_controlExtension"); b(this, "_dispose$", new Ee(this)); b(this, "dispose$", this._dispose$.asObservable()); /** * eventSource: selectionShapeExtension selectionMoving$.next, * Observer: prompt.controller */ b(this, "selectionMoving$", new xe()); b(this, "selectionMoveEnd$", new xe()); b(this, "selectionScaling$", new xe()); b(this, "selectionScaled$", new xe()); b(this, "selectionFilling$", new xe()); b(this, "_selectionFilled$", new xe()); b(this, "selectionFilled$", this._selectionFilled$.asObservable()); b(this, "_antLineOffset", 0); b(this, "_antRequestNewFrame", -1); this._scene = t, this._zIndex = n, this._themeService = i, this._enableAutoFill = (s = o == null ? void 0 : o.enableAutoFill) != null ? s : !0, this._highlightHeader = (l = o == null ? void 0 : o.highlightHeader) != null ? l : !0, this._rowHeaderWidth = (a = o == null ? void 0 : o.rowHeaderWidth) != null ? a : 0, this._columnHeaderHeight = (c = o == null ? void 0 : o.columnHeaderHeight) != null ? c : 0, this._initializeSheetBody(), this._initialHeader(); } _initializeSheetBody() { this._defaultStyle = Sr(this._themeService), this._currentStyle = Sr(this._themeService), this._selectionRenderModel = new gC(); const t = this._zIndex; this._leftBorder = new we("__SpreadsheetSelectionShapeLeftControl__" + t, { zIndex: t }), this._rightBorder = new we("__SpreadsheetSelectionShapeRightControl__" + t, { zIndex: t }), this._topBorder = new we("__SpreadsheetSelectionTopControl__" + t, { zIndex: t }), this._bottomBorder = new we("__SpreadsheetSelectionBottomControl__" + t, { zIndex: t }), this._backgroundControlTop = new we("__SpreadsheetSelectionBackgroundControlTop__" + t, { zIndex: t - 1, evented: !1 }), this._backgroundControlBottom = new we("__SpreadsheetSelectionBackgroundControlBottom__" + t, { zIndex: t - 1, evented: !1 }), this._backgroundControlMiddleLeft = new we("__SpreadsheetSelectionBackgroundControlMiddleLeft__" + t, { zIndex: t - 1, evented: !1 }), this._backgroundControlMiddleRight = new we("__SpreadsheetSelectionBackgroundControlMiddleRight__" + t, { zIndex: t - 1, evented: !1 }), this._autoFillControl = new we("__SpreadsheetSelectionFillControl__" + t, { zIndex: t + 1 }), this._autoFillControl.hide(), this._dashedRect = new pv("__SpreadsheetDragDashControl__" + t, { zIndex: t + 2, evented: !1, stroke: "#fff" }); const n = [ this._autoFillControl, this._leftBorder, this._rightBorder, this._topBorder, this._bottomBorder, this._backgroundControlTop, this._backgroundControlMiddleLeft, this._backgroundControlMiddleRight, this._backgroundControlBottom, this._dashedRect ]; this._widgetRects = this._initialWidget(), this._selectionShapeGroup = new ba("__SpreadsheetSelectionShape__" + t, ...n, ...this._widgetRects), this._selectionShapeGroup.hide(), this._selectionShapeGroup.evented = !1, this._selectionShapeGroup.zIndex = t; const i = this.getScene(); i.addObject(this._selectionShapeGroup, Hs), this.disposeWithMe( We( i.onTransformChange$.subscribeEvent((o) => { o.type === fc.scale && (this._updateLayoutOfSelectionControl(this._currentStyle), this._updateControlCoord()); }) ) ); } _initialHeader() { const t = this._zIndex; this._rowHeaderBackground = new we("__SpreadSheetSelectionRowHeaderBackground__" + t, { zIndex: t - 1, evented: !1 }), this._rowHeaderBorder = new we("__SpreadSheetSelectionRowHeaderBorder__" + t, { zIndex: t - 1, evented: !1 }), this._rowHeaderGroup = new ba( "__SpreadSheetSelectionRowHeaderGroup__" + t, this._rowHeaderBackground, this._rowHeaderBorder ), this._rowHeaderGroup.hide(), this._rowHeaderGroup.evented = !1, this._rowHeaderGroup.zIndex = t, this._columnHeaderBackground = new we("__SpreadSheetSelectionColumnHeaderBackground__" + t, { zIndex: t - 1, evented: !1 }), this._columnHeaderBorder = new we("__SpreadSheetSelectionColumnHeaderBorder__" + t, { zIndex: t - 1, evented: !1 }), this._columnHeaderGroup = new ba( "__SpreadSheetSelectionColumnHeaderGroup__" + t, this._columnHeaderBackground, this._columnHeaderBorder ), this._columnHeaderGroup.hide(), this._columnHeaderGroup.evented = !1, this._columnHeaderGroup.zIndex = t, this.getScene().addObjects([this._rowHeaderGroup, this._columnHeaderGroup], hC); } _initialWidget() { const t = this._zIndex; return this._topLeftWidget = new we("__SpreadSheetSelectionTopLeftWidget__" + t, { zIndex: t + 1 }), this._topCenterWidget = new we