@univerjs/find-replace 0.1.3 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  [![npm version](https://img.shields.io/npm/v/@univerjs/find-replace)](https://npmjs.org/packages/@univerjs/find-replace)
4
4
  [![license](https://img.shields.io/npm/l/@univerjs/find-replace)](https://img.shields.io/npm/l/@univerjs/find-replace)
5
+ ![CSS Included](https://img.shields.io/badge/CSS_Included-blue?logo=CSS3)
6
+ ![i18n](https://img.shields.io/badge/zh--CN%20%7C%20en--US-cornflowerblue?label=i18n)
5
7
 
6
8
  ## Introduction
7
9
 
package/lib/cjs/index.js CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";var Oe=Object.defineProperty;var Pe=(t,e,n)=>e in t?Oe(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var d=(t,e,n)=>(Pe(t,typeof e!="symbol"?e+"":e,n),n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("@univerjs/core"),M=require("@wendellhu/redi"),h=require("@univerjs/ui"),S=require("rxjs"),Te=require("@univerjs/engine-render"),l=require("react"),p=require("@univerjs/design"),y=require("@wendellhu/redi/react-bindings");var R=function(){return R=Object.assign||function(t){for(var e,n=1,i=arguments.length;n<i;n++){e=arguments[n];for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&(t[s]=e[s])}return t},R.apply(this,arguments)},Ee=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 s=0,i=Object.getOwnPropertySymbols(t);s<i.length;s++)e.indexOf(i[s])<0&&Object.prototype.propertyIsEnumerable.call(t,i[s])&&(n[i[s]]=t[i[s]]);return n},q=l.forwardRef(function(t,e){var n=t.icon,i=t.id,s=t.className,r=t.extend,a=Ee(t,["icon","id","className","extend"]),o="univerjs-icon univerjs-icon-".concat(i," ").concat(s||"").trim(),f=l.useRef("_".concat(je()));return z(n,"".concat(i),{defIds:n.defIds,idSuffix:f.current},R({ref:e,className:o},a),r)});function z(t,e,n,i,s){return l.createElement(t.tag,R(R({key:e},$e(t,n,s)),i),(Ne(t,n).children||[]).map(function(r,a){return z(r,"".concat(e,"-").concat(t.tag,"-").concat(a),n,void 0,s)}))}function $e(t,e,n){var i=R({},t.attrs);n!=null&&n.colorChannel1&&i.fill==="colorChannel1"&&(i.fill=n.colorChannel1);var s=e.defIds;return!s||s.length===0||(t.tag==="use"&&i["xlink:href"]&&(i["xlink:href"]=i["xlink:href"]+e.idSuffix),Object.entries(i).forEach(function(r){var a=r[0],o=r[1];typeof o=="string"&&(i[a]=o.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))})),i}function Ne(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)?R(R({},t),{children:t.children.map(function(s){return typeof s.attrs.id=="string"&&i&&i.indexOf(s.attrs.id)>-1?R(R({},s),{attrs:R(R({},s.attrs),{id:s.attrs.id+e.idSuffix})}):s})}):t}function je(){return Math.random().toString(36).substring(2,8)}q.displayName="UniverIcon";var Le={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"}}]}]},Y=l.forwardRef(function(t,e){return l.createElement(q,Object.assign({},t,{id:"search-single-16",ref:e,icon:Le}))});Y.displayName="SearchSingle16";const Z="FIND_REPLACE_INPUT_FOCUS",J="FIND_REPLACE_DIALOG_FOCUS",Q="FIND_REPLACE_REPLACE_REVEALED";var Ae=Object.defineProperty,we=Object.getOwnPropertyDescriptor,X=(t,e,n,i)=>{for(var s=i>1?void 0:i?we(e,n):e,r=t.length-1,a;r>=0;r--)(a=t[r])&&(s=(i?a(e,n,s):a(s))||s);return i&&s&&Ae(e,n,s),s},O=(t,e)=>(n,i)=>e(n,i,t);class Ue extends c.Disposable{}const b=M.createIdentifier("find-replace.service");function Be(t){return typeof t.findString<"u"||typeof t.inputtingFindString<"u"||typeof t.findDirection<"u"||typeof t.matchesTheWholeCell<"u"||typeof t.caseSensitive<"u"||typeof t.findScope<"u"||typeof t.findBy<"u"}let w=class extends c.Disposable{constructor(e,n,i,s){super();d(this,"currentMatch$",new S.BehaviorSubject(null));d(this,"replaceables$",new S.BehaviorSubject([]));d(this,"_findModels",[]);d(this,"_matchingModel",null);d(this,"_matches",[]);d(this,"_currentSearchingDisposables",null);this._state=e,this._providers=n,this._univerInstanceService=i,this._logService=s,this.disposeWithMe(this._state.stateUpdates$.pipe(S.throttleTime(200,void 0,{leading:!0,trailing:!0})).subscribe(async r=>{const a=this._state.state;Be(r)&&(a.findString!==""&&!a.replaceRevealed?(await this._startSearching(),this._state.changeState({findCompleted:!0})):r.replaceRevealed!==!0&&this._stopSearching())}))}get searched(){return this._findModels.length>0}dispose(){super.dispose(),this._stopSearching(),this.currentMatch$.complete(),this.replaceables$.complete(),this._state.changeState({...B(),revealed:!1})}async start(){if(!this._state.findString)return{results:[]};const e=await this._startSearching();return this._state.changeState({findCompleted:!0}),e}async _startSearching(){if(!this._state.findString)return{results:[]};const e=Array.from(this._providers),n=this._findModels=(await Promise.all(e.map(r=>r.find({findString:this._state.findString,findDirection:this._state.findDirection,findScope:this._state.findScope,findBy:this._state.findBy,replaceRevealed:this._state.replaceRevealed,caseSensitive:this._state.caseSensitive,matchesTheWholeCell:this._state.matchesTheWholeCell})))).flat();this._subscribeToModelsChanges(n);const i=this._matches=n.map(r=>r.getMatches()).flat();if(this.replaceables$.next(i.filter(r=>r.replaceable)),!i.length)return this._state.changeState({matchesCount:0,matchesPosition:0}),{results:[]};const s=this._moveToInitialMatch(n,i);return this._state.changeState({matchesCount:i.length,matchesPosition:s+1}),{results:i}}_stopSearching(){var e;this._providers.forEach(n=>n.terminate()),this._findModels=[],this._matches=[],this._matchingModel=null,(e=this._currentSearchingDisposables)==null||e.dispose(),this._currentSearchingDisposables=null,this.currentMatch$.next(null),this.replaceables$.next([]),this._state.changeState({findCompleted:!1,matchesCount:0,matchesPosition:0})}_subscribeToModelsChanges(e){const n=this._currentSearchingDisposables=new c.DisposableCollection,i=S.combineLatest(e.map(s=>s.matchesUpdate$)).pipe(S.debounceTime(220)).subscribe(([...s])=>{const r=this._matches=s.flat();if(r.length){const a=this._moveToInitialMatch(this._findModels,r,!0);this._state.changeState({matchesCount:r.length,matchesPosition:a+1}),this.replaceables$.next(r.filter(o=>o.replaceable))}else this._state.changeState({matchesCount:0,matchesPosition:0}),this.replaceables$.next([])});e.forEach(s=>n.add(c.toDisposable(s.activelyChangingMatch$.subscribe(r=>{const a=this._matches.findIndex(o=>o===r);this._state.changeState({matchesPosition:a+1})})))),n.add(c.toDisposable(i))}async replace(){return this._matchingModel?this._matchingModel.replace(this._state.replaceString):!1}async replaceAll(){const e=await Promise.all(this._findModels.map(n=>n.replaceAll(this._state.replaceString))).then(n=>n.reduce((i,s)=>(i.success+=s.success,i.failure+=s.failure,i),{success:0,failure:0}));return e.failure===0&&this._stopSearching(),e}getCurrentMatch(){return this._state.matchesPosition>0?this._matches[this._state.matchesPosition-1]:null}moveToNextMatch(){if(!this._matchingModel)return;const e=this._findModels.length===1,n=this._matchingModel.moveToNextMatch({loop:e});if(n){const i=this._matches.findIndex(s=>s===n);this.currentMatch$.next(n),this._state.changeState({matchesPosition:i+1})}else{const i=this._findModels.findIndex(o=>o===this._matchingModel),s=this._findModels[(i+1)%this._findModels.length],r=s.moveToNextMatch(),a=this._matches.findIndex(o=>o===r);this.currentMatch$.next(r),this._matchingModel=s,this._state.changeState({matchesPosition:a+1})}}moveToPreviousMatch(){if(!this._matchingModel)return;const e=this._findModels.length===1,n=this._matchingModel.moveToPreviousMatch({loop:e});if(n){const i=this._matches.findIndex(s=>s===n);this.currentMatch$.next(n),this._state.changeState({matchesPosition:i+1})}else{const i=this._findModels.findIndex(o=>o===this._matchingModel),s=this._findModels[(i-1+this._findModels.length)%this._findModels.length],r=s.moveToPreviousMatch(),a=this._matches.findIndex(o=>o===r);this.currentMatch$.next(r),this._matchingModel=s,this._state.changeState({matchesPosition:a+1})}}_moveToInitialMatch(e,n,i=!1){var f;const s=(f=this._univerInstanceService.getFocusedUniverInstance())==null?void 0:f.getUnitId();if(!s)return-1;const r=e.find(g=>g.unitId===s);if(r){this._matchingModel=r;const g=r.moveToNextMatch({stayIfOnMatch:!0,noFocus:i}),v=n.findIndex(m=>m===g);return this.currentMatch$.next(g),v}this._matchingModel=e[0];const a=this._matchingModel.moveToNextMatch({noFocus:i}),o=this._matches.findIndex(g=>g===a);return this.currentMatch$.next(a),o}};w=X([O(2,c.IUniverInstanceService),O(3,c.ILogService)],w);var P=(t=>(t.ROW="row",t.COLUMN="column",t))(P||{}),T=(t=>(t.VALUE="value",t.FORMULA="formula",t))(T||{}),E=(t=>(t.SUBUNIT="subunit",t.UNIT="unit",t))(E||{});function B(){return{caseSensitive:!1,findBy:"value",findCompleted:!1,findDirection:"row",findScope:"subunit",findString:"",inputtingFindString:"",matchesCount:0,matchesPosition:0,matchesTheWholeCell:!1,replaceRevealed:!1,replaceString:"",revealed:!0}}class We{constructor(){d(this,"_stateUpdates$",new S.Subject);d(this,"stateUpdates$",this._stateUpdates$.asObservable());d(this,"_state$",new S.BehaviorSubject(B()));d(this,"state$",this._state$.asObservable());d(this,"_findString","");d(this,"_inputtingFindString","");d(this,"_replaceString","");d(this,"_revealed",!1);d(this,"_replaceRevealed",!1);d(this,"_matchesPosition",0);d(this,"_matchesCount",0);d(this,"_caseSensitive",!0);d(this,"_matchesTheWholeCell",!1);d(this,"_findDirection","row");d(this,"_findScope","subunit");d(this,"_findBy","value");d(this,"_findCompleted",!1)}get state(){return this._state$.getValue()}get inputtingFindString(){return this._inputtingFindString}get findString(){return this._findString}get revealed(){return this._revealed}get replaceRevealed(){return this._replaceRevealed}get matchesPosition(){return this._matchesPosition}get matchesCount(){return this._matchesCount}get replaceString(){return this._replaceString}get caseSensitive(){return this._caseSensitive}get matchesTheWholeCell(){return this._matchesTheWholeCell}get findDirection(){return this._findDirection}get findScope(){return this._findScope}get findBy(){return this._findBy}get findCompleted(){return this._findCompleted}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.replaceString<"u"&&e.replaceString!==this._replaceString&&(this._replaceString=e.replaceString,i.replaceString=e.replaceString,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),typeof e.findBy<"u"&&e.findBy!==this._findBy&&(this._findBy=e.findBy,i.findBy=e.findBy,n=!0),typeof e.findScope<"u"&&e.findScope!==this._findScope&&(this._findScope=e.findScope,i.findScope=e.findScope,n=!0),typeof e.findDirection<"u"&&e.findDirection!==this._findDirection&&(this._findDirection=e.findDirection,i.findDirection=e.findDirection,n=!0),typeof e.caseSensitive<"u"&&e.caseSensitive!==this._caseSensitive&&(this._caseSensitive=e.caseSensitive,i.caseSensitive=e.caseSensitive,n=!0),typeof e.matchesTheWholeCell<"u"&&e.matchesTheWholeCell!==this._matchesTheWholeCell&&(this._matchesTheWholeCell=e.matchesTheWholeCell,i.matchesTheWholeCell=e.matchesTheWholeCell,n=!0),typeof e.inputtingFindString<"u"&&e.inputtingFindString!==this._inputtingFindString&&(this._inputtingFindString=e.inputtingFindString,i.inputtingFindString=e.inputtingFindString,n=!0),typeof e.findCompleted<"u"&&e.findCompleted!==this._findCompleted&&(this._findCompleted=e.findCompleted,i.findCompleted=e.findCompleted,n=!0),n&&(this._state$.next({caseSensitive:this._caseSensitive,findBy:this._findBy,findCompleted:this._findCompleted,findDirection:this._findDirection,findScope:this._findScope,findString:this._findString,inputtingFindString:this._inputtingFindString,matchesCount:this._matchesCount,matchesPosition:this._matchesPosition,matchesTheWholeCell:this._matchesTheWholeCell,replaceRevealed:this._replaceRevealed,revealed:this._revealed}),this._stateUpdates$.next(i))}}let U=class extends c.Disposable{constructor(e,n){super();d(this,"_providers",new Set);d(this,"_state",new We);d(this,"_model");d(this,"_currentMatch$",new S.BehaviorSubject(null));d(this,"currentMatch$",this._currentMatch$.asObservable());d(this,"_replaceables$",new S.BehaviorSubject([]));d(this,"replaceables$",this._replaceables$.asObservable());d(this,"_focusSignal$",new S.Subject);d(this,"focusSignal$",this._focusSignal$.asObservable());this._injector=e,this._contextService=n}get stateUpdates$(){return this._state.stateUpdates$}get state$(){return this._state.state$}get revealed(){return this._state.revealed}get replaceRevealed(){return this._state.replaceRevealed}dispose(){super.dispose(),this._currentMatch$.next(null),this._currentMatch$.complete(),this._replaceables$.next([]),this._replaceables$.complete(),this._focusSignal$.complete()}getCurrentMatch(){var e;return(e=this._model)==null?void 0:e.getCurrentMatch()}getFindString(){return this._state.findString}changeFindString(e){this._state.changeState({findString:e})}focusFindInput(){this._focusSignal$.next()}changeInputtingFindString(e){e?this._state.changeState({inputtingFindString:e}):this._state.changeState({inputtingFindString:"",findString:""})}changeReplaceString(e){this._state.changeState({replaceString:e})}changeMatchesTheWholeCell(e){this._state.changeState({matchesTheWholeCell:e})}changeCaseSensitive(e){this._state.changeState({caseSensitive:e})}changeFindBy(e){this._state.changeState({findBy:e}),this._toggleDisplayRawFormula(e==="formula")}changeFindScope(e){this._state.changeState({findScope:e})}changeFindDirection(e){this._state.changeState({findDirection:e})}moveToNextMatch(){this._model&&(this._state.replaceRevealed&&!this._model.searched?(this._state.changeState({findString:this._state.inputtingFindString}),this._model.start()):this._model.moveToNextMatch(),this._focusSignal$.next())}moveToPreviousMatch(){this._model&&(this._state.replaceRevealed&&!this._model.searched?(this._state.changeState({findString:this._state.inputtingFindString}),this._model.start()):this._model.moveToPreviousMatch(),this._focusSignal$.next())}async replace(){return this._model?this._model.replace():!1}async replaceAll(){if(!this._model)throw new Error("[FindReplaceService] replaceAll: model is not initialized!");return this._model.replaceAll()}revealReplace(){this._state.changeState({replaceRevealed:!0,inputtingFindString:this._state.findString}),this._toggleRevealReplace(!0)}start(e=!1){if(this._providers.size===0)return!1;this._model=this._injector.createInstance(w,this._state,this._providers),this._model.currentMatch$.subscribe(i=>this._currentMatch$.next(i)),this._model.replaceables$.subscribe(i=>this._replaceables$.next(i));const n=B();return e&&(n.replaceRevealed=!0),this._state.changeState(n),this._toggleRevealReplace(e),!0}find(){var e;(e=this._model)==null||e.start()}terminate(){var e;(e=this._model)==null||e.dispose(),this._model=null,this._toggleDisplayRawFormula(!1),this._toggleRevealReplace(!1)}registerFindReplaceProvider(e){return this._providers.add(e),c.toDisposable(()=>this._providers.delete(e))}_toggleRevealReplace(e){this._contextService.setContextValue(Q,e)}_toggleDisplayRawFormula(e){this._contextService.setContextValue(Te.RENDER_RAW_FORMULA_KEY,e)}};U=X([O(0,M.Inject(M.Injector)),O(1,c.IContextService)],U);const N={id:"ui.operation.open-find-dialog",type:c.CommandType.OPERATION,handler:t=>{const e=t.get(b);return e.revealed?e.focusFindInput():e.start(),!0}},W={id:"ui.operation.open-replace-dialog",type:c.CommandType.OPERATION,handler:t=>{const e=t.get(b);return e.revealed?e.replaceRevealed?e.focusFindInput():e.revealReplace():e.start(!0),!0}},ee={type:c.CommandType.OPERATION,id:"ui.operation.go-to-next-match",handler:t=>(t.get(b).moveToNextMatch(),!0)},te={type:c.CommandType.OPERATION,id:"ui.operation.go-to-previous-match",handler:t=>(t.get(b).moveToPreviousMatch(),!0)};var ie={exports:{}},j={};/**
1
+ "use strict";var Oe=Object.defineProperty;var Pe=(t,e,n)=>e in t?Oe(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var d=(t,e,n)=>(Pe(t,typeof e!="symbol"?e+"":e,n),n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("@univerjs/core"),M=require("@wendellhu/redi"),h=require("@univerjs/ui"),S=require("rxjs"),Te=require("@univerjs/engine-render"),l=require("react"),p=require("@univerjs/design"),y=require("@wendellhu/redi/react-bindings");var R=function(){return R=Object.assign||function(t){for(var e,n=1,i=arguments.length;n<i;n++){e=arguments[n];for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&(t[s]=e[s])}return t},R.apply(this,arguments)},Ee=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 s=0,i=Object.getOwnPropertySymbols(t);s<i.length;s++)e.indexOf(i[s])<0&&Object.prototype.propertyIsEnumerable.call(t,i[s])&&(n[i[s]]=t[i[s]]);return n},H=l.forwardRef(function(t,e){var n=t.icon,i=t.id,s=t.className,r=t.extend,a=Ee(t,["icon","id","className","extend"]),o="univerjs-icon univerjs-icon-".concat(i," ").concat(s||"").trim(),f=l.useRef("_".concat(je()));return K(n,"".concat(i),{defIds:n.defIds,idSuffix:f.current},R({ref:e,className:o},a),r)});function K(t,e,n,i,s){return l.createElement(t.tag,R(R({key:e},$e(t,n,s)),i),(Ne(t,n).children||[]).map(function(r,a){return K(r,"".concat(e,"-").concat(t.tag,"-").concat(a),n,void 0,s)}))}function $e(t,e,n){var i=R({},t.attrs);n!=null&&n.colorChannel1&&i.fill==="colorChannel1"&&(i.fill=n.colorChannel1);var s=e.defIds;return!s||s.length===0||(t.tag==="use"&&i["xlink:href"]&&(i["xlink:href"]=i["xlink:href"]+e.idSuffix),Object.entries(i).forEach(function(r){var a=r[0],o=r[1];typeof o=="string"&&(i[a]=o.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))})),i}function Ne(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)?R(R({},t),{children:t.children.map(function(s){return typeof s.attrs.id=="string"&&i&&i.indexOf(s.attrs.id)>-1?R(R({},s),{attrs:R(R({},s.attrs),{id:s.attrs.id+e.idSuffix})}):s})}):t}function je(){return Math.random().toString(36).substring(2,8)}H.displayName="UniverIcon";var Le={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"}}]}]},q=l.forwardRef(function(t,e){return l.createElement(H,Object.assign({},t,{id:"search-single-16",ref:e,icon:Le}))});q.displayName="SearchSingle16";const z="FIND_REPLACE_INPUT_FOCUS",Y="FIND_REPLACE_DIALOG_FOCUS",Z="FIND_REPLACE_REPLACE_REVEALED";var Ae=Object.defineProperty,we=Object.getOwnPropertyDescriptor,J=(t,e,n,i)=>{for(var s=i>1?void 0:i?we(e,n):e,r=t.length-1,a;r>=0;r--)(a=t[r])&&(s=(i?a(e,n,s):a(s))||s);return i&&s&&Ae(e,n,s),s},O=(t,e)=>(n,i)=>e(n,i,t);class Ue extends c.Disposable{}const b=M.createIdentifier("find-replace.service");function Be(t){return typeof t.findString<"u"||typeof t.inputtingFindString<"u"||typeof t.findDirection<"u"||typeof t.matchesTheWholeCell<"u"||typeof t.caseSensitive<"u"||typeof t.findScope<"u"||typeof t.findBy<"u"}let w=class extends c.Disposable{constructor(e,n,i,s){super();d(this,"currentMatch$",new S.BehaviorSubject(null));d(this,"replaceables$",new S.BehaviorSubject([]));d(this,"_findModels",[]);d(this,"_matchingModel",null);d(this,"_matches",[]);d(this,"_currentSearchingDisposables",null);this._state=e,this._providers=n,this._univerInstanceService=i,this._logService=s,this.disposeWithMe(this._state.stateUpdates$.pipe(S.throttleTime(200,void 0,{leading:!0,trailing:!0})).subscribe(async r=>{const a=this._state.state;Be(r)&&(a.findString!==""&&!a.replaceRevealed?(await this._startSearching(),this._state.changeState({findCompleted:!0})):r.replaceRevealed!==!0&&this._stopSearching())}))}get searched(){return this._findModels.length>0}dispose(){super.dispose(),this._stopSearching(),this.currentMatch$.complete(),this.replaceables$.complete(),this._state.changeState({...B(),revealed:!1})}async start(){if(!this._state.findString)return{results:[]};const e=await this._startSearching();return this._state.changeState({findCompleted:!0}),e}async _startSearching(){if(!this._state.findString)return{results:[]};const e=Array.from(this._providers),n=this._findModels=(await Promise.all(e.map(r=>r.find({findString:this._state.findString,findDirection:this._state.findDirection,findScope:this._state.findScope,findBy:this._state.findBy,replaceRevealed:this._state.replaceRevealed,caseSensitive:this._state.caseSensitive,matchesTheWholeCell:this._state.matchesTheWholeCell})))).flat();this._subscribeToModelsChanges(n);const i=this._matches=n.map(r=>r.getMatches()).flat();if(this.replaceables$.next(i.filter(r=>r.replaceable)),!i.length)return this._state.changeState({matchesCount:0,matchesPosition:0}),{results:[]};const s=this._moveToInitialMatch(n,i);return this._state.changeState({matchesCount:i.length,matchesPosition:s+1}),{results:i}}_stopSearching(){var e;this._providers.forEach(n=>n.terminate()),this._findModels=[],this._matches=[],this._matchingModel=null,(e=this._currentSearchingDisposables)==null||e.dispose(),this._currentSearchingDisposables=null,this.currentMatch$.next(null),this.replaceables$.next([]),this._state.changeState({findCompleted:!1,matchesCount:0,matchesPosition:0})}_subscribeToModelsChanges(e){const n=this._currentSearchingDisposables=new c.DisposableCollection,i=S.combineLatest(e.map(s=>s.matchesUpdate$)).pipe(S.debounceTime(220)).subscribe(([...s])=>{const r=this._matches=s.flat();if(r.length){const a=this._moveToInitialMatch(this._findModels,r,!0);this._state.changeState({matchesCount:r.length,matchesPosition:a+1}),this.replaceables$.next(r.filter(o=>o.replaceable))}else this._state.changeState({matchesCount:0,matchesPosition:0}),this.replaceables$.next([])});e.forEach(s=>n.add(c.toDisposable(s.activelyChangingMatch$.subscribe(r=>{const a=this._matches.findIndex(o=>o===r);this._state.changeState({matchesPosition:a+1})})))),n.add(c.toDisposable(i))}async replace(){return this._matchingModel?this._matchingModel.replace(this._state.replaceString):!1}async replaceAll(){const e=await Promise.all(this._findModels.map(n=>n.replaceAll(this._state.replaceString))).then(n=>n.reduce((i,s)=>(i.success+=s.success,i.failure+=s.failure,i),{success:0,failure:0}));return e.failure===0&&this._stopSearching(),e}getCurrentMatch(){return this._state.matchesPosition>0?this._matches[this._state.matchesPosition-1]:null}moveToNextMatch(){if(!this._matchingModel)return;const e=this._findModels.length===1,n=this._matchingModel.moveToNextMatch({loop:e});if(n){const i=this._matches.findIndex(s=>s===n);this.currentMatch$.next(n),this._state.changeState({matchesPosition:i+1})}else{const i=this._findModels.findIndex(o=>o===this._matchingModel),s=this._findModels[(i+1)%this._findModels.length],r=s.moveToNextMatch(),a=this._matches.findIndex(o=>o===r);this.currentMatch$.next(r),this._matchingModel=s,this._state.changeState({matchesPosition:a+1})}}moveToPreviousMatch(){if(!this._matchingModel)return;const e=this._findModels.length===1,n=this._matchingModel.moveToPreviousMatch({loop:e});if(n){const i=this._matches.findIndex(s=>s===n);this.currentMatch$.next(n),this._state.changeState({matchesPosition:i+1})}else{const i=this._findModels.findIndex(o=>o===this._matchingModel),s=this._findModels[(i-1+this._findModels.length)%this._findModels.length],r=s.moveToPreviousMatch(),a=this._matches.findIndex(o=>o===r);this.currentMatch$.next(r),this._matchingModel=s,this._state.changeState({matchesPosition:a+1})}}_moveToInitialMatch(e,n,i=!1){var f;const s=(f=this._univerInstanceService.getFocusedUniverInstance())==null?void 0:f.getUnitId();if(!s)return-1;const r=e.find(g=>g.unitId===s);if(r){this._matchingModel=r;const g=r.moveToNextMatch({stayIfOnMatch:!0,noFocus:i}),v=n.findIndex(m=>m===g);return this.currentMatch$.next(g),v}this._matchingModel=e[0];const a=this._matchingModel.moveToNextMatch({noFocus:i}),o=this._matches.findIndex(g=>g===a);return this.currentMatch$.next(a),o}};w=J([O(2,c.IUniverInstanceService),O(3,c.ILogService)],w);var P=(t=>(t.ROW="row",t.COLUMN="column",t))(P||{}),T=(t=>(t.VALUE="value",t.FORMULA="formula",t))(T||{}),E=(t=>(t.SUBUNIT="subunit",t.UNIT="unit",t))(E||{});function B(){return{caseSensitive:!1,findBy:"value",findCompleted:!1,findDirection:"row",findScope:"subunit",findString:"",inputtingFindString:"",matchesCount:0,matchesPosition:0,matchesTheWholeCell:!1,replaceRevealed:!1,replaceString:"",revealed:!0}}class We{constructor(){d(this,"_stateUpdates$",new S.Subject);d(this,"stateUpdates$",this._stateUpdates$.asObservable());d(this,"_state$",new S.BehaviorSubject(B()));d(this,"state$",this._state$.asObservable());d(this,"_findString","");d(this,"_inputtingFindString","");d(this,"_replaceString","");d(this,"_revealed",!1);d(this,"_replaceRevealed",!1);d(this,"_matchesPosition",0);d(this,"_matchesCount",0);d(this,"_caseSensitive",!0);d(this,"_matchesTheWholeCell",!1);d(this,"_findDirection","row");d(this,"_findScope","subunit");d(this,"_findBy","value");d(this,"_findCompleted",!1)}get state(){return this._state$.getValue()}get inputtingFindString(){return this._inputtingFindString}get findString(){return this._findString}get revealed(){return this._revealed}get replaceRevealed(){return this._replaceRevealed}get matchesPosition(){return this._matchesPosition}get matchesCount(){return this._matchesCount}get replaceString(){return this._replaceString}get caseSensitive(){return this._caseSensitive}get matchesTheWholeCell(){return this._matchesTheWholeCell}get findDirection(){return this._findDirection}get findScope(){return this._findScope}get findBy(){return this._findBy}get findCompleted(){return this._findCompleted}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.replaceString<"u"&&e.replaceString!==this._replaceString&&(this._replaceString=e.replaceString,i.replaceString=e.replaceString,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),typeof e.findBy<"u"&&e.findBy!==this._findBy&&(this._findBy=e.findBy,i.findBy=e.findBy,n=!0),typeof e.findScope<"u"&&e.findScope!==this._findScope&&(this._findScope=e.findScope,i.findScope=e.findScope,n=!0),typeof e.findDirection<"u"&&e.findDirection!==this._findDirection&&(this._findDirection=e.findDirection,i.findDirection=e.findDirection,n=!0),typeof e.caseSensitive<"u"&&e.caseSensitive!==this._caseSensitive&&(this._caseSensitive=e.caseSensitive,i.caseSensitive=e.caseSensitive,n=!0),typeof e.matchesTheWholeCell<"u"&&e.matchesTheWholeCell!==this._matchesTheWholeCell&&(this._matchesTheWholeCell=e.matchesTheWholeCell,i.matchesTheWholeCell=e.matchesTheWholeCell,n=!0),typeof e.inputtingFindString<"u"&&e.inputtingFindString!==this._inputtingFindString&&(this._inputtingFindString=e.inputtingFindString,i.inputtingFindString=e.inputtingFindString,n=!0),typeof e.findCompleted<"u"&&e.findCompleted!==this._findCompleted&&(this._findCompleted=e.findCompleted,i.findCompleted=e.findCompleted,n=!0),n&&(this._state$.next({caseSensitive:this._caseSensitive,findBy:this._findBy,findCompleted:this._findCompleted,findDirection:this._findDirection,findScope:this._findScope,findString:this._findString,inputtingFindString:this._inputtingFindString,matchesCount:this._matchesCount,matchesPosition:this._matchesPosition,matchesTheWholeCell:this._matchesTheWholeCell,replaceRevealed:this._replaceRevealed,revealed:this._revealed}),this._stateUpdates$.next(i))}}let U=class extends c.Disposable{constructor(e,n){super();d(this,"_providers",new Set);d(this,"_state",new We);d(this,"_model");d(this,"_currentMatch$",new S.BehaviorSubject(null));d(this,"currentMatch$",this._currentMatch$.asObservable());d(this,"_replaceables$",new S.BehaviorSubject([]));d(this,"replaceables$",this._replaceables$.asObservable());d(this,"_focusSignal$",new S.Subject);d(this,"focusSignal$",this._focusSignal$.asObservable());this._injector=e,this._contextService=n}get stateUpdates$(){return this._state.stateUpdates$}get state$(){return this._state.state$}get revealed(){return this._state.revealed}get replaceRevealed(){return this._state.replaceRevealed}dispose(){super.dispose(),this._currentMatch$.next(null),this._currentMatch$.complete(),this._replaceables$.next([]),this._replaceables$.complete(),this._focusSignal$.complete()}getCurrentMatch(){var e;return(e=this._model)==null?void 0:e.getCurrentMatch()}getFindString(){return this._state.findString}changeFindString(e){this._state.changeState({findString:e})}focusFindInput(){this._focusSignal$.next()}changeInputtingFindString(e){e?this._state.changeState({inputtingFindString:e}):this._state.changeState({inputtingFindString:"",findString:""})}changeReplaceString(e){this._state.changeState({replaceString:e})}changeMatchesTheWholeCell(e){this._state.changeState({matchesTheWholeCell:e})}changeCaseSensitive(e){this._state.changeState({caseSensitive:e})}changeFindBy(e){this._state.changeState({findBy:e}),this._toggleDisplayRawFormula(e==="formula")}changeFindScope(e){this._state.changeState({findScope:e})}changeFindDirection(e){this._state.changeState({findDirection:e})}moveToNextMatch(){this._model&&(this._state.replaceRevealed&&!this._model.searched?(this._state.changeState({findString:this._state.inputtingFindString}),this._model.start()):this._model.moveToNextMatch(),this._focusSignal$.next())}moveToPreviousMatch(){this._model&&(this._state.replaceRevealed&&!this._model.searched?(this._state.changeState({findString:this._state.inputtingFindString}),this._model.start()):this._model.moveToPreviousMatch(),this._focusSignal$.next())}async replace(){return this._model?this._model.replace():!1}async replaceAll(){if(!this._model)throw new Error("[FindReplaceService] replaceAll: model is not initialized!");return this._model.replaceAll()}revealReplace(){this._state.changeState({replaceRevealed:!0,inputtingFindString:this._state.findString}),this._toggleRevealReplace(!0)}start(e=!1){if(this._providers.size===0)return!1;this._model=this._injector.createInstance(w,this._state,this._providers),this._model.currentMatch$.subscribe(i=>this._currentMatch$.next(i)),this._model.replaceables$.subscribe(i=>this._replaceables$.next(i));const n=B();return e&&(n.replaceRevealed=!0),this._state.changeState(n),this._toggleRevealReplace(e),!0}find(){var e;(e=this._model)==null||e.start()}terminate(){var e;(e=this._model)==null||e.dispose(),this._model=null,this._toggleDisplayRawFormula(!1),this._toggleRevealReplace(!1)}registerFindReplaceProvider(e){return this._providers.add(e),c.toDisposable(()=>this._providers.delete(e))}_toggleRevealReplace(e){this._contextService.setContextValue(Z,e)}_toggleDisplayRawFormula(e){this._contextService.setContextValue(Te.RENDER_RAW_FORMULA_KEY,e)}};U=J([O(0,M.Inject(M.Injector)),O(1,c.IContextService)],U);const N={id:"ui.operation.open-find-dialog",type:c.CommandType.OPERATION,handler:t=>{const e=t.get(b);return e.revealed?e.focusFindInput():e.start(),!0}},W={id:"ui.operation.open-replace-dialog",type:c.CommandType.OPERATION,handler:t=>{const e=t.get(b);return e.revealed?e.replaceRevealed?e.focusFindInput():e.revealReplace():e.start(!0),!0}},Q={type:c.CommandType.OPERATION,id:"ui.operation.go-to-next-match",handler:t=>(t.get(b).moveToNextMatch(),!0)},X={type:c.CommandType.OPERATION,id:"ui.operation.go-to-previous-match",handler:t=>(t.get(b).moveToPreviousMatch(),!0)};var ee={exports:{}},j={};/**
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 ke=l,Ge=Symbol.for("react.element"),Ve=Symbol.for("react.fragment"),He=Object.prototype.hasOwnProperty,Ke=ke.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,qe={key:!0,ref:!0,__self:!0,__source:!0};function ne(t,e,n){var i,s={},r=null,a=null;n!==void 0&&(r=""+n),e.key!==void 0&&(r=""+e.key),e.ref!==void 0&&(a=e.ref);for(i in e)He.call(e,i)&&!qe.hasOwnProperty(i)&&(s[i]=e[i]);if(t&&t.defaultProps)for(i in e=t.defaultProps,e)s[i]===void 0&&(s[i]=e[i]);return{$$typeof:Ge,type:t,key:r,ref:a,props:s,_owner:Ke.current}}j.Fragment=Ve;j.jsx=ne;j.jsxs=ne;ie.exports=j;var u=ie.exports;const se={id:"ui.command.replace-current-match",type:c.CommandType.COMMAND,handler:t=>t.get(b).replace()},ze="CONFIRM_REPLACE_ALL",re={id:"ui.command.replace-all-matches",type:c.CommandType.COMMAND,handler:async t=>{const e=t.get(h.IConfirmService),n=t.get(c.LocaleService),i=t.get(h.IMessageService);if(!await e.confirm({id:ze,title:{title:n.t("find-replace.replace.confirm.title")},cancelText:n.t("button.cancel"),confirmText:n.t("button.confirm")}))return!1;const r=await t.get(b).replaceAll(),{success:a,failure:o}=r;return o>0?(a===0?i.show({type:p.MessageType.Error,content:n.t("find-replace.replace.all-failure")}):i.show({type:p.MessageType.Warning,content:n.t("find-replace.replace.partial-success",`${a}`,`${o}`)}),!1):(i.show({type:p.MessageType.Success,content:n.t("find-replace.replace.all-success",`${a}`)}),!0)}};function ae(t){const{findCompleted:e,localeService:n,matchesCount:i,matchesPosition:s,findString:r,findReplaceService:a,onChange:o,...f}=t,v=e&&i===0?n.t("find-replace.dialog.no-result"):i===0?" ":void 0;return u.jsx(p.InputWithSlot,{autoFocus:!0,placeholder:n.t("find-replace.dialog.find-placeholder"),slot:u.jsx(p.Pager,{loop:!0,text:v,value:s,total:i,onChange:m=>{s===i&&m===1?a.moveToNextMatch():s===1&&m===i||m<s?a.moveToPreviousMatch():a.moveToNextMatch()}}),value:r,onChange:m=>o==null?void 0:o(m),...f})}const Ye="univer-find-replace-dialog-container",Ze="univer-find-replace-expand-container",Je="univer-button-text",Qe="univer-find-replace-buttons-group",Xe="univer-find-replace-buttons-group-right",$={findReplaceDialogContainer:Ye,findReplaceExpandContainer:Ze,buttonText:Je,findReplaceButtonsGroup:Qe,findReplaceButtonsGroupRight:Xe};function oe(t,e){const n=l.useCallback(()=>{var s;(s=document.querySelector(".univer-find-input input"))==null||s.focus()},[]),i=l.useCallback(()=>{const s=document.querySelectorAll(".univer-find-replace-dialog-container .univer-select-selection-search-input");return Array.from(s).some(r=>r===document.activeElement)},[]);return l.useImperativeHandle(e,()=>({focus:n,selectHasFocus:i})),l.useEffect(()=>{const s=t.focusSignal$.subscribe(()=>n());return()=>s.unsubscribe()},[t,n]),{focus:n,selectHasFocus:i}}const et=l.forwardRef(function(e,n){const i=y.useDependency(c.LocaleService),s=y.useDependency(b),r=y.useDependency(c.ICommandService),a=h.useObservable(s.state$,void 0,!0),{findCompleted:o,findString:f,matchesCount:g,matchesPosition:v}=a,m=l.useCallback(()=>{r.executeCommand(W.id)},[r]),I=l.useCallback(x=>s.changeFindString(x),[s]);return oe(s,n),u.jsxs(l.Fragment,{children:[u.jsx(ae,{findCompleted:o,className:"univer-find-input",matchesCount:g,matchesPosition:v,findReplaceService:s,localeService:i,findString:f,onChange:I}),u.jsx("div",{className:$.findReplaceExpandContainer,children:u.jsx(p.Button,{type:"text",size:"small",onClick:m,children:i.t("find-replace.dialog.advanced-finding")})})]})}),tt=l.forwardRef(function(e,n){const i=y.useDependency(b),s=y.useDependency(c.LocaleService),r=y.useDependency(c.ICommandService),a=y.useDependency(h.IMessageService),o=h.useObservable(i.currentMatch$,void 0,!0),f=h.useObservable(i.replaceables$,void 0,!0),g=h.useObservable(i.state$,void 0,!0),{matchesCount:v,matchesPosition:m,findString:I,inputtingFindString:x,replaceString:de,caseSensitive:V,matchesTheWholeCell:H,findDirection:ue,findScope:he,findBy:pe,findCompleted:A}=g,fe=x.length===0,_e=v===0||!(o!=null&&o.replaceable),ge=f.length===0,me=l.useCallback(_=>i.changeInputtingFindString(_),[i]),ve=l.useCallback(_=>i.changeReplaceString(_),[i]),{focus:Se}=oe(i,n),Ce=l.useCallback(()=>{I===x?i.moveToNextMatch():(i.changeFindString(x),i.find())},[I,x,i]),Re=l.useCallback(()=>r.executeCommand(se.id),[r]),be=l.useCallback(async()=>{await r.executeCommand(re.id),Se()},[r]),ye=l.useCallback(_=>{i.changeFindDirection(_)},[i]),Me=l.useCallback(_=>{i.changeFindScope(_)},[i]),xe=l.useCallback(_=>{i.changeFindBy(_)},[i]),Ie=nt(s),Fe=st(s),De=rt(s);return l.useEffect(()=>{const _=A&&v===0;let D=null;return _&&(D=a.show({content:s.t("find-replace.dialog.no-match"),type:p.MessageType.Warning,delay:5e3})),()=>D==null?void 0:D.dispose()},[A,v,a,s]),u.jsxs(l.Fragment,{children:[u.jsx(p.FormLayout,{label:s.t("find-replace.dialog.find"),children:u.jsx(ae,{findCompleted:A,className:"univer-find-input",matchesCount:v,matchesPosition:m,findReplaceService:i,localeService:s,findString:x,onChange:me})}),u.jsx(p.FormLayout,{label:s.t("find-replace.dialog.replace"),children:u.jsx(p.Input,{placeholder:s.t("find-replace.dialog.replace-placeholder"),value:de,onChange:_=>ve(_)})}),u.jsx(p.FormLayout,{label:s.t("find-replace.dialog.find-direction.title"),children:u.jsx(p.Select,{value:ue,options:Fe,onChange:ye})}),u.jsx(p.FormDualColumnLayout,{children:u.jsxs(l.Fragment,{children:[u.jsx(p.FormLayout,{label:s.t("find-replace.dialog.find-scope.title"),children:u.jsx(p.Select,{value:he,options:Ie,onChange:Me})}),u.jsx(p.FormLayout,{label:s.t("find-replace.dialog.find-by.title"),children:u.jsx(p.Select,{value:pe,options:De,onChange:xe})})]})}),u.jsx(p.FormDualColumnLayout,{children:u.jsxs(l.Fragment,{children:[u.jsx(p.FormLayout,{children:u.jsx(p.Checkbox,{checked:V,value:V,onChange:_=>{i.changeCaseSensitive(_)},children:s.t("find-replace.dialog.case-sensitive")})}),u.jsx(p.FormLayout,{children:u.jsx(p.Checkbox,{checked:H,value:H,onChange:_=>{i.changeMatchesTheWholeCell(_)},children:s.t("find-replace.dialog.match-the-whole-cell")})})]})}),u.jsxs("div",{className:$.findReplaceButtonsGroup,children:[u.jsx(p.Button,{type:"primary",onClick:Ce,disabled:fe,children:s.t("find-replace.dialog.find")}),u.jsxs("span",{className:$.findReplaceButtonsGroupRight,children:[u.jsx(p.Button,{disabled:_e,onClick:Re,children:s.t("find-replace.dialog.replace")}),u.jsx(p.Button,{disabled:ge,onClick:be,children:s.t("find-replace.dialog.replace-all")})]})]})]})});function it(){const t=y.useDependency(b),e=y.useDependency(h.ILayoutService),n=y.useDependency(c.IContextService),i=h.useObservable(t.state$,void 0,!0),s=l.useRef(null);l.useEffect(()=>{let f;return s.current&&(f=e.registerContainerElement(s.current)),()=>f==null?void 0:f.dispose()},[e]);const r=l.useRef(null),a=l.useCallback(f=>n.setContextValue(J,f),[n]),o=l.useCallback(f=>n.setContextValue(Z,f),[n]);return l.useEffect(()=>{var g;const f=S.fromEvent(document,"focusin").subscribe(v=>{var m;v.target&&((m=s.current)!=null&&m.contains(v.target))?a(!0):a(!1),!r.current||!r.current.selectHasFocus()?o(!0):o(!1)});return(g=r.current)==null||g.focus(),a(!0),o(!0),()=>{f.unsubscribe(),a(!1)}},[a,o]),u.jsx("div",{className:$.findReplaceDialogContainer,ref:s,children:i.replaceRevealed?u.jsx(tt,{ref:r}):u.jsx(et,{ref:r})})}function nt(t){const e=t.getCurrentLocale();return l.useMemo(()=>[{label:t.t("find-replace.dialog.find-scope.current-sheet"),value:E.SUBUNIT},{label:t.t("find-replace.dialog.find-scope.workbook"),value:E.UNIT}],[e])}function st(t){const e=t.getCurrentLocale();return l.useMemo(()=>[{label:t.t("find-replace.dialog.find-direction.row"),value:P.ROW},{label:t.t("find-replace.dialog.find-direction.column"),value:P.COLUMN}],[e])}function rt(t){const e=t.getCurrentLocale();return l.useMemo(()=>[{label:t.t("find-replace.dialog.find-by.value"),value:T.VALUE},{label:t.t("find-replace.dialog.find-by.formula"),value:T.FORMULA}],[e])}function F(t){return t.getContextValue(J)}function at(t){return t.getContextValue(Q)}function ce(t){return t.getContextValue(Z)}const L="7_find-replace-shortcuts";function k(t){return t.getContextValue(c.FOCUSING_SHEET)}function G(t){return!t.getContextValue(c.EDITOR_ACTIVATED)}const ot={id:N.id,description:"find-replace.shortcut.open-find-dialog",binding:h.KeyCode.F|h.MetaKeys.CTRL_COMMAND,group:L,preconditions(t){return!F(t)&&k(t)&&G(t)}},ct={id:N.id,description:"find-replace.shortcut.open-find-dialog",binding:h.KeyCode.F|h.MetaKeys.CTRL_COMMAND,mac:h.KeyCode.F|h.MetaKeys.MAC_CTRL,preconditions(t){return!F(t)&&k(t)&&G(t)}},lt={id:W.id,description:"find-replace.shortcut.open-replace-dialog",binding:h.KeyCode.H|h.MetaKeys.CTRL_COMMAND,mac:h.KeyCode.H|h.MetaKeys.MAC_CTRL,group:L,preconditions(t){return k(t)&&G(t)&&(!F(t)||!at(t))}},dt={id:ee.id,description:"find-replace.shortcut.go-to-next-match",binding:h.KeyCode.ENTER,group:L,priority:1e3,preconditions(t){return ce(t)&&F(t)}},ut={id:te.id,description:"find-replace.shortcut.go-to-previous-match",binding:h.KeyCode.ENTER|h.MetaKeys.SHIFT,group:L,priority:1e3,preconditions(t){return ce(t)&&F(t)}};function ht(t){const e=t.get(c.IContextService);return{id:N.id,icon:"SearchIcon",tooltip:"find-replace.toolbar",group:h.MenuGroup.TOOLBAR_OTHERS,type:h.MenuItemType.BUTTON,positions:[h.MenuPosition.TOOLBAR_START],hidden$:h.getMenuHiddenObservable(t,c.UniverInstanceType.SHEET),disabled$:S.combineLatest([e.subscribeContextValue$(c.EDITOR_ACTIVATED),e.subscribeContextValue$(c.FOCUSING_SHEET)]).pipe(S.map(([n,i])=>n||!i))}}var pt=Object.defineProperty,ft=Object.getOwnPropertyDescriptor,_t=(t,e,n,i)=>{for(var s=i>1?void 0:i?ft(e,n):e,r=t.length-1,a;r>=0;r--)(a=t[r])&&(s=(i?a(e,n,s):a(s))||s);return i&&s&&pt(e,n,s),s},C=(t,e)=>(n,i)=>e(n,i,t);const K="DESKTOP_FIND_REPLACE_DIALOG",le=350,gt=20,mt=0;exports.FindReplaceController=class extends c.RxDisposable{constructor(e,n,i,s,r,a,o,f,g,v,m,I){super(),this._univerInstanceService=e,this._menuService=n,this._shortcutService=i,this._commandService=s,this._findReplaceService=r,this._logService=a,this._dialogService=o,this._contextService=f,this._layoutService=g,this._localeService=v,this._componentManager=m,this._injector=I,this._initCommands(),this._initUI(),this._initShortcuts()}_initCommands(){[N,W,ee,te,re,se].forEach(e=>{this.disposeWithMe(this._commandService.registerCommand(e))})}_initShortcuts(){[lt,ot,ct,ut,dt].forEach(e=>this.disposeWithMe(this._shortcutService.registerShortcut(e)))}_initUI(){this.disposeWithMe(this._menuService.addMenuItem(this._injector.invoke(ht))),this.disposeWithMe(this._componentManager.register("FindReplaceDialog",it)),this.disposeWithMe(this._componentManager.register("SearchIcon",Y)),this._findReplaceService.stateUpdates$.pipe(S.takeUntil(this.dispose$)).subscribe(e=>{e.revealed===!0&&this._openPanel()}),this.disposeWithMe(this._univerInstanceService.focused$.pipe(S.takeUntil(this.dispose$)).subscribe(e=>{(!e||!this._univerInstanceService.getUniverSheetInstance(e))&&this.closePanel()}))}_openPanel(){this._dialogService.open({id:K,draggable:!0,width:le,title:{title:this._localeService.t("find-replace.dialog.title")},children:{label:"FindReplaceDialog"},destroyOnClose:!0,defaultPosition:vt(),onClose:()=>this.closePanel()})}closePanel(){this._dialogService.close(K),this._findReplaceService.terminate(),queueMicrotask(()=>this._layoutService.focus())}};exports.FindReplaceController=_t([c.OnLifecycle(c.LifecycleStages.Rendered,exports.FindReplaceController),C(0,c.IUniverInstanceService),C(1,h.IMenuService),C(2,h.IShortcutService),C(3,c.ICommandService),C(4,b),C(5,c.ILogService),C(6,h.IDialogService),C(7,c.IContextService),C(8,h.ILayoutService),C(9,M.Inject(c.LocaleService)),C(10,M.Inject(h.ComponentManager)),C(11,M.Inject(M.Injector))],exports.FindReplaceController);function vt(){const{innerWidth:t}=window;return{x:t-le-gt,y:mt}}const St={"find-replace":{toolbar:"查找替换",shortcut:{"open-find-dialog":"打开查找对话框","open-replace-dialog":"打开替换对话框","close-dialog":"关闭查找替换对话框","go-to-next-match":"下一个匹配项","go-to-previous-match":"下一个匹配项"},dialog:{title:"查找",find:"查找",replace:"替换","replace-all":"替换全部","find-placeholder":"输入查找内容","advanced-finding":"替换 / 高级查找","replace-placeholder":"输入替换内容","case-sensitive":"匹配大小写","match-the-whole-cell":"匹配整个单元格","find-scope":{title:"查找范围","current-sheet":"当前子表",workbook:"整个工作簿"},"find-direction":{title:"查找顺序",column:"按列查找",row:"按行查找"},"find-by":{title:"查找方式",formula:"查找公式",value:"查找值"},"no-match":"已完成搜索,但是未找到任何匹配项","no-result":"无结果"},replace:{"all-success":"已全部替换 {0} 个匹配项","all-failure":"替换失败",confirm:{title:"确定要替换所有的匹配项吗?"}}},"find-replace-shortcuts":"查找替换"};var Ct=Object.defineProperty,Rt=Object.getOwnPropertyDescriptor,bt=(t,e,n,i)=>{for(var s=i>1?void 0:i?Rt(e,n):e,r=t.length-1,a;r>=0;r--)(a=t[r])&&(s=(i?a(e,n,s):a(s))||s);return i&&s&&Ct(e,n,s),s},yt=(t,e)=>(n,i)=>e(n,i,t);const Mt="FIND_REPLACE";exports.UniverFindReplacePlugin=class extends c.Plugin{constructor(e,n){super(Mt),this._injector=e,this._localeService=n,this._localeService.load({zhCN:St})}onStarting(e){[[exports.FindReplaceController],[b,{useClass:U}]].forEach(n=>{e.add(n)})}};exports.UniverFindReplacePlugin=bt([yt(1,M.Inject(c.LocaleService))],exports.UniverFindReplacePlugin);exports.FindBy=T;exports.FindDirection=P;exports.FindModel=Ue;exports.FindScope=E;exports.IFindReplaceService=b;
9
+ */var ke=l,Ge=Symbol.for("react.element"),Ve=Symbol.for("react.fragment"),He=Object.prototype.hasOwnProperty,Ke=ke.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,qe={key:!0,ref:!0,__self:!0,__source:!0};function te(t,e,n){var i,s={},r=null,a=null;n!==void 0&&(r=""+n),e.key!==void 0&&(r=""+e.key),e.ref!==void 0&&(a=e.ref);for(i in e)He.call(e,i)&&!qe.hasOwnProperty(i)&&(s[i]=e[i]);if(t&&t.defaultProps)for(i in e=t.defaultProps,e)s[i]===void 0&&(s[i]=e[i]);return{$$typeof:Ge,type:t,key:r,ref:a,props:s,_owner:Ke.current}}j.Fragment=Ve;j.jsx=te;j.jsxs=te;ee.exports=j;var u=ee.exports;const ie={id:"ui.command.replace-current-match",type:c.CommandType.COMMAND,handler:t=>t.get(b).replace()},ze="CONFIRM_REPLACE_ALL",ne={id:"ui.command.replace-all-matches",type:c.CommandType.COMMAND,handler:async t=>{const e=t.get(h.IConfirmService),n=t.get(c.LocaleService),i=t.get(h.IMessageService);if(!await e.confirm({id:ze,title:{title:n.t("find-replace.replace.confirm.title")},cancelText:n.t("button.cancel"),confirmText:n.t("button.confirm")}))return!1;const r=await t.get(b).replaceAll(),{success:a,failure:o}=r;return o>0?(a===0?i.show({type:p.MessageType.Error,content:n.t("find-replace.replace.all-failure")}):i.show({type:p.MessageType.Warning,content:n.t("find-replace.replace.partial-success",`${a}`,`${o}`)}),!1):(i.show({type:p.MessageType.Success,content:n.t("find-replace.replace.all-success",`${a}`)}),!0)}};function se(t){const{findCompleted:e,localeService:n,matchesCount:i,matchesPosition:s,findString:r,findReplaceService:a,onChange:o,...f}=t,v=e&&i===0?n.t("find-replace.dialog.no-result"):i===0?" ":void 0;return u.jsx(p.InputWithSlot,{autoFocus:!0,placeholder:n.t("find-replace.dialog.find-placeholder"),slot:u.jsx(p.Pager,{loop:!0,text:v,value:s,total:i,onChange:m=>{s===i&&m===1?a.moveToNextMatch():s===1&&m===i||m<s?a.moveToPreviousMatch():a.moveToNextMatch()}}),value:r,onChange:m=>o==null?void 0:o(m),...f})}const Ye="univer-find-replace-dialog-container",Ze="univer-find-replace-expand-container",Je="univer-button-text",Qe="univer-find-replace-buttons-group",Xe="univer-find-replace-buttons-group-right",$={findReplaceDialogContainer:Ye,findReplaceExpandContainer:Ze,buttonText:Je,findReplaceButtonsGroup:Qe,findReplaceButtonsGroupRight:Xe};function re(t,e){const n=l.useCallback(()=>{var s;(s=document.querySelector(".univer-find-input input"))==null||s.focus()},[]),i=l.useCallback(()=>{const s=document.querySelectorAll(".univer-find-replace-dialog-container .univer-select-selection-search-input");return Array.from(s).some(r=>r===document.activeElement)},[]);return l.useImperativeHandle(e,()=>({focus:n,selectHasFocus:i})),l.useEffect(()=>{const s=t.focusSignal$.subscribe(()=>n());return()=>s.unsubscribe()},[t,n]),{focus:n,selectHasFocus:i}}const et=l.forwardRef(function(e,n){const i=y.useDependency(c.LocaleService),s=y.useDependency(b),r=y.useDependency(c.ICommandService),a=h.useObservable(s.state$,void 0,!0),{findCompleted:o,findString:f,matchesCount:g,matchesPosition:v}=a,m=l.useCallback(()=>{r.executeCommand(W.id)},[r]),I=l.useCallback(x=>s.changeFindString(x),[s]);return re(s,n),u.jsxs(l.Fragment,{children:[u.jsx(se,{findCompleted:o,className:"univer-find-input",matchesCount:g,matchesPosition:v,findReplaceService:s,localeService:i,findString:f,onChange:I}),u.jsx("div",{className:$.findReplaceExpandContainer,children:u.jsx(p.Button,{type:"text",size:"small",onClick:m,children:i.t("find-replace.dialog.advanced-finding")})})]})}),tt=l.forwardRef(function(e,n){const i=y.useDependency(b),s=y.useDependency(c.LocaleService),r=y.useDependency(c.ICommandService),a=y.useDependency(h.IMessageService),o=h.useObservable(i.currentMatch$,void 0,!0),f=h.useObservable(i.replaceables$,void 0,!0),g=h.useObservable(i.state$,void 0,!0),{matchesCount:v,matchesPosition:m,findString:I,inputtingFindString:x,replaceString:ce,caseSensitive:le,matchesTheWholeCell:de,findDirection:ue,findScope:he,findBy:pe,findCompleted:A}=g,fe=x.length===0,_e=v===0||!(o!=null&&o.replaceable),ge=f.length===0,me=l.useCallback(_=>i.changeInputtingFindString(_),[i]),ve=l.useCallback(_=>i.changeReplaceString(_),[i]),{focus:Se}=re(i,n),Ce=l.useCallback(()=>{I===x?i.moveToNextMatch():(i.changeFindString(x),i.find())},[I,x,i]),Re=l.useCallback(()=>r.executeCommand(ie.id),[r]),be=l.useCallback(async()=>{await r.executeCommand(ne.id),Se()},[r]),ye=l.useCallback(_=>{i.changeFindDirection(_)},[i]),Me=l.useCallback(_=>{i.changeFindScope(_)},[i]),xe=l.useCallback(_=>{i.changeFindBy(_)},[i]),Ie=nt(s),Fe=st(s),De=rt(s);return l.useEffect(()=>{const _=A&&v===0;let D=null;return _&&(D=a.show({content:s.t("find-replace.dialog.no-match"),type:p.MessageType.Warning,delay:5e3})),()=>D==null?void 0:D.dispose()},[A,v,a,s]),u.jsxs(l.Fragment,{children:[u.jsx(p.FormLayout,{label:s.t("find-replace.dialog.find"),children:u.jsx(se,{findCompleted:A,className:"univer-find-input",matchesCount:v,matchesPosition:m,findReplaceService:i,localeService:s,findString:x,onChange:me})}),u.jsx(p.FormLayout,{label:s.t("find-replace.dialog.replace"),children:u.jsx(p.Input,{placeholder:s.t("find-replace.dialog.replace-placeholder"),value:ce,onChange:_=>ve(_)})}),u.jsx(p.FormLayout,{label:s.t("find-replace.dialog.find-direction.title"),children:u.jsx(p.Select,{value:ue,options:Fe,onChange:ye})}),u.jsx(p.FormDualColumnLayout,{children:u.jsxs(l.Fragment,{children:[u.jsx(p.FormLayout,{label:s.t("find-replace.dialog.find-scope.title"),children:u.jsx(p.Select,{value:he,options:Ie,onChange:Me})}),u.jsx(p.FormLayout,{label:s.t("find-replace.dialog.find-by.title"),children:u.jsx(p.Select,{value:pe,options:De,onChange:xe})})]})}),u.jsx(p.FormDualColumnLayout,{children:u.jsxs(l.Fragment,{children:[u.jsx(p.FormLayout,{children:u.jsx(p.Checkbox,{checked:le,onChange:_=>{i.changeCaseSensitive(_)},children:s.t("find-replace.dialog.case-sensitive")})}),u.jsx(p.FormLayout,{children:u.jsx(p.Checkbox,{checked:de,onChange:_=>{i.changeMatchesTheWholeCell(_)},children:s.t("find-replace.dialog.match-the-whole-cell")})})]})}),u.jsxs("div",{className:$.findReplaceButtonsGroup,children:[u.jsx(p.Button,{type:"primary",onClick:Ce,disabled:fe,children:s.t("find-replace.dialog.find")}),u.jsxs("span",{className:$.findReplaceButtonsGroupRight,children:[u.jsx(p.Button,{disabled:_e,onClick:Re,children:s.t("find-replace.dialog.replace")}),u.jsx(p.Button,{disabled:ge,onClick:be,children:s.t("find-replace.dialog.replace-all")})]})]})]})});function it(){const t=y.useDependency(b),e=y.useDependency(h.ILayoutService),n=y.useDependency(c.IContextService),i=h.useObservable(t.state$,void 0,!0),s=l.useRef(null);l.useEffect(()=>{let f;return s.current&&(f=e.registerContainerElement(s.current)),()=>f==null?void 0:f.dispose()},[e]);const r=l.useRef(null),a=l.useCallback(f=>n.setContextValue(Y,f),[n]),o=l.useCallback(f=>n.setContextValue(z,f),[n]);return l.useEffect(()=>{var g;const f=S.fromEvent(document,"focusin").subscribe(v=>{var m;v.target&&((m=s.current)!=null&&m.contains(v.target))?a(!0):a(!1),!r.current||!r.current.selectHasFocus()?o(!0):o(!1)});return(g=r.current)==null||g.focus(),a(!0),o(!0),()=>{f.unsubscribe(),a(!1)}},[a,o]),u.jsx("div",{className:$.findReplaceDialogContainer,ref:s,children:i.replaceRevealed?u.jsx(tt,{ref:r}):u.jsx(et,{ref:r})})}function nt(t){const e=t.getCurrentLocale();return l.useMemo(()=>[{label:t.t("find-replace.dialog.find-scope.current-sheet"),value:E.SUBUNIT},{label:t.t("find-replace.dialog.find-scope.workbook"),value:E.UNIT}],[e])}function st(t){const e=t.getCurrentLocale();return l.useMemo(()=>[{label:t.t("find-replace.dialog.find-direction.row"),value:P.ROW},{label:t.t("find-replace.dialog.find-direction.column"),value:P.COLUMN}],[e])}function rt(t){const e=t.getCurrentLocale();return l.useMemo(()=>[{label:t.t("find-replace.dialog.find-by.value"),value:T.VALUE},{label:t.t("find-replace.dialog.find-by.formula"),value:T.FORMULA}],[e])}function F(t){return t.getContextValue(Y)}function at(t){return t.getContextValue(Z)}function ae(t){return t.getContextValue(z)}const L="7_find-replace-shortcuts";function k(t){return t.getContextValue(c.FOCUSING_SHEET)}function G(t){return!t.getContextValue(c.EDITOR_ACTIVATED)}const ot={id:N.id,description:"find-replace.shortcut.open-find-dialog",binding:h.KeyCode.F|h.MetaKeys.CTRL_COMMAND,group:L,preconditions(t){return!F(t)&&k(t)&&G(t)}},ct={id:N.id,description:"find-replace.shortcut.open-find-dialog",binding:h.KeyCode.F|h.MetaKeys.CTRL_COMMAND,mac:h.KeyCode.F|h.MetaKeys.MAC_CTRL,preconditions(t){return!F(t)&&k(t)&&G(t)}},lt={id:W.id,description:"find-replace.shortcut.open-replace-dialog",binding:h.KeyCode.H|h.MetaKeys.CTRL_COMMAND,mac:h.KeyCode.H|h.MetaKeys.MAC_CTRL,group:L,preconditions(t){return k(t)&&G(t)&&(!F(t)||!at(t))}},dt={id:Q.id,description:"find-replace.shortcut.go-to-next-match",binding:h.KeyCode.ENTER,group:L,priority:1e3,preconditions(t){return ae(t)&&F(t)}},ut={id:X.id,description:"find-replace.shortcut.go-to-previous-match",binding:h.KeyCode.ENTER|h.MetaKeys.SHIFT,group:L,priority:1e3,preconditions(t){return ae(t)&&F(t)}};function ht(t){const e=t.get(c.IContextService);return{id:N.id,icon:"SearchIcon",tooltip:"find-replace.toolbar",group:h.MenuGroup.TOOLBAR_OTHERS,type:h.MenuItemType.BUTTON,positions:[h.MenuPosition.TOOLBAR_START],hidden$:h.getMenuHiddenObservable(t,c.UniverInstanceType.SHEET),disabled$:S.combineLatest([e.subscribeContextValue$(c.EDITOR_ACTIVATED),e.subscribeContextValue$(c.FOCUSING_SHEET)]).pipe(S.map(([n,i])=>n||!i))}}var pt=Object.defineProperty,ft=Object.getOwnPropertyDescriptor,_t=(t,e,n,i)=>{for(var s=i>1?void 0:i?ft(e,n):e,r=t.length-1,a;r>=0;r--)(a=t[r])&&(s=(i?a(e,n,s):a(s))||s);return i&&s&&pt(e,n,s),s},C=(t,e)=>(n,i)=>e(n,i,t);const V="DESKTOP_FIND_REPLACE_DIALOG",oe=350,gt=20,mt=-90;exports.FindReplaceController=class extends c.RxDisposable{constructor(e,n,i,s,r,a,o,f,g,v,m,I){super(),this._univerInstanceService=e,this._menuService=n,this._shortcutService=i,this._commandService=s,this._findReplaceService=r,this._logService=a,this._dialogService=o,this._contextService=f,this._layoutService=g,this._localeService=v,this._componentManager=m,this._injector=I,this._initCommands(),this._initUI(),this._initShortcuts()}_initCommands(){[N,W,Q,X,ne,ie].forEach(e=>{this.disposeWithMe(this._commandService.registerCommand(e))})}_initShortcuts(){[lt,ot,ct,ut,dt].forEach(e=>this.disposeWithMe(this._shortcutService.registerShortcut(e)))}_initUI(){this.disposeWithMe(this._menuService.addMenuItem(this._injector.invoke(ht))),this.disposeWithMe(this._componentManager.register("FindReplaceDialog",it)),this.disposeWithMe(this._componentManager.register("SearchIcon",q)),this._findReplaceService.stateUpdates$.pipe(S.takeUntil(this.dispose$)).subscribe(e=>{e.revealed===!0&&this._openPanel()}),this.disposeWithMe(this._univerInstanceService.focused$.pipe(S.takeUntil(this.dispose$)).subscribe(e=>{(!e||!this._univerInstanceService.getUniverSheetInstance(e))&&this.closePanel()}))}_openPanel(){this._dialogService.open({id:V,draggable:!0,width:oe,title:{title:this._localeService.t("find-replace.dialog.title")},children:{label:"FindReplaceDialog"},destroyOnClose:!0,defaultPosition:vt(),preservePositionOnDestroy:!0,onClose:()=>this.closePanel()})}closePanel(){this._dialogService.close(V),this._findReplaceService.terminate(),queueMicrotask(()=>this._layoutService.focus())}};exports.FindReplaceController=_t([c.OnLifecycle(c.LifecycleStages.Rendered,exports.FindReplaceController),C(0,c.IUniverInstanceService),C(1,h.IMenuService),C(2,h.IShortcutService),C(3,c.ICommandService),C(4,b),C(5,c.ILogService),C(6,h.IDialogService),C(7,c.IContextService),C(8,h.ILayoutService),C(9,M.Inject(c.LocaleService)),C(10,M.Inject(h.ComponentManager)),C(11,M.Inject(M.Injector))],exports.FindReplaceController);function vt(){const{innerWidth:t}=window;return{x:(t-oe)/2-gt,y:mt}}const St={"find-replace":{toolbar:"查找替换",shortcut:{"open-find-dialog":"打开查找对话框","open-replace-dialog":"打开替换对话框","close-dialog":"关闭查找替换对话框","go-to-next-match":"下一个匹配项","go-to-previous-match":"下一个匹配项"},dialog:{title:"查找",find:"查找",replace:"替换","replace-all":"替换全部","find-placeholder":"输入查找内容","advanced-finding":"替换 / 高级查找","replace-placeholder":"输入替换内容","case-sensitive":"匹配大小写","match-the-whole-cell":"匹配整个单元格","find-scope":{title:"查找范围","current-sheet":"当前子表",workbook:"整个工作簿"},"find-direction":{title:"查找顺序",column:"按列查找",row:"按行查找"},"find-by":{title:"查找方式",formula:"查找公式",value:"查找值"},"no-match":"已完成搜索,但是未找到任何匹配项","no-result":"无结果"},replace:{"all-success":"已全部替换 {0} 个匹配项","all-failure":"替换失败",confirm:{title:"确定要替换所有的匹配项吗?"}}},"find-replace-shortcuts":"查找替换"};var Ct=Object.defineProperty,Rt=Object.getOwnPropertyDescriptor,bt=(t,e,n,i)=>{for(var s=i>1?void 0:i?Rt(e,n):e,r=t.length-1,a;r>=0;r--)(a=t[r])&&(s=(i?a(e,n,s):a(s))||s);return i&&s&&Ct(e,n,s),s},yt=(t,e)=>(n,i)=>e(n,i,t);const Mt="FIND_REPLACE";exports.UniverFindReplacePlugin=class extends c.Plugin{constructor(e,n){super(Mt),this._injector=e,this._localeService=n,this._localeService.load({zhCN:St})}onStarting(e){[[exports.FindReplaceController],[b,{useClass:U}]].forEach(n=>{e.add(n)})}};exports.UniverFindReplacePlugin=bt([yt(1,M.Inject(c.LocaleService))],exports.UniverFindReplacePlugin);exports.FindBy=T;exports.FindDirection=P;exports.FindModel=Ue;exports.FindScope=E;exports.IFindReplaceService=b;
package/lib/es/index.js CHANGED
@@ -1,13 +1,13 @@
1
1
  var rt = Object.defineProperty;
