@univerjs/find-replace 0.1.0-beta.3 → 0.1.0-beta.4

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 Y=Object.defineProperty;var Q=(t,e,n)=>e in t?Y(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var u=(t,e,n)=>(Q(t,typeof e!="symbol"?e+"":e,n),n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("@univerjs/core"),S=require("@wendellhu/redi"),d=require("@univerjs/ui"),O=require("rxjs"),p=require("react"),f=require("@univerjs/design"),P=require("@wendellhu/redi/react-bindings");var _=function(){return _=Object.assign||function(t){for(var e,n=1,i=arguments.length;n<i;n++){e=arguments[n];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])}return t},_.apply(this,arguments)},X=function(t,e){var n={};for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&e.indexOf(i)<0&&(n[i]=t[i]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,i=Object.getOwnPropertySymbols(t);r<i.length;r++)e.indexOf(i[r])<0&&Object.prototype.propertyIsEnumerable.call(t,i[r])&&(n[i[r]]=t[i[r]]);return n},N=p.forwardRef(function(t,e){var n=t.icon,i=t.id,r=t.className,o=t.extend,a=X(t,["icon","id","className","extend"]),c="univerjs-icon univerjs-icon-".concat(i," ").concat(r||"").trim(),v=p.useRef("_".concat(te()));return U(n,"".concat(i),{defIds:n.defIds,idSuffix:v.current},_({ref:e,className:c},a),o)});function U(t,e,n,i,r){return p.createElement(t.tag,_(_({key:e},Z(t,n,r)),i),(ee(t,n).children||[]).map(function(o,a){return U(o,"".concat(e,"-").concat(t.tag,"-").concat(a),n,void 0,r)}))}function Z(t,e,n){var i=_({},t.attrs);n!=null&&n.colorChannel1&&i.fill==="colorChannel1"&&(i.fill=n.colorChannel1);var r=e.defIds;return!r||r.length===0||(t.tag==="use"&&i["xlink:href"]&&(i["xlink:href"]=i["xlink:href"]+e.idSuffix),Object.entries(i).forEach(function(o){var a=o[0],c=o[1];typeof c=="string"&&(i[a]=c.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))})),i}function ee(t,e){var n,i=e.defIds;return!i||i.length===0?t:t.tag==="defs"&&(!((n=t.children)===null||n===void 0)&&n.length)?_(_({},t),{children:t.children.map(function(r){return typeof r.attrs.id=="string"&&i&&i.indexOf(r.attrs.id)>-1?_(_({},r),{attrs:_(_({},r.attrs),{id:r.attrs.id+e.idSuffix})}):r})}):t}function te(){return Math.random().toString(36).substring(2,8)}N.displayName="UniverIcon";var ie={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"mask",attrs:{id:"mask0_217_40",style:{"mask-type":"alpha"},width:17,height:17,x:0,y:0,maskUnits:"userSpaceOnUse"},children:[{tag:"path",attrs:{fill:"#D9D9D9",d:"M.9.09h16v16H.9z"}}]},{tag:"g",attrs:{mask:"url(#mask0_217_40)"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M2.4 7.37a5.78 5.78 0 1110.31 3.58l2.49 2.48a.68.68 0 01-.97.96l-2.48-2.48A5.78 5.78 0 012.4 7.37zm5.77-4.42a4.42 4.42 0 100 8.84 4.42 4.42 0 000-8.84z",fillRule:"evenodd",clipRule:"evenodd"}}]}]},$=p.forwardRef(function(t,e){return p.createElement(N,Object.assign({},t,{id:"search-single-16",ref:e,icon:ie}))});$.displayName="SearchSingle16";const ne=$;var re=Object.defineProperty,oe=Object.getOwnPropertyDescriptor,A=(t,e,n,i)=>{for(var r=i>1?void 0:i?oe(e,n):e,o=t.length-1,a;o>=0;o--)(a=t[o])&&(r=(i?a(e,n,r):a(r))||r);return i&&r&&re(e,n,r),r},M=(t,e)=>(n,i)=>e(n,i,t);class ae extends s.Disposable{}const m=S.createIdentifier("univer.find-replace.service");let T=class extends s.Disposable{constructor(e,n,i,r){super();u(this,"_matchPositionFindModel",null);u(this,"_findModels",[]);u(this,"_matches",[]);u(this,"_positionModel",null);this._state=e,this._providers=n,this._logService=i,this._univerInstanceService=r,this._state.stateUpdates$.subscribe(o=>{typeof o.findString<"u"&&(o.findString?this.find():this._cancelFinding())})}async find(){this._cancelFinding();const e=Array.from(this._providers),n=this._findModels=(await Promise.all(e.map(o=>o.find({text:this._state.findString})))).flat(),i=n.map(o=>o.getMatches()).flat();if(this._matches=i,!i.length)return{results:[]};const r=this._moveToInitialMatch(n,i);return this._state.changeState({matchesCount:i.length,matchesPosition:r+1}),{results:i}}moveToNextMatch(){if(!this._positionModel)return;const e=this._findModels.length===1,n=this._positionModel.moveToNextMatch(e);if(n){const i=this._matches.findIndex(r=>r===n);this._state.changeState({matchesPosition:i+1})}else{const i=this._findModels.findIndex(c=>c===this._positionModel),r=this._findModels[(i+1)%this._findModels.length],o=r.moveToNextMatch(),a=this._matches.findIndex(c=>c===o);this._positionModel=r,this._state.changeState({matchesPosition:a+1})}}moveToPreviousMatch(){if(!this._positionModel)return;const e=this._findModels.length===1,n=this._positionModel.moveToPreviousMatch(e);if(n){const i=this._matches.findIndex(r=>r===n);this._state.changeState({matchesPosition:i+1})}else{const i=this._findModels.findIndex(c=>c===this._positionModel),r=this._findModels[(i-1+this._findModels.length)%this._findModels.length],o=r.moveToPreviousMatch(),a=this._matches.findIndex(c=>c===o);this._positionModel=r,this._state.changeState({matchesPosition:a+1})}}_moveToInitialMatch(e,n){var c;const i=(c=this._univerInstanceService.getFocusedUniverInstance())==null?void 0:c.getUnitId();if(!i)return-1;const r=e.find(v=>v.unitId===i);if(r){this._positionModel=r;const v=r.moveToNextMatch();return n.findIndex(I=>I===v)}this._positionModel=e[0];const o=this._positionModel.moveToNextMatch();return this._matches.findIndex(v=>v===o)}_cancelFinding(){this._providers.forEach(e=>e.cancel()),this._state.changeState({matchesCount:0,matchesPosition:0})}};T=A([M(2,s.ILogService),M(3,s.IUniverInstanceService)],T);function L(){return{revealed:!0,findString:"",replaceRevealed:!1,matchesPosition:0,matchesCount:0}}class se{constructor(){u(this,"_stateUpdates$",new O.Subject);u(this,"stateUpdates$",this._stateUpdates$.asObservable());u(this,"_state$",new O.BehaviorSubject(L()));u(this,"state$",this._state$.asObservable());u(this,"_findString","");u(this,"_revealed",!1);u(this,"_replaceRevealed",!1);u(this,"_matchesPosition",0);u(this,"_matchesCount",0)}get state(){return this._state$.getValue()}get findString(){return this._findString}changeState(e){let n=!1;const i={};typeof e.findString<"u"&&e.findString!==this._findString&&(this._findString=e.findString,i.findString=this._findString,n=!0),typeof e.revealed<"u"&&e.revealed!==this._revealed&&(this._revealed=e.revealed,i.revealed=e.revealed,n=!0),typeof e.replaceRevealed<"u"&&e.replaceRevealed!==this._replaceRevealed&&(this._replaceRevealed=e.replaceRevealed,i.replaceRevealed=e.replaceRevealed,n=!0),typeof e.matchesCount<"u"&&e.matchesCount!==this._matchesCount&&(this._matchesCount=e.matchesCount,i.matchesCount=e.matchesCount,n=!0),typeof e.matchesPosition<"u"&&e.matchesPosition!==this._matchesPosition&&(this._matchesPosition=e.matchesPosition,i.matchesPosition=e.matchesPosition,n=!0),n&&(this._stateUpdates$.next(i),this._state$.next({findString:this._findString,revealed:this._revealed,replaceRevealed:this._replaceRevealed,matchesCount:this._matchesCount,matchesPosition:this._matchesPosition}))}}let b=class extends s.Disposable{constructor(e,n,i){super();u(this,"_providers",new Set);u(this,"_state",new se);u(this,"_model");this._injector=e,this._univerInstanceService=n,this._logService=i}get stateUpdates$(){return this._state.stateUpdates$}get state$(){return this._state.state$}changeFindString(e){this._state.changeState({findString:e})}moveToNextMatch(){var e;this._model&&((e=this._model)==null||e.moveToNextMatch())}moveToPreviousMatch(){var e;this._model&&((e=this._model)==null||e.moveToPreviousMatch())}replace(){return!0}replaceAll(){return!0}revealReplace(){this._state.changeState({replaceRevealed:!0})}disposeModel(){var e;(e=this._model)==null||e.dispose(),this._model=null}start(){if(this._providers.size===0)return!1;this._model=this._injector.createInstance(T,this._state,this._providers);const e=L();return e.revealed=!0,this._state.changeState(e),!0}end(){return this._state.changeState({revealed:!1,replaceRevealed:!1}),!0}registerFindReplaceProvider(e){return this._providers.add(e),s.toDisposable(()=>this._providers.delete(e))}};b=A([M(0,S.Inject(S.Injector)),M(1,s.IUniverInstanceService),M(2,s.ILogService)],b);const F={id:"ui.operation.open-find-dialog",type:s.CommandType.OPERATION,handler:t=>(t.get(m).start(),!0)},w={id:"ui.operation.open-replace-dialog",type:s.CommandType.OPERATION,handler:t=>(t.get(m).start(),!0)},ce={id:"ui.operation.toggle-replace-dialog",type:s.CommandType.OPERATION,handler:t=>(t.get(m),!0)},B={id:"ui.operation.close-find-replace-dialog",type:s.CommandType.OPERATION,handler:t=>!0},V={type:s.CommandType.OPERATION,id:"ui.operation.go-to-next-match",handler:t=>(t.get(m).moveToNextMatch(),!0)},q={type:s.CommandType.OPERATION,id:"ui.operation.go-to-previous-match",handler:t=>(t.get(m).moveToPreviousMatch(),!0)},x="FIND_REPLACE_ACTIVATED";var K={exports:{}},C={};/**
1
+ "use strict";var J=Object.defineProperty;var Y=(t,e,n)=>e in t?J(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var u=(t,e,n)=>(Y(t,typeof e!="symbol"?e+"":e,n),n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("@univerjs/core"),S=require("@wendellhu/redi"),d=require("@univerjs/ui"),O=require("rxjs"),p=require("react"),f=require("@univerjs/design"),P=require("@wendellhu/redi/react-bindings");var _=function(){return _=Object.assign||function(t){for(var e,n=1,i=arguments.length;n<i;n++){e=arguments[n];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])}return t},_.apply(this,arguments)},Q=function(t,e){var n={};for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&e.indexOf(i)<0&&(n[i]=t[i]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,i=Object.getOwnPropertySymbols(t);r<i.length;r++)e.indexOf(i[r])<0&&Object.prototype.propertyIsEnumerable.call(t,i[r])&&(n[i[r]]=t[i[r]]);return n},N=p.forwardRef(function(t,e){var n=t.icon,i=t.id,r=t.className,o=t.extend,a=Q(t,["icon","id","className","extend"]),c="univerjs-icon univerjs-icon-".concat(i," ").concat(r||"").trim(),v=p.useRef("_".concat(te()));return U(n,"".concat(i),{defIds:n.defIds,idSuffix:v.current},_({ref:e,className:c},a),o)});function U(t,e,n,i,r){return p.createElement(t.tag,_(_({key:e},X(t,n,r)),i),(ee(t,n).children||[]).map(function(o,a){return U(o,"".concat(e,"-").concat(t.tag,"-").concat(a),n,void 0,r)}))}function X(t,e,n){var i=_({},t.attrs);n!=null&&n.colorChannel1&&i.fill==="colorChannel1"&&(i.fill=n.colorChannel1);var r=e.defIds;return!r||r.length===0||(t.tag==="use"&&i["xlink:href"]&&(i["xlink:href"]=i["xlink:href"]+e.idSuffix),Object.entries(i).forEach(function(o){var a=o[0],c=o[1];typeof c=="string"&&(i[a]=c.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))})),i}function ee(t,e){var n,i=e.defIds;return!i||i.length===0?t:t.tag==="defs"&&(!((n=t.children)===null||n===void 0)&&n.length)?_(_({},t),{children:t.children.map(function(r){return typeof r.attrs.id=="string"&&i&&i.indexOf(r.attrs.id)>-1?_(_({},r),{attrs:_(_({},r.attrs),{id:r.attrs.id+e.idSuffix})}):r})}):t}function te(){return Math.random().toString(36).substring(2,8)}N.displayName="UniverIcon";var ie={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"mask",attrs:{id:"mask0_217_40",style:{"mask-type":"alpha"},width:17,height:17,x:0,y:0,maskUnits:"userSpaceOnUse"},children:[{tag:"path",attrs:{fill:"#D9D9D9",d:"M0.9 0.09H16.9V16.09H0.9z"}}]},{tag:"g",attrs:{mask:"url(#mask0_217_40)"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M2.39551 7.37266C2.39551 4.18105 4.98281 1.59375 8.17441 1.59375C11.366 1.59375 13.9533 4.18105 13.9533 7.37266C13.9533 8.72342 13.4898 9.96603 12.7133 10.95L15.1964 13.4331C15.4619 13.6986 15.4619 14.1291 15.1964 14.3946C14.9309 14.6601 14.5004 14.6601 14.2349 14.3946L11.7518 11.9115C10.7678 12.6881 9.52525 13.1516 8.17441 13.1516C4.98281 13.1516 2.39551 10.5642 2.39551 7.37266ZM8.17441 2.95349C5.73378 2.95349 3.75525 4.93202 3.75525 7.37266C3.75525 9.81333 5.73378 11.7918 8.17441 11.7918C10.6151 11.7918 12.5936 9.81333 12.5936 7.37266C12.5936 4.93202 10.6151 2.95349 8.17441 2.95349Z",fillRule:"evenodd",clipRule:"evenodd"}}]}]},$=p.forwardRef(function(t,e){return p.createElement(N,Object.assign({},t,{id:"search-single-16",ref:e,icon:ie}))});$.displayName="SearchSingle16";const ne=$;var re=Object.defineProperty,oe=Object.getOwnPropertyDescriptor,A=(t,e,n,i)=>{for(var r=i>1?void 0:i?oe(e,n):e,o=t.length-1,a;o>=0;o--)(a=t[o])&&(r=(i?a(e,n,r):a(r))||r);return i&&r&&re(e,n,r),r},I=(t,e)=>(n,i)=>e(n,i,t);class ae extends s.Disposable{}const m=S.createIdentifier("univer.find-replace.service");let T=class extends s.Disposable{constructor(e,n,i,r){super();u(this,"_matchPositionFindModel",null);u(this,"_findModels",[]);u(this,"_matches",[]);u(this,"_positionModel",null);this._state=e,this._providers=n,this._logService=i,this._univerInstanceService=r,this._state.stateUpdates$.subscribe(o=>{typeof o.findString<"u"&&(o.findString?this.find():this._cancelFinding())})}async find(){this._cancelFinding();const e=Array.from(this._providers),n=this._findModels=(await Promise.all(e.map(o=>o.find({text:this._state.findString})))).flat(),i=n.map(o=>o.getMatches()).flat();if(this._matches=i,!i.length)return{results:[]};const r=this._moveToInitialMatch(n,i);return this._state.changeState({matchesCount:i.length,matchesPosition:r+1}),{results:i}}moveToNextMatch(){if(!this._positionModel)return;const e=this._findModels.length===1,n=this._positionModel.moveToNextMatch(e);if(n){const i=this._matches.findIndex(r=>r===n);this._state.changeState({matchesPosition:i+1})}else{const i=this._findModels.findIndex(c=>c===this._positionModel),r=this._findModels[(i+1)%this._findModels.length],o=r.moveToNextMatch(),a=this._matches.findIndex(c=>c===o);this._positionModel=r,this._state.changeState({matchesPosition:a+1})}}moveToPreviousMatch(){if(!this._positionModel)return;const e=this._findModels.length===1,n=this._positionModel.moveToPreviousMatch(e);if(n){const i=this._matches.findIndex(r=>r===n);this._state.changeState({matchesPosition:i+1})}else{const i=this._findModels.findIndex(c=>c===this._positionModel),r=this._findModels[(i-1+this._findModels.length)%this._findModels.length],o=r.moveToPreviousMatch(),a=this._matches.findIndex(c=>c===o);this._positionModel=r,this._state.changeState({matchesPosition:a+1})}}_moveToInitialMatch(e,n){var c;const i=(c=this._univerInstanceService.getFocusedUniverInstance())==null?void 0:c.getUnitId();if(!i)return-1;const r=e.find(v=>v.unitId===i);if(r){this._positionModel=r;const v=r.moveToNextMatch();return n.findIndex(C=>C===v)}this._positionModel=e[0];const o=this._positionModel.moveToNextMatch();return this._matches.findIndex(v=>v===o)}_cancelFinding(){this._providers.forEach(e=>e.cancel()),this._state.changeState({matchesCount:0,matchesPosition:0})}};T=A([I(2,s.ILogService),I(3,s.IUniverInstanceService)],T);function L(){return{revealed:!0,findString:"",replaceRevealed:!1,matchesPosition:0,matchesCount:0}}class se{constructor(){u(this,"_stateUpdates$",new O.Subject);u(this,"stateUpdates$",this._stateUpdates$.asObservable());u(this,"_state$",new O.BehaviorSubject(L()));u(this,"state$",this._state$.asObservable());u(this,"_findString","");u(this,"_revealed",!1);u(this,"_replaceRevealed",!1);u(this,"_matchesPosition",0);u(this,"_matchesCount",0)}get state(){return this._state$.getValue()}get findString(){return this._findString}changeState(e){let n=!1;const i={};typeof e.findString<"u"&&e.findString!==this._findString&&(this._findString=e.findString,i.findString=this._findString,n=!0),typeof e.revealed<"u"&&e.revealed!==this._revealed&&(this._revealed=e.revealed,i.revealed=e.revealed,n=!0),typeof e.replaceRevealed<"u"&&e.replaceRevealed!==this._replaceRevealed&&(this._replaceRevealed=e.replaceRevealed,i.replaceRevealed=e.replaceRevealed,n=!0),typeof e.matchesCount<"u"&&e.matchesCount!==this._matchesCount&&(this._matchesCount=e.matchesCount,i.matchesCount=e.matchesCount,n=!0),typeof e.matchesPosition<"u"&&e.matchesPosition!==this._matchesPosition&&(this._matchesPosition=e.matchesPosition,i.matchesPosition=e.matchesPosition,n=!0),n&&(this._stateUpdates$.next(i),this._state$.next({findString:this._findString,revealed:this._revealed,replaceRevealed:this._replaceRevealed,matchesCount:this._matchesCount,matchesPosition:this._matchesPosition}))}}let b=class extends s.Disposable{constructor(e,n,i){super();u(this,"_providers",new Set);u(this,"_state",new se);u(this,"_model");this._injector=e,this._univerInstanceService=n,this._logService=i}get stateUpdates$(){return this._state.stateUpdates$}get state$(){return this._state.state$}changeFindString(e){this._state.changeState({findString:e})}moveToNextMatch(){var e;this._model&&((e=this._model)==null||e.moveToNextMatch())}moveToPreviousMatch(){var e;this._model&&((e=this._model)==null||e.moveToPreviousMatch())}replace(){return!0}replaceAll(){return!0}revealReplace(){this._state.changeState({replaceRevealed:!0})}disposeModel(){var e;(e=this._model)==null||e.dispose(),this._model=null}start(){if(this._providers.size===0)return!1;this._model=this._injector.createInstance(T,this._state,this._providers);const e=L();return e.revealed=!0,this._state.changeState(e),!0}end(){return this._state.changeState({revealed:!1,replaceRevealed:!1}),!0}registerFindReplaceProvider(e){return this._providers.add(e),s.toDisposable(()=>this._providers.delete(e))}};b=A([I(0,S.Inject(S.Injector)),I(1,s.IUniverInstanceService),I(2,s.ILogService)],b);const F={id:"ui.operation.open-find-dialog",type:s.CommandType.OPERATION,handler:t=>(t.get(m).start(),!0)},w={id:"ui.operation.open-replace-dialog",type:s.CommandType.OPERATION,handler:t=>(t.get(m).start(),!0)},ce={id:"ui.operation.toggle-replace-dialog",type:s.CommandType.OPERATION,handler:t=>(t.get(m),!0)},B={id:"ui.operation.close-find-replace-dialog",type:s.CommandType.OPERATION,handler:t=>!0},V={type:s.CommandType.OPERATION,id:"ui.operation.go-to-next-match",handler:t=>(t.get(m).moveToNextMatch(),!0)},q={type:s.CommandType.OPERATION,id:"ui.operation.go-to-previous-match",handler:t=>(t.get(m).moveToPreviousMatch(),!0)},x="FIND_REPLACE_ACTIVATED";var K={exports:{}},y={};/**
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 le=p,de=Symbol.for("react.element"),ue=Symbol.for("react.fragment"),he=Object.prototype.hasOwnProperty,pe=le.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,fe={key:!0,ref:!0,__self:!0,__source:!0};function k(t,e,n){var i,r={},o=null,a=null;n!==void 0&&(o=""+n),e.key!==void 0&&(o=""+e.key),e.ref!==void 0&&(a=e.ref);for(i in e)he.call(e,i)&&!fe.hasOwnProperty(i)&&(r[i]=e[i]);if(t&&t.defaultProps)for(i in e=t.defaultProps,e)r[i]===void 0&&(r[i]=e[i]);return{$$typeof:de,type:t,key:o,ref:a,props:r,_owner:pe.current}}C.Fragment=ue;C.jsx=k;C.jsxs=k;K.exports=C;var h=K.exports;const ve="univer-find-replace-expand-container",E={findReplaceExpandContainer:ve};function _e(){const t=P.useDependency(m),e=P.useDependency(s.LocaleService),n=P.useDependency(d.LayoutService),[i,r]=p.useState(""),[o,a]=p.useState(""),c=p.useRef(null),v=f.useObservable(t.state$,!0),{matchesCount:R,matchesPosition:I}=v,G=p.useCallback(()=>t.revealReplace(),[t]),W=p.useCallback(l=>t.changeFindString(l),[t]),z=p.useCallback(l=>{r(l),W(l)},[t]),j=p.useCallback(l=>{a(l)},[t]);p.useEffect(()=>{let l;return c.current&&(l=n.registerContainer(c.current)),()=>l==null?void 0:l.dispose()},[c.current]);function H(){return h.jsxs(p.Fragment,{children:[h.jsx(f.InputWithSlot,{autoFocus:!0,placeholder:e.t("univer.find-replace.dialog.find-placeholder"),slot:h.jsx(f.Pager,{loop:!0,value:I,total:R,onChange:l=>{I===R&&l===1?t.moveToNextMatch():I===1&&l===R||l<I?t.moveToPreviousMatch():t.moveToNextMatch()}}),value:i,onChange:l=>z(l)}),h.jsx("div",{className:E.findReplaceExpandContainer,children:h.jsx(f.Button,{type:"text",size:"small",onClick:G,children:e.t("univer.find-replace.dialog.advanced-finding")})})]})}function J(){return h.jsxs(p.Fragment,{children:[h.jsx(f.FormLayout,{label:e.t("univer.find-replace.dialog.find"),children:h.jsx(f.Input,{placeholder:e.t("univer.find-replace.dialog.find-placeholder"),autoFocus:!0,value:i,onChange:l=>j(l)})}),h.jsx(f.FormLayout,{label:e.t("univer.find-replace.dialog.replace"),children:h.jsx(f.Input,{placeholder:e.t("univer.find-replace.dialog.replace-placeholder"),value:o,onChange:l=>j(l)})}),h.jsx(f.FormLayout,{label:e.t("univer.find-replace.dialog.find-range"),children:h.jsx(f.Select,{value:"123",onChange:()=>{}})}),h.jsx(f.Button,{type:"primary",children:e.t("univer.find-replace.dialog.find")}),h.jsx(f.Button,{children:e.t("univer.find-replace.dialog.replace")}),h.jsx(f.Button,{children:e.t("univer.find-replace.dialog.replace-all")})]})}return h.jsx("div",{className:E.findReplaceDialogContainer,ref:c,children:v.replaceRevealed?J():H()})}function ge(t){return{id:F.id,icon:"SearchIcon",tooltip:"toolbar.find-replace",group:d.MenuGroup.TOOLBAR_OTHERS,type:d.MenuItemType.BUTTON,positions:[d.MenuPosition.TOOLBAR_START],hidden$:d.getMenuHiddenObservable(t,s.UniverInstanceType.SHEET)}}const me={id:F.id,description:"shortcut.find-replace.open-find-dialog",binding:d.KeyCode.F|d.MetaKeys.CTRL_COMMAND,group:"4_find-replace",preconditions(t){return!t.getContextValue(x)}},Se={id:w.id,description:"shortcut.find-replace.open-replace-dialog",binding:d.KeyCode.H|d.MetaKeys.CTRL_COMMAND,group:"4_find-replace",preconditions(t){return!t.getContextValue(x)}},xe={id:B.id,description:"shortcut.find-replace.close-dialog",binding:d.KeyCode.ESC,group:"4_find-replace",priority:1e3,preconditions(t){return!!t.getContextValue(x)}},Re={id:V.id,description:"shortcut.find-replace.go-to-next-find-match",binding:d.KeyCode.ENTER,group:"4_find-replace",priority:1e3,preconditions(t){return!!t.getContextValue(x)}},Ie={id:q.id,description:"shortcut.find-replace.go-to-previous-find-match",binding:d.KeyCode.ENTER|d.MetaKeys.SHIFT,group:"4_find-replace",priority:1e3,preconditions(t){return!!t.getContextValue(x)}};var Me=Object.defineProperty,ye=Object.getOwnPropertyDescriptor,Ce=(t,e,n,i)=>{for(var r=i>1?void 0:i?ye(e,n):e,o=t.length-1,a;o>=0;o--)(a=t[o])&&(r=(i?a(e,n,r):a(r))||r);return i&&r&&Me(e,n,r),r},g=(t,e)=>(n,i)=>e(n,i,t);const D="DESKTOP_FIND_REPLACE_DIALOG";let y=class extends s.RxDisposable{constructor(t,e,n,i,r,o,a,c,v,R){super(),this._menuService=t,this._shortcutService=e,this._commandService=n,this._findReplaceService=i,this._dialogService=r,this._contextService=o,this._focusService=a,this._localeService=c,this._componentManager=v,this._injector=R,this._initOperations(),this._initUI(),this._initShortcuts()}_initOperations(){[B,F,w,ce,V,q].forEach(t=>{this.disposeWithMe(this._commandService.registerCommand(t))})}_initUI(){[ge].forEach(t=>{this.disposeWithMe(this._menuService.addMenuItem(this._injector.invoke(t)))}),this.disposeWithMe(this._componentManager.register("FindReplaceDialog",_e)),this.disposeWithMe(this._componentManager.register("SearchIcon",ne)),this._findReplaceService.stateUpdates$.pipe(O.takeUntil(this.dispose$)).subscribe(t=>{t.revealed===!0?this._openPanel():t.revealed===!1&&this._closePanel()})}_initShortcuts(){[Se,me,xe,Ie,Re].forEach(t=>{this.disposeWithMe(this._shortcutService.registerShortcut(t))})}_openPanel(){this._dialogService.open({id:D,draggable:!0,width:350,title:{title:this._localeService.t("univer.find-replace.dialog.title")},children:{label:"FindReplaceDialog"},onClose:()=>this._closePanel()}),this._contextService.setContextValue(x,!0)}_closePanel(){this._dialogService.close(D),this._contextService.setContextValue(x,!1),this._focusService.forceFocus(),this._findReplaceService.end()}};y=Ce([s.OnLifecycle(s.LifecycleStages.Rendered,y),g(0,d.IMenuService),g(1,d.IShortcutService),g(2,s.ICommandService),g(3,m),g(4,d.IDialogService),g(5,s.IContextService),g(6,d.IFocusService),g(7,S.Inject(s.LocaleService)),g(8,S.Inject(d.ComponentManager)),g(9,S.Inject(S.Injector))],y);const Pe={univer:{"find-replace":{dialog:{title:"查找",find:"查找",replace:"替换","replace-all":"替换全部","find-range":"查找范围","find-placeholder":"输入查找内容","advanced-finding":"替换 / 高级查找","replace-placeholder":"输入替换内容"}}}};var Oe=Object.defineProperty,Te=Object.getOwnPropertyDescriptor,be=(t,e,n,i)=>{for(var r=i>1?void 0:i?Te(e,n):e,o=t.length-1,a;o>=0;o--)(a=t[o])&&(r=(i?a(e,n,r):a(r))||r);return i&&r&&Oe(e,n,r),r},Fe=(t,e)=>(n,i)=>e(n,i,t);const je="FIND_REPLACE";exports.UniverFindReplacePlugin=class extends s.Plugin{constructor(e,n){super(je),this._injector=e,this._localeService=n,this._localeService.load({zhCN:Pe})}onStarting(e){[[y],[m,{useClass:b}]].forEach(n=>{e.add(n)})}};exports.UniverFindReplacePlugin=be([Fe(1,S.Inject(s.LocaleService))],exports.UniverFindReplacePlugin);exports.FindModel=ae;exports.IFindReplaceService=m;
9
+ */var le=p,de=Symbol.for("react.element"),ue=Symbol.for("react.fragment"),he=Object.prototype.hasOwnProperty,pe=le.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,fe={key:!0,ref:!0,__self:!0,__source:!0};function k(t,e,n){var i,r={},o=null,a=null;n!==void 0&&(o=""+n),e.key!==void 0&&(o=""+e.key),e.ref!==void 0&&(a=e.ref);for(i in e)he.call(e,i)&&!fe.hasOwnProperty(i)&&(r[i]=e[i]);if(t&&t.defaultProps)for(i in e=t.defaultProps,e)r[i]===void 0&&(r[i]=e[i]);return{$$typeof:de,type:t,key:o,ref:a,props:r,_owner:pe.current}}y.Fragment=ue;y.jsx=k;y.jsxs=k;K.exports=y;var h=K.exports;const ve="univer-find-replace-expand-container",E={findReplaceExpandContainer:ve};function _e(){const t=P.useDependency(m),e=P.useDependency(s.LocaleService),n=P.useDependency(d.LayoutService),[i,r]=p.useState(""),[o,a]=p.useState(""),c=p.useRef(null),v=f.useObservable(t.state$,!0),{matchesCount:R,matchesPosition:C}=v,G=p.useCallback(()=>t.revealReplace(),[t]),H=p.useCallback(l=>t.changeFindString(l),[t]),W=p.useCallback(l=>{r(l),H(l)},[t]),j=p.useCallback(l=>{a(l)},[t]);p.useEffect(()=>{let l;return c.current&&(l=n.registerContainer(c.current)),()=>l==null?void 0:l.dispose()},[c.current]);function z(){return h.jsxs(p.Fragment,{children:[h.jsx(f.InputWithSlot,{autoFocus:!0,placeholder:e.t("univer.find-replace.dialog.find-placeholder"),slot:h.jsx(f.Pager,{loop:!0,value:C,total:R,onChange:l=>{C===R&&l===1?t.moveToNextMatch():C===1&&l===R||l<C?t.moveToPreviousMatch():t.moveToNextMatch()}}),value:i,onChange:l=>W(l)}),h.jsx("div",{className:E.findReplaceExpandContainer,children:h.jsx(f.Button,{type:"text",size:"small",onClick:G,children:e.t("univer.find-replace.dialog.advanced-finding")})})]})}function Z(){return h.jsxs(p.Fragment,{children:[h.jsx(f.FormLayout,{label:e.t("univer.find-replace.dialog.find"),children:h.jsx(f.Input,{placeholder:e.t("univer.find-replace.dialog.find-placeholder"),autoFocus:!0,value:i,onChange:l=>j(l)})}),h.jsx(f.FormLayout,{label:e.t("univer.find-replace.dialog.replace"),children:h.jsx(f.Input,{placeholder:e.t("univer.find-replace.dialog.replace-placeholder"),value:o,onChange:l=>j(l)})}),h.jsx(f.FormLayout,{label:e.t("univer.find-replace.dialog.find-range"),children:h.jsx(f.Select,{value:"123",onChange:()=>{}})}),h.jsx(f.Button,{type:"primary",children:e.t("univer.find-replace.dialog.find")}),h.jsx(f.Button,{children:e.t("univer.find-replace.dialog.replace")}),h.jsx(f.Button,{children:e.t("univer.find-replace.dialog.replace-all")})]})}return h.jsx("div",{className:E.findReplaceDialogContainer,ref:c,children:v.replaceRevealed?Z():z()})}function ge(t){return{id:F.id,icon:"SearchIcon",tooltip:"toolbar.find-replace",group:d.MenuGroup.TOOLBAR_OTHERS,type:d.MenuItemType.BUTTON,positions:[d.MenuPosition.TOOLBAR_START],hidden$:d.getMenuHiddenObservable(t,s.UniverInstanceType.SHEET)}}const me={id:F.id,description:"shortcut.find-replace.open-find-dialog",binding:d.KeyCode.F|d.MetaKeys.CTRL_COMMAND,group:"4_find-replace",preconditions(t){return!t.getContextValue(x)}},Se={id:w.id,description:"shortcut.find-replace.open-replace-dialog",binding:d.KeyCode.H|d.MetaKeys.CTRL_COMMAND,group:"4_find-replace",preconditions(t){return!t.getContextValue(x)}},xe={id:B.id,description:"shortcut.find-replace.close-dialog",binding:d.KeyCode.ESC,group:"4_find-replace",priority:1e3,preconditions(t){return!!t.getContextValue(x)}},Re={id:V.id,description:"shortcut.find-replace.go-to-next-find-match",binding:d.KeyCode.ENTER,group:"4_find-replace",priority:1e3,preconditions(t){return!!t.getContextValue(x)}},Ce={id:q.id,description:"shortcut.find-replace.go-to-previous-find-match",binding:d.KeyCode.ENTER|d.MetaKeys.SHIFT,group:"4_find-replace",priority:1e3,preconditions(t){return!!t.getContextValue(x)}};var Ie=Object.defineProperty,Me=Object.getOwnPropertyDescriptor,ye=(t,e,n,i)=>{for(var r=i>1?void 0:i?Me(e,n):e,o=t.length-1,a;o>=0;o--)(a=t[o])&&(r=(i?a(e,n,r):a(r))||r);return i&&r&&Ie(e,n,r),r},g=(t,e)=>(n,i)=>e(n,i,t);const D="DESKTOP_FIND_REPLACE_DIALOG";let M=class extends s.RxDisposable{constructor(t,e,n,i,r,o,a,c,v,R){super(),this._menuService=t,this._shortcutService=e,this._commandService=n,this._findReplaceService=i,this._dialogService=r,this._contextService=o,this._focusService=a,this._localeService=c,this._componentManager=v,this._injector=R,this._initOperations(),this._initUI(),this._initShortcuts()}_initOperations(){[B,F,w,ce,V,q].forEach(t=>{this.disposeWithMe(this._commandService.registerCommand(t))})}_initUI(){[ge].forEach(t=>{this.disposeWithMe(this._menuService.addMenuItem(this._injector.invoke(t)))}),this.disposeWithMe(this._componentManager.register("FindReplaceDialog",_e)),this.disposeWithMe(this._componentManager.register("SearchIcon",ne)),this._findReplaceService.stateUpdates$.pipe(O.takeUntil(this.dispose$)).subscribe(t=>{t.revealed===!0?this._openPanel():t.revealed===!1&&this._closePanel()})}_initShortcuts(){[Se,me,xe,Ce,Re].forEach(t=>{this.disposeWithMe(this._shortcutService.registerShortcut(t))})}_openPanel(){this._dialogService.open({id:D,draggable:!0,width:350,title:{title:this._localeService.t("univer.find-replace.dialog.title")},children:{label:"FindReplaceDialog"},onClose:()=>this._closePanel()}),this._contextService.setContextValue(x,!0)}_closePanel(){this._dialogService.close(D),this._contextService.setContextValue(x,!1),this._focusService.forceFocus(),this._findReplaceService.end()}};M=ye([s.OnLifecycle(s.LifecycleStages.Rendered,M),g(0,d.IMenuService),g(1,d.IShortcutService),g(2,s.ICommandService),g(3,m),g(4,d.IDialogService),g(5,s.IContextService),g(6,d.IFocusService),g(7,S.Inject(s.LocaleService)),g(8,S.Inject(d.ComponentManager)),g(9,S.Inject(S.Injector))],M);const Pe={univer:{"find-replace":{dialog:{title:"查找",find:"查找",replace:"替换","replace-all":"替换全部","find-range":"查找范围","find-placeholder":"输入查找内容","advanced-finding":"替换 / 高级查找","replace-placeholder":"输入替换内容"}}}};var Oe=Object.defineProperty,Te=Object.getOwnPropertyDescriptor,be=(t,e,n,i)=>{for(var r=i>1?void 0:i?Te(e,n):e,o=t.length-1,a;o>=0;o--)(a=t[o])&&(r=(i?a(e,n,r):a(r))||r);return i&&r&&Oe(e,n,r),r},Fe=(t,e)=>(n,i)=>e(n,i,t);const je="FIND_REPLACE";exports.UniverFindReplacePlugin=class extends s.Plugin{constructor(e,n){super(je),this._injector=e,this._localeService=n,this._localeService.load({zhCN:Pe})}onStarting(e){[[M],[m,{useClass:b}]].forEach(n=>{e.add(n)})}};exports.UniverFindReplacePlugin=be([Fe(1,S.Inject(s.LocaleService))],exports.UniverFindReplacePlugin);exports.FindModel=ae;exports.IFindReplaceService=m;
package/lib/es/index.js CHANGED
@@ -2,11 +2,11 @@ var le = Object.defineProperty;
2
2
  var de = (t, e, n) => e in t ? le(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n;
3
3
  var l = (t, e, n) => (de(t, typeof e != "symbol" ? e + "" : e, n), n);
4
4
  import { Disposable as E, ILogService as B, IUniverInstanceService as G, toDisposable as he, CommandType as m, LocaleService as F, UniverInstanceType as ue, OnLifecycle as pe, LifecycleStages as fe, RxDisposable as ve, ICommandService as _e, IContextService as ge, Plugin as me } from "@univerjs/core";
5
- import { createIdentifier as Se, Inject as S, Injector as W } from "@wendellhu/redi";
6
- import { LayoutService as xe, MenuGroup as Re, MenuItemType as Me, MenuPosition as Ie, getMenuHiddenObservable as Oe, KeyCode as R, MetaKeys as j, ComponentManager as Pe, IMenuService as Ce, IShortcutService as ye, IDialogService as Te, IFocusService as be } from "@univerjs/ui";
5
+ import { createIdentifier as Se, Inject as S, Injector as H } from "@wendellhu/redi";
6
+ import { LayoutService as xe, MenuGroup as Re, MenuItemType as Me, MenuPosition as Ie, getMenuHiddenObservable as Ce, KeyCode as R, MetaKeys as j, ComponentManager as Oe, IMenuService as Pe, IShortcutService as ye, IDialogService as Te, IFocusService as be } from "@univerjs/ui";
7
7
  import { Subject as Ee, BehaviorSubject as Fe, takeUntil as je } from "rxjs";
8
- import De, { forwardRef as z, useRef as H, createElement as k, useState as $, useCallback as M, useEffect as Ne, Fragment as A } from "react";
9
- import { useObservable as $e, InputWithSlot as Ae, Pager as Ue, Button as I, FormLayout as C, Input as U, Select as we } from "@univerjs/design";
8
+ import De, { forwardRef as W, useRef as k, createElement as z, useState as $, useCallback as M, useEffect as Ne, Fragment as A } from "react";
9
+ import { useObservable as $e, InputWithSlot as Ae, Pager as Ue, Button as I, FormLayout as P, Input as U, Select as Le } from "@univerjs/design";
10
10
  import { useDependency as y } from "@wendellhu/redi/react-bindings";
11
11
  var u = function() {
12
12
  return u = Object.assign || function(t) {
@@ -17,7 +17,7 @@ var u = function() {
17
17
  }
18
18
  return t;
19
19
  }, u.apply(this, arguments);
20
- }, Le = function(t, e) {
20
+ }, we = function(t, e) {
21
21
  var n = {};
22
22
  for (var i in t)
23
23
  Object.prototype.hasOwnProperty.call(t, i) && e.indexOf(i) < 0 && (n[i] = t[i]);
@@ -25,12 +25,12 @@ var u = function() {
25
25
  for (var r = 0, i = Object.getOwnPropertySymbols(t); r < i.length; r++)
26
26
  e.indexOf(i[r]) < 0 && Object.prototype.propertyIsEnumerable.call(t, i[r]) && (n[i[r]] = t[i[r]]);
27
27
  return n;
28
- }, K = z(function(t, e) {
29
- var n = t.icon, i = t.id, r = t.className, o = t.extend, a = Le(t, ["icon", "id", "className", "extend"]), s = "univerjs-icon univerjs-icon-".concat(i, " ").concat(r || "").trim(), h = H("_".concat(Ge()));
28
+ }, K = W(function(t, e) {
29
+ var n = t.icon, i = t.id, r = t.className, o = t.extend, a = we(t, ["icon", "id", "className", "extend"]), s = "univerjs-icon univerjs-icon-".concat(i, " ").concat(r || "").trim(), h = k("_".concat(Ge()));
30
30
  return q(n, "".concat(i), { defIds: n.defIds, idSuffix: h.current }, u({ ref: e, className: s }, a), o);
31
31
  });
32
32
  function q(t, e, n, i, r) {
33
- return k(t.tag, u(u({ key: e }, Ve(t, n, r)), i), (Be(t, n).children || []).map(function(o, a) {
33
+ return z(t.tag, u(u({ key: e }, Ve(t, n, r)), i), (Be(t, n).children || []).map(function(o, a) {
34
34
  return q(o, "".concat(e, "-").concat(t.tag, "-").concat(a), n, void 0, r);
35
35
  }));
36
36
  }
@@ -53,7 +53,7 @@ function Ge() {
53
53
  return Math.random().toString(36).substring(2, 8);
54
54
  }
55
55
  K.displayName = "UniverIcon";
56
- var We = {
56
+ var He = {
57
57
  tag: "svg",
58
58
  attrs: { fill: "none", viewBox: "0 0 17 17", width: "1em", height: "1em" },
59
59
  children: [
@@ -69,7 +69,10 @@ var We = {
69
69
  maskUnits: "userSpaceOnUse"
70
70
  },
71
71
  children: [
72
- { tag: "path", attrs: { fill: "#D9D9D9", d: "M.9.09h16v16H.9z" } }
72
+ {
73
+ tag: "path",
74
+ attrs: { fill: "#D9D9D9", d: "M0.9 0.09H16.9V16.09H0.9z" }
75
+ }
73
76
  ]
74
77
  },
75
78
  {
@@ -80,7 +83,7 @@ var We = {
80
83
  tag: "path",
81
84
  attrs: {
82
85
  fill: "currentColor",
83
- d: "M2.4 7.37a5.78 5.78 0 1110.31 3.58l2.49 2.48a.68.68 0 01-.97.96l-2.48-2.48A5.78 5.78 0 012.4 7.37zm5.77-4.42a4.42 4.42 0 100 8.84 4.42 4.42 0 000-8.84z",
86
+ d: "M2.39551 7.37266C2.39551 4.18105 4.98281 1.59375 8.17441 1.59375C11.366 1.59375 13.9533 4.18105 13.9533 7.37266C13.9533 8.72342 13.4898 9.96603 12.7133 10.95L15.1964 13.4331C15.4619 13.6986 15.4619 14.1291 15.1964 14.3946C14.9309 14.6601 14.5004 14.6601 14.2349 14.3946L11.7518 11.9115C10.7678 12.6881 9.52525 13.1516 8.17441 13.1516C4.98281 13.1516 2.39551 10.5642 2.39551 7.37266ZM8.17441 2.95349C5.73378 2.95349 3.75525 4.93202 3.75525 7.37266C3.75525 9.81333 5.73378 11.7918 8.17441 11.7918C10.6151 11.7918 12.5936 9.81333 12.5936 7.37266C12.5936 4.93202 10.6151 2.95349 8.17441 2.95349Z",
84
87
  fillRule: "evenodd",
85
88
  clipRule: "evenodd"
86
89
  }
@@ -88,21 +91,21 @@ var We = {
88
91
  ]
89
92
  }
90
93
  ]
91
- }, J = z(function(t, e) {
92
- return k(K, Object.assign({}, t, {
94
+ }, Z = W(function(t, e) {
95
+ return z(K, Object.assign({}, t, {
93
96
  id: "search-single-16",
94
97
  ref: e,
95
- icon: We
98
+ icon: He
96
99
  }));
97
100
  });
98
- J.displayName = "SearchSingle16";
99
- const ze = J;
100
- var He = Object.defineProperty, ke = Object.getOwnPropertyDescriptor, Y = (t, e, n, i) => {
101
- for (var r = i > 1 ? void 0 : i ? ke(e, n) : e, o = t.length - 1, a; o >= 0; o--)
101
+ Z.displayName = "SearchSingle16";
102
+ const We = Z;
103
+ var ke = Object.defineProperty, ze = Object.getOwnPropertyDescriptor, J = (t, e, n, i) => {
104
+ for (var r = i > 1 ? void 0 : i ? ze(e, n) : e, o = t.length - 1, a; o >= 0; o--)
102
105
  (a = t[o]) && (r = (i ? a(e, n, r) : a(r)) || r);
103
- return i && r && He(e, n, r), r;
106
+ return i && r && ke(e, n, r), r;
104
107
  }, x = (t, e) => (n, i) => e(n, i, t);
105
- class Ct extends E {
108
+ class Pt extends E {
106
109
  }
107
110
  const f = Se("univer.find-replace.service");
108
111
  let T = class extends E {
@@ -187,11 +190,11 @@ let T = class extends E {
187
190
  });
188
191
  }
189
192
  };
190
- T = Y([
193
+ T = J([
191
194
  x(2, B),
192
195
  x(3, G)
193
196
  ], T);
194
- function Q() {
197
+ function Y() {
195
198
  return {
196
199
  revealed: !0,
197
200
  findString: "",
@@ -204,7 +207,7 @@ class Ke {
204
207
  constructor() {
205
208
  l(this, "_stateUpdates$", new Ee());
206
209
  l(this, "stateUpdates$", this._stateUpdates$.asObservable());
207
- l(this, "_state$", new Fe(Q()));
210
+ l(this, "_state$", new Fe(Y()));
208
211
  l(this, "state$", this._state$.asObservable());
209
212
  // TODO@wzhudev: put all state properties here
210
213
  l(this, "_findString", "");
@@ -275,7 +278,7 @@ let b = class extends E {
275
278
  if (this._providers.size === 0)
276
279
  return !1;
277
280
  this._model = this._injector.createInstance(T, this._state, this._providers);
278
- const e = Q();
281
+ const e = Y();
279
282
  return e.revealed = !0, this._state.changeState(e), !0;
280
283
  }
281
284
  end() {
@@ -285,8 +288,8 @@ let b = class extends E {
285
288
  return this._providers.add(e), he(() => this._providers.delete(e));
286
289
  }
287
290
  };
288
- b = Y([
289
- x(0, S(W)),
291
+ b = J([
292
+ x(0, S(H)),
290
293
  x(1, G),
291
294
  x(2, B)
292
295
  ], b);
@@ -294,7 +297,7 @@ const D = {
294
297
  id: "ui.operation.open-find-dialog",
295
298
  type: m.OPERATION,
296
299
  handler: (t) => (t.get(f).start(), !0)
297
- }, X = {
300
+ }, Q = {
298
301
  id: "ui.operation.open-replace-dialog",
299
302
  type: m.OPERATION,
300
303
  handler: (t) => (t.get(f).start(), !0)
@@ -302,7 +305,7 @@ const D = {
302
305
  id: "ui.operation.toggle-replace-dialog",
303
306
  type: m.OPERATION,
304
307
  handler: (t) => (t.get(f), !0)
305
- }, Z = {
308
+ }, X = {
306
309
  id: "ui.operation.close-find-replace-dialog",
307
310
  type: m.OPERATION,
308
311
  handler: (t) => !0
@@ -315,7 +318,7 @@ const D = {
315
318
  id: "ui.operation.go-to-previous-match",
316
319
  handler: (t) => (t.get(f).moveToPreviousMatch(), !0)
317
320
  }, v = "FIND_REPLACE_ACTIVATED";
318
- var ie = { exports: {} }, P = {};
321
+ var ie = { exports: {} }, O = {};
319
322
  /**
320
323
  * @license React
321
324
  * react-jsx-runtime.production.min.js
@@ -325,27 +328,27 @@ var ie = { exports: {} }, P = {};
325
328
  * This source code is licensed under the MIT license found in the
326
329
  * LICENSE file in the root directory of this source tree.
327
330
  */
328
- var Je = De, Ye = Symbol.for("react.element"), Qe = Symbol.for("react.fragment"), Xe = Object.prototype.hasOwnProperty, Ze = Je.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, et = { key: !0, ref: !0, __self: !0, __source: !0 };
331
+ var Ze = De, Je = Symbol.for("react.element"), Ye = Symbol.for("react.fragment"), Qe = Object.prototype.hasOwnProperty, Xe = Ze.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, et = { key: !0, ref: !0, __self: !0, __source: !0 };
329
332
  function ne(t, e, n) {
330
333
  var i, r = {}, o = null, a = null;
331
334
  n !== void 0 && (o = "" + n), e.key !== void 0 && (o = "" + e.key), e.ref !== void 0 && (a = e.ref);
332
335
  for (i in e)
333
- Xe.call(e, i) && !et.hasOwnProperty(i) && (r[i] = e[i]);
336
+ Qe.call(e, i) && !et.hasOwnProperty(i) && (r[i] = e[i]);
334
337
  if (t && t.defaultProps)
335
338
  for (i in e = t.defaultProps, e)
336
339
  r[i] === void 0 && (r[i] = e[i]);
337
- return { $$typeof: Ye, type: t, key: o, ref: a, props: r, _owner: Ze.current };
340
+ return { $$typeof: Je, type: t, key: o, ref: a, props: r, _owner: Xe.current };
338
341
  }
339
- P.Fragment = Qe;
340
- P.jsx = ne;
341
- P.jsxs = ne;
342
- ie.exports = P;
342
+ O.Fragment = Ye;
343
+ O.jsx = ne;
344
+ O.jsxs = ne;
345
+ ie.exports = O;
343
346
  var d = ie.exports;
344
- const tt = "univer-find-replace-expand-container", w = {
347
+ const tt = "univer-find-replace-expand-container", L = {
345
348
  findReplaceExpandContainer: tt
346
349
  };
347
350
  function it() {
348
- const t = y(f), e = y(F), n = y(xe), [i, r] = $(""), [o, a] = $(""), s = H(null), h = $e(t.state$, !0), { matchesCount: _, matchesPosition: g } = h, re = M(() => t.revealReplace(), [t]), oe = M(
351
+ const t = y(f), e = y(F), n = y(xe), [i, r] = $(""), [o, a] = $(""), s = k(null), h = $e(t.state$, !0), { matchesCount: _, matchesPosition: g } = h, re = M(() => t.revealReplace(), [t]), oe = M(
349
352
  (c) => t.changeFindString(c),
350
353
  // FIXME@wzhudev: this throttle function has no leading and taling config hence has some problems
351
354
  // throttle((findString: string) => findReplaceService.changeFindString(findString), FIND_THROTTLE_TIME),
@@ -387,12 +390,12 @@ function it() {
387
390
  onChange: (c) => ae(c)
388
391
  }
389
392
  ),
390
- /* @__PURE__ */ d.jsx("div", { className: w.findReplaceExpandContainer, children: /* @__PURE__ */ d.jsx(I, { type: "text", size: "small", onClick: re, children: e.t("univer.find-replace.dialog.advanced-finding") }) })
393
+ /* @__PURE__ */ d.jsx("div", { className: L.findReplaceExpandContainer, children: /* @__PURE__ */ d.jsx(I, { type: "text", size: "small", onClick: re, children: e.t("univer.find-replace.dialog.advanced-finding") }) })
391
394
  ] });
392
395
  }
393
396
  function ce() {
394
397
  return /* @__PURE__ */ d.jsxs(A, { children: [
395
- /* @__PURE__ */ d.jsx(C, { label: e.t("univer.find-replace.dialog.find"), children: /* @__PURE__ */ d.jsx(
398
+ /* @__PURE__ */ d.jsx(P, { label: e.t("univer.find-replace.dialog.find"), children: /* @__PURE__ */ d.jsx(
396
399
  U,
397
400
  {
398
401
  placeholder: e.t("univer.find-replace.dialog.find-placeholder"),
@@ -401,7 +404,7 @@ function it() {
401
404
  onChange: (c) => N(c)
402
405
  }
403
406
  ) }),
404
- /* @__PURE__ */ d.jsx(C, { label: e.t("univer.find-replace.dialog.replace"), children: /* @__PURE__ */ d.jsx(
407
+ /* @__PURE__ */ d.jsx(P, { label: e.t("univer.find-replace.dialog.replace"), children: /* @__PURE__ */ d.jsx(
405
408
  U,
406
409
  {
407
410
  placeholder: e.t("univer.find-replace.dialog.replace-placeholder"),
@@ -409,14 +412,14 @@ function it() {
409
412
  onChange: (c) => N(c)
410
413
  }
411
414
  ) }),
412
- /* @__PURE__ */ d.jsx(C, { label: e.t("univer.find-replace.dialog.find-range"), children: /* @__PURE__ */ d.jsx(we, { value: "123", onChange: () => {
415
+ /* @__PURE__ */ d.jsx(P, { label: e.t("univer.find-replace.dialog.find-range"), children: /* @__PURE__ */ d.jsx(Le, { value: "123", onChange: () => {
413
416
  } }) }),
414
417
  /* @__PURE__ */ d.jsx(I, { type: "primary", children: e.t("univer.find-replace.dialog.find") }),
415
418
  /* @__PURE__ */ d.jsx(I, { children: e.t("univer.find-replace.dialog.replace") }),
416
419
  /* @__PURE__ */ d.jsx(I, { children: e.t("univer.find-replace.dialog.replace-all") })
417
420
  ] });
418
421
  }
419
- return /* @__PURE__ */ d.jsx("div", { className: w.findReplaceDialogContainer, ref: s, children: h.replaceRevealed ? ce() : se() });
422
+ return /* @__PURE__ */ d.jsx("div", { className: L.findReplaceDialogContainer, ref: s, children: h.replaceRevealed ? ce() : se() });
420
423
  }
421
424
  function nt(t) {
422
425
  return {
@@ -426,7 +429,7 @@ function nt(t) {
426
429
  group: Re.TOOLBAR_OTHERS,
427
430
  type: Me.BUTTON,
428
431
  positions: [Ie.TOOLBAR_START],
429
- hidden$: Oe(t, ue.SHEET)
432
+ hidden$: Ce(t, ue.SHEET)
430
433
  };
431
434
  }
432
435
  const rt = {
@@ -438,7 +441,7 @@ const rt = {
438
441
  return !t.getContextValue(v);
439
442
  }
440
443
  }, ot = {
441
- id: X.id,
444
+ id: Q.id,
442
445
  description: "shortcut.find-replace.open-replace-dialog",
443
446
  binding: R.H | j.CTRL_COMMAND,
444
447
  group: "4_find-replace",
@@ -446,7 +449,7 @@ const rt = {
446
449
  return !t.getContextValue(v);
447
450
  }
448
451
  }, at = {
449
- id: Z.id,
452
+ id: X.id,
450
453
  description: "shortcut.find-replace.close-dialog",
451
454
  binding: R.ESC,
452
455
  group: "4_find-replace",
@@ -478,16 +481,16 @@ var lt = Object.defineProperty, dt = Object.getOwnPropertyDescriptor, ht = (t, e
478
481
  (a = t[o]) && (r = (i ? a(e, n, r) : a(r)) || r);
479
482
  return i && r && lt(e, n, r), r;
480
483
  }, p = (t, e) => (n, i) => e(n, i, t);
481
- const L = "DESKTOP_FIND_REPLACE_DIALOG";
482
- let O = class extends ve {
484
+ const w = "DESKTOP_FIND_REPLACE_DIALOG";
485
+ let C = class extends ve {
483
486
  constructor(t, e, n, i, r, o, a, s, h, _) {
484
487
  super(), this._menuService = t, this._shortcutService = e, this._commandService = n, this._findReplaceService = i, this._dialogService = r, this._contextService = o, this._focusService = a, this._localeService = s, this._componentManager = h, this._injector = _, this._initOperations(), this._initUI(), this._initShortcuts();
485
488
  }
486
489
  _initOperations() {
487
490
  [
488
- Z,
489
- D,
490
491
  X,
492
+ D,
493
+ Q,
491
494
  qe,
492
495
  ee,
493
496
  te
@@ -498,7 +501,7 @@ let O = class extends ve {
498
501
  _initUI() {
499
502
  [nt].forEach((t) => {
500
503
  this.disposeWithMe(this._menuService.addMenuItem(this._injector.invoke(t)));
501
- }), this.disposeWithMe(this._componentManager.register("FindReplaceDialog", it)), this.disposeWithMe(this._componentManager.register("SearchIcon", ze)), this._findReplaceService.stateUpdates$.pipe(je(this.dispose$)).subscribe((t) => {
504
+ }), this.disposeWithMe(this._componentManager.register("FindReplaceDialog", it)), this.disposeWithMe(this._componentManager.register("SearchIcon", We)), this._findReplaceService.stateUpdates$.pipe(je(this.dispose$)).subscribe((t) => {
502
505
  t.revealed === !0 ? this._openPanel() : t.revealed === !1 && this._closePanel();
503
506
  });
504
507
  }
@@ -515,7 +518,7 @@ let O = class extends ve {
515
518
  }
516
519
  _openPanel() {
517
520
  this._dialogService.open({
518
- id: L,
521
+ id: w,
519
522
  draggable: !0,
520
523
  width: 350,
521
524
  title: { title: this._localeService.t("univer.find-replace.dialog.title") },
@@ -524,12 +527,12 @@ let O = class extends ve {
524
527
  }), this._contextService.setContextValue(v, !0);
525
528
  }
526
529
  _closePanel() {
527
- this._dialogService.close(L), this._contextService.setContextValue(v, !1), this._focusService.forceFocus(), this._findReplaceService.end();
530
+ this._dialogService.close(w), this._contextService.setContextValue(v, !1), this._focusService.forceFocus(), this._findReplaceService.end();
528
531
  }
529
532
  };
530
- O = ht([
531
- pe(fe.Rendered, O),
532
- p(0, Ce),
533
+ C = ht([
534
+ pe(fe.Rendered, C),
535
+ p(0, Pe),
533
536
  p(1, ye),
534
537
  p(2, _e),
535
538
  p(3, f),
@@ -537,9 +540,9 @@ O = ht([
537
540
  p(5, ge),
538
541
  p(6, be),
539
542
  p(7, S(F)),
540
- p(8, S(Pe)),
541
- p(9, S(W))
542
- ], O);
543
+ p(8, S(Oe)),
544
+ p(9, S(H))
545
+ ], C);
543
546
  const ut = {
544
547
  univer: {
545
548
  "find-replace": {
@@ -569,7 +572,7 @@ let V = class extends me {
569
572
  });
570
573
  }
571
574
  onStarting(t) {
572
- [[O], [f, { useClass: b }]].forEach(
575
+ [[C], [f, { useClass: b }]].forEach(
573
576
  (e) => {
574
577
  t.add(e);
575
578
  }
@@ -580,7 +583,7 @@ V = vt([
580
583
  _t(1, S(F))
581
584
  ], V);
582
585
  export {
583
- Ct as FindModel,
586
+ Pt as FindModel,
584
587
  f as IFindReplaceService,
585
588
  V as UniverFindReplacePlugin
586
589
  };
package/lib/umd/index.js CHANGED
@@ -1,4 +1,4 @@
1
- (function(c,o){typeof exports=="object"&&typeof module<"u"?o(exports,require("@univerjs/core"),require("@wendellhu/redi"),require("@univerjs/ui"),require("rxjs"),require("react"),require("@univerjs/design"),require("@wendellhu/redi/react-bindings")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@wendellhu/redi","@univerjs/ui","rxjs","react","@univerjs/design","@wendellhu/redi/react-bindings"],o):(c=typeof globalThis<"u"?globalThis:c||self,o(c.UniverFindReplace={},c.UniverCore,c["@wendellhu/redi"],c.UniverUi,c.rxjs,c.React,c.UniverDesign,c["@wendellhu/redi/react-bindings"]))})(this,function(c,o,v,h,O,p,_,T){"use strict";var Fe=Object.defineProperty;var be=(c,o,v)=>o in c?Fe(c,o,{enumerable:!0,configurable:!0,writable:!0,value:v}):c[o]=v;var u=(c,o,v)=>(be(c,typeof o!="symbol"?o+"":o,v),v);var g=function(){return g=Object.assign||function(t){for(var e,r=1,i=arguments.length;r<i;r++){e=arguments[r];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])}return t},g.apply(this,arguments)},H=function(t,e){var r={};for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&e.indexOf(i)<0&&(r[i]=t[i]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,i=Object.getOwnPropertySymbols(t);n<i.length;n++)e.indexOf(i[n])<0&&Object.prototype.propertyIsEnumerable.call(t,i[n])&&(r[i[n]]=t[i[n]]);return r},E=p.forwardRef(function(t,e){var r=t.icon,i=t.id,n=t.className,a=t.extend,s=H(t,["icon","id","className","extend"]),l="univerjs-icon univerjs-icon-".concat(i," ").concat(n||"").trim(),m=p.useRef("_".concat(Q()));return D(r,"".concat(i),{defIds:r.defIds,idSuffix:m.current},g({ref:e,className:l},s),a)});function D(t,e,r,i,n){return p.createElement(t.tag,g(g({key:e},J(t,r,n)),i),(Y(t,r).children||[]).map(function(a,s){return D(a,"".concat(e,"-").concat(t.tag,"-").concat(s),r,void 0,n)}))}function J(t,e,r){var i=g({},t.attrs);r!=null&&r.colorChannel1&&i.fill==="colorChannel1"&&(i.fill=r.colorChannel1);var n=e.defIds;return!n||n.length===0||(t.tag==="use"&&i["xlink:href"]&&(i["xlink:href"]=i["xlink:href"]+e.idSuffix),Object.entries(i).forEach(function(a){var s=a[0],l=a[1];typeof l=="string"&&(i[s]=l.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))})),i}function Y(t,e){var r,i=e.defIds;return!i||i.length===0?t:t.tag==="defs"&&(!((r=t.children)===null||r===void 0)&&r.length)?g(g({},t),{children:t.children.map(function(n){return typeof n.attrs.id=="string"&&i&&i.indexOf(n.attrs.id)>-1?g(g({},n),{attrs:g(g({},n.attrs),{id:n.attrs.id+e.idSuffix})}):n})}):t}function Q(){return Math.random().toString(36).substring(2,8)}E.displayName="UniverIcon";var X={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"mask",attrs:{id:"mask0_217_40",style:{"mask-type":"alpha"},width:17,height:17,x:0,y:0,maskUnits:"userSpaceOnUse"},children:[{tag:"path",attrs:{fill:"#D9D9D9",d:"M.9.09h16v16H.9z"}}]},{tag:"g",attrs:{mask:"url(#mask0_217_40)"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M2.4 7.37a5.78 5.78 0 1110.31 3.58l2.49 2.48a.68.68 0 01-.97.96l-2.48-2.48A5.78 5.78 0 012.4 7.37zm5.77-4.42a4.42 4.42 0 100 8.84 4.42 4.42 0 000-8.84z",fillRule:"evenodd",clipRule:"evenodd"}}]}]},N=p.forwardRef(function(t,e){return p.createElement(E,Object.assign({},t,{id:"search-single-16",ref:e,icon:X}))});N.displayName="SearchSingle16";const Z=N;var $=Object.defineProperty,q=Object.getOwnPropertyDescriptor,U=(t,e,r,i)=>{for(var n=i>1?void 0:i?q(e,r):e,a=t.length-1,s;a>=0;a--)(s=t[a])&&(n=(i?s(e,r,n):s(n))||n);return i&&n&&$(e,r,n),n},y=(t,e)=>(r,i)=>e(r,i,t);class ee extends o.Disposable{}const x=v.createIdentifier("univer.find-replace.service");let j=class extends o.Disposable{constructor(e,r,i,n){super();u(this,"_matchPositionFindModel",null);u(this,"_findModels",[]);u(this,"_matches",[]);u(this,"_positionModel",null);this._state=e,this._providers=r,this._logService=i,this._univerInstanceService=n,this._state.stateUpdates$.subscribe(a=>{typeof a.findString<"u"&&(a.findString?this.find():this._cancelFinding())})}async find(){this._cancelFinding();const e=Array.from(this._providers),r=this._findModels=(await Promise.all(e.map(a=>a.find({text:this._state.findString})))).flat(),i=r.map(a=>a.getMatches()).flat();if(this._matches=i,!i.length)return{results:[]};const n=this._moveToInitialMatch(r,i);return this._state.changeState({matchesCount:i.length,matchesPosition:n+1}),{results:i}}moveToNextMatch(){if(!this._positionModel)return;const e=this._findModels.length===1,r=this._positionModel.moveToNextMatch(e);if(r){const i=this._matches.findIndex(n=>n===r);this._state.changeState({matchesPosition:i+1})}else{const i=this._findModels.findIndex(l=>l===this._positionModel),n=this._findModels[(i+1)%this._findModels.length],a=n.moveToNextMatch(),s=this._matches.findIndex(l=>l===a);this._positionModel=n,this._state.changeState({matchesPosition:s+1})}}moveToPreviousMatch(){if(!this._positionModel)return;const e=this._findModels.length===1,r=this._positionModel.moveToPreviousMatch(e);if(r){const i=this._matches.findIndex(n=>n===r);this._state.changeState({matchesPosition:i+1})}else{const i=this._findModels.findIndex(l=>l===this._positionModel),n=this._findModels[(i-1+this._findModels.length)%this._findModels.length],a=n.moveToPreviousMatch(),s=this._matches.findIndex(l=>l===a);this._positionModel=n,this._state.changeState({matchesPosition:s+1})}}_moveToInitialMatch(e,r){var l;const i=(l=this._univerInstanceService.getFocusedUniverInstance())==null?void 0:l.getUnitId();if(!i)return-1;const n=e.find(m=>m.unitId===i);if(n){this._positionModel=n;const m=n.moveToNextMatch();return r.findIndex(M=>M===m)}this._positionModel=e[0];const a=this._positionModel.moveToNextMatch();return this._matches.findIndex(m=>m===a)}_cancelFinding(){this._providers.forEach(e=>e.cancel()),this._state.changeState({matchesCount:0,matchesPosition:0})}};j=U([y(2,o.ILogService),y(3,o.IUniverInstanceService)],j);function A(){return{revealed:!0,findString:"",replaceRevealed:!1,matchesPosition:0,matchesCount:0}}class te{constructor(){u(this,"_stateUpdates$",new O.Subject);u(this,"stateUpdates$",this._stateUpdates$.asObservable());u(this,"_state$",new O.BehaviorSubject(A()));u(this,"state$",this._state$.asObservable());u(this,"_findString","");u(this,"_revealed",!1);u(this,"_replaceRevealed",!1);u(this,"_matchesPosition",0);u(this,"_matchesCount",0)}get state(){return this._state$.getValue()}get findString(){return this._findString}changeState(e){let r=!1;const i={};typeof e.findString<"u"&&e.findString!==this._findString&&(this._findString=e.findString,i.findString=this._findString,r=!0),typeof e.revealed<"u"&&e.revealed!==this._revealed&&(this._revealed=e.revealed,i.revealed=e.revealed,r=!0),typeof e.replaceRevealed<"u"&&e.replaceRevealed!==this._replaceRevealed&&(this._replaceRevealed=e.replaceRevealed,i.replaceRevealed=e.replaceRevealed,r=!0),typeof e.matchesCount<"u"&&e.matchesCount!==this._matchesCount&&(this._matchesCount=e.matchesCount,i.matchesCount=e.matchesCount,r=!0),typeof e.matchesPosition<"u"&&e.matchesPosition!==this._matchesPosition&&(this._matchesPosition=e.matchesPosition,i.matchesPosition=e.matchesPosition,r=!0),r&&(this._stateUpdates$.next(i),this._state$.next({findString:this._findString,revealed:this._revealed,replaceRevealed:this._replaceRevealed,matchesCount:this._matchesCount,matchesPosition:this._matchesPosition}))}}let F=class extends o.Disposable{constructor(e,r,i){super();u(this,"_providers",new Set);u(this,"_state",new te);u(this,"_model");this._injector=e,this._univerInstanceService=r,this._logService=i}get stateUpdates$(){return this._state.stateUpdates$}get state$(){return this._state.state$}changeFindString(e){this._state.changeState({findString:e})}moveToNextMatch(){var e;this._model&&((e=this._model)==null||e.moveToNextMatch())}moveToPreviousMatch(){var e;this._model&&((e=this._model)==null||e.moveToPreviousMatch())}replace(){return!0}replaceAll(){return!0}revealReplace(){this._state.changeState({replaceRevealed:!0})}disposeModel(){var e;(e=this._model)==null||e.dispose(),this._model=null}start(){if(this._providers.size===0)return!1;this._model=this._injector.createInstance(j,this._state,this._providers);const e=A();return e.revealed=!0,this._state.changeState(e),!0}end(){return this._state.changeState({revealed:!1,replaceRevealed:!1}),!0}registerFindReplaceProvider(e){return this._providers.add(e),o.toDisposable(()=>this._providers.delete(e))}};F=U([y(0,v.Inject(v.Injector)),y(1,o.IUniverInstanceService),y(2,o.ILogService)],F);const b={id:"ui.operation.open-find-dialog",type:o.CommandType.OPERATION,handler:t=>(t.get(x).start(),!0)},w={id:"ui.operation.open-replace-dialog",type:o.CommandType.OPERATION,handler:t=>(t.get(x).start(),!0)},ie={id:"ui.operation.toggle-replace-dialog",type:o.CommandType.OPERATION,handler:t=>(t.get(x),!0)},L={id:"ui.operation.close-find-replace-dialog",type:o.CommandType.OPERATION,handler:t=>!0},V={type:o.CommandType.OPERATION,id:"ui.operation.go-to-next-match",handler:t=>(t.get(x).moveToNextMatch(),!0)},B={type:o.CommandType.OPERATION,id:"ui.operation.go-to-previous-match",handler:t=>(t.get(x).moveToPreviousMatch(),!0)},R="FIND_REPLACE_ACTIVATED";var K={exports:{}},C={};/**
1
+ (function(c,o){typeof exports=="object"&&typeof module<"u"?o(exports,require("@univerjs/core"),require("@wendellhu/redi"),require("@univerjs/ui"),require("rxjs"),require("react"),require("@univerjs/design"),require("@wendellhu/redi/react-bindings")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@wendellhu/redi","@univerjs/ui","rxjs","react","@univerjs/design","@wendellhu/redi/react-bindings"],o):(c=typeof globalThis<"u"?globalThis:c||self,o(c.UniverFindReplace={},c.UniverCore,c["@wendellhu/redi"],c.UniverUi,c.rxjs,c.React,c.UniverDesign,c["@wendellhu/redi/react-bindings"]))})(this,function(c,o,v,h,O,p,_,T){"use strict";var Fe=Object.defineProperty;var be=(c,o,v)=>o in c?Fe(c,o,{enumerable:!0,configurable:!0,writable:!0,value:v}):c[o]=v;var u=(c,o,v)=>(be(c,typeof o!="symbol"?o+"":o,v),v);var g=function(){return g=Object.assign||function(t){for(var e,r=1,i=arguments.length;r<i;r++){e=arguments[r];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])}return t},g.apply(this,arguments)},z=function(t,e){var r={};for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&e.indexOf(i)<0&&(r[i]=t[i]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,i=Object.getOwnPropertySymbols(t);n<i.length;n++)e.indexOf(i[n])<0&&Object.prototype.propertyIsEnumerable.call(t,i[n])&&(r[i[n]]=t[i[n]]);return r},E=p.forwardRef(function(t,e){var r=t.icon,i=t.id,n=t.className,a=t.extend,s=z(t,["icon","id","className","extend"]),l="univerjs-icon univerjs-icon-".concat(i," ").concat(n||"").trim(),m=p.useRef("_".concat(Y()));return D(r,"".concat(i),{defIds:r.defIds,idSuffix:m.current},g({ref:e,className:l},s),a)});function D(t,e,r,i,n){return p.createElement(t.tag,g(g({key:e},Z(t,r,n)),i),(J(t,r).children||[]).map(function(a,s){return D(a,"".concat(e,"-").concat(t.tag,"-").concat(s),r,void 0,n)}))}function Z(t,e,r){var i=g({},t.attrs);r!=null&&r.colorChannel1&&i.fill==="colorChannel1"&&(i.fill=r.colorChannel1);var n=e.defIds;return!n||n.length===0||(t.tag==="use"&&i["xlink:href"]&&(i["xlink:href"]=i["xlink:href"]+e.idSuffix),Object.entries(i).forEach(function(a){var s=a[0],l=a[1];typeof l=="string"&&(i[s]=l.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))})),i}function J(t,e){var r,i=e.defIds;return!i||i.length===0?t:t.tag==="defs"&&(!((r=t.children)===null||r===void 0)&&r.length)?g(g({},t),{children:t.children.map(function(n){return typeof n.attrs.id=="string"&&i&&i.indexOf(n.attrs.id)>-1?g(g({},n),{attrs:g(g({},n.attrs),{id:n.attrs.id+e.idSuffix})}):n})}):t}function Y(){return Math.random().toString(36).substring(2,8)}E.displayName="UniverIcon";var Q={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"mask",attrs:{id:"mask0_217_40",style:{"mask-type":"alpha"},width:17,height:17,x:0,y:0,maskUnits:"userSpaceOnUse"},children:[{tag:"path",attrs:{fill:"#D9D9D9",d:"M0.9 0.09H16.9V16.09H0.9z"}}]},{tag:"g",attrs:{mask:"url(#mask0_217_40)"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M2.39551 7.37266C2.39551 4.18105 4.98281 1.59375 8.17441 1.59375C11.366 1.59375 13.9533 4.18105 13.9533 7.37266C13.9533 8.72342 13.4898 9.96603 12.7133 10.95L15.1964 13.4331C15.4619 13.6986 15.4619 14.1291 15.1964 14.3946C14.9309 14.6601 14.5004 14.6601 14.2349 14.3946L11.7518 11.9115C10.7678 12.6881 9.52525 13.1516 8.17441 13.1516C4.98281 13.1516 2.39551 10.5642 2.39551 7.37266ZM8.17441 2.95349C5.73378 2.95349 3.75525 4.93202 3.75525 7.37266C3.75525 9.81333 5.73378 11.7918 8.17441 11.7918C10.6151 11.7918 12.5936 9.81333 12.5936 7.37266C12.5936 4.93202 10.6151 2.95349 8.17441 2.95349Z",fillRule:"evenodd",clipRule:"evenodd"}}]}]},N=p.forwardRef(function(t,e){return p.createElement(E,Object.assign({},t,{id:"search-single-16",ref:e,icon:Q}))});N.displayName="SearchSingle16";const X=N;var $=Object.defineProperty,q=Object.getOwnPropertyDescriptor,U=(t,e,r,i)=>{for(var n=i>1?void 0:i?q(e,r):e,a=t.length-1,s;a>=0;a--)(s=t[a])&&(n=(i?s(e,r,n):s(n))||n);return i&&n&&$(e,r,n),n},M=(t,e)=>(r,i)=>e(r,i,t);class ee extends o.Disposable{}const x=v.createIdentifier("univer.find-replace.service");let j=class extends o.Disposable{constructor(e,r,i,n){super();u(this,"_matchPositionFindModel",null);u(this,"_findModels",[]);u(this,"_matches",[]);u(this,"_positionModel",null);this._state=e,this._providers=r,this._logService=i,this._univerInstanceService=n,this._state.stateUpdates$.subscribe(a=>{typeof a.findString<"u"&&(a.findString?this.find():this._cancelFinding())})}async find(){this._cancelFinding();const e=Array.from(this._providers),r=this._findModels=(await Promise.all(e.map(a=>a.find({text:this._state.findString})))).flat(),i=r.map(a=>a.getMatches()).flat();if(this._matches=i,!i.length)return{results:[]};const n=this._moveToInitialMatch(r,i);return this._state.changeState({matchesCount:i.length,matchesPosition:n+1}),{results:i}}moveToNextMatch(){if(!this._positionModel)return;const e=this._findModels.length===1,r=this._positionModel.moveToNextMatch(e);if(r){const i=this._matches.findIndex(n=>n===r);this._state.changeState({matchesPosition:i+1})}else{const i=this._findModels.findIndex(l=>l===this._positionModel),n=this._findModels[(i+1)%this._findModels.length],a=n.moveToNextMatch(),s=this._matches.findIndex(l=>l===a);this._positionModel=n,this._state.changeState({matchesPosition:s+1})}}moveToPreviousMatch(){if(!this._positionModel)return;const e=this._findModels.length===1,r=this._positionModel.moveToPreviousMatch(e);if(r){const i=this._matches.findIndex(n=>n===r);this._state.changeState({matchesPosition:i+1})}else{const i=this._findModels.findIndex(l=>l===this._positionModel),n=this._findModels[(i-1+this._findModels.length)%this._findModels.length],a=n.moveToPreviousMatch(),s=this._matches.findIndex(l=>l===a);this._positionModel=n,this._state.changeState({matchesPosition:s+1})}}_moveToInitialMatch(e,r){var l;const i=(l=this._univerInstanceService.getFocusedUniverInstance())==null?void 0:l.getUnitId();if(!i)return-1;const n=e.find(m=>m.unitId===i);if(n){this._positionModel=n;const m=n.moveToNextMatch();return r.findIndex(I=>I===m)}this._positionModel=e[0];const a=this._positionModel.moveToNextMatch();return this._matches.findIndex(m=>m===a)}_cancelFinding(){this._providers.forEach(e=>e.cancel()),this._state.changeState({matchesCount:0,matchesPosition:0})}};j=U([M(2,o.ILogService),M(3,o.IUniverInstanceService)],j);function w(){return{revealed:!0,findString:"",replaceRevealed:!1,matchesPosition:0,matchesCount:0}}class te{constructor(){u(this,"_stateUpdates$",new O.Subject);u(this,"stateUpdates$",this._stateUpdates$.asObservable());u(this,"_state$",new O.BehaviorSubject(w()));u(this,"state$",this._state$.asObservable());u(this,"_findString","");u(this,"_revealed",!1);u(this,"_replaceRevealed",!1);u(this,"_matchesPosition",0);u(this,"_matchesCount",0)}get state(){return this._state$.getValue()}get findString(){return this._findString}changeState(e){let r=!1;const i={};typeof e.findString<"u"&&e.findString!==this._findString&&(this._findString=e.findString,i.findString=this._findString,r=!0),typeof e.revealed<"u"&&e.revealed!==this._revealed&&(this._revealed=e.revealed,i.revealed=e.revealed,r=!0),typeof e.replaceRevealed<"u"&&e.replaceRevealed!==this._replaceRevealed&&(this._replaceRevealed=e.replaceRevealed,i.replaceRevealed=e.replaceRevealed,r=!0),typeof e.matchesCount<"u"&&e.matchesCount!==this._matchesCount&&(this._matchesCount=e.matchesCount,i.matchesCount=e.matchesCount,r=!0),typeof e.matchesPosition<"u"&&e.matchesPosition!==this._matchesPosition&&(this._matchesPosition=e.matchesPosition,i.matchesPosition=e.matchesPosition,r=!0),r&&(this._stateUpdates$.next(i),this._state$.next({findString:this._findString,revealed:this._revealed,replaceRevealed:this._replaceRevealed,matchesCount:this._matchesCount,matchesPosition:this._matchesPosition}))}}let F=class extends o.Disposable{constructor(e,r,i){super();u(this,"_providers",new Set);u(this,"_state",new te);u(this,"_model");this._injector=e,this._univerInstanceService=r,this._logService=i}get stateUpdates$(){return this._state.stateUpdates$}get state$(){return this._state.state$}changeFindString(e){this._state.changeState({findString:e})}moveToNextMatch(){var e;this._model&&((e=this._model)==null||e.moveToNextMatch())}moveToPreviousMatch(){var e;this._model&&((e=this._model)==null||e.moveToPreviousMatch())}replace(){return!0}replaceAll(){return!0}revealReplace(){this._state.changeState({replaceRevealed:!0})}disposeModel(){var e;(e=this._model)==null||e.dispose(),this._model=null}start(){if(this._providers.size===0)return!1;this._model=this._injector.createInstance(j,this._state,this._providers);const e=w();return e.revealed=!0,this._state.changeState(e),!0}end(){return this._state.changeState({revealed:!1,replaceRevealed:!1}),!0}registerFindReplaceProvider(e){return this._providers.add(e),o.toDisposable(()=>this._providers.delete(e))}};F=U([M(0,v.Inject(v.Injector)),M(1,o.IUniverInstanceService),M(2,o.ILogService)],F);const b={id:"ui.operation.open-find-dialog",type:o.CommandType.OPERATION,handler:t=>(t.get(x).start(),!0)},A={id:"ui.operation.open-replace-dialog",type:o.CommandType.OPERATION,handler:t=>(t.get(x).start(),!0)},ie={id:"ui.operation.toggle-replace-dialog",type:o.CommandType.OPERATION,handler:t=>(t.get(x),!0)},L={id:"ui.operation.close-find-replace-dialog",type:o.CommandType.OPERATION,handler:t=>!0},V={type:o.CommandType.OPERATION,id:"ui.operation.go-to-next-match",handler:t=>(t.get(x).moveToNextMatch(),!0)},B={type:o.CommandType.OPERATION,id:"ui.operation.go-to-previous-match",handler:t=>(t.get(x).moveToPreviousMatch(),!0)},R="FIND_REPLACE_ACTIVATED";var K={exports:{}},y={};/**
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=p,re=Symbol.for("react.element"),ae=Symbol.for("react.fragment"),oe=Object.prototype.hasOwnProperty,se=ne.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,ce={key:!0,ref:!0,__self:!0,__source:!0};function k(t,e,r){var i,n={},a=null,s=null;r!==void 0&&(a=""+r),e.key!==void 0&&(a=""+e.key),e.ref!==void 0&&(s=e.ref);for(i in e)oe.call(e,i)&&!ce.hasOwnProperty(i)&&(n[i]=e[i]);if(t&&t.defaultProps)for(i in e=t.defaultProps,e)n[i]===void 0&&(n[i]=e[i]);return{$$typeof:re,type:t,key:a,ref:s,props:n,_owner:se.current}}C.Fragment=ae,C.jsx=k,C.jsxs=k,K.exports=C;var f=K.exports;const G={findReplaceExpandContainer:"univer-find-replace-expand-container"};function le(){const t=T.useDependency(x),e=T.useDependency(o.LocaleService),r=T.useDependency(h.LayoutService),[i,n]=p.useState(""),[a,s]=p.useState(""),l=p.useRef(null),m=_.useObservable(t.state$,!0),{matchesCount:I,matchesPosition:M}=m,Ce=p.useCallback(()=>t.revealReplace(),[t]),Pe=p.useCallback(d=>t.changeFindString(d),[t]),Oe=p.useCallback(d=>{n(d),Pe(d)},[t]),z=p.useCallback(d=>{s(d)},[t]);p.useEffect(()=>{let d;return l.current&&(d=r.registerContainer(l.current)),()=>d==null?void 0:d.dispose()},[l.current]);function Te(){return f.jsxs(p.Fragment,{children:[f.jsx(_.InputWithSlot,{autoFocus:!0,placeholder:e.t("univer.find-replace.dialog.find-placeholder"),slot:f.jsx(_.Pager,{loop:!0,value:M,total:I,onChange:d=>{M===I&&d===1?t.moveToNextMatch():M===1&&d===I||d<M?t.moveToPreviousMatch():t.moveToNextMatch()}}),value:i,onChange:d=>Oe(d)}),f.jsx("div",{className:G.findReplaceExpandContainer,children:f.jsx(_.Button,{type:"text",size:"small",onClick:Ce,children:e.t("univer.find-replace.dialog.advanced-finding")})})]})}function je(){return f.jsxs(p.Fragment,{children:[f.jsx(_.FormLayout,{label:e.t("univer.find-replace.dialog.find"),children:f.jsx(_.Input,{placeholder:e.t("univer.find-replace.dialog.find-placeholder"),autoFocus:!0,value:i,onChange:d=>z(d)})}),f.jsx(_.FormLayout,{label:e.t("univer.find-replace.dialog.replace"),children:f.jsx(_.Input,{placeholder:e.t("univer.find-replace.dialog.replace-placeholder"),value:a,onChange:d=>z(d)})}),f.jsx(_.FormLayout,{label:e.t("univer.find-replace.dialog.find-range"),children:f.jsx(_.Select,{value:"123",onChange:()=>{}})}),f.jsx(_.Button,{type:"primary",children:e.t("univer.find-replace.dialog.find")}),f.jsx(_.Button,{children:e.t("univer.find-replace.dialog.replace")}),f.jsx(_.Button,{children:e.t("univer.find-replace.dialog.replace-all")})]})}return f.jsx("div",{className:G.findReplaceDialogContainer,ref:l,children:m.replaceRevealed?je():Te()})}function de(t){return{id:b.id,icon:"SearchIcon",tooltip:"toolbar.find-replace",group:h.MenuGroup.TOOLBAR_OTHERS,type:h.MenuItemType.BUTTON,positions:[h.MenuPosition.TOOLBAR_START],hidden$:h.getMenuHiddenObservable(t,o.UniverInstanceType.SHEET)}}const he={id:b.id,description:"shortcut.find-replace.open-find-dialog",binding:h.KeyCode.F|h.MetaKeys.CTRL_COMMAND,group:"4_find-replace",preconditions(t){return!t.getContextValue(R)}},ue={id:w.id,description:"shortcut.find-replace.open-replace-dialog",binding:h.KeyCode.H|h.MetaKeys.CTRL_COMMAND,group:"4_find-replace",preconditions(t){return!t.getContextValue(R)}},pe={id:L.id,description:"shortcut.find-replace.close-dialog",binding:h.KeyCode.ESC,group:"4_find-replace",priority:1e3,preconditions(t){return!!t.getContextValue(R)}},fe={id:V.id,description:"shortcut.find-replace.go-to-next-find-match",binding:h.KeyCode.ENTER,group:"4_find-replace",priority:1e3,preconditions(t){return!!t.getContextValue(R)}},ve={id:B.id,description:"shortcut.find-replace.go-to-previous-find-match",binding:h.KeyCode.ENTER|h.MetaKeys.SHIFT,group:"4_find-replace",priority:1e3,preconditions(t){return!!t.getContextValue(R)}};var _e=Object.defineProperty,ge=Object.getOwnPropertyDescriptor,me=(t,e,r,i)=>{for(var n=i>1?void 0:i?ge(e,r):e,a=t.length-1,s;a>=0;a--)(s=t[a])&&(n=(i?s(e,r,n):s(n))||n);return i&&n&&_e(e,r,n),n},S=(t,e)=>(r,i)=>e(r,i,t);const W="DESKTOP_FIND_REPLACE_DIALOG";let P=class extends o.RxDisposable{constructor(t,e,r,i,n,a,s,l,m,I){super(),this._menuService=t,this._shortcutService=e,this._commandService=r,this._findReplaceService=i,this._dialogService=n,this._contextService=a,this._focusService=s,this._localeService=l,this._componentManager=m,this._injector=I,this._initOperations(),this._initUI(),this._initShortcuts()}_initOperations(){[L,b,w,ie,V,B].forEach(t=>{this.disposeWithMe(this._commandService.registerCommand(t))})}_initUI(){[de].forEach(t=>{this.disposeWithMe(this._menuService.addMenuItem(this._injector.invoke(t)))}),this.disposeWithMe(this._componentManager.register("FindReplaceDialog",le)),this.disposeWithMe(this._componentManager.register("SearchIcon",Z)),this._findReplaceService.stateUpdates$.pipe(O.takeUntil(this.dispose$)).subscribe(t=>{t.revealed===!0?this._openPanel():t.revealed===!1&&this._closePanel()})}_initShortcuts(){[ue,he,pe,ve,fe].forEach(t=>{this.disposeWithMe(this._shortcutService.registerShortcut(t))})}_openPanel(){this._dialogService.open({id:W,draggable:!0,width:350,title:{title:this._localeService.t("univer.find-replace.dialog.title")},children:{label:"FindReplaceDialog"},onClose:()=>this._closePanel()}),this._contextService.setContextValue(R,!0)}_closePanel(){this._dialogService.close(W),this._contextService.setContextValue(R,!1),this._focusService.forceFocus(),this._findReplaceService.end()}};P=me([o.OnLifecycle(o.LifecycleStages.Rendered,P),S(0,h.IMenuService),S(1,h.IShortcutService),S(2,o.ICommandService),S(3,x),S(4,h.IDialogService),S(5,o.IContextService),S(6,h.IFocusService),S(7,v.Inject(o.LocaleService)),S(8,v.Inject(h.ComponentManager)),S(9,v.Inject(v.Injector))],P);const Se={univer:{"find-replace":{dialog:{title:"查找",find:"查找",replace:"替换","replace-all":"替换全部","find-range":"查找范围","find-placeholder":"输入查找内容","advanced-finding":"替换 / 高级查找","replace-placeholder":"输入替换内容"}}}};var xe=Object.defineProperty,Re=Object.getOwnPropertyDescriptor,Ie=(t,e,r,i)=>{for(var n=i>1?void 0:i?Re(e,r):e,a=t.length-1,s;a>=0;a--)(s=t[a])&&(n=(i?s(e,r,n):s(n))||n);return i&&n&&xe(e,r,n),n},Me=(t,e)=>(r,i)=>e(r,i,t);const ye="FIND_REPLACE";c.UniverFindReplacePlugin=class extends o.Plugin{constructor(e,r){super(ye),this._injector=e,this._localeService=r,this._localeService.load({zhCN:Se})}onStarting(e){[[P],[x,{useClass:F}]].forEach(r=>{e.add(r)})}},c.UniverFindReplacePlugin=Ie([Me(1,v.Inject(o.LocaleService))],c.UniverFindReplacePlugin),c.FindModel=ee,c.IFindReplaceService=x,Object.defineProperty(c,Symbol.toStringTag,{value:"Module"})});
9
+ */var ne=p,re=Symbol.for("react.element"),ae=Symbol.for("react.fragment"),oe=Object.prototype.hasOwnProperty,se=ne.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,ce={key:!0,ref:!0,__self:!0,__source:!0};function k(t,e,r){var i,n={},a=null,s=null;r!==void 0&&(a=""+r),e.key!==void 0&&(a=""+e.key),e.ref!==void 0&&(s=e.ref);for(i in e)oe.call(e,i)&&!ce.hasOwnProperty(i)&&(n[i]=e[i]);if(t&&t.defaultProps)for(i in e=t.defaultProps,e)n[i]===void 0&&(n[i]=e[i]);return{$$typeof:re,type:t,key:a,ref:s,props:n,_owner:se.current}}y.Fragment=ae,y.jsx=k,y.jsxs=k,K.exports=y;var f=K.exports;const G={findReplaceExpandContainer:"univer-find-replace-expand-container"};function le(){const t=T.useDependency(x),e=T.useDependency(o.LocaleService),r=T.useDependency(h.LayoutService),[i,n]=p.useState(""),[a,s]=p.useState(""),l=p.useRef(null),m=_.useObservable(t.state$,!0),{matchesCount:C,matchesPosition:I}=m,ye=p.useCallback(()=>t.revealReplace(),[t]),Pe=p.useCallback(d=>t.changeFindString(d),[t]),Oe=p.useCallback(d=>{n(d),Pe(d)},[t]),W=p.useCallback(d=>{s(d)},[t]);p.useEffect(()=>{let d;return l.current&&(d=r.registerContainer(l.current)),()=>d==null?void 0:d.dispose()},[l.current]);function Te(){return f.jsxs(p.Fragment,{children:[f.jsx(_.InputWithSlot,{autoFocus:!0,placeholder:e.t("univer.find-replace.dialog.find-placeholder"),slot:f.jsx(_.Pager,{loop:!0,value:I,total:C,onChange:d=>{I===C&&d===1?t.moveToNextMatch():I===1&&d===C||d<I?t.moveToPreviousMatch():t.moveToNextMatch()}}),value:i,onChange:d=>Oe(d)}),f.jsx("div",{className:G.findReplaceExpandContainer,children:f.jsx(_.Button,{type:"text",size:"small",onClick:ye,children:e.t("univer.find-replace.dialog.advanced-finding")})})]})}function je(){return f.jsxs(p.Fragment,{children:[f.jsx(_.FormLayout,{label:e.t("univer.find-replace.dialog.find"),children:f.jsx(_.Input,{placeholder:e.t("univer.find-replace.dialog.find-placeholder"),autoFocus:!0,value:i,onChange:d=>W(d)})}),f.jsx(_.FormLayout,{label:e.t("univer.find-replace.dialog.replace"),children:f.jsx(_.Input,{placeholder:e.t("univer.find-replace.dialog.replace-placeholder"),value:a,onChange:d=>W(d)})}),f.jsx(_.FormLayout,{label:e.t("univer.find-replace.dialog.find-range"),children:f.jsx(_.Select,{value:"123",onChange:()=>{}})}),f.jsx(_.Button,{type:"primary",children:e.t("univer.find-replace.dialog.find")}),f.jsx(_.Button,{children:e.t("univer.find-replace.dialog.replace")}),f.jsx(_.Button,{children:e.t("univer.find-replace.dialog.replace-all")})]})}return f.jsx("div",{className:G.findReplaceDialogContainer,ref:l,children:m.replaceRevealed?je():Te()})}function de(t){return{id:b.id,icon:"SearchIcon",tooltip:"toolbar.find-replace",group:h.MenuGroup.TOOLBAR_OTHERS,type:h.MenuItemType.BUTTON,positions:[h.MenuPosition.TOOLBAR_START],hidden$:h.getMenuHiddenObservable(t,o.UniverInstanceType.SHEET)}}const he={id:b.id,description:"shortcut.find-replace.open-find-dialog",binding:h.KeyCode.F|h.MetaKeys.CTRL_COMMAND,group:"4_find-replace",preconditions(t){return!t.getContextValue(R)}},ue={id:A.id,description:"shortcut.find-replace.open-replace-dialog",binding:h.KeyCode.H|h.MetaKeys.CTRL_COMMAND,group:"4_find-replace",preconditions(t){return!t.getContextValue(R)}},pe={id:L.id,description:"shortcut.find-replace.close-dialog",binding:h.KeyCode.ESC,group:"4_find-replace",priority:1e3,preconditions(t){return!!t.getContextValue(R)}},fe={id:V.id,description:"shortcut.find-replace.go-to-next-find-match",binding:h.KeyCode.ENTER,group:"4_find-replace",priority:1e3,preconditions(t){return!!t.getContextValue(R)}},ve={id:B.id,description:"shortcut.find-replace.go-to-previous-find-match",binding:h.KeyCode.ENTER|h.MetaKeys.SHIFT,group:"4_find-replace",priority:1e3,preconditions(t){return!!t.getContextValue(R)}};var _e=Object.defineProperty,ge=Object.getOwnPropertyDescriptor,me=(t,e,r,i)=>{for(var n=i>1?void 0:i?ge(e,r):e,a=t.length-1,s;a>=0;a--)(s=t[a])&&(n=(i?s(e,r,n):s(n))||n);return i&&n&&_e(e,r,n),n},S=(t,e)=>(r,i)=>e(r,i,t);const H="DESKTOP_FIND_REPLACE_DIALOG";let P=class extends o.RxDisposable{constructor(t,e,r,i,n,a,s,l,m,C){super(),this._menuService=t,this._shortcutService=e,this._commandService=r,this._findReplaceService=i,this._dialogService=n,this._contextService=a,this._focusService=s,this._localeService=l,this._componentManager=m,this._injector=C,this._initOperations(),this._initUI(),this._initShortcuts()}_initOperations(){[L,b,A,ie,V,B].forEach(t=>{this.disposeWithMe(this._commandService.registerCommand(t))})}_initUI(){[de].forEach(t=>{this.disposeWithMe(this._menuService.addMenuItem(this._injector.invoke(t)))}),this.disposeWithMe(this._componentManager.register("FindReplaceDialog",le)),this.disposeWithMe(this._componentManager.register("SearchIcon",X)),this._findReplaceService.stateUpdates$.pipe(O.takeUntil(this.dispose$)).subscribe(t=>{t.revealed===!0?this._openPanel():t.revealed===!1&&this._closePanel()})}_initShortcuts(){[ue,he,pe,ve,fe].forEach(t=>{this.disposeWithMe(this._shortcutService.registerShortcut(t))})}_openPanel(){this._dialogService.open({id:H,draggable:!0,width:350,title:{title:this._localeService.t("univer.find-replace.dialog.title")},children:{label:"FindReplaceDialog"},onClose:()=>this._closePanel()}),this._contextService.setContextValue(R,!0)}_closePanel(){this._dialogService.close(H),this._contextService.setContextValue(R,!1),this._focusService.forceFocus(),this._findReplaceService.end()}};P=me([o.OnLifecycle(o.LifecycleStages.Rendered,P),S(0,h.IMenuService),S(1,h.IShortcutService),S(2,o.ICommandService),S(3,x),S(4,h.IDialogService),S(5,o.IContextService),S(6,h.IFocusService),S(7,v.Inject(o.LocaleService)),S(8,v.Inject(h.ComponentManager)),S(9,v.Inject(v.Injector))],P);const Se={univer:{"find-replace":{dialog:{title:"查找",find:"查找",replace:"替换","replace-all":"替换全部","find-range":"查找范围","find-placeholder":"输入查找内容","advanced-finding":"替换 / 高级查找","replace-placeholder":"输入替换内容"}}}};var xe=Object.defineProperty,Re=Object.getOwnPropertyDescriptor,Ce=(t,e,r,i)=>{for(var n=i>1?void 0:i?Re(e,r):e,a=t.length-1,s;a>=0;a--)(s=t[a])&&(n=(i?s(e,r,n):s(n))||n);return i&&n&&xe(e,r,n),n},Ie=(t,e)=>(r,i)=>e(r,i,t);const Me="FIND_REPLACE";c.UniverFindReplacePlugin=class extends o.Plugin{constructor(e,r){super(Me),this._injector=e,this._localeService=r,this._localeService.load({zhCN:Se})}onStarting(e){[[P],[x,{useClass:F}]].forEach(r=>{e.add(r)})}},c.UniverFindReplacePlugin=Ce([Ie(1,v.Inject(o.LocaleService))],c.UniverFindReplacePlugin),c.FindModel=ee,c.IFindReplaceService=x,Object.defineProperty(c,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@univerjs/find-replace",
3
- "version": "0.1.0-beta.3",
3
+ "version": "0.1.0-beta.4",
4
4
  "private": false,
5
5
  "description": "",
6
6
  "author": "DreamNum <developer@univer.ai>",
@@ -35,16 +35,16 @@
35
35
  "npm": ">=8.0.0"
36
36
  },
37
37
  "peerDependencies": {
38
- "@univerjs/icons": "^0.1.26",
38
+ "@univerjs/icons": "^0.1.27",
39
39
  "@wendellhu/redi": ">=0.12.13",
40
40
  "react": "^18.2.0",
41
41
  "rxjs": ">=7.0.0",
42
- "@univerjs/core": "0.1.0-beta.3",
43
- "@univerjs/ui": "0.1.0-beta.3",
44
- "@univerjs/design": "0.1.0-beta.3"
42
+ "@univerjs/design": "0.1.0-beta.4",
43
+ "@univerjs/ui": "0.1.0-beta.4",
44
+ "@univerjs/core": "0.1.0-beta.4"
45
45
  },
46
46
  "dependencies": {
47
- "@univerjs/icons": "^0.1.26"
47
+ "@univerjs/icons": "^0.1.27"
48
48
  },
49
49
  "devDependencies": {
50
50
  "@types/react": "^18.2.48",
@@ -54,10 +54,10 @@
54
54
  "typescript": "^5.3.3",
55
55
  "vite": "^5.0.12",
56
56
  "vitest": "^1.2.1",
57
- "@univerjs/core": "0.1.0-beta.3",
58
- "@univerjs/ui": "0.1.0-beta.3",
59
- "@univerjs/shared": "0.1.0-beta.3",
60
- "@univerjs/design": "0.1.0-beta.3"
57
+ "@univerjs/core": "0.1.0-beta.4",
58
+ "@univerjs/shared": "0.1.0-beta.4",
59
+ "@univerjs/ui": "0.1.0-beta.4",
60
+ "@univerjs/design": "0.1.0-beta.4"
61
61
  },
62
62
  "scripts": {
63
63
  "test": "vitest run",