vue-composable-ui 0.0.1 → 1.0.1

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.
Files changed (81) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +5 -1
  3. package/dist/composable-ui.js +1114 -0
  4. package/dist/composable-ui.umd.cjs +1 -0
  5. package/dist/types/components/combobox/comboboxHiddenInput.vue.d.ts +8 -0
  6. package/dist/types/components/combobox/comboboxInput.vue.d.ts +9 -0
  7. package/dist/types/components/combobox/comboboxOption.vue.d.ts +22 -0
  8. package/dist/types/components/combobox/comboboxOptions.vue.d.ts +11 -0
  9. package/dist/types/components/injectionKeys.d.ts +43 -0
  10. package/dist/types/components/listbox/listbox.vue.d.ts +26 -0
  11. package/dist/types/components/listbox/listboxOption.vue.d.ts +22 -0
  12. package/dist/types/components/menu/menuItem.vue.d.ts +26 -0
  13. package/dist/types/components/menu/menuItems.vue.d.ts +11 -0
  14. package/dist/types/components/popover/popoverDialog.vue.d.ts +11 -0
  15. package/dist/types/components/tabs/tab.vue.d.ts +19 -0
  16. package/dist/types/components/tabs/tabContainer.vue.d.ts +18 -0
  17. package/dist/types/components/tabs/tabList.vue.d.ts +17 -0
  18. package/dist/types/components/tabs/tabPanel.vue.d.ts +15 -0
  19. package/dist/types/components/tooltip.vue.d.ts +36 -0
  20. package/dist/types/composables/formControl.d.ts +48 -0
  21. package/dist/types/composables/list.d.ts +103 -0
  22. package/dist/types/composables/listOption.d.ts +30 -0
  23. package/dist/types/composables/popover.d.ts +68 -0
  24. package/{src/main.ts → dist/types/main.d.ts} +3 -44
  25. package/dist/types/utils/element.d.ts +3 -0
  26. package/dist/types/utils/id.d.ts +1 -0
  27. package/package.json +19 -6
  28. package/.github/workflows/deploy.yml +0 -21
  29. package/.github/workflows/docs.yml +0 -62
  30. package/.vscode/extensions.json +0 -7
  31. package/docs/.vitepress/config.mts +0 -40
  32. package/docs/.vitepress/theme/index.js +0 -4
  33. package/docs/.vitepress/theme/style.scss +0 -155
  34. package/docs/components/combobox.md +0 -174
  35. package/docs/components/demos/combobox.vue +0 -142
  36. package/docs/components/demos/combobox_autocomplete.vue +0 -75
  37. package/docs/components/demos/combobox_tags.vue +0 -127
  38. package/docs/components/demos/input.vue +0 -35
  39. package/docs/components/demos/listbox.vue +0 -64
  40. package/docs/components/demos/menu.vue +0 -93
  41. package/docs/components/demos/popover.vue +0 -16
  42. package/docs/components/demos/tabs.vue +0 -59
  43. package/docs/components/demos/tooltip.vue +0 -27
  44. package/docs/components/listbox.md +0 -9
  45. package/docs/components/menu.md +0 -121
  46. package/docs/components/popover.md +0 -82
  47. package/docs/components/tabs.md +0 -9
  48. package/docs/components/tooltip.md +0 -78
  49. package/docs/composables/form-control.md +0 -130
  50. package/docs/composables/list-option.md +0 -47
  51. package/docs/composables/list.md +0 -192
  52. package/docs/composables/popover.md +0 -90
  53. package/docs/index.md +0 -24
  54. package/docs/intro.md +0 -0
  55. package/src/components/combobox/combobox.vue +0 -229
  56. package/src/components/combobox/comboboxFormInput.vue +0 -33
  57. package/src/components/combobox/comboboxOption.vue +0 -52
  58. package/src/components/combobox/comboboxOptions.vue +0 -17
  59. package/src/components/injectionKeys.ts +0 -50
  60. package/src/components/listbox/listbox.vue +0 -91
  61. package/src/components/listbox/listboxOption.vue +0 -37
  62. package/src/components/menu/menu.vue +0 -100
  63. package/src/components/menu/menuItem.vue +0 -86
  64. package/src/components/menu/menuItems.vue +0 -51
  65. package/src/components/popover/popover.vue +0 -68
  66. package/src/components/popover/popoverDialog.vue +0 -35
  67. package/src/components/tabs/tab.vue +0 -35
  68. package/src/components/tabs/tabContainer.vue +0 -50
  69. package/src/components/tabs/tabList.vue +0 -52
  70. package/src/components/tabs/tabPanel.vue +0 -36
  71. package/src/components/tooltip.vue +0 -115
  72. package/src/composables/formControl.ts +0 -144
  73. package/src/composables/list.ts +0 -326
  74. package/src/composables/listOption.ts +0 -80
  75. package/src/composables/popover.ts +0 -306
  76. package/src/utils/element.ts +0 -19
  77. package/src/utils/id.ts +0 -5
  78. package/src/vite-env.d.ts +0 -1
  79. package/tsconfig.json +0 -27
  80. package/tsconfig.node.json +0 -10
  81. package/vite.config.ts +0 -28
