@univerjs/sheets-crosshair-highlight 0.5.5-nightly.202501241606 → 0.6.0-alpha.0

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