@univerjs/find-replace 0.1.11 → 0.1.12

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.
@@ -1,22 +1,25 @@
1
- import { ICommandService, IContextService, ILogService, IUniverInstanceService, LocaleService, RxDisposable } from '@univerjs/core';
2
- import { ComponentManager, IDialogService, ILayoutService, IMenuService, IShortcutService } from '@univerjs/ui';
1
+ import { ICommandService, IUniverInstanceService, LocaleService, RxDisposable } from '@univerjs/core';
2
+ import { MenuConfig, ComponentManager, IDialogService, ILayoutService, IMenuService, IShortcutService } from '@univerjs/ui';
3
3
  import { Injector } from '@wendellhu/redi';
4
4
  import { IFindReplaceService } from '../services/find-replace.service';
5
5
 
6
+ export interface IUniverFindReplaceConfig {
7
+ menu: MenuConfig;
8
+ }
9
+ export declare const DefaultFindReplaceConfig: {};
6
10
  export declare class FindReplaceController extends RxDisposable {
11
+ private readonly _config;
7
12
  private readonly _univerInstanceService;
8
13
  private readonly _menuService;
9
14
  private readonly _shortcutService;
10
15
  private readonly _commandService;
11
16
  private readonly _findReplaceService;
12
- private readonly _logService;
13
17
  private readonly _dialogService;
14
- private readonly _contextService;
15
18
  private readonly _layoutService;
16
19
  private readonly _localeService;
17
20
  private readonly _componentManager;
18
21
  private readonly _injector;
19
- constructor(_univerInstanceService: IUniverInstanceService, _menuService: IMenuService, _shortcutService: IShortcutService, _commandService: ICommandService, _findReplaceService: IFindReplaceService, _logService: ILogService, _dialogService: IDialogService, _contextService: IContextService, _layoutService: ILayoutService, _localeService: LocaleService, _componentManager: ComponentManager, _injector: Injector);
22
+ constructor(_config: Partial<IUniverFindReplaceConfig>, _univerInstanceService: IUniverInstanceService, _menuService: IMenuService, _shortcutService: IShortcutService, _commandService: ICommandService, _findReplaceService: IFindReplaceService, _dialogService: IDialogService, _layoutService: ILayoutService, _localeService: LocaleService, _componentManager: ComponentManager, _injector: Injector);
20
23
  private _initCommands;
21
24
  private _initShortcuts;
22
25
  private _initUI;
@@ -1,10 +1,12 @@
1
1
  import { LocaleService, Plugin } from '@univerjs/core';
2
2
  import { Injector } from '@wendellhu/redi';
3
+ import { IUniverFindReplaceConfig } from './controllers/find-replace.controller';
3
4
 
4
5
  export declare class UniverFindReplacePlugin extends Plugin {
5
- protected readonly _injector: Injector;
6
+ private readonly _config;
7
+ readonly _injector: Injector;
6
8
  private readonly _localeService;
7
9
  static pluginName: string;
8
- constructor(_injector: Injector, _localeService: LocaleService);
10
+ constructor(_config: Partial<IUniverFindReplaceConfig>, _injector: Injector, _localeService: LocaleService);
9
11
  onStarting(injector: Injector): void;
10
12
  }
package/lib/umd/index.js CHANGED
@@ -1,4 +1,4 @@
1
- (function(d,r){typeof exports=="object"&&typeof module<"u"?r(exports,require("@univerjs/core"),require("@wendellhu/redi"),require("@univerjs/ui"),require("rxjs"),require("@univerjs/engine-render"),require("react"),require("@univerjs/design"),require("@wendellhu/redi/react-bindings")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@wendellhu/redi","@univerjs/ui","rxjs","@univerjs/engine-render","react","@univerjs/design","@wendellhu/redi/react-bindings"],r):(d=typeof globalThis<"u"?globalThis:d||self,r(d.UniverFindReplace={},d.UniverCore,d["@wendellhu/redi"],d.UniverUi,d.rxjs,d.UniverEngineRender,d.React,d.UniverDesign,d["@wendellhu/redi/react-bindings"]))})(this,function(d,r,R,p,S,he,c,f,F){"use strict";var bt=Object.defineProperty;var yt=(d,r,R)=>r in d?bt(d,r,{enumerable:!0,configurable:!0,writable:!0,value:R}):d[r]=R;var h=(d,r,R)=>(yt(d,typeof r!="symbol"?r+"":r,R),R);var H;var b=function(){return b=Object.assign||function(n){for(var e,i=1,t=arguments.length;i<t;i++){e=arguments[i];for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&(n[a]=e[a])}return n},b.apply(this,arguments)},ue=function(n,e){var i={};for(var t in n)Object.prototype.hasOwnProperty.call(n,t)&&e.indexOf(t)<0&&(i[t]=n[t]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var 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=c.forwardRef(function(n,e){var i=n.icon,t=n.id,a=n.className,s=n.extend,o=ue(n,["icon","id","className","extend"]),l="univerjs-icon univerjs-icon-".concat(t," ").concat(a||"").trim(),_=c.useRef("_".concat(_e()));return z(i,"".concat(t),{defIds:i.defIds,idSuffix:_.current},b({ref:e,className:l},o),s)});function z(n,e,i,t,a){return c.createElement(n.tag,b(b({key:e},pe(n,i,a)),t),(fe(n,i).children||[]).map(function(s,o){return z(s,"".concat(e,"-").concat(n.tag,"-").concat(o),i,void 0,a)}))}function pe(n,e,i){var t=b({},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 fe(n,e){var i,t=e.defIds;return!t||t.length===0?n:n.tag==="defs"&&(!((i=n.children)===null||i===void 0)&&i.length)?b(b({},n),{children:n.children.map(function(a){return typeof a.attrs.id=="string"&&t&&t.indexOf(a.attrs.id)>-1?b(b({},a),{attrs:b(b({},a.attrs),{id:a.attrs.id+e.idSuffix})}):a})}):n}function _e(){return Math.random().toString(36).substring(2,8)}K.displayName="UniverIcon";var ge={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"mask",attrs:{id:"mask0_217_40",style:{maskType:"alpha"},width:17,height:17,x:0,y:0,maskUnits:"userSpaceOnUse"},children:[{tag:"path",attrs:{fill:"#D9D9D9",d:"M0.9 0.09H16.9V16.09H0.9z"}}]},{tag:"g",attrs:{mask:"url(#mask0_217_40)"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M2.39551 7.37266C2.39551 4.18105 4.98281 1.59375 8.17441 1.59375C11.366 1.59375 13.9533 4.18105 13.9533 7.37266C13.9533 8.72342 13.4898 9.96603 12.7133 10.95L15.1964 13.4331C15.4619 13.6986 15.4619 14.1291 15.1964 14.3946C14.9309 14.6601 14.5004 14.6601 14.2349 14.3946L11.7518 11.9115C10.7678 12.6881 9.52525 13.1516 8.17441 13.1516C4.98281 13.1516 2.39551 10.5642 2.39551 7.37266ZM8.17441 2.95349C5.73378 2.95349 3.75525 4.93202 3.75525 7.37266C3.75525 9.81333 5.73378 11.7918 8.17441 11.7918C10.6151 11.7918 12.5936 9.81333 12.5936 7.37266C12.5936 4.93202 10.6151 2.95349 8.17441 2.95349Z",fillRule:"evenodd",clipRule:"evenodd"}}]}]},Y=c.forwardRef(function(n,e){return c.createElement(K,Object.assign({},n,{id:"search-single-16",ref:e,icon:ge}))});Y.displayName="SearchSingle16";const Z="FIND_REPLACE_INPUT_FOCUS",J="FIND_REPLACE_DIALOG_FOCUS",Q="FIND_REPLACE_REPLACE_REVEALED";var me=Object.defineProperty,ve=Object.getOwnPropertyDescriptor,X=(n,e,i,t)=>{for(var a=t>1?void 0:t?ve(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&&me(e,i,a),a},O=(n,e)=>(i,t)=>e(i,t,n);class Se extends r.Disposable{}const y=R.createIdentifier("find-replace.service");function Ce(n){return typeof n.findString<"u"||typeof n.inputtingFindString<"u"||typeof n.findDirection<"u"||typeof n.matchesTheWholeCell<"u"||typeof n.caseSensitive<"u"||typeof n.findScope<"u"||typeof n.findBy<"u"}let U=class extends r.Disposable{constructor(e,i,t,a){super();h(this,"currentMatch$",new S.BehaviorSubject(null));h(this,"replaceables$",new S.BehaviorSubject([]));h(this,"_findModels",[]);h(this,"_matchingModel",null);h(this,"_matches",[]);h(this,"_currentSearchingDisposables",null);this._state=e,this._providers=i,this._univerInstanceService=t,this._logService=a,this.disposeWithMe(this._state.stateUpdates$.pipe(S.throttleTime(200,void 0,{leading:!0,trailing:!0})).subscribe(async s=>{const o=this._state.state;Ce(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({...B(),revealed:!1})}async start(){if(!this._state.findString)return{results:[]};const e=await this._startSearching();return this._state.changeState({findCompleted:!0}),e}async _startSearching(){if(!this._state.findString)return{results:[]};const e=Array.from(this._providers),i=this._findModels=(await Promise.all(e.map(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();if(this.replaceables$.next(t.filter(s=>s.replaceable)),!t.length)return this._state.changeState({matchesCount:0,matchesPosition:0}),{results:[]};const a=this._moveToInitialMatch(i,t);return this._state.changeState({matchesCount:t.length,matchesPosition:a+1}),{results:t}}_stopSearching(){var e;this._providers.forEach(i=>i.terminate()),this._findModels=[],this._matches=[],this._matchingModel=null,(e=this._currentSearchingDisposables)==null||e.dispose(),this._currentSearchingDisposables=null,this.currentMatch$.next(null),this.replaceables$.next([]),this._state.changeState({findCompleted:!1,matchesCount:0,matchesPosition:0})}_subscribeToModelsChanges(e){const i=this._currentSearchingDisposables=new r.DisposableCollection,t=S.combineLatest(e.map(a=>a.matchesUpdate$)).pipe(S.debounceTime(220)).subscribe(([...a])=>{const s=this._matches=a.flat();if(s.length){const o=this._moveToInitialMatch(this._findModels,s,!0);this._state.changeState({matchesCount:s.length,matchesPosition:o+1}),this.replaceables$.next(s.filter(l=>l.replaceable))}else this._state.changeState({matchesCount:0,matchesPosition:0}),this.replaceables$.next([])});e.forEach(a=>i.add(r.toDisposable(a.activelyChangingMatch$.subscribe(s=>{const o=this._matches.findIndex(l=>l===s);this._state.changeState({matchesPosition:o+1})})))),i.add(r.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,a)=>(t.success+=a.success,t.failure+=a.failure,t),{success:0,failure:0}));return e.failure===0&&this._stopSearching(),e}getCurrentMatch(){return this._state.matchesPosition>0?this._matches[this._state.matchesPosition-1]:null}moveToNextMatch(){if(!this._matchingModel)return;const e=this._findModels.length===1,i=this._matchingModel.moveToNextMatch({loop:e});if(i){const t=this._matches.findIndex(a=>a===i);this.currentMatch$.next(i),this._state.changeState({matchesPosition:t+1})}else{const t=this._findModels.findIndex(l=>l===this._matchingModel),a=this._findModels[(t+1)%this._findModels.length],s=a.moveToNextMatch(),o=this._matches.findIndex(l=>l===s);this.currentMatch$.next(s),this._matchingModel=a,this._state.changeState({matchesPosition:o+1})}}moveToPreviousMatch(){if(!this._matchingModel)return;const e=this._findModels.length===1,i=this._matchingModel.moveToPreviousMatch({loop:e});if(i){const t=this._matches.findIndex(a=>a===i);this.currentMatch$.next(i),this._state.changeState({matchesPosition:t+1})}else{const t=this._findModels.findIndex(l=>l===this._matchingModel),a=this._findModels[(t-1+this._findModels.length)%this._findModels.length],s=a.moveToPreviousMatch(),o=this._matches.findIndex(l=>l===s);this.currentMatch$.next(s),this._matchingModel=a,this._state.changeState({matchesPosition:o+1})}}_moveToInitialMatch(e,i,t=!1){var _;const a=(_=this._univerInstanceService.getFocusedUnit())==null?void 0:_.getUnitId();if(!a)return-1;const s=e.find(m=>m.unitId===a);if(s){this._matchingModel=s;const m=s.moveToNextMatch({stayIfOnMatch:!0,noFocus:t}),C=i.findIndex(v=>v===m);return this.currentMatch$.next(m),C}this._matchingModel=e[0];const o=this._matchingModel.moveToNextMatch({noFocus:t}),l=this._matches.findIndex(m=>m===o);return this.currentMatch$.next(o),l}};U=X([O(2,r.IUniverInstanceService),O(3,r.ILogService)],U);var P=(n=>(n.ROW="row",n.COLUMN="column",n))(P||{}),T=(n=>(n.VALUE="value",n.FORMULA="formula",n))(T||{}),E=(n=>(n.SUBUNIT="subunit",n.UNIT="unit",n))(E||{});function B(){return{caseSensitive:!1,findBy:"value",findCompleted:!1,findDirection:"row",findScope:"subunit",findString:"",inputtingFindString:"",matchesCount:0,matchesPosition:0,matchesTheWholeCell:!1,replaceRevealed:!1,replaceString:"",revealed:!0}}class Re{constructor(){h(this,"_stateUpdates$",new S.Subject);h(this,"stateUpdates$",this._stateUpdates$.asObservable());h(this,"_state$",new S.BehaviorSubject(B()));h(this,"state$",this._state$.asObservable());h(this,"_findString","");h(this,"_inputtingFindString","");h(this,"_replaceString","");h(this,"_revealed",!1);h(this,"_replaceRevealed",!1);h(this,"_matchesPosition",0);h(this,"_matchesCount",0);h(this,"_caseSensitive",!0);h(this,"_matchesTheWholeCell",!1);h(this,"_findDirection","row");h(this,"_findScope","subunit");h(this,"_findBy","value");h(this,"_findCompleted",!1)}get state(){return this._state$.getValue()}get inputtingFindString(){return this._inputtingFindString}get findString(){return this._findString}get revealed(){return this._revealed}get replaceRevealed(){return this._replaceRevealed}get matchesPosition(){return this._matchesPosition}get matchesCount(){return this._matchesCount}get replaceString(){return this._replaceString}get caseSensitive(){return this._caseSensitive}get matchesTheWholeCell(){return this._matchesTheWholeCell}get findDirection(){return this._findDirection}get findScope(){return this._findScope}get findBy(){return this._findBy}get findCompleted(){return this._findCompleted}changeState(e){let i=!1;const t={};typeof e.findString<"u"&&e.findString!==this._findString&&(this._findString=e.findString,t.findString=this._findString,i=!0),typeof e.revealed<"u"&&e.revealed!==this._revealed&&(this._revealed=e.revealed,t.revealed=e.revealed,i=!0),typeof e.replaceRevealed<"u"&&e.replaceRevealed!==this._replaceRevealed&&(this._replaceRevealed=e.replaceRevealed,t.replaceRevealed=e.replaceRevealed,i=!0),typeof e.replaceString<"u"&&e.replaceString!==this._replaceString&&(this._replaceString=e.replaceString,t.replaceString=e.replaceString,i=!0),typeof e.matchesCount<"u"&&e.matchesCount!==this._matchesCount&&(this._matchesCount=e.matchesCount,t.matchesCount=e.matchesCount,i=!0),typeof e.matchesPosition<"u"&&e.matchesPosition!==this._matchesPosition&&(this._matchesPosition=e.matchesPosition,t.matchesPosition=e.matchesPosition,i=!0),typeof e.findBy<"u"&&e.findBy!==this._findBy&&(this._findBy=e.findBy,t.findBy=e.findBy,i=!0),typeof e.findScope<"u"&&e.findScope!==this._findScope&&(this._findScope=e.findScope,t.findScope=e.findScope,i=!0),typeof e.findDirection<"u"&&e.findDirection!==this._findDirection&&(this._findDirection=e.findDirection,t.findDirection=e.findDirection,i=!0),typeof e.caseSensitive<"u"&&e.caseSensitive!==this._caseSensitive&&(this._caseSensitive=e.caseSensitive,t.caseSensitive=e.caseSensitive,i=!0),typeof e.matchesTheWholeCell<"u"&&e.matchesTheWholeCell!==this._matchesTheWholeCell&&(this._matchesTheWholeCell=e.matchesTheWholeCell,t.matchesTheWholeCell=e.matchesTheWholeCell,i=!0),typeof e.inputtingFindString<"u"&&e.inputtingFindString!==this._inputtingFindString&&(this._inputtingFindString=e.inputtingFindString,t.inputtingFindString=e.inputtingFindString,i=!0),typeof e.findCompleted<"u"&&e.findCompleted!==this._findCompleted&&(this._findCompleted=e.findCompleted,t.findCompleted=e.findCompleted,i=!0),i&&(this._state$.next({caseSensitive:this._caseSensitive,findBy:this._findBy,findCompleted:this._findCompleted,findDirection:this._findDirection,findScope:this._findScope,findString:this._findString,inputtingFindString:this._inputtingFindString,matchesCount:this._matchesCount,matchesPosition:this._matchesPosition,matchesTheWholeCell:this._matchesTheWholeCell,replaceRevealed:this._replaceRevealed,revealed:this._revealed}),this._stateUpdates$.next(t))}}let k=class extends r.Disposable{constructor(e,i){super();h(this,"_providers",new Set);h(this,"_state",new Re);h(this,"_model");h(this,"_currentMatch$",new S.BehaviorSubject(null));h(this,"currentMatch$",this._currentMatch$.asObservable());h(this,"_replaceables$",new S.BehaviorSubject([]));h(this,"replaceables$",this._replaceables$.asObservable());h(this,"_focusSignal$",new S.Subject);h(this,"focusSignal$",this._focusSignal$.asObservable());this._injector=e,this._contextService=i}get stateUpdates$(){return this._state.stateUpdates$}get state$(){return this._state.state$}get revealed(){return this._state.revealed}get replaceRevealed(){return this._state.replaceRevealed}dispose(){super.dispose(),this._currentMatch$.next(null),this._currentMatch$.complete(),this._replaceables$.next([]),this._replaceables$.complete(),this._focusSignal$.complete()}getCurrentMatch(){var e;return(e=this._model)==null?void 0:e.getCurrentMatch()}getFindString(){return this._state.findString}changeFindString(e){this._state.changeState({findString:e})}focusFindInput(){this._focusSignal$.next()}changeInputtingFindString(e){e?this._state.changeState({inputtingFindString:e}):this._state.changeState({inputtingFindString:"",findString:""})}changeReplaceString(e){this._state.changeState({replaceString:e})}changeMatchesTheWholeCell(e){this._state.changeState({matchesTheWholeCell:e})}changeCaseSensitive(e){this._state.changeState({caseSensitive:e})}changeFindBy(e){this._state.changeState({findBy:e}),this._toggleDisplayRawFormula(e==="formula")}changeFindScope(e){this._state.changeState({findScope:e})}changeFindDirection(e){this._state.changeState({findDirection:e})}moveToNextMatch(){this._model&&(this._state.replaceRevealed&&!this._model.searched?(this._state.changeState({findString:this._state.inputtingFindString}),this._model.start()):this._model.moveToNextMatch(),this._focusSignal$.next())}moveToPreviousMatch(){this._model&&(this._state.replaceRevealed&&!this._model.searched?(this._state.changeState({findString:this._state.inputtingFindString}),this._model.start()):this._model.moveToPreviousMatch(),this._focusSignal$.next())}async replace(){return this._model?this._model.replace():!1}async replaceAll(){if(!this._model)throw new Error("[FindReplaceService] replaceAll: model is not initialized!");return this._model.replaceAll()}revealReplace(){this._state.changeState({replaceRevealed:!0,inputtingFindString:this._state.findString}),this._toggleRevealReplace(!0)}start(e=!1){if(this._providers.size===0)return!1;this._model=this._injector.createInstance(U,this._state,this._providers),this._model.currentMatch$.subscribe(t=>this._currentMatch$.next(t)),this._model.replaceables$.subscribe(t=>this._replaceables$.next(t));const i=B();return e&&(i.replaceRevealed=!0),this._state.changeState(i),this._toggleRevealReplace(e),!0}find(){var e;(e=this._model)==null||e.start()}terminate(){var e;(e=this._model)==null||e.dispose(),this._model=null,this._toggleDisplayRawFormula(!1),this._toggleRevealReplace(!1)}registerFindReplaceProvider(e){return this._providers.add(e),r.toDisposable(()=>this._providers.delete(e))}_toggleRevealReplace(e){this._contextService.setContextValue(Q,e)}_toggleDisplayRawFormula(e){this._contextService.setContextValue(he.RENDER_RAW_FORMULA_KEY,e)}};k=X([O(0,R.Inject(R.Injector)),O(1,r.IContextService)],k);const N={id:"ui.operation.open-find-dialog",type:r.CommandType.OPERATION,handler:n=>{const e=n.get(y);return e.revealed?e.focusFindInput():e.start(),!0}},W={id:"ui.operation.open-replace-dialog",type:r.CommandType.OPERATION,handler:n=>{const e=n.get(y);return e.revealed?e.replaceRevealed?e.focusFindInput():e.revealReplace():e.start(!0),!0}},q={type:r.CommandType.OPERATION,id:"ui.operation.go-to-next-match",handler:n=>(n.get(y).moveToNextMatch(),!0)},ee={type:r.CommandType.OPERATION,id:"ui.operation.go-to-previous-match",handler:n=>(n.get(y).moveToPreviousMatch(),!0)};var te={exports:{}},w={};/**
1
+ (function(l,r){typeof exports=="object"&&typeof module<"u"?r(exports,require("@univerjs/core"),require("@wendellhu/redi"),require("@univerjs/ui"),require("rxjs"),require("@univerjs/engine-render"),require("react"),require("@univerjs/design"),require("@wendellhu/redi/react-bindings")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@wendellhu/redi","@univerjs/ui","rxjs","@univerjs/engine-render","react","@univerjs/design","@wendellhu/redi/react-bindings"],r):(l=typeof globalThis<"u"?globalThis:l||self,r(l.UniverFindReplace={},l.UniverCore,l["@wendellhu/redi"],l.UniverUi,l.rxjs,l.UniverEngineRender,l.React,l.UniverDesign,l["@wendellhu/redi/react-bindings"]))})(this,function(l,r,m,f,C,ue,d,p,M){"use strict";var yt=Object.defineProperty;var Mt=(l,r,m)=>r in l?yt(l,r,{enumerable:!0,configurable:!0,writable:!0,value:m}):l[r]=m;var h=(l,r,m)=>(Mt(l,typeof r!="symbol"?r+"":r,m),m);var H;var b=function(){return b=Object.assign||function(n){for(var e,i=1,t=arguments.length;i<t;i++){e=arguments[i];for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&(n[a]=e[a])}return n},b.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 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=d.forwardRef(function(n,e){var i=n.icon,t=n.id,a=n.className,s=n.extend,o=fe(n,["icon","id","className","extend"]),c="univerjs-icon univerjs-icon-".concat(t," ").concat(a||"").trim(),_=d.useRef("_".concat(ge()));return z(i,"".concat(t),{defIds:i.defIds,idSuffix:_.current},b({ref:e,className:c},o),s)});function z(n,e,i,t,a){return d.createElement(n.tag,b(b({key:e},pe(n,i,a)),t),(_e(n,i).children||[]).map(function(s,o){return z(s,"".concat(e,"-").concat(n.tag,"-").concat(o),i,void 0,a)}))}function pe(n,e,i){var t=b({},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],c=s[1];typeof c=="string"&&(t[o]=c.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)?b(b({},n),{children:n.children.map(function(a){return typeof a.attrs.id=="string"&&t&&t.indexOf(a.attrs.id)>-1?b(b({},a),{attrs:b(b({},a.attrs),{id:a.attrs.id+e.idSuffix})}):a})}):n}function ge(){return Math.random().toString(36).substring(2,8)}K.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"}}]}]},Y=d.forwardRef(function(n,e){return d.createElement(K,Object.assign({},n,{id:"search-single-16",ref:e,icon:me}))});Y.displayName="SearchSingle16";const Z="FIND_REPLACE_INPUT_FOCUS",J="FIND_REPLACE_DIALOG_FOCUS",Q="FIND_REPLACE_REPLACE_REVEALED";var ve=Object.defineProperty,Se=Object.getOwnPropertyDescriptor,X=(n,e,i,t)=>{for(var a=t>1?void 0:t?Se(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&&ve(e,i,a),a},x=(n,e)=>(i,t)=>e(i,t,n);class Ce extends r.Disposable{}const y=m.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 r.Disposable{constructor(e,i,t,a){super();h(this,"currentMatch$",new C.BehaviorSubject(null));h(this,"replaceables$",new C.BehaviorSubject([]));h(this,"_findModels",[]);h(this,"_matchingModel",null);h(this,"_matches",[]);h(this,"_currentSearchingDisposables",null);this._state=e,this._providers=i,this._univerInstanceService=t,this._logService=a,this.disposeWithMe(this._state.stateUpdates$.pipe(C.throttleTime(200,void 0,{leading:!0,trailing:!0})).subscribe(async s=>{const o=this._state.state;Re(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({...B(),revealed:!1})}async start(){if(!this._state.findString)return{results:[]};const e=await this._startSearching();return this._state.changeState({findCompleted:!0}),e}async _startSearching(){if(!this._state.findString)return{results:[]};const e=Array.from(this._providers),i=this._findModels=(await Promise.all(e.map(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();if(this.replaceables$.next(t.filter(s=>s.replaceable)),!t.length)return this._state.changeState({matchesCount:0,matchesPosition:0}),{results:[]};const a=this._moveToInitialMatch(i,t);return this._state.changeState({matchesCount:t.length,matchesPosition:a+1}),{results:t}}_stopSearching(){var e;this._providers.forEach(i=>i.terminate()),this._findModels=[],this._matches=[],this._matchingModel=null,(e=this._currentSearchingDisposables)==null||e.dispose(),this._currentSearchingDisposables=null,this.currentMatch$.next(null),this.replaceables$.next([]),this._state.changeState({findCompleted:!1,matchesCount:0,matchesPosition:0})}_subscribeToModelsChanges(e){const i=this._currentSearchingDisposables=new r.DisposableCollection,t=C.combineLatest(e.map(a=>a.matchesUpdate$)).pipe(C.debounceTime(220)).subscribe(([...a])=>{const s=this._matches=a.flat();if(s.length){const o=this._moveToInitialMatch(this._findModels,s,!0);this._state.changeState({matchesCount:s.length,matchesPosition:o+1}),this.replaceables$.next(s.filter(c=>c.replaceable))}else this._state.changeState({matchesCount:0,matchesPosition:0}),this.replaceables$.next([])});e.forEach(a=>i.add(r.toDisposable(a.activelyChangingMatch$.subscribe(s=>{const o=this._matches.findIndex(c=>c===s);this._state.changeState({matchesPosition:o+1})})))),i.add(r.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,a)=>(t.success+=a.success,t.failure+=a.failure,t),{success:0,failure:0}));return e.failure===0&&this._stopSearching(),e}getCurrentMatch(){return this._state.matchesPosition>0?this._matches[this._state.matchesPosition-1]:null}moveToNextMatch(){if(!this._matchingModel)return;const e=this._findModels.length===1,i=this._matchingModel.moveToNextMatch({loop:e});if(i){const t=this._matches.findIndex(a=>a===i);this.currentMatch$.next(i),this._state.changeState({matchesPosition:t+1})}else{const t=this._findModels.findIndex(c=>c===this._matchingModel),a=this._findModels[(t+1)%this._findModels.length],s=a.moveToNextMatch(),o=this._matches.findIndex(c=>c===s);this.currentMatch$.next(s),this._matchingModel=a,this._state.changeState({matchesPosition:o+1})}}moveToPreviousMatch(){if(!this._matchingModel)return;const e=this._findModels.length===1,i=this._matchingModel.moveToPreviousMatch({loop:e});if(i){const t=this._matches.findIndex(a=>a===i);this.currentMatch$.next(i),this._state.changeState({matchesPosition:t+1})}else{const t=this._findModels.findIndex(c=>c===this._matchingModel),a=this._findModels[(t-1+this._findModels.length)%this._findModels.length],s=a.moveToPreviousMatch(),o=this._matches.findIndex(c=>c===s);this.currentMatch$.next(s),this._matchingModel=a,this._state.changeState({matchesPosition:o+1})}}_moveToInitialMatch(e,i,t=!1){var _;const a=(_=this._univerInstanceService.getFocusedUnit())==null?void 0:_.getUnitId();if(!a)return-1;const s=e.find(v=>v.unitId===a);if(s){this._matchingModel=s;const v=s.moveToNextMatch({stayIfOnMatch:!0,noFocus:t}),R=i.findIndex(S=>S===v);return this.currentMatch$.next(v),R}this._matchingModel=e[0];const o=this._matchingModel.moveToNextMatch({noFocus:t}),c=this._matches.findIndex(v=>v===o);return this.currentMatch$.next(o),c}};U=X([x(2,r.IUniverInstanceService),x(3,r.ILogService)],U);var O=(n=>(n.ROW="row",n.COLUMN="column",n))(O||{}),P=(n=>(n.VALUE="value",n.FORMULA="formula",n))(P||{}),T=(n=>(n.SUBUNIT="subunit",n.UNIT="unit",n))(T||{});function B(){return{caseSensitive:!1,findBy:"value",findCompleted:!1,findDirection:"row",findScope:"subunit",findString:"",inputtingFindString:"",matchesCount:0,matchesPosition:0,matchesTheWholeCell:!1,replaceRevealed:!1,replaceString:"",revealed:!0}}class be{constructor(){h(this,"_stateUpdates$",new C.Subject);h(this,"stateUpdates$",this._stateUpdates$.asObservable());h(this,"_state$",new C.BehaviorSubject(B()));h(this,"state$",this._state$.asObservable());h(this,"_findString","");h(this,"_inputtingFindString","");h(this,"_replaceString","");h(this,"_revealed",!1);h(this,"_replaceRevealed",!1);h(this,"_matchesPosition",0);h(this,"_matchesCount",0);h(this,"_caseSensitive",!0);h(this,"_matchesTheWholeCell",!1);h(this,"_findDirection","row");h(this,"_findScope","subunit");h(this,"_findBy","value");h(this,"_findCompleted",!1)}get state(){return this._state$.getValue()}get inputtingFindString(){return this._inputtingFindString}get findString(){return this._findString}get revealed(){return this._revealed}get replaceRevealed(){return this._replaceRevealed}get matchesPosition(){return this._matchesPosition}get matchesCount(){return this._matchesCount}get replaceString(){return this._replaceString}get caseSensitive(){return this._caseSensitive}get matchesTheWholeCell(){return this._matchesTheWholeCell}get findDirection(){return this._findDirection}get findScope(){return this._findScope}get findBy(){return this._findBy}get findCompleted(){return this._findCompleted}changeState(e){let i=!1;const t={};typeof e.findString<"u"&&e.findString!==this._findString&&(this._findString=e.findString,t.findString=this._findString,i=!0),typeof e.revealed<"u"&&e.revealed!==this._revealed&&(this._revealed=e.revealed,t.revealed=e.revealed,i=!0),typeof e.replaceRevealed<"u"&&e.replaceRevealed!==this._replaceRevealed&&(this._replaceRevealed=e.replaceRevealed,t.replaceRevealed=e.replaceRevealed,i=!0),typeof e.replaceString<"u"&&e.replaceString!==this._replaceString&&(this._replaceString=e.replaceString,t.replaceString=e.replaceString,i=!0),typeof e.matchesCount<"u"&&e.matchesCount!==this._matchesCount&&(this._matchesCount=e.matchesCount,t.matchesCount=e.matchesCount,i=!0),typeof e.matchesPosition<"u"&&e.matchesPosition!==this._matchesPosition&&(this._matchesPosition=e.matchesPosition,t.matchesPosition=e.matchesPosition,i=!0),typeof e.findBy<"u"&&e.findBy!==this._findBy&&(this._findBy=e.findBy,t.findBy=e.findBy,i=!0),typeof e.findScope<"u"&&e.findScope!==this._findScope&&(this._findScope=e.findScope,t.findScope=e.findScope,i=!0),typeof e.findDirection<"u"&&e.findDirection!==this._findDirection&&(this._findDirection=e.findDirection,t.findDirection=e.findDirection,i=!0),typeof e.caseSensitive<"u"&&e.caseSensitive!==this._caseSensitive&&(this._caseSensitive=e.caseSensitive,t.caseSensitive=e.caseSensitive,i=!0),typeof e.matchesTheWholeCell<"u"&&e.matchesTheWholeCell!==this._matchesTheWholeCell&&(this._matchesTheWholeCell=e.matchesTheWholeCell,t.matchesTheWholeCell=e.matchesTheWholeCell,i=!0),typeof e.inputtingFindString<"u"&&e.inputtingFindString!==this._inputtingFindString&&(this._inputtingFindString=e.inputtingFindString,t.inputtingFindString=e.inputtingFindString,i=!0),typeof e.findCompleted<"u"&&e.findCompleted!==this._findCompleted&&(this._findCompleted=e.findCompleted,t.findCompleted=e.findCompleted,i=!0),i&&(this._state$.next({caseSensitive:this._caseSensitive,findBy:this._findBy,findCompleted:this._findCompleted,findDirection:this._findDirection,findScope:this._findScope,findString:this._findString,inputtingFindString:this._inputtingFindString,matchesCount:this._matchesCount,matchesPosition:this._matchesPosition,matchesTheWholeCell:this._matchesTheWholeCell,replaceRevealed:this._replaceRevealed,revealed:this._revealed}),this._stateUpdates$.next(t))}}let k=class extends r.Disposable{constructor(e,i){super();h(this,"_providers",new Set);h(this,"_state",new be);h(this,"_model");h(this,"_currentMatch$",new C.BehaviorSubject(null));h(this,"currentMatch$",this._currentMatch$.asObservable());h(this,"_replaceables$",new C.BehaviorSubject([]));h(this,"replaceables$",this._replaceables$.asObservable());h(this,"_focusSignal$",new C.Subject);h(this,"focusSignal$",this._focusSignal$.asObservable());this._injector=e,this._contextService=i}get stateUpdates$(){return this._state.stateUpdates$}get state$(){return this._state.state$}get revealed(){return this._state.revealed}get replaceRevealed(){return this._state.replaceRevealed}dispose(){super.dispose(),this._currentMatch$.next(null),this._currentMatch$.complete(),this._replaceables$.next([]),this._replaceables$.complete(),this._focusSignal$.complete()}getCurrentMatch(){var e;return(e=this._model)==null?void 0:e.getCurrentMatch()}getFindString(){return this._state.findString}changeFindString(e){this._state.changeState({findString:e})}focusFindInput(){this._focusSignal$.next()}changeInputtingFindString(e){e?this._state.changeState({inputtingFindString:e}):this._state.changeState({inputtingFindString:"",findString:""})}changeReplaceString(e){this._state.changeState({replaceString:e})}changeMatchesTheWholeCell(e){this._state.changeState({matchesTheWholeCell:e})}changeCaseSensitive(e){this._state.changeState({caseSensitive:e})}changeFindBy(e){this._state.changeState({findBy:e}),this._toggleDisplayRawFormula(e==="formula")}changeFindScope(e){this._state.changeState({findScope:e})}changeFindDirection(e){this._state.changeState({findDirection:e})}moveToNextMatch(){this._model&&(this._state.replaceRevealed&&!this._model.searched?(this._state.changeState({findString:this._state.inputtingFindString}),this._model.start()):this._model.moveToNextMatch(),this._focusSignal$.next())}moveToPreviousMatch(){this._model&&(this._state.replaceRevealed&&!this._model.searched?(this._state.changeState({findString:this._state.inputtingFindString}),this._model.start()):this._model.moveToPreviousMatch(),this._focusSignal$.next())}async replace(){return this._model?this._model.replace():!1}async replaceAll(){if(!this._model)throw new Error("[FindReplaceService] replaceAll: model is not initialized!");return this._model.replaceAll()}revealReplace(){this._state.changeState({replaceRevealed:!0,inputtingFindString:this._state.findString}),this._toggleRevealReplace(!0)}start(e=!1){if(this._providers.size===0)return!1;this._model=this._injector.createInstance(U,this._state,this._providers),this._model.currentMatch$.subscribe(t=>this._currentMatch$.next(t)),this._model.replaceables$.subscribe(t=>this._replaceables$.next(t));const i=B();return e&&(i.replaceRevealed=!0),this._state.changeState(i),this._toggleRevealReplace(e),!0}find(){var e;(e=this._model)==null||e.start()}terminate(){var e;(e=this._model)==null||e.dispose(),this._model=null,this._toggleDisplayRawFormula(!1),this._toggleRevealReplace(!1)}registerFindReplaceProvider(e){return this._providers.add(e),r.toDisposable(()=>this._providers.delete(e))}_toggleRevealReplace(e){this._contextService.setContextValue(Q,e)}_toggleDisplayRawFormula(e){this._contextService.setContextValue(ue.RENDER_RAW_FORMULA_KEY,e)}};k=X([x(0,m.Inject(m.Injector)),x(1,r.IContextService)],k);const E={id:"ui.operation.open-find-dialog",type:r.CommandType.OPERATION,handler:n=>{const e=n.get(y);return e.revealed?e.focusFindInput():e.start(),!0}},W={id:"ui.operation.open-replace-dialog",type:r.CommandType.OPERATION,handler:n=>{const e=n.get(y);return e.revealed?e.replaceRevealed?e.focusFindInput():e.revealReplace():e.start(!0),!0}},q={type:r.CommandType.OPERATION,id:"ui.operation.go-to-next-match",handler:n=>(n.get(y).moveToNextMatch(),!0)},ee={type:r.CommandType.OPERATION,id:"ui.operation.go-to-previous-match",handler:n=>(n.get(y).moveToPreviousMatch(),!0)};var te={exports:{}},N={};/**
2
2
  * @license React
3
3
  * react-jsx-runtime.production.min.js
4
4
  *
@@ -6,4 +6,4 @@
6
6
  *
7
7
  * This source code is licensed under the MIT license found in the
8
8
  * LICENSE file in the root directory of this source tree.
9
- */var be=c,ye=Symbol.for("react.element"),Me=Symbol.for("react.fragment"),Fe=Object.prototype.hasOwnProperty,Ie=be.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,xe={key:!0,ref:!0,__self:!0,__source:!0};function ne(n,e,i){var t,a={},s=null,o=null;i!==void 0&&(s=""+i),e.key!==void 0&&(s=""+e.key),e.ref!==void 0&&(o=e.ref);for(t in e)Fe.call(e,t)&&!xe.hasOwnProperty(t)&&(a[t]=e[t]);if(n&&n.defaultProps)for(t in e=n.defaultProps,e)a[t]===void 0&&(a[t]=e[t]);return{$$typeof:ye,type:n,key:s,ref:o,props:a,_owner:Ie.current}}w.Fragment=Me,w.jsx=ne,w.jsxs=ne,te.exports=w;var u=te.exports;const ie={id:"ui.command.replace-current-match",type:r.CommandType.COMMAND,handler:n=>n.get(y).replace()},De="CONFIRM_REPLACE_ALL",ae={id:"ui.command.replace-all-matches",type:r.CommandType.COMMAND,handler:async n=>{const e=n.get(p.IConfirmService),i=n.get(r.LocaleService),t=n.get(p.IMessageService);if(!await e.confirm({id:De,title:{title:i.t("find-replace.replace.confirm.title")},cancelText:i.t("button.cancel"),confirmText:i.t("button.confirm")}))return!1;const s=await n.get(y).replaceAll(),{success:o,failure:l}=s;return l>0?(o===0?t.show({type:f.MessageType.Error,content:i.t("find-replace.replace.all-failure")}):t.show({type:f.MessageType.Warning,content:i.t("find-replace.replace.partial-success",`${o}`,`${l}`)}),!1):(t.show({type:f.MessageType.Success,content:i.t("find-replace.replace.all-success",`${o}`)}),!0)}};function se(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 u.jsx(f.InputWithSlot,{autoFocus:!0,placeholder:i.t("find-replace.dialog.find-placeholder"),slot:u.jsx(f.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),..._})}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 oe(n,e){const i=c.useCallback(()=>{var a;(a=document.querySelector(".univer-find-input input"))==null||a.focus()},[]),t=c.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 c.useImperativeHandle(e,()=>({focus:i,selectHasFocus:t})),c.useEffect(()=>{const a=n.focusSignal$.subscribe(()=>i());return()=>a.unsubscribe()},[n,i]),{focus:i,selectHasFocus:t}}const Oe=c.forwardRef(function(e,i){const t=F.useDependency(r.LocaleService),a=F.useDependency(y),s=F.useDependency(r.ICommandService),o=p.useObservable(a.state$,void 0,!0),{findCompleted:l,findString:_,matchesCount:m,matchesPosition:C}=o,v=c.useCallback(()=>{s.executeCommand(W.id)},[s]),x=c.useCallback(I=>a.changeFindString(I),[a]);return oe(a,i),u.jsxs(c.Fragment,{children:[u.jsx(se,{findCompleted:l,className:"univer-find-input",matchesCount:m,matchesPosition:C,findReplaceService:a,localeService:t,findString:_,onChange:x}),u.jsx("div",{className:L.findReplaceExpandContainer,children:u.jsx(f.Button,{type:"text",size:"small",onClick:v,children:t.t("find-replace.dialog.advanced-finding")})})]})}),Pe=c.forwardRef(function(e,i){const t=F.useDependency(y),a=F.useDependency(r.LocaleService),s=F.useDependency(r.ICommandService),o=F.useDependency(p.IMessageService),l=p.useObservable(t.currentMatch$,void 0,!0),_=p.useObservable(t.replaceables$,void 0,!0),m=p.useObservable(t.state$,void 0,!0),{matchesCount:C,matchesPosition:v,findString:x,inputtingFindString:I,replaceString:tt,caseSensitive:nt,matchesTheWholeCell:it,findDirection:at,findScope:st,findBy:ot,findCompleted:$}=m,rt=I.length===0,lt=C===0||!(l!=null&&l.replaceable),ct=_.length===0,dt=c.useCallback(g=>t.changeInputtingFindString(g),[t]),ht=c.useCallback(g=>t.changeReplaceString(g),[t]),{focus:ut}=oe(t,i),pt=c.useCallback(()=>{x===I?t.moveToNextMatch():(t.changeFindString(I),t.find())},[x,I,t]),ft=c.useCallback(()=>s.executeCommand(ie.id),[s]),_t=c.useCallback(async()=>{await s.executeCommand(ae.id),ut()},[s]),gt=c.useCallback(g=>{t.changeFindDirection(g)},[t]),mt=c.useCallback(g=>{t.changeFindScope(g)},[t]),vt=c.useCallback(g=>{t.changeFindBy(g)},[t]),St=Ee(a),Ct=Ne(a),Rt=we(a);return c.useEffect(()=>{const g=$&&C===0;let j=null;return g&&(j=o.show({content:a.t("find-replace.dialog.no-match"),type:f.MessageType.Warning,delay:5e3})),()=>j==null?void 0:j.dispose()},[$,C,o,a]),u.jsxs(c.Fragment,{children:[u.jsx(f.FormLayout,{label:a.t("find-replace.dialog.find"),children:u.jsx(se,{findCompleted:$,className:"univer-find-input",matchesCount:C,matchesPosition:v,findReplaceService:t,localeService:a,findString:I,onChange:dt})}),u.jsx(f.FormLayout,{label:a.t("find-replace.dialog.replace"),children:u.jsx(f.Input,{placeholder:a.t("find-replace.dialog.replace-placeholder"),value:tt,onChange:g=>ht(g)})}),u.jsx(f.FormLayout,{label:a.t("find-replace.dialog.find-direction.title"),children:u.jsx(f.Select,{value:at,options:Ct,onChange:gt})}),u.jsx(f.FormDualColumnLayout,{children:u.jsxs(c.Fragment,{children:[u.jsx(f.FormLayout,{label:a.t("find-replace.dialog.find-scope.title"),children:u.jsx(f.Select,{value:st,options:St,onChange:mt})}),u.jsx(f.FormLayout,{label:a.t("find-replace.dialog.find-by.title"),children:u.jsx(f.Select,{value:ot,options:Rt,onChange:vt})})]})}),u.jsx(f.FormDualColumnLayout,{children:u.jsxs(c.Fragment,{children:[u.jsx(f.FormLayout,{children:u.jsx(f.Checkbox,{checked:nt,onChange:g=>{t.changeCaseSensitive(g)},children:a.t("find-replace.dialog.case-sensitive")})}),u.jsx(f.FormLayout,{children:u.jsx(f.Checkbox,{checked:it,onChange:g=>{t.changeMatchesTheWholeCell(g)},children:a.t("find-replace.dialog.match-the-whole-cell")})})]})}),u.jsxs("div",{className:L.findReplaceButtonsGroup,children:[u.jsx(f.Button,{type:"primary",onClick:pt,disabled:rt,children:a.t("find-replace.dialog.find")}),u.jsxs("span",{className:L.findReplaceButtonsGroupRight,children:[u.jsx(f.Button,{disabled:lt,onClick:ft,children:a.t("find-replace.dialog.replace")}),u.jsx(f.Button,{disabled:ct,onClick:_t,children:a.t("find-replace.dialog.replace-all")})]})]})]})});function Te(){const n=F.useDependency(y),e=F.useDependency(p.ILayoutService),i=F.useDependency(r.IContextService),t=p.useObservable(n.state$,void 0,!0),a=c.useRef(null);c.useEffect(()=>{let _;return a.current&&(_=e.registerContainerElement(a.current)),()=>_==null?void 0:_.dispose()},[e]);const s=c.useRef(null),o=c.useCallback(_=>i.setContextValue(J,_),[i]),l=c.useCallback(_=>i.setContextValue(Z,_),[i]);return c.useEffect(()=>{var m;const _=S.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(m=s.current)==null||m.focus(),o(!0),l(!0),()=>{_.unsubscribe(),o(!1)}},[o,l]),u.jsx("div",{className:L.findReplaceDialogContainer,ref:a,children:t.replaceRevealed?u.jsx(Pe,{ref:s}):u.jsx(Oe,{ref:s})})}function Ee(n){const e=n.getCurrentLocale();return c.useMemo(()=>[{label:n.t("find-replace.dialog.find-scope.current-sheet"),value:E.SUBUNIT},{label:n.t("find-replace.dialog.find-scope.workbook"),value:E.UNIT}],[e])}function Ne(n){const e=n.getCurrentLocale();return c.useMemo(()=>[{label:n.t("find-replace.dialog.find-direction.row"),value:P.ROW},{label:n.t("find-replace.dialog.find-direction.column"),value:P.COLUMN}],[e])}function we(n){const e=n.getCurrentLocale();return c.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 D(n){return n.getContextValue(J)}function Le(n){return n.getContextValue(Q)}function re(n){return n.getContextValue(Z)}const A="7_find-replace-shortcuts";function G(n){return n.getContextValue(r.FOCUSING_SHEET)}function V(n){return!n.getContextValue(r.EDITOR_ACTIVATED)}const Ae={id:N.id,description:"find-replace.shortcut.open-find-dialog",binding:p.KeyCode.F|p.MetaKeys.CTRL_COMMAND,group:A,preconditions(n){return!D(n)&&G(n)&&V(n)}},je={id:N.id,description:"find-replace.shortcut.open-find-dialog",binding:p.KeyCode.F|p.MetaKeys.CTRL_COMMAND,mac:p.KeyCode.F|p.MetaKeys.MAC_CTRL,preconditions(n){return!D(n)&&G(n)&&V(n)}},Ue={id:W.id,description:"find-replace.shortcut.open-replace-dialog",binding:p.KeyCode.H|p.MetaKeys.CTRL_COMMAND,mac:p.KeyCode.H|p.MetaKeys.MAC_CTRL,group:A,preconditions(n){return G(n)&&V(n)&&(!D(n)||!Le(n))}},Be={id:q.id,description:"find-replace.shortcut.go-to-next-match",binding:p.KeyCode.ENTER,group:A,priority:1e3,preconditions(n){return re(n)&&D(n)}},ke={id:ee.id,description:"find-replace.shortcut.go-to-previous-match",binding:p.KeyCode.ENTER|p.MetaKeys.SHIFT,group:A,priority:1e3,preconditions(n){return re(n)&&D(n)}};function We(n){const e=n.get(r.IContextService);return{id:N.id,icon:"SearchIcon",tooltip:"find-replace.toolbar",group:p.MenuGroup.TOOLBAR_OTHERS,type:p.MenuItemType.BUTTON,positions:[p.MenuPosition.TOOLBAR_START],hidden$:p.getMenuHiddenObservable(n,r.UniverInstanceType.UNIVER_SHEET),disabled$:S.combineLatest([e.subscribeContextValue$(r.EDITOR_ACTIVATED),e.subscribeContextValue$(r.FOCUSING_SHEET)]).pipe(S.map(([i,t])=>i||!t))}}var Ge=Object.defineProperty,Ve=Object.getOwnPropertyDescriptor,He=(n,e,i,t)=>{for(var a=t>1?void 0:t?Ve(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&&Ge(e,i,a),a},M=(n,e)=>(i,t)=>e(i,t,n);const le="DESKTOP_FIND_REPLACE_DIALOG",ce=350,$e=20,Ke=-90;d.FindReplaceController=class extends r.RxDisposable{constructor(e,i,t,a,s,o,l,_,m,C,v,x){super(),this._univerInstanceService=e,this._menuService=i,this._shortcutService=t,this._commandService=a,this._findReplaceService=s,this._logService=o,this._dialogService=l,this._contextService=_,this._layoutService=m,this._localeService=C,this._componentManager=v,this._injector=x,this._initCommands(),this._initUI(),this._initShortcuts()}_initCommands(){[N,W,q,ee,ae,ie].forEach(e=>{this.disposeWithMe(this._commandService.registerCommand(e))})}_initShortcuts(){[Ue,Ae,je,ke,Be].forEach(e=>this.disposeWithMe(this._shortcutService.registerShortcut(e)))}_initUI(){this.disposeWithMe(this._menuService.addMenuItem(this._injector.invoke(We))),this.disposeWithMe(this._componentManager.register("FindReplaceDialog",Te)),this.disposeWithMe(this._componentManager.register("SearchIcon",Y)),this._findReplaceService.stateUpdates$.pipe(S.takeUntil(this.dispose$)).subscribe(e=>{e.revealed===!0&&this._openPanel()}),this.disposeWithMe(this._univerInstanceService.focused$.pipe(S.takeUntil(this.dispose$)).subscribe(e=>{(!e||!this._univerInstanceService.getUniverSheetInstance(e))&&this.closePanel()}))}_openPanel(){this._dialogService.open({id:le,draggable:!0,width:ce,title:{title:this._localeService.t("find-replace.dialog.title")},children:{label:"FindReplaceDialog"},destroyOnClose:!0,defaultPosition:ze(),preservePositionOnDestroy:!0,onClose:()=>this.closePanel()})}closePanel(){this._dialogService.close(le),this._findReplaceService.terminate(),queueMicrotask(()=>this._layoutService.focus())}},d.FindReplaceController=He([r.OnLifecycle(r.LifecycleStages.Rendered,d.FindReplaceController),M(0,r.IUniverInstanceService),M(1,p.IMenuService),M(2,p.IShortcutService),M(3,r.ICommandService),M(4,y),M(5,r.ILogService),M(6,p.IDialogService),M(7,r.IContextService),M(8,p.ILayoutService),M(9,R.Inject(r.LocaleService)),M(10,R.Inject(p.ComponentManager)),M(11,R.Inject(R.Injector))],d.FindReplaceController);function ze(){const{innerWidth:n}=window;return{x:(n-ce)/2-$e,y:Ke}}const Ye={"find-replace":{toolbar:"Find & Replace",shortcut:{"open-find-dialog":"Open Find Dialog","open-replace-dialog":"Open Replace Dialog","close-dialog":"Close Find & Replace Dialog","go-to-next-match":"Go to Next Match","go-to-previous-match":"Go to Previous Match"},dialog:{title:"Find",find:"Find",replace:"Replace","replace-all":"Replace All","case-sensitive":"Case Sensitive","find-placeholder":"Find in this Sheet","advanced-finding":"Advanced Searching & Replace","replace-placeholder":"Input Replace String","match-the-whole-cell":"Match the Whole Cell","find-direction":{title:"Find Direction",row:"Search by Row",column:"Search by Column"},"find-scope":{title:"Find Range","current-sheet":"Current Sheet",workbook:"Workbook"},"find-by":{title:"Find By",value:"Find by Value",formula:"Find Formula"},"no-match":"Finding completed but no match found.","no-result":"No Result"},replace:{"all-success":"Replaced all {0} matches","all-failure":"Replace failed",confirm:{title:"Are you sure to replace all matches?"}}},"find-replace-shortcuts":"Find & Replace"},de={"find-replace":{toolbar:"查找替换",shortcut:{"open-find-dialog":"打开查找对话框","open-replace-dialog":"打开替换对话框","close-dialog":"关闭查找替换对话框","go-to-next-match":"下一个匹配项","go-to-previous-match":"下一个匹配项"},dialog:{title:"查找",find:"查找",replace:"替换","replace-all":"替换全部","find-placeholder":"输入查找内容","advanced-finding":"替换 / 高级查找","replace-placeholder":"输入替换内容","case-sensitive":"匹配大小写","match-the-whole-cell":"匹配整个单元格","find-scope":{title:"查找范围","current-sheet":"当前子表",workbook:"整个工作簿"},"find-direction":{title:"查找顺序",column:"按列查找",row:"按行查找"},"find-by":{title:"查找方式",formula:"查找公式",value:"查找值"},"no-match":"已完成搜索,但是未找到任何匹配项","no-result":"无结果"},replace:{"all-success":"已全部替换 {0} 个匹配项","all-failure":"替换失败",confirm:{title:"确定要替换所有的匹配项吗?"}}},"find-replace-shortcuts":"查找替换"},Ze={"find-replace":{toolbar:"Найти и заменить",shortcut:{"open-find-dialog":"Открыть диалог поиска","open-replace-dialog":"Открыть диалог замены","close-dialog":"Закрыть диалог поиска и замены","go-to-next-match":"Перейти к следующему совпадению","go-to-previous-match":"Перейти к предыдущему совпадению"},dialog:{title:"Найти",find:"Найти",replace:"Заменить","replace-all":"Заменить все","case-sensitive":"С учетом регистра","find-placeholder":"Найти в этом листе","advanced-finding":"Расширенный поиск и замена","replace-placeholder":"Введите строку для замены","match-the-whole-cell":"Точное совпадение","find-direction":{title:"Направление поиска",row:"Поиск по строкам",column:"Поиск по столбцам"},"find-scope":{title:"Область поиска","current-sheet":"Текущий лист",workbook:"Книга"},"find-by":{title:"Поиск по",value:"Поиск по значению",formula:"Поиск по формуле"},"no-match":"Поиск завершен, совпадений не найдено.","no-result":"Нет результатов"},replace:{"all-success":"Заменены все {0} совпадений","all-failure":"Не удалось заменить",confirm:{title:"Вы уверены, что хотите заменить все совпадения?"}}},"find-replace-shortcuts":"Найти и заменить"};var Je=Object.defineProperty,Qe=Object.getOwnPropertyDescriptor,Xe=(n,e,i,t)=>{for(var a=t>1?void 0:t?Qe(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&&Je(e,i,a),a},qe=(n,e)=>(i,t)=>e(i,t,n);const et="FIND_REPLACE";d.UniverFindReplacePlugin=(H=class extends r.Plugin{constructor(e,i){super(),this._injector=e,this._localeService=i,this._localeService.load({zhCN:de})}onStarting(e){[[d.FindReplaceController],[y,{useClass:k}]].forEach(i=>{e.add(i)})}},h(H,"pluginName",et),H),d.UniverFindReplacePlugin=Xe([qe(1,R.Inject(r.LocaleService))],d.UniverFindReplacePlugin),d.FindBy=T,d.FindDirection=P,d.FindModel=Se,d.FindScope=E,d.IFindReplaceService=y,d.enUS=Ye,d.ruRU=Ze,d.zhCN=de,Object.defineProperty(d,Symbol.toStringTag,{value:"Module"})});
9
+ */var ye=d,Me=Symbol.for("react.element"),Fe=Symbol.for("react.fragment"),Ie=Object.prototype.hasOwnProperty,De=ye.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,xe={key:!0,ref:!0,__self:!0,__source:!0};function ne(n,e,i){var t,a={},s=null,o=null;i!==void 0&&(s=""+i),e.key!==void 0&&(s=""+e.key),e.ref!==void 0&&(o=e.ref);for(t in e)Ie.call(e,t)&&!xe.hasOwnProperty(t)&&(a[t]=e[t]);if(n&&n.defaultProps)for(t in e=n.defaultProps,e)a[t]===void 0&&(a[t]=e[t]);return{$$typeof:Me,type:n,key:s,ref:o,props:a,_owner:De.current}}N.Fragment=Fe,N.jsx=ne,N.jsxs=ne,te.exports=N;var u=te.exports;const ie={id:"ui.command.replace-current-match",type:r.CommandType.COMMAND,handler:n=>n.get(y).replace()},Oe="CONFIRM_REPLACE_ALL",ae={id:"ui.command.replace-all-matches",type:r.CommandType.COMMAND,handler:async n=>{const e=n.get(f.IConfirmService),i=n.get(r.LocaleService),t=n.get(f.IMessageService);if(!await e.confirm({id:Oe,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(y).replaceAll(),{success:o,failure:c}=s;return c>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}`,`${c}`)}),!1):(t.show({type:p.MessageType.Success,content:i.t("find-replace.replace.all-success",`${o}`)}),!0)}};function se(n){const{findCompleted:e,localeService:i,matchesCount:t,matchesPosition:a,findString:s,findReplaceService:o,onChange:c,..._}=n,R=e&&t===0?i.t("find-replace.dialog.no-result"):t===0?" ":void 0;return u.jsx(p.InputWithSlot,{autoFocus:!0,placeholder:i.t("find-replace.dialog.find-placeholder"),slot:u.jsx(p.Pager,{loop:!0,text:R,value:a,total:t,onChange:S=>{a===t&&S===1?o.moveToNextMatch():a===1&&S===t||S<a?o.moveToPreviousMatch():o.moveToNextMatch()}}),value:s,onChange:S=>c==null?void 0:c(S),..._})}const w={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 oe(n,e){const i=d.useCallback(()=>{var a;(a=document.querySelector(".univer-find-input input"))==null||a.focus()},[]),t=d.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 d.useImperativeHandle(e,()=>({focus:i,selectHasFocus:t})),d.useEffect(()=>{const a=n.focusSignal$.subscribe(()=>i());return()=>a.unsubscribe()},[n,i]),{focus:i,selectHasFocus:t}}const Pe=d.forwardRef(function(e,i){const t=M.useDependency(r.LocaleService),a=M.useDependency(y),s=M.useDependency(r.ICommandService),o=f.useObservable(a.state$,void 0,!0),{findCompleted:c,findString:_,matchesCount:v,matchesPosition:R}=o,S=d.useCallback(()=>{s.executeCommand(W.id)},[s]),L=d.useCallback(I=>a.changeFindString(I),[a]);return oe(a,i),u.jsxs(d.Fragment,{children:[u.jsx(se,{findCompleted:c,className:"univer-find-input",matchesCount:v,matchesPosition:R,findReplaceService:a,localeService:t,findString:_,onChange:L}),u.jsx("div",{className:w.findReplaceExpandContainer,children:u.jsx(p.Button,{type:"text",size:"small",onClick:S,children:t.t("find-replace.dialog.advanced-finding")})})]})}),Te=d.forwardRef(function(e,i){const t=M.useDependency(y),a=M.useDependency(r.LocaleService),s=M.useDependency(r.ICommandService),o=M.useDependency(f.IMessageService),c=f.useObservable(t.currentMatch$,void 0,!0),_=f.useObservable(t.replaceables$,void 0,!0),v=f.useObservable(t.state$,void 0,!0),{matchesCount:R,matchesPosition:S,findString:L,inputtingFindString:I,replaceString:nt,caseSensitive:it,matchesTheWholeCell:at,findDirection:st,findScope:ot,findBy:rt,findCompleted:$}=v,ct=I.length===0,lt=R===0||!(c!=null&&c.replaceable),dt=_.length===0,ht=d.useCallback(g=>t.changeInputtingFindString(g),[t]),ut=d.useCallback(g=>t.changeReplaceString(g),[t]),{focus:ft}=oe(t,i),pt=d.useCallback(()=>{L===I?t.moveToNextMatch():(t.changeFindString(I),t.find())},[L,I,t]),_t=d.useCallback(()=>s.executeCommand(ie.id),[s]),gt=d.useCallback(async()=>{await s.executeCommand(ae.id),ft()},[s]),mt=d.useCallback(g=>{t.changeFindDirection(g)},[t]),vt=d.useCallback(g=>{t.changeFindScope(g)},[t]),St=d.useCallback(g=>{t.changeFindBy(g)},[t]),Ct=Ne(a),Rt=we(a),bt=je(a);return d.useEffect(()=>{const g=$&&R===0;let A=null;return g&&(A=o.show({content:a.t("find-replace.dialog.no-match"),type:p.MessageType.Warning,delay:5e3})),()=>A==null?void 0:A.dispose()},[$,R,o,a]),u.jsxs(d.Fragment,{children:[u.jsx(p.FormLayout,{label:a.t("find-replace.dialog.find"),children:u.jsx(se,{findCompleted:$,className:"univer-find-input",matchesCount:R,matchesPosition:S,findReplaceService:t,localeService:a,findString:I,onChange:ht})}),u.jsx(p.FormLayout,{label:a.t("find-replace.dialog.replace"),children:u.jsx(p.Input,{placeholder:a.t("find-replace.dialog.replace-placeholder"),value:nt,onChange:g=>ut(g)})}),u.jsx(p.FormLayout,{label:a.t("find-replace.dialog.find-direction.title"),children:u.jsx(p.Select,{value:st,options:Rt,onChange:mt})}),u.jsx(p.FormDualColumnLayout,{children:u.jsxs(d.Fragment,{children:[u.jsx(p.FormLayout,{label:a.t("find-replace.dialog.find-scope.title"),children:u.jsx(p.Select,{value:ot,options:Ct,onChange:vt})}),u.jsx(p.FormLayout,{label:a.t("find-replace.dialog.find-by.title"),children:u.jsx(p.Select,{value:rt,options:bt,onChange:St})})]})}),u.jsx(p.FormDualColumnLayout,{children:u.jsxs(d.Fragment,{children:[u.jsx(p.FormLayout,{children:u.jsx(p.Checkbox,{checked:it,onChange:g=>{t.changeCaseSensitive(g)},children:a.t("find-replace.dialog.case-sensitive")})}),u.jsx(p.FormLayout,{children:u.jsx(p.Checkbox,{checked:at,onChange:g=>{t.changeMatchesTheWholeCell(g)},children:a.t("find-replace.dialog.match-the-whole-cell")})})]})}),u.jsxs("div",{className:w.findReplaceButtonsGroup,children:[u.jsx(p.Button,{type:"primary",onClick:pt,disabled:ct,children:a.t("find-replace.dialog.find")}),u.jsxs("span",{className:w.findReplaceButtonsGroupRight,children:[u.jsx(p.Button,{disabled:lt,onClick:_t,children:a.t("find-replace.dialog.replace")}),u.jsx(p.Button,{disabled:dt,onClick:gt,children:a.t("find-replace.dialog.replace-all")})]})]})]})});function Ee(){const n=M.useDependency(y),e=M.useDependency(f.ILayoutService),i=M.useDependency(r.IContextService),t=f.useObservable(n.state$,void 0,!0),a=d.useRef(null);d.useEffect(()=>{let _;return a.current&&(_=e.registerContainerElement(a.current)),()=>_==null?void 0:_.dispose()},[e]);const s=d.useRef(null),o=d.useCallback(_=>i.setContextValue(J,_),[i]),c=d.useCallback(_=>i.setContextValue(Z,_),[i]);return d.useEffect(()=>{var v;const _=C.fromEvent(document,"focusin").subscribe(R=>{var S;R.target&&((S=a.current)!=null&&S.contains(R.target))?o(!0):o(!1),!s.current||!s.current.selectHasFocus()?c(!0):c(!1)});return(v=s.current)==null||v.focus(),o(!0),c(!0),()=>{_.unsubscribe(),o(!1)}},[o,c]),u.jsx("div",{className:w.findReplaceDialogContainer,ref:a,children:t.replaceRevealed?u.jsx(Te,{ref:s}):u.jsx(Pe,{ref:s})})}function Ne(n){const e=n.getCurrentLocale();return d.useMemo(()=>[{label:n.t("find-replace.dialog.find-scope.current-sheet"),value:T.SUBUNIT},{label:n.t("find-replace.dialog.find-scope.workbook"),value:T.UNIT}],[e])}function we(n){const e=n.getCurrentLocale();return d.useMemo(()=>[{label:n.t("find-replace.dialog.find-direction.row"),value:O.ROW},{label:n.t("find-replace.dialog.find-direction.column"),value:O.COLUMN}],[e])}function je(n){const e=n.getCurrentLocale();return d.useMemo(()=>[{label:n.t("find-replace.dialog.find-by.value"),value:P.VALUE},{label:n.t("find-replace.dialog.find-by.formula"),value:P.FORMULA}],[e])}function D(n){return n.getContextValue(J)}function Le(n){return n.getContextValue(Q)}function re(n){return n.getContextValue(Z)}const j="7_find-replace-shortcuts";function G(n){return n.getContextValue(r.FOCUSING_SHEET)}function V(n){return!n.getContextValue(r.EDITOR_ACTIVATED)}const Ae={id:E.id,description:"find-replace.shortcut.open-find-dialog",binding:f.KeyCode.F|f.MetaKeys.CTRL_COMMAND,group:j,preconditions(n){return!D(n)&&G(n)&&V(n)}},Ue={id:E.id,description:"find-replace.shortcut.open-find-dialog",binding:f.KeyCode.F|f.MetaKeys.CTRL_COMMAND,mac:f.KeyCode.F|f.MetaKeys.MAC_CTRL,preconditions(n){return!D(n)&&G(n)&&V(n)}},Be={id:W.id,description:"find-replace.shortcut.open-replace-dialog",binding:f.KeyCode.H|f.MetaKeys.CTRL_COMMAND,mac:f.KeyCode.H|f.MetaKeys.MAC_CTRL,group:j,preconditions(n){return G(n)&&V(n)&&(!D(n)||!Le(n))}},ke={id:q.id,description:"find-replace.shortcut.go-to-next-match",binding:f.KeyCode.ENTER,group:j,priority:1e3,preconditions(n){return re(n)&&D(n)}},We={id:ee.id,description:"find-replace.shortcut.go-to-previous-match",binding:f.KeyCode.ENTER|f.MetaKeys.SHIFT,group:j,priority:1e3,preconditions(n){return re(n)&&D(n)}};function Ge(n){const e=n.get(r.IContextService);return{id:E.id,icon:"SearchIcon",tooltip:"find-replace.toolbar",group:f.MenuGroup.TOOLBAR_OTHERS,type:f.MenuItemType.BUTTON,positions:[f.MenuPosition.TOOLBAR_START],hidden$:f.getMenuHiddenObservable(n,r.UniverInstanceType.UNIVER_SHEET),disabled$:C.combineLatest([e.subscribeContextValue$(r.EDITOR_ACTIVATED),e.subscribeContextValue$(r.FOCUSING_SHEET)]).pipe(C.map(([i,t])=>i||!t))}}var Ve=Object.defineProperty,He=Object.getOwnPropertyDescriptor,$e=(n,e,i,t)=>{for(var a=t>1?void 0:t?He(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&&Ve(e,i,a),a},F=(n,e)=>(i,t)=>e(i,t,n);const Ke={},ce="DESKTOP_FIND_REPLACE_DIALOG",le=350,ze=20,Ye=-90;l.FindReplaceController=class extends r.RxDisposable{constructor(e,i,t,a,s,o,c,_,v,R,S){super(),this._config=e,this._univerInstanceService=i,this._menuService=t,this._shortcutService=a,this._commandService=s,this._findReplaceService=o,this._dialogService=c,this._layoutService=_,this._localeService=v,this._componentManager=R,this._injector=S,this._initCommands(),this._initUI(),this._initShortcuts()}_initCommands(){[E,W,q,ee,ae,ie].forEach(e=>{this.disposeWithMe(this._commandService.registerCommand(e))})}_initShortcuts(){[Be,Ae,Ue,We,ke].forEach(e=>this.disposeWithMe(this._shortcutService.registerShortcut(e)))}_initUI(){const{menu:e={}}=this._config;this.disposeWithMe(this._menuService.addMenuItem(this._injector.invoke(Ge),e)),this.disposeWithMe(this._componentManager.register("FindReplaceDialog",Ee)),this.disposeWithMe(this._componentManager.register("SearchIcon",Y)),this._findReplaceService.stateUpdates$.pipe(C.takeUntil(this.dispose$)).subscribe(i=>{i.revealed===!0&&this._openPanel()}),this.disposeWithMe(this._univerInstanceService.focused$.pipe(C.takeUntil(this.dispose$)).subscribe(i=>{(!i||!this._univerInstanceService.getUniverSheetInstance(i))&&this.closePanel()}))}_openPanel(){this._dialogService.open({id:ce,draggable:!0,width:le,title:{title:this._localeService.t("find-replace.dialog.title")},children:{label:"FindReplaceDialog"},destroyOnClose:!0,defaultPosition:Ze(),preservePositionOnDestroy:!0,onClose:()=>this.closePanel()})}closePanel(){this._dialogService.close(ce),this._findReplaceService.terminate(),queueMicrotask(()=>this._layoutService.focus())}},l.FindReplaceController=$e([r.OnLifecycle(r.LifecycleStages.Rendered,l.FindReplaceController),F(1,r.IUniverInstanceService),F(2,f.IMenuService),F(3,f.IShortcutService),F(4,r.ICommandService),F(5,y),F(6,f.IDialogService),F(7,f.ILayoutService),F(8,m.Inject(r.LocaleService)),F(9,m.Inject(f.ComponentManager)),F(10,m.Inject(m.Injector))],l.FindReplaceController);function Ze(){const{innerWidth:n}=window;return{x:(n-le)/2-ze,y:Ye}}const Je={"find-replace":{toolbar:"Find & Replace",shortcut:{"open-find-dialog":"Open Find Dialog","open-replace-dialog":"Open Replace Dialog","close-dialog":"Close Find & Replace Dialog","go-to-next-match":"Go to Next Match","go-to-previous-match":"Go to Previous Match"},dialog:{title:"Find",find:"Find",replace:"Replace","replace-all":"Replace All","case-sensitive":"Case Sensitive","find-placeholder":"Find in this Sheet","advanced-finding":"Advanced Searching & Replace","replace-placeholder":"Input Replace String","match-the-whole-cell":"Match the Whole Cell","find-direction":{title:"Find Direction",row:"Search by Row",column:"Search by Column"},"find-scope":{title:"Find Range","current-sheet":"Current Sheet",workbook:"Workbook"},"find-by":{title:"Find By",value:"Find by Value",formula:"Find Formula"},"no-match":"Finding completed but no match found.","no-result":"No Result"},replace:{"all-success":"Replaced all {0} matches","all-failure":"Replace failed",confirm:{title:"Are you sure to replace all matches?"}}},"find-replace-shortcuts":"Find & Replace"},de={"find-replace":{toolbar:"查找替换",shortcut:{"open-find-dialog":"打开查找对话框","open-replace-dialog":"打开替换对话框","close-dialog":"关闭查找替换对话框","go-to-next-match":"下一个匹配项","go-to-previous-match":"下一个匹配项"},dialog:{title:"查找",find:"查找",replace:"替换","replace-all":"替换全部","find-placeholder":"输入查找内容","advanced-finding":"替换 / 高级查找","replace-placeholder":"输入替换内容","case-sensitive":"匹配大小写","match-the-whole-cell":"匹配整个单元格","find-scope":{title:"查找范围","current-sheet":"当前子表",workbook:"整个工作簿"},"find-direction":{title:"查找顺序",column:"按列查找",row:"按行查找"},"find-by":{title:"查找方式",formula:"查找公式",value:"查找值"},"no-match":"已完成搜索,但是未找到任何匹配项","no-result":"无结果"},replace:{"all-success":"已全部替换 {0} 个匹配项","all-failure":"替换失败",confirm:{title:"确定要替换所有的匹配项吗?"}}},"find-replace-shortcuts":"查找替换"},Qe={"find-replace":{toolbar:"Найти и заменить",shortcut:{"open-find-dialog":"Открыть диалог поиска","open-replace-dialog":"Открыть диалог замены","close-dialog":"Закрыть диалог поиска и замены","go-to-next-match":"Перейти к следующему совпадению","go-to-previous-match":"Перейти к предыдущему совпадению"},dialog:{title:"Найти",find:"Найти",replace:"Заменить","replace-all":"Заменить все","case-sensitive":"С учетом регистра","find-placeholder":"Найти в этом листе","advanced-finding":"Расширенный поиск и замена","replace-placeholder":"Введите строку для замены","match-the-whole-cell":"Точное совпадение","find-direction":{title:"Направление поиска",row:"Поиск по строкам",column:"Поиск по столбцам"},"find-scope":{title:"Область поиска","current-sheet":"Текущий лист",workbook:"Книга"},"find-by":{title:"Поиск по",value:"Поиск по значению",formula:"Поиск по формуле"},"no-match":"Поиск завершен, совпадений не найдено.","no-result":"Нет результатов"},replace:{"all-success":"Заменены все {0} совпадений","all-failure":"Не удалось заменить",confirm:{title:"Вы уверены, что хотите заменить все совпадения?"}}},"find-replace-shortcuts":"Найти и заменить"};var Xe=Object.defineProperty,qe=Object.getOwnPropertyDescriptor,et=(n,e,i,t)=>{for(var a=t>1?void 0:t?qe(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&&Xe(e,i,a),a},he=(n,e)=>(i,t)=>e(i,t,n);const tt="FIND_REPLACE_PLUGIN";l.UniverFindReplacePlugin=(H=class extends r.Plugin{constructor(e={},i,t){super(),this._config=e,this._injector=i,this._localeService=t,this._localeService.load({zhCN:de}),this._config=r.Tools.deepMerge({},Ke,this._config)}onStarting(e){[[l.FindReplaceController,{useFactory:()=>this._injector.createInstance(l.FindReplaceController,this._config)}],[y,{useClass:k}]].forEach(i=>{e.add(i)})}},h(H,"pluginName",tt),H),l.UniverFindReplacePlugin=et([he(1,m.Inject(m.Injector)),he(2,m.Inject(r.LocaleService))],l.UniverFindReplacePlugin),l.FindBy=P,l.FindDirection=O,l.FindModel=Ce,l.FindScope=T,l.IFindReplaceService=y,l.enUS=Je,l.ruRU=Qe,l.zhCN=de,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.1.11",
3
+ "version": "0.1.12",
4
4
  "private": false,
5
5
  "description": "",
6
6
  "author": "DreamNum <developer@univer.ai>",
@@ -53,32 +53,32 @@
53
53
  "npm": ">=8.0.0"
54
54
  },
55
55
  "peerDependencies": {
56
- "@wendellhu/redi": "^0.15.1",
56
+ "@wendellhu/redi": "0.15.2",
57
57
  "react": "^16.9.0 || ^17.0.0 || ^18.0.0",
58
58
  "rxjs": ">=7.0.0",
59
- "@univerjs/design": "0.1.11",
60
- "@univerjs/core": "0.1.11",
61
- "@univerjs/engine-render": "0.1.11",
62
- "@univerjs/ui": "0.1.11"
59
+ "@univerjs/core": "0.1.12",
60
+ "@univerjs/engine-render": "0.1.12",
61
+ "@univerjs/design": "0.1.12",
62
+ "@univerjs/ui": "0.1.12"
63
63
  },
64
64
  "dependencies": {
65
- "@univerjs/icons": "^0.1.45"
65
+ "@univerjs/icons": "^0.1.52"
66
66
  },
67
67
  "devDependencies": {
68
68
  "@types/react": "^18.2.79",
69
- "@wendellhu/redi": "^0.15.1",
69
+ "@wendellhu/redi": "0.15.2",
70
70
  "less": "^4.2.0",
71
71
  "react": "18.2.0",
72
72
  "rxjs": "^7.8.1",
73
73
  "typescript": "^5.4.5",
74
74
  "vite": "^5.2.11",
75
75
  "vitest": "^1.6.0",
76
- "@univerjs/core": "0.1.11",
77
- "@univerjs/design": "0.1.11",
78
- "@univerjs/engine-formula": "0.1.11",
79
- "@univerjs/shared": "0.1.11",
80
- "@univerjs/ui": "0.1.11",
81
- "@univerjs/engine-render": "0.1.11"
76
+ "@univerjs/core": "0.1.12",
77
+ "@univerjs/design": "0.1.12",
78
+ "@univerjs/engine-formula": "0.1.12",
79
+ "@univerjs/engine-render": "0.1.12",
80
+ "@univerjs/shared": "0.1.12",
81
+ "@univerjs/ui": "0.1.12"
82
82
  },
83
83
  "scripts": {
84
84
  "test": "vitest run",