@univerjs/sheets-crosshair-highlight 0.5.1 → 0.5.2-nightly.202412281605

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/cjs/index.js CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";var K=Object.defineProperty;var z=(n,e,t)=>e in n?K(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var g=(n,e,t)=>z(n,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("@univerjs/core"),M=require("@univerjs/engine-render"),m=require("@univerjs/ui"),_=require("rxjs"),C=require("react"),P=require("@univerjs/sheets-ui"),$=require("@univerjs/sheets"),Q="sheets-crosshair-highlight.config",ee={};var u=function(){return u=Object.assign||function(n){for(var e,t=1,r=arguments.length;t<r;t++){e=arguments[t];for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(n[i]=e[i])}return n},u.apply(this,arguments)},te=function(n,e){var t={};for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&e.indexOf(r)<0&&(t[r]=n[r]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,r=Object.getOwnPropertySymbols(n);i<r.length;i++)e.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(n,r[i])&&(t[r[i]]=n[r[i]]);return t},U=C.forwardRef(function(n,e){var t=n.icon,r=n.id,i=n.className,s=n.extend,o=te(n,["icon","id","className","extend"]),c="univerjs-icon univerjs-icon-".concat(r," ").concat(i||"").trim(),l=C.useRef("_".concat(ie()));return D(t,"".concat(r),{defIds:t.defIds,idSuffix:l.current},u({ref:e,className:c},o),s)});function D(n,e,t,r,i){return C.createElement(n.tag,u(u({key:e},re(n,t,i)),r),(ne(n,t).children||[]).map(function(s,o){return D(s,"".concat(e,"-").concat(n.tag,"-").concat(o),t,void 0,i)}))}function re(n,e,t){var r=u({},n.attrs);t!=null&&t.colorChannel1&&r.fill==="colorChannel1"&&(r.fill=t.colorChannel1);var i=e.defIds;return!i||i.length===0||(n.tag==="use"&&r["xlink:href"]&&(r["xlink:href"]=r["xlink:href"]+e.idSuffix),Object.entries(r).forEach(function(s){var o=s[0],c=s[1];typeof c=="string"&&(r[o]=c.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))})),r}function ne(n,e){var t,r=e.defIds;return!r||r.length===0?n:n.tag==="defs"&&(!((t=n.children)===null||t===void 0)&&t.length)?u(u({},n),{children:n.children.map(function(i){return typeof i.attrs.id=="string"&&r&&r.indexOf(i.attrs.id)>-1?u(u({},i),{attrs:u(u({},i.attrs),{id:i.attrs.id+e.idSuffix})}):i})}):n}function ie(){return Math.random().toString(36).substring(2,8)}U.displayName="UniverIcon";var se={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"}}]},q=C.forwardRef(function(n,e){return C.createElement(U,Object.assign({},n,{id:"cross-highlighting-single",ref:e,icon:se}))});q.displayName="CrossHighlightingSingle";const j=["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 p extends a.Disposable{constructor(){super(...arguments);g(this,"_enabled$",new _.BehaviorSubject(!1));g(this,"enabled$",this._enabled$.asObservable());g(this,"_color$",new _.BehaviorSubject(j[0]));g(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 y={id:"sheet.operation.toggle-crosshair-highlight",type:a.CommandType.OPERATION,handler(n){const e=n.get(p),t=e.enabled;return e.setEnabled(!t),!0}},N={id:"sheet.operation.set-crosshair-highlight-color",type:a.CommandType.OPERATION,handler(n,{value:e}){const t=n.get(p);return t.enabled||t.setEnabled(!0),t.setColor(e),!0}},Y={id:"sheet.operation.enable-crosshair-highlight",type:a.CommandType.OPERATION,handler(n){const e=n.get(p);return e.enabled?!1:(e.setEnabled(!0),!0)}},k={id:"sheet.operation.disable-crosshair-highlight",type:a.CommandType.OPERATION,handler(n){const e=n.get(p);return e.enabled?(e.setEnabled(!1),!0):!1}};var E={exports:{}},R={};/**
1
+ "use strict";var z=Object.defineProperty;var Q=(n,e,t)=>e in n?z(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var g=(n,e,t)=>Q(n,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("@univerjs/core"),P=require("@univerjs/engine-render"),m=require("@univerjs/ui"),_=require("rxjs"),C=require("react"),$=require("@univerjs/sheets"),M=require("@univerjs/sheets-ui"),ee="sheets-crosshair-highlight.config",A={};var u=function(){return u=Object.assign||function(n){for(var e,t=1,r=arguments.length;t<r;t++){e=arguments[t];for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(n[i]=e[i])}return n},u.apply(this,arguments)},te=function(n,e){var t={};for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&e.indexOf(r)<0&&(t[r]=n[r]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,r=Object.getOwnPropertySymbols(n);i<r.length;i++)e.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(n,r[i])&&(t[r[i]]=n[r[i]]);return t},D=C.forwardRef(function(n,e){var t=n.icon,r=n.id,i=n.className,s=n.extend,o=te(n,["icon","id","className","extend"]),c="univerjs-icon univerjs-icon-".concat(r," ").concat(i||"").trim(),l=C.useRef("_".concat(ie()));return q(t,"".concat(r),{defIds:t.defIds,idSuffix:l.current},u({ref:e,className:c},o),s)});function q(n,e,t,r,i){return C.createElement(n.tag,u(u({key:e},re(n,t,i)),r),(ne(n,t).children||[]).map(function(s,o){return q(s,"".concat(e,"-").concat(n.tag,"-").concat(o),t,void 0,i)}))}function re(n,e,t){var r=u({},n.attrs);t!=null&&t.colorChannel1&&r.fill==="colorChannel1"&&(r.fill=t.colorChannel1);var i=e.defIds;return!i||i.length===0||(n.tag==="use"&&r["xlink:href"]&&(r["xlink:href"]=r["xlink:href"]+e.idSuffix),Object.entries(r).forEach(function(s){var o=s[0],c=s[1];typeof c=="string"&&(r[o]=c.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))})),r}function ne(n,e){var t,r=e.defIds;return!r||r.length===0?n:n.tag==="defs"&&(!((t=n.children)===null||t===void 0)&&t.length)?u(u({},n),{children:n.children.map(function(i){return typeof i.attrs.id=="string"&&r&&r.indexOf(i.attrs.id)>-1?u(u({},i),{attrs:u(u({},i.attrs),{id:i.attrs.id+e.idSuffix})}):i})}):n}function ie(){return Math.random().toString(36).substring(2,8)}D.displayName="UniverIcon";var se={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"}}]},Y=C.forwardRef(function(n,e){return C.createElement(D,Object.assign({},n,{id:"cross-highlighting-single",ref:e,icon:se}))});Y.displayName="CrossHighlightingSingle";const j=["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 p extends a.Disposable{constructor(){super(...arguments);g(this,"_enabled$",new _.BehaviorSubject(!1));g(this,"enabled$",this._enabled$.asObservable());g(this,"_color$",new _.BehaviorSubject(j[0]));g(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 E={id:"sheet.operation.toggle-crosshair-highlight",type:a.CommandType.OPERATION,handler(n){const e=n.get(p),t=e.enabled;return e.setEnabled(!t),!0}},N={id:"sheet.operation.set-crosshair-highlight-color",type:a.CommandType.OPERATION,handler(n,{value:e}){const t=n.get(p);return t.enabled||t.setEnabled(!0),t.setColor(e),!0}},k={id:"sheet.operation.enable-crosshair-highlight",type:a.CommandType.OPERATION,handler(n){const e=n.get(p);return e.enabled?!1:(e.setEnabled(!0),!0)}},B={id:"sheet.operation.disable-crosshair-highlight",type:a.CommandType.OPERATION,handler(n){const e=n.get(p);return e.enabled?(e.setEnabled(!1),!0):!1}};var y={exports:{}},R={};/**
2
2
  * @license React
3
3
  * react-jsx-runtime.production.min.js
4
4
  *
@@ -6,4 +6,4 @@
6
6
  *
7
7
  * This source code is licensed under the MIT license found in the
8
8
  * LICENSE file in the root directory of this source tree.
9
- */var A;function oe(){if(A)return R;A=1;var n=C,e=Symbol.for("react.element"),t=Symbol.for("react.fragment"),r=Object.prototype.hasOwnProperty,i=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,s={key:!0,ref:!0,__self:!0,__source:!0};function o(c,l,S){var h,f={},v=null,d=null;S!==void 0&&(v=""+S),l.key!==void 0&&(v=""+l.key),l.ref!==void 0&&(d=l.ref);for(h in l)r.call(l,h)&&!s.hasOwnProperty(h)&&(f[h]=l[h]);if(c&&c.defaultProps)for(h in l=c.defaultProps,l)f[h]===void 0&&(f[h]=l[h]);return{$$typeof:e,type:c,key:v,ref:d,props:f,_owner:i.current}}return R.Fragment=t,R.jsx=o,R.jsxs=o,R}var L;function ae(){return L||(L=1,E.exports=oe()),E.exports}var G=ae();function B(n){var e,t,r="";if(typeof n=="string"||typeof n=="number")r+=n;else if(typeof n=="object")if(Array.isArray(n)){var i=n.length;for(e=0;e<i;e++)n[e]&&(t=B(n[e]))&&(r&&(r+=" "),r+=t)}else for(t in n)n[t]&&(r&&(r+=" "),r+=t);return r}function ce(){for(var n,e,t=0,r="",i=arguments.length;t<i;t++)(n=arguments[t])&&(e=B(n))&&(r&&(r+=" "),r+=e);return r}const le="univer-crosshair-highlight-overlay",he="univer-crosshair-highlight-item",ge="univer-crosshair-highlight-item-selected",T={crosshairHighlightOverlay:le,crosshairHighlightItem:he,crosshairHighlightItemSelected:ge};function ue(n){const{onChange:e}=n,t=a.useDependency(p),r=a.useObservable(t.color$),i=C.useCallback(s=>{e==null||e(s)},[e]);return G.jsx("div",{className:T.crosshairHighlightOverlay,children:j.map(s=>G.jsx("div",{className:ce(T.crosshairHighlightItem,{[T.crosshairHighlightItemSelected]:s===r}),style:{backgroundColor:s},onClick:()=>i(s)},s))})}const Z="CROSSHAIR_HIGHLIGHT_OVERLAY_COMPONENT";function de(n){const e=n.get(p);return{id:y.id,tooltip:"crosshair.button.tooltip",type:m.MenuItemType.BUTTON_SELECTOR,icon:"CrossHighlightingSingle",selections:[{label:{name:Z,hoverable:!1}}],selectionsCommandId:N.id,activated$:e.enabled$,hidden$:m.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}const fe={[m.ContextMenuPosition.FOOTER_MENU]:{[m.ContextMenuGroup.OTHERS]:{[y.id]:{order:0,menuItemFactory:de}}}};var _e=Object.defineProperty,Se=Object.getOwnPropertyDescriptor,ve=(n,e,t,r)=>{for(var i=r>1?void 0:r?Se(e,t):e,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&_e(e,t,i),i},w=(n,e)=>(t,r)=>e(t,r,n);let O=class extends a.Disposable{constructor(n,e,t){super(),this._componentMgr=n,this._menuManagerService=e,this._cmdSrv=t,this._initCommands(),this._initMenus(),this._initComponents()}_initCommands(){[y,N,Y,k].forEach(n=>this._cmdSrv.registerCommand(n))}_initMenus(){this._menuManagerService.mergeMenu(fe)}_initComponents(){this._componentMgr.register(Z,ue),this._componentMgr.register("CrossHighlightingSingle",q)}};O=ve([w(0,a.Inject(m.ComponentManager)),w(1,m.IMenuManagerService),w(2,a.ICommandService)],O);const pe=1;class Ce{constructor(){g(this,"_selectedRanges",[]);g(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 i of t.concat(this._selectedRanges)){const s=[];for(const o of r){const c=a.Rectangle.subtract(o,i);c&&c.length>0&&s.push(...c)}r=s}return r.filter(i=>i.startRow<=i.endRow&&i.startColumn<=i.endColumn)}_getIntersects(e){const t=[];for(const r of this._ranges){const i=a.Rectangle.getIntersects(r,e);i&&t.push(i)}return t}getRanges(){return this._ranges}reset(){this._ranges=[],this._selectedRanges=[]}}class me extends M.Shape{constructor(t,r){super(t,r);g(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){const r=`rgba(${this._color.r}, ${this._color.g}, ${this._color.b}, ${this._color.a})`;M.Rect.drawWith(t,{width:this.width,height:this.height,fill:r,stroke:void 0,strokeWidth:0,evented:!1})}}var Re=Object.defineProperty,be=Object.getOwnPropertyDescriptor,He=(n,e,t,r)=>{for(var i=r>1?void 0:r?be(e,t):e,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&Re(e,t,i),i},b=(n,e)=>(t,r)=>e(t,r,n);let I=class extends a.Disposable{constructor(e,t,r,i,s,o){super();g(this,"_shapes",[]);g(this,"_rangeCollection",new Ce);g(this,"_color","rgba(255,0,0,0.5)");this._context=e,this._sheetSkeletonManagerService=t,this._sheetsSelectionsService=r,this._sheetsCrosshairHighlightService=i,this._contextService=s,this._refSelectionsService=o,this._initRenderListener()}_transformSelection(e,t){if(!e)return;const r=t.getRowCount(),i=t.getColumnCount(),s=[];for(const o of e){const{startRow:c,endRow:l,startColumn:S,endColumn:h}=o.range;l-c+1===r||h-S+1===i||s.push(o.range)}this._rangeCollection.setSelectedRanges(s);for(const o of s)this.addSelection(o,t)}_initRenderListener(){const e=this._context.unit;this.disposeWithMe(_.combineLatest([this._contextService.subscribeContextValue$($.DISABLE_NORMAL_SELECTIONS).pipe(_.startWith(!1)),this._sheetSkeletonManagerService.currentSkeleton$,this._sheetsCrosshairHighlightService.enabled$,this._sheetsCrosshairHighlightService.color$.pipe(_.tap(t=>this._color=t)),_.merge(this._sheetsSelectionsService.selectionMoveStart$,this._sheetsSelectionsService.selectionMoving$,this._sheetsSelectionsService.selectionMoveEnd$,e.activeSheet$.pipe(_.map(()=>this._sheetsSelectionsService.getCurrentSelections()))),_.merge(this._refSelectionsService.selectionMoveStart$,this._refSelectionsService.selectionMoving$,this._refSelectionsService.selectionMoveEnd$,e.activeSheet$.pipe(_.map(()=>this._refSelectionsService.getCurrentSelections())))]).subscribe(([t,r,i,s,o,c])=>{if(this._clear(),!i)return;const l=t?c:o;this._rangeCollection.reset(),this._transformSelection(l,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(),i=t.getColumnCount(),{startRow:s,endRow:o,startColumn:c,endColumn:l}=e,S={startRow:s,endRow:o,startColumn:0,endColumn:c-1},h={startRow:s,endRow:o,startColumn:l+1,endColumn:i},f={startRow:0,endRow:s-1,startColumn:c,endColumn:l},v={startRow:o+1,endRow:r,startColumn:c,endColumn:l};for(const d of[S,h,f,v])d.startRow<=d.endRow&&d.startColumn<=d.endColumn&&this._rangeCollection.addRange(d)}_clear(){this._shapes.forEach(e=>{e.dispose()}),this._shapes=[]}_addShapes(e,t,r,i){const{startRow:s,endRow:o,startColumn:c,endColumn:l}=e,S=P.getCoordByCell(s,c,r,i),h=P.getCoordByCell(o,l,r,i),{startX:f,startY:v}=S,{endX:d,endY:W}=h,F=d-f,J=W-v,X={left:f,top:v,color:new a.ColorKit(this._color).toRgb(),width:F,height:J,zIndex:pe,evented:!1},V=new me(`crosshair-${t}`,X);this._shapes.push(V),r.addObject(V)}render(e){const t=this._sheetSkeletonManagerService.getCurrentSkeleton();if(!t)return;const{scene:r}=this._context;this._clear();for(let i=0;i<e.length;i++){const s=e[i];this._addShapes(s,i,r,t)}r.makeDirty(!0)}async dispose(){super.dispose()}};I=He([b(1,a.Inject(P.SheetSkeletonManagerService)),b(2,a.Inject($.SheetsSelectionsService)),b(3,a.Inject(p)),b(4,a.Inject(a.IContextService)),b(5,$.IRefSelectionsService)],I);var Oe=Object.defineProperty,Ie=Object.getOwnPropertyDescriptor,ye=(n,e,t,r)=>{for(var i=r>1?void 0:r?Ie(e,t):e,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&Oe(e,t,i),i},x=(n,e)=>(t,r)=>e(t,r,n),H;exports.UniverSheetsCrosshairHighlightPlugin=(H=class extends a.Plugin{constructor(e=ee,t,r,i){super(),this._config=e,this._injector=t,this._renderManagerService=r,this._configService=i;const{...s}=this._config;this._configService.setConfig(Q,s)}onStarting(){[[p],[O]].forEach(e=>this._injector.add(e))}onReady(){[[I]].forEach(e=>this._injector.add(e)),this._injector.get(O),this._renderManagerService.registerRenderModule(a.UniverInstanceType.UNIVER_SHEET,[I])}},g(H,"pluginName","SHEET_CROSSHAIR_HIGHLIGHT_PLUGIN"),g(H,"type",a.UniverInstanceType.UNIVER_SHEET),H);exports.UniverSheetsCrosshairHighlightPlugin=ye([x(1,a.Inject(a.Injector)),x(2,M.IRenderManagerService),x(3,a.IConfigService)],exports.UniverSheetsCrosshairHighlightPlugin);exports.CROSSHAIR_HIGHLIGHT_COLORS=j;exports.DisableCrosshairHighlightOperation=k;exports.EnableCrosshairHighlightOperation=Y;exports.SetCrosshairHighlightColorOperation=N;exports.ToggleCrosshairHighlightOperation=y;
9
+ */var L;function oe(){if(L)return R;L=1;var n=C,e=Symbol.for("react.element"),t=Symbol.for("react.fragment"),r=Object.prototype.hasOwnProperty,i=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,s={key:!0,ref:!0,__self:!0,__source:!0};function o(c,l,S){var h,f={},v=null,d=null;S!==void 0&&(v=""+S),l.key!==void 0&&(v=""+l.key),l.ref!==void 0&&(d=l.ref);for(h in l)r.call(l,h)&&!s.hasOwnProperty(h)&&(f[h]=l[h]);if(c&&c.defaultProps)for(h in l=c.defaultProps,l)f[h]===void 0&&(f[h]=l[h]);return{$$typeof:e,type:c,key:v,ref:d,props:f,_owner:i.current}}return R.Fragment=t,R.jsx=o,R.jsxs=o,R}var G;function ae(){return G||(G=1,y.exports=oe()),y.exports}var U=ae();function Z(n){var e,t,r="";if(typeof n=="string"||typeof n=="number")r+=n;else if(typeof n=="object")if(Array.isArray(n)){var i=n.length;for(e=0;e<i;e++)n[e]&&(t=Z(n[e]))&&(r&&(r+=" "),r+=t)}else for(t in n)n[t]&&(r&&(r+=" "),r+=t);return r}function ce(){for(var n,e,t=0,r="",i=arguments.length;t<i;t++)(n=arguments[t])&&(e=Z(n))&&(r&&(r+=" "),r+=e);return r}const le="univer-crosshair-highlight-overlay",he="univer-crosshair-highlight-item",ge="univer-crosshair-highlight-item-selected",T={crosshairHighlightOverlay:le,crosshairHighlightItem:he,crosshairHighlightItemSelected:ge};function ue(n){const{onChange:e}=n,t=a.useDependency(p),r=a.useObservable(t.color$),i=C.useCallback(s=>{e==null||e(s)},[e]);return U.jsx("div",{className:T.crosshairHighlightOverlay,children:j.map(s=>U.jsx("div",{className:ce(T.crosshairHighlightItem,{[T.crosshairHighlightItemSelected]:s===r}),style:{backgroundColor:s},onClick:()=>i(s)},s))})}const F="CROSSHAIR_HIGHLIGHT_OVERLAY_COMPONENT";function de(n){const e=n.get(p);return{id:E.id,tooltip:"crosshair.button.tooltip",type:m.MenuItemType.BUTTON_SELECTOR,icon:"CrossHighlightingSingle",selections:[{label:{name:F,hoverable:!1}}],selectionsCommandId:N.id,activated$:e.enabled$,hidden$:m.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}const fe={[m.ContextMenuPosition.FOOTER_MENU]:{[m.ContextMenuGroup.OTHERS]:{[E.id]:{order:0,menuItemFactory:de}}}};var _e=Object.defineProperty,Se=Object.getOwnPropertyDescriptor,ve=(n,e,t,r)=>{for(var i=r>1?void 0:r?Se(e,t):e,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&_e(e,t,i),i},w=(n,e)=>(t,r)=>e(t,r,n);let O=class extends a.Disposable{constructor(n,e,t){super(),this._componentMgr=n,this._menuManagerService=e,this._cmdSrv=t,this._initCommands(),this._initMenus(),this._initComponents()}_initCommands(){[E,N,k,B].forEach(n=>this._cmdSrv.registerCommand(n))}_initMenus(){this._menuManagerService.mergeMenu(fe)}_initComponents(){this._componentMgr.register(F,ue),this._componentMgr.register("CrossHighlightingSingle",Y)}};O=ve([w(0,a.Inject(m.ComponentManager)),w(1,m.IMenuManagerService),w(2,a.ICommandService)],O);const pe=1;class Ce{constructor(){g(this,"_selectedRanges",[]);g(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 i of t.concat(this._selectedRanges)){const s=[];for(const o of r){const c=a.Rectangle.subtract(o,i);c&&c.length>0&&s.push(...c)}r=s}return r.filter(i=>i.startRow<=i.endRow&&i.startColumn<=i.endColumn)}_getIntersects(e){const t=[];for(const r of this._ranges){const i=a.Rectangle.getIntersects(r,e);i&&t.push(i)}return t}getRanges(){return this._ranges}reset(){this._ranges=[],this._selectedRanges=[]}}class me extends P.Shape{constructor(t,r){super(t,r);g(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){const r=`rgba(${this._color.r}, ${this._color.g}, ${this._color.b}, ${this._color.a})`;P.Rect.drawWith(t,{width:this.width,height:this.height,fill:r,stroke:void 0,strokeWidth:0,evented:!1})}}var Re=Object.defineProperty,be=Object.getOwnPropertyDescriptor,He=(n,e,t,r)=>{for(var i=r>1?void 0:r?be(e,t):e,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&Re(e,t,i),i},b=(n,e)=>(t,r)=>e(t,r,n);let I=class extends a.Disposable{constructor(e,t,r,i,s,o){super();g(this,"_shapes",[]);g(this,"_rangeCollection",new Ce);g(this,"_color","rgba(255,0,0,0.5)");this._context=e,this._sheetSkeletonManagerService=t,this._sheetsSelectionsService=r,this._sheetsCrosshairHighlightService=i,this._contextService=s,this._refSelectionsService=o,this._initRenderListener()}_transformSelection(e,t){if(!e)return;const r=t.getRowCount(),i=t.getColumnCount(),s=[];for(const o of e){const{startRow:c,endRow:l,startColumn:S,endColumn:h}=o.range;l-c+1===r||h-S+1===i||s.push(o.range)}this._rangeCollection.setSelectedRanges(s);for(const o of s)this.addSelection(o,t)}_initRenderListener(){const e=this._context.unit;this.disposeWithMe(_.combineLatest([this._contextService.subscribeContextValue$($.REF_SELECTIONS_ENABLED).pipe(_.startWith(!1)),this._sheetSkeletonManagerService.currentSkeleton$,this._sheetsCrosshairHighlightService.enabled$,this._sheetsCrosshairHighlightService.color$.pipe(_.tap(t=>this._color=t)),_.merge(this._sheetsSelectionsService.selectionMoveStart$,this._sheetsSelectionsService.selectionMoving$,this._sheetsSelectionsService.selectionMoveEnd$,this._sheetsSelectionsService.selectionSet$,e.activeSheet$.pipe(_.map(()=>this._sheetsSelectionsService.getCurrentSelections()))),_.merge(this._refSelectionsService.selectionMoveStart$,this._refSelectionsService.selectionMoving$,this._refSelectionsService.selectionMoveEnd$,this._sheetsSelectionsService.selectionSet$,e.activeSheet$.pipe(_.map(()=>this._refSelectionsService.getCurrentSelections())))]).subscribe(([t,r,i,s,o,c])=>{if(this._clear(),!i)return;const l=t?c:o;this._rangeCollection.reset(),this._transformSelection(l,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(),i=t.getColumnCount(),{startRow:s,endRow:o,startColumn:c,endColumn:l}=e,S={startRow:s,endRow:o,startColumn:0,endColumn:c-1},h={startRow:s,endRow:o,startColumn:l+1,endColumn:i},f={startRow:0,endRow:s-1,startColumn:c,endColumn:l},v={startRow:o+1,endRow:r,startColumn:c,endColumn:l};for(const d of[S,h,f,v])d.startRow<=d.endRow&&d.startColumn<=d.endColumn&&this._rangeCollection.addRange(d)}_clear(){this._shapes.forEach(e=>{e.dispose()}),this._shapes=[]}_addShapes(e,t,r,i){const{startRow:s,endRow:o,startColumn:c,endColumn:l}=e,S=M.getCoordByCell(s,c,r,i),h=M.getCoordByCell(o,l,r,i),{startX:f,startY:v}=S,{endX:d,endY:W}=h,J=d-f,X=W-v,K={left:f,top:v,color:new a.ColorKit(this._color).toRgb(),width:J,height:X,zIndex:pe,evented:!1},V=new me(`crosshair-${t}`,K);this._shapes.push(V),r.addObject(V)}render(e){const t=this._sheetSkeletonManagerService.getCurrentSkeleton();if(!t)return;const{scene:r}=this._context;this._clear();for(let i=0;i<e.length;i++){const s=e[i];this._addShapes(s,i,r,t)}r.makeDirty(!0)}async dispose(){super.dispose()}};I=He([b(1,a.Inject(M.SheetSkeletonManagerService)),b(2,a.Inject($.SheetsSelectionsService)),b(3,a.Inject(p)),b(4,a.Inject(a.IContextService)),b(5,$.IRefSelectionsService)],I);var Oe=Object.defineProperty,Ie=Object.getOwnPropertyDescriptor,Ee=(n,e,t,r)=>{for(var i=r>1?void 0:r?Ie(e,t):e,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&Oe(e,t,i),i},x=(n,e)=>(t,r)=>e(t,r,n),H;exports.UniverSheetsCrosshairHighlightPlugin=(H=class extends a.Plugin{constructor(e=A,t,r,i){super(),this._config=e,this._injector=t,this._renderManagerService=r,this._configService=i;const{...s}=a.merge({},A,this._config);this._configService.setConfig(ee,s)}onStarting(){[[p],[O]].forEach(e=>this._injector.add(e))}onReady(){[[I]].forEach(e=>this._injector.add(e)),this._injector.get(O),this._renderManagerService.registerRenderModule(a.UniverInstanceType.UNIVER_SHEET,[I])}},g(H,"pluginName","SHEET_CROSSHAIR_HIGHLIGHT_PLUGIN"),g(H,"type",a.UniverInstanceType.UNIVER_SHEET),H);exports.UniverSheetsCrosshairHighlightPlugin=Ee([x(1,a.Inject(a.Injector)),x(2,P.IRenderManagerService),x(3,a.IConfigService)],exports.UniverSheetsCrosshairHighlightPlugin);exports.CROSSHAIR_HIGHLIGHT_COLORS=j;exports.DisableCrosshairHighlightOperation=B;exports.EnableCrosshairHighlightOperation=k;exports.SetCrosshairHighlightColorOperation=N;exports.ToggleCrosshairHighlightOperation=E;
package/lib/es/index.js CHANGED
@@ -1,14 +1,14 @@
1
- var te = Object.defineProperty;
2
- var re = (n, e, t) => e in n ? te(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
3
- var h = (n, e, t) => re(n, typeof e != "symbol" ? e + "" : e, t);
4
- import { Disposable as M, CommandType as O, useDependency as ne, useObservable as se, UniverInstanceType as x, Inject as S, ICommandService as ie, RANGE_TYPE as p, Rectangle as T, IContextService as oe, ColorKit as ae, Plugin as ce, Injector as le, IConfigService as he } from "@univerjs/core";
5
- import { Shape as ge, Rect as ue, IRenderManagerService as de } from "@univerjs/engine-render";
6
- import { MenuItemType as fe, getMenuHiddenObservable as _e, ContextMenuPosition as ve, ContextMenuGroup as Se, ComponentManager as pe, IMenuManagerService as me } from "@univerjs/ui";
7
- import { BehaviorSubject as N, combineLatest as Ce, startWith as Re, tap as be, merge as j, map as V } from "rxjs";
8
- import He, { forwardRef as k, useRef as Oe, createElement as Z, useCallback as Ie } from "react";
9
- import { SheetSkeletonManagerService as ye, getCoordByCell as L } from "@univerjs/sheets-ui";
10
- import { SheetsSelectionsService as Ee, DISABLE_NORMAL_SELECTIONS as we, IRefSelectionsService as xe } from "@univerjs/sheets";
11
- const Me = "sheets-crosshair-highlight.config", $e = {};
1
+ var re = Object.defineProperty;
2
+ var ne = (n, e, t) => e in n ? re(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
3
+ var h = (n, e, t) => ne(n, typeof e != "symbol" ? e + "" : e, t);
4
+ import { Disposable as $, CommandType as O, useDependency as se, useObservable as ie, UniverInstanceType as x, Inject as v, ICommandService as oe, RANGE_TYPE as p, Rectangle as T, IContextService as ae, ColorKit as ce, Plugin as le, merge as he, Injector as ge, IConfigService as ue } from "@univerjs/core";
5
+ import { Shape as de, Rect as fe, IRenderManagerService as _e } from "@univerjs/engine-render";
6
+ import { MenuItemType as Se, getMenuHiddenObservable as ve, ContextMenuPosition as pe, ContextMenuGroup as me, ComponentManager as Ce, IMenuManagerService as Re } from "@univerjs/ui";
7
+ import { BehaviorSubject as N, combineLatest as be, startWith as He, tap as Oe, merge as j, map as V } from "rxjs";
8
+ import Ie, { forwardRef as Z, useRef as ye, createElement as B, useCallback as Ee } from "react";
9
+ import { SheetsSelectionsService as we, REF_SELECTIONS_ENABLED as xe, IRefSelectionsService as $e } from "@univerjs/sheets";
10
+ import { SheetSkeletonManagerService as Me, getCoordByCell as L } from "@univerjs/sheets-ui";
11
+ const Pe = "sheets-crosshair-highlight.config", A = {};
12
12
  var g = function() {
13
13
  return g = Object.assign || function(n) {
14
14
  for (var e, t = 1, r = arguments.length; t < r; t++) {
@@ -17,23 +17,23 @@ var g = function() {
17
17
  }
18
18
  return n;
19
19
  }, g.apply(this, arguments);
20
- }, Pe = function(n, e) {
20
+ }, Te = function(n, e) {
21
21
  var t = {};
22
22
  for (var r in n) Object.prototype.hasOwnProperty.call(n, r) && e.indexOf(r) < 0 && (t[r] = n[r]);
23
23
  if (n != null && typeof Object.getOwnPropertySymbols == "function")
24
24
  for (var s = 0, r = Object.getOwnPropertySymbols(n); s < r.length; s++)
25
25
  e.indexOf(r[s]) < 0 && Object.prototype.propertyIsEnumerable.call(n, r[s]) && (t[r[s]] = n[r[s]]);
26
26
  return t;
27
- }, B = k(function(n, e) {
28
- var t = n.icon, r = n.id, s = n.className, i = n.extend, o = Pe(n, ["icon", "id", "className", "extend"]), a = "univerjs-icon univerjs-icon-".concat(r, " ").concat(s || "").trim(), c = Oe("_".concat(je()));
27
+ }, F = Z(function(n, e) {
28
+ var t = n.icon, r = n.id, s = n.className, i = n.extend, o = Te(n, ["icon", "id", "className", "extend"]), a = "univerjs-icon univerjs-icon-".concat(r, " ").concat(s || "").trim(), c = ye("_".concat(Ve()));
29
29
  return W(t, "".concat(r), { defIds: t.defIds, idSuffix: c.current }, g({ ref: e, className: a }, o), i);
30
30
  });
31
31
  function W(n, e, t, r, s) {
32
- return Z(n.tag, g(g({ key: e }, Te(n, t, s)), r), (Ne(n, t).children || []).map(function(i, o) {
32
+ return B(n.tag, g(g({ key: e }, Ne(n, t, s)), r), (je(n, t).children || []).map(function(i, o) {
33
33
  return W(i, "".concat(e, "-").concat(n.tag, "-").concat(o), t, void 0, s);
34
34
  }));
35
35
  }
36
- function Te(n, e, t) {
36
+ function Ne(n, e, t) {
37
37
  var r = g({}, n.attrs);
38
38
  t != null && t.colorChannel1 && r.fill === "colorChannel1" && (r.fill = t.colorChannel1);
39
39
  var s = e.defIds;
@@ -42,21 +42,21 @@ function Te(n, e, t) {
42
42
  typeof a == "string" && (r[o] = a.replace(/url\(#(.*)\)/, "url(#$1".concat(e.idSuffix, ")")));
43
43
  })), r;
44
44
  }
45
- function Ne(n, e) {
45
+ function je(n, e) {
46
46
  var t, r = e.defIds;
47
47
  return !r || r.length === 0 ? n : n.tag === "defs" && (!((t = n.children) === null || t === void 0) && t.length) ? g(g({}, n), { children: n.children.map(function(s) {
48
48
  return typeof s.attrs.id == "string" && r && r.indexOf(s.attrs.id) > -1 ? g(g({}, s), { attrs: g(g({}, s.attrs), { id: s.attrs.id + e.idSuffix }) }) : s;
49
49
  }) }) : n;
50
50
  }
51
- function je() {
51
+ function Ve() {
52
52
  return Math.random().toString(36).substring(2, 8);
53
53
  }
54
- B.displayName = "UniverIcon";
55
- var Ve = { 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" } }] }, Y = k(function(n, e) {
56
- return Z(B, Object.assign({}, n, {
54
+ F.displayName = "UniverIcon";
55
+ var Le = { 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" } }] }, Y = Z(function(n, e) {
56
+ return B(F, Object.assign({}, n, {
57
57
  id: "cross-highlighting-single",
58
58
  ref: e,
59
- icon: Ve
59
+ icon: Le
60
60
  }));
61
61
  });
62
62
  Y.displayName = "CrossHighlightingSingle";
@@ -78,7 +78,7 @@ const q = [
78
78
  "rgba(242, 72, 166, 0.15)",
79
79
  "rgba(153, 153, 153, 0.15)"
80
80
  ];
81
- class v extends M {
81
+ class S extends $ {
82
82
  constructor() {
83
83
  super(...arguments);
84
84
  h(this, "_enabled$", new N(!1));
@@ -102,32 +102,32 @@ class v extends M {
102
102
  this._color$.next(t);
103
103
  }
104
104
  }
105
- const $ = {
105
+ const M = {
106
106
  id: "sheet.operation.toggle-crosshair-highlight",
107
107
  type: O.OPERATION,
108
108
  handler(n) {
109
- const e = n.get(v), t = e.enabled;
109
+ const e = n.get(S), t = e.enabled;
110
110
  return e.setEnabled(!t), !0;
111
111
  }
112
- }, F = {
112
+ }, J = {
113
113
  id: "sheet.operation.set-crosshair-highlight-color",
114
114
  type: O.OPERATION,
115
115
  handler(n, { value: e }) {
116
- const t = n.get(v);
116
+ const t = n.get(S);
117
117
  return t.enabled || t.setEnabled(!0), t.setColor(e), !0;
118
118
  }
119
- }, Le = {
119
+ }, Ae = {
120
120
  id: "sheet.operation.enable-crosshair-highlight",
121
121
  type: O.OPERATION,
122
122
  handler(n) {
123
- const e = n.get(v);
123
+ const e = n.get(S);
124
124
  return e.enabled ? !1 : (e.setEnabled(!0), !0);
125
125
  }
126
- }, Ae = {
126
+ }, Ge = {
127
127
  id: "sheet.operation.disable-crosshair-highlight",
128
128
  type: O.OPERATION,
129
129
  handler(n) {
130
- const e = n.get(v);
130
+ const e = n.get(S);
131
131
  return e.enabled ? (e.setEnabled(!1), !0) : !1;
132
132
  }
133
133
  };
@@ -141,11 +141,11 @@ var I = { exports: {} }, m = {};
141
141
  * This source code is licensed under the MIT license found in the
142
142
  * LICENSE file in the root directory of this source tree.
143
143
  */
144
- var A;
145
- function Ge() {
146
- if (A) return m;
147
- A = 1;
148
- var n = He, e = Symbol.for("react.element"), t = Symbol.for("react.fragment"), r = Object.prototype.hasOwnProperty, s = n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, i = { key: !0, ref: !0, __self: !0, __source: !0 };
144
+ var G;
145
+ function Ue() {
146
+ if (G) return m;
147
+ G = 1;
148
+ var n = Ie, e = Symbol.for("react.element"), t = Symbol.for("react.fragment"), r = Object.prototype.hasOwnProperty, s = n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, i = { key: !0, ref: !0, __self: !0, __source: !0 };
149
149
  function o(a, c, f) {
150
150
  var l, d = {}, _ = null, u = null;
151
151
  f !== void 0 && (_ = "" + f), c.key !== void 0 && (_ = "" + c.key), c.ref !== void 0 && (u = c.ref);
@@ -155,37 +155,37 @@ function Ge() {
155
155
  }
156
156
  return m.Fragment = t, m.jsx = o, m.jsxs = o, m;
157
157
  }
158
- var G;
159
- function Ue() {
160
- return G || (G = 1, I.exports = Ge()), I.exports;
158
+ var U;
159
+ function De() {
160
+ return U || (U = 1, I.exports = Ue()), I.exports;
161
161
  }
162
- var U = Ue();
163
- function J(n) {
162
+ var D = De();
163
+ function X(n) {
164
164
  var e, t, r = "";
165
165
  if (typeof n == "string" || typeof n == "number") r += n;
166
166
  else if (typeof n == "object") if (Array.isArray(n)) {
167
167
  var s = n.length;
168
- for (e = 0; e < s; e++) n[e] && (t = J(n[e])) && (r && (r += " "), r += t);
168
+ for (e = 0; e < s; e++) n[e] && (t = X(n[e])) && (r && (r += " "), r += t);
169
169
  } else for (t in n) n[t] && (r && (r += " "), r += t);
170
170
  return r;
171
171
  }
172
- function De() {
173
- for (var n, e, t = 0, r = "", s = arguments.length; t < s; t++) (n = arguments[t]) && (e = J(n)) && (r && (r += " "), r += e);
172
+ function ke() {
173
+ for (var n, e, t = 0, r = "", s = arguments.length; t < s; t++) (n = arguments[t]) && (e = X(n)) && (r && (r += " "), r += e);
174
174
  return r;
175
175
  }
176
- const ke = "univer-crosshair-highlight-overlay", Ze = "univer-crosshair-highlight-item", Be = "univer-crosshair-highlight-item-selected", y = {
177
- crosshairHighlightOverlay: ke,
178
- crosshairHighlightItem: Ze,
179
- crosshairHighlightItemSelected: Be
176
+ const Ze = "univer-crosshair-highlight-overlay", Be = "univer-crosshair-highlight-item", Fe = "univer-crosshair-highlight-item-selected", y = {
177
+ crosshairHighlightOverlay: Ze,
178
+ crosshairHighlightItem: Be,
179
+ crosshairHighlightItemSelected: Fe
180
180
  };
181
181
  function We(n) {
182
- const { onChange: e } = n, t = ne(v), r = se(t.color$), s = Ie((i) => {
182
+ const { onChange: e } = n, t = se(S), r = ie(t.color$), s = Ee((i) => {
183
183
  e == null || e(i);
184
184
  }, [e]);
185
- return /* @__PURE__ */ U.jsx("div", { className: y.crosshairHighlightOverlay, children: q.map((i) => /* @__PURE__ */ U.jsx(
185
+ return /* @__PURE__ */ D.jsx("div", { className: y.crosshairHighlightOverlay, children: q.map((i) => /* @__PURE__ */ D.jsx(
186
186
  "div",
187
187
  {
188
- className: De(y.crosshairHighlightItem, {
188
+ className: ke(y.crosshairHighlightItem, {
189
189
  [y.crosshairHighlightItemSelected]: i === r
190
190
  }),
191
191
  style: { backgroundColor: i },
@@ -194,68 +194,68 @@ function We(n) {
194
194
  i
195
195
  )) });
196
196
  }
197
- const X = "CROSSHAIR_HIGHLIGHT_OVERLAY_COMPONENT";
197
+ const K = "CROSSHAIR_HIGHLIGHT_OVERLAY_COMPONENT";
198
198
  function Ye(n) {
199
- const e = n.get(v);
199
+ const e = n.get(S);
200
200
  return {
201
- id: $.id,
201
+ id: M.id,
202
202
  tooltip: "crosshair.button.tooltip",
203
- type: fe.BUTTON_SELECTOR,
203
+ type: Se.BUTTON_SELECTOR,
204
204
  icon: "CrossHighlightingSingle",
205
205
  selections: [
206
206
  {
207
207
  label: {
208
- name: X,
208
+ name: K,
209
209
  hoverable: !1
210
210
  }
211
211
  }
212
212
  ],
213
- selectionsCommandId: F.id,
213
+ selectionsCommandId: J.id,
214
214
  activated$: e.enabled$,
215
- hidden$: _e(n, x.UNIVER_SHEET)
215
+ hidden$: ve(n, x.UNIVER_SHEET)
216
216
  };
217
217
  }
218
218
  const qe = {
219
- [ve.FOOTER_MENU]: {
220
- [Se.OTHERS]: {
221
- [$.id]: {
219
+ [pe.FOOTER_MENU]: {
220
+ [me.OTHERS]: {
221
+ [M.id]: {
222
222
  order: 0,
223
223
  menuItemFactory: Ye
224
224
  }
225
225
  }
226
226
  }
227
227
  };
228
- var Fe = Object.defineProperty, Je = Object.getOwnPropertyDescriptor, Xe = (n, e, t, r) => {
229
- for (var s = r > 1 ? void 0 : r ? Je(e, t) : e, i = n.length - 1, o; i >= 0; i--)
228
+ var Je = Object.defineProperty, Xe = Object.getOwnPropertyDescriptor, Ke = (n, e, t, r) => {
229
+ for (var s = r > 1 ? void 0 : r ? Xe(e, t) : e, i = n.length - 1, o; i >= 0; i--)
230
230
  (o = n[i]) && (s = (r ? o(e, t, s) : o(s)) || s);
231
- return r && s && Fe(e, t, s), s;
231
+ return r && s && Je(e, t, s), s;
232
232
  }, E = (n, e) => (t, r) => e(t, r, n);
233
- let b = class extends M {
233
+ let b = class extends $ {
234
234
  constructor(n, e, t) {
235
235
  super(), this._componentMgr = n, this._menuManagerService = e, this._cmdSrv = t, this._initCommands(), this._initMenus(), this._initComponents();
236
236
  }
237
237
  _initCommands() {
238
238
  [
239
- $,
240
- F,
241
- Le,
242
- Ae
239
+ M,
240
+ J,
241
+ Ae,
242
+ Ge
243
243
  ].forEach((n) => this._cmdSrv.registerCommand(n));
244
244
  }
245
245
  _initMenus() {
246
246
  this._menuManagerService.mergeMenu(qe);
247
247
  }
248
248
  _initComponents() {
249
- this._componentMgr.register(X, We), this._componentMgr.register("CrossHighlightingSingle", Y);
249
+ this._componentMgr.register(K, We), this._componentMgr.register("CrossHighlightingSingle", Y);
250
250
  }
251
251
  };
252
- b = Xe([
253
- E(0, S(pe)),
254
- E(1, me),
255
- E(2, ie)
252
+ b = Ke([
253
+ E(0, v(Ce)),
254
+ E(1, Re),
255
+ E(2, oe)
256
256
  ], b);
257
- const Ke = 1;
258
- class ze {
257
+ const ze = 1;
258
+ class Qe {
259
259
  constructor() {
260
260
  h(this, "_selectedRanges", []);
261
261
  h(this, "_ranges", []);
@@ -296,7 +296,7 @@ class ze {
296
296
  this._ranges = [], this._selectedRanges = [];
297
297
  }
298
298
  }
299
- class Qe extends ge {
299
+ class et extends de {
300
300
  constructor(t, r) {
301
301
  super(t, r);
302
302
  // protected _showHighLight = false;
@@ -311,7 +311,7 @@ class Qe extends ge {
311
311
  }
312
312
  _draw(t) {
313
313
  const r = `rgba(${this._color.r}, ${this._color.g}, ${this._color.b}, ${this._color.a})`;
314
- ue.drawWith(t, {
314
+ fe.drawWith(t, {
315
315
  width: this.width,
316
316
  height: this.height,
317
317
  fill: r,
@@ -321,16 +321,16 @@ class Qe extends ge {
321
321
  });
322
322
  }
323
323
  }
324
- var et = Object.defineProperty, tt = Object.getOwnPropertyDescriptor, rt = (n, e, t, r) => {
325
- for (var s = r > 1 ? void 0 : r ? tt(e, t) : e, i = n.length - 1, o; i >= 0; i--)
324
+ var tt = Object.defineProperty, rt = Object.getOwnPropertyDescriptor, nt = (n, e, t, r) => {
325
+ for (var s = r > 1 ? void 0 : r ? rt(e, t) : e, i = n.length - 1, o; i >= 0; i--)
326
326
  (o = n[i]) && (s = (r ? o(e, t, s) : o(s)) || s);
327
- return r && s && et(e, t, s), s;
327
+ return r && s && tt(e, t, s), s;
328
328
  }, C = (n, e) => (t, r) => e(t, r, n);
329
- let H = class extends M {
329
+ let H = class extends $ {
330
330
  constructor(e, t, r, s, i, o) {
331
331
  super();
332
332
  h(this, "_shapes", []);
333
- h(this, "_rangeCollection", new ze());
333
+ h(this, "_rangeCollection", new Qe());
334
334
  h(this, "_color", "rgba(255,0,0,0.5)");
335
335
  this._context = e, this._sheetSkeletonManagerService = t, this._sheetsSelectionsService = r, this._sheetsCrosshairHighlightService = s, this._contextService = i, this._refSelectionsService = o, this._initRenderListener();
336
336
  }
@@ -348,21 +348,23 @@ let H = class extends M {
348
348
  }
349
349
  _initRenderListener() {
350
350
  const e = this._context.unit;
351
- this.disposeWithMe(Ce([
352
- this._contextService.subscribeContextValue$(we).pipe(Re(!1)),
351
+ this.disposeWithMe(be([
352
+ this._contextService.subscribeContextValue$(xe).pipe(He(!1)),
353
353
  this._sheetSkeletonManagerService.currentSkeleton$,
354
354
  this._sheetsCrosshairHighlightService.enabled$,
355
- this._sheetsCrosshairHighlightService.color$.pipe(be((t) => this._color = t)),
355
+ this._sheetsCrosshairHighlightService.color$.pipe(Oe((t) => this._color = t)),
356
356
  j(
357
357
  this._sheetsSelectionsService.selectionMoveStart$,
358
358
  this._sheetsSelectionsService.selectionMoving$,
359
359
  this._sheetsSelectionsService.selectionMoveEnd$,
360
+ this._sheetsSelectionsService.selectionSet$,
360
361
  e.activeSheet$.pipe(V(() => this._sheetsSelectionsService.getCurrentSelections()))
361
362
  ),
362
363
  j(
363
364
  this._refSelectionsService.selectionMoveStart$,
364
365
  this._refSelectionsService.selectionMoving$,
365
366
  this._refSelectionsService.selectionMoveEnd$,
367
+ this._sheetsSelectionsService.selectionSet$,
366
368
  e.activeSheet$.pipe(V(() => this._refSelectionsService.getCurrentSelections()))
367
369
  )
368
370
  ]).subscribe(([t, r, s, i, o, a]) => {
@@ -404,15 +406,15 @@ let H = class extends M {
404
406
  }), this._shapes = [];
405
407
  }
406
408
  _addShapes(e, t, r, s) {
407
- const { startRow: i, endRow: o, startColumn: a, endColumn: c } = e, f = L(i, a, r, s), l = L(o, c, r, s), { startX: d, startY: _ } = f, { endX: u, endY: K } = l, z = u - d, Q = K - _, ee = {
409
+ const { startRow: i, endRow: o, startColumn: a, endColumn: c } = e, f = L(i, a, r, s), l = L(o, c, r, s), { startX: d, startY: _ } = f, { endX: u, endY: z } = l, Q = u - d, ee = z - _, te = {
408
410
  left: d,
409
411
  top: _,
410
- color: new ae(this._color).toRgb(),
411
- width: z,
412
- height: Q,
413
- zIndex: Ke,
412
+ color: new ce(this._color).toRgb(),
413
+ width: Q,
414
+ height: ee,
415
+ zIndex: ze,
414
416
  evented: !1
415
- }, P = new Qe(`crosshair-${t}`, ee);
417
+ }, P = new et(`crosshair-${t}`, te);
416
418
  this._shapes.push(P), r.addObject(P);
417
419
  }
418
420
  render(e) {
@@ -431,27 +433,31 @@ let H = class extends M {
431
433
  super.dispose();
432
434
  }
433
435
  };
434
- H = rt([
435
- C(1, S(ye)),
436
- C(2, S(Ee)),
437
- C(3, S(v)),
438
- C(4, S(oe)),
439
- C(5, xe)
436
+ H = nt([
437
+ C(1, v(Me)),
438
+ C(2, v(we)),
439
+ C(3, v(S)),
440
+ C(4, v(ae)),
441
+ C(5, $e)
440
442
  ], H);
441
- var nt = Object.defineProperty, st = Object.getOwnPropertyDescriptor, it = (n, e, t, r) => {
442
- for (var s = r > 1 ? void 0 : r ? st(e, t) : e, i = n.length - 1, o; i >= 0; i--)
443
+ var st = Object.defineProperty, it = Object.getOwnPropertyDescriptor, ot = (n, e, t, r) => {
444
+ for (var s = r > 1 ? void 0 : r ? it(e, t) : e, i = n.length - 1, o; i >= 0; i--)
443
445
  (o = n[i]) && (s = (r ? o(e, t, s) : o(s)) || s);
444
- return r && s && nt(e, t, s), s;
446
+ return r && s && st(e, t, s), s;
445
447
  }, w = (n, e) => (t, r) => e(t, r, n), R;
446
- let D = (R = class extends ce {
447
- constructor(n = $e, e, t, r) {
448
+ let k = (R = class extends le {
449
+ constructor(n = A, e, t, r) {
448
450
  super(), this._config = n, this._injector = e, this._renderManagerService = t, this._configService = r;
449
- const { ...s } = this._config;
450
- this._configService.setConfig(Me, s);
451
+ const { ...s } = he(
452
+ {},
453
+ A,
454
+ this._config
455
+ );
456
+ this._configService.setConfig(Pe, s);
451
457
  }
452
458
  onStarting() {
453
459
  [
454
- [v],
460
+ [S],
455
461
  [b]
456
462
  ].forEach((n) => this._injector.add(n));
457
463
  }
@@ -461,16 +467,16 @@ let D = (R = class extends ce {
461
467
  ].forEach((n) => this._injector.add(n)), this._injector.get(b), this._renderManagerService.registerRenderModule(x.UNIVER_SHEET, [H]);
462
468
  }
463
469
  }, h(R, "pluginName", "SHEET_CROSSHAIR_HIGHLIGHT_PLUGIN"), h(R, "type", x.UNIVER_SHEET), R);
464
- D = it([
465
- w(1, S(le)),
466
- w(2, de),
467
- w(3, he)
468
- ], D);
470
+ k = ot([
471
+ w(1, v(ge)),
472
+ w(2, _e),
473
+ w(3, ue)
474
+ ], k);
469
475
  export {
470
476
  q as CROSSHAIR_HIGHLIGHT_COLORS,
471
- Ae as DisableCrosshairHighlightOperation,
472
- Le as EnableCrosshairHighlightOperation,
473
- F as SetCrosshairHighlightColorOperation,
474
- $ as ToggleCrosshairHighlightOperation,
475
- D as UniverSheetsCrosshairHighlightPlugin
477
+ Ge as DisableCrosshairHighlightOperation,
478
+ Ae as EnableCrosshairHighlightOperation,
479
+ J as SetCrosshairHighlightColorOperation,
480
+ M as ToggleCrosshairHighlightOperation,
481
+ k as UniverSheetsCrosshairHighlightPlugin
476
482
  };
package/lib/index.css CHANGED
@@ -1 +1 @@
1
- .univer-crosshair-highlight-overlay{display:grid;row-gap:12px;column-gap:8px;grid-template-columns:repeat(8,20px)}.univer-crosshair-highlight-item{width:20px;height:20px;box-sizing:border-box;border-radius:4px;border:.5px solid rgb(var(--grey-400))}.univer-crosshair-highlight-item-selected{outline:1.5px solid rgb(var(--primary-color));outline-offset:1.5px}
1
+ *,:before,:after{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(63 131 248 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }::backdrop{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(63 131 248 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }*{scrollbar-color:initial;scrollbar-width:initial}@keyframes enter{0%{opacity:var(--tw-enter-opacity, 1);transform:translate3d(var(--tw-enter-translate-x, 0),var(--tw-enter-translate-y, 0),0) scale3d(var(--tw-enter-scale, 1),var(--tw-enter-scale, 1),var(--tw-enter-scale, 1)) rotate(var(--tw-enter-rotate, 0))}}@keyframes exit{to{opacity:var(--tw-exit-opacity, 1);transform:translate3d(var(--tw-exit-translate-x, 0),var(--tw-exit-translate-y, 0),0) scale3d(var(--tw-exit-scale, 1),var(--tw-exit-scale, 1),var(--tw-exit-scale, 1)) rotate(var(--tw-exit-rotate, 0))}}.univer-crosshair-highlight-overlay{display:grid;row-gap:12px;-moz-column-gap:8px;column-gap:8px;grid-template-columns:repeat(8,20px)}.univer-crosshair-highlight-item{width:20px;height:20px;box-sizing:border-box;border-radius:4px;border:.5px solid rgb(var(--grey-400))}.univer-crosshair-highlight-item-selected{outline:1.5px solid rgb(var(--primary-color));outline-offset:1.5px}
@@ -1,7 +1,7 @@
1
1
  import { IRange, Workbook, Worksheet, Disposable, IContextService } from '@univerjs/core';
2
2
  import { IRenderContext, IRenderModule } from '@univerjs/engine-render';
3
- import { SheetSkeletonManagerService } from '@univerjs/sheets-ui';
4
3
  import { SheetsSelectionsService } from '@univerjs/sheets';
4
+ import { SheetSkeletonManagerService } from '@univerjs/sheets-ui';
5
5
  import { SheetsCrosshairHighlightService } from '../../services/crosshair.service';
6
6
  export declare class SheetCrosshairHighlightRenderController extends Disposable implements IRenderModule {
7
7
  private readonly _context;
package/lib/umd/index.js CHANGED
@@ -1,4 +1,4 @@
1
- (function(c,o){typeof exports=="object"&&typeof module<"u"?o(exports,require("@univerjs/core"),require("@univerjs/engine-render"),require("@univerjs/ui"),require("rxjs"),require("react"),require("@univerjs/sheets-ui"),require("@univerjs/sheets")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/engine-render","@univerjs/ui","rxjs","react","@univerjs/sheets-ui","@univerjs/sheets"],o):(c=typeof globalThis<"u"?globalThis:c||self,o(c.UniverSheetsCrosshairHighlight={},c.UniverCore,c.UniverEngineRender,c.UniverUi,c.rxjs,c.React,c.UniverSheetsUi,c.UniverSheets))})(this,function(c,o,S,H,_,R,w,M){"use strict";var Oe=Object.defineProperty;var be=(c,o,S)=>o in c?Oe(c,o,{enumerable:!0,configurable:!0,writable:!0,value:S}):c[o]=S;var u=(c,o,S)=>be(c,typeof o!="symbol"?o+"":o,S);var T;const F="sheets-crosshair-highlight.config",J={};var d=function(){return d=Object.assign||function(n){for(var e,t=1,r=arguments.length;t<r;t++){e=arguments[t];for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(n[i]=e[i])}return n},d.apply(this,arguments)},X=function(n,e){var t={};for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&e.indexOf(r)<0&&(t[r]=n[r]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,r=Object.getOwnPropertySymbols(n);i<r.length;i++)e.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(n,r[i])&&(t[r[i]]=n[r[i]]);return t},A=R.forwardRef(function(n,e){var t=n.icon,r=n.id,i=n.className,s=n.extend,a=X(n,["icon","id","className","extend"]),l="univerjs-icon univerjs-icon-".concat(r," ").concat(i||"").trim(),h=R.useRef("_".concat(Q()));return L(t,"".concat(r),{defIds:t.defIds,idSuffix:h.current},d({ref:e,className:l},a),s)});function L(n,e,t,r,i){return R.createElement(n.tag,d(d({key:e},K(n,t,i)),r),(z(n,t).children||[]).map(function(s,a){return L(s,"".concat(e,"-").concat(n.tag,"-").concat(a),t,void 0,i)}))}function K(n,e,t){var r=d({},n.attrs);t!=null&&t.colorChannel1&&r.fill==="colorChannel1"&&(r.fill=t.colorChannel1);var i=e.defIds;return!i||i.length===0||(n.tag==="use"&&r["xlink:href"]&&(r["xlink:href"]=r["xlink:href"]+e.idSuffix),Object.entries(r).forEach(function(s){var a=s[0],l=s[1];typeof l=="string"&&(r[a]=l.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))})),r}function z(n,e){var t,r=e.defIds;return!r||r.length===0?n:n.tag==="defs"&&(!((t=n.children)===null||t===void 0)&&t.length)?d(d({},n),{children:n.children.map(function(i){return typeof i.attrs.id=="string"&&r&&r.indexOf(i.attrs.id)>-1?d(d({},i),{attrs:d(d({},i.attrs),{id:i.attrs.id+e.idSuffix})}):i})}):n}function Q(){return Math.random().toString(36).substring(2,8)}A.displayName="UniverIcon";var ee={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=R.forwardRef(function(n,e){return R.createElement(A,Object.assign({},n,{id:"cross-highlighting-single",ref:e,icon:ee}))});U.displayName="CrossHighlightingSingle";const P=["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 p extends o.Disposable{constructor(){super(...arguments);u(this,"_enabled$",new _.BehaviorSubject(!1));u(this,"enabled$",this._enabled$.asObservable());u(this,"_color$",new _.BehaviorSubject(P[0]));u(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:o.CommandType.OPERATION,handler(n){const e=n.get(p),t=e.enabled;return e.setEnabled(!t),!0}},j={id:"sheet.operation.set-crosshair-highlight-color",type:o.CommandType.OPERATION,handler(n,{value:e}){const t=n.get(p);return t.enabled||t.setEnabled(!0),t.setColor(e),!0}},G={id:"sheet.operation.enable-crosshair-highlight",type:o.CommandType.OPERATION,handler(n){const e=n.get(p);return e.enabled?!1:(e.setEnabled(!0),!0)}},D={id:"sheet.operation.disable-crosshair-highlight",type:o.CommandType.OPERATION,handler(n){const e=n.get(p);return e.enabled?(e.setEnabled(!1),!0):!1}};var N={exports:{}},O={};/**
1
+ (function(c,o){typeof exports=="object"&&typeof module<"u"?o(exports,require("@univerjs/core"),require("@univerjs/engine-render"),require("@univerjs/ui"),require("rxjs"),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","@univerjs/sheets","@univerjs/sheets-ui"],o):(c=typeof globalThis<"u"?globalThis:c||self,o(c.UniverSheetsCrosshairHighlight={},c.UniverCore,c.UniverEngineRender,c.UniverUi,c.rxjs,c.React,c.UniverSheets,c.UniverSheetsUi))})(this,function(c,o,S,H,_,R,w,P){"use strict";var be=Object.defineProperty;var Oe=(c,o,S)=>o in c?be(c,o,{enumerable:!0,configurable:!0,writable:!0,value:S}):c[o]=S;var u=(c,o,S)=>Oe(c,typeof o!="symbol"?o+"":o,S);var T;const J="sheets-crosshair-highlight.config",A={};var d=function(){return d=Object.assign||function(n){for(var e,t=1,r=arguments.length;t<r;t++){e=arguments[t];for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(n[i]=e[i])}return n},d.apply(this,arguments)},X=function(n,e){var t={};for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&e.indexOf(r)<0&&(t[r]=n[r]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,r=Object.getOwnPropertySymbols(n);i<r.length;i++)e.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(n,r[i])&&(t[r[i]]=n[r[i]]);return t},L=R.forwardRef(function(n,e){var t=n.icon,r=n.id,i=n.className,s=n.extend,a=X(n,["icon","id","className","extend"]),l="univerjs-icon univerjs-icon-".concat(r," ").concat(i||"").trim(),h=R.useRef("_".concat(Q()));return U(t,"".concat(r),{defIds:t.defIds,idSuffix:h.current},d({ref:e,className:l},a),s)});function U(n,e,t,r,i){return R.createElement(n.tag,d(d({key:e},K(n,t,i)),r),(z(n,t).children||[]).map(function(s,a){return U(s,"".concat(e,"-").concat(n.tag,"-").concat(a),t,void 0,i)}))}function K(n,e,t){var r=d({},n.attrs);t!=null&&t.colorChannel1&&r.fill==="colorChannel1"&&(r.fill=t.colorChannel1);var i=e.defIds;return!i||i.length===0||(n.tag==="use"&&r["xlink:href"]&&(r["xlink:href"]=r["xlink:href"]+e.idSuffix),Object.entries(r).forEach(function(s){var a=s[0],l=s[1];typeof l=="string"&&(r[a]=l.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))})),r}function z(n,e){var t,r=e.defIds;return!r||r.length===0?n:n.tag==="defs"&&(!((t=n.children)===null||t===void 0)&&t.length)?d(d({},n),{children:n.children.map(function(i){return typeof i.attrs.id=="string"&&r&&r.indexOf(i.attrs.id)>-1?d(d({},i),{attrs:d(d({},i.attrs),{id:i.attrs.id+e.idSuffix})}):i})}):n}function Q(){return Math.random().toString(36).substring(2,8)}L.displayName="UniverIcon";var ee={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=R.forwardRef(function(n,e){return R.createElement(L,Object.assign({},n,{id:"cross-highlighting-single",ref:e,icon:ee}))});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 p extends o.Disposable{constructor(){super(...arguments);u(this,"_enabled$",new _.BehaviorSubject(!1));u(this,"enabled$",this._enabled$.asObservable());u(this,"_color$",new _.BehaviorSubject(M[0]));u(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:o.CommandType.OPERATION,handler(n){const e=n.get(p),t=e.enabled;return e.setEnabled(!t),!0}},j={id:"sheet.operation.set-crosshair-highlight-color",type:o.CommandType.OPERATION,handler(n,{value:e}){const t=n.get(p);return t.enabled||t.setEnabled(!0),t.setColor(e),!0}},D={id:"sheet.operation.enable-crosshair-highlight",type:o.CommandType.OPERATION,handler(n){const e=n.get(p);return e.enabled?!1:(e.setEnabled(!0),!0)}},Y={id:"sheet.operation.disable-crosshair-highlight",type:o.CommandType.OPERATION,handler(n){const e=n.get(p);return e.enabled?(e.setEnabled(!1),!0):!1}};var N={exports:{}},b={};/**
2
2
  * @license React
3
3
  * react-jsx-runtime.production.min.js
4
4
  *
@@ -6,4 +6,4 @@
6
6
  *
7
7
  * This source code is licensed under the MIT license found in the
8
8
  * LICENSE file in the root directory of this source tree.
9
- */var Y;function te(){if(Y)return O;Y=1;var n=R,e=Symbol.for("react.element"),t=Symbol.for("react.fragment"),r=Object.prototype.hasOwnProperty,i=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,s={key:!0,ref:!0,__self:!0,__source:!0};function a(l,h,C){var g,v={},m=null,f=null;C!==void 0&&(m=""+C),h.key!==void 0&&(m=""+h.key),h.ref!==void 0&&(f=h.ref);for(g in h)r.call(h,g)&&!s.hasOwnProperty(g)&&(v[g]=h[g]);if(l&&l.defaultProps)for(g in h=l.defaultProps,h)v[g]===void 0&&(v[g]=h[g]);return{$$typeof:e,type:l,key:m,ref:f,props:v,_owner:i.current}}return O.Fragment=t,O.jsx=a,O.jsxs=a,O}var k;function re(){return k||(k=1,N.exports=te()),N.exports}var B=re();function Z(n){var e,t,r="";if(typeof n=="string"||typeof n=="number")r+=n;else if(typeof n=="object")if(Array.isArray(n)){var i=n.length;for(e=0;e<i;e++)n[e]&&(t=Z(n[e]))&&(r&&(r+=" "),r+=t)}else for(t in n)n[t]&&(r&&(r+=" "),r+=t);return r}function ne(){for(var n,e,t=0,r="",i=arguments.length;t<i;t++)(n=arguments[t])&&(e=Z(n))&&(r&&(r+=" "),r+=e);return r}const x={crosshairHighlightOverlay:"univer-crosshair-highlight-overlay",crosshairHighlightItem:"univer-crosshair-highlight-item",crosshairHighlightItemSelected:"univer-crosshair-highlight-item-selected"};function ie(n){const{onChange:e}=n,t=o.useDependency(p),r=o.useObservable(t.color$),i=R.useCallback(s=>{e==null||e(s)},[e]);return B.jsx("div",{className:x.crosshairHighlightOverlay,children:P.map(s=>B.jsx("div",{className:ne(x.crosshairHighlightItem,{[x.crosshairHighlightItemSelected]:s===r}),style:{backgroundColor:s},onClick:()=>i(s)},s))})}const W="CROSSHAIR_HIGHLIGHT_OVERLAY_COMPONENT";function se(n){const e=n.get(p);return{id:I.id,tooltip:"crosshair.button.tooltip",type:H.MenuItemType.BUTTON_SELECTOR,icon:"CrossHighlightingSingle",selections:[{label:{name:W,hoverable:!1}}],selectionsCommandId:j.id,activated$:e.enabled$,hidden$:H.getMenuHiddenObservable(n,o.UniverInstanceType.UNIVER_SHEET)}}const oe={[H.ContextMenuPosition.FOOTER_MENU]:{[H.ContextMenuGroup.OTHERS]:{[I.id]:{order:0,menuItemFactory:se}}}};var ae=Object.defineProperty,ce=Object.getOwnPropertyDescriptor,le=(n,e,t,r)=>{for(var i=r>1?void 0:r?ce(e,t):e,s=n.length-1,a;s>=0;s--)(a=n[s])&&(i=(r?a(e,t,i):a(i))||i);return r&&i&&ae(e,t,i),i},V=(n,e)=>(t,r)=>e(t,r,n);let y=class extends o.Disposable{constructor(n,e,t){super(),this._componentMgr=n,this._menuManagerService=e,this._cmdSrv=t,this._initCommands(),this._initMenus(),this._initComponents()}_initCommands(){[I,j,G,D].forEach(n=>this._cmdSrv.registerCommand(n))}_initMenus(){this._menuManagerService.mergeMenu(oe)}_initComponents(){this._componentMgr.register(W,ie),this._componentMgr.register("CrossHighlightingSingle",U)}};y=le([V(0,o.Inject(H.ComponentManager)),V(1,H.IMenuManagerService),V(2,o.ICommandService)],y);const he=1;class ge{constructor(){u(this,"_selectedRanges",[]);u(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),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 i of t.concat(this._selectedRanges)){const s=[];for(const a of r){const l=o.Rectangle.subtract(a,i);l&&l.length>0&&s.push(...l)}r=s}return r.filter(i=>i.startRow<=i.endRow&&i.startColumn<=i.endColumn)}_getIntersects(e){const t=[];for(const r of this._ranges){const i=o.Rectangle.getIntersects(r,e);i&&t.push(i)}return t}getRanges(){return this._ranges}reset(){this._ranges=[],this._selectedRanges=[]}}class ue extends S.Shape{constructor(t,r){super(t,r);u(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){const r=`rgba(${this._color.r}, ${this._color.g}, ${this._color.b}, ${this._color.a})`;S.Rect.drawWith(t,{width:this.width,height:this.height,fill:r,stroke:void 0,strokeWidth:0,evented:!1})}}var de=Object.defineProperty,fe=Object.getOwnPropertyDescriptor,_e=(n,e,t,r)=>{for(var i=r>1?void 0:r?fe(e,t):e,s=n.length-1,a;s>=0;s--)(a=n[s])&&(i=(r?a(e,t,i):a(i))||i);return r&&i&&de(e,t,i),i},b=(n,e)=>(t,r)=>e(t,r,n);let E=class extends o.Disposable{constructor(e,t,r,i,s,a){super();u(this,"_shapes",[]);u(this,"_rangeCollection",new ge);u(this,"_color","rgba(255,0,0,0.5)");this._context=e,this._sheetSkeletonManagerService=t,this._sheetsSelectionsService=r,this._sheetsCrosshairHighlightService=i,this._contextService=s,this._refSelectionsService=a,this._initRenderListener()}_transformSelection(e,t){if(!e)return;const r=t.getRowCount(),i=t.getColumnCount(),s=[];for(const a of e){const{startRow:l,endRow:h,startColumn:C,endColumn:g}=a.range;h-l+1===r||g-C+1===i||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(_.combineLatest([this._contextService.subscribeContextValue$(M.DISABLE_NORMAL_SELECTIONS).pipe(_.startWith(!1)),this._sheetSkeletonManagerService.currentSkeleton$,this._sheetsCrosshairHighlightService.enabled$,this._sheetsCrosshairHighlightService.color$.pipe(_.tap(t=>this._color=t)),_.merge(this._sheetsSelectionsService.selectionMoveStart$,this._sheetsSelectionsService.selectionMoving$,this._sheetsSelectionsService.selectionMoveEnd$,e.activeSheet$.pipe(_.map(()=>this._sheetsSelectionsService.getCurrentSelections()))),_.merge(this._refSelectionsService.selectionMoveStart$,this._refSelectionsService.selectionMoving$,this._refSelectionsService.selectionMoveEnd$,e.activeSheet$.pipe(_.map(()=>this._refSelectionsService.getCurrentSelections())))]).subscribe(([t,r,i,s,a,l])=>{if(this._clear(),!i)return;const h=t?l:a;this._rangeCollection.reset(),this._transformSelection(h,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 r=t.getRowCount(),i=t.getColumnCount(),{startRow:s,endRow:a,startColumn:l,endColumn:h}=e,C={startRow:s,endRow:a,startColumn:0,endColumn:l-1},g={startRow:s,endRow:a,startColumn:h+1,endColumn:i},v={startRow:0,endRow:s-1,startColumn:l,endColumn:h},m={startRow:a+1,endRow:r,startColumn:l,endColumn:h};for(const f of[C,g,v,m])f.startRow<=f.endRow&&f.startColumn<=f.endColumn&&this._rangeCollection.addRange(f)}_clear(){this._shapes.forEach(e=>{e.dispose()}),this._shapes=[]}_addShapes(e,t,r,i){const{startRow:s,endRow:a,startColumn:l,endColumn:h}=e,C=w.getCoordByCell(s,l,r,i),g=w.getCoordByCell(a,h,r,i),{startX:v,startY:m}=C,{endX:f,endY:Ce}=g,me=f-v,Re=Ce-m,He={left:v,top:m,color:new o.ColorKit(this._color).toRgb(),width:me,height:Re,zIndex:he,evented:!1},q=new ue(`crosshair-${t}`,He);this._shapes.push(q),r.addObject(q)}render(e){const t=this._sheetSkeletonManagerService.getCurrentSkeleton();if(!t)return;const{scene:r}=this._context;this._clear();for(let i=0;i<e.length;i++){const s=e[i];this._addShapes(s,i,r,t)}r.makeDirty(!0)}async dispose(){super.dispose()}};E=_e([b(1,o.Inject(w.SheetSkeletonManagerService)),b(2,o.Inject(M.SheetsSelectionsService)),b(3,o.Inject(p)),b(4,o.Inject(o.IContextService)),b(5,M.IRefSelectionsService)],E);var ve=Object.defineProperty,Se=Object.getOwnPropertyDescriptor,pe=(n,e,t,r)=>{for(var i=r>1?void 0:r?Se(e,t):e,s=n.length-1,a;s>=0;s--)(a=n[s])&&(i=(r?a(e,t,i):a(i))||i);return r&&i&&ve(e,t,i),i},$=(n,e)=>(t,r)=>e(t,r,n);c.UniverSheetsCrosshairHighlightPlugin=(T=class extends o.Plugin{constructor(e=J,t,r,i){super(),this._config=e,this._injector=t,this._renderManagerService=r,this._configService=i;const{...s}=this._config;this._configService.setConfig(F,s)}onStarting(){[[p],[y]].forEach(e=>this._injector.add(e))}onReady(){[[E]].forEach(e=>this._injector.add(e)),this._injector.get(y),this._renderManagerService.registerRenderModule(o.UniverInstanceType.UNIVER_SHEET,[E])}},u(T,"pluginName","SHEET_CROSSHAIR_HIGHLIGHT_PLUGIN"),u(T,"type",o.UniverInstanceType.UNIVER_SHEET),T),c.UniverSheetsCrosshairHighlightPlugin=pe([$(1,o.Inject(o.Injector)),$(2,S.IRenderManagerService),$(3,o.IConfigService)],c.UniverSheetsCrosshairHighlightPlugin),c.CROSSHAIR_HIGHLIGHT_COLORS=P,c.DisableCrosshairHighlightOperation=D,c.EnableCrosshairHighlightOperation=G,c.SetCrosshairHighlightColorOperation=j,c.ToggleCrosshairHighlightOperation=I,Object.defineProperty(c,Symbol.toStringTag,{value:"Module"})});
9
+ */var k;function te(){if(k)return b;k=1;var n=R,e=Symbol.for("react.element"),t=Symbol.for("react.fragment"),r=Object.prototype.hasOwnProperty,i=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,s={key:!0,ref:!0,__self:!0,__source:!0};function a(l,h,C){var g,v={},m=null,f=null;C!==void 0&&(m=""+C),h.key!==void 0&&(m=""+h.key),h.ref!==void 0&&(f=h.ref);for(g in h)r.call(h,g)&&!s.hasOwnProperty(g)&&(v[g]=h[g]);if(l&&l.defaultProps)for(g in h=l.defaultProps,h)v[g]===void 0&&(v[g]=h[g]);return{$$typeof:e,type:l,key:m,ref:f,props:v,_owner:i.current}}return b.Fragment=t,b.jsx=a,b.jsxs=a,b}var B;function re(){return B||(B=1,N.exports=te()),N.exports}var Z=re();function F(n){var e,t,r="";if(typeof n=="string"||typeof n=="number")r+=n;else if(typeof n=="object")if(Array.isArray(n)){var i=n.length;for(e=0;e<i;e++)n[e]&&(t=F(n[e]))&&(r&&(r+=" "),r+=t)}else for(t in n)n[t]&&(r&&(r+=" "),r+=t);return r}function ne(){for(var n,e,t=0,r="",i=arguments.length;t<i;t++)(n=arguments[t])&&(e=F(n))&&(r&&(r+=" "),r+=e);return r}const x={crosshairHighlightOverlay:"univer-crosshair-highlight-overlay",crosshairHighlightItem:"univer-crosshair-highlight-item",crosshairHighlightItemSelected:"univer-crosshair-highlight-item-selected"};function ie(n){const{onChange:e}=n,t=o.useDependency(p),r=o.useObservable(t.color$),i=R.useCallback(s=>{e==null||e(s)},[e]);return Z.jsx("div",{className:x.crosshairHighlightOverlay,children:M.map(s=>Z.jsx("div",{className:ne(x.crosshairHighlightItem,{[x.crosshairHighlightItemSelected]:s===r}),style:{backgroundColor:s},onClick:()=>i(s)},s))})}const W="CROSSHAIR_HIGHLIGHT_OVERLAY_COMPONENT";function se(n){const e=n.get(p);return{id:I.id,tooltip:"crosshair.button.tooltip",type:H.MenuItemType.BUTTON_SELECTOR,icon:"CrossHighlightingSingle",selections:[{label:{name:W,hoverable:!1}}],selectionsCommandId:j.id,activated$:e.enabled$,hidden$:H.getMenuHiddenObservable(n,o.UniverInstanceType.UNIVER_SHEET)}}const oe={[H.ContextMenuPosition.FOOTER_MENU]:{[H.ContextMenuGroup.OTHERS]:{[I.id]:{order:0,menuItemFactory:se}}}};var ae=Object.defineProperty,ce=Object.getOwnPropertyDescriptor,le=(n,e,t,r)=>{for(var i=r>1?void 0:r?ce(e,t):e,s=n.length-1,a;s>=0;s--)(a=n[s])&&(i=(r?a(e,t,i):a(i))||i);return r&&i&&ae(e,t,i),i},$=(n,e)=>(t,r)=>e(t,r,n);let y=class extends o.Disposable{constructor(n,e,t){super(),this._componentMgr=n,this._menuManagerService=e,this._cmdSrv=t,this._initCommands(),this._initMenus(),this._initComponents()}_initCommands(){[I,j,D,Y].forEach(n=>this._cmdSrv.registerCommand(n))}_initMenus(){this._menuManagerService.mergeMenu(oe)}_initComponents(){this._componentMgr.register(W,ie),this._componentMgr.register("CrossHighlightingSingle",G)}};y=le([$(0,o.Inject(H.ComponentManager)),$(1,H.IMenuManagerService),$(2,o.ICommandService)],y);const he=1;class ge{constructor(){u(this,"_selectedRanges",[]);u(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),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 i of t.concat(this._selectedRanges)){const s=[];for(const a of r){const l=o.Rectangle.subtract(a,i);l&&l.length>0&&s.push(...l)}r=s}return r.filter(i=>i.startRow<=i.endRow&&i.startColumn<=i.endColumn)}_getIntersects(e){const t=[];for(const r of this._ranges){const i=o.Rectangle.getIntersects(r,e);i&&t.push(i)}return t}getRanges(){return this._ranges}reset(){this._ranges=[],this._selectedRanges=[]}}class ue extends S.Shape{constructor(t,r){super(t,r);u(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){const r=`rgba(${this._color.r}, ${this._color.g}, ${this._color.b}, ${this._color.a})`;S.Rect.drawWith(t,{width:this.width,height:this.height,fill:r,stroke:void 0,strokeWidth:0,evented:!1})}}var de=Object.defineProperty,fe=Object.getOwnPropertyDescriptor,_e=(n,e,t,r)=>{for(var i=r>1?void 0:r?fe(e,t):e,s=n.length-1,a;s>=0;s--)(a=n[s])&&(i=(r?a(e,t,i):a(i))||i);return r&&i&&de(e,t,i),i},O=(n,e)=>(t,r)=>e(t,r,n);let E=class extends o.Disposable{constructor(e,t,r,i,s,a){super();u(this,"_shapes",[]);u(this,"_rangeCollection",new ge);u(this,"_color","rgba(255,0,0,0.5)");this._context=e,this._sheetSkeletonManagerService=t,this._sheetsSelectionsService=r,this._sheetsCrosshairHighlightService=i,this._contextService=s,this._refSelectionsService=a,this._initRenderListener()}_transformSelection(e,t){if(!e)return;const r=t.getRowCount(),i=t.getColumnCount(),s=[];for(const a of e){const{startRow:l,endRow:h,startColumn:C,endColumn:g}=a.range;h-l+1===r||g-C+1===i||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(_.combineLatest([this._contextService.subscribeContextValue$(w.REF_SELECTIONS_ENABLED).pipe(_.startWith(!1)),this._sheetSkeletonManagerService.currentSkeleton$,this._sheetsCrosshairHighlightService.enabled$,this._sheetsCrosshairHighlightService.color$.pipe(_.tap(t=>this._color=t)),_.merge(this._sheetsSelectionsService.selectionMoveStart$,this._sheetsSelectionsService.selectionMoving$,this._sheetsSelectionsService.selectionMoveEnd$,this._sheetsSelectionsService.selectionSet$,e.activeSheet$.pipe(_.map(()=>this._sheetsSelectionsService.getCurrentSelections()))),_.merge(this._refSelectionsService.selectionMoveStart$,this._refSelectionsService.selectionMoving$,this._refSelectionsService.selectionMoveEnd$,this._sheetsSelectionsService.selectionSet$,e.activeSheet$.pipe(_.map(()=>this._refSelectionsService.getCurrentSelections())))]).subscribe(([t,r,i,s,a,l])=>{if(this._clear(),!i)return;const h=t?l:a;this._rangeCollection.reset(),this._transformSelection(h,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 r=t.getRowCount(),i=t.getColumnCount(),{startRow:s,endRow:a,startColumn:l,endColumn:h}=e,C={startRow:s,endRow:a,startColumn:0,endColumn:l-1},g={startRow:s,endRow:a,startColumn:h+1,endColumn:i},v={startRow:0,endRow:s-1,startColumn:l,endColumn:h},m={startRow:a+1,endRow:r,startColumn:l,endColumn:h};for(const f of[C,g,v,m])f.startRow<=f.endRow&&f.startColumn<=f.endColumn&&this._rangeCollection.addRange(f)}_clear(){this._shapes.forEach(e=>{e.dispose()}),this._shapes=[]}_addShapes(e,t,r,i){const{startRow:s,endRow:a,startColumn:l,endColumn:h}=e,C=P.getCoordByCell(s,l,r,i),g=P.getCoordByCell(a,h,r,i),{startX:v,startY:m}=C,{endX:f,endY:Ce}=g,me=f-v,Re=Ce-m,He={left:v,top:m,color:new o.ColorKit(this._color).toRgb(),width:me,height:Re,zIndex:he,evented:!1},q=new ue(`crosshair-${t}`,He);this._shapes.push(q),r.addObject(q)}render(e){const t=this._sheetSkeletonManagerService.getCurrentSkeleton();if(!t)return;const{scene:r}=this._context;this._clear();for(let i=0;i<e.length;i++){const s=e[i];this._addShapes(s,i,r,t)}r.makeDirty(!0)}async dispose(){super.dispose()}};E=_e([O(1,o.Inject(P.SheetSkeletonManagerService)),O(2,o.Inject(w.SheetsSelectionsService)),O(3,o.Inject(p)),O(4,o.Inject(o.IContextService)),O(5,w.IRefSelectionsService)],E);var ve=Object.defineProperty,Se=Object.getOwnPropertyDescriptor,pe=(n,e,t,r)=>{for(var i=r>1?void 0:r?Se(e,t):e,s=n.length-1,a;s>=0;s--)(a=n[s])&&(i=(r?a(e,t,i):a(i))||i);return r&&i&&ve(e,t,i),i},V=(n,e)=>(t,r)=>e(t,r,n);c.UniverSheetsCrosshairHighlightPlugin=(T=class extends o.Plugin{constructor(e=A,t,r,i){super(),this._config=e,this._injector=t,this._renderManagerService=r,this._configService=i;const{...s}=o.merge({},A,this._config);this._configService.setConfig(J,s)}onStarting(){[[p],[y]].forEach(e=>this._injector.add(e))}onReady(){[[E]].forEach(e=>this._injector.add(e)),this._injector.get(y),this._renderManagerService.registerRenderModule(o.UniverInstanceType.UNIVER_SHEET,[E])}},u(T,"pluginName","SHEET_CROSSHAIR_HIGHLIGHT_PLUGIN"),u(T,"type",o.UniverInstanceType.UNIVER_SHEET),T),c.UniverSheetsCrosshairHighlightPlugin=pe([V(1,o.Inject(o.Injector)),V(2,S.IRenderManagerService),V(3,o.IConfigService)],c.UniverSheetsCrosshairHighlightPlugin),c.CROSSHAIR_HIGHLIGHT_COLORS=M,c.DisableCrosshairHighlightOperation=Y,c.EnableCrosshairHighlightOperation=D,c.SetCrosshairHighlightColorOperation=j,c.ToggleCrosshairHighlightOperation=I,Object.defineProperty(c,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@univerjs/sheets-crosshair-highlight",
3
- "version": "0.5.1",
3
+ "version": "0.5.2-nightly.202412281605",
4
4
  "private": false,
5
5
  "description": "",
6
6
  "author": "DreamNum <developer@univer.ai>",
@@ -59,22 +59,22 @@
59
59
  "dependencies": {
60
60
  "@univerjs/icons": "^0.2.8",
61
61
  "clsx": "^2.1.1",
62
- "@univerjs/core": "0.5.1",
63
- "@univerjs/engine-render": "0.5.1",
64
- "@univerjs/sheets": "0.5.1",
65
- "@univerjs/ui": "0.5.1",
66
- "@univerjs/sheets-ui": "0.5.1"
62
+ "@univerjs/engine-render": "0.5.2-nightly.202412281605",
63
+ "@univerjs/core": "0.5.2-nightly.202412281605",
64
+ "@univerjs/sheets": "0.5.2-nightly.202412281605",
65
+ "@univerjs/ui": "0.5.2-nightly.202412281605",
66
+ "@univerjs/sheets-ui": "0.5.2-nightly.202412281605"
67
67
  },
68
68
  "devDependencies": {
69
69
  "less": "^4.2.1",
70
70
  "postcss": "^8.4.49",
71
71
  "react": "18.3.1",
72
72
  "rxjs": "^7.8.1",
73
- "tailwindcss": "^3.4.15",
73
+ "tailwindcss": "^3.4.16",
74
74
  "typescript": "^5.7.2",
75
- "vite": "^6.0.1",
76
- "vitest": "^2.1.6",
77
- "@univerjs-infra/shared": "0.5.1"
75
+ "vite": "^6.0.3",
76
+ "vitest": "^2.1.8",
77
+ "@univerjs-infra/shared": "0.5.2"
78
78
  },
79
79
  "space": {
80
80
  ".": {
package/LICENSE DELETED
@@ -1,176 +0,0 @@
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