UNPKG

@platformos/pos-cli

Version:
2 lines (1 loc) 6.99 kB
import{S as le,i as ae,s as ne,d as g,O as ie,x as ce,o as L,p as C,R as fe,H as ue,F as G,b as B,c as p,J as z,z as b,e as v,f as I,h as K,K as P,j as k,k as A,l as Y,N as de,W as he,a5 as re,n as R,E as F,I as J,L as Q,M as W,X as _e,a3 as me,a as pe,Q as M,g as be,t as ge,C as Z,m as ve,u as ke,q as Ee,r as ye}from"../chunks/n7YEDvJi.js";import"../chunks/IHki7fMi.js";import{e as x}from"../chunks/DMhVG_ro.js";import{f as Se}from"../chunks/BaKpYqK2.js";import{p as Ie}from"../chunks/DjNrOAme.js";import{s as ee}from"../chunks/Bp_ajb_u.js";import{t as we}from"../chunks/t7b_BBSP.js";import{I as oe}from"../chunks/DHO4ENnJ.js";function te(i,e,t){const r=i.slice();return r[15]=e[t],r[17]=t,r}function Ce(i){let e,t,r;return t=new oe({props:{icon:"search",size:"18"}}),{c(){e=k("i"),W(t.$$.fragment),this.h()},l(o){e=v(o,"I",{class:!0});var l=I(e);Q(t.$$.fragment,l),l.forEach(g),this.h()},h(){b(e,"class","svelte-117f3bg")},m(o,l){B(o,e,l),J(t,e,null),r=!0},p:R,i(o){r||(C(t.$$.fragment,o),r=!0)},o(o){L(t.$$.fragment,o),r=!1},d(o){o&&g(e),F(t)}}}function De(i){let e,t,r="Reset filter",o,l,d,s,a;return l=new oe({props:{icon:"x",size:"18"}}),{c(){e=k("button"),t=k("span"),t.textContent=r,o=A(),W(l.$$.fragment),this.h()},l(n){e=v(n,"BUTTON",{class:!0});var m=I(e);t=v(m,"SPAN",{class:!0,"data-svelte-h":!0}),P(t)!=="svelte-8g7ehw"&&(t.textContent=r),o=K(m),Q(l.$$.fragment,m),m.forEach(g),this.h()},h(){b(t,"class","label"),b(e,"class","svelte-117f3bg")},m(n,m){B(n,e,m),p(e,t),p(e,o),J(l,e,null),d=!0,s||(a=z(e,"click",i[8]),s=!0)},p:R,i(n){d||(C(l.$$.fragment,n),d=!0)},o(n){L(l.$$.fragment,n),d=!1},d(n){n&&g(e),F(l),s=!1,a()}}}function se(i){let e,t,r=i[15].name+"",o,l,d,s;return{c(){e=k("li"),t=k("a"),o=ge(r),d=A(),this.h()},l(a){e=v(a,"LI",{});var n=I(e);t=v(n,"A",{href:!0,class:!0});var m=I(t);o=be(m,r),m.forEach(g),d=K(n),n.forEach(g),this.h()},h(){b(t,"href",l="/database/table/"+i[15].id),b(t,"class","svelte-117f3bg"),M(t,"active",i[15].id===i[4].params.id)},m(a,n){B(a,e,n),p(e,t),p(t,o),p(e,d)},p(a,n){n&1&&r!==(r=a[15].name+"")&&pe(o,r),n&1&&l!==(l="/database/table/"+a[15].id)&&b(t,"href",l),n&17&&M(t,"active",a[15].id===a[4].params.id)},i(a){a&&(s||_e(()=>{s=me(e,Se,{duration:100,delay:7*i[17]}),s.start()}))},o:R,d(a){a&&g(e)}}}function $e(i){let e,t,r,o,l,d,s,a,n,m="Ctrl",y,j="K",V,D,$,N,H,c;const T=[De,Ce],S=[];function U(f,_){return f[3]?0:1}o=U(i),l=S[o]=T[o](i);let w=x(i[0]),h=[];for(let f=0;f<w.length;f+=1)h[f]=se(te(i,w,f));return{c(){e=k("aside"),t=k("div"),r=k("div"),l.c(),d=A(),s=k("input"),a=A(),n=k("kbd"),n.textContent=m,y=k("kbd"),y.textContent=j,V=A(),D=k("nav"),$=k("ul");for(let f=0;f<h.length;f+=1)h[f].c();this.h()},l(f){e=v(f,"ASIDE",{class:!0});var _=I(e);t=v(_,"DIV",{class:!0});var E=I(t);r=v(E,"DIV",{class:!0});var u=I(r);l.l(u),d=K(u),s=v(u,"INPUT",{type:!0,placeholder:!0,class:!0}),a=K(u),n=v(u,"KBD",{class:!0,"data-svelte-h":!0}),P(n)!=="svelte-1c7qffr"&&(n.textContent=m),y=v(u,"KBD",{class:!0,"data-svelte-h":!0}),P(y)!=="svelte-3k5xuj"&&(y.textContent=j),u.forEach(g),E.forEach(g),V=K(_),D=v(_,"NAV",{class:!0});var q=I(D);$=v(q,"UL",{});var X=I($);for(let O=0;O<h.length;O+=1)h[O].l(X);X.forEach(g),q.forEach(g),_.forEach(g),this.h()},h(){b(s,"type","text"),b(s,"placeholder","Search tables"),b(s,"class","svelte-117f3bg"),b(n,"class","svelte-117f3bg"),b(y,"class","svelte-117f3bg"),b(r,"class","filter svelte-117f3bg"),b(t,"class","filter-container svelte-117f3bg"),b(D,"class","svelte-117f3bg"),b(e,"class","svelte-117f3bg")},m(f,_){B(f,e,_),p(e,t),p(t,r),S[o].m(r,null),p(r,d),p(r,s),i[9](s),G(s,i[3]),p(r,a),p(r,n),p(r,y),p(e,V),p(e,D),p(D,$);for(let E=0;E<h.length;E+=1)h[E]&&h[E].m($,null);i[11](e),N=!0,H||(c=[z(s,"input",i[10]),z(s,"input",i[5]),z(s,"keydown",i[6]),z(e,"keydown",i[7])],H=!0)},p(f,[_]){let E=o;if(o=U(f),o===E?S[o].p(f,_):(fe(),L(S[E],1,1,()=>{S[E]=null}),ue(),l=S[o],l?l.p(f,_):(l=S[o]=T[o](f),l.c()),C(l,1),l.m(r,d)),_&8&&s.value!==f[3]&&G(s,f[3]),_&17){w=x(f[0]);let u;for(u=0;u<w.length;u+=1){const q=te(f,w,u);h[u]?(h[u].p(q,_),C(h[u],1)):(h[u]=se(q),h[u].c(),C(h[u],1),h[u].m($,null))}for(;u<h.length;u+=1)h[u].d(1);h.length=w.length}},i(f){if(!N){C(l);for(let _=0;_<w.length;_+=1)C(h[_]);N=!0}},o(f){L(l),N=!1},d(f){f&&g(e),S[o].d(),i[9](null),ie(h,f),i[11](null),H=!1,ce(c)}}}function qe(i,e,t){let r,o;Y(i,Ie,c=>t(4,r=c)),Y(i,ee,c=>t(13,o=c));let l=o.tables,d=l,s,a,n;(async()=>await we.get())().then(c=>{l=c,t(0,d=c),de(ee,o.tables=c,o)});const m=he();re(async()=>{a.focus(),document.addEventListener("keydown",c=>{c.ctrlKey&&c.key==="k"&&(c.preventDefault(),m("sidebarNeeded"),a.focus(),a.select())}),r.data.table&&s.querySelector(`[href$="${r.data.table.id}"]`).scrollIntoView({behavior:"smooth",block:"center"})});const y=()=>{n?t(0,d=l.filter(c=>c.name.includes(n))):t(0,d=l)},j=c=>{c.key==="Escape"&&(t(3,n=""),y()),c.key==="Enter"&&s.querySelector("li:first-child a").click()},V=c=>{var T,S,U,w,h,f,_,E,u,q;c.key==="ArrowDown"&&s.contains(document.activeElement)&&(c.preventDefault(),document.activeElement.matches("input")?(T=s.querySelector("a"))==null||T.focus():(h=(w=(U=(S=document.activeElement)==null?void 0:S.parentElement)==null?void 0:U.nextElementSibling)==null?void 0:w.querySelector("a"))==null||h.focus()),c.key==="ArrowUp"&&s.contains(document.activeElement)&&(c.preventDefault(),(f=document.activeElement)!=null&&f.matches("li:first-child a")?a.focus():(q=(u=(E=(_=document.activeElement)==null?void 0:_.parentElement)==null?void 0:E.previousElementSibling)==null?void 0:u.querySelector("a"))==null||q.focus()),c.key==="Escape"&&s.contains(document.activeElement)&&(a.focus(),t(3,n=""),y())},D=()=>{t(3,n=null),y()};function $(c){Z[c?"unshift":"push"](()=>{a=c,t(2,a)})}function N(){n=this.value,t(3,n)}function H(c){Z[c?"unshift":"push"](()=>{s=c,t(1,s)})}return[d,s,a,n,r,y,j,V,D,$,N,H]}class Ne extends le{constructor(e){super(),ae(this,e,qe,$e,ne,{})}}function Ke(i){let e,t,r,o,l;r=new Ne({}),r.$on("sidebarNeeded",i[3]);const d=i[2].default,s=ve(d,i,i[1],null);return{c(){e=k("div"),t=k("div"),W(r.$$.fragment),o=A(),s&&s.c(),this.h()},l(a){e=v(a,"DIV",{class:!0});var n=I(e);t=v(n,"DIV",{class:!0});var m=I(t);Q(r.$$.fragment,m),m.forEach(g),o=K(n),s&&s.l(n),n.forEach(g),this.h()},h(){b(t,"class","tables-container svelte-s8xmdg"),b(e,"class","container svelte-s8xmdg"),M(e,"tablesHidden",i[0])},m(a,n){B(a,e,n),p(e,t),J(r,t,null),p(e,o),s&&s.m(e,null),l=!0},p(a,[n]){s&&s.p&&(!l||n&2)&&ke(s,d,a,a[1],l?ye(d,a[1],n,null):Ee(a[1]),null),(!l||n&1)&&M(e,"tablesHidden",a[0])},i(a){l||(C(r.$$.fragment,a),C(s,a),l=!0)},o(a){L(r.$$.fragment,a),L(s,a),l=!1},d(a){a&&g(e),F(r),s&&s.d(a)}}}function Ae(i,e,t){let{$$slots:r={},$$scope:o}=e,l=!1;re(()=>{document.addEventListener("keydown",s=>{!s.target.matches("input, textarea")&&s.key==="b"&&(t(0,l=!l),localStorage.tablesHidden=l)})});const d=()=>t(0,l=!1);return i.$$set=s=>{"$$scope"in s&&t(1,o=s.$$scope)},[l,o,r,d]}class Me extends le{constructor(e){super(),ae(this,e,Ae,Ke,ne,{})}}export{Me as component};