@univerjs/find-replace 0.5.2 → 0.5.3-experimental.20250106-e3b7a39

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/cjs/index.js CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";var Te=Object.defineProperty;var Pe=(i,e,n)=>e in i?Te(i,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):i[e]=n;var l=(i,e,n)=>Pe(i,typeof e!="symbol"?e+"":e,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("@univerjs/core"),p=require("@univerjs/ui"),v=require("rxjs"),f=require("@univerjs/design"),Ee=require("@univerjs/engine-render"),h=require("react"),Ne="find-replace.config",q={};var C=function(){return C=Object.assign||function(i){for(var e,n=1,t=arguments.length;n<t;n++){e=arguments[n];for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&(i[s]=e[s])}return i},C.apply(this,arguments)},Le=function(i,e){var n={};for(var t in i)Object.prototype.hasOwnProperty.call(i,t)&&e.indexOf(t)<0&&(n[t]=i[t]);if(i!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,t=Object.getOwnPropertySymbols(i);s<t.length;s++)e.indexOf(t[s])<0&&Object.prototype.propertyIsEnumerable.call(i,t[s])&&(n[t[s]]=i[t[s]]);return n},Q=h.forwardRef(function(i,e){var n=i.icon,t=i.id,s=i.className,r=i.extend,a=Le(i,["icon","id","className","extend"]),d="univerjs-icon univerjs-icon-".concat(t," ").concat(s||"").trim(),u=h.useRef("_".concat(Ae()));return X(n,"".concat(t),{defIds:n.defIds,idSuffix:u.current},C({ref:e,className:d},a),r)});function X(i,e,n,t,s){return h.createElement(i.tag,C(C({key:e},$e(i,n,s)),t),(je(i,n).children||[]).map(function(r,a){return X(r,"".concat(e,"-").concat(i.tag,"-").concat(a),n,void 0,s)}))}function $e(i,e,n){var t=C({},i.attrs);n!=null&&n.colorChannel1&&t.fill==="colorChannel1"&&(t.fill=n.colorChannel1);var s=e.defIds;return!s||s.length===0||(i.tag==="use"&&t["xlink:href"]&&(t["xlink:href"]=t["xlink:href"]+e.idSuffix),Object.entries(t).forEach(function(r){var a=r[0],d=r[1];typeof d=="string"&&(t[a]=d.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))})),t}function je(i,e){var n,t=e.defIds;return!t||t.length===0?i:i.tag==="defs"&&(!((n=i.children)===null||n===void 0)&&n.length)?C(C({},i),{children:i.children.map(function(s){return typeof s.attrs.id=="string"&&t&&t.indexOf(s.attrs.id)>-1?C(C({},s),{attrs:C(C({},s.attrs),{id:s.attrs.id+e.idSuffix})}):s})}):i}function Ae(){return Math.random().toString(36).substring(2,8)}Q.displayName="UniverIcon";var we={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"}}]}]},ee=h.forwardRef(function(i,e){return h.createElement(Q,Object.assign({},i,{id:"search-single-16",ref:e,icon:we}))});ee.displayName="SearchSingle16";const te="FIND_REPLACE_INPUT_FOCUS",ie="FIND_REPLACE_DIALOG_FOCUS",ne="FIND_REPLACE_REPLACE_REVEALED";var Ue=Object.defineProperty,Be=Object.getOwnPropertyDescriptor,se=(i,e,n,t)=>{for(var s=t>1?void 0:t?Be(e,n):e,r=i.length-1,a;r>=0;r--)(a=i[r])&&(s=(t?a(e,n,s):a(s))||s);return t&&s&&Ue(e,n,s),s},A=(i,e)=>(n,t)=>e(n,t,i);class ke extends o.Disposable{}const R=o.createIdentifier("find-replace.service");function We(i){return typeof i.findString<"u"||typeof i.inputtingFindString<"u"||typeof i.findDirection<"u"||typeof i.matchesTheWholeCell<"u"||typeof i.caseSensitive<"u"||typeof i.findScope<"u"||typeof i.findBy<"u"}let w=class extends o.Disposable{constructor(e,n,t){super();l(this,"currentMatch$",new v.BehaviorSubject(null));l(this,"replaceables$",new v.BehaviorSubject([]));l(this,"_findModels",[]);l(this,"_matchingModel",null);l(this,"_matches",[]);l(this,"_currentSearchingDisposables",null);this._state=e,this._providers=n,this._univerInstanceService=t,this.disposeWithMe(this._state.stateUpdates$.pipe(v.throttleTime(200,void 0,{leading:!0,trailing:!0})).subscribe(async s=>{const r=this._state.state;We(s)&&(r.findString!==""&&!r.replaceRevealed?(await this._startSearching(),this._state.changeState({findCompleted:!0})):s.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(s=>s.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 t=this._matches=n.map(s=>s.getMatches()).flat();return this.replaceables$.next(t.filter(s=>s.replaceable)),t.length?(this._moveToInitialMatch(n),this._state.changeState({matchesCount:t.length}),{results:t}):(this._state.changeState({matchesCount:0,matchesPosition:0}),{results:[]})}_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 o.DisposableCollection,t=v.combineLatest(e.map(s=>s.matchesUpdate$)).pipe(v.debounceTime(220)).subscribe(([...s])=>{const r=this._matches=s.flat();r.length?(this._moveToInitialMatch(this._findModels,!0),this._state.changeState({matchesCount:r.length}),this.replaceables$.next(r.filter(a=>a.replaceable))):(this._state.changeState({matchesCount:0,matchesPosition:0}),this.replaceables$.next([]))});e.forEach(s=>n.add(o.toDisposable(s.activelyChangingMatch$.subscribe(r=>{const a=this._matches.findIndex(d=>d===r);this._state.changeState({matchesPosition:a+1})})))),n.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(n=>n.replaceAll(this._state.replaceString))).then(n=>n.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}_markMatch(e){const n=this._matches.findIndex(t=>t===e);this.currentMatch$.next(e),this._state.changeState({matchesPosition:n+1})}moveToNextMatch(){if(!this._matchingModel)return;const e=this._findModels.length===1,n=this._matchingModel.moveToNextMatch({loop:e});if(n)this._markMatch(n);else{const t=this._findModels.findIndex(s=>s===this._matchingModel);this._moveToNextUnitMatch(t)}}_moveToNextUnitMatch(e){const n=this._findModels.length;for(let t=(e+1)%n;t!==e;){const s=this._findModels[t],r=s.moveToNextMatch({ignoreSelection:!0});if(r){this._matchingModel=s,this._markMatch(r);return}t=(t+1)%n}if(this._matchingModel){const t=this._matchingModel.moveToNextMatch({ignoreSelection:!0});t&&this._markMatch(t)}}moveToPreviousMatch(){if(!this._matchingModel)return;const e=this._findModels.length===1,n=this._matchingModel.moveToPreviousMatch({loop:e});if(n){const t=this._matches.findIndex(s=>s===n);this.currentMatch$.next(n),this._state.changeState({matchesPosition:t+1})}else{const t=this._findModels.length,s=this._findModels.findIndex(a=>a===this._matchingModel);for(let a=(s-1+t)%t;a!==s;){const d=this._findModels[a],u=d.moveToPreviousMatch({ignoreSelection:!0});if(u){this._matchingModel=d,this._markMatch(u);return}a=(a-1)%t}const r=this._matchingModel.moveToPreviousMatch({ignoreSelection:!0});r&&this._markMatch(r)}}_moveToInitialMatch(e,n=!1){var r;const t=(r=this._univerInstanceService.getFocusedUnit())==null?void 0:r.getUnitId();if(!t)return-1;const s=e.findIndex(a=>a.unitId===t);if(s!==-1){this._matchingModel=e[s];const a=this._matchingModel.moveToNextMatch({stayIfOnMatch:!0,noFocus:n});if(a)return this._markMatch(a),s}return this._moveToNextUnitMatch(s),0}};w=se([A(2,o.IUniverInstanceService)],w);var D=(i=>(i.ROW="row",i.COLUMN="column",i))(D||{}),O=(i=>(i.VALUE="value",i.FORMULA="formula",i))(O||{}),T=(i=>(i.SUBUNIT="subunit",i.UNIT="unit",i))(T||{});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 Ge{constructor(){l(this,"_stateUpdates$",new v.Subject);l(this,"stateUpdates$",this._stateUpdates$.asObservable());l(this,"_state$",new v.BehaviorSubject(B()));l(this,"state$",this._state$.asObservable());l(this,"_findString","");l(this,"_inputtingFindString","");l(this,"_replaceString","");l(this,"_revealed",!1);l(this,"_replaceRevealed",!1);l(this,"_matchesPosition",0);l(this,"_matchesCount",0);l(this,"_caseSensitive",!0);l(this,"_matchesTheWholeCell",!1);l(this,"_findDirection","row");l(this,"_findScope","subunit");l(this,"_findBy","value");l(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 t={};typeof e.findString<"u"&&e.findString!==this._findString&&(this._findString=e.findString,t.findString=this._findString,n=!0),typeof e.revealed<"u"&&e.revealed!==this._revealed&&(this._revealed=e.revealed,t.revealed=e.revealed,n=!0),typeof e.replaceRevealed<"u"&&e.replaceRevealed!==this._replaceRevealed&&(this._replaceRevealed=e.replaceRevealed,t.replaceRevealed=e.replaceRevealed,n=!0),typeof e.replaceString<"u"&&e.replaceString!==this._replaceString&&(this._replaceString=e.replaceString,t.replaceString=e.replaceString,n=!0),typeof e.matchesCount<"u"&&e.matchesCount!==this._matchesCount&&(this._matchesCount=e.matchesCount,t.matchesCount=e.matchesCount,n=!0),typeof e.matchesPosition<"u"&&e.matchesPosition!==this._matchesPosition&&(this._matchesPosition=e.matchesPosition,t.matchesPosition=e.matchesPosition,n=!0),typeof e.findBy<"u"&&e.findBy!==this._findBy&&(this._findBy=e.findBy,t.findBy=e.findBy,n=!0),typeof e.findScope<"u"&&e.findScope!==this._findScope&&(this._findScope=e.findScope,t.findScope=e.findScope,n=!0),typeof e.findDirection<"u"&&e.findDirection!==this._findDirection&&(this._findDirection=e.findDirection,t.findDirection=e.findDirection,n=!0),typeof e.caseSensitive<"u"&&e.caseSensitive!==this._caseSensitive&&(this._caseSensitive=e.caseSensitive,t.caseSensitive=e.caseSensitive,n=!0),typeof e.matchesTheWholeCell<"u"&&e.matchesTheWholeCell!==this._matchesTheWholeCell&&(this._matchesTheWholeCell=e.matchesTheWholeCell,t.matchesTheWholeCell=e.matchesTheWholeCell,n=!0),typeof e.inputtingFindString<"u"&&e.inputtingFindString!==this._inputtingFindString&&(this._inputtingFindString=e.inputtingFindString,t.inputtingFindString=e.inputtingFindString,n=!0),typeof e.findCompleted<"u"&&e.findCompleted!==this._findCompleted&&(this._findCompleted=e.findCompleted,t.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(t))}}let U=class extends o.Disposable{constructor(e,n){super();l(this,"_providers",new Set);l(this,"_state",new Ge);l(this,"_model");l(this,"_currentMatch$",new v.BehaviorSubject(null));l(this,"currentMatch$",this._currentMatch$.asObservable());l(this,"_replaceables$",new v.BehaviorSubject([]));l(this,"replaceables$",this._replaceables$.asObservable());l(this,"_focusSignal$",new v.Subject);l(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(t=>this._currentMatch$.next(t)),this._model.replaceables$.subscribe(t=>this._replaceables$.next(t));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),o.toDisposable(()=>this._providers.delete(e))}_toggleRevealReplace(e){this._contextService.setContextValue(ne,e)}_toggleDisplayRawFormula(e){this._contextService.setContextValue(Ee.RENDER_RAW_FORMULA_KEY,e)}};U=se([A(0,o.Inject(o.Injector)),A(1,o.IContextService)],U);const k={id:"ui.command.replace-current-match",type:o.CommandType.COMMAND,handler:i=>i.get(R).replace()},Ve="CONFIRM_REPLACE_ALL",W={id:"ui.command.replace-all-matches",type:o.CommandType.COMMAND,handler:async i=>{const e=i.get(p.IConfirmService),n=i.get(o.LocaleService),t=i.get(p.IMessageService);if(!await e.confirm({id:Ve,title:{title:n.t("find-replace.replace.confirm.title")},cancelText:n.t("button.cancel"),confirmText:n.t("button.confirm")}))return!1;const r=await i.get(R).replaceAll(),{success:a,failure:d}=r;return d>0?(a===0?t.show({type:f.MessageType.Error,content:n.t("find-replace.replace.all-failure")}):t.show({type:f.MessageType.Warning,content:n.t("find-replace.replace.partial-success",`${a}`,`${d}`)}),!1):(t.show({type:f.MessageType.Success,content:n.t("find-replace.replace.all-success",`${a}`)}),!0)}},I={id:"ui.operation.open-find-dialog",type:o.CommandType.OPERATION,handler:i=>{const e=i.get(R);return e.revealed?e.focusFindInput():e.start(),!0}},E={id:"ui.operation.open-replace-dialog",type:o.CommandType.OPERATION,handler:i=>{const e=i.get(R);return e.revealed?e.replaceRevealed?e.focusFindInput():e.revealReplace():e.start(!0),!0}},G={type:o.CommandType.OPERATION,id:"ui.operation.go-to-next-match",handler:i=>(i.get(R).moveToNextMatch(),!0)},V={type:o.CommandType.OPERATION,id:"ui.operation.go-to-previous-match",handler:i=>(i.get(R).moveToPreviousMatch(),!0)};var $={exports:{}},x={};/**
1
+ "use strict";var Te=Object.defineProperty;var Pe=(t,e,n)=>e in t?Te(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var u=(t,e,n)=>Pe(t,typeof e!="symbol"?e+"":e,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("@univerjs/core"),p=require("@univerjs/ui"),S=require("rxjs"),f=require("@univerjs/design"),Ee=require("@univerjs/engine-render"),h=require("react"),Ne="find-replace.config",K={};var C=function(){return C=Object.assign||function(t){for(var e,n=1,i=arguments.length;n<i;n++){e=arguments[n];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])}return t},C.apply(this,arguments)},Le=function(t,e){var n={};for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&e.indexOf(i)<0&&(n[i]=t[i]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,i=Object.getOwnPropertySymbols(t);r<i.length;r++)e.indexOf(i[r])<0&&Object.prototype.propertyIsEnumerable.call(t,i[r])&&(n[i[r]]=t[i[r]]);return n},Z=h.forwardRef(function(t,e){var n=t.icon,i=t.id,r=t.className,s=t.extend,a=Le(t,["icon","id","className","extend"]),c="univerjs-icon univerjs-icon-".concat(i," ").concat(r||"").trim(),d=h.useRef("_".concat(Ae()));return Q(n,"".concat(i),{defIds:n.defIds,idSuffix:d.current},C({ref:e,className:c},a),s)});function Q(t,e,n,i,r){return h.createElement(t.tag,C(C({key:e},$e(t,n,r)),i),(je(t,n).children||[]).map(function(s,a){return Q(s,"".concat(e,"-").concat(t.tag,"-").concat(a),n,void 0,r)}))}function $e(t,e,n){var i=C({},t.attrs);n!=null&&n.colorChannel1&&i.fill==="colorChannel1"&&(i.fill=n.colorChannel1);var r=e.defIds;return!r||r.length===0||(t.tag==="use"&&i["xlink:href"]&&(i["xlink:href"]=i["xlink:href"]+e.idSuffix),Object.entries(i).forEach(function(s){var a=s[0],c=s[1];typeof c=="string"&&(i[a]=c.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))})),i}function je(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)?C(C({},t),{children:t.children.map(function(r){return typeof r.attrs.id=="string"&&i&&i.indexOf(r.attrs.id)>-1?C(C({},r),{attrs:C(C({},r.attrs),{id:r.attrs.id+e.idSuffix})}):r})}):t}function Ae(){return Math.random().toString(36).substring(2,8)}Z.displayName="UniverIcon";var we={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"}}]}]},X=h.forwardRef(function(t,e){return h.createElement(Z,Object.assign({},t,{id:"search-single-16",ref:e,icon:we}))});X.displayName="SearchSingle16";const ee="FIND_REPLACE_INPUT_FOCUS",te="FIND_REPLACE_DIALOG_FOCUS",ie="FIND_REPLACE_REPLACE_REVEALED";var Ue=Object.defineProperty,Be=Object.getOwnPropertyDescriptor,ne=(t,e,n,i)=>{for(var r=i>1?void 0:i?Be(e,n):e,s=t.length-1,a;s>=0;s--)(a=t[s])&&(r=(i?a(e,n,r):a(r))||r);return i&&r&&Ue(e,n,r),r},w=(t,e)=>(n,i)=>e(n,i,t);class ke extends o.Disposable{}const R=o.createIdentifier("find-replace.service");function We(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"}exports.FindReplaceModel=class extends o.Disposable{constructor(n,i,r){super();u(this,"currentMatch$",new S.BehaviorSubject(null));u(this,"replaceables$",new S.BehaviorSubject([]));u(this,"_findModels",[]);u(this,"_matchingModel",null);u(this,"_matches",[]);u(this,"_currentSearchingDisposables",null);this._state=n,this._providers=i,this._univerInstanceService=r,this.disposeWithMe(this._state.stateUpdates$.pipe(S.throttleTime(200,void 0,{leading:!0,trailing:!0})).subscribe(async s=>{const a=this._state.state;We(s)&&(a.findString!==""&&!a.replaceRevealed?(await this._startSearching(),this._state.changeState({findCompleted:!0})):s.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({...E(),revealed:!1})}async start(){if(!this._state.findString)return{results:[]};const n=await this._startSearching();return this._state.changeState({findCompleted:!0}),n}async _startSearching(){if(!this._state.findString)return{results:[]};const n=Array.from(this._providers),i=this._findModels=(await Promise.all(n.map(s=>s.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 r=this._matches=i.map(s=>s.getMatches()).flat();return this.replaceables$.next(r.filter(s=>s.replaceable)),r.length?(this._moveToInitialMatch(i),this._state.changeState({matchesCount:r.length}),{results:r}):(this._state.changeState({matchesCount:0,matchesPosition:0}),{results:[]})}_stopSearching(){var n;this._providers.forEach(i=>i.terminate()),this._findModels=[],this._matches=[],this._matchingModel=null,(n=this._currentSearchingDisposables)==null||n.dispose(),this._currentSearchingDisposables=null,this.currentMatch$.next(null),this.replaceables$.next([]),this._state.changeState({findCompleted:!1,matchesCount:0,matchesPosition:0})}_subscribeToModelsChanges(n){const i=this._currentSearchingDisposables=new o.DisposableCollection,r=S.combineLatest(n.map(s=>s.matchesUpdate$)).pipe(S.debounceTime(220)).subscribe(([...s])=>{const a=this._matches=s.flat();a.length?(this._moveToInitialMatch(this._findModels,!0),this._state.changeState({matchesCount:a.length}),this.replaceables$.next(a.filter(c=>c.replaceable))):(this._state.changeState({matchesCount:0,matchesPosition:0}),this.replaceables$.next([]))});n.forEach(s=>i.add(o.toDisposable(s.activelyChangingMatch$.subscribe(a=>{const c=this._matches.findIndex(d=>d===a);this._state.changeState({matchesPosition:c+1})})))),i.add(o.toDisposable(r))}async replace(){return this._matchingModel?this._matchingModel.replace(this._state.replaceString):!1}async replaceAll(){const n=await Promise.all(this._findModels.map(i=>i.replaceAll(this._state.replaceString))).then(i=>i.reduce((r,s)=>(r.success+=s.success,r.failure+=s.failure,r),{success:0,failure:0}));return n.failure===0&&this._stopSearching(),n}getCurrentMatch(){return this._state.matchesPosition>0?this._matches[this._state.matchesPosition-1]:null}_markMatch(n){const i=this._matches.findIndex(r=>r===n);this.currentMatch$.next(n),this._state.changeState({matchesPosition:i+1})}moveToNextMatch(){if(!this._matchingModel)return;const n=this._findModels.length===1,i=this._matchingModel.moveToNextMatch({loop:n});if(i)return this._markMatch(i),i;{const r=this._findModels.findIndex(s=>s===this._matchingModel);return this._moveToNextUnitMatch(r)}}_moveToNextUnitMatch(n){const i=this._findModels.length;for(let r=(n+1)%i;r!==n;){const s=this._findModels[r],a=s.moveToNextMatch({ignoreSelection:!0});if(a)return this._matchingModel=s,this._markMatch(a),a;r=(r+1)%i}if(this._matchingModel){const r=this._matchingModel.moveToNextMatch({ignoreSelection:!0});return r&&this._markMatch(r),r}}moveToPreviousMatch(){if(!this._matchingModel)return;const n=this._findModels.length===1,i=this._matchingModel.moveToPreviousMatch({loop:n});if(i){const r=this._matches.findIndex(s=>s===i);return this.currentMatch$.next(i),this._state.changeState({matchesPosition:r+1}),i}else{const r=this._findModels.length,s=this._findModels.findIndex(c=>c===this._matchingModel);for(let c=(s-1+r)%r;c!==s;){const d=this._findModels[c],m=d.moveToPreviousMatch({ignoreSelection:!0});if(m)return this._matchingModel=d,this._markMatch(m),m;c=(c-1)%r}const a=this._matchingModel.moveToPreviousMatch({ignoreSelection:!0});return a&&this._markMatch(a),a}}_moveToInitialMatch(n,i=!1){var a;const r=(a=this._univerInstanceService.getFocusedUnit())==null?void 0:a.getUnitId();if(!r)return-1;const s=n.findIndex(c=>c.unitId===r);if(s!==-1){this._matchingModel=n[s];const c=this._matchingModel.moveToNextMatch({stayIfOnMatch:!0,noFocus:i});if(c)return this._markMatch(c),s}return this._moveToNextUnitMatch(s),0}};exports.FindReplaceModel=ne([w(2,o.IUniverInstanceService)],exports.FindReplaceModel);var D=(t=>(t.ROW="row",t.COLUMN="column",t))(D||{}),O=(t=>(t.VALUE="value",t.FORMULA="formula",t))(O||{}),T=(t=>(t.SUBUNIT="subunit",t.UNIT="unit",t))(T||{});function E(){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(){u(this,"_stateUpdates$",new S.Subject);u(this,"stateUpdates$",this._stateUpdates$.asObservable());u(this,"_state$",new S.BehaviorSubject(E()));u(this,"state$",this._state$.asObservable());u(this,"_findString","");u(this,"_inputtingFindString","");u(this,"_replaceString","");u(this,"_revealed",!1);u(this,"_replaceRevealed",!1);u(this,"_matchesPosition",0);u(this,"_matchesCount",0);u(this,"_caseSensitive",!0);u(this,"_matchesTheWholeCell",!1);u(this,"_findDirection","row");u(this,"_findScope","subunit");u(this,"_findBy","value");u(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 o.Disposable{constructor(e,n){super();u(this,"_providers",new Set);u(this,"_state",new re);u(this,"_model");u(this,"_currentMatch$",new S.BehaviorSubject(null));u(this,"currentMatch$",this._currentMatch$.asObservable());u(this,"_replaceables$",new S.BehaviorSubject([]));u(this,"replaceables$",this._replaceables$.asObservable());u(this,"_focusSignal$",new S.Subject);u(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()}getProviders(){return this._providers}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(exports.FindReplaceModel,this._state,this._providers),this._model.currentMatch$.subscribe(i=>this._currentMatch$.next(i)),this._model.replaceables$.subscribe(i=>this._replaceables$.next(i));const n=E();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),o.toDisposable(()=>this._providers.delete(e))}_toggleRevealReplace(e){this._contextService.setContextValue(ie,e)}_toggleDisplayRawFormula(e){this._contextService.setContextValue(Ee.RENDER_RAW_FORMULA_KEY,e)}};U=ne([w(0,o.Inject(o.Injector)),w(1,o.IContextService)],U);const B={id:"ui.command.replace-current-match",type:o.CommandType.COMMAND,handler:t=>t.get(R).replace()},Ge="CONFIRM_REPLACE_ALL",k={id:"ui.command.replace-all-matches",type:o.CommandType.COMMAND,handler:async t=>{const e=t.get(p.IConfirmService),n=t.get(o.LocaleService),i=t.get(p.IMessageService);if(!await e.confirm({id:Ge,title:{title:n.t("find-replace.replace.confirm.title")},cancelText:n.t("button.cancel"),confirmText:n.t("button.confirm")}))return!1;const s=await t.get(R).replaceAll(),{success:a,failure:c}=s;return c>0?(a===0?i.show({type:f.MessageType.Error,content:n.t("find-replace.replace.all-failure")}):i.show({type:f.MessageType.Warning,content:n.t("find-replace.replace.partial-success",`${a}`,`${c}`)}),!1):(i.show({type:f.MessageType.Success,content:n.t("find-replace.replace.all-success",`${a}`)}),!0)}},I={id:"ui.operation.open-find-dialog",type:o.CommandType.OPERATION,handler:t=>{const e=t.get(R);return e.revealed?e.focusFindInput():e.start(),!0}},N={id:"ui.operation.open-replace-dialog",type:o.CommandType.OPERATION,handler:t=>{const e=t.get(R);return e.revealed?e.replaceRevealed?e.focusFindInput():e.revealReplace():e.start(!0),!0}},W={type:o.CommandType.OPERATION,id:"ui.operation.go-to-next-match",handler:t=>(t.get(R).moveToNextMatch(),!0)},G={type:o.CommandType.OPERATION,id:"ui.operation.go-to-previous-match",handler:t=>(t.get(R).moveToPreviousMatch(),!0)};var j={exports:{}},x={};/**
2
2
  * @license React
3
3
  * react-jsx-runtime.production.min.js
4
4
  *
@@ -6,4 +6,4 @@
6
6
  *
7
7
  * This source code is licensed under the MIT license found in the
8
8
  * LICENSE file in the root directory of this source tree.
9
- */var J;function He(){if(J)return x;J=1;var i=h,e=Symbol.for("react.element"),n=Symbol.for("react.fragment"),t=Object.prototype.hasOwnProperty,s=i.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,r={key:!0,ref:!0,__self:!0,__source:!0};function a(d,u,S){var _,g={},y=null,b=null;S!==void 0&&(y=""+S),u.key!==void 0&&(y=""+u.key),u.ref!==void 0&&(b=u.ref);for(_ in u)t.call(u,_)&&!r.hasOwnProperty(_)&&(g[_]=u[_]);if(d&&d.defaultProps)for(_ in u=d.defaultProps,u)g[_]===void 0&&(g[_]=u[_]);return{$$typeof:e,type:d,key:y,ref:b,props:g,_owner:s.current}}return x.Fragment=n,x.jsx=a,x.jsxs=a,x}var z;function Ke(){return z||(z=1,$.exports=He()),$.exports}var c=Ke();const qe="univer-find-replace-dialog-container",Je="univer-find-replace-expand-container",ze="univer-button-text",Ye="univer-find-replace-buttons-group",Ze="univer-find-replace-buttons-group-right",P={findReplaceDialogContainer:qe,findReplaceExpandContainer:Je,buttonText:ze,findReplaceButtonsGroup:Ye,findReplaceButtonsGroupRight:Ze};function re(i){const{findCompleted:e,localeService:n,matchesCount:t,matchesPosition:s,findString:r,findReplaceService:a,onChange:d,...u}=i,_=e&&t===0?n.t("find-replace.dialog.no-result"):t===0?" ":void 0;return c.jsx(f.InputWithSlot,{autoFocus:!0,placeholder:n.t("find-replace.dialog.find-placeholder"),slot:c.jsx(f.Pager,{loop:!0,text:_,value:s,total:t,onChange:g=>{s===t&&g===1?a.moveToNextMatch():s===1&&g===t||g<s?a.moveToPreviousMatch():a.moveToNextMatch()}}),value:r,onChange:g=>d==null?void 0:d(g),...u})}function ae(i,e){const n=h.useCallback(()=>{var s;(s=document.querySelector(".univer-find-input input"))==null||s.focus()},[]),t=h.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 h.useImperativeHandle(e,()=>({focus:n,selectHasFocus:t})),h.useEffect(()=>{const s=i.focusSignal$.subscribe(()=>n());return()=>s.unsubscribe()},[i,n]),{focus:n,selectHasFocus:t}}const Qe=h.forwardRef(function(e,n){const t=o.useDependency(o.LocaleService),s=o.useDependency(R),r=o.useDependency(o.ICommandService),a=p.useObservable(s.state$,void 0,!0),{findCompleted:d,findString:u,matchesCount:S,matchesPosition:_}=a,g=h.useCallback(()=>{r.executeCommand(E.id)},[r]),y=h.useCallback(b=>s.changeFindString(b),[s]);return ae(s,n),c.jsxs(c.Fragment,{children:[c.jsx(re,{findCompleted:d,className:"univer-find-input",matchesCount:S,matchesPosition:_,findReplaceService:s,localeService:t,findString:u,onChange:y}),c.jsx("div",{className:P.findReplaceExpandContainer,children:c.jsx(f.Button,{type:"text",size:"small",onClick:g,children:t.t("find-replace.dialog.advanced-finding")})})]})}),Xe=h.forwardRef(function(e,n){const t=o.useDependency(R),s=o.useDependency(o.LocaleService),r=o.useDependency(o.ICommandService),a=o.useDependency(p.IMessageService),d=p.useObservable(t.currentMatch$,void 0,!0),u=p.useObservable(t.replaceables$,void 0,!0),S=p.useObservable(t.state$,void 0,!0),{matchesCount:_,matchesPosition:g,findString:y,inputtingFindString:b,replaceString:le,caseSensitive:de,matchesTheWholeCell:ue,findDirection:he,findScope:pe,findBy:fe,findCompleted:L}=S,_e=b.length===0,ge=_===0||!(d!=null&&d.replaceable),me=u.length===0,ve=h.useCallback(m=>t.changeInputtingFindString(m),[t]),Se=h.useCallback(m=>t.changeReplaceString(m),[t]),{focus:Ce}=ae(t,n),Re=h.useCallback(()=>{y===b?t.moveToNextMatch():(t.changeFindString(b),t.find())},[y,b,t]),be=h.useCallback(()=>r.executeCommand(k.id),[r]),Me=h.useCallback(async()=>{await r.executeCommand(W.id),Ce()},[r]),ye=h.useCallback(m=>{t.changeFindDirection(m)},[t]),Ie=h.useCallback(m=>{t.changeFindScope(m)},[t]),xe=h.useCallback(m=>{t.changeFindBy(m)},[t]),Fe=tt(s),De=it(s),Oe=nt(s);return h.useEffect(()=>{L&&_===0&&a.show({content:s.t("find-replace.dialog.no-match"),type:f.MessageType.Warning,duration:5e3})},[L,_,a,s]),c.jsxs(c.Fragment,{children:[c.jsx(f.FormLayout,{label:s.t("find-replace.dialog.find"),children:c.jsx(re,{findCompleted:L,className:"univer-find-input",matchesCount:_,matchesPosition:g,findReplaceService:t,localeService:s,findString:b,onChange:ve})}),c.jsx(f.FormLayout,{label:s.t("find-replace.dialog.replace"),children:c.jsx(f.Input,{placeholder:s.t("find-replace.dialog.replace-placeholder"),value:le,onChange:m=>Se(m)})}),c.jsx(f.FormLayout,{label:s.t("find-replace.dialog.find-direction.title"),children:c.jsx(f.Select,{value:he,options:De,onChange:ye})}),c.jsx(f.FormDualColumnLayout,{children:c.jsxs(c.Fragment,{children:[c.jsx(f.FormLayout,{label:s.t("find-replace.dialog.find-scope.title"),children:c.jsx(f.Select,{value:pe,options:Fe,onChange:Ie})}),c.jsx(f.FormLayout,{label:s.t("find-replace.dialog.find-by.title"),children:c.jsx(f.Select,{value:fe,options:Oe,onChange:xe})})]})}),c.jsx(f.FormDualColumnLayout,{children:c.jsxs(c.Fragment,{children:[c.jsx(f.FormLayout,{children:c.jsx(f.Checkbox,{checked:de,onChange:m=>{t.changeCaseSensitive(m)},children:s.t("find-replace.dialog.case-sensitive")})}),c.jsx(f.FormLayout,{children:c.jsx(f.Checkbox,{checked:ue,onChange:m=>{t.changeMatchesTheWholeCell(m)},children:s.t("find-replace.dialog.match-the-whole-cell")})})]})}),c.jsxs("div",{className:P.findReplaceButtonsGroup,children:[c.jsx(f.Button,{type:"primary",onClick:Re,disabled:_e,children:s.t("find-replace.dialog.find")}),c.jsxs("span",{className:P.findReplaceButtonsGroupRight,children:[c.jsx(f.Button,{disabled:ge,onClick:be,children:s.t("find-replace.dialog.replace")}),c.jsx(f.Button,{disabled:me,onClick:Me,children:s.t("find-replace.dialog.replace-all")})]})]})]})});function et(){const i=o.useDependency(R),e=o.useDependency(p.ILayoutService),n=o.useDependency(o.IContextService),t=p.useObservable(i.state$,void 0,!0),s=h.useRef(null);h.useEffect(()=>{let u;return s.current&&(u=e.registerContainerElement(s.current)),()=>u==null?void 0:u.dispose()},[e]);const r=h.useRef(null),a=h.useCallback(u=>n.setContextValue(ie,u),[n]),d=h.useCallback(u=>n.setContextValue(te,u),[n]);return h.useEffect(()=>{var S;const u=v.fromEvent(document,"focusin").subscribe(_=>{var g;_.target&&((g=s.current)!=null&&g.contains(_.target))?a(!0):a(!1),!r.current||!r.current.selectHasFocus()?d(!0):d(!1)});return(S=r.current)==null||S.focus(),a(!0),d(!0),()=>{u.unsubscribe(),a(!1)}},[a,d]),c.jsx("div",{className:P.findReplaceDialogContainer,ref:s,children:t.replaceRevealed?c.jsx(Xe,{ref:r}):c.jsx(Qe,{ref:r})})}function tt(i){const e=i.getCurrentLocale();return h.useMemo(()=>[{label:i.t("find-replace.dialog.find-scope.current-sheet"),value:T.SUBUNIT},{label:i.t("find-replace.dialog.find-scope.workbook"),value:T.UNIT}],[e])}function it(i){const e=i.getCurrentLocale();return h.useMemo(()=>[{label:i.t("find-replace.dialog.find-direction.row"),value:D.ROW},{label:i.t("find-replace.dialog.find-direction.column"),value:D.COLUMN}],[e])}function nt(i){const e=i.getCurrentLocale();return h.useMemo(()=>[{label:i.t("find-replace.dialog.find-by.value"),value:O.VALUE},{label:i.t("find-replace.dialog.find-by.formula"),value:O.FORMULA}],[e])}function F(i){return i.getContextValue(ie)}function st(i){return i.getContextValue(ne)}function oe(i){return i.getContextValue(te)}const N="7_find-replace-shortcuts";function H(i){return i.getContextValue(o.FOCUSING_SHEET)}function K(i){return!i.getContextValue(o.EDITOR_ACTIVATED)}const rt={id:I.id,description:"find-replace.shortcut.open-find-dialog",binding:p.KeyCode.F|p.MetaKeys.CTRL_COMMAND,group:N,preconditions(i){return!F(i)&&H(i)&&K(i)}},at={id:I.id,description:"find-replace.shortcut.open-find-dialog",binding:p.KeyCode.F|p.MetaKeys.CTRL_COMMAND,mac:p.KeyCode.F|p.MetaKeys.MAC_CTRL,preconditions(i){return!F(i)&&H(i)&&K(i)}},ot={id:E.id,description:"find-replace.shortcut.open-replace-dialog",binding:p.KeyCode.H|p.MetaKeys.CTRL_COMMAND,mac:p.KeyCode.H|p.MetaKeys.MAC_CTRL,group:N,preconditions(i){return H(i)&&K(i)&&(!F(i)||!st(i))}},ct={id:G.id,description:"find-replace.shortcut.go-to-next-match",binding:p.KeyCode.ENTER,group:N,priority:1e3,preconditions(i){return oe(i)&&F(i)}},lt={id:V.id,description:"find-replace.shortcut.go-to-previous-match",binding:p.KeyCode.ENTER|p.MetaKeys.SHIFT,group:N,priority:1e3,preconditions(i){return oe(i)&&F(i)}};function dt(i){const e=i.get(o.IContextService);return{id:I.id,icon:"SearchIcon",tooltip:"find-replace.toolbar",type:p.MenuItemType.BUTTON,hidden$:p.getMenuHiddenObservable(i,o.UniverInstanceType.UNIVER_SHEET),disabled$:v.combineLatest([e.subscribeContextValue$(o.EDITOR_ACTIVATED),e.subscribeContextValue$(o.FOCUSING_SHEET)]).pipe(v.map(([n,t])=>n||!t))}}const ut={[p.RibbonStartGroup.OTHERS]:{[I.id]:{order:2,menuItemFactory:dt}}};var ht=Object.defineProperty,pt=Object.getOwnPropertyDescriptor,ft=(i,e,n,t)=>{for(var s=t>1?void 0:t?pt(e,n):e,r=i.length-1,a;r>=0;r--)(a=i[r])&&(s=(t?a(e,n,s):a(s))||s);return t&&s&&ht(e,n,s),s},M=(i,e)=>(n,t)=>e(n,t,i);const Y="DESKTOP_FIND_REPLACE_DIALOG",ce=350,_t=20,gt=-90;exports.FindReplaceController=class extends o.RxDisposable{constructor(n,t,s,r,a,d,u,S,_,g){super();l(this,"_closingListenerDisposable");this._univerInstanceService=n,this._menuManagerService=t,this._shortcutService=s,this._commandService=r,this._findReplaceService=a,this._dialogService=d,this._layoutService=u,this._localeService=S,this._componentManager=_,this._injector=g,this._initCommands(),this._initUI(),this._initShortcuts()}dispose(){var n;super.dispose(),(n=this._closingListenerDisposable)==null||n.dispose(),this._closingListenerDisposable=null}_initCommands(){[I,E,G,V,W,k].forEach(n=>{this.disposeWithMe(this._commandService.registerCommand(n))})}_initShortcuts(){[ot,rt,at,lt,ct].forEach(n=>this.disposeWithMe(this._shortcutService.registerShortcut(n)))}_initUI(){this.disposeWithMe(this._componentManager.register("FindReplaceDialog",et)),this.disposeWithMe(this._componentManager.register("SearchIcon",ee)),this._menuManagerService.mergeMenu(ut),this._findReplaceService.stateUpdates$.pipe(v.takeUntil(this.dispose$)).subscribe(n=>{n.revealed===!0&&this._openPanel()})}_openPanel(){this._dialogService.open({id:Y,draggable:!0,width:ce,title:{title:this._localeService.t("find-replace.dialog.title")},children:{label:"FindReplaceDialog"},destroyOnClose:!0,defaultPosition:mt(),preservePositionOnDestroy:!0,onClose:()=>this.closePanel()}),this._closingListenerDisposable=o.toDisposable(this._univerInstanceService.focused$.pipe(v.takeUntil(this.dispose$)).subscribe(n=>{(!n||!this._univerInstanceService.getUniverSheetInstance(n))&&this.closePanel()}))}closePanel(){this._closingListenerDisposable&&(this._closingListenerDisposable.dispose(),this._closingListenerDisposable=null,this._dialogService.close(Y),this._findReplaceService.terminate(),queueMicrotask(()=>this._layoutService.focus()))}};exports.FindReplaceController=ft([M(0,o.IUniverInstanceService),M(1,p.IMenuManagerService),M(2,p.IShortcutService),M(3,o.ICommandService),M(4,R),M(5,p.IDialogService),M(6,p.ILayoutService),M(7,o.Inject(o.LocaleService)),M(8,o.Inject(p.ComponentManager)),M(9,o.Inject(o.Injector))],exports.FindReplaceController);function mt(){const{innerWidth:i}=window;return{x:(i-ce)/2-_t,y:gt}}var vt=Object.defineProperty,St=Object.getOwnPropertyDescriptor,Ct=(i,e,n,t)=>{for(var s=t>1?void 0:t?St(e,n):e,r=i.length-1,a;r>=0;r--)(a=i[r])&&(s=(t?a(e,n,s):a(s))||s);return t&&s&&vt(e,n,s),s},Z=(i,e)=>(n,t)=>e(n,t,i);const Rt="UNIVER_FIND_REPLACE_PLUGIN";var j;exports.UniverFindReplacePlugin=(j=class extends o.Plugin{constructor(e=q,n,t){super(),this._config=e,this._injector=n,this._configService=t;const{...s}=o.merge({},q,this._config);this._configService.setConfig(Ne,s)}onStarting(){[[exports.FindReplaceController],[R,{useClass:U}]].forEach(e=>this._injector.add(e))}onRendered(){this._injector.get(exports.FindReplaceController)}},l(j,"pluginName",Rt),j);exports.UniverFindReplacePlugin=Ct([Z(1,o.Inject(o.Injector)),Z(2,o.IConfigService)],exports.UniverFindReplacePlugin);exports.FindBy=O;exports.FindDirection=D;exports.FindModel=ke;exports.FindScope=T;exports.GoToNextMatchOperation=G;exports.GoToPreviousMatchOperation=V;exports.IFindReplaceService=R;exports.OpenFindDialogOperation=I;exports.OpenReplaceDialogOperation=E;exports.ReplaceAllMatchesCommand=W;exports.ReplaceCurrentMatchCommand=k;
9
+ */var q;function Ve(){if(q)return x;q=1;var t=h,e=Symbol.for("react.element"),n=Symbol.for("react.fragment"),i=Object.prototype.hasOwnProperty,r=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,s={key:!0,ref:!0,__self:!0,__source:!0};function a(c,d,m){var _,g={},y=null,b=null;m!==void 0&&(y=""+m),d.key!==void 0&&(y=""+d.key),d.ref!==void 0&&(b=d.ref);for(_ in d)i.call(d,_)&&!s.hasOwnProperty(_)&&(g[_]=d[_]);if(c&&c.defaultProps)for(_ in d=c.defaultProps,d)g[_]===void 0&&(g[_]=d[_]);return{$$typeof:e,type:c,key:y,ref:b,props:g,_owner:r.current}}return x.Fragment=n,x.jsx=a,x.jsxs=a,x}var J;function He(){return J||(J=1,j.exports=Ve()),j.exports}var l=He();const Ke="univer-find-replace-dialog-container",qe="univer-find-replace-expand-container",Je="univer-button-text",ze="univer-find-replace-buttons-group",Ye="univer-find-replace-buttons-group-right",P={findReplaceDialogContainer:Ke,findReplaceExpandContainer:qe,buttonText:Je,findReplaceButtonsGroup:ze,findReplaceButtonsGroupRight:Ye};function se(t){const{findCompleted:e,localeService:n,matchesCount:i,matchesPosition:r,findString:s,findReplaceService:a,onChange:c,...d}=t,_=e&&i===0?n.t("find-replace.dialog.no-result"):i===0?" ":void 0;return l.jsx(f.InputWithSlot,{autoFocus:!0,placeholder:n.t("find-replace.dialog.find-placeholder"),slot:l.jsx(f.Pager,{loop:!0,text:_,value:r,total:i,onChange:g=>{r===i&&g===1?a.moveToNextMatch():r===1&&g===i||g<r?a.moveToPreviousMatch():a.moveToNextMatch()}}),value:s,onChange:g=>c==null?void 0:c(g),...d})}function ae(t,e){const n=h.useCallback(()=>{var r;(r=document.querySelector(".univer-find-input input"))==null||r.focus()},[]),i=h.useCallback(()=>{const r=document.querySelectorAll(".univer-find-replace-dialog-container .univer-select-selection-search-input");return Array.from(r).some(s=>s===document.activeElement)},[]);return h.useImperativeHandle(e,()=>({focus:n,selectHasFocus:i})),h.useEffect(()=>{const r=t.focusSignal$.subscribe(()=>n());return()=>r.unsubscribe()},[t,n]),{focus:n,selectHasFocus:i}}const Ze=h.forwardRef(function(e,n){const i=o.useDependency(o.LocaleService),r=o.useDependency(R),s=o.useDependency(o.ICommandService),a=p.useObservable(r.state$,void 0,!0),{findCompleted:c,findString:d,matchesCount:m,matchesPosition:_}=a,g=h.useCallback(()=>{s.executeCommand(N.id)},[s]),y=h.useCallback(b=>r.changeFindString(b),[r]);return ae(r,n),l.jsxs(l.Fragment,{children:[l.jsx(se,{findCompleted:c,className:"univer-find-input",matchesCount:m,matchesPosition:_,findReplaceService:r,localeService:i,findString:d,onChange:y}),l.jsx("div",{className:P.findReplaceExpandContainer,children:l.jsx(f.Button,{type:"text",size:"small",onClick:g,children:i.t("find-replace.dialog.advanced-finding")})})]})}),Qe=h.forwardRef(function(e,n){const i=o.useDependency(R),r=o.useDependency(o.LocaleService),s=o.useDependency(o.ICommandService),a=o.useDependency(p.IMessageService),c=p.useObservable(i.currentMatch$,void 0,!0),d=p.useObservable(i.replaceables$,void 0,!0),m=p.useObservable(i.state$,void 0,!0),{matchesCount:_,matchesPosition:g,findString:y,inputtingFindString:b,replaceString:le,caseSensitive:de,matchesTheWholeCell:ue,findDirection:he,findScope:pe,findBy:fe,findCompleted:$}=m,_e=b.length===0,ge=_===0||!(c!=null&&c.replaceable),me=d.length===0,ve=h.useCallback(v=>i.changeInputtingFindString(v),[i]),Se=h.useCallback(v=>i.changeReplaceString(v),[i]),{focus:Ce}=ae(i,n),Re=h.useCallback(()=>{y===b?i.moveToNextMatch():(i.changeFindString(b),i.find())},[y,b,i]),be=h.useCallback(()=>s.executeCommand(B.id),[s]),Me=h.useCallback(async()=>{await s.executeCommand(k.id),Ce()},[s]),ye=h.useCallback(v=>{i.changeFindDirection(v)},[i]),Ie=h.useCallback(v=>{i.changeFindScope(v)},[i]),xe=h.useCallback(v=>{i.changeFindBy(v)},[i]),Fe=et(r),De=tt(r),Oe=it(r);return h.useEffect(()=>{$&&_===0&&a.show({content:r.t("find-replace.dialog.no-match"),type:f.MessageType.Warning,duration:5e3})},[$,_,a,r]),l.jsxs(l.Fragment,{children:[l.jsx(f.FormLayout,{label:r.t("find-replace.dialog.find"),children:l.jsx(se,{findCompleted:$,className:"univer-find-input",matchesCount:_,matchesPosition:g,findReplaceService:i,localeService:r,findString:b,onChange:ve})}),l.jsx(f.FormLayout,{label:r.t("find-replace.dialog.replace"),children:l.jsx(f.Input,{placeholder:r.t("find-replace.dialog.replace-placeholder"),value:le,onChange:v=>Se(v)})}),l.jsx(f.FormLayout,{label:r.t("find-replace.dialog.find-direction.title"),children:l.jsx(f.Select,{value:he,options:De,onChange:ye})}),l.jsx(f.FormDualColumnLayout,{children:l.jsxs(l.Fragment,{children:[l.jsx(f.FormLayout,{label:r.t("find-replace.dialog.find-scope.title"),children:l.jsx(f.Select,{value:pe,options:Fe,onChange:Ie})}),l.jsx(f.FormLayout,{label:r.t("find-replace.dialog.find-by.title"),children:l.jsx(f.Select,{value:fe,options:Oe,onChange:xe})})]})}),l.jsx(f.FormDualColumnLayout,{children:l.jsxs(l.Fragment,{children:[l.jsx(f.FormLayout,{children:l.jsx(f.Checkbox,{checked:de,onChange:v=>{i.changeCaseSensitive(v)},children:r.t("find-replace.dialog.case-sensitive")})}),l.jsx(f.FormLayout,{children:l.jsx(f.Checkbox,{checked:ue,onChange:v=>{i.changeMatchesTheWholeCell(v)},children:r.t("find-replace.dialog.match-the-whole-cell")})})]})}),l.jsxs("div",{className:P.findReplaceButtonsGroup,children:[l.jsx(f.Button,{type:"primary",onClick:Re,disabled:_e,children:r.t("find-replace.dialog.find")}),l.jsxs("span",{className:P.findReplaceButtonsGroupRight,children:[l.jsx(f.Button,{disabled:ge,onClick:be,children:r.t("find-replace.dialog.replace")}),l.jsx(f.Button,{disabled:me,onClick:Me,children:r.t("find-replace.dialog.replace-all")})]})]})]})});function Xe(){const t=o.useDependency(R),e=o.useDependency(p.ILayoutService),n=o.useDependency(o.IContextService),i=p.useObservable(t.state$,void 0,!0),r=h.useRef(null);h.useEffect(()=>{let d;return r.current&&(d=e.registerContainerElement(r.current)),()=>d==null?void 0:d.dispose()},[e]);const s=h.useRef(null),a=h.useCallback(d=>n.setContextValue(te,d),[n]),c=h.useCallback(d=>n.setContextValue(ee,d),[n]);return h.useEffect(()=>{var m;const d=S.fromEvent(document,"focusin").subscribe(_=>{var g;_.target&&((g=r.current)!=null&&g.contains(_.target))?a(!0):a(!1),!s.current||!s.current.selectHasFocus()?c(!0):c(!1)});return(m=s.current)==null||m.focus(),a(!0),c(!0),()=>{d.unsubscribe(),a(!1)}},[a,c]),l.jsx("div",{className:P.findReplaceDialogContainer,ref:r,children:i.replaceRevealed?l.jsx(Qe,{ref:s}):l.jsx(Ze,{ref:s})})}function et(t){const e=t.getCurrentLocale();return h.useMemo(()=>[{label:t.t("find-replace.dialog.find-scope.current-sheet"),value:T.SUBUNIT},{label:t.t("find-replace.dialog.find-scope.workbook"),value:T.UNIT}],[e])}function tt(t){const e=t.getCurrentLocale();return h.useMemo(()=>[{label:t.t("find-replace.dialog.find-direction.row"),value:D.ROW},{label:t.t("find-replace.dialog.find-direction.column"),value:D.COLUMN}],[e])}function it(t){const e=t.getCurrentLocale();return h.useMemo(()=>[{label:t.t("find-replace.dialog.find-by.value"),value:O.VALUE},{label:t.t("find-replace.dialog.find-by.formula"),value:O.FORMULA}],[e])}function F(t){return t.getContextValue(te)}function nt(t){return t.getContextValue(ie)}function oe(t){return t.getContextValue(ee)}const L="7_find-replace-shortcuts";function V(t){return t.getContextValue(o.FOCUSING_SHEET)}function H(t){return!t.getContextValue(o.EDITOR_ACTIVATED)}const rt={id:I.id,description:"find-replace.shortcut.open-find-dialog",binding:p.KeyCode.F|p.MetaKeys.CTRL_COMMAND,group:L,preconditions(t){return!F(t)&&V(t)&&H(t)}},st={id:I.id,description:"find-replace.shortcut.open-find-dialog",binding:p.KeyCode.F|p.MetaKeys.CTRL_COMMAND,mac:p.KeyCode.F|p.MetaKeys.MAC_CTRL,preconditions(t){return!F(t)&&V(t)&&H(t)}},at={id:N.id,description:"find-replace.shortcut.open-replace-dialog",binding:p.KeyCode.H|p.MetaKeys.CTRL_COMMAND,mac:p.KeyCode.H|p.MetaKeys.MAC_CTRL,group:L,preconditions(t){return V(t)&&H(t)&&(!F(t)||!nt(t))}},ot={id:W.id,description:"find-replace.shortcut.go-to-next-match",binding:p.KeyCode.ENTER,group:L,priority:1e3,preconditions(t){return oe(t)&&F(t)}},ct={id:G.id,description:"find-replace.shortcut.go-to-previous-match",binding:p.KeyCode.ENTER|p.MetaKeys.SHIFT,group:L,priority:1e3,preconditions(t){return oe(t)&&F(t)}};function lt(t){const e=t.get(o.IContextService);return{id:I.id,icon:"SearchIcon",tooltip:"find-replace.toolbar",type:p.MenuItemType.BUTTON,hidden$:p.getMenuHiddenObservable(t,o.UniverInstanceType.UNIVER_SHEET),disabled$:S.combineLatest([e.subscribeContextValue$(o.EDITOR_ACTIVATED),e.subscribeContextValue$(o.FOCUSING_SHEET)]).pipe(S.map(([n,i])=>n||!i))}}const dt={[p.RibbonStartGroup.OTHERS]:{[I.id]:{order:2,menuItemFactory:lt}}};var ut=Object.defineProperty,ht=Object.getOwnPropertyDescriptor,pt=(t,e,n,i)=>{for(var r=i>1?void 0:i?ht(e,n):e,s=t.length-1,a;s>=0;s--)(a=t[s])&&(r=(i?a(e,n,r):a(r))||r);return i&&r&&ut(e,n,r),r},M=(t,e)=>(n,i)=>e(n,i,t);const z="DESKTOP_FIND_REPLACE_DIALOG",ce=350,ft=20,_t=-90;exports.FindReplaceController=class extends o.RxDisposable{constructor(n,i,r,s,a,c,d,m,_,g){super();u(this,"_closingListenerDisposable");this._univerInstanceService=n,this._menuManagerService=i,this._shortcutService=r,this._commandService=s,this._findReplaceService=a,this._dialogService=c,this._layoutService=d,this._localeService=m,this._componentManager=_,this._injector=g,this._initCommands(),this._initUI(),this._initShortcuts()}dispose(){var n;super.dispose(),(n=this._closingListenerDisposable)==null||n.dispose(),this._closingListenerDisposable=null}_initCommands(){[I,N,W,G,k,B].forEach(n=>{this.disposeWithMe(this._commandService.registerCommand(n))})}_initShortcuts(){[at,rt,st,ct,ot].forEach(n=>this.disposeWithMe(this._shortcutService.registerShortcut(n)))}_initUI(){this.disposeWithMe(this._componentManager.register("FindReplaceDialog",Xe)),this.disposeWithMe(this._componentManager.register("SearchIcon",X)),this._menuManagerService.mergeMenu(dt),this._findReplaceService.stateUpdates$.pipe(S.takeUntil(this.dispose$)).subscribe(n=>{n.revealed===!0&&this._openPanel()})}_openPanel(){this._dialogService.open({id:z,draggable:!0,width:ce,title:{title:this._localeService.t("find-replace.dialog.title")},children:{label:"FindReplaceDialog"},destroyOnClose:!0,defaultPosition:gt(),preservePositionOnDestroy:!0,onClose:()=>this.closePanel()}),this._closingListenerDisposable=o.toDisposable(this._univerInstanceService.focused$.pipe(S.takeUntil(this.dispose$)).subscribe(n=>{(!n||!this._univerInstanceService.getUniverSheetInstance(n))&&this.closePanel()}))}closePanel(){this._closingListenerDisposable&&(this._closingListenerDisposable.dispose(),this._closingListenerDisposable=null,this._dialogService.close(z),this._findReplaceService.terminate(),queueMicrotask(()=>this._layoutService.focus()))}};exports.FindReplaceController=pt([M(0,o.IUniverInstanceService),M(1,p.IMenuManagerService),M(2,p.IShortcutService),M(3,o.ICommandService),M(4,R),M(5,p.IDialogService),M(6,p.ILayoutService),M(7,o.Inject(o.LocaleService)),M(8,o.Inject(p.ComponentManager)),M(9,o.Inject(o.Injector))],exports.FindReplaceController);function gt(){const{innerWidth:t}=window;return{x:(t-ce)/2-ft,y:_t}}var mt=Object.defineProperty,vt=Object.getOwnPropertyDescriptor,St=(t,e,n,i)=>{for(var r=i>1?void 0:i?vt(e,n):e,s=t.length-1,a;s>=0;s--)(a=t[s])&&(r=(i?a(e,n,r):a(r))||r);return i&&r&&mt(e,n,r),r},Y=(t,e)=>(n,i)=>e(n,i,t);const Ct="UNIVER_FIND_REPLACE_PLUGIN";var A;exports.UniverFindReplacePlugin=(A=class extends o.Plugin{constructor(e=K,n,i){super(),this._config=e,this._injector=n,this._configService=i;const{...r}=o.merge({},K,this._config);this._configService.setConfig(Ne,r)}onStarting(){[[exports.FindReplaceController],[R,{useClass:U}]].forEach(e=>this._injector.add(e))}onRendered(){this._injector.get(exports.FindReplaceController)}},u(A,"pluginName",Ct),A);exports.UniverFindReplacePlugin=St([Y(1,o.Inject(o.Injector)),Y(2,o.IConfigService)],exports.UniverFindReplacePlugin);exports.FindBy=O;exports.FindDirection=D;exports.FindModel=ke;exports.FindReplaceState=re;exports.FindScope=T;exports.GoToNextMatchOperation=W;exports.GoToPreviousMatchOperation=G;exports.IFindReplaceService=R;exports.OpenFindDialogOperation=I;exports.OpenReplaceDialogOperation=N;exports.ReplaceAllMatchesCommand=k;exports.ReplaceCurrentMatchCommand=B;exports.createInitFindReplaceState=E;
package/lib/es/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  var at = Object.defineProperty;
2
2
  var ot = (t, e, n) => e in t ? at(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n;
3
- var c = (t, e, n) => ot(t, typeof e != "symbol" ? e + "" : e, n);
4
- import { createIdentifier as ct, Inject as F, Injector as Q, Disposable as X, IUniverInstanceService as ge, IContextService as ee, DisposableCollection as lt, toDisposable as $, CommandType as y, LocaleService as w, useDependency as C, ICommandService as te, FOCUSING_SHEET as me, EDITOR_ACTIVATED as ve, UniverInstanceType as dt, RxDisposable as ht, Plugin as ut, merge as ft, IConfigService as pt } from "@univerjs/core";
3
+ var l = (t, e, n) => ot(t, typeof e != "symbol" ? e + "" : e, n);
4
+ import { createIdentifier as ct, Inject as F, Injector as Q, Disposable as X, DisposableCollection as lt, toDisposable as $, IUniverInstanceService as ge, IContextService as ee, CommandType as y, LocaleService as w, useDependency as C, ICommandService as te, FOCUSING_SHEET as me, EDITOR_ACTIVATED as ve, UniverInstanceType as dt, RxDisposable as ht, Plugin as ut, merge as ft, IConfigService as pt } from "@univerjs/core";
5
5
  import { IConfirmService as _t, IMessageService as Se, useObservable as D, ILayoutService as Ce, KeyCode as b, MetaKeys as x, MenuItemType as gt, getMenuHiddenObservable as mt, RibbonStartGroup as vt, ComponentManager as St, IMenuManagerService as Ct, IShortcutService as Rt, IDialogService as Mt } from "@univerjs/ui";
6
6
  import { throttleTime as bt, BehaviorSubject as P, combineLatest as Re, debounceTime as xt, Subject as Me, fromEvent as yt, map as It, takeUntil as oe } from "rxjs";
7
7
  import { MessageType as E, InputWithSlot as Ft, Pager as Dt, Button as N, FormLayout as M, Input as Pt, Select as G, FormDualColumnLayout as ce, Checkbox as le } from "@univerjs/design";
@@ -24,8 +24,8 @@ var g = function() {
24
24
  e.indexOf(i[r]) < 0 && Object.prototype.propertyIsEnumerable.call(t, i[r]) && (n[i[r]] = t[i[r]]);
25
25
  return n;
26
26
  }, xe = U(function(t, e) {
27
- var n = t.icon, i = t.id, r = t.className, s = t.extend, a = $t(t, ["icon", "id", "className", "extend"]), l = "univerjs-icon univerjs-icon-".concat(i, " ").concat(r || "").trim(), d = H("_".concat(jt()));
28
- return ye(n, "".concat(i), { defIds: n.defIds, idSuffix: d.current }, g({ ref: e, className: l }, a), s);
27
+ var n = t.icon, i = t.id, r = t.className, s = t.extend, a = $t(t, ["icon", "id", "className", "extend"]), d = "univerjs-icon univerjs-icon-".concat(i, " ").concat(r || "").trim(), c = H("_".concat(jt()));
28
+ return ye(n, "".concat(i), { defIds: n.defIds, idSuffix: c.current }, g({ ref: e, className: d }, a), s);
29
29
  });
30
30
  function ye(t, e, n, i, r) {
31
31
  return be(t.tag, g(g({ key: e }, At(t, n, r)), i), (Lt(t, n).children || []).map(function(s, a) {
@@ -37,8 +37,8 @@ function At(t, e, n) {
37
37
  n != null && n.colorChannel1 && i.fill === "colorChannel1" && (i.fill = n.colorChannel1);
38
38
  var r = e.defIds;
39
39
  return !r || r.length === 0 || (t.tag === "use" && i["xlink:href"] && (i["xlink:href"] = i["xlink:href"] + e.idSuffix), Object.entries(i).forEach(function(s) {
40
- var a = s[0], l = s[1];
41
- typeof l == "string" && (i[a] = l.replace(/url\(#(.*)\)/, "url(#$1".concat(e.idSuffix, ")")));
40
+ var a = s[0], d = s[1];
41
+ typeof d == "string" && (i[a] = d.replace(/url\(#(.*)\)/, "url(#$1".concat(e.idSuffix, ")")));
42
42
  })), i;
43
43
  }
44
44
  function Lt(t, e) {
@@ -74,14 +74,14 @@ function Wt(t) {
74
74
  let J = class extends X {
75
75
  constructor(e, n, i) {
76
76
  super();
77
- c(this, "currentMatch$", new P(null));
78
- c(this, "replaceables$", new P([]));
77
+ l(this, "currentMatch$", new P(null));
78
+ l(this, "replaceables$", new P([]));
79
79
  /** All find models returned by providers. */
80
- c(this, "_findModels", []);
80
+ l(this, "_findModels", []);
81
81
  /** The find model that the current match is from. */
82
- c(this, "_matchingModel", null);
83
- c(this, "_matches", []);
84
- c(this, "_currentSearchingDisposables", null);
82
+ l(this, "_matchingModel", null);
83
+ l(this, "_matches", []);
84
+ l(this, "_currentSearchingDisposables", null);
85
85
  this._state = e, this._providers = n, this._univerInstanceService = i, this.disposeWithMe(
86
86
  this._state.stateUpdates$.pipe(bt(200, void 0, { leading: !0, trailing: !0 })).subscribe(async (r) => {
87
87
  const s = this._state.state;
@@ -134,7 +134,7 @@ let J = class extends X {
134
134
  s.length ? (this._moveToInitialMatch(this._findModels, !0), this._state.changeState({ matchesCount: s.length }), this.replaceables$.next(s.filter((a) => a.replaceable))) : (this._state.changeState({ matchesCount: 0, matchesPosition: 0 }), this.replaceables$.next([]));
135
135
  });
136
136
  e.forEach((r) => n.add($(r.activelyChangingMatch$.subscribe((s) => {
137
- const a = this._matches.findIndex((l) => l === s);
137
+ const a = this._matches.findIndex((d) => d === s);
138
138
  this._state.changeState({ matchesPosition: a + 1 });
139
139
  })))), n.add($(i));
140
140
  }
@@ -157,25 +157,23 @@ let J = class extends X {
157
157
  return;
158
158
  const e = this._findModels.length === 1, n = this._matchingModel.moveToNextMatch({ loop: e });
159
159
  if (n)
160
- this._markMatch(n);
161
- else {
160
+ return this._markMatch(n), n;
161
+ {
162
162
  const i = this._findModels.findIndex((r) => r === this._matchingModel);
163
- this._moveToNextUnitMatch(i);
163
+ return this._moveToNextUnitMatch(i);
164
164
  }
165
165
  }
166
166
  _moveToNextUnitMatch(e) {
167
167
  const n = this._findModels.length;
168
168
  for (let i = (e + 1) % n; i !== e; ) {
169
169
  const r = this._findModels[i], s = r.moveToNextMatch({ ignoreSelection: !0 });
170
- if (s) {
171
- this._matchingModel = r, this._markMatch(s);
172
- return;
173
- }
170
+ if (s)
171
+ return this._matchingModel = r, this._markMatch(s), s;
174
172
  i = (i + 1) % n;
175
173
  }
176
174
  if (this._matchingModel) {
177
175
  const i = this._matchingModel.moveToNextMatch({ ignoreSelection: !0 });
178
- i && this._markMatch(i);
176
+ return i && this._markMatch(i), i;
179
177
  }
180
178
  }
181
179
  moveToPreviousMatch() {
@@ -184,19 +182,17 @@ let J = class extends X {
184
182
  const e = this._findModels.length === 1, n = this._matchingModel.moveToPreviousMatch({ loop: e });
185
183
  if (n) {
186
184
  const i = this._matches.findIndex((r) => r === n);
187
- this.currentMatch$.next(n), this._state.changeState({ matchesPosition: i + 1 });
185
+ return this.currentMatch$.next(n), this._state.changeState({ matchesPosition: i + 1 }), n;
188
186
  } else {
189
187
  const i = this._findModels.length, r = this._findModels.findIndex((a) => a === this._matchingModel);
190
188
  for (let a = (r - 1 + i) % i; a !== r; ) {
191
- const l = this._findModels[a], d = l.moveToPreviousMatch({ ignoreSelection: !0 });
192
- if (d) {
193
- this._matchingModel = l, this._markMatch(d);
194
- return;
195
- }
189
+ const d = this._findModels[a], c = d.moveToPreviousMatch({ ignoreSelection: !0 });
190
+ if (c)
191
+ return this._matchingModel = d, this._markMatch(c), c;
196
192
  a = (a - 1) % i;
197
193
  }
198
194
  const s = this._matchingModel.moveToPreviousMatch({ ignoreSelection: !0 });
199
- s && this._markMatch(s);
195
+ return s && this._markMatch(s), s;
200
196
  }
201
197
  }
202
198
  _moveToInitialMatch(e, n = !1) {
@@ -237,23 +233,23 @@ function ne() {
237
233
  }
238
234
  class Gt {
239
235
  constructor() {
240
- c(this, "_stateUpdates$", new Me());
241
- c(this, "stateUpdates$", this._stateUpdates$.asObservable());
242
- c(this, "_state$", new P(ne()));
243
- c(this, "state$", this._state$.asObservable());
244
- c(this, "_findString", "");
245
- c(this, "_inputtingFindString", "");
246
- c(this, "_replaceString", "");
247
- c(this, "_revealed", !1);
248
- c(this, "_replaceRevealed", !1);
249
- c(this, "_matchesPosition", 0);
250
- c(this, "_matchesCount", 0);
251
- c(this, "_caseSensitive", !0);
252
- c(this, "_matchesTheWholeCell", !1);
253
- c(this, "_findDirection", "row");
254
- c(this, "_findScope", "subunit");
255
- c(this, "_findBy", "value");
256
- c(this, "_findCompleted", !1);
236
+ l(this, "_stateUpdates$", new Me());
237
+ l(this, "stateUpdates$", this._stateUpdates$.asObservable());
238
+ l(this, "_state$", new P(ne()));
239
+ l(this, "state$", this._state$.asObservable());
240
+ l(this, "_findString", "");
241
+ l(this, "_inputtingFindString", "");
242
+ l(this, "_replaceString", "");
243
+ l(this, "_revealed", !1);
244
+ l(this, "_replaceRevealed", !1);
245
+ l(this, "_matchesPosition", 0);
246
+ l(this, "_matchesCount", 0);
247
+ l(this, "_caseSensitive", !0);
248
+ l(this, "_matchesTheWholeCell", !1);
249
+ l(this, "_findDirection", "row");
250
+ l(this, "_findScope", "subunit");
251
+ l(this, "_findBy", "value");
252
+ l(this, "_findCompleted", !1);
257
253
  }
258
254
  get state() {
259
255
  return this._state$.getValue();
@@ -320,15 +316,15 @@ class Gt {
320
316
  let Z = class extends X {
321
317
  constructor(e, n) {
322
318
  super();
323
- c(this, "_providers", /* @__PURE__ */ new Set());
324
- c(this, "_state", new Gt());
325
- c(this, "_model");
326
- c(this, "_currentMatch$", new P(null));
327
- c(this, "currentMatch$", this._currentMatch$.asObservable());
328
- c(this, "_replaceables$", new P([]));
329
- c(this, "replaceables$", this._replaceables$.asObservable());
330
- c(this, "_focusSignal$", new Me());
331
- c(this, "focusSignal$", this._focusSignal$.asObservable());
319
+ l(this, "_providers", /* @__PURE__ */ new Set());
320
+ l(this, "_state", new Gt());
321
+ l(this, "_model");
322
+ l(this, "_currentMatch$", new P(null));
323
+ l(this, "currentMatch$", this._currentMatch$.asObservable());
324
+ l(this, "_replaceables$", new P([]));
325
+ l(this, "replaceables$", this._replaceables$.asObservable());
326
+ l(this, "_focusSignal$", new Me());
327
+ l(this, "focusSignal$", this._focusSignal$.asObservable());
332
328
  this._injector = e, this._contextService = n;
333
329
  }
334
330
  get stateUpdates$() {
@@ -346,6 +342,9 @@ let Z = class extends X {
346
342
  dispose() {
347
343
  super.dispose(), this._currentMatch$.next(null), this._currentMatch$.complete(), this._replaceables$.next([]), this._replaceables$.complete(), this._focusSignal$.complete();
348
344
  }
345
+ getProviders() {
346
+ return this._providers;
347
+ }
349
348
  getCurrentMatch() {
350
349
  var e;
351
350
  return (e = this._model) == null ? void 0 : e.getCurrentMatch();
@@ -445,13 +444,13 @@ const Te = {
445
444
  confirmText: n.t("button.confirm")
446
445
  }))
447
446
  return !1;
448
- const s = await t.get(m).replaceAll(), { success: a, failure: l } = s;
449
- return l > 0 ? (a === 0 ? i.show({
447
+ const s = await t.get(m).replaceAll(), { success: a, failure: d } = s;
448
+ return d > 0 ? (a === 0 ? i.show({
450
449
  type: E.Error,
451
450
  content: n.t("find-replace.replace.all-failure")
452
451
  }) : i.show({
453
452
  type: E.Warning,
454
- content: n.t("find-replace.replace.partial-success", `${a}`, `${l}`)
453
+ content: n.t("find-replace.replace.partial-success", `${a}`, `${d}`)
455
454
  }), !1) : (i.show({
456
455
  type: E.Success,
457
456
  content: n.t("find-replace.replace.all-success", `${a}`)
@@ -495,12 +494,12 @@ function Vt() {
495
494
  if (he) return I;
496
495
  he = 1;
497
496
  var t = Tt, e = Symbol.for("react.element"), n = Symbol.for("react.fragment"), i = Object.prototype.hasOwnProperty, r = t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, s = { key: !0, ref: !0, __self: !0, __source: !0 };
498
- function a(l, d, _) {
497
+ function a(d, c, _) {
499
498
  var h, u = {}, R = null, v = null;
500
- _ !== void 0 && (R = "" + _), d.key !== void 0 && (R = "" + d.key), d.ref !== void 0 && (v = d.ref);
501
- for (h in d) i.call(d, h) && !s.hasOwnProperty(h) && (u[h] = d[h]);
502
- if (l && l.defaultProps) for (h in d = l.defaultProps, d) u[h] === void 0 && (u[h] = d[h]);
503
- return { $$typeof: e, type: l, key: R, ref: v, props: u, _owner: r.current };
499
+ _ !== void 0 && (R = "" + _), c.key !== void 0 && (R = "" + c.key), c.ref !== void 0 && (v = c.ref);
500
+ for (h in c) i.call(c, h) && !s.hasOwnProperty(h) && (u[h] = c[h]);
501
+ if (d && d.defaultProps) for (h in c = d.defaultProps, c) u[h] === void 0 && (u[h] = c[h]);
502
+ return { $$typeof: e, type: d, key: R, ref: v, props: u, _owner: r.current };
504
503
  }
505
504
  return I.Fragment = n, I.jsx = a, I.jsxs = a, I;
506
505
  }
@@ -517,7 +516,7 @@ const qt = "univer-find-replace-dialog-container", Jt = "univer-find-replace-exp
517
516
  findReplaceButtonsGroupRight: Yt
518
517
  };
519
518
  function Ae(t) {
520
- const { findCompleted: e, localeService: n, matchesCount: i, matchesPosition: r, findString: s, findReplaceService: a, onChange: l, ...d } = t, h = e && i === 0 ? n.t("find-replace.dialog.no-result") : i === 0 ? " " : void 0;
519
+ const { findCompleted: e, localeService: n, matchesCount: i, matchesPosition: r, findString: s, findReplaceService: a, onChange: d, ...c } = t, h = e && i === 0 ? n.t("find-replace.dialog.no-result") : i === 0 ? " " : void 0;
521
520
  return /* @__PURE__ */ o.jsx(
522
521
  Ft,
523
522
  {
@@ -536,8 +535,8 @@ function Ae(t) {
536
535
  }
537
536
  ),
538
537
  value: s,
539
- onChange: (u) => l == null ? void 0 : l(u),
540
- ...d
538
+ onChange: (u) => d == null ? void 0 : d(u),
539
+ ...c
541
540
  }
542
541
  );
543
542
  }
@@ -555,27 +554,27 @@ function Le(t, e) {
555
554
  }, [t, n]), { focus: n, selectHasFocus: i };
556
555
  }
557
556
  const Zt = U(function(e, n) {
558
- const i = C(w), r = C(m), s = C(te), a = D(r.state$, void 0, !0), { findCompleted: l, findString: d, matchesCount: _, matchesPosition: h } = a, u = p(() => {
557
+ const i = C(w), r = C(m), s = C(te), a = D(r.state$, void 0, !0), { findCompleted: d, findString: c, matchesCount: _, matchesPosition: h } = a, u = p(() => {
559
558
  s.executeCommand(re.id);
560
559
  }, [s]), R = p((v) => r.changeFindString(v), [r]);
561
560
  return Le(r, n), /* @__PURE__ */ o.jsxs(o.Fragment, { children: [
562
561
  /* @__PURE__ */ o.jsx(
563
562
  Ae,
564
563
  {
565
- findCompleted: l,
564
+ findCompleted: d,
566
565
  className: "univer-find-input",
567
566
  matchesCount: _,
568
567
  matchesPosition: h,
569
568
  findReplaceService: r,
570
569
  localeService: i,
571
- findString: d,
570
+ findString: c,
572
571
  onChange: R
573
572
  }
574
573
  ),
575
574
  /* @__PURE__ */ o.jsx("div", { className: L.findReplaceExpandContainer, children: /* @__PURE__ */ o.jsx(N, { type: "text", size: "small", onClick: u, children: i.t("find-replace.dialog.advanced-finding") }) })
576
575
  ] });
577
576
  }), Qt = U(function(e, n) {
578
- const i = C(m), r = C(w), s = C(te), a = C(Se), l = D(i.currentMatch$, void 0, !0), d = D(i.replaceables$, void 0, !0), _ = D(i.state$, void 0, !0), {
577
+ const i = C(m), r = C(w), s = C(te), a = C(Se), d = D(i.currentMatch$, void 0, !0), c = D(i.replaceables$, void 0, !0), _ = D(i.state$, void 0, !0), {
579
578
  matchesCount: h,
580
579
  matchesPosition: u,
581
580
  findString: R,
@@ -587,7 +586,7 @@ const Zt = U(function(e, n) {
587
586
  findScope: ke,
588
587
  findBy: Ve,
589
588
  findCompleted: W
590
- } = _, He = v.length === 0, qe = h === 0 || !(l != null && l.replaceable), Je = d.length === 0, Ke = p(
589
+ } = _, He = v.length === 0, qe = h === 0 || !(d != null && d.replaceable), Je = c.length === 0, Ke = p(
591
590
  (f) => i.changeInputtingFindString(f),
592
591
  [i]
593
592
  ), ze = p(
@@ -671,26 +670,26 @@ const Zt = U(function(e, n) {
671
670
  function Xt() {
672
671
  const t = C(m), e = C(Ce), n = C(ee), i = D(t.state$, void 0, !0), r = H(null);
673
672
  A(() => {
674
- let d;
675
- return r.current && (d = e.registerContainerElement(r.current)), () => d == null ? void 0 : d.dispose();
673
+ let c;
674
+ return r.current && (c = e.registerContainerElement(r.current)), () => c == null ? void 0 : c.dispose();
676
675
  }, [e]);
677
676
  const s = H(null), a = p(
678
- (d) => n.setContextValue(De, d),
677
+ (c) => n.setContextValue(De, c),
679
678
  [n]
680
- ), l = p(
681
- (d) => n.setContextValue(Fe, d),
679
+ ), d = p(
680
+ (c) => n.setContextValue(Fe, c),
682
681
  [n]
683
682
  );
684
683
  return A(() => {
685
684
  var _;
686
- const d = yt(document, "focusin").subscribe((h) => {
685
+ const c = yt(document, "focusin").subscribe((h) => {
687
686
  var u;
688
- h.target && ((u = r.current) != null && u.contains(h.target)) ? a(!0) : a(!1), !s.current || !s.current.selectHasFocus() ? l(!0) : l(!1);
687
+ h.target && ((u = r.current) != null && u.contains(h.target)) ? a(!0) : a(!1), !s.current || !s.current.selectHasFocus() ? d(!0) : d(!1);
689
688
  });
690
- return (_ = s.current) == null || _.focus(), a(!0), l(!0), () => {
691
- d.unsubscribe(), a(!1);
689
+ return (_ = s.current) == null || _.focus(), a(!0), d(!0), () => {
690
+ c.unsubscribe(), a(!1);
692
691
  };
693
- }, [a, l]), /* @__PURE__ */ o.jsx("div", { className: L.findReplaceDialogContainer, ref: r, children: i.replaceRevealed ? /* @__PURE__ */ o.jsx(Qt, { ref: s }) : /* @__PURE__ */ o.jsx(Zt, { ref: s }) });
692
+ }, [a, d]), /* @__PURE__ */ o.jsx("div", { className: L.findReplaceDialogContainer, ref: r, children: i.replaceRevealed ? /* @__PURE__ */ o.jsx(Qt, { ref: s }) : /* @__PURE__ */ o.jsx(Zt, { ref: s }) });
694
693
  }
695
694
  function ei(t) {
696
695
  const e = t.getCurrentLocale();
@@ -802,10 +801,10 @@ var hi = Object.defineProperty, ui = Object.getOwnPropertyDescriptor, fi = (t, e
802
801
  }, S = (t, e) => (n, i) => e(n, i, t);
803
802
  const fe = "DESKTOP_FIND_REPLACE_DIALOG", we = 350, pi = 20, _i = -90;
804
803
  let j = class extends ht {
805
- constructor(e, n, i, r, s, a, l, d, _, h) {
804
+ constructor(e, n, i, r, s, a, d, c, _, h) {
806
805
  super();
807
- c(this, "_closingListenerDisposable");
808
- this._univerInstanceService = e, this._menuManagerService = n, this._shortcutService = i, this._commandService = r, this._findReplaceService = s, this._dialogService = a, this._layoutService = l, this._localeService = d, this._componentManager = _, this._injector = h, this._initCommands(), this._initUI(), this._initShortcuts();
806
+ l(this, "_closingListenerDisposable");
807
+ this._univerInstanceService = e, this._menuManagerService = n, this._shortcutService = i, this._commandService = r, this._findReplaceService = s, this._dialogService = a, this._layoutService = d, this._localeService = c, this._componentManager = _, this._injector = h, this._initCommands(), this._initUI(), this._initShortcuts();
809
808
  }
810
809
  dispose() {
811
810
  var e;
@@ -898,7 +897,7 @@ let _e = (V = class extends ut {
898
897
  onRendered() {
899
898
  this._injector.get(j);
900
899
  }
901
- }, c(V, "pluginName", Ci), V);
900
+ }, l(V, "pluginName", Ci), V);
902
901
  _e = Si([
903
902
  pe(1, F(Q)),
904
903
  pe(2, pt)
@@ -908,6 +907,8 @@ export {
908
907
  K as FindDirection,
909
908
  Di as FindModel,
910
909
  j as FindReplaceController,
910
+ J as FindReplaceModel,
911
+ Gt as FindReplaceState,
911
912
  Y as FindScope,
912
913
  Ne as GoToNextMatchOperation,
913
914
  $e as GoToPreviousMatchOperation,
@@ -916,5 +917,6 @@ export {
916
917
  re as OpenReplaceDialogOperation,
917
918
  Ee as ReplaceAllMatchesCommand,
918
919
  Te as ReplaceCurrentMatchCommand,
919
- _e as UniverFindReplacePlugin
920
+ _e as UniverFindReplacePlugin,
921
+ ne as createInitFindReplaceState
920
922
  };
package/lib/index.css CHANGED
@@ -1 +1 @@
1
- *,:before,:after{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(63 131 248 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }::backdrop{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(63 131 248 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }*{scrollbar-color:initial;scrollbar-width:initial}@keyframes enter{0%{opacity:var(--tw-enter-opacity, 1);transform:translate3d(var(--tw-enter-translate-x, 0),var(--tw-enter-translate-y, 0),0) scale3d(var(--tw-enter-scale, 1),var(--tw-enter-scale, 1),var(--tw-enter-scale, 1)) rotate(var(--tw-enter-rotate, 0))}}@keyframes exit{to{opacity:var(--tw-exit-opacity, 1);transform:translate3d(var(--tw-exit-translate-x, 0),var(--tw-exit-translate-y, 0),0) scale3d(var(--tw-exit-scale, 1),var(--tw-exit-scale, 1),var(--tw-exit-scale, 1)) rotate(var(--tw-exit-rotate, 0))}}.univer-find-replace-dialog-container{display:block}.univer-find-replace-expand-container{margin-top:16px;text-align:center}.univer-find-replace-expand-container .univer-button-text{color:rgb(var(--primary-color))}.univer-find-replace-buttons-group{display:flex;justify-content:space-between;margin-top:24px}.univer-find-replace-buttons-group-right>button:not(:first-child){margin-left:8px}
1
+ .univer-find-replace-dialog-container{display:block}.univer-find-replace-expand-container{margin-top:16px;text-align:center}.univer-find-replace-expand-container .univer-button-text{color:rgb(var(--primary-color))}.univer-find-replace-buttons-group{display:flex;justify-content:space-between;margin-top:24px}.univer-find-replace-buttons-group-right>button:not(:first-child){margin-left:8px}
@@ -16,7 +16,7 @@
16
16
  import './global.css';
17
17
  export { UniverFindReplacePlugin } from './plugin';
18
18
  export { FindReplaceController } from './controllers/find-replace.controller';
19
- export type { IFindComplete, IFindMatch, IFindMoveParams, IFindQuery, IFindReplaceProvider, IReplaceAllResult, } from './services/find-replace.service';
20
- export { FindBy, FindDirection, FindModel, FindScope, IFindReplaceService } from './services/find-replace.service';
19
+ export type { IFindComplete, IFindMatch, IFindMoveParams, IFindQuery, IFindReplaceProvider, IFindReplaceState, IReplaceAllResult, } from './services/find-replace.service';
20
+ export { createInitFindReplaceState, FindBy, FindDirection, FindModel, FindReplaceModel, FindReplaceState, FindScope, IFindReplaceService } from './services/find-replace.service';
21
21
  export { ReplaceAllMatchesCommand, ReplaceCurrentMatchCommand } from './commands/commands/replace.command';
22
22
  export { GoToNextMatchOperation, GoToPreviousMatchOperation, OpenFindDialogOperation, OpenReplaceDialogOperation } from './commands/operations/find-replace.operation';
@@ -107,6 +107,7 @@ export interface IFindReplaceService {
107
107
  moveToPreviousMatch(): void;
108
108
  replace(): Promise<boolean>;
109
109
  replaceAll(): Promise<IReplaceAllResult>;
110
+ getProviders(): Set<IFindReplaceProvider>;
110
111
  }
111
112
  export declare const IFindReplaceService: import('@wendellhu/redi').IdentifierDecorator<IFindReplaceService>;
112
113
  /**
@@ -145,9 +146,9 @@ export declare class FindReplaceModel extends Disposable {
145
146
  replaceAll(): Promise<IReplaceAllResult>;
146
147
  getCurrentMatch(): Nullable<IFindMatch>;
147
148
  private _markMatch;
148
- moveToNextMatch(): void;
149
+ moveToNextMatch(): IFindMatch<unknown> | null | undefined;
149
150
  private _moveToNextUnitMatch;
150
- moveToPreviousMatch(): void;
151
+ moveToPreviousMatch(): IFindMatch<unknown> | null | undefined;
151
152
  private _moveToInitialMatch;
152
153
  }
153
154
  export declare enum FindDirection {
@@ -185,6 +186,7 @@ export interface IFindReplaceState {
185
186
  findScope: FindScope;
186
187
  findBy: FindBy;
187
188
  }
189
+ export declare function createInitFindReplaceState(): IFindReplaceState;
188
190
  /**
189
191
  * This class stores find replace options state. These state are stored
190
192
  * here instead of the React component so we can change state from
@@ -242,6 +244,7 @@ export declare class FindReplaceService extends Disposable implements IFindRepla
242
244
  get replaceRevealed(): boolean;
243
245
  constructor(_injector: Injector, _contextService: IContextService);
244
246
  dispose(): void;
247
+ getProviders(): Set<IFindReplaceProvider>;
245
248
  getCurrentMatch(): Nullable<IFindMatch>;
246
249
  getFindString(): string;
247
250
  changeFindString(findString: string): void;
package/lib/umd/index.js CHANGED
@@ -1,4 +1,4 @@
1
- (function(l,a){typeof exports=="object"&&typeof module<"u"?a(exports,require("@univerjs/core"),require("@univerjs/ui"),require("rxjs"),require("@univerjs/design"),require("@univerjs/engine-render"),require("react")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/ui","rxjs","@univerjs/design","@univerjs/engine-render","react"],a):(l=typeof globalThis<"u"?globalThis:l||self,a(l.UniverFindReplace={},l.UniverCore,l.UniverUi,l.rxjs,l.UniverDesign,l.UniverEngineRender,l.React))})(this,function(l,a,d,S,_,de,p){"use strict";var gt=Object.defineProperty;var mt=(l,a,d)=>a in l?gt(l,a,{enumerable:!0,configurable:!0,writable:!0,value:d}):l[a]=d;var u=(l,a,d)=>mt(l,typeof a!="symbol"?a+"":a,d);var $;const ue="find-replace.config",z={};var C=function(){return C=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},C.apply(this,arguments)},he=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},Y=p.forwardRef(function(n,e){var i=n.icon,t=n.id,s=n.className,r=n.extend,o=he(n,["icon","id","className","extend"]),h="univerjs-icon univerjs-icon-".concat(t," ").concat(s||"").trim(),f=p.useRef("_".concat(_e()));return Z(i,"".concat(t),{defIds:i.defIds,idSuffix:f.current},C({ref:e,className:h},o),r)});function Z(n,e,i,t,s){return p.createElement(n.tag,C(C({key:e},fe(n,i,s)),t),(pe(n,i).children||[]).map(function(r,o){return Z(r,"".concat(e,"-").concat(n.tag,"-").concat(o),i,void 0,s)}))}function fe(n,e,i){var t=C({},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(r){var o=r[0],h=r[1];typeof h=="string"&&(t[o]=h.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)?C(C({},n),{children:n.children.map(function(s){return typeof s.attrs.id=="string"&&t&&t.indexOf(s.attrs.id)>-1?C(C({},s),{attrs:C(C({},s.attrs),{id:s.attrs.id+e.idSuffix})}):s})}):n}function _e(){return Math.random().toString(36).substring(2,8)}Y.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"}}]}]},Q=p.forwardRef(function(n,e){return p.createElement(Y,Object.assign({},n,{id:"search-single-16",ref:e,icon:ge}))});Q.displayName="SearchSingle16";const X="FIND_REPLACE_INPUT_FOCUS",q="FIND_REPLACE_DIALOG_FOCUS",ee="FIND_REPLACE_REPLACE_REVEALED";var me=Object.defineProperty,ve=Object.getOwnPropertyDescriptor,te=(n,e,i,t)=>{for(var s=t>1?void 0:t?ve(e,i):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(t?o(e,i,s):o(s))||s);return t&&s&&me(e,i,s),s},j=(n,e)=>(i,t)=>e(i,t,n);class Se extends a.Disposable{}const R=a.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 A=class extends a.Disposable{constructor(e,i,t){super();u(this,"currentMatch$",new S.BehaviorSubject(null));u(this,"replaceables$",new S.BehaviorSubject([]));u(this,"_findModels",[]);u(this,"_matchingModel",null);u(this,"_matches",[]);u(this,"_currentSearchingDisposables",null);this._state=e,this._providers=i,this._univerInstanceService=t,this.disposeWithMe(this._state.stateUpdates$.pipe(S.throttleTime(200,void 0,{leading:!0,trailing:!0})).subscribe(async s=>{const r=this._state.state;Ce(s)&&(r.findString!==""&&!r.replaceRevealed?(await this._startSearching(),this._state.changeState({findCompleted:!0})):s.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({...U(),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(s=>s.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(s=>s.getMatches()).flat();return this.replaceables$.next(t.filter(s=>s.replaceable)),t.length?(this._moveToInitialMatch(i),this._state.changeState({matchesCount:t.length}),{results:t}):(this._state.changeState({matchesCount:0,matchesPosition:0}),{results:[]})}_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 a.DisposableCollection,t=S.combineLatest(e.map(s=>s.matchesUpdate$)).pipe(S.debounceTime(220)).subscribe(([...s])=>{const r=this._matches=s.flat();r.length?(this._moveToInitialMatch(this._findModels,!0),this._state.changeState({matchesCount:r.length}),this.replaceables$.next(r.filter(o=>o.replaceable))):(this._state.changeState({matchesCount:0,matchesPosition:0}),this.replaceables$.next([]))});e.forEach(s=>i.add(a.toDisposable(s.activelyChangingMatch$.subscribe(r=>{const o=this._matches.findIndex(h=>h===r);this._state.changeState({matchesPosition:o+1})})))),i.add(a.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}_markMatch(e){const i=this._matches.findIndex(t=>t===e);this.currentMatch$.next(e),this._state.changeState({matchesPosition:i+1})}moveToNextMatch(){if(!this._matchingModel)return;const e=this._findModels.length===1,i=this._matchingModel.moveToNextMatch({loop:e});if(i)this._markMatch(i);else{const t=this._findModels.findIndex(s=>s===this._matchingModel);this._moveToNextUnitMatch(t)}}_moveToNextUnitMatch(e){const i=this._findModels.length;for(let t=(e+1)%i;t!==e;){const s=this._findModels[t],r=s.moveToNextMatch({ignoreSelection:!0});if(r){this._matchingModel=s,this._markMatch(r);return}t=(t+1)%i}if(this._matchingModel){const t=this._matchingModel.moveToNextMatch({ignoreSelection:!0});t&&this._markMatch(t)}}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.length,s=this._findModels.findIndex(o=>o===this._matchingModel);for(let o=(s-1+t)%t;o!==s;){const h=this._findModels[o],f=h.moveToPreviousMatch({ignoreSelection:!0});if(f){this._matchingModel=h,this._markMatch(f);return}o=(o-1)%t}const r=this._matchingModel.moveToPreviousMatch({ignoreSelection:!0});r&&this._markMatch(r)}}_moveToInitialMatch(e,i=!1){var r;const t=(r=this._univerInstanceService.getFocusedUnit())==null?void 0:r.getUnitId();if(!t)return-1;const s=e.findIndex(o=>o.unitId===t);if(s!==-1){this._matchingModel=e[s];const o=this._matchingModel.moveToNextMatch({stayIfOnMatch:!0,noFocus:i});if(o)return this._markMatch(o),s}return this._moveToNextUnitMatch(s),0}};A=te([j(2,a.IUniverInstanceService)],A);var T=(n=>(n.ROW="row",n.COLUMN="column",n))(T||{}),O=(n=>(n.VALUE="value",n.FORMULA="formula",n))(O||{}),P=(n=>(n.SUBUNIT="subunit",n.UNIT="unit",n))(P||{});function U(){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(){u(this,"_stateUpdates$",new S.Subject);u(this,"stateUpdates$",this._stateUpdates$.asObservable());u(this,"_state$",new S.BehaviorSubject(U()));u(this,"state$",this._state$.asObservable());u(this,"_findString","");u(this,"_inputtingFindString","");u(this,"_replaceString","");u(this,"_revealed",!1);u(this,"_replaceRevealed",!1);u(this,"_matchesPosition",0);u(this,"_matchesCount",0);u(this,"_caseSensitive",!0);u(this,"_matchesTheWholeCell",!1);u(this,"_findDirection","row");u(this,"_findScope","subunit");u(this,"_findBy","value");u(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 a.Disposable{constructor(e,i){super();u(this,"_providers",new Set);u(this,"_state",new Re);u(this,"_model");u(this,"_currentMatch$",new S.BehaviorSubject(null));u(this,"currentMatch$",this._currentMatch$.asObservable());u(this,"_replaceables$",new S.BehaviorSubject([]));u(this,"replaceables$",this._replaceables$.asObservable());u(this,"_focusSignal$",new S.Subject);u(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(A,this._state,this._providers),this._model.currentMatch$.subscribe(t=>this._currentMatch$.next(t)),this._model.replaceables$.subscribe(t=>this._replaceables$.next(t));const i=U();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),a.toDisposable(()=>this._providers.delete(e))}_toggleRevealReplace(e){this._contextService.setContextValue(ee,e)}_toggleDisplayRawFormula(e){this._contextService.setContextValue(de.RENDER_RAW_FORMULA_KEY,e)}};w=te([j(0,a.Inject(a.Injector)),j(1,a.IContextService)],w);const B={id:"ui.command.replace-current-match",type:a.CommandType.COMMAND,handler:n=>n.get(R).replace()},be="CONFIRM_REPLACE_ALL",k={id:"ui.command.replace-all-matches",type:a.CommandType.COMMAND,handler:async n=>{const e=n.get(d.IConfirmService),i=n.get(a.LocaleService),t=n.get(d.IMessageService);if(!await e.confirm({id:be,title:{title:i.t("find-replace.replace.confirm.title")},cancelText:i.t("button.cancel"),confirmText:i.t("button.confirm")}))return!1;const r=await n.get(R).replaceAll(),{success:o,failure:h}=r;return h>0?(o===0?t.show({type:_.MessageType.Error,content:i.t("find-replace.replace.all-failure")}):t.show({type:_.MessageType.Warning,content:i.t("find-replace.replace.partial-success",`${o}`,`${h}`)}),!1):(t.show({type:_.MessageType.Success,content:i.t("find-replace.replace.all-success",`${o}`)}),!0)}},F={id:"ui.operation.open-find-dialog",type:a.CommandType.OPERATION,handler:n=>{const e=n.get(R);return e.revealed?e.focusFindInput():e.start(),!0}},E={id:"ui.operation.open-replace-dialog",type:a.CommandType.OPERATION,handler:n=>{const e=n.get(R);return e.revealed?e.replaceRevealed?e.focusFindInput():e.revealReplace():e.start(!0),!0}},W={type:a.CommandType.OPERATION,id:"ui.operation.go-to-next-match",handler:n=>(n.get(R).moveToNextMatch(),!0)},G={type:a.CommandType.OPERATION,id:"ui.operation.go-to-previous-match",handler:n=>(n.get(R).moveToPreviousMatch(),!0)};var V={exports:{}},D={};/**
1
+ (function(l,r){typeof exports=="object"&&typeof module<"u"?r(exports,require("@univerjs/core"),require("@univerjs/ui"),require("rxjs"),require("@univerjs/design"),require("@univerjs/engine-render"),require("react")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/ui","rxjs","@univerjs/design","@univerjs/engine-render","react"],r):(l=typeof globalThis<"u"?globalThis:l||self,r(l.UniverFindReplace={},l.UniverCore,l.UniverUi,l.rxjs,l.UniverDesign,l.UniverEngineRender,l.React))})(this,function(l,r,h,C,_,de,p){"use strict";var _t=Object.defineProperty;var gt=(l,r,h)=>r in l?_t(l,r,{enumerable:!0,configurable:!0,writable:!0,value:h}):l[r]=h;var f=(l,r,h)=>gt(l,typeof r!="symbol"?r+"":r,h);var K;const ue="find-replace.config",J={};var R=function(){return R=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},R.apply(this,arguments)},he=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},z=p.forwardRef(function(n,e){var i=n.icon,t=n.id,s=n.className,a=n.extend,o=he(n,["icon","id","className","extend"]),c="univerjs-icon univerjs-icon-".concat(t," ").concat(s||"").trim(),u=p.useRef("_".concat(_e()));return Y(i,"".concat(t),{defIds:i.defIds,idSuffix:u.current},R({ref:e,className:c},o),a)});function Y(n,e,i,t,s){return p.createElement(n.tag,R(R({key:e},fe(n,i,s)),t),(pe(n,i).children||[]).map(function(a,o){return Y(a,"".concat(e,"-").concat(n.tag,"-").concat(o),i,void 0,s)}))}function fe(n,e,i){var t=R({},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 o=a[0],c=a[1];typeof c=="string"&&(t[o]=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)?R(R({},n),{children:n.children.map(function(s){return typeof s.attrs.id=="string"&&t&&t.indexOf(s.attrs.id)>-1?R(R({},s),{attrs:R(R({},s.attrs),{id:s.attrs.id+e.idSuffix})}):s})}):n}function _e(){return Math.random().toString(36).substring(2,8)}z.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=p.forwardRef(function(n,e){return p.createElement(z,Object.assign({},n,{id:"search-single-16",ref:e,icon:ge}))});Z.displayName="SearchSingle16";const Q="FIND_REPLACE_INPUT_FOCUS",X="FIND_REPLACE_DIALOG_FOCUS",q="FIND_REPLACE_REPLACE_REVEALED";var me=Object.defineProperty,ve=Object.getOwnPropertyDescriptor,ee=(n,e,i,t)=>{for(var s=t>1?void 0:t?ve(e,i):e,a=n.length-1,o;a>=0;a--)(o=n[a])&&(s=(t?o(e,i,s):o(s))||s);return t&&s&&me(e,i,s),s},A=(n,e)=>(i,t)=>e(i,t,n);class Se extends r.Disposable{}const b=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"}l.FindReplaceModel=class extends r.Disposable{constructor(i,t,s){super();f(this,"currentMatch$",new C.BehaviorSubject(null));f(this,"replaceables$",new C.BehaviorSubject([]));f(this,"_findModels",[]);f(this,"_matchingModel",null);f(this,"_matches",[]);f(this,"_currentSearchingDisposables",null);this._state=i,this._providers=t,this._univerInstanceService=s,this.disposeWithMe(this._state.stateUpdates$.pipe(C.throttleTime(200,void 0,{leading:!0,trailing:!0})).subscribe(async a=>{const o=this._state.state;Ce(a)&&(o.findString!==""&&!o.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({...E(),revealed:!1})}async start(){if(!this._state.findString)return{results:[]};const i=await this._startSearching();return this._state.changeState({findCompleted:!0}),i}async _startSearching(){if(!this._state.findString)return{results:[]};const i=Array.from(this._providers),t=this._findModels=(await Promise.all(i.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(t);const s=this._matches=t.map(a=>a.getMatches()).flat();return this.replaceables$.next(s.filter(a=>a.replaceable)),s.length?(this._moveToInitialMatch(t),this._state.changeState({matchesCount:s.length}),{results:s}):(this._state.changeState({matchesCount:0,matchesPosition:0}),{results:[]})}_stopSearching(){var i;this._providers.forEach(t=>t.terminate()),this._findModels=[],this._matches=[],this._matchingModel=null,(i=this._currentSearchingDisposables)==null||i.dispose(),this._currentSearchingDisposables=null,this.currentMatch$.next(null),this.replaceables$.next([]),this._state.changeState({findCompleted:!1,matchesCount:0,matchesPosition:0})}_subscribeToModelsChanges(i){const t=this._currentSearchingDisposables=new r.DisposableCollection,s=C.combineLatest(i.map(a=>a.matchesUpdate$)).pipe(C.debounceTime(220)).subscribe(([...a])=>{const o=this._matches=a.flat();o.length?(this._moveToInitialMatch(this._findModels,!0),this._state.changeState({matchesCount:o.length}),this.replaceables$.next(o.filter(c=>c.replaceable))):(this._state.changeState({matchesCount:0,matchesPosition:0}),this.replaceables$.next([]))});i.forEach(a=>t.add(r.toDisposable(a.activelyChangingMatch$.subscribe(o=>{const c=this._matches.findIndex(u=>u===o);this._state.changeState({matchesPosition:c+1})})))),t.add(r.toDisposable(s))}async replace(){return this._matchingModel?this._matchingModel.replace(this._state.replaceString):!1}async replaceAll(){const i=await Promise.all(this._findModels.map(t=>t.replaceAll(this._state.replaceString))).then(t=>t.reduce((s,a)=>(s.success+=a.success,s.failure+=a.failure,s),{success:0,failure:0}));return i.failure===0&&this._stopSearching(),i}getCurrentMatch(){return this._state.matchesPosition>0?this._matches[this._state.matchesPosition-1]:null}_markMatch(i){const t=this._matches.findIndex(s=>s===i);this.currentMatch$.next(i),this._state.changeState({matchesPosition:t+1})}moveToNextMatch(){if(!this._matchingModel)return;const i=this._findModels.length===1,t=this._matchingModel.moveToNextMatch({loop:i});if(t)return this._markMatch(t),t;{const s=this._findModels.findIndex(a=>a===this._matchingModel);return this._moveToNextUnitMatch(s)}}_moveToNextUnitMatch(i){const t=this._findModels.length;for(let s=(i+1)%t;s!==i;){const a=this._findModels[s],o=a.moveToNextMatch({ignoreSelection:!0});if(o)return this._matchingModel=a,this._markMatch(o),o;s=(s+1)%t}if(this._matchingModel){const s=this._matchingModel.moveToNextMatch({ignoreSelection:!0});return s&&this._markMatch(s),s}}moveToPreviousMatch(){if(!this._matchingModel)return;const i=this._findModels.length===1,t=this._matchingModel.moveToPreviousMatch({loop:i});if(t){const s=this._matches.findIndex(a=>a===t);return this.currentMatch$.next(t),this._state.changeState({matchesPosition:s+1}),t}else{const s=this._findModels.length,a=this._findModels.findIndex(c=>c===this._matchingModel);for(let c=(a-1+s)%s;c!==a;){const u=this._findModels[c],v=u.moveToPreviousMatch({ignoreSelection:!0});if(v)return this._matchingModel=u,this._markMatch(v),v;c=(c-1)%s}const o=this._matchingModel.moveToPreviousMatch({ignoreSelection:!0});return o&&this._markMatch(o),o}}_moveToInitialMatch(i,t=!1){var o;const s=(o=this._univerInstanceService.getFocusedUnit())==null?void 0:o.getUnitId();if(!s)return-1;const a=i.findIndex(c=>c.unitId===s);if(a!==-1){this._matchingModel=i[a];const c=this._matchingModel.moveToNextMatch({stayIfOnMatch:!0,noFocus:t});if(c)return this._markMatch(c),a}return this._moveToNextUnitMatch(a),0}},l.FindReplaceModel=ee([A(2,r.IUniverInstanceService)],l.FindReplaceModel);var x=(n=>(n.ROW="row",n.COLUMN="column",n))(x||{}),O=(n=>(n.VALUE="value",n.FORMULA="formula",n))(O||{}),P=(n=>(n.SUBUNIT="subunit",n.UNIT="unit",n))(P||{});function E(){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 te{constructor(){f(this,"_stateUpdates$",new C.Subject);f(this,"stateUpdates$",this._stateUpdates$.asObservable());f(this,"_state$",new C.BehaviorSubject(E()));f(this,"state$",this._state$.asObservable());f(this,"_findString","");f(this,"_inputtingFindString","");f(this,"_replaceString","");f(this,"_revealed",!1);f(this,"_replaceRevealed",!1);f(this,"_matchesPosition",0);f(this,"_matchesCount",0);f(this,"_caseSensitive",!0);f(this,"_matchesTheWholeCell",!1);f(this,"_findDirection","row");f(this,"_findScope","subunit");f(this,"_findBy","value");f(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 U=class extends r.Disposable{constructor(e,i){super();f(this,"_providers",new Set);f(this,"_state",new te);f(this,"_model");f(this,"_currentMatch$",new C.BehaviorSubject(null));f(this,"currentMatch$",this._currentMatch$.asObservable());f(this,"_replaceables$",new C.BehaviorSubject([]));f(this,"replaceables$",this._replaceables$.asObservable());f(this,"_focusSignal$",new C.Subject);f(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()}getProviders(){return this._providers}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(l.FindReplaceModel,this._state,this._providers),this._model.currentMatch$.subscribe(t=>this._currentMatch$.next(t)),this._model.replaceables$.subscribe(t=>this._replaceables$.next(t));const i=E();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),r.toDisposable(()=>this._providers.delete(e))}_toggleRevealReplace(e){this._contextService.setContextValue(q,e)}_toggleDisplayRawFormula(e){this._contextService.setContextValue(de.RENDER_RAW_FORMULA_KEY,e)}};U=ee([A(0,r.Inject(r.Injector)),A(1,r.IContextService)],U);const w={id:"ui.command.replace-current-match",type:r.CommandType.COMMAND,handler:n=>n.get(b).replace()},Re="CONFIRM_REPLACE_ALL",B={id:"ui.command.replace-all-matches",type:r.CommandType.COMMAND,handler:async n=>{const e=n.get(h.IConfirmService),i=n.get(r.LocaleService),t=n.get(h.IMessageService);if(!await e.confirm({id:Re,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(b).replaceAll(),{success:o,failure:c}=a;return c>0?(o===0?t.show({type:_.MessageType.Error,content:i.t("find-replace.replace.all-failure")}):t.show({type:_.MessageType.Warning,content:i.t("find-replace.replace.partial-success",`${o}`,`${c}`)}),!1):(t.show({type:_.MessageType.Success,content:i.t("find-replace.replace.all-success",`${o}`)}),!0)}},F={id:"ui.operation.open-find-dialog",type:r.CommandType.OPERATION,handler:n=>{const e=n.get(b);return e.revealed?e.focusFindInput():e.start(),!0}},N={id:"ui.operation.open-replace-dialog",type:r.CommandType.OPERATION,handler:n=>{const e=n.get(b);return e.revealed?e.replaceRevealed?e.focusFindInput():e.revealReplace():e.start(!0),!0}},k={type:r.CommandType.OPERATION,id:"ui.operation.go-to-next-match",handler:n=>(n.get(b).moveToNextMatch(),!0)},W={type:r.CommandType.OPERATION,id:"ui.operation.go-to-previous-match",handler:n=>(n.get(b).moveToPreviousMatch(),!0)};var G={exports:{}},D={};/**
2
2
  * @license React
3
3
  * react-jsx-runtime.production.min.js
4
4
  *
@@ -6,4 +6,4 @@
6
6
  *
7
7
  * This source code is licensed under the MIT license found in the
8
8
  * LICENSE file in the root directory of this source tree.
9
- */var ne;function Me(){if(ne)return D;ne=1;var n=p,e=Symbol.for("react.element"),i=Symbol.for("react.fragment"),t=Object.prototype.hasOwnProperty,s=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,r={key:!0,ref:!0,__self:!0,__source:!0};function o(h,f,b){var g,m={},I=null,y=null;b!==void 0&&(I=""+b),f.key!==void 0&&(I=""+f.key),f.ref!==void 0&&(y=f.ref);for(g in f)t.call(f,g)&&!r.hasOwnProperty(g)&&(m[g]=f[g]);if(h&&h.defaultProps)for(g in f=h.defaultProps,f)m[g]===void 0&&(m[g]=f[g]);return{$$typeof:e,type:h,key:I,ref:y,props:m,_owner:s.current}}return D.Fragment=i,D.jsx=o,D.jsxs=o,D}var ie;function ye(){return ie||(ie=1,V.exports=Me()),V.exports}var c=ye();const N={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 se(n){const{findCompleted:e,localeService:i,matchesCount:t,matchesPosition:s,findString:r,findReplaceService:o,onChange:h,...f}=n,g=e&&t===0?i.t("find-replace.dialog.no-result"):t===0?" ":void 0;return c.jsx(_.InputWithSlot,{autoFocus:!0,placeholder:i.t("find-replace.dialog.find-placeholder"),slot:c.jsx(_.Pager,{loop:!0,text:g,value:s,total:t,onChange:m=>{s===t&&m===1?o.moveToNextMatch():s===1&&m===t||m<s?o.moveToPreviousMatch():o.moveToNextMatch()}}),value:r,onChange:m=>h==null?void 0:h(m),...f})}function ae(n,e){const i=p.useCallback(()=>{var s;(s=document.querySelector(".univer-find-input input"))==null||s.focus()},[]),t=p.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 p.useImperativeHandle(e,()=>({focus:i,selectHasFocus:t})),p.useEffect(()=>{const s=n.focusSignal$.subscribe(()=>i());return()=>s.unsubscribe()},[n,i]),{focus:i,selectHasFocus:t}}const Ie=p.forwardRef(function(e,i){const t=a.useDependency(a.LocaleService),s=a.useDependency(R),r=a.useDependency(a.ICommandService),o=d.useObservable(s.state$,void 0,!0),{findCompleted:h,findString:f,matchesCount:b,matchesPosition:g}=o,m=p.useCallback(()=>{r.executeCommand(E.id)},[r]),I=p.useCallback(y=>s.changeFindString(y),[s]);return ae(s,i),c.jsxs(c.Fragment,{children:[c.jsx(se,{findCompleted:h,className:"univer-find-input",matchesCount:b,matchesPosition:g,findReplaceService:s,localeService:t,findString:f,onChange:I}),c.jsx("div",{className:N.findReplaceExpandContainer,children:c.jsx(_.Button,{type:"text",size:"small",onClick:m,children:t.t("find-replace.dialog.advanced-finding")})})]})}),Fe=p.forwardRef(function(e,i){const t=a.useDependency(R),s=a.useDependency(a.LocaleService),r=a.useDependency(a.ICommandService),o=a.useDependency(d.IMessageService),h=d.useObservable(t.currentMatch$,void 0,!0),f=d.useObservable(t.replaceables$,void 0,!0),b=d.useObservable(t.state$,void 0,!0),{matchesCount:g,matchesPosition:m,findString:I,inputtingFindString:y,replaceString:Ye,caseSensitive:Ze,matchesTheWholeCell:Qe,findDirection:Xe,findScope:qe,findBy:et,findCompleted:J}=b,tt=y.length===0,nt=g===0||!(h!=null&&h.replaceable),it=f.length===0,st=p.useCallback(v=>t.changeInputtingFindString(v),[t]),at=p.useCallback(v=>t.changeReplaceString(v),[t]),{focus:rt}=ae(t,i),ot=p.useCallback(()=>{I===y?t.moveToNextMatch():(t.changeFindString(y),t.find())},[I,y,t]),ct=p.useCallback(()=>r.executeCommand(B.id),[r]),lt=p.useCallback(async()=>{await r.executeCommand(k.id),rt()},[r]),dt=p.useCallback(v=>{t.changeFindDirection(v)},[t]),ut=p.useCallback(v=>{t.changeFindScope(v)},[t]),ht=p.useCallback(v=>{t.changeFindBy(v)},[t]),ft=xe(s),pt=Te(s),_t=Oe(s);return p.useEffect(()=>{J&&g===0&&o.show({content:s.t("find-replace.dialog.no-match"),type:_.MessageType.Warning,duration:5e3})},[J,g,o,s]),c.jsxs(c.Fragment,{children:[c.jsx(_.FormLayout,{label:s.t("find-replace.dialog.find"),children:c.jsx(se,{findCompleted:J,className:"univer-find-input",matchesCount:g,matchesPosition:m,findReplaceService:t,localeService:s,findString:y,onChange:st})}),c.jsx(_.FormLayout,{label:s.t("find-replace.dialog.replace"),children:c.jsx(_.Input,{placeholder:s.t("find-replace.dialog.replace-placeholder"),value:Ye,onChange:v=>at(v)})}),c.jsx(_.FormLayout,{label:s.t("find-replace.dialog.find-direction.title"),children:c.jsx(_.Select,{value:Xe,options:pt,onChange:dt})}),c.jsx(_.FormDualColumnLayout,{children:c.jsxs(c.Fragment,{children:[c.jsx(_.FormLayout,{label:s.t("find-replace.dialog.find-scope.title"),children:c.jsx(_.Select,{value:qe,options:ft,onChange:ut})}),c.jsx(_.FormLayout,{label:s.t("find-replace.dialog.find-by.title"),children:c.jsx(_.Select,{value:et,options:_t,onChange:ht})})]})}),c.jsx(_.FormDualColumnLayout,{children:c.jsxs(c.Fragment,{children:[c.jsx(_.FormLayout,{children:c.jsx(_.Checkbox,{checked:Ze,onChange:v=>{t.changeCaseSensitive(v)},children:s.t("find-replace.dialog.case-sensitive")})}),c.jsx(_.FormLayout,{children:c.jsx(_.Checkbox,{checked:Qe,onChange:v=>{t.changeMatchesTheWholeCell(v)},children:s.t("find-replace.dialog.match-the-whole-cell")})})]})}),c.jsxs("div",{className:N.findReplaceButtonsGroup,children:[c.jsx(_.Button,{type:"primary",onClick:ot,disabled:tt,children:s.t("find-replace.dialog.find")}),c.jsxs("span",{className:N.findReplaceButtonsGroupRight,children:[c.jsx(_.Button,{disabled:nt,onClick:ct,children:s.t("find-replace.dialog.replace")}),c.jsx(_.Button,{disabled:it,onClick:lt,children:s.t("find-replace.dialog.replace-all")})]})]})]})});function De(){const n=a.useDependency(R),e=a.useDependency(d.ILayoutService),i=a.useDependency(a.IContextService),t=d.useObservable(n.state$,void 0,!0),s=p.useRef(null);p.useEffect(()=>{let f;return s.current&&(f=e.registerContainerElement(s.current)),()=>f==null?void 0:f.dispose()},[e]);const r=p.useRef(null),o=p.useCallback(f=>i.setContextValue(q,f),[i]),h=p.useCallback(f=>i.setContextValue(X,f),[i]);return p.useEffect(()=>{var b;const f=S.fromEvent(document,"focusin").subscribe(g=>{var m;g.target&&((m=s.current)!=null&&m.contains(g.target))?o(!0):o(!1),!r.current||!r.current.selectHasFocus()?h(!0):h(!1)});return(b=r.current)==null||b.focus(),o(!0),h(!0),()=>{f.unsubscribe(),o(!1)}},[o,h]),c.jsx("div",{className:N.findReplaceDialogContainer,ref:s,children:t.replaceRevealed?c.jsx(Fe,{ref:r}):c.jsx(Ie,{ref:r})})}function xe(n){const e=n.getCurrentLocale();return p.useMemo(()=>[{label:n.t("find-replace.dialog.find-scope.current-sheet"),value:P.SUBUNIT},{label:n.t("find-replace.dialog.find-scope.workbook"),value:P.UNIT}],[e])}function Te(n){const e=n.getCurrentLocale();return p.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 Oe(n){const e=n.getCurrentLocale();return p.useMemo(()=>[{label:n.t("find-replace.dialog.find-by.value"),value:O.VALUE},{label:n.t("find-replace.dialog.find-by.formula"),value:O.FORMULA}],[e])}function x(n){return n.getContextValue(q)}function Pe(n){return n.getContextValue(ee)}function re(n){return n.getContextValue(X)}const L="7_find-replace-shortcuts";function H(n){return n.getContextValue(a.FOCUSING_SHEET)}function K(n){return!n.getContextValue(a.EDITOR_ACTIVATED)}const Ee={id:F.id,description:"find-replace.shortcut.open-find-dialog",binding:d.KeyCode.F|d.MetaKeys.CTRL_COMMAND,group:L,preconditions(n){return!x(n)&&H(n)&&K(n)}},Ne={id:F.id,description:"find-replace.shortcut.open-find-dialog",binding:d.KeyCode.F|d.MetaKeys.CTRL_COMMAND,mac:d.KeyCode.F|d.MetaKeys.MAC_CTRL,preconditions(n){return!x(n)&&H(n)&&K(n)}},Le={id:E.id,description:"find-replace.shortcut.open-replace-dialog",binding:d.KeyCode.H|d.MetaKeys.CTRL_COMMAND,mac:d.KeyCode.H|d.MetaKeys.MAC_CTRL,group:L,preconditions(n){return H(n)&&K(n)&&(!x(n)||!Pe(n))}},je={id:W.id,description:"find-replace.shortcut.go-to-next-match",binding:d.KeyCode.ENTER,group:L,priority:1e3,preconditions(n){return re(n)&&x(n)}},Ae={id:G.id,description:"find-replace.shortcut.go-to-previous-match",binding:d.KeyCode.ENTER|d.MetaKeys.SHIFT,group:L,priority:1e3,preconditions(n){return re(n)&&x(n)}};function Ue(n){const e=n.get(a.IContextService);return{id:F.id,icon:"SearchIcon",tooltip:"find-replace.toolbar",type:d.MenuItemType.BUTTON,hidden$:d.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET),disabled$:S.combineLatest([e.subscribeContextValue$(a.EDITOR_ACTIVATED),e.subscribeContextValue$(a.FOCUSING_SHEET)]).pipe(S.map(([i,t])=>i||!t))}}const we={[d.RibbonStartGroup.OTHERS]:{[F.id]:{order:2,menuItemFactory:Ue}}};var Be=Object.defineProperty,ke=Object.getOwnPropertyDescriptor,We=(n,e,i,t)=>{for(var s=t>1?void 0:t?ke(e,i):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(t?o(e,i,s):o(s))||s);return t&&s&&Be(e,i,s),s},M=(n,e)=>(i,t)=>e(i,t,n);const oe="DESKTOP_FIND_REPLACE_DIALOG",ce=350,Ge=20,Ve=-90;l.FindReplaceController=class extends a.RxDisposable{constructor(i,t,s,r,o,h,f,b,g,m){super();u(this,"_closingListenerDisposable");this._univerInstanceService=i,this._menuManagerService=t,this._shortcutService=s,this._commandService=r,this._findReplaceService=o,this._dialogService=h,this._layoutService=f,this._localeService=b,this._componentManager=g,this._injector=m,this._initCommands(),this._initUI(),this._initShortcuts()}dispose(){var i;super.dispose(),(i=this._closingListenerDisposable)==null||i.dispose(),this._closingListenerDisposable=null}_initCommands(){[F,E,W,G,k,B].forEach(i=>{this.disposeWithMe(this._commandService.registerCommand(i))})}_initShortcuts(){[Le,Ee,Ne,Ae,je].forEach(i=>this.disposeWithMe(this._shortcutService.registerShortcut(i)))}_initUI(){this.disposeWithMe(this._componentManager.register("FindReplaceDialog",De)),this.disposeWithMe(this._componentManager.register("SearchIcon",Q)),this._menuManagerService.mergeMenu(we),this._findReplaceService.stateUpdates$.pipe(S.takeUntil(this.dispose$)).subscribe(i=>{i.revealed===!0&&this._openPanel()})}_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:He(),preservePositionOnDestroy:!0,onClose:()=>this.closePanel()}),this._closingListenerDisposable=a.toDisposable(this._univerInstanceService.focused$.pipe(S.takeUntil(this.dispose$)).subscribe(i=>{(!i||!this._univerInstanceService.getUniverSheetInstance(i))&&this.closePanel()}))}closePanel(){this._closingListenerDisposable&&(this._closingListenerDisposable.dispose(),this._closingListenerDisposable=null,this._dialogService.close(oe),this._findReplaceService.terminate(),queueMicrotask(()=>this._layoutService.focus()))}},l.FindReplaceController=We([M(0,a.IUniverInstanceService),M(1,d.IMenuManagerService),M(2,d.IShortcutService),M(3,a.ICommandService),M(4,R),M(5,d.IDialogService),M(6,d.ILayoutService),M(7,a.Inject(a.LocaleService)),M(8,a.Inject(d.ComponentManager)),M(9,a.Inject(a.Injector))],l.FindReplaceController);function He(){const{innerWidth:n}=window;return{x:(n-ce)/2-Ge,y:Ve}}var Ke=Object.defineProperty,$e=Object.getOwnPropertyDescriptor,Je=(n,e,i,t)=>{for(var s=t>1?void 0:t?$e(e,i):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(t?o(e,i,s):o(s))||s);return t&&s&&Ke(e,i,s),s},le=(n,e)=>(i,t)=>e(i,t,n);const ze="UNIVER_FIND_REPLACE_PLUGIN";l.UniverFindReplacePlugin=($=class extends a.Plugin{constructor(e=z,i,t){super(),this._config=e,this._injector=i,this._configService=t;const{...s}=a.merge({},z,this._config);this._configService.setConfig(ue,s)}onStarting(){[[l.FindReplaceController],[R,{useClass:w}]].forEach(e=>this._injector.add(e))}onRendered(){this._injector.get(l.FindReplaceController)}},u($,"pluginName",ze),$),l.UniverFindReplacePlugin=Je([le(1,a.Inject(a.Injector)),le(2,a.IConfigService)],l.UniverFindReplacePlugin),l.FindBy=O,l.FindDirection=T,l.FindModel=Se,l.FindScope=P,l.GoToNextMatchOperation=W,l.GoToPreviousMatchOperation=G,l.IFindReplaceService=R,l.OpenFindDialogOperation=F,l.OpenReplaceDialogOperation=E,l.ReplaceAllMatchesCommand=k,l.ReplaceCurrentMatchCommand=B,Object.defineProperty(l,Symbol.toStringTag,{value:"Module"})});
9
+ */var ne;function be(){if(ne)return D;ne=1;var n=p,e=Symbol.for("react.element"),i=Symbol.for("react.fragment"),t=Object.prototype.hasOwnProperty,s=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,a={key:!0,ref:!0,__self:!0,__source:!0};function o(c,u,v){var g,m={},I=null,y=null;v!==void 0&&(I=""+v),u.key!==void 0&&(I=""+u.key),u.ref!==void 0&&(y=u.ref);for(g in u)t.call(u,g)&&!a.hasOwnProperty(g)&&(m[g]=u[g]);if(c&&c.defaultProps)for(g in u=c.defaultProps,u)m[g]===void 0&&(m[g]=u[g]);return{$$typeof:e,type:c,key:I,ref:y,props:m,_owner:s.current}}return D.Fragment=i,D.jsx=o,D.jsxs=o,D}var ie;function Me(){return ie||(ie=1,G.exports=be()),G.exports}var d=Me();const L={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 se(n){const{findCompleted:e,localeService:i,matchesCount:t,matchesPosition:s,findString:a,findReplaceService:o,onChange:c,...u}=n,g=e&&t===0?i.t("find-replace.dialog.no-result"):t===0?" ":void 0;return d.jsx(_.InputWithSlot,{autoFocus:!0,placeholder:i.t("find-replace.dialog.find-placeholder"),slot:d.jsx(_.Pager,{loop:!0,text:g,value:s,total:t,onChange:m=>{s===t&&m===1?o.moveToNextMatch():s===1&&m===t||m<s?o.moveToPreviousMatch():o.moveToNextMatch()}}),value:a,onChange:m=>c==null?void 0:c(m),...u})}function ae(n,e){const i=p.useCallback(()=>{var s;(s=document.querySelector(".univer-find-input input"))==null||s.focus()},[]),t=p.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 p.useImperativeHandle(e,()=>({focus:i,selectHasFocus:t})),p.useEffect(()=>{const s=n.focusSignal$.subscribe(()=>i());return()=>s.unsubscribe()},[n,i]),{focus:i,selectHasFocus:t}}const ye=p.forwardRef(function(e,i){const t=r.useDependency(r.LocaleService),s=r.useDependency(b),a=r.useDependency(r.ICommandService),o=h.useObservable(s.state$,void 0,!0),{findCompleted:c,findString:u,matchesCount:v,matchesPosition:g}=o,m=p.useCallback(()=>{a.executeCommand(N.id)},[a]),I=p.useCallback(y=>s.changeFindString(y),[s]);return ae(s,i),d.jsxs(d.Fragment,{children:[d.jsx(se,{findCompleted:c,className:"univer-find-input",matchesCount:v,matchesPosition:g,findReplaceService:s,localeService:t,findString:u,onChange:I}),d.jsx("div",{className:L.findReplaceExpandContainer,children:d.jsx(_.Button,{type:"text",size:"small",onClick:m,children:t.t("find-replace.dialog.advanced-finding")})})]})}),Ie=p.forwardRef(function(e,i){const t=r.useDependency(b),s=r.useDependency(r.LocaleService),a=r.useDependency(r.ICommandService),o=r.useDependency(h.IMessageService),c=h.useObservable(t.currentMatch$,void 0,!0),u=h.useObservable(t.replaceables$,void 0,!0),v=h.useObservable(t.state$,void 0,!0),{matchesCount:g,matchesPosition:m,findString:I,inputtingFindString:y,replaceString:ze,caseSensitive:Ye,matchesTheWholeCell:Ze,findDirection:Qe,findScope:Xe,findBy:qe,findCompleted:$}=v,et=y.length===0,tt=g===0||!(c!=null&&c.replaceable),nt=u.length===0,it=p.useCallback(S=>t.changeInputtingFindString(S),[t]),st=p.useCallback(S=>t.changeReplaceString(S),[t]),{focus:at}=ae(t,i),rt=p.useCallback(()=>{I===y?t.moveToNextMatch():(t.changeFindString(y),t.find())},[I,y,t]),ot=p.useCallback(()=>a.executeCommand(w.id),[a]),ct=p.useCallback(async()=>{await a.executeCommand(B.id),at()},[a]),lt=p.useCallback(S=>{t.changeFindDirection(S)},[t]),dt=p.useCallback(S=>{t.changeFindScope(S)},[t]),ut=p.useCallback(S=>{t.changeFindBy(S)},[t]),ht=De(s),ft=Te(s),pt=xe(s);return p.useEffect(()=>{$&&g===0&&o.show({content:s.t("find-replace.dialog.no-match"),type:_.MessageType.Warning,duration:5e3})},[$,g,o,s]),d.jsxs(d.Fragment,{children:[d.jsx(_.FormLayout,{label:s.t("find-replace.dialog.find"),children:d.jsx(se,{findCompleted:$,className:"univer-find-input",matchesCount:g,matchesPosition:m,findReplaceService:t,localeService:s,findString:y,onChange:it})}),d.jsx(_.FormLayout,{label:s.t("find-replace.dialog.replace"),children:d.jsx(_.Input,{placeholder:s.t("find-replace.dialog.replace-placeholder"),value:ze,onChange:S=>st(S)})}),d.jsx(_.FormLayout,{label:s.t("find-replace.dialog.find-direction.title"),children:d.jsx(_.Select,{value:Qe,options:ft,onChange:lt})}),d.jsx(_.FormDualColumnLayout,{children:d.jsxs(d.Fragment,{children:[d.jsx(_.FormLayout,{label:s.t("find-replace.dialog.find-scope.title"),children:d.jsx(_.Select,{value:Xe,options:ht,onChange:dt})}),d.jsx(_.FormLayout,{label:s.t("find-replace.dialog.find-by.title"),children:d.jsx(_.Select,{value:qe,options:pt,onChange:ut})})]})}),d.jsx(_.FormDualColumnLayout,{children:d.jsxs(d.Fragment,{children:[d.jsx(_.FormLayout,{children:d.jsx(_.Checkbox,{checked:Ye,onChange:S=>{t.changeCaseSensitive(S)},children:s.t("find-replace.dialog.case-sensitive")})}),d.jsx(_.FormLayout,{children:d.jsx(_.Checkbox,{checked:Ze,onChange:S=>{t.changeMatchesTheWholeCell(S)},children:s.t("find-replace.dialog.match-the-whole-cell")})})]})}),d.jsxs("div",{className:L.findReplaceButtonsGroup,children:[d.jsx(_.Button,{type:"primary",onClick:rt,disabled:et,children:s.t("find-replace.dialog.find")}),d.jsxs("span",{className:L.findReplaceButtonsGroupRight,children:[d.jsx(_.Button,{disabled:tt,onClick:ot,children:s.t("find-replace.dialog.replace")}),d.jsx(_.Button,{disabled:nt,onClick:ct,children:s.t("find-replace.dialog.replace-all")})]})]})]})});function Fe(){const n=r.useDependency(b),e=r.useDependency(h.ILayoutService),i=r.useDependency(r.IContextService),t=h.useObservable(n.state$,void 0,!0),s=p.useRef(null);p.useEffect(()=>{let u;return s.current&&(u=e.registerContainerElement(s.current)),()=>u==null?void 0:u.dispose()},[e]);const a=p.useRef(null),o=p.useCallback(u=>i.setContextValue(X,u),[i]),c=p.useCallback(u=>i.setContextValue(Q,u),[i]);return p.useEffect(()=>{var v;const u=C.fromEvent(document,"focusin").subscribe(g=>{var m;g.target&&((m=s.current)!=null&&m.contains(g.target))?o(!0):o(!1),!a.current||!a.current.selectHasFocus()?c(!0):c(!1)});return(v=a.current)==null||v.focus(),o(!0),c(!0),()=>{u.unsubscribe(),o(!1)}},[o,c]),d.jsx("div",{className:L.findReplaceDialogContainer,ref:s,children:t.replaceRevealed?d.jsx(Ie,{ref:a}):d.jsx(ye,{ref:a})})}function De(n){const e=n.getCurrentLocale();return p.useMemo(()=>[{label:n.t("find-replace.dialog.find-scope.current-sheet"),value:P.SUBUNIT},{label:n.t("find-replace.dialog.find-scope.workbook"),value:P.UNIT}],[e])}function Te(n){const e=n.getCurrentLocale();return p.useMemo(()=>[{label:n.t("find-replace.dialog.find-direction.row"),value:x.ROW},{label:n.t("find-replace.dialog.find-direction.column"),value:x.COLUMN}],[e])}function xe(n){const e=n.getCurrentLocale();return p.useMemo(()=>[{label:n.t("find-replace.dialog.find-by.value"),value:O.VALUE},{label:n.t("find-replace.dialog.find-by.formula"),value:O.FORMULA}],[e])}function T(n){return n.getContextValue(X)}function Oe(n){return n.getContextValue(q)}function re(n){return n.getContextValue(Q)}const j="7_find-replace-shortcuts";function V(n){return n.getContextValue(r.FOCUSING_SHEET)}function H(n){return!n.getContextValue(r.EDITOR_ACTIVATED)}const Pe={id:F.id,description:"find-replace.shortcut.open-find-dialog",binding:h.KeyCode.F|h.MetaKeys.CTRL_COMMAND,group:j,preconditions(n){return!T(n)&&V(n)&&H(n)}},Ee={id:F.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(n){return!T(n)&&V(n)&&H(n)}},Ne={id:N.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:j,preconditions(n){return V(n)&&H(n)&&(!T(n)||!Oe(n))}},Le={id:k.id,description:"find-replace.shortcut.go-to-next-match",binding:h.KeyCode.ENTER,group:j,priority:1e3,preconditions(n){return re(n)&&T(n)}},je={id:W.id,description:"find-replace.shortcut.go-to-previous-match",binding:h.KeyCode.ENTER|h.MetaKeys.SHIFT,group:j,priority:1e3,preconditions(n){return re(n)&&T(n)}};function Ae(n){const e=n.get(r.IContextService);return{id:F.id,icon:"SearchIcon",tooltip:"find-replace.toolbar",type:h.MenuItemType.BUTTON,hidden$:h.getMenuHiddenObservable(n,r.UniverInstanceType.UNIVER_SHEET),disabled$:C.combineLatest([e.subscribeContextValue$(r.EDITOR_ACTIVATED),e.subscribeContextValue$(r.FOCUSING_SHEET)]).pipe(C.map(([i,t])=>i||!t))}}const Ue={[h.RibbonStartGroup.OTHERS]:{[F.id]:{order:2,menuItemFactory:Ae}}};var we=Object.defineProperty,Be=Object.getOwnPropertyDescriptor,ke=(n,e,i,t)=>{for(var s=t>1?void 0:t?Be(e,i):e,a=n.length-1,o;a>=0;a--)(o=n[a])&&(s=(t?o(e,i,s):o(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,We=20,Ge=-90;l.FindReplaceController=class extends r.RxDisposable{constructor(i,t,s,a,o,c,u,v,g,m){super();f(this,"_closingListenerDisposable");this._univerInstanceService=i,this._menuManagerService=t,this._shortcutService=s,this._commandService=a,this._findReplaceService=o,this._dialogService=c,this._layoutService=u,this._localeService=v,this._componentManager=g,this._injector=m,this._initCommands(),this._initUI(),this._initShortcuts()}dispose(){var i;super.dispose(),(i=this._closingListenerDisposable)==null||i.dispose(),this._closingListenerDisposable=null}_initCommands(){[F,N,k,W,B,w].forEach(i=>{this.disposeWithMe(this._commandService.registerCommand(i))})}_initShortcuts(){[Ne,Pe,Ee,je,Le].forEach(i=>this.disposeWithMe(this._shortcutService.registerShortcut(i)))}_initUI(){this.disposeWithMe(this._componentManager.register("FindReplaceDialog",Fe)),this.disposeWithMe(this._componentManager.register("SearchIcon",Z)),this._menuManagerService.mergeMenu(Ue),this._findReplaceService.stateUpdates$.pipe(C.takeUntil(this.dispose$)).subscribe(i=>{i.revealed===!0&&this._openPanel()})}_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:Ve(),preservePositionOnDestroy:!0,onClose:()=>this.closePanel()}),this._closingListenerDisposable=r.toDisposable(this._univerInstanceService.focused$.pipe(C.takeUntil(this.dispose$)).subscribe(i=>{(!i||!this._univerInstanceService.getUniverSheetInstance(i))&&this.closePanel()}))}closePanel(){this._closingListenerDisposable&&(this._closingListenerDisposable.dispose(),this._closingListenerDisposable=null,this._dialogService.close(oe),this._findReplaceService.terminate(),queueMicrotask(()=>this._layoutService.focus()))}},l.FindReplaceController=ke([M(0,r.IUniverInstanceService),M(1,h.IMenuManagerService),M(2,h.IShortcutService),M(3,r.ICommandService),M(4,b),M(5,h.IDialogService),M(6,h.ILayoutService),M(7,r.Inject(r.LocaleService)),M(8,r.Inject(h.ComponentManager)),M(9,r.Inject(r.Injector))],l.FindReplaceController);function Ve(){const{innerWidth:n}=window;return{x:(n-ce)/2-We,y:Ge}}var He=Object.defineProperty,Ke=Object.getOwnPropertyDescriptor,$e=(n,e,i,t)=>{for(var s=t>1?void 0:t?Ke(e,i):e,a=n.length-1,o;a>=0;a--)(o=n[a])&&(s=(t?o(e,i,s):o(s))||s);return t&&s&&He(e,i,s),s},le=(n,e)=>(i,t)=>e(i,t,n);const Je="UNIVER_FIND_REPLACE_PLUGIN";l.UniverFindReplacePlugin=(K=class extends r.Plugin{constructor(e=J,i,t){super(),this._config=e,this._injector=i,this._configService=t;const{...s}=r.merge({},J,this._config);this._configService.setConfig(ue,s)}onStarting(){[[l.FindReplaceController],[b,{useClass:U}]].forEach(e=>this._injector.add(e))}onRendered(){this._injector.get(l.FindReplaceController)}},f(K,"pluginName",Je),K),l.UniverFindReplacePlugin=$e([le(1,r.Inject(r.Injector)),le(2,r.IConfigService)],l.UniverFindReplacePlugin),l.FindBy=O,l.FindDirection=x,l.FindModel=Se,l.FindReplaceState=te,l.FindScope=P,l.GoToNextMatchOperation=k,l.GoToPreviousMatchOperation=W,l.IFindReplaceService=b,l.OpenFindDialogOperation=F,l.OpenReplaceDialogOperation=N,l.ReplaceAllMatchesCommand=B,l.ReplaceCurrentMatchCommand=w,l.createInitFindReplaceState=E,Object.defineProperty(l,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@univerjs/find-replace",
3
- "version": "0.5.2",
3
+ "version": "0.5.3-experimental.20250106-e3b7a39",
4
4
  "private": false,
5
5
  "description": "",
6
6
  "author": "DreamNum <developer@univer.ai>",
@@ -54,40 +54,21 @@
54
54
  "rxjs": ">=7.0.0"
55
55
  },
56
56
  "dependencies": {
57
- "@univerjs/icons": "^0.2.8",
58
- "@univerjs/core": "0.5.2",
59
- "@univerjs/engine-render": "0.5.2",
60
- "@univerjs/design": "0.5.2",
61
- "@univerjs/ui": "0.5.2"
57
+ "@univerjs/icons": "^0.2.10",
58
+ "@univerjs/core": "0.5.3-experimental.20250106-e3b7a39",
59
+ "@univerjs/design": "0.5.3-experimental.20250106-e3b7a39",
60
+ "@univerjs/ui": "0.5.3-experimental.20250106-e3b7a39",
61
+ "@univerjs/engine-render": "0.5.3-experimental.20250106-e3b7a39"
62
62
  },
63
63
  "devDependencies": {
64
64
  "less": "^4.2.1",
65
65
  "postcss": "^8.4.49",
66
66
  "react": "18.3.1",
67
67
  "rxjs": "^7.8.1",
68
- "tailwindcss": "^3.4.16",
69
68
  "typescript": "^5.7.2",
70
- "vite": "^6.0.3",
69
+ "vite": "^6.0.6",
71
70
  "vitest": "^2.1.8",
72
- "@univerjs-infra/shared": "0.5.2"
73
- },
74
- "space": {
75
- ".": {
76
- "import": "./lib/es/index.js",
77
- "require": "./lib/cjs/index.js",
78
- "types": "./lib/types/index.d.ts"
79
- },
80
- "./*": {
81
- "import": "./lib/es/*",
82
- "require": "./lib/cjs/*",
83
- "types": "./lib/types/index.d.ts"
84
- },
85
- "./locale/*": {
86
- "import": "./lib/es/locale/*.js",
87
- "require": "./lib/cjs/locale/*.js",
88
- "types": "./lib/types/locale/*.d.ts"
89
- },
90
- "./lib/*": "./lib/*"
71
+ "@univerjs-infra/shared": "0.5.3"
91
72
  },
92
73
  "scripts": {
93
74
  "test": "vitest run",
package/LICENSE DELETED
@@ -1,176 +0,0 @@
1
- Apache License
2
- Version 2.0, January 2004
3
- http://www.apache.org/licenses/
4
-
5
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
-
7
- 1. Definitions.
8
-
9
- "License" shall mean the terms and conditions for use, reproduction,
10
- and distribution as defined by Sections 1 through 9 of this document.
11
-
12
- "Licensor" shall mean the copyright owner or entity authorized by
13
- the copyright owner that is granting the License.
14
-
15
- "Legal Entity" shall mean the union of the acting entity and all
16
- other entities that control, are controlled by, or are under common
17
- control with that entity. For the purposes of this definition,
18
- "control" means (i) the power, direct or indirect, to cause the
19
- direction or management of such entity, whether by contract or
20
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
- outstanding shares, or (iii) beneficial ownership of such entity.
22
-
23
- "You" (or "Your") shall mean an individual or Legal Entity
24
- exercising permissions granted by this License.
25
-
26
- "Source" form shall mean the preferred form for making modifications,
27
- including but not limited to software source code, documentation
28
- source, and configuration files.
29
-
30
- "Object" form shall mean any form resulting from mechanical
31
- transformation or translation of a Source form, including but
32
- not limited to compiled object code, generated documentation,
33
- and conversions to other media types.
34
-
35
- "Work" shall mean the work of authorship, whether in Source or
36
- Object form, made available under the License, as indicated by a
37
- copyright notice that is included in or attached to the work
38
- (an example is provided in the Appendix below).
39
-
40
- "Derivative Works" shall mean any work, whether in Source or Object
41
- form, that is based on (or derived from) the Work and for which the
42
- editorial revisions, annotations, elaborations, or other modifications
43
- represent, as a whole, an original work of authorship. For the purposes
44
- of this License, Derivative Works shall not include works that remain
45
- separable from, or merely link (or bind by name) to the interfaces of,
46
- the Work and Derivative Works thereof.
47
-
48
- "Contribution" shall mean any work of authorship, including
49
- the original version of the Work and any modifications or additions
50
- to that Work or Derivative Works thereof, that is intentionally
51
- submitted to Licensor for inclusion in the Work by the copyright owner
52
- or by an individual or Legal Entity authorized to submit on behalf of
53
- the copyright owner. For the purposes of this definition, "submitted"
54
- means any form of electronic, verbal, or written communication sent
55
- to the Licensor or its representatives, including but not limited to
56
- communication on electronic mailing lists, source code control systems,
57
- and issue tracking systems that are managed by, or on behalf of, the
58
- Licensor for the purpose of discussing and improving the Work, but
59
- excluding communication that is conspicuously marked or otherwise
60
- designated in writing by the copyright owner as "Not a Contribution."
61
-
62
- "Contributor" shall mean Licensor and any individual or Legal Entity
63
- on behalf of whom a Contribution has been received by Licensor and
64
- subsequently incorporated within the Work.
65
-
66
- 2. Grant of Copyright License. Subject to the terms and conditions of
67
- this License, each Contributor hereby grants to You a perpetual,
68
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
- copyright license to reproduce, prepare Derivative Works of,
70
- publicly display, publicly perform, sublicense, and distribute the
71
- Work and such Derivative Works in Source or Object form.
72
-
73
- 3. Grant of Patent License. Subject to the terms and conditions of
74
- this License, each Contributor hereby grants to You a perpetual,
75
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
- (except as stated in this section) patent license to make, have made,
77
- use, offer to sell, sell, import, and otherwise transfer the Work,
78
- where such license applies only to those patent claims licensable
79
- by such Contributor that are necessarily infringed by their
80
- Contribution(s) alone or by combination of their Contribution(s)
81
- with the Work to which such Contribution(s) was submitted. If You
82
- institute patent litigation against any entity (including a
83
- cross-claim or counterclaim in a lawsuit) alleging that the Work
84
- or a Contribution incorporated within the Work constitutes direct
85
- or contributory patent infringement, then any patent licenses
86
- granted to You under this License for that Work shall terminate
87
- as of the date such litigation is filed.
88
-
89
- 4. Redistribution. You may reproduce and distribute copies of the
90
- Work or Derivative Works thereof in any medium, with or without
91
- modifications, and in Source or Object form, provided that You
92
- meet the following conditions:
93
-
94
- (a) You must give any other recipients of the Work or
95
- Derivative Works a copy of this License; and
96
-
97
- (b) You must cause any modified files to carry prominent notices
98
- stating that You changed the files; and
99
-
100
- (c) You must retain, in the Source form of any Derivative Works
101
- that You distribute, all copyright, patent, trademark, and
102
- attribution notices from the Source form of the Work,
103
- excluding those notices that do not pertain to any part of
104
- the Derivative Works; and
105
-
106
- (d) If the Work includes a "NOTICE" text file as part of its
107
- distribution, then any Derivative Works that You distribute must
108
- include a readable copy of the attribution notices contained
109
- within such NOTICE file, excluding those notices that do not
110
- pertain to any part of the Derivative Works, in at least one
111
- of the following places: within a NOTICE text file distributed
112
- as part of the Derivative Works; within the Source form or
113
- documentation, if provided along with the Derivative Works; or,
114
- within a display generated by the Derivative Works, if and
115
- wherever such third-party notices normally appear. The contents
116
- of the NOTICE file are for informational purposes only and
117
- do not modify the License. You may add Your own attribution
118
- notices within Derivative Works that You distribute, alongside
119
- or as an addendum to the NOTICE text from the Work, provided
120
- that such additional attribution notices cannot be construed
121
- as modifying the License.
122
-
123
- You may add Your own copyright statement to Your modifications and
124
- may provide additional or different license terms and conditions
125
- for use, reproduction, or distribution of Your modifications, or
126
- for any such Derivative Works as a whole, provided Your use,
127
- reproduction, and distribution of the Work otherwise complies with
128
- the conditions stated in this License.
129
-
130
- 5. Submission of Contributions. Unless You explicitly state otherwise,
131
- any Contribution intentionally submitted for inclusion in the Work
132
- by You to the Licensor shall be under the terms and conditions of
133
- this License, without any additional terms or conditions.
134
- Notwithstanding the above, nothing herein shall supersede or modify
135
- the terms of any separate license agreement you may have executed
136
- with Licensor regarding such Contributions.
137
-
138
- 6. Trademarks. This License does not grant permission to use the trade
139
- names, trademarks, service marks, or product names of the Licensor,
140
- except as required for reasonable and customary use in describing the
141
- origin of the Work and reproducing the content of the NOTICE file.
142
-
143
- 7. Disclaimer of Warranty. Unless required by applicable law or
144
- agreed to in writing, Licensor provides the Work (and each
145
- Contributor provides its Contributions) on an "AS IS" BASIS,
146
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
- implied, including, without limitation, any warranties or conditions
148
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
- PARTICULAR PURPOSE. You are solely responsible for determining the
150
- appropriateness of using or redistributing the Work and assume any
151
- risks associated with Your exercise of permissions under this License.
152
-
153
- 8. Limitation of Liability. In no event and under no legal theory,
154
- whether in tort (including negligence), contract, or otherwise,
155
- unless required by applicable law (such as deliberate and grossly
156
- negligent acts) or agreed to in writing, shall any Contributor be
157
- liable to You for damages, including any direct, indirect, special,
158
- incidental, or consequential damages of any character arising as a
159
- result of this License or out of the use or inability to use the
160
- Work (including but not limited to damages for loss of goodwill,
161
- work stoppage, computer failure or malfunction, or any and all
162
- other commercial damages or losses), even if such Contributor
163
- has been advised of the possibility of such damages.
164
-
165
- 9. Accepting Warranty or Additional Liability. While redistributing
166
- the Work or Derivative Works thereof, You may choose to offer,
167
- and charge a fee for, acceptance of support, warranty, indemnity,
168
- or other liability obligations and/or rights consistent with this
169
- License. However, in accepting such obligations, You may act only
170
- on Your own behalf and on Your sole responsibility, not on behalf
171
- of any other Contributor, and only if You agree to indemnify,
172
- defend, and hold each Contributor harmless for any liability
173
- incurred by, or claims asserted against, such Contributor by reason
174
- of your accepting any such warranty or additional liability.
175
-
176
- END OF TERMS AND CONDITIONS