UNPKG

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 • 11.1 kB
import{d as e,m as t,p as n,s as r,y as i}from"./dist-CQkORLgM.js";import{c as a,h as o,m as s,o as c,r as l,t as u,u as d}from"./dist-UgqBTi89.js";var f=class{constructor(e,t,n){this.from=e,this.to=t,this.diagnostic=n}},p=class t{constructor(e,t,n){this.diagnostics=e,this.panel=t,this.selected=n}static init(n,r,i){let a=i.facet(D).markerFilter;a&&(n=a(n,i));let o=n.slice().sort((e,t)=>e.from-t.from||e.to-t.to),s=new e,c=[],l=0,d=i.doc.iter(),f=0,p=i.doc.length;for(let e=0;;){let t=e==o.length?null:o[e];if(!t&&!c.length)break;let n,r;if(c.length)n=l,r=c.reduce((e,t)=>Math.min(e,t.to),t&&t.from>n?t.from:1e8);else{if(n=t.from,n>p)break;r=t.to,c.push(t),e++}for(;e<o.length;){let t=o[e];if(t.from==n&&(t.to>t.from||t.to==n))c.push(t),e++,r=Math.min(t.to,r);else{r=Math.min(t.from,r);break}}r=Math.min(r,p);let i=!1;if(c.some(e=>e.from==n&&(e.to==r||r==p))&&(i=n==r,!i&&r-n<10)){let e=n-(f+d.value.length);e>0&&(d.next(e),f=n);for(let e=n;;){if(e>=r){i=!0;break}if(!d.lineBreak&&f+d.value.length>e)break;e=f+d.value.length,f+=d.value.length,d.next()}}let a=R(c);if(i)s.add(n,n,u.widget({widget:new j(a),diagnostics:c.slice()}));else{let e=c.reduce((e,t)=>t.markClass?e+` `+t.markClass:e,``);s.add(n,r,u.mark({class:`cm-lintRange cm-lintRange-`+a+e,diagnostics:c.slice(),inclusiveEnd:c.some(e=>e.to>r)}))}if(l=r,l==p)break;for(let e=0;e<c.length;e++)c[e].to<=l&&c.splice(e--,1)}let h=s.finish();return new t(h,r,m(h))}};function m(e,t=null,n=0){let r=null;return e.between(n,1e9,(e,n,{spec:i})=>{if(!(t&&i.diagnostics.indexOf(t)<0))if(!r)r=new f(e,n,t||i.diagnostics[0]);else if(i.diagnostics.indexOf(r.diagnostic)<0)return!1;else r=new f(r.from,n,r.diagnostic)}),r}function h(e,t){let n=t.pos,r=t.end||n,i=e.state.facet(D).hideOn(e,n,r);if(i!=null)return i;let a=e.startState.doc.lineAt(t.pos);return!!(e.effects.some(e=>e.is(_))||e.changes.touchesRange(a.from,Math.max(a.to,r)))}function g(e,t){return e.field(b,!1)?t:t.concat(n.appendConfig.of(z))}var _=n.define(),v=n.define(),y=n.define(),b=t.define({create(){return new p(u.none,null,null)},update(e,t){if(t.docChanged&&e.diagnostics.size){let n=e.diagnostics.map(t.changes),r=null,i=e.panel;if(e.selected){let i=t.changes.mapPos(e.selected.from,1);r=m(n,e.selected.diagnostic,i)||m(n,null,i)}!n.size&&i&&t.state.facet(D).autoPanel&&(i=null),e=new p(n,i,r)}for(let n of t.effects)if(n.is(_)){let r=t.state.facet(D).autoPanel?n.value.length?N.open:null:e.panel;e=p.init(n.value,r,t.state)}else n.is(v)?e=new p(e.diagnostics,n.value?N.open:null,e.selected):n.is(y)&&(e=new p(e.diagnostics,e.panel,n.value));return e},provide:e=>[s.from(e,e=>e.panel),l.decorations.from(e,e=>e.diagnostics)]}),x=u.mark({class:`cm-lintRange cm-lintRange-active`});function S(e,t,n){let{diagnostics:r}=e.state.field(b),i,a=-1,o=-1;r.between(t-+(n<0),t+ +(n>0),(e,r,{spec:s})=>{if(t>=e&&t<=r&&(e==r||(t>e||n>0)&&(t<r||n<0)))return i=s.diagnostics,a=e,o=r,!1});let s=e.state.facet(D).tooltipFilter;return i&&s&&(i=s(i,e.state)),i?{pos:a,end:o,above:e.state.doc.lineAt(a).to<o,create(){return{dom:C(e,i)}}}:null}function C(e,t){return o(`ul`,{class:`cm-tooltip-lint`},t.map(t=>A(e,t,!1)))}var w=e=>{let t=e.state.field(b,!1);(!t||!t.panel)&&e.dispatch({effects:g(e.state,[v.of(!0)])});let n=a(e,N.open);return n&&n.dom.querySelector(`.cm-panel-lint ul`).focus(),!0},T=e=>{let t=e.state.field(b,!1);return!t||!t.panel?!1:(e.dispatch({effects:v.of(!1)}),!0)},E=[{key:`Mod-Shift-m`,run:w,preventDefault:!0},{key:`F8`,run:e=>{let t=e.state.field(b,!1);if(!t)return!1;let n=e.state.selection.main,r=m(t.diagnostics,null,n.to+1);return!r&&(r=m(t.diagnostics,null,0),!r||r.from==n.from&&r.to==n.to)?!1:(e.dispatch({selection:{anchor:r.from,head:r.to},scrollIntoView:!0}),!0)}}],D=r.define({combine(e){return{sources:e.map(e=>e.source).filter(e=>e!=null),...i(e.map(e=>e.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{delay:Math.max,markerFilter:O,tooltipFilter:O,needsRefresh:(e,t)=>e?t?n=>e(n)||t(n):e:t,hideOn:(e,t)=>e?t?(n,r,i)=>e(n,r,i)||t(n,r,i):e:t,autoPanel:(e,t)=>e||t})}}});function O(e,t){return e?t?(n,r)=>t(e(n,r),r):e:t}function k(e){let t=[];if(e)actions:for(let{name:n}of e){for(let e=0;e<n.length;e++){let r=n[e];if(/[a-zA-Z]/.test(r)&&!t.some(e=>e.toLowerCase()==r.toLowerCase())){t.push(r);continue actions}}t.push(``)}return t}function A(e,t,n){let r=n?k(t.actions):[];return o(`li`,{class:`cm-diagnostic cm-diagnostic-`+t.severity},o(`span`,{class:`cm-diagnosticText`},t.renderMessage?t.renderMessage(e):t.message),t.actions?.map((n,i)=>{let a=!1,s=r=>{if(r.preventDefault(),a)return;a=!0;let i=m(e.state.field(b).diagnostics,t);i&&n.apply(e,i.from,i.to)},{name:c}=n,l=r[i]?c.indexOf(r[i]):-1,u=l<0?c:[c.slice(0,l),o(`u`,c.slice(l,l+1)),c.slice(l+1)];return o(`button`,{type:`button`,class:`cm-diagnosticAction`+(n.markClass?` `+n.markClass:``),onclick:s,onmousedown:s,"aria-label":` Action: ${c}${l<0?``:` (access key "${r[i]})"`}.`},u)}),t.source&&o(`div`,{class:`cm-diagnosticSource`},t.source))}var j=class extends c{constructor(e){super(),this.sev=e}eq(e){return e.sev==this.sev}toDOM(){return o(`span`,{class:`cm-lintPoint cm-lintPoint-`+this.sev})}},M=class{constructor(e,t){this.diagnostic=t,this.id=`item_`+Math.floor(Math.random()*4294967295).toString(16),this.dom=A(e,t,!0),this.dom.id=this.id,this.dom.setAttribute(`role`,`option`)}},N=class e{constructor(e){this.view=e,this.items=[];let t=t=>{if(!(t.ctrlKey||t.altKey||t.metaKey)){if(t.keyCode==27)T(this.view),this.view.focus();else if(t.keyCode==38||t.keyCode==33)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(t.keyCode==40||t.keyCode==34)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(t.keyCode==36)this.moveSelection(0);else if(t.keyCode==35)this.moveSelection(this.items.length-1);else if(t.keyCode==13)this.view.focus();else if(t.keyCode>=65&&t.keyCode<=90&&this.selectedIndex>=0){let{diagnostic:n}=this.items[this.selectedIndex],r=k(n.actions);for(let i=0;i<r.length;i++)if(r[i].toUpperCase().charCodeAt(0)==t.keyCode){let t=m(this.view.state.field(b).diagnostics,n);t&&n.actions[i].apply(e,t.from,t.to)}}else return;t.preventDefault()}},n=e=>{for(let t=0;t<this.items.length;t++)this.items[t].dom.contains(e.target)&&this.moveSelection(t)};this.list=o(`ul`,{tabIndex:0,role:`listbox`,"aria-label":this.view.state.phrase(`Diagnostics`),onkeydown:t,onclick:n}),this.dom=o(`div`,{class:`cm-panel-lint`},this.list,o(`button`,{type:`button`,name:`close`,"aria-label":this.view.state.phrase(`close`),onclick:()=>T(this.view)},`×`)),this.update()}get selectedIndex(){let e=this.view.state.field(b).selected;if(!e)return-1;for(let t=0;t<this.items.length;t++)if(this.items[t].diagnostic==e.diagnostic)return t;return-1}update(){let{diagnostics:e,selected:t}=this.view.state.field(b),n=0,r=!1,i=null,a=new Set;for(e.between(0,this.view.state.doc.length,(e,o,{spec:s})=>{for(let e of s.diagnostics){if(a.has(e))continue;a.add(e);let o=-1,s;for(let t=n;t<this.items.length;t++)if(this.items[t].diagnostic==e){o=t;break}o<0?(s=new M(this.view,e),this.items.splice(n,0,s),r=!0):(s=this.items[o],o>n&&(this.items.splice(n,o-n),r=!0)),t&&s.diagnostic==t.diagnostic?s.dom.hasAttribute(`aria-selected`)||(s.dom.setAttribute(`aria-selected`,`true`),i=s):s.dom.hasAttribute(`aria-selected`)&&s.dom.removeAttribute(`aria-selected`),n++}});n<this.items.length&&!(this.items.length==1&&this.items[0].diagnostic.from<0);)r=!0,this.items.pop();this.items.length==0&&(this.items.push(new M(this.view,{from:-1,to:-1,severity:`info`,message:this.view.state.phrase(`No diagnostics`)})),r=!0),i?(this.list.setAttribute(`aria-activedescendant`,i.id),this.view.requestMeasure({key:this,read:()=>({sel:i.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:e,panel:t})=>{let n=t.height/this.list.offsetHeight;e.top<t.top?this.list.scrollTop-=(t.top-e.top)/n:e.bottom>t.bottom&&(this.list.scrollTop+=(e.bottom-t.bottom)/n)}})):this.selectedIndex<0&&this.list.removeAttribute(`aria-activedescendant`),r&&this.sync()}sync(){let e=this.list.firstChild;function t(){let t=e;e=t.nextSibling,t.remove()}for(let n of this.items)if(n.dom.parentNode==this.list){for(;e!=n.dom;)t();e=n.dom.nextSibling}else this.list.insertBefore(n.dom,e);for(;e;)t()}moveSelection(e){if(this.selectedIndex<0)return;let t=m(this.view.state.field(b).diagnostics,this.items[e].diagnostic);t&&this.view.dispatch({selection:{anchor:t.from,head:t.to},scrollIntoView:!0,effects:y.of(t)})}static open(t){return new e(t)}};function P(e,t=`viewBox="0 0 40 40"`){return`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${t}>${encodeURIComponent(e)}</svg>')`}function F(e){return P(`<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="${e}" fill="none" stroke-width=".7"/>`,`width="6" height="3"`)}var I=l.baseTheme({".cm-diagnostic":{padding:`3px 6px 3px 8px`,marginLeft:`-1px`,display:`block`,whiteSpace:`pre-wrap`},".cm-diagnostic-error":{borderLeft:`5px solid #d11`},".cm-diagnostic-warning":{borderLeft:`5px solid orange`},".cm-diagnostic-info":{borderLeft:`5px solid #999`},".cm-diagnostic-hint":{borderLeft:`5px solid #66d`},".cm-diagnosticAction":{font:`inherit`,border:`none`,padding:`2px 4px`,backgroundColor:`#444`,color:`white`,borderRadius:`3px`,marginLeft:`8px`,cursor:`pointer`},".cm-diagnosticSource":{fontSize:`70%`,opacity:.7},".cm-lintRange":{backgroundPosition:`left bottom`,backgroundRepeat:`repeat-x`,paddingBottom:`0.7px`},".cm-lintRange-error":{backgroundImage:F(`#d11`)},".cm-lintRange-warning":{backgroundImage:F(`orange`)},".cm-lintRange-info":{backgroundImage:F(`#999`)},".cm-lintRange-hint":{backgroundImage:F(`#66d`)},".cm-lintRange-active":{backgroundColor:`#ffdd9980`},".cm-tooltip-lint":{padding:0,margin:0},".cm-lintPoint":{position:`relative`,"&:after":{content:`""`,position:`absolute`,bottom:0,left:`-2px`,borderLeft:`3px solid transparent`,borderRight:`3px solid transparent`,borderBottom:`4px solid #d11`}},".cm-lintPoint-warning":{"&:after":{borderBottomColor:`orange`}},".cm-lintPoint-info":{"&:after":{borderBottomColor:`#999`}},".cm-lintPoint-hint":{"&:after":{borderBottomColor:`#66d`}},".cm-panel.cm-panel-lint":{position:`relative`,"& ul":{maxHeight:`100px`,overflowY:`auto`,"& [aria-selected]":{backgroundColor:`#ddd`,"& u":{textDecoration:`underline`}},"&:focus [aria-selected]":{background_fallback:`#bdf`,backgroundColor:`Highlight`,color_fallback:`white`,color:`HighlightText`},"& u":{textDecoration:`none`},padding:0,margin:0},"& [name=close]":{position:`absolute`,top:`0`,right:`2px`,background:`inherit`,border:`none`,font:`inherit`,padding:0,margin:0}},"&dark .cm-lintRange-active":{backgroundColor:`#86714a80`},"&dark .cm-panel.cm-panel-lint ul":{"& [aria-selected]":{backgroundColor:`#2e343e`}}});function L(e){return e==`error`?4:e==`warning`?3:e==`info`?2:1}function R(e){let t=`hint`,n=1;for(let r of e){let e=L(r.severity);e>n&&(n=e,t=r.severity)}return t}var z=[b,l.decorations.compute([b],e=>{let{selected:t,panel:n}=e.field(b);return!t||!n||t.from==t.to?u.none:u.set([x.range(t.from,t.to)])}),d(S,{hideOn:h}),I];export{E as lintKeymap};