@univerjs/find-replace 0.1.0-beta.4 → 0.1.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 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={};/**
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:{maskType:"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";var ne=Object.defineProperty,re=Object.getOwnPropertyDescriptor,L=(t,e,n,i)=>{for(var r=i>1?void 0:i?re(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&&ne(e,n,r),r},I=(t,e)=>(n,i)=>e(n,i,t);class oe 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=L([I(2,s.ILogService),I(3,s.IUniverInstanceService)],T);function A(){return{revealed:!0,findString:"",replaceRevealed:!1,matchesPosition:0,matchesCount:0}}class ae{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 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 ae);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=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),s.toDisposable(()=>this._providers.delete(e))}};b=L([I(0,S.Inject(S.Injector)),I(1,s.IUniverInstanceService),I(2,s.ILogService)],b);const j={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)},se={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}}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;
9
+ */var ce=p,le=Symbol.for("react.element"),de=Symbol.for("react.fragment"),ue=Object.prototype.hasOwnProperty,he=ce.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,pe={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)ue.call(e,i)&&!pe.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:le,type:t,key:o,ref:a,props:r,_owner:he.current}}y.Fragment=de;y.jsx=k;y.jsxs=k;K.exports=y;var h=K.exports;const fe="univer-find-replace-expand-container",E={findReplaceExpandContainer:fe};function ve(){const t=P.useDependency(m),e=P.useDependency(s.LocaleService),n=P.useDependency(d.ILayoutService),[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]),F=p.useCallback(l=>{a(l)},[t]);p.useEffect(()=>{let l;return c.current&&(l=n.registerContainerElement(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=>F(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=>F(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 _e(t){return{id:j.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 ge={id:j.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)}},me={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)}},Se={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)}},xe={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)}},Re={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 Ce=Object.defineProperty,Ie=Object.getOwnPropertyDescriptor,Me=(t,e,n,i)=>{for(var r=i>1?void 0:i?Ie(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&&Ce(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._layoutService=a,this._localeService=c,this._componentManager=v,this._injector=R,this._initOperations(),this._initUI(),this._initShortcuts()}_initOperations(){[B,j,w,se,V,q].forEach(t=>{this.disposeWithMe(this._commandService.registerCommand(t))})}_initUI(){[_e].forEach(t=>{this.disposeWithMe(this._menuService.addMenuItem(this._injector.invoke(t)))}),this.disposeWithMe(this._componentManager.register("FindReplaceDialog",ve)),this.disposeWithMe(this._componentManager.register("SearchIcon",$)),this._findReplaceService.stateUpdates$.pipe(O.takeUntil(this.dispose$)).subscribe(t=>{t.revealed===!0?this._openPanel():t.revealed===!1&&this._closePanel()})}_initShortcuts(){[me,ge,Se,Re,xe].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._layoutService.focus(),this._findReplaceService.end()}};M=Me([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.ILayoutService),g(7,S.Inject(s.LocaleService)),g(8,S.Inject(d.ComponentManager)),g(9,S.Inject(S.Injector))],M);const ye={univer:{"find-replace":{dialog:{title:"查找",find:"查找",replace:"替换","replace-all":"替换全部","find-range":"查找范围","find-placeholder":"输入查找内容","advanced-finding":"替换 / 高级查找","replace-placeholder":"输入替换内容"}}}};var Pe=Object.defineProperty,Oe=Object.getOwnPropertyDescriptor,Te=(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&&Pe(e,n,r),r},be=(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:ye})}onStarting(e){[[M],[m,{useClass:b}]].forEach(n=>{e.add(n)})}};exports.UniverFindReplacePlugin=Te([be(1,S.Inject(s.LocaleService))],exports.UniverFindReplacePlugin);exports.FindModel=oe;exports.IFindReplaceService=m;
package/lib/es/index.js CHANGED
@@ -1,12 +1,12 @@
1
- var le = Object.defineProperty;
2
- var de = (t, e, n) => e in t ? le(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n;
3
- var l = (t, e, n) => (de(t, typeof e != "symbol" ? e + "" : e, n), n);
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 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
- import { Subject as Ee, BehaviorSubject as Fe, takeUntil as je } from "rxjs";
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";
1
+ var de = Object.defineProperty;
2
+ var he = (t, e, n) => e in t ? de(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n;
3
+ var l = (t, e, n) => (he(t, typeof e != "symbol" ? e + "" : e, n), n);
4
+ import { Disposable as E, ILogService as B, IUniverInstanceService as G, toDisposable as ue, CommandType as m, LocaleService as j, UniverInstanceType as pe, OnLifecycle as fe, LifecycleStages as _e, RxDisposable as ve, ICommandService as ge, IContextService as me, Plugin as Se } from "@univerjs/core";
5
+ import { createIdentifier as xe, Inject as S, Injector as H } from "@wendellhu/redi";
6
+ import { ILayoutService as W, MenuGroup as Re, MenuItemType as Me, MenuPosition as Ie, getMenuHiddenObservable as Ce, KeyCode as R, MetaKeys as F, ComponentManager as Oe, IMenuService as Pe, IShortcutService as ye, IDialogService as Te } from "@univerjs/ui";
7
+ import { Subject as be, BehaviorSubject as Ee, takeUntil as je } from "rxjs";
8
+ import Fe, { forwardRef as k, useRef as z, createElement as K, useState as $, useCallback as M, useEffect as De, Fragment as A } from "react";
9
+ import { useObservable as Ne, InputWithSlot as $e, Pager as Ae, Button as I, FormLayout as P, Input as U, Select as Ue } 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
- }, we = function(t, e) {
20
+ }, Le = 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,16 +25,16 @@ 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 = 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
- return q(n, "".concat(i), { defIds: n.defIds, idSuffix: h.current }, u({ ref: e, className: s }, a), o);
28
+ }, q = k(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 = z("_".concat(Be()));
30
+ return Z(n, "".concat(i), { defIds: n.defIds, idSuffix: h.current }, u({ ref: e, className: s }, a), o);
31
31
  });