2
2
  var at = (t, e, n) => e in t ? rt(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n;
3
3
  var c = (t, e, n) => (at(t, typeof e != "symbol" ? e + "" : e, n), n);
4
- import { Disposable as X, IUniverInstanceService as fe, ILogService as pe, IContextService as U, DisposableCollection as ot, toDisposable as q, CommandType as b, LocaleService as P, ICommandService as ee, FOCUSING_SHEET as _e, EDITOR_ACTIVATED as ge, UniverInstanceType as ct, OnLifecycle as lt, LifecycleStages as dt, RxDisposable as ht, Plugin as ut } from "@univerjs/core";
5
- import { createIdentifier as ft, Inject as y, Injector as me } from "@wendellhu/redi";
6
- import { IConfirmService as pt, IMessageService as ve, useObservable as I, ILayoutService as Se, KeyCode as x, MetaKeys as M, MenuGroup as _t, MenuItemType as gt, MenuPosition as mt, getMenuHiddenObservable as vt, ComponentManager as St, IMenuService as Ct, IShortcutService as Rt, IDialogService as xt } from "@univerjs/ui";
7
- import { throttleTime as Mt, BehaviorSubject as F, combineLatest as Ce, debounceTime as bt, Subject as Re, fromEvent as yt, map as It, takeUntil as ce } from "rxjs";
4
+ import { Disposable as X, IUniverInstanceService as he, ILogService as ue, toDisposable as q, IContextService as U, DisposableCollection as ot, CommandType as b, LocaleService as P, ICommandService as ee, FOCUSING_SHEET as fe, EDITOR_ACTIVATED as pe, UniverInstanceType as ct, RxDisposable as lt, OnLifecycle as dt, LifecycleStages as ht, Plugin as ut } from "@univerjs/core";
5
+ import { createIdentifier as ft, Inject as y, Injector as _e } from "@wendellhu/redi";
6
+ import { IConfirmService as pt, IMessageService as ge, useObservable as I, ILayoutService as me, KeyCode as x, MetaKeys as M, MenuGroup as _t, MenuItemType as gt, MenuPosition as mt, getMenuHiddenObservable as vt, ComponentManager as St, IMenuService as Ct, IShortcutService as Rt, IDialogService as xt } from "@univerjs/ui";
7
+ import { BehaviorSubject as F, Subject as ve, throttleTime as Mt, combineLatest as Se, debounceTime as bt, fromEvent as yt, map as It, takeUntil as ae } from "rxjs";
8
8
  import { RENDER_RAW_FORMULA_KEY as Ft } from "@univerjs/engine-render";
9
- import Pt, { forwardRef as B, useRef as z, createElement as xe, useCallback as _, Fragment as E, useEffect as j, useMemo as te, useImperativeHandle as Dt } from "react";
10
- import { MessageType as $, InputWithSlot as Ot, Pager as Tt, Button as N, FormLayout as R, Input as Et, Select as H, FormDualColumnLayout as le, Checkbox as de } from "@univerjs/design";
9
+ import Pt, { forwardRef as B, useRef as z, createElement as Ce, useCallback as _, Fragment as E, useEffect as j, useMemo as te, useImperativeHandle as Dt } from "react";
10
+ import { MessageType as $, InputWithSlot as Ot, Pager as Tt, Button as N, FormLayout as R, Input as Et, Select as H, FormDualColumnLayout as oe, Checkbox as ce } from "@univerjs/design";
11
11
  import { useDependency as S } from "@wendellhu/redi/react-bindings";
12
12
  var m = function() {
13
13
  return m = Object.assign || function(t) {
@@ -26,13 +26,13 @@ var m = function() {
26
26
  for (var s = 0, i = Object.getOwnPropertySymbols(t); s < i.length; s++)
27
27
  e.indexOf(i[s]) < 0 && Object.prototype.propertyIsEnumerable.call(t, i[s]) && (n[i[s]] = t[i[s]]);
28
28
  return n;
29
- }, Me = B(function(t, e) {
29
+ }, Re = B(function(t, e) {
30
30
  var n = t.icon, i = t.id, s = t.className, r = t.extend, a = $t(t, ["icon", "id", "className", "extend"]), o = "univerjs-icon univerjs-icon-".concat(i, " ").concat(s || "").trim(), d = z("_".concat(jt()));
31
- return be(n, "".concat(i), { defIds: n.defIds, idSuffix: d.current }, m({ ref: e, className: o }, a), r);
31
+ return xe(n, "".concat(i), { defIds: n.defIds, idSuffix: d.current }, m({ ref: e, className: o }, a), r);
32
32
  });
33
- function be(t, e, n, i, s) {
34
- return xe(t.tag, m(m({ key: e }, Nt(t, n, s)), i), (At(t, n).children || []).map(function(r, a) {
35
- return be(r, "".concat(e, "-").concat(t.tag, "-").concat(a), n, void 0, s);
33
+ function xe(t, e, n, i, s) {
34
+ return Ce(t.tag, m(m({ key: e }, Nt(t, n, s)), i), (At(t, n).children || []).map(function(r, a) {
35
+ return xe(r, "".concat(e, "-").concat(t.tag, "-").concat(a), n, void 0, s);
36
36
  }));
37
37
  }
38
38
  function Nt(t, e, n) {
@@ -53,17 +53,17 @@ function At(t, e) {
53
53
  function jt() {
54
54
  return Math.random().toString(36).substring(2, 8);
55
55
  }
56
- Me.displayName = "UniverIcon";
57
- var wt = { 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" } }] }] }, ye = B(function(t, e) {
58
- return xe(Me, Object.assign({}, t, {
56
+ Re.displayName = "UniverIcon";
57
+ var wt = { 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" } }] }] }, Me = B(function(t, e) {
58
+ return Ce(Re, Object.assign({}, t, {
59
59
  id: "search-single-16",
60
60
  ref: e,
61
61
  icon: wt
62
62
  }));
63
63
  });
64
- ye.displayName = "SearchSingle16";
65
- const Ie = "FIND_REPLACE_INPUT_FOCUS", Fe = "FIND_REPLACE_DIALOG_FOCUS", Pe = "FIND_REPLACE_REPLACE_REVEALED";
66
- var Lt = Object.defineProperty, Ut = Object.getOwnPropertyDescriptor, De = (t, e, n, i) => {
64
+ Me.displayName = "SearchSingle16";
65
+ const be = "FIND_REPLACE_INPUT_FOCUS", ye = "FIND_REPLACE_DIALOG_FOCUS", Ie = "FIND_REPLACE_REPLACE_REVEALED";
66
+ var Lt = Object.defineProperty, Ut = Object.getOwnPropertyDescriptor, Fe = (t, e, n, i) => {
67
67
  for (var s = i > 1 ? void 0 : i ? Ut(e, n) : e, r = t.length - 1, a; r >= 0; r--)
68
68
  (a = t[r]) && (s = (i ? a(e, n, s) : a(s)) || s);
69
69
  return i && s && Lt(e, n, s), s;
@@ -139,7 +139,7 @@ let K = class extends X {
139
139
  }
140
140
  // When a document's content changes, we should reset all matches and try to move to the next match.
141
141
  _subscribeToModelsChanges(e) {
142
- const n = this._currentSearchingDisposables = new ot(), i = Ce(e.map((s) => s.matchesUpdate$)).pipe(bt(220)).subscribe(([...s]) => {
142
+ const n = this._currentSearchingDisposables = new ot(), i = Se(e.map((s) => s.matchesUpdate$)).pipe(bt(220)).subscribe(([...s]) => {
143
143
  const r = this._matches = s.flat();
144
144
  if (r.length) {
145
145
  const a = this._moveToInitialMatch(this._findModels, r, !0);
@@ -210,9 +210,9 @@ let K = class extends X {
210
210
  return this.currentMatch$.next(a), o;
211
211
  }
212
212
  };
213
- K = De([
214
- w(2, fe),
215
- w(3, pe)
213
+ K = Fe([
214
+ w(2, he),
215
+ w(3, ue)
216
216
  ], K);
217
217
  var Y = /* @__PURE__ */ ((t) => (t.ROW = "row", t.COLUMN = "column", t))(Y || {}), Z = /* @__PURE__ */ ((t) => (t.VALUE = "value", t.FORMULA = "formula", t))(Z || {}), J = /* @__PURE__ */ ((t) => (t.SUBUNIT = "subunit", t.UNIT = "unit", t))(J || {});
218
218
  function ie() {
@@ -234,7 +234,7 @@ function ie() {
234
234
  }
235
235
  class Wt {
236
236
  constructor() {
237
- c(this, "_stateUpdates$", new Re());
237
+ c(this, "_stateUpdates$", new ve());
238
238
  c(this, "stateUpdates$", this._stateUpdates$.asObservable());
239
239
  c(this, "_state$", new F(ie()));
240
240
  c(this, "state$", this._state$.asObservable());
@@ -323,7 +323,7 @@ let Q = class extends X {
323
323
  c(this, "currentMatch$", this._currentMatch$.asObservable());
324
324
  c(this, "_replaceables$", new F([]));
325
325
  c(this, "replaceables$", this._replaceables$.asObservable());
326
- c(this, "_focusSignal$", new Re());
326
+ c(this, "_focusSignal$", new ve());
327
327
  c(this, "focusSignal$", this._focusSignal$.asObservable());
328
328
  this._injector = e, this._contextService = n;
329
329
  }
@@ -415,14 +415,14 @@ let Q = class extends X {
415
415
  return this._providers.add(e), q(() => this._providers.delete(e));
416
416
  }
417
417
  _toggleRevealReplace(e) {
418
- this._contextService.setContextValue(Pe, e);
418
+ this._contextService.setContextValue(Ie, e);
419
419
  }
420
420
  _toggleDisplayRawFormula(e) {
421
421
  this._contextService.setContextValue(Ft, e);
422
422
  }
423
423
  };
424
- Q = De([
425
- w(0, y(me)),
424
+ Q = Fe([
425
+ w(0, y(_e)),
426
426
  w(1, U)
427
427
  ], Q);
428
428
  const W = {
@@ -439,16 +439,16 @@ const W = {
439
439
  const e = t.get(v);
440
440
  return e.revealed ? e.replaceRevealed ? e.focusFindInput() : e.revealReplace() : e.start(!0), !0;
441
441
  }
442
- }, Oe = {
442
+ }, Pe = {
443
443
  type: b.OPERATION,
444
444
  id: "ui.operation.go-to-next-match",
445
445
  handler: (t) => (t.get(v).moveToNextMatch(), !0)
446
- }, Te = {
446
+ }, De = {
447
447
  type: b.OPERATION,
448
448
  id: "ui.operation.go-to-previous-match",
449
449
  handler: (t) => (t.get(v).moveToPreviousMatch(), !0)
450
450
  };
451
- var Ee = { exports: {} }, G = {};
451
+ var Oe = { exports: {} }, G = {};
452
452
  /**
453
453
  * @license React
454
454
  * react-jsx-runtime.production.min.js
@@ -459,7 +459,7 @@ var Ee = { exports: {} }, G = {};
459
459
  * LICENSE file in the root directory of this source tree.
460
460
  */
461
461
  var Gt = Pt, kt = Symbol.for("react.element"), Vt = Symbol.for("react.fragment"), Ht = Object.prototype.hasOwnProperty, qt = Gt.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, zt = { key: !0, ref: !0, __self: !0, __source: !0 };
462
- function $e(t, e, n) {
462
+ function Te(t, e, n) {
463
463
  var i, s = {}, r = null, a = null;
464
464
  n !== void 0 && (r = "" + n), e.key !== void 0 && (r = "" + e.key), e.ref !== void 0 && (a = e.ref);
465
465
  for (i in e)
@@ -470,19 +470,19 @@ function $e(t, e, n) {
470
470
  return { $$typeof: kt, type: t, key: r, ref: a, props: s, _owner: qt.current };
471
471
  }
472
472
  G.Fragment = Vt;
473
- G.jsx = $e;
474
- G.jsxs = $e;
475
- Ee.exports = G;
476
- var l = Ee.exports;
477
- const Ne = {
473
+ G.jsx = Te;
474
+ G.jsxs = Te;
475
+ Oe.exports = G;
476
+ var l = Oe.exports;
477
+ const Ee = {
478
478
  id: "ui.command.replace-current-match",
479
479
  type: b.COMMAND,
480
480
  handler: (t) => t.get(v).replace()
481
- }, Kt = "CONFIRM_REPLACE_ALL", Ae = {
481
+ }, Kt = "CONFIRM_REPLACE_ALL", $e = {
482
482
  id: "ui.command.replace-all-matches",
483
483
  type: b.COMMAND,
484
484
  handler: async (t) => {
485
- const e = t.get(pt), n = t.get(P), i = t.get(ve);
485
+ const e = t.get(pt), n = t.get(P), i = t.get(ge);
486
486
  if (!await e.confirm({
487
487
  id: Kt,
488
488
  title: { title: n.t("find-replace.replace.confirm.title") },
@@ -503,7 +503,7 @@ const Ne = {
503
503
  }), !0);
504
504
  }
505
505
  };
506
- function je(t) {
506
+ function Ne(t) {
507
507
  const { findCompleted: e, localeService: n, matchesCount: i, matchesPosition: s, findString: r, findReplaceService: a, onChange: o, ...d } = t, p = e && i === 0 ? n.t("find-replace.dialog.no-result") : i === 0 ? " " : void 0;
508
508
  return /* @__PURE__ */ l.jsx(
509
509
  Ot,
@@ -535,7 +535,7 @@ const Yt = "univer-find-replace-dialog-container", Zt = "univer-find-replace-exp
535
535
  findReplaceButtonsGroup: Qt,
536
536
  findReplaceButtonsGroupRight: Xt
537
537
  };
538
- function we(t, e) {
538
+ function Ae(t, e) {
539
539
  const n = _(() => {
540
540
  var s;
541
541
  (s = document.querySelector(".univer-find-input input")) == null || s.focus();
@@ -552,9 +552,9 @@ const ei = B(function(e, n) {
552
552
  const i = S(P), s = S(v), r = S(ee), a = I(s.state$, void 0, !0), { findCompleted: o, findString: d, matchesCount: u, matchesPosition: p } = a, f = _(() => {
553
553
  r.executeCommand(ne.id);
554
554
  }, [r]), O = _((C) => s.changeFindString(C), [s]);
555
- return we(s, n), /* @__PURE__ */ l.jsxs(E, { children: [
555
+ return Ae(s, n), /* @__PURE__ */ l.jsxs(E, { children: [
556
556
  /* @__PURE__ */ l.jsx(
557
- je,
557
+ Ne,
558
558
  {
559
559
  findCompleted: o,
560
560
  className: "univer-find-input",
@@ -569,14 +569,14 @@ const ei = B(function(e, n) {
569
569
  /* @__PURE__ */ l.jsx("div", { className: L.findReplaceExpandContainer, children: /* @__PURE__ */ l.jsx(N, { type: "text", size: "small", onClick: f, children: i.t("find-replace.dialog.advanced-finding") }) })
570
570
  ] });
571
571
  }), ti = B(function(e, n) {
572
- const i = S(v), s = S(P), r = S(ee), a = S(ve), o = I(i.currentMatch$, void 0, !0), d = I(i.replaceables$, void 0, !0), u = I(i.state$, void 0, !0), {
572
+ const i = S(v), s = S(P), r = S(ee), a = S(ge), o = I(i.currentMatch$, void 0, !0), d = I(i.replaceables$, void 0, !0), u = I(i.state$, void 0, !0), {
573
573
  matchesCount: p,
574
574
  matchesPosition: f,
575
575
  findString: O,
576
576
  inputtingFindString: C,
577
- replaceString: Be,
578
- caseSensitive: ae,
579
- matchesTheWholeCell: oe,
577
+ replaceString: Le,
578
+ caseSensitive: Ue,
579
+ matchesTheWholeCell: Be,
580
580
  findDirection: We,
581
581
  findScope: Ge,
582
582
  findBy: ke,
@@ -587,10 +587,10 @@ const ei = B(function(e, n) {
587
587
  ), Ke = _(
588
588
  (h) => i.changeReplaceString(h),
589
589
  [i]
590
- ), { focus: Ye } = we(i, n), Ze = _(() => {
590
+ ), { focus: Ye } = Ae(i, n), Ze = _(() => {
591
591
  O === C ? i.moveToNextMatch() : (i.changeFindString(C), i.find());
592
- }, [O, C, i]), Je = _(() => r.executeCommand(Ne.id), [r]), Qe = _(async () => {
593
- await r.executeCommand(Ae.id), Ye();
592
+ }, [O, C, i]), Je = _(() => r.executeCommand(Ee.id), [r]), Qe = _(async () => {
593
+ await r.executeCommand($e.id), Ye();
594
594
  }, [r]), Xe = _((h) => {
595
595
  i.changeFindDirection(h);
596
596
  }, [i]), et = _((h) => {
@@ -608,7 +608,7 @@ const ei = B(function(e, n) {
608
608
  })), () => T == null ? void 0 : T.dispose();
609
609
  }, [V, p, a, s]), /* @__PURE__ */ l.jsxs(E, { children: [
610
610
  /* @__PURE__ */ l.jsx(R, { label: s.t("find-replace.dialog.find"), children: /* @__PURE__ */ l.jsx(
611
- je,
611
+ Ne,
612
612
  {
613
613
  findCompleted: V,
614
614
  className: "univer-find-input",
@@ -624,21 +624,20 @@ const ei = B(function(e, n) {
624
624
  Et,
625
625
  {
626
626
  placeholder: s.t("find-replace.dialog.replace-placeholder"),
627
- value: Be,
627
+ value: Le,
628
628
  onChange: (h) => Ke(h)
629
629
  }
630
630
  ) }),
631
631
  /* @__PURE__ */ l.jsx(R, { label: s.t("find-replace.dialog.find-direction.title"), children: /* @__PURE__ */ l.jsx(H, { value: We, options: nt, onChange: Xe }) }),
632
- /* @__PURE__ */ l.jsx(le, { children: /* @__PURE__ */ l.jsxs(E, { children: [
632
+ /* @__PURE__ */ l.jsx(oe, { children: /* @__PURE__ */ l.jsxs(E, { children: [
633
633
  /* @__PURE__ */ l.jsx(R, { label: s.t("find-replace.dialog.find-scope.title"), children: /* @__PURE__ */ l.jsx(H, { value: Ge, options: it, onChange: et }) }),
634
634
  /* @__PURE__ */ l.jsx(R, { label: s.t("find-replace.dialog.find-by.title"), children: /* @__PURE__ */ l.jsx(H, { value: ke, options: st, onChange: tt }) })
635
635
  ] }) }),
636
- /* @__PURE__ */ l.jsx(le, { children: /* @__PURE__ */ l.jsxs(E, { children: [
636
+ /* @__PURE__ */ l.jsx(oe, { children: /* @__PURE__ */ l.jsxs(E, { children: [
637
637
  /* @__PURE__ */ l.jsx(R, { children: /* @__PURE__ */ l.jsx(
638
- de,
638
+ ce,
639
639
  {
640
- checked: ae,
641
- value: ae,
640
+ checked: Ue,
642
641
  onChange: (h) => {
643
642
  i.changeCaseSensitive(h);
644
643
  },
@@ -646,10 +645,9 @@ const ei = B(function(e, n) {
646
645
  }
647
646
  ) }),
648
647
  /* @__PURE__ */ l.jsx(R, { children: /* @__PURE__ */ l.jsx(
649
- de,
648
+ ce,
650
649
  {
651
- checked: oe,
652
- value: oe,
650
+ checked: Be,
653
651
  onChange: (h) => {
654
652
  i.changeMatchesTheWholeCell(h);
655
653
  },
@@ -667,16 +665,16 @@ const ei = B(function(e, n) {
667
665
  ] });
668
666
  });
669
667
  function ii() {
670
- const t = S(v), e = S(Se), n = S(U), i = I(t.state$, void 0, !0), s = z(null);
668
+ const t = S(v), e = S(me), n = S(U), i = I(t.state$, void 0, !0), s = z(null);
671
669
  j(() => {
672
670
  let d;
673
671
  return s.current && (d = e.registerContainerElement(s.current)), () => d == null ? void 0 : d.dispose();
674
672
  }, [e]);
675
673
  const r = z(null), a = _(
676
- (d) => n.setContextValue(Fe, d),
674
+ (d) => n.setContextValue(ye, d),
677
675
  [n]
678
676
  ), o = _(
679
- (d) => n.setContextValue(Ie, d),
677
+ (d) => n.setContextValue(be, d),
680
678
  [n]
681
679
  );
682
680
  return j(() => {
@@ -712,20 +710,20 @@ function ri(t) {
712
710
  ], [e]);
713
711
  }
714
712
  function D(t) {
715
- return t.getContextValue(Fe);
713
+ return t.getContextValue(ye);
716
714
  }
717
715
  function ai(t) {
718
- return t.getContextValue(Pe);
719
- }
720
- function Le(t) {
721
716
  return t.getContextValue(Ie);
722
717
  }
718
+ function je(t) {
719
+ return t.getContextValue(be);
720
+ }
723
721
  const k = "7_find-replace-shortcuts";
724
722
  function se(t) {
725
- return t.getContextValue(_e);
723
+ return t.getContextValue(fe);
726
724
  }
727
725
  function re(t) {
728
- return !t.getContextValue(ge);
726
+ return !t.getContextValue(pe);
729
727
  }
730
728
  const oi = {
731
729
  id: W.id,
@@ -753,22 +751,22 @@ const oi = {
753
751
  return se(t) && re(t) && (!D(t) || !ai(t));
754
752
  }
755
753
  }, di = {
756
- id: Oe.id,
754
+ id: Pe.id,
757
755
  description: "find-replace.shortcut.go-to-next-match",
758
756
  binding: x.ENTER,
759
757
  group: k,
760
758
  priority: 1e3,
761
759
  preconditions(t) {
762
- return Le(t) && D(t);
760
+ return je(t) && D(t);
763
761
  }
764
762
  }, hi = {
765
- id: Te.id,
763
+ id: De.id,
766
764
  description: "find-replace.shortcut.go-to-previous-match",
767
765
  binding: x.ENTER | M.SHIFT,
768
766
  group: k,
769
767
  priority: 1e3,
770
768
  preconditions(t) {
771
- return Le(t) && D(t);
769
+ return je(t) && D(t);
772
770
  }
773
771
  };
774
772
  function ui(t) {
@@ -781,9 +779,9 @@ function ui(t) {
781
779
  type: gt.BUTTON,
782
780
  positions: [mt.TOOLBAR_START],
783
781
  hidden$: vt(t, ct.SHEET),
784
- disabled$: Ce([
785
- e.subscribeContextValue$(ge),
786
- e.subscribeContextValue$(_e)
782
+ disabled$: Se([
783
+ e.subscribeContextValue$(pe),
784
+ e.subscribeContextValue$(fe)
787
785
  ]).pipe(It(([n, i]) => n || !i))
788
786
  };
789
787
  }
@@ -792,8 +790,8 @@ var fi = Object.defineProperty, pi = Object.getOwnPropertyDescriptor, _i = (t, e
792
790
  (a = t[r]) && (s = (i ? a(e, n, s) : a(s)) || s);
793
791
  return i && s && fi(e, n, s), s;
794
792
  }, g = (t, e) => (n, i) => e(n, i, t);
795
- const he = "DESKTOP_FIND_REPLACE_DIALOG", Ue = 350, gi = 20, mi = 0;
796
- let A = class extends ht {
793
+ const le = "DESKTOP_FIND_REPLACE_DIALOG", we = 350, gi = 20, mi = -90;
794
+ let A = class extends lt {
797
795
  constructor(t, e, n, i, s, r, a, o, d, u, p, f) {
798
796
  super(), this._univerInstanceService = t, this._menuService = e, this._shortcutService = n, this._commandService = i, this._findReplaceService = s, this._logService = r, this._dialogService = a, this._contextService = o, this._layoutService = d, this._localeService = u, this._componentManager = p, this._injector = f, this._initCommands(), this._initUI(), this._initShortcuts();
799
797
  }
@@ -801,10 +799,10 @@ let A = class extends ht {
801
799
  [
802
800
  W,
803
801
  ne,
804
- Oe,
805
- Te,
806
- Ae,
807
- Ne
802
+ Pe,
803
+ De,
804
+ $e,
805
+ Ee
808
806
  ].forEach((t) => {
809
807
  this.disposeWithMe(this._commandService.registerCommand(t));
810
808
  });
@@ -819,48 +817,49 @@ let A = class extends ht {
819
817
  ].forEach((t) => this.disposeWithMe(this._shortcutService.registerShortcut(t)));
820
818
  }
821
819
  _initUI() {
822
- this.disposeWithMe(this._menuService.addMenuItem(this._injector.invoke(ui))), this.disposeWithMe(this._componentManager.register("FindReplaceDialog", ii)), this.disposeWithMe(this._componentManager.register("SearchIcon", ye)), this._findReplaceService.stateUpdates$.pipe(ce(this.dispose$)).subscribe((t) => {
820
+ this.disposeWithMe(this._menuService.addMenuItem(this._injector.invoke(ui))), this.disposeWithMe(this._componentManager.register("FindReplaceDialog", ii)), this.disposeWithMe(this._componentManager.register("SearchIcon", Me)), this._findReplaceService.stateUpdates$.pipe(ae(this.dispose$)).subscribe((t) => {
823
821
  t.revealed === !0 && this._openPanel();
824
822
  }), this.disposeWithMe(
825
- this._univerInstanceService.focused$.pipe(ce(this.dispose$)).subscribe((t) => {
823
+ this._univerInstanceService.focused$.pipe(ae(this.dispose$)).subscribe((t) => {
826
824
  (!t || !this._univerInstanceService.getUniverSheetInstance(t)) && this.closePanel();
827
825
  })
828
826
  );
829
827
  }
830
828
  _openPanel() {
831
829
  this._dialogService.open({
832
- id: he,
830
+ id: le,
833
831
  draggable: !0,
834
- width: Ue,
832
+ width: we,
835
833
  title: { title: this._localeService.t("find-replace.dialog.title") },
836
834
  children: { label: "FindReplaceDialog" },
837
835
  destroyOnClose: !0,
838
836
  defaultPosition: vi(),
837
+ preservePositionOnDestroy: !0,
839
838
  onClose: () => this.closePanel()
840
839
  });
841
840
  }
842
841
  closePanel() {
843
- this._dialogService.close(he), this._findReplaceService.terminate(), queueMicrotask(() => this._layoutService.focus());
842
+ this._dialogService.close(le), this._findReplaceService.terminate(), queueMicrotask(() => this._layoutService.focus());
844
843
  }
845
844
  };
846
845
  A = _i([
847
- lt(dt.Rendered, A),
848
- g(0, fe),
846
+ dt(ht.Rendered, A),
847
+ g(0, he),
849
848
  g(1, Ct),
850
849
  g(2, Rt),
851
850
  g(3, ee),
852
851
  g(4, v),
853
- g(5, pe),
852
+ g(5, ue),
854
853
  g(6, xt),
855
854
  g(7, U),
856
- g(8, Se),
855
+ g(8, me),
857
856
  g(9, y(P)),
858
857
  g(10, y(St)),
859
- g(11, y(me))
858
+ g(11, y(_e))
860
859
  ], A);
861
860
  function vi() {
862
861
  const { innerWidth: t } = window;
863
- return { x: t - Ue - gi, y: mi };
862
+ return { x: (t - we) / 2 - gi, y: mi };
864
863
  }
865
864
  const Si = {
866
865
  "find-replace": {
@@ -916,7 +915,7 @@ var Ci = Object.defineProperty, Ri = Object.getOwnPropertyDescriptor, xi = (t, e
916
915
  return i && s && Ci(e, n, s), s;
917
916
  }, Mi = (t, e) => (n, i) => e(n, i, t);
918
917
  const bi = "FIND_REPLACE";
919
- let ue = class extends ut {
918
+ let de = class extends ut {
920
919
  constructor(t, e) {
921
920
  super(bi), this._injector = t, this._localeService = e, this._localeService.load({
922
921
  zhCN: Si
@@ -930,9 +929,9 @@ let ue = class extends ut {
930
929
  );
931
930
  }
932
931
  };
933
- ue = xi([
932
+ de = xi([
934
933
  Mi(1, y(P))
935
- ], ue);
934
+ ], de);
936
935
  export {
937
936
  Z as FindBy,
938
937
  Y as FindDirection,
@@ -940,5 +939,5 @@ export {
940
939
  A as FindReplaceController,
941
940
  J as FindScope,
942
941
  v as IFindReplaceService,
943
- ue as UniverFindReplacePlugin
942
+ de as UniverFindReplacePlugin
944
943
  };
package/lib/umd/index.js CHANGED
@@ -1,4 +1,4 @@
1
- (function(u,o){typeof exports=="object"&&typeof module<"u"?o(exports,require("@univerjs/core"),require("@wendellhu/redi"),require("@univerjs/ui"),require("rxjs"),require("@univerjs/engine-render"),require("react"),require("@univerjs/design"),require("@wendellhu/redi/react-bindings")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@wendellhu/redi","@univerjs/ui","rxjs","@univerjs/engine-render","react","@univerjs/design","@wendellhu/redi/react-bindings"],o):(u=typeof globalThis<"u"?globalThis:u||self,o(u.UniverFindReplace={},u.UniverCore,u["@wendellhu/redi"],u.UniverUi,u.rxjs,u.UniverEngineRender,u.React,u.UniverDesign,u["@wendellhu/redi/react-bindings"]))})(this,function(u,o,R,f,S,he,l,p,I){"use strict";var St=Object.defineProperty;var Ct=(u,o,R)=>o in u?St(u,o,{enumerable:!0,configurable:!0,writable:!0,value:R}):u[o]=R;var h=(u,o,R)=>(Ct(u,typeof o!="symbol"?o+"":o,R),R);var b=function(){return b=Object.assign||function(n){for(var e,i=1,t=arguments.length;i<t;i++){e=arguments[i];for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&(n[s]=e[s])}return n},b.apply(this,arguments)},ue=function(n,e){var i={};for(var t in n)Object.prototype.hasOwnProperty.call(n,t)&&e.indexOf(t)<0&&(i[t]=n[t]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,t=Object.getOwnPropertySymbols(n);s<t.length;s++)e.indexOf(t[s])<0&&Object.prototype.propertyIsEnumerable.call(n,t[s])&&(i[t[s]]=n[t[s]]);return i},K=l.forwardRef(function(n,e){var i=n.icon,t=n.id,s=n.className,a=n.extend,r=ue(n,["icon","id","className","extend"]),c="univerjs-icon univerjs-icon-".concat(t," ").concat(s||"").trim(),_=l.useRef("_".concat(_e()));return $(i,"".concat(t),{defIds:i.defIds,idSuffix:_.current},b({ref:e,className:c},r),a)});function $(n,e,i,t,s){return l.createElement(n.tag,b(b({key:e},fe(n,i,s)),t),(pe(n,i).children||[]).map(function(a,r){return $(a,"".concat(e,"-").concat(n.tag,"-").concat(r),i,void 0,s)}))}function fe(n,e,i){var t=b({},n.attrs);i!=null&&i.colorChannel1&&t.fill==="colorChannel1"&&(t.fill=i.colorChannel1);var s=e.defIds;return!s||s.length===0||(n.tag==="use"&&t["xlink:href"]&&(t["xlink:href"]=t["xlink:href"]+e.idSuffix),Object.entries(t).forEach(function(a){var r=a[0],c=a[1];typeof c=="string"&&(t[r]=c.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))})),t}function pe(n,e){var i,t=e.defIds;return!t||t.length===0?n:n.tag==="defs"&&(!((i=n.children)===null||i===void 0)&&i.length)?b(b({},n),{children:n.children.map(function(s){return typeof s.attrs.id=="string"&&t&&t.indexOf(s.attrs.id)>-1?b(b({},s),{attrs:b(b({},s.attrs),{id:s.attrs.id+e.idSuffix})}):s})}):n}function _e(){return Math.random().toString(36).substring(2,8)}K.displayName="UniverIcon";var ge={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"}}]}]},z=l.forwardRef(function(n,e){return l.createElement(K,Object.assign({},n,{id:"search-single-16",ref:e,icon:ge}))});z.displayName="SearchSingle16";const Y="FIND_REPLACE_INPUT_FOCUS",Z="FIND_REPLACE_DIALOG_FOCUS",J="FIND_REPLACE_REPLACE_REVEALED";var me=Object.defineProperty,ve=Object.getOwnPropertyDescriptor,Q=(n,e,i,t)=>{for(var s=t>1?void 0:t?ve(e,i):e,a=n.length-1,r;a>=0;a--)(r=n[a])&&(s=(t?r(e,i,s):r(s))||s);return t&&s&&me(e,i,s),s},T=(n,e)=>(i,t)=>e(i,t,n);class Se extends o.Disposable{}const y=R.createIdentifier("find-replace.service");function Ce(n){return typeof n.findString<"u"||typeof n.inputtingFindString<"u"||typeof n.findDirection<"u"||typeof n.matchesTheWholeCell<"u"||typeof n.caseSensitive<"u"||typeof n.findScope<"u"||typeof n.findBy<"u"}let U=class extends o.Disposable{constructor(e,i,t,s){super();h(this,"currentMatch$",new S.BehaviorSubject(null));h(this,"replaceables$",new S.BehaviorSubject([]));h(this,"_findModels",[]);h(this,"_matchingModel",null);h(this,"_matches",[]);h(this,"_currentSearchingDisposables",null);this._state=e,this._providers=i,this._univerInstanceService=t,this._logService=s,this.disposeWithMe(this._state.stateUpdates$.pipe(S.throttleTime(200,void 0,{leading:!0,trailing:!0})).subscribe(async a=>{const r=this._state.state;Ce(a)&&(r.findString!==""&&!r.replaceRevealed?(await this._startSearching(),this._state.changeState({findCompleted:!0})):a.replaceRevealed!==!0&&this._stopSearching())}))}get searched(){return this._findModels.length>0}dispose(){super.dispose(),this._stopSearching(),this.currentMatch$.complete(),this.replaceables$.complete(),this._state.changeState({...B(),revealed:!1})}async start(){if(!this._state.findString)return{results:[]};const e=await this._startSearching();return this._state.changeState({findCompleted:!0}),e}async _startSearching(){if(!this._state.findString)return{results:[]};const e=Array.from(this._providers),i=this._findModels=(await Promise.all(e.map(a=>a.find({findString:this._state.findString,findDirection:this._state.findDirection,findScope:this._state.findScope,findBy:this._state.findBy,replaceRevealed:this._state.replaceRevealed,caseSensitive:this._state.caseSensitive,matchesTheWholeCell:this._state.matchesTheWholeCell})))).flat();this._subscribeToModelsChanges(i);const t=this._matches=i.map(a=>a.getMatches()).flat();if(this.replaceables$.next(t.filter(a=>a.replaceable)),!t.length)return this._state.changeState({matchesCount:0,matchesPosition:0}),{results:[]};const s=this._moveToInitialMatch(i,t);return this._state.changeState({matchesCount:t.length,matchesPosition:s+1}),{results:t}}_stopSearching(){var e;this._providers.forEach(i=>i.terminate()),this._findModels=[],this._matches=[],this._matchingModel=null,(e=this._currentSearchingDisposables)==null||e.dispose(),this._currentSearchingDisposables=null,this.currentMatch$.next(null),this.replaceables$.next([]),this._state.changeState({findCompleted:!1,matchesCount:0,matchesPosition:0})}_subscribeToModelsChanges(e){const i=this._currentSearchingDisposables=new o.DisposableCollection,t=S.combineLatest(e.map(s=>s.matchesUpdate$)).pipe(S.debounceTime(220)).subscribe(([...s])=>{const a=this._matches=s.flat();if(a.length){const r=this._moveToInitialMatch(this._findModels,a,!0);this._state.changeState({matchesCount:a.length,matchesPosition:r+1}),this.replaceables$.next(a.filter(c=>c.replaceable))}else this._state.changeState({matchesCount:0,matchesPosition:0}),this.replaceables$.next([])});e.forEach(s=>i.add(o.toDisposable(s.activelyChangingMatch$.subscribe(a=>{const r=this._matches.findIndex(c=>c===a);this._state.changeState({matchesPosition:r+1})})))),i.add(o.toDisposable(t))}async replace(){return this._matchingModel?this._matchingModel.replace(this._state.replaceString):!1}async replaceAll(){const e=await Promise.all(this._findModels.map(i=>i.replaceAll(this._state.replaceString))).then(i=>i.reduce((t,s)=>(t.success+=s.success,t.failure+=s.failure,t),{success:0,failure:0}));return e.failure===0&&this._stopSearching(),e}getCurrentMatch(){return this._state.matchesPosition>0?this._matches[this._state.matchesPosition-1]:null}moveToNextMatch(){if(!this._matchingModel)return;const e=this._findModels.length===1,i=this._matchingModel.moveToNextMatch({loop:e});if(i){const t=this._matches.findIndex(s=>s===i);this.currentMatch$.next(i),this._state.changeState({matchesPosition:t+1})}else{const t=this._findModels.findIndex(c=>c===this._matchingModel),s=this._findModels[(t+1)%this._findModels.length],a=s.moveToNextMatch(),r=this._matches.findIndex(c=>c===a);this.currentMatch$.next(a),this._matchingModel=s,this._state.changeState({matchesPosition:r+1})}}moveToPreviousMatch(){if(!this._matchingModel)return;const e=this._findModels.length===1,i=this._matchingModel.moveToPreviousMatch({loop:e});if(i){const t=this._matches.findIndex(s=>s===i);this.currentMatch$.next(i),this._state.changeState({matchesPosition:t+1})}else{const t=this._findModels.findIndex(c=>c===this._matchingModel),s=this._findModels[(t-1+this._findModels.length)%this._findModels.length],a=s.moveToPreviousMatch(),r=this._matches.findIndex(c=>c===a);this.currentMatch$.next(a),this._matchingModel=s,this._state.changeState({matchesPosition:r+1})}}_moveToInitialMatch(e,i,t=!1){var _;const s=(_=this._univerInstanceService.getFocusedUniverInstance())==null?void 0:_.getUnitId();if(!s)return-1;const a=e.find(m=>m.unitId===s);if(a){this._matchingModel=a;const m=a.moveToNextMatch({stayIfOnMatch:!0,noFocus:t}),C=i.findIndex(v=>v===m);return this.currentMatch$.next(m),C}this._matchingModel=e[0];const r=this._matchingModel.moveToNextMatch({noFocus:t}),c=this._matches.findIndex(m=>m===r);return this.currentMatch$.next(r),c}};U=Q([T(2,o.IUniverInstanceService),T(3,o.ILogService)],U);var O=(n=>(n.ROW="row",n.COLUMN="column",n))(O||{}),P=(n=>(n.VALUE="value",n.FORMULA="formula",n))(P||{}),E=(n=>(n.SUBUNIT="subunit",n.UNIT="unit",n))(E||{});function B(){return{caseSensitive:!1,findBy:"value",findCompleted:!1,findDirection:"row",findScope:"subunit",findString:"",inputtingFindString:"",matchesCount:0,matchesPosition:0,matchesTheWholeCell:!1,replaceRevealed:!1,replaceString:"",revealed:!0}}class Re{constructor(){h(this,"_stateUpdates$",new S.Subject);h(this,"stateUpdates$",this._stateUpdates$.asObservable());h(this,"_state$",new S.BehaviorSubject(B()));h(this,"state$",this._state$.asObservable());h(this,"_findString","");h(this,"_inputtingFindString","");h(this,"_replaceString","");h(this,"_revealed",!1);h(this,"_replaceRevealed",!1);h(this,"_matchesPosition",0);h(this,"_matchesCount",0);h(this,"_caseSensitive",!0);h(this,"_matchesTheWholeCell",!1);h(this,"_findDirection","row");h(this,"_findScope","subunit");h(this,"_findBy","value");h(this,"_findCompleted",!1)}get state(){return this._state$.getValue()}get inputtingFindString(){return this._inputtingFindString}get findString(){return this._findString}get revealed(){return this._revealed}get replaceRevealed(){return this._replaceRevealed}get matchesPosition(){return this._matchesPosition}get matchesCount(){return this._matchesCount}get replaceString(){return this._replaceString}get caseSensitive(){return this._caseSensitive}get matchesTheWholeCell(){return this._matchesTheWholeCell}get findDirection(){return this._findDirection}get findScope(){return this._findScope}get findBy(){return this._findBy}get findCompleted(){return this._findCompleted}changeState(e){let i=!1;const t={};typeof e.findString<"u"&&e.findString!==this._findString&&(this._findString=e.findString,t.findString=this._findString,i=!0),typeof e.revealed<"u"&&e.revealed!==this._revealed&&(this._revealed=e.revealed,t.revealed=e.revealed,i=!0),typeof e.replaceRevealed<"u"&&e.replaceRevealed!==this._replaceRevealed&&(this._replaceRevealed=e.replaceRevealed,t.replaceRevealed=e.replaceRevealed,i=!0),typeof e.replaceString<"u"&&e.replaceString!==this._replaceString&&(this._replaceString=e.replaceString,t.replaceString=e.replaceString,i=!0),typeof e.matchesCount<"u"&&e.matchesCount!==this._matchesCount&&(this._matchesCount=e.matchesCount,t.matchesCount=e.matchesCount,i=!0),typeof e.matchesPosition<"u"&&e.matchesPosition!==this._matchesPosition&&(this._matchesPosition=e.matchesPosition,t.matchesPosition=e.matchesPosition,i=!0),typeof e.findBy<"u"&&e.findBy!==this._findBy&&(this._findBy=e.findBy,t.findBy=e.findBy,i=!0),typeof e.findScope<"u"&&e.findScope!==this._findScope&&(this._findScope=e.findScope,t.findScope=e.findScope,i=!0),typeof e.findDirection<"u"&&e.findDirection!==this._findDirection&&(this._findDirection=e.findDirection,t.findDirection=e.findDirection,i=!0),typeof e.caseSensitive<"u"&&e.caseSensitive!==this._caseSensitive&&(this._caseSensitive=e.caseSensitive,t.caseSensitive=e.caseSensitive,i=!0),typeof e.matchesTheWholeCell<"u"&&e.matchesTheWholeCell!==this._matchesTheWholeCell&&(this._matchesTheWholeCell=e.matchesTheWholeCell,t.matchesTheWholeCell=e.matchesTheWholeCell,i=!0),typeof e.inputtingFindString<"u"&&e.inputtingFindString!==this._inputtingFindString&&(this._inputtingFindString=e.inputtingFindString,t.inputtingFindString=e.inputtingFindString,i=!0),typeof e.findCompleted<"u"&&e.findCompleted!==this._findCompleted&&(this._findCompleted=e.findCompleted,t.findCompleted=e.findCompleted,i=!0),i&&(this._state$.next({caseSensitive:this._caseSensitive,findBy:this._findBy,findCompleted:this._findCompleted,findDirection:this._findDirection,findScope:this._findScope,findString:this._findString,inputtingFindString:this._inputtingFindString,matchesCount:this._matchesCount,matchesPosition:this._matchesPosition,matchesTheWholeCell:this._matchesTheWholeCell,replaceRevealed:this._replaceRevealed,revealed:this._revealed}),this._stateUpdates$.next(t))}}let W=class extends o.Disposable{constructor(e,i){super();h(this,"_providers",new Set);h(this,"_state",new Re);h(this,"_model");h(this,"_currentMatch$",new S.BehaviorSubject(null));h(this,"currentMatch$",this._currentMatch$.asObservable());h(this,"_replaceables$",new S.BehaviorSubject([]));h(this,"replaceables$",this._replaceables$.asObservable());h(this,"_focusSignal$",new S.Subject);h(this,"focusSignal$",this._focusSignal$.asObservable());this._injector=e,this._contextService=i}get stateUpdates$(){return this._state.stateUpdates$}get state$(){return this._state.state$}get revealed(){return this._state.revealed}get replaceRevealed(){return this._state.replaceRevealed}dispose(){super.dispose(),this._currentMatch$.next(null),this._currentMatch$.complete(),this._replaceables$.next([]),this._replaceables$.complete(),this._focusSignal$.complete()}getCurrentMatch(){var e;return(e=this._model)==null?void 0:e.getCurrentMatch()}getFindString(){return this._state.findString}changeFindString(e){this._state.changeState({findString:e})}focusFindInput(){this._focusSignal$.next()}changeInputtingFindString(e){e?this._state.changeState({inputtingFindString:e}):this._state.changeState({inputtingFindString:"",findString:""})}changeReplaceString(e){this._state.changeState({replaceString:e})}changeMatchesTheWholeCell(e){this._state.changeState({matchesTheWholeCell:e})}changeCaseSensitive(e){this._state.changeState({caseSensitive:e})}changeFindBy(e){this._state.changeState({findBy:e}),this._toggleDisplayRawFormula(e==="formula")}changeFindScope(e){this._state.changeState({findScope:e})}changeFindDirection(e){this._state.changeState({findDirection:e})}moveToNextMatch(){this._model&&(this._state.replaceRevealed&&!this._model.searched?(this._state.changeState({findString:this._state.inputtingFindString}),this._model.start()):this._model.moveToNextMatch(),this._focusSignal$.next())}moveToPreviousMatch(){this._model&&(this._state.replaceRevealed&&!this._model.searched?(this._state.changeState({findString:this._state.inputtingFindString}),this._model.start()):this._model.moveToPreviousMatch(),this._focusSignal$.next())}async replace(){return this._model?this._model.replace():!1}async replaceAll(){if(!this._model)throw new Error("[FindReplaceService] replaceAll: model is not initialized!");return this._model.replaceAll()}revealReplace(){this._state.changeState({replaceRevealed:!0,inputtingFindString:this._state.findString}),this._toggleRevealReplace(!0)}start(e=!1){if(this._providers.size===0)return!1;this._model=this._injector.createInstance(U,this._state,this._providers),this._model.currentMatch$.subscribe(t=>this._currentMatch$.next(t)),this._model.replaceables$.subscribe(t=>this._replaceables$.next(t));const i=B();return e&&(i.replaceRevealed=!0),this._state.changeState(i),this._toggleRevealReplace(e),!0}find(){var e;(e=this._model)==null||e.start()}terminate(){var e;(e=this._model)==null||e.dispose(),this._model=null,this._toggleDisplayRawFormula(!1),this._toggleRevealReplace(!1)}registerFindReplaceProvider(e){return this._providers.add(e),o.toDisposable(()=>this._providers.delete(e))}_toggleRevealReplace(e){this._contextService.setContextValue(J,e)}_toggleDisplayRawFormula(e){this._contextService.setContextValue(he.RENDER_RAW_FORMULA_KEY,e)}};W=Q([T(0,R.Inject(R.Injector)),T(1,o.IContextService)],W);const N={id:"ui.operation.open-find-dialog",type:o.CommandType.OPERATION,handler:n=>{const e=n.get(y);return e.revealed?e.focusFindInput():e.start(),!0}},k={id:"ui.operation.open-replace-dialog",type:o.CommandType.OPERATION,handler:n=>{const e=n.get(y);return e.revealed?e.replaceRevealed?e.focusFindInput():e.revealReplace():e.start(!0),!0}},X={type:o.CommandType.OPERATION,id:"ui.operation.go-to-next-match",handler:n=>(n.get(y).moveToNextMatch(),!0)},q={type:o.CommandType.OPERATION,id:"ui.operation.go-to-previous-match",handler:n=>(n.get(y).moveToPreviousMatch(),!0)};var ee={exports:{}},L={};/**
1
+ (function(u,o){typeof exports=="object"&&typeof module<"u"?o(exports,require("@univerjs/core"),require("@wendellhu/redi"),require("@univerjs/ui"),require("rxjs"),require("@univerjs/engine-render"),require("react"),require("@univerjs/design"),require("@wendellhu/redi/react-bindings")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@wendellhu/redi","@univerjs/ui","rxjs","@univerjs/engine-render","react","@univerjs/design","@wendellhu/redi/react-bindings"],o):(u=typeof globalThis<"u"?globalThis:u||self,o(u.UniverFindReplace={},u.UniverCore,u["@wendellhu/redi"],u.UniverUi,u.rxjs,u.UniverEngineRender,u.React,u.UniverDesign,u["@wendellhu/redi/react-bindings"]))})(this,function(u,o,R,f,S,le,l,p,I){"use strict";var St=Object.defineProperty;var Ct=(u,o,R)=>o in u?St(u,o,{enumerable:!0,configurable:!0,writable:!0,value:R}):u[o]=R;var h=(u,o,R)=>(Ct(u,typeof o!="symbol"?o+"":o,R),R);var b=function(){return b=Object.assign||function(n){for(var e,i=1,t=arguments.length;i<t;i++){e=arguments[i];for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&(n[s]=e[s])}return n},b.apply(this,arguments)},de=function(n,e){var i={};for(var t in n)Object.prototype.hasOwnProperty.call(n,t)&&e.indexOf(t)<0&&(i[t]=n[t]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,t=Object.getOwnPropertySymbols(n);s<t.length;s++)e.indexOf(t[s])<0&&Object.prototype.propertyIsEnumerable.call(n,t[s])&&(i[t[s]]=n[t[s]]);return i},K=l.forwardRef(function(n,e){var i=n.icon,t=n.id,s=n.className,a=n.extend,r=de(n,["icon","id","className","extend"]),c="univerjs-icon univerjs-icon-".concat(t," ").concat(s||"").trim(),_=l.useRef("_".concat(fe()));return $(i,"".concat(t),{defIds:i.defIds,idSuffix:_.current},b({ref:e,className:c},r),a)});function $(n,e,i,t,s){return l.createElement(n.tag,b(b({key:e},he(n,i,s)),t),(ue(n,i).children||[]).map(function(a,r){return $(a,"".concat(e,"-").concat(n.tag,"-").concat(r),i,void 0,s)}))}function he(n,e,i){var t=b({},n.attrs);i!=null&&i.colorChannel1&&t.fill==="colorChannel1"&&(t.fill=i.colorChannel1);var s=e.defIds;return!s||s.length===0||(n.tag==="use"&&t["xlink:href"]&&(t["xlink:href"]=t["xlink:href"]+e.idSuffix),Object.entries(t).forEach(function(a){var r=a[0],c=a[1];typeof c=="string"&&(t[r]=c.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))})),t}function ue(n,e){var i,t=e.defIds;return!t||t.length===0?n:n.tag==="defs"&&(!((i=n.children)===null||i===void 0)&&i.length)?b(b({},n),{children:n.children.map(function(s){return typeof s.attrs.id=="string"&&t&&t.indexOf(s.attrs.id)>-1?b(b({},s),{attrs:b(b({},s.attrs),{id:s.attrs.id+e.idSuffix})}):s})}):n}function fe(){return Math.random().toString(36).substring(2,8)}K.displayName="UniverIcon";var pe={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"}}]}]},z=l.forwardRef(function(n,e){return l.createElement(K,Object.assign({},n,{id:"search-single-16",ref:e,icon:pe}))});z.displayName="SearchSingle16";const Y="FIND_REPLACE_INPUT_FOCUS",Z="FIND_REPLACE_DIALOG_FOCUS",J="FIND_REPLACE_REPLACE_REVEALED";var _e=Object.defineProperty,ge=Object.getOwnPropertyDescriptor,Q=(n,e,i,t)=>{for(var s=t>1?void 0:t?ge(e,i):e,a=n.length-1,r;a>=0;a--)(r=n[a])&&(s=(t?r(e,i,s):r(s))||s);return t&&s&&_e(e,i,s),s},O=(n,e)=>(i,t)=>e(i,t,n);class me extends o.Disposable{}const y=R.createIdentifier("find-replace.service");function ve(n){return typeof n.findString<"u"||typeof n.inputtingFindString<"u"||typeof n.findDirection<"u"||typeof n.matchesTheWholeCell<"u"||typeof n.caseSensitive<"u"||typeof n.findScope<"u"||typeof n.findBy<"u"}let U=class extends o.Disposable{constructor(e,i,t,s){super();h(this,"currentMatch$",new S.BehaviorSubject(null));h(this,"replaceables$",new S.BehaviorSubject([]));h(this,"_findModels",[]);h(this,"_matchingModel",null);h(this,"_matches",[]);h(this,"_currentSearchingDisposables",null);this._state=e,this._providers=i,this._univerInstanceService=t,this._logService=s,this.disposeWithMe(this._state.stateUpdates$.pipe(S.throttleTime(200,void 0,{leading:!0,trailing:!0})).subscribe(async a=>{const r=this._state.state;ve(a)&&(r.findString!==""&&!r.replaceRevealed?(await this._startSearching(),this._state.changeState({findCompleted:!0})):a.replaceRevealed!==!0&&this._stopSearching())}))}get searched(){return this._findModels.length>0}dispose(){super.dispose(),this._stopSearching(),this.currentMatch$.complete(),this.replaceables$.complete(),this._state.changeState({...B(),revealed:!1})}async start(){if(!this._state.findString)return{results:[]};const e=await this._startSearching();return this._state.changeState({findCompleted:!0}),e}async _startSearching(){if(!this._state.findString)return{results:[]};const e=Array.from(this._providers),i=this._findModels=(await Promise.all(e.map(a=>a.find({findString:this._state.findString,findDirection:this._state.findDirection,findScope:this._state.findScope,findBy:this._state.findBy,replaceRevealed:this._state.replaceRevealed,caseSensitive:this._state.caseSensitive,matchesTheWholeCell:this._state.matchesTheWholeCell})))).flat();this._subscribeToModelsChanges(i);const t=this._matches=i.map(a=>a.getMatches()).flat();if(this.replaceables$.next(t.filter(a=>a.replaceable)),!t.length)return this._state.changeState({matchesCount:0,matchesPosition:0}),{results:[]};const s=this._moveToInitialMatch(i,t);return this._state.changeState({matchesCount:t.length,matchesPosition:s+1}),{results:t}}_stopSearching(){var e;this._providers.forEach(i=>i.terminate()),this._findModels=[],this._matches=[],this._matchingModel=null,(e=this._currentSearchingDisposables)==null||e.dispose(),this._currentSearchingDisposables=null,this.currentMatch$.next(null),this.replaceables$.next([]),this._state.changeState({findCompleted:!1,matchesCount:0,matchesPosition:0})}_subscribeToModelsChanges(e){const i=this._currentSearchingDisposables=new o.DisposableCollection,t=S.combineLatest(e.map(s=>s.matchesUpdate$)).pipe(S.debounceTime(220)).subscribe(([...s])=>{const a=this._matches=s.flat();if(a.length){const r=this._moveToInitialMatch(this._findModels,a,!0);this._state.changeState({matchesCount:a.length,matchesPosition:r+1}),this.replaceables$.next(a.filter(c=>c.replaceable))}else this._state.changeState({matchesCount:0,matchesPosition:0}),this.replaceables$.next([])});e.forEach(s=>i.add(o.toDisposable(s.activelyChangingMatch$.subscribe(a=>{const r=this._matches.findIndex(c=>c===a);this._state.changeState({matchesPosition:r+1})})))),i.add(o.toDisposable(t))}async replace(){return this._matchingModel?this._matchingModel.replace(this._state.replaceString):!1}async replaceAll(){const e=await Promise.all(this._findModels.map(i=>i.replaceAll(this._state.replaceString))).then(i=>i.reduce((t,s)=>(t.success+=s.success,t.failure+=s.failure,t),{success:0,failure:0}));return e.failure===0&&this._stopSearching(),e}getCurrentMatch(){return this._state.matchesPosition>0?this._matches[this._state.matchesPosition-1]:null}moveToNextMatch(){if(!this._matchingModel)return;const e=this._findModels.length===1,i=this._matchingModel.moveToNextMatch({loop:e});if(i){const t=this._matches.findIndex(s=>s===i);this.currentMatch$.next(i),this._state.changeState({matchesPosition:t+1})}else{const t=this._findModels.findIndex(c=>c===this._matchingModel),s=this._findModels[(t+1)%this._findModels.length],a=s.moveToNextMatch(),r=this._matches.findIndex(c=>c===a);this.currentMatch$.next(a),this._matchingModel=s,this._state.changeState({matchesPosition:r+1})}}moveToPreviousMatch(){if(!this._matchingModel)return;const e=this._findModels.length===1,i=this._matchingModel.moveToPreviousMatch({loop:e});if(i){const t=this._matches.findIndex(s=>s===i);this.currentMatch$.next(i),this._state.changeState({matchesPosition:t+1})}else{const t=this._findModels.findIndex(c=>c===this._matchingModel),s=this._findModels[(t-1+this._findModels.length)%this._findModels.length],a=s.moveToPreviousMatch(),r=this._matches.findIndex(c=>c===a);this.currentMatch$.next(a),this._matchingModel=s,this._state.changeState({matchesPosition:r+1})}}_moveToInitialMatch(e,i,t=!1){var _;const s=(_=this._univerInstanceService.getFocusedUniverInstance())==null?void 0:_.getUnitId();if(!s)return-1;const a=e.find(m=>m.unitId===s);if(a){this._matchingModel=a;const m=a.moveToNextMatch({stayIfOnMatch:!0,noFocus:t}),C=i.findIndex(v=>v===m);return this.currentMatch$.next(m),C}this._matchingModel=e[0];const r=this._matchingModel.moveToNextMatch({noFocus:t}),c=this._matches.findIndex(m=>m===r);return this.currentMatch$.next(r),c}};U=Q([O(2,o.IUniverInstanceService),O(3,o.ILogService)],U);var T=(n=>(n.ROW="row",n.COLUMN="column",n))(T||{}),P=(n=>(n.VALUE="value",n.FORMULA="formula",n))(P||{}),E=(n=>(n.SUBUNIT="subunit",n.UNIT="unit",n))(E||{});function B(){return{caseSensitive:!1,findBy:"value",findCompleted:!1,findDirection:"row",findScope:"subunit",findString:"",inputtingFindString:"",matchesCount:0,matchesPosition:0,matchesTheWholeCell:!1,replaceRevealed:!1,replaceString:"",revealed:!0}}class Se{constructor(){h(this,"_stateUpdates$",new S.Subject);h(this,"stateUpdates$",this._stateUpdates$.asObservable());h(this,"_state$",new S.BehaviorSubject(B()));h(this,"state$",this._state$.asObservable());h(this,"_findString","");h(this,"_inputtingFindString","");h(this,"_replaceString","");h(this,"_revealed",!1);h(this,"_replaceRevealed",!1);h(this,"_matchesPosition",0);h(this,"_matchesCount",0);h(this,"_caseSensitive",!0);h(this,"_matchesTheWholeCell",!1);h(this,"_findDirection","row");h(this,"_findScope","subunit");h(this,"_findBy","value");h(this,"_findCompleted",!1)}get state(){return this._state$.getValue()}get inputtingFindString(){return this._inputtingFindString}get findString(){return this._findString}get revealed(){return this._revealed}get replaceRevealed(){return this._replaceRevealed}get matchesPosition(){return this._matchesPosition}get matchesCount(){return this._matchesCount}get replaceString(){return this._replaceString}get caseSensitive(){return this._caseSensitive}get matchesTheWholeCell(){return this._matchesTheWholeCell}get findDirection(){return this._findDirection}get findScope(){return this._findScope}get findBy(){return this._findBy}get findCompleted(){return this._findCompleted}changeState(e){let i=!1;const t={};typeof e.findString<"u"&&e.findString!==this._findString&&(this._findString=e.findString,t.findString=this._findString,i=!0),typeof e.revealed<"u"&&e.revealed!==this._revealed&&(this._revealed=e.revealed,t.revealed=e.revealed,i=!0),typeof e.replaceRevealed<"u"&&e.replaceRevealed!==this._replaceRevealed&&(this._replaceRevealed=e.replaceRevealed,t.replaceRevealed=e.replaceRevealed,i=!0),typeof e.replaceString<"u"&&e.replaceString!==this._replaceString&&(this._replaceString=e.replaceString,t.replaceString=e.replaceString,i=!0),typeof e.matchesCount<"u"&&e.matchesCount!==this._matchesCount&&(this._matchesCount=e.matchesCount,t.matchesCount=e.matchesCount,i=!0),typeof e.matchesPosition<"u"&&e.matchesPosition!==this._matchesPosition&&(this._matchesPosition=e.matchesPosition,t.matchesPosition=e.matchesPosition,i=!0),typeof e.findBy<"u"&&e.findBy!==this._findBy&&(this._findBy=e.findBy,t.findBy=e.findBy,i=!0),typeof e.findScope<"u"&&e.findScope!==this._findScope&&(this._findScope=e.findScope,t.findScope=e.findScope,i=!0),typeof e.findDirection<"u"&&e.findDirection!==this._findDirection&&(this._findDirection=e.findDirection,t.findDirection=e.findDirection,i=!0),typeof e.caseSensitive<"u"&&e.caseSensitive!==this._caseSensitive&&(this._caseSensitive=e.caseSensitive,t.caseSensitive=e.caseSensitive,i=!0),typeof e.matchesTheWholeCell<"u"&&e.matchesTheWholeCell!==this._matchesTheWholeCell&&(this._matchesTheWholeCell=e.matchesTheWholeCell,t.matchesTheWholeCell=e.matchesTheWholeCell,i=!0),typeof e.inputtingFindString<"u"&&e.inputtingFindString!==this._inputtingFindString&&(this._inputtingFindString=e.inputtingFindString,t.inputtingFindString=e.inputtingFindString,i=!0),typeof e.findCompleted<"u"&&e.findCompleted!==this._findCompleted&&(this._findCompleted=e.findCompleted,t.findCompleted=e.findCompleted,i=!0),i&&(this._state$.next({caseSensitive:this._caseSensitive,findBy:this._findBy,findCompleted:this._findCompleted,findDirection:this._findDirection,findScope:this._findScope,findString:this._findString,inputtingFindString:this._inputtingFindString,matchesCount:this._matchesCount,matchesPosition:this._matchesPosition,matchesTheWholeCell:this._matchesTheWholeCell,replaceRevealed:this._replaceRevealed,revealed:this._revealed}),this._stateUpdates$.next(t))}}let W=class extends o.Disposable{constructor(e,i){super();h(this,"_providers",new Set);h(this,"_state",new Se);h(this,"_model");h(this,"_currentMatch$",new S.BehaviorSubject(null));h(this,"currentMatch$",this._currentMatch$.asObservable());h(this,"_replaceables$",new S.BehaviorSubject([]));h(this,"replaceables$",this._replaceables$.asObservable());h(this,"_focusSignal$",new S.Subject);h(this,"focusSignal$",this._focusSignal$.asObservable());this._injector=e,this._contextService=i}get stateUpdates$(){return this._state.stateUpdates$}get state$(){return this._state.state$}get revealed(){return this._state.revealed}get replaceRevealed(){return this._state.replaceRevealed}dispose(){super.dispose(),this._currentMatch$.next(null),this._currentMatch$.complete(),this._replaceables$.next([]),this._replaceables$.complete(),this._focusSignal$.complete()}getCurrentMatch(){var e;return(e=this._model)==null?void 0:e.getCurrentMatch()}getFindString(){return this._state.findString}changeFindString(e){this._state.changeState({findString:e})}focusFindInput(){this._focusSignal$.next()}changeInputtingFindString(e){e?this._state.changeState({inputtingFindString:e}):this._state.changeState({inputtingFindString:"",findString:""})}changeReplaceString(e){this._state.changeState({replaceString:e})}changeMatchesTheWholeCell(e){this._state.changeState({matchesTheWholeCell:e})}changeCaseSensitive(e){this._state.changeState({caseSensitive:e})}changeFindBy(e){this._state.changeState({findBy:e}),this._toggleDisplayRawFormula(e==="formula")}changeFindScope(e){this._state.changeState({findScope:e})}changeFindDirection(e){this._state.changeState({findDirection:e})}moveToNextMatch(){this._model&&(this._state.replaceRevealed&&!this._model.searched?(this._state.changeState({findString:this._state.inputtingFindString}),this._model.start()):this._model.moveToNextMatch(),this._focusSignal$.next())}moveToPreviousMatch(){this._model&&(this._state.replaceRevealed&&!this._model.searched?(this._state.changeState({findString:this._state.inputtingFindString}),this._model.start()):this._model.moveToPreviousMatch(),this._focusSignal$.next())}async replace(){return this._model?this._model.replace():!1}async replaceAll(){if(!this._model)throw new Error("[FindReplaceService] replaceAll: model is not initialized!");return this._model.replaceAll()}revealReplace(){this._state.changeState({replaceRevealed:!0,inputtingFindString:this._state.findString}),this._toggleRevealReplace(!0)}start(e=!1){if(this._providers.size===0)return!1;this._model=this._injector.createInstance(U,this._state,this._providers),this._model.currentMatch$.subscribe(t=>this._currentMatch$.next(t)),this._model.replaceables$.subscribe(t=>this._replaceables$.next(t));const i=B();return e&&(i.replaceRevealed=!0),this._state.changeState(i),this._toggleRevealReplace(e),!0}find(){var e;(e=this._model)==null||e.start()}terminate(){var e;(e=this._model)==null||e.dispose(),this._model=null,this._toggleDisplayRawFormula(!1),this._toggleRevealReplace(!1)}registerFindReplaceProvider(e){return this._providers.add(e),o.toDisposable(()=>this._providers.delete(e))}_toggleRevealReplace(e){this._contextService.setContextValue(J,e)}_toggleDisplayRawFormula(e){this._contextService.setContextValue(le.RENDER_RAW_FORMULA_KEY,e)}};W=Q([O(0,R.Inject(R.Injector)),O(1,o.IContextService)],W);const N={id:"ui.operation.open-find-dialog",type:o.CommandType.OPERATION,handler:n=>{const e=n.get(y);return e.revealed?e.focusFindInput():e.start(),!0}},k={id:"ui.operation.open-replace-dialog",type:o.CommandType.OPERATION,handler:n=>{const e=n.get(y);return e.revealed?e.replaceRevealed?e.focusFindInput():e.revealReplace():e.start(!0),!0}},X={type:o.CommandType.OPERATION,id:"ui.operation.go-to-next-match",handler:n=>(n.get(y).moveToNextMatch(),!0)},q={type:o.CommandType.OPERATION,id:"ui.operation.go-to-previous-match",handler:n=>(n.get(y).moveToPreviousMatch(),!0)};var ee={exports:{}},L={};/**
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 be=l,ye=Symbol.for("react.element"),Me=Symbol.for("react.fragment"),Ie=Object.prototype.hasOwnProperty,Fe=be.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,xe={key:!0,ref:!0,__self:!0,__source:!0};function te(n,e,i){var t,s={},a=null,r=null;i!==void 0&&(a=""+i),e.key!==void 0&&(a=""+e.key),e.ref!==void 0&&(r=e.ref);for(t in e)Ie.call(e,t)&&!xe.hasOwnProperty(t)&&(s[t]=e[t]);if(n&&n.defaultProps)for(t in e=n.defaultProps,e)s[t]===void 0&&(s[t]=e[t]);return{$$typeof:ye,type:n,key:a,ref:r,props:s,_owner:Fe.current}}L.Fragment=Me,L.jsx=te,L.jsxs=te,ee.exports=L;var d=ee.exports;const ne={id:"ui.command.replace-current-match",type:o.CommandType.COMMAND,handler:n=>n.get(y).replace()},De="CONFIRM_REPLACE_ALL",ie={id:"ui.command.replace-all-matches",type:o.CommandType.COMMAND,handler:async n=>{const e=n.get(f.IConfirmService),i=n.get(o.LocaleService),t=n.get(f.IMessageService);if(!await e.confirm({id:De,title:{title:i.t("find-replace.replace.confirm.title")},cancelText:i.t("button.cancel"),confirmText:i.t("button.confirm")}))return!1;const a=await n.get(y).replaceAll(),{success:r,failure:c}=a;return c>0?(r===0?t.show({type:p.MessageType.Error,content:i.t("find-replace.replace.all-failure")}):t.show({type:p.MessageType.Warning,content:i.t("find-replace.replace.partial-success",`${r}`,`${c}`)}),!1):(t.show({type:p.MessageType.Success,content:i.t("find-replace.replace.all-success",`${r}`)}),!0)}};function se(n){const{findCompleted:e,localeService:i,matchesCount:t,matchesPosition:s,findString:a,findReplaceService:r,onChange:c,..._}=n,C=e&&t===0?i.t("find-replace.dialog.no-result"):t===0?" ":void 0;return d.jsx(p.InputWithSlot,{autoFocus:!0,placeholder:i.t("find-replace.dialog.find-placeholder"),slot:d.jsx(p.Pager,{loop:!0,text:C,value:s,total:t,onChange:v=>{s===t&&v===1?r.moveToNextMatch():s===1&&v===t||v<s?r.moveToPreviousMatch():r.moveToNextMatch()}}),value:a,onChange:v=>c==null?void 0:c(v),..._})}const j={findReplaceDialogContainer:"univer-find-replace-dialog-container",findReplaceExpandContainer:"univer-find-replace-expand-container",buttonText:"univer-button-text",findReplaceButtonsGroup:"univer-find-replace-buttons-group",findReplaceButtonsGroupRight:"univer-find-replace-buttons-group-right"};function ae(n,e){const i=l.useCallback(()=>{var s;(s=document.querySelector(".univer-find-input input"))==null||s.focus()},[]),t=l.useCallback(()=>{const s=document.querySelectorAll(".univer-find-replace-dialog-container .univer-select-selection-search-input");return Array.from(s).some(a=>a===document.activeElement)},[]);return l.useImperativeHandle(e,()=>({focus:i,selectHasFocus:t})),l.useEffect(()=>{const s=n.focusSignal$.subscribe(()=>i());return()=>s.unsubscribe()},[n,i]),{focus:i,selectHasFocus:t}}const Te=l.forwardRef(function(e,i){const t=I.useDependency(o.LocaleService),s=I.useDependency(y),a=I.useDependency(o.ICommandService),r=f.useObservable(s.state$,void 0,!0),{findCompleted:c,findString:_,matchesCount:m,matchesPosition:C}=r,v=l.useCallback(()=>{a.executeCommand(k.id)},[a]),x=l.useCallback(F=>s.changeFindString(F),[s]);return ae(s,i),d.jsxs(l.Fragment,{children:[d.jsx(se,{findCompleted:c,className:"univer-find-input",matchesCount:m,matchesPosition:C,findReplaceService:s,localeService:t,findString:_,onChange:x}),d.jsx("div",{className:j.findReplaceExpandContainer,children:d.jsx(p.Button,{type:"text",size:"small",onClick:v,children:t.t("find-replace.dialog.advanced-finding")})})]})}),Oe=l.forwardRef(function(e,i){const t=I.useDependency(y),s=I.useDependency(o.LocaleService),a=I.useDependency(o.ICommandService),r=I.useDependency(f.IMessageService),c=f.useObservable(t.currentMatch$,void 0,!0),_=f.useObservable(t.replaceables$,void 0,!0),m=f.useObservable(t.state$,void 0,!0),{matchesCount:C,matchesPosition:v,findString:x,inputtingFindString:F,replaceString:et,caseSensitive:le,matchesTheWholeCell:de,findDirection:tt,findScope:nt,findBy:it,findCompleted:H}=m,st=F.length===0,at=C===0||!(c!=null&&c.replaceable),rt=_.length===0,ot=l.useCallback(g=>t.changeInputtingFindString(g),[t]),ct=l.useCallback(g=>t.changeReplaceString(g),[t]),{focus:lt}=ae(t,i),dt=l.useCallback(()=>{x===F?t.moveToNextMatch():(t.changeFindString(F),t.find())},[x,F,t]),ht=l.useCallback(()=>a.executeCommand(ne.id),[a]),ut=l.useCallback(async()=>{await a.executeCommand(ie.id),lt()},[a]),ft=l.useCallback(g=>{t.changeFindDirection(g)},[t]),pt=l.useCallback(g=>{t.changeFindScope(g)},[t]),_t=l.useCallback(g=>{t.changeFindBy(g)},[t]),gt=Ee(s),mt=Ne(s),vt=Le(s);return l.useEffect(()=>{const g=H&&C===0;let A=null;return g&&(A=r.show({content:s.t("find-replace.dialog.no-match"),type:p.MessageType.Warning,delay:5e3})),()=>A==null?void 0:A.dispose()},[H,C,r,s]),d.jsxs(l.Fragment,{children:[d.jsx(p.FormLayout,{label:s.t("find-replace.dialog.find"),children:d.jsx(se,{findCompleted:H,className:"univer-find-input",matchesCount:C,matchesPosition:v,findReplaceService:t,localeService:s,findString:F,onChange:ot})}),d.jsx(p.FormLayout,{label:s.t("find-replace.dialog.replace"),children:d.jsx(p.Input,{placeholder:s.t("find-replace.dialog.replace-placeholder"),value:et,onChange:g=>ct(g)})}),d.jsx(p.FormLayout,{label:s.t("find-replace.dialog.find-direction.title"),children:d.jsx(p.Select,{value:tt,options:mt,onChange:ft})}),d.jsx(p.FormDualColumnLayout,{children:d.jsxs(l.Fragment,{children:[d.jsx(p.FormLayout,{label:s.t("find-replace.dialog.find-scope.title"),children:d.jsx(p.Select,{value:nt,options:gt,onChange:pt})}),d.jsx(p.FormLayout,{label:s.t("find-replace.dialog.find-by.title"),children:d.jsx(p.Select,{value:it,options:vt,onChange:_t})})]})}),d.jsx(p.FormDualColumnLayout,{children:d.jsxs(l.Fragment,{children:[d.jsx(p.FormLayout,{children:d.jsx(p.Checkbox,{checked:le,value:le,onChange:g=>{t.changeCaseSensitive(g)},children:s.t("find-replace.dialog.case-sensitive")})}),d.jsx(p.FormLayout,{children:d.jsx(p.Checkbox,{checked:de,value:de,onChange:g=>{t.changeMatchesTheWholeCell(g)},children:s.t("find-replace.dialog.match-the-whole-cell")})})]})}),d.jsxs("div",{className:j.findReplaceButtonsGroup,children:[d.jsx(p.Button,{type:"primary",onClick:dt,disabled:st,children:s.t("find-replace.dialog.find")}),d.jsxs("span",{className:j.findReplaceButtonsGroupRight,children:[d.jsx(p.Button,{disabled:at,onClick:ht,children:s.t("find-replace.dialog.replace")}),d.jsx(p.Button,{disabled:rt,onClick:ut,children:s.t("find-replace.dialog.replace-all")})]})]})]})});function Pe(){const n=I.useDependency(y),e=I.useDependency(f.ILayoutService),i=I.useDependency(o.IContextService),t=f.useObservable(n.state$,void 0,!0),s=l.useRef(null);l.useEffect(()=>{let _;return s.current&&(_=e.registerContainerElement(s.current)),()=>_==null?void 0:_.dispose()},[e]);const a=l.useRef(null),r=l.useCallback(_=>i.setContextValue(Z,_),[i]),c=l.useCallback(_=>i.setContextValue(Y,_),[i]);return l.useEffect(()=>{var m;const _=S.fromEvent(document,"focusin").subscribe(C=>{var v;C.target&&((v=s.current)!=null&&v.contains(C.target))?r(!0):r(!1),!a.current||!a.current.selectHasFocus()?c(!0):c(!1)});return(m=a.current)==null||m.focus(),r(!0),c(!0),()=>{_.unsubscribe(),r(!1)}},[r,c]),d.jsx("div",{className:j.findReplaceDialogContainer,ref:s,children:t.replaceRevealed?d.jsx(Oe,{ref:a}):d.jsx(Te,{ref:a})})}function Ee(n){const e=n.getCurrentLocale();return l.useMemo(()=>[{label:n.t("find-replace.dialog.find-scope.current-sheet"),value:E.SUBUNIT},{label:n.t("find-replace.dialog.find-scope.workbook"),value:E.UNIT}],[e])}function Ne(n){const e=n.getCurrentLocale();return l.useMemo(()=>[{label:n.t("find-replace.dialog.find-direction.row"),value:O.ROW},{label:n.t("find-replace.dialog.find-direction.column"),value:O.COLUMN}],[e])}function Le(n){const e=n.getCurrentLocale();return l.useMemo(()=>[{label:n.t("find-replace.dialog.find-by.value"),value:P.VALUE},{label:n.t("find-replace.dialog.find-by.formula"),value:P.FORMULA}],[e])}function D(n){return n.getContextValue(Z)}function je(n){return n.getContextValue(J)}function re(n){return n.getContextValue(Y)}const w="7_find-replace-shortcuts";function G(n){return n.getContextValue(o.FOCUSING_SHEET)}function V(n){return!n.getContextValue(o.EDITOR_ACTIVATED)}const we={id:N.id,description:"find-replace.shortcut.open-find-dialog",binding:f.KeyCode.F|f.MetaKeys.CTRL_COMMAND,group:w,preconditions(n){return!D(n)&&G(n)&&V(n)}},Ae={id:N.id,description:"find-replace.shortcut.open-find-dialog",binding:f.KeyCode.F|f.MetaKeys.CTRL_COMMAND,mac:f.KeyCode.F|f.MetaKeys.MAC_CTRL,preconditions(n){return!D(n)&&G(n)&&V(n)}},Ue={id:k.id,description:"find-replace.shortcut.open-replace-dialog",binding:f.KeyCode.H|f.MetaKeys.CTRL_COMMAND,mac:f.KeyCode.H|f.MetaKeys.MAC_CTRL,group:w,preconditions(n){return G(n)&&V(n)&&(!D(n)||!je(n))}},Be={id:X.id,description:"find-replace.shortcut.go-to-next-match",binding:f.KeyCode.ENTER,group:w,priority:1e3,preconditions(n){return re(n)&&D(n)}},We={id:q.id,description:"find-replace.shortcut.go-to-previous-match",binding:f.KeyCode.ENTER|f.MetaKeys.SHIFT,group:w,priority:1e3,preconditions(n){return re(n)&&D(n)}};function ke(n){const e=n.get(o.IContextService);return{id:N.id,icon:"SearchIcon",tooltip:"find-replace.toolbar",group:f.MenuGroup.TOOLBAR_OTHERS,type:f.MenuItemType.BUTTON,positions:[f.MenuPosition.TOOLBAR_START],hidden$:f.getMenuHiddenObservable(n,o.UniverInstanceType.SHEET),disabled$:S.combineLatest([e.subscribeContextValue$(o.EDITOR_ACTIVATED),e.subscribeContextValue$(o.FOCUSING_SHEET)]).pipe(S.map(([i,t])=>i||!t))}}var Ge=Object.defineProperty,Ve=Object.getOwnPropertyDescriptor,He=(n,e,i,t)=>{for(var s=t>1?void 0:t?Ve(e,i):e,a=n.length-1,r;a>=0;a--)(r=n[a])&&(s=(t?r(e,i,s):r(s))||s);return t&&s&&Ge(e,i,s),s},M=(n,e)=>(i,t)=>e(i,t,n);const oe="DESKTOP_FIND_REPLACE_DIALOG",ce=350,Ke=20,$e=0;u.FindReplaceController=class extends o.RxDisposable{constructor(e,i,t,s,a,r,c,_,m,C,v,x){super(),this._univerInstanceService=e,this._menuService=i,this._shortcutService=t,this._commandService=s,this._findReplaceService=a,this._logService=r,this._dialogService=c,this._contextService=_,this._layoutService=m,this._localeService=C,this._componentManager=v,this._injector=x,this._initCommands(),this._initUI(),this._initShortcuts()}_initCommands(){[N,k,X,q,ie,ne].forEach(e=>{this.disposeWithMe(this._commandService.registerCommand(e))})}_initShortcuts(){[Ue,we,Ae,We,Be].forEach(e=>this.disposeWithMe(this._shortcutService.registerShortcut(e)))}_initUI(){this.disposeWithMe(this._menuService.addMenuItem(this._injector.invoke(ke))),this.disposeWithMe(this._componentManager.register("FindReplaceDialog",Pe)),this.disposeWithMe(this._componentManager.register("SearchIcon",z)),this._findReplaceService.stateUpdates$.pipe(S.takeUntil(this.dispose$)).subscribe(e=>{e.revealed===!0&&this._openPanel()}),this.disposeWithMe(this._univerInstanceService.focused$.pipe(S.takeUntil(this.dispose$)).subscribe(e=>{(!e||!this._univerInstanceService.getUniverSheetInstance(e))&&this.closePanel()}))}_openPanel(){this._dialogService.open({id:oe,draggable:!0,width:ce,title:{title:this._localeService.t("find-replace.dialog.title")},children:{label:"FindReplaceDialog"},destroyOnClose:!0,defaultPosition:ze(),onClose:()=>this.closePanel()})}closePanel(){this._dialogService.close(oe),this._findReplaceService.terminate(),queueMicrotask(()=>this._layoutService.focus())}},u.FindReplaceController=He([o.OnLifecycle(o.LifecycleStages.Rendered,u.FindReplaceController),M(0,o.IUniverInstanceService),M(1,f.IMenuService),M(2,f.IShortcutService),M(3,o.ICommandService),M(4,y),M(5,o.ILogService),M(6,f.IDialogService),M(7,o.IContextService),M(8,f.ILayoutService),M(9,R.Inject(o.LocaleService)),M(10,R.Inject(f.ComponentManager)),M(11,R.Inject(R.Injector))],u.FindReplaceController);function ze(){const{innerWidth:n}=window;return{x:n-ce-Ke,y:$e}}const Ye={"find-replace":{toolbar:"查找替换",shortcut:{"open-find-dialog":"打开查找对话框","open-replace-dialog":"打开替换对话框","close-dialog":"关闭查找替换对话框","go-to-next-match":"下一个匹配项","go-to-previous-match":"下一个匹配项"},dialog:{title:"查找",find:"查找",replace:"替换","replace-all":"替换全部","find-placeholder":"输入查找内容","advanced-finding":"替换 / 高级查找","replace-placeholder":"输入替换内容","case-sensitive":"匹配大小写","match-the-whole-cell":"匹配整个单元格","find-scope":{title:"查找范围","current-sheet":"当前子表",workbook:"整个工作簿"},"find-direction":{title:"查找顺序",column:"按列查找",row:"按行查找"},"find-by":{title:"查找方式",formula:"查找公式",value:"查找值"},"no-match":"已完成搜索,但是未找到任何匹配项","no-result":"无结果"},replace:{"all-success":"已全部替换 {0} 个匹配项","all-failure":"替换失败",confirm:{title:"确定要替换所有的匹配项吗?"}}},"find-replace-shortcuts":"查找替换"};var Ze=Object.defineProperty,Je=Object.getOwnPropertyDescriptor,Qe=(n,e,i,t)=>{for(var s=t>1?void 0:t?Je(e,i):e,a=n.length-1,r;a>=0;a--)(r=n[a])&&(s=(t?r(e,i,s):r(s))||s);return t&&s&&Ze(e,i,s),s},Xe=(n,e)=>(i,t)=>e(i,t,n);const qe="FIND_REPLACE";u.UniverFindReplacePlugin=class extends o.Plugin{constructor(e,i){super(qe),this._injector=e,this._localeService=i,this._localeService.load({zhCN:Ye})}onStarting(e){[[u.FindReplaceController],[y,{useClass:W}]].forEach(i=>{e.add(i)})}},u.UniverFindReplacePlugin=Qe([Xe(1,R.Inject(o.LocaleService))],u.UniverFindReplacePlugin),u.FindBy=P,u.FindDirection=O,u.FindModel=Se,u.FindScope=E,u.IFindReplaceService=y,Object.defineProperty(u,Symbol.toStringTag,{value:"Module"})});
9
+ */var Ce=l,Re=Symbol.for("react.element"),be=Symbol.for("react.fragment"),ye=Object.prototype.hasOwnProperty,Me=Ce.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,Ie={key:!0,ref:!0,__self:!0,__source:!0};function te(n,e,i){var t,s={},a=null,r=null;i!==void 0&&(a=""+i),e.key!==void 0&&(a=""+e.key),e.ref!==void 0&&(r=e.ref);for(t in e)ye.call(e,t)&&!Ie.hasOwnProperty(t)&&(s[t]=e[t]);if(n&&n.defaultProps)for(t in e=n.defaultProps,e)s[t]===void 0&&(s[t]=e[t]);return{$$typeof:Re,type:n,key:a,ref:r,props:s,_owner:Me.current}}L.Fragment=be,L.jsx=te,L.jsxs=te,ee.exports=L;var d=ee.exports;const ne={id:"ui.command.replace-current-match",type:o.CommandType.COMMAND,handler:n=>n.get(y).replace()},Fe="CONFIRM_REPLACE_ALL",ie={id:"ui.command.replace-all-matches",type:o.CommandType.COMMAND,handler:async n=>{const e=n.get(f.IConfirmService),i=n.get(o.LocaleService),t=n.get(f.IMessageService);if(!await e.confirm({id:Fe,title:{title:i.t("find-replace.replace.confirm.title")},cancelText:i.t("button.cancel"),confirmText:i.t("button.confirm")}))return!1;const a=await n.get(y).replaceAll(),{success:r,failure:c}=a;return c>0?(r===0?t.show({type:p.MessageType.Error,content:i.t("find-replace.replace.all-failure")}):t.show({type:p.MessageType.Warning,content:i.t("find-replace.replace.partial-success",`${r}`,`${c}`)}),!1):(t.show({type:p.MessageType.Success,content:i.t("find-replace.replace.all-success",`${r}`)}),!0)}};function se(n){const{findCompleted:e,localeService:i,matchesCount:t,matchesPosition:s,findString:a,findReplaceService:r,onChange:c,..._}=n,C=e&&t===0?i.t("find-replace.dialog.no-result"):t===0?" ":void 0;return d.jsx(p.InputWithSlot,{autoFocus:!0,placeholder:i.t("find-replace.dialog.find-placeholder"),slot:d.jsx(p.Pager,{loop:!0,text:C,value:s,total:t,onChange:v=>{s===t&&v===1?r.moveToNextMatch():s===1&&v===t||v<s?r.moveToPreviousMatch():r.moveToNextMatch()}}),value:a,onChange:v=>c==null?void 0:c(v),..._})}const j={findReplaceDialogContainer:"univer-find-replace-dialog-container",findReplaceExpandContainer:"univer-find-replace-expand-container",buttonText:"univer-button-text",findReplaceButtonsGroup:"univer-find-replace-buttons-group",findReplaceButtonsGroupRight:"univer-find-replace-buttons-group-right"};function ae(n,e){const i=l.useCallback(()=>{var s;(s=document.querySelector(".univer-find-input input"))==null||s.focus()},[]),t=l.useCallback(()=>{const s=document.querySelectorAll(".univer-find-replace-dialog-container .univer-select-selection-search-input");return Array.from(s).some(a=>a===document.activeElement)},[]);return l.useImperativeHandle(e,()=>({focus:i,selectHasFocus:t})),l.useEffect(()=>{const s=n.focusSignal$.subscribe(()=>i());return()=>s.unsubscribe()},[n,i]),{focus:i,selectHasFocus:t}}const xe=l.forwardRef(function(e,i){const t=I.useDependency(o.LocaleService),s=I.useDependency(y),a=I.useDependency(o.ICommandService),r=f.useObservable(s.state$,void 0,!0),{findCompleted:c,findString:_,matchesCount:m,matchesPosition:C}=r,v=l.useCallback(()=>{a.executeCommand(k.id)},[a]),x=l.useCallback(F=>s.changeFindString(F),[s]);return ae(s,i),d.jsxs(l.Fragment,{children:[d.jsx(se,{findCompleted:c,className:"univer-find-input",matchesCount:m,matchesPosition:C,findReplaceService:s,localeService:t,findString:_,onChange:x}),d.jsx("div",{className:j.findReplaceExpandContainer,children:d.jsx(p.Button,{type:"text",size:"small",onClick:v,children:t.t("find-replace.dialog.advanced-finding")})})]})}),De=l.forwardRef(function(e,i){const t=I.useDependency(y),s=I.useDependency(o.LocaleService),a=I.useDependency(o.ICommandService),r=I.useDependency(f.IMessageService),c=f.useObservable(t.currentMatch$,void 0,!0),_=f.useObservable(t.replaceables$,void 0,!0),m=f.useObservable(t.state$,void 0,!0),{matchesCount:C,matchesPosition:v,findString:x,inputtingFindString:F,replaceString:Xe,caseSensitive:qe,matchesTheWholeCell:et,findDirection:tt,findScope:nt,findBy:it,findCompleted:H}=m,st=F.length===0,at=C===0||!(c!=null&&c.replaceable),rt=_.length===0,ot=l.useCallback(g=>t.changeInputtingFindString(g),[t]),ct=l.useCallback(g=>t.changeReplaceString(g),[t]),{focus:lt}=ae(t,i),dt=l.useCallback(()=>{x===F?t.moveToNextMatch():(t.changeFindString(F),t.find())},[x,F,t]),ht=l.useCallback(()=>a.executeCommand(ne.id),[a]),ut=l.useCallback(async()=>{await a.executeCommand(ie.id),lt()},[a]),ft=l.useCallback(g=>{t.changeFindDirection(g)},[t]),pt=l.useCallback(g=>{t.changeFindScope(g)},[t]),_t=l.useCallback(g=>{t.changeFindBy(g)},[t]),gt=Te(s),mt=Pe(s),vt=Ee(s);return l.useEffect(()=>{const g=H&&C===0;let A=null;return g&&(A=r.show({content:s.t("find-replace.dialog.no-match"),type:p.MessageType.Warning,delay:5e3})),()=>A==null?void 0:A.dispose()},[H,C,r,s]),d.jsxs(l.Fragment,{children:[d.jsx(p.FormLayout,{label:s.t("find-replace.dialog.find"),children:d.jsx(se,{findCompleted:H,className:"univer-find-input",matchesCount:C,matchesPosition:v,findReplaceService:t,localeService:s,findString:F,onChange:ot})}),d.jsx(p.FormLayout,{label:s.t("find-replace.dialog.replace"),children:d.jsx(p.Input,{placeholder:s.t("find-replace.dialog.replace-placeholder"),value:Xe,onChange:g=>ct(g)})}),d.jsx(p.FormLayout,{label:s.t("find-replace.dialog.find-direction.title"),children:d.jsx(p.Select,{value:tt,options:mt,onChange:ft})}),d.jsx(p.FormDualColumnLayout,{children:d.jsxs(l.Fragment,{children:[d.jsx(p.FormLayout,{label:s.t("find-replace.dialog.find-scope.title"),children:d.jsx(p.Select,{value:nt,options:gt,onChange:pt})}),d.jsx(p.FormLayout,{label:s.t("find-replace.dialog.find-by.title"),children:d.jsx(p.Select,{value:it,options:vt,onChange:_t})})]})}),d.jsx(p.FormDualColumnLayout,{children:d.jsxs(l.Fragment,{children:[d.jsx(p.FormLayout,{children:d.jsx(p.Checkbox,{checked:qe,onChange:g=>{t.changeCaseSensitive(g)},children:s.t("find-replace.dialog.case-sensitive")})}),d.jsx(p.FormLayout,{children:d.jsx(p.Checkbox,{checked:et,onChange:g=>{t.changeMatchesTheWholeCell(g)},children:s.t("find-replace.dialog.match-the-whole-cell")})})]})}),d.jsxs("div",{className:j.findReplaceButtonsGroup,children:[d.jsx(p.Button,{type:"primary",onClick:dt,disabled:st,children:s.t("find-replace.dialog.find")}),d.jsxs("span",{className:j.findReplaceButtonsGroupRight,children:[d.jsx(p.Button,{disabled:at,onClick:ht,children:s.t("find-replace.dialog.replace")}),d.jsx(p.Button,{disabled:rt,onClick:ut,children:s.t("find-replace.dialog.replace-all")})]})]})]})});function Oe(){const n=I.useDependency(y),e=I.useDependency(f.ILayoutService),i=I.useDependency(o.IContextService),t=f.useObservable(n.state$,void 0,!0),s=l.useRef(null);l.useEffect(()=>{let _;return s.current&&(_=e.registerContainerElement(s.current)),()=>_==null?void 0:_.dispose()},[e]);const a=l.useRef(null),r=l.useCallback(_=>i.setContextValue(Z,_),[i]),c=l.useCallback(_=>i.setContextValue(Y,_),[i]);return l.useEffect(()=>{var m;const _=S.fromEvent(document,"focusin").subscribe(C=>{var v;C.target&&((v=s.current)!=null&&v.contains(C.target))?r(!0):r(!1),!a.current||!a.current.selectHasFocus()?c(!0):c(!1)});return(m=a.current)==null||m.focus(),r(!0),c(!0),()=>{_.unsubscribe(),r(!1)}},[r,c]),d.jsx("div",{className:j.findReplaceDialogContainer,ref:s,children:t.replaceRevealed?d.jsx(De,{ref:a}):d.jsx(xe,{ref:a})})}function Te(n){const e=n.getCurrentLocale();return l.useMemo(()=>[{label:n.t("find-replace.dialog.find-scope.current-sheet"),value:E.SUBUNIT},{label:n.t("find-replace.dialog.find-scope.workbook"),value:E.UNIT}],[e])}function Pe(n){const e=n.getCurrentLocale();return l.useMemo(()=>[{label:n.t("find-replace.dialog.find-direction.row"),value:T.ROW},{label:n.t("find-replace.dialog.find-direction.column"),value:T.COLUMN}],[e])}function Ee(n){const e=n.getCurrentLocale();return l.useMemo(()=>[{label:n.t("find-replace.dialog.find-by.value"),value:P.VALUE},{label:n.t("find-replace.dialog.find-by.formula"),value:P.FORMULA}],[e])}function D(n){return n.getContextValue(Z)}function Ne(n){return n.getContextValue(J)}function re(n){return n.getContextValue(Y)}const w="7_find-replace-shortcuts";function G(n){return n.getContextValue(o.FOCUSING_SHEET)}function V(n){return!n.getContextValue(o.EDITOR_ACTIVATED)}const Le={id:N.id,description:"find-replace.shortcut.open-find-dialog",binding:f.KeyCode.F|f.MetaKeys.CTRL_COMMAND,group:w,preconditions(n){return!D(n)&&G(n)&&V(n)}},je={id:N.id,description:"find-replace.shortcut.open-find-dialog",binding:f.KeyCode.F|f.MetaKeys.CTRL_COMMAND,mac:f.KeyCode.F|f.MetaKeys.MAC_CTRL,preconditions(n){return!D(n)&&G(n)&&V(n)}},we={id:k.id,description:"find-replace.shortcut.open-replace-dialog",binding:f.KeyCode.H|f.MetaKeys.CTRL_COMMAND,mac:f.KeyCode.H|f.MetaKeys.MAC_CTRL,group:w,preconditions(n){return G(n)&&V(n)&&(!D(n)||!Ne(n))}},Ae={id:X.id,description:"find-replace.shortcut.go-to-next-match",binding:f.KeyCode.ENTER,group:w,priority:1e3,preconditions(n){return re(n)&&D(n)}},Ue={id:q.id,description:"find-replace.shortcut.go-to-previous-match",binding:f.KeyCode.ENTER|f.MetaKeys.SHIFT,group:w,priority:1e3,preconditions(n){return re(n)&&D(n)}};function Be(n){const e=n.get(o.IContextService);return{id:N.id,icon:"SearchIcon",tooltip:"find-replace.toolbar",group:f.MenuGroup.TOOLBAR_OTHERS,type:f.MenuItemType.BUTTON,positions:[f.MenuPosition.TOOLBAR_START],hidden$:f.getMenuHiddenObservable(n,o.UniverInstanceType.SHEET),disabled$:S.combineLatest([e.subscribeContextValue$(o.EDITOR_ACTIVATED),e.subscribeContextValue$(o.FOCUSING_SHEET)]).pipe(S.map(([i,t])=>i||!t))}}var We=Object.defineProperty,ke=Object.getOwnPropertyDescriptor,Ge=(n,e,i,t)=>{for(var s=t>1?void 0:t?ke(e,i):e,a=n.length-1,r;a>=0;a--)(r=n[a])&&(s=(t?r(e,i,s):r(s))||s);return t&&s&&We(e,i,s),s},M=(n,e)=>(i,t)=>e(i,t,n);const oe="DESKTOP_FIND_REPLACE_DIALOG",ce=350,Ve=20,He=-90;u.FindReplaceController=class extends o.RxDisposable{constructor(e,i,t,s,a,r,c,_,m,C,v,x){super(),this._univerInstanceService=e,this._menuService=i,this._shortcutService=t,this._commandService=s,this._findReplaceService=a,this._logService=r,this._dialogService=c,this._contextService=_,this._layoutService=m,this._localeService=C,this._componentManager=v,this._injector=x,this._initCommands(),this._initUI(),this._initShortcuts()}_initCommands(){[N,k,X,q,ie,ne].forEach(e=>{this.disposeWithMe(this._commandService.registerCommand(e))})}_initShortcuts(){[we,Le,je,Ue,Ae].forEach(e=>this.disposeWithMe(this._shortcutService.registerShortcut(e)))}_initUI(){this.disposeWithMe(this._menuService.addMenuItem(this._injector.invoke(Be))),this.disposeWithMe(this._componentManager.register("FindReplaceDialog",Oe)),this.disposeWithMe(this._componentManager.register("SearchIcon",z)),this._findReplaceService.stateUpdates$.pipe(S.takeUntil(this.dispose$)).subscribe(e=>{e.revealed===!0&&this._openPanel()}),this.disposeWithMe(this._univerInstanceService.focused$.pipe(S.takeUntil(this.dispose$)).subscribe(e=>{(!e||!this._univerInstanceService.getUniverSheetInstance(e))&&this.closePanel()}))}_openPanel(){this._dialogService.open({id:oe,draggable:!0,width:ce,title:{title:this._localeService.t("find-replace.dialog.title")},children:{label:"FindReplaceDialog"},destroyOnClose:!0,defaultPosition:Ke(),preservePositionOnDestroy:!0,onClose:()=>this.closePanel()})}closePanel(){this._dialogService.close(oe),this._findReplaceService.terminate(),queueMicrotask(()=>this._layoutService.focus())}},u.FindReplaceController=Ge([o.OnLifecycle(o.LifecycleStages.Rendered,u.FindReplaceController),M(0,o.IUniverInstanceService),M(1,f.IMenuService),M(2,f.IShortcutService),M(3,o.ICommandService),M(4,y),M(5,o.ILogService),M(6,f.IDialogService),M(7,o.IContextService),M(8,f.ILayoutService),M(9,R.Inject(o.LocaleService)),M(10,R.Inject(f.ComponentManager)),M(11,R.Inject(R.Injector))],u.FindReplaceController);function Ke(){const{innerWidth:n}=window;return{x:(n-ce)/2-Ve,y:He}}const $e={"find-replace":{toolbar:"查找替换",shortcut:{"open-find-dialog":"打开查找对话框","open-replace-dialog":"打开替换对话框","close-dialog":"关闭查找替换对话框","go-to-next-match":"下一个匹配项","go-to-previous-match":"下一个匹配项"},dialog:{title:"查找",find:"查找",replace:"替换","replace-all":"替换全部","find-placeholder":"输入查找内容","advanced-finding":"替换 / 高级查找","replace-placeholder":"输入替换内容","case-sensitive":"匹配大小写","match-the-whole-cell":"匹配整个单元格","find-scope":{title:"查找范围","current-sheet":"当前子表",workbook:"整个工作簿"},"find-direction":{title:"查找顺序",column:"按列查找",row:"按行查找"},"find-by":{title:"查找方式",formula:"查找公式",value:"查找值"},"no-match":"已完成搜索,但是未找到任何匹配项","no-result":"无结果"},replace:{"all-success":"已全部替换 {0} 个匹配项","all-failure":"替换失败",confirm:{title:"确定要替换所有的匹配项吗?"}}},"find-replace-shortcuts":"查找替换"};var ze=Object.defineProperty,Ye=Object.getOwnPropertyDescriptor,Ze=(n,e,i,t)=>{for(var s=t>1?void 0:t?Ye(e,i):e,a=n.length-1,r;a>=0;a--)(r=n[a])&&(s=(t?r(e,i,s):r(s))||s);return t&&s&&ze(e,i,s),s},Je=(n,e)=>(i,t)=>e(i,t,n);const Qe="FIND_REPLACE";u.UniverFindReplacePlugin=class extends o.Plugin{constructor(e,i){super(Qe),this._injector=e,this._localeService=i,this._localeService.load({zhCN:$e})}onStarting(e){[[u.FindReplaceController],[y,{useClass:W}]].forEach(i=>{e.add(i)})}},u.UniverFindReplacePlugin=Ze([Je(1,R.Inject(o.LocaleService))],u.UniverFindReplacePlugin),u.FindBy=P,u.FindDirection=T,u.FindModel=me,u.FindScope=E,u.IFindReplaceService=y,Object.defineProperty(u,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@univerjs/find-replace",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "private": false,
5
5
  "description": "",
6
6
  "author": "DreamNum <developer@univer.ai>",
@@ -17,7 +17,12 @@
17
17
  "bugs": {
18
18
  "url": "https://github.com/dream-num/univer/issues"
19
19
  },
20
- "keywords": [],
20
+ "keywords": [
21
+ "univer"
22
+ ],
23
+ "sideEffects": [
24
+ "**/*.css"
25
+ ],
21
26
  "exports": {
22
27
  ".": {
23
28
  "import": "./lib/es/index.js",
@@ -51,28 +56,29 @@
51
56
  "@wendellhu/redi": "0.13.0",
52
57
  "react": ">=16.9.0",
53
58
  "rxjs": ">=7.0.0",
54
- "@univerjs/core": "0.1.3",
55
- "@univerjs/design": "0.1.3",
56
- "@univerjs/engine-render": "0.1.3",
57
- "@univerjs/ui": "0.1.3"
59
+ "@univerjs/design": "0.1.4",
60
+ "@univerjs/engine-render": "0.1.4",
61
+ "@univerjs/ui": "0.1.4",
62
+ "@univerjs/core": "0.1.4"
58
63
  },
59
64
  "dependencies": {
60
- "@univerjs/icons": "^0.1.41"
65
+ "@univerjs/icons": "^0.1.42"
61
66
  },
62
67
  "devDependencies": {
63
- "@types/react": "^18.2.66",
68
+ "@types/react": "^18.2.67",
64
69
  "@wendellhu/redi": "^0.13.0",
70
+ "less": "^4.2.0",
65
71
  "react": "^18.2.0",
66
72
  "rxjs": "^7.8.1",
67
73
  "typescript": "^5.4.2",
68
74
  "vite": "^5.1.6",
69
- "vitest": "^1.3.1",
70
- "@univerjs/core": "0.1.3",
71
- "@univerjs/engine-formula": "0.1.3",
72
- "@univerjs/engine-render": "0.1.3",
73
- "@univerjs/shared": "0.1.3",
74
- "@univerjs/design": "0.1.3",
75
- "@univerjs/ui": "0.1.3"
75
+ "vitest": "^1.4.0",
76
+ "@univerjs/core": "0.1.4",
77
+ "@univerjs/engine-formula": "0.1.4",
78
+ "@univerjs/design": "0.1.4",
79
+ "@univerjs/engine-render": "0.1.4",
80
+ "@univerjs/shared": "0.1.4",
81
+ "@univerjs/ui": "0.1.4"
76
82
  },
77
83
  "scripts": {
78
84
  "test": "vitest run",