@univerjs/find-replace 0.4.2-nightly.202411061606 → 0.4.2-nightly.202411081606
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 -0
- package/lib/cjs/locale/en-US.js +1 -0
- package/lib/cjs/locale/fa-IR.js +1 -0
- package/lib/cjs/locale/ru-RU.js +1 -0
- package/lib/cjs/locale/vi-VN.js +1 -0
- package/lib/cjs/locale/zh-CN.js +1 -0
- package/lib/cjs/locale/zh-TW.js +1 -0
- package/lib/es/index.js +559 -609
- package/lib/{locale → es/locale}/en-US.js +2 -2
- package/lib/{locale → es/locale}/fa-IR.js +2 -2
- package/lib/{locale → es/locale}/ru-RU.js +2 -2
- package/lib/{locale → es/locale}/vi-VN.js +2 -2
- package/lib/{locale → es/locale}/zh-CN.js +2 -2
- package/lib/{locale → es/locale}/zh-TW.js +2 -2
- package/lib/umd/index.js +1 -9
- package/package.json +21 -15
package/lib/cjs/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var Fe=Object.defineProperty;var xe=(i,e,n)=>e in i?Fe(i,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):i[e]=n;var c=(i,e,n)=>xe(i,typeof e!="symbol"?e+"":e,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("@univerjs/core"),u=require("@univerjs/ui"),_=require("rxjs"),p=require("@univerjs/design"),De=require("@univerjs/engine-render"),d=require("react/jsx-runtime"),l=require("react"),Te="find-replace.config",Pe={};var S=function(){return S=Object.assign||function(i){for(var e,n=1,t=arguments.length;n<t;n++){e=arguments[n];for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&(i[s]=e[s])}return i},S.apply(this,arguments)},Oe=function(i,e){var n={};for(var t in i)Object.prototype.hasOwnProperty.call(i,t)&&e.indexOf(t)<0&&(n[t]=i[t]);if(i!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,t=Object.getOwnPropertySymbols(i);s<t.length;s++)e.indexOf(t[s])<0&&Object.prototype.propertyIsEnumerable.call(i,t[s])&&(n[t[s]]=i[t[s]]);return n},z=l.forwardRef(function(i,e){var n=i.icon,t=i.id,s=i.className,r=i.extend,a=Oe(i,["icon","id","className","extend"]),h="univerjs-icon univerjs-icon-".concat(t," ").concat(s||"").trim(),f=l.useRef("_".concat(Le()));return Y(n,"".concat(t),{defIds:n.defIds,idSuffix:f.current},S({ref:e,className:h},a),r)});function Y(i,e,n,t,s){return l.createElement(i.tag,S(S({key:e},Ee(i,n,s)),t),(Ne(i,n).children||[]).map(function(r,a){return Y(r,"".concat(e,"-").concat(i.tag,"-").concat(a),n,void 0,s)}))}function Ee(i,e,n){var t=S({},i.attrs);n!=null&&n.colorChannel1&&t.fill==="colorChannel1"&&(t.fill=n.colorChannel1);var s=e.defIds;return!s||s.length===0||(i.tag==="use"&&t["xlink:href"]&&(t["xlink:href"]=t["xlink:href"]+e.idSuffix),Object.entries(t).forEach(function(r){var a=r[0],h=r[1];typeof h=="string"&&(t[a]=h.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))})),t}function Ne(i,e){var n,t=e.defIds;return!t||t.length===0?i:i.tag==="defs"&&(!((n=i.children)===null||n===void 0)&&n.length)?S(S({},i),{children:i.children.map(function(s){return typeof s.attrs.id=="string"&&t&&t.indexOf(s.attrs.id)>-1?S(S({},s),{attrs:S(S({},s.attrs),{id:s.attrs.id+e.idSuffix})}):s})}):i}function Le(){return Math.random().toString(36).substring(2,8)}z.displayName="UniverIcon";var $e={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"mask",attrs:{id:"mask0_217_40",style:{maskType:"alpha"},width:17,height:17,x:0,y:0,maskUnits:"userSpaceOnUse"},children:[{tag:"path",attrs:{fill:"#D9D9D9",d:"M0.9 0.09H16.9V16.09H0.9z"}}]},{tag:"g",attrs:{mask:"url(#mask0_217_40)"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M2.39551 7.37266C2.39551 4.18105 4.98281 1.59375 8.17441 1.59375C11.366 1.59375 13.9533 4.18105 13.9533 7.37266C13.9533 8.72342 13.4898 9.96603 12.7133 10.95L15.1964 13.4331C15.4619 13.6986 15.4619 14.1291 15.1964 14.3946C14.9309 14.6601 14.5004 14.6601 14.2349 14.3946L11.7518 11.9115C10.7678 12.6881 9.52525 13.1516 8.17441 13.1516C4.98281 13.1516 2.39551 10.5642 2.39551 7.37266ZM8.17441 2.95349C5.73378 2.95349 3.75525 4.93202 3.75525 7.37266C3.75525 9.81333 5.73378 11.7918 8.17441 11.7918C10.6151 11.7918 12.5936 9.81333 12.5936 7.37266C12.5936 4.93202 10.6151 2.95349 8.17441 2.95349Z",fillRule:"evenodd",clipRule:"evenodd"}}]}]},Z=l.forwardRef(function(i,e){return l.createElement(z,Object.assign({},i,{id:"search-single-16",ref:e,icon:$e}))});Z.displayName="SearchSingle16";const J="FIND_REPLACE_INPUT_FOCUS",Q="FIND_REPLACE_DIALOG_FOCUS",X="FIND_REPLACE_REPLACE_REVEALED";var je=Object.defineProperty,Ae=Object.getOwnPropertyDescriptor,ee=(i,e,n,t)=>{for(var s=t>1?void 0:t?Ae(e,n):e,r=i.length-1,a;r>=0;r--)(a=i[r])&&(s=(t?a(e,n,s):a(s))||s);return t&&s&&je(e,n,s),s},j=(i,e)=>(n,t)=>e(n,t,i);class we extends o.Disposable{}const C=o.createIdentifier("find-replace.service");function Ue(i){return typeof i.findString<"u"||typeof i.inputtingFindString<"u"||typeof i.findDirection<"u"||typeof i.matchesTheWholeCell<"u"||typeof i.caseSensitive<"u"||typeof i.findScope<"u"||typeof i.findBy<"u"}let A=class extends o.Disposable{constructor(e,n,t){super();c(this,"currentMatch$",new _.BehaviorSubject(null));c(this,"replaceables$",new _.BehaviorSubject([]));c(this,"_findModels",[]);c(this,"_matchingModel",null);c(this,"_matches",[]);c(this,"_currentSearchingDisposables",null);this._state=e,this._providers=n,this._univerInstanceService=t,this.disposeWithMe(this._state.stateUpdates$.pipe(_.throttleTime(200,void 0,{leading:!0,trailing:!0})).subscribe(async s=>{const r=this._state.state;Ue(s)&&(r.findString!==""&&!r.replaceRevealed?(await this._startSearching(),this._state.changeState({findCompleted:!0})):s.replaceRevealed!==!0&&this._stopSearching())}))}get searched(){return this._findModels.length>0}dispose(){super.dispose(),this._stopSearching(),this.currentMatch$.complete(),this.replaceables$.complete(),this._state.changeState({...U(),revealed:!1})}async start(){if(!this._state.findString)return{results:[]};const e=await this._startSearching();return this._state.changeState({findCompleted:!0}),e}async _startSearching(){if(!this._state.findString)return{results:[]};const e=Array.from(this._providers),n=this._findModels=(await Promise.all(e.map(s=>s.find({findString:this._state.findString,findDirection:this._state.findDirection,findScope:this._state.findScope,findBy:this._state.findBy,replaceRevealed:this._state.replaceRevealed,caseSensitive:this._state.caseSensitive,matchesTheWholeCell:this._state.matchesTheWholeCell})))).flat();this._subscribeToModelsChanges(n);const t=this._matches=n.map(s=>s.getMatches()).flat();return this.replaceables$.next(t.filter(s=>s.replaceable)),t.length?(this._moveToInitialMatch(n),this._state.changeState({matchesCount:t.length}),{results:t}):(this._state.changeState({matchesCount:0,matchesPosition:0}),{results:[]})}_stopSearching(){var e;this._providers.forEach(n=>n.terminate()),this._findModels=[],this._matches=[],this._matchingModel=null,(e=this._currentSearchingDisposables)==null||e.dispose(),this._currentSearchingDisposables=null,this.currentMatch$.next(null),this.replaceables$.next([]),this._state.changeState({findCompleted:!1,matchesCount:0,matchesPosition:0})}_subscribeToModelsChanges(e){const n=this._currentSearchingDisposables=new o.DisposableCollection,t=_.combineLatest(e.map(s=>s.matchesUpdate$)).pipe(_.debounceTime(220)).subscribe(([...s])=>{const r=this._matches=s.flat();r.length?(this._moveToInitialMatch(this._findModels,!0),this._state.changeState({matchesCount:r.length}),this.replaceables$.next(r.filter(a=>a.replaceable))):(this._state.changeState({matchesCount:0,matchesPosition:0}),this.replaceables$.next([]))});e.forEach(s=>n.add(o.toDisposable(s.activelyChangingMatch$.subscribe(r=>{const a=this._matches.findIndex(h=>h===r);this._state.changeState({matchesPosition:a+1})})))),n.add(o.toDisposable(t))}async replace(){return this._matchingModel?this._matchingModel.replace(this._state.replaceString):!1}async replaceAll(){const e=await Promise.all(this._findModels.map(n=>n.replaceAll(this._state.replaceString))).then(n=>n.reduce((t,s)=>(t.success+=s.success,t.failure+=s.failure,t),{success:0,failure:0}));return e.failure===0&&this._stopSearching(),e}getCurrentMatch(){return this._state.matchesPosition>0?this._matches[this._state.matchesPosition-1]:null}_markMatch(e){const n=this._matches.findIndex(t=>t===e);this.currentMatch$.next(e),this._state.changeState({matchesPosition:n+1})}moveToNextMatch(){if(!this._matchingModel)return;const e=this._findModels.length===1,n=this._matchingModel.moveToNextMatch({loop:e});if(n)this._markMatch(n);else{const t=this._findModels.findIndex(s=>s===this._matchingModel);this._moveToNextUnitMatch(t)}}_moveToNextUnitMatch(e){const n=this._findModels.length;for(let t=(e+1)%n;t!==e;){const s=this._findModels[t],r=s.moveToNextMatch({ignoreSelection:!0});if(r){this._matchingModel=s,this._markMatch(r);return}t=(t+1)%n}if(this._matchingModel){const t=this._matchingModel.moveToNextMatch({ignoreSelection:!0});t&&this._markMatch(t)}}moveToPreviousMatch(){if(!this._matchingModel)return;const e=this._findModels.length===1,n=this._matchingModel.moveToPreviousMatch({loop:e});if(n){const t=this._matches.findIndex(s=>s===n);this.currentMatch$.next(n),this._state.changeState({matchesPosition:t+1})}else{const t=this._findModels.length,s=this._findModels.findIndex(a=>a===this._matchingModel);for(let a=(s-1+t)%t;a!==s;){const h=this._findModels[a],f=h.moveToPreviousMatch({ignoreSelection:!0});if(f){this._matchingModel=h,this._markMatch(f);return}a=(a-1)%t}const r=this._matchingModel.moveToPreviousMatch({ignoreSelection:!0});r&&this._markMatch(r)}}_moveToInitialMatch(e,n=!1){var r;const t=(r=this._univerInstanceService.getFocusedUnit())==null?void 0:r.getUnitId();if(!t)return-1;const s=e.findIndex(a=>a.unitId===t);if(s!==-1){this._matchingModel=e[s];const a=this._matchingModel.moveToNextMatch({stayIfOnMatch:!0,noFocus:n});if(a)return this._markMatch(a),s}return this._moveToNextUnitMatch(s),0}};A=ee([j(2,o.IUniverInstanceService)],A);var D=(i=>(i.ROW="row",i.COLUMN="column",i))(D||{}),T=(i=>(i.VALUE="value",i.FORMULA="formula",i))(T||{}),P=(i=>(i.SUBUNIT="subunit",i.UNIT="unit",i))(P||{});function U(){return{caseSensitive:!1,findBy:"value",findCompleted:!1,findDirection:"row",findScope:"subunit",findString:"",inputtingFindString:"",matchesCount:0,matchesPosition:0,matchesTheWholeCell:!1,replaceRevealed:!1,replaceString:"",revealed:!0}}class Be{constructor(){c(this,"_stateUpdates$",new _.Subject);c(this,"stateUpdates$",this._stateUpdates$.asObservable());c(this,"_state$",new _.BehaviorSubject(U()));c(this,"state$",this._state$.asObservable());c(this,"_findString","");c(this,"_inputtingFindString","");c(this,"_replaceString","");c(this,"_revealed",!1);c(this,"_replaceRevealed",!1);c(this,"_matchesPosition",0);c(this,"_matchesCount",0);c(this,"_caseSensitive",!0);c(this,"_matchesTheWholeCell",!1);c(this,"_findDirection","row");c(this,"_findScope","subunit");c(this,"_findBy","value");c(this,"_findCompleted",!1)}get state(){return this._state$.getValue()}get inputtingFindString(){return this._inputtingFindString}get findString(){return this._findString}get revealed(){return this._revealed}get replaceRevealed(){return this._replaceRevealed}get matchesPosition(){return this._matchesPosition}get matchesCount(){return this._matchesCount}get replaceString(){return this._replaceString}get caseSensitive(){return this._caseSensitive}get matchesTheWholeCell(){return this._matchesTheWholeCell}get findDirection(){return this._findDirection}get findScope(){return this._findScope}get findBy(){return this._findBy}get findCompleted(){return this._findCompleted}changeState(e){let n=!1;const t={};typeof e.findString<"u"&&e.findString!==this._findString&&(this._findString=e.findString,t.findString=this._findString,n=!0),typeof e.revealed<"u"&&e.revealed!==this._revealed&&(this._revealed=e.revealed,t.revealed=e.revealed,n=!0),typeof e.replaceRevealed<"u"&&e.replaceRevealed!==this._replaceRevealed&&(this._replaceRevealed=e.replaceRevealed,t.replaceRevealed=e.replaceRevealed,n=!0),typeof e.replaceString<"u"&&e.replaceString!==this._replaceString&&(this._replaceString=e.replaceString,t.replaceString=e.replaceString,n=!0),typeof e.matchesCount<"u"&&e.matchesCount!==this._matchesCount&&(this._matchesCount=e.matchesCount,t.matchesCount=e.matchesCount,n=!0),typeof e.matchesPosition<"u"&&e.matchesPosition!==this._matchesPosition&&(this._matchesPosition=e.matchesPosition,t.matchesPosition=e.matchesPosition,n=!0),typeof e.findBy<"u"&&e.findBy!==this._findBy&&(this._findBy=e.findBy,t.findBy=e.findBy,n=!0),typeof e.findScope<"u"&&e.findScope!==this._findScope&&(this._findScope=e.findScope,t.findScope=e.findScope,n=!0),typeof e.findDirection<"u"&&e.findDirection!==this._findDirection&&(this._findDirection=e.findDirection,t.findDirection=e.findDirection,n=!0),typeof e.caseSensitive<"u"&&e.caseSensitive!==this._caseSensitive&&(this._caseSensitive=e.caseSensitive,t.caseSensitive=e.caseSensitive,n=!0),typeof e.matchesTheWholeCell<"u"&&e.matchesTheWholeCell!==this._matchesTheWholeCell&&(this._matchesTheWholeCell=e.matchesTheWholeCell,t.matchesTheWholeCell=e.matchesTheWholeCell,n=!0),typeof e.inputtingFindString<"u"&&e.inputtingFindString!==this._inputtingFindString&&(this._inputtingFindString=e.inputtingFindString,t.inputtingFindString=e.inputtingFindString,n=!0),typeof e.findCompleted<"u"&&e.findCompleted!==this._findCompleted&&(this._findCompleted=e.findCompleted,t.findCompleted=e.findCompleted,n=!0),n&&(this._state$.next({caseSensitive:this._caseSensitive,findBy:this._findBy,findCompleted:this._findCompleted,findDirection:this._findDirection,findScope:this._findScope,findString:this._findString,inputtingFindString:this._inputtingFindString,matchesCount:this._matchesCount,matchesPosition:this._matchesPosition,matchesTheWholeCell:this._matchesTheWholeCell,replaceRevealed:this._replaceRevealed,revealed:this._revealed}),this._stateUpdates$.next(t))}}let w=class extends o.Disposable{constructor(e,n){super();c(this,"_providers",new Set);c(this,"_state",new Be);c(this,"_model");c(this,"_currentMatch$",new _.BehaviorSubject(null));c(this,"currentMatch$",this._currentMatch$.asObservable());c(this,"_replaceables$",new _.BehaviorSubject([]));c(this,"replaceables$",this._replaceables$.asObservable());c(this,"_focusSignal$",new _.Subject);c(this,"focusSignal$",this._focusSignal$.asObservable());this._injector=e,this._contextService=n}get stateUpdates$(){return this._state.stateUpdates$}get state$(){return this._state.state$}get revealed(){return this._state.revealed}get replaceRevealed(){return this._state.replaceRevealed}dispose(){super.dispose(),this._currentMatch$.next(null),this._currentMatch$.complete(),this._replaceables$.next([]),this._replaceables$.complete(),this._focusSignal$.complete()}getCurrentMatch(){var e;return(e=this._model)==null?void 0:e.getCurrentMatch()}getFindString(){return this._state.findString}changeFindString(e){this._state.changeState({findString:e})}focusFindInput(){this._focusSignal$.next()}changeInputtingFindString(e){e?this._state.changeState({inputtingFindString:e}):this._state.changeState({inputtingFindString:"",findString:""})}changeReplaceString(e){this._state.changeState({replaceString:e})}changeMatchesTheWholeCell(e){this._state.changeState({matchesTheWholeCell:e})}changeCaseSensitive(e){this._state.changeState({caseSensitive:e})}changeFindBy(e){this._state.changeState({findBy:e}),this._toggleDisplayRawFormula(e==="formula")}changeFindScope(e){this._state.changeState({findScope:e})}changeFindDirection(e){this._state.changeState({findDirection:e})}moveToNextMatch(){this._model&&(this._state.replaceRevealed&&!this._model.searched?(this._state.changeState({findString:this._state.inputtingFindString}),this._model.start()):this._model.moveToNextMatch(),this._focusSignal$.next())}moveToPreviousMatch(){this._model&&(this._state.replaceRevealed&&!this._model.searched?(this._state.changeState({findString:this._state.inputtingFindString}),this._model.start()):this._model.moveToPreviousMatch(),this._focusSignal$.next())}async replace(){return this._model?this._model.replace():!1}async replaceAll(){if(!this._model)throw new Error("[FindReplaceService] replaceAll: model is not initialized!");return this._model.replaceAll()}revealReplace(){this._state.changeState({replaceRevealed:!0,inputtingFindString:this._state.findString}),this._toggleRevealReplace(!0)}start(e=!1){if(this._providers.size===0)return!1;this._model=this._injector.createInstance(A,this._state,this._providers),this._model.currentMatch$.subscribe(t=>this._currentMatch$.next(t)),this._model.replaceables$.subscribe(t=>this._replaceables$.next(t));const n=U();return e&&(n.replaceRevealed=!0),this._state.changeState(n),this._toggleRevealReplace(e),!0}find(){var e;(e=this._model)==null||e.start()}terminate(){var e;(e=this._model)==null||e.dispose(),this._model=null,this._toggleDisplayRawFormula(!1),this._toggleRevealReplace(!1)}registerFindReplaceProvider(e){return this._providers.add(e),o.toDisposable(()=>this._providers.delete(e))}_toggleRevealReplace(e){this._contextService.setContextValue(X,e)}_toggleDisplayRawFormula(e){this._contextService.setContextValue(De.RENDER_RAW_FORMULA_KEY,e)}};w=ee([j(0,o.Inject(o.Injector)),j(1,o.IContextService)],w);const B={id:"ui.command.replace-current-match",type:o.CommandType.COMMAND,handler:i=>i.get(C).replace()},ke="CONFIRM_REPLACE_ALL",k={id:"ui.command.replace-all-matches",type:o.CommandType.COMMAND,handler:async i=>{const e=i.get(u.IConfirmService),n=i.get(o.LocaleService),t=i.get(u.IMessageService);if(!await e.confirm({id:ke,title:{title:n.t("find-replace.replace.confirm.title")},cancelText:n.t("button.cancel"),confirmText:n.t("button.confirm")}))return!1;const r=await i.get(C).replaceAll(),{success:a,failure:h}=r;return h>0?(a===0?t.show({type:p.MessageType.Error,content:n.t("find-replace.replace.all-failure")}):t.show({type:p.MessageType.Warning,content:n.t("find-replace.replace.partial-success",`${a}`,`${h}`)}),!1):(t.show({type:p.MessageType.Success,content:n.t("find-replace.replace.all-success",`${a}`)}),!0)}},y={id:"ui.operation.open-find-dialog",type:o.CommandType.OPERATION,handler:i=>{const e=i.get(C);return e.revealed?e.focusFindInput():e.start(),!0}},E={id:"ui.operation.open-replace-dialog",type:o.CommandType.OPERATION,handler:i=>{const e=i.get(C);return e.revealed?e.replaceRevealed?e.focusFindInput():e.revealReplace():e.start(!0),!0}},W={type:o.CommandType.OPERATION,id:"ui.operation.go-to-next-match",handler:i=>(i.get(C).moveToNextMatch(),!0)},G={type:o.CommandType.OPERATION,id:"ui.operation.go-to-previous-match",handler:i=>(i.get(C).moveToPreviousMatch(),!0)};function te(i){const{findCompleted:e,localeService:n,matchesCount:t,matchesPosition:s,findString:r,findReplaceService:a,onChange:h,...f}=i,v=e&&t===0?n.t("find-replace.dialog.no-result"):t===0?" ":void 0;return d.jsx(p.InputWithSlot,{autoFocus:!0,placeholder:n.t("find-replace.dialog.find-placeholder"),slot:d.jsx(p.Pager,{loop:!0,text:v,value:s,total:t,onChange:m=>{s===t&&m===1?a.moveToNextMatch():s===1&&m===t||m<s?a.moveToPreviousMatch():a.moveToNextMatch()}}),value:r,onChange:m=>h==null?void 0:h(m),...f})}const We="univer-find-replace-dialog-container",Ge="univer-find-replace-expand-container",Ve="univer-button-text",He="univer-find-replace-buttons-group",Ke="univer-find-replace-buttons-group-right",O={findReplaceDialogContainer:We,findReplaceExpandContainer:Ge,buttonText:Ve,findReplaceButtonsGroup:He,findReplaceButtonsGroupRight:Ke};function ie(i,e){const n=l.useCallback(()=>{var s;(s=document.querySelector(".univer-find-input input"))==null||s.focus()},[]),t=l.useCallback(()=>{const s=document.querySelectorAll(".univer-find-replace-dialog-container .univer-select-selection-search-input");return Array.from(s).some(r=>r===document.activeElement)},[]);return l.useImperativeHandle(e,()=>({focus:n,selectHasFocus:t})),l.useEffect(()=>{const s=i.focusSignal$.subscribe(()=>n());return()=>s.unsubscribe()},[i,n]),{focus:n,selectHasFocus:t}}const qe=l.forwardRef(function(e,n){const t=o.useDependency(o.LocaleService),s=o.useDependency(C),r=o.useDependency(o.ICommandService),a=u.useObservable(s.state$,void 0,!0),{findCompleted:h,findString:f,matchesCount:R,matchesPosition:v}=a,m=l.useCallback(()=>{r.executeCommand(E.id)},[r]),F=l.useCallback(M=>s.changeFindString(M),[s]);return ie(s,n),d.jsxs(l.Fragment,{children:[d.jsx(te,{findCompleted:h,className:"univer-find-input",matchesCount:R,matchesPosition:v,findReplaceService:s,localeService:t,findString:f,onChange:F}),d.jsx("div",{className:O.findReplaceExpandContainer,children:d.jsx(p.Button,{type:"text",size:"small",onClick:m,children:t.t("find-replace.dialog.advanced-finding")})})]})}),ze=l.forwardRef(function(e,n){const t=o.useDependency(C),s=o.useDependency(o.LocaleService),r=o.useDependency(o.ICommandService),a=o.useDependency(u.IMessageService),h=u.useObservable(t.currentMatch$,void 0,!0),f=u.useObservable(t.replaceables$,void 0,!0),R=u.useObservable(t.state$,void 0,!0),{matchesCount:v,matchesPosition:m,findString:F,inputtingFindString:M,replaceString:re,caseSensitive:ae,matchesTheWholeCell:oe,findDirection:ce,findScope:le,findBy:de,findCompleted:L}=R,ue=M.length===0,he=v===0||!(h!=null&&h.replaceable),pe=f.length===0,fe=l.useCallback(g=>t.changeInputtingFindString(g),[t]),ge=l.useCallback(g=>t.changeReplaceString(g),[t]),{focus:_e}=ie(t,n),me=l.useCallback(()=>{F===M?t.moveToNextMatch():(t.changeFindString(M),t.find())},[F,M,t]),ve=l.useCallback(()=>r.executeCommand(B.id),[r]),Se=l.useCallback(async()=>{await r.executeCommand(k.id),_e()},[r]),Ce=l.useCallback(g=>{t.changeFindDirection(g)},[t]),be=l.useCallback(g=>{t.changeFindScope(g)},[t]),Re=l.useCallback(g=>{t.changeFindBy(g)},[t]),Me=Ze(s),ye=Je(s),Ie=Qe(s);return l.useEffect(()=>{const g=L&&v===0;let x=null;return g&&(x=a.show({content:s.t("find-replace.dialog.no-match"),type:p.MessageType.Warning,duration:5e3})),()=>x==null?void 0:x.dispose()},[L,v,a,s]),d.jsxs(l.Fragment,{children:[d.jsx(p.FormLayout,{label:s.t("find-replace.dialog.find"),children:d.jsx(te,{findCompleted:L,className:"univer-find-input",matchesCount:v,matchesPosition:m,findReplaceService:t,localeService:s,findString:M,onChange:fe})}),d.jsx(p.FormLayout,{label:s.t("find-replace.dialog.replace"),children:d.jsx(p.Input,{placeholder:s.t("find-replace.dialog.replace-placeholder"),value:re,onChange:g=>ge(g)})}),d.jsx(p.FormLayout,{label:s.t("find-replace.dialog.find-direction.title"),children:d.jsx(p.Select,{value:ce,options:ye,onChange:Ce})}),d.jsx(p.FormDualColumnLayout,{children:d.jsxs(l.Fragment,{children:[d.jsx(p.FormLayout,{label:s.t("find-replace.dialog.find-scope.title"),children:d.jsx(p.Select,{value:le,options:Me,onChange:be})}),d.jsx(p.FormLayout,{label:s.t("find-replace.dialog.find-by.title"),children:d.jsx(p.Select,{value:de,options:Ie,onChange:Re})})]})}),d.jsx(p.FormDualColumnLayout,{children:d.jsxs(l.Fragment,{children:[d.jsx(p.FormLayout,{children:d.jsx(p.Checkbox,{checked:ae,onChange:g=>{t.changeCaseSensitive(g)},children:s.t("find-replace.dialog.case-sensitive")})}),d.jsx(p.FormLayout,{children:d.jsx(p.Checkbox,{checked:oe,onChange:g=>{t.changeMatchesTheWholeCell(g)},children:s.t("find-replace.dialog.match-the-whole-cell")})})]})}),d.jsxs("div",{className:O.findReplaceButtonsGroup,children:[d.jsx(p.Button,{type:"primary",onClick:me,disabled:ue,children:s.t("find-replace.dialog.find")}),d.jsxs("span",{className:O.findReplaceButtonsGroupRight,children:[d.jsx(p.Button,{disabled:he,onClick:ve,children:s.t("find-replace.dialog.replace")}),d.jsx(p.Button,{disabled:pe,onClick:Se,children:s.t("find-replace.dialog.replace-all")})]})]})]})});function Ye(){const i=o.useDependency(C),e=o.useDependency(u.ILayoutService),n=o.useDependency(o.IContextService),t=u.useObservable(i.state$,void 0,!0),s=l.useRef(null);l.useEffect(()=>{let f;return s.current&&(f=e.registerContainerElement(s.current)),()=>f==null?void 0:f.dispose()},[e]);const r=l.useRef(null),a=l.useCallback(f=>n.setContextValue(Q,f),[n]),h=l.useCallback(f=>n.setContextValue(J,f),[n]);return l.useEffect(()=>{var R;const f=_.fromEvent(document,"focusin").subscribe(v=>{var m;v.target&&((m=s.current)!=null&&m.contains(v.target))?a(!0):a(!1),!r.current||!r.current.selectHasFocus()?h(!0):h(!1)});return(R=r.current)==null||R.focus(),a(!0),h(!0),()=>{f.unsubscribe(),a(!1)}},[a,h]),d.jsx("div",{className:O.findReplaceDialogContainer,ref:s,children:t.replaceRevealed?d.jsx(ze,{ref:r}):d.jsx(qe,{ref:r})})}function Ze(i){const e=i.getCurrentLocale();return l.useMemo(()=>[{label:i.t("find-replace.dialog.find-scope.current-sheet"),value:P.SUBUNIT},{label:i.t("find-replace.dialog.find-scope.workbook"),value:P.UNIT}],[e])}function Je(i){const e=i.getCurrentLocale();return l.useMemo(()=>[{label:i.t("find-replace.dialog.find-direction.row"),value:D.ROW},{label:i.t("find-replace.dialog.find-direction.column"),value:D.COLUMN}],[e])}function Qe(i){const e=i.getCurrentLocale();return l.useMemo(()=>[{label:i.t("find-replace.dialog.find-by.value"),value:T.VALUE},{label:i.t("find-replace.dialog.find-by.formula"),value:T.FORMULA}],[e])}function I(i){return i.getContextValue(Q)}function Xe(i){return i.getContextValue(X)}function ne(i){return i.getContextValue(J)}const N="7_find-replace-shortcuts";function V(i){return i.getContextValue(o.FOCUSING_SHEET)}function H(i){return!i.getContextValue(o.EDITOR_ACTIVATED)}const et={id:y.id,description:"find-replace.shortcut.open-find-dialog",binding:u.KeyCode.F|u.MetaKeys.CTRL_COMMAND,group:N,preconditions(i){return!I(i)&&V(i)&&H(i)}},tt={id:y.id,description:"find-replace.shortcut.open-find-dialog",binding:u.KeyCode.F|u.MetaKeys.CTRL_COMMAND,mac:u.KeyCode.F|u.MetaKeys.MAC_CTRL,preconditions(i){return!I(i)&&V(i)&&H(i)}},it={id:E.id,description:"find-replace.shortcut.open-replace-dialog",binding:u.KeyCode.H|u.MetaKeys.CTRL_COMMAND,mac:u.KeyCode.H|u.MetaKeys.MAC_CTRL,group:N,preconditions(i){return V(i)&&H(i)&&(!I(i)||!Xe(i))}},nt={id:W.id,description:"find-replace.shortcut.go-to-next-match",binding:u.KeyCode.ENTER,group:N,priority:1e3,preconditions(i){return ne(i)&&I(i)}},st={id:G.id,description:"find-replace.shortcut.go-to-previous-match",binding:u.KeyCode.ENTER|u.MetaKeys.SHIFT,group:N,priority:1e3,preconditions(i){return ne(i)&&I(i)}};function rt(i){const e=i.get(o.IContextService);return{id:y.id,icon:"SearchIcon",tooltip:"find-replace.toolbar",type:u.MenuItemType.BUTTON,hidden$:u.getMenuHiddenObservable(i,o.UniverInstanceType.UNIVER_SHEET),disabled$:_.combineLatest([e.subscribeContextValue$(o.EDITOR_ACTIVATED),e.subscribeContextValue$(o.FOCUSING_SHEET)]).pipe(_.map(([n,t])=>n||!t))}}const at={[u.RibbonStartGroup.OTHERS]:{[y.id]:{order:2,menuItemFactory:rt}}};var ot=Object.defineProperty,ct=Object.getOwnPropertyDescriptor,lt=(i,e,n,t)=>{for(var s=t>1?void 0:t?ct(e,n):e,r=i.length-1,a;r>=0;r--)(a=i[r])&&(s=(t?a(e,n,s):a(s))||s);return t&&s&&ot(e,n,s),s},b=(i,e)=>(n,t)=>e(n,t,i);const K="DESKTOP_FIND_REPLACE_DIALOG",se=350,dt=20,ut=-90;exports.FindReplaceController=class extends o.RxDisposable{constructor(n,t,s,r,a,h,f,R,v,m){super();c(this,"_closingListenerDisposable");this._univerInstanceService=n,this._menuManagerService=t,this._shortcutService=s,this._commandService=r,this._findReplaceService=a,this._dialogService=h,this._layoutService=f,this._localeService=R,this._componentManager=v,this._injector=m,this._initCommands(),this._initUI(),this._initShortcuts()}dispose(){var n;super.dispose(),(n=this._closingListenerDisposable)==null||n.dispose(),this._closingListenerDisposable=null}_initCommands(){[y,E,W,G,k,B].forEach(n=>{this.disposeWithMe(this._commandService.registerCommand(n))})}_initShortcuts(){[it,et,tt,st,nt].forEach(n=>this.disposeWithMe(this._shortcutService.registerShortcut(n)))}_initUI(){this.disposeWithMe(this._componentManager.register("FindReplaceDialog",Ye)),this.disposeWithMe(this._componentManager.register("SearchIcon",Z)),this._menuManagerService.mergeMenu(at),this._findReplaceService.stateUpdates$.pipe(_.takeUntil(this.dispose$)).subscribe(n=>{n.revealed===!0&&this._openPanel()})}_openPanel(){this._dialogService.open({id:K,draggable:!0,width:se,title:{title:this._localeService.t("find-replace.dialog.title")},children:{label:"FindReplaceDialog"},destroyOnClose:!0,defaultPosition:ht(),preservePositionOnDestroy:!0,onClose:()=>this.closePanel()}),this._closingListenerDisposable=o.toDisposable(this._univerInstanceService.focused$.pipe(_.takeUntil(this.dispose$)).subscribe(n=>{(!n||!this._univerInstanceService.getUniverSheetInstance(n))&&this.closePanel()}))}closePanel(){this._closingListenerDisposable&&(this._closingListenerDisposable.dispose(),this._closingListenerDisposable=null,this._dialogService.close(K),this._findReplaceService.terminate(),queueMicrotask(()=>this._layoutService.focus()))}};exports.FindReplaceController=lt([b(0,o.IUniverInstanceService),b(1,u.IMenuManagerService),b(2,u.IShortcutService),b(3,o.ICommandService),b(4,C),b(5,u.IDialogService),b(6,u.ILayoutService),b(7,o.Inject(o.LocaleService)),b(8,o.Inject(u.ComponentManager)),b(9,o.Inject(o.Injector))],exports.FindReplaceController);function ht(){const{innerWidth:i}=window;return{x:(i-se)/2-dt,y:ut}}var pt=Object.defineProperty,ft=Object.getOwnPropertyDescriptor,gt=(i,e,n,t)=>{for(var s=t>1?void 0:t?ft(e,n):e,r=i.length-1,a;r>=0;r--)(a=i[r])&&(s=(t?a(e,n,s):a(s))||s);return t&&s&&pt(e,n,s),s},q=(i,e)=>(n,t)=>e(n,t,i);const _t="UNIVER_FIND_REPLACE_PLUGIN";var $;exports.UniverFindReplacePlugin=($=class extends o.Plugin{constructor(e=Pe,n,t){super(),this._config=e,this._injector=n,this._configService=t;const{...s}=this._config;this._configService.setConfig(Te,s)}onStarting(){[[exports.FindReplaceController],[C,{useClass:w}]].forEach(e=>this._injector.add(e))}onRendered(){this._injector.get(exports.FindReplaceController)}},c($,"pluginName",_t),$);exports.UniverFindReplacePlugin=gt([q(1,o.Inject(o.Injector)),q(2,o.IConfigService)],exports.UniverFindReplacePlugin);exports.FindBy=T;exports.FindDirection=D;exports.FindModel=we;exports.FindScope=P;exports.GoToNextMatchOperation=W;exports.GoToPreviousMatchOperation=G;exports.IFindReplaceService=C;exports.OpenFindDialogOperation=y;exports.OpenReplaceDialogOperation=E;exports.ReplaceAllMatchesCommand=k;exports.ReplaceCurrentMatchCommand=B;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const e={"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"};module.exports=e;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const e={"find-replace":{toolbar:"یافتن و جایگزینی",shortcut:{"open-find-dialog":"باز کردن پنجره گفتگوی یافتن","open-replace-dialog":"باز کردن پنجره گفتگوی جایگزینی","close-dialog":"بستن پنجره گفتگوی یافتن و جایگزینی","go-to-next-match":"رفتن به تطابق بعدی","go-to-previous-match":"رفتن به تطابق قبلی"},dialog:{title:"یافتن",find:"یافتن",replace:"جایگزینی","replace-all":"جایگزینی همه","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":"یافتن و جایگزینی"};module.exports=e;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const e={"find-replace":{toolbar:"Найти и заменить",shortcut:{"open-find-dialog":"Открыть диалог поиска","open-replace-dialog":"Открыть диалог замены","close-dialog":"Закрыть диалог поиска и замены","go-to-next-match":"Перейти к следующему совпадению","go-to-previous-match":"Перейти к предыдущему совпадению"},dialog:{title:"Найти",find:"Найти",replace:"Заменить","replace-all":"Заменить все","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":"Найти и заменить"};module.exports=e;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const t={"find-replace":{toolbar:"Tìm kiếm và Thay thế",shortcut:{"open-find-dialog":"Mở hộp thoại tìm kiếm","open-replace-dialog":"Mở hộp thoại thay thế","close-dialog":"Đóng hộp thoại tìm kiếm và thay thế","go-to-next-match":"Đến mục khớp tiếp theo","go-to-previous-match":"Đến mục khớp trước đó"},dialog:{title:"Tìm kiếm",find:"Tìm kiếm",replace:"Thay thế","replace-all":"Thay thế tất cả","find-placeholder":"Nhập nội dung tìm kiếm","advanced-finding":"Thay thế / Tìm kiếm nâng cao","replace-placeholder":"Nhập nội dung thay thế","case-sensitive":"Phân biệt chữ hoa chữ thường","match-the-whole-cell":"Khớp toàn bộ ô","find-scope":{title:"Phạm vi tìm kiếm","current-sheet":"Bảng hiện tại",workbook:"Toàn bộ sổ làm việc"},"find-direction":{title:"Thứ tự tìm kiếm",column:"Tìm theo cột",row:"Tìm theo hàng"},"find-by":{title:"Phương thức tìm kiếm",formula:"Tìm công thức",value:"Tìm giá trị"},"no-match":"Đã hoàn thành tìm kiếm nhưng không tìm thấy mục nào khớp","no-result":"Không có kết quả"},replace:{"all-success":"Đã thay thế tất cả {0} mục khớp","all-failure":"Thay thế thất bại",confirm:{title:"Bạn có chắc muốn thay thế tất cả các mục khớp không?"}}},"find-replace-shortcuts":"Tìm kiếm và Thay thế"};module.exports=t;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const e={"find-replace":{toolbar:"查找替换",shortcut:{"open-find-dialog":"打开查找对话框","open-replace-dialog":"打开替换对话框","close-dialog":"关闭查找替换对话框","go-to-next-match":"下一个匹配项","go-to-previous-match":"下一个匹配项"},dialog:{title:"查找",find:"查找",replace:"替换","replace-all":"替换全部","find-placeholder":"输入查找内容","advanced-finding":"替换 / 高级查找","replace-placeholder":"输入替换内容","case-sensitive":"匹配大小写","match-the-whole-cell":"匹配整个单元格","find-scope":{title:"查找范围","current-sheet":"当前子表",workbook:"整个工作簿"},"find-direction":{title:"查找顺序",column:"按列查找",row:"按行查找"},"find-by":{title:"查找方式",formula:"查找公式",value:"查找值"},"no-match":"已完成搜索,但是未找到任何匹配项","no-result":"无结果"},replace:{"all-success":"已全部替换 {0} 个匹配项","all-failure":"替换失败",confirm:{title:"确定要替换所有的匹配项吗?"}}},"find-replace-shortcuts":"查找替换"};module.exports=e;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const e={"find-replace":{toolbar:"尋找替換",shortcut:{"open-find-dialog":"開啟尋找對話框","open-replace-dialog":"開啟替換對話框","close-dialog":"關閉查找替換對話框","go-to-next-match":"下一個匹配項","go-to-previous-match":"下一個匹配項"},dialog:{title:"找",find:"找",replace:"替換","replace-all":"替換全部","find-placeholder":"輸入查找內容","advanced-finding":"取代 / 進階查找","replace-placeholder":"輸入替換內容","case-sensitive":"匹配大小寫","match-the-whole-cell":"符合整個儲存格","find-scope":{title:"找出範圍","current-sheet":"目前子表",workbook:"整個工作簿"},"find-direction":{title:"找出順序",column:"按列查找",row:"按行查找"},"find-by":{title:"找出方式",formula:"找出公式",value:"查找值"},"no-match":"已完成搜索,但是未找到任何匹配項","no-result":"無結果"},replace:{"all-success":"已全部替換 {0} 個匹配項","all-failure":"替換失敗",confirm:{title:"確定要取代所有的符合項目嗎? "}}},"find-replace-shortcuts":"尋找替換"};module.exports=e;
|