@univerjs/sheets-crosshair-highlight 1.4.0 → 1.5.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/README.md CHANGED
@@ -8,9 +8,9 @@
8
8
 
9
9
  ## Package Overview
10
10
 
11
- | Package | UMD global | CSS | Locales | Facade entry |
12
- | --- | --- | :---: | :---: | :---: |
13
- | `@univerjs/sheets-crosshair-highlight` | `UniverSheetsCrosshairHighlight` | Yes | Yes | Yes |
11
+ | Package | UMD global | CSS | Locales | Facade entry | Worker entry |
12
+ | --- | --- | :---: | :---: | :---: | :---: |
13
+ | `@univerjs/sheets-crosshair-highlight` | `UniverSheetsCrosshairHighlight` | Yes | Yes | Yes | No |
14
14
 
15
15
  ## Installation
16
16
 
@@ -20,10 +20,10 @@ pnpm add @univerjs/sheets-crosshair-highlight
20
20
  npm install @univerjs/sheets-crosshair-highlight
21
21
  ```
22
22
 
23
- Keep all `@univerjs/*` packages on the same version.
24
-
25
23
  ## Usage
26
24
 
25
+ Start with the [integration setup](https://docs.univer.ai/) for your document type, including its required plugins, styles, and locale resources. The snippet below assumes that setup is complete.
26
+
27
27
  ```ts
28
28
  import '@univerjs/sheets-crosshair-highlight/lib/index.css';
29
29
  import EnUS from '@univerjs/sheets-crosshair-highlight/locale/en-US';
@@ -34,6 +34,10 @@ univer.registerPlugin(UniverSheetsCrosshairHighlightPlugin);
34
34
  // Merge EnUS into your Univer locale map when this package contributes UI text.
35
35
  ```
36
36
 
37
+ ## Integration Notes
38
+
39
+ - Import `@univerjs/sheets-crosshair-highlight/facade` when using this package through Univer Facade APIs.
40
+
37
41
  ## Resources
38
42
 
39
43
  - [Documentation](https://docs.univer.ai)
package/lib/cjs/index.js CHANGED
@@ -10,7 +10,7 @@ let _univerjs_design = require("@univerjs/design");
10
10
  let react = require("react");
11
11
  let react_jsx_runtime = require("react/jsx-runtime");
12
12
 
13
- // \0@oxc-project+runtime@0.156.0/helpers/esm/typeof.js
13
+ // \0@oxc-project+runtime@0.157.0/helpers/esm/typeof.js
14
14
  function _typeof(o) {
15
15
  "@babel/helpers - typeof";
16
16
  return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
@@ -20,25 +20,25 @@ function _typeof(o) {
20
20
  }, _typeof(o);
21
21
  }
22
22
 
23
- // \0@oxc-project+runtime@0.156.0/helpers/esm/toPrimitive.js
24
- function toPrimitive(t, r) {
23
+ // \0@oxc-project+runtime@0.157.0/helpers/esm/toPrimitive.js
24
+ function toPrimitive(t, e) {
25
25
  if ("object" != _typeof(t) || !t) return t;
26
- var e = t[Symbol.toPrimitive];
27
- if (void 0 !== e) {
28
- var i = e.call(t, r || "default");
26
+ var r;
27
+ if ("undefined" != typeof Symbol && void 0 !== (r = t[Symbol.toPrimitive])) {
28
+ var i = r.call(t, e || "default");
29
29
  if ("object" != _typeof(i)) return i;
30
30
  throw new TypeError("@@toPrimitive must return a primitive value.");
31
31
  }
32
- return ("string" === r ? String : Number)(t);
32
+ return ("string" === e ? String : Number)(t);
33
33
  }
34
34
 
35
- // \0@oxc-project+runtime@0.156.0/helpers/esm/toPropertyKey.js
35
+ // \0@oxc-project+runtime@0.157.0/helpers/esm/toPropertyKey.js
36
36
  function toPropertyKey(t) {
37
37
  var i = toPrimitive(t, "string");
38
38
  return "symbol" == _typeof(i) ? i : i + "";
39
39
  }
40
40
 
41
- // \0@oxc-project+runtime@0.156.0/helpers/esm/defineProperty.js
41
+ // \0@oxc-project+runtime@0.157.0/helpers/esm/defineProperty.js
42
42
  function _defineProperty(e, r, t) {
43
43
  return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
44
44
  value: t,
@@ -48,14 +48,14 @@ function _defineProperty(e, r, t) {
48
48
  }) : e[r] = t, e;
49
49
  }
50
50
 
51
- // \0@oxc-project+runtime@0.156.0/helpers/esm/decorateParam.js
51
+ // \0@oxc-project+runtime@0.157.0/helpers/esm/decorateParam.js
52
52
  function __decorateParam(paramIndex, decorator) {
53
53
  return function(target, key) {
54
54
  decorator(target, key, paramIndex);
55
55
  };
56
56
  }
57
57
 
58
- // \0@oxc-project+runtime@0.156.0/helpers/esm/decorate.js
58
+ // \0@oxc-project+runtime@0.157.0/helpers/esm/decorate.js
59
59
  function __decorate(decorators, target, key, desc) {
60
60
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
61
61
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -198,7 +198,7 @@ const menuSchema = {
198
198
 
199
199
  // package.json
200
200
  var name = "@univerjs/sheets-crosshair-highlight";
201
- var version = "1.4.0";
201
+ var version = "1.5.0";
202
202
 
203
203
  // src/config/config.ts
204
204
  const SHEETS_CROSSHAIR_HIGHLIGHT_PLUGIN_CONFIG_KEY = "sheets-crosshair-highlight.config";
@@ -265,6 +265,21 @@ function CrosshairOverlay(props) {
265
265
  }
266
266
 
267
267
  // src/views/mobile/MobileCrosshairHighlightPanel.tsx
268
+ /**
269
+ * Copyright 2023-present DreamNum Co., Ltd.
270
+ *
271
+ * Licensed under the Apache License, Version 2.0 (the "License");
272
+ * you may not use this file except in compliance with the License.
273
+ * You may obtain a copy of the License at
274
+ *
275
+ * http://www.apache.org/licenses/LICENSE-2.0
276
+ *
277
+ * Unless required by applicable law or agreed to in writing, software
278
+ * distributed under the License is distributed on an "AS IS" BASIS,
279
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
280
+ * See the License for the specific language governing permissions and
281
+ * limitations under the License.
282
+ */
268
283
  function MobileCrosshairHighlightPanel() {
269
284
  const commandService = (0, _univerjs_ui.useDependency)(_univerjs_core.ICommandService);
270
285
  const crosshairHighlightService = (0, _univerjs_ui.useDependency)(SheetsCrosshairHighlightService);
@@ -281,6 +296,7 @@ function MobileCrosshairHighlightPanel() {
281
296
  className: "univer-min-w-0 univer-flex-1 univer-text-base univer-font-medium univer-text-gray-900 dark:!univer-text-gray-100",
282
297
  children: localeService.t("sheets-crosshair-highlight.button.tooltip")
283
298
  }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Switch, {
299
+ "aria-label": localeService.t("sheets-crosshair-highlight.button.tooltip"),
284
300
  defaultChecked: enabled,
285
301
  onChange: (checked) => {
286
302
  const operation = checked ? EnableCrosshairHighlightOperation : DisableCrosshairHighlightOperation;
package/lib/es/index.js CHANGED
@@ -9,7 +9,7 @@ import { Switch, borderClassName, clsx, resetButtonClassName } from "@univerjs/d
9
9
  import { useCallback } from "react";
10
10
  import { jsx, jsxs } from "react/jsx-runtime";
11
11
 
12
- // \0@oxc-project+runtime@0.156.0/helpers/esm/typeof.js
12
+ // \0@oxc-project+runtime@0.157.0/helpers/esm/typeof.js
13
13
  function _typeof(o) {
14
14
  "@babel/helpers - typeof";
15
15
  return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
@@ -19,25 +19,25 @@ function _typeof(o) {
19
19
  }, _typeof(o);
20
20
  }
21
21
 
22
- // \0@oxc-project+runtime@0.156.0/helpers/esm/toPrimitive.js
23
- function toPrimitive(t, r) {
22
+ // \0@oxc-project+runtime@0.157.0/helpers/esm/toPrimitive.js
23
+ function toPrimitive(t, e) {
24
24
  if ("object" != _typeof(t) || !t) return t;
25
- var e = t[Symbol.toPrimitive];
26
- if (void 0 !== e) {
27
- var i = e.call(t, r || "default");
25
+ var r;
26
+ if ("undefined" != typeof Symbol && void 0 !== (r = t[Symbol.toPrimitive])) {
27
+ var i = r.call(t, e || "default");
28
28
  if ("object" != _typeof(i)) return i;
29
29
  throw new TypeError("@@toPrimitive must return a primitive value.");
30
30
  }
31
- return ("string" === r ? String : Number)(t);
31
+ return ("string" === e ? String : Number)(t);
32
32
  }
33
33
 
34
- // \0@oxc-project+runtime@0.156.0/helpers/esm/toPropertyKey.js
34
+ // \0@oxc-project+runtime@0.157.0/helpers/esm/toPropertyKey.js
35
35
  function toPropertyKey(t) {
36
36
  var i = toPrimitive(t, "string");
37
37
  return "symbol" == _typeof(i) ? i : i + "";
38
38
  }
39
39
 
40
- // \0@oxc-project+runtime@0.156.0/helpers/esm/defineProperty.js
40
+ // \0@oxc-project+runtime@0.157.0/helpers/esm/defineProperty.js
41
41
  function _defineProperty(e, r, t) {
42
42
  return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
43
43
  value: t,
@@ -47,14 +47,14 @@ function _defineProperty(e, r, t) {
47
47
  }) : e[r] = t, e;
48
48
  }
49
49
 
50
- // \0@oxc-project+runtime@0.156.0/helpers/esm/decorateParam.js
50
+ // \0@oxc-project+runtime@0.157.0/helpers/esm/decorateParam.js
51
51
  function __decorateParam(paramIndex, decorator) {
52
52
  return function(target, key) {
53
53
  decorator(target, key, paramIndex);
54
54
  };
55
55
  }
56
56
 
57
- // \0@oxc-project+runtime@0.156.0/helpers/esm/decorate.js
57
+ // \0@oxc-project+runtime@0.157.0/helpers/esm/decorate.js
58
58
  function __decorate(decorators, target, key, desc) {
59
59
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
60
60
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -197,7 +197,7 @@ const menuSchema = {
197
197
 
198
198
  // package.json
199
199
  var name = "@univerjs/sheets-crosshair-highlight";
200
- var version = "1.4.0";
200
+ var version = "1.5.0";
201
201
 
202
202
  // src/config/config.ts
203
203
  const SHEETS_CROSSHAIR_HIGHLIGHT_PLUGIN_CONFIG_KEY = "sheets-crosshair-highlight.config";
@@ -264,6 +264,21 @@ function CrosshairOverlay(props) {
264
264
  }
265
265
 
266
266
  // src/views/mobile/MobileCrosshairHighlightPanel.tsx
267
+ /**
268
+ * Copyright 2023-present DreamNum Co., Ltd.
269
+ *
270
+ * Licensed under the Apache License, Version 2.0 (the "License");
271
+ * you may not use this file except in compliance with the License.
272
+ * You may obtain a copy of the License at
273
+ *
274
+ * http://www.apache.org/licenses/LICENSE-2.0
275
+ *
276
+ * Unless required by applicable law or agreed to in writing, software
277
+ * distributed under the License is distributed on an "AS IS" BASIS,
278
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
279
+ * See the License for the specific language governing permissions and
280
+ * limitations under the License.
281
+ */
267
282
  function MobileCrosshairHighlightPanel() {
268
283
  const commandService = useDependency(ICommandService);
269
284
  const crosshairHighlightService = useDependency(SheetsCrosshairHighlightService);
@@ -280,6 +295,7 @@ function MobileCrosshairHighlightPanel() {
280
295
  className: "univer-min-w-0 univer-flex-1 univer-text-base univer-font-medium univer-text-gray-900 dark:!univer-text-gray-100",
281
296
  children: localeService.t("sheets-crosshair-highlight.button.tooltip")
282
297
  }), /* @__PURE__ */ jsx(Switch, {
298
+ "aria-label": localeService.t("sheets-crosshair-highlight.button.tooltip"),
283
299
  defaultChecked: enabled,
284
300
  onChange: (checked) => {
285
301
  const operation = checked ? EnableCrosshairHighlightOperation : DisableCrosshairHighlightOperation;
package/lib/index.js CHANGED
@@ -9,7 +9,7 @@ import { Switch, borderClassName, clsx, resetButtonClassName } from "@univerjs/d
9
9
  import { useCallback } from "react";
10
10
  import { jsx, jsxs } from "react/jsx-runtime";
11
11
 
12
- // \0@oxc-project+runtime@0.156.0/helpers/esm/typeof.js
12
+ // \0@oxc-project+runtime@0.157.0/helpers/esm/typeof.js
13
13
  function _typeof(o) {
14
14
  "@babel/helpers - typeof";
15
15
  return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
@@ -19,25 +19,25 @@ function _typeof(o) {
19
19
  }, _typeof(o);
20
20
  }
21
21
 
22
- // \0@oxc-project+runtime@0.156.0/helpers/esm/toPrimitive.js
23
- function toPrimitive(t, r) {
22
+ // \0@oxc-project+runtime@0.157.0/helpers/esm/toPrimitive.js
23
+ function toPrimitive(t, e) {
24
24
  if ("object" != _typeof(t) || !t) return t;
25
- var e = t[Symbol.toPrimitive];
26
- if (void 0 !== e) {
27
- var i = e.call(t, r || "default");
25
+ var r;
26
+ if ("undefined" != typeof Symbol && void 0 !== (r = t[Symbol.toPrimitive])) {
27
+ var i = r.call(t, e || "default");
28
28
  if ("object" != _typeof(i)) return i;
29
29
  throw new TypeError("@@toPrimitive must return a primitive value.");
30
30
  }
31
- return ("string" === r ? String : Number)(t);
31
+ return ("string" === e ? String : Number)(t);
32
32
  }
33
33
 
34
- // \0@oxc-project+runtime@0.156.0/helpers/esm/toPropertyKey.js
34
+ // \0@oxc-project+runtime@0.157.0/helpers/esm/toPropertyKey.js
35
35
  function toPropertyKey(t) {
36
36
  var i = toPrimitive(t, "string");
37
37
  return "symbol" == _typeof(i) ? i : i + "";
38
38
  }
39
39
 
40
- // \0@oxc-project+runtime@0.156.0/helpers/esm/defineProperty.js
40
+ // \0@oxc-project+runtime@0.157.0/helpers/esm/defineProperty.js
41
41
  function _defineProperty(e, r, t) {
42
42
  return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
43
43
  value: t,
@@ -47,14 +47,14 @@ function _defineProperty(e, r, t) {
47
47
  }) : e[r] = t, e;
48
48
  }
49
49
 
50
- // \0@oxc-project+runtime@0.156.0/helpers/esm/decorateParam.js
50
+ // \0@oxc-project+runtime@0.157.0/helpers/esm/decorateParam.js
51
51
  function __decorateParam(paramIndex, decorator) {
52
52
  return function(target, key) {
53
53
  decorator(target, key, paramIndex);
54
54
  };
55
55
  }
56
56
 
57
- // \0@oxc-project+runtime@0.156.0/helpers/esm/decorate.js
57
+ // \0@oxc-project+runtime@0.157.0/helpers/esm/decorate.js
58
58
  function __decorate(decorators, target, key, desc) {
59
59
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
60
60
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -197,7 +197,7 @@ const menuSchema = {
197
197
 
198
198
  // package.json
199
199
  var name = "@univerjs/sheets-crosshair-highlight";
200
- var version = "1.4.0";
200
+ var version = "1.5.0";
201
201
 
202
202
  // src/config/config.ts
203
203
  const SHEETS_CROSSHAIR_HIGHLIGHT_PLUGIN_CONFIG_KEY = "sheets-crosshair-highlight.config";
@@ -264,6 +264,21 @@ function CrosshairOverlay(props) {
264
264
  }
265
265
 
266
266
  // src/views/mobile/MobileCrosshairHighlightPanel.tsx
267
+ /**
268
+ * Copyright 2023-present DreamNum Co., Ltd.
269
+ *
270
+ * Licensed under the Apache License, Version 2.0 (the "License");
271
+ * you may not use this file except in compliance with the License.
272
+ * You may obtain a copy of the License at
273
+ *
274
+ * http://www.apache.org/licenses/LICENSE-2.0
275
+ *
276
+ * Unless required by applicable law or agreed to in writing, software
277
+ * distributed under the License is distributed on an "AS IS" BASIS,
278
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
279
+ * See the License for the specific language governing permissions and
280
+ * limitations under the License.
281
+ */
267
282
  function MobileCrosshairHighlightPanel() {
268
283
  const commandService = useDependency(ICommandService);
269
284
  const crosshairHighlightService = useDependency(SheetsCrosshairHighlightService);
@@ -280,6 +295,7 @@ function MobileCrosshairHighlightPanel() {
280
295
  className: "univer-min-w-0 univer-flex-1 univer-text-base univer-font-medium univer-text-gray-900 dark:!univer-text-gray-100",
281
296
  children: localeService.t("sheets-crosshair-highlight.button.tooltip")
282
297
  }), /* @__PURE__ */ jsx(Switch, {
298
+ "aria-label": localeService.t("sheets-crosshair-highlight.button.tooltip"),
283
299
  defaultChecked: enabled,
284
300
  onChange: (checked) => {
285
301
  const operation = checked ? EnableCrosshairHighlightOperation : DisableCrosshairHighlightOperation;
package/lib/umd/index.js CHANGED
@@ -1 +1 @@
1
- (function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("@univerjs/core"),require("rxjs"),require("@univerjs/ui"),require("@univerjs/engine-render"),require("@univerjs/sheets"),require("@univerjs/sheets-ui"),require("react"),require("@univerjs/design"),require("react/jsx-runtime")):typeof define==`function`&&define.amd?define([`exports`,`@univerjs/core`,`rxjs`,`@univerjs/ui`,`@univerjs/engine-render`,`@univerjs/sheets`,`@univerjs/sheets-ui`,`react`,`@univerjs/design`,`react/jsx-runtime`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.UniverSheetsCrosshairHighlight={},e.UniverCore,e.rxjs,e.UniverUi,e.UniverEngineRender,e.UniverSheets,e.UniverSheetsUi,e.React,e.UniverDesign,e.React))})(this,function(e,t,n,r,i,a,o,s,c,l){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});function u(e){"@babel/helpers - typeof";return u=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},u(e)}function d(e,t){if(u(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(u(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function f(e){var t=d(e,`string`);return u(t)==`symbol`?t:t+``}function p(e,t,n){return(t=f(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function m(e,t){return function(n,r){t(n,r,e)}}function h(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}let g=Array.from({length:16},(e,t)=>`highlight.background.${t+1}`),_=g[0];function v(e,n){let r=e.getColorFromTheme(n);if(r==null||typeof r.color!=`string`||typeof r.alpha!=`number`)throw Error(`Theme token ${n} is required.`);let i=e.getColorFromTheme(r.color)??r.color;return new t.ColorKit(i).setAlpha(r.alpha).toRgbString()}function y(e){return g.map(t=>v(e,t))}let b=class extends t.Disposable{get enabled(){return this._enabled$.getValue()}constructor(e){super(),this._themeService=e,p(this,`_enabled$`,new n.BehaviorSubject(!1)),p(this,`enabled$`,this._enabled$.asObservable()),p(this,`_colorToken$`,new n.BehaviorSubject(_)),p(this,`colorToken$`,this._colorToken$.asObservable()),p(this,`color$`,void 0),p(this,`highlightColor$`,void 0),this.color$=(0,n.combineLatest)([this._colorToken$,this._themeService.currentTheme$]).pipe((0,n.map)(([e])=>v(this._themeService,e))),this.highlightColor$=this.color$}dispose(){this._enabled$.complete(),this._colorToken$.complete()}setEnabled(e){this._enabled$.next(e)}setColor(e){this._colorToken$.next(e)}};b=h([m(0,(0,t.Inject)(t.ThemeService))],b);let x={id:`sheet.operation.toggle-crosshair-highlight`,type:t.CommandType.OPERATION,handler(e){let t=e.get(b),n=t.enabled;return t.setEnabled(!n),!0}},S={id:`sheet.operation.set-crosshair-highlight-color`,type:t.CommandType.OPERATION,handler(e,{value:t}){let n=e.get(b);return n.enabled||n.setEnabled(!0),n.setColor(t),!0}},C={id:`sheet.operation.enable-crosshair-highlight`,type:t.CommandType.OPERATION,handler(e){let t=e.get(b);return!t.enabled&&(t.setEnabled(!0),!0)}},w={id:`sheet.operation.disable-crosshair-highlight`,type:t.CommandType.OPERATION,handler(e){let t=e.get(b);return t.enabled?(t.setEnabled(!1),!0):!1}},T=`CROSSHAIR_HIGHLIGHT_OVERLAY_COMPONENT`;function E(e){let n=e.get(b);return{id:x.id,tooltip:`sheets-crosshair-highlight.button.tooltip`,type:r.MenuItemType.BUTTON_SELECTOR,icon:`CrossHighlightingIcon`,selections:[{label:{name:T,hoverable:!1,selectable:!1,props:{embedded:!0}}}],selectionsCommandId:S.id,activated$:n.enabled$,hidden$:(0,r.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_SHEET)}}let D={[r.RibbonViewGroup.DISPLAY]:{[x.id]:{order:2,gridLayout:{row:2,column:2},menuItemFactory:E}},[r.ContextMenuPosition.FOOTER_MENU]:{[r.ContextMenuGroup.OTHERS]:{[x.id]:{order:0,menuItemFactory:E}}}};var O=`@univerjs/sheets-crosshair-highlight`,k=`1.4.0`;let A=`sheets-crosshair-highlight.config`,j={},M=`SHEET_CROSSHAIR_HIGHLIGHT_PLUGIN`;function N({ref:e,...t}){let{preserveStrokeWidth:n,icon:r,id:i,className:a,extend:o,...c}=t,l=`univerjs-icon univerjs-icon-${i} ${a||``}`.trim(),u=`_${(0,s.useId)()}`,d=(0,s.useRef)(null);return(0,s.useImperativeHandle)(e,()=>d.current),(0,s.useLayoutEffect)(()=>{if(n&&d.current&&d.current.localName===r.tag)return L(d.current)},[n,r]),P(r,`${i}`,{defIds:r.defIds,idSuffix:u},{ref:d,className:l,...c},o)}function P(e,t,n,r,i){return(0,s.createElement)(e.tag,{key:t,...F(e,n,i),...r},(I(e,n).children||[]).map((r,a)=>P(r,`${t}-${e.tag}-${a}`,n,void 0,i)))}function F(e,t,n){let r={...e.attrs};n!=null&&n.colorChannel1&&r.fill===`colorChannel1`&&(r.fill=n.colorChannel1),n!=null&&n.colorChannel1&&r.stroke===`colorChannel1`&&(r.stroke=n.colorChannel1),e.tag===`mask`&&r.id&&(r.id+=t.idSuffix),Object.entries(r).forEach(([e,n])=>{e===`mask`&&typeof n==`string`&&(r[e]=n.replace(/url\(#(.*)\)/,`url(#$1${t.idSuffix})`))});let{defIds:i}=t;return!i||i.length===0||(e.tag===`use`&&r[`xlink:href`]&&(r[`xlink:href`]+=t.idSuffix),Object.entries(r).forEach(([e,n])=>{typeof n==`string`&&(r[e]=n.replace(/url\(#(.*)\)/,`url(#$1${t.idSuffix})`))})),r}function I(e,t){var n;let{defIds:r}=t;return!r||r.length===0?e:e.tag===`defs`&&(n=e.children)!=null&&n.length?{...e,children:e.children.map(e=>typeof e.attrs.id==`string`&&r&&r.includes(e.attrs.id)?{...e,attrs:{...e.attrs,id:e.attrs.id+t.idSuffix}}:e)}:e}function L(e){let t=e.viewBox.baseVal,n=Math.max(t.width,t.height);if(!Number.isFinite(n)||n<=0||t.width<=0||t.height<=0)return()=>void 0;let r=16/n,i=Array.from(e.querySelectorAll(`circle, ellipse, line, path, polygon, polyline, rect, text, textPath, tspan, use`)).flatMap(e=>{let t=getComputedStyle(e),n=Number.parseFloat(t.strokeWidth);return t.stroke===`none`||Number.parseFloat(t.strokeOpacity)===0||t.vectorEffect===`non-scaling-stroke`||!Number.isFinite(n)||n<=0?[]:[{element:e,hadStyleAttribute:e.hasAttribute(`style`),originalStrokeWidth:n,strokeWidth:R(e.style,`stroke-width`)}]}).map(e=>({appliedStrokeWidth:null,element:e.element,hadStyleAttribute:e.hadStyleAttribute,isReleased:!1,originalStrokeWidth:e.originalStrokeWidth,strokeWidth:e.strokeWidth}));if(i.length===0)return()=>void 0;let a=(e,n)=>{if(t.width<=0||t.height<=0||e<=0||n<=0)return;let a=Math.min(e/t.width,n/t.height);!Number.isFinite(a)||a<=0||i.forEach(e=>{if(e.isReleased)return;if(e.appliedStrokeWidth!==null&&(e.element.style.getPropertyValue(`stroke-width`)!==e.appliedStrokeWidth||e.element.style.getPropertyPriority(`stroke-width`)!==e.strokeWidth.priority)){e.appliedStrokeWidth=null,e.isReleased=!0;return}let t=e.originalStrokeWidth*r/a,n=`${Number(t.toFixed(12))}px`;e.element.style.setProperty(`stroke-width`,n,e.strokeWidth.priority),e.appliedStrokeWidth=n})},o=e.getBoundingClientRect();a(o.width,o.height);let s=typeof ResizeObserver>`u`?null:new ResizeObserver(t=>{if(t.some(t=>t.target===e)){let t=e.getBoundingClientRect();a(t.width,t.height)}});return s==null||s.observe(e),()=>{s==null||s.disconnect(),i.forEach(e=>{e.appliedStrokeWidth!==null&&(z(e.element.style,`stroke-width`,e.appliedStrokeWidth,e.strokeWidth.priority,e.strokeWidth),!e.hadStyleAttribute&&e.element.style.length===0&&e.element.removeAttribute(`style`))})}}function R(e,t){return{priority:e.getPropertyPriority(t),value:e.getPropertyValue(t)}}function z(e,t,n,r,i){e.getPropertyValue(t)===n&&e.getPropertyPriority(t)===r&&(i.value?e.setProperty(t,i.value,i.priority):e.removeProperty(t))}N.displayName=`UniverIcon`;let B={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{stroke:`currentColor`,d:`M5 2H2V5M11 2H14V5M14 11V14H11M5 14H2V11`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:1.3}},{tag:`path`,attrs:{stroke:`currentColor`,d:`M6.6 3.8H9.4V6.6H12.2V9.4H9.4V12.2H6.6V9.4H3.8V6.6H6.6V3.8Z`,strokeLinejoin:`round`,strokeWidth:1.15}},{tag:`rect`,attrs:{width:2.6,height:2.6,x:6.7,y:6.7,fill:`currentColor`,rx:.35}}]},V=(0,s.forwardRef)(function(e,t){return(0,s.createElement)(N,Object.assign({},e,{id:`cross-highlighting-icon`,ref:t,icon:B}))});V.displayName=`CrossHighlightingIcon`;let H=`sheet.menu.mobile.crosshair-highlight`,U=`MOBILE_CROSSHAIR_HIGHLIGHT_PANEL`;function W(e){return{id:H,type:r.MenuItemType.SELECTOR,icon:`CrossHighlightingIcon`,title:`sheets-crosshair-highlight.button.tooltip`,tooltip:`sheets-crosshair-highlight.button.tooltip`,selections:[{label:{name:U,hoverable:!1,selectable:!1}}],hidden$:(0,r.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_SHEET)}}function G(e){let{onChange:i}=e,a=(0,r.useDependency)(b),o=(0,r.useDependency)(t.ThemeService),u=(0,r.useObservable)(a.color$),d=(0,r.useObservable)(()=>o.currentTheme$.pipe((0,n.map)(()=>y(o))),y(o),!1,[o]),f=(0,s.useCallback)(e=>{i==null||i(e)},[i]);return/* @__PURE__ */ (0,l.jsx)(`div`,{className:`univer-grid univer-grid-cols-8 univer-gap-x-2 univer-gap-y-3 univer-p-1.5`,children:d.map((e,t)=>/* @__PURE__ */ (0,l.jsx)(`div`,{className:(0,c.clsx)(`univer-box-border univer-size-5 univer-cursor-pointer univer-rounded univer-ring-offset-1 univer-transition-shadow hover:univer-ring-[1.5px] hover:univer-ring-primary-600`,c.borderClassName,{"univer-ring-[1.5px] univer-ring-primary-600 hover:univer-ring-primary-600":e===u}),style:{backgroundColor:e},onClick:()=>f(g[t])},g[t]))})}function K(){let e=(0,r.useDependency)(t.ICommandService),i=(0,r.useDependency)(b),a=(0,r.useDependency)(t.LocaleService),o=(0,r.useDependency)(t.ThemeService),s=(0,r.useObservable)(i.enabled$,!1),u=(0,r.useObservable)(i.color$),d=(0,r.useObservable)(()=>o.currentTheme$.pipe((0,n.map)(()=>y(o))),y(o),!1,[o]);return/* @__PURE__ */ (0,l.jsxs)(`div`,{className:`univer-grid univer-w-full univer-gap-4 univer-p-4`,children:[/* @__PURE__ */ (0,l.jsxs)(`div`,{className:`univer-flex univer-min-h-8 univer-items-center univer-gap-4`,children:[/* @__PURE__ */ (0,l.jsx)(`span`,{className:`univer-min-w-0 univer-flex-1 univer-text-base univer-font-medium univer-text-gray-900 dark:!univer-text-gray-100`,children:a.t(`sheets-crosshair-highlight.button.tooltip`)}),/* @__PURE__ */ (0,l.jsx)(c.Switch,{defaultChecked:s,onChange:t=>{let n=t?C:w;e.executeCommand(n.id).catch(()=>void 0)}})]}),/* @__PURE__ */ (0,l.jsx)(`div`,{className:`univer-grid univer-grid-cols-8 univer-gap-3`,children:d.map((t,n)=>{let r=g[n],i=t===u;return/* @__PURE__ */ (0,l.jsx)(`button`,{type:`button`,"data-color-token":r,title:t,"aria-pressed":i,className:(0,c.clsx)(c.resetButtonClassName,`univer-box-border univer-size-8 univer-rounded-lg univer-border univer-border-solid univer-border-gray-200 univer-ring-offset-2 active:univer-opacity-70 dark:!univer-border-gray-600`,{"univer-ring-2 univer-ring-primary-600":i}),style:{backgroundColor:t},onClick:()=>{e.executeCommand(S.id,{value:r}).catch(()=>void 0)}},r)})})]})}let q=class extends t.Disposable{constructor(e,t){super(),this._componentManager=e,this._iconManager=t,this._registerComponents(),this._registerIcons()}_registerComponents(){this.disposeWithMe(this._componentManager.register(T,G)),this.disposeWithMe(this._componentManager.register(U,K))}_registerIcons(){this.disposeWithMe(this._iconManager.register({CrossHighlightingIcon:V}))}};q=h([m(0,(0,t.Inject)(r.ComponentManager)),m(1,(0,t.Inject)(r.IconManager))],q);let J={[r.RibbonDataGroup.ORGANIZATION]:{[H]:{order:21,menuItemFactory:W}}},Y=class extends t.Disposable{constructor(e,t){super(),[x,S,C,w].forEach(t=>this.disposeWithMe(e.registerCommand(t))),t.mergeMenu(J)}};Y=h([m(0,t.ICommandService),m(1,r.IMenuManagerService)],Y);var ee=class{constructor(){p(this,`_selectedRanges`,[]),p(this,`_ranges`,[])}addRange(e){if(e.rangeType===t.RANGE_TYPE.COLUMN||e.rangeType===t.RANGE_TYPE.ROW||e.rangeType===t.RANGE_TYPE.ALL)return;let n=this._getIntersects(e),r=this._getSplitRanges(e,n);r.length>0&&this._ranges.push(...r)}setSelectedRanges(e){this._selectedRanges=e}_getSplitRanges(e,n){let r=[e];for(let e of n.concat(this._selectedRanges)){let n=[];for(let i of r){let r=t.Rectangle.subtract(i,e);r&&r.length>0&&n.push(...r)}r=n}return r.filter(e=>e.startRow<=e.endRow&&e.startColumn<=e.endColumn)}_getIntersects(e){let n=[];for(let r of this._ranges){let i=(0,t.getIntersectRange)(r,e);i&&n.push(i)}return n}getRanges(){return this._ranges}reset(){this._ranges=[],this._selectedRanges=[]}},te=class extends i.Shape{constructor(e,t){super(e,t),p(this,`_color`,void 0),t&&this.setShapeProps(t)}setShapeProps(e){e.color!==void 0&&(this._color=e.color),this.transformByState({width:e.width,height:e.height})}_draw(e){var t;let n=`rgba(${this._color.r}, ${this._color.g}, ${this._color.b}, ${((t=this._color)==null?void 0:t.a)??.5})`;i.Rect.drawWith(e,{width:this.width,height:this.height,fill:n,stroke:void 0,strokeWidth:0,evented:!1})}};let X=class extends t.Disposable{constructor(e,t,n,r,i,a){super(),this._context=e,this._sheetSkeletonManagerService=t,this._sheetsSelectionsService=n,this._sheetsCrosshairHighlightService=r,this._contextService=i,this._refSelectionsService=a,p(this,`_shapes`,[]),p(this,`_rangeCollection`,new ee),p(this,`_color`,`rgba(255,0,0,0.5)`),this._initRenderListener()}_transformSelection(e,t){if(!e)return;let n=t.getRowCount(),r=t.getColumnCount(),i=[];for(let t of e){let{startRow:e,endRow:a,startColumn:o,endColumn:s}=t.range;a-e+1!==n&&s-o+1!==r&&i.push(t.range)}this._rangeCollection.setSelectedRanges(i);for(let e of i)this.addSelection(e,t)}_initRenderListener(){let e=this._context.unit;this.disposeWithMe((0,n.combineLatest)([this._contextService.subscribeContextValue$(a.REF_SELECTIONS_ENABLED).pipe((0,n.startWith)(!1)),this._sheetSkeletonManagerService.currentSkeleton$,this._sheetsCrosshairHighlightService.enabled$,this._sheetsCrosshairHighlightService.highlightColor$.pipe((0,n.tap)(e=>this._color=e)),(0,n.merge)(this._sheetsSelectionsService.selectionMoveStart$,this._sheetsSelectionsService.selectionMoving$,this._sheetsSelectionsService.selectionMoveEnd$,this._sheetsSelectionsService.selectionSet$,e.activeSheet$.pipe((0,n.map)(()=>this._sheetsSelectionsService.getCurrentSelections()))),(0,n.merge)(this._refSelectionsService.selectionMoveStart$,this._refSelectionsService.selectionMoving$,this._refSelectionsService.selectionMoveEnd$,this._sheetsSelectionsService.selectionSet$,e.activeSheet$.pipe((0,n.map)(()=>this._refSelectionsService.getCurrentSelections())))]).subscribe(([t,n,r,i,a,o])=>{if(this._clear(),!r)return;let s=t?o:a;this._rangeCollection.reset(),this._transformSelection(s,e.getActiveSheet()),this.render(this._rangeCollection.getRanges())}))}addSelection(e,n){if(e.rangeType===t.RANGE_TYPE.COLUMN||e.rangeType===t.RANGE_TYPE.ROW||e.rangeType===t.RANGE_TYPE.ALL)return;let r=n.getRowCount(),i=n.getColumnCount(),{startRow:a,endRow:o,startColumn:s,endColumn:c}=e,l={startRow:a,endRow:o,startColumn:0,endColumn:s-1},u={startRow:a,endRow:o,startColumn:c+1,endColumn:i},d={startRow:0,endRow:a-1,startColumn:s,endColumn:c},f={startRow:o+1,endRow:r,startColumn:s,endColumn:c};for(let e of[l,u,d,f])e.startRow<=e.endRow&&e.startColumn<=e.endColumn&&this._rangeCollection.addRange(e)}_clear(){this._shapes.forEach(e=>{e.dispose()}),this._shapes=[]}_addShapes(e,n,r,i){let{startRow:a,endRow:s,startColumn:c,endColumn:l}=e,u=(0,o.getCoordByCell)(a,c,r,i),d=(0,o.getCoordByCell)(s,l,r,i),{startX:f,startY:p}=u,{endX:m,endY:h}=d,g=m-f,_=h-p,v={left:f,top:p,color:new t.ColorKit(this._color).toRgb(),width:g,height:_,zIndex:1,evented:!1},y=new te(`crosshair-${n}`,v);this._shapes.push(y),r.addObject(y)}render(e){let t=this._sheetSkeletonManagerService.getCurrentSkeleton();if(!t)return;let{scene:n}=this._context;this._clear();for(let r=0;r<e.length;r++){let i=e[r];this._addShapes(i,r,n,t)}n.makeDirty(!0)}async dispose(){super.dispose()}};X=h([m(1,(0,t.Inject)(o.SheetSkeletonManagerService)),m(2,(0,t.Inject)(a.SheetsSelectionsService)),m(3,(0,t.Inject)(b)),m(4,(0,t.Inject)(t.IContextService)),m(5,a.IRefSelectionsService)],X);let Z=class extends t.Plugin{constructor(e=j,n,r,i){super(),this._config=e,this._injector=n,this._renderManagerService=r,this._configService=i;let{...a}=(0,t.merge)({},j,this._config);this._configService.setConfig(A,a)}onStarting(){[[q],[b],[Y]].forEach(e=>this._injector.add(e))}onReady(){this._injector.get(q),this._injector.get(Y),this.disposeWithMe(this._renderManagerService.registerRenderModule(t.UniverInstanceType.UNIVER_SHEET,[X]))}};p(Z,`pluginName`,M),p(Z,`packageName`,O),p(Z,`version`,k),p(Z,`type`,t.UniverInstanceType.UNIVER_SHEET),Z=h([(0,t.DependentOn)(i.UniverRenderEnginePlugin,a.UniverSheetsPlugin,o.UniverSheetsMobileUIPlugin,r.UniverMobileUIPlugin),m(1,(0,t.Inject)(t.Injector)),m(2,i.IRenderManagerService),m(3,t.IConfigService)],Z);let Q=class extends t.Disposable{constructor(e,t){super(),this._menuManagerService=e,this._cmdSrv=t,this._initCommands(),this._initMenus()}_initCommands(){[x,S,C,w].forEach(e=>this._cmdSrv.registerCommand(e))}_initMenus(){this._menuManagerService.mergeMenu(D)}};Q=h([m(0,r.IMenuManagerService),m(1,t.ICommandService)],Q);let $=class extends t.Plugin{constructor(e=j,n,r,i){super(),this._config=e,this._injector=n,this._renderManagerService=r,this._configService=i;let{...a}=(0,t.merge)({},j,this._config);this._configService.setConfig(A,a)}onStarting(){[[q],[b],[Q]].forEach(e=>this._injector.add(e))}onReady(){[[X]].forEach(e=>this._injector.add(e)),this._injector.get(q),this._injector.get(Q),this._renderManagerService.registerRenderModule(t.UniverInstanceType.UNIVER_SHEET,[X])}};p($,`pluginName`,M),p($,`packageName`,O),p($,`version`,k),p($,`type`,t.UniverInstanceType.UNIVER_SHEET),$=h([(0,t.DependentOn)(i.UniverRenderEnginePlugin,a.UniverSheetsPlugin,o.UniverSheetsUIPlugin),m(1,(0,t.Inject)(t.Injector)),m(2,i.IRenderManagerService),m(3,t.IConfigService)],$),e.DisableCrosshairHighlightOperation=w,e.EnableCrosshairHighlightOperation=C,e.SetCrosshairHighlightColorOperation=S,e.SheetsCrosshairHighlightMenuSchema=D,Object.defineProperty(e,"SheetsCrosshairHighlightService",{enumerable:!0,get:function(){return b}}),e.ToggleCrosshairHighlightOperation=x,Object.defineProperty(e,"UniverSheetsCrosshairHighlightMobileUIPlugin",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"UniverSheetsCrosshairHighlightPlugin",{enumerable:!0,get:function(){return $}})});
1
+ (function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("@univerjs/core"),require("rxjs"),require("@univerjs/ui"),require("@univerjs/engine-render"),require("@univerjs/sheets"),require("@univerjs/sheets-ui"),require("react"),require("@univerjs/design"),require("react/jsx-runtime")):typeof define==`function`&&define.amd?define([`exports`,`@univerjs/core`,`rxjs`,`@univerjs/ui`,`@univerjs/engine-render`,`@univerjs/sheets`,`@univerjs/sheets-ui`,`react`,`@univerjs/design`,`react/jsx-runtime`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.UniverSheetsCrosshairHighlight={},e.UniverCore,e.rxjs,e.UniverUi,e.UniverEngineRender,e.UniverSheets,e.UniverSheetsUi,e.React,e.UniverDesign,e.React))})(this,function(e,t,n,r,i,a,o,s,c,l){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});function u(e){"@babel/helpers - typeof";return u=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},u(e)}function d(e,t){if(u(e)!=`object`||!e)return e;var n;if(typeof Symbol<`u`&&(n=e[Symbol.toPrimitive])!==void 0){var r=n.call(e,t||`default`);if(u(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function f(e){var t=d(e,`string`);return u(t)==`symbol`?t:t+``}function p(e,t,n){return(t=f(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function m(e,t){return function(n,r){t(n,r,e)}}function h(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}let g=Array.from({length:16},(e,t)=>`highlight.background.${t+1}`),_=g[0];function v(e,n){let r=e.getColorFromTheme(n);if(r==null||typeof r.color!=`string`||typeof r.alpha!=`number`)throw Error(`Theme token ${n} is required.`);let i=e.getColorFromTheme(r.color)??r.color;return new t.ColorKit(i).setAlpha(r.alpha).toRgbString()}function y(e){return g.map(t=>v(e,t))}let b=class extends t.Disposable{get enabled(){return this._enabled$.getValue()}constructor(e){super(),this._themeService=e,p(this,`_enabled$`,new n.BehaviorSubject(!1)),p(this,`enabled$`,this._enabled$.asObservable()),p(this,`_colorToken$`,new n.BehaviorSubject(_)),p(this,`colorToken$`,this._colorToken$.asObservable()),p(this,`color$`,void 0),p(this,`highlightColor$`,void 0),this.color$=(0,n.combineLatest)([this._colorToken$,this._themeService.currentTheme$]).pipe((0,n.map)(([e])=>v(this._themeService,e))),this.highlightColor$=this.color$}dispose(){this._enabled$.complete(),this._colorToken$.complete()}setEnabled(e){this._enabled$.next(e)}setColor(e){this._colorToken$.next(e)}};b=h([m(0,(0,t.Inject)(t.ThemeService))],b);let x={id:`sheet.operation.toggle-crosshair-highlight`,type:t.CommandType.OPERATION,handler(e){let t=e.get(b),n=t.enabled;return t.setEnabled(!n),!0}},S={id:`sheet.operation.set-crosshair-highlight-color`,type:t.CommandType.OPERATION,handler(e,{value:t}){let n=e.get(b);return n.enabled||n.setEnabled(!0),n.setColor(t),!0}},C={id:`sheet.operation.enable-crosshair-highlight`,type:t.CommandType.OPERATION,handler(e){let t=e.get(b);return!t.enabled&&(t.setEnabled(!0),!0)}},w={id:`sheet.operation.disable-crosshair-highlight`,type:t.CommandType.OPERATION,handler(e){let t=e.get(b);return t.enabled?(t.setEnabled(!1),!0):!1}},T=`CROSSHAIR_HIGHLIGHT_OVERLAY_COMPONENT`;function E(e){let n=e.get(b);return{id:x.id,tooltip:`sheets-crosshair-highlight.button.tooltip`,type:r.MenuItemType.BUTTON_SELECTOR,icon:`CrossHighlightingIcon`,selections:[{label:{name:T,hoverable:!1,selectable:!1,props:{embedded:!0}}}],selectionsCommandId:S.id,activated$:n.enabled$,hidden$:(0,r.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_SHEET)}}let D={[r.RibbonViewGroup.DISPLAY]:{[x.id]:{order:2,gridLayout:{row:2,column:2},menuItemFactory:E}},[r.ContextMenuPosition.FOOTER_MENU]:{[r.ContextMenuGroup.OTHERS]:{[x.id]:{order:0,menuItemFactory:E}}}};var O=`@univerjs/sheets-crosshair-highlight`,k=`1.5.0`;let A=`sheets-crosshair-highlight.config`,j={},M=`SHEET_CROSSHAIR_HIGHLIGHT_PLUGIN`;function N({ref:e,...t}){let{preserveStrokeWidth:n,icon:r,id:i,className:a,extend:o,...c}=t,l=`univerjs-icon univerjs-icon-${i} ${a||``}`.trim(),u=`_${(0,s.useId)()}`,d=(0,s.useRef)(null);return(0,s.useImperativeHandle)(e,()=>d.current),(0,s.useLayoutEffect)(()=>{if(n&&d.current&&d.current.localName===r.tag)return L(d.current)},[n,r]),P(r,`${i}`,{defIds:r.defIds,idSuffix:u},{ref:d,className:l,...c},o)}function P(e,t,n,r,i){return(0,s.createElement)(e.tag,{key:t,...F(e,n,i),...r},(I(e,n).children||[]).map((r,a)=>P(r,`${t}-${e.tag}-${a}`,n,void 0,i)))}function F(e,t,n){let r={...e.attrs};n!=null&&n.colorChannel1&&r.fill===`colorChannel1`&&(r.fill=n.colorChannel1),n!=null&&n.colorChannel1&&r.stroke===`colorChannel1`&&(r.stroke=n.colorChannel1),e.tag===`mask`&&r.id&&(r.id+=t.idSuffix),Object.entries(r).forEach(([e,n])=>{e===`mask`&&typeof n==`string`&&(r[e]=n.replace(/url\(#(.*)\)/,`url(#$1${t.idSuffix})`))});let{defIds:i}=t;return!i||i.length===0||(e.tag===`use`&&r[`xlink:href`]&&(r[`xlink:href`]+=t.idSuffix),Object.entries(r).forEach(([e,n])=>{typeof n==`string`&&(r[e]=n.replace(/url\(#(.*)\)/,`url(#$1${t.idSuffix})`))})),r}function I(e,t){var n;let{defIds:r}=t;return!r||r.length===0?e:e.tag===`defs`&&(n=e.children)!=null&&n.length?{...e,children:e.children.map(e=>typeof e.attrs.id==`string`&&r&&r.includes(e.attrs.id)?{...e,attrs:{...e.attrs,id:e.attrs.id+t.idSuffix}}:e)}:e}function L(e){let t=e.viewBox.baseVal,n=Math.max(t.width,t.height);if(!Number.isFinite(n)||n<=0||t.width<=0||t.height<=0)return()=>void 0;let r=16/n,i=Array.from(e.querySelectorAll(`circle, ellipse, line, path, polygon, polyline, rect, text, textPath, tspan, use`)).flatMap(e=>{let t=getComputedStyle(e),n=Number.parseFloat(t.strokeWidth);return t.stroke===`none`||Number.parseFloat(t.strokeOpacity)===0||t.vectorEffect===`non-scaling-stroke`||!Number.isFinite(n)||n<=0?[]:[{element:e,hadStyleAttribute:e.hasAttribute(`style`),originalStrokeWidth:n,strokeWidth:R(e.style,`stroke-width`)}]}).map(e=>({appliedStrokeWidth:null,element:e.element,hadStyleAttribute:e.hadStyleAttribute,isReleased:!1,originalStrokeWidth:e.originalStrokeWidth,strokeWidth:e.strokeWidth}));if(i.length===0)return()=>void 0;let a=(e,n)=>{if(t.width<=0||t.height<=0||e<=0||n<=0)return;let a=Math.min(e/t.width,n/t.height);!Number.isFinite(a)||a<=0||i.forEach(e=>{if(e.isReleased)return;if(e.appliedStrokeWidth!==null&&(e.element.style.getPropertyValue(`stroke-width`)!==e.appliedStrokeWidth||e.element.style.getPropertyPriority(`stroke-width`)!==e.strokeWidth.priority)){e.appliedStrokeWidth=null,e.isReleased=!0;return}let t=e.originalStrokeWidth*r/a,n=`${Number(t.toFixed(12))}px`;e.element.style.setProperty(`stroke-width`,n,e.strokeWidth.priority),e.appliedStrokeWidth=n})},o=e.getBoundingClientRect();a(o.width,o.height);let s=typeof ResizeObserver>`u`?null:new ResizeObserver(t=>{if(t.some(t=>t.target===e)){let t=e.getBoundingClientRect();a(t.width,t.height)}});return s==null||s.observe(e),()=>{s==null||s.disconnect(),i.forEach(e=>{e.appliedStrokeWidth!==null&&(z(e.element.style,`stroke-width`,e.appliedStrokeWidth,e.strokeWidth.priority,e.strokeWidth),!e.hadStyleAttribute&&e.element.style.length===0&&e.element.removeAttribute(`style`))})}}function R(e,t){return{priority:e.getPropertyPriority(t),value:e.getPropertyValue(t)}}function z(e,t,n,r,i){e.getPropertyValue(t)===n&&e.getPropertyPriority(t)===r&&(i.value?e.setProperty(t,i.value,i.priority):e.removeProperty(t))}N.displayName=`UniverIcon`;let B={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{stroke:`currentColor`,d:`M5 2H2V5M11 2H14V5M14 11V14H11M5 14H2V11`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:1.3}},{tag:`path`,attrs:{stroke:`currentColor`,d:`M6.6 3.8H9.4V6.6H12.2V9.4H9.4V12.2H6.6V9.4H3.8V6.6H6.6V3.8Z`,strokeLinejoin:`round`,strokeWidth:1.15}},{tag:`rect`,attrs:{width:2.6,height:2.6,x:6.7,y:6.7,fill:`currentColor`,rx:.35}}]},V=(0,s.forwardRef)(function(e,t){return(0,s.createElement)(N,Object.assign({},e,{id:`cross-highlighting-icon`,ref:t,icon:B}))});V.displayName=`CrossHighlightingIcon`;let H=`sheet.menu.mobile.crosshair-highlight`,U=`MOBILE_CROSSHAIR_HIGHLIGHT_PANEL`;function W(e){return{id:H,type:r.MenuItemType.SELECTOR,icon:`CrossHighlightingIcon`,title:`sheets-crosshair-highlight.button.tooltip`,tooltip:`sheets-crosshair-highlight.button.tooltip`,selections:[{label:{name:U,hoverable:!1,selectable:!1}}],hidden$:(0,r.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_SHEET)}}function G(e){let{onChange:i}=e,a=(0,r.useDependency)(b),o=(0,r.useDependency)(t.ThemeService),u=(0,r.useObservable)(a.color$),d=(0,r.useObservable)(()=>o.currentTheme$.pipe((0,n.map)(()=>y(o))),y(o),!1,[o]),f=(0,s.useCallback)(e=>{i==null||i(e)},[i]);return/* @__PURE__ */ (0,l.jsx)(`div`,{className:`univer-grid univer-grid-cols-8 univer-gap-x-2 univer-gap-y-3 univer-p-1.5`,children:d.map((e,t)=>/* @__PURE__ */ (0,l.jsx)(`div`,{className:(0,c.clsx)(`univer-box-border univer-size-5 univer-cursor-pointer univer-rounded univer-ring-offset-1 univer-transition-shadow hover:univer-ring-[1.5px] hover:univer-ring-primary-600`,c.borderClassName,{"univer-ring-[1.5px] univer-ring-primary-600 hover:univer-ring-primary-600":e===u}),style:{backgroundColor:e},onClick:()=>f(g[t])},g[t]))})}function K(){let e=(0,r.useDependency)(t.ICommandService),i=(0,r.useDependency)(b),a=(0,r.useDependency)(t.LocaleService),o=(0,r.useDependency)(t.ThemeService),s=(0,r.useObservable)(i.enabled$,!1),u=(0,r.useObservable)(i.color$),d=(0,r.useObservable)(()=>o.currentTheme$.pipe((0,n.map)(()=>y(o))),y(o),!1,[o]);return/* @__PURE__ */ (0,l.jsxs)(`div`,{className:`univer-grid univer-w-full univer-gap-4 univer-p-4`,children:[/* @__PURE__ */ (0,l.jsxs)(`div`,{className:`univer-flex univer-min-h-8 univer-items-center univer-gap-4`,children:[/* @__PURE__ */ (0,l.jsx)(`span`,{className:`univer-min-w-0 univer-flex-1 univer-text-base univer-font-medium univer-text-gray-900 dark:!univer-text-gray-100`,children:a.t(`sheets-crosshair-highlight.button.tooltip`)}),/* @__PURE__ */ (0,l.jsx)(c.Switch,{"aria-label":a.t(`sheets-crosshair-highlight.button.tooltip`),defaultChecked:s,onChange:t=>{let n=t?C:w;e.executeCommand(n.id).catch(()=>void 0)}})]}),/* @__PURE__ */ (0,l.jsx)(`div`,{className:`univer-grid univer-grid-cols-8 univer-gap-3`,children:d.map((t,n)=>{let r=g[n],i=t===u;return/* @__PURE__ */ (0,l.jsx)(`button`,{type:`button`,"data-color-token":r,title:t,"aria-pressed":i,className:(0,c.clsx)(c.resetButtonClassName,`univer-box-border univer-size-8 univer-rounded-lg univer-border univer-border-solid univer-border-gray-200 univer-ring-offset-2 active:univer-opacity-70 dark:!univer-border-gray-600`,{"univer-ring-2 univer-ring-primary-600":i}),style:{backgroundColor:t},onClick:()=>{e.executeCommand(S.id,{value:r}).catch(()=>void 0)}},r)})})]})}let q=class extends t.Disposable{constructor(e,t){super(),this._componentManager=e,this._iconManager=t,this._registerComponents(),this._registerIcons()}_registerComponents(){this.disposeWithMe(this._componentManager.register(T,G)),this.disposeWithMe(this._componentManager.register(U,K))}_registerIcons(){this.disposeWithMe(this._iconManager.register({CrossHighlightingIcon:V}))}};q=h([m(0,(0,t.Inject)(r.ComponentManager)),m(1,(0,t.Inject)(r.IconManager))],q);let J={[r.RibbonDataGroup.ORGANIZATION]:{[H]:{order:21,menuItemFactory:W}}},Y=class extends t.Disposable{constructor(e,t){super(),[x,S,C,w].forEach(t=>this.disposeWithMe(e.registerCommand(t))),t.mergeMenu(J)}};Y=h([m(0,t.ICommandService),m(1,r.IMenuManagerService)],Y);var ee=class{constructor(){p(this,`_selectedRanges`,[]),p(this,`_ranges`,[])}addRange(e){if(e.rangeType===t.RANGE_TYPE.COLUMN||e.rangeType===t.RANGE_TYPE.ROW||e.rangeType===t.RANGE_TYPE.ALL)return;let n=this._getIntersects(e),r=this._getSplitRanges(e,n);r.length>0&&this._ranges.push(...r)}setSelectedRanges(e){this._selectedRanges=e}_getSplitRanges(e,n){let r=[e];for(let e of n.concat(this._selectedRanges)){let n=[];for(let i of r){let r=t.Rectangle.subtract(i,e);r&&r.length>0&&n.push(...r)}r=n}return r.filter(e=>e.startRow<=e.endRow&&e.startColumn<=e.endColumn)}_getIntersects(e){let n=[];for(let r of this._ranges){let i=(0,t.getIntersectRange)(r,e);i&&n.push(i)}return n}getRanges(){return this._ranges}reset(){this._ranges=[],this._selectedRanges=[]}},te=class extends i.Shape{constructor(e,t){super(e,t),p(this,`_color`,void 0),t&&this.setShapeProps(t)}setShapeProps(e){e.color!==void 0&&(this._color=e.color),this.transformByState({width:e.width,height:e.height})}_draw(e){var t;let n=`rgba(${this._color.r}, ${this._color.g}, ${this._color.b}, ${((t=this._color)==null?void 0:t.a)??.5})`;i.Rect.drawWith(e,{width:this.width,height:this.height,fill:n,stroke:void 0,strokeWidth:0,evented:!1})}};let X=class extends t.Disposable{constructor(e,t,n,r,i,a){super(),this._context=e,this._sheetSkeletonManagerService=t,this._sheetsSelectionsService=n,this._sheetsCrosshairHighlightService=r,this._contextService=i,this._refSelectionsService=a,p(this,`_shapes`,[]),p(this,`_rangeCollection`,new ee),p(this,`_color`,`rgba(255,0,0,0.5)`),this._initRenderListener()}_transformSelection(e,t){if(!e)return;let n=t.getRowCount(),r=t.getColumnCount(),i=[];for(let t of e){let{startRow:e,endRow:a,startColumn:o,endColumn:s}=t.range;a-e+1!==n&&s-o+1!==r&&i.push(t.range)}this._rangeCollection.setSelectedRanges(i);for(let e of i)this.addSelection(e,t)}_initRenderListener(){let e=this._context.unit;this.disposeWithMe((0,n.combineLatest)([this._contextService.subscribeContextValue$(a.REF_SELECTIONS_ENABLED).pipe((0,n.startWith)(!1)),this._sheetSkeletonManagerService.currentSkeleton$,this._sheetsCrosshairHighlightService.enabled$,this._sheetsCrosshairHighlightService.highlightColor$.pipe((0,n.tap)(e=>this._color=e)),(0,n.merge)(this._sheetsSelectionsService.selectionMoveStart$,this._sheetsSelectionsService.selectionMoving$,this._sheetsSelectionsService.selectionMoveEnd$,this._sheetsSelectionsService.selectionSet$,e.activeSheet$.pipe((0,n.map)(()=>this._sheetsSelectionsService.getCurrentSelections()))),(0,n.merge)(this._refSelectionsService.selectionMoveStart$,this._refSelectionsService.selectionMoving$,this._refSelectionsService.selectionMoveEnd$,this._sheetsSelectionsService.selectionSet$,e.activeSheet$.pipe((0,n.map)(()=>this._refSelectionsService.getCurrentSelections())))]).subscribe(([t,n,r,i,a,o])=>{if(this._clear(),!r)return;let s=t?o:a;this._rangeCollection.reset(),this._transformSelection(s,e.getActiveSheet()),this.render(this._rangeCollection.getRanges())}))}addSelection(e,n){if(e.rangeType===t.RANGE_TYPE.COLUMN||e.rangeType===t.RANGE_TYPE.ROW||e.rangeType===t.RANGE_TYPE.ALL)return;let r=n.getRowCount(),i=n.getColumnCount(),{startRow:a,endRow:o,startColumn:s,endColumn:c}=e,l={startRow:a,endRow:o,startColumn:0,endColumn:s-1},u={startRow:a,endRow:o,startColumn:c+1,endColumn:i},d={startRow:0,endRow:a-1,startColumn:s,endColumn:c},f={startRow:o+1,endRow:r,startColumn:s,endColumn:c};for(let e of[l,u,d,f])e.startRow<=e.endRow&&e.startColumn<=e.endColumn&&this._rangeCollection.addRange(e)}_clear(){this._shapes.forEach(e=>{e.dispose()}),this._shapes=[]}_addShapes(e,n,r,i){let{startRow:a,endRow:s,startColumn:c,endColumn:l}=e,u=(0,o.getCoordByCell)(a,c,r,i),d=(0,o.getCoordByCell)(s,l,r,i),{startX:f,startY:p}=u,{endX:m,endY:h}=d,g=m-f,_=h-p,v={left:f,top:p,color:new t.ColorKit(this._color).toRgb(),width:g,height:_,zIndex:1,evented:!1},y=new te(`crosshair-${n}`,v);this._shapes.push(y),r.addObject(y)}render(e){let t=this._sheetSkeletonManagerService.getCurrentSkeleton();if(!t)return;let{scene:n}=this._context;this._clear();for(let r=0;r<e.length;r++){let i=e[r];this._addShapes(i,r,n,t)}n.makeDirty(!0)}async dispose(){super.dispose()}};X=h([m(1,(0,t.Inject)(o.SheetSkeletonManagerService)),m(2,(0,t.Inject)(a.SheetsSelectionsService)),m(3,(0,t.Inject)(b)),m(4,(0,t.Inject)(t.IContextService)),m(5,a.IRefSelectionsService)],X);let Z=class extends t.Plugin{constructor(e=j,n,r,i){super(),this._config=e,this._injector=n,this._renderManagerService=r,this._configService=i;let{...a}=(0,t.merge)({},j,this._config);this._configService.setConfig(A,a)}onStarting(){[[q],[b],[Y]].forEach(e=>this._injector.add(e))}onReady(){this._injector.get(q),this._injector.get(Y),this.disposeWithMe(this._renderManagerService.registerRenderModule(t.UniverInstanceType.UNIVER_SHEET,[X]))}};p(Z,`pluginName`,M),p(Z,`packageName`,O),p(Z,`version`,k),p(Z,`type`,t.UniverInstanceType.UNIVER_SHEET),Z=h([(0,t.DependentOn)(i.UniverRenderEnginePlugin,a.UniverSheetsPlugin,o.UniverSheetsMobileUIPlugin,r.UniverMobileUIPlugin),m(1,(0,t.Inject)(t.Injector)),m(2,i.IRenderManagerService),m(3,t.IConfigService)],Z);let Q=class extends t.Disposable{constructor(e,t){super(),this._menuManagerService=e,this._cmdSrv=t,this._initCommands(),this._initMenus()}_initCommands(){[x,S,C,w].forEach(e=>this._cmdSrv.registerCommand(e))}_initMenus(){this._menuManagerService.mergeMenu(D)}};Q=h([m(0,r.IMenuManagerService),m(1,t.ICommandService)],Q);let $=class extends t.Plugin{constructor(e=j,n,r,i){super(),this._config=e,this._injector=n,this._renderManagerService=r,this._configService=i;let{...a}=(0,t.merge)({},j,this._config);this._configService.setConfig(A,a)}onStarting(){[[q],[b],[Q]].forEach(e=>this._injector.add(e))}onReady(){[[X]].forEach(e=>this._injector.add(e)),this._injector.get(q),this._injector.get(Q),this._renderManagerService.registerRenderModule(t.UniverInstanceType.UNIVER_SHEET,[X])}};p($,`pluginName`,M),p($,`packageName`,O),p($,`version`,k),p($,`type`,t.UniverInstanceType.UNIVER_SHEET),$=h([(0,t.DependentOn)(i.UniverRenderEnginePlugin,a.UniverSheetsPlugin,o.UniverSheetsUIPlugin),m(1,(0,t.Inject)(t.Injector)),m(2,i.IRenderManagerService),m(3,t.IConfigService)],$),e.DisableCrosshairHighlightOperation=w,e.EnableCrosshairHighlightOperation=C,e.SetCrosshairHighlightColorOperation=S,e.SheetsCrosshairHighlightMenuSchema=D,Object.defineProperty(e,"SheetsCrosshairHighlightService",{enumerable:!0,get:function(){return b}}),e.ToggleCrosshairHighlightOperation=x,Object.defineProperty(e,"UniverSheetsCrosshairHighlightMobileUIPlugin",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"UniverSheetsCrosshairHighlightPlugin",{enumerable:!0,get:function(){return $}})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@univerjs/sheets-crosshair-highlight",
3
- "version": "1.4.0",
3
+ "version": "1.5.0",
4
4
  "private": false,
5
5
  "description": "Crosshair highlight plugin for Univer Sheets.",
6
6
  "author": "DreamNum Co., Ltd. <developer@univer.ai>",
@@ -68,22 +68,22 @@
68
68
  "rxjs": ">=7.0.0"
69
69
  },
70
70
  "dependencies": {
71
- "@univerjs/core": "1.4.0",
72
- "@univerjs/design": "1.4.0",
73
- "@univerjs/engine-render": "1.4.0",
71
+ "@univerjs/core": "1.5.0",
72
+ "@univerjs/design": "1.5.0",
73
+ "@univerjs/engine-render": "1.5.0",
74
74
  "@univerjs/icons": "1.47.0",
75
- "@univerjs/sheets": "1.4.0",
76
- "@univerjs/sheets-ui": "1.4.0",
77
- "@univerjs/ui": "1.4.0"
75
+ "@univerjs/sheets": "1.5.0",
76
+ "@univerjs/sheets-ui": "1.5.0",
77
+ "@univerjs/ui": "1.5.0"
78
78
  },
79
79
  "devDependencies": {
80
- "@univerjs-infra/shared": "1.4.0",
80
+ "@univerjs-infra/shared": "1.5.0",
81
81
  "postcss": "^8.5.32",
82
82
  "react": "18.3.1",
83
83
  "rxjs": "7.8.2",
84
84
  "tailwindcss": "3.4.18",
85
- "tsrs": "0.20.1-ts7.1.0-beta",
86
- "vitest": "^5.0.5"
85
+ "tsrs": "0.23.0-ts7.1.0-beta",
86
+ "vitest": "^5.1.0"
87
87
  },
88
88
  "scripts": {
89
89
  "test": "vitest run",