@univerjs/sheets-crosshair-highlight 0.5.0 → 0.5.1

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,r)=>e in n?K(n,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):n[e]=r;var l=(n,e,r)=>z(n,typeof e!="symbol"?e+"":e,r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("@univerjs/core"),M=require("@univerjs/engine-render"),v=require("@univerjs/ui"),u=require("rxjs"),_=require("react"),P=require("@univerjs/sheets-ui"),$=require("@univerjs/sheets");var h=function(){return h=Object.assign||function(n){for(var e,r=1,t=arguments.length;r<t;r++){e=arguments[r];for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&(n[s]=e[s])}return n},h.apply(this,arguments)},J=function(n,e){var r={};for(var t in n)Object.prototype.hasOwnProperty.call(n,t)&&e.indexOf(t)<0&&(r[t]=n[t]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,t=Object.getOwnPropertySymbols(n);s<t.length;s++)e.indexOf(t[s])<0&&Object.prototype.propertyIsEnumerable.call(n,t[s])&&(r[t[s]]=n[t[s]]);return r},A=_.forwardRef(function(n,e){var r=n.icon,t=n.id,s=n.className,i=n.extend,o=J(n,["icon","id","className","extend"]),c="univerjs-icon univerjs-icon-".concat(t," ").concat(s||"").trim(),g=_.useRef("_".concat(te()));return L(r,"".concat(t),{defIds:r.defIds,idSuffix:g.current},h({ref:e,className:c},o),i)});function L(n,e,r,t,s){return _.createElement(n.tag,h(h({key:e},Q(n,r,s)),t),(ee(n,r).children||[]).map(function(i,o){return L(i,"".concat(e,"-").concat(n.tag,"-").concat(o),r,void 0,s)}))}function Q(n,e,r){var t=h({},n.attrs);r!=null&&r.colorChannel1&&t.fill==="colorChannel1"&&(t.fill=r.colorChannel1);var s=e.defIds;return!s||s.length===0||(n.tag==="use"&&t["xlink:href"]&&(t["xlink:href"]=t["xlink:href"]+e.idSuffix),Object.entries(t).forEach(function(i){var o=i[0],c=i[1];typeof c=="string"&&(t[o]=c.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))})),t}function ee(n,e){var r,t=e.defIds;return!t||t.length===0?n:n.tag==="defs"&&(!((r=n.children)===null||r===void 0)&&r.length)?h(h({},n),{children:n.children.map(function(s){return typeof s.attrs.id=="string"&&t&&t.indexOf(s.attrs.id)>-1?h(h({},s),{attrs:h(h({},s.attrs),{id:s.attrs.id+e.idSuffix})}):s})}):n}function te(){return Math.random().toString(36).substring(2,8)}A.displayName="UniverIcon";var re={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=_.forwardRef(function(n,e){return _.createElement(A,Object.assign({},n,{id:"cross-highlighting-single",ref:e,icon:re}))});G.displayName="CrossHighlightingSingle";const x=["rgba(158, 109, 227, 0.3)","rgba(254, 75, 75, 0.3)","rgba(255, 140, 81, 0.3)","rgba(164, 220, 22, 0.3)","rgba(45, 174, 255, 0.3)","rgba(58, 96, 247, 0.3)","rgba(242, 72, 166, 0.3)","rgba(153, 153, 153, 0.3)","rgba(158, 109, 227, 0.15)","rgba(254, 75, 75, 0.15)","rgba(255, 140, 81, 0.15)","rgba(164, 220, 22, 0.15)","rgba(45, 174, 255, 0.15)","rgba(58, 96, 247, 0.15)","rgba(242, 72, 166, 0.15)","rgba(153, 153, 153, 0.15)"];class d extends a.Disposable{constructor(){super(...arguments);l(this,"_enabled$",new u.BehaviorSubject(!1));l(this,"enabled$",this._enabled$.asObservable());l(this,"_color$",new u.BehaviorSubject(x[0]));l(this,"color$",this._color$.asObservable())}get enabled(){return this._enabled$.getValue()}get color(){return this._color$.getValue()}dispose(){this._enabled$.complete()}setEnabled(r){this._enabled$.next(r)}setColor(r){this._color$.next(r)}}const I={id:"sheet.operation.toggle-crosshair-highlight",type:a.CommandType.OPERATION,handler(n){const e=n.get(d),r=e.enabled;return e.setEnabled(!r),!0}},j={id:"sheet.operation.set-crosshair-highlight-color",type:a.CommandType.OPERATION,handler(n,{value:e}){const r=n.get(d);return r.enabled||r.setEnabled(!0),r.setColor(e),!0}},U={id:"sheet.operation.enable-crosshair-highlight",type:a.CommandType.OPERATION,handler(n){const e=n.get(d);return e.enabled?!1:(e.setEnabled(!0),!0)}},D={id:"sheet.operation.disable-crosshair-highlight",type:a.CommandType.OPERATION,handler(n){const e=n.get(d);return e.enabled?(e.setEnabled(!1),!0):!1}};var Y={exports:{}},y={};/**
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={};/**
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 ne=_,se=Symbol.for("react.element"),ie=Symbol.for("react.fragment"),oe=Object.prototype.hasOwnProperty,ae=ne.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,ce={key:!0,ref:!0,__self:!0,__source:!0};function k(n,e,r){var t,s={},i=null,o=null;r!==void 0&&(i=""+r),e.key!==void 0&&(i=""+e.key),e.ref!==void 0&&(o=e.ref);for(t in e)oe.call(e,t)&&!ce.hasOwnProperty(t)&&(s[t]=e[t]);if(n&&n.defaultProps)for(t in e=n.defaultProps,e)s[t]===void 0&&(s[t]=e[t]);return{$$typeof:se,type:n,key:i,ref:o,props:s,_owner:ae.current}}y.Fragment=ie;y.jsx=k;y.jsxs=k;Y.exports=y;var V=Y.exports;function B(n){var e,r,t="";if(typeof n=="string"||typeof n=="number")t+=n;else if(typeof n=="object")if(Array.isArray(n)){var s=n.length;for(e=0;e<s;e++)n[e]&&(r=B(n[e]))&&(t&&(t+=" "),t+=r)}else for(r in n)n[r]&&(t&&(t+=" "),t+=r);return t}function le(){for(var n,e,r=0,t="",s=arguments.length;r<s;r++)(n=arguments[r])&&(e=B(n))&&(t&&(t+=" "),t+=e);return t}const he="univer-crosshair-highlight-overlay",ge="univer-crosshair-highlight-item",ue="univer-crosshair-highlight-item-selected",E={crosshairHighlightOverlay:he,crosshairHighlightItem:ge,crosshairHighlightItemSelected:ue};function de(n){const{onChange:e}=n,r=a.useDependency(d),t=a.useObservable(r.color$),s=_.useCallback(i=>{e==null||e(i)},[e]);return V.jsx("div",{className:E.crosshairHighlightOverlay,children:x.map(i=>V.jsx("div",{className:le(E.crosshairHighlightItem,{[E.crosshairHighlightItemSelected]:i===t}),style:{backgroundColor:i},onClick:()=>s(i)},i))})}const q="CROSSHAIR_HIGHLIGHT_OVERLAY_COMPONENT";function fe(n){const e=n.get(d);return{id:I.id,tooltip:"crosshair.button.tooltip",type:v.MenuItemType.BUTTON_SELECTOR,icon:"CrossHighlightingSingle",selections:[{label:{name:q,hoverable:!1}}],selectionsCommandId:j.id,activated$:e.enabled$,hidden$:v.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}const _e={[v.ContextMenuPosition.FOOTER_MENU]:{[v.ContextMenuGroup.OTHERS]:{[I.id]:{order:0,menuItemFactory:fe}}}};var ve=Object.defineProperty,Se=Object.getOwnPropertyDescriptor,pe=(n,e,r,t)=>{for(var s=t>1?void 0:t?Se(e,r):e,i=n.length-1,o;i>=0;i--)(o=n[i])&&(s=(t?o(e,r,s):o(s))||s);return t&&s&&ve(e,r,s),s},w=(n,e)=>(r,t)=>e(r,t,n);let H=class extends a.Disposable{constructor(n,e,r){super(),this._componentMgr=n,this._menuManagerService=e,this._cmdSrv=r,this._initCommands(),this._initMenus(),this._initComponents()}_initCommands(){[I,j,U,D].forEach(n=>this._cmdSrv.registerCommand(n))}_initMenus(){this._menuManagerService.mergeMenu(_e)}_initComponents(){this._componentMgr.register(q,de),this._componentMgr.register("CrossHighlightingSingle",G)}};H=pe([w(0,a.Inject(v.ComponentManager)),w(1,v.IMenuManagerService),w(2,a.ICommandService)],H);const Ce=1;class me{constructor(){l(this,"_selectedRanges",[]);l(this,"_ranges",[])}addRange(e){if(e.rangeType===a.RANGE_TYPE.COLUMN||e.rangeType===a.RANGE_TYPE.ROW||e.rangeType===a.RANGE_TYPE.ALL)return;const r=this._getIntersects(e),t=this._getSplitRanges(e,r);t.length>0&&this._ranges.push(...t)}setSelectedRanges(e){this._selectedRanges=e}_getSplitRanges(e,r){let t=[e];for(const s of r.concat(this._selectedRanges)){const i=[];for(const o of t){const c=a.Rectangle.subtract(o,s);c&&c.length>0&&i.push(...c)}t=i}return t.filter(s=>s.startRow<=s.endRow&&s.startColumn<=s.endColumn)}_getIntersects(e){const r=[];for(const t of this._ranges){const s=a.Rectangle.getIntersects(t,e);s&&r.push(s)}return r}getRanges(){return this._ranges}reset(){this._ranges=[],this._selectedRanges=[]}}class be extends M.Shape{constructor(r,t){super(r,t);l(this,"_color");t&&this.setShapeProps(t)}setShapeProps(r){typeof r.color<"u"&&(this._color=r.color),this.transformByState({width:r.width,height:r.height})}_draw(r){const t=`rgba(${this._color.r}, ${this._color.g}, ${this._color.b}, ${this._color.a})`;M.Rect.drawWith(r,{width:this.width,height:this.height,fill:t,stroke:void 0,strokeWidth:0,evented:!1})}}var Re=Object.defineProperty,He=Object.getOwnPropertyDescriptor,Oe=(n,e,r,t)=>{for(var s=t>1?void 0:t?He(e,r):e,i=n.length-1,o;i>=0;i--)(o=n[i])&&(s=(t?o(e,r,s):o(s))||s);return t&&s&&Re(e,r,s),s},C=(n,e)=>(r,t)=>e(r,t,n);let O=class extends a.Disposable{constructor(e,r,t,s,i,o){super();l(this,"_shapes",[]);l(this,"_rangeCollection",new me);l(this,"_color","rgba(255,0,0,0.5)");this._context=e,this._sheetSkeletonManagerService=r,this._sheetsSelectionsService=t,this._sheetsCrosshairHighlightService=s,this._contextService=i,this._refSelectionsService=o,this._initRenderListener()}_transformSelection(e,r){if(!e)return;const t=r.getRowCount(),s=r.getColumnCount(),i=[];for(const o of e){const{startRow:c,endRow:g,startColumn:S,endColumn:p}=o.range;g-c+1===t||p-S+1===s||i.push(o.range)}this._rangeCollection.setSelectedRanges(i);for(const o of i)this.addSelection(o,r)}_initRenderListener(){const e=this._context.unit;this.disposeWithMe(u.combineLatest([this._contextService.subscribeContextValue$($.DISABLE_NORMAL_SELECTIONS).pipe(u.startWith(!1)),this._sheetSkeletonManagerService.currentSkeleton$,this._sheetsCrosshairHighlightService.enabled$,this._sheetsCrosshairHighlightService.color$.pipe(u.tap(r=>this._color=r)),u.merge(this._sheetsSelectionsService.selectionMoveStart$,this._sheetsSelectionsService.selectionMoving$,this._sheetsSelectionsService.selectionMoveEnd$,e.activeSheet$.pipe(u.map(()=>this._sheetsSelectionsService.getCurrentSelections()))),u.merge(this._refSelectionsService.selectionMoveStart$,this._refSelectionsService.selectionMoving$,this._refSelectionsService.selectionMoveEnd$,e.activeSheet$.pipe(u.map(()=>this._refSelectionsService.getCurrentSelections())))]).subscribe(([r,t,s,i,o,c])=>{if(this._clear(),!s)return;const g=r?c:o;this._rangeCollection.reset(),this._transformSelection(g,e.getActiveSheet()),this.render(this._rangeCollection.getRanges())}))}addSelection(e,r){if(e.rangeType===a.RANGE_TYPE.COLUMN||e.rangeType===a.RANGE_TYPE.ROW||e.rangeType===a.RANGE_TYPE.ALL)return;const t=r.getRowCount(),s=r.getColumnCount(),{startRow:i,endRow:o,startColumn:c,endColumn:g}=e,S={startRow:i,endRow:o,startColumn:0,endColumn:c-1},p={startRow:i,endRow:o,startColumn:g+1,endColumn:s},m={startRow:0,endRow:i-1,startColumn:c,endColumn:g},b={startRow:o+1,endRow:t,startColumn:c,endColumn:g};for(const f of[S,p,m,b])f.startRow<=f.endRow&&f.startColumn<=f.endColumn&&this._rangeCollection.addRange(f)}_clear(){this._shapes.forEach(e=>{e.dispose()}),this._shapes=[]}_addShapes(e,r,t,s){const{startRow:i,endRow:o,startColumn:c,endColumn:g}=e,S=P.getCoordByCell(i,c,t,s),p=P.getCoordByCell(o,g,t,s),{startX:m,startY:b}=S,{endX:f,endY:Z}=p,W=f-m,F=Z-b,X={left:m,top:b,color:new a.ColorKit(this._color).toRgb(),width:W,height:F,zIndex:Ce,evented:!1},N=new be(`crosshair-${r}`,X);this._shapes.push(N),t.addObject(N)}render(e){const r=this._sheetSkeletonManagerService.getCurrentSkeleton();if(!r)return;const{scene:t}=this._context;this._clear();for(let s=0;s<e.length;s++){const i=e[s];this._addShapes(i,s,t,r)}t.makeDirty(!0)}async dispose(){super.dispose()}};O=Oe([C(1,a.Inject(P.SheetSkeletonManagerService)),C(2,a.Inject($.SheetsSelectionsService)),C(3,a.Inject(d)),C(4,a.Inject(a.IContextService)),C(5,$.IRefSelectionsService)],O);const Ie="sheets-crosshair-highlight.config",ye={};var Ee=Object.defineProperty,we=Object.getOwnPropertyDescriptor,Te=(n,e,r,t)=>{for(var s=t>1?void 0:t?we(e,r):e,i=n.length-1,o;i>=0;i--)(o=n[i])&&(s=(t?o(e,r,s):o(s))||s);return t&&s&&Ee(e,r,s),s},T=(n,e)=>(r,t)=>e(r,t,n),R;exports.UniverSheetsCrosshairHighlightPlugin=(R=class extends a.Plugin{constructor(e=ye,r,t,s){super(),this._config=e,this._injector=r,this._renderManagerService=t,this._configService=s;const{...i}=this._config;this._configService.setConfig(Ie,i)}onStarting(){[[d],[H]].forEach(e=>this._injector.add(e))}onReady(){[[O]].forEach(e=>this._injector.add(e)),this._injector.get(H),this._renderManagerService.registerRenderModule(a.UniverInstanceType.UNIVER_SHEET,[O])}},l(R,"pluginName","SHEET_CROSSHAIR_HIGHLIGHT_PLUGIN"),l(R,"type",a.UniverInstanceType.UNIVER_SHEET),R);exports.UniverSheetsCrosshairHighlightPlugin=Te([T(1,a.Inject(a.Injector)),T(2,M.IRenderManagerService),T(3,a.IConfigService)],exports.UniverSheetsCrosshairHighlightPlugin);exports.CROSSHAIR_HIGHLIGHT_COLORS=x;exports.DisableCrosshairHighlightOperation=D;exports.EnableCrosshairHighlightOperation=U;exports.SetCrosshairHighlightColorOperation=j;exports.ToggleCrosshairHighlightOperation=I;
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;
@@ -0,0 +1 @@
1
+ "use strict";const t={crosshair:{button:{tooltip:"Surlignage du réticule"}}};module.exports=t;
package/lib/es/index.js CHANGED
@@ -1,65 +1,66 @@
1
- var ee = Object.defineProperty;
2
- var te = (n, e, r) => e in n ? ee(n, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : n[e] = r;
3
- var c = (n, e, r) => te(n, typeof e != "symbol" ? e + "" : e, r);
4
- import { Disposable as M, CommandType as O, useDependency as re, useObservable as ne, UniverInstanceType as w, Inject as d, ICommandService as se, RANGE_TYPE as f, Rectangle as P, IContextService as ie, ColorKit as oe, Plugin as ae, Injector as ce, IConfigService as le } from "@univerjs/core";
5
- import { Shape as he, Rect as ge, IRenderManagerService as ue } from "@univerjs/engine-render";
6
- import { MenuItemType as de, getMenuHiddenObservable as fe, ContextMenuPosition as _e, ContextMenuGroup as ve, ComponentManager as Se, IMenuManagerService as pe } from "@univerjs/ui";
7
- import { BehaviorSubject as T, combineLatest as me, startWith as Ce, tap as be, merge as N, map as j } from "rxjs";
8
- import Re, { forwardRef as G, useRef as Oe, createElement as U, useCallback as He } from "react";
9
- import { SheetSkeletonManagerService as Ie, getCoordByCell as V } from "@univerjs/sheets-ui";
10
- import { SheetsSelectionsService as ye, DISABLE_NORMAL_SELECTIONS as Ee, IRefSelectionsService as we } from "@univerjs/sheets";
11
- var l = function() {
12
- return l = Object.assign || function(n) {
13
- for (var e, r = 1, t = arguments.length; r < t; r++) {
14
- e = arguments[r];
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 = {};
12
+ var g = function() {
13
+ return g = Object.assign || function(n) {
14
+ for (var e, t = 1, r = arguments.length; t < r; t++) {
15
+ e = arguments[t];
15
16
  for (var s in e) Object.prototype.hasOwnProperty.call(e, s) && (n[s] = e[s]);
16
17
  }
17
18
  return n;
18
- }, l.apply(this, arguments);
19
- }, Me = function(n, e) {
20
- var r = {};
21
- for (var t in n) Object.prototype.hasOwnProperty.call(n, t) && e.indexOf(t) < 0 && (r[t] = n[t]);
19
+ }, g.apply(this, arguments);
20
+ }, Pe = function(n, e) {
21
+ var t = {};
22
+ for (var r in n) Object.prototype.hasOwnProperty.call(n, r) && e.indexOf(r) < 0 && (t[r] = n[r]);
22
23
  if (n != null && typeof Object.getOwnPropertySymbols == "function")
23
- for (var s = 0, t = Object.getOwnPropertySymbols(n); s < t.length; s++)
24
- e.indexOf(t[s]) < 0 && Object.prototype.propertyIsEnumerable.call(n, t[s]) && (r[t[s]] = n[t[s]]);
25
- return r;
26
- }, D = G(function(n, e) {
27
- var r = n.icon, t = n.id, s = n.className, i = n.extend, o = Me(n, ["icon", "id", "className", "extend"]), a = "univerjs-icon univerjs-icon-".concat(t, " ").concat(s || "").trim(), h = Oe("_".concat(Pe()));
28
- return k(r, "".concat(t), { defIds: r.defIds, idSuffix: h.current }, l({ ref: e, className: a }, o), i);
24
+ for (var s = 0, r = Object.getOwnPropertySymbols(n); s < r.length; s++)
25
+ e.indexOf(r[s]) < 0 && Object.prototype.propertyIsEnumerable.call(n, r[s]) && (t[r[s]] = n[r[s]]);
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()));
29
+ return W(t, "".concat(r), { defIds: t.defIds, idSuffix: c.current }, g({ ref: e, className: a }, o), i);
29
30
  });
30
- function k(n, e, r, t, s) {
31
- return U(n.tag, l(l({ key: e }, $e(n, r, s)), t), (xe(n, r).children || []).map(function(i, o) {
32
- return k(i, "".concat(e, "-").concat(n.tag, "-").concat(o), r, void 0, s);
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) {
33
+ return W(i, "".concat(e, "-").concat(n.tag, "-").concat(o), t, void 0, s);
33
34
  }));
34
35
  }
35
- function $e(n, e, r) {
36
- var t = l({}, n.attrs);
37
- r != null && r.colorChannel1 && t.fill === "colorChannel1" && (t.fill = r.colorChannel1);
36
+ function Te(n, e, t) {
37
+ var r = g({}, n.attrs);
38
+ t != null && t.colorChannel1 && r.fill === "colorChannel1" && (r.fill = t.colorChannel1);
38
39
  var s = e.defIds;
39
- return !s || s.length === 0 || (n.tag === "use" && t["xlink:href"] && (t["xlink:href"] = t["xlink:href"] + e.idSuffix), Object.entries(t).forEach(function(i) {
40
+ return !s || s.length === 0 || (n.tag === "use" && r["xlink:href"] && (r["xlink:href"] = r["xlink:href"] + e.idSuffix), Object.entries(r).forEach(function(i) {
40
41
  var o = i[0], a = i[1];
41
- typeof a == "string" && (t[o] = a.replace(/url\(#(.*)\)/, "url(#$1".concat(e.idSuffix, ")")));
42
- })), t;
42
+ typeof a == "string" && (r[o] = a.replace(/url\(#(.*)\)/, "url(#$1".concat(e.idSuffix, ")")));
43
+ })), r;
43
44
  }
44
- function xe(n, e) {
45
- var r, t = e.defIds;
46
- return !t || t.length === 0 ? n : n.tag === "defs" && (!((r = n.children) === null || r === void 0) && r.length) ? l(l({}, n), { children: n.children.map(function(s) {
47
- return typeof s.attrs.id == "string" && t && t.indexOf(s.attrs.id) > -1 ? l(l({}, s), { attrs: l(l({}, s.attrs), { id: s.attrs.id + e.idSuffix }) }) : s;
45
+ function Ne(n, e) {
46
+ var t, r = e.defIds;
47
+ return !r || r.length === 0 ? n : n.tag === "defs" && (!((t = n.children) === null || t === void 0) && t.length) ? g(g({}, n), { children: n.children.map(function(s) {
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;
48
49
  }) }) : n;
49
50
  }
50
- function Pe() {
51
+ function je() {
51
52
  return Math.random().toString(36).substring(2, 8);
52
53
  }
53
- D.displayName = "UniverIcon";
54
- var Te = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "#E5E5E5", d: "M1.6499 3.65002C1.6499 2.54545 2.54533 1.65002 3.6499 1.65002H12.3499C13.4545 1.65002 14.3499 2.54545 14.3499 3.65002V12.35C14.3499 13.4546 13.4545 14.35 12.3499 14.35H3.6499C2.54533 14.35 1.6499 13.4546 1.6499 12.35V3.65002Z" } }, { tag: "path", attrs: { fill: "#fff", d: "M9.9998 1.65002H5.9998V6H1.6499V10H5.9998V14.35H9.9998V10H14.3499V6H9.9998V1.65002Z" } }, { tag: "path", attrs: { fill: "currentColor", d: "M3.6498 1.05005C2.21386 1.05005 1.0498 2.21411 1.0498 3.65005V12.35C1.0498 13.786 2.21386 14.95 3.6498 14.95H12.3498C13.7857 14.95 14.9498 13.786 14.9498 12.3501V3.65005C14.9498 2.21411 13.7857 1.05005 12.3498 1.05005H3.6498ZM5.4002 2.25005H3.6498C2.87661 2.25005 2.2498 2.87685 2.2498 3.65005V5.40002H5.4002V2.25005ZM2.2498 10.6V12.35C2.2498 13.1232 2.87661 13.75 3.6498 13.75H5.4002V10.6H2.2498ZM6.60019 13.75H9.4002V9.40002H13.7498V6.60002H9.4002V2.25005H6.60019V6.60002H2.25029V9.40002H6.60019V13.75ZM10.6002 2.25005V5.40002H13.7498V3.65005C13.7498 2.87685 13.123 2.25005 12.3498 2.25005H10.6002ZM13.7498 10.6H10.6002V13.75H12.3498C13.123 13.75 13.7498 13.1232 13.7498 12.3501V10.6Z", fillRule: "evenodd", clipRule: "evenodd" } }] }, Z = G(function(n, e) {
55
- return U(D, Object.assign({}, n, {
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, {
56
57
  id: "cross-highlighting-single",
57
58
  ref: e,
58
- icon: Te
59
+ icon: Ve
59
60
  }));
60
61
  });
61
- Z.displayName = "CrossHighlightingSingle";
62
- const B = [
62
+ Y.displayName = "CrossHighlightingSingle";
63
+ const q = [
63
64
  "rgba(158, 109, 227, 0.3)",
64
65
  "rgba(254, 75, 75, 0.3)",
65
66
  "rgba(255, 140, 81, 0.3)",
@@ -77,13 +78,13 @@ const B = [
77
78
  "rgba(242, 72, 166, 0.15)",
78
79
  "rgba(153, 153, 153, 0.15)"
79
80
  ];
80
- class g extends M {
81
+ class v extends M {
81
82
  constructor() {
82
83
  super(...arguments);
83
- c(this, "_enabled$", new T(!1));
84
- c(this, "enabled$", this._enabled$.asObservable());
85
- c(this, "_color$", new T(B[0]));
86
- c(this, "color$", this._color$.asObservable());
84
+ h(this, "_enabled$", new N(!1));
85
+ h(this, "enabled$", this._enabled$.asObservable());
86
+ h(this, "_color$", new N(q[0]));
87
+ h(this, "color$", this._color$.asObservable());
87
88
  }
88
89
  get enabled() {
89
90
  return this._enabled$.getValue();
@@ -94,43 +95,43 @@ class g extends M {
94
95
  dispose() {
95
96
  this._enabled$.complete();
96
97
  }
97
- setEnabled(r) {
98
- this._enabled$.next(r);
98
+ setEnabled(t) {
99
+ this._enabled$.next(t);
99
100
  }
100
- setColor(r) {
101
- this._color$.next(r);
101
+ setColor(t) {
102
+ this._color$.next(t);
102
103
  }
103
104
  }
104
105
  const $ = {
105
106
  id: "sheet.operation.toggle-crosshair-highlight",
106
107
  type: O.OPERATION,
107
108
  handler(n) {
108
- const e = n.get(g), r = e.enabled;
109
- return e.setEnabled(!r), !0;
109
+ const e = n.get(v), t = e.enabled;
110
+ return e.setEnabled(!t), !0;
110
111
  }
111
- }, W = {
112
+ }, F = {
112
113
  id: "sheet.operation.set-crosshair-highlight-color",
113
114
  type: O.OPERATION,
114
115
  handler(n, { value: e }) {
115
- const r = n.get(g);
116
- return r.enabled || r.setEnabled(!0), r.setColor(e), !0;
116
+ const t = n.get(v);
117
+ return t.enabled || t.setEnabled(!0), t.setColor(e), !0;
117
118
  }
118
- }, Ne = {
119
+ }, Le = {
119
120
  id: "sheet.operation.enable-crosshair-highlight",
120
121
  type: O.OPERATION,
121
122
  handler(n) {
122
- const e = n.get(g);
123
+ const e = n.get(v);
123
124
  return e.enabled ? !1 : (e.setEnabled(!0), !0);
124
125
  }
125
- }, je = {
126
+ }, Ae = {
126
127
  id: "sheet.operation.disable-crosshair-highlight",
127
128
  type: O.OPERATION,
128
129
  handler(n) {
129
- const e = n.get(g);
130
+ const e = n.get(v);
130
131
  return e.enabled ? (e.setEnabled(!1), !0) : !1;
131
132
  }
132
133
  };
133
- var Y = { exports: {} }, H = {};
134
+ var I = { exports: {} }, m = {};
134
135
  /**
135
136
  * @license React
136
137
  * react-jsx-runtime.production.min.js
@@ -140,46 +141,52 @@ var Y = { exports: {} }, H = {};
140
141
  * This source code is licensed under the MIT license found in the
141
142
  * LICENSE file in the root directory of this source tree.
142
143
  */
143
- var Ve = Re, Le = Symbol.for("react.element"), Ae = Symbol.for("react.fragment"), Ge = Object.prototype.hasOwnProperty, Ue = Ve.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, De = { key: !0, ref: !0, __self: !0, __source: !0 };
144
- function F(n, e, r) {
145
- var t, s = {}, i = null, o = null;
146
- r !== void 0 && (i = "" + r), e.key !== void 0 && (i = "" + e.key), e.ref !== void 0 && (o = e.ref);
147
- for (t in e) Ge.call(e, t) && !De.hasOwnProperty(t) && (s[t] = e[t]);
148
- if (n && n.defaultProps) for (t in e = n.defaultProps, e) s[t] === void 0 && (s[t] = e[t]);
149
- return { $$typeof: Le, type: n, key: i, ref: o, props: s, _owner: Ue.current };
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 };
149
+ function o(a, c, f) {
150
+ var l, d = {}, _ = null, u = null;
151
+ f !== void 0 && (_ = "" + f), c.key !== void 0 && (_ = "" + c.key), c.ref !== void 0 && (u = c.ref);
152
+ for (l in c) r.call(c, l) && !i.hasOwnProperty(l) && (d[l] = c[l]);
153
+ if (a && a.defaultProps) for (l in c = a.defaultProps, c) d[l] === void 0 && (d[l] = c[l]);
154
+ return { $$typeof: e, type: a, key: _, ref: u, props: d, _owner: s.current };
155
+ }
156
+ return m.Fragment = t, m.jsx = o, m.jsxs = o, m;
157
+ }
158
+ var G;
159
+ function Ue() {
160
+ return G || (G = 1, I.exports = Ge()), I.exports;
150
161
  }
