@univerjs/find-replace 0.5.5 → 0.6.0-alpha.0
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 +1 -9
- package/lib/es/index.js +339 -368
- package/lib/types/views/dialog/FindReplaceDialog.d.ts +1 -1
- package/lib/types/views/dialog/FindReplaceDialog.stories.d.ts +2 -3
- package/lib/types/views/dialog/SearchInput.d.ts +1 -2
- package/lib/umd/index.js +1 -9
- package/package.json +9 -9
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
2
|
export declare const FindDialog: React.ForwardRefExoticComponent<React.RefAttributes<unknown>>;
|
|
3
3
|
export declare const ReplaceDialog: React.ForwardRefExoticComponent<React.RefAttributes<unknown>>;
|
|
4
|
-
export declare function FindReplaceDialog():
|
|
4
|
+
export declare function FindReplaceDialog(): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { Meta } from '@storybook/react';
|
|
2
|
-
import { default as React } from 'react';
|
|
3
2
|
declare const meta: Meta;
|
|
4
3
|
export default meta;
|
|
5
4
|
export declare const FindDialog: {
|
|
6
|
-
render():
|
|
5
|
+
render(): import("react/jsx-runtime").JSX.Element;
|
|
7
6
|
};
|
|
8
7
|
export declare const ReplaceDialog: {
|
|
9
|
-
render():
|
|
8
|
+
render(): import("react/jsx-runtime").JSX.Element;
|
|
10
9
|
};
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { LocaleService } from '@univerjs/core';
|
|
2
2
|
import { IInputWithSlotProps } from '@univerjs/design';
|
|
3
|
-
import { default as React } from 'react';
|
|
4
3
|
import { IFindReplaceService } from '../../services/find-replace.service';
|
|
5
4
|
export interface ISearchInputProps extends Pick<IInputWithSlotProps, 'onFocus' | 'onBlur' | 'className' | 'onChange'> {
|
|
6
5
|
findCompleted: boolean;
|
|
@@ -10,4 +9,4 @@ export interface ISearchInputProps extends Pick<IInputWithSlotProps, 'onFocus' |
|
|
|
10
9
|
matchesCount: number;
|
|
11
10
|
findString: string;
|
|
12
11
|
}
|
|
13
|
-
export declare function SearchInput(props: ISearchInputProps):
|
|
12
|
+
export declare function SearchInput(props: ISearchInputProps): import("react/jsx-runtime").JSX.Element;
|
package/lib/umd/index.js
CHANGED
|
@@ -1,9 +1 @@
|
|
|
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
|
-
* @license React
|
|
3
|
-
* react-jsx-runtime.production.min.js
|
|
4
|
-
*
|
|
5
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
6
|
-
*
|
|
7
|
-
* This source code is licensed under the MIT license found in the
|
|
8
|
-
* LICENSE file in the root directory of this source tree.
|
|
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"})});
|
|
1
|
+
(function(c,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/jsx-runtime"),require("react")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/ui","rxjs","@univerjs/design","@univerjs/engine-render","react/jsx-runtime","react"],r):(c=typeof globalThis<"u"?globalThis:c||self,r(c.UniverFindReplace={},c.UniverCore,c.UniverUi,c.rxjs,c.UniverDesign,c.UniverEngineRender,c.React,c.React))})(this,function(c,r,h,m,p,re,d,f){"use strict";var lt=Object.defineProperty;var dt=(c,r,h)=>r in c?lt(c,r,{enumerable:!0,configurable:!0,writable:!0,value:h}):c[r]=h;var u=(c,r,h)=>dt(c,typeof r!="symbol"?r+"":r,h);var G;const oe="find-replace.config",H={};var M=function(){return M=Object.assign||function(n){for(var e,i=1,t=arguments.length;i<t;i++){e=arguments[i];for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&(n[a]=e[a])}return n},M.apply(this,arguments)},ce=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 a=0,t=Object.getOwnPropertySymbols(n);a<t.length;a++)e.indexOf(t[a])<0&&Object.prototype.propertyIsEnumerable.call(n,t[a])&&(i[t[a]]=n[t[a]]);return i},K=f.forwardRef(function(n,e){var i=n.icon,t=n.id,a=n.className,s=n.extend,o=ce(n,["icon","id","className","extend"]),l="univerjs-icon univerjs-icon-".concat(t," ").concat(a||"").trim(),_=f.useRef("_".concat(he()));return q(i,"".concat(t),{defIds:i.defIds,idSuffix:_.current},M({ref:e,className:l},o),s)});function q(n,e,i,t,a){return f.createElement(n.tag,M(M({key:e},le(n,i,a)),t),(de(n,i).children||[]).map(function(s,o){return q(s,"".concat(e,"-").concat(n.tag,"-").concat(o),i,void 0,a)}))}function le(n,e,i){var t=M({},n.attrs);i!=null&&i.colorChannel1&&t.fill==="colorChannel1"&&(t.fill=i.colorChannel1);var a=e.defIds;return!a||a.length===0||(n.tag==="use"&&t["xlink:href"]&&(t["xlink:href"]=t["xlink:href"]+e.idSuffix),Object.entries(t).forEach(function(s){var o=s[0],l=s[1];typeof l=="string"&&(t[o]=l.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))})),t}function de(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)?M(M({},n),{children:n.children.map(function(a){return typeof a.attrs.id=="string"&&t&&t.indexOf(a.attrs.id)>-1?M(M({},a),{attrs:M(M({},a.attrs),{id:a.attrs.id+e.idSuffix})}):a})}):n}function he(){return Math.random().toString(36).substring(2,8)}K.displayName="UniverIcon";var ue={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=f.forwardRef(function(n,e){return f.createElement(K,Object.assign({},n,{id:"search-single-16",ref:e,icon:ue}))});z.displayName="SearchSingle16";const Y="FIND_REPLACE_INPUT_FOCUS",Z="FIND_REPLACE_DIALOG_FOCUS",J="FIND_REPLACE_REPLACE_REVEALED";var fe=Object.defineProperty,pe=Object.getOwnPropertyDescriptor,Q=(n,e,i,t)=>{for(var a=t>1?void 0:t?pe(e,i):e,s=n.length-1,o;s>=0;s--)(o=n[s])&&(a=(t?o(e,i,a):o(a))||a);return t&&a&&fe(e,i,a),a},A=(n,e)=>(i,t)=>e(i,t,n);class _e extends r.Disposable{}const b=r.createIdentifier("find-replace.service");function ge(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"}c.FindReplaceModel=class extends r.Disposable{constructor(i,t,a){super();u(this,"currentMatch$",new m.BehaviorSubject(null));u(this,"replaceables$",new m.BehaviorSubject([]));u(this,"_findModels",[]);u(this,"_matchingModel",null);u(this,"_matches",[]);u(this,"_currentSearchingDisposables",null);this._state=i,this._providers=t,this._univerInstanceService=a,this.disposeWithMe(this._state.stateUpdates$.pipe(m.throttleTime(200,void 0,{leading:!0,trailing:!0})).subscribe(async s=>{const o=this._state.state;ge(s)&&(o.findString!==""&&!o.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({...O(),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(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(t);const a=this._matches=t.map(s=>s.getMatches()).flat();return this.replaceables$.next(a.filter(s=>s.replaceable)),a.length?(this._moveToInitialMatch(t),this._state.changeState({matchesCount:a.length}),{results:a}):(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,a=m.combineLatest(i.map(s=>s.matchesUpdate$)).pipe(m.debounceTime(220)).subscribe(([...s])=>{const o=this._matches=s.flat();o.length?(this._moveToInitialMatch(this._findModels,!0),this._state.changeState({matchesCount:o.length}),this.replaceables$.next(o.filter(l=>l.replaceable))):(this._state.changeState({matchesCount:0,matchesPosition:0}),this.replaceables$.next([]))});i.forEach(s=>t.add(r.toDisposable(s.activelyChangingMatch$.subscribe(o=>{const l=this._matches.findIndex(_=>_===o);this._state.changeState({matchesPosition:l+1})})))),t.add(r.toDisposable(a))}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((a,s)=>(a.success+=s.success,a.failure+=s.failure,a),{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(a=>a===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 a=this._findModels.findIndex(s=>s===this._matchingModel);return this._moveToNextUnitMatch(a)}}_moveToNextUnitMatch(i){const t=this._findModels.length;for(let a=(i+1)%t;a!==i;){const s=this._findModels[a],o=s.moveToNextMatch({ignoreSelection:!0});if(o)return this._matchingModel=s,this._markMatch(o),o;a=(a+1)%t}if(this._matchingModel){const a=this._matchingModel.moveToNextMatch({ignoreSelection:!0});return a&&this._markMatch(a),a}}moveToPreviousMatch(){if(!this._matchingModel)return;const i=this._findModels.length===1,t=this._matchingModel.moveToPreviousMatch({loop:i});if(t){const a=this._matches.findIndex(s=>s===t);return this.currentMatch$.next(t),this._state.changeState({matchesPosition:a+1}),t}else{const a=this._findModels.length,s=this._findModels.findIndex(l=>l===this._matchingModel);for(let l=(s-1+a)%a;l!==s;){const _=this._findModels[l],S=_.moveToPreviousMatch({ignoreSelection:!0});if(S)return this._matchingModel=_,this._markMatch(S),S;l=(l-1)%a}const o=this._matchingModel.moveToPreviousMatch({ignoreSelection:!0});return o&&this._markMatch(o),o}}_moveToInitialMatch(i,t=!1){var o;const a=(o=this._univerInstanceService.getFocusedUnit())==null?void 0:o.getUnitId();if(!a)return-1;const s=i.findIndex(l=>l.unitId===a);if(s!==-1){this._matchingModel=i[s];const l=this._matchingModel.moveToNextMatch({stayIfOnMatch:!0,noFocus:t});if(l)return this._markMatch(l),s}return this._moveToNextUnitMatch(s),0}},c.FindReplaceModel=Q([A(2,r.IUniverInstanceService)],c.FindReplaceModel);var D=(n=>(n.ROW="row",n.COLUMN="column",n))(D||{}),T=(n=>(n.VALUE="value",n.FORMULA="formula",n))(T||{}),P=(n=>(n.SUBUNIT="subunit",n.UNIT="unit",n))(P||{});function O(){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 X{constructor(){u(this,"_stateUpdates$",new m.Subject);u(this,"stateUpdates$",this._stateUpdates$.asObservable());u(this,"_state$",new m.BehaviorSubject(O()));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 x=class extends r.Disposable{constructor(e,i){super();u(this,"_providers",new Set);u(this,"_state",new X);u(this,"_model");u(this,"_currentMatch$",new m.BehaviorSubject(null));u(this,"currentMatch$",this._currentMatch$.asObservable());u(this,"_replaceables$",new m.BehaviorSubject([]));u(this,"replaceables$",this._replaceables$.asObservable());u(this,"_focusSignal$",new m.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()}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(c.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=O();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(J,e)}_toggleDisplayRawFormula(e){this._contextService.setContextValue(re.RENDER_RAW_FORMULA_KEY,e)}};x=Q([A(0,r.Inject(r.Injector)),A(1,r.IContextService)],x);const U={id:"ui.command.replace-current-match",type:r.CommandType.COMMAND,handler:n=>n.get(b).replace()},me="CONFIRM_REPLACE_ALL",w={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:me,title:{title:i.t("find-replace.replace.confirm.title")},cancelText:i.t("button.cancel"),confirmText:i.t("button.confirm")}))return!1;const s=await n.get(b).replaceAll(),{success:o,failure:l}=s;return l>0?(o===0?t.show({type:p.MessageType.Error,content:i.t("find-replace.replace.all-failure")}):t.show({type:p.MessageType.Warning,content:i.t("find-replace.replace.partial-success",`${o}`,`${l}`)}),!1):(t.show({type:p.MessageType.Success,content:i.t("find-replace.replace.all-success",`${o}`)}),!0)}},I={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}},E={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}},B={type:r.CommandType.OPERATION,id:"ui.operation.go-to-next-match",handler:n=>(n.get(b).moveToNextMatch(),!0)},j={type:r.CommandType.OPERATION,id:"ui.operation.go-to-previous-match",handler:n=>(n.get(b).moveToPreviousMatch(),!0)},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 ee(n){const{findCompleted:e,localeService:i,matchesCount:t,matchesPosition:a,findString:s,findReplaceService:o,onChange:l,..._}=n,C=e&&t===0?i.t("find-replace.dialog.no-result"):t===0?" ":void 0;return d.jsx(p.InputWithSlot,{autoFocus:!0,placeholder:i.t("find-replace.dialog.find-placeholder"),slot:d.jsx(p.Pager,{loop:!0,text:C,value:a,total:t,onChange:v=>{a===t&&v===1?o.moveToNextMatch():a===1&&v===t||v<a?o.moveToPreviousMatch():o.moveToNextMatch()}}),value:s,onChange:v=>l==null?void 0:l(v),..._})}function te(n,e){const i=f.useCallback(()=>{var a;(a=document.querySelector(".univer-find-input input"))==null||a.focus()},[]),t=f.useCallback(()=>{const a=document.querySelectorAll(".univer-find-replace-dialog-container .univer-select-selection-search-input");return Array.from(a).some(s=>s===document.activeElement)},[]);return f.useImperativeHandle(e,()=>({focus:i,selectHasFocus:t})),f.useEffect(()=>{const a=n.focusSignal$.subscribe(()=>i());return()=>a.unsubscribe()},[n,i]),{focus:i,selectHasFocus:t}}const ve=f.forwardRef(function(e,i){const t=r.useDependency(r.LocaleService),a=r.useDependency(b),s=r.useDependency(r.ICommandService),o=h.useObservable(a.state$,void 0,!0),{findCompleted:l,findString:_,matchesCount:S,matchesPosition:C}=o,v=f.useCallback(()=>{s.executeCommand(E.id)},[s]),$=f.useCallback(R=>a.changeFindString(R),[a]);return te(a,i),d.jsxs(d.Fragment,{children:[d.jsx(ee,{findCompleted:l,className:"univer-find-input",matchesCount:S,matchesPosition:C,findReplaceService:a,localeService:t,findString:_,onChange:$}),d.jsx("div",{className:N.findReplaceExpandContainer,children:d.jsx(p.Button,{type:"text",size:"small",onClick:v,children:t.t("find-replace.dialog.advanced-finding")})})]})}),Se=f.forwardRef(function(e,i){const t=r.useDependency(b),a=r.useDependency(r.LocaleService),s=r.useDependency(r.ICommandService),o=r.useDependency(h.IMessageService),l=h.useObservable(t.currentMatch$,void 0,!0),_=h.useObservable(t.replaceables$,void 0,!0),S=h.useObservable(t.state$,void 0,!0),{matchesCount:C,matchesPosition:v,findString:$,inputtingFindString:R,replaceString:We,caseSensitive:Ge,matchesTheWholeCell:Ve,findDirection:He,findScope:Ke,findBy:qe,findCompleted:V}=S,ze=R.length===0,Ye=C===0||!(l!=null&&l.replaceable),Ze=_.length===0,Je=f.useCallback(g=>t.changeInputtingFindString(g),[t]),Qe=f.useCallback(g=>t.changeReplaceString(g),[t]),{focus:Xe}=te(t,i),et=f.useCallback(()=>{$===R?t.moveToNextMatch():(t.changeFindString(R),t.find())},[$,R,t]),tt=f.useCallback(()=>s.executeCommand(U.id),[s]),nt=f.useCallback(async()=>{await s.executeCommand(w.id),Xe()},[s]),it=f.useCallback(g=>{t.changeFindDirection(g)},[t]),at=f.useCallback(g=>{t.changeFindScope(g)},[t]),st=f.useCallback(g=>{t.changeFindBy(g)},[t]),rt=Me(a),ot=be(a),ct=ye(a);return f.useEffect(()=>{V&&C===0&&o.show({content:a.t("find-replace.dialog.no-match"),type:p.MessageType.Warning,duration:5e3})},[V,C,o,a]),d.jsxs(d.Fragment,{children:[d.jsx(p.FormLayout,{label:a.t("find-replace.dialog.find"),children:d.jsx(ee,{findCompleted:V,className:"univer-find-input",matchesCount:C,matchesPosition:v,findReplaceService:t,localeService:a,findString:R,onChange:Je})}),d.jsx(p.FormLayout,{label:a.t("find-replace.dialog.replace"),children:d.jsx(p.Input,{placeholder:a.t("find-replace.dialog.replace-placeholder"),value:We,onChange:g=>Qe(g)})}),d.jsx(p.FormLayout,{label:a.t("find-replace.dialog.find-direction.title"),children:d.jsx(p.Select,{value:He,options:ot,onChange:it})}),d.jsx(p.FormDualColumnLayout,{children:d.jsxs(d.Fragment,{children:[d.jsx(p.FormLayout,{label:a.t("find-replace.dialog.find-scope.title"),children:d.jsx(p.Select,{value:Ke,options:rt,onChange:at})}),d.jsx(p.FormLayout,{label:a.t("find-replace.dialog.find-by.title"),children:d.jsx(p.Select,{value:qe,options:ct,onChange:st})})]})}),d.jsx(p.FormDualColumnLayout,{children:d.jsxs(d.Fragment,{children:[d.jsx(p.FormLayout,{children:d.jsx(p.Checkbox,{checked:Ge,onChange:g=>{t.changeCaseSensitive(g)},children:a.t("find-replace.dialog.case-sensitive")})}),d.jsx(p.FormLayout,{children:d.jsx(p.Checkbox,{checked:Ve,onChange:g=>{t.changeMatchesTheWholeCell(g)},children:a.t("find-replace.dialog.match-the-whole-cell")})})]})}),d.jsxs("div",{className:N.findReplaceButtonsGroup,children:[d.jsx(p.Button,{type:"primary",onClick:et,disabled:ze,children:a.t("find-replace.dialog.find")}),d.jsxs("span",{className:N.findReplaceButtonsGroupRight,children:[d.jsx(p.Button,{disabled:Ye,onClick:tt,children:a.t("find-replace.dialog.replace")}),d.jsx(p.Button,{disabled:Ze,onClick:nt,children:a.t("find-replace.dialog.replace-all")})]})]})]})});function Ce(){const n=r.useDependency(b),e=r.useDependency(h.ILayoutService),i=r.useDependency(r.IContextService),t=h.useObservable(n.state$,void 0,!0),a=f.useRef(null);f.useEffect(()=>{let _;return a.current&&(_=e.registerContainerElement(a.current)),()=>_==null?void 0:_.dispose()},[e]);const s=f.useRef(null),o=f.useCallback(_=>i.setContextValue(Z,_),[i]),l=f.useCallback(_=>i.setContextValue(Y,_),[i]);return f.useEffect(()=>{var S;const _=m.fromEvent(document,"focusin").subscribe(C=>{var v;C.target&&((v=a.current)!=null&&v.contains(C.target))?o(!0):o(!1),!s.current||!s.current.selectHasFocus()?l(!0):l(!1)});return(S=s.current)==null||S.focus(),o(!0),l(!0),()=>{_.unsubscribe(),o(!1)}},[o,l]),d.jsx("div",{className:N.findReplaceDialogContainer,ref:a,children:t.replaceRevealed?d.jsx(Se,{ref:s}):d.jsx(ve,{ref:s})})}function Me(n){const e=n.getCurrentLocale();return f.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 be(n){const e=n.getCurrentLocale();return f.useMemo(()=>[{label:n.t("find-replace.dialog.find-direction.row"),value:D.ROW},{label:n.t("find-replace.dialog.find-direction.column"),value:D.COLUMN}],[e])}function ye(n){const e=n.getCurrentLocale();return f.useMemo(()=>[{label:n.t("find-replace.dialog.find-by.value"),value:T.VALUE},{label:n.t("find-replace.dialog.find-by.formula"),value:T.FORMULA}],[e])}function F(n){return n.getContextValue(Z)}function Re(n){return n.getContextValue(J)}function ne(n){return n.getContextValue(Y)}const L="7_find-replace-shortcuts";function k(n){return n.getContextValue(r.FOCUSING_SHEET)}function W(n){return!n.getContextValue(r.EDITOR_ACTIVATED)}const Ie={id:I.id,description:"find-replace.shortcut.open-find-dialog",binding:h.KeyCode.F|h.MetaKeys.CTRL_COMMAND,group:L,preconditions(n){return!F(n)&&k(n)&&W(n)}},Fe={id:I.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!F(n)&&k(n)&&W(n)}},De={id:E.id,description:"find-replace.shortcut.open-replace-dialog",binding:h.KeyCode.H|h.MetaKeys.CTRL_COMMAND,mac:h.KeyCode.H|h.MetaKeys.MAC_CTRL,group:L,preconditions(n){return k(n)&&W(n)&&(!F(n)||!Re(n))}},Te={id:B.id,description:"find-replace.shortcut.go-to-next-match",binding:h.KeyCode.ENTER,group:L,priority:1e3,preconditions(n){return ne(n)&&F(n)}},Pe={id:j.id,description:"find-replace.shortcut.go-to-previous-match",binding:h.KeyCode.ENTER|h.MetaKeys.SHIFT,group:L,priority:1e3,preconditions(n){return ne(n)&&F(n)}};function Oe(n){const e=n.get(r.IContextService);return{id:I.id,icon:"SearchIcon",tooltip:"find-replace.toolbar",type:h.MenuItemType.BUTTON,hidden$:h.getMenuHiddenObservable(n,r.UniverInstanceType.UNIVER_SHEET),disabled$:m.combineLatest([e.subscribeContextValue$(r.EDITOR_ACTIVATED),e.subscribeContextValue$(r.FOCUSING_SHEET)]).pipe(m.map(([i,t])=>i||!t))}}const Ee={[h.RibbonStartGroup.OTHERS]:{[I.id]:{order:2,menuItemFactory:Oe}}};var Ne=Object.defineProperty,Le=Object.getOwnPropertyDescriptor,$e=(n,e,i,t)=>{for(var a=t>1?void 0:t?Le(e,i):e,s=n.length-1,o;s>=0;s--)(o=n[s])&&(a=(t?o(e,i,a):o(a))||a);return t&&a&&Ne(e,i,a),a},y=(n,e)=>(i,t)=>e(i,t,n);const ie="DESKTOP_FIND_REPLACE_DIALOG",ae=350,Ae=20,xe=-90;c.FindReplaceController=class extends r.RxDisposable{constructor(i,t,a,s,o,l,_,S,C,v){super();u(this,"_closingListenerDisposable");this._univerInstanceService=i,this._menuManagerService=t,this._shortcutService=a,this._commandService=s,this._findReplaceService=o,this._dialogService=l,this._layoutService=_,this._localeService=S,this._componentManager=C,this._injector=v,this._initCommands(),this._initUI(),this._initShortcuts()}dispose(){var i;super.dispose(),(i=this._closingListenerDisposable)==null||i.dispose(),this._closingListenerDisposable=null}_initCommands(){[I,E,B,j,w,U].forEach(i=>{this.disposeWithMe(this._commandService.registerCommand(i))})}_initShortcuts(){[De,Ie,Fe,Pe,Te].forEach(i=>this.disposeWithMe(this._shortcutService.registerShortcut(i)))}_initUI(){this.disposeWithMe(this._componentManager.register("FindReplaceDialog",Ce)),this.disposeWithMe(this._componentManager.register("SearchIcon",z)),this._menuManagerService.mergeMenu(Ee),this._findReplaceService.stateUpdates$.pipe(m.takeUntil(this.dispose$)).subscribe(i=>{i.revealed===!0&&this._openPanel()})}_openPanel(){this._dialogService.open({id:ie,draggable:!0,width:ae,title:{title:this._localeService.t("find-replace.dialog.title")},children:{label:"FindReplaceDialog"},destroyOnClose:!0,defaultPosition:Ue(),preservePositionOnDestroy:!0,onClose:()=>this.closePanel()}),this._closingListenerDisposable=r.toDisposable(this._univerInstanceService.focused$.pipe(m.takeUntil(this.dispose$)).subscribe(i=>{(!i||!this._univerInstanceService.getUniverSheetInstance(i))&&this.closePanel()}))}closePanel(){this._closingListenerDisposable&&(this._closingListenerDisposable.dispose(),this._closingListenerDisposable=null,this._dialogService.close(ie),this._findReplaceService.terminate(),queueMicrotask(()=>this._layoutService.focus()))}},c.FindReplaceController=$e([y(0,r.IUniverInstanceService),y(1,h.IMenuManagerService),y(2,h.IShortcutService),y(3,r.ICommandService),y(4,b),y(5,h.IDialogService),y(6,h.ILayoutService),y(7,r.Inject(r.LocaleService)),y(8,r.Inject(h.ComponentManager)),y(9,r.Inject(r.Injector))],c.FindReplaceController);function Ue(){const{innerWidth:n}=window;return{x:(n-ae)/2-Ae,y:xe}}var we=Object.defineProperty,Be=Object.getOwnPropertyDescriptor,je=(n,e,i,t)=>{for(var a=t>1?void 0:t?Be(e,i):e,s=n.length-1,o;s>=0;s--)(o=n[s])&&(a=(t?o(e,i,a):o(a))||a);return t&&a&&we(e,i,a),a},se=(n,e)=>(i,t)=>e(i,t,n);const ke="UNIVER_FIND_REPLACE_PLUGIN";c.UniverFindReplacePlugin=(G=class extends r.Plugin{constructor(e=H,i,t){super(),this._config=e,this._injector=i,this._configService=t;const{...a}=r.merge({},H,this._config);this._configService.setConfig(oe,a)}onStarting(){[[c.FindReplaceController],[b,{useClass:x}]].forEach(e=>this._injector.add(e))}onRendered(){this._injector.get(c.FindReplaceController)}},u(G,"pluginName",ke),G),c.UniverFindReplacePlugin=je([se(1,r.Inject(r.Injector)),se(2,r.IConfigService)],c.UniverFindReplacePlugin),c.FindBy=T,c.FindDirection=D,c.FindModel=_e,c.FindReplaceState=X,c.FindScope=P,c.GoToNextMatchOperation=B,c.GoToPreviousMatchOperation=j,c.IFindReplaceService=b,c.OpenFindDialogOperation=I,c.OpenReplaceDialogOperation=E,c.ReplaceAllMatchesCommand=w,c.ReplaceCurrentMatchCommand=U,c.createInitFindReplaceState=O,Object.defineProperty(c,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@univerjs/find-replace",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0-alpha.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "",
|
|
6
6
|
"author": "DreamNum <developer@univer.ai>",
|
|
@@ -50,15 +50,15 @@
|
|
|
50
50
|
"lib"
|
|
51
51
|
],
|
|
52
52
|
"peerDependencies": {
|
|
53
|
-
"react": "
|
|
53
|
+
"react": ">=16.9.0 || >=17 || >=18 || >=19",
|
|
54
54
|
"rxjs": ">=7.0.0"
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
|
-
"@univerjs/icons": "^0.2.
|
|
58
|
-
"@univerjs/core": "0.
|
|
59
|
-
"@univerjs/engine-render": "0.
|
|
60
|
-
"@univerjs/
|
|
61
|
-
"@univerjs/
|
|
57
|
+
"@univerjs/icons": "^0.2.14",
|
|
58
|
+
"@univerjs/core": "0.6.0-alpha.0",
|
|
59
|
+
"@univerjs/engine-render": "0.6.0-alpha.0",
|
|
60
|
+
"@univerjs/ui": "0.6.0-alpha.0",
|
|
61
|
+
"@univerjs/design": "0.6.0-alpha.0"
|
|
62
62
|
},
|
|
63
63
|
"devDependencies": {
|
|
64
64
|
"less": "^4.2.1",
|
|
@@ -66,10 +66,10 @@
|
|
|
66
66
|
"react": "18.3.1",
|
|
67
67
|
"rxjs": "^7.8.1",
|
|
68
68
|
"tailwindcss": "^3.4.17",
|
|
69
|
-
"typescript": "^5.7.
|
|
69
|
+
"typescript": "^5.7.3",
|
|
70
70
|
"vite": "^6.0.7",
|
|
71
71
|
"vitest": "^2.1.8",
|
|
72
|
-
"@univerjs-infra/shared": "0.
|
|
72
|
+
"@univerjs-infra/shared": "0.6.0-alpha.0"
|
|
73
73
|
},
|
|
74
74
|
"scripts": {
|
|
75
75
|
"test": "vitest run",
|