Introduce token-based author authentication (register/verify API), skill forking with EditGate protection, tag metadata on skills, and download/push stats. Enhanced push scripts with token auth and per-skill filtering. Updated UI with stats, tags, and author info on skill cards.
2 lines
13 KiB
JavaScript
2 lines
13 KiB
JavaScript
import{c as i,a as n,w as q,v as U,F as P,r as E,p as j,g as Q,b as Z,e as Ee,n as z,t as h,h as Le,i as c,q as Ie,j as Ve,k as f,m as Fe,o as u,d as le}from"./runtime-dom.esm-bundler.A7MyAQcw.js";import{_ as Oe}from"./_plugin-vue_export-helper.DlAUqK2U.js";const ae=12,se=20,qe=Le({__name:"SkillSearch",props:{authors:{},tags:{},totalCount:{}},setup(D,{expose:t}){t();const m=D,e=m.authors?m.authors.split(",").map(r=>r.trim()).filter(Boolean):[],H=m.tags?m.tags.split(",").map(r=>r.trim()).filter(Boolean):[],k=c(""),o=c(""),x=typeof localStorage<"u"&&localStorage.getItem("skillsViewMode"),w=c(x==="table"?"table":"grid"),g=c(1),T=c(m.totalCount||0),p=f(()=>w.value==="grid"?ae:se),K=f(()=>Math.max(1,Math.ceil(T.value/p.value))),ie=f(()=>T.value===0?0:(g.value-1)*p.value+1),ue=f(()=>Math.min(g.value*p.value,T.value)),ce=f(()=>{const r=[],l=K.value,s=g.value,C=7;if(l<=C)for(let b=1;b<=l;b++)r.push(b);else{const b=Math.floor(C/2);let M=Math.max(1,s-b),y=M+C-1;y>l&&(y=l,M=y-C+1);for(let F=M;F<=y;F++)r.push(F)}return r}),d=c([]),A=c(""),R=c(!1),J=c(),N=f(()=>{const r=A.value.toLowerCase().trim(),l=new Set(d.value.map(s=>s.toLowerCase()));return e.filter(s=>!l.has(s.toLowerCase())&&(!r||s.toLowerCase().includes(r)))});let L;function de(){L=setTimeout(()=>{R.value=!1},200)}function W(r){clearTimeout(L),d.value.some(l=>l.toLowerCase()===r.toLowerCase())||d.value.push(r),A.value="",J.value?.focus()}function ve(r){d.value=d.value.filter(l=>l!==r)}function ge(){N.value.length>0&&W(N.value[0])}function he(){!A.value&&d.value.length>0&&d.value.pop()}const v=c([]),B=c(""),X=c(!1),Y=c(),G=f(()=>{const r=B.value.toLowerCase().trim(),l=new Set(v.value.map(s=>s.toLowerCase()));return H.filter(s=>!l.has(s.toLowerCase())&&(!r||s.toLowerCase().includes(r)))});let I;function fe(){I=setTimeout(()=>{X.value=!1},200)}function $(r){clearTimeout(I),v.value.some(l=>l.toLowerCase()===r.toLowerCase())||v.value.push(r),B.value="",Y.value?.focus()}function me(r){v.value=v.value.filter(l=>l!==r)}function xe(){G.value.length>0&&$(G.value[0])}function we(){!B.value&&v.value.length>0&&v.value.pop()}function ee(r){w.value=r,localStorage.setItem("skillsViewMode",r);const l=document.getElementById("skills-grid"),s=document.getElementById("skills-table");l&&s&&(l.classList.toggle("hidden",r!=="grid"),s.classList.toggle("hidden",r!=="table")),g.value=1,Fe(()=>V())}Ie(()=>{w.value!=="grid"&&ee(w.value)});const pe=f(()=>k.value||d.value.length>0||v.value.length>0||o.value);function V(){const r=k.value.toLowerCase().trim(),l=d.value.map(a=>a.toLowerCase()),s=v.value.map(a=>a.toLowerCase()),C=o.value?parseInt(o.value):0,b=w.value==="grid"?"skills-grid":"skills-table",M=w.value==="grid"?"skills-table":"skills-grid",y=Array.from(document.querySelectorAll(`#${b} [data-skill]`));document.querySelectorAll(`#${M} [data-skill]`).forEach(a=>a.style.display="none");const O=[];y.forEach(a=>{const S=a.dataset.name||"",Ce=a.dataset.description||"",Te=a.dataset.tools||"",Ae=a.dataset.author||"",ne=(a.dataset.tags||"").split(",").filter(Boolean),Be=parseInt(a.dataset.forks||"0"),Me=!r||S.includes(r)||Ce.includes(r)||Te.includes(r)||ne.some(_=>_.includes(r)),Se=l.length===0||l.some(_=>Ae.includes(_)),_e=s.length===0||s.every(_=>ne.includes(_)),Pe=Be>=C;Me&&Se&&_e&&Pe&&O.push(a)}),T.value=O.length;const oe=Math.max(1,Math.ceil(O.length/p.value));g.value>oe&&(g.value=oe);const re=(g.value-1)*p.value,ke=re+p.value;y.forEach(a=>{const S=O.indexOf(a);S===-1?a.style.display="none":S>=re&&S<ke?a.style.display="":a.style.display="none"})}function be(r){r<1||r>K.value||(g.value=r,V())}function ye(){k.value="",d.value=[],A.value="",v.value=[],B.value="",o.value="",g.value=1}Ve([k,d,v,o],()=>{g.value=1,V()},{deep:!0});const te={props:m,authorList:e,tagList:H,query:k,forkFilter:o,savedView:x,viewMode:w,currentPage:g,filteredCount:T,PER_PAGE_GRID:ae,PER_PAGE_TABLE:se,perPage:p,totalPages:K,rangeStart:ie,rangeEnd:ue,visiblePages:ce,selectedAuthors:d,authorQuery:A,authorOpen:R,authorInputEl:J,authorSuggestions:N,get authorBlurTimer(){return L},set authorBlurTimer(r){L=r},onAuthorBlur:de,addAuthor:W,removeAuthor:ve,onAuthorEnter:ge,onAuthorBackspace:he,selectedTags:v,tagQuery:B,tagOpen:X,tagInputEl:Y,tagSuggestions:G,get tagBlurTimer(){return I},set tagBlurTimer(r){I=r},onTagBlur:fe,addTag:$,removeTag:me,onTagEnter:xe,onTagBackspace:we,setView:ee,hasActiveFilters:pe,applyFilters:V,goToPage:be,reset:ye};return Object.defineProperty(te,"__isScriptSetup",{enumerable:!1,value:!0}),te}}),je={class:"mb-6 space-y-4"},Qe={class:"flex flex-wrap items-end gap-3"},Ze={class:"w-full sm:w-auto sm:flex-1 sm:min-w-[180px]"},He={class:"relative"},Ke={class:"w-[calc(50%-6px)] sm:w-auto sm:flex-1 sm:min-w-[160px] relative"},Ne={class:"flex flex-wrap items-center gap-1.5 rounded-xl border border-white/[0.06] bg-[var(--color-surface-100)] px-3 py-2 min-h-[42px] focus-within:border-[var(--color-accent-500)]/50 focus-within:ring-1 focus-within:ring-[var(--color-accent-500)]/20 transition-all"},Ge=["onClick"],Ue=["placeholder","onKeydown"],ze={key:0,class:"absolute z-20 mt-1 w-full max-h-48 overflow-y-auto rounded-xl border border-white/[0.06] bg-[var(--color-surface-100)] shadow-xl"},De=["onMousedown"],Re={class:"w-[calc(50%-6px)] sm:w-auto sm:flex-1 sm:min-w-[160px] relative"},Je={class:"flex flex-wrap items-center gap-1.5 rounded-xl border border-white/[0.06] bg-[var(--color-surface-100)] px-3 py-2 min-h-[42px] focus-within:border-[var(--color-accent-500)]/50 focus-within:ring-1 focus-within:ring-[var(--color-accent-500)]/20 transition-all"},We=["onClick"],Xe=["placeholder","onKeydown"],Ye={key:0,class:"absolute z-20 mt-1 w-full max-h-48 overflow-y-auto rounded-xl border border-white/[0.06] bg-[var(--color-surface-100)] shadow-xl"},$e=["onMousedown"],et={class:"w-[calc(50%-6px)] sm:w-auto sm:min-w-[130px]"},tt={class:"flex rounded-xl border border-white/[0.06] overflow-hidden"},ot={key:0,class:"flex flex-wrap items-center justify-between gap-3"},rt={class:"text-sm text-gray-500"},nt={class:"flex items-center gap-1"},lt=["disabled"],at=["onClick"],st=["disabled"];function it(D,t,m,e,H,k){return u(),i("div",je,[n("div",Qe,[n("div",Ze,[t[15]||(t[15]=n("label",{class:"block text-xs font-medium uppercase tracking-wider text-gray-600 mb-1"},"Search",-1)),n("div",He,[t[14]||(t[14]=n("svg",{class:"pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-600",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor","stroke-width":"2"},[n("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"m21 21-5.197-5.197m0 0A7.5 7.5 0 1 0 5.196 5.196a7.5 7.5 0 0 0 10.607 10.607Z"})],-1)),q(n("input",{"onUpdate:modelValue":t[0]||(t[0]=o=>e.query=o),type:"text",placeholder:"Name, description, tools...",class:"w-full rounded-xl border border-white/[0.06] bg-[var(--color-surface-100)] pl-10 pr-4 py-2.5 text-sm text-white placeholder-gray-600 focus:border-[var(--color-accent-500)]/50 focus:outline-none focus:ring-1 focus:ring-[var(--color-accent-500)]/20 transition-all"},null,512),[[U,e.query]])])]),n("div",Ke,[t[16]||(t[16]=n("label",{class:"block text-xs font-medium uppercase tracking-wider text-gray-600 mb-1"},"Authors",-1)),n("div",Ne,[(u(!0),i(P,null,E(e.selectedAuthors,o=>(u(),i("span",{key:o,class:"inline-flex items-center gap-1 rounded-full bg-[var(--color-accent-500)]/15 text-[var(--color-accent-400)] px-2.5 py-0.5 text-xs font-medium"},[le(h(o)+" ",1),n("button",{onClick:x=>e.removeAuthor(o),class:"hover:text-white transition-colors"},"×",8,Ge)]))),128)),q(n("input",{ref:"authorInputEl","onUpdate:modelValue":t[1]||(t[1]=o=>e.authorQuery=o),type:"text",placeholder:e.selectedAuthors.length?"":"Filter by author...",onFocus:t[2]||(t[2]=o=>e.authorOpen=!0),onClick:t[3]||(t[3]=o=>e.authorOpen=!0),onInput:t[4]||(t[4]=o=>e.authorOpen=!0),onBlur:e.onAuthorBlur,onKeydown:[j(Q(e.onAuthorEnter,["prevent"]),["enter"]),j(e.onAuthorBackspace,["backspace"])],class:"flex-1 min-w-[80px] bg-transparent text-sm text-white placeholder-gray-600 outline-none"},null,40,Ue),[[U,e.authorQuery]])]),e.authorOpen&&e.authorSuggestions.length>0?(u(),i("div",ze,[(u(!0),i(P,null,E(e.authorSuggestions,o=>(u(),i("button",{key:o,onMousedown:Q(x=>e.addAuthor(o),["prevent"]),class:"block w-full text-left px-4 py-2 text-sm text-gray-400 hover:bg-white/[0.06] hover:text-white transition-colors"},h(o),41,De))),128))])):Z("",!0)]),n("div",Re,[t[17]||(t[17]=n("label",{class:"block text-xs font-medium uppercase tracking-wider text-gray-600 mb-1"},"Tags",-1)),n("div",Je,[(u(!0),i(P,null,E(e.selectedTags,o=>(u(),i("span",{key:o,class:"inline-flex items-center gap-1 rounded-full bg-[var(--color-accent-500)]/15 text-[var(--color-accent-400)] px-2.5 py-0.5 text-xs font-medium"},[le(h(o)+" ",1),n("button",{onClick:x=>e.removeTag(o),class:"hover:text-white transition-colors"},"×",8,We)]))),128)),q(n("input",{ref:"tagInputEl","onUpdate:modelValue":t[5]||(t[5]=o=>e.tagQuery=o),type:"text",placeholder:e.selectedTags.length?"":"Filter by tag...",onFocus:t[6]||(t[6]=o=>e.tagOpen=!0),onClick:t[7]||(t[7]=o=>e.tagOpen=!0),onInput:t[8]||(t[8]=o=>e.tagOpen=!0),onBlur:e.onTagBlur,onKeydown:[j(Q(e.onTagEnter,["prevent"]),["enter"]),j(e.onTagBackspace,["backspace"])],class:"flex-1 min-w-[80px] bg-transparent text-sm text-white placeholder-gray-600 outline-none"},null,40,Xe),[[U,e.tagQuery]])]),e.tagOpen&&e.tagSuggestions.length>0?(u(),i("div",Ye,[(u(!0),i(P,null,E(e.tagSuggestions,o=>(u(),i("button",{key:o,onMousedown:Q(x=>e.addTag(o),["prevent"]),class:"block w-full text-left px-4 py-2 text-sm text-gray-400 hover:bg-white/[0.06] hover:text-white transition-colors"},h(o),41,$e))),128))])):Z("",!0)]),n("div",et,[t[19]||(t[19]=n("label",{class:"block text-xs font-medium uppercase tracking-wider text-gray-600 mb-1"},"Forks",-1)),q(n("select",{"onUpdate:modelValue":t[9]||(t[9]=o=>e.forkFilter=o),class:"w-full rounded-xl border border-white/[0.06] bg-[var(--color-surface-100)] px-4 py-2.5 text-sm text-white focus:border-[var(--color-accent-500)]/50 focus:outline-none focus:ring-1 focus:ring-[var(--color-accent-500)]/20 transition-all"},[...t[18]||(t[18]=[n("option",{value:""},"Any",-1),n("option",{value:"1"},"1+ forks",-1),n("option",{value:"3"},"3+ forks",-1),n("option",{value:"5"},"5+ forks",-1)])],512),[[Ee,e.forkFilter]])]),e.hasActiveFilters?(u(),i("button",{key:0,onClick:e.reset,class:"rounded-xl border border-white/[0.06] bg-[var(--color-surface-100)] px-4 py-2.5 text-sm text-gray-500 hover:text-white hover:bg-white/[0.06] transition-all"}," Clear ")):Z("",!0),n("div",tt,[n("button",{onClick:t[10]||(t[10]=o=>e.setView("grid")),class:z(["px-3 py-2.5 transition-all",e.viewMode==="grid"?"bg-white/[0.08] text-white":"text-gray-600 hover:text-gray-400 hover:bg-white/[0.03]"]),title:"Grid view"},[...t[20]||(t[20]=[n("svg",{class:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor","stroke-width":"2"},[n("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M3.75 6A2.25 2.25 0 0 1 6 3.75h2.25A2.25 2.25 0 0 1 10.5 6v2.25a2.25 2.25 0 0 1-2.25 2.25H6a2.25 2.25 0 0 1-2.25-2.25V6ZM3.75 15.75A2.25 2.25 0 0 1 6 13.5h2.25a2.25 2.25 0 0 1 2.25 2.25V18a2.25 2.25 0 0 1-2.25 2.25H6A2.25 2.25 0 0 1 3.75 18v-2.25ZM13.5 6a2.25 2.25 0 0 1 2.25-2.25H18A2.25 2.25 0 0 1 20.25 6v2.25A2.25 2.25 0 0 1 18 10.5h-2.25a2.25 2.25 0 0 1-2.25-2.25V6ZM13.5 15.75a2.25 2.25 0 0 1 2.25-2.25H18a2.25 2.25 0 0 1 2.25 2.25V18A2.25 2.25 0 0 1 18 20.25h-2.25A2.25 2.25 0 0 1 13.5 18v-2.25Z"})],-1)])],2),n("button",{onClick:t[11]||(t[11]=o=>e.setView("table")),class:z(["px-3 py-2.5 transition-all",e.viewMode==="table"?"bg-white/[0.08] text-white":"text-gray-600 hover:text-gray-400 hover:bg-white/[0.03]"]),title:"Table view"},[...t[21]||(t[21]=[n("svg",{class:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor","stroke-width":"2"},[n("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M3.75 12h16.5m-16.5 3.75h16.5M3.75 19.5h16.5M5.625 4.5h12.75a1.875 1.875 0 0 1 0 3.75H5.625a1.875 1.875 0 0 1 0-3.75Z"})],-1)])],2)])]),e.totalPages>1?(u(),i("div",ot,[n("span",rt," Showing "+h(e.rangeStart)+"–"+h(e.rangeEnd)+" of "+h(e.filteredCount),1),n("div",nt,[n("button",{onClick:t[12]||(t[12]=o=>e.goToPage(e.currentPage-1)),disabled:e.currentPage===1,class:"rounded-lg border border-white/[0.06] px-3 py-1.5 text-sm transition-all disabled:opacity-30 disabled:cursor-not-allowed text-gray-400 hover:text-white hover:bg-white/[0.06]"}," Prev ",8,lt),(u(!0),i(P,null,E(e.visiblePages,o=>(u(),i("button",{key:o,onClick:x=>e.goToPage(o),class:z(["rounded-lg px-3 py-1.5 text-sm transition-all",o===e.currentPage?"bg-[var(--color-accent-500)] text-white font-medium":"border border-white/[0.06] text-gray-400 hover:text-white hover:bg-white/[0.06]"])},h(o),11,at))),128)),n("button",{onClick:t[13]||(t[13]=o=>e.goToPage(e.currentPage+1)),disabled:e.currentPage===e.totalPages,class:"rounded-lg border border-white/[0.06] px-3 py-1.5 text-sm transition-all disabled:opacity-30 disabled:cursor-not-allowed text-gray-400 hover:text-white hover:bg-white/[0.06]"}," Next ",8,st)])])):Z("",!0)])}const dt=Oe(qe,[["render",it]]);export{dt as default};
|