151
- H.Fragment = Ae;
152
- H.jsx = F;
153
- H.jsxs = F;
154
- Y.exports = H;
155
- var L = Y.exports;
156
- function X(n) {
157
- var e, r, t = "";
158
- if (typeof n == "string" || typeof n == "number") t += n;
162
+ var U = Ue();
163
+ function J(n) {
164
+ var e, t, r = "";
165
+ if (typeof n == "string" || typeof n == "number") r += n;
159
166
  else if (typeof n == "object") if (Array.isArray(n)) {
160
167
  var s = n.length;
161
- for (e = 0; e < s; e++) n[e] && (r = X(n[e])) && (t && (t += " "), t += r);
162
- } else for (r in n) n[r] && (t && (t += " "), t += r);
163
- return t;
168
+ for (e = 0; e < s; e++) n[e] && (t = J(n[e])) && (r && (r += " "), r += t);
169
+ } else for (t in n) n[t] && (r && (r += " "), r += t);
170
+ return r;
164
171
  }
165
- function ke() {
166
- for (var n, e, r = 0, t = "", s = arguments.length; r < s; r++) (n = arguments[r]) && (e = X(n)) && (t && (t += " "), t += e);
167
- return t;
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);
174
+ return r;
168
175
  }
169
- const Ze = "univer-crosshair-highlight-overlay", Be = "univer-crosshair-highlight-item", We = "univer-crosshair-highlight-item-selected", I = {
170
- crosshairHighlightOverlay: Ze,
171
- crosshairHighlightItem: Be,
172
- crosshairHighlightItemSelected: We
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
173
180
  };
