@univerjs/sheets-crosshair-highlight 0.4.2-nightly.202411071606 → 0.4.2-nightly.202411081606

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
@@ -1,201 +1,264 @@
1
- var __defProp = Object.defineProperty;
2
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value;
3
- var __name = (target, value) => __defProp(target, "name", { value, configurable: !0 });
4
- var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key != "symbol" ? key + "" : key, value);
5
- import { useDependency, useObservable, UniverInstanceType, Inject, Disposable, ICommandService, RANGE_TYPE, Rectangle, IContextService, ColorKit, Plugin, Injector, IConfigService } from "@univerjs/core";
6
- import { Shape, Rect, IRenderManagerService } from "@univerjs/engine-render";
7
- import { MenuItemType, getMenuHiddenObservable, ContextMenuPosition, ContextMenuGroup, ComponentManager, IMenuManagerService } from "@univerjs/ui";
8
- import { S as SheetsCrosshairHighlightService, C as CROSSHAIR_HIGHLIGHT_COLORS, T as ToggleCrosshairHighlightOperation, a as SetCrosshairHighlightColorOperation, E as EnableCrosshairHighlightOperation, D as DisableCrosshairHighlightOperation } from "../operation-8Cu0xxNn.mjs";
9
- import React, { forwardRef, useRef, createElement, useCallback } from "react";
10
- import { SheetSkeletonManagerService, getCoordByCell } from "@univerjs/sheets-ui";
11
- import { SheetsSelectionsService, DISABLE_NORMAL_SELECTIONS, IRefSelectionsService } from "@univerjs/sheets";
12
- import { combineLatest, startWith, tap, merge, map } from "rxjs";
13
- var __assign = function() {
14
- return __assign = Object.assign || function(t) {
15
- for (var s, i = 1, n = arguments.length; i < n; i++) {
16
- s = arguments[i];
17
- for (var p in s) Object.prototype.hasOwnProperty.call(s, p) && (t[p] = s[p]);
1
+ var q = Object.defineProperty;
2
+ var J = (n, e, t) => e in n ? q(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
3
+ var c = (n, e, t) => J(n, typeof e != "symbol" ? e + "" : e, t);
4
+ import { Disposable as M, CommandType as R, useDependency as Q, useObservable as ee, UniverInstanceType as E, Inject as u, ICommandService as te, RANGE_TYPE as f, Rectangle as x, IContextService as re, ColorKit as ne, Plugin as se, Injector as ie, IConfigService as oe } from "@univerjs/core";
5
+ import { Shape as ae, Rect as ce, IRenderManagerService as le } from "@univerjs/engine-render";
6
+ import { MenuItemType as he, getMenuHiddenObservable as ge, ContextMenuPosition as de, ContextMenuGroup as ue, ComponentManager as fe, IMenuManagerService as _e } from "@univerjs/ui";
7
+ import { BehaviorSubject as P, combineLatest as Se, startWith as ve, tap as pe, merge as T, map as V } from "rxjs";
8
+ import { jsx as N } from "react/jsx-runtime";
9
+ import { forwardRef as A, useRef as Ce, createElement as G, useCallback as me } from "react";
10
+ import { SheetSkeletonManagerService as be, getCoordByCell as j } from "@univerjs/sheets-ui";
11
+ import { SheetsSelectionsService as He, DISABLE_NORMAL_SELECTIONS as Re, IRefSelectionsService as Oe } from "@univerjs/sheets";
12
+ var l = function() {
13
+ return l = Object.assign || function(n) {
14
+ for (var e, t = 1, r = arguments.length; t < r; t++) {
15
+ e = arguments[t];
16
+ for (var s in e) Object.prototype.hasOwnProperty.call(e, s) && (n[s] = e[s]);
18
17
  }
19
- return t;
20
- }, __assign.apply(this, arguments);
21
- }, __rest = function(s, e) {
18
+ return n;
19
+ }, l.apply(this, arguments);
20
+ }, Ie = function(n, e) {
22
21
  var t = {};
23
- for (var p in s) Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0 && (t[p] = s[p]);
24
- if (s != null && typeof Object.getOwnPropertySymbols == "function")
25
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++)
26
- e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]) && (t[p[i]] = s[p[i]]);
22
+ for (var r in n) Object.prototype.hasOwnProperty.call(n, r) && e.indexOf(r) < 0 && (t[r] = n[r]);
23
+ if (n != null && typeof Object.getOwnPropertySymbols == "function")
24
+ for (var s = 0, r = Object.getOwnPropertySymbols(n); s < r.length; s++)
25
+ e.indexOf(r[s]) < 0 && Object.prototype.propertyIsEnumerable.call(n, r[s]) && (t[r[s]] = n[r[s]]);
27
26
  return t;
28
- }, IconBase = forwardRef(function(props, ref) {
29
- 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()));
30
- return render(icon, "".concat(id), { defIds: icon.defIds, idSuffix: idSuffix.current }, __assign({ ref, className: cls }, restProps), extend);
27
+ }, U = A(function(n, e) {
28
+ var t = n.icon, r = n.id, s = n.className, i = n.extend, o = Ie(n, ["icon", "id", "className", "extend"]), a = "univerjs-icon univerjs-icon-".concat(r, " ").concat(s || "").trim(), h = Ce("_".concat(Me()));
29
+ return D(t, "".concat(r), { defIds: t.defIds, idSuffix: h.current }, l({ ref: e, className: a }, o), i);
31
30
  });
