@headlessui/vue
Advanced tools
Comparing version 0.0.0-insiders.ef3e154 to 0.0.0-insiders.ef78d58
@@ -1,3 +0,2 @@ | ||
import { PropType } from 'vue'; | ||
declare function defaultComparator<T>(a: T, z: T): boolean; | ||
import { type PropType } from 'vue'; | ||
export declare let Combobox: import("vue").DefineComponent<{ | ||
@@ -14,3 +13,4 @@ as: { | ||
type: (StringConstructor | FunctionConstructor)[]; | ||
default: () => typeof defaultComparator; | ||
nullable: boolean; | ||
default: null; | ||
}; | ||
@@ -25,4 +25,9 @@ modelValue: { | ||
}; | ||
form: { | ||
type: StringConstructor; | ||
optional: boolean; | ||
}; | ||
name: { | ||
type: StringConstructor; | ||
optional: boolean; | ||
}; | ||
@@ -37,2 +42,13 @@ nullable: { | ||
}; | ||
immediate: { | ||
type: BooleanConstructor[]; | ||
default: boolean; | ||
}; | ||
virtual: { | ||
type: PropType<{ | ||
options: unknown[]; | ||
disabled?: ((value: unknown) => boolean) | undefined; | ||
} | null>; | ||
default: null; | ||
}; | ||
}, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, { | ||
@@ -53,3 +69,4 @@ [key: string]: any; | ||
type: (StringConstructor | FunctionConstructor)[]; | ||
default: () => typeof defaultComparator; | ||
nullable: boolean; | ||
default: null; | ||
}; | ||
@@ -64,4 +81,9 @@ modelValue: { | ||
}; | ||
form: { | ||
type: StringConstructor; | ||
optional: boolean; | ||
}; | ||
name: { | ||
type: StringConstructor; | ||
optional: boolean; | ||
}; | ||
@@ -76,2 +98,13 @@ nullable: { | ||
}; | ||
immediate: { | ||
type: BooleanConstructor[]; | ||
default: boolean; | ||
}; | ||
virtual: { | ||
type: PropType<{ | ||
options: unknown[]; | ||
disabled?: ((value: unknown) => boolean) | undefined; | ||
} | null>; | ||
default: null; | ||
}; | ||
}>> & { | ||
@@ -87,2 +120,7 @@ "onUpdate:modelValue"?: ((_value: any) => any) | undefined; | ||
multiple: boolean; | ||
immediate: boolean; | ||
virtual: { | ||
options: unknown[]; | ||
disabled?: ((value: unknown) => boolean) | undefined; | ||
} | null; | ||
}>; | ||
@@ -112,4 +150,4 @@ export declare let ComboboxLabel: import("vue").DefineComponent<{ | ||
}>>, { | ||
id: string; | ||
as: string | Record<string, any>; | ||
id: string; | ||
}>; | ||
@@ -139,4 +177,4 @@ export declare let ComboboxButton: import("vue").DefineComponent<{ | ||
}>>, { | ||
id: string; | ||
as: string | Record<string, any>; | ||
id: string; | ||
}>; | ||
@@ -204,6 +242,6 @@ export declare let ComboboxInput: import("vue").DefineComponent<{ | ||
}, { | ||
id: string; | ||
as: string | Record<string, any>; | ||
unmount: boolean; | ||
static: boolean; | ||
id: string; | ||
defaultValue: string; | ||
@@ -267,2 +305,6 @@ }>; | ||
}; | ||
order: { | ||
type: NumberConstructor[]; | ||
default: null; | ||
}; | ||
}, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, { | ||
@@ -284,6 +326,10 @@ [key: string]: any; | ||
}; | ||
order: { | ||
type: NumberConstructor[]; | ||
default: null; | ||
}; | ||
}>>, { | ||
as: string | Record<string, any>; | ||
disabled: boolean; | ||
order: number; | ||
}>; | ||
export {}; |
@@ -1,1 +0,1 @@ | ||
import{Fragment as Q,computed as C,defineComponent as F,h as q,inject as X,nextTick as L,onMounted as $,onUnmounted as Y,provide as Z,ref as P,toRaw as c,watch as _,watchEffect as U}from"vue";import{Features as K,render as B,omit as J,compact as z}from'../../utils/render.js';import{useId as N}from'../../hooks/use-id.js';import{Keys as V}from'../../keyboard.js';import{calculateActiveIndex as ee,Focus as R}from'../../utils/calculate-active-index.js';import{dom as I}from'../../utils/dom.js';import{useOpenClosed as te,State as W,useOpenClosedProvider as oe}from'../../internal/open-closed.js';import{match as M}from'../../utils/match.js';import{useResolveButtonType as ae}from'../../hooks/use-resolve-button-type.js';import{useTreeWalker as le}from'../../hooks/use-tree-walker.js';import{sortByDomNode as ne}from'../../utils/focus-management.js';import{useOutsideClick as ie}from'../../hooks/use-outside-click.js';import{Hidden as ue,Features as re}from'../../internal/hidden.js';import{objectToFormEntries as se}from'../../utils/form.js';import{useControllable as de}from'../../hooks/use-controllable.js';function pe(o,O){return o===O}var fe=(s=>(s[s.Open=0]="Open",s[s.Closed=1]="Closed",s))(fe||{}),be=(s=>(s[s.Single=0]="Single",s[s.Multi=1]="Multi",s))(be||{}),ve=(s=>(s[s.Pointer=0]="Pointer",s[s.Other=1]="Other",s))(ve||{});let G=Symbol("ComboboxContext");function j(o){let O=X(G,null);if(O===null){let s=new Error(`<${o} /> is missing a parent <Combobox /> component.`);throw Error.captureStackTrace&&Error.captureStackTrace(s,j),s}return O}let Le=F({name:"Combobox",emits:{"update:modelValue":o=>!0},props:{as:{type:[Object,String],default:"template"},disabled:{type:[Boolean],default:!1},by:{type:[String,Function],default:()=>pe},modelValue:{type:[Object,String,Number,Boolean],default:void 0},defaultValue:{type:[Object,String,Number,Boolean],default:void 0},name:{type:String},nullable:{type:Boolean,default:!1},multiple:{type:[Boolean],default:!1}},inheritAttrs:!1,setup(o,{slots:O,attrs:s,emit:T}){let e=P(1),t=P(null),d=P(null),g=P(null),p=P(null),b=P({static:!1,hold:!1}),v=P([]),x=P(null),y=P(1),h=P(!1);function m(a=n=>n){let n=x.value!==null?v.value[x.value]:null,r=ne(a(v.value.slice()),f=>I(f.dataRef.domRef)),i=n?r.indexOf(n):null;return i===-1&&(i=null),{options:r,activeOptionIndex:i}}let w=C(()=>o.multiple?1:0),H=C(()=>o.nullable),[A,l]=de(C(()=>o.modelValue===void 0?M(w.value,{[1]:[],[0]:void 0}):o.modelValue),a=>T("update:modelValue",a),C(()=>o.defaultValue)),u={comboboxState:e,value:A,mode:w,compare(a,n){if(typeof o.by=="string"){let r=o.by;return(a==null?void 0:a[r])===(n==null?void 0:n[r])}return o.by(a,n)},defaultValue:C(()=>o.defaultValue),nullable:H,inputRef:d,labelRef:t,buttonRef:g,optionsRef:p,disabled:C(()=>o.disabled),options:v,change(a){l(a)},activeOptionIndex:C(()=>{if(h.value&&x.value===null&&v.value.length>0){let a=v.value.findIndex(n=>!n.dataRef.disabled);if(a!==-1)return a}return x.value}),activationTrigger:y,optionsPropsRef:b,closeCombobox(){h.value=!1,!o.disabled&&e.value!==1&&(e.value=1,x.value=null)},openCombobox(){if(h.value=!0,o.disabled||e.value===0)return;let a=v.value.findIndex(n=>{let r=c(n.dataRef.value);return M(w.value,{[0]:()=>u.compare(c(u.value.value),c(r)),[1]:()=>c(u.value.value).some(f=>u.compare(c(f),c(r)))})});a!==-1&&(x.value=a),e.value=0},goToOption(a,n,r){if(h.value=!1,o.disabled||p.value&&!b.value.static&&e.value===1)return;let i=m();if(i.activeOptionIndex===null){let S=i.options.findIndex(E=>!E.dataRef.disabled);S!==-1&&(i.activeOptionIndex=S)}let f=ee(a===R.Specific?{focus:R.Specific,id:n}:{focus:a},{resolveItems:()=>i.options,resolveActiveIndex:()=>i.activeOptionIndex,resolveId:S=>S.id,resolveDisabled:S=>S.dataRef.disabled});x.value=f,y.value=r!=null?r:1,v.value=i.options},selectOption(a){let n=v.value.find(i=>i.id===a);if(!n)return;let{dataRef:r}=n;l(M(w.value,{[0]:()=>r.value,[1]:()=>{let i=c(u.value.value).slice(),f=c(r.value),S=i.findIndex(E=>u.compare(f,c(E)));return S===-1?i.push(f):i.splice(S,1),i}}))},selectActiveOption(){if(u.activeOptionIndex.value===null)return;let{dataRef:a,id:n}=v.value[u.activeOptionIndex.value];l(M(w.value,{[0]:()=>a.value,[1]:()=>{let r=c(u.value.value).slice(),i=c(a.value),f=r.findIndex(S=>u.compare(i,c(S)));return f===-1?r.push(i):r.splice(f,1),r}})),u.goToOption(R.Specific,n)},registerOption(a,n){let r={id:a,dataRef:n},i=m(f=>[...f,r]);if(x.value===null){let f=n.value.value;M(w.value,{[0]:()=>u.compare(c(u.value.value),c(f)),[1]:()=>c(u.value.value).some(E=>u.compare(c(E),c(f)))})&&(i.activeOptionIndex=i.options.indexOf(r))}v.value=i.options,x.value=i.activeOptionIndex,y.value=1},unregisterOption(a){let n=m(r=>{let i=r.findIndex(f=>f.id===a);return i!==-1&&r.splice(i,1),r});v.value=n.options,x.value=n.activeOptionIndex,y.value=1}};ie([d,g,p],()=>u.closeCombobox(),C(()=>e.value===0)),Z(G,u),oe(C(()=>M(e.value,{[0]:W.Open,[1]:W.Closed})));let k=C(()=>u.activeOptionIndex.value===null?null:v.value[u.activeOptionIndex.value].dataRef.value),D=C(()=>{var a;return(a=I(d))==null?void 0:a.closest("form")});return $(()=>{_([D],()=>{if(!D.value||o.defaultValue===void 0)return;function a(){u.change(o.defaultValue)}return D.value.addEventListener("reset",a),()=>{var n;(n=D.value)==null||n.removeEventListener("reset",a)}},{immediate:!0})}),()=>{let{name:a,disabled:n,...r}=o,i={open:e.value===0,disabled:n,activeIndex:u.activeOptionIndex.value,activeOption:k.value,value:A.value};return q(Q,[...a!=null&&A.value!=null?se({[a]:A.value}).map(([f,S])=>q(ue,z({features:re.Hidden,key:f,as:"input",type:"hidden",hidden:!0,readOnly:!0,name:f,value:S}))):[],B({theirProps:{...s,...J(r,["modelValue","defaultValue","nullable","multiple","onUpdate:modelValue","by"])},ourProps:{},slot:i,slots:O,attrs:s,name:"Combobox"})])}}}),Fe=F({name:"ComboboxLabel",props:{as:{type:[Object,String],default:"label"},id:{type:String,default:()=>`headlessui-combobox-label-${N()}`}},setup(o,{attrs:O,slots:s}){let T=j("ComboboxLabel");function e(){var t;(t=I(T.inputRef))==null||t.focus({preventScroll:!0})}return()=>{let t={open:T.comboboxState.value===0,disabled:T.disabled.value},{id:d,...g}=o,p={id:d,ref:T.labelRef,onClick:e};return B({ourProps:p,theirProps:g,slot:t,attrs:O,slots:s,name:"ComboboxLabel"})}}}),Be=F({name:"ComboboxButton",props:{as:{type:[Object,String],default:"button"},id:{type:String,default:()=>`headlessui-combobox-button-${N()}`}},setup(o,{attrs:O,slots:s,expose:T}){let e=j("ComboboxButton");T({el:e.buttonRef,$el:e.buttonRef});function t(p){e.disabled.value||(e.comboboxState.value===0?e.closeCombobox():(p.preventDefault(),e.openCombobox()),L(()=>{var b;return(b=I(e.inputRef))==null?void 0:b.focus({preventScroll:!0})}))}function d(p){switch(p.key){case V.ArrowDown:p.preventDefault(),p.stopPropagation(),e.comboboxState.value===1&&e.openCombobox(),L(()=>{var b;return(b=e.inputRef.value)==null?void 0:b.focus({preventScroll:!0})});return;case V.ArrowUp:p.preventDefault(),p.stopPropagation(),e.comboboxState.value===1&&(e.openCombobox(),L(()=>{e.value.value||e.goToOption(R.Last)})),L(()=>{var b;return(b=e.inputRef.value)==null?void 0:b.focus({preventScroll:!0})});return;case V.Escape:if(e.comboboxState.value!==0)return;p.preventDefault(),e.optionsRef.value&&!e.optionsPropsRef.value.static&&p.stopPropagation(),e.closeCombobox(),L(()=>{var b;return(b=e.inputRef.value)==null?void 0:b.focus({preventScroll:!0})});return}}let g=ae(C(()=>({as:o.as,type:O.type})),e.buttonRef);return()=>{var y,h;let p={open:e.comboboxState.value===0,disabled:e.disabled.value,value:e.value.value},{id:b,...v}=o,x={ref:e.buttonRef,id:b,type:g.value,tabindex:"-1","aria-haspopup":!0,"aria-controls":(y=I(e.optionsRef))==null?void 0:y.id,"aria-expanded":e.disabled.value?void 0:e.comboboxState.value===0,"aria-labelledby":e.labelRef.value?[(h=I(e.labelRef))==null?void 0:h.id,b].join(" "):void 0,disabled:e.disabled.value===!0?!0:void 0,onKeydown:d,onClick:t};return B({ourProps:x,theirProps:v,slot:p,attrs:O,slots:s,name:"ComboboxButton"})}}}),je=F({name:"ComboboxInput",props:{as:{type:[Object,String],default:"input"},static:{type:Boolean,default:!1},unmount:{type:Boolean,default:!0},displayValue:{type:Function},defaultValue:{type:String,default:void 0},id:{type:String,default:()=>`headlessui-combobox-input-${N()}`}},emits:{change:o=>!0},setup(o,{emit:O,attrs:s,slots:T,expose:e}){let t=j("ComboboxInput"),d={value:!1};e({el:t.inputRef,$el:t.inputRef});let g=P(t.value.value),p=()=>{var u;let l=t.value.value;return I(t.inputRef)?typeof o.displayValue!="undefined"?(u=o.displayValue(l))!=null?u:"":typeof l=="string"?l:"":""},b=P("");$(()=>{_([t.value,b],()=>{g.value=p()},{flush:"sync",immediate:!0}),_([g,t.comboboxState],([l,u],[k,D])=>{if(d.value)return;let a=I(t.inputRef);!a||(D===0&&u===1||l!==k)&&(a.value=l)},{immediate:!0})});let v=P(!1);function x(){v.value=!0}function y(){setTimeout(()=>{v.value=!1})}function h(l){switch(d.value=!0,l.key){case V.Backspace:case V.Delete:if(t.mode.value!==0||!t.nullable.value)return;let u=l.currentTarget;requestAnimationFrame(()=>{if(u.value===""){t.change(null);let k=I(t.optionsRef);k&&(k.scrollTop=0),t.goToOption(R.Nothing)}});break;case V.Enter:if(d.value=!1,t.comboboxState.value!==0||v.value)return;if(l.preventDefault(),l.stopPropagation(),t.activeOptionIndex.value===null){t.closeCombobox();return}t.selectActiveOption(),t.mode.value===0&&t.closeCombobox();break;case V.ArrowDown:return d.value=!1,l.preventDefault(),l.stopPropagation(),M(t.comboboxState.value,{[0]:()=>t.goToOption(R.Next),[1]:()=>t.openCombobox()});case V.ArrowUp:return d.value=!1,l.preventDefault(),l.stopPropagation(),M(t.comboboxState.value,{[0]:()=>t.goToOption(R.Previous),[1]:()=>{t.openCombobox(),L(()=>{t.value.value||t.goToOption(R.Last)})}});case V.Home:if(l.shiftKey)break;return d.value=!1,l.preventDefault(),l.stopPropagation(),t.goToOption(R.First);case V.PageUp:return d.value=!1,l.preventDefault(),l.stopPropagation(),t.goToOption(R.First);case V.End:if(l.shiftKey)break;return d.value=!1,l.preventDefault(),l.stopPropagation(),t.goToOption(R.Last);case V.PageDown:return d.value=!1,l.preventDefault(),l.stopPropagation(),t.goToOption(R.Last);case V.Escape:if(d.value=!1,t.comboboxState.value!==0)return;l.preventDefault(),t.optionsRef.value&&!t.optionsPropsRef.value.static&&l.stopPropagation(),t.closeCombobox();break;case V.Tab:if(d.value=!1,t.comboboxState.value!==0)return;t.mode.value===0&&t.selectActiveOption(),t.closeCombobox();break}}function m(l){O("change",l)}function w(l){t.openCombobox(),O("change",l)}function H(){d.value=!1}let A=C(()=>{var l,u,k,D;return(D=(k=(u=o.defaultValue)!=null?u:(l=o.displayValue)==null?void 0:l.call(o,t.defaultValue.value))!=null?k:t.defaultValue.value)!=null?D:""});return()=>{var n,r,i,f,S,E;let l={open:t.comboboxState.value===0},{id:u,displayValue:k,...D}=o,a={"aria-controls":(n=t.optionsRef.value)==null?void 0:n.id,"aria-expanded":t.disabled.value?void 0:t.comboboxState.value===0,"aria-activedescendant":t.activeOptionIndex.value===null||(r=t.options.value[t.activeOptionIndex.value])==null?void 0:r.id,"aria-multiselectable":t.mode.value===1?!0:void 0,"aria-labelledby":(S=(i=I(t.labelRef))==null?void 0:i.id)!=null?S:(f=I(t.buttonRef))==null?void 0:f.id,id:u,onCompositionstart:x,onCompositionend:y,onKeydown:h,onChange:m,onInput:w,onBlur:H,role:"combobox",type:(E=s.type)!=null?E:"text",tabIndex:0,ref:t.inputRef,defaultValue:A.value};return B({ourProps:a,theirProps:D,slot:l,attrs:s,slots:T,features:K.RenderStrategy|K.Static,name:"ComboboxInput"})}}}),He=F({name:"ComboboxOptions",props:{as:{type:[Object,String],default:"ul"},static:{type:Boolean,default:!1},unmount:{type:Boolean,default:!0},hold:{type:[Boolean],default:!1}},setup(o,{attrs:O,slots:s,expose:T}){let e=j("ComboboxOptions"),t=`headlessui-combobox-options-${N()}`;T({el:e.optionsRef,$el:e.optionsRef}),U(()=>{e.optionsPropsRef.value.static=o.static}),U(()=>{e.optionsPropsRef.value.hold=o.hold});let d=te(),g=C(()=>d!==null?d.value===W.Open:e.comboboxState.value===0);return le({container:C(()=>I(e.optionsRef)),enabled:C(()=>e.comboboxState.value===0),accept(p){return p.getAttribute("role")==="option"?NodeFilter.FILTER_REJECT:p.hasAttribute("role")?NodeFilter.FILTER_SKIP:NodeFilter.FILTER_ACCEPT},walk(p){p.setAttribute("role","none")}}),()=>{var x,y,h,m;let p={open:e.comboboxState.value===0},b={"aria-activedescendant":e.activeOptionIndex.value===null||(x=e.options.value[e.activeOptionIndex.value])==null?void 0:x.id,"aria-labelledby":(m=(y=I(e.labelRef))==null?void 0:y.id)!=null?m:(h=I(e.buttonRef))==null?void 0:h.id,id:t,ref:e.optionsRef,role:"listbox"},v=J(o,["hold"]);return B({ourProps:b,theirProps:v,slot:p,attrs:O,slots:s,features:K.RenderStrategy|K.Static,visible:g.value,name:"ComboboxOptions"})}}}),Ne=F({name:"ComboboxOption",props:{as:{type:[Object,String],default:"li"},value:{type:[Object,String,Number,Boolean]},disabled:{type:Boolean,default:!1}},setup(o,{slots:O,attrs:s,expose:T}){let e=j("ComboboxOption"),t=`headlessui-combobox-option-${N()}`,d=P(null);T({el:d,$el:d});let g=C(()=>e.activeOptionIndex.value!==null?e.options.value[e.activeOptionIndex.value].id===t:!1),p=C(()=>M(e.mode.value,{[0]:()=>e.compare(c(e.value.value),c(o.value)),[1]:()=>c(e.value.value).some(m=>e.compare(c(m),c(o.value)))})),b=C(()=>({disabled:o.disabled,value:o.value,domRef:d}));$(()=>e.registerOption(t,b)),Y(()=>e.unregisterOption(t)),U(()=>{e.comboboxState.value===0&&(!g.value||e.activationTrigger.value!==0&&L(()=>{var m,w;return(w=(m=I(d))==null?void 0:m.scrollIntoView)==null?void 0:w.call(m,{block:"nearest"})}))});function v(m){if(o.disabled)return m.preventDefault();e.selectOption(t),e.mode.value===0&&e.closeCombobox()}function x(){if(o.disabled)return e.goToOption(R.Nothing);e.goToOption(R.Specific,t)}function y(){o.disabled||g.value||e.goToOption(R.Specific,t,0)}function h(){o.disabled||!g.value||e.optionsPropsRef.value.hold||e.goToOption(R.Nothing)}return()=>{let{disabled:m}=o,w={active:g.value,selected:p.value,disabled:m},H={id:t,ref:d,role:"option",tabIndex:m===!0?void 0:-1,"aria-disabled":m===!0?!0:void 0,"aria-selected":p.value,disabled:void 0,onClick:v,onFocus:x,onPointermove:y,onMousemove:y,onPointerleave:h,onMouseleave:h};return B({ourProps:H,theirProps:o,slot:w,attrs:s,slots:O,name:"ComboboxOption"})}}});export{Le as Combobox,Be as ComboboxButton,je as ComboboxInput,Fe as ComboboxLabel,Ne as ComboboxOption,He as ComboboxOptions}; | ||
import{useVirtualizer as re}from"@tanstack/vue-virtual";import{Fragment as de,cloneVNode as se,computed as b,defineComponent as j,h as z,inject as ee,nextTick as H,onMounted as X,onUnmounted as fe,provide as te,reactive as ve,ref as A,toRaw as L,watch as q,watchEffect as Y}from"vue";import{useControllable as pe}from'../../hooks/use-controllable.js';import{useFrameDebounce as be}from'../../hooks/use-frame-debounce.js';import{useId as J}from'../../hooks/use-id.js';import{useOutsideClick as ce}from'../../hooks/use-outside-click.js';import{useResolveButtonType as me}from'../../hooks/use-resolve-button-type.js';import{useTrackedPointer as xe}from'../../hooks/use-tracked-pointer.js';import{useTreeWalker as ge}from'../../hooks/use-tree-walker.js';import{Hidden as Se,Features as Oe}from'../../internal/hidden.js';import{State as G,useOpenClosed as Ce,useOpenClosedProvider as Re}from'../../internal/open-closed.js';import{Keys as k}from'../../keyboard.js';import{MouseButton as ye}from'../../mouse.js';import{history as oe}from'../../utils/active-element-history.js';import{Focus as w,calculateActiveIndex as le}from'../../utils/calculate-active-index.js';import{disposables as ae}from'../../utils/disposables.js';import{dom as x}from'../../utils/dom.js';import{sortByDomNode as Te}from'../../utils/focus-management.js';import{objectToFormEntries as Ie}from'../../utils/form.js';import{match as $}from'../../utils/match.js';import{getOwnerDocument as he}from'../../utils/owner.js';import{isMobile as Pe}from'../../utils/platform.js';import{Features as Q,compact as we,omit as Z,render as _}from'../../utils/render.js';function De(a,I){return a===I}var Ee=(u=>(u[u.Open=0]="Open",u[u.Closed=1]="Closed",u))(Ee||{}),Ve=(u=>(u[u.Single=0]="Single",u[u.Multi=1]="Multi",u))(Ve||{}),Ae=(O=>(O[O.Pointer=0]="Pointer",O[O.Focus=1]="Focus",O[O.Other=2]="Other",O))(Ae||{});let ne=Symbol("ComboboxContext");function N(a){let I=ee(ne,null);if(I===null){let u=new Error(`<${a} /> is missing a parent <Combobox /> component.`);throw Error.captureStackTrace&&Error.captureStackTrace(u,N),u}return I}let ie=Symbol("VirtualContext"),Fe=j({name:"VirtualProvider",setup(a,{slots:I}){let u=N("VirtualProvider"),O=b(()=>{let r=x(u.optionsRef);if(!r)return{start:0,end:0};let f=window.getComputedStyle(r);return{start:parseFloat(f.paddingBlockStart||f.paddingTop),end:parseFloat(f.paddingBlockEnd||f.paddingBottom)}}),t=re(b(()=>({scrollPaddingStart:O.value.start,scrollPaddingEnd:O.value.end,count:u.virtual.value.options.length,estimateSize(){return 40},getScrollElement(){return x(u.optionsRef)},overscan:12}))),e=b(()=>{var r;return(r=u.virtual.value)==null?void 0:r.options}),C=A(0);return q([e],()=>{C.value+=1}),te(ie,u.virtual.value?t:null),()=>[z("div",{style:{position:"relative",width:"100%",height:`${t.value.getTotalSize()}px`},ref:r=>{if(r){if(typeof process!="undefined"&&process.env.JEST_WORKER_ID!==void 0||u.activationTrigger.value===0)return;u.activeOptionIndex.value!==null&&u.virtual.value.options.length>u.activeOptionIndex.value&&t.value.scrollToIndex(u.activeOptionIndex.value)}}},t.value.getVirtualItems().map(r=>se(I.default({option:u.virtual.value.options[r.index],open:u.comboboxState.value===0})[0],{key:`${C.value}-${r.index}`,"data-index":r.index,"aria-setsize":u.virtual.value.options.length,"aria-posinset":r.index+1,style:{position:"absolute",top:0,left:0,transform:`translateY(${r.start}px)`,overflowAnchor:"none"}})))]}}),lt=j({name:"Combobox",emits:{"update:modelValue":a=>!0},props:{as:{type:[Object,String],default:"template"},disabled:{type:[Boolean],default:!1},by:{type:[String,Function],nullable:!0,default:null},modelValue:{type:[Object,String,Number,Boolean],default:void 0},defaultValue:{type:[Object,String,Number,Boolean],default:void 0},form:{type:String,optional:!0},name:{type:String,optional:!0},nullable:{type:Boolean,default:!1},multiple:{type:[Boolean],default:!1},immediate:{type:[Boolean],default:!1},virtual:{type:Object,default:null}},inheritAttrs:!1,setup(a,{slots:I,attrs:u,emit:O}){let t=A(1),e=A(null),C=A(null),r=A(null),f=A(null),p=A({static:!1,hold:!1}),c=A([]),g=A(null),P=A(2),D=A(!1);function V(l=i=>i){let i=g.value!==null?c.value[g.value]:null,s=l(c.value.slice()),v=s.length>0&&s[0].dataRef.order.value!==null?s.sort((y,F)=>y.dataRef.order.value-F.dataRef.order.value):Te(s,y=>x(y.dataRef.domRef)),R=i?v.indexOf(i):null;return R===-1&&(R=null),{options:v,activeOptionIndex:R}}let M=b(()=>a.multiple?1:0),K=b(()=>a.nullable),[B,d]=pe(b(()=>a.modelValue),l=>O("update:modelValue",l),b(()=>a.defaultValue)),o=b(()=>B.value===void 0?$(M.value,{[1]:[],[0]:void 0}):B.value),m=null,S=null;function h(l){return $(M.value,{[0](){return d==null?void 0:d(l)},[1]:()=>{let i=L(n.value.value).slice(),s=L(l),v=i.findIndex(R=>n.compare(s,L(R)));return v===-1?i.push(s):i.splice(v,1),d==null?void 0:d(i)}})}let T=b(()=>{var l;return(l=a.virtual)==null?void 0:l.options});q([T],([l],[i])=>{if(n.virtual.value&&l&&i&&g.value!==null){let s=l.indexOf(i[g.value]);s!==-1?g.value=s:g.value=null}});let n={comboboxState:t,value:o,mode:M,compare(l,i){if(typeof a.by=="string"){let s=a.by;return(l==null?void 0:l[s])===(i==null?void 0:i[s])}return a.by===null?De(l,i):a.by(l,i)},calculateIndex(l){return n.virtual.value?a.by===null?n.virtual.value.options.indexOf(l):n.virtual.value.options.findIndex(i=>n.compare(i,l)):c.value.findIndex(i=>n.compare(i.dataRef.value,l))},defaultValue:b(()=>a.defaultValue),nullable:K,immediate:b(()=>a.immediate),virtual:b(()=>{var l;return a.virtual?{options:a.virtual.options,disabled:(l=a.virtual.disabled)!=null?l:()=>!1}:null}),inputRef:C,labelRef:e,buttonRef:r,optionsRef:f,disabled:b(()=>a.disabled),options:c,change(l){d(l)},activeOptionIndex:b(()=>{if(D.value&&g.value===null&&(n.virtual.value?n.virtual.value.options.length>0:c.value.length>0)){if(n.virtual.value){let i=n.virtual.value.options.findIndex(s=>{var v;return!((v=n.virtual.value)!=null&&v.disabled(s))});if(i!==-1)return i}let l=c.value.findIndex(i=>!i.dataRef.disabled);if(l!==-1)return l}return g.value}),activationTrigger:P,optionsPropsRef:p,closeCombobox(){D.value=!1,!a.disabled&&t.value!==1&&(t.value=1,g.value=null)},openCombobox(){if(D.value=!0,!a.disabled&&t.value!==0){if(n.value.value){let l=n.calculateIndex(n.value.value);l!==-1&&(g.value=l)}t.value=0}},setActivationTrigger(l){P.value=l},goToOption(l,i,s){D.value=!1,m!==null&&cancelAnimationFrame(m),m=requestAnimationFrame(()=>{if(a.disabled||f.value&&!p.value.static&&t.value===1)return;if(n.virtual.value){g.value=l===w.Specific?i:le({focus:l},{resolveItems:()=>n.virtual.value.options,resolveActiveIndex:()=>{var y,F;return(F=(y=n.activeOptionIndex.value)!=null?y:n.virtual.value.options.findIndex(W=>{var U;return!((U=n.virtual.value)!=null&&U.disabled(W))}))!=null?F:null},resolveDisabled:y=>n.virtual.value.disabled(y),resolveId(){throw new Error("Function not implemented.")}}),P.value=s!=null?s:2;return}let v=V();if(v.activeOptionIndex===null){let y=v.options.findIndex(F=>!F.dataRef.disabled);y!==-1&&(v.activeOptionIndex=y)}let R=l===w.Specific?i:le({focus:l},{resolveItems:()=>v.options,resolveActiveIndex:()=>v.activeOptionIndex,resolveId:y=>y.id,resolveDisabled:y=>y.dataRef.disabled});g.value=R,P.value=s!=null?s:2,c.value=v.options})},selectOption(l){let i=c.value.find(v=>v.id===l);if(!i)return;let{dataRef:s}=i;h(s.value)},selectActiveOption(){if(n.activeOptionIndex.value!==null){if(n.virtual.value)h(n.virtual.value.options[n.activeOptionIndex.value]);else{let{dataRef:l}=c.value[n.activeOptionIndex.value];h(l.value)}n.goToOption(w.Specific,n.activeOptionIndex.value)}},registerOption(l,i){let s=ve({id:l,dataRef:i});if(n.virtual.value){c.value.push(s);return}S&&cancelAnimationFrame(S);let v=V(R=>(R.push(s),R));g.value===null&&n.isSelected(i.value.value)&&(v.activeOptionIndex=v.options.indexOf(s)),c.value=v.options,g.value=v.activeOptionIndex,P.value=2,v.options.some(R=>!x(R.dataRef.domRef))&&(S=requestAnimationFrame(()=>{let R=V();c.value=R.options,g.value=R.activeOptionIndex}))},unregisterOption(l,i){if(m!==null&&cancelAnimationFrame(m),i&&(D.value=!0),n.virtual.value){c.value=c.value.filter(v=>v.id!==l);return}let s=V(v=>{let R=v.findIndex(y=>y.id===l);return R!==-1&&v.splice(R,1),v});c.value=s.options,g.value=s.activeOptionIndex,P.value=2},isSelected(l){return $(M.value,{[0]:()=>n.compare(L(n.value.value),L(l)),[1]:()=>L(n.value.value).some(i=>n.compare(L(i),L(l)))})},isActive(l){return g.value===n.calculateIndex(l)}};ce([C,r,f],()=>n.closeCombobox(),b(()=>t.value===0)),te(ne,n),Re(b(()=>$(t.value,{[0]:G.Open,[1]:G.Closed})));let E=b(()=>{var l;return(l=x(C))==null?void 0:l.closest("form")});return X(()=>{q([E],()=>{if(!E.value||a.defaultValue===void 0)return;function l(){n.change(a.defaultValue)}return E.value.addEventListener("reset",l),()=>{var i;(i=E.value)==null||i.removeEventListener("reset",l)}},{immediate:!0})}),()=>{var y,F,W;let{name:l,disabled:i,form:s,...v}=a,R={open:t.value===0,disabled:i,activeIndex:n.activeOptionIndex.value,activeOption:n.activeOptionIndex.value===null?null:n.virtual.value?n.virtual.value.options[(y=n.activeOptionIndex.value)!=null?y:0]:(W=(F=n.options.value[n.activeOptionIndex.value])==null?void 0:F.dataRef.value)!=null?W:null,value:o.value};return z(de,[...l!=null&&o.value!=null?Ie({[l]:o.value}).map(([U,ue])=>z(Se,we({features:Oe.Hidden,key:U,as:"input",type:"hidden",hidden:!0,readOnly:!0,form:s,disabled:i,name:U,value:ue}))):[],_({theirProps:{...u,...Z(v,["by","defaultValue","immediate","modelValue","multiple","nullable","onUpdate:modelValue","virtual"])},ourProps:{},slot:R,slots:I,attrs:u,name:"Combobox"})])}}}),at=j({name:"ComboboxLabel",props:{as:{type:[Object,String],default:"label"},id:{type:String,default:()=>`headlessui-combobox-label-${J()}`}},setup(a,{attrs:I,slots:u}){let O=N("ComboboxLabel");function t(){var e;(e=x(O.inputRef))==null||e.focus({preventScroll:!0})}return()=>{let e={open:O.comboboxState.value===0,disabled:O.disabled.value},{id:C,...r}=a,f={id:C,ref:O.labelRef,onClick:t};return _({ourProps:f,theirProps:r,slot:e,attrs:I,slots:u,name:"ComboboxLabel"})}}}),nt=j({name:"ComboboxButton",props:{as:{type:[Object,String],default:"button"},id:{type:String,default:()=>`headlessui-combobox-button-${J()}`}},setup(a,{attrs:I,slots:u,expose:O}){let t=N("ComboboxButton");O({el:t.buttonRef,$el:t.buttonRef});function e(f){t.disabled.value||(t.comboboxState.value===0?t.closeCombobox():(f.preventDefault(),t.openCombobox()),H(()=>{var p;return(p=x(t.inputRef))==null?void 0:p.focus({preventScroll:!0})}))}function C(f){switch(f.key){case k.ArrowDown:f.preventDefault(),f.stopPropagation(),t.comboboxState.value===1&&t.openCombobox(),H(()=>{var p;return(p=t.inputRef.value)==null?void 0:p.focus({preventScroll:!0})});return;case k.ArrowUp:f.preventDefault(),f.stopPropagation(),t.comboboxState.value===1&&(t.openCombobox(),H(()=>{t.value.value||t.goToOption(w.Last)})),H(()=>{var p;return(p=t.inputRef.value)==null?void 0:p.focus({preventScroll:!0})});return;case k.Escape:if(t.comboboxState.value!==0)return;f.preventDefault(),t.optionsRef.value&&!t.optionsPropsRef.value.static&&f.stopPropagation(),t.closeCombobox(),H(()=>{var p;return(p=t.inputRef.value)==null?void 0:p.focus({preventScroll:!0})});return}}let r=me(b(()=>({as:a.as,type:I.type})),t.buttonRef);return()=>{var P,D;let f={open:t.comboboxState.value===0,disabled:t.disabled.value,value:t.value.value},{id:p,...c}=a,g={ref:t.buttonRef,id:p,type:r.value,tabindex:"-1","aria-haspopup":"listbox","aria-controls":(P=x(t.optionsRef))==null?void 0:P.id,"aria-expanded":t.comboboxState.value===0,"aria-labelledby":t.labelRef.value?[(D=x(t.labelRef))==null?void 0:D.id,p].join(" "):void 0,disabled:t.disabled.value===!0?!0:void 0,onKeydown:C,onClick:e};return _({ourProps:g,theirProps:c,slot:f,attrs:I,slots:u,name:"ComboboxButton"})}}}),it=j({name:"ComboboxInput",props:{as:{type:[Object,String],default:"input"},static:{type:Boolean,default:!1},unmount:{type:Boolean,default:!0},displayValue:{type:Function},defaultValue:{type:String,default:void 0},id:{type:String,default:()=>`headlessui-combobox-input-${J()}`}},emits:{change:a=>!0},setup(a,{emit:I,attrs:u,slots:O,expose:t}){let e=N("ComboboxInput"),C=b(()=>he(x(e.inputRef))),r={value:!1};t({el:e.inputRef,$el:e.inputRef});function f(){e.change(null);let o=x(e.optionsRef);o&&(o.scrollTop=0),e.goToOption(w.Nothing)}let p=b(()=>{var m;let o=e.value.value;return x(e.inputRef)?typeof a.displayValue!="undefined"&&o!==void 0?(m=a.displayValue(o))!=null?m:"":typeof o=="string"?o:"":""});X(()=>{q([p,e.comboboxState,C],([o,m],[S,h])=>{if(r.value)return;let T=x(e.inputRef);T&&((h===0&&m===1||o!==S)&&(T.value=o),requestAnimationFrame(()=>{var l;if(r.value||!T||((l=C.value)==null?void 0:l.activeElement)!==T)return;let{selectionStart:n,selectionEnd:E}=T;Math.abs((E!=null?E:0)-(n!=null?n:0))===0&&n===0&&T.setSelectionRange(T.value.length,T.value.length)}))},{immediate:!0}),q([e.comboboxState],([o],[m])=>{if(o===0&&m===1){if(r.value)return;let S=x(e.inputRef);if(!S)return;let h=S.value,{selectionStart:T,selectionEnd:n,selectionDirection:E}=S;S.value="",S.value=h,E!==null?S.setSelectionRange(T,n,E):S.setSelectionRange(T,n)}})});let c=A(!1);function g(){c.value=!0}function P(){ae().nextFrame(()=>{c.value=!1})}let D=be();function V(o){switch(r.value=!0,D(()=>{c.value||(r.value=!1)}),o.key){case k.Enter:if(r.value=!1,e.comboboxState.value!==0||c.value)return;if(o.preventDefault(),o.stopPropagation(),e.activeOptionIndex.value===null){e.closeCombobox();return}e.selectActiveOption(),e.mode.value===0&&e.closeCombobox();break;case k.ArrowDown:return r.value=!1,o.preventDefault(),o.stopPropagation(),$(e.comboboxState.value,{[0]:()=>e.goToOption(w.Next),[1]:()=>e.openCombobox()});case k.ArrowUp:return r.value=!1,o.preventDefault(),o.stopPropagation(),$(e.comboboxState.value,{[0]:()=>e.goToOption(w.Previous),[1]:()=>{e.openCombobox(),H(()=>{e.value.value||e.goToOption(w.Last)})}});case k.Home:if(o.shiftKey)break;return r.value=!1,o.preventDefault(),o.stopPropagation(),e.goToOption(w.First);case k.PageUp:return r.value=!1,o.preventDefault(),o.stopPropagation(),e.goToOption(w.First);case k.End:if(o.shiftKey)break;return r.value=!1,o.preventDefault(),o.stopPropagation(),e.goToOption(w.Last);case k.PageDown:return r.value=!1,o.preventDefault(),o.stopPropagation(),e.goToOption(w.Last);case k.Escape:if(r.value=!1,e.comboboxState.value!==0)return;o.preventDefault(),e.optionsRef.value&&!e.optionsPropsRef.value.static&&o.stopPropagation(),e.nullable.value&&e.mode.value===0&&e.value.value===null&&f(),e.closeCombobox();break;case k.Tab:if(r.value=!1,e.comboboxState.value!==0)return;e.mode.value===0&&e.activationTrigger.value!==1&&e.selectActiveOption(),e.closeCombobox();break}}function M(o){I("change",o),e.nullable.value&&e.mode.value===0&&o.target.value===""&&f(),e.openCombobox()}function K(o){var S,h,T;let m=(S=o.relatedTarget)!=null?S:oe.find(n=>n!==o.currentTarget);if(r.value=!1,!((h=x(e.optionsRef))!=null&&h.contains(m))&&!((T=x(e.buttonRef))!=null&&T.contains(m))&&e.comboboxState.value===0)return o.preventDefault(),e.mode.value===0&&(e.nullable.value&&e.value.value===null?f():e.activationTrigger.value!==1&&e.selectActiveOption()),e.closeCombobox()}function B(o){var S,h,T;let m=(S=o.relatedTarget)!=null?S:oe.find(n=>n!==o.currentTarget);(h=x(e.buttonRef))!=null&&h.contains(m)||(T=x(e.optionsRef))!=null&&T.contains(m)||e.disabled.value||e.immediate.value&&e.comboboxState.value!==0&&(e.openCombobox(),ae().nextFrame(()=>{e.setActivationTrigger(1)}))}let d=b(()=>{var o,m,S,h;return(h=(S=(m=a.defaultValue)!=null?m:e.defaultValue.value!==void 0?(o=a.displayValue)==null?void 0:o.call(a,e.defaultValue.value):null)!=null?S:e.defaultValue.value)!=null?h:""});return()=>{var E,l,i,s,v,R,y;let o={open:e.comboboxState.value===0},{id:m,displayValue:S,onChange:h,...T}=a,n={"aria-controls":(E=e.optionsRef.value)==null?void 0:E.id,"aria-expanded":e.comboboxState.value===0,"aria-activedescendant":e.activeOptionIndex.value===null?void 0:e.virtual.value?(l=e.options.value.find(F=>!e.virtual.value.disabled(F.dataRef.value)&&e.compare(F.dataRef.value,e.virtual.value.options[e.activeOptionIndex.value])))==null?void 0:l.id:(i=e.options.value[e.activeOptionIndex.value])==null?void 0:i.id,"aria-labelledby":(R=(s=x(e.labelRef))==null?void 0:s.id)!=null?R:(v=x(e.buttonRef))==null?void 0:v.id,"aria-autocomplete":"list",id:m,onCompositionstart:g,onCompositionend:P,onKeydown:V,onInput:M,onFocus:B,onBlur:K,role:"combobox",type:(y=u.type)!=null?y:"text",tabIndex:0,ref:e.inputRef,defaultValue:d.value,disabled:e.disabled.value===!0?!0:void 0};return _({ourProps:n,theirProps:T,slot:o,attrs:u,slots:O,features:Q.RenderStrategy|Q.Static,name:"ComboboxInput"})}}}),ut=j({name:"ComboboxOptions",props:{as:{type:[Object,String],default:"ul"},static:{type:Boolean,default:!1},unmount:{type:Boolean,default:!0},hold:{type:[Boolean],default:!1}},setup(a,{attrs:I,slots:u,expose:O}){let t=N("ComboboxOptions"),e=`headlessui-combobox-options-${J()}`;O({el:t.optionsRef,$el:t.optionsRef}),Y(()=>{t.optionsPropsRef.value.static=a.static}),Y(()=>{t.optionsPropsRef.value.hold=a.hold});let C=Ce(),r=b(()=>C!==null?(C.value&G.Open)===G.Open:t.comboboxState.value===0);ge({container:b(()=>x(t.optionsRef)),enabled:b(()=>t.comboboxState.value===0),accept(p){return p.getAttribute("role")==="option"?NodeFilter.FILTER_REJECT:p.hasAttribute("role")?NodeFilter.FILTER_SKIP:NodeFilter.FILTER_ACCEPT},walk(p){p.setAttribute("role","none")}});function f(p){p.preventDefault()}return()=>{var P,D,V;let p={open:t.comboboxState.value===0},c={"aria-labelledby":(V=(P=x(t.labelRef))==null?void 0:P.id)!=null?V:(D=x(t.buttonRef))==null?void 0:D.id,id:e,ref:t.optionsRef,role:"listbox","aria-multiselectable":t.mode.value===1?!0:void 0,onMousedown:f},g=Z(a,["hold"]);return _({ourProps:c,theirProps:g,slot:p,attrs:I,slots:t.virtual.value&&t.comboboxState.value===0?{...u,default:()=>[z(Fe,{},u.default)]}:u,features:Q.RenderStrategy|Q.Static,visible:r.value,name:"ComboboxOptions"})}}}),rt=j({name:"ComboboxOption",props:{as:{type:[Object,String],default:"li"},value:{type:[Object,String,Number,Boolean]},disabled:{type:Boolean,default:!1},order:{type:[Number],default:null}},setup(a,{slots:I,attrs:u,expose:O}){let t=N("ComboboxOption"),e=`headlessui-combobox-option-${J()}`,C=A(null),r=b(()=>{var d;return a.disabled||((d=t.virtual.value)==null?void 0:d.disabled(a.value))});O({el:C,$el:C});let f=b(()=>{var d;return t.virtual.value?t.activeOptionIndex.value===t.calculateIndex(a.value):t.activeOptionIndex.value===null?!1:((d=t.options.value[t.activeOptionIndex.value])==null?void 0:d.id)===e}),p=b(()=>t.isSelected(a.value)),c=ee(ie,null),g=b(()=>({disabled:a.disabled,value:a.value,domRef:C,order:b(()=>a.order)}));X(()=>t.registerOption(e,g)),fe(()=>t.unregisterOption(e,f.value)),Y(()=>{let d=x(C);d&&(c==null||c.value.measureElement(d))}),Y(()=>{t.comboboxState.value===0&&f.value&&(t.virtual.value||t.activationTrigger.value!==0&&H(()=>{var d,o;return(o=(d=x(C))==null?void 0:d.scrollIntoView)==null?void 0:o.call(d,{block:"nearest"})}))});function P(d){d.preventDefault(),d.button===ye.Left&&(r.value||(t.selectOption(e),Pe()||requestAnimationFrame(()=>{var o;return(o=x(t.inputRef))==null?void 0:o.focus({preventScroll:!0})}),t.mode.value===0&&t.closeCombobox()))}function D(){var o;if(a.disabled||(o=t.virtual.value)!=null&&o.disabled(a.value))return t.goToOption(w.Nothing);let d=t.calculateIndex(a.value);t.goToOption(w.Specific,d)}let V=xe();function M(d){V.update(d)}function K(d){var m;if(!V.wasMoved(d)||a.disabled||(m=t.virtual.value)!=null&&m.disabled(a.value)||f.value)return;let o=t.calculateIndex(a.value);t.goToOption(w.Specific,o,0)}function B(d){var o;V.wasMoved(d)&&(a.disabled||(o=t.virtual.value)!=null&&o.disabled(a.value)||f.value&&(t.optionsPropsRef.value.hold||t.goToOption(w.Nothing)))}return()=>{let{disabled:d}=a,o={active:f.value,selected:p.value,disabled:d},m={id:e,ref:C,role:"option",tabIndex:d===!0?void 0:-1,"aria-disabled":d===!0?!0:void 0,"aria-selected":p.value,disabled:void 0,onMousedown:P,onFocus:D,onPointerenter:M,onMouseenter:M,onPointermove:K,onMousemove:K,onPointerleave:B,onMouseleave:B},S=Z(a,["order","value"]);return _({ourProps:m,theirProps:S,slot:o,attrs:u,slots:I,name:"ComboboxOption"})}}});export{lt as Combobox,nt as ComboboxButton,it as ComboboxInput,at as ComboboxLabel,rt as ComboboxOption,ut as ComboboxOptions}; |
@@ -1,2 +0,2 @@ | ||
import { ComputedRef, Ref } from 'vue'; | ||
import { type ComputedRef, type Ref } from 'vue'; | ||
export declare function useDescriptions({ slot, name, props, }?: { | ||
@@ -30,4 +30,4 @@ slot?: Ref<Record<string, unknown>>; | ||
}>>, { | ||
id: string; | ||
as: string | Record<string, any>; | ||
id: string; | ||
}>; |
@@ -1,1 +0,1 @@ | ||
import{computed as m,defineComponent as x,inject as R,onMounted as v,onUnmounted as D,provide as j,ref as u,unref as y}from"vue";import{useId as C}from'../../hooks/use-id.js';import{render as h}from'../../utils/render.js';let p=Symbol("DescriptionContext");function b(){let t=R(p,null);if(t===null)throw new Error("Missing parent");return t}function M({slot:t=u({}),name:i="Description",props:o={}}={}){let e=u([]);function s(n){return e.value.push(n),()=>{let r=e.value.indexOf(n);r!==-1&&e.value.splice(r,1)}}return j(p,{register:s,slot:t,name:i,props:o}),m(()=>e.value.length>0?e.value.join(" "):void 0)}let E=x({name:"Description",props:{as:{type:[Object,String],default:"p"},id:{type:String,default:()=>`headlessui-description-${C()}`}},setup(t,{attrs:i,slots:o}){let e=b();return v(()=>D(e.register(t.id))),()=>{let{name:s="Description",slot:n=u({}),props:r={}}=e,{id:d,...l}=t,c={...Object.entries(r).reduce((f,[a,g])=>Object.assign(f,{[a]:y(g)}),{}),id:d};return h({ourProps:c,theirProps:l,slot:n.value,attrs:i,slots:o,name:s})}}});export{E as Description,M as useDescriptions}; | ||
import{computed as m,defineComponent as x,inject as y,onMounted as R,onUnmounted as v,provide as D,ref as p,unref as j}from"vue";import{useId as C}from'../../hooks/use-id.js';import{render as h}from'../../utils/render.js';let u=Symbol("DescriptionContext");function b(){let t=y(u,null);if(t===null)throw new Error("Missing parent");return t}function S({slot:t=p({}),name:i="Description",props:o={}}={}){let e=p([]);function s(n){return e.value.push(n),()=>{let r=e.value.indexOf(n);r!==-1&&e.value.splice(r,1)}}return D(u,{register:s,slot:t,name:i,props:o}),m(()=>e.value.length>0?e.value.join(" "):void 0)}let k=x({name:"Description",props:{as:{type:[Object,String],default:"p"},id:{type:String,default:()=>`headlessui-description-${C()}`}},setup(t,{attrs:i,slots:o}){let e=b();return R(()=>v(e.register(t.id))),()=>{let{name:s="Description",slot:n=p({}),props:r={}}=e,{id:d,...l}=t,c={...Object.entries(r).reduce((f,[a,g])=>Object.assign(f,{[a]:j(g)}),{}),id:d};return h({ourProps:c,theirProps:l,slot:n.value,attrs:i,slots:o,name:s})}}});export{k as Description,S as useDescriptions}; |
@@ -1,2 +0,2 @@ | ||
import { PropType } from 'vue'; | ||
import { type PropType } from 'vue'; | ||
export declare let Dialog: import("vue").DefineComponent<{ | ||
@@ -27,2 +27,6 @@ as: { | ||
}; | ||
role: { | ||
type: PropType<"dialog" | "alertdialog">; | ||
default: string; | ||
}; | ||
}, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, { | ||
@@ -57,9 +61,14 @@ [key: string]: any; | ||
}; | ||
role: { | ||
type: PropType<"dialog" | "alertdialog">; | ||
default: string; | ||
}; | ||
}>> & { | ||
onClose?: ((_close: boolean) => any) | undefined; | ||
}, { | ||
id: string; | ||
role: "dialog" | "alertdialog"; | ||
as: string | Record<string, any>; | ||
unmount: boolean; | ||
static: boolean; | ||
id: string; | ||
open: string | boolean; | ||
@@ -91,4 +100,4 @@ initialFocus: HTMLElement | null; | ||
}>>, { | ||
id: string; | ||
as: string | Record<string, any>; | ||
id: string; | ||
}>; | ||
@@ -116,4 +125,4 @@ export declare let DialogBackdrop: import("vue").DefineComponent<{ | ||
}>>, { | ||
id: string; | ||
as: string | Record<string, any>; | ||
id: string; | ||
}>; | ||
@@ -143,4 +152,4 @@ export declare let DialogPanel: import("vue").DefineComponent<{ | ||
}>>, { | ||
id: string; | ||
as: string | Record<string, any>; | ||
id: string; | ||
}>; | ||
@@ -170,4 +179,4 @@ export declare let DialogTitle: import("vue").DefineComponent<{ | ||
}>>, { | ||
id: string; | ||
as: string | Record<string, any>; | ||
id: string; | ||
}>; | ||
@@ -197,4 +206,4 @@ export declare let DialogDescription: import("vue").DefineComponent<{ | ||
}>>, { | ||
id: string; | ||
as: string | Record<string, any>; | ||
id: string; | ||
}>; |
@@ -1,1 +0,1 @@ | ||
import{computed as g,defineComponent as b,h,inject as N,nextTick as ee,onMounted as M,onUnmounted as te,provide as le,ref as S,watchEffect as V}from"vue";import{render as P,Features as Y}from'../../utils/render.js';import{Keys as oe}from'../../keyboard.js';import{useId as w}from'../../hooks/use-id.js';import{FocusTrap as R}from'../../components/focus-trap/focus-trap.js';import{useInertOthers as ae}from'../../hooks/use-inert-others.js';import{Portal as _,PortalGroup as ie}from'../portal/portal.js';import{StackMessage as U,useStackProvider as re}from'../../internal/stack-context.js';import{match as F}from'../../utils/match.js';import{ForcePortalRoot as $}from'../../internal/portal-force-root.js';import{Description as ne,useDescriptions as ue}from'../description/description.js';import{dom as q}from'../../utils/dom.js';import{useOpenClosed as se,State as G}from'../../internal/open-closed.js';import{useOutsideClick as pe}from'../../hooks/use-outside-click.js';import{getOwnerDocument as de}from'../../utils/owner.js';import{useEventListener as fe}from'../../hooks/use-event-listener.js';import{Hidden as ge,Features as ce}from'../../internal/hidden.js';import{disposables as me}from'../../utils/disposables.js';import{isIOS as ve}from'../../utils/platform.js';var De=(t=>(t[t.Open=0]="Open",t[t.Closed=1]="Closed",t))(De||{});let j=Symbol("DialogContext");function T(o){let n=N(j,null);if(n===null){let t=new Error(`<${o} /> is missing a parent <Dialog /> component.`);throw Error.captureStackTrace&&Error.captureStackTrace(t,T),t}return n}let k="DC8F892D-2EBD-447C-A4C8-A03058436FF4",Ke=b({name:"Dialog",inheritAttrs:!1,props:{as:{type:[Object,String],default:"div"},static:{type:Boolean,default:!1},unmount:{type:Boolean,default:!0},open:{type:[Boolean,String],default:k},initialFocus:{type:Object,default:null},id:{type:String,default:()=>`headlessui-dialog-${w()}`}},emits:{close:o=>!0},setup(o,{emit:n,attrs:t,slots:s,expose:u}){var A;let a=S(!1);M(()=>{a.value=!0});let p=S(0),m=se(),v=g(()=>o.open===k&&m!==null?F(m.value,{[G.Open]:!0,[G.Closed]:!1}):o.open),x=S(new Set),c=S(null),B=S(null),I=g(()=>de(c));if(u({el:c,$el:c}),!(o.open!==k||m!==null))throw new Error("You forgot to provide an `open` prop to the `Dialog`.");if(typeof v.value!="boolean")throw new Error(`You provided an \`open\` prop to the \`Dialog\`, but the value is not a boolean. Received: ${v.value===k?void 0:o.open}`);let f=g(()=>a.value&&v.value?0:1),H=g(()=>f.value===0),C=g(()=>p.value>1),z=N(j,null)!==null,J=g(()=>C.value?"parent":"leaf");ae(c,g(()=>C.value?H.value:!1)),re({type:"Dialog",enabled:g(()=>f.value===0),element:c,onUpdate:(i,l,r)=>{if(l==="Dialog")return F(i,{[U.Add](){x.value.add(r),p.value+=1},[U.Remove](){x.value.delete(r),p.value-=1}})}});let Q=ue({name:"DialogDescription",slot:g(()=>({open:v.value}))}),E=S(null),y={titleId:E,panelRef:S(null),dialogState:f,setTitleId(i){E.value!==i&&(E.value=i)},close(){n("close",!1)}};return le(j,y),pe(()=>{var l,r,d;return[...Array.from((r=(l=I.value)==null?void 0:l.querySelectorAll("body > *, [data-headlessui-portal]"))!=null?r:[]).filter(e=>!(!(e instanceof HTMLElement)||e.contains(q(B))||y.panelRef.value&&e.contains(y.panelRef.value))),(d=y.panelRef.value)!=null?d:c.value]},(i,l)=>{y.close(),ee(()=>l==null?void 0:l.focus())},g(()=>f.value===0&&!C.value)),fe((A=I.value)==null?void 0:A.defaultView,"keydown",i=>{i.defaultPrevented||i.key===oe.Escape&&f.value===0&&(C.value||(i.preventDefault(),i.stopPropagation(),y.close()))}),V(i=>{var K;if(f.value!==0||z)return;let l=I.value;if(!l)return;let r=me();function d(D,O,X){let Z=D.style.getPropertyValue(O);return Object.assign(D.style,{[O]:X}),r.add(()=>{Object.assign(D.style,{[O]:Z})})}let e=l==null?void 0:l.documentElement,W=((K=l.defaultView)!=null?K:window).innerWidth-e.clientWidth;if(d(e,"overflow","hidden"),W>0){let D=e.clientWidth-e.offsetWidth,O=W-D;d(e,"paddingRight",`${O}px`)}if(ve()){let D=window.pageYOffset;d(e,"position","fixed"),d(e,"marginTop",`-${D}px`),d(e,"width","100%"),r.add(()=>window.scrollTo(0,D))}i(r.dispose)}),V(i=>{if(f.value!==0)return;let l=q(c);if(!l)return;let r=new IntersectionObserver(d=>{for(let e of d)e.boundingClientRect.x===0&&e.boundingClientRect.y===0&&e.boundingClientRect.width===0&&e.boundingClientRect.height===0&&y.close()});r.observe(l),i(()=>r.disconnect())}),()=>{let{id:i,open:l,initialFocus:r,...d}=o,e={...t,ref:c,id:i,role:"dialog","aria-modal":f.value===0?!0:void 0,"aria-labelledby":E.value,"aria-describedby":Q.value},L={open:f.value===0};return h($,{force:!0},()=>[h(_,()=>h(ie,{target:c.value},()=>h($,{force:!1},()=>h(R,{initialFocus:r,containers:x,features:H.value?F(J.value,{parent:R.features.RestoreFocus,leaf:R.features.All&~R.features.FocusLock}):R.features.None},()=>P({ourProps:e,theirProps:d,slot:L,attrs:t,slots:s,visible:f.value===0,features:Y.RenderStrategy|Y.Static,name:"Dialog"}))))),h(ge,{features:ce.Hidden,ref:B})])}}}),Ne=b({name:"DialogOverlay",props:{as:{type:[Object,String],default:"div"},id:{type:String,default:()=>`headlessui-dialog-overlay-${w()}`}},setup(o,{attrs:n,slots:t}){let s=T("DialogOverlay");function u(a){a.target===a.currentTarget&&(a.preventDefault(),a.stopPropagation(),s.close())}return()=>{let{id:a,...p}=o;return P({ourProps:{id:a,"aria-hidden":!0,onClick:u},theirProps:p,slot:{open:s.dialogState.value===0},attrs:n,slots:t,name:"DialogOverlay"})}}}),Ve=b({name:"DialogBackdrop",props:{as:{type:[Object,String],default:"div"},id:{type:String,default:()=>`headlessui-dialog-backdrop-${w()}`}},inheritAttrs:!1,setup(o,{attrs:n,slots:t,expose:s}){let u=T("DialogBackdrop"),a=S(null);return s({el:a,$el:a}),M(()=>{if(u.panelRef.value===null)throw new Error("A <DialogBackdrop /> component is being used, but a <DialogPanel /> component is missing.")}),()=>{let{id:p,...m}=o,v={id:p,ref:a,"aria-hidden":!0};return h($,{force:!0},()=>h(_,()=>P({ourProps:v,theirProps:{...n,...m},slot:{open:u.dialogState.value===0},attrs:n,slots:t,name:"DialogBackdrop"})))}}}),Ye=b({name:"DialogPanel",props:{as:{type:[Object,String],default:"div"},id:{type:String,default:()=>`headlessui-dialog-panel-${w()}`}},setup(o,{attrs:n,slots:t,expose:s}){let u=T("DialogPanel");s({el:u.panelRef,$el:u.panelRef});function a(p){p.stopPropagation()}return()=>{let{id:p,...m}=o,v={id:p,ref:u.panelRef,onClick:a};return P({ourProps:v,theirProps:m,slot:{open:u.dialogState.value===0},attrs:n,slots:t,name:"DialogPanel"})}}}),_e=b({name:"DialogTitle",props:{as:{type:[Object,String],default:"h2"},id:{type:String,default:()=>`headlessui-dialog-title-${w()}`}},setup(o,{attrs:n,slots:t}){let s=T("DialogTitle");return M(()=>{s.setTitleId(o.id),te(()=>s.setTitleId(null))}),()=>{let{id:u,...a}=o;return P({ourProps:{id:u},theirProps:a,slot:{open:s.dialogState.value===0},attrs:n,slots:t,name:"DialogTitle"})}}}),Ue=ne;export{Ke as Dialog,Ve as DialogBackdrop,Ue as DialogDescription,Ne as DialogOverlay,Ye as DialogPanel,_e as DialogTitle}; | ||
import{computed as o,defineComponent as O,h as g,inject as q,nextTick as ie,onMounted as L,onUnmounted as ue,provide as se,ref as y,watchEffect as pe}from"vue";import{FocusTrap as P}from'../../components/focus-trap/focus-trap.js';import{useDocumentOverflowLockedEffect as de}from'../../hooks/document-overflow/use-document-overflow.js';import{useEventListener as fe}from'../../hooks/use-event-listener.js';import{useId as b}from'../../hooks/use-id.js';import{useInert as W}from'../../hooks/use-inert.js';import{useOutsideClick as ge}from'../../hooks/use-outside-click.js';import{useRootContainers as ce}from'../../hooks/use-root-containers.js';import{State as x,useOpenClosed as ve}from'../../internal/open-closed.js';import{ForcePortalRoot as $}from'../../internal/portal-force-root.js';import{StackMessage as Y,useStackProvider as me}from'../../internal/stack-context.js';import{Keys as De}from'../../keyboard.js';import{dom as F}from'../../utils/dom.js';import{match as _}from'../../utils/match.js';import{getOwnerDocument as ye}from'../../utils/owner.js';import{Features as z,render as C}from'../../utils/render.js';import{Description as Se,useDescriptions as he}from'../description/description.js';import{Portal as G,PortalGroup as Oe,useNestedPortals as Pe}from'../portal/portal.js';var be=(l=>(l[l.Open=0]="Open",l[l.Closed=1]="Closed",l))(be||{});let j=Symbol("DialogContext");function T(t){let n=q(j,null);if(n===null){let l=new Error(`<${t} /> is missing a parent <Dialog /> component.`);throw Error.captureStackTrace&&Error.captureStackTrace(l,T),l}return n}let I="DC8F892D-2EBD-447C-A4C8-A03058436FF4",qe=O({name:"Dialog",inheritAttrs:!1,props:{as:{type:[Object,String],default:"div"},static:{type:Boolean,default:!1},unmount:{type:Boolean,default:!0},open:{type:[Boolean,String],default:I},initialFocus:{type:Object,default:null},id:{type:String,default:()=>`headlessui-dialog-${b()}`},role:{type:String,default:"dialog"}},emits:{close:t=>!0},setup(t,{emit:n,attrs:l,slots:u,expose:i}){var U;let r=y(!1);L(()=>{r.value=!0});let s=!1,v=o(()=>t.role==="dialog"||t.role==="alertdialog"?t.role:(s||(s=!0,console.warn(`Invalid role [${v}] passed to <Dialog />. Only \`dialog\` and and \`alertdialog\` are supported. Using \`dialog\` instead.`)),"dialog")),m=y(0),S=ve(),R=o(()=>t.open===I&&S!==null?(S.value&x.Open)===x.Open:t.open),c=y(null),E=o(()=>ye(c));if(i({el:c,$el:c}),!(t.open!==I||S!==null))throw new Error("You forgot to provide an `open` prop to the `Dialog`.");if(typeof R.value!="boolean")throw new Error(`You provided an \`open\` prop to the \`Dialog\`, but the value is not a boolean. Received: ${R.value===I?void 0:t.open}`);let f=o(()=>r.value&&R.value?0:1),k=o(()=>f.value===0),w=o(()=>m.value>1),H=q(j,null)!==null,[V,J]=Pe(),{resolveContainers:A,mainTreeNodeRef:N,MainTreeNode:Q}=ce({portals:V,defaultContainers:[o(()=>{var e;return(e=h.panelRef.value)!=null?e:c.value})]}),X=o(()=>w.value?"parent":"leaf"),K=o(()=>S!==null?(S.value&x.Closing)===x.Closing:!1),Z=o(()=>H||K.value?!1:k.value),ee=o(()=>{var e,a,p;return(p=Array.from((a=(e=E.value)==null?void 0:e.querySelectorAll("body > *"))!=null?a:[]).find(d=>d.id==="headlessui-portal-root"?!1:d.contains(F(N))&&d instanceof HTMLElement))!=null?p:null});W(ee,Z);let te=o(()=>w.value?!0:k.value),le=o(()=>{var e,a,p;return(p=Array.from((a=(e=E.value)==null?void 0:e.querySelectorAll("[data-headlessui-portal]"))!=null?a:[]).find(d=>d.contains(F(N))&&d instanceof HTMLElement))!=null?p:null});W(le,te),me({type:"Dialog",enabled:o(()=>f.value===0),element:c,onUpdate:(e,a)=>{if(a==="Dialog")return _(e,{[Y.Add]:()=>m.value+=1,[Y.Remove]:()=>m.value-=1})}});let ae=he({name:"DialogDescription",slot:o(()=>({open:R.value}))}),M=y(null),h={titleId:M,panelRef:y(null),dialogState:f,setTitleId(e){M.value!==e&&(M.value=e)},close(){n("close",!1)}};se(j,h);let oe=o(()=>!(!k.value||w.value));ge(A,(e,a)=>{e.preventDefault(),h.close(),ie(()=>a==null?void 0:a.focus())},oe);let re=o(()=>!(w.value||f.value!==0));fe((U=E.value)==null?void 0:U.defaultView,"keydown",e=>{re.value&&(e.defaultPrevented||e.key===De.Escape&&(e.preventDefault(),e.stopPropagation(),h.close()))});let ne=o(()=>!(K.value||f.value!==0||H));return de(E,ne,e=>{var a;return{containers:[...(a=e.containers)!=null?a:[],A]}}),pe(e=>{if(f.value!==0)return;let a=F(c);if(!a)return;let p=new ResizeObserver(d=>{for(let B of d){let D=B.target.getBoundingClientRect();D.x===0&&D.y===0&&D.width===0&&D.height===0&&h.close()}});p.observe(a),e(()=>p.disconnect())}),()=>{let{id:e,open:a,initialFocus:p,...d}=t,B={...l,ref:c,id:e,role:v.value,"aria-modal":f.value===0?!0:void 0,"aria-labelledby":M.value,"aria-describedby":ae.value},D={open:f.value===0};return g($,{force:!0},()=>[g(G,()=>g(Oe,{target:c.value},()=>g($,{force:!1},()=>g(P,{initialFocus:p,containers:A,features:k.value?_(X.value,{parent:P.features.RestoreFocus,leaf:P.features.All&~P.features.FocusLock}):P.features.None},()=>g(J,{},()=>C({ourProps:B,theirProps:{...d,...l},slot:D,attrs:l,slots:u,visible:f.value===0,features:z.RenderStrategy|z.Static,name:"Dialog"})))))),g(Q)])}}}),We=O({name:"DialogOverlay",props:{as:{type:[Object,String],default:"div"},id:{type:String,default:()=>`headlessui-dialog-overlay-${b()}`}},setup(t,{attrs:n,slots:l}){let u=T("DialogOverlay");function i(r){r.target===r.currentTarget&&(r.preventDefault(),r.stopPropagation(),u.close())}return()=>{let{id:r,...s}=t;return C({ourProps:{id:r,"aria-hidden":!0,onClick:i},theirProps:s,slot:{open:u.dialogState.value===0},attrs:n,slots:l,name:"DialogOverlay"})}}}),Ye=O({name:"DialogBackdrop",props:{as:{type:[Object,String],default:"div"},id:{type:String,default:()=>`headlessui-dialog-backdrop-${b()}`}},inheritAttrs:!1,setup(t,{attrs:n,slots:l,expose:u}){let i=T("DialogBackdrop"),r=y(null);return u({el:r,$el:r}),L(()=>{if(i.panelRef.value===null)throw new Error("A <DialogBackdrop /> component is being used, but a <DialogPanel /> component is missing.")}),()=>{let{id:s,...v}=t,m={id:s,ref:r,"aria-hidden":!0};return g($,{force:!0},()=>g(G,()=>C({ourProps:m,theirProps:{...n,...v},slot:{open:i.dialogState.value===0},attrs:n,slots:l,name:"DialogBackdrop"})))}}}),_e=O({name:"DialogPanel",props:{as:{type:[Object,String],default:"div"},id:{type:String,default:()=>`headlessui-dialog-panel-${b()}`}},setup(t,{attrs:n,slots:l,expose:u}){let i=T("DialogPanel");u({el:i.panelRef,$el:i.panelRef});function r(s){s.stopPropagation()}return()=>{let{id:s,...v}=t,m={id:s,ref:i.panelRef,onClick:r};return C({ourProps:m,theirProps:v,slot:{open:i.dialogState.value===0},attrs:n,slots:l,name:"DialogPanel"})}}}),ze=O({name:"DialogTitle",props:{as:{type:[Object,String],default:"h2"},id:{type:String,default:()=>`headlessui-dialog-title-${b()}`}},setup(t,{attrs:n,slots:l}){let u=T("DialogTitle");return L(()=>{u.setTitleId(t.id),ue(()=>u.setTitleId(null))}),()=>{let{id:i,...r}=t;return C({ourProps:{id:i},theirProps:r,slot:{open:u.dialogState.value===0},attrs:n,slots:l,name:"DialogTitle"})}}}),Ge=Se;export{qe as Dialog,Ye as DialogBackdrop,Ge as DialogDescription,We as DialogOverlay,_e as DialogPanel,ze as DialogTitle}; |
@@ -38,3 +38,3 @@ export declare let Disclosure: import("vue").DefineComponent<{ | ||
type: StringConstructor; | ||
default: () => string; | ||
default: null; | ||
}; | ||
@@ -56,8 +56,8 @@ }, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, { | ||
type: StringConstructor; | ||
default: () => string; | ||
default: null; | ||
}; | ||
}>>, { | ||
id: string; | ||
as: string | Record<string, any>; | ||
disabled: boolean; | ||
id: string; | ||
}>; | ||
@@ -79,3 +79,3 @@ export declare let DisclosurePanel: import("vue").DefineComponent<{ | ||
type: StringConstructor; | ||
default: () => string; | ||
default: null; | ||
}; | ||
@@ -101,9 +101,9 @@ }, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, { | ||
type: StringConstructor; | ||
default: () => string; | ||
default: null; | ||
}; | ||
}>>, { | ||
id: string; | ||
as: string | Record<string, any>; | ||
unmount: boolean; | ||
static: boolean; | ||
id: string; | ||
}>; |
@@ -1,1 +0,1 @@ | ||
import{defineComponent as v,ref as d,provide as C,inject as O,computed as m,watchEffect as M,onMounted as P,onUnmounted as h}from"vue";import{Keys as f}from'../../keyboard.js';import{match as I}from'../../utils/match.js';import{render as y,Features as R}from'../../utils/render.js';import{useId as E}from'../../hooks/use-id.js';import{dom as p}from'../../utils/dom.js';import{useOpenClosedProvider as w,State as b,useOpenClosed as H}from'../../internal/open-closed.js';import{useResolveButtonType as L}from'../../hooks/use-resolve-button-type.js';var j=(o=>(o[o.Open=0]="Open",o[o.Closed=1]="Closed",o))(j||{});let x=Symbol("DisclosureContext");function g(t){let r=O(x,null);if(r===null){let o=new Error(`<${t} /> is missing a parent <Disclosure /> component.`);throw Error.captureStackTrace&&Error.captureStackTrace(o,g),o}return r}let B=Symbol("DisclosurePanelContext");function $(){return O(B,null)}let Q=v({name:"Disclosure",props:{as:{type:[Object,String],default:"template"},defaultOpen:{type:[Boolean],default:!1}},setup(t,{slots:r,attrs:o}){let u=d(t.defaultOpen?0:1),e=d(null),i=d(null),s={buttonId:d(null),panelId:d(null),disclosureState:u,panel:e,button:i,toggleDisclosure(){u.value=I(u.value,{[0]:1,[1]:0})},closeDisclosure(){u.value!==1&&(u.value=1)},close(l){s.closeDisclosure();let a=(()=>l?l instanceof HTMLElement?l:l.value instanceof HTMLElement?p(l):p(s.button):p(s.button))();a==null||a.focus()}};return C(x,s),w(m(()=>I(u.value,{[0]:b.Open,[1]:b.Closed}))),()=>{let{defaultOpen:l,...a}=t,c={open:u.value===0,close:s.close};return y({theirProps:a,ourProps:{},slot:c,slots:r,attrs:o,name:"Disclosure"})}}}),V=v({name:"DisclosureButton",props:{as:{type:[Object,String],default:"button"},disabled:{type:[Boolean],default:!1},id:{type:String,default:()=>`headlessui-disclosure-button-${E()}`}},setup(t,{attrs:r,slots:o,expose:u}){let e=g("DisclosureButton");P(()=>{e.buttonId.value=t.id}),h(()=>{e.buttonId.value=null});let i=$(),s=m(()=>i===null?!1:i.value===e.panelId.value),l=d(null);u({el:l,$el:l}),s.value||M(()=>{e.button.value=l.value});let a=L(m(()=>({as:t.as,type:r.type})),l);function c(){var n;t.disabled||(s.value?(e.toggleDisclosure(),(n=p(e.button))==null||n.focus()):e.toggleDisclosure())}function D(n){var S;if(!t.disabled)if(s.value)switch(n.key){case f.Space:case f.Enter:n.preventDefault(),n.stopPropagation(),e.toggleDisclosure(),(S=p(e.button))==null||S.focus();break}else switch(n.key){case f.Space:case f.Enter:n.preventDefault(),n.stopPropagation(),e.toggleDisclosure();break}}function T(n){switch(n.key){case f.Space:n.preventDefault();break}}return()=>{let n={open:e.disclosureState.value===0},{id:S,...k}=t,K=s.value?{ref:l,type:a.value,onClick:c,onKeydown:D}:{id:S,ref:l,type:a.value,"aria-expanded":t.disabled?void 0:e.disclosureState.value===0,"aria-controls":p(e.panel)?e.panelId.value:void 0,disabled:t.disabled?!0:void 0,onClick:c,onKeydown:D,onKeyup:T};return y({ourProps:K,theirProps:k,slot:n,attrs:r,slots:o,name:"DisclosureButton"})}}}),X=v({name:"DisclosurePanel",props:{as:{type:[Object,String],default:"div"},static:{type:Boolean,default:!1},unmount:{type:Boolean,default:!0},id:{type:String,default:()=>`headlessui-disclosure-panel-${E()}`}},setup(t,{attrs:r,slots:o,expose:u}){let e=g("DisclosurePanel");P(()=>{e.panelId.value=t.id}),h(()=>{e.panelId.value=null}),u({el:e.panel,$el:e.panel}),C(B,e.panelId);let i=H(),s=m(()=>i!==null?i.value===b.Open:e.disclosureState.value===0);return()=>{let l={open:e.disclosureState.value===0,close:e.close},{id:a,...c}=t,D={id:a,ref:e.panel};return y({ourProps:D,theirProps:c,slot:l,attrs:r,slots:o,features:R.RenderStrategy|R.Static,visible:s.value,name:"DisclosurePanel"})}}});export{Q as Disclosure,V as DisclosureButton,X as DisclosurePanel}; | ||
import{computed as m,defineComponent as b,inject as I,onMounted as P,onUnmounted as h,provide as R,ref as d,watchEffect as w}from"vue";import{useId as E}from'../../hooks/use-id.js';import{useResolveButtonType as H}from'../../hooks/use-resolve-button-type.js';import{State as y,useOpenClosed as L,useOpenClosedProvider as j}from'../../internal/open-closed.js';import{Keys as f}from'../../keyboard.js';import{dom as p}from'../../utils/dom.js';import{match as x}from'../../utils/match.js';import{Features as B,render as g}from'../../utils/render.js';var $=(o=>(o[o.Open=0]="Open",o[o.Closed=1]="Closed",o))($||{});let T=Symbol("DisclosureContext");function O(t){let r=I(T,null);if(r===null){let o=new Error(`<${t} /> is missing a parent <Disclosure /> component.`);throw Error.captureStackTrace&&Error.captureStackTrace(o,O),o}return r}let k=Symbol("DisclosurePanelContext");function U(){return I(k,null)}let N=b({name:"Disclosure",props:{as:{type:[Object,String],default:"template"},defaultOpen:{type:[Boolean],default:!1}},setup(t,{slots:r,attrs:o}){let s=d(t.defaultOpen?0:1),e=d(null),i=d(null),n={buttonId:d(`headlessui-disclosure-button-${E()}`),panelId:d(`headlessui-disclosure-panel-${E()}`),disclosureState:s,panel:e,button:i,toggleDisclosure(){s.value=x(s.value,{[0]:1,[1]:0})},closeDisclosure(){s.value!==1&&(s.value=1)},close(l){n.closeDisclosure();let a=(()=>l?l instanceof HTMLElement?l:l.value instanceof HTMLElement?p(l):p(n.button):p(n.button))();a==null||a.focus()}};return R(T,n),j(m(()=>x(s.value,{[0]:y.Open,[1]:y.Closed}))),()=>{let{defaultOpen:l,...a}=t,c={open:s.value===0,close:n.close};return g({theirProps:a,ourProps:{},slot:c,slots:r,attrs:o,name:"Disclosure"})}}}),Q=b({name:"DisclosureButton",props:{as:{type:[Object,String],default:"button"},disabled:{type:[Boolean],default:!1},id:{type:String,default:null}},setup(t,{attrs:r,slots:o,expose:s}){let e=O("DisclosureButton"),i=U(),n=m(()=>i===null?!1:i.value===e.panelId.value);P(()=>{n.value||t.id!==null&&(e.buttonId.value=t.id)}),h(()=>{n.value||(e.buttonId.value=null)});let l=d(null);s({el:l,$el:l}),n.value||w(()=>{e.button.value=l.value});let a=H(m(()=>({as:t.as,type:r.type})),l);function c(){var u;t.disabled||(n.value?(e.toggleDisclosure(),(u=p(e.button))==null||u.focus()):e.toggleDisclosure())}function D(u){var S;if(!t.disabled)if(n.value)switch(u.key){case f.Space:case f.Enter:u.preventDefault(),u.stopPropagation(),e.toggleDisclosure(),(S=p(e.button))==null||S.focus();break}else switch(u.key){case f.Space:case f.Enter:u.preventDefault(),u.stopPropagation(),e.toggleDisclosure();break}}function v(u){switch(u.key){case f.Space:u.preventDefault();break}}return()=>{var C;let u={open:e.disclosureState.value===0},{id:S,...K}=t,M=n.value?{ref:l,type:a.value,onClick:c,onKeydown:D}:{id:(C=e.buttonId.value)!=null?C:S,ref:l,type:a.value,"aria-expanded":e.disclosureState.value===0,"aria-controls":e.disclosureState.value===0||p(e.panel)?e.panelId.value:void 0,disabled:t.disabled?!0:void 0,onClick:c,onKeydown:D,onKeyup:v};return g({ourProps:M,theirProps:K,slot:u,attrs:r,slots:o,name:"DisclosureButton"})}}}),V=b({name:"DisclosurePanel",props:{as:{type:[Object,String],default:"div"},static:{type:Boolean,default:!1},unmount:{type:Boolean,default:!0},id:{type:String,default:null}},setup(t,{attrs:r,slots:o,expose:s}){let e=O("DisclosurePanel");P(()=>{t.id!==null&&(e.panelId.value=t.id)}),h(()=>{e.panelId.value=null}),s({el:e.panel,$el:e.panel}),R(k,e.panelId);let i=L(),n=m(()=>i!==null?(i.value&y.Open)===y.Open:e.disclosureState.value===0);return()=>{var v;let l={open:e.disclosureState.value===0,close:e.close},{id:a,...c}=t,D={id:(v=e.panelId.value)!=null?v:a,ref:e.panel};return g({ourProps:D,theirProps:c,slot:l,attrs:r,slots:o,features:B.RenderStrategy|B.Static,visible:n.value,name:"DisclosurePanel"})}}});export{N as Disclosure,Q as DisclosureButton,V as DisclosurePanel}; |
@@ -1,2 +0,3 @@ | ||
import { PropType, Ref } from 'vue'; | ||
import { type PropType, type Ref } from 'vue'; | ||
type Containers = (() => Iterable<HTMLElement>) | Ref<Set<Ref<HTMLElement | null>>>; | ||
declare enum Features { | ||
@@ -24,3 +25,3 @@ /** No features enabled for the focus trap. */ | ||
initialFocus: HTMLElement | null; | ||
containers: Ref<Set<Ref<HTMLElement | null>>>; | ||
containers: Containers; | ||
}> & Omit<Readonly<import("vue").ExtractPropTypes<{ | ||
@@ -40,3 +41,3 @@ as: { | ||
containers: { | ||
type: PropType<Ref<Set<Ref<HTMLElement | null>>>>; | ||
type: PropType<Containers>; | ||
default: Ref<Set<unknown>>; | ||
@@ -72,3 +73,3 @@ }; | ||
containers: { | ||
type: PropType<Ref<Set<Ref<HTMLElement | null>>>>; | ||
type: PropType<Containers>; | ||
default: Ref<Set<unknown>>; | ||
@@ -82,3 +83,3 @@ }; | ||
initialFocus: HTMLElement | null; | ||
containers: Ref<Set<Ref<HTMLElement | null>>>; | ||
containers: Containers; | ||
}> & { | ||
@@ -118,3 +119,3 @@ beforeCreate?: ((() => void) | (() => void)[]) | undefined; | ||
containers: { | ||
type: PropType<Ref<Set<Ref<HTMLElement | null>>>>; | ||
type: PropType<Containers>; | ||
default: Ref<Set<unknown>>; | ||
@@ -124,3 +125,3 @@ }; | ||
[key: string]: any; | ||
}>> & {} & {} & import("vue").ComponentCustomProperties; | ||
}>> & {} & import("vue").ComponentCustomProperties; | ||
__isFragment?: undefined; | ||
@@ -143,3 +144,3 @@ __isTeleport?: undefined; | ||
containers: { | ||
type: PropType<Ref<Set<Ref<HTMLElement | null>>>>; | ||
type: PropType<Containers>; | ||
default: Ref<Set<unknown>>; | ||
@@ -153,3 +154,3 @@ }; | ||
initialFocus: HTMLElement | null; | ||
containers: Ref<Set<Ref<HTMLElement | null>>>; | ||
containers: Containers; | ||
}> & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps & { | ||
@@ -156,0 +157,0 @@ features: typeof Features; |
@@ -1,1 +0,1 @@ | ||
import{computed as m,defineComponent as k,h as d,onMounted as v,onUnmounted as H,ref as T,watch as R,Fragment as P}from"vue";import{render as B}from'../../utils/render.js';import{Hidden as M,Features as D}from'../../internal/hidden.js';import{dom as L}from'../../utils/dom.js';import{focusIn as b,Focus as F,focusElement as E,FocusResult as I}from'../../utils/focus-management.js';import{match as S}from'../../utils/match.js';import{useTabDirection as g,Direction as w}from'../../hooks/use-tab-direction.js';import{getOwnerDocument as N}from'../../utils/owner.js';import{useEventListener as O}from'../../hooks/use-event-listener.js';import{microTask as j}from'../../utils/micro-task.js';var h=(e=>(e[e.None=1]="None",e[e.InitialFocus=2]="InitialFocus",e[e.TabLock=4]="TabLock",e[e.FocusLock=8]="FocusLock",e[e.RestoreFocus=16]="RestoreFocus",e[e.All=30]="All",e))(h||{});let ee=Object.assign(k({name:"FocusTrap",props:{as:{type:[Object,String],default:"div"},initialFocus:{type:Object,default:null},features:{type:Number,default:30},containers:{type:Object,default:T(new Set)}},inheritAttrs:!1,setup(u,{attrs:a,slots:t,expose:r}){let n=T(null);r({el:n,$el:n});let o=m(()=>N(n));A({ownerDocument:o},m(()=>Boolean(u.features&16)));let e=C({ownerDocument:o,container:n,initialFocus:m(()=>u.initialFocus)},m(()=>Boolean(u.features&2)));_({ownerDocument:o,container:n,containers:u.containers,previousActiveElement:e},m(()=>Boolean(u.features&8)));let s=g();function i(){let l=L(n);!l||S(s.value,{[w.Forwards]:()=>b(l,F.First),[w.Backwards]:()=>b(l,F.Last)})}return()=>{let l={},c={ref:n},{features:f,initialFocus:p,containers:U,...y}=u;return d(P,[Boolean(f&4)&&d(M,{as:"button",type:"button",onFocus:i,features:D.Focusable}),B({ourProps:c,theirProps:{...a,...y},slot:l,attrs:a,slots:t,name:"FocusTrap"}),Boolean(f&4)&&d(M,{as:"button",type:"button",onFocus:i,features:D.Focusable})])}}}),{features:h});function A({ownerDocument:u},a){let t=T(null);function r(){var o;t.value||(t.value=(o=u.value)==null?void 0:o.activeElement)}function n(){!t.value||(E(t.value),t.value=null)}v(()=>{R(a,(o,e)=>{o!==e&&(o?r():n())},{immediate:!0})}),H(n)}function C({ownerDocument:u,container:a,initialFocus:t},r){let n=T(null),o=T(!1);return v(()=>o.value=!0),H(()=>o.value=!1),v(()=>{R([a,t,r],(e,s)=>{if(e.every((l,c)=>(s==null?void 0:s[c])===l)||!r.value)return;let i=L(a);!i||j(()=>{var f,p;if(!o.value)return;let l=L(t),c=(f=u.value)==null?void 0:f.activeElement;if(l){if(l===c){n.value=c;return}}else if(i.contains(c)){n.value=c;return}l?E(l):b(i,F.First|F.NoScroll)===I.Error&&console.warn("There are no focusable elements inside the <FocusTrap />"),n.value=(p=u.value)==null?void 0:p.activeElement})},{immediate:!0,flush:"post"})}),n}function _({ownerDocument:u,container:a,containers:t,previousActiveElement:r},n){var o;O((o=u.value)==null?void 0:o.defaultView,"focus",e=>{if(!n.value)return;let s=new Set(t==null?void 0:t.value);s.add(a);let i=r.value;if(!i)return;let l=e.target;l&&l instanceof HTMLElement?x(s,l)?(r.value=l,E(l)):(e.preventDefault(),e.stopPropagation(),E(i)):E(r.value)},!0)}function x(u,a){var t;for(let r of u)if((t=r.value)!=null&&t.contains(a))return!0;return!1}export{ee as FocusTrap}; | ||
import{Fragment as I,computed as L,defineComponent as j,h as R,onMounted as M,onUnmounted as h,ref as E,watch as g,watchEffect as K}from"vue";import{useEventListener as U}from'../../hooks/use-event-listener.js';import{Direction as y,useTabDirection as _}from'../../hooks/use-tab-direction.js';import{Hidden as k,Features as D}from'../../internal/hidden.js';import{history as C}from'../../utils/active-element-history.js';import{dom as c}from'../../utils/dom.js';import{Focus as v,FocusResult as q,focusElement as p,focusIn as b}from'../../utils/focus-management.js';import{match as P}from'../../utils/match.js';import{microTask as S}from'../../utils/micro-task.js';import{getOwnerDocument as x}from'../../utils/owner.js';import{render as G}from'../../utils/render.js';function B(t){if(!t)return new Set;if(typeof t=="function")return new Set(t());let n=new Set;for(let r of t.value){let l=c(r);l instanceof HTMLElement&&n.add(l)}return n}var A=(e=>(e[e.None=1]="None",e[e.InitialFocus=2]="InitialFocus",e[e.TabLock=4]="TabLock",e[e.FocusLock=8]="FocusLock",e[e.RestoreFocus=16]="RestoreFocus",e[e.All=30]="All",e))(A||{});let ue=Object.assign(j({name:"FocusTrap",props:{as:{type:[Object,String],default:"div"},initialFocus:{type:Object,default:null},features:{type:Number,default:30},containers:{type:[Object,Function],default:E(new Set)}},inheritAttrs:!1,setup(t,{attrs:n,slots:r,expose:l}){let o=E(null);l({el:o,$el:o});let i=L(()=>x(o)),e=E(!1);M(()=>e.value=!0),h(()=>e.value=!1),$({ownerDocument:i},L(()=>e.value&&!!(t.features&16)));let m=z({ownerDocument:i,container:o,initialFocus:L(()=>t.initialFocus)},L(()=>e.value&&!!(t.features&2)));J({ownerDocument:i,container:o,containers:t.containers,previousActiveElement:m},L(()=>e.value&&!!(t.features&8)));let f=_();function a(u){let T=c(o);if(!T)return;(w=>w())(()=>{P(f.value,{[y.Forwards]:()=>{b(T,v.First,{skipElements:[u.relatedTarget]})},[y.Backwards]:()=>{b(T,v.Last,{skipElements:[u.relatedTarget]})}})})}let s=E(!1);function F(u){u.key==="Tab"&&(s.value=!0,requestAnimationFrame(()=>{s.value=!1}))}function H(u){if(!e.value)return;let T=B(t.containers);c(o)instanceof HTMLElement&&T.add(c(o));let d=u.relatedTarget;d instanceof HTMLElement&&d.dataset.headlessuiFocusGuard!=="true"&&(N(T,d)||(s.value?b(c(o),P(f.value,{[y.Forwards]:()=>v.Next,[y.Backwards]:()=>v.Previous})|v.WrapAround,{relativeTo:u.target}):u.target instanceof HTMLElement&&p(u.target)))}return()=>{let u={},T={ref:o,onKeydown:F,onFocusout:H},{features:d,initialFocus:w,containers:Q,...O}=t;return R(I,[!!(d&4)&&R(k,{as:"button",type:"button","data-headlessui-focus-guard":!0,onFocus:a,features:D.Focusable}),G({ourProps:T,theirProps:{...n,...O},slot:u,attrs:n,slots:r,name:"FocusTrap"}),!!(d&4)&&R(k,{as:"button",type:"button","data-headlessui-focus-guard":!0,onFocus:a,features:D.Focusable})])}}}),{features:A});function W(t){let n=E(C.slice());return g([t],([r],[l])=>{l===!0&&r===!1?S(()=>{n.value.splice(0)}):l===!1&&r===!0&&(n.value=C.slice())},{flush:"post"}),()=>{var r;return(r=n.value.find(l=>l!=null&&l.isConnected))!=null?r:null}}function $({ownerDocument:t},n){let r=W(n);M(()=>{K(()=>{var l,o;n.value||((l=t.value)==null?void 0:l.activeElement)===((o=t.value)==null?void 0:o.body)&&p(r())},{flush:"post"})}),h(()=>{n.value&&p(r())})}function z({ownerDocument:t,container:n,initialFocus:r},l){let o=E(null),i=E(!1);return M(()=>i.value=!0),h(()=>i.value=!1),M(()=>{g([n,r,l],(e,m)=>{if(e.every((a,s)=>(m==null?void 0:m[s])===a)||!l.value)return;let f=c(n);f&&S(()=>{var F,H;if(!i.value)return;let a=c(r),s=(F=t.value)==null?void 0:F.activeElement;if(a){if(a===s){o.value=s;return}}else if(f.contains(s)){o.value=s;return}a?p(a):b(f,v.First|v.NoScroll)===q.Error&&console.warn("There are no focusable elements inside the <FocusTrap />"),o.value=(H=t.value)==null?void 0:H.activeElement})},{immediate:!0,flush:"post"})}),o}function J({ownerDocument:t,container:n,containers:r,previousActiveElement:l},o){var i;U((i=t.value)==null?void 0:i.defaultView,"focus",e=>{if(!o.value)return;let m=B(r);c(n)instanceof HTMLElement&&m.add(c(n));let f=l.value;if(!f)return;let a=e.target;a&&a instanceof HTMLElement?N(m,a)?(l.value=a,p(a)):(e.preventDefault(),e.stopPropagation(),p(f)):p(l.value)},!0)}function N(t,n){for(let r of t)if(r.contains(n))return!0;return!1}export{ue as FocusTrap}; |
@@ -1,2 +0,2 @@ | ||
import { ComputedRef } from 'vue'; | ||
import { type ComputedRef } from 'vue'; | ||
export declare function useLabels({ slot, name, props, }?: { | ||
@@ -38,5 +38,5 @@ slot?: Record<string, unknown>; | ||
}>>, { | ||
passive: boolean; | ||
id: string; | ||
as: string | Record<string, any>; | ||
id: string; | ||
passive: boolean; | ||
}>; |
@@ -1,1 +0,1 @@ | ||
import{computed as m,defineComponent as v,inject as x,onMounted as L,onUnmounted as k,provide as C,ref as j,unref as w}from"vue";import{useId as R}from'../../hooks/use-id.js';import{render as h}from'../../utils/render.js';let a=Symbol("LabelContext");function d(){let t=x(a,null);if(t===null){let n=new Error("You used a <Label /> component, but it is not inside a parent.");throw Error.captureStackTrace&&Error.captureStackTrace(n,d),n}return t}function K({slot:t={},name:n="Label",props:i={}}={}){let e=j([]);function l(r){return e.value.push(r),()=>{let o=e.value.indexOf(r);o!==-1&&e.value.splice(o,1)}}return C(a,{register:l,slot:t,name:n,props:i}),m(()=>e.value.length>0?e.value.join(" "):void 0)}let T=v({name:"Label",props:{as:{type:[Object,String],default:"label"},passive:{type:[Boolean],default:!1},id:{type:String,default:()=>`headlessui-label-${R()}`}},setup(t,{slots:n,attrs:i}){let e=d();return L(()=>k(e.register(t.id))),()=>{let{name:l="Label",slot:r={},props:o={}}=e,{id:p,passive:c,...s}=t,u={...Object.entries(o).reduce((f,[b,g])=>Object.assign(f,{[b]:w(g)}),{}),id:p};return c&&(delete u.onClick,delete s.onClick),h({ourProps:u,theirProps:s,slot:r,attrs:i,slots:n,name:l})}}});export{T as Label,K as useLabels}; | ||
import{computed as m,defineComponent as v,inject as x,onMounted as L,onUnmounted as k,provide as C,ref as j,unref as y}from"vue";import{useId as h}from'../../hooks/use-id.js';import{render as w}from'../../utils/render.js';let a=Symbol("LabelContext");function d(){let t=x(a,null);if(t===null){let n=new Error("You used a <Label /> component, but it is not inside a parent.");throw Error.captureStackTrace&&Error.captureStackTrace(n,d),n}return t}function O({slot:t={},name:n="Label",props:i={}}={}){let e=j([]);function l(r){return e.value.push(r),()=>{let o=e.value.indexOf(r);o!==-1&&e.value.splice(o,1)}}return C(a,{register:l,slot:t,name:n,props:i}),m(()=>e.value.length>0?e.value.join(" "):void 0)}let E=v({name:"Label",props:{as:{type:[Object,String],default:"label"},passive:{type:[Boolean],default:!1},id:{type:String,default:()=>`headlessui-label-${h()}`}},setup(t,{slots:n,attrs:i}){let e=d();return L(()=>k(e.register(t.id))),()=>{let{name:l="Label",slot:r={},props:o={}}=e,{id:p,passive:c,...u}=t,s={...Object.entries(o).reduce((f,[b,g])=>Object.assign(f,{[b]:y(g)}),{}),id:p};return c&&(delete s.onClick,delete s.htmlFor,delete u.onClick),w({ourProps:s,theirProps:u,slot:r,attrs:i,slots:n,name:l})}}});export{E as Label,O as useLabels}; |
@@ -1,2 +0,2 @@ | ||
import { PropType } from 'vue'; | ||
import { type PropType } from 'vue'; | ||
declare function defaultComparator<T>(a: T, z: T): boolean; | ||
@@ -28,2 +28,6 @@ export declare let Listbox: import("vue").DefineComponent<{ | ||
}; | ||
form: { | ||
type: StringConstructor; | ||
optional: boolean; | ||
}; | ||
name: { | ||
@@ -66,2 +70,6 @@ type: StringConstructor; | ||
}; | ||
form: { | ||
type: StringConstructor; | ||
optional: boolean; | ||
}; | ||
name: { | ||
@@ -80,2 +88,3 @@ type: StringConstructor; | ||
disabled: boolean; | ||
horizontal: boolean; | ||
by: string | Function; | ||
@@ -85,3 +94,2 @@ modelValue: string | number | boolean | object | null; | ||
multiple: boolean; | ||
horizontal: boolean; | ||
}>; | ||
@@ -111,4 +119,4 @@ export declare let ListboxLabel: import("vue").DefineComponent<{ | ||
}>>, { | ||
id: string; | ||
as: string | Record<string, any>; | ||
id: string; | ||
}>; | ||
@@ -138,4 +146,4 @@ export declare let ListboxButton: import("vue").DefineComponent<{ | ||
}>>, { | ||
id: string; | ||
as: string | Record<string, any>; | ||
id: string; | ||
}>; | ||
@@ -181,6 +189,6 @@ export declare let ListboxOptions: import("vue").DefineComponent<{ | ||
}>>, { | ||
id: string; | ||
as: string | Record<string, any>; | ||
unmount: boolean; | ||
static: boolean; | ||
id: string; | ||
}>; | ||
@@ -224,6 +232,6 @@ export declare let ListboxOption: import("vue").DefineComponent<{ | ||
}>>, { | ||
id: string; | ||
as: string | Record<string, any>; | ||
disabled: boolean; | ||
id: string; | ||
}>; | ||
export {}; |
@@ -1,1 +0,1 @@ | ||
import{Fragment as $,computed as O,defineComponent as V,h as K,inject as Q,nextTick as P,onMounted as A,onUnmounted as z,provide as _,ref as k,toRaw as R,watch as N,watchEffect as q}from"vue";import{Features as H,render as I,omit as W,compact as G}from'../../utils/render.js';import{useId as F}from'../../hooks/use-id.js';import{Keys as c}from'../../keyboard.js';import{calculateActiveIndex as J,Focus as g}from'../../utils/calculate-active-index.js';import{dom as v}from'../../utils/dom.js';import{useOpenClosed as X,State as B,useOpenClosedProvider as Y}from'../../internal/open-closed.js';import{match as C}from'../../utils/match.js';import{useResolveButtonType as Z}from'../../hooks/use-resolve-button-type.js';import{FocusableMode as ee,isFocusableElement as te,sortByDomNode as ae}from'../../utils/focus-management.js';import{useOutsideClick as ie}from'../../hooks/use-outside-click.js';import{Hidden as oe,Features as le}from'../../internal/hidden.js';import{objectToFormEntries as ne}from'../../utils/form.js';import{useControllable as ue}from'../../hooks/use-controllable.js';function re(t,b){return t===b}var se=(u=>(u[u.Open=0]="Open",u[u.Closed=1]="Closed",u))(se||{}),de=(u=>(u[u.Single=0]="Single",u[u.Multi=1]="Multi",u))(de||{}),fe=(u=>(u[u.Pointer=0]="Pointer",u[u.Other=1]="Other",u))(fe||{});function pe(t){requestAnimationFrame(()=>requestAnimationFrame(t))}let U=Symbol("ListboxContext");function E(t){let b=Q(U,null);if(b===null){let u=new Error(`<${t} /> is missing a parent <Listbox /> component.`);throw Error.captureStackTrace&&Error.captureStackTrace(u,E),u}return b}let Ve=V({name:"Listbox",emits:{"update:modelValue":t=>!0},props:{as:{type:[Object,String],default:"template"},disabled:{type:[Boolean],default:!1},by:{type:[String,Function],default:()=>re},horizontal:{type:[Boolean],default:!1},modelValue:{type:[Object,String,Number,Boolean],default:void 0},defaultValue:{type:[Object,String,Number,Boolean],default:void 0},name:{type:String,optional:!0},multiple:{type:[Boolean],default:!1}},inheritAttrs:!1,setup(t,{slots:b,attrs:u,emit:y}){let e=k(1),s=k(null),m=k(null),x=k(null),d=k([]),a=k(""),i=k(null),T=k(1);function w(o=l=>l){let l=i.value!==null?d.value[i.value]:null,n=ae(o(d.value.slice()),h=>v(h.dataRef.domRef)),p=l?n.indexOf(l):null;return p===-1&&(p=null),{options:n,activeOptionIndex:p}}let L=O(()=>t.multiple?1:0),[r,f]=ue(O(()=>t.modelValue===void 0?C(L.value,{[1]:[],[0]:void 0}):t.modelValue),o=>y("update:modelValue",o),O(()=>t.defaultValue)),S={listboxState:e,value:r,mode:L,compare(o,l){if(typeof t.by=="string"){let n=t.by;return(o==null?void 0:o[n])===(l==null?void 0:l[n])}return t.by(o,l)},orientation:O(()=>t.horizontal?"horizontal":"vertical"),labelRef:s,buttonRef:m,optionsRef:x,disabled:O(()=>t.disabled),options:d,searchQuery:a,activeOptionIndex:i,activationTrigger:T,closeListbox(){t.disabled||e.value!==1&&(e.value=1,i.value=null)},openListbox(){t.disabled||e.value!==0&&(e.value=0)},goToOption(o,l,n){if(t.disabled||e.value===1)return;let p=w(),h=J(o===g.Specific?{focus:g.Specific,id:l}:{focus:o},{resolveItems:()=>p.options,resolveActiveIndex:()=>p.activeOptionIndex,resolveId:D=>D.id,resolveDisabled:D=>D.dataRef.disabled});a.value="",i.value=h,T.value=n!=null?n:1,d.value=p.options},search(o){if(t.disabled||e.value===1)return;let n=a.value!==""?0:1;a.value+=o.toLowerCase();let h=(i.value!==null?d.value.slice(i.value+n).concat(d.value.slice(0,i.value+n)):d.value).find(j=>j.dataRef.textValue.startsWith(a.value)&&!j.dataRef.disabled),D=h?d.value.indexOf(h):-1;D===-1||D===i.value||(i.value=D,T.value=1)},clearSearch(){t.disabled||e.value!==1&&a.value!==""&&(a.value="")},registerOption(o,l){let n=w(p=>[...p,{id:o,dataRef:l}]);d.value=n.options,i.value=n.activeOptionIndex},unregisterOption(o){let l=w(n=>{let p=n.findIndex(h=>h.id===o);return p!==-1&&n.splice(p,1),n});d.value=l.options,i.value=l.activeOptionIndex,T.value=1},select(o){t.disabled||f(C(L.value,{[0]:()=>o,[1]:()=>{let l=R(S.value.value).slice(),n=R(o),p=l.findIndex(h=>S.compare(n,R(h)));return p===-1?l.push(n):l.splice(p,1),l}}))}};ie([m,x],(o,l)=>{var n;S.closeListbox(),te(l,ee.Loose)||(o.preventDefault(),(n=v(m))==null||n.focus())},O(()=>e.value===0)),_(U,S),Y(O(()=>C(e.value,{[0]:B.Open,[1]:B.Closed})));let M=O(()=>{var o;return(o=v(m))==null?void 0:o.closest("form")});return A(()=>{N([M],()=>{if(!M.value||t.defaultValue===void 0)return;function o(){S.select(t.defaultValue)}return M.value.addEventListener("reset",o),()=>{var l;(l=M.value)==null||l.removeEventListener("reset",o)}},{immediate:!0})}),()=>{let{name:o,modelValue:l,disabled:n,...p}=t,h={open:e.value===0,disabled:n,value:r.value};return K($,[...o!=null&&r.value!=null?ne({[o]:r.value}).map(([D,j])=>K(oe,G({features:le.Hidden,key:D,as:"input",type:"hidden",hidden:!0,readOnly:!0,name:D,value:j}))):[],I({ourProps:{},theirProps:{...u,...W(p,["defaultValue","onUpdate:modelValue","horizontal","multiple","by"])},slot:h,slots:b,attrs:u,name:"Listbox"})])}}}),Ie=V({name:"ListboxLabel",props:{as:{type:[Object,String],default:"label"},id:{type:String,default:()=>`headlessui-listbox-label-${F()}`}},setup(t,{attrs:b,slots:u}){let y=E("ListboxLabel");function e(){var s;(s=v(y.buttonRef))==null||s.focus({preventScroll:!0})}return()=>{let s={open:y.listboxState.value===0,disabled:y.disabled.value},{id:m,...x}=t,d={id:m,ref:y.labelRef,onClick:e};return I({ourProps:d,theirProps:x,slot:s,attrs:b,slots:u,name:"ListboxLabel"})}}}),Ee=V({name:"ListboxButton",props:{as:{type:[Object,String],default:"button"},id:{type:String,default:()=>`headlessui-listbox-button-${F()}`}},setup(t,{attrs:b,slots:u,expose:y}){let e=E("ListboxButton");y({el:e.buttonRef,$el:e.buttonRef});function s(a){switch(a.key){case c.Space:case c.Enter:case c.ArrowDown:a.preventDefault(),e.openListbox(),P(()=>{var i;(i=v(e.optionsRef))==null||i.focus({preventScroll:!0}),e.value.value||e.goToOption(g.First)});break;case c.ArrowUp:a.preventDefault(),e.openListbox(),P(()=>{var i;(i=v(e.optionsRef))==null||i.focus({preventScroll:!0}),e.value.value||e.goToOption(g.Last)});break}}function m(a){switch(a.key){case c.Space:a.preventDefault();break}}function x(a){e.disabled.value||(e.listboxState.value===0?(e.closeListbox(),P(()=>{var i;return(i=v(e.buttonRef))==null?void 0:i.focus({preventScroll:!0})})):(a.preventDefault(),e.openListbox(),pe(()=>{var i;return(i=v(e.optionsRef))==null?void 0:i.focus({preventScroll:!0})})))}let d=Z(O(()=>({as:t.as,type:b.type})),e.buttonRef);return()=>{var L,r;let a={open:e.listboxState.value===0,disabled:e.disabled.value,value:e.value.value},{id:i,...T}=t,w={ref:e.buttonRef,id:i,type:d.value,"aria-haspopup":!0,"aria-controls":(L=v(e.optionsRef))==null?void 0:L.id,"aria-expanded":e.disabled.value?void 0:e.listboxState.value===0,"aria-labelledby":e.labelRef.value?[(r=v(e.labelRef))==null?void 0:r.id,i].join(" "):void 0,disabled:e.disabled.value===!0?!0:void 0,onKeydown:s,onKeyup:m,onClick:x};return I({ourProps:w,theirProps:T,slot:a,attrs:b,slots:u,name:"ListboxButton"})}}}),je=V({name:"ListboxOptions",props:{as:{type:[Object,String],default:"ul"},static:{type:Boolean,default:!1},unmount:{type:Boolean,default:!0},id:{type:String,default:()=>`headlessui-listbox-options-${F()}`}},setup(t,{attrs:b,slots:u,expose:y}){let e=E("ListboxOptions"),s=k(null);y({el:e.optionsRef,$el:e.optionsRef});function m(a){switch(s.value&&clearTimeout(s.value),a.key){case c.Space:if(e.searchQuery.value!=="")return a.preventDefault(),a.stopPropagation(),e.search(a.key);case c.Enter:if(a.preventDefault(),a.stopPropagation(),e.activeOptionIndex.value!==null){let i=e.options.value[e.activeOptionIndex.value];e.select(i.dataRef.value)}e.mode.value===0&&(e.closeListbox(),P(()=>{var i;return(i=v(e.buttonRef))==null?void 0:i.focus({preventScroll:!0})}));break;case C(e.orientation.value,{vertical:c.ArrowDown,horizontal:c.ArrowRight}):return a.preventDefault(),a.stopPropagation(),e.goToOption(g.Next);case C(e.orientation.value,{vertical:c.ArrowUp,horizontal:c.ArrowLeft}):return a.preventDefault(),a.stopPropagation(),e.goToOption(g.Previous);case c.Home:case c.PageUp:return a.preventDefault(),a.stopPropagation(),e.goToOption(g.First);case c.End:case c.PageDown:return a.preventDefault(),a.stopPropagation(),e.goToOption(g.Last);case c.Escape:a.preventDefault(),a.stopPropagation(),e.closeListbox(),P(()=>{var i;return(i=v(e.buttonRef))==null?void 0:i.focus({preventScroll:!0})});break;case c.Tab:a.preventDefault(),a.stopPropagation();break;default:a.key.length===1&&(e.search(a.key),s.value=setTimeout(()=>e.clearSearch(),350));break}}let x=X(),d=O(()=>x!==null?x.value===B.Open:e.listboxState.value===0);return()=>{var L,r,f,S;let a={open:e.listboxState.value===0},{id:i,...T}=t,w={"aria-activedescendant":e.activeOptionIndex.value===null||(L=e.options.value[e.activeOptionIndex.value])==null?void 0:L.id,"aria-multiselectable":e.mode.value===1?!0:void 0,"aria-labelledby":(S=(r=v(e.labelRef))==null?void 0:r.id)!=null?S:(f=v(e.buttonRef))==null?void 0:f.id,"aria-orientation":e.orientation.value,id:i,onKeydown:m,role:"listbox",tabIndex:0,ref:e.optionsRef};return I({ourProps:w,theirProps:T,slot:a,attrs:b,slots:u,features:H.RenderStrategy|H.Static,visible:d.value,name:"ListboxOptions"})}}}),Ae=V({name:"ListboxOption",props:{as:{type:[Object,String],default:"li"},value:{type:[Object,String,Number,Boolean]},disabled:{type:Boolean,default:!1},id:{type:String,default:()=>`headlessui-listbox.option-${F()}`}},setup(t,{slots:b,attrs:u,expose:y}){let e=E("ListboxOption"),s=k(null);y({el:s,$el:s});let m=O(()=>e.activeOptionIndex.value!==null?e.options.value[e.activeOptionIndex.value].id===t.id:!1),x=O(()=>C(e.mode.value,{[0]:()=>e.compare(R(e.value.value),R(t.value)),[1]:()=>R(e.value.value).some(r=>e.compare(R(r),R(t.value)))})),d=O(()=>C(e.mode.value,{[1]:()=>{var f;let r=R(e.value.value);return((f=e.options.value.find(S=>r.some(M=>e.compare(R(M),R(S.dataRef.value)))))==null?void 0:f.id)===t.id},[0]:()=>x.value})),a=O(()=>({disabled:t.disabled,value:t.value,textValue:"",domRef:s}));A(()=>{var f,S;let r=(S=(f=v(s))==null?void 0:f.textContent)==null?void 0:S.toLowerCase().trim();r!==void 0&&(a.value.textValue=r)}),A(()=>e.registerOption(t.id,a)),z(()=>e.unregisterOption(t.id)),A(()=>{N([e.listboxState,x],()=>{e.listboxState.value===0&&(!x.value||C(e.mode.value,{[1]:()=>{d.value&&e.goToOption(g.Specific,t.id)},[0]:()=>{e.goToOption(g.Specific,t.id)}}))},{immediate:!0})}),q(()=>{e.listboxState.value===0&&(!m.value||e.activationTrigger.value!==0&&P(()=>{var r,f;return(f=(r=v(s))==null?void 0:r.scrollIntoView)==null?void 0:f.call(r,{block:"nearest"})}))});function i(r){if(t.disabled)return r.preventDefault();e.select(t.value),e.mode.value===0&&(e.closeListbox(),P(()=>{var f;return(f=v(e.buttonRef))==null?void 0:f.focus({preventScroll:!0})}))}function T(){if(t.disabled)return e.goToOption(g.Nothing);e.goToOption(g.Specific,t.id)}function w(){t.disabled||m.value||e.goToOption(g.Specific,t.id,0)}function L(){t.disabled||!m.value||e.goToOption(g.Nothing)}return()=>{let{disabled:r}=t,f={active:m.value,selected:x.value,disabled:r},{id:S,value:M,disabled:o,...l}=t,n={id:S,ref:s,role:"option",tabIndex:r===!0?void 0:-1,"aria-disabled":r===!0?!0:void 0,"aria-selected":x.value,disabled:void 0,onClick:i,onFocus:T,onPointermove:w,onMousemove:w,onPointerleave:L,onMouseleave:L};return I({ourProps:n,theirProps:l,slot:f,attrs:u,slots:b,name:"ListboxOption"})}}});export{Ve as Listbox,Ee as ListboxButton,Ie as ListboxLabel,Ae as ListboxOption,je as ListboxOptions}; | ||
import{Fragment as z,computed as x,defineComponent as E,h as N,inject as _,nextTick as C,onMounted as K,onUnmounted as q,provide as W,ref as w,toRaw as R,watch as H,watchEffect as G}from"vue";import{useControllable as J}from'../../hooks/use-controllable.js';import{useId as F}from'../../hooks/use-id.js';import{useOutsideClick as X}from'../../hooks/use-outside-click.js';import{useResolveButtonType as Y}from'../../hooks/use-resolve-button-type.js';import{useTextValue as Z}from'../../hooks/use-text-value.js';import{useTrackedPointer as ee}from'../../hooks/use-tracked-pointer.js';import{Hidden as te,Features as oe}from'../../internal/hidden.js';import{State as B,useOpenClosed as ie,useOpenClosedProvider as ae}from'../../internal/open-closed.js';import{Keys as p}from'../../keyboard.js';import{Focus as g,calculateActiveIndex as ne}from'../../utils/calculate-active-index.js';import{dom as S}from'../../utils/dom.js';import{FocusableMode as le,isFocusableElement as ue,sortByDomNode as re}from'../../utils/focus-management.js';import{objectToFormEntries as se}from'../../utils/form.js';import{match as P}from'../../utils/match.js';import{Features as U,compact as de,omit as fe,render as j}from'../../utils/render.js';function pe(t,c){return t===c}var ce=(u=>(u[u.Open=0]="Open",u[u.Closed=1]="Closed",u))(ce||{}),ve=(u=>(u[u.Single=0]="Single",u[u.Multi=1]="Multi",u))(ve||{}),be=(u=>(u[u.Pointer=0]="Pointer",u[u.Other=1]="Other",u))(be||{});function me(t){requestAnimationFrame(()=>requestAnimationFrame(t))}let $=Symbol("ListboxContext");function A(t){let c=_($,null);if(c===null){let u=new Error(`<${t} /> is missing a parent <Listbox /> component.`);throw Error.captureStackTrace&&Error.captureStackTrace(u,A),u}return c}let Ie=E({name:"Listbox",emits:{"update:modelValue":t=>!0},props:{as:{type:[Object,String],default:"template"},disabled:{type:[Boolean],default:!1},by:{type:[String,Function],default:()=>pe},horizontal:{type:[Boolean],default:!1},modelValue:{type:[Object,String,Number,Boolean],default:void 0},defaultValue:{type:[Object,String,Number,Boolean],default:void 0},form:{type:String,optional:!0},name:{type:String,optional:!0},multiple:{type:[Boolean],default:!1}},inheritAttrs:!1,setup(t,{slots:c,attrs:u,emit:L}){let e=w(1),d=w(null),v=w(null),b=w(null),f=w([]),o=w(""),i=w(null),T=w(1);function D(a=n=>n){let n=i.value!==null?f.value[i.value]:null,l=re(a(f.value.slice()),O=>S(O.dataRef.domRef)),s=n?l.indexOf(n):null;return s===-1&&(s=null),{options:l,activeOptionIndex:s}}let y=x(()=>t.multiple?1:0),[h,V]=J(x(()=>t.modelValue),a=>L("update:modelValue",a),x(()=>t.defaultValue)),M=x(()=>h.value===void 0?P(y.value,{[1]:[],[0]:void 0}):h.value),r={listboxState:e,value:M,mode:y,compare(a,n){if(typeof t.by=="string"){let l=t.by;return(a==null?void 0:a[l])===(n==null?void 0:n[l])}return t.by(a,n)},orientation:x(()=>t.horizontal?"horizontal":"vertical"),labelRef:d,buttonRef:v,optionsRef:b,disabled:x(()=>t.disabled),options:f,searchQuery:o,activeOptionIndex:i,activationTrigger:T,closeListbox(){t.disabled||e.value!==1&&(e.value=1,i.value=null)},openListbox(){t.disabled||e.value!==0&&(e.value=0)},goToOption(a,n,l){if(t.disabled||e.value===1)return;let s=D(),O=ne(a===g.Specific?{focus:g.Specific,id:n}:{focus:a},{resolveItems:()=>s.options,resolveActiveIndex:()=>s.activeOptionIndex,resolveId:k=>k.id,resolveDisabled:k=>k.dataRef.disabled});o.value="",i.value=O,T.value=l!=null?l:1,f.value=s.options},search(a){if(t.disabled||e.value===1)return;let l=o.value!==""?0:1;o.value+=a.toLowerCase();let O=(i.value!==null?f.value.slice(i.value+l).concat(f.value.slice(0,i.value+l)):f.value).find(I=>I.dataRef.textValue.startsWith(o.value)&&!I.dataRef.disabled),k=O?f.value.indexOf(O):-1;k===-1||k===i.value||(i.value=k,T.value=1)},clearSearch(){t.disabled||e.value!==1&&o.value!==""&&(o.value="")},registerOption(a,n){let l=D(s=>[...s,{id:a,dataRef:n}]);f.value=l.options,i.value=l.activeOptionIndex},unregisterOption(a){let n=D(l=>{let s=l.findIndex(O=>O.id===a);return s!==-1&&l.splice(s,1),l});f.value=n.options,i.value=n.activeOptionIndex,T.value=1},theirOnChange(a){t.disabled||V(a)},select(a){t.disabled||V(P(y.value,{[0]:()=>a,[1]:()=>{let n=R(r.value.value).slice(),l=R(a),s=n.findIndex(O=>r.compare(l,R(O)));return s===-1?n.push(l):n.splice(s,1),n}}))}};X([v,b],(a,n)=>{var l;r.closeListbox(),ue(n,le.Loose)||(a.preventDefault(),(l=S(v))==null||l.focus())},x(()=>e.value===0)),W($,r),ae(x(()=>P(e.value,{[0]:B.Open,[1]:B.Closed})));let m=x(()=>{var a;return(a=S(v))==null?void 0:a.closest("form")});return K(()=>{H([m],()=>{if(!m.value||t.defaultValue===void 0)return;function a(){r.theirOnChange(t.defaultValue)}return m.value.addEventListener("reset",a),()=>{var n;(n=m.value)==null||n.removeEventListener("reset",a)}},{immediate:!0})}),()=>{let{name:a,modelValue:n,disabled:l,form:s,...O}=t,k={open:e.value===0,disabled:l,value:M.value};return N(z,[...a!=null&&M.value!=null?se({[a]:M.value}).map(([I,Q])=>N(te,de({features:oe.Hidden,key:I,as:"input",type:"hidden",hidden:!0,readOnly:!0,form:s,disabled:l,name:I,value:Q}))):[],j({ourProps:{},theirProps:{...u,...fe(O,["defaultValue","onUpdate:modelValue","horizontal","multiple","by"])},slot:k,slots:c,attrs:u,name:"Listbox"})])}}}),Ee=E({name:"ListboxLabel",props:{as:{type:[Object,String],default:"label"},id:{type:String,default:()=>`headlessui-listbox-label-${F()}`}},setup(t,{attrs:c,slots:u}){let L=A("ListboxLabel");function e(){var d;(d=S(L.buttonRef))==null||d.focus({preventScroll:!0})}return()=>{let d={open:L.listboxState.value===0,disabled:L.disabled.value},{id:v,...b}=t,f={id:v,ref:L.labelRef,onClick:e};return j({ourProps:f,theirProps:b,slot:d,attrs:c,slots:u,name:"ListboxLabel"})}}}),je=E({name:"ListboxButton",props:{as:{type:[Object,String],default:"button"},id:{type:String,default:()=>`headlessui-listbox-button-${F()}`}},setup(t,{attrs:c,slots:u,expose:L}){let e=A("ListboxButton");L({el:e.buttonRef,$el:e.buttonRef});function d(o){switch(o.key){case p.Space:case p.Enter:case p.ArrowDown:o.preventDefault(),e.openListbox(),C(()=>{var i;(i=S(e.optionsRef))==null||i.focus({preventScroll:!0}),e.value.value||e.goToOption(g.First)});break;case p.ArrowUp:o.preventDefault(),e.openListbox(),C(()=>{var i;(i=S(e.optionsRef))==null||i.focus({preventScroll:!0}),e.value.value||e.goToOption(g.Last)});break}}function v(o){switch(o.key){case p.Space:o.preventDefault();break}}function b(o){e.disabled.value||(e.listboxState.value===0?(e.closeListbox(),C(()=>{var i;return(i=S(e.buttonRef))==null?void 0:i.focus({preventScroll:!0})})):(o.preventDefault(),e.openListbox(),me(()=>{var i;return(i=S(e.optionsRef))==null?void 0:i.focus({preventScroll:!0})})))}let f=Y(x(()=>({as:t.as,type:c.type})),e.buttonRef);return()=>{var y,h;let o={open:e.listboxState.value===0,disabled:e.disabled.value,value:e.value.value},{id:i,...T}=t,D={ref:e.buttonRef,id:i,type:f.value,"aria-haspopup":"listbox","aria-controls":(y=S(e.optionsRef))==null?void 0:y.id,"aria-expanded":e.listboxState.value===0,"aria-labelledby":e.labelRef.value?[(h=S(e.labelRef))==null?void 0:h.id,i].join(" "):void 0,disabled:e.disabled.value===!0?!0:void 0,onKeydown:d,onKeyup:v,onClick:b};return j({ourProps:D,theirProps:T,slot:o,attrs:c,slots:u,name:"ListboxButton"})}}}),Ae=E({name:"ListboxOptions",props:{as:{type:[Object,String],default:"ul"},static:{type:Boolean,default:!1},unmount:{type:Boolean,default:!0},id:{type:String,default:()=>`headlessui-listbox-options-${F()}`}},setup(t,{attrs:c,slots:u,expose:L}){let e=A("ListboxOptions"),d=w(null);L({el:e.optionsRef,$el:e.optionsRef});function v(o){switch(d.value&&clearTimeout(d.value),o.key){case p.Space:if(e.searchQuery.value!=="")return o.preventDefault(),o.stopPropagation(),e.search(o.key);case p.Enter:if(o.preventDefault(),o.stopPropagation(),e.activeOptionIndex.value!==null){let i=e.options.value[e.activeOptionIndex.value];e.select(i.dataRef.value)}e.mode.value===0&&(e.closeListbox(),C(()=>{var i;return(i=S(e.buttonRef))==null?void 0:i.focus({preventScroll:!0})}));break;case P(e.orientation.value,{vertical:p.ArrowDown,horizontal:p.ArrowRight}):return o.preventDefault(),o.stopPropagation(),e.goToOption(g.Next);case P(e.orientation.value,{vertical:p.ArrowUp,horizontal:p.ArrowLeft}):return o.preventDefault(),o.stopPropagation(),e.goToOption(g.Previous);case p.Home:case p.PageUp:return o.preventDefault(),o.stopPropagation(),e.goToOption(g.First);case p.End:case p.PageDown:return o.preventDefault(),o.stopPropagation(),e.goToOption(g.Last);case p.Escape:o.preventDefault(),o.stopPropagation(),e.closeListbox(),C(()=>{var i;return(i=S(e.buttonRef))==null?void 0:i.focus({preventScroll:!0})});break;case p.Tab:o.preventDefault(),o.stopPropagation();break;default:o.key.length===1&&(e.search(o.key),d.value=setTimeout(()=>e.clearSearch(),350));break}}let b=ie(),f=x(()=>b!==null?(b.value&B.Open)===B.Open:e.listboxState.value===0);return()=>{var y,h;let o={open:e.listboxState.value===0},{id:i,...T}=t,D={"aria-activedescendant":e.activeOptionIndex.value===null||(y=e.options.value[e.activeOptionIndex.value])==null?void 0:y.id,"aria-multiselectable":e.mode.value===1?!0:void 0,"aria-labelledby":(h=S(e.buttonRef))==null?void 0:h.id,"aria-orientation":e.orientation.value,id:i,onKeydown:v,role:"listbox",tabIndex:0,ref:e.optionsRef};return j({ourProps:D,theirProps:T,slot:o,attrs:c,slots:u,features:U.RenderStrategy|U.Static,visible:f.value,name:"ListboxOptions"})}}}),Fe=E({name:"ListboxOption",props:{as:{type:[Object,String],default:"li"},value:{type:[Object,String,Number,Boolean]},disabled:{type:Boolean,default:!1},id:{type:String,default:()=>`headlessui-listbox.option-${F()}`}},setup(t,{slots:c,attrs:u,expose:L}){let e=A("ListboxOption"),d=w(null);L({el:d,$el:d});let v=x(()=>e.activeOptionIndex.value!==null?e.options.value[e.activeOptionIndex.value].id===t.id:!1),b=x(()=>P(e.mode.value,{[0]:()=>e.compare(R(e.value.value),R(t.value)),[1]:()=>R(e.value.value).some(r=>e.compare(R(r),R(t.value)))})),f=x(()=>P(e.mode.value,{[1]:()=>{var m;let r=R(e.value.value);return((m=e.options.value.find(a=>r.some(n=>e.compare(R(n),R(a.dataRef.value)))))==null?void 0:m.id)===t.id},[0]:()=>b.value})),o=Z(d),i=x(()=>({disabled:t.disabled,value:t.value,get textValue(){return o()},domRef:d}));K(()=>e.registerOption(t.id,i)),q(()=>e.unregisterOption(t.id)),K(()=>{H([e.listboxState,b],()=>{e.listboxState.value===0&&b.value&&P(e.mode.value,{[1]:()=>{f.value&&e.goToOption(g.Specific,t.id)},[0]:()=>{e.goToOption(g.Specific,t.id)}})},{immediate:!0})}),G(()=>{e.listboxState.value===0&&v.value&&e.activationTrigger.value!==0&&C(()=>{var r,m;return(m=(r=S(d))==null?void 0:r.scrollIntoView)==null?void 0:m.call(r,{block:"nearest"})})});function T(r){if(t.disabled)return r.preventDefault();e.select(t.value),e.mode.value===0&&(e.closeListbox(),C(()=>{var m;return(m=S(e.buttonRef))==null?void 0:m.focus({preventScroll:!0})}))}function D(){if(t.disabled)return e.goToOption(g.Nothing);e.goToOption(g.Specific,t.id)}let y=ee();function h(r){y.update(r)}function V(r){y.wasMoved(r)&&(t.disabled||v.value||e.goToOption(g.Specific,t.id,0))}function M(r){y.wasMoved(r)&&(t.disabled||v.value&&e.goToOption(g.Nothing))}return()=>{let{disabled:r}=t,m={active:v.value,selected:b.value,disabled:r},{id:a,value:n,disabled:l,...s}=t,O={id:a,ref:d,role:"option",tabIndex:r===!0?void 0:-1,"aria-disabled":r===!0?!0:void 0,"aria-selected":b.value,disabled:void 0,onClick:T,onFocus:D,onPointerenter:h,onMouseenter:h,onPointermove:V,onMousemove:V,onPointerleave:M,onMouseleave:M};return j({ourProps:O,theirProps:s,slot:m,attrs:u,slots:c,name:"ListboxOption"})}}});export{Ie as Listbox,je as ListboxButton,Ee as ListboxLabel,Fe as ListboxOption,Ae as ListboxOptions}; |
@@ -49,5 +49,5 @@ export declare let Menu: import("vue").DefineComponent<{ | ||
}>>, { | ||
id: string; | ||
as: string | Record<string, any>; | ||
disabled: boolean; | ||
id: string; | ||
}>; | ||
@@ -93,6 +93,6 @@ export declare let MenuItems: import("vue").DefineComponent<{ | ||
}>>, { | ||
id: string; | ||
as: string | Record<string, any>; | ||
unmount: boolean; | ||
static: boolean; | ||
id: string; | ||
}>; | ||
@@ -130,5 +130,5 @@ export declare let MenuItem: import("vue").DefineComponent<{ | ||
}>>, { | ||
id: string; | ||
as: string | Record<string, any>; | ||
disabled: boolean; | ||
id: string; | ||
}>; |
@@ -1,1 +0,1 @@ | ||
import{defineComponent as x,ref as M,provide as K,inject as L,onMounted as k,onUnmounted as N,computed as R,nextTick as h,watchEffect as j}from"vue";import{Features as C,render as T}from'../../utils/render.js';import{useId as O}from'../../hooks/use-id.js';import{Keys as c}from'../../keyboard.js';import{Focus as g,calculateActiveIndex as B}from'../../utils/calculate-active-index.js';import{dom as f}from'../../utils/dom.js';import{useTreeWalker as U}from'../../hooks/use-tree-walker.js';import{useOpenClosedProvider as $,State as P,useOpenClosed as V}from'../../internal/open-closed.js';import{match as H}from'../../utils/match.js';import{useResolveButtonType as Q}from'../../hooks/use-resolve-button-type.js';import{FocusableMode as _,isFocusableElement as q,sortByDomNode as W,Focus as E,focusFrom as J,restoreFocusIfNecessary as F}from'../../utils/focus-management.js';import{useOutsideClick as z}from'../../hooks/use-outside-click.js';var G=(l=>(l[l.Open=0]="Open",l[l.Closed=1]="Closed",l))(G||{}),X=(l=>(l[l.Pointer=0]="Pointer",l[l.Other=1]="Other",l))(X||{});function Y(i){requestAnimationFrame(()=>requestAnimationFrame(i))}let A=Symbol("MenuContext");function D(i){let S=L(A,null);if(S===null){let l=new Error(`<${i} /> is missing a parent <Menu /> component.`);throw Error.captureStackTrace&&Error.captureStackTrace(l,D),l}return S}let ve=x({name:"Menu",props:{as:{type:[Object,String],default:"template"}},setup(i,{slots:S,attrs:l}){let I=M(1),e=M(null),m=M(null),o=M([]),p=M(""),s=M(null),r=M(1);function t(a=n=>n){let n=s.value!==null?o.value[s.value]:null,u=W(a(o.value.slice()),b=>f(b.dataRef.domRef)),d=n?u.indexOf(n):null;return d===-1&&(d=null),{items:u,activeItemIndex:d}}let v={menuState:I,buttonRef:e,itemsRef:m,items:o,searchQuery:p,activeItemIndex:s,activationTrigger:r,closeMenu:()=>{I.value=1,s.value=null},openMenu:()=>I.value=0,goToItem(a,n,u){let d=t(),b=B(a===g.Specific?{focus:g.Specific,id:n}:{focus:a},{resolveItems:()=>d.items,resolveActiveIndex:()=>d.activeItemIndex,resolveId:y=>y.id,resolveDisabled:y=>y.dataRef.disabled});p.value="",s.value=b,r.value=u!=null?u:1,o.value=d.items},search(a){let u=p.value!==""?0:1;p.value+=a.toLowerCase();let b=(s.value!==null?o.value.slice(s.value+u).concat(o.value.slice(0,s.value+u)):o.value).find(w=>w.dataRef.textValue.startsWith(p.value)&&!w.dataRef.disabled),y=b?o.value.indexOf(b):-1;y===-1||y===s.value||(s.value=y,r.value=1)},clearSearch(){p.value=""},registerItem(a,n){let u=t(d=>[...d,{id:a,dataRef:n}]);o.value=u.items,s.value=u.activeItemIndex,r.value=1},unregisterItem(a){let n=t(u=>{let d=u.findIndex(b=>b.id===a);return d!==-1&&u.splice(d,1),u});o.value=n.items,s.value=n.activeItemIndex,r.value=1}};return z([e,m],(a,n)=>{var u;v.closeMenu(),q(n,_.Loose)||(a.preventDefault(),(u=f(e))==null||u.focus())},R(()=>I.value===0)),K(A,v),$(R(()=>H(I.value,{[0]:P.Open,[1]:P.Closed}))),()=>{let a={open:I.value===0,close:v.closeMenu};return T({ourProps:{},theirProps:i,slot:a,slots:S,attrs:l,name:"Menu"})}}}),Ie=x({name:"MenuButton",props:{disabled:{type:Boolean,default:!1},as:{type:[Object,String],default:"button"},id:{type:String,default:()=>`headlessui-menu-button-${O()}`}},setup(i,{attrs:S,slots:l,expose:I}){let e=D("MenuButton");I({el:e.buttonRef,$el:e.buttonRef});function m(r){switch(r.key){case c.Space:case c.Enter:case c.ArrowDown:r.preventDefault(),r.stopPropagation(),e.openMenu(),h(()=>{var t;(t=f(e.itemsRef))==null||t.focus({preventScroll:!0}),e.goToItem(g.First)});break;case c.ArrowUp:r.preventDefault(),r.stopPropagation(),e.openMenu(),h(()=>{var t;(t=f(e.itemsRef))==null||t.focus({preventScroll:!0}),e.goToItem(g.Last)});break}}function o(r){switch(r.key){case c.Space:r.preventDefault();break}}function p(r){i.disabled||(e.menuState.value===0?(e.closeMenu(),h(()=>{var t;return(t=f(e.buttonRef))==null?void 0:t.focus({preventScroll:!0})})):(r.preventDefault(),e.openMenu(),Y(()=>{var t;return(t=f(e.itemsRef))==null?void 0:t.focus({preventScroll:!0})})))}let s=Q(R(()=>({as:i.as,type:S.type})),e.buttonRef);return()=>{var n;let r={open:e.menuState.value===0},{id:t,...v}=i,a={ref:e.buttonRef,id:t,type:s.value,"aria-haspopup":!0,"aria-controls":(n=f(e.itemsRef))==null?void 0:n.id,"aria-expanded":i.disabled?void 0:e.menuState.value===0,onKeydown:m,onKeyup:o,onClick:p};return T({ourProps:a,theirProps:v,slot:r,attrs:S,slots:l,name:"MenuButton"})}}}),ge=x({name:"MenuItems",props:{as:{type:[Object,String],default:"div"},static:{type:Boolean,default:!1},unmount:{type:Boolean,default:!0},id:{type:String,default:()=>`headlessui-menu-items-${O()}`}},setup(i,{attrs:S,slots:l,expose:I}){let e=D("MenuItems"),m=M(null);I({el:e.itemsRef,$el:e.itemsRef}),U({container:R(()=>f(e.itemsRef)),enabled:R(()=>e.menuState.value===0),accept(t){return t.getAttribute("role")==="menuitem"?NodeFilter.FILTER_REJECT:t.hasAttribute("role")?NodeFilter.FILTER_SKIP:NodeFilter.FILTER_ACCEPT},walk(t){t.setAttribute("role","none")}});function o(t){var v;switch(m.value&&clearTimeout(m.value),t.key){case c.Space:if(e.searchQuery.value!=="")return t.preventDefault(),t.stopPropagation(),e.search(t.key);case c.Enter:if(t.preventDefault(),t.stopPropagation(),e.activeItemIndex.value!==null){let n=e.items.value[e.activeItemIndex.value];(v=f(n.dataRef.domRef))==null||v.click()}e.closeMenu(),F(f(e.buttonRef));break;case c.ArrowDown:return t.preventDefault(),t.stopPropagation(),e.goToItem(g.Next);case c.ArrowUp:return t.preventDefault(),t.stopPropagation(),e.goToItem(g.Previous);case c.Home:case c.PageUp:return t.preventDefault(),t.stopPropagation(),e.goToItem(g.First);case c.End:case c.PageDown:return t.preventDefault(),t.stopPropagation(),e.goToItem(g.Last);case c.Escape:t.preventDefault(),t.stopPropagation(),e.closeMenu(),h(()=>{var a;return(a=f(e.buttonRef))==null?void 0:a.focus({preventScroll:!0})});break;case c.Tab:t.preventDefault(),t.stopPropagation(),e.closeMenu(),h(()=>J(f(e.buttonRef),t.shiftKey?E.Previous:E.Next));break;default:t.key.length===1&&(e.search(t.key),m.value=setTimeout(()=>e.clearSearch(),350));break}}function p(t){switch(t.key){case c.Space:t.preventDefault();break}}let s=V(),r=R(()=>s!==null?s.value===P.Open:e.menuState.value===0);return()=>{var u,d;let t={open:e.menuState.value===0},{id:v,...a}=i,n={"aria-activedescendant":e.activeItemIndex.value===null||(u=e.items.value[e.activeItemIndex.value])==null?void 0:u.id,"aria-labelledby":(d=f(e.buttonRef))==null?void 0:d.id,id:v,onKeydown:o,onKeyup:p,role:"menu",tabIndex:0,ref:e.itemsRef};return T({ourProps:n,theirProps:a,slot:t,attrs:S,slots:l,features:C.RenderStrategy|C.Static,visible:r.value,name:"MenuItems"})}}}),Se=x({name:"MenuItem",props:{as:{type:[Object,String],default:"template"},disabled:{type:Boolean,default:!1},id:{type:String,default:()=>`headlessui-menu-item-${O()}`}},setup(i,{slots:S,attrs:l,expose:I}){let e=D("MenuItem"),m=M(null);I({el:m,$el:m});let o=R(()=>e.activeItemIndex.value!==null?e.items.value[e.activeItemIndex.value].id===i.id:!1),p=R(()=>({disabled:i.disabled,textValue:"",domRef:m}));k(()=>{var n,u;let a=(u=(n=f(m))==null?void 0:n.textContent)==null?void 0:u.toLowerCase().trim();a!==void 0&&(p.value.textValue=a)}),k(()=>e.registerItem(i.id,p)),N(()=>e.unregisterItem(i.id)),j(()=>{e.menuState.value===0&&(!o.value||e.activationTrigger.value!==0&&h(()=>{var a,n;return(n=(a=f(m))==null?void 0:a.scrollIntoView)==null?void 0:n.call(a,{block:"nearest"})}))});function s(a){if(i.disabled)return a.preventDefault();e.closeMenu(),F(f(e.buttonRef))}function r(){if(i.disabled)return e.goToItem(g.Nothing);e.goToItem(g.Specific,i.id)}function t(){i.disabled||o.value||e.goToItem(g.Specific,i.id,0)}function v(){i.disabled||!o.value||e.goToItem(g.Nothing)}return()=>{let{disabled:a}=i,n={active:o.value,disabled:a,close:e.closeMenu},{id:u,...d}=i;return T({ourProps:{id:u,ref:m,role:"menuitem",tabIndex:a===!0?void 0:-1,"aria-disabled":a===!0?!0:void 0,onClick:s,onFocus:r,onPointermove:t,onMousemove:t,onPointerleave:v,onMouseleave:v},theirProps:d,slot:n,attrs:l,slots:S,name:"MenuItem"})}}});export{ve as Menu,Ie as MenuButton,Se as MenuItem,ge as MenuItems}; | ||
import{computed as y,defineComponent as T,inject as C,nextTick as h,onMounted as K,onUnmounted as N,provide as j,ref as R,watchEffect as L}from"vue";import{useId as w}from'../../hooks/use-id.js';import{useOutsideClick as B}from'../../hooks/use-outside-click.js';import{useResolveButtonType as U}from'../../hooks/use-resolve-button-type.js';import{useTextValue as $}from'../../hooks/use-text-value.js';import{useTrackedPointer as V}from'../../hooks/use-tracked-pointer.js';import{useTreeWalker as H}from'../../hooks/use-tree-walker.js';import{State as D,useOpenClosed as Q,useOpenClosedProvider as _}from'../../internal/open-closed.js';import{Keys as c}from'../../keyboard.js';import{Focus as S,calculateActiveIndex as q}from'../../utils/calculate-active-index.js';import{dom as p}from'../../utils/dom.js';import{Focus as E,FocusableMode as W,focusFrom as J,isFocusableElement as z,restoreFocusIfNecessary as k,sortByDomNode as G}from'../../utils/focus-management.js';import{match as X}from'../../utils/match.js';import{Features as F,render as P}from'../../utils/render.js';var Y=(l=>(l[l.Open=0]="Open",l[l.Closed=1]="Closed",l))(Y||{}),Z=(l=>(l[l.Pointer=0]="Pointer",l[l.Other=1]="Other",l))(Z||{});function ee(i){requestAnimationFrame(()=>requestAnimationFrame(i))}let A=Symbol("MenuContext");function O(i){let M=C(A,null);if(M===null){let l=new Error(`<${i} /> is missing a parent <Menu /> component.`);throw Error.captureStackTrace&&Error.captureStackTrace(l,O),l}return M}let Ie=T({name:"Menu",props:{as:{type:[Object,String],default:"template"}},setup(i,{slots:M,attrs:l}){let I=R(1),e=R(null),f=R(null),s=R([]),g=R(""),d=R(null),o=R(1);function t(a=r=>r){let r=d.value!==null?s.value[d.value]:null,u=G(a(s.value.slice()),m=>p(m.dataRef.domRef)),n=r?u.indexOf(r):null;return n===-1&&(n=null),{items:u,activeItemIndex:n}}let v={menuState:I,buttonRef:e,itemsRef:f,items:s,searchQuery:g,activeItemIndex:d,activationTrigger:o,closeMenu:()=>{I.value=1,d.value=null},openMenu:()=>I.value=0,goToItem(a,r,u){let n=t(),m=q(a===S.Specific?{focus:S.Specific,id:r}:{focus:a},{resolveItems:()=>n.items,resolveActiveIndex:()=>n.activeItemIndex,resolveId:b=>b.id,resolveDisabled:b=>b.dataRef.disabled});g.value="",d.value=m,o.value=u!=null?u:1,s.value=n.items},search(a){let u=g.value!==""?0:1;g.value+=a.toLowerCase();let m=(d.value!==null?s.value.slice(d.value+u).concat(s.value.slice(0,d.value+u)):s.value).find(x=>x.dataRef.textValue.startsWith(g.value)&&!x.dataRef.disabled),b=m?s.value.indexOf(m):-1;b===-1||b===d.value||(d.value=b,o.value=1)},clearSearch(){g.value=""},registerItem(a,r){let u=t(n=>[...n,{id:a,dataRef:r}]);s.value=u.items,d.value=u.activeItemIndex,o.value=1},unregisterItem(a){let r=t(u=>{let n=u.findIndex(m=>m.id===a);return n!==-1&&u.splice(n,1),u});s.value=r.items,d.value=r.activeItemIndex,o.value=1}};return B([e,f],(a,r)=>{var u;v.closeMenu(),z(r,W.Loose)||(a.preventDefault(),(u=p(e))==null||u.focus())},y(()=>I.value===0)),j(A,v),_(y(()=>X(I.value,{[0]:D.Open,[1]:D.Closed}))),()=>{let a={open:I.value===0,close:v.closeMenu};return P({ourProps:{},theirProps:i,slot:a,slots:M,attrs:l,name:"Menu"})}}}),ge=T({name:"MenuButton",props:{disabled:{type:Boolean,default:!1},as:{type:[Object,String],default:"button"},id:{type:String,default:()=>`headlessui-menu-button-${w()}`}},setup(i,{attrs:M,slots:l,expose:I}){let e=O("MenuButton");I({el:e.buttonRef,$el:e.buttonRef});function f(o){switch(o.key){case c.Space:case c.Enter:case c.ArrowDown:o.preventDefault(),o.stopPropagation(),e.openMenu(),h(()=>{var t;(t=p(e.itemsRef))==null||t.focus({preventScroll:!0}),e.goToItem(S.First)});break;case c.ArrowUp:o.preventDefault(),o.stopPropagation(),e.openMenu(),h(()=>{var t;(t=p(e.itemsRef))==null||t.focus({preventScroll:!0}),e.goToItem(S.Last)});break}}function s(o){switch(o.key){case c.Space:o.preventDefault();break}}function g(o){i.disabled||(e.menuState.value===0?(e.closeMenu(),h(()=>{var t;return(t=p(e.buttonRef))==null?void 0:t.focus({preventScroll:!0})})):(o.preventDefault(),e.openMenu(),ee(()=>{var t;return(t=p(e.itemsRef))==null?void 0:t.focus({preventScroll:!0})})))}let d=U(y(()=>({as:i.as,type:M.type})),e.buttonRef);return()=>{var r;let o={open:e.menuState.value===0},{id:t,...v}=i,a={ref:e.buttonRef,id:t,type:d.value,"aria-haspopup":"menu","aria-controls":(r=p(e.itemsRef))==null?void 0:r.id,"aria-expanded":e.menuState.value===0,onKeydown:f,onKeyup:s,onClick:g};return P({ourProps:a,theirProps:v,slot:o,attrs:M,slots:l,name:"MenuButton"})}}}),Se=T({name:"MenuItems",props:{as:{type:[Object,String],default:"div"},static:{type:Boolean,default:!1},unmount:{type:Boolean,default:!0},id:{type:String,default:()=>`headlessui-menu-items-${w()}`}},setup(i,{attrs:M,slots:l,expose:I}){let e=O("MenuItems"),f=R(null);I({el:e.itemsRef,$el:e.itemsRef}),H({container:y(()=>p(e.itemsRef)),enabled:y(()=>e.menuState.value===0),accept(t){return t.getAttribute("role")==="menuitem"?NodeFilter.FILTER_REJECT:t.hasAttribute("role")?NodeFilter.FILTER_SKIP:NodeFilter.FILTER_ACCEPT},walk(t){t.setAttribute("role","none")}});function s(t){var v;switch(f.value&&clearTimeout(f.value),t.key){case c.Space:if(e.searchQuery.value!=="")return t.preventDefault(),t.stopPropagation(),e.search(t.key);case c.Enter:if(t.preventDefault(),t.stopPropagation(),e.activeItemIndex.value!==null){let r=e.items.value[e.activeItemIndex.value];(v=p(r.dataRef.domRef))==null||v.click()}e.closeMenu(),k(p(e.buttonRef));break;case c.ArrowDown:return t.preventDefault(),t.stopPropagation(),e.goToItem(S.Next);case c.ArrowUp:return t.preventDefault(),t.stopPropagation(),e.goToItem(S.Previous);case c.Home:case c.PageUp:return t.preventDefault(),t.stopPropagation(),e.goToItem(S.First);case c.End:case c.PageDown:return t.preventDefault(),t.stopPropagation(),e.goToItem(S.Last);case c.Escape:t.preventDefault(),t.stopPropagation(),e.closeMenu(),h(()=>{var a;return(a=p(e.buttonRef))==null?void 0:a.focus({preventScroll:!0})});break;case c.Tab:t.preventDefault(),t.stopPropagation(),e.closeMenu(),h(()=>J(p(e.buttonRef),t.shiftKey?E.Previous:E.Next));break;default:t.key.length===1&&(e.search(t.key),f.value=setTimeout(()=>e.clearSearch(),350));break}}function g(t){switch(t.key){case c.Space:t.preventDefault();break}}let d=Q(),o=y(()=>d!==null?(d.value&D.Open)===D.Open:e.menuState.value===0);return()=>{var u,n;let t={open:e.menuState.value===0},{id:v,...a}=i,r={"aria-activedescendant":e.activeItemIndex.value===null||(u=e.items.value[e.activeItemIndex.value])==null?void 0:u.id,"aria-labelledby":(n=p(e.buttonRef))==null?void 0:n.id,id:v,onKeydown:s,onKeyup:g,role:"menu",tabIndex:0,ref:e.itemsRef};return P({ourProps:r,theirProps:a,slot:t,attrs:M,slots:l,features:F.RenderStrategy|F.Static,visible:o.value,name:"MenuItems"})}}}),Me=T({name:"MenuItem",inheritAttrs:!1,props:{as:{type:[Object,String],default:"template"},disabled:{type:Boolean,default:!1},id:{type:String,default:()=>`headlessui-menu-item-${w()}`}},setup(i,{slots:M,attrs:l,expose:I}){let e=O("MenuItem"),f=R(null);I({el:f,$el:f});let s=y(()=>e.activeItemIndex.value!==null?e.items.value[e.activeItemIndex.value].id===i.id:!1),g=$(f),d=y(()=>({disabled:i.disabled,get textValue(){return g()},domRef:f}));K(()=>e.registerItem(i.id,d)),N(()=>e.unregisterItem(i.id)),L(()=>{e.menuState.value===0&&s.value&&e.activationTrigger.value!==0&&h(()=>{var n,m;return(m=(n=p(f))==null?void 0:n.scrollIntoView)==null?void 0:m.call(n,{block:"nearest"})})});function o(n){if(i.disabled)return n.preventDefault();e.closeMenu(),k(p(e.buttonRef))}function t(){if(i.disabled)return e.goToItem(S.Nothing);e.goToItem(S.Specific,i.id)}let v=V();function a(n){v.update(n)}function r(n){v.wasMoved(n)&&(i.disabled||s.value||e.goToItem(S.Specific,i.id,0))}function u(n){v.wasMoved(n)&&(i.disabled||s.value&&e.goToItem(S.Nothing))}return()=>{let{id:n,disabled:m,...b}=i,x={active:s.value,disabled:m,close:e.closeMenu};return P({ourProps:{id:n,ref:f,role:"menuitem",tabIndex:m===!0?void 0:-1,"aria-disabled":m===!0?!0:void 0,onClick:o,onFocus:t,onPointerenter:a,onMouseenter:a,onPointermove:r,onMousemove:r,onPointerleave:u,onMouseleave:u},theirProps:{...l,...b},slot:x,attrs:l,slots:M,name:"MenuItem"})}}});export{Ie as Menu,ge as MenuButton,Me as MenuItem,Se as MenuItems}; |
@@ -8,5 +8,3 @@ export declare let Popover: import("vue").DefineComponent<{ | ||
[key: string]: any; | ||
}> | import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, { | ||
[key: string]: any; | ||
}>[] | null, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, Record<string, any>, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{ | ||
}>, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, Record<string, any>, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{ | ||
as: { | ||
@@ -48,5 +46,5 @@ type: (ObjectConstructor | StringConstructor)[]; | ||
}>>, { | ||
id: string; | ||
as: string | Record<string, any>; | ||
disabled: boolean; | ||
id: string; | ||
}>; | ||
@@ -135,7 +133,7 @@ export declare let PopoverOverlay: import("vue").DefineComponent<{ | ||
}>>, { | ||
focus: boolean; | ||
id: string; | ||
as: string | Record<string, any>; | ||
unmount: boolean; | ||
static: boolean; | ||
id: string; | ||
focus: boolean; | ||
}>; | ||
@@ -149,5 +147,3 @@ export declare let PopoverGroup: import("vue").DefineComponent<{ | ||
[key: string]: any; | ||
}> | import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, { | ||
[key: string]: any; | ||
}>[] | null, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, Record<string, any>, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{ | ||
}>, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, Record<string, any>, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{ | ||
as: { | ||
@@ -154,0 +150,0 @@ type: (ObjectConstructor | StringConstructor)[]; |
@@ -1,1 +0,1 @@ | ||
import{Fragment as Q,computed as O,defineComponent as L,h as H,inject as V,provide as _,ref as T,shallowRef as ae,watchEffect as U,onMounted as X,onUnmounted as Y}from"vue";import{match as K}from'../../utils/match.js';import{render as $,Features as G}from'../../utils/render.js';import{useId as M}from'../../hooks/use-id.js';import{Keys as F}from'../../keyboard.js';import{getFocusableElements as Z,Focus as R,focusIn as x,isFocusableElement as ue,FocusableMode as ie}from'../../utils/focus-management.js';import{dom as l}from'../../utils/dom.js';import{useOpenClosedProvider as se,State as N,useOpenClosed as ee}from'../../internal/open-closed.js';import{useResolveButtonType as pe}from'../../hooks/use-resolve-button-type.js';import{useOutsideClick as fe}from'../../hooks/use-outside-click.js';import{getOwnerDocument as W}from'../../utils/owner.js';import{useEventListener as ve}from'../../hooks/use-event-listener.js';import{Hidden as q,Features as z}from'../../internal/hidden.js';import{useTabDirection as te,Direction as k}from'../../hooks/use-tab-direction.js';import'../../utils/micro-task.js';var ce=(p=>(p[p.Open=0]="Open",p[p.Closed=1]="Closed",p))(ce||{});let oe=Symbol("PopoverContext");function A(c){let m=V(oe,null);if(m===null){let p=new Error(`<${c} /> is missing a parent <${Pe.name} /> component.`);throw Error.captureStackTrace&&Error.captureStackTrace(p,A),p}return m}let ne=Symbol("PopoverGroupContext");function le(){return V(ne,null)}let re=Symbol("PopoverPanelContext");function de(){return V(re,null)}let Pe=L({name:"Popover",props:{as:{type:[Object,String],default:"div"}},setup(c,{slots:m,attrs:p,expose:y}){var n;let o=T(null);y({el:o,$el:o});let e=T(1),f=T(null),d=T(null),I=T(null),s=T(null),b=O(()=>W(o)),P=O(()=>{var h,w;if(!l(f)||!l(s))return!1;for(let C of document.querySelectorAll("body > *"))if(Number(C==null?void 0:C.contains(l(f)))^Number(C==null?void 0:C.contains(l(s))))return!0;let t=Z(),r=t.indexOf(l(f)),u=(r+t.length-1)%t.length,v=(r+1)%t.length,S=t[u],j=t[v];return!((h=l(s))!=null&&h.contains(S))&&!((w=l(s))!=null&&w.contains(j))}),a={popoverState:e,buttonId:T(null),panelId:T(null),panel:s,button:f,isPortalled:P,beforePanelSentinel:d,afterPanelSentinel:I,togglePopover(){e.value=K(e.value,{[0]:1,[1]:0})},closePopover(){e.value!==1&&(e.value=1)},close(t){a.closePopover();let r=(()=>t?t instanceof HTMLElement?t:t.value instanceof HTMLElement?l(t):l(a.button):l(a.button))();r==null||r.focus()}};_(oe,a),se(O(()=>K(e.value,{[0]:N.Open,[1]:N.Closed})));let D={buttonId:a.buttonId,panelId:a.panelId,close(){a.closePopover()}},g=le(),E=g==null?void 0:g.registerPopover;function i(){var t,r,u,v;return(v=g==null?void 0:g.isFocusWithinPopoverGroup())!=null?v:((t=b.value)==null?void 0:t.activeElement)&&(((r=l(f))==null?void 0:r.contains(b.value.activeElement))||((u=l(s))==null?void 0:u.contains(b.value.activeElement)))}return U(()=>E==null?void 0:E(D)),ve((n=b.value)==null?void 0:n.defaultView,"focus",t=>{var r,u;e.value===0&&(i()||!f||!s||t.target!==window&&((r=l(a.beforePanelSentinel))!=null&&r.contains(t.target)||(u=l(a.afterPanelSentinel))!=null&&u.contains(t.target)||a.closePopover()))},!0),fe([f,s],(t,r)=>{var u;a.closePopover(),ue(r,ie.Loose)||(t.preventDefault(),(u=l(f))==null||u.focus())},O(()=>e.value===0)),()=>{let t={open:e.value===0,close:a.close};return $({theirProps:c,ourProps:{ref:o},slot:t,slots:m,attrs:p,name:"Popover"})}}}),Be=L({name:"PopoverButton",props:{as:{type:[Object,String],default:"button"},disabled:{type:[Boolean],default:!1},id:{type:String,default:()=>`headlessui-popover-button-${M()}`}},inheritAttrs:!1,setup(c,{attrs:m,slots:p,expose:y}){let o=A("PopoverButton"),e=O(()=>W(o.button));y({el:o.button,$el:o.button}),X(()=>{o.buttonId.value=c.id}),Y(()=>{o.buttonId.value=null});let f=le(),d=f==null?void 0:f.closeOthers,I=de(),s=O(()=>I===null?!1:I.value===o.panelId.value),b=T(null),P=`headlessui-focus-sentinel-${M()}`;s.value||U(()=>{o.button.value=b.value});let a=pe(O(()=>({as:c.as,type:m.type})),b);function D(n){var t,r,u,v,S;if(s.value){if(o.popoverState.value===1)return;switch(n.key){case F.Space:case F.Enter:n.preventDefault(),(r=(t=n.target).click)==null||r.call(t),o.closePopover(),(u=l(o.button))==null||u.focus();break}}else switch(n.key){case F.Space:case F.Enter:n.preventDefault(),n.stopPropagation(),o.popoverState.value===1&&(d==null||d(o.buttonId.value)),o.togglePopover();break;case F.Escape:if(o.popoverState.value!==0)return d==null?void 0:d(o.buttonId.value);if(!l(o.button)||((v=e.value)==null?void 0:v.activeElement)&&!((S=l(o.button))!=null&&S.contains(e.value.activeElement)))return;n.preventDefault(),n.stopPropagation(),o.closePopover();break}}function g(n){s.value||n.key===F.Space&&n.preventDefault()}function E(n){var t,r;c.disabled||(s.value?(o.closePopover(),(t=l(o.button))==null||t.focus()):(n.preventDefault(),n.stopPropagation(),o.popoverState.value===1&&(d==null||d(o.buttonId.value)),o.togglePopover(),(r=l(o.button))==null||r.focus()))}function i(n){n.preventDefault(),n.stopPropagation()}return()=>{let n=o.popoverState.value===0,t={open:n},{id:r,...u}=c,v=s.value?{ref:b,type:a.value,onKeydown:D,onClick:E}:{ref:b,id:r,type:a.value,"aria-expanded":c.disabled?void 0:o.popoverState.value===0,"aria-controls":l(o.panel)?o.panelId.value:void 0,disabled:c.disabled?!0:void 0,onKeydown:D,onKeyup:g,onClick:E,onMousedown:i},S=te();function j(){let h=l(o.panel);if(!h)return;function w(){K(S.value,{[k.Forwards]:()=>x(h,R.First),[k.Backwards]:()=>x(h,R.Last)})}w()}return H(Q,[$({ourProps:v,theirProps:{...m,...u},slot:t,attrs:m,slots:p,name:"PopoverButton"}),n&&!s.value&&o.isPortalled.value&&H(q,{id:P,features:z.Focusable,as:"button",type:"button",onFocus:j})])}}}),Le=L({name:"PopoverOverlay",props:{as:{type:[Object,String],default:"div"},static:{type:Boolean,default:!1},unmount:{type:Boolean,default:!0}},setup(c,{attrs:m,slots:p}){let y=A("PopoverOverlay"),o=`headlessui-popover-overlay-${M()}`,e=ee(),f=O(()=>e!==null?e.value===N.Open:y.popoverState.value===0);function d(){y.closePopover()}return()=>{let I={open:y.popoverState.value===0};return $({ourProps:{id:o,"aria-hidden":!0,onClick:d},theirProps:c,slot:I,attrs:m,slots:p,features:G.RenderStrategy|G.Static,visible:f.value,name:"PopoverOverlay"})}}}),He=L({name:"PopoverPanel",props:{as:{type:[Object,String],default:"div"},static:{type:Boolean,default:!1},unmount:{type:Boolean,default:!0},focus:{type:Boolean,default:!1},id:{type:String,default:()=>`headlessui-popover-panel-${M()}`}},inheritAttrs:!1,setup(c,{attrs:m,slots:p,expose:y}){let{focus:o}=c,e=A("PopoverPanel"),f=O(()=>W(e.panel)),d=`headlessui-focus-sentinel-before-${M()}`,I=`headlessui-focus-sentinel-after-${M()}`;y({el:e.panel,$el:e.panel}),X(()=>{e.panelId.value=c.id}),Y(()=>{e.panelId.value=null}),_(re,e.panelId),U(()=>{var n,t;if(!o||e.popoverState.value!==0||!e.panel)return;let i=(n=f.value)==null?void 0:n.activeElement;(t=l(e.panel))!=null&&t.contains(i)||x(l(e.panel),R.First)});let s=ee(),b=O(()=>s!==null?s.value===N.Open:e.popoverState.value===0);function P(i){var n,t;switch(i.key){case F.Escape:if(e.popoverState.value!==0||!l(e.panel)||f.value&&!((n=l(e.panel))!=null&&n.contains(f.value.activeElement)))return;i.preventDefault(),i.stopPropagation(),e.closePopover(),(t=l(e.button))==null||t.focus();break}}function a(i){var t,r,u,v,S;let n=i.relatedTarget;!n||!l(e.panel)||(t=l(e.panel))!=null&&t.contains(n)||(e.closePopover(),(((u=(r=l(e.beforePanelSentinel))==null?void 0:r.contains)==null?void 0:u.call(r,n))||((S=(v=l(e.afterPanelSentinel))==null?void 0:v.contains)==null?void 0:S.call(v,n)))&&n.focus({preventScroll:!0}))}let D=te();function g(){let i=l(e.panel);if(!i)return;function n(){K(D.value,{[k.Forwards]:()=>{x(i,R.Next)},[k.Backwards]:()=>{var t;(t=l(e.button))==null||t.focus({preventScroll:!0})}})}n()}function E(){let i=l(e.panel);if(!i)return;function n(){K(D.value,{[k.Forwards]:()=>{var w,C;let t=l(e.button),r=l(e.panel);if(!t)return;let u=Z(),v=u.indexOf(t),S=u.slice(0,v+1),h=[...u.slice(v+1),...S];for(let B of h.slice())if(((C=(w=B==null?void 0:B.id)==null?void 0:w.startsWith)==null?void 0:C.call(w,"headlessui-focus-sentinel-"))||(r==null?void 0:r.contains(B))){let J=h.indexOf(B);J!==-1&&h.splice(J,1)}x(h,R.First,!1)},[k.Backwards]:()=>x(i,R.Previous)})}n()}return()=>{let i={open:e.popoverState.value===0,close:e.close},{id:n,focus:t,...r}=c,u={ref:e.panel,id:n,onKeydown:P,onFocusout:o&&e.popoverState.value===0?a:void 0,tabIndex:-1};return $({ourProps:u,theirProps:{...m,...r},attrs:m,slot:i,slots:{...p,default:(...v)=>{var S;return[H(Q,[b.value&&e.isPortalled.value&&H(q,{id:d,ref:e.beforePanelSentinel,features:z.Focusable,as:"button",type:"button",onFocus:g}),(S=p.default)==null?void 0:S.call(p,...v),b.value&&e.isPortalled.value&&H(q,{id:I,ref:e.afterPanelSentinel,features:z.Focusable,as:"button",type:"button",onFocus:E})])]}},features:G.RenderStrategy|G.Static,visible:b.value,name:"PopoverPanel"})}}}),Ke=L({name:"PopoverGroup",props:{as:{type:[Object,String],default:"div"}},setup(c,{attrs:m,slots:p,expose:y}){let o=T(null),e=ae([]),f=O(()=>W(o));y({el:o,$el:o});function d(P){let a=e.value.indexOf(P);a!==-1&&e.value.splice(a,1)}function I(P){return e.value.push(P),()=>{d(P)}}function s(){var D;let P=f.value;if(!P)return!1;let a=P.activeElement;return(D=l(o))!=null&&D.contains(a)?!0:e.value.some(g=>{var E,i;return((E=P.getElementById(g.buttonId.value))==null?void 0:E.contains(a))||((i=P.getElementById(g.panelId.value))==null?void 0:i.contains(a))})}function b(P){for(let a of e.value)a.buttonId.value!==P&&a.close()}return _(ne,{registerPopover:I,unregisterPopover:d,isFocusWithinPopoverGroup:s,closeOthers:b}),()=>$({ourProps:{ref:o},theirProps:c,slot:{},attrs:m,slots:p,name:"PopoverGroup"})}});export{Pe as Popover,Be as PopoverButton,Ke as PopoverGroup,Le as PopoverOverlay,He as PopoverPanel}; | ||
import{Fragment as j,computed as T,defineComponent as K,h as R,inject as _,onMounted as ee,onUnmounted as te,provide as U,ref as F,shallowRef as ie,watchEffect as q}from"vue";import{useNestedPortals as se}from'../../components/portal/portal.js';import{useEventListener as pe}from'../../hooks/use-event-listener.js';import{useId as L}from'../../hooks/use-id.js';import{useOutsideClick as fe}from'../../hooks/use-outside-click.js';import{useResolveButtonType as ve}from'../../hooks/use-resolve-button-type.js';import{useMainTreeNode as ce,useRootContainers as de}from'../../hooks/use-root-containers.js';import{Direction as w,useTabDirection as oe}from'../../hooks/use-tab-direction.js';import{Hidden as z,Features as J}from'../../internal/hidden.js';import{State as x,useOpenClosed as ne,useOpenClosedProvider as Pe}from'../../internal/open-closed.js';import{Keys as D}from'../../keyboard.js';import{dom as r}from'../../utils/dom.js';import{Focus as C,FocusResult as Q,FocusableMode as me,focusIn as B,getFocusableElements as X,isFocusableElement as be}from'../../utils/focus-management.js';import{match as H}from'../../utils/match.js';import'../../utils/micro-task.js';import{getOwnerDocument as A}from'../../utils/owner.js';import{Features as W,render as G}from'../../utils/render.js';var Se=(p=>(p[p.Open=0]="Open",p[p.Closed=1]="Closed",p))(Se||{});let re=Symbol("PopoverContext");function V(P){let b=_(re,null);if(b===null){let p=new Error(`<${P} /> is missing a parent <${ye.name} /> component.`);throw Error.captureStackTrace&&Error.captureStackTrace(p,V),p}return b}let le=Symbol("PopoverGroupContext");function ae(){return _(le,null)}let ue=Symbol("PopoverPanelContext");function ge(){return _(ue,null)}let ye=K({name:"Popover",inheritAttrs:!1,props:{as:{type:[Object,String],default:"div"}},setup(P,{slots:b,attrs:p,expose:h}){var v;let t=F(null);h({el:t,$el:t});let e=F(1),c=F(null),d=F(null),O=F(null),f=F(null),y=T(()=>A(t)),M=T(()=>{var Y,Z;if(!r(c)||!r(f))return!1;for(let k of document.querySelectorAll("body > *"))if(Number(k==null?void 0:k.contains(r(c)))^Number(k==null?void 0:k.contains(r(f))))return!0;let o=X(),a=o.indexOf(r(c)),g=(a+o.length-1)%o.length,E=(a+1)%o.length,N=o[g],$=o[E];return!((Y=r(f))!=null&&Y.contains(N))&&!((Z=r(f))!=null&&Z.contains($))}),l={popoverState:e,buttonId:F(null),panelId:F(null),panel:f,button:c,isPortalled:M,beforePanelSentinel:d,afterPanelSentinel:O,togglePopover(){e.value=H(e.value,{[0]:1,[1]:0})},closePopover(){e.value!==1&&(e.value=1)},close(o){l.closePopover();let a=(()=>o?o instanceof HTMLElement?o:o.value instanceof HTMLElement?r(o):r(l.button):r(l.button))();a==null||a.focus()}};U(re,l),Pe(T(()=>H(e.value,{[0]:x.Open,[1]:x.Closed})));let m={buttonId:l.buttonId,panelId:l.panelId,close(){l.closePopover()}},S=ae(),I=S==null?void 0:S.registerPopover,[s,u]=se(),i=de({mainTreeNodeRef:S==null?void 0:S.mainTreeNodeRef,portals:s,defaultContainers:[c,f]});function n(){var o,a,g,E;return(E=S==null?void 0:S.isFocusWithinPopoverGroup())!=null?E:((o=y.value)==null?void 0:o.activeElement)&&(((a=r(c))==null?void 0:a.contains(y.value.activeElement))||((g=r(f))==null?void 0:g.contains(y.value.activeElement)))}return q(()=>I==null?void 0:I(m)),pe((v=y.value)==null?void 0:v.defaultView,"focus",o=>{var a,g;o.target!==window&&o.target instanceof HTMLElement&&e.value===0&&(n()||c&&f&&(i.contains(o.target)||(a=r(l.beforePanelSentinel))!=null&&a.contains(o.target)||(g=r(l.afterPanelSentinel))!=null&&g.contains(o.target)||l.closePopover()))},!0),fe(i.resolveContainers,(o,a)=>{var g;l.closePopover(),be(a,me.Loose)||(o.preventDefault(),(g=r(c))==null||g.focus())},T(()=>e.value===0)),()=>{let o={open:e.value===0,close:l.close};return R(j,[R(u,{},()=>G({theirProps:{...P,...p},ourProps:{ref:t},slot:o,slots:b,attrs:p,name:"Popover"})),R(i.MainTreeNode)])}}}),Ge=K({name:"PopoverButton",props:{as:{type:[Object,String],default:"button"},disabled:{type:[Boolean],default:!1},id:{type:String,default:()=>`headlessui-popover-button-${L()}`}},inheritAttrs:!1,setup(P,{attrs:b,slots:p,expose:h}){let t=V("PopoverButton"),e=T(()=>A(t.button));h({el:t.button,$el:t.button}),ee(()=>{t.buttonId.value=P.id}),te(()=>{t.buttonId.value=null});let c=ae(),d=c==null?void 0:c.closeOthers,O=ge(),f=T(()=>O===null?!1:O.value===t.panelId.value),y=F(null),M=`headlessui-focus-sentinel-${L()}`;f.value||q(()=>{t.button.value=r(y)});let l=ve(T(()=>({as:P.as,type:b.type})),y);function m(n){var v,o,a,g,E;if(f.value){if(t.popoverState.value===1)return;switch(n.key){case D.Space:case D.Enter:n.preventDefault(),(o=(v=n.target).click)==null||o.call(v),t.closePopover(),(a=r(t.button))==null||a.focus();break}}else switch(n.key){case D.Space:case D.Enter:n.preventDefault(),n.stopPropagation(),t.popoverState.value===1&&(d==null||d(t.buttonId.value)),t.togglePopover();break;case D.Escape:if(t.popoverState.value!==0)return d==null?void 0:d(t.buttonId.value);if(!r(t.button)||(g=e.value)!=null&&g.activeElement&&!((E=r(t.button))!=null&&E.contains(e.value.activeElement)))return;n.preventDefault(),n.stopPropagation(),t.closePopover();break}}function S(n){f.value||n.key===D.Space&&n.preventDefault()}function I(n){var v,o;P.disabled||(f.value?(t.closePopover(),(v=r(t.button))==null||v.focus()):(n.preventDefault(),n.stopPropagation(),t.popoverState.value===1&&(d==null||d(t.buttonId.value)),t.togglePopover(),(o=r(t.button))==null||o.focus()))}function s(n){n.preventDefault(),n.stopPropagation()}let u=oe();function i(){let n=r(t.panel);if(!n)return;function v(){H(u.value,{[w.Forwards]:()=>B(n,C.First),[w.Backwards]:()=>B(n,C.Last)})===Q.Error&&B(X().filter(a=>a.dataset.headlessuiFocusGuard!=="true"),H(u.value,{[w.Forwards]:C.Next,[w.Backwards]:C.Previous}),{relativeTo:r(t.button)})}v()}return()=>{let n=t.popoverState.value===0,v={open:n},{id:o,...a}=P,g=f.value?{ref:y,type:l.value,onKeydown:m,onClick:I}:{ref:y,id:o,type:l.value,"aria-expanded":t.popoverState.value===0,"aria-controls":r(t.panel)?t.panelId.value:void 0,disabled:P.disabled?!0:void 0,onKeydown:m,onKeyup:S,onClick:I,onMousedown:s};return R(j,[G({ourProps:g,theirProps:{...b,...a},slot:v,attrs:b,slots:p,name:"PopoverButton"}),n&&!f.value&&t.isPortalled.value&&R(z,{id:M,features:J.Focusable,"data-headlessui-focus-guard":!0,as:"button",type:"button",onFocus:i})])}}}),$e=K({name:"PopoverOverlay",props:{as:{type:[Object,String],default:"div"},static:{type:Boolean,default:!1},unmount:{type:Boolean,default:!0}},setup(P,{attrs:b,slots:p}){let h=V("PopoverOverlay"),t=`headlessui-popover-overlay-${L()}`,e=ne(),c=T(()=>e!==null?(e.value&x.Open)===x.Open:h.popoverState.value===0);function d(){h.closePopover()}return()=>{let O={open:h.popoverState.value===0};return G({ourProps:{id:t,"aria-hidden":!0,onClick:d},theirProps:P,slot:O,attrs:b,slots:p,features:W.RenderStrategy|W.Static,visible:c.value,name:"PopoverOverlay"})}}}),je=K({name:"PopoverPanel",props:{as:{type:[Object,String],default:"div"},static:{type:Boolean,default:!1},unmount:{type:Boolean,default:!0},focus:{type:Boolean,default:!1},id:{type:String,default:()=>`headlessui-popover-panel-${L()}`}},inheritAttrs:!1,setup(P,{attrs:b,slots:p,expose:h}){let{focus:t}=P,e=V("PopoverPanel"),c=T(()=>A(e.panel)),d=`headlessui-focus-sentinel-before-${L()}`,O=`headlessui-focus-sentinel-after-${L()}`;h({el:e.panel,$el:e.panel}),ee(()=>{e.panelId.value=P.id}),te(()=>{e.panelId.value=null}),U(ue,e.panelId),q(()=>{var u,i;if(!t||e.popoverState.value!==0||!e.panel)return;let s=(u=c.value)==null?void 0:u.activeElement;(i=r(e.panel))!=null&&i.contains(s)||B(r(e.panel),C.First)});let f=ne(),y=T(()=>f!==null?(f.value&x.Open)===x.Open:e.popoverState.value===0);function M(s){var u,i;switch(s.key){case D.Escape:if(e.popoverState.value!==0||!r(e.panel)||c.value&&!((u=r(e.panel))!=null&&u.contains(c.value.activeElement)))return;s.preventDefault(),s.stopPropagation(),e.closePopover(),(i=r(e.button))==null||i.focus();break}}function l(s){var i,n,v,o,a;let u=s.relatedTarget;u&&r(e.panel)&&((i=r(e.panel))!=null&&i.contains(u)||(e.closePopover(),((v=(n=r(e.beforePanelSentinel))==null?void 0:n.contains)!=null&&v.call(n,u)||(a=(o=r(e.afterPanelSentinel))==null?void 0:o.contains)!=null&&a.call(o,u))&&u.focus({preventScroll:!0})))}let m=oe();function S(){let s=r(e.panel);if(!s)return;function u(){H(m.value,{[w.Forwards]:()=>{var n;B(s,C.First)===Q.Error&&((n=r(e.afterPanelSentinel))==null||n.focus())},[w.Backwards]:()=>{var i;(i=r(e.button))==null||i.focus({preventScroll:!0})}})}u()}function I(){let s=r(e.panel);if(!s)return;function u(){H(m.value,{[w.Forwards]:()=>{let i=r(e.button),n=r(e.panel);if(!i)return;let v=X(),o=v.indexOf(i),a=v.slice(0,o+1),E=[...v.slice(o+1),...a];for(let N of E.slice())if(N.dataset.headlessuiFocusGuard==="true"||n!=null&&n.contains(N)){let $=E.indexOf(N);$!==-1&&E.splice($,1)}B(E,C.First,{sorted:!1})},[w.Backwards]:()=>{var n;B(s,C.Previous)===Q.Error&&((n=r(e.button))==null||n.focus())}})}u()}return()=>{let s={open:e.popoverState.value===0,close:e.close},{id:u,focus:i,...n}=P,v={ref:e.panel,id:u,onKeydown:M,onFocusout:t&&e.popoverState.value===0?l:void 0,tabIndex:-1};return G({ourProps:v,theirProps:{...b,...n},attrs:b,slot:s,slots:{...p,default:(...o)=>{var a;return[R(j,[y.value&&e.isPortalled.value&&R(z,{id:d,ref:e.beforePanelSentinel,features:J.Focusable,"data-headlessui-focus-guard":!0,as:"button",type:"button",onFocus:S}),(a=p.default)==null?void 0:a.call(p,...o),y.value&&e.isPortalled.value&&R(z,{id:O,ref:e.afterPanelSentinel,features:J.Focusable,"data-headlessui-focus-guard":!0,as:"button",type:"button",onFocus:I})])]}},features:W.RenderStrategy|W.Static,visible:y.value,name:"PopoverPanel"})}}}),Ae=K({name:"PopoverGroup",inheritAttrs:!1,props:{as:{type:[Object,String],default:"div"}},setup(P,{attrs:b,slots:p,expose:h}){let t=F(null),e=ie([]),c=T(()=>A(t)),d=ce();h({el:t,$el:t});function O(l){let m=e.value.indexOf(l);m!==-1&&e.value.splice(m,1)}function f(l){return e.value.push(l),()=>{O(l)}}function y(){var S;let l=c.value;if(!l)return!1;let m=l.activeElement;return(S=r(t))!=null&&S.contains(m)?!0:e.value.some(I=>{var s,u;return((s=l.getElementById(I.buttonId.value))==null?void 0:s.contains(m))||((u=l.getElementById(I.panelId.value))==null?void 0:u.contains(m))})}function M(l){for(let m of e.value)m.buttonId.value!==l&&m.close()}return U(le,{registerPopover:f,unregisterPopover:O,isFocusWithinPopoverGroup:y,closeOthers:M,mainTreeNodeRef:d.mainTreeNodeRef}),()=>R(j,[G({ourProps:{ref:t},theirProps:{...P,...b},slot:{},attrs:b,slots:p,name:"PopoverGroup"}),R(d.MainTreeNode)])}});export{ye as Popover,Ge as PopoverButton,Ae as PopoverGroup,$e as PopoverOverlay,je as PopoverPanel}; |
@@ -1,2 +0,2 @@ | ||
import { PropType } from 'vue'; | ||
import { type PropType, type Ref } from 'vue'; | ||
export declare let Portal: import("vue").DefineComponent<{ | ||
@@ -17,2 +17,5 @@ as: { | ||
}>; | ||
export declare function useNestedPortals(): readonly [Ref<HTMLElement[]>, import("vue").DefineComponent<{}, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, { | ||
[key: string]: any; | ||
}>[] | undefined, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, import("vue").EmitsOptions, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{}>>, {}>]; | ||
export declare let PortalGroup: import("vue").DefineComponent<{ | ||
@@ -19,0 +22,0 @@ as: { |
@@ -1,1 +0,1 @@ | ||
import{Teleport as P,defineComponent as s,h,inject as y,onUnmounted as T,provide as E,reactive as w,ref as d,watchEffect as C,computed as b}from"vue";import{render as f}from'../../utils/render.js';import{usePortalRoot as j}from'../../internal/portal-force-root.js';import{getOwnerDocument as v}from'../../utils/owner.js';function c(t){let r=v(t);if(!r){if(t===null)return null;throw new Error(`[Headless UI]: Cannot find ownerDocument for contextElement: ${t}`)}let o=r.getElementById("headlessui-portal-root");if(o)return o;let e=r.createElement("div");return e.setAttribute("id","headlessui-portal-root"),r.body.appendChild(e)}let R=s({name:"Portal",props:{as:{type:[Object,String],default:"div"}},setup(t,{slots:r,attrs:o}){let e=d(null),p=b(()=>v(e)),n=j(),u=y(g,null),l=d(n===!0||u==null?c(e.value):u.resolveTarget());return C(()=>{n||u!=null&&(l.value=u.resolveTarget())}),T(()=>{var i,m;let a=(i=p.value)==null?void 0:i.getElementById("headlessui-portal-root");!a||l.value===a&&l.value.children.length<=0&&((m=l.value.parentElement)==null||m.removeChild(l.value))}),()=>{if(l.value===null)return null;let a={ref:e,"data-headlessui-portal":""};return h(P,{to:l.value},f({ourProps:a,theirProps:t,slot:{},attrs:o,slots:r,name:"Portal"}))}}}),g=Symbol("PortalGroupContext"),L=s({name:"PortalGroup",props:{as:{type:[Object,String],default:"template"},target:{type:Object,default:null}},setup(t,{attrs:r,slots:o}){let e=w({resolveTarget(){return t.target}});return E(g,e),()=>{let{target:p,...n}=t;return f({theirProps:n,ourProps:{},slot:{},attrs:r,slots:o,name:"PortalGroup"})}}});export{R as Portal,L as PortalGroup}; | ||
import{Teleport as M,computed as L,defineComponent as s,getCurrentInstance as j,h as w,inject as f,onMounted as I,onUnmounted as y,provide as T,reactive as b,ref as p,watch as R,watchEffect as G}from"vue";import{usePortalRoot as O}from'../../internal/portal-force-root.js';import{dom as D}from'../../utils/dom.js';import{getOwnerDocument as E}from'../../utils/owner.js';import{render as h}from'../../utils/render.js';function x(r){let e=E(r);if(!e){if(r===null)return null;throw new Error(`[Headless UI]: Cannot find ownerDocument for contextElement: ${r}`)}let u=e.getElementById("headlessui-portal-root");if(u)return u;let t=e.createElement("div");return t.setAttribute("id","headlessui-portal-root"),e.body.appendChild(t)}let _=s({name:"Portal",props:{as:{type:[Object,String],default:"div"}},setup(r,{slots:e,attrs:u}){let t=p(null),i=L(()=>E(t)),l=O(),n=f(C,null),o=p(l===!0||n==null?x(t.value):n.resolveTarget()),d=p(!1);I(()=>{d.value=!0}),G(()=>{l||n!=null&&(o.value=n.resolveTarget())});let c=f(m,null),v=!1,H=j();return R(t,()=>{if(v||!c)return;let a=D(t);a&&(y(c.register(a),H),v=!0)}),y(()=>{var g,P;let a=(g=i.value)==null?void 0:g.getElementById("headlessui-portal-root");a&&o.value===a&&o.value.children.length<=0&&((P=o.value.parentElement)==null||P.removeChild(o.value))}),()=>{if(!d.value||o.value===null)return null;let a={ref:t,"data-headlessui-portal":""};return w(M,{to:o.value},h({ourProps:a,theirProps:r,slot:{},attrs:u,slots:e,name:"Portal"}))}}}),m=Symbol("PortalParentContext");function A(){let r=f(m,null),e=p([]);function u(l){return e.value.push(l),r&&r.register(l),()=>t(l)}function t(l){let n=e.value.indexOf(l);n!==-1&&e.value.splice(n,1),r&&r.unregister(l)}let i={register:u,unregister:t,portals:e};return[e,s({name:"PortalWrapper",setup(l,{slots:n}){return T(m,i),()=>{var o;return(o=n.default)==null?void 0:o.call(n)}}})]}let C=Symbol("PortalGroupContext"),N=s({name:"PortalGroup",props:{as:{type:[Object,String],default:"template"},target:{type:Object,default:null}},setup(r,{attrs:e,slots:u}){let t=b({resolveTarget(){return r.target}});return T(C,t),()=>{let{target:i,...l}=r;return h({theirProps:l,ourProps:{},slot:{},attrs:e,slots:u,name:"PortalGroup"})}}});export{_ as Portal,N as PortalGroup,A as useNestedPortals}; |
@@ -16,9 +16,13 @@ declare function defaultComparator<T>(a: T, z: T): boolean; | ||
modelValue: { | ||
type: (ObjectConstructor | BooleanConstructor | StringConstructor | NumberConstructor)[]; | ||
type: (ObjectConstructor | NumberConstructor | BooleanConstructor | StringConstructor)[]; | ||
default: undefined; | ||
}; | ||
defaultValue: { | ||
type: (ObjectConstructor | BooleanConstructor | StringConstructor | NumberConstructor)[]; | ||
type: (ObjectConstructor | NumberConstructor | BooleanConstructor | StringConstructor)[]; | ||
default: undefined; | ||
}; | ||
form: { | ||
type: StringConstructor; | ||
optional: boolean; | ||
}; | ||
name: { | ||
@@ -50,9 +54,13 @@ type: StringConstructor; | ||
modelValue: { | ||
type: (ObjectConstructor | BooleanConstructor | StringConstructor | NumberConstructor)[]; | ||
type: (ObjectConstructor | NumberConstructor | BooleanConstructor | StringConstructor)[]; | ||
default: undefined; | ||
}; | ||
defaultValue: { | ||
type: (ObjectConstructor | BooleanConstructor | StringConstructor | NumberConstructor)[]; | ||
type: (ObjectConstructor | NumberConstructor | BooleanConstructor | StringConstructor)[]; | ||
default: undefined; | ||
}; | ||
form: { | ||
type: StringConstructor; | ||
optional: boolean; | ||
}; | ||
name: { | ||
@@ -69,5 +77,5 @@ type: StringConstructor; | ||
}, { | ||
id: string; | ||
as: string | Record<string, any>; | ||
disabled: boolean; | ||
id: string; | ||
by: string | Function; | ||
@@ -83,3 +91,3 @@ modelValue: string | number | boolean | Record<string, any>; | ||
value: { | ||
type: (ObjectConstructor | BooleanConstructor | StringConstructor | NumberConstructor)[]; | ||
type: (ObjectConstructor | NumberConstructor | BooleanConstructor | StringConstructor)[]; | ||
}; | ||
@@ -104,3 +112,3 @@ disabled: { | ||
value: { | ||
type: (ObjectConstructor | BooleanConstructor | StringConstructor | NumberConstructor)[]; | ||
type: (ObjectConstructor | NumberConstructor | BooleanConstructor | StringConstructor)[]; | ||
}; | ||
@@ -116,5 +124,5 @@ disabled: { | ||
}>>, { | ||
id: string; | ||
as: string | Record<string, any>; | ||
disabled: boolean; | ||
id: string; | ||
}>; | ||
@@ -152,5 +160,5 @@ export declare let RadioGroupLabel: import("vue").DefineComponent<{ | ||
}>>, { | ||
passive: boolean; | ||
id: string; | ||
as: string | Record<string, any>; | ||
id: string; | ||
passive: boolean; | ||
}>; | ||
@@ -180,5 +188,5 @@ export declare let RadioGroupDescription: import("vue").DefineComponent<{ | ||
}>>, { | ||
id: string; | ||
as: string | Record<string, any>; | ||
id: string; | ||
}>; | ||
export {}; |
@@ -1,1 +0,1 @@ | ||
import{Fragment as K,computed as u,defineComponent as G,h as L,inject as M,onMounted as A,onUnmounted as _,provide as $,ref as h,toRaw as v,watch as U}from"vue";import{dom as F}from'../../utils/dom.js';import{Keys as y}from'../../keyboard.js';import{focusIn as C,Focus as O,FocusResult as D,sortByDomNode as W}from'../../utils/focus-management.js';import{useId as x}from'../../hooks/use-id.js';import{compact as J,omit as q,render as I}from'../../utils/render.js';import{Label as Q,useLabels as P}from'../label/label.js';import{Description as X,useDescriptions as B}from'../description/description.js';import{useTreeWalker as Y}from'../../hooks/use-tree-walker.js';import{Hidden as Z,Features as z}from'../../internal/hidden.js';import{attemptSubmit as ee,objectToFormEntries as te}from'../../utils/form.js';import{getOwnerDocument as T}from'../../utils/owner.js';import{useControllable as ae}from'../../hooks/use-controllable.js';function ne(t,m){return t===m}let V=Symbol("RadioGroupContext");function j(t){let m=M(V,null);if(m===null){let o=new Error(`<${t} /> is missing a parent <RadioGroup /> component.`);throw Error.captureStackTrace&&Error.captureStackTrace(o,j),o}return m}let Oe=G({name:"RadioGroup",emits:{"update:modelValue":t=>!0},props:{as:{type:[Object,String],default:"div"},disabled:{type:[Boolean],default:!1},by:{type:[String,Function],default:()=>ne},modelValue:{type:[Object,String,Number,Boolean],default:void 0},defaultValue:{type:[Object,String,Number,Boolean],default:void 0},name:{type:String,optional:!0},id:{type:String,default:()=>`headlessui-radiogroup-${x()}`}},inheritAttrs:!1,setup(t,{emit:m,attrs:o,slots:k,expose:d}){let s=h(null),i=h([]),b=P({name:"RadioGroupLabel"}),E=B({name:"RadioGroupDescription"});d({el:s,$el:s});let[f,w]=ae(u(()=>t.modelValue),e=>m("update:modelValue",e),u(()=>t.defaultValue)),l={options:i,value:f,disabled:u(()=>t.disabled),firstOption:u(()=>i.value.find(e=>!e.propsRef.disabled)),containsCheckedOption:u(()=>i.value.some(e=>l.compare(v(e.propsRef.value),v(t.modelValue)))),compare(e,a){if(typeof t.by=="string"){let n=t.by;return(e==null?void 0:e[n])===(a==null?void 0:a[n])}return t.by(e,a)},change(e){var n;if(t.disabled||l.compare(v(f.value),v(e)))return!1;let a=(n=i.value.find(r=>l.compare(v(r.propsRef.value),v(e))))==null?void 0:n.propsRef;return a!=null&&a.disabled?!1:(w(e),!0)},registerOption(e){i.value.push(e),i.value=W(i.value,a=>a.element)},unregisterOption(e){let a=i.value.findIndex(n=>n.id===e);a!==-1&&i.value.splice(a,1)}};$(V,l),Y({container:u(()=>F(s)),accept(e){return e.getAttribute("role")==="radio"?NodeFilter.FILTER_REJECT:e.hasAttribute("role")?NodeFilter.FILTER_SKIP:NodeFilter.FILTER_ACCEPT},walk(e){e.setAttribute("role","none")}});function g(e){if(!s.value||!s.value.contains(e.target))return;let a=i.value.filter(n=>n.propsRef.disabled===!1).map(n=>n.element);switch(e.key){case y.Enter:ee(e.currentTarget);break;case y.ArrowLeft:case y.ArrowUp:if(e.preventDefault(),e.stopPropagation(),C(a,O.Previous|O.WrapAround)===D.Success){let r=i.value.find(p=>{var c;return p.element===((c=T(s))==null?void 0:c.activeElement)});r&&l.change(r.propsRef.value)}break;case y.ArrowRight:case y.ArrowDown:if(e.preventDefault(),e.stopPropagation(),C(a,O.Next|O.WrapAround)===D.Success){let r=i.value.find(p=>{var c;return p.element===((c=T(p.element))==null?void 0:c.activeElement)});r&&l.change(r.propsRef.value)}break;case y.Space:{e.preventDefault(),e.stopPropagation();let n=i.value.find(r=>{var p;return r.element===((p=T(r.element))==null?void 0:p.activeElement)});n&&l.change(n.propsRef.value)}break}}let R=u(()=>{var e;return(e=F(s))==null?void 0:e.closest("form")});return A(()=>{U([R],()=>{if(!R.value||t.defaultValue===void 0)return;function e(){l.change(t.defaultValue)}return R.value.addEventListener("reset",e),()=>{var a;(a=R.value)==null||a.removeEventListener("reset",e)}},{immediate:!0})}),()=>{let{disabled:e,name:a,id:n,...r}=t,p={ref:s,id:n,role:"radiogroup","aria-labelledby":b.value,"aria-describedby":E.value,onKeydown:g};return L(K,[...a!=null&&f.value!=null?te({[a]:f.value}).map(([c,S])=>L(Z,J({features:z.Hidden,key:c,as:"input",type:"hidden",hidden:!0,readOnly:!0,name:c,value:S}))):[],I({ourProps:p,theirProps:{...o,...q(r,["modelValue","defaultValue"])},slot:{},attrs:o,slots:k,name:"RadioGroup"})])}}});var re=(o=>(o[o.Empty=1]="Empty",o[o.Active=2]="Active",o))(re||{});let ke=G({name:"RadioGroupOption",props:{as:{type:[Object,String],default:"div"},value:{type:[Object,String,Number,Boolean]},disabled:{type:Boolean,default:!1},id:{type:String,default:()=>`headlessui-radiogroup-option-${x()}`}},setup(t,{attrs:m,slots:o,expose:k}){let d=j("RadioGroupOption"),s=P({name:"RadioGroupLabel"}),i=B({name:"RadioGroupDescription"}),b=h(null),E=u(()=>({value:t.value,disabled:t.disabled})),f=h(1);k({el:b,$el:b}),A(()=>d.registerOption({id:t.id,element:b,propsRef:E})),_(()=>d.unregisterOption(t.id));let w=u(()=>{var r;return((r=d.firstOption.value)==null?void 0:r.id)===t.id}),l=u(()=>d.disabled.value||t.disabled),g=u(()=>d.compare(v(d.value.value),v(t.value))),R=u(()=>l.value?-1:g.value||!d.containsCheckedOption.value&&w.value?0:-1);function e(){var r;!d.change(t.value)||(f.value|=2,(r=b.value)==null||r.focus())}function a(){f.value|=2}function n(){f.value&=-3}return()=>{let{id:r,value:p,disabled:c,...S}=t,H={checked:g.value,disabled:l.value,active:Boolean(f.value&2)},N={id:r,ref:b,role:"radio","aria-checked":g.value?"true":"false","aria-labelledby":s.value,"aria-describedby":i.value,"aria-disabled":l.value?!0:void 0,tabIndex:R.value,onClick:l.value?void 0:e,onFocus:l.value?void 0:a,onBlur:l.value?void 0:n};return I({ourProps:N,theirProps:S,slot:H,attrs:m,slots:o,name:"RadioGroupOption"})}}}),Ee=Q,we=X;export{Oe as RadioGroup,we as RadioGroupDescription,Ee as RadioGroupLabel,ke as RadioGroupOption}; | ||
import{Fragment as M,computed as o,defineComponent as A,h as F,inject as _,onMounted as C,onUnmounted as $,provide as U,ref as h,toRaw as y,watch as W}from"vue";import{useControllable as J}from'../../hooks/use-controllable.js';import{useId as D}from'../../hooks/use-id.js';import{useTreeWalker as q}from'../../hooks/use-tree-walker.js';import{Hidden as Q,Features as X}from'../../internal/hidden.js';import{Keys as g}from'../../keyboard.js';import{dom as O}from'../../utils/dom.js';import{Focus as k,FocusResult as x,focusIn as I,sortByDomNode as Y}from'../../utils/focus-management.js';import{attemptSubmit as Z,objectToFormEntries as z}from'../../utils/form.js';import{getOwnerDocument as L}from'../../utils/owner.js';import{compact as ee,omit as te,render as P}from'../../utils/render.js';import{Description as ae,useDescriptions as B}from'../description/description.js';import{Label as ne,useLabels as V}from'../label/label.js';function re(t,c){return t===c}let j=Symbol("RadioGroupContext");function H(t){let c=_(j,null);if(c===null){let u=new Error(`<${t} /> is missing a parent <RadioGroup /> component.`);throw Error.captureStackTrace&&Error.captureStackTrace(u,H),u}return c}let ge=A({name:"RadioGroup",emits:{"update:modelValue":t=>!0},props:{as:{type:[Object,String],default:"div"},disabled:{type:[Boolean],default:!1},by:{type:[String,Function],default:()=>re},modelValue:{type:[Object,String,Number,Boolean],default:void 0},defaultValue:{type:[Object,String,Number,Boolean],default:void 0},form:{type:String,optional:!0},name:{type:String,optional:!0},id:{type:String,default:()=>`headlessui-radiogroup-${D()}`}},inheritAttrs:!1,setup(t,{emit:c,attrs:u,slots:E,expose:d}){let s=h(null),i=h([]),R=V({name:"RadioGroupLabel"}),w=B({name:"RadioGroupDescription"});d({el:s,$el:s});let[f,S]=J(o(()=>t.modelValue),e=>c("update:modelValue",e),o(()=>t.defaultValue)),p={options:i,value:f,disabled:o(()=>t.disabled),firstOption:o(()=>i.value.find(e=>!e.propsRef.disabled)),containsCheckedOption:o(()=>i.value.some(e=>p.compare(y(e.propsRef.value),y(t.modelValue)))),compare(e,a){if(typeof t.by=="string"){let n=t.by;return(e==null?void 0:e[n])===(a==null?void 0:a[n])}return t.by(e,a)},change(e){var n;if(t.disabled||p.compare(y(f.value),y(e)))return!1;let a=(n=i.value.find(l=>p.compare(y(l.propsRef.value),y(e))))==null?void 0:n.propsRef;return a!=null&&a.disabled?!1:(S(e),!0)},registerOption(e){i.value.push(e),i.value=Y(i.value,a=>a.element)},unregisterOption(e){let a=i.value.findIndex(n=>n.id===e);a!==-1&&i.value.splice(a,1)}};U(j,p),q({container:o(()=>O(s)),accept(e){return e.getAttribute("role")==="radio"?NodeFilter.FILTER_REJECT:e.hasAttribute("role")?NodeFilter.FILTER_SKIP:NodeFilter.FILTER_ACCEPT},walk(e){e.setAttribute("role","none")}});function m(e){if(!s.value||!s.value.contains(e.target))return;let a=i.value.filter(n=>n.propsRef.disabled===!1).map(n=>n.element);switch(e.key){case g.Enter:Z(e.currentTarget);break;case g.ArrowLeft:case g.ArrowUp:if(e.preventDefault(),e.stopPropagation(),I(a,k.Previous|k.WrapAround)===x.Success){let l=i.value.find(r=>{var b;return r.element===((b=L(s))==null?void 0:b.activeElement)});l&&p.change(l.propsRef.value)}break;case g.ArrowRight:case g.ArrowDown:if(e.preventDefault(),e.stopPropagation(),I(a,k.Next|k.WrapAround)===x.Success){let l=i.value.find(r=>{var b;return r.element===((b=L(r.element))==null?void 0:b.activeElement)});l&&p.change(l.propsRef.value)}break;case g.Space:{e.preventDefault(),e.stopPropagation();let n=i.value.find(l=>{var r;return l.element===((r=L(l.element))==null?void 0:r.activeElement)});n&&p.change(n.propsRef.value)}break}}let v=o(()=>{var e;return(e=O(s))==null?void 0:e.closest("form")});return C(()=>{W([v],()=>{if(!v.value||t.defaultValue===void 0)return;function e(){p.change(t.defaultValue)}return v.value.addEventListener("reset",e),()=>{var a;(a=v.value)==null||a.removeEventListener("reset",e)}},{immediate:!0})}),()=>{let{disabled:e,name:a,id:n,form:l,...r}=t,b={ref:s,id:n,role:"radiogroup","aria-labelledby":R.value,"aria-describedby":w.value,onKeydown:m};return F(M,[...a!=null&&f.value!=null?z({[a]:f.value}).map(([T,G])=>F(Q,ee({features:X.Hidden,key:T,as:"input",type:"hidden",hidden:!0,readOnly:!0,form:l,disabled:e,name:T,value:G}))):[],P({ourProps:b,theirProps:{...u,...te(r,["modelValue","defaultValue","by"])},slot:{},attrs:u,slots:E,name:"RadioGroup"})])}}});var ie=(u=>(u[u.Empty=1]="Empty",u[u.Active=2]="Active",u))(ie||{});let he=A({name:"RadioGroupOption",props:{as:{type:[Object,String],default:"div"},value:{type:[Object,String,Number,Boolean]},disabled:{type:Boolean,default:!1},id:{type:String,default:()=>`headlessui-radiogroup-option-${D()}`}},setup(t,{attrs:c,slots:u,expose:E}){let d=H("RadioGroupOption"),s=V({name:"RadioGroupLabel"}),i=B({name:"RadioGroupDescription"}),R=h(null),w=o(()=>({value:t.value,disabled:t.disabled})),f=h(1);E({el:R,$el:R});let S=o(()=>O(R));C(()=>d.registerOption({id:t.id,element:S,propsRef:w})),$(()=>d.unregisterOption(t.id));let p=o(()=>{var r;return((r=d.firstOption.value)==null?void 0:r.id)===t.id}),m=o(()=>d.disabled.value||t.disabled),v=o(()=>d.compare(y(d.value.value),y(t.value))),e=o(()=>m.value?-1:v.value||!d.containsCheckedOption.value&&p.value?0:-1);function a(){var r;d.change(t.value)&&(f.value|=2,(r=O(R))==null||r.focus())}function n(){f.value|=2}function l(){f.value&=-3}return()=>{let{id:r,value:b,disabled:T,...G}=t,N={checked:v.value,disabled:m.value,active:!!(f.value&2)},K={id:r,ref:R,role:"radio","aria-checked":v.value?"true":"false","aria-labelledby":s.value,"aria-describedby":i.value,"aria-disabled":m.value?!0:void 0,tabIndex:e.value,onClick:m.value?void 0:a,onFocus:m.value?void 0:n,onBlur:m.value?void 0:l};return P({ourProps:K,theirProps:G,slot:N,attrs:c,slots:u,name:"RadioGroupOption"})}}}),Oe=ne,ke=ae;export{ge as RadioGroup,ke as RadioGroupDescription,Oe as RadioGroupLabel,he as RadioGroupOption}; |
@@ -31,2 +31,6 @@ export declare let SwitchGroup: import("vue").DefineComponent<{ | ||
}; | ||
form: { | ||
type: StringConstructor; | ||
optional: boolean; | ||
}; | ||
name: { | ||
@@ -44,2 +48,10 @@ type: StringConstructor; | ||
}; | ||
disabled: { | ||
type: BooleanConstructor; | ||
default: boolean; | ||
}; | ||
tabIndex: { | ||
type: NumberConstructor; | ||
default: number; | ||
}; | ||
}, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, { | ||
@@ -62,2 +74,6 @@ [key: string]: any; | ||
}; | ||
form: { | ||
type: StringConstructor; | ||
optional: boolean; | ||
}; | ||
name: { | ||
@@ -75,7 +91,17 @@ type: StringConstructor; | ||
}; | ||
disabled: { | ||
type: BooleanConstructor; | ||
default: boolean; | ||
}; | ||
tabIndex: { | ||
type: NumberConstructor; | ||
default: number; | ||
}; | ||
}>> & { | ||
"onUpdate:modelValue"?: ((_value: boolean) => any) | undefined; | ||
}, { | ||
id: string; | ||
tabIndex: number; | ||
as: string | Record<string, any>; | ||
id: string; | ||
disabled: boolean; | ||
modelValue: boolean; | ||
@@ -115,5 +141,5 @@ defaultChecked: boolean; | ||
}>>, { | ||
passive: boolean; | ||
id: string; | ||
as: string | Record<string, any>; | ||
id: string; | ||
passive: boolean; | ||
}>; | ||
@@ -143,4 +169,4 @@ export declare let SwitchDescription: import("vue").DefineComponent<{ | ||
}>>, { | ||
id: string; | ||
as: string | Record<string, any>; | ||
id: string; | ||
}>; |
@@ -1,1 +0,1 @@ | ||
import{Fragment as x,computed as d,defineComponent as m,h,inject as H,provide as P,ref as y,watch as j,onMounted as B}from"vue";import{render as b,compact as G,omit as M}from'../../utils/render.js';import{useId as T}from'../../hooks/use-id.js';import{Keys as v}from'../../keyboard.js';import{Label as V,useLabels as I}from'../label/label.js';import{Description as O,useDescriptions as F}from'../description/description.js';import{useResolveButtonType as $}from'../../hooks/use-resolve-button-type.js';import{Hidden as A,Features as U}from'../../internal/hidden.js';import{attemptSubmit as _}from'../../utils/form.js';import{useControllable as q}from'../../hooks/use-controllable.js';import{dom as z}from'../../utils/dom.js';let S=Symbol("GroupContext"),oe=m({name:"SwitchGroup",props:{as:{type:[Object,String],default:"template"}},setup(l,{slots:c,attrs:o}){let r=y(null),p=I({name:"SwitchLabel",props:{onClick(){!r.value||(r.value.click(),r.value.focus({preventScroll:!0}))}}}),t=F({name:"SwitchDescription"});return P(S,{switchRef:r,labelledby:p,describedby:t}),()=>b({theirProps:l,ourProps:{},slot:{},slots:c,attrs:o,name:"SwitchGroup"})}}),ue=m({name:"Switch",emits:{"update:modelValue":l=>!0},props:{as:{type:[Object,String],default:"button"},modelValue:{type:Boolean,default:void 0},defaultChecked:{type:Boolean,optional:!0},name:{type:String,optional:!0},value:{type:String,optional:!0},id:{type:String,default:()=>`headlessui-switch-${T()}`}},inheritAttrs:!1,setup(l,{emit:c,attrs:o,slots:r,expose:p}){let t=H(S,null),[i,s]=q(d(()=>l.modelValue),e=>c("update:modelValue",e),d(()=>l.defaultChecked));function f(){s(!i.value)}let w=y(null),u=t===null?w:t.switchRef,k=$(d(()=>({as:l.as,type:o.type})),u);p({el:u,$el:u});function C(e){e.preventDefault(),f()}function g(e){e.key===v.Space?(e.preventDefault(),f()):e.key===v.Enter&&_(e.currentTarget)}function R(e){e.preventDefault()}let a=d(()=>{var e,n;return(n=(e=z(u))==null?void 0:e.closest)==null?void 0:n.call(e,"form")});return B(()=>{j([a],()=>{if(!a.value||l.defaultChecked===void 0)return;function e(){s(l.defaultChecked)}return a.value.addEventListener("reset",e),()=>{var n;(n=a.value)==null||n.removeEventListener("reset",e)}},{immediate:!0})}),()=>{let{id:e,name:n,value:D,...E}=l,K={checked:i.value},L={id:e,ref:u,role:"switch",type:k.value,tabIndex:0,"aria-checked":i.value,"aria-labelledby":t==null?void 0:t.labelledby.value,"aria-describedby":t==null?void 0:t.describedby.value,onClick:C,onKeyup:g,onKeypress:R};return h(x,[n!=null&&i.value!=null?h(A,G({features:U.Hidden,as:"input",type:"checkbox",hidden:!0,readOnly:!0,checked:i.value,name:n,value:D})):null,b({ourProps:L,theirProps:{...o,...M(E,["modelValue","defaultChecked"])},slot:K,attrs:o,slots:r,name:"Switch"})])}}}),ae=V,de=O;export{ue as Switch,de as SwitchDescription,oe as SwitchGroup,ae as SwitchLabel}; | ||
import{Fragment as B,computed as d,defineComponent as y,h as b,inject as H,onMounted as M,provide as I,ref as v,watch as P}from"vue";import{useControllable as j}from'../../hooks/use-controllable.js';import{useId as G}from'../../hooks/use-id.js';import{useResolveButtonType as V}from'../../hooks/use-resolve-button-type.js';import{Hidden as F,Features as O}from'../../internal/hidden.js';import{Keys as S}from'../../keyboard.js';import{dom as A}from'../../utils/dom.js';import{attemptSubmit as N}from'../../utils/form.js';import{compact as $,omit as U,render as w}from'../../utils/render.js';import{Description as _,useDescriptions as q}from'../description/description.js';import{Label as z,useLabels as J}from'../label/label.js';let g=Symbol("GroupContext"),ie=y({name:"SwitchGroup",props:{as:{type:[Object,String],default:"template"}},setup(l,{slots:p,attrs:o}){let a=v(null),f=J({name:"SwitchLabel",props:{htmlFor:d(()=>{var n;return(n=a.value)==null?void 0:n.id}),onClick(n){a.value&&(n.currentTarget.tagName==="LABEL"&&n.preventDefault(),a.value.click(),a.value.focus({preventScroll:!0}))}}}),t=q({name:"SwitchDescription"});return I(g,{switchRef:a,labelledby:f,describedby:t}),()=>w({theirProps:l,ourProps:{},slot:{},slots:p,attrs:o,name:"SwitchGroup"})}}),oe=y({name:"Switch",emits:{"update:modelValue":l=>!0},props:{as:{type:[Object,String],default:"button"},modelValue:{type:Boolean,default:void 0},defaultChecked:{type:Boolean,optional:!0},form:{type:String,optional:!0},name:{type:String,optional:!0},value:{type:String,optional:!0},id:{type:String,default:()=>`headlessui-switch-${G()}`},disabled:{type:Boolean,default:!1},tabIndex:{type:Number,default:0}},inheritAttrs:!1,setup(l,{emit:p,attrs:o,slots:a,expose:f}){let t=H(g,null),[i,n]=j(d(()=>l.modelValue),e=>p("update:modelValue",e),d(()=>l.defaultChecked));function s(){n(!i.value)}let k=v(null),u=t===null?k:t.switchRef,C=V(d(()=>({as:l.as,type:o.type})),u);f({el:u,$el:u});function E(e){e.preventDefault(),s()}function L(e){e.key===S.Space?(e.preventDefault(),s()):e.key===S.Enter&&N(e.currentTarget)}function D(e){e.preventDefault()}let c=d(()=>{var e,r;return(r=(e=A(u))==null?void 0:e.closest)==null?void 0:r.call(e,"form")});return M(()=>{P([c],()=>{if(!c.value||l.defaultChecked===void 0)return;function e(){n(l.defaultChecked)}return c.value.addEventListener("reset",e),()=>{var r;(r=c.value)==null||r.removeEventListener("reset",e)}},{immediate:!0})}),()=>{let{id:e,name:r,value:R,form:x,tabIndex:m,...h}=l,K={checked:i.value},T={id:e,ref:u,role:"switch",type:C.value,tabIndex:m===-1?0:m,"aria-checked":i.value,"aria-labelledby":t==null?void 0:t.labelledby.value,"aria-describedby":t==null?void 0:t.describedby.value,onClick:E,onKeyup:L,onKeypress:D};return b(B,[r!=null&&i.value!=null?b(F,$({features:O.Hidden,as:"input",type:"checkbox",hidden:!0,readOnly:!0,checked:i.value,form:x,disabled:h.disabled,name:r,value:R})):null,w({ourProps:T,theirProps:{...o,...U(h,["modelValue","defaultChecked"])},slot:K,attrs:o,slots:a,name:"Switch"})])}}}),ue=z,de=_;export{oe as Switch,de as SwitchDescription,ie as SwitchGroup,ue as SwitchLabel}; |
@@ -104,5 +104,5 @@ export declare let TabGroup: import("vue").DefineComponent<{ | ||
}>>, { | ||
id: string; | ||
as: string | Record<string, any>; | ||
disabled: boolean; | ||
id: string; | ||
}>; | ||
@@ -143,2 +143,6 @@ export declare let TabPanels: import("vue").DefineComponent<{ | ||
}; | ||
tabIndex: { | ||
type: NumberConstructor; | ||
default: number; | ||
}; | ||
}, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, { | ||
@@ -165,7 +169,12 @@ [key: string]: any; | ||
}; | ||
tabIndex: { | ||
type: NumberConstructor; | ||
default: number; | ||
}; | ||
}>>, { | ||
id: string; | ||
tabIndex: number; | ||
as: string | Record<string, any>; | ||
unmount: boolean; | ||
static: boolean; | ||
id: string; | ||
}>; |
@@ -1,1 +0,1 @@ | ||
import{Fragment as B,computed as m,defineComponent as S,h as D,inject as F,onMounted as M,onUnmounted as O,provide as C,ref as I,watchEffect as K}from"vue";import{Features as H,render as E,omit as $}from'../../utils/render.js';import{useId as k}from'../../hooks/use-id.js';import{Keys as p}from'../../keyboard.js';import{dom as g}from'../../utils/dom.js';import{match as G}from'../../utils/match.js';import{focusIn as P,Focus as b,FocusResult as L}from'../../utils/focus-management.js';import{useResolveButtonType as N}from'../../hooks/use-resolve-button-type.js';import{FocusSentinel as U}from'../../internal/focus-sentinel.js';import{microTask as W}from'../../utils/micro-task.js';import{Hidden as z}from'../../internal/hidden.js';import{getOwnerDocument as _}from'../../utils/owner.js';let A=Symbol("TabsContext");function R(n){let o=F(A,null);if(o===null){let s=new Error(`<${n} /> is missing a parent <TabGroup /> component.`);throw Error.captureStackTrace&&Error.captureStackTrace(s,R),s}return o}let ie=S({name:"TabGroup",emits:{change:n=>!0},props:{as:{type:[Object,String],default:"template"},selectedIndex:{type:[Number],default:null},defaultIndex:{type:[Number],default:0},vertical:{type:[Boolean],default:!1},manual:{type:[Boolean],default:!1}},inheritAttrs:!1,setup(n,{slots:o,attrs:s,emit:c}){let e=I(null),a=I([]),u=I([]),f=m(()=>n.selectedIndex!==null),T=m(()=>f.value?n.selectedIndex:e.value),v={selectedIndex:e,orientation:m(()=>n.vertical?"vertical":"horizontal"),activation:m(()=>n.manual?"manual":"auto"),tabs:a,panels:u,setSelectedIndex(l){T.value!==l&&c("change",l),f.value||(e.value=l)},registerTab(l){a.value.includes(l)||a.value.push(l)},unregisterTab(l){let r=a.value.indexOf(l);r!==-1&&a.value.splice(r,1)},registerPanel(l){u.value.includes(l)||u.value.push(l)},unregisterPanel(l){let r=u.value.indexOf(l);r!==-1&&u.value.splice(r,1)}};return C(A,v),K(()=>{var w;if(v.tabs.value.length<=0||n.selectedIndex===null&&e.value!==null)return;let l=v.tabs.value.map(t=>g(t)).filter(Boolean),r=l.filter(t=>!t.hasAttribute("disabled")),i=(w=n.selectedIndex)!=null?w:n.defaultIndex;if(i<0)e.value=l.indexOf(r[0]);else if(i>v.tabs.value.length)e.value=l.indexOf(r[r.length-1]);else{let t=l.slice(0,i),x=[...l.slice(i),...t].find(y=>r.includes(y));if(!x)return;e.value=l.indexOf(x)}}),()=>{let l={selectedIndex:e.value};return D(B,[a.value.length<=0&&D(U,{onFocus:()=>{for(let r of a.value){let i=g(r);if((i==null?void 0:i.tabIndex)===0)return i.focus(),!0}return!1}}),E({theirProps:{...s,...$(n,["selectedIndex","defaultIndex","manual","vertical","onChange"])},ourProps:{},slot:l,slots:o,attrs:s,name:"TabGroup"})])}}}),oe=S({name:"TabList",props:{as:{type:[Object,String],default:"div"}},setup(n,{attrs:o,slots:s}){let c=R("TabList");return()=>{let e={selectedIndex:c.selectedIndex.value},a={role:"tablist","aria-orientation":c.orientation.value};return E({ourProps:a,theirProps:n,slot:e,attrs:o,slots:s,name:"TabList"})}}}),se=S({name:"Tab",props:{as:{type:[Object,String],default:"button"},disabled:{type:[Boolean],default:!1},id:{type:String,default:()=>`headlessui-tabs-tab-${k()}`}},setup(n,{attrs:o,slots:s,expose:c}){let e=R("Tab"),a=I(null);c({el:a,$el:a}),M(()=>e.registerTab(a)),O(()=>e.unregisterTab(a));let u=m(()=>e.tabs.value.indexOf(a)),f=m(()=>u.value===e.selectedIndex.value);function T(t){var x;let d=t();if(d===L.Success&&e.activation.value==="auto"){let y=(x=_(a))==null?void 0:x.activeElement,h=e.tabs.value.findIndex(j=>g(j)===y);h!==-1&&e.setSelectedIndex(h)}return d}function v(t){let d=e.tabs.value.map(y=>g(y)).filter(Boolean);if(t.key===p.Space||t.key===p.Enter){t.preventDefault(),t.stopPropagation(),e.setSelectedIndex(u.value);return}switch(t.key){case p.Home:case p.PageUp:return t.preventDefault(),t.stopPropagation(),T(()=>P(d,b.First));case p.End:case p.PageDown:return t.preventDefault(),t.stopPropagation(),T(()=>P(d,b.Last))}if(T(()=>G(e.orientation.value,{vertical(){return t.key===p.ArrowUp?P(d,b.Previous|b.WrapAround):t.key===p.ArrowDown?P(d,b.Next|b.WrapAround):L.Error},horizontal(){return t.key===p.ArrowLeft?P(d,b.Previous|b.WrapAround):t.key===p.ArrowRight?P(d,b.Next|b.WrapAround):L.Error}}))===L.Success)return t.preventDefault()}let l=I(!1);function r(){var t;l.value||(l.value=!0,!n.disabled&&((t=g(a))==null||t.focus(),e.setSelectedIndex(u.value),W(()=>{l.value=!1})))}function i(t){t.preventDefault()}let w=N(m(()=>({as:n.as,type:o.type})),a);return()=>{var h;let t={selected:f.value},{id:d,...x}=n,y={ref:a,onKeydown:v,onMousedown:i,onClick:r,id:d,role:"tab",type:w.value,"aria-controls":(h=g(e.panels.value[u.value]))==null?void 0:h.id,"aria-selected":f.value,tabIndex:f.value?0:-1,disabled:n.disabled?!0:void 0};return E({ourProps:y,theirProps:x,slot:t,attrs:o,slots:s,name:"Tab"})}}}),de=S({name:"TabPanels",props:{as:{type:[Object,String],default:"div"}},setup(n,{slots:o,attrs:s}){let c=R("TabPanels");return()=>{let e={selectedIndex:c.selectedIndex.value};return E({theirProps:n,ourProps:{},slot:e,attrs:s,slots:o,name:"TabPanels"})}}}),fe=S({name:"TabPanel",props:{as:{type:[Object,String],default:"div"},static:{type:Boolean,default:!1},unmount:{type:Boolean,default:!0},id:{type:String,default:()=>`headlessui-tabs-panel-${k()}`}},setup(n,{attrs:o,slots:s,expose:c}){let e=R("TabPanel"),a=I(null);c({el:a,$el:a}),M(()=>e.registerPanel(a)),O(()=>e.unregisterPanel(a));let u=m(()=>e.panels.value.indexOf(a)),f=m(()=>u.value===e.selectedIndex.value);return()=>{var i;let T={selected:f.value},{id:v,...l}=n,r={ref:a,id:v,role:"tabpanel","aria-labelledby":(i=g(e.tabs.value[u.value]))==null?void 0:i.id,tabIndex:f.value?0:-1};return!f.value&&n.unmount&&!n.static?D(z,{as:"span",...r}):E({ourProps:r,theirProps:l,slot:T,attrs:o,slots:s,features:H.Static|H.RenderStrategy,visible:f.value,name:"TabPanel"})}}});export{se as Tab,ie as TabGroup,oe as TabList,fe as TabPanel,de as TabPanels}; | ||
import{Fragment as z,computed as c,defineComponent as D,h as H,inject as A,onMounted as M,onUnmounted as K,provide as N,ref as h,watch as _,watchEffect as J}from"vue";import{useId as $}from'../../hooks/use-id.js';import{useResolveButtonType as Q}from'../../hooks/use-resolve-button-type.js';import{FocusSentinel as V}from'../../internal/focus-sentinel.js';import{Hidden as X}from'../../internal/hidden.js';import{Keys as I}from'../../keyboard.js';import{dom as o}from'../../utils/dom.js';import{Focus as y,FocusResult as C,focusIn as R,sortByDomNode as O}from'../../utils/focus-management.js';import{match as F}from'../../utils/match.js';import{microTask as Y}from'../../utils/micro-task.js';import{getOwnerDocument as Z}from'../../utils/owner.js';import{Features as q,omit as ee,render as L}from'../../utils/render.js';var te=(i=>(i[i.Forwards=0]="Forwards",i[i.Backwards=1]="Backwards",i))(te||{}),le=(s=>(s[s.Less=-1]="Less",s[s.Equal=0]="Equal",s[s.Greater=1]="Greater",s))(le||{});let U=Symbol("TabsContext");function k(a){let v=A(U,null);if(v===null){let i=new Error(`<${a} /> is missing a parent <TabGroup /> component.`);throw Error.captureStackTrace&&Error.captureStackTrace(i,k),i}return v}let j=Symbol("TabsSSRContext"),me=D({name:"TabGroup",emits:{change:a=>!0},props:{as:{type:[Object,String],default:"template"},selectedIndex:{type:[Number],default:null},defaultIndex:{type:[Number],default:0},vertical:{type:[Boolean],default:!1},manual:{type:[Boolean],default:!1}},inheritAttrs:!1,setup(a,{slots:v,attrs:i,emit:s}){var P;let l=h((P=a.selectedIndex)!=null?P:a.defaultIndex),n=h([]),d=h([]),S=c(()=>a.selectedIndex!==null),b=c(()=>S.value?a.selectedIndex:l.value);function m(t){var T;let e=O(r.tabs.value,o),u=O(r.panels.value,o),f=e.filter(p=>{var x;return!((x=o(p))!=null&&x.hasAttribute("disabled"))});if(t<0||t>e.length-1){let p=F(l.value===null?0:Math.sign(t-l.value),{[-1]:()=>1,[0]:()=>F(Math.sign(t),{[-1]:()=>0,[0]:()=>0,[1]:()=>1}),[1]:()=>0}),x=F(p,{[0]:()=>e.indexOf(f[0]),[1]:()=>e.indexOf(f[f.length-1])});x!==-1&&(l.value=x),r.tabs.value=e,r.panels.value=u}else{let p=e.slice(0,t),G=[...e.slice(t),...p].find(W=>f.includes(W));if(!G)return;let B=(T=e.indexOf(G))!=null?T:r.selectedIndex.value;B===-1&&(B=r.selectedIndex.value),l.value=B,r.tabs.value=e,r.panels.value=u}}let r={selectedIndex:c(()=>{var t,e;return(e=(t=l.value)!=null?t:a.defaultIndex)!=null?e:null}),orientation:c(()=>a.vertical?"vertical":"horizontal"),activation:c(()=>a.manual?"manual":"auto"),tabs:n,panels:d,setSelectedIndex(t){b.value!==t&&s("change",t),S.value||m(t)},registerTab(t){var u;if(n.value.includes(t))return;let e=n.value[l.value];if(n.value.push(t),n.value=O(n.value,o),!S.value){let f=(u=n.value.indexOf(e))!=null?u:l.value;f!==-1&&(l.value=f)}},unregisterTab(t){let e=n.value.indexOf(t);e!==-1&&n.value.splice(e,1)},registerPanel(t){d.value.includes(t)||(d.value.push(t),d.value=O(d.value,o))},unregisterPanel(t){let e=d.value.indexOf(t);e!==-1&&d.value.splice(e,1)}};N(U,r);let w=h({tabs:[],panels:[]}),g=h(!1);M(()=>{g.value=!0}),N(j,c(()=>g.value?null:w.value));let E=c(()=>a.selectedIndex);return M(()=>{_([E],()=>{var t;return m((t=a.selectedIndex)!=null?t:a.defaultIndex)},{immediate:!0})}),J(()=>{if(!S.value||b.value==null||r.tabs.value.length<=0)return;let t=O(r.tabs.value,o);t.some((u,f)=>o(r.tabs.value[f])!==o(u))&&r.setSelectedIndex(t.findIndex(u=>o(u)===o(r.tabs.value[b.value])))}),()=>{let t={selectedIndex:l.value};return H(z,[n.value.length<=0&&H(V,{onFocus:()=>{for(let e of n.value){let u=o(e);if((u==null?void 0:u.tabIndex)===0)return u.focus(),!0}return!1}}),L({theirProps:{...i,...ee(a,["selectedIndex","defaultIndex","manual","vertical","onChange"])},ourProps:{},slot:t,slots:v,attrs:i,name:"TabGroup"})])}}}),pe=D({name:"TabList",props:{as:{type:[Object,String],default:"div"}},setup(a,{attrs:v,slots:i}){let s=k("TabList");return()=>{let l={selectedIndex:s.selectedIndex.value},n={role:"tablist","aria-orientation":s.orientation.value};return L({ourProps:n,theirProps:a,slot:l,attrs:v,slots:i,name:"TabList"})}}}),xe=D({name:"Tab",props:{as:{type:[Object,String],default:"button"},disabled:{type:[Boolean],default:!1},id:{type:String,default:()=>`headlessui-tabs-tab-${$()}`}},setup(a,{attrs:v,slots:i,expose:s}){let l=k("Tab"),n=h(null);s({el:n,$el:n}),M(()=>l.registerTab(n)),K(()=>l.unregisterTab(n));let d=A(j),S=c(()=>{if(d.value){let e=d.value.tabs.indexOf(a.id);return e===-1?d.value.tabs.push(a.id)-1:e}return-1}),b=c(()=>{let e=l.tabs.value.indexOf(n);return e===-1?S.value:e}),m=c(()=>b.value===l.selectedIndex.value);function r(e){var f;let u=e();if(u===C.Success&&l.activation.value==="auto"){let T=(f=Z(n))==null?void 0:f.activeElement,p=l.tabs.value.findIndex(x=>o(x)===T);p!==-1&&l.setSelectedIndex(p)}return u}function w(e){let u=l.tabs.value.map(T=>o(T)).filter(Boolean);if(e.key===I.Space||e.key===I.Enter){e.preventDefault(),e.stopPropagation(),l.setSelectedIndex(b.value);return}switch(e.key){case I.Home:case I.PageUp:return e.preventDefault(),e.stopPropagation(),r(()=>R(u,y.First));case I.End:case I.PageDown:return e.preventDefault(),e.stopPropagation(),r(()=>R(u,y.Last))}if(r(()=>F(l.orientation.value,{vertical(){return e.key===I.ArrowUp?R(u,y.Previous|y.WrapAround):e.key===I.ArrowDown?R(u,y.Next|y.WrapAround):C.Error},horizontal(){return e.key===I.ArrowLeft?R(u,y.Previous|y.WrapAround):e.key===I.ArrowRight?R(u,y.Next|y.WrapAround):C.Error}}))===C.Success)return e.preventDefault()}let g=h(!1);function E(){var e;g.value||(g.value=!0,!a.disabled&&((e=o(n))==null||e.focus({preventScroll:!0}),l.setSelectedIndex(b.value),Y(()=>{g.value=!1})))}function P(e){e.preventDefault()}let t=Q(c(()=>({as:a.as,type:v.type})),n);return()=>{var p,x;let e={selected:m.value,disabled:(p=a.disabled)!=null?p:!1},{id:u,...f}=a,T={ref:n,onKeydown:w,onMousedown:P,onClick:E,id:u,role:"tab",type:t.value,"aria-controls":(x=o(l.panels.value[b.value]))==null?void 0:x.id,"aria-selected":m.value,tabIndex:m.value?0:-1,disabled:a.disabled?!0:void 0};return L({ourProps:T,theirProps:f,slot:e,attrs:v,slots:i,name:"Tab"})}}}),Ie=D({name:"TabPanels",props:{as:{type:[Object,String],default:"div"}},setup(a,{slots:v,attrs:i}){let s=k("TabPanels");return()=>{let l={selectedIndex:s.selectedIndex.value};return L({theirProps:a,ourProps:{},slot:l,attrs:i,slots:v,name:"TabPanels"})}}}),ye=D({name:"TabPanel",props:{as:{type:[Object,String],default:"div"},static:{type:Boolean,default:!1},unmount:{type:Boolean,default:!0},id:{type:String,default:()=>`headlessui-tabs-panel-${$()}`},tabIndex:{type:Number,default:0}},setup(a,{attrs:v,slots:i,expose:s}){let l=k("TabPanel"),n=h(null);s({el:n,$el:n}),M(()=>l.registerPanel(n)),K(()=>l.unregisterPanel(n));let d=A(j),S=c(()=>{if(d.value){let r=d.value.panels.indexOf(a.id);return r===-1?d.value.panels.push(a.id)-1:r}return-1}),b=c(()=>{let r=l.panels.value.indexOf(n);return r===-1?S.value:r}),m=c(()=>b.value===l.selectedIndex.value);return()=>{var t;let r={selected:m.value},{id:w,tabIndex:g,...E}=a,P={ref:n,id:w,role:"tabpanel","aria-labelledby":(t=o(l.tabs.value[b.value]))==null?void 0:t.id,tabIndex:m.value?g:-1};return!m.value&&a.unmount&&!a.static?H(X,{as:"span","aria-hidden":!0,...P}):L({ourProps:P,theirProps:E,slot:r,attrs:v,slots:i,features:q.Static|q.RenderStrategy,visible:m.value,name:"TabPanel"})}}});export{xe as Tab,me as TabGroup,pe as TabList,ye as TabPanel,Ie as TabPanels}; |
@@ -1,1 +0,1 @@ | ||
import{computed as b,defineComponent as A,h as D,inject as L,onMounted as h,onUnmounted as I,provide as H,ref as T,watch as X,watchEffect as y}from"vue";import{useId as Y}from'../../hooks/use-id.js';import{match as E}from'../../utils/match.js';import{Features as Z,omit as ee,render as P,RenderStrategy as f}from'../../utils/render.js';import{Reason as j,transition as M}from'./utils/transition.js';import{dom as U}from'../../utils/dom.js';import{useOpenClosedProvider as te,State as V,useOpenClosed as ne,hasOpenClosed as re}from'../../internal/open-closed.js';function d(e=""){return e.split(" ").filter(t=>t.trim().length>1)}let B=Symbol("TransitionContext");var ae=(a=>(a.Visible="visible",a.Hidden="hidden",a))(ae||{});function le(){return L(B,null)!==null}function ie(){let e=L(B,null);if(e===null)throw new Error("A <TransitionChild /> is used but it is missing a parent <TransitionRoot />.");return e}function se(){let e=L(F,null);if(e===null)throw new Error("A <TransitionChild /> is used but it is missing a parent <TransitionRoot />.");return e}let F=Symbol("NestingContext");function w(e){return"children"in e?w(e.children):e.value.filter(({state:t})=>t==="visible").length>0}function K(e){let t=T([]),a=T(!1);h(()=>a.value=!0),I(()=>a.value=!1);function s(r,n=f.Hidden){let l=t.value.findIndex(({id:i})=>i===r);l!==-1&&(E(n,{[f.Unmount](){t.value.splice(l,1)},[f.Hidden](){t.value[l].state="hidden"}}),!w(t)&&a.value&&(e==null||e()))}function v(r){let n=t.value.find(({id:l})=>l===r);return n?n.state!=="visible"&&(n.state="visible"):t.value.push({id:r,state:"visible"}),()=>s(r,f.Unmount)}return{children:t,register:v,unregister:s}}let _=Z.RenderStrategy,oe=A({props:{as:{type:[Object,String],default:"div"},show:{type:[Boolean],default:null},unmount:{type:[Boolean],default:!0},appear:{type:[Boolean],default:!1},enter:{type:[String],default:""},enterFrom:{type:[String],default:""},enterTo:{type:[String],default:""},entered:{type:[String],default:""},leave:{type:[String],default:""},leaveFrom:{type:[String],default:""},leaveTo:{type:[String],default:""}},emits:{beforeEnter:()=>!0,afterEnter:()=>!0,beforeLeave:()=>!0,afterLeave:()=>!0},setup(e,{emit:t,attrs:a,slots:s,expose:v}){if(!le()&&re())return()=>D(fe,{...e,onBeforeEnter:()=>t("beforeEnter"),onAfterEnter:()=>t("afterEnter"),onBeforeLeave:()=>t("beforeLeave"),onAfterLeave:()=>t("afterLeave")},s);let r=T(null),n=T("visible"),l=b(()=>e.unmount?f.Unmount:f.Hidden);v({el:r,$el:r});let{show:i,appear:x}=ie(),{register:g,unregister:p}=se(),R={value:!0},m=Y(),S={value:!1},N=K(()=>{S.value||(n.value="hidden",p(m),t("afterLeave"))});h(()=>{let o=g(m);I(o)}),y(()=>{if(l.value===f.Hidden&&!!m){if(i&&n.value!=="visible"){n.value="visible";return}E(n.value,{["hidden"]:()=>p(m),["visible"]:()=>g(m)})}});let k=d(e.enter),$=d(e.enterFrom),q=d(e.enterTo),O=d(e.entered),z=d(e.leave),G=d(e.leaveFrom),J=d(e.leaveTo);h(()=>{y(()=>{if(n.value==="visible"){let o=U(r);if(o instanceof Comment&&o.data==="")throw new Error("Did you forget to passthrough the `ref` to the actual DOM node?")}})});function Q(o){let c=R.value&&!x.value,u=U(r);!u||!(u instanceof HTMLElement)||c||(S.value=!0,i.value&&t("beforeEnter"),i.value||t("beforeLeave"),o(i.value?M(u,k,$,q,O,C=>{S.value=!1,C===j.Finished&&t("afterEnter")}):M(u,z,G,J,O,C=>{S.value=!1,C===j.Finished&&(w(N)||(n.value="hidden",p(m),t("afterLeave")))})))}return h(()=>{X([i],(o,c,u)=>{Q(u),R.value=!1},{immediate:!0})}),H(F,N),te(b(()=>E(n.value,{["visible"]:V.Open,["hidden"]:V.Closed}))),()=>{let{appear:o,show:c,enter:u,enterFrom:C,enterTo:de,entered:ve,leave:pe,leaveFrom:me,leaveTo:Te,...W}=e;return P({theirProps:W,ourProps:{ref:r},slot:{},slots:s,attrs:a,features:_,visible:n.value==="visible",name:"TransitionChild"})}}}),ue=oe,fe=A({inheritAttrs:!1,props:{as:{type:[Object,String],default:"div"},show:{type:[Boolean],default:null},unmount:{type:[Boolean],default:!0},appear:{type:[Boolean],default:!1},enter:{type:[String],default:""},enterFrom:{type:[String],default:""},enterTo:{type:[String],default:""},entered:{type:[String],default:""},leave:{type:[String],default:""},leaveFrom:{type:[String],default:""},leaveTo:{type:[String],default:""}},emits:{beforeEnter:()=>!0,afterEnter:()=>!0,beforeLeave:()=>!0,afterLeave:()=>!0},setup(e,{emit:t,attrs:a,slots:s}){let v=ne(),r=b(()=>e.show===null&&v!==null?E(v.value,{[V.Open]:!0,[V.Closed]:!1}):e.show);y(()=>{if(![!0,!1].includes(r.value))throw new Error('A <Transition /> is used but it is missing a `:show="true | false"` prop.')});let n=T(r.value?"visible":"hidden"),l=K(()=>{n.value="hidden"}),i=T(!0),x={show:r,appear:b(()=>e.appear||!i.value)};return h(()=>{y(()=>{i.value=!1,r.value?n.value="visible":w(l)||(n.value="hidden")})}),H(F,l),H(B,x),()=>{let g=ee(e,["show","appear","unmount","onBeforeEnter","onBeforeLeave","onAfterEnter","onAfterLeave"]),p={unmount:e.unmount};return P({ourProps:{...p,as:"template"},theirProps:{},slot:{},slots:{...s,default:()=>[D(ue,{onBeforeEnter:()=>t("beforeEnter"),onAfterEnter:()=>t("afterEnter"),onBeforeLeave:()=>t("beforeLeave"),onAfterLeave:()=>t("afterLeave"),...a,...p,...g},s.default)]},attrs:{},features:_,visible:n.value==="visible",name:"Transition"})}}});export{oe as TransitionChild,fe as TransitionRoot}; | ||
import{computed as w,defineComponent as K,h as k,inject as F,normalizeClass as ae,onMounted as C,onUnmounted as z,provide as B,ref as m,watch as le,watchEffect as x}from"vue";import{useId as ie}from'../../hooks/use-id.js';import{State as u,hasOpenClosed as se,useOpenClosed as oe,useOpenClosedProvider as ue}from'../../internal/open-closed.js';import{dom as $}from'../../utils/dom.js';import{env as fe}from'../../utils/env.js';import{match as O}from'../../utils/match.js';import{Features as de,RenderStrategy as T,omit as ve,render as q}from'../../utils/render.js';import{Reason as G,transition as J}from'./utils/transition.js';function g(e=""){return e.split(/\s+/).filter(t=>t.length>1)}let R=Symbol("TransitionContext");var pe=(a=>(a.Visible="visible",a.Hidden="hidden",a))(pe||{});function me(){return F(R,null)!==null}function Te(){let e=F(R,null);if(e===null)throw new Error("A <TransitionChild /> is used but it is missing a parent <TransitionRoot />.");return e}function ge(){let e=F(N,null);if(e===null)throw new Error("A <TransitionChild /> is used but it is missing a parent <TransitionRoot />.");return e}let N=Symbol("NestingContext");function L(e){return"children"in e?L(e.children):e.value.filter(({state:t})=>t==="visible").length>0}function Q(e){let t=m([]),a=m(!1);C(()=>a.value=!0),z(()=>a.value=!1);function s(n,r=T.Hidden){let l=t.value.findIndex(({id:f})=>f===n);l!==-1&&(O(r,{[T.Unmount](){t.value.splice(l,1)},[T.Hidden](){t.value[l].state="hidden"}}),!L(t)&&a.value&&(e==null||e()))}function h(n){let r=t.value.find(({id:l})=>l===n);return r?r.state!=="visible"&&(r.state="visible"):t.value.push({id:n,state:"visible"}),()=>s(n,T.Unmount)}return{children:t,register:h,unregister:s}}let W=de.RenderStrategy,he=K({props:{as:{type:[Object,String],default:"div"},show:{type:[Boolean],default:null},unmount:{type:[Boolean],default:!0},appear:{type:[Boolean],default:!1},enter:{type:[String],default:""},enterFrom:{type:[String],default:""},enterTo:{type:[String],default:""},entered:{type:[String],default:""},leave:{type:[String],default:""},leaveFrom:{type:[String],default:""},leaveTo:{type:[String],default:""}},emits:{beforeEnter:()=>!0,afterEnter:()=>!0,beforeLeave:()=>!0,afterLeave:()=>!0},setup(e,{emit:t,attrs:a,slots:s,expose:h}){let n=m(0);function r(){n.value|=u.Opening,t("beforeEnter")}function l(){n.value&=~u.Opening,t("afterEnter")}function f(){n.value|=u.Closing,t("beforeLeave")}function S(){n.value&=~u.Closing,t("afterLeave")}if(!me()&&se())return()=>k(Se,{...e,onBeforeEnter:r,onAfterEnter:l,onBeforeLeave:f,onAfterLeave:S},s);let d=m(null),y=w(()=>e.unmount?T.Unmount:T.Hidden);h({el:d,$el:d});let{show:v,appear:A}=Te(),{register:D,unregister:H}=ge(),i=m(v.value?"visible":"hidden"),I={value:!0},c=ie(),b={value:!1},P=Q(()=>{!b.value&&i.value!=="hidden"&&(i.value="hidden",H(c),S())});C(()=>{let o=D(c);z(o)}),x(()=>{if(y.value===T.Hidden&&c){if(v.value&&i.value!=="visible"){i.value="visible";return}O(i.value,{["hidden"]:()=>H(c),["visible"]:()=>D(c)})}});let j=g(e.enter),M=g(e.enterFrom),X=g(e.enterTo),_=g(e.entered),Y=g(e.leave),Z=g(e.leaveFrom),ee=g(e.leaveTo);C(()=>{x(()=>{if(i.value==="visible"){let o=$(d);if(o instanceof Comment&&o.data==="")throw new Error("Did you forget to passthrough the `ref` to the actual DOM node?")}})});function te(o){let E=I.value&&!A.value,p=$(d);!p||!(p instanceof HTMLElement)||E||(b.value=!0,v.value&&r(),v.value||f(),o(v.value?J(p,j,M,X,_,V=>{b.value=!1,V===G.Finished&&l()}):J(p,Y,Z,ee,_,V=>{b.value=!1,V===G.Finished&&(L(P)||(i.value="hidden",H(c),S()))})))}return C(()=>{le([v],(o,E,p)=>{te(p),I.value=!1},{immediate:!0})}),B(N,P),ue(w(()=>O(i.value,{["visible"]:u.Open,["hidden"]:u.Closed})|n.value)),()=>{let{appear:o,show:E,enter:p,enterFrom:V,enterTo:Ce,entered:ye,leave:be,leaveFrom:Ee,leaveTo:Ve,...U}=e,ne={ref:d},re={...U,...A.value&&v.value&&fe.isServer?{class:ae([a.class,U.class,...j,...M])}:{}};return q({theirProps:re,ourProps:ne,slot:{},slots:s,attrs:a,features:W,visible:i.value==="visible",name:"TransitionChild"})}}}),ce=he,Se=K({inheritAttrs:!1,props:{as:{type:[Object,String],default:"div"},show:{type:[Boolean],default:null},unmount:{type:[Boolean],default:!0},appear:{type:[Boolean],default:!1},enter:{type:[String],default:""},enterFrom:{type:[String],default:""},enterTo:{type:[String],default:""},entered:{type:[String],default:""},leave:{type:[String],default:""},leaveFrom:{type:[String],default:""},leaveTo:{type:[String],default:""}},emits:{beforeEnter:()=>!0,afterEnter:()=>!0,beforeLeave:()=>!0,afterLeave:()=>!0},setup(e,{emit:t,attrs:a,slots:s}){let h=oe(),n=w(()=>e.show===null&&h!==null?(h.value&u.Open)===u.Open:e.show);x(()=>{if(![!0,!1].includes(n.value))throw new Error('A <Transition /> is used but it is missing a `:show="true | false"` prop.')});let r=m(n.value?"visible":"hidden"),l=Q(()=>{r.value="hidden"}),f=m(!0),S={show:n,appear:w(()=>e.appear||!f.value)};return C(()=>{x(()=>{f.value=!1,n.value?r.value="visible":L(l)||(r.value="hidden")})}),B(N,l),B(R,S),()=>{let d=ve(e,["show","appear","unmount","onBeforeEnter","onBeforeLeave","onAfterEnter","onAfterLeave"]),y={unmount:e.unmount};return q({ourProps:{...y,as:"template"},theirProps:{},slot:{},slots:{...s,default:()=>[k(ce,{onBeforeEnter:()=>t("beforeEnter"),onAfterEnter:()=>t("afterEnter"),onBeforeLeave:()=>t("beforeLeave"),onAfterLeave:()=>t("afterLeave"),...a,...y,...d},s.default)]},attrs:{},features:W,visible:r.value==="visible",name:"Transition"})}}});export{he as TransitionChild,Se as TransitionRoot}; |
@@ -1,1 +0,1 @@ | ||
import{once as f}from'../../../utils/once.js';import{disposables as p}from'../../../utils/disposables.js';function m(e,...t){e&&t.length>0&&e.classList.add(...t)}function d(e,...t){e&&t.length>0&&e.classList.remove(...t)}var g=(i=>(i.Finished="finished",i.Cancelled="cancelled",i))(g||{});function F(e,t){let i=p();if(!e)return i.dispose;let{transitionDuration:n,transitionDelay:a}=getComputedStyle(e),[l,s]=[n,a].map(o=>{let[u=0]=o.split(",").filter(Boolean).map(r=>r.includes("ms")?parseFloat(r):parseFloat(r)*1e3).sort((r,c)=>c-r);return u});return l!==0?i.setTimeout(()=>t("finished"),l+s):t("finished"),i.add(()=>t("cancelled")),i.dispose}function L(e,t,i,n,a,l){let s=p(),o=l!==void 0?f(l):()=>{};return d(e,...a),m(e,...t,...i),s.nextFrame(()=>{d(e,...i),m(e,...n),s.add(F(e,u=>(d(e,...n,...t),m(e,...a),o(u))))}),s.add(()=>d(e,...t,...i,...n,...a)),s.add(()=>o("cancelled")),s.dispose}export{g as Reason,L as transition}; | ||
import{disposables as p}from'../../../utils/disposables.js';import{once as f}from'../../../utils/once.js';function m(e,...t){e&&t.length>0&&e.classList.add(...t)}function d(e,...t){e&&t.length>0&&e.classList.remove(...t)}var g=(i=>(i.Finished="finished",i.Cancelled="cancelled",i))(g||{});function F(e,t){let i=p();if(!e)return i.dispose;let{transitionDuration:n,transitionDelay:a}=getComputedStyle(e),[l,s]=[n,a].map(o=>{let[u=0]=o.split(",").filter(Boolean).map(r=>r.includes("ms")?parseFloat(r):parseFloat(r)*1e3).sort((r,c)=>c-r);return u});return l!==0?i.setTimeout(()=>t("finished"),l+s):t("finished"),i.add(()=>t("cancelled")),i.dispose}function L(e,t,i,n,a,l){let s=p(),o=l!==void 0?f(l):()=>{};return d(e,...a),m(e,...t,...i),s.nextFrame(()=>{d(e,...i),m(e,...n),s.add(F(e,u=>(d(e,...n,...t),m(e,...a),o(u))))}),s.add(()=>d(e,...t,...i,...n,...a)),s.add(()=>o("cancelled")),s.dispose}export{g as Reason,L as transition}; |
@@ -1,1 +0,1 @@ | ||
export*from'./components/combobox/combobox.js';export*from'./components/dialog/dialog.js';export*from'./components/disclosure/disclosure.js';export*from'./components/focus-trap/focus-trap.js';export*from'./components/listbox/listbox.js';export*from'./components/menu/menu.js';export*from'./components/popover/popover.js';export*from'./components/portal/portal.js';export*from'./components/radio-group/radio-group.js';export*from'./components/switch/switch.js';export*from'./components/tabs/tabs.js';export*from'./components/transitions/transition.js'; | ||
export*from'./components/combobox/combobox.js';export*from'./components/dialog/dialog.js';export*from'./components/disclosure/disclosure.js';export*from'./components/focus-trap/focus-trap.js';export*from'./components/listbox/listbox.js';export*from'./components/menu/menu.js';export*from'./components/popover/popover.js';import{Portal as l,PortalGroup as P}from'./components/portal/portal.js';export*from'./components/radio-group/radio-group.js';export*from'./components/switch/switch.js';export*from'./components/tabs/tabs.js';export*from'./components/transitions/transition.js';export{l as Portal,P as PortalGroup}; |
@@ -1,2 +0,2 @@ | ||
import { ComputedRef, UnwrapRef } from 'vue'; | ||
import { type ComputedRef, type UnwrapRef } from 'vue'; | ||
export declare function useControllable<T>(controlledValue: ComputedRef<T | undefined>, onChange?: (value: T) => void, defaultValue?: ComputedRef<T>): readonly [ComputedRef<T | UnwrapRef<T> | undefined>, (value: unknown) => void | undefined]; |
@@ -1,1 +0,1 @@ | ||
import{computed as p,ref as s}from"vue";function d(u,e,r){let i=s(r==null?void 0:r.value),f=p(()=>u.value!==void 0);return[p(()=>f.value?u.value:i.value),function(t){return f.value||(i.value=t),e==null?void 0:e(t)}]}export{d as useControllable}; | ||
import{computed as f,ref as s}from"vue";function T(u,e,r){let p=s(r==null?void 0:r.value),i=f(()=>u.value!==void 0);return[f(()=>i.value?u.value:p.value),function(t){return i.value||(p.value=t),e==null?void 0:e(t)}]}export{T as useControllable}; |
@@ -1,1 +0,2 @@ | ||
export declare function useDocumentEvent<TType extends keyof DocumentEventMap>(type: TType, listener: (this: Document, ev: DocumentEventMap[TType]) => any, options?: boolean | AddEventListenerOptions): void; | ||
import { type Ref } from 'vue'; | ||
export declare function useDocumentEvent<TType extends keyof DocumentEventMap>(enabled: Ref<boolean>, type: TType, listener: (this: Document, ev: DocumentEventMap[TType]) => any, options?: boolean | AddEventListenerOptions): void; |
@@ -1,1 +0,1 @@ | ||
import{watchEffect as r}from"vue";import{isServer as m}from'../utils/ssr.js';function v(e,t,n){m||r(o=>{document.addEventListener(e,t,n),o(()=>document.removeEventListener(e,t,n))})}export{v as useDocumentEvent}; | ||
import{watchEffect as m}from"vue";import{env as u}from'../utils/env.js';function c(o,e,t,n){u.isServer||m(r=>{o.value&&(document.addEventListener(e,t,n),r(()=>document.removeEventListener(e,t,n)))})}export{c as useDocumentEvent}; |
@@ -1,1 +0,1 @@ | ||
import{watchEffect as i}from"vue";import{isServer as a}from'../utils/ssr.js';function E(n,e,o,r){a||i(t=>{n=n!=null?n:window,n.addEventListener(e,o,r),t(()=>n.removeEventListener(e,o,r))})}export{E as useEventListener}; | ||
import{watchEffect as i}from"vue";import{env as a}from'../utils/env.js';function E(n,e,o,r){a.isServer||i(t=>{n=n!=null?n:window,n.addEventListener(e,o,r),t(()=>n.removeEventListener(e,o,r))})}export{E as useEventListener}; |
@@ -1,6 +0,6 @@ | ||
import { Ref, ComputedRef } from 'vue'; | ||
declare type Container = Ref<HTMLElement | null> | HTMLElement | null; | ||
declare type ContainerCollection = Container[] | Set<Container>; | ||
declare type ContainerInput = Container | ContainerCollection; | ||
export declare function useOutsideClick(containers: ContainerInput | (() => ContainerInput), cb: (event: MouseEvent | PointerEvent | FocusEvent, target: HTMLElement) => void, enabled?: ComputedRef<boolean>): void; | ||
import { type ComputedRef, type Ref } from 'vue'; | ||
type Container = Ref<HTMLElement | null> | HTMLElement | null; | ||
type ContainerCollection = Container[] | Set<Container>; | ||
type ContainerInput = Container | ContainerCollection; | ||
export declare function useOutsideClick(containers: ContainerInput | (() => ContainerInput), cb: (event: MouseEvent | PointerEvent | FocusEvent | TouchEvent, target: HTMLElement) => void, enabled?: ComputedRef<boolean>): void; | ||
export {}; |
@@ -1,1 +0,1 @@ | ||
import{computed as E,ref as s}from"vue";import{FocusableMode as C,isFocusableElement as d}from'../utils/focus-management.js';import{dom as p}from'../utils/dom.js';import{useDocumentEvent as l}from'./use-document-event.js';function y(f,m,i=E(()=>!0)){function a(e,u){if(!i.value||e.defaultPrevented)return;let n=u(e);if(n===null||!n.getRootNode().contains(n))return;let c=function o(t){return typeof t=="function"?o(t()):Array.isArray(t)||t instanceof Set?t:[t]}(f);for(let o of c){if(o===null)continue;let t=o instanceof HTMLElement?o:p(o);if(t!=null&&t.contains(n))return}return!d(n,C.Loose)&&n.tabIndex!==-1&&e.preventDefault(),m(e,n)}let r=s(null);l("mousedown",e=>{var u,n;i.value&&(r.value=((n=(u=e.composedPath)==null?void 0:u.call(e))==null?void 0:n[0])||e.target)},!0),l("click",e=>{!r.value||(a(e,()=>r.value),r.value=null)},!0),l("blur",e=>a(e,()=>window.document.activeElement instanceof HTMLIFrameElement?window.document.activeElement:null),!0)}export{y as useOutsideClick}; | ||
import{computed as p,ref as d}from"vue";import{dom as C}from'../utils/dom.js';import{FocusableMode as h,isFocusableElement as T}from'../utils/focus-management.js';import{isMobile as M}from'../utils/platform.js';import{useDocumentEvent as l}from'./use-document-event.js';import{useWindowEvent as y}from'./use-window-event.js';const f=30;function R(s,m,r=p(()=>!0)){function c(t,o){if(t.defaultPrevented)return;let e=o(t);if(e===null||!e.getRootNode().contains(e))return;let E=function u(n){return typeof n=="function"?u(n()):Array.isArray(n)||n instanceof Set?n:[n]}(s);for(let u of E){if(u===null)continue;let n=u instanceof HTMLElement?u:C(u);if(n!=null&&n.contains(e)||t.composed&&t.composedPath().includes(n))return}return!T(e,h.Loose)&&e.tabIndex!==-1&&t.preventDefault(),m(t,e)}let i=d(null);l(r,"pointerdown",t=>{var o,e;i.value=((e=(o=t.composedPath)==null?void 0:o.call(t))==null?void 0:e[0])||t.target},!0),l(r,"mousedown",t=>{var o,e;i.value=((e=(o=t.composedPath)==null?void 0:o.call(t))==null?void 0:e[0])||t.target},!0),l(r,"click",t=>{M()||i.value&&(c(t,()=>i.value),i.value=null)},!0);let a={x:0,y:0};l(r,"touchstart",t=>{a.x=t.touches[0].clientX,a.y=t.touches[0].clientY},!0),l(r,"touchend",t=>{let o={x:t.changedTouches[0].clientX,y:t.changedTouches[0].clientY};if(!(Math.abs(o.x-a.x)>=f||Math.abs(o.y-a.y)>=f))return c(t,()=>t.target instanceof HTMLElement?t.target:null)},!0),y(r,"blur",t=>c(t,()=>window.document.activeElement instanceof HTMLIFrameElement?window.document.activeElement:null),!0)}export{R as useOutsideClick}; |
@@ -1,5 +0,5 @@ | ||
import { Ref } from 'vue'; | ||
import { type ComponentPublicInstance, type Ref } from 'vue'; | ||
export declare function useResolveButtonType(data: Ref<{ | ||
as: string | object; | ||
type?: unknown; | ||
}>, refElement: Ref<HTMLElement | null>): Ref<unknown>; | ||
}>, refElement: Ref<HTMLElement | ComponentPublicInstance | null>): Ref<{} | undefined>; |
@@ -1,1 +0,1 @@ | ||
import{ref as f,onMounted as i,watchEffect as l}from"vue";import{dom as u}from'../utils/dom.js';function r(t,e){if(t)return t;let n=e!=null?e:"button";if(typeof n=="string"&&n.toLowerCase()==="button")return"button"}function b(t,e){let n=f(r(t.value.type,t.value.as));return i(()=>{n.value=r(t.value.type,t.value.as)}),l(()=>{var o;n.value||!u(e)||u(e)instanceof HTMLButtonElement&&!((o=u(e))!=null&&o.hasAttribute("type"))&&(n.value="button")}),n}export{b as useResolveButtonType}; | ||
import{onMounted as i,ref as f,watchEffect as l}from"vue";import{dom as o}from'../utils/dom.js';function r(t,e){if(t)return t;let n=e!=null?e:"button";if(typeof n=="string"&&n.toLowerCase()==="button")return"button"}function s(t,e){let n=f(r(t.value.type,t.value.as));return i(()=>{n.value=r(t.value.type,t.value.as)}),l(()=>{var u;n.value||o(e)&&o(e)instanceof HTMLButtonElement&&!((u=o(e))!=null&&u.hasAttribute("type"))&&(n.value="button")}),n}export{s as useResolveButtonType}; |
@@ -1,1 +0,1 @@ | ||
import{ref as a}from"vue";import{useWindowEvent as t}from'./use-window-event.js';var d=(r=>(r[r.Forwards=0]="Forwards",r[r.Backwards=1]="Backwards",r))(d||{});function n(){let o=a(0);return t("keydown",e=>{e.key==="Tab"&&(o.value=e.shiftKey?1:0)}),o}export{d as Direction,n as useTabDirection}; | ||
import{ref as o}from"vue";import{useWindowEvent as t}from'./use-window-event.js';var d=(r=>(r[r.Forwards=0]="Forwards",r[r.Backwards=1]="Backwards",r))(d||{});function s(){let e=o(0),a=o(!0);return t(a,"keydown",r=>{r.key==="Tab"&&(e.value=r.shiftKey?1:0)}),e}export{d as Direction,s as useTabDirection}; |
@@ -1,3 +0,3 @@ | ||
import { ComputedRef } from 'vue'; | ||
declare type AcceptNode = (node: HTMLElement) => typeof NodeFilter.FILTER_ACCEPT | typeof NodeFilter.FILTER_SKIP | typeof NodeFilter.FILTER_REJECT; | ||
import { type ComputedRef } from 'vue'; | ||
type AcceptNode = (node: HTMLElement) => typeof NodeFilter.FILTER_ACCEPT | typeof NodeFilter.FILTER_SKIP | typeof NodeFilter.FILTER_REJECT; | ||
export declare function useTreeWalker({ container, accept, walk, enabled, }: { | ||
@@ -4,0 +4,0 @@ container: ComputedRef<HTMLElement | null>; |
@@ -1,1 +0,1 @@ | ||
import{watchEffect as u}from"vue";import{getOwnerDocument as E}from'../utils/owner.js';function p({container:e,accept:t,walk:d,enabled:o}){u(()=>{let r=e.value;if(!r||o!==void 0&&!o.value)return;let l=E(e);if(!l)return;let c=Object.assign(f=>t(f),{acceptNode:t}),n=l.createTreeWalker(r,NodeFilter.SHOW_ELEMENT,c,!1);for(;n.nextNode();)d(n.currentNode)})}export{p as useTreeWalker}; | ||
import{watchEffect as p}from"vue";import{getOwnerDocument as u}from'../utils/owner.js';function i({container:e,accept:t,walk:d,enabled:o}){p(()=>{let r=e.value;if(!r||o!==void 0&&!o.value)return;let l=u(e);if(!l)return;let c=Object.assign(f=>t(f),{acceptNode:t}),n=l.createTreeWalker(r,NodeFilter.SHOW_ELEMENT,c,!1);for(;n.nextNode();)d(n.currentNode)})}export{i as useTreeWalker}; |
@@ -1,1 +0,2 @@ | ||
export declare function useWindowEvent<TType extends keyof WindowEventMap>(type: TType, listener: (this: Window, ev: WindowEventMap[TType]) => any, options?: boolean | AddEventListenerOptions): void; | ||
import { type Ref } from 'vue'; | ||
export declare function useWindowEvent<TType extends keyof WindowEventMap>(enabled: Ref<boolean>, type: TType, listener: (this: Window, ev: WindowEventMap[TType]) => any, options?: boolean | AddEventListenerOptions): void; |
@@ -1,1 +0,1 @@ | ||
import{watchEffect as i}from"vue";import{isServer as r}from'../utils/ssr.js';function w(e,n,t){r||i(o=>{window.addEventListener(e,n,t),o(()=>window.removeEventListener(e,n,t))})}export{w as useWindowEvent}; | ||
import{watchEffect as r}from"vue";import{env as d}from'../utils/env.js';function w(o,e,n,t){d.isServer||r(i=>{o.value&&(window.addEventListener(e,n,t),i(()=>window.removeEventListener(e,n,t)))})}export{w as useWindowEvent}; |
@@ -8,3 +8,3 @@ export * from './components/combobox/combobox.js'; | ||
export * from './components/popover/popover.js'; | ||
export * from './components/portal/portal.js'; | ||
export { Portal, PortalGroup } from './components/portal/portal.js'; | ||
export * from './components/radio-group/radio-group.js'; | ||
@@ -11,0 +11,0 @@ export * from './components/switch/switch.js'; |
@@ -1,1 +0,1 @@ | ||
export*from'./components/combobox/combobox.js';export*from'./components/dialog/dialog.js';export*from'./components/disclosure/disclosure.js';export*from'./components/focus-trap/focus-trap.js';export*from'./components/listbox/listbox.js';export*from'./components/menu/menu.js';export*from'./components/popover/popover.js';export*from'./components/portal/portal.js';export*from'./components/radio-group/radio-group.js';export*from'./components/switch/switch.js';export*from'./components/tabs/tabs.js';export*from'./components/transitions/transition.js'; | ||
export*from'./components/combobox/combobox.js';export*from'./components/dialog/dialog.js';export*from'./components/disclosure/disclosure.js';export*from'./components/focus-trap/focus-trap.js';export*from'./components/listbox/listbox.js';export*from'./components/menu/menu.js';export*from'./components/popover/popover.js';import{Portal as l,PortalGroup as P}from'./components/portal/portal.js';export*from'./components/radio-group/radio-group.js';export*from'./components/switch/switch.js';export*from'./components/tabs/tabs.js';export*from'./components/transitions/transition.js';export{l as Portal,P as PortalGroup}; |
@@ -1,1 +0,1 @@ | ||
import{h as i,ref as m,defineComponent as f}from"vue";import{Hidden as l,Features as F}from'./hidden.js';let d=f({props:{onFocus:{type:Function,required:!0}},setup(t){let n=m(!0);return()=>n.value?i(l,{as:"button",type:"button",features:F.Focusable,onFocus(o){o.preventDefault();let e,a=50;function r(){var u;if(a--<=0){e&&cancelAnimationFrame(e);return}if((u=t.onFocus)!=null&&u.call(t)){n.value=!1,cancelAnimationFrame(e);return}e=requestAnimationFrame(r)}e=requestAnimationFrame(r)}}):null}});export{d as FocusSentinel}; | ||
import{defineComponent as i,h as m,ref as f}from"vue";import{Features as l,Hidden as F}from'./hidden.js';let d=i({props:{onFocus:{type:Function,required:!0}},setup(t){let n=f(!0);return()=>n.value?m(F,{as:"button",type:"button",features:l.Focusable,onFocus(o){o.preventDefault();let e,a=50;function r(){var u;if(a--<=0){e&&cancelAnimationFrame(e);return}if((u=t.onFocus)!=null&&u.call(t)){n.value=!1,cancelAnimationFrame(e);return}e=requestAnimationFrame(r)}e=requestAnimationFrame(r)}}):null}});export{d as FocusSentinel}; |
@@ -1,2 +0,2 @@ |
import { PropType } from 'vue'; |
import { type PropType } from 'vue'; |
export declare enum Features { |
@@ -3,0 +3,0 @@ None = 1, |
@@ -1,1 +0,1 @@ |
import{defineComponent as i}from"vue";import{render as p}from'../utils/render.js';var a=(e=>(e[e.None=1]="None",e[e.Focusable=2]="Focusable",e[e.Hidden=4]="Hidden",e))(a||{});let f=i({name:"Hidden",props:{as:{type:[Object,String],default:"div"},features:{type:Number,default:1}},setup(r,{slots:t,attrs:d}){return()=>{let{features:e,...o}=r,n={"aria-hidden":(e&2)===2?!0:void 0,style:{position:"fixed",top:1,left:1,width:1,height:0,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0",...(e&4)===4&&(e&2)!==2&&{display:"none"}}};return p({ourProps:n,theirProps:o,slot:{},attrs:d,slots:t,name:"Hidden"})}}});export{a as Features,f as Hidden}; |
import{defineComponent as a}from"vue";import{render as p}from'../utils/render.js';var u=(e=>(e[e.None=1]="None",e[e.Focusable=2]="Focusable",e[e.Hidden=4]="Hidden",e))(u||{});let f=a({name:"Hidden",props:{as:{type:[Object,String],default:"div"},features:{type:Number,default:1}},setup(t,{slots:n,attrs:i}){return()=>{var r;let{features:e,...d}=t,o={"aria-hidden":(e&2)===2?!0:(r=d["aria-hidden"])!=null?r:void 0,hidden:(e&4)===4?!0:void 0,style:{position:"fixed",top:1,left:1,width:1,height:0,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0",...(e&4)===4&&(e&2)!==2&&{display:"none"}}};return p({ourProps:o,theirProps:d,slot:{},attrs:i,slots:n,name:"Hidden"})}}});export{u as Features,f as Hidden}; |
@@ -1,5 +0,7 @@ | ||
import { Ref } from 'vue'; | ||
import { type Ref } from 'vue'; | ||
export declare enum State { | ||
Open = 0, | ||
Closed = 1 | ||
Open = 1, | ||
Closed = 2, | ||
Closing = 4, | ||
Opening = 8 | ||
} | ||
@@ -6,0 +8,0 @@ export declare function hasOpenClosed(): boolean; |
@@ -1,1 +0,1 @@ | ||
import{inject as t,provide as r}from"vue";let n=Symbol("Context");var l=(e=>(e[e.Open=0]="Open",e[e.Closed=1]="Closed",e))(l||{});function f(){return p()!==null}function p(){return t(n,null)}function c(o){r(n,o)}export{l as State,f as hasOpenClosed,p as useOpenClosed,c as useOpenClosedProvider}; | ||
import{inject as p,provide as r}from"vue";let n=Symbol("Context");var i=(e=>(e[e.Open=1]="Open",e[e.Closed=2]="Closed",e[e.Closing=4]="Closing",e[e.Opening=8]="Opening",e))(i||{});function s(){return l()!==null}function l(){return p(n,null)}function t(o){r(n,o)}export{i as State,s as hasOpenClosed,l as useOpenClosed,t as useOpenClosedProvider}; |
@@ -1,1 +0,1 @@ | ||
import{defineComponent as l,inject as a,provide as c}from"vue";import{render as p}from'../utils/render.js';let e=Symbol("ForcePortalRootContext");function u(){return a(e,!1)}let P=l({name:"ForcePortalRoot",props:{as:{type:[Object,String],default:"template"},force:{type:Boolean,default:!1}},setup(o,{slots:t,attrs:r}){return c(e,o.force),()=>{let{force:f,...n}=o;return p({theirProps:n,ourProps:{},slot:{},slots:t,attrs:r,name:"ForcePortalRoot"})}}});export{P as ForcePortalRoot,u as usePortalRoot}; | ||
import{defineComponent as l,inject as a,provide as c}from"vue";import{render as p}from'../utils/render.js';let e=Symbol("ForcePortalRootContext");function s(){return a(e,!1)}let u=l({name:"ForcePortalRoot",props:{as:{type:[Object,String],default:"template"},force:{type:Boolean,default:!1}},setup(o,{slots:t,attrs:r}){return c(e,o.force),()=>{let{force:f,...n}=o;return p({theirProps:n,ourProps:{},slot:{},slots:t,attrs:r,name:"ForcePortalRoot"})}}});export{u as ForcePortalRoot,s as usePortalRoot}; |
@@ -1,3 +0,3 @@ | ||
import { Ref } from 'vue'; | ||
declare type OnUpdate = (message: StackMessage, type: string, element: Ref<HTMLElement | null>) => void; | ||
import { type Ref } from 'vue'; | ||
type OnUpdate = (message: StackMessage, type: string, element: Ref<HTMLElement | null>) => void; | ||
export declare enum StackMessage { | ||
@@ -4,0 +4,0 @@ Add = 0, |
@@ -1,1 +0,1 @@ | ||
import{inject as f,provide as m,onMounted as l,onUnmounted as c,watch as s}from"vue";let u=Symbol("StackContext");var p=(e=>(e[e.Add=0]="Add",e[e.Remove=1]="Remove",e))(p||{});function v(){return f(u,()=>{})}function S({type:o,enabled:r,element:e,onUpdate:i}){let a=v();function t(...n){i==null||i(...n),a(...n)}l(()=>{s(r,(n,d)=>{n?t(0,o,e):d===!0&&t(1,o,e)},{immediate:!0,flush:"sync"})}),c(()=>{r.value&&t(1,o,e)}),m(u,t)}export{p as StackMessage,v as useStackContext,S as useStackProvider}; | ||
import{inject as f,onMounted as m,onUnmounted as l,provide as c,watch as p}from"vue";let u=Symbol("StackContext");var s=(e=>(e[e.Add=0]="Add",e[e.Remove=1]="Remove",e))(s||{});function y(){return f(u,()=>{})}function R({type:o,enabled:r,element:e,onUpdate:i}){let a=y();function t(...n){i==null||i(...n),a(...n)}m(()=>{p(r,(n,d)=>{n?t(0,o,e):d===!0&&t(1,o,e)},{immediate:!0,flush:"sync"})}),l(()=>{r.value&&t(1,o,e)}),c(u,t)}export{s as StackMessage,y as useStackContext,R as useStackProvider}; |
@@ -23,4 +23,4 @@ export declare enum Focus { | ||
resolveActiveIndex(): number | null; | ||
resolveId(item: TItem): string; | ||
resolveDisabled(item: TItem): boolean; | ||
resolveId(item: TItem, index: number, items: TItem[]): string; | ||
resolveDisabled(item: TItem, index: number, items: TItem[]): boolean; | ||
}): number | null; |
@@ -1,1 +0,1 @@ | ||
function f(r){throw new Error("Unexpected object: "+r)}var a=(e=>(e[e.First=0]="First",e[e.Previous=1]="Previous",e[e.Next=2]="Next",e[e.Last=3]="Last",e[e.Specific=4]="Specific",e[e.Nothing=5]="Nothing",e))(a||{});function x(r,n){let t=n.resolveItems();if(t.length<=0)return null;let l=n.resolveActiveIndex(),s=l!=null?l:-1,d=(()=>{switch(r.focus){case 0:return t.findIndex(e=>!n.resolveDisabled(e));case 1:{let e=t.slice().reverse().findIndex((i,c,u)=>s!==-1&&u.length-c-1>=s?!1:!n.resolveDisabled(i));return e===-1?e:t.length-1-e}case 2:return t.findIndex((e,i)=>i<=s?!1:!n.resolveDisabled(e));case 3:{let e=t.slice().reverse().findIndex(i=>!n.resolveDisabled(i));return e===-1?e:t.length-1-e}case 4:return t.findIndex(e=>n.resolveId(e)===r.id);case 5:return null;default:f(r)}})();return d===-1?l:d}export{a as Focus,x as calculateActiveIndex}; | ||
function u(l){throw new Error("Unexpected object: "+l)}var c=(i=>(i[i.First=0]="First",i[i.Previous=1]="Previous",i[i.Next=2]="Next",i[i.Last=3]="Last",i[i.Specific=4]="Specific",i[i.Nothing=5]="Nothing",i))(c||{});function f(l,n){let t=n.resolveItems();if(t.length<=0)return null;let r=n.resolveActiveIndex(),s=r!=null?r:-1;switch(l.focus){case 0:{for(let e=0;e<t.length;++e)if(!n.resolveDisabled(t[e],e,t))return e;return r}case 1:{s===-1&&(s=t.length);for(let e=s-1;e>=0;--e)if(!n.resolveDisabled(t[e],e,t))return e;return r}case 2:{for(let e=s+1;e<t.length;++e)if(!n.resolveDisabled(t[e],e,t))return e;return r}case 3:{for(let e=t.length-1;e>=0;--e)if(!n.resolveDisabled(t[e],e,t))return e;return r}case 4:{for(let e=0;e<t.length;++e)if(n.resolveId(t[e],e,t)===l.id)return e;return r}case 5:return null;default:u(l)}}export{c as Focus,f as calculateActiveIndex}; |
@@ -0,10 +1,12 @@ | ||
export type Disposables = ReturnType<typeof disposables>; | ||
export declare function disposables(): { | ||
enqueue(fn: Function): void; | ||
addEventListener<TEventName extends keyof WindowEventMap>(element: HTMLElement | Document, name: TEventName, listener: (event: WindowEventMap[TEventName]) => any, options?: boolean | AddEventListenerOptions | undefined): void; | ||
addEventListener<TEventName extends keyof WindowEventMap>(element: HTMLElement | Window | Document, name: TEventName, listener: (event: WindowEventMap[TEventName]) => any, options?: boolean | AddEventListenerOptions): () => void; | ||
requestAnimationFrame(callback: FrameRequestCallback): void; | ||
nextFrame(callback: FrameRequestCallback): void; | ||
setTimeout(callback: (...args: any[]) => void, ms?: number | undefined, ...args: any[]): void; | ||
add(cb: () => void): void; | ||
microTask(cb: () => void): () => void; | ||
style(node: HTMLElement, property: string, value: string): () => void; | ||
group(cb: (d: typeof this) => void): () => void; | ||
add(cb: () => void): () => void; | ||
dispose(): void; | ||
workQueue(): Promise<void>; | ||
}; |
@@ -1,1 +0,1 @@ | ||
function s(){let a=[],i=[],t={enqueue(e){i.push(e)},addEventListener(e,n,o,r){return e.addEventListener(n,o,r),t.add(()=>e.removeEventListener(n,o,r))},requestAnimationFrame(...e){let n=requestAnimationFrame(...e);t.add(()=>cancelAnimationFrame(n))},nextFrame(...e){t.requestAnimationFrame(()=>{t.requestAnimationFrame(...e)})},setTimeout(...e){let n=setTimeout(...e);t.add(()=>clearTimeout(n))},add(e){a.push(e)},dispose(){for(let e of a.splice(0))e()},async workQueue(){for(let e of i.splice(0))await e()}};return t}export{s as disposables}; | ||
import{microTask as n}from'./micro-task.js';function o(){let a=[],s={addEventListener(e,t,r,i){return e.addEventListener(t,r,i),s.add(()=>e.removeEventListener(t,r,i))},requestAnimationFrame(...e){let t=requestAnimationFrame(...e);s.add(()=>cancelAnimationFrame(t))},nextFrame(...e){s.requestAnimationFrame(()=>{s.requestAnimationFrame(...e)})},setTimeout(...e){let t=setTimeout(...e);s.add(()=>clearTimeout(t))},microTask(...e){let t={current:!0};return n(()=>{t.current&&e[0]()}),s.add(()=>{t.current=!1})},style(e,t,r){let i=e.style.getPropertyValue(t);return Object.assign(e.style,{[t]:r}),this.add(()=>{Object.assign(e.style,{[t]:i})})},group(e){let t=o();return e(t),this.add(()=>t.dispose())},add(e){return a.push(e),()=>{let t=a.indexOf(e);if(t>=0)for(let r of a.splice(t,1))r()}},dispose(){for(let e of a.splice(0))e()}};return s}export{o as disposables}; |
@@ -1,2 +0,4 @@ | ||
import { Ref, ComponentPublicInstance } from 'vue'; | ||
export declare function dom<T extends Element | ComponentPublicInstance>(ref?: Ref<T | null>): T | null; | ||
import type { ComponentPublicInstance, Ref } from 'vue'; | ||
type AsElement<T extends HTMLElement | ComponentPublicInstance> = (T extends HTMLElement ? T : HTMLElement) | null; | ||
export declare function dom<T extends HTMLElement | ComponentPublicInstance>(ref?: Ref<T | null>): AsElement<T> | null; | ||
export {}; |
@@ -1,1 +0,1 @@ | ||
function o(n){var l;return n==null||n.value==null?null:(l=n.value.$el)!=null?l:n.value}export{o as dom}; | ||
function t(e){var l;if(e==null||e.value==null)return null;let n=(l=e.value.$el)!=null?l:e.value;return n instanceof Node?n:null}export{t as dom}; |
@@ -0,1 +1,2 @@ | ||
export declare let focusableSelector: string; | ||
export declare enum Focus { | ||
@@ -33,2 +34,6 @@ /** Focus the first non-disabled element */ | ||
export declare function focusFrom(current: HTMLElement | null, focus: Focus): FocusResult; | ||
export declare function focusIn(container: HTMLElement | HTMLElement[], focus: Focus, sorted?: boolean, active?: HTMLElement | null): FocusResult; | ||
export declare function focusIn(container: HTMLElement | HTMLElement[], focus: Focus, { sorted, relativeTo, skipElements, }?: Partial<{ | ||
sorted: boolean; | ||
relativeTo: HTMLElement | null; | ||
skipElements: HTMLElement[]; | ||
}>): FocusResult; |
@@ -1,1 +0,1 @@ | ||
import{nextTick as T}from"vue";import{match as L}from'./match.js';import{getOwnerDocument as d}from'./owner.js';let m=["[contentEditable=true]","[tabindex]","a[href]","area[href]","button:not([disabled])","iframe","input:not([disabled])","select:not([disabled])","textarea:not([disabled])"].map(e=>`${e}:not([tabindex='-1'])`).join(",");var M=(n=>(n[n.First=1]="First",n[n.Previous=2]="Previous",n[n.Next=4]="Next",n[n.Last=8]="Last",n[n.WrapAround=16]="WrapAround",n[n.NoScroll=32]="NoScroll",n))(M||{}),N=(o=>(o[o.Error=0]="Error",o[o.Overflow=1]="Overflow",o[o.Success=2]="Success",o[o.Underflow=3]="Underflow",o))(N||{}),b=(r=>(r[r.Previous=-1]="Previous",r[r.Next=1]="Next",r))(b||{});function E(e=document.body){return e==null?[]:Array.from(e.querySelectorAll(m))}var F=(r=>(r[r.Strict=0]="Strict",r[r.Loose=1]="Loose",r))(F||{});function h(e,t=0){var r;return e===((r=d(e))==null?void 0:r.body)?!1:L(t,{[0](){return e.matches(m)},[1](){let l=e;for(;l!==null;){if(l.matches(m))return!0;l=l.parentElement}return!1}})}function D(e){let t=d(e);T(()=>{t&&!h(t.activeElement,0)&&w(e)})}function w(e){e==null||e.focus({preventScroll:!0})}let H=["textarea","input"].join(",");function S(e){var t,r;return(r=(t=e==null?void 0:e.matches)==null?void 0:t.call(e,H))!=null?r:!1}function O(e,t=r=>r){return e.slice().sort((r,l)=>{let o=t(r),s=t(l);if(o===null||s===null)return 0;let n=o.compareDocumentPosition(s);return n&Node.DOCUMENT_POSITION_FOLLOWING?-1:n&Node.DOCUMENT_POSITION_PRECEDING?1:0})}function v(e,t){return P(E(),t,!0,e)}function P(e,t,r=!0,l=null){var c;let o=(c=Array.isArray(e)?e.length>0?e[0].ownerDocument:document:e==null?void 0:e.ownerDocument)!=null?c:document,s=Array.isArray(e)?r?O(e):e:E(e);l=l!=null?l:o.activeElement;let n=(()=>{if(t&5)return 1;if(t&10)return-1;throw new Error("Missing Focus.First, Focus.Previous, Focus.Next or Focus.Last")})(),x=(()=>{if(t&1)return 0;if(t&2)return Math.max(0,s.indexOf(l))-1;if(t&4)return Math.max(0,s.indexOf(l))+1;if(t&8)return s.length-1;throw new Error("Missing Focus.First, Focus.Previous, Focus.Next or Focus.Last")})(),p=t&32?{preventScroll:!0}:{},a=0,i=s.length,u;do{if(a>=i||a+i<=0)return 0;let f=x+a;if(t&16)f=(f+i)%i;else{if(f<0)return 3;if(f>=i)return 1}u=s[f],u==null||u.focus(p),a+=n}while(u!==o.activeElement);return t&6&&S(u)&&u.select(),u.hasAttribute("tabindex")||u.setAttribute("tabindex","0"),2}export{M as Focus,N as FocusResult,F as FocusableMode,w as focusElement,v as focusFrom,P as focusIn,E as getFocusableElements,h as isFocusableElement,D as restoreFocusIfNecessary,O as sortByDomNode}; | ||
import{nextTick as b}from"vue";import{match as M}from'./match.js';import{getOwnerDocument as f}from'./owner.js';let c=["[contentEditable=true]","[tabindex]","a[href]","area[href]","button:not([disabled])","iframe","input:not([disabled])","select:not([disabled])","textarea:not([disabled])"].map(e=>`${e}:not([tabindex='-1'])`).join(",");var N=(n=>(n[n.First=1]="First",n[n.Previous=2]="Previous",n[n.Next=4]="Next",n[n.Last=8]="Last",n[n.WrapAround=16]="WrapAround",n[n.NoScroll=32]="NoScroll",n))(N||{}),T=(o=>(o[o.Error=0]="Error",o[o.Overflow=1]="Overflow",o[o.Success=2]="Success",o[o.Underflow=3]="Underflow",o))(T||{}),F=(t=>(t[t.Previous=-1]="Previous",t[t.Next=1]="Next",t))(F||{});function E(e=document.body){return e==null?[]:Array.from(e.querySelectorAll(c)).sort((r,t)=>Math.sign((r.tabIndex||Number.MAX_SAFE_INTEGER)-(t.tabIndex||Number.MAX_SAFE_INTEGER)))}var h=(t=>(t[t.Strict=0]="Strict",t[t.Loose=1]="Loose",t))(h||{});function w(e,r=0){var t;return e===((t=f(e))==null?void 0:t.body)?!1:M(r,{[0](){return e.matches(c)},[1](){let l=e;for(;l!==null;){if(l.matches(c))return!0;l=l.parentElement}return!1}})}function _(e){let r=f(e);b(()=>{r&&!w(r.activeElement,0)&&S(e)})}var y=(t=>(t[t.Keyboard=0]="Keyboard",t[t.Mouse=1]="Mouse",t))(y||{});typeof window!="undefined"&&typeof document!="undefined"&&(document.addEventListener("keydown",e=>{e.metaKey||e.altKey||e.ctrlKey||(document.documentElement.dataset.headlessuiFocusVisible="")},!0),document.addEventListener("click",e=>{e.detail===1?delete document.documentElement.dataset.headlessuiFocusVisible:e.detail===0&&(document.documentElement.dataset.headlessuiFocusVisible="")},!0));function S(e){e==null||e.focus({preventScroll:!0})}let H=["textarea","input"].join(",");function I(e){var r,t;return(t=(r=e==null?void 0:e.matches)==null?void 0:r.call(e,H))!=null?t:!1}function O(e,r=t=>t){return e.slice().sort((t,l)=>{let o=r(t),i=r(l);if(o===null||i===null)return 0;let n=o.compareDocumentPosition(i);return n&Node.DOCUMENT_POSITION_FOLLOWING?-1:n&Node.DOCUMENT_POSITION_PRECEDING?1:0})}function v(e,r){return P(E(),r,{relativeTo:e})}function P(e,r,{sorted:t=!0,relativeTo:l=null,skipElements:o=[]}={}){var m;let i=(m=Array.isArray(e)?e.length>0?e[0].ownerDocument:document:e==null?void 0:e.ownerDocument)!=null?m:document,n=Array.isArray(e)?t?O(e):e:E(e);o.length>0&&n.length>1&&(n=n.filter(s=>!o.includes(s))),l=l!=null?l:i.activeElement;let x=(()=>{if(r&5)return 1;if(r&10)return-1;throw new Error("Missing Focus.First, Focus.Previous, Focus.Next or Focus.Last")})(),p=(()=>{if(r&1)return 0;if(r&2)return Math.max(0,n.indexOf(l))-1;if(r&4)return Math.max(0,n.indexOf(l))+1;if(r&8)return n.length-1;throw new Error("Missing Focus.First, Focus.Previous, Focus.Next or Focus.Last")})(),L=r&32?{preventScroll:!0}:{},a=0,d=n.length,u;do{if(a>=d||a+d<=0)return 0;let s=p+a;if(r&16)s=(s+d)%d;else{if(s<0)return 3;if(s>=d)return 1}u=n[s],u==null||u.focus(L),a+=x}while(u!==i.activeElement);return r&6&&I(u)&&u.select(),2}export{N as Focus,T as FocusResult,h as FocusableMode,S as focusElement,v as focusFrom,P as focusIn,c as focusableSelector,E as getFocusableElements,w as isFocusableElement,_ as restoreFocusIfNecessary,O as sortByDomNode}; |
@@ -1,4 +0,4 @@ | ||
declare type Entries = [string, string][]; | ||
type Entries = [string, string][]; | ||
export declare function objectToFormEntries(source?: Record<string, any>, parentKey?: string | null, entries?: Entries): Entries; | ||
export declare function attemptSubmit(element: HTMLElement): void; | ||
export declare function attemptSubmit(elementInForm: HTMLElement): void; | ||
export {}; |
@@ -1,1 +0,1 @@ | ||
function e(n={},r=null,t=[]){for(let[i,o]of Object.entries(n))f(t,s(r,i),o);return t}function s(n,r){return n?n+"["+r+"]":r}function f(n,r,t){if(Array.isArray(t))for(let[i,o]of t.entries())f(n,s(r,i.toString()),o);else t instanceof Date?n.push([r,t.toISOString()]):typeof t=="boolean"?n.push([r,t?"1":"0"]):typeof t=="string"?n.push([r,t]):typeof t=="number"?n.push([r,`${t}`]):t==null?n.push([r,""]):e(t,r,n)}function p(n){var t;let r=(t=n==null?void 0:n.form)!=null?t:n.closest("form");if(!!r){for(let i of r.elements)if(i.tagName==="INPUT"&&i.type==="submit"||i.tagName==="BUTTON"&&i.type==="submit"||i.nodeName==="INPUT"&&i.type==="image"){i.click();return}}}export{p as attemptSubmit,e as objectToFormEntries}; | ||
function e(i={},s=null,t=[]){for(let[r,n]of Object.entries(i))o(t,f(s,r),n);return t}function f(i,s){return i?i+"["+s+"]":s}function o(i,s,t){if(Array.isArray(t))for(let[r,n]of t.entries())o(i,f(s,r.toString()),n);else t instanceof Date?i.push([s,t.toISOString()]):typeof t=="boolean"?i.push([s,t?"1":"0"]):typeof t=="string"?i.push([s,t]):typeof t=="number"?i.push([s,`${t}`]):t==null?i.push([s,""]):e(t,s,i)}function p(i){var t,r;let s=(t=i==null?void 0:i.form)!=null?t:i.closest("form");if(s){for(let n of s.elements)if(n!==i&&(n.tagName==="INPUT"&&n.type==="submit"||n.tagName==="BUTTON"&&n.type==="submit"||n.nodeName==="INPUT"&&n.type==="image")){n.click();return}(r=s.requestSubmit)==null||r.call(s)}}export{p as attemptSubmit,e as objectToFormEntries}; |
@@ -1,2 +0,2 @@ | ||
import { Ref } from 'vue'; | ||
export declare function getOwnerDocument<T extends Element | Ref<Element | null>>(element: T | null | undefined): Document | null; | ||
import type { Ref } from 'vue'; | ||
export declare function getOwnerDocument<T extends HTMLElement | Ref<HTMLElement | null>>(element: T | null | undefined): Document | null; |
@@ -1,1 +0,1 @@ | ||
import{dom as n}from'./dom.js';import{isServer as t}from'./ssr.js';function m(r){if(t)return null;if(r instanceof Node)return r.ownerDocument;if(r!=null&&r.hasOwnProperty("value")){let o=n(r);if(o)return o.ownerDocument}return document}export{m as getOwnerDocument}; | ||
import{dom as o}from'./dom.js';import{env as t}from'./env.js';function f(r){if(t.isServer)return null;if(r instanceof Node)return r.ownerDocument;if(r!=null&&r.hasOwnProperty("value")){let n=o(r);if(n)return n.ownerDocument}return document}export{f as getOwnerDocument}; |
export declare function isIOS(): boolean; | ||
export declare function isAndroid(): boolean; | ||
export declare function isMobile(): boolean; |
@@ -1,1 +0,1 @@ | ||
function o(){return/iPhone/gi.test(window.navigator.platform)||/Mac/gi.test(window.navigator.platform)&&window.navigator.maxTouchPoints>0}export{o as isIOS}; | ||
function t(){return/iPhone/gi.test(window.navigator.platform)||/Mac/gi.test(window.navigator.platform)&&window.navigator.maxTouchPoints>0}function i(){return/Android/gi.test(window.navigator.userAgent)}function n(){return t()||i()}export{i as isAndroid,t as isIOS,n as isMobile}; |
@@ -1,2 +0,2 @@ | ||
import { Slots, VNode } from 'vue'; | ||
import { type Slots, type VNode } from 'vue'; | ||
export declare enum Features { | ||
@@ -3,0 +3,0 @@ /** No features at all */ |
@@ -1,4 +0,4 @@ | ||
import{h as m,cloneVNode as h,Fragment as b}from"vue";import{match as j}from'./match.js';var R=(o=>(o[o.None=0]="None",o[o.RenderStrategy=1]="RenderStrategy",o[o.Static=2]="Static",o))(R||{}),O=(e=>(e[e.Unmount=0]="Unmount",e[e.Hidden=1]="Hidden",e))(O||{});function P({visible:r=!0,features:t=0,ourProps:e,theirProps:o,...i}){var a;let n=k(o,e),s=Object.assign(i,{props:n});if(r||t&2&&n.static)return p(s);if(t&1){let l=(a=n.unmount)==null||a?0:1;return j(l,{[0](){return null},[1](){return p({...i,props:{...n,hidden:!0,style:{display:"none"}}})}})}return p(s)}function p({props:r,attrs:t,slots:e,slot:o,name:i}){var y;let{as:n,...s}=w(r,["unmount","static"]),a=(y=e.default)==null?void 0:y.call(e,o),l={};if(o){let d=!1,u=[];for(let[f,c]of Object.entries(o))typeof c=="boolean"&&(d=!0),c===!0&&u.push(f);d&&(l["data-headlessui-state"]=u.join(" "))}if(n==="template"){if(a=g(a!=null?a:[]),Object.keys(s).length>0||Object.keys(t).length>0){let[d,...u]=a!=null?a:[];if(!x(d)||u.length>0)throw new Error(['Passing props on "template"!',"",`The current component <${i} /> is rendering a "template".`,"However we need to passthrough the following props:",Object.keys(s).concat(Object.keys(t)).sort((f,c)=>f.localeCompare(c)).map(f=>` - ${f}`).join(` | ||
`),"","You can apply a few solutions:",['Add an `as="..."` prop, to ensure that we render an actual element instead of a "template".',"Render a single element as the child so that we can forward the props onto that element."].map(f=>` - ${f}`).join(` | ||
import{cloneVNode as O,Fragment as x,h as k}from"vue";import{match as w}from'./match.js';var N=(o=>(o[o.None=0]="None",o[o.RenderStrategy=1]="RenderStrategy",o[o.Static=2]="Static",o))(N||{}),S=(e=>(e[e.Unmount=0]="Unmount",e[e.Hidden=1]="Hidden",e))(S||{});function A({visible:r=!0,features:t=0,ourProps:e,theirProps:o,...i}){var a;let n=j(o,e),l=Object.assign(i,{props:n});if(r||t&2&&n.static)return y(l);if(t&1){let d=(a=n.unmount)==null||a?0:1;return w(d,{[0](){return null},[1](){return y({...i,props:{...n,hidden:!0,style:{display:"none"}}})}})}return y(l)}function y({props:r,attrs:t,slots:e,slot:o,name:i}){var m,h;let{as:n,...l}=T(r,["unmount","static"]),a=(m=e.default)==null?void 0:m.call(e,o),d={};if(o){let u=!1,c=[];for(let[p,f]of Object.entries(o))typeof f=="boolean"&&(u=!0),f===!0&&c.push(p);u&&(d["data-headlessui-state"]=c.join(" "))}if(n==="template"){if(a=b(a!=null?a:[]),Object.keys(l).length>0||Object.keys(t).length>0){let[u,...c]=a!=null?a:[];if(!v(u)||c.length>0)throw new Error(['Passing props on "template"!',"",`The current component <${i} /> is rendering a "template".`,"However we need to passthrough the following props:",Object.keys(l).concat(Object.keys(t)).map(s=>s.trim()).filter((s,g,R)=>R.indexOf(s)===g).sort((s,g)=>s.localeCompare(g)).map(s=>` - ${s}`).join(` | ||
`),"","You can apply a few solutions:",['Add an `as="..."` prop, to ensure that we render an actual element instead of a "template".',"Render a single element as the child so that we can forward the props onto that element."].map(s=>` - ${s}`).join(` | ||
`)].join(` | ||
`));return h(d,Object.assign({},s,l))}return Array.isArray(a)&&a.length===1?a[0]:a}return m(n,Object.assign({},s,l),{default:()=>a})}function g(r){return r.flatMap(t=>t.type===b?g(t.children):[t])}function k(...r){var o;if(r.length===0)return{};if(r.length===1)return r[0];let t={},e={};for(let i of r)for(let n in i)n.startsWith("on")&&typeof i[n]=="function"?((o=e[n])!=null||(e[n]=[]),e[n].push(i[n])):t[n]=i[n];if(t.disabled||t["aria-disabled"])return Object.assign(t,Object.fromEntries(Object.keys(e).map(i=>[i,void 0])));for(let i in e)Object.assign(t,{[i](n,...s){let a=e[i];for(let l of a){if(n instanceof Event&&n.defaultPrevented)return;l(n,...s)}}});return t}function V(r){let t=Object.assign({},r);for(let e in t)t[e]===void 0&&delete t[e];return t}function w(r,t=[]){let e=Object.assign({},r);for(let o of t)o in e&&delete e[o];return e}function x(r){return r==null?!1:typeof r.type=="string"||typeof r.type=="object"||typeof r.type=="function"}export{R as Features,O as RenderStrategy,V as compact,w as omit,P as render}; | ||
`));let p=j((h=u.props)!=null?h:{},l,d),f=O(u,p,!0);for(let s in p)s.startsWith("on")&&(f.props||(f.props={}),f.props[s]=p[s]);return f}return Array.isArray(a)&&a.length===1?a[0]:a}return k(n,Object.assign({},l,d),{default:()=>a})}function b(r){return r.flatMap(t=>t.type===x?b(t.children):[t])}function j(...r){var o;if(r.length===0)return{};if(r.length===1)return r[0];let t={},e={};for(let i of r)for(let n in i)n.startsWith("on")&&typeof i[n]=="function"?((o=e[n])!=null||(e[n]=[]),e[n].push(i[n])):t[n]=i[n];if(t.disabled||t["aria-disabled"])return Object.assign(t,Object.fromEntries(Object.keys(e).map(i=>[i,void 0])));for(let i in e)Object.assign(t,{[i](n,...l){let a=e[i];for(let d of a){if(n instanceof Event&&n.defaultPrevented)return;d(n,...l)}}});return t}function E(r){let t=Object.assign({},r);for(let e in t)t[e]===void 0&&delete t[e];return t}function T(r,t=[]){let e=Object.assign({},r);for(let o of t)o in e&&delete e[o];return e}function v(r){return r==null?!1:typeof r.type=="string"||typeof r.type=="object"||typeof r.type=="function"}export{N as Features,S as RenderStrategy,E as compact,T as omit,A as render}; |
{ | ||
"name": "@headlessui/vue", | ||
"version": "0.0.0-insiders.ef3e154", | ||
"version": "0.0.0-insiders.ef78d58", | ||
"description": "A set of completely unstyled, fully accessible UI components for Vue 3, designed to integrate beautifully with Tailwind CSS.", | ||
@@ -14,5 +14,8 @@ "main": "dist/index.cjs", | ||
"exports": { | ||
"types": { | ||
"import": "./dist/index.d.ts", | ||
"require": "./dist/index.d.cts" | ||
}, | ||
"import": "./dist/headlessui.esm.js", | ||
"require": "./dist/index.cjs", | ||
"types": "./dist/index.d.ts" | ||
"require": "./dist/index.cjs" | ||
}, | ||
@@ -38,3 +41,4 @@ "type": "module", | ||
"lint": "../../scripts/lint.sh", | ||
"playground": "yarn workspace playground-vue dev", | ||
"lint-types": "npm run attw -P --workspaces --if-present", | ||
"playground": "npm run dev --workspace=playground-vue", | ||
"clean": "rimraf ./dist" | ||
@@ -46,6 +50,9 @@ }, | ||
"devDependencies": { | ||
"@testing-library/vue": "^5.8.2", | ||
"@vue/test-utils": "^2.0.0-rc.18", | ||
"vue": "^3.2.29" | ||
"@testing-library/vue": "8.0.0", | ||
"@vue/test-utils": "^2.4.1", | ||
"vue": "3.2.37" | ||
}, | ||
"dependencies": { | ||
"@tanstack/vue-virtual": "3.0.0-beta.60" | ||
} | ||
} |
@@ -26,3 +26,3 @@ <h3 align="center"> | ||
For full documentation, visit [headlessui.dev](https://headlessui.dev/vue/menu). | ||
For full documentation, visit [headlessui.com](https://headlessui.com/v1/vue). | ||
@@ -29,0 +29,0 @@ ## Community |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
601361
135
11534
2
4
+ Added@tanstack/virtual-core@3.0.0-beta.60(transitive)
+ Added@tanstack/vue-virtual@3.0.0-beta.60(transitive)