@univerjs/sheets-crosshair-highlight 0.6.1-nightly.202502251606 → 0.6.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,176 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
package/lib/cjs/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";var F=Object.defineProperty;var X=(i,e,t)=>e in i?F(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t;var l=(i,e,t)=>X(i,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("@univerjs/core"),w=require("@univerjs/engine-render"),f=require("@univerjs/ui"),u=require("rxjs"),j=require("react/jsx-runtime"),S=require("react"),M=require("@univerjs/sheets"),$=require("@univerjs/sheets-ui"),K="sheets-crosshair-highlight.config",V={};var h=function(){return h=Object.assign||function(i){for(var e,t=1,r=arguments.length;t<r;t++){e=arguments[t];for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&(i[s]=e[s])}return i},h.apply(this,arguments)},z=function(i,e){var t={};for(var r in i)Object.prototype.hasOwnProperty.call(i,r)&&e.indexOf(r)<0&&(t[r]=i[r]);if(i!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,r=Object.getOwnPropertySymbols(i);s<r.length;s++)e.indexOf(r[s])<0&&Object.prototype.propertyIsEnumerable.call(i,r[s])&&(t[r[s]]=i[r[s]]);return t},A=S.forwardRef(function(i,e){var t=i.icon,r=i.id,s=i.className,n=i.extend,o=z(i,["icon","id","className","extend"]),c="univerjs-icon univerjs-icon-".concat(r," ").concat(s||"").trim(),g=S.useRef("_".concat(ee()));return L(t,"".concat(r),{defIds:t.defIds,idSuffix:g.current},h({ref:e,className:c},o),n)});function L(i,e,t,r,s){return S.createElement(i.tag,h(h({key:e},J(i,t,s)),r),(Q(i,t).children||[]).map(function(n,o){return L(n,"".concat(e,"-").concat(i.tag,"-").concat(o),t,void 0,s)}))}function J(i,e,t){var r=h({},i.attrs);t!=null&&t.colorChannel1&&r.fill==="colorChannel1"&&(r.fill=t.colorChannel1),i.tag==="mask"&&r.id&&(r.id=r.id+e.idSuffix),Object.entries(r).forEach(function(n){var o=n[0],c=n[1];o==="mask"&&typeof c=="string"&&(r[o]=c.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))});var s=e.defIds;return!s||s.length===0||(i.tag==="use"&&r["xlink:href"]&&(r["xlink:href"]=r["xlink:href"]+e.idSuffix),Object.entries(r).forEach(function(n){var o=n[0],c=n[1];typeof c=="string"&&(r[o]=c.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))})),r}function Q(i,e){var t,r=e.defIds;return!r||r.length===0?i:i.tag==="defs"&&(!((t=i.children)===null||t===void 0)&&t.length)?h(h({},i),{children:i.children.map(function(s){return typeof s.attrs.id=="string"&&r&&r.indexOf(s.attrs.id)>-1?h(h({},s),{attrs:h(h({},s.attrs),{id:s.attrs.id+e.idSuffix})}):s})}):i}function ee(){return Math.random().toString(36).substring(2,8)}A.displayName="UniverIcon";var te={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"}}]},G=S.forwardRef(function(i,e){return S.createElement(A,Object.assign({},i,{id:"cross-highlighting-single",ref:e,icon:te}))});G.displayName="CrossHighlightingSingle";const x=["rgba(158, 109, 227, 0.3)","rgba(254, 75, 75, 0.3)","rgba(255, 140, 81, 0.3)","rgba(164, 220, 22, 0.3)","rgba(45, 174, 255, 0.3)","rgba(58, 96, 247, 0.3)","rgba(242, 72, 166, 0.3)","rgba(153, 153, 153, 0.3)","rgba(158, 109, 227, 0.15)","rgba(254, 75, 75, 0.15)","rgba(255, 140, 81, 0.15)","rgba(164, 220, 22, 0.15)","rgba(45, 174, 255, 0.15)","rgba(58, 96, 247, 0.15)","rgba(242, 72, 166, 0.15)","rgba(153, 153, 153, 0.15)"];class d extends a.Disposable{constructor(){super(...arguments);l(this,"_enabled$",new u.BehaviorSubject(!1));l(this,"enabled$",this._enabled$.asObservable());l(this,"_color$",new u.BehaviorSubject(x[0]));l(this,"color$",this._color$.asObservable())}get enabled(){return this._enabled$.getValue()}get color(){return this._color$.getValue()}dispose(){this._enabled$.complete()}setEnabled(t){this._enabled$.next(t)}setColor(t){this._color$.next(t)}}const I={id:"sheet.operation.toggle-crosshair-highlight",type:a.CommandType.OPERATION,handler(i){const e=i.get(d),t=e.enabled;return e.setEnabled(!t),!0}},N={id:"sheet.operation.set-crosshair-highlight-color",type:a.CommandType.OPERATION,handler(i,{value:e}){const t=i.get(d);return t.enabled||t.setEnabled(!0),t.setColor(e),!0}},k={id:"sheet.operation.enable-crosshair-highlight",type:a.CommandType.OPERATION,handler(i){const e=i.get(d);return e.enabled?!1:(e.setEnabled(!0),!0)}},U={id:"sheet.operation.disable-crosshair-highlight",type:a.CommandType.OPERATION,handler(i){const e=i.get(d);return e.enabled?(e.setEnabled(!1),!0):!1}};function D(i){var e,t,r="";if(typeof i=="string"||typeof i=="number")r+=i;else if(typeof i=="object")if(Array.isArray(i)){var s=i.length;for(e=0;e<s;e++)i[e]&&(t=D(i[e]))&&(r&&(r+=" "),r+=t)}else for(t in i)i[t]&&(r&&(r+=" "),r+=t);return r}function re(){for(var i,e,t=0,r="",s=arguments.length;t<s;t++)(i=arguments[t])&&(e=D(i))&&(r&&(r+=" "),r+=e);return r}const ie="univer-crosshair-highlight-overlay",se="univer-crosshair-highlight-item",ne="univer-crosshair-highlight-item-selected",E={crosshairHighlightOverlay:ie,crosshairHighlightItem:se,crosshairHighlightItemSelected:ne};function oe(i){const{onChange:e}=i,t=f.useDependency(d),r=f.useObservable(t.color$),s=S.useCallback(n=>{e==null||e(n)},[e]);return j.jsx("div",{className:E.crosshairHighlightOverlay,children:x.map(n=>j.jsx("div",{className:re(E.crosshairHighlightItem,{[E.crosshairHighlightItemSelected]:n===r}),style:{backgroundColor:n},onClick:()=>s(n)},n))})}const Y="CROSSHAIR_HIGHLIGHT_OVERLAY_COMPONENT";function ae(i){const e=i.get(d);return{id:I.id,tooltip:"crosshair.button.tooltip",type:f.MenuItemType.BUTTON_SELECTOR,icon:"CrossHighlightingSingle",selections:[{label:{name:Y,hoverable:!1}}],selectionsCommandId:N.id,activated$:e.enabled$,hidden$:f.getMenuHiddenObservable(i,a.UniverInstanceType.UNIVER_SHEET)}}const ce={[f.ContextMenuPosition.FOOTER_MENU]:{[f.ContextMenuGroup.OTHERS]:{[I.id]:{order:0,menuItemFactory:ae}}}};var le=Object.getOwnPropertyDescriptor,he=(i,e,t,r)=>{for(var s=r>1?void 0:r?le(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(s=o(s)||s);return s},y=(i,e)=>(t,r)=>e(t,r,i);let R=class extends a.Disposable{constructor(i,e,t){super(),this._componentMgr=i,this._menuManagerService=e,this._cmdSrv=t,this._initCommands(),this._initMenus(),this._initComponents()}_initCommands(){[I,N,k,U].forEach(i=>this._cmdSrv.registerCommand(i))}_initMenus(){this._menuManagerService.mergeMenu(ce)}_initComponents(){this._componentMgr.register(Y,oe),this._componentMgr.register("CrossHighlightingSingle",G)}};R=he([y(0,a.Inject(f.ComponentManager)),y(1,f.IMenuManagerService),y(2,a.ICommandService)],R);const ge=1;class ue{constructor(){l(this,"_selectedRanges",[]);l(this,"_ranges",[])}addRange(e){if(e.rangeType===a.RANGE_TYPE.COLUMN||e.rangeType===a.RANGE_TYPE.ROW||e.rangeType===a.RANGE_TYPE.ALL)return;const t=this._getIntersects(e),r=this._getSplitRanges(e,t);r.length>0&&this._ranges.push(...r)}setSelectedRanges(e){this._selectedRanges=e}_getSplitRanges(e,t){let r=[e];for(const s of t.concat(this._selectedRanges)){const n=[];for(const o of r){const c=a.Rectangle.subtract(o,s);c&&c.length>0&&n.push(...c)}r=n}return r.filter(s=>s.startRow<=s.endRow&&s.startColumn<=s.endColumn)}_getIntersects(e){const t=[];for(const r of this._ranges){const s=a.Rectangle.getIntersects(r,e);s&&t.push(s)}return t}getRanges(){return this._ranges}reset(){this._ranges=[],this._selectedRanges=[]}}class de extends w.Shape{constructor(t,r){super(t,r);l(this,"_color");r&&this.setShapeProps(r)}setShapeProps(t){typeof t.color<"u"&&(this._color=t.color),this.transformByState({width:t.width,height:t.height})}_draw(t){var s,n;const r=`rgba(${this._color.r}, ${this._color.g}, ${this._color.b}, ${(n=(s=this._color)==null?void 0:s.a)!=null?n:.5})`;w.Rect.drawWith(t,{width:this.width,height:this.height,fill:r,stroke:void 0,strokeWidth:0,evented:!1})}}var fe=Object.getOwnPropertyDescriptor,_e=(i,e,t,r)=>{for(var s=r>1?void 0:r?fe(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(s=o(s)||s);return s},p=(i,e)=>(t,r)=>e(t,r,i);let O=class extends a.Disposable{constructor(e,t,r,s,n,o){super();l(this,"_shapes",[]);l(this,"_rangeCollection",new ue);l(this,"_color","rgba(255,0,0,0.5)");this._context=e,this._sheetSkeletonManagerService=t,this._sheetsSelectionsService=r,this._sheetsCrosshairHighlightService=s,this._contextService=n,this._refSelectionsService=o,this._initRenderListener()}_transformSelection(e,t){if(!e)return;const r=t.getRowCount(),s=t.getColumnCount(),n=[];for(const o of e){const{startRow:c,endRow:g,startColumn:v,endColumn:C}=o.range;g-c+1===r||C-v+1===s||n.push(o.range)}this._rangeCollection.setSelectedRanges(n);for(const o of n)this.addSelection(o,t)}_initRenderListener(){const e=this._context.unit;this.disposeWithMe(u.combineLatest([this._contextService.subscribeContextValue$(M.REF_SELECTIONS_ENABLED).pipe(u.startWith(!1)),this._sheetSkeletonManagerService.currentSkeleton$,this._sheetsCrosshairHighlightService.enabled$,this._sheetsCrosshairHighlightService.color$.pipe(u.tap(t=>this._color=t)),u.merge(this._sheetsSelectionsService.selectionMoveStart$,this._sheetsSelectionsService.selectionMoving$,this._sheetsSelectionsService.selectionMoveEnd$,this._sheetsSelectionsService.selectionSet$,e.activeSheet$.pipe(u.map(()=>this._sheetsSelectionsService.getCurrentSelections()))),u.merge(this._refSelectionsService.selectionMoveStart$,this._refSelectionsService.selectionMoving$,this._refSelectionsService.selectionMoveEnd$,this._sheetsSelectionsService.selectionSet$,e.activeSheet$.pipe(u.map(()=>this._refSelectionsService.getCurrentSelections())))]).subscribe(([t,r,s,n,o,c])=>{if(this._clear(),!s)return;const g=t?c:o;this._rangeCollection.reset(),this._transformSelection(g,e.getActiveSheet()),this.render(this._rangeCollection.getRanges())}))}addSelection(e,t){if(e.rangeType===a.RANGE_TYPE.COLUMN||e.rangeType===a.RANGE_TYPE.ROW||e.rangeType===a.RANGE_TYPE.ALL)return;const r=t.getRowCount(),s=t.getColumnCount(),{startRow:n,endRow:o,startColumn:c,endColumn:g}=e,v={startRow:n,endRow:o,startColumn:0,endColumn:c-1},C={startRow:n,endRow:o,startColumn:g+1,endColumn:s},m={startRow:0,endRow:n-1,startColumn:c,endColumn:g},H={startRow:o+1,endRow:r,startColumn:c,endColumn:g};for(const _ of[v,C,m,H])_.startRow<=_.endRow&&_.startColumn<=_.endColumn&&this._rangeCollection.addRange(_)}_clear(){this._shapes.forEach(e=>{e.dispose()}),this._shapes=[]}_addShapes(e,t,r,s){const{startRow:n,endRow:o,startColumn:c,endColumn:g}=e,v=$.getCoordByCell(n,c,r,s),C=$.getCoordByCell(o,g,r,s),{startX:m,startY:H}=v,{endX:_,endY:B}=C,Z=_-m,q=B-H,W={left:m,top:H,color:new a.ColorKit(this._color).toRgb(),width:Z,height:q,zIndex:ge,evented:!1},P=new de(`crosshair-${t}`,W);this._shapes.push(P),r.addObject(P)}render(e){const t=this._sheetSkeletonManagerService.getCurrentSkeleton();if(!t)return;const{scene:r}=this._context;this._clear();for(let s=0;s<e.length;s++){const n=e[s];this._addShapes(n,s,r,t)}r.makeDirty(!0)}async dispose(){super.dispose()}};O=_e([p(1,a.Inject($.SheetSkeletonManagerService)),p(2,a.Inject(M.SheetsSelectionsService)),p(3,a.Inject(d)),p(4,a.Inject(a.IContextService)),p(5,M.IRefSelectionsService)],O);var Se=Object.getOwnPropertyDescriptor,ve=(i,e,t,r)=>{for(var s=r>1?void 0:r?Se(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(s=o(s)||s);return s},T=(i,e)=>(t,r)=>e(t,r,i),b;exports.UniverSheetsCrosshairHighlightPlugin=(b=class extends a.Plugin{constructor(e=V,t,r,s){super(),this._config=e,this._injector=t,this._renderManagerService=r,this._configService=s;const{...n}=a.merge({},V,this._config);this._configService.setConfig(K,n)}onStarting(){[[d],[R]].forEach(e=>this._injector.add(e))}onReady(){[[O]].forEach(e=>this._injector.add(e)),this._injector.get(R),this._renderManagerService.registerRenderModule(a.UniverInstanceType.UNIVER_SHEET,[O])}},l(b,"pluginName","SHEET_CROSSHAIR_HIGHLIGHT_PLUGIN"),l(b,"type",a.UniverInstanceType.UNIVER_SHEET),b);exports.UniverSheetsCrosshairHighlightPlugin=ve([T(1,a.Inject(a.Injector)),T(2,w.IRenderManagerService),T(3,a.IConfigService)],exports.UniverSheetsCrosshairHighlightPlugin);exports.CROSSHAIR_HIGHLIGHT_COLORS=x;exports.DisableCrosshairHighlightOperation=U;exports.EnableCrosshairHighlightOperation=k;exports.SetCrosshairHighlightColorOperation=N;exports.SheetsCrosshairHighlightService=d;exports.ToggleCrosshairHighlightOperation=I;
1
+ "use strict";var W=Object.defineProperty;var F=(i,e,t)=>e in i?W(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t;var l=(i,e,t)=>F(i,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("@univerjs/core"),w=require("@univerjs/engine-render"),f=require("@univerjs/ui"),d=require("rxjs"),j=require("react/jsx-runtime"),X=require("@univerjs/design"),S=require("react"),M=require("@univerjs/sheets"),$=require("@univerjs/sheets-ui"),K="sheets-crosshair-highlight.config",V={};var h=function(){return h=Object.assign||function(i){for(var e,t=1,r=arguments.length;t<r;t++){e=arguments[t];for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&(i[s]=e[s])}return i},h.apply(this,arguments)},z=function(i,e){var t={};for(var r in i)Object.prototype.hasOwnProperty.call(i,r)&&e.indexOf(r)<0&&(t[r]=i[r]);if(i!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,r=Object.getOwnPropertySymbols(i);s<r.length;s++)e.indexOf(r[s])<0&&Object.prototype.propertyIsEnumerable.call(i,r[s])&&(t[r[s]]=i[r[s]]);return t},A=S.forwardRef(function(i,e){var t=i.icon,r=i.id,s=i.className,n=i.extend,o=z(i,["icon","id","className","extend"]),c="univerjs-icon univerjs-icon-".concat(r," ").concat(s||"").trim(),g=S.useRef("_".concat(ee()));return L(t,"".concat(r),{defIds:t.defIds,idSuffix:g.current},h({ref:e,className:c},o),n)});function L(i,e,t,r,s){return S.createElement(i.tag,h(h({key:e},J(i,t,s)),r),(Q(i,t).children||[]).map(function(n,o){return L(n,"".concat(e,"-").concat(i.tag,"-").concat(o),t,void 0,s)}))}function J(i,e,t){var r=h({},i.attrs);t!=null&&t.colorChannel1&&r.fill==="colorChannel1"&&(r.fill=t.colorChannel1),i.tag==="mask"&&r.id&&(r.id=r.id+e.idSuffix),Object.entries(r).forEach(function(n){var o=n[0],c=n[1];o==="mask"&&typeof c=="string"&&(r[o]=c.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))});var s=e.defIds;return!s||s.length===0||(i.tag==="use"&&r["xlink:href"]&&(r["xlink:href"]=r["xlink:href"]+e.idSuffix),Object.entries(r).forEach(function(n){var o=n[0],c=n[1];typeof c=="string"&&(r[o]=c.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))})),r}function Q(i,e){var t,r=e.defIds;return!r||r.length===0?i:i.tag==="defs"&&(!((t=i.children)===null||t===void 0)&&t.length)?h(h({},i),{children:i.children.map(function(s){return typeof s.attrs.id=="string"&&r&&r.indexOf(s.attrs.id)>-1?h(h({},s),{attrs:h(h({},s.attrs),{id:s.attrs.id+e.idSuffix})}):s})}):i}function ee(){return Math.random().toString(36).substring(2,8)}A.displayName="UniverIcon";var te={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"}}]},G=S.forwardRef(function(i,e){return S.createElement(A,Object.assign({},i,{id:"cross-highlighting-single",ref:e,icon:te}))});G.displayName="CrossHighlightingSingle";const x=["rgba(158, 109, 227, 0.3)","rgba(254, 75, 75, 0.3)","rgba(255, 140, 81, 0.3)","rgba(164, 220, 22, 0.3)","rgba(45, 174, 255, 0.3)","rgba(58, 96, 247, 0.3)","rgba(242, 72, 166, 0.3)","rgba(153, 153, 153, 0.3)","rgba(158, 109, 227, 0.15)","rgba(254, 75, 75, 0.15)","rgba(255, 140, 81, 0.15)","rgba(164, 220, 22, 0.15)","rgba(45, 174, 255, 0.15)","rgba(58, 96, 247, 0.15)","rgba(242, 72, 166, 0.15)","rgba(153, 153, 153, 0.15)"];class u extends a.Disposable{constructor(){super(...arguments);l(this,"_enabled$",new d.BehaviorSubject(!1));l(this,"enabled$",this._enabled$.asObservable());l(this,"_color$",new d.BehaviorSubject(x[0]));l(this,"color$",this._color$.asObservable())}get enabled(){return this._enabled$.getValue()}get color(){return this._color$.getValue()}dispose(){this._enabled$.complete()}setEnabled(t){this._enabled$.next(t)}setColor(t){this._color$.next(t)}}const I={id:"sheet.operation.toggle-crosshair-highlight",type:a.CommandType.OPERATION,handler(i){const e=i.get(u),t=e.enabled;return e.setEnabled(!t),!0}},N={id:"sheet.operation.set-crosshair-highlight-color",type:a.CommandType.OPERATION,handler(i,{value:e}){const t=i.get(u);return t.enabled||t.setEnabled(!0),t.setColor(e),!0}},k={id:"sheet.operation.enable-crosshair-highlight",type:a.CommandType.OPERATION,handler(i){const e=i.get(u);return e.enabled?!1:(e.setEnabled(!0),!0)}},U={id:"sheet.operation.disable-crosshair-highlight",type:a.CommandType.OPERATION,handler(i){const e=i.get(u);return e.enabled?(e.setEnabled(!1),!0):!1}},re="univer-crosshair-highlight-overlay",ie="univer-crosshair-highlight-item",se="univer-crosshair-highlight-item-selected",E={crosshairHighlightOverlay:re,crosshairHighlightItem:ie,crosshairHighlightItemSelected:se};function ne(i){const{onChange:e}=i,t=f.useDependency(u),r=f.useObservable(t.color$),s=S.useCallback(n=>{e==null||e(n)},[e]);return j.jsx("div",{className:E.crosshairHighlightOverlay,children:x.map(n=>j.jsx("div",{className:X.clsx(E.crosshairHighlightItem,{[E.crosshairHighlightItemSelected]:n===r}),style:{backgroundColor:n},onClick:()=>s(n)},n))})}const D="CROSSHAIR_HIGHLIGHT_OVERLAY_COMPONENT";function oe(i){const e=i.get(u);return{id:I.id,tooltip:"crosshair.button.tooltip",type:f.MenuItemType.BUTTON_SELECTOR,icon:"CrossHighlightingSingle",selections:[{label:{name:D,hoverable:!1}}],selectionsCommandId:N.id,activated$:e.enabled$,hidden$:f.getMenuHiddenObservable(i,a.UniverInstanceType.UNIVER_SHEET)}}const ae={[f.ContextMenuPosition.FOOTER_MENU]:{[f.ContextMenuGroup.OTHERS]:{[I.id]:{order:0,menuItemFactory:oe}}}};var ce=Object.getOwnPropertyDescriptor,le=(i,e,t,r)=>{for(var s=r>1?void 0:r?ce(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(s=o(s)||s);return s},y=(i,e)=>(t,r)=>e(t,r,i);let b=class extends a.Disposable{constructor(i,e,t){super(),this._componentMgr=i,this._menuManagerService=e,this._cmdSrv=t,this._initCommands(),this._initMenus(),this._initComponents()}_initCommands(){[I,N,k,U].forEach(i=>this._cmdSrv.registerCommand(i))}_initMenus(){this._menuManagerService.mergeMenu(ae)}_initComponents(){this._componentMgr.register(D,ne),this._componentMgr.register("CrossHighlightingSingle",G)}};b=le([y(0,a.Inject(f.ComponentManager)),y(1,f.IMenuManagerService),y(2,a.ICommandService)],b);const he=1;class ge{constructor(){l(this,"_selectedRanges",[]);l(this,"_ranges",[])}addRange(e){if(e.rangeType===a.RANGE_TYPE.COLUMN||e.rangeType===a.RANGE_TYPE.ROW||e.rangeType===a.RANGE_TYPE.ALL)return;const t=this._getIntersects(e),r=this._getSplitRanges(e,t);r.length>0&&this._ranges.push(...r)}setSelectedRanges(e){this._selectedRanges=e}_getSplitRanges(e,t){let r=[e];for(const s of t.concat(this._selectedRanges)){const n=[];for(const o of r){const c=a.Rectangle.subtract(o,s);c&&c.length>0&&n.push(...c)}r=n}return r.filter(s=>s.startRow<=s.endRow&&s.startColumn<=s.endColumn)}_getIntersects(e){const t=[];for(const r of this._ranges){const s=a.Rectangle.getIntersects(r,e);s&&t.push(s)}return t}getRanges(){return this._ranges}reset(){this._ranges=[],this._selectedRanges=[]}}class de extends w.Shape{constructor(t,r){super(t,r);l(this,"_color");r&&this.setShapeProps(r)}setShapeProps(t){typeof t.color<"u"&&(this._color=t.color),this.transformByState({width:t.width,height:t.height})}_draw(t){var s,n;const r=`rgba(${this._color.r}, ${this._color.g}, ${this._color.b}, ${(n=(s=this._color)==null?void 0:s.a)!=null?n:.5})`;w.Rect.drawWith(t,{width:this.width,height:this.height,fill:r,stroke:void 0,strokeWidth:0,evented:!1})}}var ue=Object.getOwnPropertyDescriptor,fe=(i,e,t,r)=>{for(var s=r>1?void 0:r?ue(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(s=o(s)||s);return s},p=(i,e)=>(t,r)=>e(t,r,i);let O=class extends a.Disposable{constructor(e,t,r,s,n,o){super();l(this,"_shapes",[]);l(this,"_rangeCollection",new ge);l(this,"_color","rgba(255,0,0,0.5)");this._context=e,this._sheetSkeletonManagerService=t,this._sheetsSelectionsService=r,this._sheetsCrosshairHighlightService=s,this._contextService=n,this._refSelectionsService=o,this._initRenderListener()}_transformSelection(e,t){if(!e)return;const r=t.getRowCount(),s=t.getColumnCount(),n=[];for(const o of e){const{startRow:c,endRow:g,startColumn:v,endColumn:C}=o.range;g-c+1===r||C-v+1===s||n.push(o.range)}this._rangeCollection.setSelectedRanges(n);for(const o of n)this.addSelection(o,t)}_initRenderListener(){const e=this._context.unit;this.disposeWithMe(d.combineLatest([this._contextService.subscribeContextValue$(M.REF_SELECTIONS_ENABLED).pipe(d.startWith(!1)),this._sheetSkeletonManagerService.currentSkeleton$,this._sheetsCrosshairHighlightService.enabled$,this._sheetsCrosshairHighlightService.color$.pipe(d.tap(t=>this._color=t)),d.merge(this._sheetsSelectionsService.selectionMoveStart$,this._sheetsSelectionsService.selectionMoving$,this._sheetsSelectionsService.selectionMoveEnd$,this._sheetsSelectionsService.selectionSet$,e.activeSheet$.pipe(d.map(()=>this._sheetsSelectionsService.getCurrentSelections()))),d.merge(this._refSelectionsService.selectionMoveStart$,this._refSelectionsService.selectionMoving$,this._refSelectionsService.selectionMoveEnd$,this._sheetsSelectionsService.selectionSet$,e.activeSheet$.pipe(d.map(()=>this._refSelectionsService.getCurrentSelections())))]).subscribe(([t,r,s,n,o,c])=>{if(this._clear(),!s)return;const g=t?c:o;this._rangeCollection.reset(),this._transformSelection(g,e.getActiveSheet()),this.render(this._rangeCollection.getRanges())}))}addSelection(e,t){if(e.rangeType===a.RANGE_TYPE.COLUMN||e.rangeType===a.RANGE_TYPE.ROW||e.rangeType===a.RANGE_TYPE.ALL)return;const r=t.getRowCount(),s=t.getColumnCount(),{startRow:n,endRow:o,startColumn:c,endColumn:g}=e,v={startRow:n,endRow:o,startColumn:0,endColumn:c-1},C={startRow:n,endRow:o,startColumn:g+1,endColumn:s},m={startRow:0,endRow:n-1,startColumn:c,endColumn:g},H={startRow:o+1,endRow:r,startColumn:c,endColumn:g};for(const _ of[v,C,m,H])_.startRow<=_.endRow&&_.startColumn<=_.endColumn&&this._rangeCollection.addRange(_)}_clear(){this._shapes.forEach(e=>{e.dispose()}),this._shapes=[]}_addShapes(e,t,r,s){const{startRow:n,endRow:o,startColumn:c,endColumn:g}=e,v=$.getCoordByCell(n,c,r,s),C=$.getCoordByCell(o,g,r,s),{startX:m,startY:H}=v,{endX:_,endY:Y}=C,q=_-m,B=Y-H,Z={left:m,top:H,color:new a.ColorKit(this._color).toRgb(),width:q,height:B,zIndex:he,evented:!1},P=new de(`crosshair-${t}`,Z);this._shapes.push(P),r.addObject(P)}render(e){const t=this._sheetSkeletonManagerService.getCurrentSkeleton();if(!t)return;const{scene:r}=this._context;this._clear();for(let s=0;s<e.length;s++){const n=e[s];this._addShapes(n,s,r,t)}r.makeDirty(!0)}async dispose(){super.dispose()}};O=fe([p(1,a.Inject($.SheetSkeletonManagerService)),p(2,a.Inject(M.SheetsSelectionsService)),p(3,a.Inject(u)),p(4,a.Inject(a.IContextService)),p(5,M.IRefSelectionsService)],O);var _e=Object.getOwnPropertyDescriptor,Se=(i,e,t,r)=>{for(var s=r>1?void 0:r?_e(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(s=o(s)||s);return s},T=(i,e)=>(t,r)=>e(t,r,i),R;exports.UniverSheetsCrosshairHighlightPlugin=(R=class extends a.Plugin{constructor(e=V,t,r,s){super(),this._config=e,this._injector=t,this._renderManagerService=r,this._configService=s;const{...n}=a.merge({},V,this._config);this._configService.setConfig(K,n)}onStarting(){[[u],[b]].forEach(e=>this._injector.add(e))}onReady(){[[O]].forEach(e=>this._injector.add(e)),this._injector.get(b),this._renderManagerService.registerRenderModule(a.UniverInstanceType.UNIVER_SHEET,[O])}},l(R,"pluginName","SHEET_CROSSHAIR_HIGHLIGHT_PLUGIN"),l(R,"type",a.UniverInstanceType.UNIVER_SHEET),R);exports.UniverSheetsCrosshairHighlightPlugin=Se([T(1,a.Inject(a.Injector)),T(2,w.IRenderManagerService),T(3,a.IConfigService)],exports.UniverSheetsCrosshairHighlightPlugin);exports.CROSSHAIR_HIGHLIGHT_COLORS=x;exports.DisableCrosshairHighlightOperation=U;exports.EnableCrosshairHighlightOperation=k;exports.SetCrosshairHighlightColorOperation=N;exports.SheetsCrosshairHighlightService=u;exports.ToggleCrosshairHighlightOperation=I;
package/lib/es/index.js CHANGED
@@ -1,20 +1,21 @@
1
- var J = Object.defineProperty;
2
- var Q = (s, e, t) => e in s ? J(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t;
3
- var c = (s, e, t) => Q(s, typeof e != "symbol" ? e + "" : e, t);
4
- import { Disposable as w, CommandType as R, UniverInstanceType as E, Inject as u, ICommandService as ee, RANGE_TYPE as f, Rectangle as x, IContextService as te, ColorKit as re, Plugin as se, merge as ne, Injector as ie, IConfigService as oe } from "@univerjs/core";
5
- import { Shape as ae, Rect as ce, IRenderManagerService as le } from "@univerjs/engine-render";
6
- import { useDependency as he, useObservable as ge, getMenuHiddenObservable as de, MenuItemType as ue, ContextMenuPosition as fe, ContextMenuGroup as _e, ComponentManager as Se, IMenuManagerService as ve } from "@univerjs/ui";
7
- import { BehaviorSubject as T, combineLatest as me, merge as V, startWith as Ce, tap as pe, map as N } from "rxjs";
1
+ var q = Object.defineProperty;
2
+ var J = (s, e, t) => e in s ? q(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t;
3
+ var c = (s, e, t) => J(s, typeof e != "symbol" ? e + "" : e, t);
4
+ import { Disposable as w, CommandType as R, UniverInstanceType as y, Inject as u, ICommandService as Q, RANGE_TYPE as f, Rectangle as x, IContextService as ee, ColorKit as te, Plugin as re, merge as se, Injector as ie, IConfigService as ne } from "@univerjs/core";
5
+ import { Shape as oe, Rect as ae, IRenderManagerService as ce } from "@univerjs/engine-render";
6
+ import { useDependency as le, useObservable as he, getMenuHiddenObservable as ge, MenuItemType as de, ContextMenuPosition as ue, ContextMenuGroup as fe, ComponentManager as _e, IMenuManagerService as Se } from "@univerjs/ui";
7
+ import { BehaviorSubject as T, combineLatest as ve, merge as V, startWith as Ce, tap as me, map as N } from "rxjs";
8
8
  import { jsx as P } from "react/jsx-runtime";
9
- import { forwardRef as k, useRef as He, createElement as G, useCallback as be } from "react";
9
+ import { clsx as pe } from "@univerjs/design";
10
+ import { forwardRef as A, useRef as He, createElement as G, useCallback as be } from "react";
10
11
  import { SheetsSelectionsService as Re, IRefSelectionsService as Oe, REF_SELECTIONS_ENABLED as Ie } from "@univerjs/sheets";
11
- import { SheetSkeletonManagerService as ye, getCoordByCell as j } from "@univerjs/sheets-ui";
12
- const Ee = "sheets-crosshair-highlight.config", L = {};
12
+ import { SheetSkeletonManagerService as Ee, getCoordByCell as j } from "@univerjs/sheets-ui";
13
+ const ye = "sheets-crosshair-highlight.config", L = {};
13
14
  var l = function() {
14
15
  return l = Object.assign || function(s) {
15
16
  for (var e, t = 1, r = arguments.length; t < r; t++) {
16
17
  e = arguments[t];
17
- for (var n in e) Object.prototype.hasOwnProperty.call(e, n) && (s[n] = e[n]);
18
+ for (var i in e) Object.prototype.hasOwnProperty.call(e, i) && (s[i] = e[i]);
18
19
  }
19
20
  return s;
20
21
  }, l.apply(this, arguments);
@@ -22,41 +23,41 @@ var l = function() {
22
23
  var t = {};
23
24
  for (var r in s) Object.prototype.hasOwnProperty.call(s, r) && e.indexOf(r) < 0 && (t[r] = s[r]);
24
25
  if (s != null && typeof Object.getOwnPropertySymbols == "function")
25
- for (var n = 0, r = Object.getOwnPropertySymbols(s); n < r.length; n++)
26
- e.indexOf(r[n]) < 0 && Object.prototype.propertyIsEnumerable.call(s, r[n]) && (t[r[n]] = s[r[n]]);
26
+ for (var i = 0, r = Object.getOwnPropertySymbols(s); i < r.length; i++)
27
+ e.indexOf(r[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, r[i]) && (t[r[i]] = s[r[i]]);
27
28
  return t;
28
- }, U = k(function(s, e) {
29
- var t = s.icon, r = s.id, n = s.className, i = s.extend, o = we(s, ["icon", "id", "className", "extend"]), a = "univerjs-icon univerjs-icon-".concat(r, " ").concat(n || "").trim(), h = He("_".concat(xe()));
30
- return D(t, "".concat(r), { defIds: t.defIds, idSuffix: h.current }, l({ ref: e, className: a }, o), i);
29
+ }, U = A(function(s, e) {
30
+ var t = s.icon, r = s.id, i = s.className, n = s.extend, o = we(s, ["icon", "id", "className", "extend"]), a = "univerjs-icon univerjs-icon-".concat(r, " ").concat(i || "").trim(), h = He("_".concat(xe()));
31
+ return D(t, "".concat(r), { defIds: t.defIds, idSuffix: h.current }, l({ ref: e, className: a }, o), n);
31
32
  });
32
- function D(s, e, t, r, n) {
33
- return G(s.tag, l(l({ key: e }, Me(s, t, n)), r), ($e(s, t).children || []).map(function(i, o) {
34
- return D(i, "".concat(e, "-").concat(s.tag, "-").concat(o), t, void 0, n);
33
+ function D(s, e, t, r, i) {
34
+ return G(s.tag, l(l({ key: e }, Me(s, t, i)), r), ($e(s, t).children || []).map(function(n, o) {
35
+ return D(n, "".concat(e, "-").concat(s.tag, "-").concat(o), t, void 0, i);
35
36
  }));
36
37
  }
37
38
  function Me(s, e, t) {
38
39
  var r = l({}, s.attrs);
39
- t != null && t.colorChannel1 && r.fill === "colorChannel1" && (r.fill = t.colorChannel1), s.tag === "mask" && r.id && (r.id = r.id + e.idSuffix), Object.entries(r).forEach(function(i) {
40
- var o = i[0], a = i[1];
40
+ t != null && t.colorChannel1 && r.fill === "colorChannel1" && (r.fill = t.colorChannel1), s.tag === "mask" && r.id && (r.id = r.id + e.idSuffix), Object.entries(r).forEach(function(n) {
41
+ var o = n[0], a = n[1];
41
42
  o === "mask" && typeof a == "string" && (r[o] = a.replace(/url\(#(.*)\)/, "url(#$1".concat(e.idSuffix, ")")));
42
43
  });
43
- var n = e.defIds;
44
- return !n || n.length === 0 || (s.tag === "use" && r["xlink:href"] && (r["xlink:href"] = r["xlink:href"] + e.idSuffix), Object.entries(r).forEach(function(i) {
45
- var o = i[0], a = i[1];
44
+ var i = e.defIds;
45
+ return !i || i.length === 0 || (s.tag === "use" && r["xlink:href"] && (r["xlink:href"] = r["xlink:href"] + e.idSuffix), Object.entries(r).forEach(function(n) {
46
+ var o = n[0], a = n[1];
46
47
  typeof a == "string" && (r[o] = a.replace(/url\(#(.*)\)/, "url(#$1".concat(e.idSuffix, ")")));
47
48
  })), r;
48
49
  }
49
50
  function $e(s, e) {
50
51
  var t, r = e.defIds;
51
- return !r || r.length === 0 ? s : s.tag === "defs" && (!((t = s.children) === null || t === void 0) && t.length) ? l(l({}, s), { children: s.children.map(function(n) {
52
- return typeof n.attrs.id == "string" && r && r.indexOf(n.attrs.id) > -1 ? l(l({}, n), { attrs: l(l({}, n.attrs), { id: n.attrs.id + e.idSuffix }) }) : n;
52
+ return !r || r.length === 0 ? s : s.tag === "defs" && (!((t = s.children) === null || t === void 0) && t.length) ? l(l({}, s), { children: s.children.map(function(i) {
53
+ return typeof i.attrs.id == "string" && r && r.indexOf(i.attrs.id) > -1 ? l(l({}, i), { attrs: l(l({}, i.attrs), { id: i.attrs.id + e.idSuffix }) }) : i;
53
54
  }) }) : s;
54
55
  }
55
56
  function xe() {
56
57
  return Math.random().toString(36).substring(2, 8);
57
58
  }
58
59
  U.displayName = "UniverIcon";
59
- var Te = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "#E5E5E5", d: "M1.6499 3.65002C1.6499 2.54545 2.54533 1.65002 3.6499 1.65002H12.3499C13.4545 1.65002 14.3499 2.54545 14.3499 3.65002V12.35C14.3499 13.4546 13.4545 14.35 12.3499 14.35H3.6499C2.54533 14.35 1.6499 13.4546 1.6499 12.35V3.65002Z" } }, { tag: "path", attrs: { fill: "#fff", d: "M9.9998 1.65002H5.9998V6H1.6499V10H5.9998V14.35H9.9998V10H14.3499V6H9.9998V1.65002Z" } }, { tag: "path", attrs: { fill: "currentColor", d: "M3.6498 1.05005C2.21386 1.05005 1.0498 2.21411 1.0498 3.65005V12.35C1.0498 13.786 2.21386 14.95 3.6498 14.95H12.3498C13.7857 14.95 14.9498 13.786 14.9498 12.3501V3.65005C14.9498 2.21411 13.7857 1.05005 12.3498 1.05005H3.6498ZM5.4002 2.25005H3.6498C2.87661 2.25005 2.2498 2.87685 2.2498 3.65005V5.40002H5.4002V2.25005ZM2.2498 10.6V12.35C2.2498 13.1232 2.87661 13.75 3.6498 13.75H5.4002V10.6H2.2498ZM6.60019 13.75H9.4002V9.40002H13.7498V6.60002H9.4002V2.25005H6.60019V6.60002H2.25029V9.40002H6.60019V13.75ZM10.6002 2.25005V5.40002H13.7498V3.65005C13.7498 2.87685 13.123 2.25005 12.3498 2.25005H10.6002ZM13.7498 10.6H10.6002V13.75H12.3498C13.123 13.75 13.7498 13.1232 13.7498 12.3501V10.6Z", fillRule: "evenodd", clipRule: "evenodd" } }] }, Z = k(function(s, e) {
60
+ var Te = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "#E5E5E5", d: "M1.6499 3.65002C1.6499 2.54545 2.54533 1.65002 3.6499 1.65002H12.3499C13.4545 1.65002 14.3499 2.54545 14.3499 3.65002V12.35C14.3499 13.4546 13.4545 14.35 12.3499 14.35H3.6499C2.54533 14.35 1.6499 13.4546 1.6499 12.35V3.65002Z" } }, { tag: "path", attrs: { fill: "#fff", d: "M9.9998 1.65002H5.9998V6H1.6499V10H5.9998V14.35H9.9998V10H14.3499V6H9.9998V1.65002Z" } }, { tag: "path", attrs: { fill: "currentColor", d: "M3.6498 1.05005C2.21386 1.05005 1.0498 2.21411 1.0498 3.65005V12.35C1.0498 13.786 2.21386 14.95 3.6498 14.95H12.3498C13.7857 14.95 14.9498 13.786 14.9498 12.3501V3.65005C14.9498 2.21411 13.7857 1.05005 12.3498 1.05005H3.6498ZM5.4002 2.25005H3.6498C2.87661 2.25005 2.2498 2.87685 2.2498 3.65005V5.40002H5.4002V2.25005ZM2.2498 10.6V12.35C2.2498 13.1232 2.87661 13.75 3.6498 13.75H5.4002V10.6H2.2498ZM6.60019 13.75H9.4002V9.40002H13.7498V6.60002H9.4002V2.25005H6.60019V6.60002H2.25029V9.40002H6.60019V13.75ZM10.6002 2.25005V5.40002H13.7498V3.65005C13.7498 2.87685 13.123 2.25005 12.3498 2.25005H10.6002ZM13.7498 10.6H10.6002V13.75H12.3498C13.123 13.75 13.7498 13.1232 13.7498 12.3501V10.6Z", fillRule: "evenodd", clipRule: "evenodd" } }] }, Z = A(function(s, e) {
60
61
  return G(U, Object.assign({}, s, {
61
62
  id: "cross-highlighting-single",
62
63
  ref: e,
@@ -134,76 +135,62 @@ const M = {
134
135
  const e = s.get(g);
135
136
  return e.enabled ? (e.setEnabled(!1), !0) : !1;
136
137
  }
137
- };
138
- function Y(s) {
139
- var e, t, r = "";
140
- if (typeof s == "string" || typeof s == "number") r += s;
141
- else if (typeof s == "object") if (Array.isArray(s)) {
142
- var n = s.length;
143
- for (e = 0; e < n; e++) s[e] && (t = Y(s[e])) && (r && (r += " "), r += t);
144
- } else for (t in s) s[t] && (r && (r += " "), r += t);
145
- return r;
146
- }
147
- function Pe() {
148
- for (var s, e, t = 0, r = "", n = arguments.length; t < n; t++) (s = arguments[t]) && (e = Y(s)) && (r && (r += " "), r += e);
149
- return r;
150
- }
151
- const je = "univer-crosshair-highlight-overlay", Le = "univer-crosshair-highlight-item", Ae = "univer-crosshair-highlight-item-selected", O = {
152
- crosshairHighlightOverlay: je,
153
- crosshairHighlightItem: Le,
154
- crosshairHighlightItemSelected: Ae
138
+ }, Pe = "univer-crosshair-highlight-overlay", je = "univer-crosshair-highlight-item", Le = "univer-crosshair-highlight-item-selected", O = {
139
+ crosshairHighlightOverlay: Pe,
140
+ crosshairHighlightItem: je,
141
+ crosshairHighlightItemSelected: Le
155
142
  };
156
143
  function ke(s) {
157
- const { onChange: e } = s, t = he(g), r = ge(t.color$), n = be((i) => {
158
- e == null || e(i);
144
+ const { onChange: e } = s, t = le(g), r = he(t.color$), i = be((n) => {
145
+ e == null || e(n);
159
146
  }, [e]);
160
- return /* @__PURE__ */ P("div", { className: O.crosshairHighlightOverlay, children: B.map((i) => /* @__PURE__ */ P(
147
+ return /* @__PURE__ */ P("div", { className: O.crosshairHighlightOverlay, children: B.map((n) => /* @__PURE__ */ P(
161
148
  "div",
162
149
  {
163
- className: Pe(O.crosshairHighlightItem, {
164
- [O.crosshairHighlightItemSelected]: i === r
150
+ className: pe(O.crosshairHighlightItem, {
151
+ [O.crosshairHighlightItemSelected]: n === r
165
152
  }),
166
- style: { backgroundColor: i },
167
- onClick: () => n(i)
153
+ style: { backgroundColor: n },
154
+ onClick: () => i(n)
168
155
  },
169
- i
156
+ n
170
157
  )) });
171
158
  }
172
- const F = "CROSSHAIR_HIGHLIGHT_OVERLAY_COMPONENT";
173
- function Ge(s) {
159
+ const Y = "CROSSHAIR_HIGHLIGHT_OVERLAY_COMPONENT";
160
+ function Ae(s) {
174
161
  const e = s.get(g);
175
162
  return {
176
163
  id: M.id,
177
164
  tooltip: "crosshair.button.tooltip",
178
- type: ue.BUTTON_SELECTOR,
165
+ type: de.BUTTON_SELECTOR,
179
166
  icon: "CrossHighlightingSingle",
180
167
  selections: [
181
168
  {
182
169
  label: {
183
- name: F,
170
+ name: Y,
184
171
  hoverable: !1
185
172
  }
186
173
  }
187
174
  ],
188
175
  selectionsCommandId: W.id,
189
176
  activated$: e.enabled$,
190
- hidden$: de(s, E.UNIVER_SHEET)
177
+ hidden$: ge(s, y.UNIVER_SHEET)
191
178
  };
192
179
  }
193
- const Ue = {
194
- [fe.FOOTER_MENU]: {
195
- [_e.OTHERS]: {
180
+ const Ge = {
181
+ [ue.FOOTER_MENU]: {
182
+ [fe.OTHERS]: {
196
183
  [M.id]: {
197
184
  order: 0,
198
- menuItemFactory: Ge
185
+ menuItemFactory: Ae
199
186
  }
200
187
  }
201
188
  }
202
189
  };
203
- var De = Object.getOwnPropertyDescriptor, Ze = (s, e, t, r) => {
204
- for (var n = r > 1 ? void 0 : r ? De(e, t) : e, i = s.length - 1, o; i >= 0; i--)
205
- (o = s[i]) && (n = o(n) || n);
206
- return n;
190
+ var Ue = Object.getOwnPropertyDescriptor, De = (s, e, t, r) => {
191
+ for (var i = r > 1 ? void 0 : r ? Ue(e, t) : e, n = s.length - 1, o; n >= 0; n--)
192
+ (o = s[n]) && (i = o(i) || i);
193
+ return i;
207
194
  }, I = (s, e) => (t, r) => e(t, r, s);
208
195
  let H = class extends w {
209
196
  constructor(s, e, t) {
@@ -218,19 +205,19 @@ let H = class extends w {
218
205
  ].forEach((s) => this._cmdSrv.registerCommand(s));
219
206
  }
220
207
  _initMenus() {
221
- this._menuManagerService.mergeMenu(Ue);
208
+ this._menuManagerService.mergeMenu(Ge);
222
209
  }
223
210
  _initComponents() {
224
- this._componentMgr.register(F, ke), this._componentMgr.register("CrossHighlightingSingle", Z);
211
+ this._componentMgr.register(Y, ke), this._componentMgr.register("CrossHighlightingSingle", Z);
225
212
  }
226
213
  };
227
- H = Ze([
228
- I(0, u(Se)),
229
- I(1, ve),
230
- I(2, ee)
214
+ H = De([
215
+ I(0, u(_e)),
216
+ I(1, Se),
217
+ I(2, Q)
231
218
  ], H);
232
- const Be = 1;
233
- class We {
219
+ const Ze = 1;
220
+ class Be {
234
221
  constructor() {
235
222
  c(this, "_selectedRanges", []);
236
223
  c(this, "_ranges", []);
@@ -246,21 +233,21 @@ class We {
246
233
  }
247
234
  _getSplitRanges(e, t) {
248
235
  let r = [e];
249
- for (const n of t.concat(this._selectedRanges)) {
250
- const i = [];
236
+ for (const i of t.concat(this._selectedRanges)) {
237
+ const n = [];
251
238
  for (const o of r) {
252
- const a = x.subtract(o, n);
253
- a && a.length > 0 && i.push(...a);
239
+ const a = x.subtract(o, i);
240
+ a && a.length > 0 && n.push(...a);
254
241
  }
255
- r = i;
242
+ r = n;
256
243
  }
257
- return r.filter((n) => n.startRow <= n.endRow && n.startColumn <= n.endColumn);
244
+ return r.filter((i) => i.startRow <= i.endRow && i.startColumn <= i.endColumn);
258
245
  }
259
246
  _getIntersects(e) {
260
247
  const t = [];
261
248
  for (const r of this._ranges) {
262
- const n = x.getIntersects(r, e);
263
- n && t.push(n);
249
+ const i = x.getIntersects(r, e);
250
+ i && t.push(i);
264
251
  }
265
252
  return t;
266
253
  }
@@ -271,7 +258,7 @@ class We {
271
258
  this._ranges = [], this._selectedRanges = [];
272
259
  }
273
260
  }
274
- class Ye extends ae {
261
+ class We extends oe {
275
262
  constructor(t, r) {
276
263
  super(t, r);
277
264
  // protected _showHighLight = false;
@@ -285,9 +272,9 @@ class Ye extends ae {
285
272
  });
286
273
  }
287
274
  _draw(t) {
288
- var n, i;
289
- const r = `rgba(${this._color.r}, ${this._color.g}, ${this._color.b}, ${(i = (n = this._color) == null ? void 0 : n.a) != null ? i : 0.5})`;
290
- ce.drawWith(t, {
275
+ var i, n;
276
+ const r = `rgba(${this._color.r}, ${this._color.g}, ${this._color.b}, ${(n = (i = this._color) == null ? void 0 : i.a) != null ? n : 0.5})`;
277
+ ae.drawWith(t, {
291
278
  width: this.width,
292
279
  height: this.height,
293
280
  fill: r,
@@ -297,38 +284,38 @@ class Ye extends ae {
297
284
  });
298
285
  }
299
286
  }
300
- var Fe = Object.getOwnPropertyDescriptor, Xe = (s, e, t, r) => {
301
- for (var n = r > 1 ? void 0 : r ? Fe(e, t) : e, i = s.length - 1, o; i >= 0; i--)
302
- (o = s[i]) && (n = o(n) || n);
303
- return n;
287
+ var Ye = Object.getOwnPropertyDescriptor, Fe = (s, e, t, r) => {
288
+ for (var i = r > 1 ? void 0 : r ? Ye(e, t) : e, n = s.length - 1, o; n >= 0; n--)
289
+ (o = s[n]) && (i = o(i) || i);
290
+ return i;
304
291
  }, v = (s, e) => (t, r) => e(t, r, s);
305
292
  let b = class extends w {
306
- constructor(e, t, r, n, i, o) {
293
+ constructor(e, t, r, i, n, o) {
307
294
  super();
308
295
  c(this, "_shapes", []);
309
- c(this, "_rangeCollection", new We());
296
+ c(this, "_rangeCollection", new Be());
310
297
  c(this, "_color", "rgba(255,0,0,0.5)");
311
- this._context = e, this._sheetSkeletonManagerService = t, this._sheetsSelectionsService = r, this._sheetsCrosshairHighlightService = n, this._contextService = i, this._refSelectionsService = o, this._initRenderListener();
298
+ this._context = e, this._sheetSkeletonManagerService = t, this._sheetsSelectionsService = r, this._sheetsCrosshairHighlightService = i, this._contextService = n, this._refSelectionsService = o, this._initRenderListener();
312
299
  }
313
300
  _transformSelection(e, t) {
314
301
  if (!e)
315
302
  return;
316
- const r = t.getRowCount(), n = t.getColumnCount(), i = [];
303
+ const r = t.getRowCount(), i = t.getColumnCount(), n = [];
317
304
  for (const o of e) {
318
305
  const { startRow: a, endRow: h, startColumn: _, endColumn: S } = o.range;
319
- h - a + 1 === r || S - _ + 1 === n || i.push(o.range);
306
+ h - a + 1 === r || S - _ + 1 === i || n.push(o.range);
320
307
  }
321
- this._rangeCollection.setSelectedRanges(i);
322
- for (const o of i)
308
+ this._rangeCollection.setSelectedRanges(n);
309
+ for (const o of n)
323
310
  this.addSelection(o, t);
324
311
  }
325
312
  _initRenderListener() {
326
313
  const e = this._context.unit;
327
- this.disposeWithMe(me([
314
+ this.disposeWithMe(ve([
328
315
  this._contextService.subscribeContextValue$(Ie).pipe(Ce(!1)),
329
316
  this._sheetSkeletonManagerService.currentSkeleton$,
330
317
  this._sheetsCrosshairHighlightService.enabled$,
331
- this._sheetsCrosshairHighlightService.color$.pipe(pe((t) => this._color = t)),
318
+ this._sheetsCrosshairHighlightService.color$.pipe(me((t) => this._color = t)),
332
319
  V(
333
320
  this._sheetsSelectionsService.selectionMoveStart$,
334
321
  this._sheetsSelectionsService.selectionMoving$,
@@ -343,8 +330,8 @@ let b = class extends w {
343
330
  this._sheetsSelectionsService.selectionSet$,
344
331
  e.activeSheet$.pipe(N(() => this._refSelectionsService.getCurrentSelections()))
345
332
  )
346
- ]).subscribe(([t, r, n, i, o, a]) => {
347
- if (this._clear(), !n) return;
333
+ ]).subscribe(([t, r, i, n, o, a]) => {
334
+ if (this._clear(), !i) return;
348
335
  const h = t ? a : o;
349
336
  this._rangeCollection.reset(), this._transformSelection(h, e.getActiveSheet()), this.render(this._rangeCollection.getRanges());
350
337
  }));
@@ -352,28 +339,28 @@ let b = class extends w {
352
339
  addSelection(e, t) {
353
340
  if (e.rangeType === f.COLUMN || e.rangeType === f.ROW || e.rangeType === f.ALL)
354
341
  return;
355
- const r = t.getRowCount(), n = t.getColumnCount(), { startRow: i, endRow: o, startColumn: a, endColumn: h } = e, _ = {
356
- startRow: i,
342
+ const r = t.getRowCount(), i = t.getColumnCount(), { startRow: n, endRow: o, startColumn: a, endColumn: h } = e, _ = {
343
+ startRow: n,
357
344
  endRow: o,
358
345
  startColumn: 0,
359
346
  endColumn: a - 1
360
347
  }, S = {
361
- startRow: i,
348
+ startRow: n,
362
349
  endRow: o,
363
350
  startColumn: h + 1,
364
- endColumn: n
365
- }, m = {
351
+ endColumn: i
352
+ }, C = {
366
353
  startRow: 0,
367
- endRow: i - 1,
354
+ endRow: n - 1,
368
355
  startColumn: a,
369
356
  endColumn: h
370
- }, C = {
357
+ }, m = {
371
358
  startRow: o + 1,
372
359
  endRow: r,
373
360
  startColumn: a,
374
361
  endColumn: h
375
362
  };
376
- for (const d of [_, S, m, C])
363
+ for (const d of [_, S, C, m])
377
364
  d.startRow <= d.endRow && d.startColumn <= d.endColumn && this._rangeCollection.addRange(d);
378
365
  }
379
366
  _clear() {
@@ -381,16 +368,16 @@ let b = class extends w {
381
368
  e.dispose();
382
369
  }), this._shapes = [];
383
370
  }
384
- _addShapes(e, t, r, n) {
385
- const { startRow: i, endRow: o, startColumn: a, endColumn: h } = e, _ = j(i, a, r, n), S = j(o, h, r, n), { startX: m, startY: C } = _, { endX: d, endY: X } = S, K = d - m, z = X - C, q = {
386
- left: m,
387
- top: C,
388
- color: new re(this._color).toRgb(),
389
- width: K,
390
- height: z,
391
- zIndex: Be,
371
+ _addShapes(e, t, r, i) {
372
+ const { startRow: n, endRow: o, startColumn: a, endColumn: h } = e, _ = j(n, a, r, i), S = j(o, h, r, i), { startX: C, startY: m } = _, { endX: d, endY: F } = S, X = d - C, K = F - m, z = {
373
+ left: C,
374
+ top: m,
375
+ color: new te(this._color).toRgb(),
376
+ width: X,
377
+ height: K,
378
+ zIndex: Ze,
392
379
  evented: !1
393
- }, $ = new Ye(`crosshair-${t}`, q);
380
+ }, $ = new We(`crosshair-${t}`, z);
394
381
  this._shapes.push($), r.addObject($);
395
382
  }
396
383
  render(e) {
@@ -399,9 +386,9 @@ let b = class extends w {
399
386
  return;
400
387
  const { scene: r } = this._context;
401
388
  this._clear();
402
- for (let n = 0; n < e.length; n++) {
403
- const i = e[n];
404
- this._addShapes(i, n, r, t);
389
+ for (let i = 0; i < e.length; i++) {
390
+ const n = e[i];
391
+ this._addShapes(n, i, r, t);
405
392
  }
406
393
  r.makeDirty(!0);
407
394
  }
@@ -409,27 +396,27 @@ let b = class extends w {
409
396
  super.dispose();
410
397
  }
411
398
  };
412
- b = Xe([
413
- v(1, u(ye)),
399
+ b = Fe([
400
+ v(1, u(Ee)),
414
401
  v(2, u(Re)),
415
402
  v(3, u(g)),
416
- v(4, u(te)),
403
+ v(4, u(ee)),
417
404
  v(5, Oe)
418
405
  ], b);
419
- var Ke = Object.getOwnPropertyDescriptor, ze = (s, e, t, r) => {
420
- for (var n = r > 1 ? void 0 : r ? Ke(e, t) : e, i = s.length - 1, o; i >= 0; i--)
421
- (o = s[i]) && (n = o(n) || n);
422
- return n;
423
- }, y = (s, e) => (t, r) => e(t, r, s), p;
424
- let A = (p = class extends se {
406
+ var Xe = Object.getOwnPropertyDescriptor, Ke = (s, e, t, r) => {
407
+ for (var i = r > 1 ? void 0 : r ? Xe(e, t) : e, n = s.length - 1, o; n >= 0; n--)
408
+ (o = s[n]) && (i = o(i) || i);
409
+ return i;
410
+ }, E = (s, e) => (t, r) => e(t, r, s), p;
411
+ let k = (p = class extends re {
425
412
  constructor(s = L, e, t, r) {
426
413
  super(), this._config = s, this._injector = e, this._renderManagerService = t, this._configService = r;
427
- const { ...n } = ne(
414
+ const { ...i } = se(
428
415
  {},
429
416
  L,
430
417
  this._config
431
418
  );
432
- this._configService.setConfig(Ee, n);
419
+ this._configService.setConfig(ye, i);
433
420
  }
434
421
  onStarting() {
435
422
  [
@@ -440,14 +427,14 @@ let A = (p = class extends se {
440
427
  onReady() {
441
428
  [
442
429
  [b]
443
- ].forEach((s) => this._injector.add(s)), this._injector.get(H), this._renderManagerService.registerRenderModule(E.UNIVER_SHEET, [b]);
444
- }
445
- }, c(p, "pluginName", "SHEET_CROSSHAIR_HIGHLIGHT_PLUGIN"), c(p, "type", E.UNIVER_SHEET), p);
446
- A = ze([
447
- y(1, u(ie)),
448
- y(2, le),
449
- y(3, oe)
450
- ], A);
430
+ ].forEach((s) => this._injector.add(s)), this._injector.get(H), this._renderManagerService.registerRenderModule(y.UNIVER_SHEET, [b]);
431
+ }
432
+ }, c(p, "pluginName", "SHEET_CROSSHAIR_HIGHLIGHT_PLUGIN"), c(p, "type", y.UNIVER_SHEET), p);
433
+ k = Ke([
434
+ E(1, u(ie)),
435
+ E(2, ce),
436
+ E(3, ne)
437
+ ], k);
451
438
  export {
452
439
  B as CROSSHAIR_HIGHLIGHT_COLORS,
453
440
  Ne as DisableCrosshairHighlightOperation,
@@ -455,5 +442,5 @@ export {
455
442
  W as SetCrosshairHighlightColorOperation,
456
443
  g as SheetsCrosshairHighlightService,
457
444
  M as ToggleCrosshairHighlightOperation,
458
- A as UniverSheetsCrosshairHighlightPlugin
445
+ k as UniverSheetsCrosshairHighlightPlugin
459
446
  };
@@ -1,5 +1,19 @@
1
- import { default as React } from 'react';
1
+ /**
2
+ * Copyright 2023-present DreamNum Co., Ltd.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
2
16
  export interface ICrosshairOverlayProps {
3
17
  onChange?: (value: string) => void;
4
18
  }
5
- export declare function CrosshairOverlay(props: ICrosshairOverlayProps): React.JSX.Element;
19
+ export declare function CrosshairOverlay(props: ICrosshairOverlayProps): import("react/jsx-runtime").JSX.Element;
package/lib/umd/index.js CHANGED
@@ -1 +1 @@
1
- (function(h,o){typeof exports=="object"&&typeof module<"u"?o(exports,require("@univerjs/core"),require("@univerjs/engine-render"),require("@univerjs/ui"),require("rxjs"),require("react/jsx-runtime"),require("react"),require("@univerjs/sheets"),require("@univerjs/sheets-ui")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/engine-render","@univerjs/ui","rxjs","react/jsx-runtime","react","@univerjs/sheets","@univerjs/sheets-ui"],o):(h=typeof globalThis<"u"?globalThis:h||self,o(h.UniverSheetsCrosshairHighlight={},h.UniverCore,h.UniverEngineRender,h.UniverUi,h.rxjs,h.React,h.React,h.UniverSheets,h.UniverSheetsUi))})(this,function(h,o,_,S,d,V,C,T,w){"use strict";var fe=Object.defineProperty;var _e=(h,o,_)=>o in h?fe(h,o,{enumerable:!0,configurable:!0,writable:!0,value:_}):h[o]=_;var l=(h,o,_)=>_e(h,typeof o!="symbol"?o+"":o,_);var I;const Z="sheets-crosshair-highlight.config",A={};var g=function(){return g=Object.assign||function(r){for(var e,i=1,t=arguments.length;i<t;i++){e=arguments[i];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(r[n]=e[n])}return r},g.apply(this,arguments)},q=function(r,e){var i={};for(var t in r)Object.prototype.hasOwnProperty.call(r,t)&&e.indexOf(t)<0&&(i[t]=r[t]);if(r!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,t=Object.getOwnPropertySymbols(r);n<t.length;n++)e.indexOf(t[n])<0&&Object.prototype.propertyIsEnumerable.call(r,t[n])&&(i[t[n]]=r[t[n]]);return i},x=C.forwardRef(function(r,e){var i=r.icon,t=r.id,n=r.className,s=r.extend,a=q(r,["icon","id","className","extend"]),c="univerjs-icon univerjs-icon-".concat(t," ").concat(n||"").trim(),u=C.useRef("_".concat(X()));return L(i,"".concat(t),{defIds:i.defIds,idSuffix:u.current},g({ref:e,className:c},a),s)});function L(r,e,i,t,n){return C.createElement(r.tag,g(g({key:e},W(r,i,n)),t),(F(r,i).children||[]).map(function(s,a){return L(s,"".concat(e,"-").concat(r.tag,"-").concat(a),i,void 0,n)}))}function W(r,e,i){var t=g({},r.attrs);i!=null&&i.colorChannel1&&t.fill==="colorChannel1"&&(t.fill=i.colorChannel1),r.tag==="mask"&&t.id&&(t.id=t.id+e.idSuffix),Object.entries(t).forEach(function(s){var a=s[0],c=s[1];a==="mask"&&typeof c=="string"&&(t[a]=c.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))});var n=e.defIds;return!n||n.length===0||(r.tag==="use"&&t["xlink:href"]&&(t["xlink:href"]=t["xlink:href"]+e.idSuffix),Object.entries(t).forEach(function(s){var a=s[0],c=s[1];typeof c=="string"&&(t[a]=c.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))})),t}function F(r,e){var i,t=e.defIds;return!t||t.length===0?r:r.tag==="defs"&&(!((i=r.children)===null||i===void 0)&&i.length)?g(g({},r),{children:r.children.map(function(n){return typeof n.attrs.id=="string"&&t&&t.indexOf(n.attrs.id)>-1?g(g({},n),{attrs:g(g({},n.attrs),{id:n.attrs.id+e.idSuffix})}):n})}):r}function X(){return Math.random().toString(36).substring(2,8)}x.displayName="UniverIcon";var K={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"}}]},G=C.forwardRef(function(r,e){return C.createElement(x,Object.assign({},r,{id:"cross-highlighting-single",ref:e,icon:K}))});G.displayName="CrossHighlightingSingle";const M=["rgba(158, 109, 227, 0.3)","rgba(254, 75, 75, 0.3)","rgba(255, 140, 81, 0.3)","rgba(164, 220, 22, 0.3)","rgba(45, 174, 255, 0.3)","rgba(58, 96, 247, 0.3)","rgba(242, 72, 166, 0.3)","rgba(153, 153, 153, 0.3)","rgba(158, 109, 227, 0.15)","rgba(254, 75, 75, 0.15)","rgba(255, 140, 81, 0.15)","rgba(164, 220, 22, 0.15)","rgba(45, 174, 255, 0.15)","rgba(58, 96, 247, 0.15)","rgba(242, 72, 166, 0.15)","rgba(153, 153, 153, 0.15)"];class f extends o.Disposable{constructor(){super(...arguments);l(this,"_enabled$",new d.BehaviorSubject(!1));l(this,"enabled$",this._enabled$.asObservable());l(this,"_color$",new d.BehaviorSubject(M[0]));l(this,"color$",this._color$.asObservable())}get enabled(){return this._enabled$.getValue()}get color(){return this._color$.getValue()}dispose(){this._enabled$.complete()}setEnabled(i){this._enabled$.next(i)}setColor(i){this._color$.next(i)}}const R={id:"sheet.operation.toggle-crosshair-highlight",type:o.CommandType.OPERATION,handler(r){const e=r.get(f),i=e.enabled;return e.setEnabled(!i),!0}},$={id:"sheet.operation.set-crosshair-highlight-color",type:o.CommandType.OPERATION,handler(r,{value:e}){const i=r.get(f);return i.enabled||i.setEnabled(!0),i.setColor(e),!0}},U={id:"sheet.operation.enable-crosshair-highlight",type:o.CommandType.OPERATION,handler(r){const e=r.get(f);return e.enabled?!1:(e.setEnabled(!0),!0)}},k={id:"sheet.operation.disable-crosshair-highlight",type:o.CommandType.OPERATION,handler(r){const e=r.get(f);return e.enabled?(e.setEnabled(!1),!0):!1}};function D(r){var e,i,t="";if(typeof r=="string"||typeof r=="number")t+=r;else if(typeof r=="object")if(Array.isArray(r)){var n=r.length;for(e=0;e<n;e++)r[e]&&(i=D(r[e]))&&(t&&(t+=" "),t+=i)}else for(i in r)r[i]&&(t&&(t+=" "),t+=i);return t}function z(){for(var r,e,i=0,t="",n=arguments.length;i<n;i++)(r=arguments[i])&&(e=D(r))&&(t&&(t+=" "),t+=e);return t}const j={crosshairHighlightOverlay:"univer-crosshair-highlight-overlay",crosshairHighlightItem:"univer-crosshair-highlight-item",crosshairHighlightItemSelected:"univer-crosshair-highlight-item-selected"};function J(r){const{onChange:e}=r,i=S.useDependency(f),t=S.useObservable(i.color$),n=C.useCallback(s=>{e==null||e(s)},[e]);return V.jsx("div",{className:j.crosshairHighlightOverlay,children:M.map(s=>V.jsx("div",{className:z(j.crosshairHighlightItem,{[j.crosshairHighlightItemSelected]:s===t}),style:{backgroundColor:s},onClick:()=>n(s)},s))})}const Y="CROSSHAIR_HIGHLIGHT_OVERLAY_COMPONENT";function Q(r){const e=r.get(f);return{id:R.id,tooltip:"crosshair.button.tooltip",type:S.MenuItemType.BUTTON_SELECTOR,icon:"CrossHighlightingSingle",selections:[{label:{name:Y,hoverable:!1}}],selectionsCommandId:$.id,activated$:e.enabled$,hidden$:S.getMenuHiddenObservable(r,o.UniverInstanceType.UNIVER_SHEET)}}const ee={[S.ContextMenuPosition.FOOTER_MENU]:{[S.ContextMenuGroup.OTHERS]:{[R.id]:{order:0,menuItemFactory:Q}}}};var te=Object.getOwnPropertyDescriptor,ie=(r,e,i,t)=>{for(var n=t>1?void 0:t?te(e,i):e,s=r.length-1,a;s>=0;s--)(a=r[s])&&(n=a(n)||n);return n},N=(r,e)=>(i,t)=>e(i,t,r);let b=class extends o.Disposable{constructor(r,e,i){super(),this._componentMgr=r,this._menuManagerService=e,this._cmdSrv=i,this._initCommands(),this._initMenus(),this._initComponents()}_initCommands(){[R,$,U,k].forEach(r=>this._cmdSrv.registerCommand(r))}_initMenus(){this._menuManagerService.mergeMenu(ee)}_initComponents(){this._componentMgr.register(Y,J),this._componentMgr.register("CrossHighlightingSingle",G)}};b=ie([N(0,o.Inject(S.ComponentManager)),N(1,S.IMenuManagerService),N(2,o.ICommandService)],b);const re=1;class ne{constructor(){l(this,"_selectedRanges",[]);l(this,"_ranges",[])}addRange(e){if(e.rangeType===o.RANGE_TYPE.COLUMN||e.rangeType===o.RANGE_TYPE.ROW||e.rangeType===o.RANGE_TYPE.ALL)return;const i=this._getIntersects(e),t=this._getSplitRanges(e,i);t.length>0&&this._ranges.push(...t)}setSelectedRanges(e){this._selectedRanges=e}_getSplitRanges(e,i){let t=[e];for(const n of i.concat(this._selectedRanges)){const s=[];for(const a of t){const c=o.Rectangle.subtract(a,n);c&&c.length>0&&s.push(...c)}t=s}return t.filter(n=>n.startRow<=n.endRow&&n.startColumn<=n.endColumn)}_getIntersects(e){const i=[];for(const t of this._ranges){const n=o.Rectangle.getIntersects(t,e);n&&i.push(n)}return i}getRanges(){return this._ranges}reset(){this._ranges=[],this._selectedRanges=[]}}class se extends _.Shape{constructor(i,t){super(i,t);l(this,"_color");t&&this.setShapeProps(t)}setShapeProps(i){typeof i.color<"u"&&(this._color=i.color),this.transformByState({width:i.width,height:i.height})}_draw(i){var n,s;const t=`rgba(${this._color.r}, ${this._color.g}, ${this._color.b}, ${(s=(n=this._color)==null?void 0:n.a)!=null?s:.5})`;_.Rect.drawWith(i,{width:this.width,height:this.height,fill:t,stroke:void 0,strokeWidth:0,evented:!1})}}var oe=Object.getOwnPropertyDescriptor,ae=(r,e,i,t)=>{for(var n=t>1?void 0:t?oe(e,i):e,s=r.length-1,a;s>=0;s--)(a=r[s])&&(n=a(n)||n);return n},p=(r,e)=>(i,t)=>e(i,t,r);let O=class extends o.Disposable{constructor(e,i,t,n,s,a){super();l(this,"_shapes",[]);l(this,"_rangeCollection",new ne);l(this,"_color","rgba(255,0,0,0.5)");this._context=e,this._sheetSkeletonManagerService=i,this._sheetsSelectionsService=t,this._sheetsCrosshairHighlightService=n,this._contextService=s,this._refSelectionsService=a,this._initRenderListener()}_transformSelection(e,i){if(!e)return;const t=i.getRowCount(),n=i.getColumnCount(),s=[];for(const a of e){const{startRow:c,endRow:u,startColumn:m,endColumn:H}=a.range;u-c+1===t||H-m+1===n||s.push(a.range)}this._rangeCollection.setSelectedRanges(s);for(const a of s)this.addSelection(a,i)}_initRenderListener(){const e=this._context.unit;this.disposeWithMe(d.combineLatest([this._contextService.subscribeContextValue$(T.REF_SELECTIONS_ENABLED).pipe(d.startWith(!1)),this._sheetSkeletonManagerService.currentSkeleton$,this._sheetsCrosshairHighlightService.enabled$,this._sheetsCrosshairHighlightService.color$.pipe(d.tap(i=>this._color=i)),d.merge(this._sheetsSelectionsService.selectionMoveStart$,this._sheetsSelectionsService.selectionMoving$,this._sheetsSelectionsService.selectionMoveEnd$,this._sheetsSelectionsService.selectionSet$,e.activeSheet$.pipe(d.map(()=>this._sheetsSelectionsService.getCurrentSelections()))),d.merge(this._refSelectionsService.selectionMoveStart$,this._refSelectionsService.selectionMoving$,this._refSelectionsService.selectionMoveEnd$,this._sheetsSelectionsService.selectionSet$,e.activeSheet$.pipe(d.map(()=>this._refSelectionsService.getCurrentSelections())))]).subscribe(([i,t,n,s,a,c])=>{if(this._clear(),!n)return;const u=i?c:a;this._rangeCollection.reset(),this._transformSelection(u,e.getActiveSheet()),this.render(this._rangeCollection.getRanges())}))}addSelection(e,i){if(e.rangeType===o.RANGE_TYPE.COLUMN||e.rangeType===o.RANGE_TYPE.ROW||e.rangeType===o.RANGE_TYPE.ALL)return;const t=i.getRowCount(),n=i.getColumnCount(),{startRow:s,endRow:a,startColumn:c,endColumn:u}=e,m={startRow:s,endRow:a,startColumn:0,endColumn:c-1},H={startRow:s,endRow:a,startColumn:u+1,endColumn:n},y={startRow:0,endRow:s-1,startColumn:c,endColumn:u},E={startRow:a+1,endRow:t,startColumn:c,endColumn:u};for(const v of[m,H,y,E])v.startRow<=v.endRow&&v.startColumn<=v.endColumn&&this._rangeCollection.addRange(v)}_clear(){this._shapes.forEach(e=>{e.dispose()}),this._shapes=[]}_addShapes(e,i,t,n){const{startRow:s,endRow:a,startColumn:c,endColumn:u}=e,m=w.getCoordByCell(s,c,t,n),H=w.getCoordByCell(a,u,t,n),{startX:y,startY:E}=m,{endX:v,endY:le}=H,ge=v-y,ue=le-E,de={left:y,top:E,color:new o.ColorKit(this._color).toRgb(),width:ge,height:ue,zIndex:re,evented:!1},B=new se(`crosshair-${i}`,de);this._shapes.push(B),t.addObject(B)}render(e){const i=this._sheetSkeletonManagerService.getCurrentSkeleton();if(!i)return;const{scene:t}=this._context;this._clear();for(let n=0;n<e.length;n++){const s=e[n];this._addShapes(s,n,t,i)}t.makeDirty(!0)}async dispose(){super.dispose()}};O=ae([p(1,o.Inject(w.SheetSkeletonManagerService)),p(2,o.Inject(T.SheetsSelectionsService)),p(3,o.Inject(f)),p(4,o.Inject(o.IContextService)),p(5,T.IRefSelectionsService)],O);var he=Object.getOwnPropertyDescriptor,ce=(r,e,i,t)=>{for(var n=t>1?void 0:t?he(e,i):e,s=r.length-1,a;s>=0;s--)(a=r[s])&&(n=a(n)||n);return n},P=(r,e)=>(i,t)=>e(i,t,r);h.UniverSheetsCrosshairHighlightPlugin=(I=class extends o.Plugin{constructor(e=A,i,t,n){super(),this._config=e,this._injector=i,this._renderManagerService=t,this._configService=n;const{...s}=o.merge({},A,this._config);this._configService.setConfig(Z,s)}onStarting(){[[f],[b]].forEach(e=>this._injector.add(e))}onReady(){[[O]].forEach(e=>this._injector.add(e)),this._injector.get(b),this._renderManagerService.registerRenderModule(o.UniverInstanceType.UNIVER_SHEET,[O])}},l(I,"pluginName","SHEET_CROSSHAIR_HIGHLIGHT_PLUGIN"),l(I,"type",o.UniverInstanceType.UNIVER_SHEET),I),h.UniverSheetsCrosshairHighlightPlugin=ce([P(1,o.Inject(o.Injector)),P(2,_.IRenderManagerService),P(3,o.IConfigService)],h.UniverSheetsCrosshairHighlightPlugin),h.CROSSHAIR_HIGHLIGHT_COLORS=M,h.DisableCrosshairHighlightOperation=k,h.EnableCrosshairHighlightOperation=U,h.SetCrosshairHighlightColorOperation=$,h.SheetsCrosshairHighlightService=f,h.ToggleCrosshairHighlightOperation=R,Object.defineProperty(h,Symbol.toStringTag,{value:"Module"})});
1
+ (function(h,o){typeof exports=="object"&&typeof module<"u"?o(exports,require("@univerjs/core"),require("@univerjs/engine-render"),require("@univerjs/ui"),require("rxjs"),require("react/jsx-runtime"),require("@univerjs/design"),require("react"),require("@univerjs/sheets"),require("@univerjs/sheets-ui")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/engine-render","@univerjs/ui","rxjs","react/jsx-runtime","@univerjs/design","react","@univerjs/sheets","@univerjs/sheets-ui"],o):(h=typeof globalThis<"u"?globalThis:h||self,o(h.UniverSheetsCrosshairHighlight={},h.UniverCore,h.UniverEngineRender,h.UniverUi,h.rxjs,h.React,h.UniverDesign,h.React,h.UniverSheets,h.UniverSheetsUi))})(this,function(h,o,_,S,u,V,q,C,T,w){"use strict";var ue=Object.defineProperty;var fe=(h,o,_)=>o in h?ue(h,o,{enumerable:!0,configurable:!0,writable:!0,value:_}):h[o]=_;var l=(h,o,_)=>fe(h,typeof o!="symbol"?o+"":o,_);var I;const B="sheets-crosshair-highlight.config",x={};var g=function(){return g=Object.assign||function(r){for(var e,t=1,i=arguments.length;t<i;t++){e=arguments[t];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(r[n]=e[n])}return r},g.apply(this,arguments)},Z=function(r,e){var t={};for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&e.indexOf(i)<0&&(t[i]=r[i]);if(r!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,i=Object.getOwnPropertySymbols(r);n<i.length;n++)e.indexOf(i[n])<0&&Object.prototype.propertyIsEnumerable.call(r,i[n])&&(t[i[n]]=r[i[n]]);return t},A=C.forwardRef(function(r,e){var t=r.icon,i=r.id,n=r.className,s=r.extend,a=Z(r,["icon","id","className","extend"]),c="univerjs-icon univerjs-icon-".concat(i," ").concat(n||"").trim(),d=C.useRef("_".concat(X()));return L(t,"".concat(i),{defIds:t.defIds,idSuffix:d.current},g({ref:e,className:c},a),s)});function L(r,e,t,i,n){return C.createElement(r.tag,g(g({key:e},W(r,t,n)),i),(F(r,t).children||[]).map(function(s,a){return L(s,"".concat(e,"-").concat(r.tag,"-").concat(a),t,void 0,n)}))}function W(r,e,t){var i=g({},r.attrs);t!=null&&t.colorChannel1&&i.fill==="colorChannel1"&&(i.fill=t.colorChannel1),r.tag==="mask"&&i.id&&(i.id=i.id+e.idSuffix),Object.entries(i).forEach(function(s){var a=s[0],c=s[1];a==="mask"&&typeof c=="string"&&(i[a]=c.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))});var n=e.defIds;return!n||n.length===0||(r.tag==="use"&&i["xlink:href"]&&(i["xlink:href"]=i["xlink:href"]+e.idSuffix),Object.entries(i).forEach(function(s){var a=s[0],c=s[1];typeof c=="string"&&(i[a]=c.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))})),i}function F(r,e){var t,i=e.defIds;return!i||i.length===0?r:r.tag==="defs"&&(!((t=r.children)===null||t===void 0)&&t.length)?g(g({},r),{children:r.children.map(function(n){return typeof n.attrs.id=="string"&&i&&i.indexOf(n.attrs.id)>-1?g(g({},n),{attrs:g(g({},n.attrs),{id:n.attrs.id+e.idSuffix})}):n})}):r}function X(){return Math.random().toString(36).substring(2,8)}A.displayName="UniverIcon";var K={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"}}]},U=C.forwardRef(function(r,e){return C.createElement(A,Object.assign({},r,{id:"cross-highlighting-single",ref:e,icon:K}))});U.displayName="CrossHighlightingSingle";const M=["rgba(158, 109, 227, 0.3)","rgba(254, 75, 75, 0.3)","rgba(255, 140, 81, 0.3)","rgba(164, 220, 22, 0.3)","rgba(45, 174, 255, 0.3)","rgba(58, 96, 247, 0.3)","rgba(242, 72, 166, 0.3)","rgba(153, 153, 153, 0.3)","rgba(158, 109, 227, 0.15)","rgba(254, 75, 75, 0.15)","rgba(255, 140, 81, 0.15)","rgba(164, 220, 22, 0.15)","rgba(45, 174, 255, 0.15)","rgba(58, 96, 247, 0.15)","rgba(242, 72, 166, 0.15)","rgba(153, 153, 153, 0.15)"];class f extends o.Disposable{constructor(){super(...arguments);l(this,"_enabled$",new u.BehaviorSubject(!1));l(this,"enabled$",this._enabled$.asObservable());l(this,"_color$",new u.BehaviorSubject(M[0]));l(this,"color$",this._color$.asObservable())}get enabled(){return this._enabled$.getValue()}get color(){return this._color$.getValue()}dispose(){this._enabled$.complete()}setEnabled(t){this._enabled$.next(t)}setColor(t){this._color$.next(t)}}const R={id:"sheet.operation.toggle-crosshair-highlight",type:o.CommandType.OPERATION,handler(r){const e=r.get(f),t=e.enabled;return e.setEnabled(!t),!0}},$={id:"sheet.operation.set-crosshair-highlight-color",type:o.CommandType.OPERATION,handler(r,{value:e}){const t=r.get(f);return t.enabled||t.setEnabled(!0),t.setColor(e),!0}},G={id:"sheet.operation.enable-crosshair-highlight",type:o.CommandType.OPERATION,handler(r){const e=r.get(f);return e.enabled?!1:(e.setEnabled(!0),!0)}},k={id:"sheet.operation.disable-crosshair-highlight",type:o.CommandType.OPERATION,handler(r){const e=r.get(f);return e.enabled?(e.setEnabled(!1),!0):!1}},j={crosshairHighlightOverlay:"univer-crosshair-highlight-overlay",crosshairHighlightItem:"univer-crosshair-highlight-item",crosshairHighlightItemSelected:"univer-crosshair-highlight-item-selected"};function z(r){const{onChange:e}=r,t=S.useDependency(f),i=S.useObservable(t.color$),n=C.useCallback(s=>{e==null||e(s)},[e]);return V.jsx("div",{className:j.crosshairHighlightOverlay,children:M.map(s=>V.jsx("div",{className:q.clsx(j.crosshairHighlightItem,{[j.crosshairHighlightItemSelected]:s===i}),style:{backgroundColor:s},onClick:()=>n(s)},s))})}const D="CROSSHAIR_HIGHLIGHT_OVERLAY_COMPONENT";function J(r){const e=r.get(f);return{id:R.id,tooltip:"crosshair.button.tooltip",type:S.MenuItemType.BUTTON_SELECTOR,icon:"CrossHighlightingSingle",selections:[{label:{name:D,hoverable:!1}}],selectionsCommandId:$.id,activated$:e.enabled$,hidden$:S.getMenuHiddenObservable(r,o.UniverInstanceType.UNIVER_SHEET)}}const Q={[S.ContextMenuPosition.FOOTER_MENU]:{[S.ContextMenuGroup.OTHERS]:{[R.id]:{order:0,menuItemFactory:J}}}};var ee=Object.getOwnPropertyDescriptor,te=(r,e,t,i)=>{for(var n=i>1?void 0:i?ee(e,t):e,s=r.length-1,a;s>=0;s--)(a=r[s])&&(n=a(n)||n);return n},N=(r,e)=>(t,i)=>e(t,i,r);let b=class extends o.Disposable{constructor(r,e,t){super(),this._componentMgr=r,this._menuManagerService=e,this._cmdSrv=t,this._initCommands(),this._initMenus(),this._initComponents()}_initCommands(){[R,$,G,k].forEach(r=>this._cmdSrv.registerCommand(r))}_initMenus(){this._menuManagerService.mergeMenu(Q)}_initComponents(){this._componentMgr.register(D,z),this._componentMgr.register("CrossHighlightingSingle",U)}};b=te([N(0,o.Inject(S.ComponentManager)),N(1,S.IMenuManagerService),N(2,o.ICommandService)],b);const ie=1;class ne{constructor(){l(this,"_selectedRanges",[]);l(this,"_ranges",[])}addRange(e){if(e.rangeType===o.RANGE_TYPE.COLUMN||e.rangeType===o.RANGE_TYPE.ROW||e.rangeType===o.RANGE_TYPE.ALL)return;const t=this._getIntersects(e),i=this._getSplitRanges(e,t);i.length>0&&this._ranges.push(...i)}setSelectedRanges(e){this._selectedRanges=e}_getSplitRanges(e,t){let i=[e];for(const n of t.concat(this._selectedRanges)){const s=[];for(const a of i){const c=o.Rectangle.subtract(a,n);c&&c.length>0&&s.push(...c)}i=s}return i.filter(n=>n.startRow<=n.endRow&&n.startColumn<=n.endColumn)}_getIntersects(e){const t=[];for(const i of this._ranges){const n=o.Rectangle.getIntersects(i,e);n&&t.push(n)}return t}getRanges(){return this._ranges}reset(){this._ranges=[],this._selectedRanges=[]}}class re extends _.Shape{constructor(t,i){super(t,i);l(this,"_color");i&&this.setShapeProps(i)}setShapeProps(t){typeof t.color<"u"&&(this._color=t.color),this.transformByState({width:t.width,height:t.height})}_draw(t){var n,s;const i=`rgba(${this._color.r}, ${this._color.g}, ${this._color.b}, ${(s=(n=this._color)==null?void 0:n.a)!=null?s:.5})`;_.Rect.drawWith(t,{width:this.width,height:this.height,fill:i,stroke:void 0,strokeWidth:0,evented:!1})}}var se=Object.getOwnPropertyDescriptor,oe=(r,e,t,i)=>{for(var n=i>1?void 0:i?se(e,t):e,s=r.length-1,a;s>=0;s--)(a=r[s])&&(n=a(n)||n);return n},p=(r,e)=>(t,i)=>e(t,i,r);let O=class extends o.Disposable{constructor(e,t,i,n,s,a){super();l(this,"_shapes",[]);l(this,"_rangeCollection",new ne);l(this,"_color","rgba(255,0,0,0.5)");this._context=e,this._sheetSkeletonManagerService=t,this._sheetsSelectionsService=i,this._sheetsCrosshairHighlightService=n,this._contextService=s,this._refSelectionsService=a,this._initRenderListener()}_transformSelection(e,t){if(!e)return;const i=t.getRowCount(),n=t.getColumnCount(),s=[];for(const a of e){const{startRow:c,endRow:d,startColumn:m,endColumn:H}=a.range;d-c+1===i||H-m+1===n||s.push(a.range)}this._rangeCollection.setSelectedRanges(s);for(const a of s)this.addSelection(a,t)}_initRenderListener(){const e=this._context.unit;this.disposeWithMe(u.combineLatest([this._contextService.subscribeContextValue$(T.REF_SELECTIONS_ENABLED).pipe(u.startWith(!1)),this._sheetSkeletonManagerService.currentSkeleton$,this._sheetsCrosshairHighlightService.enabled$,this._sheetsCrosshairHighlightService.color$.pipe(u.tap(t=>this._color=t)),u.merge(this._sheetsSelectionsService.selectionMoveStart$,this._sheetsSelectionsService.selectionMoving$,this._sheetsSelectionsService.selectionMoveEnd$,this._sheetsSelectionsService.selectionSet$,e.activeSheet$.pipe(u.map(()=>this._sheetsSelectionsService.getCurrentSelections()))),u.merge(this._refSelectionsService.selectionMoveStart$,this._refSelectionsService.selectionMoving$,this._refSelectionsService.selectionMoveEnd$,this._sheetsSelectionsService.selectionSet$,e.activeSheet$.pipe(u.map(()=>this._refSelectionsService.getCurrentSelections())))]).subscribe(([t,i,n,s,a,c])=>{if(this._clear(),!n)return;const d=t?c:a;this._rangeCollection.reset(),this._transformSelection(d,e.getActiveSheet()),this.render(this._rangeCollection.getRanges())}))}addSelection(e,t){if(e.rangeType===o.RANGE_TYPE.COLUMN||e.rangeType===o.RANGE_TYPE.ROW||e.rangeType===o.RANGE_TYPE.ALL)return;const i=t.getRowCount(),n=t.getColumnCount(),{startRow:s,endRow:a,startColumn:c,endColumn:d}=e,m={startRow:s,endRow:a,startColumn:0,endColumn:c-1},H={startRow:s,endRow:a,startColumn:d+1,endColumn:n},E={startRow:0,endRow:s-1,startColumn:c,endColumn:d},y={startRow:a+1,endRow:i,startColumn:c,endColumn:d};for(const v of[m,H,E,y])v.startRow<=v.endRow&&v.startColumn<=v.endColumn&&this._rangeCollection.addRange(v)}_clear(){this._shapes.forEach(e=>{e.dispose()}),this._shapes=[]}_addShapes(e,t,i,n){const{startRow:s,endRow:a,startColumn:c,endColumn:d}=e,m=w.getCoordByCell(s,c,i,n),H=w.getCoordByCell(a,d,i,n),{startX:E,startY:y}=m,{endX:v,endY:ce}=H,le=v-E,ge=ce-y,de={left:E,top:y,color:new o.ColorKit(this._color).toRgb(),width:le,height:ge,zIndex:ie,evented:!1},Y=new re(`crosshair-${t}`,de);this._shapes.push(Y),i.addObject(Y)}render(e){const t=this._sheetSkeletonManagerService.getCurrentSkeleton();if(!t)return;const{scene:i}=this._context;this._clear();for(let n=0;n<e.length;n++){const s=e[n];this._addShapes(s,n,i,t)}i.makeDirty(!0)}async dispose(){super.dispose()}};O=oe([p(1,o.Inject(w.SheetSkeletonManagerService)),p(2,o.Inject(T.SheetsSelectionsService)),p(3,o.Inject(f)),p(4,o.Inject(o.IContextService)),p(5,T.IRefSelectionsService)],O);var ae=Object.getOwnPropertyDescriptor,he=(r,e,t,i)=>{for(var n=i>1?void 0:i?ae(e,t):e,s=r.length-1,a;s>=0;s--)(a=r[s])&&(n=a(n)||n);return n},P=(r,e)=>(t,i)=>e(t,i,r);h.UniverSheetsCrosshairHighlightPlugin=(I=class extends o.Plugin{constructor(e=x,t,i,n){super(),this._config=e,this._injector=t,this._renderManagerService=i,this._configService=n;const{...s}=o.merge({},x,this._config);this._configService.setConfig(B,s)}onStarting(){[[f],[b]].forEach(e=>this._injector.add(e))}onReady(){[[O]].forEach(e=>this._injector.add(e)),this._injector.get(b),this._renderManagerService.registerRenderModule(o.UniverInstanceType.UNIVER_SHEET,[O])}},l(I,"pluginName","SHEET_CROSSHAIR_HIGHLIGHT_PLUGIN"),l(I,"type",o.UniverInstanceType.UNIVER_SHEET),I),h.UniverSheetsCrosshairHighlightPlugin=he([P(1,o.Inject(o.Injector)),P(2,_.IRenderManagerService),P(3,o.IConfigService)],h.UniverSheetsCrosshairHighlightPlugin),h.CROSSHAIR_HIGHLIGHT_COLORS=M,h.DisableCrosshairHighlightOperation=k,h.EnableCrosshairHighlightOperation=G,h.SetCrosshairHighlightColorOperation=$,h.SheetsCrosshairHighlightService=f,h.ToggleCrosshairHighlightOperation=R,Object.defineProperty(h,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@univerjs/sheets-crosshair-highlight",
3
- "version": "0.6.1-nightly.202502251606",
3
+ "version": "0.6.2",
4
4
  "private": false,
5
5
  "description": "",
6
6
  "author": "DreamNum <developer@univer.ai>",
@@ -58,12 +58,12 @@
58
58
  },
59
59
  "dependencies": {
60
60
  "@univerjs/icons": "^0.2.20",
61
- "clsx": "^2.1.1",
62
- "@univerjs/core": "0.6.1-nightly.202502251606",
63
- "@univerjs/engine-render": "0.6.1-nightly.202502251606",
64
- "@univerjs/sheets": "0.6.1-nightly.202502251606",
65
- "@univerjs/sheets-ui": "0.6.1-nightly.202502251606",
66
- "@univerjs/ui": "0.6.1-nightly.202502251606"
61
+ "@univerjs/core": "0.6.2",
62
+ "@univerjs/design": "0.6.2",
63
+ "@univerjs/engine-render": "0.6.2",
64
+ "@univerjs/sheets-ui": "0.6.2",
65
+ "@univerjs/ui": "0.6.2",
66
+ "@univerjs/sheets": "0.6.2"
67
67
  },
68
68
  "devDependencies": {
69
69
  "less": "^4.2.2",
@@ -72,9 +72,9 @@
72
72
  "rxjs": "^7.8.1",
73
73
  "tailwindcss": "^3.4.17",
74
74
  "typescript": "^5.7.3",
75
- "vite": "^6.1.1",
76
- "vitest": "^3.0.6",
77
- "@univerjs-infra/shared": "0.6.1"
75
+ "vite": "^6.2.0",
76
+ "vitest": "^3.0.7",
77
+ "@univerjs-infra/shared": "0.6.2"
78
78
  },
79
79
  "scripts": {
80
80
  "test": "vitest run",