@univerjs/find-replace 0.5.1 → 0.5.2

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/index.css CHANGED
@@ -1 +1 @@
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}
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}
package/lib/umd/index.js CHANGED
@@ -1,4 +1,4 @@
1
- (function(c,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):(c=typeof globalThis<"u"?globalThis:c||self,a(c.UniverFindReplace={},c.UniverCore,c.UniverUi,c.rxjs,c.UniverDesign,c.UniverEngineRender,c.React))})(this,function(c,a,d,S,_,de,l){"use strict";var mt=Object.defineProperty;var vt=(c,a,d)=>a in c?mt(c,a,{enumerable:!0,configurable:!0,writable:!0,value:d}):c[a]=d;var u=(c,a,d)=>vt(c,typeof a!="symbol"?a+"":a,d);var J;const ue="find-replace.config",he={};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)},fe=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=l.forwardRef(function(n,e){var i=n.icon,t=n.id,s=n.className,r=n.extend,o=fe(n,["icon","id","className","extend"]),h="univerjs-icon univerjs-icon-".concat(t," ").concat(s||"").trim(),f=l.useRef("_".concat(ge()));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 l.createElement(n.tag,C(C({key:e},pe(n,i,s)),t),(_e(n,i).children||[]).map(function(r,o){return Z(r,"".concat(e,"-").concat(n.tag,"-").concat(o),i,void 0,s)}))}function pe(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 _e(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 ge(){return Math.random().toString(36).substring(2,8)}Y.displayName="UniverIcon";var me={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"mask",attrs:{id:"mask0_217_40",style:{maskType:"alpha"},width:17,height:17,x:0,y:0,maskUnits:"userSpaceOnUse"},children:[{tag:"path",attrs:{fill:"#D9D9D9",d:"M0.9 0.09H16.9V16.09H0.9z"}}]},{tag:"g",attrs:{mask:"url(#mask0_217_40)"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M2.39551 7.37266C2.39551 4.18105 4.98281 1.59375 8.17441 1.59375C11.366 1.59375 13.9533 4.18105 13.9533 7.37266C13.9533 8.72342 13.4898 9.96603 12.7133 10.95L15.1964 13.4331C15.4619 13.6986 15.4619 14.1291 15.1964 14.3946C14.9309 14.6601 14.5004 14.6601 14.2349 14.3946L11.7518 11.9115C10.7678 12.6881 9.52525 13.1516 8.17441 13.1516C4.98281 13.1516 2.39551 10.5642 2.39551 7.37266ZM8.17441 2.95349C5.73378 2.95349 3.75525 4.93202 3.75525 7.37266C3.75525 9.81333 5.73378 11.7918 8.17441 11.7918C10.6151 11.7918 12.5936 9.81333 12.5936 7.37266C12.5936 4.93202 10.6151 2.95349 8.17441 2.95349Z",fillRule:"evenodd",clipRule:"evenodd"}}]}]},Q=l.forwardRef(function(n,e){return l.createElement(Y,Object.assign({},n,{id:"search-single-16",ref:e,icon:me}))});Q.displayName="SearchSingle16";const X="FIND_REPLACE_INPUT_FOCUS",q="FIND_REPLACE_DIALOG_FOCUS",ee="FIND_REPLACE_REPLACE_REVEALED";var ve=Object.defineProperty,Se=Object.getOwnPropertyDescriptor,te=(n,e,i,t)=>{for(var s=t>1?void 0:t?Se(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&&ve(e,i,s),s},A=(n,e)=>(i,t)=>e(i,t,n);class Ce extends a.Disposable{}const R=a.createIdentifier("find-replace.service");function Re(n){return typeof n.findString<"u"||typeof n.inputtingFindString<"u"||typeof n.findDirection<"u"||typeof n.matchesTheWholeCell<"u"||typeof n.caseSensitive<"u"||typeof n.findScope<"u"||typeof n.findBy<"u"}let U=class extends 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;Re(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({...w(),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}};U=te([A(2,a.IUniverInstanceService)],U);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 w(){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 be{constructor(){u(this,"_stateUpdates$",new S.Subject);u(this,"stateUpdates$",this._stateUpdates$.asObservable());u(this,"_state$",new S.BehaviorSubject(w()));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 B=class extends a.Disposable{constructor(e,i){super();u(this,"_providers",new Set);u(this,"_state",new be);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(U,this._state,this._providers),this._model.currentMatch$.subscribe(t=>this._currentMatch$.next(t)),this._model.replaceables$.subscribe(t=>this._replaceables$.next(t));const i=w();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)}};B=te([A(0,a.Inject(a.Injector)),A(1,a.IContextService)],B);const k={id:"ui.command.replace-current-match",type:a.CommandType.COMMAND,handler:n=>n.get(R).replace()},Me="CONFIRM_REPLACE_ALL",W={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:Me,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}},G={type:a.CommandType.OPERATION,id:"ui.operation.go-to-next-match",handler:n=>(n.get(R).moveToNextMatch(),!0)},V={type:a.CommandType.OPERATION,id:"ui.operation.go-to-previous-match",handler:n=>(n.get(R).moveToPreviousMatch(),!0)};var H={exports:{}},D={};/**
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={};/**
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 ye(){if(ne)return D;ne=1;var n=l,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 Ie(){return ie||(ie=1,H.exports=ye()),H.exports}var p=Ie();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 p.jsx(_.InputWithSlot,{autoFocus:!0,placeholder:i.t("find-replace.dialog.find-placeholder"),slot:p.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})}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 ae(n,e){const i=l.useCallback(()=>{var s;(s=document.querySelector(".univer-find-input input"))==null||s.focus()},[]),t=l.useCallback(()=>{const s=document.querySelectorAll(".univer-find-replace-dialog-container .univer-select-selection-search-input");return Array.from(s).some(r=>r===document.activeElement)},[]);return l.useImperativeHandle(e,()=>({focus:i,selectHasFocus:t})),l.useEffect(()=>{const s=n.focusSignal$.subscribe(()=>i());return()=>s.unsubscribe()},[n,i]),{focus:i,selectHasFocus:t}}const Fe=l.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=l.useCallback(()=>{r.executeCommand(E.id)},[r]),I=l.useCallback(y=>s.changeFindString(y),[s]);return ae(s,i),p.jsxs(l.Fragment,{children:[p.jsx(se,{findCompleted:h,className:"univer-find-input",matchesCount:b,matchesPosition:g,findReplaceService:s,localeService:t,findString:f,onChange:I}),p.jsx("div",{className:N.findReplaceExpandContainer,children:p.jsx(_.Button,{type:"text",size:"small",onClick:m,children:t.t("find-replace.dialog.advanced-finding")})})]})}),De=l.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:Ze,caseSensitive:Qe,matchesTheWholeCell:Xe,findDirection:qe,findScope:et,findBy:tt,findCompleted:z}=b,nt=y.length===0,it=g===0||!(h!=null&&h.replaceable),st=f.length===0,at=l.useCallback(v=>t.changeInputtingFindString(v),[t]),rt=l.useCallback(v=>t.changeReplaceString(v),[t]),{focus:ot}=ae(t,i),ct=l.useCallback(()=>{I===y?t.moveToNextMatch():(t.changeFindString(y),t.find())},[I,y,t]),lt=l.useCallback(()=>r.executeCommand(k.id),[r]),dt=l.useCallback(async()=>{await r.executeCommand(W.id),ot()},[r]),ut=l.useCallback(v=>{t.changeFindDirection(v)},[t]),ht=l.useCallback(v=>{t.changeFindScope(v)},[t]),ft=l.useCallback(v=>{t.changeFindBy(v)},[t]),pt=Te(s),_t=Oe(s),gt=Pe(s);return l.useEffect(()=>{const v=z&&g===0;let j=null;return v&&(j=o.show({content:s.t("find-replace.dialog.no-match"),type:_.MessageType.Warning,duration:5e3})),()=>j==null?void 0:j.dispose()},[z,g,o,s]),p.jsxs(l.Fragment,{children:[p.jsx(_.FormLayout,{label:s.t("find-replace.dialog.find"),children:p.jsx(se,{findCompleted:z,className:"univer-find-input",matchesCount:g,matchesPosition:m,findReplaceService:t,localeService:s,findString:y,onChange:at})}),p.jsx(_.FormLayout,{label:s.t("find-replace.dialog.replace"),children:p.jsx(_.Input,{placeholder:s.t("find-replace.dialog.replace-placeholder"),value:Ze,onChange:v=>rt(v)})}),p.jsx(_.FormLayout,{label:s.t("find-replace.dialog.find-direction.title"),children:p.jsx(_.Select,{value:qe,options:_t,onChange:ut})}),p.jsx(_.FormDualColumnLayout,{children:p.jsxs(l.Fragment,{children:[p.jsx(_.FormLayout,{label:s.t("find-replace.dialog.find-scope.title"),children:p.jsx(_.Select,{value:et,options:pt,onChange:ht})}),p.jsx(_.FormLayout,{label:s.t("find-replace.dialog.find-by.title"),children:p.jsx(_.Select,{value:tt,options:gt,onChange:ft})})]})}),p.jsx(_.FormDualColumnLayout,{children:p.jsxs(l.Fragment,{children:[p.jsx(_.FormLayout,{children:p.jsx(_.Checkbox,{checked:Qe,onChange:v=>{t.changeCaseSensitive(v)},children:s.t("find-replace.dialog.case-sensitive")})}),p.jsx(_.FormLayout,{children:p.jsx(_.Checkbox,{checked:Xe,onChange:v=>{t.changeMatchesTheWholeCell(v)},children:s.t("find-replace.dialog.match-the-whole-cell")})})]})}),p.jsxs("div",{className:N.findReplaceButtonsGroup,children:[p.jsx(_.Button,{type:"primary",onClick:ct,disabled:nt,children:s.t("find-replace.dialog.find")}),p.jsxs("span",{className:N.findReplaceButtonsGroupRight,children:[p.jsx(_.Button,{disabled:it,onClick:lt,children:s.t("find-replace.dialog.replace")}),p.jsx(_.Button,{disabled:st,onClick:dt,children:s.t("find-replace.dialog.replace-all")})]})]})]})});function xe(){const n=a.useDependency(R),e=a.useDependency(d.ILayoutService),i=a.useDependency(a.IContextService),t=d.useObservable(n.state$,void 0,!0),s=l.useRef(null);l.useEffect(()=>{let f;return s.current&&(f=e.registerContainerElement(s.current)),()=>f==null?void 0:f.dispose()},[e]);const r=l.useRef(null),o=l.useCallback(f=>i.setContextValue(q,f),[i]),h=l.useCallback(f=>i.setContextValue(X,f),[i]);return l.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]),p.jsx("div",{className:N.findReplaceDialogContainer,ref:s,children:t.replaceRevealed?p.jsx(De,{ref:r}):p.jsx(Fe,{ref:r})})}function Te(n){const e=n.getCurrentLocale();return l.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 Oe(n){const e=n.getCurrentLocale();return l.useMemo(()=>[{label:n.t("find-replace.dialog.find-direction.row"),value:T.ROW},{label:n.t("find-replace.dialog.find-direction.column"),value:T.COLUMN}],[e])}function Pe(n){const e=n.getCurrentLocale();return l.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 Ee(n){return n.getContextValue(ee)}function re(n){return n.getContextValue(X)}const L="7_find-replace-shortcuts";function K(n){return n.getContextValue(a.FOCUSING_SHEET)}function $(n){return!n.getContextValue(a.EDITOR_ACTIVATED)}const Ne={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)&&K(n)&&$(n)}},Le={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)&&K(n)&&$(n)}},je={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 K(n)&&$(n)&&(!x(n)||!Ee(n))}},Ae={id:G.id,description:"find-replace.shortcut.go-to-next-match",binding:d.KeyCode.ENTER,group:L,priority:1e3,preconditions(n){return re(n)&&x(n)}},Ue={id:V.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 we(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 Be={[d.RibbonStartGroup.OTHERS]:{[F.id]:{order:2,menuItemFactory:we}}};var ke=Object.defineProperty,We=Object.getOwnPropertyDescriptor,Ge=(n,e,i,t)=>{for(var s=t>1?void 0:t?We(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},M=(n,e)=>(i,t)=>e(i,t,n);const oe="DESKTOP_FIND_REPLACE_DIALOG",ce=350,Ve=20,He=-90;c.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,G,V,W,k].forEach(i=>{this.disposeWithMe(this._commandService.registerCommand(i))})}_initShortcuts(){[je,Ne,Le,Ue,Ae].forEach(i=>this.disposeWithMe(this._shortcutService.registerShortcut(i)))}_initUI(){this.disposeWithMe(this._componentManager.register("FindReplaceDialog",xe)),this.disposeWithMe(this._componentManager.register("SearchIcon",Q)),this._menuManagerService.mergeMenu(Be),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:Ke(),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()))}},c.FindReplaceController=Ge([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))],c.FindReplaceController);function Ke(){const{innerWidth:n}=window;return{x:(n-ce)/2-Ve,y:He}}var $e=Object.defineProperty,Je=Object.getOwnPropertyDescriptor,ze=(n,e,i,t)=>{for(var s=t>1?void 0:t?Je(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&&$e(e,i,s),s},le=(n,e)=>(i,t)=>e(i,t,n);const Ye="UNIVER_FIND_REPLACE_PLUGIN";c.UniverFindReplacePlugin=(J=class extends a.Plugin{constructor(e=he,i,t){super(),this._config=e,this._injector=i,this._configService=t;const{...s}=this._config;this._configService.setConfig(ue,s)}onStarting(){[[c.FindReplaceController],[R,{useClass:B}]].forEach(e=>this._injector.add(e))}onRendered(){this._injector.get(c.FindReplaceController)}},u(J,"pluginName",Ye),J),c.UniverFindReplacePlugin=ze([le(1,a.Inject(a.Injector)),le(2,a.IConfigService)],c.UniverFindReplacePlugin),c.FindBy=O,c.FindDirection=T,c.FindModel=Ce,c.FindScope=P,c.GoToNextMatchOperation=G,c.GoToPreviousMatchOperation=V,c.IFindReplaceService=R,c.OpenFindDialogOperation=F,c.OpenReplaceDialogOperation=E,c.ReplaceAllMatchesCommand=W,c.ReplaceCurrentMatchCommand=k,Object.defineProperty(c,Symbol.toStringTag,{value:"Module"})});
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"})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@univerjs/find-replace",
3
- "version": "0.5.1",
3
+ "version": "0.5.2",
4
4
  "private": false,
5
5
  "description": "",
6
6
  "author": "DreamNum <developer@univer.ai>",
@@ -55,21 +55,21 @@
55
55
  },
56
56
  "dependencies": {
57
57
  "@univerjs/icons": "^0.2.8",
58
- "@univerjs/core": "0.5.1",
59
- "@univerjs/design": "0.5.1",
60
- "@univerjs/engine-render": "0.5.1",
61
- "@univerjs/ui": "0.5.1"
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"
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.15",
68
+ "tailwindcss": "^3.4.16",
69
69
  "typescript": "^5.7.2",
70
- "vite": "^6.0.1",
71
- "vitest": "^2.1.6",
72
- "@univerjs-infra/shared": "0.5.1"
70
+ "vite": "^6.0.3",
71
+ "vitest": "^2.1.8",
72
+ "@univerjs-infra/shared": "0.5.2"
73
73
  },
74
74
  "space": {
75
75
  ".": {