32
- function q(t, e, n, i, r) {
33
- return z(t.tag, u(u({ key: e }, Ve(t, n, r)), i), (Be(t, n).children || []).map(function(o, a) {
34
- return q(o, "".concat(e, "-").concat(t.tag, "-").concat(a), n, void 0, r);
32
+ function Z(t, e, n, i, r) {
33
+ return K(t.tag, u(u({ key: e }, we(t, n, r)), i), (Ve(t, n).children || []).map(function(o, a) {
34
+ return Z(o, "".concat(e, "-").concat(t.tag, "-").concat(a), n, void 0, r);
35
35
  }));
36
36
  }
37
- function Ve(t, e, n) {
37
+ function we(t, e, n) {
38
38
  var i = u({}, t.attrs);
39
39
  n != null && n.colorChannel1 && i.fill === "colorChannel1" && (i.fill = n.colorChannel1);
40
40
  var r = e.defIds;
@@ -43,17 +43,17 @@ function Ve(t, e, n) {
43
43
  typeof s == "string" && (i[a] = s.replace(/url\(#(.*)\)/, "url(#$1".concat(e.idSuffix, ")")));
44
44
  })), i;
45
45
  }
46
- function Be(t, e) {
46
+ function Ve(t, e) {
47
47
  var n, i = e.defIds;
48
48
  return !i || i.length === 0 ? t : t.tag === "defs" && (!((n = t.children) === null || n === void 0) && n.length) ? u(u({}, t), { children: t.children.map(function(r) {
49
49
  return typeof r.attrs.id == "string" && i && i.indexOf(r.attrs.id) > -1 ? u(u({}, r), { attrs: u(u({}, r.attrs), { id: r.attrs.id + e.idSuffix }) }) : r;
50
50
  }) }) : t;
51
51
  }
52
- function Ge() {
52
+ function Be() {
53
53
  return Math.random().toString(36).substring(2, 8);
54
54
  }
55
- K.displayName = "UniverIcon";
56
- var He = {
55
+ q.displayName = "UniverIcon";
56
+ var Ge = {
57
57
  tag: "svg",
58
58
  attrs: { fill: "none", viewBox: "0 0 17 17", width: "1em", height: "1em" },
59
59
  children: [
@@ -61,7 +61,7 @@ var He = {
61
61
  tag: "mask",
62
62
  attrs: {
63
63
  id: "mask0_217_40",
64
- style: { "mask-type": "alpha" },
64
+ style: { maskType: "alpha" },
65
65
  width: 17,
66
66
  height: 17,
67
67
  x: 0,
@@ -91,23 +91,22 @@ var He = {
91
91
  ]
92
92
  }
93
93
  ]
94
- }, Z = W(function(t, e) {
95
- return z(K, Object.assign({}, t, {
94
+ }, J = k(function(t, e) {
95
+ return K(q, Object.assign({}, t, {
96
96
  id: "search-single-16",
97
97
  ref: e,
98
- icon: He
98
+ icon: Ge
99
99
  }));
100
100
  });
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--)
101
+ J.displayName = "SearchSingle16";
102
+ var He = Object.defineProperty, We = Object.getOwnPropertyDescriptor, Y = (t, e, n, i) => {
103
+ for (var r = i > 1 ? void 0 : i ? We(e, n) : e, o = t.length - 1, a; o >= 0; o--)
105
104
  (a = t[o]) && (r = (i ? a(e, n, r) : a(r)) || r);
106
- return i && r && ke(e, n, r), r;
105
+ return i && r && He(e, n, r), r;
107
106
  }, x = (t, e) => (n, i) => e(n, i, t);
108
- class Pt extends E {
107
+ class Ct extends E {
109
108
  }
110
- const f = Se("univer.find-replace.service");
109
+ const f = xe("univer.find-replace.service");
111
110
  let T = class extends E {
112
111
  constructor(e, n, i, r) {
113
112
  super();
@@ -190,11 +189,11 @@ let T = class extends E {
190
189
  });
191
190
  }
192
191
  };
193
- T = J([
192
+ T = Y([
194
193
  x(2, B),
195
194
  x(3, G)
196
195
  ], T);
197
- function Y() {
196
+ function Q() {
198
197
  return {
199
198
  revealed: !0,
200
199
  findString: "",
@@ -203,11 +202,11 @@ function Y() {
203
202
  matchesCount: 0
204
203
  };
205
204
  }
206
- class Ke {
205
+ class ke {
207
206
  constructor() {
208
- l(this, "_stateUpdates$", new Ee());
207
+ l(this, "_stateUpdates$", new be());
209
208
  l(this, "stateUpdates$", this._stateUpdates$.asObservable());
210
- l(this, "_state$", new Fe(Y()));
209
+ l(this, "_state$", new Ee(Q()));
211
210
  l(this, "state$", this._state$.asObservable());
212
211
  // TODO@wzhudev: put all state properties here
213
212
  l(this, "_findString", "");
@@ -238,7 +237,7 @@ let b = class extends E {
238
237
  constructor(e, n, i) {
239
238
  super();
240
239
  l(this, "_providers", /* @__PURE__ */ new Set());
241
- l(this, "_state", new Ke());
240
+ l(this, "_state", new ke());
242
241
  l(this, "_model");
243
242
  this._injector = e, this._univerInstanceService = n, this._logService = i;
244
243
  }
@@ -278,17 +277,17 @@ let b = class extends E {
278
277
  if (this._providers.size === 0)
279
278
  return !1;
280
279
  this._model = this._injector.createInstance(T, this._state, this._providers);
281
- const e = Y();
280
+ const e = Q();
282
281
  return e.revealed = !0, this._state.changeState(e), !0;
283
282
  }
284
283
  end() {
285
284
  return this._state.changeState({ revealed: !1, replaceRevealed: !1 }), !0;
286
285
  }
287
286
  registerFindReplaceProvider(e) {
288
- return this._providers.add(e), he(() => this._providers.delete(e));
287
+ return this._providers.add(e), ue(() => this._providers.delete(e));
289
288
  }
290
289
  };
291
- b = J([
290
+ b = Y([
292
291
  x(0, S(H)),
293
292
  x(1, G),
294
293
  x(2, B)
@@ -297,28 +296,28 @@ const D = {
297
296
  id: "ui.operation.open-find-dialog",
298
297
  type: m.OPERATION,
299
298
  handler: (t) => (t.get(f).start(), !0)
300
- }, Q = {
299
+ }, X = {
301
300
  id: "ui.operation.open-replace-dialog",
302
301
  type: m.OPERATION,
303
302
  handler: (t) => (t.get(f).start(), !0)
304
- }, qe = {
303
+ }, ze = {
305
304
  id: "ui.operation.toggle-replace-dialog",
306
305
  type: m.OPERATION,
307
306
  handler: (t) => (t.get(f), !0)
308
- }, X = {
307
+ }, ee = {
309
308
  id: "ui.operation.close-find-replace-dialog",
310
309
  type: m.OPERATION,
311
310
  handler: (t) => !0
312
- }, ee = {
311
+ }, te = {
313
312
  type: m.OPERATION,
314
313
  id: "ui.operation.go-to-next-match",
315
314
  handler: (t) => (t.get(f).moveToNextMatch(), !0)
316
- }, te = {
315
+ }, ie = {
317
316
  type: m.OPERATION,
318
317
  id: "ui.operation.go-to-previous-match",
319
318
  handler: (t) => (t.get(f).moveToPreviousMatch(), !0)
320
- }, v = "FIND_REPLACE_ACTIVATED";
321
- var ie = { exports: {} }, O = {};
319
+ }, _ = "FIND_REPLACE_ACTIVATED";
320
+ var ne = { exports: {} }, O = {};
322
321
  /**
323
322
  * @license React
324
323
  * react-jsx-runtime.production.min.js
@@ -328,34 +327,34 @@ var ie = { exports: {} }, O = {};
328
327
  * This source code is licensed under the MIT license found in the
329
328
  * LICENSE file in the root directory of this source tree.
330
329
  */
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 };
332
- function ne(t, e, n) {
330
+ var Ke = Fe, qe = Symbol.for("react.element"), Ze = Symbol.for("react.fragment"), Je = Object.prototype.hasOwnProperty, Ye = Ke.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, Qe = { key: !0, ref: !0, __self: !0, __source: !0 };
331
+ function re(t, e, n) {
333
332
  var i, r = {}, o = null, a = null;
334
333
  n !== void 0 && (o = "" + n), e.key !== void 0 && (o = "" + e.key), e.ref !== void 0 && (a = e.ref);
335
334
  for (i in e)
336
- Qe.call(e, i) && !et.hasOwnProperty(i) && (r[i] = e[i]);
335
+ Je.call(e, i) && !Qe.hasOwnProperty(i) && (r[i] = e[i]);
337
336
  if (t && t.defaultProps)
338
337
  for (i in e = t.defaultProps, e)
339
338
  r[i] === void 0 && (r[i] = e[i]);
340
- return { $$typeof: Je, type: t, key: o, ref: a, props: r, _owner: Xe.current };
339
+ return { $$typeof: qe, type: t, key: o, ref: a, props: r, _owner: Ye.current };
341
340
  }
342
- O.Fragment = Ye;
343
- O.jsx = ne;
344
- O.jsxs = ne;
345
- ie.exports = O;
346
- var d = ie.exports;
347
- const tt = "univer-find-replace-expand-container", L = {
348
- findReplaceExpandContainer: tt
341
+ O.Fragment = Ze;
342
+ O.jsx = re;
343
+ O.jsxs = re;
344
+ ne.exports = O;
345
+ var d = ne.exports;
346
+ const Xe = "univer-find-replace-expand-container", L = {
347
+ findReplaceExpandContainer: Xe
349
348
  };
350
- function it() {
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
+ function et() {
350
+ const t = y(f), e = y(j), n = y(W), [i, r] = $(""), [o, a] = $(""), s = z(null), h = Ne(t.state$, !0), { matchesCount: v, matchesPosition: g } = h, oe = M(() => t.revealReplace(), [t]), ae = M(
352
351
  (c) => t.changeFindString(c),
353
352
  // FIXME@wzhudev: this throttle function has no leading and taling config hence has some problems
354
353
  // throttle((findString: string) => findReplaceService.changeFindString(findString), FIND_THROTTLE_TIME),
355
354
  [t]
356
- ), ae = M(
355
+ ), se = M(
357
356
  (c) => {
358
- r(c), oe(c);
357
+ r(c), ae(c);
359
358
  },
360
359
  [t]
361
360
  ), N = M(
@@ -364,36 +363,36 @@ function it() {
364
363
  },
365
364
  [t]
366
365
  );
367
- Ne(() => {
366
+ De(() => {
368
367
  let c;
369
- return s.current && (c = n.registerContainer(s.current)), () => c == null ? void 0 : c.dispose();
368
+ return s.current && (c = n.registerContainerElement(s.current)), () => c == null ? void 0 : c.dispose();
370
369
  }, [s.current]);
371
- function se() {
370
+ function ce() {
372
371
  return /* @__PURE__ */ d.jsxs(A, { children: [
373
372
  /* @__PURE__ */ d.jsx(
374
- Ae,
373
+ $e,
375
374
  {
376
375
  autoFocus: !0,
377
376
  placeholder: e.t("univer.find-replace.dialog.find-placeholder"),
378
377
  slot: /* @__PURE__ */ d.jsx(
379
- Ue,
378
+ Ae,
380
379
  {
381
380
  loop: !0,
382
381
  value: g,
383
- total: _,
382
+ total: v,
384
383
  onChange: (c) => {
385
- g === _ && c === 1 ? t.moveToNextMatch() : g === 1 && c === _ || c < g ? t.moveToPreviousMatch() : t.moveToNextMatch();
384
+ g === v && c === 1 ? t.moveToNextMatch() : g === 1 && c === v || c < g ? t.moveToPreviousMatch() : t.moveToNextMatch();
386
385
  }
387
386
  }
388
387
  ),
389
388
  value: i,
390
- onChange: (c) => ae(c)
389
+ onChange: (c) => se(c)
391
390
  }
392
391
  ),
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") }) })
392
+ /* @__PURE__ */ d.jsx("div", { className: L.findReplaceExpandContainer, children: /* @__PURE__ */ d.jsx(I, { type: "text", size: "small", onClick: oe, children: e.t("univer.find-replace.dialog.advanced-finding") }) })
394
393
  ] });
395
394
  }
396
- function ce() {
395
+ function le() {
397
396
  return /* @__PURE__ */ d.jsxs(A, { children: [
398
397
  /* @__PURE__ */ d.jsx(P, { label: e.t("univer.find-replace.dialog.find"), children: /* @__PURE__ */ d.jsx(
399
398
  U,
@@ -412,16 +411,16 @@ function it() {
412
411
  onChange: (c) => N(c)
413
412
  }
414
413
  ) }),
415
- /* @__PURE__ */ d.jsx(P, { label: e.t("univer.find-replace.dialog.find-range"), children: /* @__PURE__ */ d.jsx(Le, { value: "123", onChange: () => {
414
+ /* @__PURE__ */ d.jsx(P, { label: e.t("univer.find-replace.dialog.find-range"), children: /* @__PURE__ */ d.jsx(Ue, { value: "123", onChange: () => {
416
415
  } }) }),
417
416
  /* @__PURE__ */ d.jsx(I, { type: "primary", children: e.t("univer.find-replace.dialog.find") }),
418
417
  /* @__PURE__ */ d.jsx(I, { children: e.t("univer.find-replace.dialog.replace") }),
419
418
  /* @__PURE__ */ d.jsx(I, { children: e.t("univer.find-replace.dialog.replace-all") })
420
419
  ] });
421
420
  }
422
- return /* @__PURE__ */ d.jsx("div", { className: L.findReplaceDialogContainer, ref: s, children: h.replaceRevealed ? ce() : se() });
421
+ return /* @__PURE__ */ d.jsx("div", { className: L.findReplaceDialogContainer, ref: s, children: h.replaceRevealed ? le() : ce() });
423
422
  }
424
- function nt(t) {
423
+ function tt(t) {
425
424
  return {
426
425
  id: D.id,
427
426
  icon: "SearchIcon",
@@ -429,89 +428,89 @@ function nt(t) {
429
428
  group: Re.TOOLBAR_OTHERS,
430
429
  type: Me.BUTTON,
431
430
  positions: [Ie.TOOLBAR_START],
432
- hidden$: Ce(t, ue.SHEET)
431
+ hidden$: Ce(t, pe.SHEET)
433
432
  };
434
433
  }
435
- const rt = {
434
+ const it = {
436
435
  id: D.id,
437
436
  description: "shortcut.find-replace.open-find-dialog",
438
- binding: R.F | j.CTRL_COMMAND,
437
+ binding: R.F | F.CTRL_COMMAND,
439
438
  group: "4_find-replace",
440
439
  preconditions(t) {
441
- return !t.getContextValue(v);
440
+ return !t.getContextValue(_);
442
441
  }
443
- }, ot = {
444
- id: Q.id,
442
+ }, nt = {
443
+ id: X.id,
445
444
  description: "shortcut.find-replace.open-replace-dialog",
446
- binding: R.H | j.CTRL_COMMAND,
445
+ binding: R.H | F.CTRL_COMMAND,
447
446
  group: "4_find-replace",
448
447
  preconditions(t) {
449
- return !t.getContextValue(v);
448
+ return !t.getContextValue(_);
450
449
  }
451
- }, at = {
452
- id: X.id,
450
+ }, rt = {
451
+ id: ee.id,
453
452
  description: "shortcut.find-replace.close-dialog",
454
453
  binding: R.ESC,
455
454
  group: "4_find-replace",
456
455
  priority: 1e3,
457
456
  preconditions(t) {
458
- return !!t.getContextValue(v);
457
+ return !!t.getContextValue(_);
459
458
  }
460
- }, st = {
461
- id: ee.id,
459
+ }, ot = {
460
+ id: te.id,
462
461
  description: "shortcut.find-replace.go-to-next-find-match",
463
462
  binding: R.ENTER,
464
463
  group: "4_find-replace",
465
464
  priority: 1e3,
466
465
  preconditions(t) {
467
- return !!t.getContextValue(v);
466
+ return !!t.getContextValue(_);
468
467
  }
469
- }, ct = {
470
- id: te.id,
468
+ }, at = {
469
+ id: ie.id,
471
470
  description: "shortcut.find-replace.go-to-previous-find-match",
472
- binding: R.ENTER | j.SHIFT,
471
+ binding: R.ENTER | F.SHIFT,
473
472
  group: "4_find-replace",
474
473
  priority: 1e3,
475
474
  preconditions(t) {
476
- return !!t.getContextValue(v);
475
+ return !!t.getContextValue(_);
477
476
  }
478
477
  };
479
- var lt = Object.defineProperty, dt = Object.getOwnPropertyDescriptor, ht = (t, e, n, i) => {
480
- for (var r = i > 1 ? void 0 : i ? dt(e, n) : e, o = t.length - 1, a; o >= 0; o--)
478
+ var st = Object.defineProperty, ct = Object.getOwnPropertyDescriptor, lt = (t, e, n, i) => {
479
+ for (var r = i > 1 ? void 0 : i ? ct(e, n) : e, o = t.length - 1, a; o >= 0; o--)
481
480
  (a = t[o]) && (r = (i ? a(e, n, r) : a(r)) || r);
482
- return i && r && lt(e, n, r), r;
481
+ return i && r && st(e, n, r), r;
483
482
  }, p = (t, e) => (n, i) => e(n, i, t);
484
483
  const w = "DESKTOP_FIND_REPLACE_DIALOG";
485
484
  let C = class extends ve {
486
- constructor(t, e, n, i, r, o, a, s, h, _) {
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
+ constructor(t, e, n, i, r, o, a, s, h, v) {
486
+ super(), this._menuService = t, this._shortcutService = e, this._commandService = n, this._findReplaceService = i, this._dialogService = r, this._contextService = o, this._layoutService = a, this._localeService = s, this._componentManager = h, this._injector = v, this._initOperations(), this._initUI(), this._initShortcuts();
488
487
  }
489
488
  _initOperations() {
490
489
  [
491
- X,
492
- D,
493
- Q,
494
- qe,
495
490
  ee,
496
- te
491
+ D,
492
+ X,
493
+ ze,
494
+ te,
495
+ ie
497
496
  ].forEach((t) => {
498
497
  this.disposeWithMe(this._commandService.registerCommand(t));
499
498
  });
500
499
  }
501
500
  _initUI() {
502
- [nt].forEach((t) => {
501
+ [tt].forEach((t) => {
503
502
  this.disposeWithMe(this._menuService.addMenuItem(this._injector.invoke(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) => {
503
+ }), this.disposeWithMe(this._componentManager.register("FindReplaceDialog", et)), this.disposeWithMe(this._componentManager.register("SearchIcon", J)), this._findReplaceService.stateUpdates$.pipe(je(this.dispose$)).subscribe((t) => {
505
504
  t.revealed === !0 ? this._openPanel() : t.revealed === !1 && this._closePanel();
506
505
  });
507
506
  }
508
507
  _initShortcuts() {
509
508
  [
510
- ot,
509
+ nt,
510
+ it,
511
511
  rt,
512
512
  at,
513
- ct,
514
- st
513
+ ot
515
514
  ].forEach((t) => {
516
515
  this.disposeWithMe(this._shortcutService.registerShortcut(t));
517
516
  });
@@ -524,26 +523,26 @@ let C = class extends ve {
524
523
  title: { title: this._localeService.t("univer.find-replace.dialog.title") },
525
524
  children: { label: "FindReplaceDialog" },
526
525
  onClose: () => this._closePanel()
527
- }), this._contextService.setContextValue(v, !0);
526
+ }), this._contextService.setContextValue(_, !0);
528
527
  }
529
528
  _closePanel() {
530
- this._dialogService.close(w), this._contextService.setContextValue(v, !1), this._focusService.forceFocus(), this._findReplaceService.end();
529
+ this._dialogService.close(w), this._contextService.setContextValue(_, !1), this._layoutService.focus(), this._findReplaceService.end();
531
530
  }
532
531
  };
533
- C = ht([
534
- pe(fe.Rendered, C),
532
+ C = lt([
533
+ fe(_e.Rendered, C),
535
534
  p(0, Pe),
536
535
  p(1, ye),
537
- p(2, _e),
536
+ p(2, ge),
538
537
  p(3, f),
539
538
  p(4, Te),
540
- p(5, ge),
541
- p(6, be),
542
- p(7, S(F)),
539
+ p(5, me),
540
+ p(6, W),
541
+ p(7, S(j)),
543
542
  p(8, S(Oe)),
544
543
  p(9, S(H))
545
544
  ], C);
546
- const ut = {
545
+ const dt = {
547
546
  univer: {
548
547
  "find-replace": {
549
548
  dialog: {
@@ -559,16 +558,16 @@ const ut = {
559
558
  }
560
559
  }
561
560
  };
562
- var pt = Object.defineProperty, ft = Object.getOwnPropertyDescriptor, vt = (t, e, n, i) => {
563
- for (var r = i > 1 ? void 0 : i ? ft(e, n) : e, o = t.length - 1, a; o >= 0; o--)
561
+ var ht = Object.defineProperty, ut = Object.getOwnPropertyDescriptor, pt = (t, e, n, i) => {
562
+ for (var r = i > 1 ? void 0 : i ? ut(e, n) : e, o = t.length - 1, a; o >= 0; o--)
564
563
  (a = t[o]) && (r = (i ? a(e, n, r) : a(r)) || r);
565
- return i && r && pt(e, n, r), r;
566
- }, _t = (t, e) => (n, i) => e(n, i, t);
567
- const gt = "FIND_REPLACE";
568
- let V = class extends me {
564
+ return i && r && ht(e, n, r), r;
565
+ }, ft = (t, e) => (n, i) => e(n, i, t);
566
+ const _t = "FIND_REPLACE";
567
+ let V = class extends Se {
569
568
  constructor(t, e) {
570
- super(gt), this._injector = t, this._localeService = e, this._localeService.load({
571
- zhCN: ut
569
+ super(_t), this._injector = t, this._localeService = e, this._localeService.load({
570
+ zhCN: dt
572
571
  });
573
572
  }
574
573
  onStarting(t) {
@@ -579,11 +578,11 @@ let V = class extends me {
579
578
  );
580
579
  }
581
580
  };
582
- V = vt([
583
- _t(1, S(F))
581
+ V = pt([
582
+ ft(1, S(j))
584
583
  ], V);
585
584
  export {
586
- Pt as FindModel,
585
+ Ct as FindModel,
587
586
  f as IFindReplaceService,
588
587
  V as UniverFindReplacePlugin
589
588
  };
@@ -14,7 +14,7 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  import { ICommandService, IContextService, LocaleService, RxDisposable } from '@univerjs/core';
17
- import { ComponentManager, IDialogService, IFocusService, IMenuService, IShortcutService } from '@univerjs/ui';
17
+ import { ComponentManager, IDialogService, ILayoutService, IMenuService, IShortcutService } from '@univerjs/ui';
18
18
  import { Injector } from '@wendellhu/redi';
19
19
  import { IFindReplaceService } from '../services/find-replace.service';
20
20
  export declare class FindReplaceController extends RxDisposable {
@@ -24,11 +24,11 @@ export declare class FindReplaceController extends RxDisposable {
24
24
  private readonly _findReplaceService;
25
25
  private readonly _dialogService;
26
26
  private readonly _contextService;
27
- private readonly _focusService;
27
+ private readonly _layoutService;
28
28
  private readonly _localeService;
29
29
  private readonly _componentManager;
30
30
  private readonly _injector;
31
- constructor(_menuService: IMenuService, _shortcutService: IShortcutService, _commandService: ICommandService, _findReplaceService: IFindReplaceService, _dialogService: IDialogService, _contextService: IContextService, _focusService: IFocusService, _localeService: LocaleService, _componentManager: ComponentManager, _injector: Injector);
31
+ constructor(_menuService: IMenuService, _shortcutService: IShortcutService, _commandService: ICommandService, _findReplaceService: IFindReplaceService, _dialogService: IDialogService, _contextService: IContextService, _layoutService: ILayoutService, _localeService: LocaleService, _componentManager: ComponentManager, _injector: Injector);
32
32
  private _initOperations;
33
33
  private _initUI;
34
34
  private _initShortcuts;
@@ -13,20 +13,6 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- declare const locale: {
17
- univer: {
18
- 'find-replace': {
19
- dialog: {
20
- title: string;
21
- find: string;
22
- replace: string;
23
- 'replace-all': string;
24
- 'find-range': string;
25
- 'find-placeholder': string;
26
- 'advanced-finding': string;
27
- 'replace-placeholder': string;
28
- };
29
- };
30
- };
31
- };
16
+ import type zhCN from './zh-CN';
17
+ declare const locale: typeof zhCN;
32
18
  export default locale;
@@ -13,6 +13,20 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- import { type default as enUS } from './en-US';
17
- declare const locale: typeof enUS;
16
+ declare const locale: {
17
+ univer: {
18
+ 'find-replace': {
19
+ dialog: {
20
+ title: string;
21
+ find: string;
22
+ replace: string;
23
+ 'replace-all': string;
24
+ 'find-range': string;
25
+ 'find-placeholder': string;
26
+ 'advanced-finding': string;
27
+ 'replace-placeholder': string;
28
+ };
29
+ };
30
+ };
31
+ };
18
32
  export default locale;
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)},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={};/**
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 je=Object.defineProperty;var be=(c,o,v)=>o in c?je(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:{maskType:"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";var X=Object.defineProperty,$=Object.getOwnPropertyDescriptor,U=(t,e,r,i)=>{for(var n=i>1?void 0:i?$(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&&X(e,r,n),n},M=(t,e)=>(r,i)=>e(r,i,t);class q 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 L(){return{revealed:!0,findString:"",replaceRevealed:!1,matchesPosition:0,matchesCount:0}}class ee{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 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 b=class extends o.Disposable{constructor(e,r,i){super();u(this,"_providers",new Set);u(this,"_state",new ee);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=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),o.toDisposable(()=>this._providers.delete(e))}};b=U([M(0,v.Inject(v.Injector)),M(1,o.IUniverInstanceService),M(2,o.ILogService)],b);const F={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)},te={id:"ui.operation.toggle-replace-dialog",type:o.CommandType.OPERATION,handler:t=>(t.get(x),!0)},A={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}}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"})});
9
+ */var ie=p,ne=Symbol.for("react.element"),re=Symbol.for("react.fragment"),ae=Object.prototype.hasOwnProperty,oe=ie.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,se={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)ae.call(e,i)&&!se.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:ne,type:t,key:a,ref:s,props:n,_owner:oe.current}}y.Fragment=re,y.jsx=k,y.jsxs=k,K.exports=y;var f=K.exports;const G={findReplaceExpandContainer:"univer-find-replace-expand-container"};function ce(){const t=T.useDependency(x),e=T.useDependency(o.LocaleService),r=T.useDependency(h.ILayoutService),[i,n]=p.useState(""),[a,s]=p.useState(""),l=p.useRef(null),m=_.useObservable(t.state$,!0),{matchesCount:C,matchesPosition:I}=m,Me=p.useCallback(()=>t.revealReplace(),[t]),ye=p.useCallback(d=>t.changeFindString(d),[t]),Pe=p.useCallback(d=>{n(d),ye(d)},[t]),W=p.useCallback(d=>{s(d)},[t]);p.useEffect(()=>{let d;return l.current&&(d=r.registerContainerElement(l.current)),()=>d==null?void 0:d.dispose()},[l.current]);function Oe(){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=>Pe(d)}),f.jsx("div",{className:G.findReplaceExpandContainer,children:f.jsx(_.Button,{type:"text",size:"small",onClick:Me,children:e.t("univer.find-replace.dialog.advanced-finding")})})]})}function Te(){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?Te():Oe()})}function le(t){return{id:F.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 de={id:F.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)}},he={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)}},ue={id:A.id,description:"shortcut.find-replace.close-dialog",binding:h.KeyCode.ESC,group:"4_find-replace",priority:1e3,preconditions(t){return!!t.getContextValue(R)}},pe={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)}},fe={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 ve=Object.defineProperty,_e=Object.getOwnPropertyDescriptor,ge=(t,e,r,i)=>{for(var n=i>1?void 0:i?_e(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&&ve(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._layoutService=s,this._localeService=l,this._componentManager=m,this._injector=C,this._initOperations(),this._initUI(),this._initShortcuts()}_initOperations(){[A,F,w,te,V,B].forEach(t=>{this.disposeWithMe(this._commandService.registerCommand(t))})}_initUI(){[le].forEach(t=>{this.disposeWithMe(this._menuService.addMenuItem(this._injector.invoke(t)))}),this.disposeWithMe(this._componentManager.register("FindReplaceDialog",ce)),this.disposeWithMe(this._componentManager.register("SearchIcon",N)),this._findReplaceService.stateUpdates$.pipe(O.takeUntil(this.dispose$)).subscribe(t=>{t.revealed===!0?this._openPanel():t.revealed===!1&&this._closePanel()})}_initShortcuts(){[he,de,ue,fe,pe].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._layoutService.focus(),this._findReplaceService.end()}};P=ge([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.ILayoutService),S(7,v.Inject(o.LocaleService)),S(8,v.Inject(h.ComponentManager)),S(9,v.Inject(v.Injector))],P);const me={univer:{"find-replace":{dialog:{title:"查找",find:"查找",replace:"替换","replace-all":"替换全部","find-range":"查找范围","find-placeholder":"输入查找内容","advanced-finding":"替换 / 高级查找","replace-placeholder":"输入替换内容"}}}};var Se=Object.defineProperty,xe=Object.getOwnPropertyDescriptor,Re=(t,e,r,i)=>{for(var n=i>1?void 0:i?xe(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&&Se(e,r,n),n},Ce=(t,e)=>(r,i)=>e(r,i,t);const Ie="FIND_REPLACE";c.UniverFindReplacePlugin=class extends o.Plugin{constructor(e,r){super(Ie),this._injector=e,this._localeService=r,this._localeService.load({zhCN:me})}onStarting(e){[[P],[x,{useClass:b}]].forEach(r=>{e.add(r)})}},c.UniverFindReplacePlugin=Re([Ce(1,v.Inject(o.LocaleService))],c.UniverFindReplacePlugin),c.FindModel=q,c.IFindReplaceService=x,Object.defineProperty(c,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,10 +1,22 @@
1
1
  {
2
2
  "name": "@univerjs/find-replace",
3
- "version": "0.1.0-beta.4",
3
+ "version": "0.1.1",
4
4
  "private": false,
5
5
  "description": "",
6
6
  "author": "DreamNum <developer@univer.ai>",
7
7
  "license": "Apache-2.0",
8
+ "funding": {
9
+ "type": "opencollective",
10
+ "url": "https://opencollective.com/univer"
11
+ },
12
+ "homepage": "https://univer.ai",
13
+ "repository": {
14
+ "type": "git",
15
+ "url": "https://github.com/dream-num/univer"
16
+ },
17
+ "bugs": {
18
+ "url": "https://github.com/dream-num/univer/issues"
19
+ },
8
20
  "keywords": [],
9
21
  "exports": {
10
22
  ".": {
@@ -16,7 +28,8 @@
16
28
  "import": "./lib/es/*",
17
29
  "require": "./lib/cjs/*",
18
30
  "types": "./lib/types/index.d.ts"
19
- }
31
+ },
32
+ "./lib/*": "./lib/*"
20
33
  },
21
34
  "main": "./lib/cjs/index.js",
22
35
  "module": "./lib/es/index.js",
@@ -35,29 +48,29 @@
35
48
  "npm": ">=8.0.0"
36
49
  },
37
50
  "peerDependencies": {
38
- "@univerjs/icons": "^0.1.27",
39
- "@wendellhu/redi": ">=0.12.13",
51
+ "@univerjs/icons": "^0.1.28",
52
+ "@wendellhu/redi": "^0.13.0",
40
53
  "react": "^18.2.0",
41
54
  "rxjs": ">=7.0.0",
42
- "@univerjs/design": "0.1.0-beta.4",
43
- "@univerjs/ui": "0.1.0-beta.4",
44
- "@univerjs/core": "0.1.0-beta.4"
55
+ "@univerjs/core": "0.1.1",
56
+ "@univerjs/design": "0.1.1",
57
+ "@univerjs/ui": "0.1.1"
45
58
  },
46
59
  "dependencies": {
47
- "@univerjs/icons": "^0.1.27"
60
+ "@univerjs/icons": "^0.1.28"
48
61
  },
49
62
  "devDependencies": {
50
- "@types/react": "^18.2.48",
51
- "@wendellhu/redi": "^0.12.13",
63
+ "@types/react": "^18.2.57",
64
+ "@wendellhu/redi": "^0.13.0",
52
65
  "react": "^18.2.0",
53
66
  "rxjs": "^7.8.1",
54
67
  "typescript": "^5.3.3",
55
- "vite": "^5.0.12",
56
- "vitest": "^1.2.1",
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"
68
+ "vite": "^5.1.4",
69
+ "vitest": "^1.3.1",
70
+ "@univerjs/core": "0.1.1",
71
+ "@univerjs/shared": "0.1.1",
72
+ "@univerjs/design": "0.1.1",
73
+ "@univerjs/ui": "0.1.1"
61
74
  },
62
75
  "scripts": {
63
76
  "test": "vitest run",