p3x-redis-ui-material
Version:
💿 P3X Redis UI triple frontend — Angular + React/MUI + Vue/Vuetify with 54 languages, 7 themes, Socket.IO, desktop notifications, and full feature parity
1 lines • 7.69 kB
JavaScript
import {X as Xe,cV as z,d1 as Ue,f as fQ,b8 as T,G as It,K as op,Q,F as x,_ as _e,m as mb,cW as zt,cX as jt,cY as Vt,cZ as Nt,e as aY,aK as iY,g as _A,y as yt$1,w as wt,d as ae,s as se,i as Qt,j as gt,B as Ba,I as IS,v as vf,k as bv,n as no,h as hv,c as In,R as Rv,r as ro,a$ as rc,b0 as Df,b1 as Ef,J as JT,t as If,x as YT,z as fm,A as pm,p as pv}from'./chunk-BwlFOdbx.js';import {w}from'./chunk-4F4EzhXh.js';import {L}from'./main-HNF44SV3.js';import {Q as Q$1}from'./chunk-BnyV8OX_.js';var bt=["editorContainer"];function yt(o,_){o&1&&(Ba(0,"mat-dialog-content",4),hv(1,"div",11,0),vf());}function St(o,_){if(o&1&&(Ba(0,"mat-dialog-content",5),IS(1),vf()),o&2){let t=JT();In(),If(" ",t.strings().label?.jsonViewNotParsable," ");}}function Mt(o,_){if(o&1){let t=YT();Ba(0,"button",12),bv("click",function(){fm(t);let e=JT(2);return pm(e.save(true))}),Ba(1,"mat-icon"),IS(2,"save"),vf(),Ba(3,"mat-icon"),IS(4,"format_line_spacing"),vf(),Ba(5,"span",8),IS(6),vf()();}if(o&2){let t=JT(2);pv("matTooltip",t.strings().intention?.saveWithFormatJson),In(6),Rv(t.strings().intention?.saveWithFormatJson);}}function Et(o,_){if(o&1){let t=YT();Ba(0,"button",12),bv("click",function(){fm(t);let e=JT();return pm(e.save(false))}),Ba(1,"mat-icon"),IS(2,"save"),vf(),Ba(3,"span",8),IS(4),vf()(),no(5,Mt,7,2,"button",13);}if(o&2){let t=JT();pv("matTooltip",t.strings().intention?.save),In(4),Rv(t.strings().intention?.save),In(),ro(t.hideFormatSave?-1:5);}}var Gt=(()=>{class o{dialogRef;data;i18n;theme;common;breakpointObserver;state;settings;diffDialog;editorContainer;isJson=false;isReadonly=false;hideFormatSave=false;lineWrap=true;minHeight="400px";strings;editorView;wrapCompartment;EditorViewClass;obj;resizeHandler;constructor(t,n,e,r,h,g,x,w,C){this.dialogRef=t,this.data=n,this.i18n=e,this.theme=r,this.common=h,this.breakpointObserver=g,this.state=x,this.settings=w,this.diffDialog=C,this.strings=this.i18n.strings;}ngOnInit(){try{this.obj=JSON.parse(this.data.value),this.isJson=!0;}catch(t){this.obj=void 0,this.isJson=false;}this.isReadonly=this.state.connection()?.readonly===true,this.hideFormatSave=this.data.hideFormatSave===true,this.updateMinHeight();}ngAfterViewInit(){return L(this,null,function*(){if(!this.isJson||!this.editorContainer)return;let{EditorView:t,keymap:n,lineNumbers:e,highlightActiveLineGutter:r,highlightSpecialChars:h,drawSelection:g,highlightActiveLine:x,rectangularSelection:w,crosshairCursor:C}=yield import('./chunk-CSgt_bzr.js').then(function(n){return n.d}),{EditorState:V,Compartment:at}=yield import('./chunk-OaLmDfu9.js');this.wrapCompartment=new at;let{json:rt}=yield import('./chunk-3Sg4CRRl.js'),{defaultKeymap:st,history:lt,historyKeymap:ct}=yield import('./chunk-C4-xh9ra.js'),{bracketMatching:mt,foldGutter:dt,foldKeymap:pt,indentOnInput:ht,syntaxHighlighting:gt,defaultHighlightStyle:ut}=yield import('./chunk-C9L1hxzX.js').then(function(n){return n.f}),{closeBrackets:ft,closeBracketsKeymap:_t}=yield import('./chunk-CjGpa3ws.js'),{searchKeymap:xt,highlightSelectionMatches:wt}=yield import('./chunk-BAVDuOhs.js'),{lintKeymap:Ct}=yield import('./chunk-C5Ei9pNs.js'),v;if(this.theme.isDark()){let{oneDark:b}=yield import('./chunk-B1DR_Rcs.js');v=b;}else {let{githubLight:b}=yield import('./chunk-wDa_nd1d.js');v=b;}let vt=JSON.stringify(this.obj,null,this.settings.jsonFormat()??2);this.EditorViewClass=t,this.editorView=new t({state:V.create({doc:vt,extensions:[e(),r(),h(),lt(),dt(),g(),ht(),gt(ut,{fallback:true}),mt(),ft(),w(),C(),x(),wt(),n.of([..._t,...st,...xt,...ct,...pt,...Ct]),rt(),v,t.theme({"&":{height:"calc(90vh - 100px)","max-height":"calc(90vh - 100px)"},".cm-scroller":{overflow:"auto","scrollbar-width":"auto"},".cm-scroller::-webkit-scrollbar":{height:"12px",display:"block"},".cm-scroller::-webkit-scrollbar-track":{background:"rgba(128, 128, 128, 0.1)"},".cm-scroller::-webkit-scrollbar-thumb":{background:"rgba(128, 128, 128, 0.4)","border-radius":"6px"},".cm-scroller::-webkit-scrollbar-thumb:hover":{background:"rgba(128, 128, 128, 0.6)"}}),this.wrapCompartment.of(this.lineWrap?t.lineWrapping:[]),V.readOnly.of(this.isReadonly)]}),parent:this.editorContainer.nativeElement}),this.resizeHandler=()=>{this.updateMinHeight();},window.addEventListener("resize",this.resizeHandler);})}ngOnDestroy(){this.resizeHandler&&window.removeEventListener("resize",this.resizeHandler),this.editorView&&(this.editorView.destroy(),this.editorView=void 0);}toggleWrap(){this.lineWrap=!this.lineWrap,this.editorView&&this.wrapCompartment&&this.EditorViewClass&&this.editorView.dispatch({effects:this.wrapCompartment.reconfigure(this.lineWrap?this.EditorViewClass.lineWrapping:[])});}save(t){return L(this,null,function*(){try{let n=this.editorView.state.doc.toString(),e=JSON.parse(n),r=JSON.stringify(e,null,t?this.settings.jsonFormat()??2:0),h=this.state.connection()?.name||"key";if(!(yield this.diffDialog.show({keyName:h,oldValue:this.data.value,newValue:r})))return;this.dialogRef.close({obj:r});}catch(n){this.common.generalHandleError(n);}})}close(){this.dialogRef.close(void 0);}updateMinHeight(){let t=this.breakpointObserver.isMatched("(max-width: 959px)");this.minHeight=t?"100%":`${Math.max(10,window.innerHeight-100)}px`;}static \u0275fac=function(n){return new(n||o)(Xe(z),Xe(Ue),Xe(fQ),Xe(T),Xe(It),Xe(op),Xe(Q),Xe(x),Xe(w))};static \u0275cmp=_e({type:o,selectors:[["p3xr-json-editor-dialog"]],viewQuery:function(n,e){if(n&1&&rc(bt,5),n&2){let r;Df(r=Ef())&&(e.editorContainer=r.first);}},decls:20,vars:5,consts:[["editorContainer",""],[1,"p3xr-dialog-toolbar","p3xr-mat-layout-strong"],["mat-dialog-title","",1,"p3xr-dialog-title","p3xr-dialog-title-with-icon"],["mat-icon-button","",3,"click"],[1,"p3xr-dialog-content","p3xr-dialog-content-mono","p3xr-dialog-content-editor"],[1,"p3xr-dialog-content","p3xr-dialog-content-mono","p3xr-dialog-content-message"],[1,"p3xr-dialog-actions"],["mat-raised-button","","type","button",1,"btn-accent",3,"click"],[1,"hide-sm"],[2,"flex","1"],[3,"cancel"],[1,"p3xr-codemirror-host"],["mat-raised-button","","type","button",1,"btn-primary",3,"click","matTooltip"],["mat-raised-button","","type","button",1,"btn-primary",3,"matTooltip"]],template:function(n,e){n&1&&(Ba(0,"mat-toolbar",1)(1,"span",2)(2,"mat-icon"),IS(3,"edit"),vf(),Ba(4,"span"),IS(5),vf()(),Ba(6,"button",3),bv("click",function(){return e.close()}),Ba(7,"mat-icon"),IS(8,"close"),vf()()(),no(9,yt,3,0,"mat-dialog-content",4)(10,St,2,1,"mat-dialog-content",5),Ba(11,"mat-dialog-actions",6)(12,"button",7),bv("click",function(){return e.toggleWrap()}),Ba(13,"mat-icon"),IS(14),vf(),Ba(15,"span",8),IS(16),vf()(),hv(17,"span",9),Ba(18,"p3xr-dialog-cancel",10),bv("cancel",function(){return e.close()}),vf(),no(19,Et,6,3),vf()),n&2&&(In(5),Rv(e.strings().intention?.jsonViewEditor),In(4),ro(e.isJson?9:10),In(5),Rv(e.lineWrap?"wrap_text":"notes"),In(2),Rv(e.lineWrap?e.strings().intention?.unwrap:e.strings().intention?.wrap),In(3),ro(e.isJson&&!e.isReadonly?19:-1));},dependencies:[mb,zt,jt,Vt,Nt,aY,iY,_A,yt$1,wt,ae,se,Qt,gt,Q$1],styles:[".hide-sm[_ngcontent-%COMP%]{display:inline}.p3xr-dialog-content-editor[_ngcontent-%COMP%]{padding:0!important;overflow:hidden!important;max-height:none!important}.p3xr-dialog-content-message[_ngcontent-%COMP%]{min-height:320px}.p3xr-codemirror-host[_ngcontent-%COMP%]{height:calc(90vh - 100px)}.p3xr-codemirror-host[_ngcontent-%COMP%] .cm-editor[_ngcontent-%COMP%]{height:100%!important;max-height:100%!important}.p3xr-codemirror-host[_ngcontent-%COMP%] .cm-scroller[_ngcontent-%COMP%]{overflow:auto!important;min-height:0!important}@media(max-width:959px){.hide-sm[_ngcontent-%COMP%]{display:none}}"],changeDetection:1})}return o})();export{Gt as JsonEditorDialogComponent};