32
- function render(node, id, runtimeProps, rootProps, extend) {
33
- return createElement(node.tag, __assign(__assign({ key: id }, replaceRuntimeIdsAndExtInAttrs(node, runtimeProps, extend)), rootProps), (replaceRuntimeIdsInDefs(node, runtimeProps).children || []).map(function(child, index) {
34
- return render(child, "".concat(id, "-").concat(node.tag, "-").concat(index), runtimeProps, void 0, extend);
31
+ function D(n, e, t, r, s) {
32
+ return G(n.tag, l(l({ key: e }, ye(n, t, s)), r), (Ee(n, t).children || []).map(function(i, o) {
33
+ return D(i, "".concat(e, "-").concat(n.tag, "-").concat(o), t, void 0, s);
35
34
  }));
36
35
  }
37
- __name(render, "render");
38
- function replaceRuntimeIdsAndExtInAttrs(node, runtimeProps, extend) {
39
- var attrs = __assign({}, node.attrs);
40
- extend != null && extend.colorChannel1 && attrs.fill === "colorChannel1" && (attrs.fill = extend.colorChannel1);
41
- var defIds = runtimeProps.defIds;
42
- return !defIds || defIds.length === 0 || (node.tag === "use" && attrs["xlink:href"] && (attrs["xlink:href"] = attrs["xlink:href"] + runtimeProps.idSuffix), Object.entries(attrs).forEach(function(_a4) {
43
- var key = _a4[0], value = _a4[1];
44
- typeof value == "string" && (attrs[key] = value.replace(/url\(#(.*)\)/, "url(#$1".concat(runtimeProps.idSuffix, ")")));
45
- })), attrs;
36
+ function ye(n, e, t) {
37
+ var r = l({}, n.attrs);
38
+ t != null && t.colorChannel1 && r.fill === "colorChannel1" && (r.fill = t.colorChannel1);
39
+ var s = e.defIds;
40
+ return !s || s.length === 0 || (n.tag === "use" && r["xlink:href"] && (r["xlink:href"] = r["xlink:href"] + e.idSuffix), Object.entries(r).forEach(function(i) {
41
+ var o = i[0], a = i[1];
42
+ typeof a == "string" && (r[o] = a.replace(/url\(#(.*)\)/, "url(#$1".concat(e.idSuffix, ")")));
43
+ })), r;
46
44
  }
47
- __name(replaceRuntimeIdsAndExtInAttrs, "replaceRuntimeIdsAndExtInAttrs");
48
- function replaceRuntimeIdsInDefs(node, runtimeProps) {
49
- var _a4, defIds = runtimeProps.defIds;
50
- return !defIds || defIds.length === 0 ? node : node.tag === "defs" && (!((_a4 = node.children) === null || _a4 === void 0) && _a4.length) ? __assign(__assign({}, node), { children: node.children.map(function(child) {
51
- 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;
52
- }) }) : node;
45
+ function Ee(n, e) {
46
+ var t, r = e.defIds;
47
+ return !r || r.length === 0 ? n : n.tag === "defs" && (!((t = n.children) === null || t === void 0) && t.length) ? l(l({}, n), { children: n.children.map(function(s) {
48
+ return typeof s.attrs.id == "string" && r && r.indexOf(s.attrs.id) > -1 ? l(l({}, s), { attrs: l(l({}, s.attrs), { id: s.attrs.id + e.idSuffix }) }) : s;
49
+ }) }) : n;
53
50
  }
54
- __name(replaceRuntimeIdsInDefs, "replaceRuntimeIdsInDefs");
55
- function generateShortUuid() {
51
+ function Me() {
56
52
  return Math.random().toString(36).substring(2, 8);
57
53
  }
58
- __name(generateShortUuid, "generateShortUuid");
59
- IconBase.displayName = "UniverIcon";
60
- var element = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "#E5E5E5", d: "M1.6499 3.65002C1.6499 2.54545 2.54533 1.65002 3.6499 1.65002H12.3499C13.4545 1.65002 14.3499 2.54545 14.3499 3.65002V12.35C14.3499 13.4546 13.4545 14.35 12.3499 14.35H3.6499C2.54533 14.35 1.6499 13.4546 1.6499 12.35V3.65002Z" } }, { tag: "path", attrs: { fill: "#fff", d: "M9.9998 1.65002H5.9998V6H1.6499V10H5.9998V14.35H9.9998V10H14.3499V6H9.9998V1.65002Z" } }, { tag: "path", attrs: { fill: "currentColor", d: "M3.6498 1.05005C2.21386 1.05005 1.0498 2.21411 1.0498 3.65005V12.35C1.0498 13.786 2.21386 14.95 3.6498 14.95H12.3498C13.7857 14.95 14.9498 13.786 14.9498 12.3501V3.65005C14.9498 2.21411 13.7857 1.05005 12.3498 1.05005H3.6498ZM5.4002 2.25005H3.6498C2.87661 2.25005 2.2498 2.87685 2.2498 3.65005V5.40002H5.4002V2.25005ZM2.2498 10.6V12.35C2.2498 13.1232 2.87661 13.75 3.6498 13.75H5.4002V10.6H2.2498ZM6.60019 13.75H9.4002V9.40002H13.7498V6.60002H9.4002V2.25005H6.60019V6.60002H2.25029V9.40002H6.60019V13.75ZM10.6002 2.25005V5.40002H13.7498V3.65005C13.7498 2.87685 13.123 2.25005 12.3498 2.25005H10.6002ZM13.7498 10.6H10.6002V13.75H12.3498C13.123 13.75 13.7498 13.1232 13.7498 12.3501V10.6Z", fillRule: "evenodd", clipRule: "evenodd" } }] }, CrossHighlightingSingle = forwardRef(function(props, ref) {
61
- return createElement(IconBase, Object.assign({}, props, {
54
+ U.displayName = "UniverIcon";
55
+ var we = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "#E5E5E5", d: "M1.6499 3.65002C1.6499 2.54545 2.54533 1.65002 3.6499 1.65002H12.3499C13.4545 1.65002 14.3499 2.54545 14.3499 3.65002V12.35C14.3499 13.4546 13.4545 14.35 12.3499 14.35H3.6499C2.54533 14.35 1.6499 13.4546 1.6499 12.35V3.65002Z" } }, { tag: "path", attrs: { fill: "#fff", d: "M9.9998 1.65002H5.9998V6H1.6499V10H5.9998V14.35H9.9998V10H14.3499V6H9.9998V1.65002Z" } }, { tag: "path", attrs: { fill: "currentColor", d: "M3.6498 1.05005C2.21386 1.05005 1.0498 2.21411 1.0498 3.65005V12.35C1.0498 13.786 2.21386 14.95 3.6498 14.95H12.3498C13.7857 14.95 14.9498 13.786 14.9498 12.3501V3.65005C14.9498 2.21411 13.7857 1.05005 12.3498 1.05005H3.6498ZM5.4002 2.25005H3.6498C2.87661 2.25005 2.2498 2.87685 2.2498 3.65005V5.40002H5.4002V2.25005ZM2.2498 10.6V12.35C2.2498 13.1232 2.87661 13.75 3.6498 13.75H5.4002V10.6H2.2498ZM6.60019 13.75H9.4002V9.40002H13.7498V6.60002H9.4002V2.25005H6.60019V6.60002H2.25029V9.40002H6.60019V13.75ZM10.6002 2.25005V5.40002H13.7498V3.65005C13.7498 2.87685 13.123 2.25005 12.3498 2.25005H10.6002ZM13.7498 10.6H10.6002V13.75H12.3498C13.123 13.75 13.7498 13.1232 13.7498 12.3501V10.6Z", fillRule: "evenodd", clipRule: "evenodd" } }] }, Z = A(function(n, e) {
56
+ return G(U, Object.assign({}, n, {
62
57
  id: "cross-highlighting-single",
63
- ref,
64
- icon: element
58
+ ref: e,
59
+ icon: we
65
60
  }));
66
61
  });
67
- CrossHighlightingSingle.displayName = "CrossHighlightingSingle";
68
- function r(e) {
69
- var t, f, n = "";
70
- if (typeof e == "string" || typeof e == "number") n += e;
71
- else if (typeof e == "object") if (Array.isArray(e)) {
72
- var o = e.length;
73
- for (t = 0; t < o; t++) e[t] && (f = r(e[t])) && (n && (n += " "), n += f);
74
- } else for (f in e) e[f] && (n && (n += " "), n += f);
75
- return n;
62
+ Z.displayName = "CrossHighlightingSingle";
63
+ const B = [
64
+ "rgba(158, 109, 227, 0.3)",
65
+ "rgba(254, 75, 75, 0.3)",
66
+ "rgba(255, 140, 81, 0.3)",
67
+ "rgba(164, 220, 22, 0.3)",
68
+ "rgba(45, 174, 255, 0.3)",
69
+ "rgba(58, 96, 247, 0.3)",
70
+ "rgba(242, 72, 166, 0.3)",
71
+ "rgba(153, 153, 153, 0.3)",
72
+ "rgba(158, 109, 227, 0.15)",
73
+ "rgba(254, 75, 75, 0.15)",
74
+ "rgba(255, 140, 81, 0.15)",
75
+ "rgba(164, 220, 22, 0.15)",
76
+ "rgba(45, 174, 255, 0.15)",
77
+ "rgba(58, 96, 247, 0.15)",
78
+ "rgba(242, 72, 166, 0.15)",
79
+ "rgba(153, 153, 153, 0.15)"
80
+ ];
81
+ class g extends M {
82
+ constructor() {
83
+ super(...arguments);
84
+ c(this, "_enabled$", new P(!1));
85
+ c(this, "enabled$", this._enabled$.asObservable());
86
+ c(this, "_color$", new P(B[0]));
87
+ c(this, "color$", this._color$.asObservable());
88
+ }
89
+ get enabled() {
90
+ return this._enabled$.getValue();
91
+ }
92
+ get color() {
93
+ return this._color$.getValue();
94
+ }
95
+ dispose() {
96
+ this._enabled$.complete();
97
+ }
98
+ setEnabled(t) {
99
+ this._enabled$.next(t);
100
+ }
101
+ setColor(t) {
102
+ this._color$.next(t);
103
+ }
104
+ }
105
+ const w = {
106
+ id: "sheet.operation.toggle-crosshair-highlight",
107
+ type: R.OPERATION,
108
+ handler(n) {
109
+ const e = n.get(g), t = e.enabled;
110
+ return e.setEnabled(!t), !0;
111
+ }
112
+ }, W = {
113
+ id: "sheet.operation.set-crosshair-highlight-color",
114
+ type: R.OPERATION,
115
+ handler(n, { value: e }) {
116
+ const t = n.get(g);
117
+ return t.enabled || t.setEnabled(!0), t.setColor(e), !0;
118
+ }
119
+ }, $e = {
120
+ id: "sheet.operation.enable-crosshair-highlight",
121
+ type: R.OPERATION,
122
+ handler(n) {
123
+ const e = n.get(g);
124
+ return e.enabled ? !1 : (e.setEnabled(!0), !0);
125
+ }
126
+ }, xe = {
127
+ id: "sheet.operation.disable-crosshair-highlight",
128
+ type: R.OPERATION,
129
+ handler(n) {
130
+ const e = n.get(g);
131
+ return e.enabled ? (e.setEnabled(!1), !0) : !1;
132
+ }
133
+ };
134
+ function Y(n) {
135
+ var e, t, r = "";
136
+ if (typeof n == "string" || typeof n == "number") r += n;
137
+ else if (typeof n == "object") if (Array.isArray(n)) {
138
+ var s = n.length;
139
+ for (e = 0; e < s; e++) n[e] && (t = Y(n[e])) && (r && (r += " "), r += t);
140
+ } else for (t in n) n[t] && (r && (r += " "), r += t);
141
+ return r;
76
142
  }
77
- __name(r, "r");
78
- function clsx() {
79
- for (var e, t, f = 0, n = "", o = arguments.length; f < o; f++) (e = arguments[f]) && (t = r(e)) && (n && (n += " "), n += t);
80
- return n;
143
+ function Pe() {
144
+ for (var n, e, t = 0, r = "", s = arguments.length; t < s; t++) (n = arguments[t]) && (e = Y(n)) && (r && (r += " "), r += e);
145
+ return r;
81
146
  }
82
- __name(clsx, "clsx");
83
- const crosshairHighlightOverlay = "univer-crosshair-highlight-overlay", crosshairHighlightItem = "univer-crosshair-highlight-item", crosshairHighlightItemSelected = "univer-crosshair-highlight-item-selected", styles = {
84
- crosshairHighlightOverlay,
85
- crosshairHighlightItem,
86
- crosshairHighlightItemSelected
147
+ const Te = "univer-crosshair-highlight-overlay", Ve = "univer-crosshair-highlight-item", Ne = "univer-crosshair-highlight-item-selected", O = {
148
+ crosshairHighlightOverlay: Te,
149
+ crosshairHighlightItem: Ve,
150
+ crosshairHighlightItemSelected: Ne
87
151
  };
88
- function CrosshairOverlay(props) {
89
- const { onChange } = props, crosshairSrv = useDependency(SheetsCrosshairHighlightService), currentColor = useObservable(crosshairSrv.color$), handleColorPicked = useCallback((color) => {
90
- onChange == null || onChange(color);
91
- }, [onChange]);
92
- return /* @__PURE__ */ React.createElement("div", { className: styles.crosshairHighlightOverlay }, CROSSHAIR_HIGHLIGHT_COLORS.map((color) => /* @__PURE__ */ React.createElement(
152
+ function je(n) {
153
+ const { onChange: e } = n, t = Q(g), r = ee(t.color$), s = me((i) => {
154
+ e == null || e(i);
155
+ }, [e]);
156
+ return /* @__PURE__ */ N("div", { className: O.crosshairHighlightOverlay, children: B.map((i) => /* @__PURE__ */ N(
93
157
  "div",
94
158
  {
95
- key: color,
96
- className: clsx(styles.crosshairHighlightItem, {
97
- [styles.crosshairHighlightItemSelected]: color === currentColor
159
+ className: Pe(O.crosshairHighlightItem, {
160
+ [O.crosshairHighlightItemSelected]: i === r
98
161
  }),
99
- style: { backgroundColor: color },
100
- onClick: /* @__PURE__ */ __name(() => handleColorPicked(color), "onClick")
101
- }
102
- )));
162
+ style: { backgroundColor: i },
163
+ onClick: () => s(i)
164
+ },
165
+ i
166
+ )) });
103
167
  }
104
- __name(CrosshairOverlay, "CrosshairOverlay");
105
- const CROSSHAIR_HIGHLIGHT_OVERLAY_COMPONENT = "CROSSHAIR_HIGHLIGHT_OVERLAY_COMPONENT";
106
- function CrosshairHighlightMenuItemFactory(accessor) {
107
- const crosshairHighlightService = accessor.get(SheetsCrosshairHighlightService);
168
+ const k = "CROSSHAIR_HIGHLIGHT_OVERLAY_COMPONENT";
169
+ function Le(n) {
170
+ const e = n.get(g);
108
171
  return {
109
- id: ToggleCrosshairHighlightOperation.id,
172
+ id: w.id,
110
173
  tooltip: "crosshair.button.tooltip",
111
- type: MenuItemType.BUTTON_SELECTOR,
174
+ type: he.BUTTON_SELECTOR,
112
175
  icon: "CrossHighlightingSingle",
113
176
  selections: [
114
177
  {
115
178
  label: {
116
- name: CROSSHAIR_HIGHLIGHT_OVERLAY_COMPONENT,
179
+ name: k,
117
180
  hoverable: !1
118
181
  }
119
182
  }
120
183
  ],
121
- selectionsCommandId: SetCrosshairHighlightColorOperation.id,
122
- activated$: crosshairHighlightService.enabled$,
123
- hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_SHEET)
184
+ selectionsCommandId: W.id,
185
+ activated$: e.enabled$,
186
+ hidden$: ge(n, E.UNIVER_SHEET)
124
187
  };
125
188
  }
126
- __name(CrosshairHighlightMenuItemFactory, "CrosshairHighlightMenuItemFactory");
127
- const menuSchema = {
128
- [ContextMenuPosition.FOOTER_MENU]: {
129
- [ContextMenuGroup.OTHERS]: {
130
- [ToggleCrosshairHighlightOperation.id]: {
189
+ const Ae = {
190
+ [de.FOOTER_MENU]: {
191
+ [ue.OTHERS]: {
192
+ [w.id]: {
131
193
  order: 0,
132
- menuItemFactory: CrosshairHighlightMenuItemFactory
194
+ menuItemFactory: Le
133
195
  }
134
196
  }
135
197
  }
136
198
  };
137
- var __defProp$2 = Object.defineProperty, __getOwnPropDesc$2 = Object.getOwnPropertyDescriptor, __decorateClass$2 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
138
- for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$2(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
139
- (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
140
- return kind && result && __defProp$2(target, key, result), result;
141
- }, "__decorateClass$2"), __decorateParam$2 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$2"), _a;
142
- let SheetsCrosshairHighlightController = (_a = class extends Disposable {
143
- constructor(_componentMgr, _menuManagerService, _cmdSrv) {
144
- super(), this._componentMgr = _componentMgr, this._menuManagerService = _menuManagerService, this._cmdSrv = _cmdSrv, this._initCommands(), this._initMenus(), this._initComponents();
199
+ var Ge = Object.defineProperty, Ue = Object.getOwnPropertyDescriptor, De = (n, e, t, r) => {
200
+ for (var s = r > 1 ? void 0 : r ? Ue(e, t) : e, i = n.length - 1, o; i >= 0; i--)
201
+ (o = n[i]) && (s = (r ? o(e, t, s) : o(s)) || s);
202
+ return r && s && Ge(e, t, s), s;
203
+ }, I = (n, e) => (t, r) => e(t, r, n);
204
+ let b = class extends M {
205
+ constructor(n, e, t) {
206
+ super(), this._componentMgr = n, this._menuManagerService = e, this._cmdSrv = t, this._initCommands(), this._initMenus(), this._initComponents();
145
207
  }
146
208
  _initCommands() {
147
209
  [
148
- ToggleCrosshairHighlightOperation,
149
- SetCrosshairHighlightColorOperation,
150
- EnableCrosshairHighlightOperation,
151
- DisableCrosshairHighlightOperation
152
- ].forEach((c) => this._cmdSrv.registerCommand(c));
210
+ w,
211
+ W,
212
+ $e,
213
+ xe
214
+ ].forEach((n) => this._cmdSrv.registerCommand(n));
153
215
  }
154
216
  _initMenus() {
155
- this._menuManagerService.mergeMenu(menuSchema);
217
+ this._menuManagerService.mergeMenu(Ae);
156
218
  }
157
219
  _initComponents() {
158
- this._componentMgr.register(CROSSHAIR_HIGHLIGHT_OVERLAY_COMPONENT, CrosshairOverlay), this._componentMgr.register("CrossHighlightingSingle", CrossHighlightingSingle);
159
- }
160
- }, __name(_a, "SheetsCrosshairHighlightController"), _a);
161
- SheetsCrosshairHighlightController = __decorateClass$2([
162
- __decorateParam$2(0, Inject(ComponentManager)),
163
- __decorateParam$2(1, IMenuManagerService),
164
- __decorateParam$2(2, ICommandService)
165
- ], SheetsCrosshairHighlightController);
166
- const SHEETS_CROSSHAIR_HIGHLIGHT_Z_INDEX = 1, _CrossHairRangeCollection = class _CrossHairRangeCollection {
220
+ this._componentMgr.register(k, je), this._componentMgr.register("CrossHighlightingSingle", Z);
221
+ }
222
+ };
223
+ b = De([
224
+ I(0, u(fe)),
225
+ I(1, _e),
226
+ I(2, te)
227
+ ], b);
228
+ const Ze = 1;
229
+ class Be {
167
230
  constructor() {
168
- __publicField(this, "_selectedRanges", []);
169
- __publicField(this, "_ranges", []);
231
+ c(this, "_selectedRanges", []);
232
+ c(this, "_ranges", []);
170
233
  }
171
- addRange(range) {
172
- if (range.rangeType === RANGE_TYPE.COLUMN || range.rangeType === RANGE_TYPE.ROW || range.rangeType === RANGE_TYPE.ALL)
234
+ addRange(e) {
235
+ if (e.rangeType === f.COLUMN || e.rangeType === f.ROW || e.rangeType === f.ALL)
173
236
  return;
174
- const intersects = this._getIntersects(range), splitRanges = this._getSplitRanges(range, intersects);
175
- splitRanges.length > 0 && this._ranges.push(...splitRanges);
176
- }
177
- setSelectedRanges(selectedRange) {
178
- this._selectedRanges = selectedRange;
179
- }
180
- _getSplitRanges(range, intersects) {
181
- let splitRanges = [range];
182
- for (const intersect of intersects.concat(this._selectedRanges)) {
183
- const newRanges = [];
184
- for (const splitRange of splitRanges) {
185
- const split = Rectangle.subtract(splitRange, intersect);
186
- split && split.length > 0 && newRanges.push(...split);
237
+ const t = this._getIntersects(e), r = this._getSplitRanges(e, t);
238
+ r.length > 0 && this._ranges.push(...r);
239
+ }
240
+ setSelectedRanges(e) {
241
+ this._selectedRanges = e;
242
+ }
243
+ _getSplitRanges(e, t) {
244
+ let r = [e];
245
+ for (const s of t.concat(this._selectedRanges)) {
246
+ const i = [];
247
+ for (const o of r) {
248
+ const a = x.subtract(o, s);
249
+ a && a.length > 0 && i.push(...a);
187
250
  }
188
- splitRanges = newRanges;
251
+ r = i;
189
252
  }
190
- return splitRanges.filter((range2) => range2.startRow <= range2.endRow && range2.startColumn <= range2.endColumn);
253
+ return r.filter((s) => s.startRow <= s.endRow && s.startColumn <= s.endColumn);
191
254
  }
192
- _getIntersects(addRange) {
193
- const intersects = [];
194
- for (const range of this._ranges) {
195
- const intersect = Rectangle.getIntersects(range, addRange);
196
- intersect && intersects.push(intersect);
255
+ _getIntersects(e) {
256
+ const t = [];
257
+ for (const r of this._ranges) {
258
+ const s = x.getIntersects(r, e);
259
+ s && t.push(s);
197
260
  }
198
- return intersects;
261
+ return t;
199
262
  }
200
263
  getRanges() {
201
264
  return this._ranges;
@@ -203,187 +266,183 @@ const SHEETS_CROSSHAIR_HIGHLIGHT_Z_INDEX = 1, _CrossHairRangeCollection = class
203
266
  reset() {
204
267
  this._ranges = [], this._selectedRanges = [];
205
268
  }
206
- };
207
- __name(_CrossHairRangeCollection, "CrossHairRangeCollection");
208
- let CrossHairRangeCollection = _CrossHairRangeCollection;
209
- const _SheetCrossHairHighlightShape = class _SheetCrossHairHighlightShape extends Shape {
210
- constructor(key, props) {
211
- super(key, props);
269
+ }
270
+ class We extends ae {
271
+ constructor(t, r) {
272
+ super(t, r);
212
273
  // protected _showHighLight = false;
213
- __publicField(this, "_color");
214
- props && this.setShapeProps(props);
274
+ c(this, "_color");
275
+ r && this.setShapeProps(r);
215
276
  }
216
- setShapeProps(props) {
217
- typeof props.color < "u" && (this._color = props.color), this.transformByState({
218
- width: props.width,
219
- height: props.height
277
+ setShapeProps(t) {
278
+ typeof t.color < "u" && (this._color = t.color), this.transformByState({
279
+ width: t.width,
280
+ height: t.height
220
281
  });
221
282
  }
222
- _draw(ctx) {
223
- const color = `rgba(${this._color.r}, ${this._color.g}, ${this._color.b}, ${this._color.a})`;
224
- Rect.drawWith(ctx, {
283
+ _draw(t) {
284
+ const r = `rgba(${this._color.r}, ${this._color.g}, ${this._color.b}, ${this._color.a})`;
285
+ ce.drawWith(t, {
225
286
  width: this.width,
226
287
  height: this.height,
227
- fill: color,
288
+ fill: r,
228
289
  stroke: void 0,
229
290
  strokeWidth: 0,
230
291
  evented: !1
231
292
  });
232
293
  }
233
- };
234
- __name(_SheetCrossHairHighlightShape, "SheetCrossHairHighlightShape");
235
- let SheetCrossHairHighlightShape = _SheetCrossHairHighlightShape;
236
- var __defProp$1 = Object.defineProperty, __getOwnPropDesc$1 = Object.getOwnPropertyDescriptor, __decorateClass$1 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
237
- for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$1(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
238
- (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
239
- return kind && result && __defProp$1(target, key, result), result;
240
- }, "__decorateClass$1"), __decorateParam$1 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$1"), _a2;
241
- let SheetCrosshairHighlightRenderController = (_a2 = class extends Disposable {
242
- constructor(_context, _sheetSkeletonManagerService, _sheetsSelectionsService, _sheetsCrosshairHighlightService, _contextService, _refSelectionsService) {
294
+ }
295
+ var Ye = Object.defineProperty, ke = Object.getOwnPropertyDescriptor, Fe = (n, e, t, r) => {
296
+ for (var s = r > 1 ? void 0 : r ? ke(e, t) : e, i = n.length - 1, o; i >= 0; i--)
297
+ (o = n[i]) && (s = (r ? o(e, t, s) : o(s)) || s);
298
+ return r && s && Ye(e, t, s), s;
299
+ }, v = (n, e) => (t, r) => e(t, r, n);
300
+ let H = class extends M {
301
+ constructor(e, t, r, s, i, o) {
243
302
  super();
244
- __publicField(this, "_shapes", []);
245
- __publicField(this, "_rangeCollection", new CrossHairRangeCollection());
246
- __publicField(this, "_color", "rgba(255,0,0,0.5)");
247
- this._context = _context, this._sheetSkeletonManagerService = _sheetSkeletonManagerService, this._sheetsSelectionsService = _sheetsSelectionsService, this._sheetsCrosshairHighlightService = _sheetsCrosshairHighlightService, this._contextService = _contextService, this._refSelectionsService = _refSelectionsService, this._initRenderListener();
303
+ c(this, "_shapes", []);
304
+ c(this, "_rangeCollection", new Be());
305
+ c(this, "_color", "rgba(255,0,0,0.5)");
306
+ this._context = e, this._sheetSkeletonManagerService = t, this._sheetsSelectionsService = r, this._sheetsCrosshairHighlightService = s, this._contextService = i, this._refSelectionsService = o, this._initRenderListener();
248
307
  }
249
- _transformSelection(selectionData, sheet) {
250
- if (!selectionData)
308
+ _transformSelection(e, t) {
309
+ if (!e)
251
310
  return;
252
- const rowCount = sheet.getRowCount(), columnCount = sheet.getColumnCount(), ranges = [];
253
- for (const selection of selectionData) {
254
- const { startRow, endRow, startColumn, endColumn } = selection.range;
255
- endRow - startRow + 1 === rowCount || endColumn - startColumn + 1 === columnCount || ranges.push(selection.range);
311
+ const r = t.getRowCount(), s = t.getColumnCount(), i = [];
312
+ for (const o of e) {
313
+ const { startRow: a, endRow: h, startColumn: _, endColumn: S } = o.range;
314
+ h - a + 1 === r || S - _ + 1 === s || i.push(o.range);
256
315
  }
257
- this._rangeCollection.setSelectedRanges(ranges);
258
- for (const range of ranges)
259
- this.addSelection(range, sheet);
316
+ this._rangeCollection.setSelectedRanges(i);
317
+ for (const o of i)
318
+ this.addSelection(o, t);
260
319
  }
261
320
  _initRenderListener() {
262
- const workbook = this._context.unit;
263
- this.disposeWithMe(combineLatest([
264
- this._contextService.subscribeContextValue$(DISABLE_NORMAL_SELECTIONS).pipe(startWith(!1)),
321
+ const e = this._context.unit;
322
+ this.disposeWithMe(Se([
323
+ this._contextService.subscribeContextValue$(Re).pipe(ve(!1)),
265
324
  this._sheetSkeletonManagerService.currentSkeleton$,
266
325
  this._sheetsCrosshairHighlightService.enabled$,
267
- this._sheetsCrosshairHighlightService.color$.pipe(tap((color) => this._color = color)),
268
- merge(
326
+ this._sheetsCrosshairHighlightService.color$.pipe(pe((t) => this._color = t)),
327
+ T(
269
328
  this._sheetsSelectionsService.selectionMoveStart$,
270
329
  this._sheetsSelectionsService.selectionMoving$,
271
330
  this._sheetsSelectionsService.selectionMoveEnd$,
272
- workbook.activeSheet$.pipe(map(() => this._sheetsSelectionsService.getCurrentSelections()))
331
+ e.activeSheet$.pipe(V(() => this._sheetsSelectionsService.getCurrentSelections()))
273
332
  ),
274
- merge(
333
+ T(
275
334
  this._refSelectionsService.selectionMoveStart$,
276
335
  this._refSelectionsService.selectionMoving$,
277
336
  this._refSelectionsService.selectionMoveEnd$,
278
- workbook.activeSheet$.pipe(map(() => this._refSelectionsService.getCurrentSelections()))
337
+ e.activeSheet$.pipe(V(() => this._refSelectionsService.getCurrentSelections()))
279
338
  )
280
- ]).subscribe(([normalSelDisabled, _, enabled, _color, normalSelections, refSelection]) => {
281
- if (this._clear(), !enabled) return;
282
- const selections = normalSelDisabled ? refSelection : normalSelections;
283
- this._rangeCollection.reset(), this._transformSelection(selections, workbook.getActiveSheet()), this.render(this._rangeCollection.getRanges());
339
+ ]).subscribe(([t, r, s, i, o, a]) => {
340
+ if (this._clear(), !s) return;
341
+ const h = t ? a : o;
342
+ this._rangeCollection.reset(), this._transformSelection(h, e.getActiveSheet()), this.render(this._rangeCollection.getRanges());
284
343
  }));
285
344
  }
286
- addSelection(range, sheet) {
287
- if (range.rangeType === RANGE_TYPE.COLUMN || range.rangeType === RANGE_TYPE.ROW || range.rangeType === RANGE_TYPE.ALL)
345
+ addSelection(e, t) {
346
+ if (e.rangeType === f.COLUMN || e.rangeType === f.ROW || e.rangeType === f.ALL)
288
347
  return;
289
- const maxRow = sheet.getRowCount(), maxColumn = sheet.getColumnCount(), { startRow, endRow, startColumn, endColumn } = range, left = {
290
- startRow,
291
- endRow,
348
+ const r = t.getRowCount(), s = t.getColumnCount(), { startRow: i, endRow: o, startColumn: a, endColumn: h } = e, _ = {
349
+ startRow: i,
350
+ endRow: o,
292
351
  startColumn: 0,
293
- endColumn: startColumn - 1
294
- }, right = {
295
- startRow,
296
- endRow,
297
- startColumn: endColumn + 1,
298
- endColumn: maxColumn
299
- }, top = {
352
+ endColumn: a - 1
353
+ }, S = {
354
+ startRow: i,
355
+ endRow: o,
356
+ startColumn: h + 1,
357
+ endColumn: s
358
+ }, p = {
300
359
  startRow: 0,
301
- endRow: startRow - 1,
302
- startColumn,
303
- endColumn
304
- }, bottom = {
305
- startRow: endRow + 1,
306
- endRow: maxRow,
307
- startColumn,
308
- endColumn
360
+ endRow: i - 1,
361
+ startColumn: a,
362
+ endColumn: h
363
+ }, C = {
364
+ startRow: o + 1,
365
+ endRow: r,
366
+ startColumn: a,
367
+ endColumn: h
309
368
  };
310
- for (const range2 of [left, right, top, bottom])
311
- range2.startRow <= range2.endRow && range2.startColumn <= range2.endColumn && this._rangeCollection.addRange(range2);
369
+ for (const d of [_, S, p, C])
370
+ d.startRow <= d.endRow && d.startColumn <= d.endColumn && this._rangeCollection.addRange(d);
312
371
  }
313
372
  _clear() {
314
- this._shapes.forEach((shape) => {
315
- shape.dispose();
373
+ this._shapes.forEach((e) => {
374
+ e.dispose();
316
375
  }), this._shapes = [];
317
376
  }
318
- _addShapes(range, index, scene, skeleton) {
319
- const { startRow, endRow, startColumn, endColumn } = range, startPosition = getCoordByCell(startRow, startColumn, scene, skeleton), endPosition = getCoordByCell(endRow, endColumn, scene, skeleton), { startX, startY } = startPosition, { endX, endY } = endPosition, width = endX - startX, height = endY - startY, shapeProps = {
320
- left: startX,
321
- top: startY,
322
- color: new ColorKit(this._color).toRgb(),
323
- width,
324
- height,
325
- zIndex: SHEETS_CROSSHAIR_HIGHLIGHT_Z_INDEX,
377
+ _addShapes(e, t, r, s) {
378
+ const { startRow: i, endRow: o, startColumn: a, endColumn: h } = e, _ = j(i, a, r, s), S = j(o, h, r, s), { startX: p, startY: C } = _, { endX: d, endY: F } = S, X = d - p, K = F - C, z = {
379
+ left: p,
380
+ top: C,
381
+ color: new ne(this._color).toRgb(),
382
+ width: X,
383
+ height: K,
384
+ zIndex: Ze,
326
385
  evented: !1
327
- }, currentShapes = new SheetCrossHairHighlightShape(`crosshair-${index}`, shapeProps);
328
- this._shapes.push(currentShapes), scene.addObject(currentShapes);
386
+ }, $ = new We(`crosshair-${t}`, z);
387
+ this._shapes.push($), r.addObject($);
329
388
  }
330
- render(ranges) {
331
- const skeleton = this._sheetSkeletonManagerService.getCurrentSkeleton();
332
- if (!skeleton)
389
+ render(e) {
390
+ const t = this._sheetSkeletonManagerService.getCurrentSkeleton();
391
+ if (!t)
333
392
  return;
334
- const { scene } = this._context;
393
+ const { scene: r } = this._context;
335
394
  this._clear();
336
- for (let i = 0; i < ranges.length; i++) {
337
- const range = ranges[i];
338
- this._addShapes(range, i, scene, skeleton);
395
+ for (let s = 0; s < e.length; s++) {
396
+ const i = e[s];
397
+ this._addShapes(i, s, r, t);
339
398
  }
340
- scene.makeDirty(!0);
399
+ r.makeDirty(!0);
341
400
  }
342
401
  async dispose() {
343
402
  super.dispose();
344
403
  }
345
- }, __name(_a2, "SheetCrosshairHighlightRenderController"), _a2);
346
- SheetCrosshairHighlightRenderController = __decorateClass$1([
347
- __decorateParam$1(1, Inject(SheetSkeletonManagerService)),
348
- __decorateParam$1(2, Inject(SheetsSelectionsService)),
349
- __decorateParam$1(3, Inject(SheetsCrosshairHighlightService)),
350
- __decorateParam$1(4, Inject(IContextService)),
351
- __decorateParam$1(5, IRefSelectionsService)
352
- ], SheetCrosshairHighlightRenderController);
353
- const PLUGIN_CONFIG_KEY = "sheets-crosshair-highlight.config", defaultPluginConfig = {};
354
- var __defProp2 = Object.defineProperty, __getOwnPropDesc = Object.getOwnPropertyDescriptor, __decorateClass = /* @__PURE__ */ __name((decorators, target, key, kind) => {
355
- for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
356
- (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
357
- return kind && result && __defProp2(target, key, result), result;
358
- }, "__decorateClass"), __decorateParam = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam"), _a3;
359
- let UniverSheetsCrosshairHighlightPlugin = (_a3 = class extends Plugin {
360
- constructor(_config = defaultPluginConfig, _injector, _renderManagerService, _configService) {
361
- super(), this._config = _config, this._injector = _injector, this._renderManagerService = _renderManagerService, this._configService = _configService;
362
- const { ...rest } = this._config;
363
- this._configService.setConfig(PLUGIN_CONFIG_KEY, rest);
404
+ };
405
+ H = Fe([
406
+ v(1, u(be)),
407
+ v(2, u(He)),
408
+ v(3, u(g)),
409
+ v(4, u(re)),
410
+ v(5, Oe)
411
+ ], H);
412
+ const Xe = "sheets-crosshair-highlight.config", Ke = {};
413
+ var ze = Object.defineProperty, qe = Object.getOwnPropertyDescriptor, Je = (n, e, t, r) => {
414
+ for (var s = r > 1 ? void 0 : r ? qe(e, t) : e, i = n.length - 1, o; i >= 0; i--)
415
+ (o = n[i]) && (s = (r ? o(e, t, s) : o(s)) || s);
416
+ return r && s && ze(e, t, s), s;
417
+ }, y = (n, e) => (t, r) => e(t, r, n), m;
418
+ let L = (m = class extends se {
419
+ constructor(n = Ke, e, t, r) {
420
+ super(), this._config = n, this._injector = e, this._renderManagerService = t, this._configService = r;
421
+ const { ...s } = this._config;
422
+ this._configService.setConfig(Xe, s);
364
423
  }
365
424
  onStarting() {
366
425
  [
367
- [SheetsCrosshairHighlightService],
368
- [SheetsCrosshairHighlightController]
369
- ].forEach((d) => this._injector.add(d));
426
+ [g],
427
+ [b]
428
+ ].forEach((n) => this._injector.add(n));
370
429
  }
371
430
  onReady() {
372
431
  [
373
- [SheetCrosshairHighlightRenderController]
374
- ].forEach((d) => this._injector.add(d)), this._injector.get(SheetsCrosshairHighlightController), this._renderManagerService.registerRenderModule(UniverInstanceType.UNIVER_SHEET, [SheetCrosshairHighlightRenderController]);
375
- }
376
- }, __name(_a3, "UniverSheetsCrosshairHighlightPlugin"), __publicField(_a3, "pluginName", "SHEET_CROSSHAIR_HIGHLIGHT_PLUGIN"), __publicField(_a3, "type", UniverInstanceType.UNIVER_SHEET), _a3);
377
- UniverSheetsCrosshairHighlightPlugin = __decorateClass([
378
- __decorateParam(1, Inject(Injector)),
379
- __decorateParam(2, IRenderManagerService),
380
- __decorateParam(3, IConfigService)
381
- ], UniverSheetsCrosshairHighlightPlugin);
432
+ [H]
433
+ ].forEach((n) => this._injector.add(n)), this._injector.get(b), this._renderManagerService.registerRenderModule(E.UNIVER_SHEET, [H]);
434
+ }
435
+ }, c(m, "pluginName", "SHEET_CROSSHAIR_HIGHLIGHT_PLUGIN"), c(m, "type", E.UNIVER_SHEET), m);
436
+ L = Je([
437
+ y(1, u(ie)),
438
+ y(2, le),
439
+ y(3, oe)
440
+ ], L);
382
441
  export {
383
- CROSSHAIR_HIGHLIGHT_COLORS,
384
- DisableCrosshairHighlightOperation,
385
- EnableCrosshairHighlightOperation,
386
- SetCrosshairHighlightColorOperation,
387
- ToggleCrosshairHighlightOperation,
388
- UniverSheetsCrosshairHighlightPlugin
442
+ B as CROSSHAIR_HIGHLIGHT_COLORS,
443
+ xe as DisableCrosshairHighlightOperation,
444
+ $e as EnableCrosshairHighlightOperation,
445
+ W as SetCrosshairHighlightColorOperation,
446
+ w as ToggleCrosshairHighlightOperation,
447
+ L as UniverSheetsCrosshairHighlightPlugin
389
448
  };