@@ -0,0 +1 @@
1
+ (function(k,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],e):(k=typeof globalThis<"u"?globalThis:k||self,e(k["Vue Composable UI"]={},k.Vue))})(this,function(k,e){"use strict";function j(i){return typeof i=="string"?e.ref(document.querySelector(i)||void 0):i instanceof HTMLElement?e.ref(i):i}function T(i,t,{direction:o="down",align:n="left",position:r="fixed",closeOnOutsideClick:l=!0,closeOnInsideClick:u=!1}={}){const a=e.ref(!1);function c(){const p=j(i);if(!p.value)throw new Error("Activator element is undefined");return p.value}function d(){const p=j(t);if(!p.value)throw new Error("Popover element is undefined");return p.value}function b({focus:p=!0}={}){a.value=!0,p&&e.nextTick(()=>{d().focus()})}function v({focus:p=!0}={}){a.value=!1,p&&c().focus()}function f(p){a.value?v(p):b(p)}function h(){if(!a.value)return;const p=c(),$=d();$.style.position=r;const{top:A,right:s,bottom:m,left:w,width:_,height:I}=p.getBoundingClientRect(),B=$.offsetHeight,V=$.offsetWidth,L=document.documentElement.clientHeight,K=document.documentElement.clientWidth;let O=o;o=="up"?A-B<0&&(O="down"):o=="down"?m+B>L&&(O="up"):o=="right"?s+V>K&&(O="left"):o=="left"&&w-V<0&&(O="right");let S=n;n=="left"?w+V>K&&(S="right"):n=="right"?s-V<0&&(S="left"):n=="top"?A+B>L&&(S="bottom"):n=="bottom"&&m-B<0&&(S="top");const C={top:"auto",bottom:"auto",left:"auto",right:"auto",width:"auto"},M=r==="fixed";O=="up"?C.bottom=`${I+(M?L-m:0)}px`:O=="down"?C.top=`${I+(M?A:0)}px`:O=="right"?C.left=`${_+(M?w:0)}px`:O=="left"&&(C.right=`${_+(M?K-s:0)}px`),["up","down"].includes(O)?S=="right"?C.right=`${M?K-s:0}px`:S=="left"||S=="stretch"?C.left=`${M?w:0}px`:S=="center"&&(C.left=`${(M?w:0)-(V-_)/2}px`):S=="bottom"?C.bottom=`${M?L-m:0}px`:S=="top"?C.top=`${M?A:0}px`:S=="center"&&(C.top=`${(M?A:0)-(B-I)/2}px`),["up","down"].includes(O)&&S==="stretch"&&(C.width=_+"px");for(const W in C)$.style[W]=C[W]}e.watch(a,p=>{p&&e.nextTick(()=>{h()})},{flush:"pre"});function E(p){const $=p.target;if(!c().contains($))try{d().contains($)?u&&v():l&&(a.value=!1)}catch{}}const g=new ResizeObserver(h),y=new AbortController;return e.onMounted(()=>{window.addEventListener("resize",h,{passive:!0,signal:y.signal}),window.addEventListener("scroll",h,{passive:!0,signal:y.signal}),window.addEventListener("click",E,{passive:!0,signal:y.signal}),g.observe(c())}),e.onBeforeUnmount(()=>{y.abort(),g.disconnect()}),{isOpen:a,open:b,close:v,toggle:f}}const U=Symbol();function R(i,t){const[o,n]=[e.unref(i),e.unref(t)];return typeof o=="object"?typeof n=="object"?JSON.stringify(o)===JSON.stringify(n):!1:o===n}function D(i){let t=0;const o=e.shallowRef([]),n=e.ref(),r=e.computed(()=>Array.isArray(i.value));function l(s){const m=o.value.find(w=>w.id===s);if(!m)throw new Error(`Item not found: (${s})`);return m}function u(s){const m=e.unref(s.element);if(m)return m.focus(),m}function a(s,{focus:m=!1}={}){n.value=(s==null?void 0:s.id)??void 0,s!==void 0&&m&&u(s)}function c(s,{focus:m=!1}={}){const w=l(s);return a(w,{focus:m})}function d(s){return n.value===s}function b(s,m,w=!1){const _=j(s),I=t++;return o.value.push({id:I,value:m,element:_,disabled:w}),e.triggerRef(o),I}function v(s){d(s)&&a();const m=l(s),w=o.value.indexOf(m);o.value.splice(w,1),e.triggerRef(o)}function f(s){const m=l(s);if(e.unref(m.disabled))return;const w=e.unref(m.value);if(w!==void 0){if(e.unref(r)){const _=i.value.findIndex(I=>R(w,I));_>-1?i.value.splice(_,1):i.value=[...i.value,w]}else i.value=w;a(m)}}function h(s){return e.unref(r)?!!i.value.find(m=>R(s.value,m)):R(i,s.value)}function E(s){try{const m=l(s);return h(m)}catch{return!1}}function g({focus:s=!1}={}){for(let m of o.value)if(h(m))return a(m,{focus:s})}function y({focus:s=!1}={}){if(o.value.length)return a(o.value[0],{focus:s})}function p({focus:s=!1}={}){if(o.value.length)return a(o.value[o.value.length-1],{focus:s})}function $({focus:s=!1,loop:m=!1}={}){if(n.value===void 0)return y({focus:s});const w=l(n.value),_=o.value.indexOf(w);let I;if(_+1<o.value.length)I=o.value[_+1];else if(m)I=o.value[0];else return;return a(I,{focus:s})}function A({focus:s=!1,loop:m=!1}={}){if(n.value===void 0)return p({focus:s});const w=l(n.value),_=o.value.indexOf(w);let I;if(_-1>-1)I=o.value[_-1];else if(m)I=o.value[o.value.length-1];else return;return a(I,{focus:s})}return e.provide(U,{value:e.readonly(i),selectItem:f,activateItem:c,isSelected:E,isActive:d,addItem:b,removeItem:v}),{items:e.shallowReadonly(o),isMultiselectable:e.readonly(r),activeItem:e.computed(()=>n.value!==void 0?l(n.value):void 0),selectActiveItem:()=>{n.value!==void 0&&f(n.value)},activateSelectedItem:g,activateFirstItem:y,activateLastItem:p,activateNextItem:$,activatePrevItem:A}}function P(i,t,o){const n=e.inject(U);if(!n)throw new Error("List injectable context is not provided");const r=e.ref(-1),l=e.computed(()=>n.isSelected(r.value)),u=e.computed(()=>n.isActive(r.value));function a(){n.selectItem(r.value)}function c({focus:d=!0}={}){e.unref(o)||n.activateItem(r.value,{focus:d})}return e.onBeforeMount(()=>{r.value=n.addItem(i,t,o)}),e.onBeforeUnmount(()=>{n.removeItem(r.value)}),{isSelected:l,isActive:u,select:a,activate:c}}function J(i,t=[],o=!0){const n=e.ref(!1),r=e.ref(!0),l=e.ref(),u=e.ref("");let a,c;function d(){a==null||a.focus()}function b(){r.value=a.validity.valid,l.value=a.validity,u.value=a.validationMessage}function v(){if(!a)throw new Error("Form element is undefined");if(a.setCustomValidity(""),a.validity.valid){const g=a.value;for(const y of e.unref(t)){const p=y(g);if(p!==!0){a.setCustomValidity(p);break}}}return b(),r.value}function f(g){b(),e.unref(o)||g.preventDefault()}function h(){v(),n.value=c!==a.value}let E=new AbortController;return e.onMounted(()=>{if(a=j(i).value,!a)throw new Error("Form element is undefined");c=a.value,a.addEventListener("change",h,{signal:E.signal,passive:!0}),a.addEventListener("invalid",f,{signal:E.signal}),a!=null&&a.autofocus&&d()}),e.onBeforeUnmount(()=>{E.abort()}),{focus:d,validate:v,isValid:r,validity:e.readonly(l),validationMessage:e.readonly(u),isChanged:n}}let G=0;function x(i="id"){return`${i}-${++G}`}const N=Symbol(),z=Symbol(),H=Symbol(),F=Symbol(),Q=["aria-activedescendant","aria-orientation","aria-multiselectable"],X=e.defineComponent({__name:"listbox",props:e.mergeModels({orientation:{default:"vertical"},loop:{type:Boolean,default:!1}},{modelValue:{},modelModifiers:{}}),emits:["update:modelValue"],setup(i){const t=i,o=e.useModel(i,"modelValue"),{isMultiselectable:n,activeItem:r,selectActiveItem:l,activateFirstItem:u,activateLastItem:a,activateNextItem:c,activatePrevItem:d}=D(o),b=e.computed(()=>{var f,h;return(h=(f=r.value)==null?void 0:f.element.value)==null?void 0:h.id});function v(f){switch(f.code){case"Space":l();break;case"ArrowUp":if(t.orientation==="horizontal")return;d({focus:!1,loop:t.loop}),n.value||l();break;case"ArrowDown":if(t.orientation==="horizontal")return;c({focus:!1,loop:t.loop}),n.value||l();break;case"ArrowLeft":if(t.orientation==="vertical")return;d({focus:!1,loop:t.loop}),n.value||l();break;case"ArrowRight":if(t.orientation==="vertical")return;c({focus:!1,loop:t.loop}),n.value||l();break;case"Home":u({focus:!1});break;case"End":a({focus:!1});break;default:return}f.preventDefault()}return(f,h)=>(e.openBlock(),e.createElementBlock("div",{onKeydown:v,"aria-activedescendant":b.value,"aria-orientation":f.orientation,"aria-multiselectable":e.unref(n),role:"listbox",tabindex:"0"},[e.renderSlot(f.$slots,"default")],40,Q))}}),Y=["id","aria-disabled","aria-selected","data-active"],Z=e.defineComponent({__name:"listboxOption",props:{id:{},value:{},disabled:{type:Boolean}},setup(i){const t=i,o=t.id??x("list-option"),n=e.ref(),{isSelected:r,isActive:l,select:u}=P(n,t.value,t.disabled);return(a,c)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"itemEl",ref:n,id:e.unref(o),onClick:c[0]||(c[0]=(...d)=>e.unref(u)&&e.unref(u)(...d)),"aria-disabled":a.disabled,"aria-selected":e.unref(r),"data-active":e.unref(l),role:"option",tabindex:"-1"},[e.renderSlot(a.$slots,"default",{isSelected:e.unref(r),isActive:e.unref(l)})],8,Y))}}),ee=e.defineComponent({__name:"tabContainer",props:{modelValue:{},modelModifiers:{}},emits:["update:modelValue"],setup(i){const t=e.useModel(i,"modelValue"),{items:o,selectActiveItem:n,activateFirstItem:r,activateLastItem:l,activateNextItem:u,activatePrevItem:a}=D(t);return e.provide(N,{getIds:c=>e.computed(()=>{var b,v;const d=o.value.find(f=>f.value===c);return{tabId:((b=d==null?void 0:d.element.value)==null?void 0:b.getAttribute("id"))||void 0,panelId:((v=d==null?void 0:d.element.value)==null?void 0:v.getAttribute("aria-controls"))||void 0}}),selectActiveItem:n,activateFirstItem:r,activateLastItem:l,activateNextItem:u,activatePrevItem:a}),(c,d)=>(e.openBlock(),e.createElementBlock("div",null,[e.renderSlot(c.$slots,"default")]))}}),te=["aria-orientation"],oe=e.defineComponent({__name:"tabList",props:{orientation:{default:"horizontal"}},setup(i){const t=i,o=e.inject(N);if(!o)throw new Error("Tabs injectable context is not provided");function n(r){switch(r.code){case"ArrowUp":t.orientation==="vertical"&&o.activatePrevItem({focus:!0,loop:!0});break;case"ArrowDown":t.orientation==="vertical"&&o.activateNextItem({focus:!0,loop:!0});break;case"ArrowLeft":t.orientation==="horizontal"&&o.activatePrevItem({focus:!0,loop:!0});break;case"ArrowRight":t.orientation==="horizontal"&&o.activateNextItem({focus:!0,loop:!0});break;case"Home":o.activateFirstItem({focus:!0});break;case"End":o.activateLastItem({focus:!0});break;default:return}o.selectActiveItem(),r.preventDefault()}return(r,l)=>(e.openBlock(),e.createElementBlock("div",{onKeydown:n,"aria-orientation":t.orientation,role:"tablist"},[e.renderSlot(r.$slots,"default")],40,te))}}),ne=["id","aria-selected","aria-controls","tabindex"],ae=e.defineComponent({__name:"tab",props:{id:{},ariaControls:{},value:{}},setup(i){const t=i,o=e.ref(),{isSelected:n,select:r}=P(o,t.value),l=t.id??x("tab"),u=t.ariaControls??x("tab-panel");return(a,c)=>(e.openBlock(),e.createElementBlock("button",{ref_key:"tab",ref:o,onClick:c[0]||(c[0]=(...d)=>e.unref(r)&&e.unref(r)(...d)),id:e.unref(l),"aria-selected":e.unref(n),"aria-controls":e.unref(u),tabindex:e.unref(n)?0:-1,role:"tab"},[e.renderSlot(a.$slots,"default")],8,ne))}}),ie=["id","aria-labelledby"],re=e.defineComponent({__name:"tabPanel",props:{value:{}},setup(i){const t=i,o=e.inject(U);if(!o)throw new Error("List injectable context is not provided");const n=e.inject(N);if(!n)throw new Error("Tabs injectable context is not provided");const r=e.computed(()=>t.value===o.value.value),l=n.getIds(t.value);return(u,a)=>r.value?(e.openBlock(),e.createElementBlock("div",{key:0,id:e.unref(l).panelId,"aria-labelledby":e.unref(l).tabId,tabindex:"0",role:"tabpanel"},[e.renderSlot(u.$slots,"default")],8,ie)):e.createCommentVNode("",!0)}}),le=e.defineComponent({__name:"popover",props:{id:{},activatorId:{},direction:{default:"down"},align:{default:"left"},position:{default:"fixed"},closeOnOutsideClick:{type:Boolean,default:!0},closeOnInsideClick:{type:Boolean,default:!1},role:{default:"dialog"}},setup(i){const t=i,o=t.id??x("popover"),n=t.activatorId??x("popover-activator"),{isOpen:r,toggle:l,open:u,close:a}=T(`#${n}`,`#${o}`,{direction:t.direction,align:t.align,position:t.position,closeOnOutsideClick:t.closeOnOutsideClick,closeOnInsideClick:t.closeOnInsideClick}),c=e.computed(()=>({id:n,"aria-controls":r.value?t.id:void 0,"aria-haspopup":t.role,"aria-expanded":r.value}));return e.provide(z,{popoverId:o,activatorId:n,role:t.role,isOpen:r,close:a}),(d,b)=>e.renderSlot(d.$slots,"default",{attrs:c.value,isOpen:e.unref(r),toggle:e.unref(l),open:e.unref(u),close:e.unref(a)})}}),se=["id","role","aria-labelledby"],ce=e.defineComponent({__name:"popoverDialog",setup(i){const t=e.inject(z);if(!t)throw new Error("Popover injectable context is not provided");function o(n){switch(n.code){case"Escape":t.close();break;default:return}n.preventDefault()}return(n,r)=>e.unref(t).isOpen.value?(e.openBlock(),e.createElementBlock("div",{key:0,onKeydown:o,id:e.unref(t).popoverId,role:e.unref(t).role,"aria-labelledby":e.unref(t).activatorId,tabindex:"-1"},[e.renderSlot(n.$slots,"default")],40,se)):e.createCommentVNode("",!0)}}),de=["id"],fe=e.defineComponent({inheritAttrs:!1,__name:"tooltip",props:{id:{},text:{},delay:{},direction:{default:"up"}},setup(i){const t=i,o=e.useSlots(),n=e.ref();let r;const l=t.id??x("tooltip"),{isOpen:u}=T(`[aria-describedby=${l}]`,n,{direction:t.direction,align:"center"});function a(){r=setTimeout(()=>{u.value=!0},typeof t.delay=="string"?parseInt(t.delay):t.delay)}function c(){u.value=!1,clearTimeout(r)}function d(f){f.key==="Escape"&&c()}const b={"aria-describedby":l,onmouseenter:a,onmouseleave:c,onfocus:a,onblur:c,onkeydown:d},v=new AbortController;return e.onMounted(()=>{if(o.default)return;const f=document.querySelector(`[aria-describedby=${l}]`);if(!f)throw new Error(`Tooltip activator not found: ${l}`);f.addEventListener("mouseenter",a,{signal:v.signal,passive:!0}),f.addEventListener("mouseleave",c,{signal:v.signal,passive:!0}),f.addEventListener("focus",a,{signal:v.signal,passive:!0}),f.addEventListener("blur",c,{signal:v.signal,passive:!0}),f.addEventListener("keydown",d,{signal:v.signal,passive:!0})}),e.onBeforeUnmount(()=>{v.abort()}),(f,h)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[e.renderSlot(f.$slots,"default",{attrs:b}),(e.openBlock(),e.createBlock(e.Teleport,{to:"body"},[e.unref(u)?(e.openBlock(),e.createElementBlock("div",e.mergeProps({key:0,ref_key:"popupEl",ref:n,id:e.unref(l)},f.$attrs,{role:"tooltip"}),[e.renderSlot(f.$slots,"content",{},()=>[e.createTextVNode(e.toDisplayString(f.text),1)])],16,de)):e.createCommentVNode("",!0)]))],64))}}),ue=e.defineComponent({__name:"menu",props:e.mergeModels({id:{},activatorId:{},direction:{default:"down"},align:{default:"left"},position:{default:"fixed"}},{modelValue:{},modelModifiers:{}}),emits:["update:modelValue"],setup(i){const t=i,o=t.id??x("menu"),n=t.activatorId??x("menu-activator"),r=e.useModel(i,"modelValue"),{isMultiselectable:l,activeItem:u,activateFirstItem:a,activateLastItem:c,activateNextItem:d,activatePrevItem:b}=D(r),{isOpen:v,toggle:f,open:h,close:E}=T(`#${n}`,`#${o}`,{direction:t.direction,align:t.align,position:t.position,closeOnOutsideClick:!0,closeOnInsideClick:!1});function g(p){switch(p.code){case"Space":case"Enter":f(),v.value&&e.nextTick(a);break;case"ArrowUp":h(),e.nextTick(c);break;case"ArrowDown":h(),e.nextTick(a);break;default:return}p.preventDefault()}const y=e.computed(()=>({id:n,"aria-controls":v.value?o:void 0,"aria-haspopup":"menu","aria-expanded":v.value,onclick:f,onkeydown:g,tabindex:0}));return e.provide(H,{menuId:o,activatorId:n,isOpen:v,close:E,isMultiselectable:l,activeItemId:e.computed(()=>{var p,$;return($=(p=u.value)==null?void 0:p.element.value)==null?void 0:$.id}),activateFirstItem:a,activateLastItem:c,activateNextItem:d,activatePrevItem:b}),(p,$)=>e.renderSlot(p.$slots,"default",{attrs:y.value})}}),pe=["id","aria-activedescendant","aria-labelledby"],me=e.defineComponent({__name:"menuItems",setup(i){const t=e.inject(H);if(!t)throw new Error("Menu injectable context is not provided");function o(n){switch(n.code){case"ArrowUp":t.activatePrevItem({focus:!0,loop:!1});break;case"ArrowDown":t.activateNextItem({focus:!0,loop:!1});break;case"Home":t.activateFirstItem({focus:!0});break;case"End":t.activateLastItem({focus:!0});break;case"Escape":t.close();break;case"Tab":t.isOpen.value=!1;return;default:return}n.preventDefault()}return(n,r)=>e.unref(t).isOpen.value?(e.openBlock(),e.createElementBlock("div",{key:0,onKeydown:o,id:e.unref(t).menuId,"aria-activedescendant":e.unref(t).activeItemId.value,"aria-labelledby":e.unref(t).activatorId,role:"menu",tabindex:"-1"},[e.renderSlot(n.$slots,"default")],40,pe)):e.createCommentVNode("",!0)}}),be=["id","data-active","role","aria-checked","aria-disabled"],ve=e.defineComponent({__name:"menuItem",props:{id:{},value:{},disabled:{type:Boolean}},emits:["select"],setup(i,{emit:t}){const o=i,n=t,r=o.id??x("menu-item"),l=e.ref(),{isSelected:u,isActive:a,select:c,activate:d}=P(l,o.value,o.disabled),b=e.inject(H);if(!b)throw new Error("Menu injectable context is not provided");const v=e.computed(()=>o.value!==void 0?b.isMultiselectable.value?"menuitemcheckbox":"menuitemradio":"menuitem");function f(){c(),n("select",o.value)}function h(){f(),(o.value===void 0||!(b!=null&&b.isMultiselectable.value))&&b.close()}function E(g){switch(g.code){case"Space":f(),o.value===void 0&&b.close();break;case"Enter":f(),b.close();break;default:return}g.preventDefault()}return(g,y)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"itemEl",ref:l,id:e.unref(r),onClick:h,onKeydown:E,onMouseenter:y[0]||(y[0]=p=>e.unref(d)({focus:!1})),"data-active":e.unref(a),role:v.value,"aria-checked":g.value!==void 0?e.unref(u):void 0,"aria-disabled":g.disabled||void 0,tabindex:"-1"},[e.renderSlot(g.$slots,"default",{isSelected:e.unref(u),isActive:e.unref(a)})],40,be))}}),ke=["name","value"],q=e.defineComponent({__name:"comboboxHiddenInput",props:{name:{},value:{}},setup(i){const t=i,o=e.computed(()=>{if(typeof t.value=="object"){const n={};for(const[r,l]of Object.entries(t.value))n[`${t.name}[${r}]`]=l;return n}else return{[t.name]:t.value}});return(n,r)=>(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.value,(l,u)=>(e.openBlock(),e.createElementBlock("input",{name:u,value:l,type:"hidden"},null,8,ke))),256))}}),Ie=e.defineComponent({inheritAttrs:!1,__name:"combobox",props:e.mergeModels({displayValue:{type:Function,default:i=>Array.isArray(i)?i.map(t=>t.toString()).join(", "):i.toString()},id:{},activatorId:{},name:{},formValue:{type:Function,default:i=>i}},{modelValue:{},modelModifiers:{}}),emits:["update:modelValue"],setup(i){const t=i,o=e.computed(()=>h.value?n.value.map(I=>t.formValue(I)):t.formValue(n.value)),n=e.useModel(i,"modelValue"),r=t.id??x("combobox"),l=t.activatorId??r,u=`${r}-popover`,{isOpen:a,toggle:c,open:d,close:b}=T(`#${l}`,`#${u}`,{direction:"down",align:"stretch",position:"fixed",closeOnOutsideClick:!0,closeOnInsideClick:!1}),{items:v,activeItem:f,isMultiselectable:h,selectActiveItem:E,activateSelectedItem:g,activateFirstItem:y,activateLastItem:p,activateNextItem:$,activatePrevItem:A}=D(n),s=e.computed(()=>t.displayValue(n.value));e.watch(v,()=>{!f.value&&v.value.length&&(g({focus:!1}),f.value||y({focus:!1}))});function m(){var B;(B=j(`#${l}`).value)==null||B.focus()}function w(I){if(a.value)switch(I.code){case"Space":E(),h.value||b({focus:!0});break;case"Enter":E(),b({focus:!0});break;case"Tab":E(),b({focus:!0});return;case"ArrowUp":A({focus:!1,loop:!1});break;case"ArrowDown":$({focus:!1,loop:!1});break;case"Home":y({focus:!1});break;case"End":p({focus:!1});break;case"Escape":b({focus:!0});break;default:return}else switch(I.code){case"Space":case"Enter":d({focus:!1});break;case"End":case"ArrowUp":d({focus:!1}),e.nextTick(()=>p({focus:!1}));break;case"Home":case"ArrowDown":d({focus:!1}),e.nextTick(()=>y({focus:!1}));break;default:return}I.preventDefault()}const _=e.computed(()=>{var I,B;return{onkeydown:w,onclick:()=>d({focus:!1}),id:r,"aria-controls":a.value?u:void 0,"aria-expanded":a.value,"aria-activedescendant":(B=(I=f.value)==null?void 0:I.element.value)==null?void 0:B.id,"aria-haspopup":"listbox",role:"combobox"}});return e.provide(F,{displayValue:s,popoverId:u,isOpen:a,open:d,close:b,focus:m,isMultiselectable:h,activatorAttrs:_}),(I,B)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[I.name?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[e.unref(h)?(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:0},e.renderList(o.value,(V,L)=>(e.openBlock(),e.createBlock(q,{name:`${I.name}[${L}]`,value:V},null,8,["name","value"]))),256)):(e.openBlock(),e.createBlock(q,{key:1,name:I.name,value:o.value},null,8,["name","value"]))],64)):e.createCommentVNode("",!0),e.renderSlot(I.$slots,"default",{popoverId:u,isOpen:e.unref(a),toggle:e.unref(c),displayValue:s.value,attrs:_.value})],64))}}),he=e.defineComponent({__name:"comboboxInput",props:{modelValue:{},modelModifiers:{}},emits:["update:modelValue"],setup(i){const t=e.inject(F);if(!t)throw new Error("Combobox injectable context is not provided");const o=e.useModel(i,"modelValue");function n(){o.value=t.displayValue.value}e.watch(t.displayValue,n,{immediate:!0});const r=e.computed(()=>({oninput:()=>t.open({focus:!0}),onchange:n,...t.activatorAttrs.value}));return(l,u)=>e.withDirectives((e.openBlock(),e.createElementBlock("input",e.mergeProps({"onUpdate:modelValue":u[0]||(u[0]=a=>o.value=a)},r.value,{autocomplete:"off"}),null,16)),[[e.vModelDynamic,o.value]])}}),we=["id"],ge=e.defineComponent({__name:"comboboxOptions",setup(i){const t=e.inject(F);if(!t)throw new Error("Combobox injectable context is not provided");return(o,n)=>e.unref(t).isOpen.value?(e.openBlock(),e.createElementBlock("div",{key:0,id:e.unref(t).popoverId,role:"listbox"},[e.renderSlot(o.$slots,"default")],8,we)):e.createCommentVNode("",!0)}}),ye=["id","data-active","aria-selected","aria-disabled"],_e=e.defineComponent({__name:"comboboxOption",props:{id:{},value:{},disabled:{type:Boolean}},setup(i){const t=i,o=t.id??x("combobox-option"),n=e.ref(),{isSelected:r,isActive:l,activate:u,select:a}=P(n,t.value,t.disabled),c=e.inject(F);if(!c)throw new Error("Combobox injectable context is not provided");function d(){a(),c.isMultiselectable.value?c.focus():c.close({focus:!0})}return(b,v)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"itemEl",ref:n,id:e.unref(o),onClick:d,onMouseenter:v[0]||(v[0]=f=>e.unref(u)({focus:!1})),"data-active":e.unref(l),"aria-selected":e.unref(r),"aria-disabled":b.disabled||void 0,role:"option"},[e.renderSlot(b.$slots,"default",{isSelected:e.unref(r),isActive:e.unref(l)})],40,ye))}});k.Combobox=Ie,k.ComboboxInput=he,k.ComboboxOption=_e,k.ComboboxOptions=ge,k.Listbox=X,k.ListboxOption=Z,k.Menu=ue,k.MenuItem=ve,k.MenuItems=me,k.Popover=le,k.PopoverDialog=ce,k.Tab=ae,k.TabContainer=ee,k.TabList=oe,k.TabPanel=re,k.Tooltip=fe,k.injectCombobox=F,k.injectMenu=H,k.injectPopover=z,k.injectTabs=N,k.useFormControl=J,k.useHTMLElement=j,k.useList=D,k.useListOption=P,k.usePopover=T,k.useSequentialId=x,Object.defineProperty(k,Symbol.toStringTag,{value:"Module"})});
@@ -0,0 +1,8 @@
1
+ declare const _default: import("vue").DefineComponent<{
2
+ name: string;
3
+ value: any;
4
+ }, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{
5
+ name: string;
6
+ value: any;
7
+ }> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
8
+ export default _default;
@@ -0,0 +1,9 @@
1
+ type __VLS_PublicProps = {
2
+ modelValue?: string;
3
+ };
4
+ declare const _default: import("vue").DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
5
+ "update:modelValue": (modelValue: string) => any;
6
+ }, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
7
+ "onUpdate:modelValue"?: ((modelValue: string) => any) | undefined;
8
+ }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
9
+ export default _default;
@@ -0,0 +1,22 @@
1
+ declare function __VLS_template(): {
2
+ default?(_: {
3
+ isSelected: boolean;
4
+ isActive: boolean;
5
+ }): any;
6
+ };
7
+ declare const __VLS_component: import("vue").DefineComponent<{
8
+ id?: string;
9
+ value: any;
10
+ disabled?: boolean;
11
+ }, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{
12
+ id?: string;
13
+ value: any;
14
+ disabled?: boolean;
15
+ }> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
16
+ declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, ReturnType<typeof __VLS_template>>;
17
+ export default _default;
18
+ type __VLS_WithTemplateSlots<T, S> = T & {
19
+ new (): {
20
+ $slots: S;
21
+ };
22
+ };
@@ -0,0 +1,11 @@
1
+ declare function __VLS_template(): {
2
+ default?(_: {}): any;
3
+ };
4
+ declare const __VLS_component: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
5
+ declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, ReturnType<typeof __VLS_template>>;
6
+ export default _default;
7
+ type __VLS_WithTemplateSlots<T, S> = T & {
8
+ new (): {
9
+ $slots: S;
10
+ };
11
+ };
@@ -0,0 +1,43 @@
1
+ import type { ComputedRef, InjectionKey } from "vue";
2
+ import type { UseListReturn } from "../composables/list";
3
+ import type { UsePopoverReturn } from "../composables/popover";
4
+ export declare const injectTabs: InjectionKey<{
5
+ getIds: (value: any) => ComputedRef<{
6
+ tabId: string | undefined;
7
+ panelId: string | undefined;
8
+ }>;
9
+ selectActiveItem: UseListReturn["selectActiveItem"];
10
+ activateFirstItem: UseListReturn["activateFirstItem"];
11
+ activateLastItem: UseListReturn["activateLastItem"];
12
+ activateNextItem: UseListReturn["activateNextItem"];
13
+ activatePrevItem: UseListReturn["activatePrevItem"];
14
+ }>;
15
+ export declare const injectPopover: InjectionKey<{
16
+ popoverId: string;
17
+ activatorId: string;
18
+ role: "dialog" | "listbox" | "menu" | "tree" | "grid";
19
+ isOpen: UsePopoverReturn["isOpen"];
20
+ close: UsePopoverReturn["close"];
21
+ }>;
22
+ export declare const injectMenu: InjectionKey<{
23
+ menuId: string;
24
+ activatorId: string;
25
+ isOpen: UsePopoverReturn["isOpen"];
26
+ close: UsePopoverReturn["close"];
27
+ activeItemId: ComputedRef<string | undefined>;
28
+ isMultiselectable: UseListReturn["isMultiselectable"];
29
+ activateFirstItem: UseListReturn["activateFirstItem"];
30
+ activateLastItem: UseListReturn["activateLastItem"];
31
+ activateNextItem: UseListReturn["activateNextItem"];
32
+ activatePrevItem: UseListReturn["activatePrevItem"];
33
+ }>;
34
+ export declare const injectCombobox: InjectionKey<{
35
+ displayValue: ComputedRef<string | undefined>;
36
+ popoverId: string;
37
+ isOpen: UsePopoverReturn["isOpen"];
38
+ open: UsePopoverReturn["open"];
39
+ close: UsePopoverReturn["close"];
40
+ isMultiselectable: UseListReturn["isMultiselectable"];
41
+ focus: () => void;
42
+ activatorAttrs: ComputedRef<Record<string, any>>;
43
+ }>;
@@ -0,0 +1,26 @@
1
+ declare let __VLS_typeProps: {
2
+ orientation?: "horizontal" | "vertical";
3
+ loop?: boolean;
4
+ };
5
+ type __VLS_PublicProps = {
6
+ modelValue?: any;
7
+ } & typeof __VLS_typeProps;
8
+ declare function __VLS_template(): {
9
+ default?(_: {}): any;
10
+ };
11
+ declare const __VLS_component: import("vue").DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
12
+ "update:modelValue": (modelValue: any) => any;
13
+ }, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
14
+ "onUpdate:modelValue"?: ((modelValue: any) => any) | undefined;
15
+ }>, {
16
+ loop: boolean;
17
+ orientation: "horizontal" | "vertical";
18
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
19
+ declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, ReturnType<typeof __VLS_template>>;
20
+ export default _default;
21
+
22
+ type __VLS_WithTemplateSlots<T, S> = T & {
23
+ new (): {
24
+ $slots: S;
25
+ };
26
+ };
@@ -0,0 +1,22 @@
1
+ declare function __VLS_template(): {
2
+ default?(_: {
3
+ isSelected: boolean;
4
+ isActive: boolean;
5
+ }): any;
6
+ };
7
+ declare const __VLS_component: import("vue").DefineComponent<{
8
+ id?: string;
9
+ value?: any;
10
+ disabled?: boolean;
11
+ }, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{
12
+ id?: string;
13
+ value?: any;
14
+ disabled?: boolean;
15
+ }> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
16
+ declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, ReturnType<typeof __VLS_template>>;
17
+ export default _default;
18
+ type __VLS_WithTemplateSlots<T, S> = T & {
19
+ new (): {
20
+ $slots: S;
21
+ };
22
+ };
@@ -0,0 +1,26 @@
1
+ declare function __VLS_template(): {
2
+ default?(_: {
3
+ isSelected: boolean;
4
+ isActive: boolean;
5
+ }): any;
6
+ };
7
+ declare const __VLS_component: import("vue").DefineComponent<{
8
+ id?: string;
9
+ value?: any;
10
+ disabled?: boolean;
11
+ }, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
12
+ select: (value: any) => any;
13
+ }, string, import("vue").PublicProps, Readonly<{
14
+ id?: string;
15
+ value?: any;
16
+ disabled?: boolean;
17
+ }> & Readonly<{
18
+ onSelect?: ((value: any) => any) | undefined;
19
+ }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
20
+ declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, ReturnType<typeof __VLS_template>>;
21
+ export default _default;
22
+ type __VLS_WithTemplateSlots<T, S> = T & {
23
+ new (): {
24
+ $slots: S;
25
+ };
26
+ };
@@ -0,0 +1,11 @@
1
+ declare function __VLS_template(): {
2
+ default?(_: {}): any;
3
+ };
4
+ declare const __VLS_component: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
5
+ declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, ReturnType<typeof __VLS_template>>;
6
+ export default _default;
7
+ type __VLS_WithTemplateSlots<T, S> = T & {
8
+ new (): {
9
+ $slots: S;
10
+ };
11
+ };
@@ -0,0 +1,11 @@
1
+ declare function __VLS_template(): {
2
+ default?(_: {}): any;
3
+ };
4
+ declare const __VLS_component: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
5
+ declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, ReturnType<typeof __VLS_template>>;
6
+ export default _default;
7
+ type __VLS_WithTemplateSlots<T, S> = T & {
8
+ new (): {
9
+ $slots: S;
10
+ };
11
+ };
@@ -0,0 +1,19 @@
1
+ declare function __VLS_template(): {
2
+ default?(_: {}): any;
3
+ };
4
+ declare const __VLS_component: import("vue").DefineComponent<{
5
+ id?: string;
6
+ ariaControls?: string;
7
+ value: string | number;
8
+ }, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{
9
+ id?: string;
10
+ ariaControls?: string;
11
+ value: string | number;
12
+ }> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
13
+ declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, ReturnType<typeof __VLS_template>>;
14
+ export default _default;
15
+ type __VLS_WithTemplateSlots<T, S> = T & {
16
+ new (): {
17
+ $slots: S;
18
+ };
19
+ };
@@ -0,0 +1,18 @@
1
+ type __VLS_PublicProps = {
2
+ modelValue?: string | number;
3
+ };
4
+ declare function __VLS_template(): {
5
+ default?(_: {}): any;
6
+ };
7
+ declare const __VLS_component: import("vue").DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
8
+ "update:modelValue": (modelValue: string | number) => any;
9
+ }, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
10
+ "onUpdate:modelValue"?: ((modelValue: string | number) => any) | undefined;
11
+ }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
12
+ declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, ReturnType<typeof __VLS_template>>;
13
+ export default _default;
14
+ type __VLS_WithTemplateSlots<T, S> = T & {
15
+ new (): {
16
+ $slots: S;
17
+ };
18
+ };
@@ -0,0 +1,17 @@
1
+ declare function __VLS_template(): {
2
+ default?(_: {}): any;
3
+ };
4
+ declare const __VLS_component: import("vue").DefineComponent<{
5
+ orientation?: "horizontal" | "vertical";
6
+ }, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{
7
+ orientation?: "horizontal" | "vertical";
8
+ }> & Readonly<{}>, {
9
+ orientation: "horizontal" | "vertical";
10
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
11
+ declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, ReturnType<typeof __VLS_template>>;
12
+ export default _default;
13
+ type __VLS_WithTemplateSlots<T, S> = T & {
14
+ new (): {
15
+ $slots: S;
16
+ };
17
+ };
@@ -0,0 +1,15 @@
1
+ declare function __VLS_template(): {
2
+ default?(_: {}): any;
3
+ };
4
+ declare const __VLS_component: import("vue").DefineComponent<{
5
+ value: string | number;
6
+ }, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{
7
+ value: string | number;
8
+ }> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
9
+ declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, ReturnType<typeof __VLS_template>>;
10
+ export default _default;
11
+ type __VLS_WithTemplateSlots<T, S> = T & {
12
+ new (): {
13
+ $slots: S;
14
+ };
15
+ };
@@ -0,0 +1,36 @@
1
+ declare function open(): void;
2
+ declare function close(): void;
3
+ declare function onKeyDown(evt: KeyboardEvent): void;
4
+ declare function __VLS_template(): {
5
+ default?(_: {
6
+ attrs: {
7
+ "aria-describedby": string;
8
+ onmouseenter: typeof open;
9
+ onmouseleave: typeof close;
10
+ onfocus: typeof open;
11
+ onblur: typeof close;
12
+ onkeydown: typeof onKeyDown;
13
+ };
14
+ }): any;
15
+ content?(_: {}): any;
16
+ };
17
+ declare const __VLS_component: import("vue").DefineComponent<{
18
+ id?: string;
19
+ text?: string;
20
+ delay?: string | number;
21
+ direction?: "up" | "down" | "left" | "right";
22
+ }, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{
23
+ id?: string;
24
+ text?: string;
25
+ delay?: string | number;
26
+ direction?: "up" | "down" | "left" | "right";
27
+ }> & Readonly<{}>, {
28
+ direction: "up" | "down" | "left" | "right";
29
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
30
+ declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, ReturnType<typeof __VLS_template>>;
31
+ export default _default;
32
+ type __VLS_WithTemplateSlots<T, S> = T & {
33
+ new (): {
34
+ $slots: S;
35
+ };
36
+ };
@@ -0,0 +1,48 @@
1
+ import type { MaybeRef, Ref } from "vue";
2
+ import type { TemplateRefOrSelector } from "../utils/element";
3
+ type FormElement = HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement;
4
+ /**
5
+ * A validating function must return `true` or a string describing the error
6
+ */
7
+ export type FormValidator = (value: string) => boolean | string;
8
+ export interface useFormControlReturn {
9
+ /**
10
+ * Focus the form control
11
+ */
12
+ focus: () => void;
13
+ /**
14
+ * Validate the form control
15
+ *
16
+ * @returns Validation result
17
+ */
18
+ validate: () => boolean;
19
+ /**
20
+ * Whether the form control is valid. A shorthand for `validity.valid`, but can be manually overriden.
21
+ */
22
+ isValid: Ref<boolean>;
23
+ /**
24
+ * The validity state of the form control
25
+ *
26
+ * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/ValidityState}
27
+ */
28
+ validity: Readonly<Ref<ValidityState | undefined>>;
29
+ /**
30
+ * A string representing a localized message that describes the validation constraints that the control does not satisfy (if any)
31
+ */
32
+ validationMessage: Readonly<Ref<string>>;
33
+ /**
34
+ * Whether the value has been changed since the form control was mounted
35
+ */
36
+ isChanged: Ref<boolean>;
37
+ }
38
+ /**
39
+ * Utilizes Constraint Validation API to enable custom validation constrains for a form control
40
+ *
41
+ * @param el A template ref or a CSS selector
42
+ * @param validators An array of validating functions
43
+ * @param showValidationError Whether to show the default browser validation error (true by default)
44
+ *
45
+ * @see {@link https://developer.mozilla.org/en-US/docs/Web/HTML/Constraint_validation}
46
+ */
47
+ export declare function useFormControl(el: TemplateRefOrSelector<FormElement>, validators?: MaybeRef<FormValidator[]>, showValidationError?: MaybeRef<boolean>): useFormControlReturn;
48
+ export {};
@@ -0,0 +1,103 @@
1
+ import type { ComputedRef, MaybeRef, Ref, ShallowRef, InjectionKey } from "vue";
2
+ import { TemplateRefOrSelector } from "../utils/element";
3
+ export type ItemValue = unknown;
4
+ export interface Item {
5
+ id: number;
6
+ element: Ref<HTMLElement | undefined>;
7
+ value: ItemValue;
8
+ disabled: MaybeRef<boolean>;
9
+ }
10
+ export interface ActivationOptions {
11
+ /**
12
+ * Focus the corresponding HTML element
13
+ *
14
+ * @defaultValue `false`
15
+ */
16
+ focus?: boolean;
17
+ }
18
+ interface NavigationOptions {
19
+ /**
20
+ * Infinitely cycle through the items
21
+ *
22
+ * @defaultValue `false`
23
+ */
24
+ loop?: boolean;
25
+ }
26
+ export interface UseListReturn {
27
+ /**
28
+ * Array of items
29
+ */
30
+ items: Readonly<ShallowRef<Item[]>>;
31
+ /**
32
+ * Multiselection flag
33
+ */
34
+ isMultiselectable: Readonly<Ref<boolean>>;
35
+ /**
36
+ * Currently active item
37
+ */
38
+ activeItem: ComputedRef<Item | undefined>;
39
+ /**
40
+ * Select the currently active item
41
+ */
42
+ selectActiveItem: () => void;
43
+ /**
44
+ * Activate the currently selected item
45
+ */
46
+ activateSelectedItem: (options?: ActivationOptions) => void;
47
+ /**
48
+ * Activate the first item
49
+ */
50
+ activateFirstItem: (options?: ActivationOptions) => void;
51
+ /**
52
+ * Activate the last item
53
+ */
54
+ activateLastItem: (options?: ActivationOptions) => void;
55
+ /**
56
+ * Activate next item
57
+ */
58
+ activateNextItem: (options?: ActivationOptions & NavigationOptions) => void;
59
+ /**
60
+ * Activate previous item
61
+ */
62
+ activatePrevItem: (options?: ActivationOptions & NavigationOptions) => void;
63
+ }
64
+ interface UseListInjectionKey {
65
+ /**
66
+ * The list value
67
+ */
68
+ value: Readonly<Ref<unknown>>;
69
+ /**
70
+ * Select an item by ID
71
+ */
72
+ selectItem: (itemId: number) => void;
73
+ /**
74
+ * Activate an item by ID
75
+ */
76
+ activateItem: (itemId: number, options?: ActivationOptions) => void;
77
+ /**
78
+ * Check if an item is selected
79
+ */
80
+ isSelected: (itemId: number) => boolean;
81
+ /**
82
+ * Check if an item is active
83
+ */
84
+ isActive: (itemId: number) => boolean;
85
+ /**
86
+ * Add an item to the list
87
+ *
88
+ * @returns New item ID
89
+ */
90
+ addItem: (itemEl: TemplateRefOrSelector, itemVal: ItemValue, disabled?: MaybeRef<boolean>) => number;
91
+ /**
92
+ * Remove an item from the list by ID
93
+ */
94
+ removeItem: (itemId: number) => void;
95
+ }
96
+ export declare const injectList: InjectionKey<UseListInjectionKey>;
97
+ /**
98
+ * Creates a reactive list of HTML elements with assigned values.
99
+ *
100
+ * @param value A ref to store the list value. Set to an array to enable multiselection.
101
+ */
102
+ export declare function useList(value: Ref<unknown>): UseListReturn;
103
+ export {};
@@ -0,0 +1,30 @@
1
+ import type { ComputedRef, MaybeRef } from "vue";
2
+ import type { TemplateRefOrSelector } from "../utils/element";
3
+ import type { ItemValue, ActivationOptions } from "./list";
4
+ interface UseListOptionReturn {
5
+ /**
6
+ * Whether the item is selected
7
+ */
8
+ isSelected: ComputedRef<boolean>;
9
+ /**
10
+ * Whether the item is active
11
+ */
12
+ isActive: ComputedRef<boolean>;
13
+ /**
14
+ * Select the item
15
+ */
16
+ select: () => void;
17
+ /**
18
+ * Activate the item
19
+ */
20
+ activate: (options?: ActivationOptions) => void;
21
+ }
22
+ /**
23
+ * Registers an HTML element and an associated value in the list created in the parent component
24
+ *
25
+ * @param el A template ref or a CSS selector
26
+ * @param value A value of any type
27
+ * @param disabled Whether the item is disabled (false by default)
28
+ */
29
+ export declare function useListOption(el: TemplateRefOrSelector, value: ItemValue, disabled?: MaybeRef<boolean>): UseListOptionReturn;
30
+ export {};
@@ -0,0 +1,68 @@
1
+ import type { Ref } from "vue";
2
+ import { TemplateRefOrSelector } from "../utils/element";
3
+ interface UsePopoverOptions {
4
+ /**
5
+ * The direction of the popover dialog
6
+ *
7
+ * @defaultValue `"down"`
8
+ */
9
+ direction?: "up" | "down" | "left" | "right";
10
+ /**
11
+ * The alignment of the popover dialog
12
+ *
13
+ * @defaultValue `"left"`
14
+ */
15
+ align?: "top" | "bottom" | "left" | "right" | "center" | "stretch";
16
+ /**
17
+ * The CSS position of the popover dialog
18
+ *
19
+ * @defaultValue `"fixed"`
20
+ */
21
+ position?: "fixed" | "absolute";
22
+ /**
23
+ * Close the popover on a click outside of the dialog
24
+ *
25
+ * @defaultValue `true`
26
+ */
27
+ closeOnOutsideClick?: boolean;
28
+ /**
29
+ * Close the popover on a click inside of the dialog
30
+ *
31
+ * @defaultValue `false`
32
+ */
33
+ closeOnInsideClick?: boolean;
34
+ }
35
+ interface FocusOptions {
36
+ /**
37
+ * Focus the popover/activator
38
+ *
39
+ * @defaultValue `true`
40
+ */
41
+ focus?: boolean;
42
+ }
43
+ export interface UsePopoverReturn {
44
+ /**
45
+ * The popover state
46
+ */
47
+ isOpen: Ref<boolean>;
48
+ /**
49
+ * Open the popover
50
+ */
51
+ open: (options?: FocusOptions) => void;
52
+ /**
53
+ * Close the popover
54
+ */
55
+ close: (options?: FocusOptions) => void;
56
+ /**
57
+ * Toggle the popover
58
+ */
59
+ toggle: (options?: FocusOptions) => void;
60
+ }
61
+ /**
62
+ *
63
+ * @param activatorEl A template ref or a CSS selector
64
+ * @param popupEl A template ref or a CSS selector
65
+ * @param options Popover options
66
+ */
67
+ export declare function usePopover(activatorEl: TemplateRefOrSelector, popupEl: TemplateRefOrSelector, { direction, align, position, closeOnOutsideClick, closeOnInsideClick, }?: UsePopoverOptions): UsePopoverReturn;
68
+ export {};