174
- function Ye(n) {
175
- const { onChange: e } = n, r = re(g), t = ne(r.color$), s = He((i) => {
181
+ function We(n) {
182
+ const { onChange: e } = n, t = ne(v), r = se(t.color$), s = Ie((i) => {
176
183
  e == null || e(i);
177
184
  }, [e]);
178
- return /* @__PURE__ */ L.jsx("div", { className: I.crosshairHighlightOverlay, children: B.map((i) => /* @__PURE__ */ L.jsx(
185
+ return /* @__PURE__ */ U.jsx("div", { className: y.crosshairHighlightOverlay, children: q.map((i) => /* @__PURE__ */ U.jsx(
179
186
  "div",
180
187
  {
181
- className: ke(I.crosshairHighlightItem, {
182
- [I.crosshairHighlightItemSelected]: i === t
188
+ className: De(y.crosshairHighlightItem, {
189
+ [y.crosshairHighlightItemSelected]: i === r
183
190
  }),
184
191
  style: { backgroundColor: i },
185
192
  onClick: () => s(i)
@@ -187,100 +194,100 @@ function Ye(n) {
187
194
  i
188
195
  )) });
189
196
  }
190
- const q = "CROSSHAIR_HIGHLIGHT_OVERLAY_COMPONENT";
191
- function Fe(n) {
192
- const e = n.get(g);
197
+ const X = "CROSSHAIR_HIGHLIGHT_OVERLAY_COMPONENT";
198
+ function Ye(n) {
199
+ const e = n.get(v);
193
200
  return {
194
201
  id: $.id,
195
202
  tooltip: "crosshair.button.tooltip",
196
- type: de.BUTTON_SELECTOR,
203
+ type: fe.BUTTON_SELECTOR,
197
204
  icon: "CrossHighlightingSingle",
198
205
  selections: [
199
206
  {
200
207
  label: {
201
- name: q,
208
+ name: X,
202
209
  hoverable: !1
203
210
  }
204
211
  }
205
212
  ],
206
- selectionsCommandId: W.id,
213
+ selectionsCommandId: F.id,
207
214
  activated$: e.enabled$,
208
- hidden$: fe(n, w.UNIVER_SHEET)
215
+ hidden$: _e(n, x.UNIVER_SHEET)
209
216
  };
210
217
  }
211
- const Xe = {
212
- [_e.FOOTER_MENU]: {
213
- [ve.OTHERS]: {
218
+ const qe = {
219
+ [ve.FOOTER_MENU]: {
220
+ [Se.OTHERS]: {
214
221
  [$.id]: {
215
222
  order: 0,
216
- menuItemFactory: Fe
223
+ menuItemFactory: Ye
217
224
  }
218
225
  }
219
226
  }
220
227
  };
221
- var qe = Object.defineProperty, Ke = Object.getOwnPropertyDescriptor, ze = (n, e, r, t) => {
222
- for (var s = t > 1 ? void 0 : t ? Ke(e, r) : e, i = n.length - 1, o; i >= 0; i--)
223
- (o = n[i]) && (s = (t ? o(e, r, s) : o(s)) || s);
224
- return t && s && qe(e, r, s), s;
225
- }, y = (n, e) => (r, t) => e(r, t, n);
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--)
230
+ (o = n[i]) && (s = (r ? o(e, t, s) : o(s)) || s);
231
+ return r && s && Fe(e, t, s), s;
232
+ }, E = (n, e) => (t, r) => e(t, r, n);
226
233
  let b = class extends M {
227
- constructor(n, e, r) {
228
- super(), this._componentMgr = n, this._menuManagerService = e, this._cmdSrv = r, this._initCommands(), this._initMenus(), this._initComponents();
234
+ constructor(n, e, t) {
235
+ super(), this._componentMgr = n, this._menuManagerService = e, this._cmdSrv = t, this._initCommands(), this._initMenus(), this._initComponents();
229
236
  }
230
237
  _initCommands() {
231
238
  [
232
239
  $,
233
- W,
234
- Ne,
235
- je
240
+ F,
241
+ Le,
242
+ Ae
236
243
  ].forEach((n) => this._cmdSrv.registerCommand(n));
237
244
  }
238
245
  _initMenus() {
239
- this._menuManagerService.mergeMenu(Xe);
246
+ this._menuManagerService.mergeMenu(qe);
240
247
  }
241
248
  _initComponents() {
242
- this._componentMgr.register(q, Ye), this._componentMgr.register("CrossHighlightingSingle", Z);
249
+ this._componentMgr.register(X, We), this._componentMgr.register("CrossHighlightingSingle", Y);
243
250
  }
244
251
  };
245
- b = ze([
246
- y(0, d(Se)),
247
- y(1, pe),
248
- y(2, se)
252
+ b = Xe([
253
+ E(0, S(pe)),
254
+ E(1, me),
255
+ E(2, ie)
249
256
  ], b);
250
- const Je = 1;
251
- class Qe {
257
+ const Ke = 1;
258
+ class ze {
252
259
  constructor() {
253
- c(this, "_selectedRanges", []);
254
- c(this, "_ranges", []);
260
+ h(this, "_selectedRanges", []);
261
+ h(this, "_ranges", []);
255
262
  }
256
263
  addRange(e) {
257
- if (e.rangeType === f.COLUMN || e.rangeType === f.ROW || e.rangeType === f.ALL)
264
+ if (e.rangeType === p.COLUMN || e.rangeType === p.ROW || e.rangeType === p.ALL)
258
265
  return;
259
- const r = this._getIntersects(e), t = this._getSplitRanges(e, r);
260
- t.length > 0 && this._ranges.push(...t);
266
+ const t = this._getIntersects(e), r = this._getSplitRanges(e, t);
267
+ r.length > 0 && this._ranges.push(...r);
261
268
  }
262
269
  setSelectedRanges(e) {
263
270
  this._selectedRanges = e;
264
271
  }
265
- _getSplitRanges(e, r) {
266
- let t = [e];
267
- for (const s of r.concat(this._selectedRanges)) {
272
+ _getSplitRanges(e, t) {
273
+ let r = [e];
274
+ for (const s of t.concat(this._selectedRanges)) {
268
275
  const i = [];
269
- for (const o of t) {
270
- const a = P.subtract(o, s);
276
+ for (const o of r) {
277
+ const a = T.subtract(o, s);
271
278
  a && a.length > 0 && i.push(...a);
272
279
  }
273
- t = i;
280
+ r = i;
274
281
  }
275
- return t.filter((s) => s.startRow <= s.endRow && s.startColumn <= s.endColumn);
282
+ return r.filter((s) => s.startRow <= s.endRow && s.startColumn <= s.endColumn);
276
283
  }
277
284
  _getIntersects(e) {
278
- const r = [];
279
- for (const t of this._ranges) {
280
- const s = P.getIntersects(t, e);
281
- s && r.push(s);
285
+ const t = [];
286
+ for (const r of this._ranges) {
287
+ const s = T.getIntersects(r, e);
288
+ s && t.push(s);
282
289
  }
283
- return r;
290
+ return t;
284
291
  }
285
292
  getRanges() {
286
293
  return this._ranges;
@@ -289,106 +296,106 @@ class Qe {
289
296
  this._ranges = [], this._selectedRanges = [];
290
297
  }
291
298
  }
292
- class et extends he {
293
- constructor(r, t) {
294
- super(r, t);
299
+ class Qe extends ge {
300
+ constructor(t, r) {
301
+ super(t, r);
295
302
  // protected _showHighLight = false;
296
- c(this, "_color");
297
- t && this.setShapeProps(t);
303
+ h(this, "_color");
304
+ r && this.setShapeProps(r);
298
305
  }
299
- setShapeProps(r) {
300
- typeof r.color < "u" && (this._color = r.color), this.transformByState({
301
- width: r.width,
302
- height: r.height
306
+ setShapeProps(t) {
307
+ typeof t.color < "u" && (this._color = t.color), this.transformByState({
308
+ width: t.width,
309
+ height: t.height
303
310
  });
304
311
  }
305
- _draw(r) {
306
- const t = `rgba(${this._color.r}, ${this._color.g}, ${this._color.b}, ${this._color.a})`;
307
- ge.drawWith(r, {
312
+ _draw(t) {
313
+ const r = `rgba(${this._color.r}, ${this._color.g}, ${this._color.b}, ${this._color.a})`;
314
+ ue.drawWith(t, {
308
315
  width: this.width,
309
316
  height: this.height,
310
- fill: t,
317
+ fill: r,
311
318
  stroke: void 0,
312
319
  strokeWidth: 0,
313
320
  evented: !1
314
321
  });
315
322
  }
316
323
  }
317
- var tt = Object.defineProperty, rt = Object.getOwnPropertyDescriptor, nt = (n, e, r, t) => {
318
- for (var s = t > 1 ? void 0 : t ? rt(e, r) : e, i = n.length - 1, o; i >= 0; i--)
319
- (o = n[i]) && (s = (t ? o(e, r, s) : o(s)) || s);
320
- return t && s && tt(e, r, s), s;
321
- }, S = (n, e) => (r, t) => e(r, t, n);
322
- let R = class extends M {
323
- constructor(e, r, t, s, i, o) {
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--)
326
+ (o = n[i]) && (s = (r ? o(e, t, s) : o(s)) || s);
327
+ return r && s && et(e, t, s), s;
328
+ }, C = (n, e) => (t, r) => e(t, r, n);
329
+ let H = class extends M {
330
+ constructor(e, t, r, s, i, o) {
324
331
  super();
325
- c(this, "_shapes", []);
326
- c(this, "_rangeCollection", new Qe());
327
- c(this, "_color", "rgba(255,0,0,0.5)");
328
- this._context = e, this._sheetSkeletonManagerService = r, this._sheetsSelectionsService = t, this._sheetsCrosshairHighlightService = s, this._contextService = i, this._refSelectionsService = o, this._initRenderListener();
332
+ h(this, "_shapes", []);
333
+ h(this, "_rangeCollection", new ze());
334
+ h(this, "_color", "rgba(255,0,0,0.5)");
335
+ this._context = e, this._sheetSkeletonManagerService = t, this._sheetsSelectionsService = r, this._sheetsCrosshairHighlightService = s, this._contextService = i, this._refSelectionsService = o, this._initRenderListener();
329
336
  }
330
- _transformSelection(e, r) {
337
+ _transformSelection(e, t) {
331
338
  if (!e)
332
339
  return;
333
- const t = r.getRowCount(), s = r.getColumnCount(), i = [];
340
+ const r = t.getRowCount(), s = t.getColumnCount(), i = [];
334
341
  for (const o of e) {
335
- const { startRow: a, endRow: h, startColumn: _, endColumn: v } = o.range;
336
- h - a + 1 === t || v - _ + 1 === s || i.push(o.range);
342
+ const { startRow: a, endRow: c, startColumn: f, endColumn: l } = o.range;
343
+ c - a + 1 === r || l - f + 1 === s || i.push(o.range);
337
344
  }
338
345
  this._rangeCollection.setSelectedRanges(i);
339
346
  for (const o of i)
340
- this.addSelection(o, r);
347
+ this.addSelection(o, t);
341
348
  }
342
349
  _initRenderListener() {
343
350
  const e = this._context.unit;
344
- this.disposeWithMe(me([
345
- this._contextService.subscribeContextValue$(Ee).pipe(Ce(!1)),
351
+ this.disposeWithMe(Ce([
352
+ this._contextService.subscribeContextValue$(we).pipe(Re(!1)),
346
353
  this._sheetSkeletonManagerService.currentSkeleton$,
347
354
  this._sheetsCrosshairHighlightService.enabled$,
348
- this._sheetsCrosshairHighlightService.color$.pipe(be((r) => this._color = r)),
349
- N(
355
+ this._sheetsCrosshairHighlightService.color$.pipe(be((t) => this._color = t)),
356
+ j(
350
357
  this._sheetsSelectionsService.selectionMoveStart$,
351
358
  this._sheetsSelectionsService.selectionMoving$,
352
359
  this._sheetsSelectionsService.selectionMoveEnd$,
353
- e.activeSheet$.pipe(j(() => this._sheetsSelectionsService.getCurrentSelections()))
360
+ e.activeSheet$.pipe(V(() => this._sheetsSelectionsService.getCurrentSelections()))
354
361
  ),
355
- N(
362
+ j(
356
363
  this._refSelectionsService.selectionMoveStart$,
357
364
  this._refSelectionsService.selectionMoving$,
358
365
  this._refSelectionsService.selectionMoveEnd$,
359
- e.activeSheet$.pipe(j(() => this._refSelectionsService.getCurrentSelections()))
366
+ e.activeSheet$.pipe(V(() => this._refSelectionsService.getCurrentSelections()))
360
367
  )
361
- ]).subscribe(([r, t, s, i, o, a]) => {
368
+ ]).subscribe(([t, r, s, i, o, a]) => {
362
369
  if (this._clear(), !s) return;
363
- const h = r ? a : o;
364
- this._rangeCollection.reset(), this._transformSelection(h, e.getActiveSheet()), this.render(this._rangeCollection.getRanges());
370
+ const c = t ? a : o;
371
+ this._rangeCollection.reset(), this._transformSelection(c, e.getActiveSheet()), this.render(this._rangeCollection.getRanges());
365
372
  }));
366
373
  }
367
- addSelection(e, r) {
368
- if (e.rangeType === f.COLUMN || e.rangeType === f.ROW || e.rangeType === f.ALL)
374
+ addSelection(e, t) {
375
+ if (e.rangeType === p.COLUMN || e.rangeType === p.ROW || e.rangeType === p.ALL)
369
376
  return;
370
- const t = r.getRowCount(), s = r.getColumnCount(), { startRow: i, endRow: o, startColumn: a, endColumn: h } = e, _ = {
377
+ const r = t.getRowCount(), s = t.getColumnCount(), { startRow: i, endRow: o, startColumn: a, endColumn: c } = e, f = {
371
378
  startRow: i,
372
379
  endRow: o,
373
380
  startColumn: 0,
374
381
  endColumn: a - 1
375
- }, v = {
382
+ }, l = {
376
383
  startRow: i,
377
384
  endRow: o,
378
- startColumn: h + 1,
385
+ startColumn: c + 1,
379
386
  endColumn: s
380
- }, p = {
387
+ }, d = {
381
388
  startRow: 0,
382
389
  endRow: i - 1,
383
390
  startColumn: a,
384
- endColumn: h
385
- }, m = {
391
+ endColumn: c
392
+ }, _ = {
386
393
  startRow: o + 1,
387
- endRow: t,
394
+ endRow: r,
388
395
  startColumn: a,
389
- endColumn: h
396
+ endColumn: c
390
397
  };
391
- for (const u of [_, v, p, m])
398
+ for (const u of [f, l, d, _])
392
399
  u.startRow <= u.endRow && u.startColumn <= u.endColumn && this._rangeCollection.addRange(u);
393
400
  }
394
401
  _clear() {
@@ -396,75 +403,74 @@ let R = class extends M {
396
403
  e.dispose();
397
404
  }), this._shapes = [];
398
405
  }
399
- _addShapes(e, r, t, s) {
400
- const { startRow: i, endRow: o, startColumn: a, endColumn: h } = e, _ = V(i, a, t, s), v = V(o, h, t, s), { startX: p, startY: m } = _, { endX: u, endY: K } = v, z = u - p, J = K - m, Q = {
401
- left: p,
402
- top: m,
403
- color: new oe(this._color).toRgb(),
406
+ _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 = {
408
+ left: d,
409
+ top: _,
410
+ color: new ae(this._color).toRgb(),
404
411
  width: z,
405
- height: J,
406
- zIndex: Je,
412
+ height: Q,
413
+ zIndex: Ke,
407
414
  evented: !1
408
- }, x = new et(`crosshair-${r}`, Q);
409
- this._shapes.push(x), t.addObject(x);
415
+ }, P = new Qe(`crosshair-${t}`, ee);
416
+ this._shapes.push(P), r.addObject(P);
410
417
  }
411
418
  render(e) {
412
- const r = this._sheetSkeletonManagerService.getCurrentSkeleton();
413
- if (!r)
419
+ const t = this._sheetSkeletonManagerService.getCurrentSkeleton();
420
+ if (!t)
414
421
  return;
415
- const { scene: t } = this._context;
422
+ const { scene: r } = this._context;
416
423
  this._clear();
417
424
  for (let s = 0; s < e.length; s++) {
418
425
  const i = e[s];
419
- this._addShapes(i, s, t, r);
426
+ this._addShapes(i, s, r, t);
420
427
  }
421
- t.makeDirty(!0);
428
+ r.makeDirty(!0);
422
429
  }
423
430
  async dispose() {
424
431
  super.dispose();
425
432
  }
426
433
  };
427
- R = nt([
428
- S(1, d(Ie)),
429
- S(2, d(ye)),
430
- S(3, d(g)),
431
- S(4, d(ie)),
432
- S(5, we)
433
- ], R);
434
- const st = "sheets-crosshair-highlight.config", it = {};
435
- var ot = Object.defineProperty, at = Object.getOwnPropertyDescriptor, ct = (n, e, r, t) => {
436
- for (var s = t > 1 ? void 0 : t ? at(e, r) : e, i = n.length - 1, o; i >= 0; i--)
437
- (o = n[i]) && (s = (t ? o(e, r, s) : o(s)) || s);
438
- return t && s && ot(e, r, s), s;
439
- }, E = (n, e) => (r, t) => e(r, t, n), C;
440
- let A = (C = class extends ae {
441
- constructor(n = it, e, r, t) {
442
- super(), this._config = n, this._injector = e, this._renderManagerService = r, this._configService = t;
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)
440
+ ], 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
+ (o = n[i]) && (s = (r ? o(e, t, s) : o(s)) || s);
444
+ return r && s && nt(e, t, s), s;
445
+ }, 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
+ super(), this._config = n, this._injector = e, this._renderManagerService = t, this._configService = r;
443
449
  const { ...s } = this._config;
444
- this._configService.setConfig(st, s);
450
+ this._configService.setConfig(Me, s);
445
451
  }
446
452
  onStarting() {
447
453
  [
448
- [g],
454
+ [v],
449
455
  [b]
450
456
  ].forEach((n) => this._injector.add(n));
451
457
  }
452
458
  onReady() {
453
459
  [
454
- [R]
455
- ].forEach((n) => this._injector.add(n)), this._injector.get(b), this._renderManagerService.registerRenderModule(w.UNIVER_SHEET, [R]);
456
- }
457
- }, c(C, "pluginName", "SHEET_CROSSHAIR_HIGHLIGHT_PLUGIN"), c(C, "type", w.UNIVER_SHEET), C);
458
- A = ct([
459
- E(1, d(ce)),
460
- E(2, ue),
461
- E(3, le)
462
- ], A);
460
+ [H]
461
+ ].forEach((n) => this._injector.add(n)), this._injector.get(b), this._renderManagerService.registerRenderModule(x.UNIVER_SHEET, [H]);
462
+ }
463
+ }, 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);
463
469
  export {
464
- B as CROSSHAIR_HIGHLIGHT_COLORS,
465
- je as DisableCrosshairHighlightOperation,
466
- Ne as EnableCrosshairHighlightOperation,
467
- W as SetCrosshairHighlightColorOperation,
470
+ q as CROSSHAIR_HIGHLIGHT_COLORS,
471
+ Ae as DisableCrosshairHighlightOperation,
472
+ Le as EnableCrosshairHighlightOperation,
473
+ F as SetCrosshairHighlightColorOperation,
468
474
  $ as ToggleCrosshairHighlightOperation,
469
- A as UniverSheetsCrosshairHighlightPlugin
475
+ D as UniverSheetsCrosshairHighlightPlugin
470
476
  };
@@ -0,0 +1,10 @@
1
+ const t = {
2
+ crosshair: {
3
+ button: {
4
+ tooltip: "Surlignage du réticule"
5
+ }
6
+ }
7
+ };
8
+ export {
9
+ t as default
10
+ };
@@ -1,5 +1,5 @@
1
1
  import { MenuConfig } from '@univerjs/ui';
2
- export declare const PLUGIN_CONFIG_KEY = "sheets-crosshair-highlight.config";
2
+ export declare const SHEETS_CROSSHAIR_HIGHLIGHT_PLUGIN_CONFIG_KEY = "sheets-crosshair-highlight.config";
3
3
  export declare const configSymbol: unique symbol;
4
4
  export interface IUniverSheetsCrosshairHighlightConfig {
5
5
  menu?: MenuConfig;
@@ -13,6 +13,7 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
+ import './global.css';
16
17
  export { UniverSheetsCrosshairHighlightPlugin } from './plugin';
17
18
  export { CROSSHAIR_HIGHLIGHT_COLORS } from './services/crosshair.service';
18
19
  export { DisableCrosshairHighlightOperation, EnableCrosshairHighlightOperation, type ISetCrosshairHighlightColorOperationParams, SetCrosshairHighlightColorOperation, ToggleCrosshairHighlightOperation, } from './commands/operations/operation';
@@ -0,0 +1,3 @@
1
+ import { default as enUS } from './en-US';
2
+ declare const locale: typeof enUS;
3
+ export default locale;
@@ -1,6 +1,6 @@
1
+ import { IUniverSheetsCrosshairHighlightConfig } from './controllers/config.schema';
1
2
  import { IConfigService, Injector, Plugin, UniverInstanceType } from '@univerjs/core';
2
3
  import { IRenderManagerService } from '@univerjs/engine-render';
3
- import { IUniverSheetsCrosshairHighlightConfig } from './controllers/config.schema';
4
4
  export declare class UniverSheetsCrosshairHighlightPlugin extends Plugin {
5
5
  private readonly _config;
6
6
  protected readonly _injector: Injector;
package/lib/umd/index.js CHANGED
@@ -1,4 +1,4 @@
1
- (function(l,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):(l=typeof globalThis<"u"?globalThis:l||self,o(l.UniverSheetsCrosshairHighlight={},l.UniverCore,l.UniverEngineRender,l.UniverUi,l.rxjs,l.React,l.UniverSheetsUi,l.UniverSheets))})(this,function(l,o,f,p,d,v,w,M){"use strict";var ye=Object.defineProperty;var Ee=(l,o,f)=>o in l?ye(l,o,{enumerable:!0,configurable:!0,writable:!0,value:f}):l[o]=f;var c=(l,o,f)=>Ee(l,typeof o!="symbol"?o+"":o,f);var y;var g=function(){return g=Object.assign||function(n){for(var e,r=1,t=arguments.length;r<t;r++){e=arguments[r];for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(n[i]=e[i])}return n},g.apply(this,arguments)},F=function(n,e){var r={};for(var t in n)Object.prototype.hasOwnProperty.call(n,t)&&e.indexOf(t)<0&&(r[t]=n[t]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,t=Object.getOwnPropertySymbols(n);i<t.length;i++)e.indexOf(t[i])<0&&Object.prototype.propertyIsEnumerable.call(n,t[i])&&(r[t[i]]=n[t[i]]);return r},$=v.forwardRef(function(n,e){var r=n.icon,t=n.id,i=n.className,s=n.extend,a=F(n,["icon","id","className","extend"]),h="univerjs-icon univerjs-icon-".concat(t," ").concat(i||"").trim(),u=v.useRef("_".concat(K()));return A(r,"".concat(t),{defIds:r.defIds,idSuffix:u.current},g({ref:e,className:h},a),s)});function A(n,e,r,t,i){return v.createElement(n.tag,g(g({key:e},X(n,r,i)),t),(q(n,r).children||[]).map(function(s,a){return A(s,"".concat(e,"-").concat(n.tag,"-").concat(a),r,void 0,i)}))}function X(n,e,r){var t=g({},n.attrs);r!=null&&r.colorChannel1&&t.fill==="colorChannel1"&&(t.fill=r.colorChannel1);var i=e.defIds;return!i||i.length===0||(n.tag==="use"&&t["xlink:href"]&&(t["xlink:href"]=t["xlink:href"]+e.idSuffix),Object.entries(t).forEach(function(s){var a=s[0],h=s[1];typeof h=="string"&&(t[a]=h.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))})),t}function q(n,e){var r,t=e.defIds;return!t||t.length===0?n:n.tag==="defs"&&(!((r=n.children)===null||r===void 0)&&r.length)?g(g({},n),{children:n.children.map(function(i){return typeof i.attrs.id=="string"&&t&&t.indexOf(i.attrs.id)>-1?g(g({},i),{attrs:g(g({},i.attrs),{id:i.attrs.id+e.idSuffix})}):i})}):n}function K(){return Math.random().toString(36).substring(2,8)}$.displayName="UniverIcon";var z={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"}}]},L=v.forwardRef(function(n,e){return v.createElement($,Object.assign({},n,{id:"cross-highlighting-single",ref:e,icon:z}))});L.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 _ extends o.Disposable{constructor(){super(...arguments);c(this,"_enabled$",new d.BehaviorSubject(!1));c(this,"enabled$",this._enabled$.asObservable());c(this,"_color$",new d.BehaviorSubject(P[0]));c(this,"color$",this._color$.asObservable())}get enabled(){return this._enabled$.getValue()}get color(){return this._color$.getValue()}dispose(){this._enabled$.complete()}setEnabled(r){this._enabled$.next(r)}setColor(r){this._color$.next(r)}}const R={id:"sheet.operation.toggle-crosshair-highlight",type:o.CommandType.OPERATION,handler(n){const e=n.get(_),r=e.enabled;return e.setEnabled(!r),!0}},j={id:"sheet.operation.set-crosshair-highlight-color",type:o.CommandType.OPERATION,handler(n,{value:e}){const r=n.get(_);return r.enabled||r.setEnabled(!0),r.setColor(e),!0}},U={id:"sheet.operation.enable-crosshair-highlight",type:o.CommandType.OPERATION,handler(n){const e=n.get(_);return e.enabled?!1:(e.setEnabled(!0),!0)}},G={id:"sheet.operation.disable-crosshair-highlight",type:o.CommandType.OPERATION,handler(n){const e=n.get(_);return e.enabled?(e.setEnabled(!1),!0):!1}};var D={exports:{}},b={};/**
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={};/**
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 J=v,Q=Symbol.for("react.element"),ee=Symbol.for("react.fragment"),te=Object.prototype.hasOwnProperty,re=J.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,ne={key:!0,ref:!0,__self:!0,__source:!0};function Y(n,e,r){var t,i={},s=null,a=null;r!==void 0&&(s=""+r),e.key!==void 0&&(s=""+e.key),e.ref!==void 0&&(a=e.ref);for(t in e)te.call(e,t)&&!ne.hasOwnProperty(t)&&(i[t]=e[t]);if(n&&n.defaultProps)for(t in e=n.defaultProps,e)i[t]===void 0&&(i[t]=e[t]);return{$$typeof:Q,type:n,key:s,ref:a,props:i,_owner:re.current}}b.Fragment=ee,b.jsx=Y,b.jsxs=Y,D.exports=b;var k=D.exports;function B(n){var e,r,t="";if(typeof n=="string"||typeof n=="number")t+=n;else if(typeof n=="object")if(Array.isArray(n)){var i=n.length;for(e=0;e<i;e++)n[e]&&(r=B(n[e]))&&(t&&(t+=" "),t+=r)}else for(r in n)n[r]&&(t&&(t+=" "),t+=r);return t}function ie(){for(var n,e,r=0,t="",i=arguments.length;r<i;r++)(n=arguments[r])&&(e=B(n))&&(t&&(t+=" "),t+=e);return t}const N={crosshairHighlightOverlay:"univer-crosshair-highlight-overlay",crosshairHighlightItem:"univer-crosshair-highlight-item",crosshairHighlightItemSelected:"univer-crosshair-highlight-item-selected"};function se(n){const{onChange:e}=n,r=o.useDependency(_),t=o.useObservable(r.color$),i=v.useCallback(s=>{e==null||e(s)},[e]);return k.jsx("div",{className:N.crosshairHighlightOverlay,children:P.map(s=>k.jsx("div",{className:ie(N.crosshairHighlightItem,{[N.crosshairHighlightItemSelected]:s===t}),style:{backgroundColor:s},onClick:()=>i(s)},s))})}const Z="CROSSHAIR_HIGHLIGHT_OVERLAY_COMPONENT";function oe(n){const e=n.get(_);return{id:R.id,tooltip:"crosshair.button.tooltip",type:p.MenuItemType.BUTTON_SELECTOR,icon:"CrossHighlightingSingle",selections:[{label:{name:Z,hoverable:!1}}],selectionsCommandId:j.id,activated$:e.enabled$,hidden$:p.getMenuHiddenObservable(n,o.UniverInstanceType.UNIVER_SHEET)}}const ae={[p.ContextMenuPosition.FOOTER_MENU]:{[p.ContextMenuGroup.OTHERS]:{[R.id]:{order:0,menuItemFactory:oe}}}};var le=Object.defineProperty,he=Object.getOwnPropertyDescriptor,ce=(n,e,r,t)=>{for(var i=t>1?void 0:t?he(e,r):e,s=n.length-1,a;s>=0;s--)(a=n[s])&&(i=(t?a(e,r,i):a(i))||i);return t&&i&&le(e,r,i),i},x=(n,e)=>(r,t)=>e(r,t,n);let O=class extends o.Disposable{constructor(n,e,r){super(),this._componentMgr=n,this._menuManagerService=e,this._cmdSrv=r,this._initCommands(),this._initMenus(),this._initComponents()}_initCommands(){[R,j,U,G].forEach(n=>this._cmdSrv.registerCommand(n))}_initMenus(){this._menuManagerService.mergeMenu(ae)}_initComponents(){this._componentMgr.register(Z,se),this._componentMgr.register("CrossHighlightingSingle",L)}};O=ce([x(0,o.Inject(p.ComponentManager)),x(1,p.IMenuManagerService),x(2,o.ICommandService)],O);const ge=1;class ue{constructor(){c(this,"_selectedRanges",[]);c(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 r=this._getIntersects(e),t=this._getSplitRanges(e,r);t.length>0&&this._ranges.push(...t)}setSelectedRanges(e){this._selectedRanges=e}_getSplitRanges(e,r){let t=[e];for(const i of r.concat(this._selectedRanges)){const s=[];for(const a of t){const h=o.Rectangle.subtract(a,i);h&&h.length>0&&s.push(...h)}t=s}return t.filter(i=>i.startRow<=i.endRow&&i.startColumn<=i.endColumn)}_getIntersects(e){const r=[];for(const t of this._ranges){const i=o.Rectangle.getIntersects(t,e);i&&r.push(i)}return r}getRanges(){return this._ranges}reset(){this._ranges=[],this._selectedRanges=[]}}class de extends f.Shape{constructor(r,t){super(r,t);c(this,"_color");t&&this.setShapeProps(t)}setShapeProps(r){typeof r.color<"u"&&(this._color=r.color),this.transformByState({width:r.width,height:r.height})}_draw(r){const t=`rgba(${this._color.r}, ${this._color.g}, ${this._color.b}, ${this._color.a})`;f.Rect.drawWith(r,{width:this.width,height:this.height,fill:t,stroke:void 0,strokeWidth:0,evented:!1})}}var fe=Object.defineProperty,_e=Object.getOwnPropertyDescriptor,ve=(n,e,r,t)=>{for(var i=t>1?void 0:t?_e(e,r):e,s=n.length-1,a;s>=0;s--)(a=n[s])&&(i=(t?a(e,r,i):a(i))||i);return t&&i&&fe(e,r,i),i},C=(n,e)=>(r,t)=>e(r,t,n);let I=class extends o.Disposable{constructor(e,r,t,i,s,a){super();c(this,"_shapes",[]);c(this,"_rangeCollection",new ue);c(this,"_color","rgba(255,0,0,0.5)");this._context=e,this._sheetSkeletonManagerService=r,this._sheetsSelectionsService=t,this._sheetsCrosshairHighlightService=i,this._contextService=s,this._refSelectionsService=a,this._initRenderListener()}_transformSelection(e,r){if(!e)return;const t=r.getRowCount(),i=r.getColumnCount(),s=[];for(const a of e){const{startRow:h,endRow:u,startColumn:m,endColumn:H}=a.range;u-h+1===t||H-m+1===i||s.push(a.range)}this._rangeCollection.setSelectedRanges(s);for(const a of s)this.addSelection(a,r)}_initRenderListener(){const e=this._context.unit;this.disposeWithMe(d.combineLatest([this._contextService.subscribeContextValue$(M.DISABLE_NORMAL_SELECTIONS).pipe(d.startWith(!1)),this._sheetSkeletonManagerService.currentSkeleton$,this._sheetsCrosshairHighlightService.enabled$,this._sheetsCrosshairHighlightService.color$.pipe(d.tap(r=>this._color=r)),d.merge(this._sheetsSelectionsService.selectionMoveStart$,this._sheetsSelectionsService.selectionMoving$,this._sheetsSelectionsService.selectionMoveEnd$,e.activeSheet$.pipe(d.map(()=>this._sheetsSelectionsService.getCurrentSelections()))),d.merge(this._refSelectionsService.selectionMoveStart$,this._refSelectionsService.selectionMoving$,this._refSelectionsService.selectionMoveEnd$,e.activeSheet$.pipe(d.map(()=>this._refSelectionsService.getCurrentSelections())))]).subscribe(([r,t,i,s,a,h])=>{if(this._clear(),!i)return;const u=r?h:a;this._rangeCollection.reset(),this._transformSelection(u,e.getActiveSheet()),this.render(this._rangeCollection.getRanges())}))}addSelection(e,r){if(e.rangeType===o.RANGE_TYPE.COLUMN||e.rangeType===o.RANGE_TYPE.ROW||e.rangeType===o.RANGE_TYPE.ALL)return;const t=r.getRowCount(),i=r.getColumnCount(),{startRow:s,endRow:a,startColumn:h,endColumn:u}=e,m={startRow:s,endRow:a,startColumn:0,endColumn:h-1},H={startRow:s,endRow:a,startColumn:u+1,endColumn:i},E={startRow:0,endRow:s-1,startColumn:h,endColumn:u},T={startRow:a+1,endRow:t,startColumn:h,endColumn:u};for(const S of[m,H,E,T])S.startRow<=S.endRow&&S.startColumn<=S.endColumn&&this._rangeCollection.addRange(S)}_clear(){this._shapes.forEach(e=>{e.dispose()}),this._shapes=[]}_addShapes(e,r,t,i){const{startRow:s,endRow:a,startColumn:h,endColumn:u}=e,m=w.getCoordByCell(s,h,t,i),H=w.getCoordByCell(a,u,t,i),{startX:E,startY:T}=m,{endX:S,endY:Re}=H,be=S-E,Oe=Re-T,Ie={left:E,top:T,color:new o.ColorKit(this._color).toRgb(),width:be,height:Oe,zIndex:ge,evented:!1},W=new de(`crosshair-${r}`,Ie);this._shapes.push(W),t.addObject(W)}render(e){const r=this._sheetSkeletonManagerService.getCurrentSkeleton();if(!r)return;const{scene:t}=this._context;this._clear();for(let i=0;i<e.length;i++){const s=e[i];this._addShapes(s,i,t,r)}t.makeDirty(!0)}async dispose(){super.dispose()}};I=ve([C(1,o.Inject(w.SheetSkeletonManagerService)),C(2,o.Inject(M.SheetsSelectionsService)),C(3,o.Inject(_)),C(4,o.Inject(o.IContextService)),C(5,M.IRefSelectionsService)],I);const Se="sheets-crosshair-highlight.config",pe={};var Ce=Object.defineProperty,me=Object.getOwnPropertyDescriptor,He=(n,e,r,t)=>{for(var i=t>1?void 0:t?me(e,r):e,s=n.length-1,a;s>=0;s--)(a=n[s])&&(i=(t?a(e,r,i):a(i))||i);return t&&i&&Ce(e,r,i),i},V=(n,e)=>(r,t)=>e(r,t,n);l.UniverSheetsCrosshairHighlightPlugin=(y=class extends o.Plugin{constructor(e=pe,r,t,i){super(),this._config=e,this._injector=r,this._renderManagerService=t,this._configService=i;const{...s}=this._config;this._configService.setConfig(Se,s)}onStarting(){[[_],[O]].forEach(e=>this._injector.add(e))}onReady(){[[I]].forEach(e=>this._injector.add(e)),this._injector.get(O),this._renderManagerService.registerRenderModule(o.UniverInstanceType.UNIVER_SHEET,[I])}},c(y,"pluginName","SHEET_CROSSHAIR_HIGHLIGHT_PLUGIN"),c(y,"type",o.UniverInstanceType.UNIVER_SHEET),y),l.UniverSheetsCrosshairHighlightPlugin=He([V(1,o.Inject(o.Injector)),V(2,f.IRenderManagerService),V(3,o.IConfigService)],l.UniverSheetsCrosshairHighlightPlugin),l.CROSSHAIR_HIGHLIGHT_COLORS=P,l.DisableCrosshairHighlightOperation=G,l.EnableCrosshairHighlightOperation=U,l.SetCrosshairHighlightColorOperation=j,l.ToggleCrosshairHighlightOperation=R,Object.defineProperty(l,Symbol.toStringTag,{value:"Module"})});
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"})});
@@ -0,0 +1 @@
1
+ (function(e,i){typeof exports=="object"&&typeof module<"u"?module.exports=i():typeof define=="function"&&define.amd?define(i):(e=typeof globalThis<"u"?globalThis:e||self,e.UniverSheetsCrosshairHighlightFrFR=i())})(this,function(){"use strict";return{crosshair:{button:{tooltip:"Surlignage du réticule"}}}});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@univerjs/sheets-crosshair-highlight",
3
- "version": "0.5.0",
3
+ "version": "0.5.1",
4
4
  "private": false,
5
5
  "description": "",
6
6
  "author": "DreamNum <developer@univer.ai>",
@@ -57,22 +57,24 @@
57
57
  "rxjs": ">=7.0.0"
58
58
  },
59
59
  "dependencies": {
60
- "@univerjs/icons": "^0.2.7",
60
+ "@univerjs/icons": "^0.2.8",
61
61
  "clsx": "^2.1.1",
62
- "@univerjs/core": "0.5.0",
63
- "@univerjs/sheets": "0.5.0",
64
- "@univerjs/ui": "0.5.0",
65
- "@univerjs/engine-render": "0.5.0",
66
- "@univerjs/sheets-ui": "0.5.0"
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"
67
67
  },
68
68
  "devDependencies": {
69
- "less": "^4.2.0",
69
+ "less": "^4.2.1",
70
+ "postcss": "^8.4.49",
70
71
  "react": "18.3.1",
71
72
  "rxjs": "^7.8.1",
72
- "typescript": "^5.6.3",
73
- "vite": "^5.4.11",
74
- "vitest": "^2.1.5",
75
- "@univerjs-infra/shared": "0.5.0"
73
+ "tailwindcss": "^3.4.15",
74
+ "typescript": "^5.7.2",
75
+ "vite": "^6.0.1",
76
+ "vitest": "^2.1.6",
77
+ "@univerjs-infra/shared": "0.5.1"
76
78
  },
77
79
  "space": {
78
80
  ".": {