@macrulez/vue-command-palette 0.1.2 → 0.2.0
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/README.md +420 -14
- package/dist/components/CommandGroup.vue.d.ts +8 -6
- package/dist/components/CommandItem.vue.d.ts +11 -3
- package/dist/components/CommandPalette.test.d.ts +1 -0
- package/dist/components/CommandPalette.vue.d.ts +336 -7
- package/dist/components/VirtualList.vue.d.ts +2 -0
- package/dist/core/CommandStore.d.ts +278 -7
- package/dist/core/CommandStore.test.d.ts +1 -0
- package/dist/core/FuzzySearch.d.ts +13 -1
- package/dist/core/generics.test.d.ts +1 -0
- package/dist/core/useCommandPalette.d.ts +40 -7
- package/dist/core/useCommandPalette.test.d.ts +1 -0
- package/dist/index.d.ts +4 -4
- package/dist/plugin.d.ts +22 -1
- package/dist/plugin.test.d.ts +1 -0
- package/dist/testing.d.ts +281 -10
- package/dist/types.d.ts +122 -10
- package/dist/vue-command-palette.js +1457 -713
- package/dist/vue-command-palette.umd.cjs +1 -1
- package/package.json +5 -1
- package/dist/style.css +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
(function($,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],e):($=typeof globalThis<"u"?globalThis:$||self,e($.VueCommandPalette={},$.Vue))})(this,function($,e){"use strict";function q(o){return o.normalize("NFD").replace(/\p{Diacritic}/gu,"").toLowerCase()}function M(o,l){const r=q(o),s=q(l);if(!r)return{score:0,matches:[]};if(s===r)return{score:100,matches:[[0,l.length-1]]};if(s.startsWith(r))return{score:80,matches:[[0,r.length-1]]};const d=s.indexOf(r);if(d!==-1)return{score:60,matches:[[d,d+r.length-1]]};const m=[];let a=0,p=0,f=-1;for(let k=0;k<s.length&&a<r.length;k++)s[k]===r[a]&&(m.push(k),f!==-1&&(p+=k-f-1),f=k,a++);if(a<r.length)return{score:-1,matches:[]};const y=[];let C=m[0],g=m[0];for(let k=1;k<m.length;k++)m[k]===g+1||(y.push([C,g]),C=m[k]),g=m[k];y.push([C,g]);const B=p/(l.length||1);return{score:Math.max(1,40-B*20),matches:y}}function oe(o){return!(o.disabled||o.enabled&&!o.enabled())}function _(o,l){if(!o.trim())return[];const r=[];for(const s of l){if(!oe(s))continue;let d=M(o,s.label);for(const m of s.keywords??[]){const a=M(o,m);a.score>d.score&&(d={score:a.score,matches:[]})}for(const m of s.aliases??[]){const a=M(o,m);a.score>d.score&&(d={score:a.score,matches:[]})}d.score>0&&r.push({command:s,score:d.score,matches:d.matches})}return r.sort((s,d)=>d.score-s.score)}function U(o,l){if(!l.length)return e.h("span",o);const r=[];let s=0;for(const[d,m]of l)s<d&&r.push(e.h("span",o.slice(s,d))),r.push(e.h("mark",{class:"vcp-match"},o.slice(d,m+1))),s=m+1;return s<o.length&&r.push(e.h("span",o.slice(s))),e.h("span",r)}function j(){const o=e.reactive({groups:new Map,commands:new Map});function l(a,p){for(const f of a)if(o.commands.set(f.id,f),p&&o.groups.has(p)){const y=o.groups.get(p);y.commands.find(C=>C.id===f.id)||y.commands.push(f)}return()=>{for(const f of a)if(o.commands.delete(f.id),p&&o.groups.has(p)){const y=o.groups.get(p),C=y.commands.findIndex(g=>g.id===f.id);C!==-1&&y.commands.splice(C,1)}}}function r(a){o.groups.set(a.id,e.reactive(a));for(const p of a.commands)o.commands.set(p.id,p);return()=>{const p=o.groups.get(a.id);if(p)for(const f of p.commands)o.commands.delete(f.id);o.groups.delete(a.id)}}function s(){return Array.from(o.commands.values())}function d(a){const p=s();if(!a.trim())return[];const f=_(a,p);for(const y of f)for(const[C,g]of o.groups)if(g.commands.find(B=>B.id===y.command.id)){y.groupId=C;break}return f}function m(){return Array.from(o.groups.values()).sort((a,p)=>(p.priority??0)-(a.priority??0))}return{state:o,registerCommands:l,registerGroup:r,search:d,getAllCommands:s,getSortedGroups:m}}const ne=new Set(["shift","ctrl","meta","alt","$mod"]);function re(o){return ne.has(o)}function Y(o){return o.length>=2&&o.every(l=>!re(l))}function ae(o,l){return o==="$mod"?l.metaKey||l.ctrlKey:o==="shift"?l.shiftKey:o==="alt"?l.altKey:o==="ctrl"?l.ctrlKey:o==="meta"?l.metaKey:l.key.toLowerCase()===o.toLowerCase()}function le(o,l){const r=o.slice(0,-1),s=o[o.length-1];for(const d of r)if(!ae(d,l))return!1;return!r.includes("$mod")&&!r.includes("ctrl")&&!r.includes("meta")&&(l.ctrlKey||l.metaKey)||!r.includes("shift")&&l.shiftKey||!r.includes("alt")&&l.altKey?!1:l.key.toLowerCase()===s.toLowerCase()}function J(){const o=[];let l=[],r=null,s=!1;function d(f){for(const{keys:g,handler:B}of o)if(!Y(g)&&le(g,f)){f.preventDefault(),B();return}const y=o.filter(g=>Y(g.keys));if(!y.length||f.metaKey||f.ctrlKey||f.altKey)return;l.push(f.key.toLowerCase()),r&&clearTimeout(r),r=setTimeout(()=>{l=[]},500);const C=l;for(const{keys:g,handler:B}of y){const k=g.map(w=>w.toLowerCase());if(C.length>=k.length&&C.slice(-k.length).every((V,P)=>V===k[P])){f.preventDefault(),l=[],B();return}}}function m(f,y){const C={keys:f,handler:y};return o.push(C),()=>{const g=o.indexOf(C);g!==-1&&o.splice(g,1)}}function a(){s||typeof document>"u"||(s=!0,document.addEventListener("keydown",d))}function p(){typeof document>"u"||(s=!1,document.removeEventListener("keydown",d))}return{registerShortcut:m,start:a,stop:p}}const G=Symbol("@macrulez/vue-command-palette"),ie={install(o,l={}){const{hotkey:r=["$mod","k"],persistRecent:s=!0,maxRecent:d=5,maxRecentPerGroup:m=0,localStorageKey:a="vcp:recent",colorTheme:p="system",onOpen:f,onClose:y,onError:C}=l,g=j(),B=J(),k=e.ref(!1),w=e.ref(""),V=e.ref(0),P=e.ref([]),E=e.ref(null);let S=[];if(s&&typeof localStorage<"u")try{S=JSON.parse(localStorage.getItem(a)??"[]")}catch{}const I=e.ref(S),x=e.computed(()=>g.search(w.value)),T=e.ref(p),K={store:g,keyboard:B,isOpen:k,query:w,activeIndex:V,history:P,recentIds:I,loadingCommandId:E,results:x,colorTheme:T,persistRecent:s,maxRecent:d,maxRecentPerGroup:m??0,localStorageKey:a,onOpen:f,onClose:y,onError:C};o.provide(G,K),B.registerShortcut(r,()=>{k.value=!k.value,k.value?(w.value="",V.value=0,f?.()):y?.()}),B.start();const L=o.unmount.bind(o);o.unmount=()=>{B.stop(),L()}}};function se(o,l){if(!(typeof localStorage>"u"))try{localStorage.setItem(l,JSON.stringify(o))}catch{}}function W(){const o=e.inject(G);if(!o)throw new Error("[@macrulez/vue-command-palette] Plugin not installed. Use app.use(VCommandPalettePlugin).");const{store:l,isOpen:r,query:s,activeIndex:d,history:m,recentIds:a,loadingCommandId:p,results:f,colorTheme:y,persistRecent:C,maxRecent:g,localStorageKey:B,onOpen:k,onClose:w,onError:V}=o;function P(h){h&&r.value?(m.value.push({paletteId:h,query:s.value,activeIndex:d.value}),s.value="",d.value=0):(r.value=!0,s.value="",d.value=0,k?.())}function E(){r.value=!1,s.value="",d.value=0,m.value=[],w?.()}function S(){r.value?E():P()}function I(){if(!m.value.length){E();return}const h=m.value.pop();s.value=h.query,d.value=h.activeIndex}function x(h){if(!C)return;const b=a.value.filter(A=>A!==h);b.unshift(h),a.value=b.slice(0,g),se(a.value,B)}async function T(h){if(!(h.disabled||h.enabled&&!h.enabled())){if(h.subCommands?.length){P(h.id);return}x(h.id),E(),p.value=h.id;try{await h.perform()}catch(b){V?V(b,h):console.error("[@macrulez/vue-command-palette] Command error:",b)}finally{p.value=null}}}async function K(){const h=f.value[d.value];h&&await T(h.command)}function L(){const h=l.getAllCommands();return a.value.map(b=>h.find(A=>A.id===b)).filter(b=>!!b)}function z(h){return l.registerCommands(h)}function O(h){return l.registerGroup(h)}return{isOpen:e.readonly(r),query:s,results:f,activeIndex:d,history:e.readonly(m),loadingCommandId:e.readonly(p),colorTheme:y,open:P,close:E,toggle:S,goBack:I,executeActive:K,executeCommand:T,getRecentCommands:L,registerCommands:z,registerGroup:O,addRecent:x}}function ce(o){const l=e.inject(G);if(!l)throw new Error("[@macrulez/vue-command-palette] Plugin not installed.");const r=l.store.registerCommands(o);e.onUnmounted(r)}function me(o){const l=e.inject(G);if(!l)throw new Error("[@macrulez/vue-command-palette] Plugin not installed.");const r=l.store.registerGroup(o);e.onUnmounted(r)}const de=["id","aria-selected","aria-disabled"],fe={key:0,class:"vcp-item__icon"},ue={class:"vcp-item__body"},pe={class:"vcp-item__label"},he={key:0,class:"vcp-item__description"},ge={key:0,class:"vcp-item__spinner","aria-label":"Loading"},ke={key:1,class:"vcp-item__shortcut"},R=e.defineComponent({__name:"CommandItem",props:{command:{},active:{type:Boolean},matches:{},itemId:{},loadingCommandId:{}},emits:["execute","activate"],setup(o){const l=o,r=e.computed(()=>l.command.disabled||l.command.enabled!=null&&!l.command.enabled()),s=e.computed(()=>l.loadingCommandId===l.command.id),d=e.computed(()=>U(l.command.label,l.matches));function m(a){return a==="$mod"?typeof navigator<"u"&&navigator.platform.includes("Mac")?"⌘":"Ctrl":a==="shift"?"⇧":a==="alt"?typeof navigator<"u"&&navigator.platform.includes("Mac")?"⌥":"Alt":a.toUpperCase()}return(a,p)=>(e.openBlock(),e.createElementBlock("div",{id:o.itemId,class:e.normalizeClass(["vcp-item",{"vcp-item--active":o.active,"vcp-item--disabled":r.value,"vcp-item--loading":s.value}]),role:"option","aria-selected":o.active,"aria-disabled":r.value,onClick:p[0]||(p[0]=f=>!r.value&&!s.value&&a.$emit("execute")),onMouseenter:p[1]||(p[1]=f=>!r.value&&a.$emit("activate"))},[e.renderSlot(a.$slots,"default",{command:o.command,active:o.active,matches:o.matches},()=>[e.renderSlot(a.$slots,"item-icon",{command:o.command},()=>[o.command.icon?(e.openBlock(),e.createElementBlock("span",fe,[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(typeof o.command.icon=="string"?"span":o.command.icon),null,{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(typeof o.command.icon=="string"?o.command.icon:""),1)]),_:1}))])):e.createCommentVNode("",!0)]),e.createElementVNode("span",ue,[e.createElementVNode("span",pe,[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(d.value)))]),o.command.description?(e.openBlock(),e.createElementBlock("span",he,e.toDisplayString(o.command.description),1)):e.createCommentVNode("",!0)]),e.renderSlot(a.$slots,"item-shortcut",{command:o.command},()=>[s.value?(e.openBlock(),e.createElementBlock("span",ge)):o.command.shortcut?.length?(e.openBlock(),e.createElementBlock("span",ke,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.command.shortcut,f=>(e.openBlock(),e.createElementBlock("kbd",{key:f,class:"vcp-kbd"},e.toDisplayString(m(f)),1))),128))])):e.createCommentVNode("",!0)])])],42,de))}}),ye={key:0,class:"vcp-group"},Ce={class:"vcp-group__header","aria-hidden":"true"},F=e.defineComponent({__name:"CommandGroup",props:{group:{},items:{},activeIndex:{},globalOffset:{},loadingCommandId:{}},emits:["execute","activate"],setup(o){return(l,r)=>o.items.length?(e.openBlock(),e.createElementBlock("div",ye,[e.renderSlot(l.$slots,"group-header",{group:o.group},()=>[e.createElementVNode("div",Ce,e.toDisplayString(o.group.label),1)]),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.items,(s,d)=>(e.openBlock(),e.createBlock(R,{key:s.command.id,command:s.command,active:o.globalOffset+d===o.activeIndex,matches:s.matches,"item-id":`vcp-item-${s.command.id}`,"loading-command-id":o.loadingCommandId,onExecute:m=>l.$emit("execute",s.command),onActivate:m=>l.$emit("activate",o.globalOffset+d)},e.createSlots({_:2},[l.$slots["item-icon"]?{name:"item-icon",fn:e.withCtx(m=>[e.renderSlot(l.$slots,"item-icon",e.mergeProps({ref_for:!0},m))]),key:"0"}:void 0,l.$slots["item-shortcut"]?{name:"item-shortcut",fn:e.withCtx(m=>[e.renderSlot(l.$slots,"item-shortcut",e.mergeProps({ref_for:!0},m))]),key:"1"}:void 0,l.$slots.item?{name:"default",fn:e.withCtx(m=>[e.renderSlot(l.$slots,"item",e.mergeProps({ref_for:!0},m))]),key:"2"}:void 0]),1032,["command","active","matches","item-id","loading-command-id","onExecute","onActivate"]))),128))])):e.createCommentVNode("",!0)}}),Q=e.defineComponent({__name:"VirtualList",props:{items:{},itemHeight:{},containerHeight:{},overscan:{default:3}},setup(o,{expose:l}){const r=o,s=e.ref(),d=e.ref(0),m=e.computed(()=>r.items.length*r.itemHeight),a=e.computed(()=>Math.max(0,Math.floor(d.value/r.itemHeight)-r.overscan)),p=e.computed(()=>{const g=Math.ceil(r.containerHeight/r.itemHeight);return Math.min(r.items.length-1,a.value+g+r.overscan*2)}),f=e.computed(()=>a.value*r.itemHeight),y=e.computed(()=>r.items.slice(a.value,p.value+1).map((g,B)=>({data:g,index:a.value+B})));function C(g){d.value=g.target.scrollTop}return e.watch(()=>r.items,()=>{d.value=0,s.value&&(s.value.scrollTop=0)}),l({containerEl:s}),(g,B)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"containerEl",ref:s,class:"vcp-virtual",style:e.normalizeStyle({height:o.containerHeight+"px",overflowY:"auto"}),onScrollPassive:C},[e.createElementVNode("div",{style:e.normalizeStyle({height:m.value+"px",position:"relative"})},[e.createElementVNode("div",{style:e.normalizeStyle({transform:`translateY(${f.value}px)`})},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(y.value,k=>e.renderSlot(g.$slots,"default",{key:k.index,item:k.data,index:k.index})),128))],4)],4)],36))}}),Be={key:0,class:"vcp-breadcrumb","aria-live":"polite"},$e={key:0,class:"vcp-breadcrumb__sep","aria-hidden":"true"},Ee={key:1,class:"vcp-confirm"},be={class:"vcp-confirm__text"},Se={class:"vcp-confirm__actions"},we={class:"vcp-input-wrap"},Pe=["placeholder","aria-activedescendant"],Ie={class:"vcp-theme-switcher","aria-label":"Color theme"},Ve=["title","onClick"],xe=["aria-label"],Te={key:0,class:"vcp-state vcp-state--loading"},Ne={key:0,class:"vcp-section","aria-hidden":"true"},Le={key:0,class:"vcp-section","aria-hidden":"true"},De={key:0,class:"vcp-group__header","aria-hidden":"true"},Re={key:1,class:"vcp-section","aria-hidden":"true"},Ae={key:0,class:"vcp-section","aria-hidden":"true"},Ge={key:4,class:"vcp-state vcp-state--empty"},Ke=50,ze=40,Me=360,Fe="vcp-input",X="vcp-listbox",Oe=e.defineComponent({__name:"CommandPalette",props:{placeholder:{default:"Search commands…"},maxResults:{default:10},emptyText:{default:"No commands found."},loadingText:{default:"Loading…"},teleportTo:{default:"body"},theme:{default:"default"},animationDuration:{default:150}},setup(o){const l=o,r=e.inject(G),s=W(),{isOpen:d,query:m,activeIndex:a,history:p,loadingCommandId:f,close:y,toggle:C,open:g,executeCommand:B,getRecentCommands:k}=s,w=e.ref(),V=e.ref(),P=e.ref(!1),E=e.ref(null),S=e.computed(()=>{const t=k();if(!r.maxRecentPerGroup)return t;const c={};return t.filter(n=>{const i=n.group??"__none__";return c[i]=(c[i]??0)+1,c[i]<=r.maxRecentPerGroup})}),I=e.computed(()=>{if(!p.value.length)return null;const t=p.value[p.value.length-1].paletteId,c=r.store.getAllCommands().find(n=>n.id===t);return c?.subCommands?.length?c.subCommands.filter(n=>!n.disabled&&(n.enabled==null||n.enabled())):null}),x=e.computed(()=>r.store.getSortedGroups().map(t=>({group:t,items:t.commands.filter(c=>!c.disabled&&(c.enabled==null||c.enabled())).map(c=>({command:c,score:0,matches:[],groupId:t.id}))})).filter(t=>t.items.length>0)),T=e.computed(()=>x.value.flatMap(t=>t.items));function K(t){return x.value.slice(0,t).reduce((c,n)=>c+n.items.length,0)}const L=e.ref([]);let z=null;e.watch(m,async t=>{z&&clearTimeout(z);const c=r.store.getSortedGroups().filter(n=>n.onSearch);if(!c.length||!t.trim()){L.value=[];return}z=setTimeout(async()=>{P.value=!0;try{const n=await Promise.all(c.map(i=>i.onSearch(t).then(u=>u.map(D=>({command:D,score:50,matches:[],groupId:i.id})))));L.value=n.flat()}finally{P.value=!1}},200)});const O=e.computed(()=>r.store.search(m.value)),h=e.computed(()=>{const t=I.value;if(t!==null&&m.value.trim()){const n=m.value.toLowerCase();return t.filter(i=>i.label.toLowerCase().includes(n)||i.description?.toLowerCase().includes(n)||i.keywords?.some(u=>u.toLowerCase().includes(n))).map(i=>({command:i,score:50,matches:[],groupId:void 0}))}const c=[...O.value];for(const n of L.value)c.find(i=>i.command.id===n.command.id)||c.push(n);return c.sort((n,i)=>i.score-n.score).slice(0,l.maxResults)}),b=e.computed(()=>{const t=r.store.getSortedGroups(),c=[];let n=0;for(let i=0;i<t.length;i++){const u=t[i],D=h.value.filter(H=>H.groupId===u.id);D.length&&(c.push({group:u,items:D,offset:n,section:i>0&&c.length>0}),n+=D.length)}return c}),A=e.computed(()=>b.value.reduce((t,c)=>t+c.items.length,0)),Z=e.computed(()=>h.value.filter(t=>!t.groupId)),He=e.computed(()=>{const t=[];let c=0;for(let n=0;n<b.value.length;n++){const{group:i,items:u,section:D}=b.value[n];D&&t.push({type:"section"}),t.push({type:"group-header",label:i.label});for(const H of u)t.push({type:"command",result:H,index:c++})}for(const n of Z.value)t.push({type:"command",result:n,index:c++});return t}),qe=e.computed(()=>{const t=h.value[a.value];return t?`vcp-item-${t.command.id}`:void 0});function _e(t){return r.store.getAllCommands().find(c=>c.id===t)?.label??t}function v(){a.value=0}async function N(t){if(t.confirm){E.value=t;return}await B(t)}async function ee(){if(!E.value)return;const t=E.value;E.value=null,await B(t)}function te(){e.nextTick(()=>{V.value?.querySelector('[aria-selected="true"]')?.scrollIntoView({block:"nearest"})})}function Ue(t){if(E.value){t.key==="Escape"&&(t.preventDefault(),E.value=null),t.key==="Enter"&&(t.preventDefault(),ee());return}const c=h.value.length||(m.value.trim()?0:I.value?I.value.length:S.value.length+T.value.length);if(t.key==="ArrowDown")t.preventDefault(),c&&(a.value=(a.value+1)%c),te();else if(t.key==="ArrowUp")t.preventDefault(),c&&(a.value=(a.value-1+c)%c),te();else if(t.key==="Enter")if(t.preventDefault(),m.value.trim()){const n=h.value[a.value];n?.command&&N(n.command)}else{const n=a.value;let i;I.value?i=I.value[n]:i=n<S.value.length?S.value[n]:T.value[n-S.value.length]?.command,i&&N(i)}else t.key==="Escape"?(t.preventDefault(),p.value.length?s.goBack():y()):t.key==="Backspace"&&!m.value?(t.preventDefault(),s.goBack()):t.key==="Tab"&&(t.preventDefault(),w.value?.focus())}return e.watch(d,async t=>{typeof document>"u"||(t?(a.value=0,document.body.style.overflow="hidden",await e.nextTick(),w.value?.focus()):(document.body.style.overflow="",E.value=null))}),(t,c)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[e.renderSlot(t.$slots,"trigger",{open:e.unref(g),toggle:e.unref(C)}),(e.openBlock(),e.createBlock(e.Teleport,{to:o.teleportTo},[e.createVNode(e.Transition,{name:"vcp-fade"},{default:e.withCtx(()=>[e.unref(d)?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(["vcp-overlay",e.unref(r).colorTheme.value!=="system"?`vcp-theme-${e.unref(r).colorTheme.value}`:""]),role:"presentation",onClick:c[6]||(c[6]=e.withModifiers((...n)=>e.unref(y)&&e.unref(y)(...n),["self"]))},[e.createElementVNode("div",{class:e.normalizeClass(["vcp-dialog",`vcp-dialog--${o.theme}`]),role:"dialog","aria-modal":"true","aria-label":"Command palette",onKeydown:Ue},[e.unref(p).length?(e.openBlock(),e.createElementBlock("div",Be,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(p),(n,i)=>(e.openBlock(),e.createElementBlock("span",{key:n.paletteId,class:"vcp-breadcrumb__item"},[i>0?(e.openBlock(),e.createElementBlock("span",$e,"›")):e.createCommentVNode("",!0),e.createTextVNode(" "+e.toDisplayString(_e(n.paletteId)),1)]))),128)),c[7]||(c[7]=e.createElementVNode("span",{class:"vcp-breadcrumb__sep","aria-hidden":"true"},"›",-1))])):e.createCommentVNode("",!0),E.value?(e.openBlock(),e.createElementBlock("div",Ee,[e.createElementVNode("p",be,e.toDisplayString(E.value.confirm),1),e.createElementVNode("div",Se,[e.createElementVNode("button",{class:"vcp-confirm__btn vcp-confirm__btn--yes",onClick:ee}," Yes, proceed "),e.createElementVNode("button",{class:"vcp-confirm__btn vcp-confirm__btn--no",onClick:c[0]||(c[0]=n=>E.value=null)}," Cancel ")])])):(e.openBlock(),e.createElementBlock(e.Fragment,{key:2},[e.renderSlot(t.$slots,"header"),e.createElementVNode("div",we,[e.renderSlot(t.$slots,"input",{query:e.unref(m),onInput:v},()=>[e.withDirectives(e.createElementVNode("input",{id:Fe,ref_key:"inputEl",ref:w,"onUpdate:modelValue":c[1]||(c[1]=n=>e.isRef(m)?m.value=n:null),class:"vcp-input",type:"text",autocomplete:"off",spellcheck:"false",placeholder:o.placeholder,role:"combobox","aria-expanded":"true","aria-controls":X,"aria-activedescendant":qe.value,onInput:v},null,40,Pe),[[e.vModelText,e.unref(m)]])]),e.createElementVNode("div",Ie,[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(["light","system","dark"],n=>e.createElementVNode("button",{key:n,class:e.normalizeClass(["vcp-theme-btn",{"vcp-theme-btn--active":e.unref(r).colorTheme.value===n}]),title:n==="light"?"Light theme":n==="dark"?"Dark theme":"System theme",type:"button",onClick:i=>e.unref(r).colorTheme.value=n},[e.createElementVNode("span",{class:e.normalizeClass(["vcp-theme-icon",`vcp-theme-icon--${n}`]),"aria-hidden":"true"},null,2)],10,Ve)),64))])]),e.withDirectives(e.createElementVNode("div",{id:X,ref_key:"listEl",ref:V,class:"vcp-list",role:"listbox","aria-label":o.placeholder},[P.value?(e.openBlock(),e.createElementBlock("div",Te,e.toDisplayString(o.loadingText),1)):e.unref(m).trim()?h.value.length>Ke?(e.openBlock(),e.createBlock(Q,{key:2,items:He.value,"item-height":ze,"container-height":Me},{default:e.withCtx(({item:n})=>[n.type==="group-header"?(e.openBlock(),e.createElementBlock("div",De,e.toDisplayString(n.label),1)):n.type==="section"?(e.openBlock(),e.createElementBlock("div",Re)):(e.openBlock(),e.createBlock(R,{key:2,command:n.result.command,active:n.index===e.unref(a),matches:n.result.matches,"item-id":`vcp-item-${n.result.command.id}`,"loading-command-id":e.unref(f),onExecute:i=>N(n.result.command),onActivate:i=>a.value=n.index},e.createSlots({_:2},[t.$slots["item-icon"]?{name:"item-icon",fn:e.withCtx(i=>[e.renderSlot(t.$slots,"item-icon",e.normalizeProps(e.guardReactiveProps(i)))]),key:"0"}:void 0,t.$slots["item-shortcut"]?{name:"item-shortcut",fn:e.withCtx(i=>[e.renderSlot(t.$slots,"item-shortcut",e.normalizeProps(e.guardReactiveProps(i)))]),key:"1"}:void 0,t.$slots.item?{name:"default",fn:e.withCtx(i=>[e.renderSlot(t.$slots,"item",e.normalizeProps(e.guardReactiveProps(i)))]),key:"2"}:void 0]),1032,["command","active","matches","item-id","loading-command-id","onExecute","onActivate"]))]),_:3},8,["items"])):h.value.length?(e.openBlock(),e.createElementBlock(e.Fragment,{key:3},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(b.value,n=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:n.group.id},[n.section?(e.openBlock(),e.createElementBlock("div",Ae)):e.createCommentVNode("",!0),e.createVNode(F,{group:n.group,items:n.items,"active-index":e.unref(a),"global-offset":n.offset,"loading-command-id":e.unref(f),onExecute:c[4]||(c[4]=i=>N(i)),onActivate:c[5]||(c[5]=i=>a.value=i)},e.createSlots({_:2},[t.$slots["group-header"]?{name:"group-header",fn:e.withCtx(i=>[e.renderSlot(t.$slots,"group-header",e.mergeProps({ref_for:!0},i))]),key:"0"}:void 0,t.$slots["item-icon"]?{name:"item-icon",fn:e.withCtx(i=>[e.renderSlot(t.$slots,"item-icon",e.mergeProps({ref_for:!0},i))]),key:"1"}:void 0,t.$slots["item-shortcut"]?{name:"item-shortcut",fn:e.withCtx(i=>[e.renderSlot(t.$slots,"item-shortcut",e.mergeProps({ref_for:!0},i))]),key:"2"}:void 0,t.$slots.item?{name:"item",fn:e.withCtx(i=>[e.renderSlot(t.$slots,"item",e.mergeProps({ref_for:!0},i))]),key:"3"}:void 0]),1032,["group","items","active-index","global-offset","loading-command-id"])],64))),128)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(Z.value,(n,i)=>(e.openBlock(),e.createBlock(R,{key:n.command.id,command:n.command,active:A.value+i===e.unref(a),matches:n.matches,"item-id":`vcp-item-${n.command.id}`,"loading-command-id":e.unref(f),onExecute:u=>N(n.command),onActivate:u=>a.value=A.value+i},e.createSlots({_:2},[t.$slots["item-icon"]?{name:"item-icon",fn:e.withCtx(u=>[e.renderSlot(t.$slots,"item-icon",e.mergeProps({ref_for:!0},u))]),key:"0"}:void 0,t.$slots["item-shortcut"]?{name:"item-shortcut",fn:e.withCtx(u=>[e.renderSlot(t.$slots,"item-shortcut",e.mergeProps({ref_for:!0},u))]),key:"1"}:void 0,t.$slots.item?{name:"default",fn:e.withCtx(u=>[e.renderSlot(t.$slots,"item",e.mergeProps({ref_for:!0},u))]),key:"2"}:void 0]),1032,["command","active","matches","item-id","loading-command-id","onExecute","onActivate"]))),128))],64)):e.unref(m).trim()?(e.openBlock(),e.createElementBlock("div",Ge,[e.renderSlot(t.$slots,"empty",{query:e.unref(m)},()=>[e.createTextVNode(e.toDisplayString(o.emptyText),1)])])):e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[I.value?(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:0},e.renderList(I.value,(n,i)=>(e.openBlock(),e.createBlock(R,{key:n.id,command:n,active:i===e.unref(a),matches:[],"item-id":`vcp-item-sub-${n.id}`,"loading-command-id":e.unref(f),onExecute:u=>N(n),onActivate:u=>a.value=i},e.createSlots({_:2},[t.$slots["item-icon"]?{name:"item-icon",fn:e.withCtx(u=>[e.renderSlot(t.$slots,"item-icon",e.mergeProps({ref_for:!0},u))]),key:"0"}:void 0,t.$slots["item-shortcut"]?{name:"item-shortcut",fn:e.withCtx(u=>[e.renderSlot(t.$slots,"item-shortcut",e.mergeProps({ref_for:!0},u))]),key:"1"}:void 0,t.$slots.item?{name:"default",fn:e.withCtx(u=>[e.renderSlot(t.$slots,"item",e.mergeProps({ref_for:!0},u))]),key:"2"}:void 0]),1032,["command","active","item-id","loading-command-id","onExecute","onActivate"]))),128)):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[S.value.length?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[c[8]||(c[8]=e.createElementVNode("div",{class:"vcp-group__header","aria-hidden":"true"},"Recent",-1)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(S.value,(n,i)=>(e.openBlock(),e.createBlock(R,{key:n.id,command:n,active:i===e.unref(a),matches:[],"item-id":`vcp-item-recent-${n.id}`,"loading-command-id":e.unref(f),onExecute:u=>N(n),onActivate:u=>a.value=i},e.createSlots({_:2},[t.$slots["item-icon"]?{name:"item-icon",fn:e.withCtx(u=>[e.renderSlot(t.$slots,"item-icon",e.mergeProps({ref_for:!0},u))]),key:"0"}:void 0,t.$slots["item-shortcut"]?{name:"item-shortcut",fn:e.withCtx(u=>[e.renderSlot(t.$slots,"item-shortcut",e.mergeProps({ref_for:!0},u))]),key:"1"}:void 0,t.$slots.item?{name:"default",fn:e.withCtx(u=>[e.renderSlot(t.$slots,"item",e.mergeProps({ref_for:!0},u))]),key:"2"}:void 0]),1032,["command","active","item-id","loading-command-id","onExecute","onActivate"]))),128)),x.value.length?(e.openBlock(),e.createElementBlock("div",Ne)):e.createCommentVNode("",!0)],64)):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(x.value,(n,i)=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:n.group.id},[i>0?(e.openBlock(),e.createElementBlock("div",Le)):e.createCommentVNode("",!0),e.createVNode(F,{group:n.group,items:n.items,"active-index":e.unref(a),"global-offset":S.value.length+K(i),"loading-command-id":e.unref(f),onExecute:c[2]||(c[2]=u=>N(u)),onActivate:c[3]||(c[3]=u=>a.value=u)},e.createSlots({_:2},[t.$slots["group-header"]?{name:"group-header",fn:e.withCtx(u=>[e.renderSlot(t.$slots,"group-header",e.mergeProps({ref_for:!0},u))]),key:"0"}:void 0,t.$slots["item-icon"]?{name:"item-icon",fn:e.withCtx(u=>[e.renderSlot(t.$slots,"item-icon",e.mergeProps({ref_for:!0},u))]),key:"1"}:void 0,t.$slots["item-shortcut"]?{name:"item-shortcut",fn:e.withCtx(u=>[e.renderSlot(t.$slots,"item-shortcut",e.mergeProps({ref_for:!0},u))]),key:"2"}:void 0,t.$slots.item?{name:"item",fn:e.withCtx(u=>[e.renderSlot(t.$slots,"item",e.mergeProps({ref_for:!0},u))]),key:"3"}:void 0]),1032,["group","items","active-index","global-offset","loading-command-id"])],64))),128))],64))],64))],8,xe),[[e.vShow,P.value||I.value!=null||S.value.length||e.unref(m).trim()||T.value.length]]),e.renderSlot(t.$slots,"footer")],64))],34)],2)):e.createCommentVNode("",!0)]),_:3})],8,["to"]))],64))}});$.CommandGroup=F,$.CommandItem=R,$.CommandPalette=Oe,$.VCommandPalettePlugin=ie,$.VirtualList=Q,$.createCommandStore=j,$.createKeyboardManager=J,$.fuzzySearch=_,$.highlightMatches=U,$.useCommandPalette=W,$.useRegisterCommands=ce,$.useRegisterGroup=me,Object.defineProperty($,Symbol.toStringTag,{value:"Module"})});
|
|
1
|
+
(function(T,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],e):(T=typeof globalThis<"u"?globalThis:T||self,e(T.VueCommandPalette={},T.Vue))})(this,function(T,e){"use strict";function et(o){return o.normalize("NFD").replace(/\p{Diacritic}/gu,"").toLowerCase()}function tt(o){const l=[],r=[];let s=0;for(const g of o){const f=s;s+=g.length;const k=g.normalize("NFD").replace(/\p{Diacritic}/gu,"").toLowerCase();for(const b of k)l.push(b),r.push(f)}return r.push(o.length),{normalized:l.join(""),map:r}}function he(o,l){return o.map(([r,s])=>[l[r],l[s+1]-1])}function ce(o,l){const r=et(o),{normalized:s,map:g}=tt(l);if(!r)return{score:0,matches:[]};if(s===r)return{score:100,matches:[[0,l.length-1]]};if(s.startsWith(r))return{score:80,matches:he([[0,r.length-1]],g)};const f=s.indexOf(r);if(f!==-1)return{score:60,matches:he([[f,f+r.length-1]],g)};const k=[];let b=0,y=0,h=-1;for(let p=0;p<s.length&&b<r.length;p++)s[p]===r[b]&&(k.push(p),h!==-1&&(y+=p-h-1),h=p,b++);if(b<r.length)return{score:-1,matches:[]};const S=[];let v=k[0],m=k[0];for(let p=1;p<k.length;p++)k[p]===m+1||(S.push([v,m]),v=k[p]),m=k[p];S.push([v,m]);const d=y/(l.length||1);return{score:Math.max(1,40-d*20),matches:he(S,g)}}function ge(o){return!(o.disabled||o.enabled&&!o.enabled())}function Ae(o,l,r=!1){if(!o.trim())return[];const s=[];for(const g of l){if(!ge(g)&&!r)continue;const f=ce(o,g.label);let k=f.score,b="label",y;if(g.description){const h=ce(o,g.description);h.score>=60&&h.score>k&&(k=h.score,b="description")}for(const h of g.keywords??[]){const S=ce(o,h);S.score>k&&(k=S.score,b="keyword",y=h)}for(const h of g.aliases??[]){const S=ce(o,h);S.score>k&&(k=S.score,b="alias",y=h)}k>0&&s.push({command:g,score:k,matches:f.score>0?f.matches:[],matchedField:b,matchedText:y})}return s.sort((g,f)=>{if(r){const k=ge(g.command)?1:0,b=ge(f.command)?1:0;if(k!==b)return b-k}return ye(g,f)})}function ye(o,l){const r=o.matches.length?1:0,s=l.matches.length?1:0;return r!==s?s-r:l.score-o.score}function le(o,l){const r=ce(o,l);return r.score>0?r.matches:[]}function de(o,l){if(!l.length)return e.h("span",o);const r=[];let s=0;for(const[g,f]of l)s<g&&r.push(e.h("span",o.slice(s,g))),r.push(e.h("mark",{class:"vcp-match"},o.slice(g,f+1))),s=f+1;return s<o.length&&r.push(e.h("span",o.slice(s))),e.h("span",r)}function Re(o,l=!0,r,s=!1){const g=o??((m,d)=>Ae(m,d,s)),f=e.reactive({groups:new Map,commands:new Map});function k(m,d){for(const p of m)if(f.commands.set(p.id,p),d&&f.groups.has(d)){const C=f.groups.get(d);C.commands.find(B=>B.id===p.id)||C.commands.push(p)}return()=>{for(const p of m)if(f.commands.delete(p.id),d&&f.groups.has(d)){const C=f.groups.get(d),B=C.commands.findIndex(E=>E.id===p.id);B!==-1&&C.commands.splice(B,1)}}}function b(m){f.groups.set(m.id,e.reactive(m));for(const d of m.commands)f.commands.set(d.id,d);return()=>{const d=f.groups.get(m.id);if(d)for(const p of d.commands)f.commands.delete(p.id);f.groups.delete(m.id)}}function y(){return Array.from(f.commands.values())}function h(m){const d=f.commands.get(m);if(d)return d;const p=Array.from(f.commands.values());for(;p.length;){const C=p.pop();if(C.subCommands?.length)for(const B of C.subCommands){if(B.id===m)return B;B.subCommands?.length&&p.push(B)}}}function S(m){if(!m.trim())return[];let d=y();const p=new Map;if(l){const E=[],_=(x,A)=>{if(E.push(x),A.length&&p.set(x,A),x.subCommands?.length)for(const w of x.subCommands)_(w,[...A,x])};for(const x of d)_(x,[]);d=E}const C=g(m,d),B=new Map;for(const[E,_]of f.groups)for(const x of _.commands)B.has(x.id)||B.set(x.id,E);for(const E of C){const _=p.get(E.command);_?.length&&(E.parents=_);const x=_?.length?_[0].id:E.command.id,A=B.get(x);A&&(E.groupId=A),r&&(E.score+=r(E.command))}return r&&C.sort(ye),C}function v(){return Array.from(f.groups.values()).sort((m,d)=>(d.priority??0)-(m.priority??0))}return{state:f,registerCommands:k,registerGroup:b,search:S,getAllCommands:y,findCommand:h,getSortedGroups:v}}const nt=new Set(["shift","ctrl","meta","alt","$mod"]);function ot(o){return nt.has(o)}function Me(o){return o.length>=2&&o.every(l=>!ot(l))}function at(o){return o.some(l=>l==="$mod"||l==="ctrl"||l==="meta")}function lt(o){const l=o.target;if(!l)return!1;const r=l.tagName;if(r==="INPUT"||r==="TEXTAREA"||r==="SELECT"||l.isContentEditable)return!0;const s=l.getAttribute?.("contenteditable");return s===""||s==="true"}function rt(o,l){return o==="$mod"?l.metaKey||l.ctrlKey:o==="shift"?l.shiftKey:o==="alt"?l.altKey:o==="ctrl"?l.ctrlKey:o==="meta"?l.metaKey:l.key.toLowerCase()===o.toLowerCase()}function it(o,l){const r=o.slice(0,-1),s=o[o.length-1];for(const g of r)if(!rt(g,l))return!1;return!r.includes("$mod")&&!r.includes("ctrl")&&!r.includes("meta")&&(l.ctrlKey||l.metaKey)||!r.includes("shift")&&l.shiftKey||!r.includes("alt")&&l.altKey?!1:l.key.toLowerCase()===s.toLowerCase()}function ze(){const o=[];let l=[],r=null,s=!1;function g(y){const h=lt(y);for(const{keys:m,handler:d}of o)if(!Me(m)&&!(h&&!at(m))&&it(m,y)){y.preventDefault(),d();return}if(h)return;const S=o.filter(m=>Me(m.keys));if(!S.length||y.metaKey||y.ctrlKey||y.altKey)return;l.push(y.key.toLowerCase()),r&&clearTimeout(r),r=setTimeout(()=>{l=[]},500);const v=l;for(const{keys:m,handler:d}of S){const p=m.map(C=>C.toLowerCase());if(v.length>=p.length&&v.slice(-p.length).every((B,E)=>B===p[E])){y.preventDefault(),l=[],d();return}}}function f(y,h){const S={keys:y,handler:h};return o.push(S),()=>{const v=o.indexOf(S);v!==-1&&o.splice(v,1)}}function k(){s||typeof document>"u"||(s=!0,document.addEventListener("keydown",g))}function b(){typeof document>"u"||(s=!1,document.removeEventListener("keydown",g))}return{registerShortcut:f,start:k,stop:b}}const ke=Symbol("@macrulez/vue-command-palette"),Ke=Symbol("@macrulez/vue-command-palette:labels"),Fe=Symbol("@macrulez/vue-command-palette:selection"),He=Symbol("@macrulez/vue-command-palette:query"),Oe=Symbol("@macrulez/vue-command-palette:pinned"),be=Symbol("@macrulez/vue-command-palette:registry");function ct(o,l=Date.now()){if(!o)return 0;const r=(l-o.lastUsed)/864e5,s=Math.max(0,1-r/30);return o.count*2+s*15}function Ce(o,l={}){{const{name:r="default",hotkey:s=["$mod","k"],persistRecent:g=!0,maxRecent:f=5,maxRecentPerGroup:k=0,localStorageKey:b="vcp:recent",colorTheme:y="system",search:h,searchNested:S=!0,showDisabled:v=!1,frecency:m=!1,onSearch:d,bindShortcuts:p=!1,onOpen:C,onClose:B,onError:E,onHighlight:_}=l;let x={};if(m&&g&&typeof localStorage<"u")try{x=JSON.parse(localStorage.getItem(b+":frecency")??"{}")}catch{}const A=e.ref(x),N=Re(h,S,m?Z=>ct(A.value[Z.id]):void 0,v),$=ze(),F=e.ref(!1),Q=e.ref(""),Y=e.ref(0),K=e.ref([]),V=e.ref(null);let H=[];if(g&&typeof localStorage<"u")try{H=JSON.parse(localStorage.getItem(b)??"[]")}catch{}const I=e.ref(H);let R=[];if(g&&typeof localStorage<"u")try{R=JSON.parse(localStorage.getItem(b+":pinned")??"[]")}catch{}const G=e.ref(R),re=e.ref([]),ie=e.computed(()=>N.search(Q.value)),W=e.ref([]),j=e.ref(null),q=e.ref(y),ne={store:N,keyboard:$,isOpen:F,query:Q,activeIndex:Y,history:K,recentIds:I,loadingCommandId:V,results:ie,currentResults:W,executeRequest:j,colorTheme:q,persistRecent:g,maxRecent:f,maxRecentPerGroup:k??0,localStorageKey:b,frecency:m,usage:A,pinnedIds:G,queryHistory:re,showDisabled:v,globalSearch:d,onOpen:C,onClose:B,onError:E,onHighlight:_},u=o.runWithContext(()=>e.inject(be,null))??new Map;u.set(r,ne),o.provide(be,u);const P=o.runWithContext(()=>e.inject(ke,null));if((r==="default"||!P)&&o.provide(ke,ne),$.registerShortcut(s,()=>{F.value=!F.value,F.value?(Q.value="",Y.value=0,C?.()):B?.()}),$.start(),p){async function Z(L){if(!(L.disabled||L.enabled&&!L.enabled())){if(L.subCommands?.length){F.value=!0;return}V.value=L.id;try{await L.perform()}catch(oe){E?E(oe,L):console.error("[@macrulez/vue-command-palette] Command error:",oe)}finally{V.value=null}}}const M=new Map;e.watch(()=>Array.from(N.state.commands.values()),L=>{const oe=new Set(L.map(O=>O.id));for(const[O,ee]of M)oe.has(O)||(ee(),M.delete(O));for(const O of L)if(O.shortcut?.length&&!M.has(O.id)){const ee=$.registerShortcut(O.shortcut,()=>{const fe=j.value;fe?fe(O):Z(O)});M.set(O.id,ee)}},{immediate:!0})}const X=o.unmount.bind(o);o.unmount=()=>{$.stop(),X()}}}const st={install:Ce};function mt(o={}){return{install(l){Ce(l,o)}}}function Ee(o,l){if(!(typeof localStorage>"u"))try{localStorage.setItem(l,JSON.stringify(o))}catch{}}function se(o){if(o){const s=e.inject(be,null)?.get(o);if(!s)throw new Error(`[@macrulez/vue-command-palette] No palette instance named "${o}". Install it with app.use(VCommandPalettePlugin, { name: "${o}" }).`);return s}const l=e.inject(ke);if(!l)throw new Error("[@macrulez/vue-command-palette] Plugin not installed. Use app.use(VCommandPalettePlugin).");return l}function Ge(o){const l=se(o),{store:r,isOpen:s,query:g,activeIndex:f,history:k,recentIds:b,loadingCommandId:y,results:h,currentResults:S,colorTheme:v,persistRecent:m,maxRecent:d,localStorageKey:p,frecency:C,usage:B,pinnedIds:E,queryHistory:_,onOpen:x,onClose:A,onError:w}=l;function N(u){u&&s.value?(k.value.push({paletteId:u,query:g.value,activeIndex:f.value}),g.value="",f.value=0):(s.value=!0,g.value="",f.value=0,x?.())}function $(){s.value=!1,g.value="",f.value=0,k.value=[],A?.()}function F(){s.value?$():N()}function Q(){if(!k.value.length){$();return}const u=k.value.pop();g.value=u.query,f.value=u.activeIndex}function Y(u){const P=b.value.filter(X=>X!==u);P.unshift(u),b.value=P.slice(0,d),m&&Ee(b.value,p)}function K(u){return E.value.includes(u)}function V(u){E.value.includes(u)||(E.value=[...E.value,u],m&&Ee(E.value,p+":pinned"))}function H(u){E.value=E.value.filter(P=>P!==u),m&&Ee(E.value,p+":pinned")}function I(u){K(u)?H(u):V(u)}function R(){return E.value.map(u=>r.findCommand(u)).filter(u=>!!u)}function G(u){const P=u.trim();P&&(_.value=[P,..._.value.filter(X=>X!==P)].slice(0,25))}function re(u){if(!C)return;const P=B.value[u];if(B.value={...B.value,[u]:{count:(P?.count??0)+1,lastUsed:Date.now()}},m&&typeof localStorage<"u")try{localStorage.setItem(p+":frecency",JSON.stringify(B.value))}catch{}}async function ie(u){if(!(u.disabled||u.enabled&&!u.enabled())){if(u.subCommands?.length||u.page){N(u.id);return}Y(u.id),re(u.id),G(g.value),$(),y.value=u.id;try{await u.perform()}catch(P){w?w(P,u):console.error("[@macrulez/vue-command-palette] Command error:",P)}finally{y.value=null}}}async function W(){const P=(S.value.length?S.value:h.value)[f.value];P&&await ie(P.command)}function j(){return b.value.map(u=>r.findCommand(u)).filter(u=>!!u)}function q(u){return r.registerCommands(u)}function ne(u){return r.registerGroup(u)}return{isOpen:e.readonly(s),query:g,results:h,activeIndex:f,history:e.readonly(k),loadingCommandId:e.readonly(y),colorTheme:v,open:N,close:$,toggle:F,goBack:Q,executeActive:W,executeCommand:ie,getRecentCommands:j,getPinnedCommands:R,registerCommands:q,registerGroup:ne,addRecent:Y,isPinned:K,pin:V,unpin:H,togglePin:I,pinnedIds:e.readonly(E),queryHistory:e.readonly(_)}}function dt(o,l){const s=se(l).store.registerCommands(o);e.onUnmounted(s)}function ft(o,l){const s=se(l).store.registerGroup(o);e.onUnmounted(s)}const ut=["id","aria-selected","aria-disabled","title"],pt={key:0,class:"vcp-item__icon"},ht={class:"vcp-item__body"},gt={class:"vcp-item__label"},yt={key:0,class:"vcp-item__context"},kt={key:1,class:"vcp-item__match-hint"},bt={key:0,class:"vcp-item__description"},Ct=["aria-label"],Et={key:1,class:"vcp-item__shortcut"},Bt={key:2,class:"vcp-item__actions-hint","aria-hidden":"true",title:"Tab for actions"},St=["title"],wt={class:"vcp-item__chevron","aria-hidden":"true"},J=e.defineComponent({__name:"CommandItem",props:{command:{},active:{type:Boolean},matches:{},itemId:{},loadingCommandId:{},parents:{},matchedText:{},alwaysShowPin:{type:Boolean}},emits:["execute","activate"],setup(o){const l=o,r=e.computed(()=>l.command.disabled||l.command.enabled!=null&&!l.command.enabled()),s=e.computed(()=>l.loadingCommandId===l.command.id),g=e.computed(()=>!!l.command.subCommands?.length||!!l.command.page),f=e.computed(()=>{const w=l.command.badge;return typeof w=="string"?w:w?.text}),k=e.computed(()=>typeof l.command.badge=="object"?l.command.badge.color:void 0),b=e.inject(Ke,void 0),y=e.computed(()=>b?.value.loading??"Loading"),h=e.inject(Fe,void 0),S=e.computed(()=>h?.value.selectable??!1),v=e.computed(()=>S.value&&(h?.value.isSelected(l.command.id)??!1)),m=e.inject(Oe,void 0),d=e.computed(()=>m?.isPinned(l.command.id)??!1),p=e.computed(()=>d.value?b?.value.unpin??"Unpin":b?.value.pin??"Pin");function C(){m?.toggle(l.command.id)}const B=e.computed(()=>de(l.command.label,l.matches)),E=e.inject(He,void 0),_=e.computed(()=>{const w=l.command.description??"",N=(E?.value??"").trim();if(!w||!N)return de(w,[]);const $=w.toLowerCase().indexOf(N.toLowerCase());return de(w,$===-1?[]:[[$,$+N.length-1]])});function x(){if(typeof navigator>"u")return!1;const w=navigator.userAgentData;return w?.platform?/mac/i.test(w.platform):/mac/i.test(navigator.platform||navigator.userAgent||"")}function A(w){return w==="$mod"?x()?"⌘":"Ctrl":w==="shift"?"⇧":w==="alt"?x()?"⌥":"Alt":w.toUpperCase()}return(w,N)=>(e.openBlock(),e.createElementBlock("div",{id:o.itemId,class:e.normalizeClass(["vcp-item",{"vcp-item--active":o.active,"vcp-item--disabled":r.value,"vcp-item--loading":s.value,"vcp-item--selected":v.value}]),role:"option","aria-selected":o.active,"aria-disabled":r.value,title:r.value&&o.command.disabledReason?o.command.disabledReason:void 0,onClick:N[0]||(N[0]=$=>!r.value&&!s.value&&w.$emit("execute")),onMouseenter:N[1]||(N[1]=$=>!r.value&&w.$emit("activate"))},[e.renderSlot(w.$slots,"default",{command:o.command,active:o.active,matches:o.matches,parents:o.parents,matchedText:o.matchedText},()=>[S.value?(e.openBlock(),e.createElementBlock("span",{key:0,class:e.normalizeClass(["vcp-item__checkbox",{"vcp-item__checkbox--on":v.value}]),"aria-hidden":"true"},null,2)):e.createCommentVNode("",!0),e.renderSlot(w.$slots,"item-icon",{command:o.command},()=>[o.command.icon?(e.openBlock(),e.createElementBlock("span",pt,[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(typeof o.command.icon=="string"?"span":o.command.icon),null,{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(typeof o.command.icon=="string"?o.command.icon:""),1)]),_:1}))])):e.createCommentVNode("",!0)]),e.createElementVNode("span",ht,[e.createElementVNode("span",gt,[o.parents?.length?(e.openBlock(),e.createElementBlock("span",yt,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.parents,$=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:$.id},[e.createTextVNode(e.toDisplayString($.label)+" › ",1)],64))),128))])):e.createCommentVNode("",!0),(e.openBlock(),e.createBlock(e.resolveDynamicComponent(B.value))),o.matchedText&&!o.matches.length?(e.openBlock(),e.createElementBlock("span",kt,"— "+e.toDisplayString(o.matchedText),1)):e.createCommentVNode("",!0)]),o.command.description?(e.openBlock(),e.createElementBlock("span",bt,[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(_.value)))])):e.createCommentVNode("",!0)]),f.value?(e.openBlock(),e.createElementBlock("span",{key:1,class:"vcp-item__badge",style:e.normalizeStyle(k.value?{background:k.value}:void 0)},e.toDisplayString(f.value),5)):e.createCommentVNode("",!0),e.renderSlot(w.$slots,"item-shortcut",{command:o.command},()=>[s.value?(e.openBlock(),e.createElementBlock("span",{key:0,class:"vcp-item__spinner","aria-label":y.value},null,8,Ct)):o.command.shortcut?.length?(e.openBlock(),e.createElementBlock("span",Et,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.command.shortcut,$=>(e.openBlock(),e.createElementBlock("kbd",{key:$,class:"vcp-kbd"},e.toDisplayString(A($)),1))),128))])):o.command.actions?.length?(e.openBlock(),e.createElementBlock("span",Bt,"⋯")):e.createCommentVNode("",!0)]),e.createElementVNode("span",{class:e.normalizeClass(["vcp-item__pin",{"vcp-item__pin--on":d.value,"vcp-item__pin--show":l.alwaysShowPin}]),title:p.value,"aria-hidden":"true",onClick:e.withModifiers(C,["stop"])},[...N[2]||(N[2]=[e.createElementVNode("svg",{class:"vcp-item__pin-icon",viewBox:"0 0 24 24",width:"12",height:"12",fill:"currentColor"},[e.createElementVNode("path",{d:"M16 9V4h1a1 1 0 0 0 0-2H7a1 1 0 0 0 0 2h1v5l-2 2v2h5v5l1 1 1-1v-5h5v-2l-2-2z"})],-1)])],10,St),e.createElementVNode("span",wt,e.toDisplayString(g.value?"›":""),1)])],42,ut))}}),vt={key:0,class:"vcp-group"},$t={class:"vcp-group__header","aria-hidden":"true"},Be=e.defineComponent({__name:"CommandGroup",props:{group:{},items:{},activeIndex:{},globalOffset:{},loadingCommandId:{}},emits:["execute","activate"],setup(o){return(l,r)=>o.items.length?(e.openBlock(),e.createElementBlock("div",vt,[e.renderSlot(l.$slots,"group-header",{group:o.group},()=>[e.createElementVNode("div",$t,e.toDisplayString(o.group.label),1)]),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.items,(s,g)=>(e.openBlock(),e.createBlock(J,{key:s.command.id,command:s.command,active:o.globalOffset+g===o.activeIndex,matches:s.matches,parents:s.parents,"matched-text":s.matchedText,"item-id":`vcp-item-${s.command.id}`,"loading-command-id":o.loadingCommandId,onExecute:f=>l.$emit("execute",s.command),onActivate:f=>l.$emit("activate",o.globalOffset+g)},e.createSlots({_:2},[l.$slots["item-icon"]?{name:"item-icon",fn:e.withCtx(f=>[e.renderSlot(l.$slots,"item-icon",e.mergeProps({ref_for:!0},f))]),key:"0"}:void 0,l.$slots["item-shortcut"]?{name:"item-shortcut",fn:e.withCtx(f=>[e.renderSlot(l.$slots,"item-shortcut",e.mergeProps({ref_for:!0},f))]),key:"1"}:void 0,l.$slots.item?{name:"default",fn:e.withCtx(f=>[e.renderSlot(l.$slots,"item",e.mergeProps({ref_for:!0},f))]),key:"2"}:void 0]),1032,["command","active","matches","parents","matched-text","item-id","loading-command-id","onExecute","onActivate"]))),128))])):e.createCommentVNode("",!0)}}),Ue=e.defineComponent({__name:"VirtualList",props:{items:{},itemHeight:{},containerHeight:{},overscan:{default:3},activeIndex:{default:-1}},setup(o,{expose:l}){const r=o,s=e.ref(),g=e.ref(0);function f(m){if(m<0)return;const d=s.value;if(!d)return;const p=m*r.itemHeight,C=p+r.itemHeight;p<d.scrollTop?d.scrollTop=p:C>d.scrollTop+r.containerHeight&&(d.scrollTop=C-r.containerHeight)}e.watch(()=>r.activeIndex,m=>{e.nextTick(()=>f(m))});const k=e.computed(()=>r.items.length*r.itemHeight),b=e.computed(()=>Math.max(0,Math.floor(g.value/r.itemHeight)-r.overscan)),y=e.computed(()=>{const m=Math.ceil(r.containerHeight/r.itemHeight);return Math.min(r.items.length-1,b.value+m+r.overscan*2)}),h=e.computed(()=>b.value*r.itemHeight),S=e.computed(()=>r.items.slice(b.value,y.value+1).map((m,d)=>({data:m,index:b.value+d})));function v(m){g.value=m.target.scrollTop}return e.watch(()=>r.items,()=>{g.value=0,s.value&&(s.value.scrollTop=0)}),l({containerEl:s}),(m,d)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"containerEl",ref:s,class:"vcp-virtual",style:e.normalizeStyle({height:o.containerHeight+"px",overflowY:"auto"}),onScrollPassive:v},[e.createElementVNode("div",{style:e.normalizeStyle({height:k.value+"px",position:"relative"})},[e.createElementVNode("div",{style:e.normalizeStyle({transform:`translateY(${h.value}px)`})},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(S.value,p=>e.renderSlot(m.$slots,"default",{key:p.index,item:p.data,index:p.index})),128))],4)],4)],36))}}),xt=["aria-label"],Tt={key:0,class:"vcp-breadcrumb","aria-live":"polite"},Pt={key:0,class:"vcp-breadcrumb__sep","aria-hidden":"true"},_t={key:1,class:"vcp-confirm"},Nt={class:"vcp-confirm__text"},Vt={class:"vcp-confirm__actions"},Dt={class:"vcp-actions"},It={class:"vcp-actions__bar"},Lt=["title"],At={class:"vcp-actions__title"},Rt={class:"vcp-actions__hint"},Mt=["aria-selected","onClick","onMouseenter"],zt={key:0,class:"vcp-item__icon"},Kt={class:"vcp-item__body"},Ft={class:"vcp-item__label"},Ht={key:1,class:"vcp-item__shortcut"},Ot={class:"vcp-input-wrap"},Gt={key:0,class:"vcp-mode-chip"},Ut=["placeholder","aria-activedescendant"],Yt=["aria-label"],jt={class:"vcp-theme-switcher","aria-label":"Color theme"},qt=["title","onClick"],Jt=["title","aria-label","aria-pressed"],Qt=["aria-label"],Wt={class:"vcp-group__header","aria-hidden":"true"},Xt={key:0,class:"vcp-section","aria-hidden":"true"},Zt={class:"vcp-group__header","aria-hidden":"true"},en={key:0,class:"vcp-group__header vcp-group__header--sub","aria-hidden":"true"},tn={key:2,class:"vcp-section","aria-hidden":"true"},nn={key:0,class:"vcp-section","aria-hidden":"true"},on={key:0,class:"vcp-group__header","aria-hidden":"true"},an={key:1,class:"vcp-section","aria-hidden":"true"},ln={key:0,class:"vcp-section","aria-hidden":"true"},rn={key:3,class:"vcp-state vcp-state--loading"},cn={key:4,class:"vcp-state vcp-state--empty"},sn=["aria-hidden"],mn={class:"vcp-preview__inner"},dn=["innerHTML"],fn={class:"vcp-sr-only",role:"status","aria-live":"polite"},un=50,pn=40,hn=360,gn="vcp-input",Ye="vcp-listbox",yn='a[href],button:not([disabled]),input:not([disabled]),textarea:not([disabled]),select:not([disabled]),[tabindex]:not([tabindex="-1"])',kn=e.defineComponent({__name:"CommandPalette",props:{name:{default:void 0},placeholder:{default:"Search commands…"},maxResults:{default:10},emptyText:{default:"No commands found."},loadingText:{default:"Loading…"},teleportTo:{default:"body"},theme:{default:"default"},animationDuration:{default:150},labels:{default:void 0},groupRecent:{type:Boolean,default:!1},modes:{default:void 0},selectable:{type:Boolean,default:!1},preview:{type:Boolean,default:!1},previewHotkey:{default:()=>["$mod","i"]}},emits:["submit-selection"],setup(o,{emit:l}){const r={recent:"Recent",pinned:"Pinned",pin:"Pin",unpin:"Unpin",confirmYes:"Yes, proceed",confirmCancel:"Cancel",themeLight:"Light theme",themeDark:"Dark theme",themeSystem:"System theme",dialogLabel:"Command palette",loading:"Loading",resultsCount:t=>`${t} result${t===1?"":"s"} available`,actions:"Actions",back:"Back",togglePreview:"Toggle preview panel"},s=o,g=l,f=e.ref(!0),k=e.computed(()=>s.preview&&f.value);function b(){f.value=!f.value}const y=e.computed(()=>({...r,...s.labels}));e.provide(Ke,y);const h=se(s.name),S=Ge(s.name),{isOpen:v,query:m,activeIndex:d,history:p,loadingCommandId:C,close:B,toggle:E,open:_,executeCommand:x,getRecentCommands:A,getPinnedCommands:w,togglePin:N,pinnedIds:$}=S;e.provide(He,m),e.provide(Oe,{isPinned:t=>$.value.includes(t),toggle:t=>N(t)});const F=e.ref(),Q=e.ref(),Y=e.ref(),K=e.ref(!1),V=e.ref(null),H=e.ref(-1),I=e.ref(null),R=e.ref(0),G=e.ref([]);function re(t){return G.value.includes(t)}function ie(t){G.value=re(t)?G.value.filter(i=>i!==t):[...G.value,t]}e.provide(Fe,e.computed(()=>({selectable:s.selectable,isSelected:re})));function W(t){return h.showDisabled||!t.disabled&&(t.enabled==null||t.enabled())}const j=e.computed(()=>w().filter(W)),q=e.computed(()=>{const t=A();let i=t;if(h.maxRecentPerGroup){const n={};i=t.filter(a=>{const c=a.group??"__none__";return n[c]=(n[c]??0)+1,n[c]<=h.maxRecentPerGroup})}if(s.groupRecent){const n=[],a=new Map;for(const c of i){const D=c.group??"";a.has(D)||(a.set(D,[]),n.push(D)),a.get(D).push(c)}i=n.flatMap(c=>a.get(c))}return i}),ne=e.computed(()=>{if(!s.groupRecent)return null;const t=[];let i=0;for(const n of q.value){const a=n.group??"",c=t[t.length-1];c&&c.label===a?c.commands.push(n):t.push({label:a,commands:[n],offset:i}),i++}return t}),u=e.computed(()=>!s.modes?.length||Z.value?null:s.modes.find(t=>t.prefix&&m.value.startsWith(t.prefix))??null),P=e.computed(()=>u.value?m.value.slice(u.value.prefix.length):m.value),X=e.computed(()=>p.value.length?h.store.findCommand(p.value[p.value.length-1].paletteId)??null:null),Z=e.computed(()=>X.value?.page??null),M=e.computed(()=>{const t=X.value;return t?t.page?(t.page.items??[]).filter(W):t.subCommands?.length?t.subCommands.filter(W):null:null}),L=e.computed(()=>h.store.getSortedGroups().map(t=>({group:t,items:t.commands.filter(W).map(i=>({command:i,score:0,matches:[],groupId:t.id}))})).filter(t=>t.items.length>0)),oe=e.computed(()=>L.value.flatMap(t=>t.items));function O(t){return L.value.slice(0,t).reduce((i,n)=>i+n.items.length,0)}const ee=e.computed(()=>j.value.length),fe=e.computed(()=>j.value.length+q.value.length),Se=e.computed(()=>[...j.value,...q.value,...oe.value.map(t=>t.command)]),we=e.ref([]);let ve=null;e.watch(m,async t=>{ve&&clearTimeout(ve);const i=h.store.getSortedGroups().filter(a=>a.onSearch),n=typeof h.globalSearch=="function";if(!i.length&&!n||!t.trim()){we.value=[];return}ve=setTimeout(async()=>{K.value=!0;try{const c=(await Promise.all(i.map(D=>D.onSearch(t).then(z=>z.map(pe=>({command:pe,score:50,matches:le(t,pe.label),groupId:D.id})))))).flat();if(h.globalSearch){const D=await h.globalSearch(t);for(const z of D)c.find(pe=>pe.command.id===z.id)||c.push({command:z,score:50,matches:le(t,z.label),groupId:void 0})}we.value=c}finally{K.value=!1}},200)});const $e=e.ref([]);let xe=null;e.watch([m,Z],async([t,i])=>{if(xe&&clearTimeout(xe),!i?.onSearch||!t.trim()){$e.value=[];return}xe=setTimeout(async()=>{K.value=!0;try{const n=await i.onSearch(t);$e.value=n.map(a=>({command:a,score:50,matches:le(t,a.label),groupId:void 0}))}finally{K.value=!1}},200)});const Te=e.ref([]);let Pe=null;e.watch([P,u],async([t,i])=>{if(Pe&&clearTimeout(Pe),!i?.onSearch||!t.trim()){Te.value=[];return}Pe=setTimeout(async()=>{K.value=!0;try{const n=await i.onSearch(t);Te.value=n.map(a=>({command:a,score:50,matches:le(t,a.label),groupId:void 0}))}finally{K.value=!1}},200)});function je(t,i){const n=i.toLowerCase();return t.filter(a=>a.label.toLowerCase().includes(n)||a.description?.toLowerCase().includes(n)||a.keywords?.some(c=>c.toLowerCase().includes(n))).map(a=>({command:a,score:50,matches:le(i,a.label),groupId:void 0}))}const bn=h.results,ae=e.computed(()=>{const t=u.value;if(t)return P.value.trim()?t.onSearch?Te.value:h.store.search(P.value).slice(0,s.maxResults):[];const i=Z.value;if(i)return m.value.trim()?i.onSearch?$e.value:je(i.items??[],m.value):[];const n=M.value;if(n!==null&&m.value.trim())return je(n,m.value);const a=[...bn.value];for(const c of we.value)a.find(D=>D.command.id===c.command.id)||a.push(c);return a.sort(ye).slice(0,s.maxResults)}),me=e.computed(()=>{const t=h.store.getSortedGroups().map(n=>{const a=ae.value.filter(c=>c.groupId===n.id);return{group:n,items:a,bestIndex:a.length?ae.value.indexOf(a[0]):1/0}}).filter(n=>n.items.length>0).sort((n,a)=>n.bestIndex-a.bestIndex);let i=0;return t.map((n,a)=>{const c={group:n.group,items:n.items,offset:i,section:a>0};return i+=n.items.length,c})}),qe=e.computed(()=>me.value.reduce((t,i)=>t+i.items.length,0)),_e=e.computed(()=>ae.value.filter(t=>!t.groupId)),ue=e.computed(()=>[...me.value.flatMap(t=>t.items),..._e.value]),Je=e.computed(()=>{const t=[];let i=0;for(let n=0;n<me.value.length;n++){const{group:a,items:c,section:D}=me.value[n];D&&t.push({type:"section"}),t.push({type:"group-header",label:a.label});for(const z of c)t.push({type:"command",result:z,index:i++})}for(const n of _e.value)t.push({type:"command",result:n,index:i++});return t});e.watch(ue,t=>{h.currentResults.value=t},{immediate:!0});const Cn=e.computed(()=>Je.value.findIndex(t=>t.type==="command"&&t.index===d.value)),En=e.computed(()=>{const t=ue.value[d.value];return t?`vcp-item-${t.command.id}`:void 0}),te=e.computed(()=>{const t=d.value;return m.value.trim()?ue.value[t]?.command??null:M.value?M.value[t]??null:Se.value[t]??null}),Bn=e.computed(()=>v.value&&m.value.trim()?y.value.resultsCount(ae.value.length):"");e.watch([te,v],([t,i])=>{h.onHighlight?.(i?t:null)});function Sn(t){return h.store.findCommand(t)?.label??t}function Qe(){d.value=0,H.value=-1}function wn(){return Y.value?Array.from(Y.value.querySelectorAll(yn)).filter(t=>t.offsetParent!==null||t===document.activeElement):[]}function vn(t){const i=wn();if(!i.length){t.preventDefault(),F.value?.focus();return}const n=i[0],a=i[i.length-1],c=document.activeElement,D=!!c&&!!Y.value?.contains(c);t.shiftKey?(!D||c===n)&&(t.preventDefault(),a.focus()):(!D||c===a)&&(t.preventDefault(),n.focus())}async function U(t){if(s.selectable){ie(t.id);return}if(t.confirm){v.value||_(),V.value=t;return}(t.subCommands?.length||t.page)&&!v.value&&_(),await x(t)}async function We(){if(!V.value)return;const t=V.value;V.value=null,await x(t)}function $n(){if(!G.value.length)return;const t=h.store.getAllCommands(),i=G.value.map(n=>t.find(a=>a.id===n)).filter(n=>!!n);g("submit-selection",i),G.value=[],B()}function xn(t){t.actions?.length&&(I.value=t,R.value=0)}function Ne(){I.value=null,e.nextTick(()=>F.value?.focus())}async function Ve(t){const i=I.value;I.value=null,B();try{await t.perform()}catch(n){h.onError&&i?h.onError(n,i):console.error("[@macrulez/vue-command-palette] Action error:",n)}}e.onMounted(()=>{h.executeRequest.value=U}),e.onUnmounted(()=>{h.executeRequest.value===U&&(h.executeRequest.value=null)});function Tn(t,i){if(!i.length)return!1;const n=i[i.length-1].toLowerCase(),a=i.slice(0,-1);return(a.includes("$mod")||a.includes("ctrl")||a.includes("meta"))!==(t.metaKey||t.ctrlKey)||a.includes("shift")!==t.shiftKey||a.includes("alt")!==t.altKey?!1:t.key.toLowerCase()===n}let Xe=0,Ze=0;function Pn(t){const i=t.changedTouches[0];Xe=i.clientX,Ze=i.clientY}function _n(t){const i=t.changedTouches[0],n=i.clientX-Xe,a=i.clientY-Ze;n>70&&Math.abs(a)<50&&p.value.length&&Ie()}function De(){e.nextTick(()=>{const t=Q.value?.querySelector('[aria-selected="true"]');t&&typeof t.scrollIntoView=="function"&&t.scrollIntoView({block:"nearest"})})}function Ie(){S.goBack(),De()}function Nn(t){if(V.value){t.key==="Escape"&&(t.preventDefault(),V.value=null),t.key==="Enter"&&(t.preventDefault(),We());return}if(I.value){const n=I.value.actions??[];if(t.key==="Escape"||t.key==="Tab"||t.key==="Backspace")t.preventDefault(),Ne();else if(t.key==="ArrowDown")t.preventDefault(),n.length&&(R.value=(R.value+1)%n.length);else if(t.key==="ArrowUp")t.preventDefault(),n.length&&(R.value=(R.value-1+n.length)%n.length);else if(t.key==="Enter"){t.preventDefault();const a=n[R.value];a&&Ve(a)}return}if(s.preview&&Tn(t,s.previewHotkey)){t.preventDefault(),b();return}if((t.metaKey||t.ctrlKey)&&t.key.toLowerCase()==="p"){t.preventDefault(),te.value&&N(te.value.id);return}if(s.selectable&&(t.metaKey||t.ctrlKey)&&t.key==="Enter"){t.preventDefault(),$n();return}if(t.altKey&&(t.key==="ArrowUp"||t.key==="ArrowDown")){const n=h.queryHistory.value;if(!n.length)return;t.preventDefault(),H.value=t.key==="ArrowUp"?Math.min(H.value+1,n.length-1):Math.max(H.value-1,-1),m.value=H.value>=0?n[H.value]:"",d.value=0;return}const i=ae.value.length||(m.value.trim()?0:M.value?M.value.length:Se.value.length);if(t.key==="ArrowDown")t.preventDefault(),i&&(d.value=(d.value+1)%i),De();else if(t.key==="ArrowUp")t.preventDefault(),i&&(d.value=(d.value-1+i)%i),De();else if(t.key==="Enter")if(t.preventDefault(),m.value.trim()){const n=ue.value[d.value];n?.command&&U(n.command)}else{const n=d.value,a=M.value?M.value[n]:Se.value[n];a&&U(a)}else t.key==="Escape"?(t.preventDefault(),p.value.length?Ie():B()):t.key==="Backspace"&&!m.value?(t.preventDefault(),Ie()):t.key==="Tab"&&(!t.shiftKey&&te.value?.actions?.length?(t.preventDefault(),xn(te.value)):vn(t))}let Le=null;return e.watch(v,async t=>{typeof document>"u"||(t?(Le=document.activeElement,d.value=0,document.body.style.overflow="hidden",await e.nextTick(),F.value?.focus()):(document.body.style.overflow="",V.value=null,I.value=null,H.value=-1,G.value=[],Le?.focus?.(),Le=null))}),e.watch([V,I],async()=>{v.value&&(await e.nextTick(),V.value||I.value?Y.value?.focus():F.value?.focus())}),(t,i)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[e.renderSlot(t.$slots,"trigger",{open:e.unref(_),toggle:e.unref(E)}),(e.openBlock(),e.createBlock(e.Teleport,{to:o.teleportTo},[e.createVNode(e.Transition,{name:"vcp-fade"},{default:e.withCtx(()=>[e.unref(v)?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(["vcp-overlay",e.unref(h).colorTheme.value!=="system"?`vcp-theme-${e.unref(h).colorTheme.value}`:""]),role:"presentation",onClick:i[6]||(i[6]=e.withModifiers((...n)=>e.unref(B)&&e.unref(B)(...n),["self"]))},[e.createElementVNode("div",{ref_key:"dialogEl",ref:Y,class:e.normalizeClass(["vcp-dialog",[`vcp-dialog--${o.theme}`,{"vcp-dialog--preview":k.value}]]),role:"dialog","aria-modal":"true",tabindex:"-1","aria-label":y.value.dialogLabel,onKeydown:Nn,onTouchstartPassive:Pn,onTouchendPassive:_n},[e.unref(p).length?(e.openBlock(),e.createElementBlock("div",Tt,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(p),(n,a)=>(e.openBlock(),e.createElementBlock("span",{key:n.paletteId,class:"vcp-breadcrumb__item"},[a>0?(e.openBlock(),e.createElementBlock("span",Pt,"›")):e.createCommentVNode("",!0),e.createTextVNode(" "+e.toDisplayString(Sn(n.paletteId)),1)]))),128)),i[7]||(i[7]=e.createElementVNode("span",{class:"vcp-breadcrumb__sep","aria-hidden":"true"},"›",-1))])):e.createCommentVNode("",!0),V.value?(e.openBlock(),e.createElementBlock("div",_t,[e.createElementVNode("p",Nt,e.toDisplayString(V.value.confirm),1),e.createElementVNode("div",Vt,[e.createElementVNode("button",{class:"vcp-confirm__btn vcp-confirm__btn--yes",onClick:We},e.toDisplayString(y.value.confirmYes),1),e.createElementVNode("button",{class:"vcp-confirm__btn vcp-confirm__btn--no",onClick:i[0]||(i[0]=n=>V.value=null)},e.toDisplayString(y.value.confirmCancel),1)])])):I.value?e.renderSlot(t.$slots,"actions",{key:2,command:I.value,run:Ve,activeIndex:R.value,close:Ne},()=>[e.createElementVNode("div",Dt,[e.createElementVNode("div",It,[e.createElementVNode("button",{class:"vcp-actions__back",type:"button",title:y.value.back,onClick:Ne},"‹",8,Lt),e.createElementVNode("span",At,e.toDisplayString(y.value.actions)+" — "+e.toDisplayString(I.value.label),1),e.createElementVNode("span",Rt,[i[8]||(i[8]=e.createElementVNode("kbd",{class:"vcp-kbd"},"Esc",-1)),e.createTextVNode(" "+e.toDisplayString(y.value.back),1)])]),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(I.value.actions,(n,a)=>(e.openBlock(),e.createElementBlock("div",{key:n.id,class:e.normalizeClass(["vcp-item",{"vcp-item--active":a===R.value}]),role:"option","aria-selected":a===R.value,onClick:c=>Ve(n),onMouseenter:c=>R.value=a},[n.icon?(e.openBlock(),e.createElementBlock("span",zt,[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(typeof n.icon=="string"?"span":n.icon),null,{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(typeof n.icon=="string"?n.icon:""),1)]),_:2},1024))])):e.createCommentVNode("",!0),e.createElementVNode("span",Kt,[e.createElementVNode("span",Ft,e.toDisplayString(n.label),1)]),n.shortcut?.length?(e.openBlock(),e.createElementBlock("span",Ht,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(n.shortcut,c=>(e.openBlock(),e.createElementBlock("kbd",{key:c,class:"vcp-kbd"},e.toDisplayString(c),1))),128))])):e.createCommentVNode("",!0)],42,Mt))),128))])]):(e.openBlock(),e.createElementBlock(e.Fragment,{key:3},[e.renderSlot(t.$slots,"header"),e.createElementVNode("div",Ot,[u.value?(e.openBlock(),e.createElementBlock("span",Gt,e.toDisplayString(u.value.label||u.value.prefix),1)):e.createCommentVNode("",!0),e.renderSlot(t.$slots,"input",{query:e.unref(m),onInput:Qe},()=>[e.withDirectives(e.createElementVNode("input",{id:gn,ref_key:"inputEl",ref:F,"onUpdate:modelValue":i[1]||(i[1]=n=>e.isRef(m)?m.value=n:null),class:"vcp-input",type:"text",autocomplete:"off",spellcheck:"false",placeholder:u.value?.placeholder||Z.value?.placeholder||o.placeholder,role:"combobox","aria-expanded":"true","aria-controls":Ye,"aria-activedescendant":En.value,onInput:Qe},null,40,Ut),[[e.vModelText,e.unref(m)]])]),K.value?(e.openBlock(),e.createElementBlock("span",{key:1,class:"vcp-input-spinner",role:"status","aria-label":y.value.loading},null,8,Yt)):e.createCommentVNode("",!0),e.createElementVNode("div",jt,[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(["light","system","dark"],n=>e.createElementVNode("button",{key:n,class:e.normalizeClass(["vcp-theme-btn",{"vcp-theme-btn--active":e.unref(h).colorTheme.value===n}]),title:n==="light"?y.value.themeLight:n==="dark"?y.value.themeDark:y.value.themeSystem,type:"button",onClick:a=>e.unref(h).colorTheme.value=n},[e.createElementVNode("span",{class:e.normalizeClass(["vcp-theme-icon",`vcp-theme-icon--${n}`]),"aria-hidden":"true"},null,2)],10,qt)),64))]),o.preview?(e.openBlock(),e.createElementBlock("button",{key:2,class:e.normalizeClass(["vcp-preview-toggle",{"vcp-preview-toggle--active":k.value}]),type:"button",title:y.value.togglePreview,"aria-label":y.value.togglePreview,"aria-pressed":k.value,onClick:b},[...i[9]||(i[9]=[e.createElementVNode("svg",{viewBox:"0 0 16 16",width:"15",height:"15","aria-hidden":"true",fill:"none",stroke:"currentColor","stroke-width":"1.5"},[e.createElementVNode("rect",{x:"1.5",y:"2.5",width:"13",height:"11",rx:"1.5"}),e.createElementVNode("line",{x1:"10",y1:"2.5",x2:"10",y2:"13.5"})],-1)])],10,Jt)):e.createCommentVNode("",!0)]),e.createElementVNode("div",{class:e.normalizeClass(["vcp-body",{"vcp-body--with-preview":o.preview}])},[e.withDirectives(e.createElementVNode("div",{id:Ye,ref_key:"listEl",ref:Q,class:"vcp-list",role:"listbox","aria-label":o.placeholder},[e.unref(m).trim()?ae.value.length>un?(e.openBlock(),e.createBlock(Ue,{key:1,items:Je.value,"item-height":pn,"container-height":hn,"active-index":Cn.value},{default:e.withCtx(({item:n})=>[n.type==="group-header"?(e.openBlock(),e.createElementBlock("div",on,e.toDisplayString(n.label),1)):n.type==="section"?(e.openBlock(),e.createElementBlock("div",an)):(e.openBlock(),e.createBlock(J,{key:2,command:n.result.command,active:n.index===e.unref(d),matches:n.result.matches,parents:n.result.parents,"matched-text":n.result.matchedText,"item-id":`vcp-item-${n.result.command.id}`,"loading-command-id":e.unref(C),onExecute:a=>U(n.result.command),onActivate:a=>d.value=n.index},e.createSlots({_:2},[t.$slots["item-icon"]?{name:"item-icon",fn:e.withCtx(a=>[e.renderSlot(t.$slots,"item-icon",e.normalizeProps(e.guardReactiveProps(a)))]),key:"0"}:void 0,t.$slots["item-shortcut"]?{name:"item-shortcut",fn:e.withCtx(a=>[e.renderSlot(t.$slots,"item-shortcut",e.normalizeProps(e.guardReactiveProps(a)))]),key:"1"}:void 0,t.$slots.item?{name:"default",fn:e.withCtx(a=>[e.renderSlot(t.$slots,"item",e.normalizeProps(e.guardReactiveProps(a)))]),key:"2"}:void 0]),1032,["command","active","matches","parents","matched-text","item-id","loading-command-id","onExecute","onActivate"]))]),_:3},8,["items","active-index"])):ae.value.length?(e.openBlock(),e.createElementBlock(e.Fragment,{key:2},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(me.value,n=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:n.group.id},[n.section?(e.openBlock(),e.createElementBlock("div",ln)):e.createCommentVNode("",!0),e.createVNode(Be,{group:n.group,items:n.items,"active-index":e.unref(d),"global-offset":n.offset,"loading-command-id":e.unref(C),onExecute:i[4]||(i[4]=a=>U(a)),onActivate:i[5]||(i[5]=a=>d.value=a)},e.createSlots({_:2},[t.$slots["group-header"]?{name:"group-header",fn:e.withCtx(a=>[e.renderSlot(t.$slots,"group-header",e.mergeProps({ref_for:!0},a))]),key:"0"}:void 0,t.$slots["item-icon"]?{name:"item-icon",fn:e.withCtx(a=>[e.renderSlot(t.$slots,"item-icon",e.mergeProps({ref_for:!0},a))]),key:"1"}:void 0,t.$slots["item-shortcut"]?{name:"item-shortcut",fn:e.withCtx(a=>[e.renderSlot(t.$slots,"item-shortcut",e.mergeProps({ref_for:!0},a))]),key:"2"}:void 0,t.$slots.item?{name:"item",fn:e.withCtx(a=>[e.renderSlot(t.$slots,"item",e.mergeProps({ref_for:!0},a))]),key:"3"}:void 0]),1032,["group","items","active-index","global-offset","loading-command-id"])],64))),128)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(_e.value,(n,a)=>(e.openBlock(),e.createBlock(J,{key:n.command.id,command:n.command,active:qe.value+a===e.unref(d),matches:n.matches,parents:n.parents,"matched-text":n.matchedText,"item-id":`vcp-item-${n.command.id}`,"loading-command-id":e.unref(C),onExecute:c=>U(n.command),onActivate:c=>d.value=qe.value+a},e.createSlots({_:2},[t.$slots["item-icon"]?{name:"item-icon",fn:e.withCtx(c=>[e.renderSlot(t.$slots,"item-icon",e.mergeProps({ref_for:!0},c))]),key:"0"}:void 0,t.$slots["item-shortcut"]?{name:"item-shortcut",fn:e.withCtx(c=>[e.renderSlot(t.$slots,"item-shortcut",e.mergeProps({ref_for:!0},c))]),key:"1"}:void 0,t.$slots.item?{name:"default",fn:e.withCtx(c=>[e.renderSlot(t.$slots,"item",e.mergeProps({ref_for:!0},c))]),key:"2"}:void 0]),1032,["command","active","matches","parents","matched-text","item-id","loading-command-id","onExecute","onActivate"]))),128))],64)):K.value?(e.openBlock(),e.createElementBlock("div",rn,e.toDisplayString(o.loadingText),1)):e.unref(m).trim()?(e.openBlock(),e.createElementBlock("div",cn,[e.renderSlot(t.$slots,"empty",{query:e.unref(m)},()=>[e.createTextVNode(e.toDisplayString(o.emptyText),1)])])):e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[M.value?(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:0},e.renderList(M.value,(n,a)=>(e.openBlock(),e.createBlock(J,{key:n.id,command:n,active:a===e.unref(d),matches:[],"item-id":`vcp-item-sub-${n.id}`,"loading-command-id":e.unref(C),onExecute:c=>U(n),onActivate:c=>d.value=a},e.createSlots({_:2},[t.$slots["item-icon"]?{name:"item-icon",fn:e.withCtx(c=>[e.renderSlot(t.$slots,"item-icon",e.mergeProps({ref_for:!0},c))]),key:"0"}:void 0,t.$slots["item-shortcut"]?{name:"item-shortcut",fn:e.withCtx(c=>[e.renderSlot(t.$slots,"item-shortcut",e.mergeProps({ref_for:!0},c))]),key:"1"}:void 0,t.$slots.item?{name:"default",fn:e.withCtx(c=>[e.renderSlot(t.$slots,"item",e.mergeProps({ref_for:!0},c))]),key:"2"}:void 0]),1032,["command","active","item-id","loading-command-id","onExecute","onActivate"]))),128)):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[j.value.length?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[e.createElementVNode("div",Wt,e.toDisplayString(y.value.pinned),1),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(j.value,(n,a)=>(e.openBlock(),e.createBlock(J,{key:n.id,command:n,active:a===e.unref(d),matches:[],"item-id":`vcp-item-pinned-${n.id}`,"loading-command-id":e.unref(C),"always-show-pin":"",onExecute:c=>U(n),onActivate:c=>d.value=a},e.createSlots({_:2},[t.$slots["item-icon"]?{name:"item-icon",fn:e.withCtx(c=>[e.renderSlot(t.$slots,"item-icon",e.mergeProps({ref_for:!0},c))]),key:"0"}:void 0,t.$slots["item-shortcut"]?{name:"item-shortcut",fn:e.withCtx(c=>[e.renderSlot(t.$slots,"item-shortcut",e.mergeProps({ref_for:!0},c))]),key:"1"}:void 0,t.$slots.item?{name:"default",fn:e.withCtx(c=>[e.renderSlot(t.$slots,"item",e.mergeProps({ref_for:!0},c))]),key:"2"}:void 0]),1032,["command","active","item-id","loading-command-id","onExecute","onActivate"]))),128)),q.value.length||L.value.length?(e.openBlock(),e.createElementBlock("div",Xt)):e.createCommentVNode("",!0)],64)):e.createCommentVNode("",!0),q.value.length?(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[e.createElementVNode("div",Zt,e.toDisplayString(y.value.recent),1),ne.value?(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:0},e.renderList(ne.value,(n,a)=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:`vcp-recsec-${a}`},[n.label?(e.openBlock(),e.createElementBlock("div",en,e.toDisplayString(n.label),1)):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(n.commands,(c,D)=>(e.openBlock(),e.createBlock(J,{key:c.id,command:c,active:ee.value+n.offset+D===e.unref(d),matches:[],"item-id":`vcp-item-recent-${c.id}`,"loading-command-id":e.unref(C),onExecute:z=>U(c),onActivate:z=>d.value=ee.value+n.offset+D},e.createSlots({_:2},[t.$slots["item-icon"]?{name:"item-icon",fn:e.withCtx(z=>[e.renderSlot(t.$slots,"item-icon",e.mergeProps({ref_for:!0},z))]),key:"0"}:void 0,t.$slots["item-shortcut"]?{name:"item-shortcut",fn:e.withCtx(z=>[e.renderSlot(t.$slots,"item-shortcut",e.mergeProps({ref_for:!0},z))]),key:"1"}:void 0,t.$slots.item?{name:"default",fn:e.withCtx(z=>[e.renderSlot(t.$slots,"item",e.mergeProps({ref_for:!0},z))]),key:"2"}:void 0]),1032,["command","active","item-id","loading-command-id","onExecute","onActivate"]))),128))],64))),128)):(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:1},e.renderList(q.value,(n,a)=>(e.openBlock(),e.createBlock(J,{key:n.id,command:n,active:ee.value+a===e.unref(d),matches:[],"item-id":`vcp-item-recent-${n.id}`,"loading-command-id":e.unref(C),onExecute:c=>U(n),onActivate:c=>d.value=ee.value+a},e.createSlots({_:2},[t.$slots["item-icon"]?{name:"item-icon",fn:e.withCtx(c=>[e.renderSlot(t.$slots,"item-icon",e.mergeProps({ref_for:!0},c))]),key:"0"}:void 0,t.$slots["item-shortcut"]?{name:"item-shortcut",fn:e.withCtx(c=>[e.renderSlot(t.$slots,"item-shortcut",e.mergeProps({ref_for:!0},c))]),key:"1"}:void 0,t.$slots.item?{name:"default",fn:e.withCtx(c=>[e.renderSlot(t.$slots,"item",e.mergeProps({ref_for:!0},c))]),key:"2"}:void 0]),1032,["command","active","item-id","loading-command-id","onExecute","onActivate"]))),128)),L.value.length?(e.openBlock(),e.createElementBlock("div",tn)):e.createCommentVNode("",!0)],64)):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(L.value,(n,a)=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:n.group.id},[a>0?(e.openBlock(),e.createElementBlock("div",nn)):e.createCommentVNode("",!0),e.createVNode(Be,{group:n.group,items:n.items,"active-index":e.unref(d),"global-offset":fe.value+O(a),"loading-command-id":e.unref(C),onExecute:i[2]||(i[2]=c=>U(c)),onActivate:i[3]||(i[3]=c=>d.value=c)},e.createSlots({_:2},[t.$slots["group-header"]?{name:"group-header",fn:e.withCtx(c=>[e.renderSlot(t.$slots,"group-header",e.mergeProps({ref_for:!0},c))]),key:"0"}:void 0,t.$slots["item-icon"]?{name:"item-icon",fn:e.withCtx(c=>[e.renderSlot(t.$slots,"item-icon",e.mergeProps({ref_for:!0},c))]),key:"1"}:void 0,t.$slots["item-shortcut"]?{name:"item-shortcut",fn:e.withCtx(c=>[e.renderSlot(t.$slots,"item-shortcut",e.mergeProps({ref_for:!0},c))]),key:"2"}:void 0,t.$slots.item?{name:"item",fn:e.withCtx(c=>[e.renderSlot(t.$slots,"item",e.mergeProps({ref_for:!0},c))]),key:"3"}:void 0]),1032,["group","items","active-index","global-offset","loading-command-id"])],64))),128))],64))],64))],8,Qt),[[e.vShow,K.value||M.value!=null||j.value.length||q.value.length||e.unref(m).trim()||oe.value.length]]),o.preview?(e.openBlock(),e.createElementBlock("aside",{key:0,class:e.normalizeClass(["vcp-preview",{"vcp-preview--collapsed":!f.value}]),"aria-hidden":!f.value},[e.createElementVNode("div",mn,[e.renderSlot(t.$slots,"preview",{command:te.value}),te.value?.info?(e.openBlock(),e.createElementBlock("div",{key:0,class:"vcp-preview__info",innerHTML:te.value.info},null,8,dn)):e.createCommentVNode("",!0)])],10,sn)):e.createCommentVNode("",!0)],2),e.renderSlot(t.$slots,"footer"),e.createElementVNode("div",fn,e.toDisplayString(Bn.value),1)],64))],42,xt)],2)):e.createCommentVNode("",!0)]),_:3})],8,["to"]))],64))}});T.CommandGroup=Be,T.CommandItem=J,T.CommandPalette=kn,T.VCommandPalettePlugin=st,T.VirtualList=Ue,T.createCommandPalette=mt,T.createCommandStore=Re,T.createKeyboardManager=ze,T.fuzzySearch=Ae,T.getMatchRanges=le,T.highlightMatches=de,T.installPalette=Ce,T.resolvePaletteContext=se,T.useCommandPalette=Ge,T.useRegisterCommands=dt,T.useRegisterGroup=ft,Object.defineProperty(T,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@macrulez/vue-command-palette",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Command+K palette for Vue 3 — headless, fuzzy search, keyboard navigation, nested palettes",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/vue-command-palette.cjs",
|
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
"build": "vite build",
|
|
21
21
|
"dev": "vite build --watch",
|
|
22
22
|
"typecheck": "tsc --noEmit",
|
|
23
|
+
"lint": "eslint \"src/**/*.{ts,vue}\"",
|
|
23
24
|
"test": "vitest run",
|
|
24
25
|
"test:watch": "vitest",
|
|
25
26
|
"coverage": "vitest run --coverage",
|
|
@@ -45,9 +46,11 @@
|
|
|
45
46
|
"@eslint/js": "^10.0.1",
|
|
46
47
|
"@vitejs/plugin-vue": "^5.0.0",
|
|
47
48
|
"@vitest/coverage-v8": "^4.1.7",
|
|
49
|
+
"@vue/test-utils": "^2.4.10",
|
|
48
50
|
"eslint": "^10.4.0",
|
|
49
51
|
"eslint-config-prettier": "^10.1.8",
|
|
50
52
|
"eslint-plugin-vue": "^10.9.1",
|
|
53
|
+
"globals": "^17.6.0",
|
|
51
54
|
"jsdom": "^29.1.1",
|
|
52
55
|
"lint-staged": "^17.0.5",
|
|
53
56
|
"postcss-html": "^1.8.1",
|
|
@@ -55,6 +58,7 @@
|
|
|
55
58
|
"stylelint": "^17.12.0",
|
|
56
59
|
"stylelint-config-standard": "^40.0.0",
|
|
57
60
|
"typescript": "^5.0.0",
|
|
61
|
+
"typescript-eslint": "^8.60.0",
|
|
58
62
|
"vite": "^5.0.0",
|
|
59
63
|
"vite-plugin-dts": "^3.0.0",
|
|
60
64
|
"vitest": "^4.1.7",
|
package/dist/style.css
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
:root{--vcp-z-index: 9999;--vcp-overlay-bg: rgba(0, 0, 0, .5);--vcp-dialog-bg: #ffffff;--vcp-dialog-color: #111111;--vcp-dialog-radius: 8px;--vcp-dialog-shadow: 0 16px 70px rgba(0, 0, 0, .2);--vcp-dialog-width: 560px;--vcp-dialog-max-height: 60vh;--vcp-dialog-padding-top: 15vh;--vcp-border-color: #eeeeee;--vcp-input-font-size: 16px;--vcp-item-height: 40px;--vcp-item-active-bg: #f0f0f0;--vcp-item-font-size: 14px;--vcp-item-radius: 4px;--vcp-group-header-color: #999999;--vcp-group-header-font-size: 11px;--vcp-kbd-bg: #eeeeee;--vcp-kbd-border: #dddddd;--vcp-match-color: inherit;--vcp-breadcrumb-color: #888888;--vcp-state-color: #999999}@media (prefers-color-scheme: dark){:root{--vcp-dialog-bg: #1a1a1a;--vcp-dialog-color: #eeeeee;--vcp-border-color: #333333;--vcp-item-active-bg: #2a2a2a;--vcp-kbd-bg: #2a2a2a;--vcp-kbd-border: #444444;--vcp-group-header-color: #666666;--vcp-scrollbar-thumb: #444444;--vcp-scrollbar-thumb-hover: #666666}}.vcp-theme-dark{--vcp-dialog-bg: #1a1a1a;--vcp-dialog-color: #eeeeee;--vcp-border-color: #333333;--vcp-item-active-bg: #2a2a2a;--vcp-kbd-bg: #2a2a2a;--vcp-kbd-border: #444444;--vcp-group-header-color: #666666;--vcp-scrollbar-thumb: #444444;--vcp-scrollbar-thumb-hover: #666666}.vcp-theme-light{--vcp-dialog-bg: #ffffff;--vcp-dialog-color: #111111;--vcp-border-color: #eeeeee;--vcp-item-active-bg: #f0f0f0;--vcp-kbd-bg: #eeeeee;--vcp-kbd-border: #dddddd;--vcp-group-header-color: #999999;--vcp-scrollbar-thumb: #d0d0d0;--vcp-scrollbar-thumb-hover: #b0b0b0}.vcp-overlay{position:fixed;inset:0;background:var(--vcp-overlay-bg);display:flex;align-items:flex-start;justify-content:center;padding-top:var(--vcp-dialog-padding-top);z-index:var(--vcp-z-index)}.vcp-dialog{background:var(--vcp-dialog-bg);color:var(--vcp-dialog-color);border-radius:var(--vcp-dialog-radius);box-shadow:var(--vcp-dialog-shadow);width:100%;max-width:var(--vcp-dialog-width);max-height:var(--vcp-dialog-max-height);display:flex;flex-direction:column;overflow:hidden}.vcp-dialog--compact{--vcp-dialog-width: 420px;--vcp-dialog-max-height: 40vh}.vcp-breadcrumb{display:flex;align-items:center;padding:6px 12px 0;font-size:12px;color:var(--vcp-breadcrumb-color);gap:4px}.vcp-breadcrumb__sep{color:var(--vcp-border-color)}.vcp-input-wrap{padding:12px;border-bottom:1px solid var(--vcp-border-color);display:flex;align-items:center;gap:8px}.vcp-input{flex:1;min-width:0;border:none;outline:none;font-size:var(--vcp-input-font-size);background:transparent;color:inherit;box-sizing:border-box}.vcp-theme-switcher{display:flex;gap:1px;flex-shrink:0}.vcp-theme-btn{border:none;background:transparent;cursor:pointer;width:26px;height:26px;border-radius:5px;font-size:13px;display:flex;align-items:center;justify-content:center;opacity:.4;transition:opacity 80ms,background 80ms;padding:0}.vcp-theme-btn:hover{opacity:.8}.vcp-theme-btn--active{opacity:1;background:var(--vcp-item-active-bg)}.vcp-theme-icon{display:block;width:14px;height:14px;background-color:currentColor;-webkit-mask-size:contain;-webkit-mask-repeat:no-repeat;-webkit-mask-position:center;mask-size:contain;mask-repeat:no-repeat;mask-position:center}.vcp-theme-icon--light{-webkit-mask-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 14 14' fill='none'%3E%3Ccircle cx='7' cy='7' r='2.5' fill='black'/%3E%3Cpath d='M7 1v2M7 11v2M1 7h2M11 7h2M9.83 4.17L11.24 2.76M4.17 4.17L2.76 2.76M4.17 9.83L2.76 11.24M9.83 9.83L11.24 11.24' stroke='black' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");mask-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 14 14' fill='none'%3E%3Ccircle cx='7' cy='7' r='2.5' fill='black'/%3E%3Cpath d='M7 1v2M7 11v2M1 7h2M11 7h2M9.83 4.17L11.24 2.76M4.17 4.17L2.76 2.76M4.17 9.83L2.76 11.24M9.83 9.83L11.24 11.24' stroke='black' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E")}.vcp-theme-icon--system{-webkit-mask-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 14 14' fill='none'%3E%3Crect x='1' y='1.5' width='12' height='8' rx='1.5' stroke='black' stroke-width='1.5'/%3E%3Cpath d='M5 13h4M7 9.5v3.5' stroke='black' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");mask-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 14 14' fill='none'%3E%3Crect x='1' y='1.5' width='12' height='8' rx='1.5' stroke='black' stroke-width='1.5'/%3E%3Cpath d='M5 13h4M7 9.5v3.5' stroke='black' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E")}.vcp-theme-icon--dark{-webkit-mask-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 14 14' fill='black'%3E%3Cpath d='M10.3 3.2A5 5 0 1 0 10.3 10.8A4 4 0 0 1 10.3 3.2Z'/%3E%3C/svg%3E");mask-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 14 14' fill='black'%3E%3Cpath d='M10.3 3.2A5 5 0 1 0 10.3 10.8A4 4 0 0 1 10.3 3.2Z'/%3E%3C/svg%3E")}.vcp-list{overflow-y:auto;padding:4px 0;flex:1;scrollbar-width:thin;scrollbar-color:var(--vcp-scrollbar-thumb, #d0d0d0) transparent}.vcp-list::-webkit-scrollbar{width:4px}.vcp-list::-webkit-scrollbar-track{background:transparent}.vcp-list::-webkit-scrollbar-thumb{background:var(--vcp-scrollbar-thumb, #d0d0d0);border-radius:2px}.vcp-list::-webkit-scrollbar-thumb:hover{background:var(--vcp-scrollbar-thumb-hover, #b0b0b0)}.vcp-group__header{padding:6px 12px 2px;font-size:var(--vcp-group-header-font-size);font-weight:600;text-transform:uppercase;letter-spacing:.05em;color:var(--vcp-group-header-color)}.vcp-item{display:flex;align-items:center;gap:8px;padding:0 12px;height:var(--vcp-item-height);cursor:pointer;border-radius:var(--vcp-item-radius);margin:0 4px;transition:background 80ms;box-sizing:border-box}.vcp-item--active{background:var(--vcp-item-active-bg)}.vcp-item--disabled{opacity:.4;cursor:not-allowed}.vcp-item--loading{opacity:.7;cursor:wait}.vcp-item__icon{flex-shrink:0;font-size:16px}.vcp-item__body{flex:1;display:flex;flex-direction:column;gap:1px;overflow:hidden}.vcp-item__label{font-size:var(--vcp-item-font-size);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.vcp-item__description{font-size:11px;color:var(--vcp-group-header-color);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.vcp-item__spinner{width:14px;height:14px;border:2px solid var(--vcp-border-color);border-top-color:currentColor;border-radius:50%;animation:vcp-spin .6s linear infinite;flex-shrink:0}@keyframes vcp-spin{to{transform:rotate(360deg)}}.vcp-section{height:1px;background:var(--vcp-border-color);margin:4px 12px}.vcp-item__shortcut{display:flex;gap:3px;flex-shrink:0}.vcp-kbd{font-family:inherit;font-size:11px;padding:2px 5px;background:var(--vcp-kbd-bg);border-radius:3px;border:1px solid var(--vcp-kbd-border)}mark.vcp-match{background:transparent;color:var(--vcp-match-color);font-weight:700;text-decoration:underline}.vcp-confirm{padding:20px;display:flex;flex-direction:column;gap:12px}.vcp-confirm__text{margin:0;font-size:14px;color:var(--vcp-dialog-color)}.vcp-confirm__actions{display:flex;gap:8px}.vcp-confirm__btn{flex:1;padding:8px 12px;border-radius:var(--vcp-item-radius);border:1px solid var(--vcp-border-color);font-size:13px;cursor:pointer;background:transparent;color:inherit;transition:background 80ms}.vcp-confirm__btn:hover{background:var(--vcp-item-active-bg)}.vcp-confirm__btn--yes{background:#dc2626;color:#fff;border-color:#dc2626}.vcp-confirm__btn--yes:hover{background:#b91c1c;border-color:#b91c1c}.vcp-state{padding:24px;text-align:center;color:var(--vcp-state-color);font-size:var(--vcp-item-font-size)}.vcp-virtual{flex:1}.vcp-fade-enter-active,.vcp-fade-leave-active{transition:opacity .15s ease}.vcp-fade-enter-from,.vcp-fade-leave-to{opacity:0}@media (prefers-reduced-motion: reduce){.vcp-fade-enter-active,.vcp-fade-leave-active{transition:none}}
|