@headlessui/vue
Advanced tools
Comparing version 0.0.0-insiders.134c0fb to 0.0.0-insiders.13b3100
@@ -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; | ||
}; | ||
@@ -41,2 +41,13 @@ modelValue: { | ||
}; | ||
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, { | ||
@@ -57,3 +68,4 @@ [key: string]: any; | ||
type: (StringConstructor | FunctionConstructor)[]; | ||
default: () => typeof defaultComparator; | ||
nullable: boolean; | ||
default: null; | ||
}; | ||
@@ -84,2 +96,13 @@ modelValue: { | ||
}; | ||
immediate: { | ||
type: BooleanConstructor[]; | ||
default: boolean; | ||
}; | ||
virtual: { | ||
type: PropType<{ | ||
options: unknown[]; | ||
disabled?: ((value: unknown) => boolean) | undefined; | ||
} | null>; | ||
default: null; | ||
}; | ||
}>> & { | ||
@@ -95,2 +118,7 @@ "onUpdate:modelValue"?: ((_value: any) => any) | undefined; | ||
multiple: boolean; | ||
immediate: boolean; | ||
virtual: { | ||
options: unknown[]; | ||
disabled?: ((value: unknown) => boolean) | undefined; | ||
} | null; | ||
}>; | ||
@@ -120,4 +148,4 @@ export declare let ComboboxLabel: import("vue").DefineComponent<{ | ||
}>>, { | ||
id: string; | ||
as: string | Record<string, any>; | ||
id: string; | ||
}>; | ||
@@ -147,4 +175,4 @@ export declare let ComboboxButton: import("vue").DefineComponent<{ | ||
}>>, { | ||
id: string; | ||
as: string | Record<string, any>; | ||
id: string; | ||
}>; | ||
@@ -212,6 +240,6 @@ export declare let ComboboxInput: import("vue").DefineComponent<{ | ||
}, { | ||
id: string; | ||
as: string | Record<string, any>; | ||
unmount: boolean; | ||
static: boolean; | ||
id: string; | ||
defaultValue: string; | ||
@@ -275,2 +303,6 @@ }>; | ||
}; | ||
order: { | ||
type: NumberConstructor[]; | ||
default: null; | ||
}; | ||
}, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, { | ||
@@ -292,6 +324,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 Z,computed as x,defineComponent as H,h as Q,inject as z,nextTick as N,onMounted as J,onUnmounted as ee,provide as te,ref as M,toRaw as S,watch as W,watchEffect as G}from"vue";import{Features as q,render as K,omit as X,compact as oe}from'../../utils/render.js';import{useId as U}from'../../hooks/use-id.js';import{Keys as D}from'../../keyboard.js';import{calculateActiveIndex as le,Focus as V}from'../../utils/calculate-active-index.js';import{dom as C}from'../../utils/dom.js';import{useOpenClosed as ae,State as _,useOpenClosedProvider as ne}from'../../internal/open-closed.js';import{match as L}from'../../utils/match.js';import{useResolveButtonType as ie}from'../../hooks/use-resolve-button-type.js';import{useTreeWalker as ue}from'../../hooks/use-tree-walker.js';import{sortByDomNode as re}from'../../utils/focus-management.js';import{useOutsideClick as se}from'../../hooks/use-outside-click.js';import{Hidden as de,Features as fe}from'../../internal/hidden.js';import{objectToFormEntries as pe}from'../../utils/form.js';import{useControllable as be}from'../../hooks/use-controllable.js';import{useTrackedPointer as ve}from'../../hooks/use-tracked-pointer.js';import{isMobile as ce}from'../../utils/platform.js';import{disposables as me}from'../../utils/disposables.js';import{getOwnerDocument as xe}from'../../utils/owner.js';function Se(l,h){return l===h}var Oe=(r=>(r[r.Open=0]="Open",r[r.Closed=1]="Closed",r))(Oe||{}),Ce=(r=>(r[r.Single=0]="Single",r[r.Multi=1]="Multi",r))(Ce||{}),ge=(r=>(r[r.Pointer=0]="Pointer",r[r.Other=1]="Other",r))(ge||{});let Y=Symbol("ComboboxContext");function $(l){let h=z(Y,null);if(h===null){let r=new Error(`<${l} /> is missing a parent <Combobox /> component.`);throw Error.captureStackTrace&&Error.captureStackTrace(r,$),r}return h}let Je=H({name:"Combobox",emits:{"update:modelValue":l=>!0},props:{as:{type:[Object,String],default:"template"},disabled:{type:[Boolean],default:!1},by:{type:[String,Function],default:()=>Se},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}},inheritAttrs:!1,setup(l,{slots:h,attrs:r,emit:w}){let t=M(1),e=M(null),R=M(null),f=M(null),s=M(null),b=M({static:!1,hold:!1}),v=M([]),O=M(null),I=M(1),P=M(!1);function j(a=u=>u){let u=O.value!==null?v.value[O.value]:null,d=re(a(v.value.slice()),p=>C(p.dataRef.domRef)),n=u?d.indexOf(u):null;return n===-1&&(n=null),{options:d,activeOptionIndex:n}}let k=x(()=>l.multiple?1:0),c=x(()=>l.nullable),[o,g]=be(x(()=>l.modelValue),a=>w("update:modelValue",a),x(()=>l.defaultValue)),m=x(()=>o.value===void 0?L(k.value,{[1]:[],[0]:void 0}):o.value),E=null,y=null,i={comboboxState:t,value:m,mode:k,compare(a,u){if(typeof l.by=="string"){let d=l.by;return(a==null?void 0:a[d])===(u==null?void 0:u[d])}return l.by(a,u)},defaultValue:x(()=>l.defaultValue),nullable:c,inputRef:R,labelRef:e,buttonRef:f,optionsRef:s,disabled:x(()=>l.disabled),options:v,change(a){g(a)},activeOptionIndex:x(()=>{if(P.value&&O.value===null&&v.value.length>0){let a=v.value.findIndex(u=>!u.dataRef.disabled);a!==-1&&(O.value=a)}return O.value}),activationTrigger:I,optionsPropsRef:b,closeCombobox(){P.value=!1,!l.disabled&&t.value!==1&&(t.value=1,O.value=null)},openCombobox(){if(P.value=!0,l.disabled||t.value===0)return;let a=v.value.findIndex(u=>{let d=S(u.dataRef.value);return L(k.value,{[0]:()=>i.compare(S(i.value.value),S(d)),[1]:()=>S(i.value.value).some(p=>i.compare(S(p),S(d)))})});a!==-1&&(O.value=a),t.value=0},goToOption(a,u,d){P.value=!1,E!==null&&cancelAnimationFrame(E),E=requestAnimationFrame(()=>{if(l.disabled||s.value&&!b.value.static&&t.value===1)return;let n=j();if(n.activeOptionIndex===null){let T=n.options.findIndex(B=>!B.dataRef.disabled);T!==-1&&(n.activeOptionIndex=T)}let p=le(a===V.Specific?{focus:V.Specific,id:u}:{focus:a},{resolveItems:()=>n.options,resolveActiveIndex:()=>n.activeOptionIndex,resolveId:T=>T.id,resolveDisabled:T=>T.dataRef.disabled});O.value=p,I.value=d!=null?d:1,v.value=n.options})},selectOption(a){let u=v.value.find(n=>n.id===a);if(!u)return;let{dataRef:d}=u;g(L(k.value,{[0]:()=>d.value,[1]:()=>{let n=S(i.value.value).slice(),p=S(d.value),T=n.findIndex(B=>i.compare(p,S(B)));return T===-1?n.push(p):n.splice(T,1),n}}))},selectActiveOption(){if(i.activeOptionIndex.value===null)return;let{dataRef:a,id:u}=v.value[i.activeOptionIndex.value];g(L(k.value,{[0]:()=>a.value,[1]:()=>{let d=S(i.value.value).slice(),n=S(a.value),p=d.findIndex(T=>i.compare(n,S(T)));return p===-1?d.push(n):d.splice(p,1),d}})),i.goToOption(V.Specific,u)},registerOption(a,u){y&&cancelAnimationFrame(y);let d={id:a,dataRef:u},n=j(p=>(p.push(d),p));if(O.value===null){let p=u.value.value;L(k.value,{[0]:()=>i.compare(S(i.value.value),S(p)),[1]:()=>S(i.value.value).some(B=>i.compare(S(B),S(p)))})&&(n.activeOptionIndex=n.options.indexOf(d))}v.value=n.options,O.value=n.activeOptionIndex,I.value=1,n.options.some(p=>!C(p.dataRef.domRef))&&(y=requestAnimationFrame(()=>{let p=j();v.value=p.options,O.value=p.activeOptionIndex}))},unregisterOption(a){var d;i.activeOptionIndex.value!==null&&((d=i.options.value[i.activeOptionIndex.value])==null?void 0:d.id)===a&&(P.value=!0);let u=j(n=>{let p=n.findIndex(T=>T.id===a);return p!==-1&&n.splice(p,1),n});v.value=u.options,O.value=u.activeOptionIndex,I.value=1}};se([R,f,s],()=>i.closeCombobox(),x(()=>t.value===0)),te(Y,i),ne(x(()=>L(t.value,{[0]:_.Open,[1]:_.Closed})));let A=x(()=>i.activeOptionIndex.value===null?null:v.value[i.activeOptionIndex.value].dataRef.value),F=x(()=>{var a;return(a=C(R))==null?void 0:a.closest("form")});return J(()=>{W([F],()=>{if(!F.value||l.defaultValue===void 0)return;function a(){i.change(l.defaultValue)}return F.value.addEventListener("reset",a),()=>{var u;(u=F.value)==null||u.removeEventListener("reset",a)}},{immediate:!0})}),()=>{let{name:a,disabled:u,form:d,...n}=l,p={open:t.value===0,disabled:u,activeIndex:i.activeOptionIndex.value,activeOption:A.value,value:m.value};return Q(Z,[...a!=null&&m.value!=null?pe({[a]:m.value}).map(([T,B])=>Q(de,oe({features:fe.Hidden,key:T,as:"input",type:"hidden",hidden:!0,readOnly:!0,form:d,name:T,value:B}))):[],K({theirProps:{...r,...X(n,["modelValue","defaultValue","nullable","multiple","onUpdate:modelValue","by"])},ourProps:{},slot:p,slots:h,attrs:r,name:"Combobox"})])}}}),We=H({name:"ComboboxLabel",props:{as:{type:[Object,String],default:"label"},id:{type:String,default:()=>`headlessui-combobox-label-${U()}`}},setup(l,{attrs:h,slots:r}){let w=$("ComboboxLabel");function t(){var e;(e=C(w.inputRef))==null||e.focus({preventScroll:!0})}return()=>{let e={open:w.comboboxState.value===0,disabled:w.disabled.value},{id:R,...f}=l,s={id:R,ref:w.labelRef,onClick:t};return K({ourProps:s,theirProps:f,slot:e,attrs:h,slots:r,name:"ComboboxLabel"})}}}),Ge=H({name:"ComboboxButton",props:{as:{type:[Object,String],default:"button"},id:{type:String,default:()=>`headlessui-combobox-button-${U()}`}},setup(l,{attrs:h,slots:r,expose:w}){let t=$("ComboboxButton");w({el:t.buttonRef,$el:t.buttonRef});function e(s){t.disabled.value||(t.comboboxState.value===0?t.closeCombobox():(s.preventDefault(),t.openCombobox()),N(()=>{var b;return(b=C(t.inputRef))==null?void 0:b.focus({preventScroll:!0})}))}function R(s){switch(s.key){case D.ArrowDown:s.preventDefault(),s.stopPropagation(),t.comboboxState.value===1&&t.openCombobox(),N(()=>{var b;return(b=t.inputRef.value)==null?void 0:b.focus({preventScroll:!0})});return;case D.ArrowUp:s.preventDefault(),s.stopPropagation(),t.comboboxState.value===1&&(t.openCombobox(),N(()=>{t.value.value||t.goToOption(V.Last)})),N(()=>{var b;return(b=t.inputRef.value)==null?void 0:b.focus({preventScroll:!0})});return;case D.Escape:if(t.comboboxState.value!==0)return;s.preventDefault(),t.optionsRef.value&&!t.optionsPropsRef.value.static&&s.stopPropagation(),t.closeCombobox(),N(()=>{var b;return(b=t.inputRef.value)==null?void 0:b.focus({preventScroll:!0})});return}}let f=ie(x(()=>({as:l.as,type:h.type})),t.buttonRef);return()=>{var I,P;let s={open:t.comboboxState.value===0,disabled:t.disabled.value,value:t.value.value},{id:b,...v}=l,O={ref:t.buttonRef,id:b,type:f.value,tabindex:"-1","aria-haspopup":"listbox","aria-controls":(I=C(t.optionsRef))==null?void 0:I.id,"aria-expanded":t.comboboxState.value===0,"aria-labelledby":t.labelRef.value?[(P=C(t.labelRef))==null?void 0:P.id,b].join(" "):void 0,disabled:t.disabled.value===!0?!0:void 0,onKeydown:R,onClick:e};return K({ourProps:O,theirProps:v,slot:s,attrs:h,slots:r,name:"ComboboxButton"})}}}),Qe=H({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-${U()}`}},emits:{change:l=>!0},setup(l,{emit:h,attrs:r,slots:w,expose:t}){let e=$("ComboboxInput"),R=x(()=>xe(C(e.inputRef))),f={value:!1};t({el:e.inputRef,$el:e.inputRef});function s(){e.change(null);let o=C(e.optionsRef);o&&(o.scrollTop=0),e.goToOption(V.Nothing)}let b=x(()=>{var g;let o=e.value.value;return C(e.inputRef)?typeof l.displayValue!="undefined"&&o!==void 0?(g=l.displayValue(o))!=null?g:"":typeof o=="string"?o:"":""});J(()=>{W([b,e.comboboxState,R],([o,g],[m,E])=>{if(f.value)return;let y=C(e.inputRef);y&&((E===0&&g===1||o!==m)&&(y.value=o),requestAnimationFrame(()=>{var F;if(f.value||!y||((F=R.value)==null?void 0:F.activeElement)!==y)return;let{selectionStart:i,selectionEnd:A}=y;Math.abs((A!=null?A:0)-(i!=null?i:0))===0&&i===0&&y.setSelectionRange(y.value.length,y.value.length)}))},{immediate:!0}),W([e.comboboxState],([o],[g])=>{if(o===0&&g===1){if(f.value)return;let m=C(e.inputRef);if(!m)return;let E=m.value,{selectionStart:y,selectionEnd:i,selectionDirection:A}=m;m.value="",m.value=E,A!==null?m.setSelectionRange(y,i,A):m.setSelectionRange(y,i)}})});let v=M(!1);function O(){v.value=!0}function I(){me().nextFrame(()=>{v.value=!1})}function P(o){switch(f.value=!0,o.key){case D.Enter:if(f.value=!1,e.comboboxState.value!==0||v.value)return;if(o.preventDefault(),o.stopPropagation(),e.activeOptionIndex.value===null){e.closeCombobox();return}e.selectActiveOption(),e.mode.value===0&&e.closeCombobox();break;case D.ArrowDown:return f.value=!1,o.preventDefault(),o.stopPropagation(),L(e.comboboxState.value,{[0]:()=>e.goToOption(V.Next),[1]:()=>e.openCombobox()});case D.ArrowUp:return f.value=!1,o.preventDefault(),o.stopPropagation(),L(e.comboboxState.value,{[0]:()=>e.goToOption(V.Previous),[1]:()=>{e.openCombobox(),N(()=>{e.value.value||e.goToOption(V.Last)})}});case D.Home:if(o.shiftKey)break;return f.value=!1,o.preventDefault(),o.stopPropagation(),e.goToOption(V.First);case D.PageUp:return f.value=!1,o.preventDefault(),o.stopPropagation(),e.goToOption(V.First);case D.End:if(o.shiftKey)break;return f.value=!1,o.preventDefault(),o.stopPropagation(),e.goToOption(V.Last);case D.PageDown:return f.value=!1,o.preventDefault(),o.stopPropagation(),e.goToOption(V.Last);case D.Escape:if(f.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&&s(),e.closeCombobox();break;case D.Tab:if(f.value=!1,e.comboboxState.value!==0)return;e.mode.value===0&&e.selectActiveOption(),e.closeCombobox();break}}function j(o){h("change",o),e.nullable.value&&e.mode.value===0&&o.target.value===""&&s(),e.openCombobox()}function k(o){var g,m;if(f.value=!1,!(o.relatedTarget instanceof Node&&((g=C(e.optionsRef))!=null&&g.contains(o.relatedTarget)))&&!(o.relatedTarget instanceof Node&&((m=C(e.buttonRef))!=null&&m.contains(o.relatedTarget)))&&e.comboboxState.value===0)return o.preventDefault(),e.mode.value===0&&(e.nullable.value&&e.value.value===null?s():e.selectActiveOption()),e.closeCombobox()}let c=x(()=>{var o,g,m,E;return(E=(m=(g=l.defaultValue)!=null?g:e.defaultValue.value!==void 0?(o=l.displayValue)==null?void 0:o.call(l,e.defaultValue.value):null)!=null?m:e.defaultValue.value)!=null?E:""});return()=>{var A,F,a,u,d,n;let o={open:e.comboboxState.value===0},{id:g,displayValue:m,onChange:E,...y}=l,i={"aria-controls":(A=e.optionsRef.value)==null?void 0:A.id,"aria-expanded":e.comboboxState.value===0,"aria-activedescendant":e.activeOptionIndex.value===null||(F=e.options.value[e.activeOptionIndex.value])==null?void 0:F.id,"aria-labelledby":(d=(a=C(e.labelRef))==null?void 0:a.id)!=null?d:(u=C(e.buttonRef))==null?void 0:u.id,"aria-autocomplete":"list",id:g,onCompositionstart:O,onCompositionend:I,onKeydown:P,onInput:j,onBlur:k,role:"combobox",type:(n=r.type)!=null?n:"text",tabIndex:0,ref:e.inputRef,defaultValue:c.value,disabled:e.disabled.value===!0?!0:void 0};return K({ourProps:i,theirProps:y,slot:o,attrs:r,slots:w,features:q.RenderStrategy|q.Static,name:"ComboboxInput"})}}}),Xe=H({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(l,{attrs:h,slots:r,expose:w}){let t=$("ComboboxOptions"),e=`headlessui-combobox-options-${U()}`;w({el:t.optionsRef,$el:t.optionsRef}),G(()=>{t.optionsPropsRef.value.static=l.static}),G(()=>{t.optionsPropsRef.value.hold=l.hold});let R=ae(),f=x(()=>R!==null?(R.value&_.Open)===_.Open:t.comboboxState.value===0);return ue({container:x(()=>C(t.optionsRef)),enabled:x(()=>t.comboboxState.value===0),accept(s){return s.getAttribute("role")==="option"?NodeFilter.FILTER_REJECT:s.hasAttribute("role")?NodeFilter.FILTER_SKIP:NodeFilter.FILTER_ACCEPT},walk(s){s.setAttribute("role","none")}}),()=>{var O,I,P;let s={open:t.comboboxState.value===0},b={"aria-labelledby":(P=(O=C(t.labelRef))==null?void 0:O.id)!=null?P:(I=C(t.buttonRef))==null?void 0:I.id,id:e,ref:t.optionsRef,role:"listbox","aria-multiselectable":t.mode.value===1?!0:void 0},v=X(l,["hold"]);return K({ourProps:b,theirProps:v,slot:s,attrs:h,slots:r,features:q.RenderStrategy|q.Static,visible:f.value,name:"ComboboxOptions"})}}}),Ye=H({name:"ComboboxOption",props:{as:{type:[Object,String],default:"li"},value:{type:[Object,String,Number,Boolean]},disabled:{type:Boolean,default:!1}},setup(l,{slots:h,attrs:r,expose:w}){let t=$("ComboboxOption"),e=`headlessui-combobox-option-${U()}`,R=M(null);w({el:R,$el:R});let f=x(()=>t.activeOptionIndex.value!==null?t.options.value[t.activeOptionIndex.value].id===e:!1),s=x(()=>L(t.mode.value,{[0]:()=>t.compare(S(t.value.value),S(l.value)),[1]:()=>S(t.value.value).some(c=>t.compare(S(c),S(l.value)))})),b=x(()=>({disabled:l.disabled,value:l.value,domRef:R}));J(()=>t.registerOption(e,b)),ee(()=>t.unregisterOption(e)),G(()=>{t.comboboxState.value===0&&f.value&&t.activationTrigger.value!==0&&N(()=>{var c,o;return(o=(c=C(R))==null?void 0:c.scrollIntoView)==null?void 0:o.call(c,{block:"nearest"})})});function v(c){if(l.disabled)return c.preventDefault();t.selectOption(e),t.mode.value===0&&t.closeCombobox(),ce()||requestAnimationFrame(()=>{var o;return(o=C(t.inputRef))==null?void 0:o.focus()})}function O(){if(l.disabled)return t.goToOption(V.Nothing);t.goToOption(V.Specific,e)}let I=ve();function P(c){I.update(c)}function j(c){I.wasMoved(c)&&(l.disabled||f.value||t.goToOption(V.Specific,e,0))}function k(c){I.wasMoved(c)&&(l.disabled||f.value&&(t.optionsPropsRef.value.hold||t.goToOption(V.Nothing)))}return()=>{let{disabled:c}=l,o={active:f.value,selected:s.value,disabled:c},g={id:e,ref:R,role:"option",tabIndex:c===!0?void 0:-1,"aria-disabled":c===!0?!0:void 0,"aria-selected":s.value,disabled:void 0,onClick:v,onFocus:O,onPointerenter:P,onMouseenter:P,onPointermove:j,onMousemove:j,onPointerleave:k,onMouseleave:k};return K({ourProps:g,theirProps:l,slot:o,attrs:r,slots:h,name:"ComboboxOption"})}}});export{Je as Combobox,Ge as ComboboxButton,Qe as ComboboxInput,We as ComboboxLabel,Ye as ComboboxOption,Xe 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<{ | ||
@@ -67,7 +67,7 @@ as: { | ||
}, { | ||
id: string; | ||
role: "dialog" | "alertdialog"; | ||
as: string | Record<string, any>; | ||
unmount: boolean; | ||
static: boolean; | ||
id: string; | ||
role: "dialog" | "alertdialog"; | ||
open: string | boolean; | ||
@@ -99,4 +99,4 @@ initialFocus: HTMLElement | null; | ||
}>>, { | ||
id: string; | ||
as: string | Record<string, any>; | ||
id: string; | ||
}>; | ||
@@ -124,4 +124,4 @@ export declare let DialogBackdrop: import("vue").DefineComponent<{ | ||
}>>, { | ||
id: string; | ||
as: string | Record<string, any>; | ||
id: string; | ||
}>; | ||
@@ -151,4 +151,4 @@ export declare let DialogPanel: import("vue").DefineComponent<{ | ||
}>>, { | ||
id: string; | ||
as: string | Record<string, any>; | ||
id: string; | ||
}>; | ||
@@ -178,4 +178,4 @@ export declare let DialogTitle: import("vue").DefineComponent<{ | ||
}>>, { | ||
id: string; | ||
as: string | Record<string, any>; | ||
id: string; | ||
}>; | ||
@@ -205,4 +205,4 @@ export declare let DialogDescription: import("vue").DefineComponent<{ | ||
}>>, { | ||
id: string; | ||
as: string | Record<string, any>; | ||
id: string; | ||
}>; |
@@ -1,1 +0,1 @@ | ||
import{computed as o,defineComponent as O,h as g,inject as _,nextTick as ie,onMounted as L,onUnmounted as ue,provide as se,ref as y,watchEffect as pe}from"vue";import{render as P,Features as q}from'../../utils/render.js';import{Keys as de}from'../../keyboard.js';import{useId as b}from'../../hooks/use-id.js';import{FocusTrap as C}from'../../components/focus-trap/focus-trap.js';import{useInert as W}from'../../hooks/use-inert.js';import{Portal as Y,PortalGroup as fe,useNestedPortals as ge}from'../portal/portal.js';import{StackMessage as z,useStackProvider as ce}from'../../internal/stack-context.js';import{match as G}from'../../utils/match.js';import{ForcePortalRoot as $}from'../../internal/portal-force-root.js';import{Description as ve,useDescriptions as me}from'../description/description.js';import{dom as F}from'../../utils/dom.js';import{useOpenClosed as De,State as x}from'../../internal/open-closed.js';import{useOutsideClick as ye}from'../../hooks/use-outside-click.js';import{getOwnerDocument as Se}from'../../utils/owner.js';import{useEventListener as he}from'../../hooks/use-event-listener.js';import{useDocumentOverflowLockedEffect as Oe}from'../../hooks/document-overflow/use-document-overflow.js';import{useRootContainers as Pe}from'../../hooks/use-root-containers.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=_(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",Ye=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=De(),R=o(()=>t.open===I&&S!==null?(S.value&x.Open)===x.Open:t.open),c=y(null),E=o(()=>Se(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=_(j,null)!==null,[V,J]=ge(),{resolveContainers:A,mainTreeNodeRef:N,MainTreeNode:Q}=Pe({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),ce({type:"Dialog",enabled:o(()=>f.value===0),element:c,onUpdate:(e,a)=>{if(a==="Dialog")return G(e,{[z.Add]:()=>m.value+=1,[z.Remove]:()=>m.value-=1})}});let ae=me({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));ye(A,(e,a)=>{h.close(),ie(()=>a==null?void 0:a.focus())},oe);let re=o(()=>!(w.value||f.value!==0));he((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 Oe(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(Y,()=>g(fe,{target:c.value},()=>g($,{force:!1},()=>g(C,{initialFocus:p,containers:A,features:k.value?G(X.value,{parent:C.features.RestoreFocus,leaf:C.features.All&~C.features.FocusLock}):C.features.None},()=>g(J,{},()=>P({ourProps:B,theirProps:{...d,...l},slot:D,attrs:l,slots:u,visible:f.value===0,features:q.RenderStrategy|q.Static,name:"Dialog"})))))),g(Q)])}}}),ze=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 P({ourProps:{id:r,"aria-hidden":!0,onClick:i},theirProps:s,slot:{open:u.dialogState.value===0},attrs:n,slots:l,name:"DialogOverlay"})}}}),Ge=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(Y,()=>P({ourProps:m,theirProps:{...n,...v},slot:{open:i.dialogState.value===0},attrs:n,slots:l,name:"DialogBackdrop"})))}}}),Ve=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 P({ourProps:m,theirProps:v,slot:{open:i.dialogState.value===0},attrs:n,slots:l,name:"DialogPanel"})}}}),Je=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 P({ourProps:{id:i},theirProps:r,slot:{open:u.dialogState.value===0},attrs:n,slots:l,name:"DialogTitle"})}}}),Qe=ve;export{Ye as Dialog,Ge as DialogBackdrop,Qe as DialogDescription,ze as DialogOverlay,Ve as DialogPanel,Je 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}; |
@@ -58,5 +58,5 @@ export declare let Disclosure: import("vue").DefineComponent<{ | ||
}>>, { | ||
id: string; | ||
as: string | Record<string, any>; | ||
disabled: boolean; | ||
id: string; | ||
}>; | ||
@@ -102,6 +102,6 @@ export declare let DisclosurePanel: import("vue").DefineComponent<{ | ||
}>>, { | ||
id: string; | ||
as: string | Record<string, any>; | ||
unmount: boolean; | ||
static: boolean; | ||
id: string; | ||
}>; |
@@ -1,1 +0,1 @@ | ||
import{defineComponent as b,ref as d,provide as I,inject as P,computed as m,watchEffect as w,onMounted as h,onUnmounted as R}from"vue";import{Keys as f}from'../../keyboard.js';import{match as E}from'../../utils/match.js';import{render as g,Features as x}from'../../utils/render.js';import{useId as B}from'../../hooks/use-id.js';import{dom as p}from'../../utils/dom.js';import{useOpenClosedProvider as H,State as y,useOpenClosed as L}from'../../internal/open-closed.js';import{useResolveButtonType as j}from'../../hooks/use-resolve-button-type.js';var $=(o=>(o[o.Open=0]="Open",o[o.Closed=1]="Closed",o))($||{});let T=Symbol("DisclosureContext");function O(t){let r=P(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 P(k,null)}let V=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-${B()}`),panelId:d(`headlessui-disclosure-panel-${B()}`),disclosureState:s,panel:e,button:i,toggleDisclosure(){s.value=E(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 I(T,n),H(m(()=>E(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"})}}}),X=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);h(()=>{n.value||t.id!==null&&(e.buttonId.value=t.id)}),R(()=>{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=j(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"})}}}),Y=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");h(()=>{t.id!==null&&(e.panelId.value=t.id)}),R(()=>{e.panelId.value=null}),s({el:e.panel,$el:e.panel}),I(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:x.RenderStrategy|x.Static,visible:n.value,name:"DisclosurePanel"})}}});export{V as Disclosure,X as DisclosureButton,Y 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,2 @@ | ||
import { PropType, Ref } from 'vue'; | ||
import { type PropType, type Ref } from 'vue'; | ||
type Containers = (() => Iterable<HTMLElement>) | Ref<Set<Ref<HTMLElement | null>>>; | ||
@@ -120,3 +120,3 @@ declare enum Features { | ||
[key: string]: any; | ||
}>> & {} & {} & import("vue").ComponentCustomProperties; | ||
}>> & {} & import("vue").ComponentCustomProperties; | ||
__isFragment?: undefined; | ||
@@ -123,0 +123,0 @@ __isTeleport?: undefined; |
@@ -1,1 +0,1 @@ | ||
import{computed as F,defineComponent as I,h,onMounted as y,onUnmounted as R,ref as T,watch as k,Fragment as j,watchEffect as K}from"vue";import{render as U}from'../../utils/render.js';import{Hidden as D,Features as C}from'../../internal/hidden.js';import{dom as f}from'../../utils/dom.js';import{focusIn as w,Focus as v,focusElement as p,FocusResult as _}from'../../utils/focus-management.js';import{match as P}from'../../utils/match.js';import{useTabDirection as q,Direction as b}from'../../hooks/use-tab-direction.js';import{getOwnerDocument as G}from'../../utils/owner.js';import{useEventListener as W}from'../../hooks/use-event-listener.js';import{microTask as S}from'../../utils/micro-task.js';import{onDocumentReady as $}from'../../utils/document-ready.js';function B(e){if(!e)return new Set;if(typeof e=="function")return new Set(e());let t=new Set;for(let l of e.value){let o=f(l);o instanceof HTMLElement&&t.add(o)}return t}var A=(n=>(n[n.None=1]="None",n[n.InitialFocus=2]="InitialFocus",n[n.TabLock=4]="TabLock",n[n.FocusLock=8]="FocusLock",n[n.RestoreFocus=16]="RestoreFocus",n[n.All=30]="All",n))(A||{});let ce=Object.assign(I({name:"FocusTrap",props:{as:{type:[Object,String],default:"div"},initialFocus:{type:Object,default:null},features:{type:Number,default:30},containers:{type:[Object,Function],default:T(new Set)}},inheritAttrs:!1,setup(e,{attrs:t,slots:l,expose:o}){let r=T(null);o({el:r,$el:r});let i=F(()=>G(r)),n=T(!1);y(()=>n.value=!0),R(()=>n.value=!1),z({ownerDocument:i},F(()=>n.value&&Boolean(e.features&16)));let m=J({ownerDocument:i,container:r,initialFocus:F(()=>e.initialFocus)},F(()=>n.value&&Boolean(e.features&2)));Q({ownerDocument:i,container:r,containers:e.containers,previousActiveElement:m},F(()=>n.value&&Boolean(e.features&8)));let c=q();function u(a){let d=f(r);if(!d)return;(g=>g())(()=>{P(c.value,{[b.Forwards]:()=>{w(d,v.First,{skipElements:[a.relatedTarget]})},[b.Backwards]:()=>{w(d,v.Last,{skipElements:[a.relatedTarget]})}})})}let s=T(!1);function H(a){a.key==="Tab"&&(s.value=!0,requestAnimationFrame(()=>{s.value=!1}))}function M(a){if(!n.value)return;let d=B(e.containers);f(r)instanceof HTMLElement&&d.add(f(r));let E=a.relatedTarget;E instanceof HTMLElement&&E.dataset.headlessuiFocusGuard!=="true"&&(N(d,E)||(s.value?w(f(r),P(c.value,{[b.Forwards]:()=>v.Next,[b.Backwards]:()=>v.Previous})|v.WrapAround,{relativeTo:a.target}):a.target instanceof HTMLElement&&p(a.target)))}return()=>{let a={},d={ref:r,onKeydown:H,onFocusout:M},{features:E,initialFocus:g,containers:X,...O}=e;return h(j,[Boolean(E&4)&&h(D,{as:"button",type:"button","data-headlessui-focus-guard":!0,onFocus:u,features:C.Focusable}),U({ourProps:d,theirProps:{...t,...O},slot:a,attrs:t,slots:l,name:"FocusTrap"}),Boolean(E&4)&&h(D,{as:"button",type:"button","data-headlessui-focus-guard":!0,onFocus:u,features:C.Focusable})])}}}),{features:A}),L=[];$(()=>{function e(t){t.target instanceof HTMLElement&&t.target!==document.body&&L[0]!==t.target&&(L.unshift(t.target),L=L.filter(l=>l!=null&&l.isConnected),L.splice(10))}window.addEventListener("click",e,{capture:!0}),window.addEventListener("mousedown",e,{capture:!0}),window.addEventListener("focus",e,{capture:!0}),document.body.addEventListener("click",e,{capture:!0}),document.body.addEventListener("mousedown",e,{capture:!0}),document.body.addEventListener("focus",e,{capture:!0})});function x(e){let t=T(L.slice());return k([e],([l],[o])=>{o===!0&&l===!1?S(()=>{t.value.splice(0)}):o===!1&&l===!0&&(t.value=L.slice())},{flush:"post"}),()=>{var l;return(l=t.value.find(o=>o!=null&&o.isConnected))!=null?l:null}}function z({ownerDocument:e},t){let l=x(t);y(()=>{K(()=>{var o,r;t.value||((o=e.value)==null?void 0:o.activeElement)===((r=e.value)==null?void 0:r.body)&&p(l())},{flush:"post"})}),R(()=>{t.value&&p(l())})}function J({ownerDocument:e,container:t,initialFocus:l},o){let r=T(null),i=T(!1);return y(()=>i.value=!0),R(()=>i.value=!1),y(()=>{k([t,l,o],(n,m)=>{if(n.every((u,s)=>(m==null?void 0:m[s])===u)||!o.value)return;let c=f(t);c&&S(()=>{var H,M;if(!i.value)return;let u=f(l),s=(H=e.value)==null?void 0:H.activeElement;if(u){if(u===s){r.value=s;return}}else if(c.contains(s)){r.value=s;return}u?p(u):w(c,v.First|v.NoScroll)===_.Error&&console.warn("There are no focusable elements inside the <FocusTrap />"),r.value=(M=e.value)==null?void 0:M.activeElement})},{immediate:!0,flush:"post"})}),r}function Q({ownerDocument:e,container:t,containers:l,previousActiveElement:o},r){var i;W((i=e.value)==null?void 0:i.defaultView,"focus",n=>{if(!r.value)return;let m=B(l);f(t)instanceof HTMLElement&&m.add(f(t));let c=o.value;if(!c)return;let u=n.target;u&&u instanceof HTMLElement?N(m,u)?(o.value=u,p(u)):(n.preventDefault(),n.stopPropagation(),p(c)):p(o.value)},!0)}function N(e,t){for(let l of e)if(l.contains(t))return!0;return!1}export{ce 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 h}from"vue";import{useId as w}from'../../hooks/use-id.js';import{render as R}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-${w()}`}},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]:h(g)}),{}),id:p};return c&&(delete s.onClick,delete s.htmlFor,delete u.onClick),R({ourProps:s,theirProps:u,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; | ||
@@ -86,2 +86,3 @@ export declare let Listbox: import("vue").DefineComponent<{ | ||
disabled: boolean; | ||
horizontal: boolean; | ||
by: string | Function; | ||
@@ -91,3 +92,2 @@ modelValue: string | number | boolean | object | null; | ||
multiple: boolean; | ||
horizontal: boolean; | ||
}>; | ||
@@ -117,4 +117,4 @@ export declare let ListboxLabel: import("vue").DefineComponent<{ | ||
}>>, { | ||
id: string; | ||
as: string | Record<string, any>; | ||
id: string; | ||
}>; | ||
@@ -144,4 +144,4 @@ export declare let ListboxButton: import("vue").DefineComponent<{ | ||
}>>, { | ||
id: string; | ||
as: string | Record<string, any>; | ||
id: string; | ||
}>; | ||
@@ -187,6 +187,6 @@ export declare let ListboxOptions: import("vue").DefineComponent<{ | ||
}>>, { | ||
id: string; | ||
as: string | Record<string, any>; | ||
unmount: boolean; | ||
static: boolean; | ||
id: string; | ||
}>; | ||
@@ -230,6 +230,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 z,computed as S,defineComponent as E,h as N,inject as _,nextTick as V,onMounted as K,onUnmounted as q,provide as W,ref as D,toRaw as R,watch as H,watchEffect as G}from"vue";import{Features as U,render as j,omit as J,compact as X}from'../../utils/render.js';import{useId as F}from'../../hooks/use-id.js';import{Keys as p}from'../../keyboard.js';import{calculateActiveIndex as Y,Focus as g}from'../../utils/calculate-active-index.js';import{dom as c}from'../../utils/dom.js';import{useOpenClosed as Z,State as B,useOpenClosedProvider as ee}from'../../internal/open-closed.js';import{match as C}from'../../utils/match.js';import{useResolveButtonType as te}from'../../hooks/use-resolve-button-type.js';import{FocusableMode as oe,isFocusableElement as ie,sortByDomNode as ae}from'../../utils/focus-management.js';import{useOutsideClick as ne}from'../../hooks/use-outside-click.js';import{Hidden as le,Features as ue}from'../../internal/hidden.js';import{objectToFormEntries as re}from'../../utils/form.js';import{useControllable as se}from'../../hooks/use-controllable.js';import{useTrackedPointer as de}from'../../hooks/use-tracked-pointer.js';import{useTextValue as fe}from'../../hooks/use-text-value.js';function pe(t,v){return t===v}var ce=(l=>(l[l.Open=0]="Open",l[l.Closed=1]="Closed",l))(ce||{}),ve=(l=>(l[l.Single=0]="Single",l[l.Multi=1]="Multi",l))(ve||{}),be=(l=>(l[l.Pointer=0]="Pointer",l[l.Other=1]="Other",l))(be||{});function me(t){requestAnimationFrame(()=>requestAnimationFrame(t))}let $=Symbol("ListboxContext");function A(t){let v=_($,null);if(v===null){let l=new Error(`<${t} /> is missing a parent <Listbox /> component.`);throw Error.captureStackTrace&&Error.captureStackTrace(l,A),l}return v}let Be=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:v,attrs:l,emit:L}){let e=D(1),d=D(null),b=D(null),m=D(null),f=D([]),o=D(""),i=D(null),T=D(1);function k(a=n=>n){let n=i.value!==null?f.value[i.value]:null,u=ae(a(f.value.slice()),O=>c(O.dataRef.domRef)),s=n?u.indexOf(n):null;return s===-1&&(s=null),{options:u,activeOptionIndex:s}}let y=S(()=>t.multiple?1:0),[h,M]=se(S(()=>t.modelValue),a=>L("update:modelValue",a),S(()=>t.defaultValue)),w=S(()=>h.value===void 0?C(y.value,{[1]:[],[0]:void 0}):h.value),r={listboxState:e,value:w,mode:y,compare(a,n){if(typeof t.by=="string"){let u=t.by;return(a==null?void 0:a[u])===(n==null?void 0:n[u])}return t.by(a,n)},orientation:S(()=>t.horizontal?"horizontal":"vertical"),labelRef:d,buttonRef:b,optionsRef:m,disabled:S(()=>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,u){if(t.disabled||e.value===1)return;let s=k(),O=Y(a===g.Specific?{focus:g.Specific,id:n}:{focus:a},{resolveItems:()=>s.options,resolveActiveIndex:()=>s.activeOptionIndex,resolveId:P=>P.id,resolveDisabled:P=>P.dataRef.disabled});o.value="",i.value=O,T.value=u!=null?u:1,f.value=s.options},search(a){if(t.disabled||e.value===1)return;let u=o.value!==""?0:1;o.value+=a.toLowerCase();let O=(i.value!==null?f.value.slice(i.value+u).concat(f.value.slice(0,i.value+u)):f.value).find(I=>I.dataRef.textValue.startsWith(o.value)&&!I.dataRef.disabled),P=O?f.value.indexOf(O):-1;P===-1||P===i.value||(i.value=P,T.value=1)},clearSearch(){t.disabled||e.value!==1&&o.value!==""&&(o.value="")},registerOption(a,n){let u=k(s=>[...s,{id:a,dataRef:n}]);f.value=u.options,i.value=u.activeOptionIndex},unregisterOption(a){let n=k(u=>{let s=u.findIndex(O=>O.id===a);return s!==-1&&u.splice(s,1),u});f.value=n.options,i.value=n.activeOptionIndex,T.value=1},theirOnChange(a){t.disabled||M(a)},select(a){t.disabled||M(C(y.value,{[0]:()=>a,[1]:()=>{let n=R(r.value.value).slice(),u=R(a),s=n.findIndex(O=>r.compare(u,R(O)));return s===-1?n.push(u):n.splice(s,1),n}}))}};ne([b,m],(a,n)=>{var u;r.closeListbox(),ie(n,oe.Loose)||(a.preventDefault(),(u=c(b))==null||u.focus())},S(()=>e.value===0)),W($,r),ee(S(()=>C(e.value,{[0]:B.Open,[1]:B.Closed})));let x=S(()=>{var a;return(a=c(b))==null?void 0:a.closest("form")});return K(()=>{H([x],()=>{if(!x.value||t.defaultValue===void 0)return;function a(){r.theirOnChange(t.defaultValue)}return x.value.addEventListener("reset",a),()=>{var n;(n=x.value)==null||n.removeEventListener("reset",a)}},{immediate:!0})}),()=>{let{name:a,modelValue:n,disabled:u,form:s,...O}=t,P={open:e.value===0,disabled:u,value:w.value};return N(z,[...a!=null&&w.value!=null?re({[a]:w.value}).map(([I,Q])=>N(le,X({features:ue.Hidden,key:I,as:"input",type:"hidden",hidden:!0,readOnly:!0,form:s,name:I,value:Q}))):[],j({ourProps:{},theirProps:{...l,...J(O,["defaultValue","onUpdate:modelValue","horizontal","multiple","by"])},slot:P,slots:v,attrs:l,name:"Listbox"})])}}}),Ke=E({name:"ListboxLabel",props:{as:{type:[Object,String],default:"label"},id:{type:String,default:()=>`headlessui-listbox-label-${F()}`}},setup(t,{attrs:v,slots:l}){let L=A("ListboxLabel");function e(){var d;(d=c(L.buttonRef))==null||d.focus({preventScroll:!0})}return()=>{let d={open:L.listboxState.value===0,disabled:L.disabled.value},{id:b,...m}=t,f={id:b,ref:L.labelRef,onClick:e};return j({ourProps:f,theirProps:m,slot:d,attrs:v,slots:l,name:"ListboxLabel"})}}}),Ne=E({name:"ListboxButton",props:{as:{type:[Object,String],default:"button"},id:{type:String,default:()=>`headlessui-listbox-button-${F()}`}},setup(t,{attrs:v,slots:l,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(),V(()=>{var i;(i=c(e.optionsRef))==null||i.focus({preventScroll:!0}),e.value.value||e.goToOption(g.First)});break;case p.ArrowUp:o.preventDefault(),e.openListbox(),V(()=>{var i;(i=c(e.optionsRef))==null||i.focus({preventScroll:!0}),e.value.value||e.goToOption(g.Last)});break}}function b(o){switch(o.key){case p.Space:o.preventDefault();break}}function m(o){e.disabled.value||(e.listboxState.value===0?(e.closeListbox(),V(()=>{var i;return(i=c(e.buttonRef))==null?void 0:i.focus({preventScroll:!0})})):(o.preventDefault(),e.openListbox(),me(()=>{var i;return(i=c(e.optionsRef))==null?void 0:i.focus({preventScroll:!0})})))}let f=te(S(()=>({as:t.as,type:v.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,k={ref:e.buttonRef,id:i,type:f.value,"aria-haspopup":"listbox","aria-controls":(y=c(e.optionsRef))==null?void 0:y.id,"aria-expanded":e.listboxState.value===0,"aria-labelledby":e.labelRef.value?[(h=c(e.labelRef))==null?void 0:h.id,i].join(" "):void 0,disabled:e.disabled.value===!0?!0:void 0,onKeydown:d,onKeyup:b,onClick:m};return j({ourProps:k,theirProps:T,slot:o,attrs:v,slots:l,name:"ListboxButton"})}}}),He=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:v,slots:l,expose:L}){let e=A("ListboxOptions"),d=D(null);L({el:e.optionsRef,$el:e.optionsRef});function b(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(),V(()=>{var i;return(i=c(e.buttonRef))==null?void 0:i.focus({preventScroll:!0})}));break;case C(e.orientation.value,{vertical:p.ArrowDown,horizontal:p.ArrowRight}):return o.preventDefault(),o.stopPropagation(),e.goToOption(g.Next);case C(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(),V(()=>{var i;return(i=c(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 m=Z(),f=S(()=>m!==null?(m.value&B.Open)===B.Open:e.listboxState.value===0);return()=>{var y,h,M,w;let o={open:e.listboxState.value===0},{id:i,...T}=t,k={"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":(w=(h=c(e.labelRef))==null?void 0:h.id)!=null?w:(M=c(e.buttonRef))==null?void 0:M.id,"aria-orientation":e.orientation.value,id:i,onKeydown:b,role:"listbox",tabIndex:0,ref:e.optionsRef};return j({ourProps:k,theirProps:T,slot:o,attrs:v,slots:l,features:U.RenderStrategy|U.Static,visible:f.value,name:"ListboxOptions"})}}}),Ue=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:v,attrs:l,expose:L}){let e=A("ListboxOption"),d=D(null);L({el:d,$el:d});let b=S(()=>e.activeOptionIndex.value!==null?e.options.value[e.activeOptionIndex.value].id===t.id:!1),m=S(()=>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)))})),f=S(()=>C(e.mode.value,{[1]:()=>{var x;let r=R(e.value.value);return((x=e.options.value.find(a=>r.some(n=>e.compare(R(n),R(a.dataRef.value)))))==null?void 0:x.id)===t.id},[0]:()=>m.value})),o=fe(d),i=S(()=>({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,m],()=>{e.listboxState.value===0&&m.value&&C(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&&b.value&&e.activationTrigger.value!==0&&V(()=>{var r,x;return(x=(r=c(d))==null?void 0:r.scrollIntoView)==null?void 0:x.call(r,{block:"nearest"})})});function T(r){if(t.disabled)return r.preventDefault();e.select(t.value),e.mode.value===0&&(e.closeListbox(),V(()=>{var x;return(x=c(e.buttonRef))==null?void 0:x.focus({preventScroll:!0})}))}function k(){if(t.disabled)return e.goToOption(g.Nothing);e.goToOption(g.Specific,t.id)}let y=de();function h(r){y.update(r)}function M(r){y.wasMoved(r)&&(t.disabled||b.value||e.goToOption(g.Specific,t.id,0))}function w(r){y.wasMoved(r)&&(t.disabled||b.value&&e.goToOption(g.Nothing))}return()=>{let{disabled:r}=t,x={active:b.value,selected:m.value,disabled:r},{id:a,value:n,disabled:u,...s}=t,O={id:a,ref:d,role:"option",tabIndex:r===!0?void 0:-1,"aria-disabled":r===!0?!0:void 0,"aria-selected":m.value,disabled:void 0,onClick:T,onFocus:k,onPointerenter:h,onMouseenter:h,onPointermove:M,onMousemove:M,onPointerleave:w,onMouseleave:w};return j({ourProps:O,theirProps:s,slot:x,attrs:l,slots:v,name:"ListboxOption"})}}});export{Be as Listbox,Ne as ListboxButton,Ke as ListboxLabel,Ue as ListboxOption,He 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 T,ref as R,provide as C,inject as K,onMounted as N,onUnmounted as j,computed as h,nextTick as y,watchEffect as L}from"vue";import{Features as E,render as D}from'../../utils/render.js';import{useId as w}from'../../hooks/use-id.js';import{Keys as c}from'../../keyboard.js';import{Focus as S,calculateActiveIndex as B}from'../../utils/calculate-active-index.js';import{dom as m}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 k,focusFrom as J,restoreFocusIfNecessary as F}from'../../utils/focus-management.js';import{useOutsideClick as z}from'../../hooks/use-outside-click.js';import{useTrackedPointer as G}from'../../hooks/use-tracked-pointer.js';import{useTextValue as X}from'../../hooks/use-text-value.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(r){requestAnimationFrame(()=>requestAnimationFrame(r))}let A=Symbol("MenuContext");function O(r){let b=K(A,null);if(b===null){let l=new Error(`<${r} /> is missing a parent <Menu /> component.`);throw Error.captureStackTrace&&Error.captureStackTrace(l,O),l}return b}let Me=T({name:"Menu",props:{as:{type:[Object,String],default:"template"}},setup(r,{slots:b,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=i=>i){let i=d.value!==null?s.value[d.value]:null,u=W(a(s.value.slice()),v=>m(v.dataRef.domRef)),n=i?u.indexOf(i):null;return n===-1&&(n=null),{items:u,activeItemIndex:n}}let p={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,i,u){let n=t(),v=B(a===S.Specific?{focus:S.Specific,id:i}:{focus:a},{resolveItems:()=>n.items,resolveActiveIndex:()=>n.activeItemIndex,resolveId:M=>M.id,resolveDisabled:M=>M.dataRef.disabled});g.value="",d.value=v,o.value=u!=null?u:1,s.value=n.items},search(a){let u=g.value!==""?0:1;g.value+=a.toLowerCase();let v=(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),M=v?s.value.indexOf(v):-1;M===-1||M===d.value||(d.value=M,o.value=1)},clearSearch(){g.value=""},registerItem(a,i){let u=t(n=>[...n,{id:a,dataRef:i}]);s.value=u.items,d.value=u.activeItemIndex,o.value=1},unregisterItem(a){let i=t(u=>{let n=u.findIndex(v=>v.id===a);return n!==-1&&u.splice(n,1),u});s.value=i.items,d.value=i.activeItemIndex,o.value=1}};return z([e,f],(a,i)=>{var u;p.closeMenu(),q(i,_.Loose)||(a.preventDefault(),(u=m(e))==null||u.focus())},h(()=>I.value===0)),C(A,p),$(h(()=>H(I.value,{[0]:P.Open,[1]:P.Closed}))),()=>{let a={open:I.value===0,close:p.closeMenu};return D({ourProps:{},theirProps:r,slot:a,slots:b,attrs:l,name:"Menu"})}}}),Re=T({name:"MenuButton",props:{disabled:{type:Boolean,default:!1},as:{type:[Object,String],default:"button"},id:{type:String,default:()=>`headlessui-menu-button-${w()}`}},setup(r,{attrs:b,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(),y(()=>{var t;(t=m(e.itemsRef))==null||t.focus({preventScroll:!0}),e.goToItem(S.First)});break;case c.ArrowUp:o.preventDefault(),o.stopPropagation(),e.openMenu(),y(()=>{var t;(t=m(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){r.disabled||(e.menuState.value===0?(e.closeMenu(),y(()=>{var t;return(t=m(e.buttonRef))==null?void 0:t.focus({preventScroll:!0})})):(o.preventDefault(),e.openMenu(),ee(()=>{var t;return(t=m(e.itemsRef))==null?void 0:t.focus({preventScroll:!0})})))}let d=Q(h(()=>({as:r.as,type:b.type})),e.buttonRef);return()=>{var i;let o={open:e.menuState.value===0},{id:t,...p}=r,a={ref:e.buttonRef,id:t,type:d.value,"aria-haspopup":"menu","aria-controls":(i=m(e.itemsRef))==null?void 0:i.id,"aria-expanded":e.menuState.value===0,onKeydown:f,onKeyup:s,onClick:g};return D({ourProps:a,theirProps:p,slot:o,attrs:b,slots:l,name:"MenuButton"})}}}),he=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(r,{attrs:b,slots:l,expose:I}){let e=O("MenuItems"),f=R(null);I({el:e.itemsRef,$el:e.itemsRef}),U({container:h(()=>m(e.itemsRef)),enabled:h(()=>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 p;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 i=e.items.value[e.activeItemIndex.value];(p=m(i.dataRef.domRef))==null||p.click()}e.closeMenu(),F(m(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(),y(()=>{var a;return(a=m(e.buttonRef))==null?void 0:a.focus({preventScroll:!0})});break;case c.Tab:t.preventDefault(),t.stopPropagation(),e.closeMenu(),y(()=>J(m(e.buttonRef),t.shiftKey?k.Previous:k.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=V(),o=h(()=>d!==null?(d.value&P.Open)===P.Open:e.menuState.value===0);return()=>{var u,n;let t={open:e.menuState.value===0},{id:p,...a}=r,i={"aria-activedescendant":e.activeItemIndex.value===null||(u=e.items.value[e.activeItemIndex.value])==null?void 0:u.id,"aria-labelledby":(n=m(e.buttonRef))==null?void 0:n.id,id:p,onKeydown:s,onKeyup:g,role:"menu",tabIndex:0,ref:e.itemsRef};return D({ourProps:i,theirProps:a,slot:t,attrs:b,slots:l,features:E.RenderStrategy|E.Static,visible:o.value,name:"MenuItems"})}}}),ye=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(r,{slots:b,attrs:l,expose:I}){let e=O("MenuItem"),f=R(null);I({el:f,$el:f});let s=h(()=>e.activeItemIndex.value!==null?e.items.value[e.activeItemIndex.value].id===r.id:!1),g=X(f),d=h(()=>({disabled:r.disabled,get textValue(){return g()},domRef:f}));N(()=>e.registerItem(r.id,d)),j(()=>e.unregisterItem(r.id)),L(()=>{e.menuState.value===0&&s.value&&e.activationTrigger.value!==0&&y(()=>{var n,v;return(v=(n=m(f))==null?void 0:n.scrollIntoView)==null?void 0:v.call(n,{block:"nearest"})})});function o(n){if(r.disabled)return n.preventDefault();e.closeMenu(),F(m(e.buttonRef))}function t(){if(r.disabled)return e.goToItem(S.Nothing);e.goToItem(S.Specific,r.id)}let p=G();function a(n){p.update(n)}function i(n){p.wasMoved(n)&&(r.disabled||s.value||e.goToItem(S.Specific,r.id,0))}function u(n){p.wasMoved(n)&&(r.disabled||s.value&&e.goToItem(S.Nothing))}return()=>{let{disabled:n}=r,v={active:s.value,disabled:n,close:e.closeMenu},{id:M,...x}=r;return D({ourProps:{id:M,ref:f,role:"menuitem",tabIndex:n===!0?void 0:-1,"aria-disabled":n===!0?!0:void 0,disabled:void 0,onClick:o,onFocus:t,onPointerenter:a,onMouseenter:a,onPointermove:i,onMousemove:i,onPointerleave:u,onMouseleave:u},theirProps:{...l,...x},slot:v,attrs:l,slots:b,name:"MenuItem"})}}});export{Me as Menu,Re as MenuButton,ye as MenuItem,he 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}; |
@@ -45,5 +45,5 @@ export declare let Popover: import("vue").DefineComponent<{ | ||
}>>, { | ||
id: string; | ||
as: string | Record<string, any>; | ||
disabled: boolean; | ||
id: string; | ||
}>; | ||
@@ -132,7 +132,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; | ||
}>; | ||
@@ -139,0 +139,0 @@ export declare let PopoverGroup: import("vue").DefineComponent<{ |
@@ -1,1 +0,1 @@ | ||
import{Fragment as j,computed as T,defineComponent as K,h as R,inject as _,provide as U,ref as F,shallowRef as ie,watchEffect as q,onMounted as ee,onUnmounted as te}from"vue";import{match as x}from'../../utils/match.js';import{render as G,Features as A}from'../../utils/render.js';import{useId as L}from'../../hooks/use-id.js';import{Keys as C}from'../../keyboard.js';import{getFocusableElements as z,Focus as w,focusIn as k,isFocusableElement as se,FocusableMode as pe,FocusResult as J}from'../../utils/focus-management.js';import{dom as r}from'../../utils/dom.js';import{useOpenClosedProvider as fe,State as H,useOpenClosed as oe}from'../../internal/open-closed.js';import{useResolveButtonType as ve}from'../../hooks/use-resolve-button-type.js';import{useOutsideClick as de}from'../../hooks/use-outside-click.js';import{getOwnerDocument as W}from'../../utils/owner.js';import{useEventListener as ce}from'../../hooks/use-event-listener.js';import{Hidden as Q,Features as X}from'../../internal/hidden.js';import{useTabDirection as ne,Direction as D}from'../../hooks/use-tab-direction.js';import'../../utils/micro-task.js';import{useMainTreeNode as Pe,useRootContainers as me}from'../../hooks/use-root-containers.js';import{useNestedPortals as be}from'../../components/portal/portal.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),d=F(null),c=F(null),O=F(null),f=F(null),y=T(()=>W(t)),M=T(()=>{var Y,Z;if(!r(d)||!r(f))return!1;for(let B of document.querySelectorAll("body > *"))if(Number(B==null?void 0:B.contains(r(d)))^Number(B==null?void 0:B.contains(r(f))))return!0;let o=z(),a=o.indexOf(r(d)),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:d,isPortalled:M,beforePanelSentinel:c,afterPanelSentinel:O,togglePopover(){e.value=x(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),fe(T(()=>x(e.value,{[0]:H.Open,[1]:H.Closed})));let m={buttonId:l.buttonId,panelId:l.panelId,close(){l.closePopover()}},S=ae(),I=S==null?void 0:S.registerPopover,[s,u]=be(),i=me({mainTreeNodeRef:S==null?void 0:S.mainTreeNodeRef,portals:s,defaultContainers:[d,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(d))==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)),ce((v=y.value)==null?void 0:v.defaultView,"focus",o=>{var a,g;o.target!==window&&o.target instanceof HTMLElement&&e.value===0&&(n()||d&&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),de(i.resolveContainers,(o,a)=>{var g;l.closePopover(),se(a,pe.Loose)||(o.preventDefault(),(g=r(d))==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)])}}}),je=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(()=>W(t.button));h({el:t.button,$el:t.button}),ee(()=>{t.buttonId.value=P.id}),te(()=>{t.buttonId.value=null});let d=ae(),c=d==null?void 0:d.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=y.value});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 C.Space:case C.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 C.Space:case C.Enter:n.preventDefault(),n.stopPropagation(),t.popoverState.value===1&&(c==null||c(t.buttonId.value)),t.togglePopover();break;case C.Escape:if(t.popoverState.value!==0)return c==null?void 0:c(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===C.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&&(c==null||c(t.buttonId.value)),t.togglePopover(),(o=r(t.button))==null||o.focus()))}function s(n){n.preventDefault(),n.stopPropagation()}let u=ne();function i(){let n=r(t.panel);if(!n)return;function v(){x(u.value,{[D.Forwards]:()=>k(n,w.First),[D.Backwards]:()=>k(n,w.Last)})===J.Error&&k(z().filter(a=>a.dataset.headlessuiFocusGuard!=="true"),x(u.value,{[D.Forwards]:w.Next,[D.Backwards]:w.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(Q,{id:M,features:X.Focusable,"data-headlessui-focus-guard":!0,as:"button",type:"button",onFocus:i})])}}}),Ae=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=oe(),d=T(()=>e!==null?(e.value&H.Open)===H.Open:h.popoverState.value===0);function c(){h.closePopover()}return()=>{let O={open:h.popoverState.value===0};return G({ourProps:{id:t,"aria-hidden":!0,onClick:c},theirProps:P,slot:O,attrs:b,slots:p,features:A.RenderStrategy|A.Static,visible:d.value,name:"PopoverOverlay"})}}}),We=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"),d=T(()=>W(e.panel)),c=`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=d.value)==null?void 0:u.activeElement;(i=r(e.panel))!=null&&i.contains(s)||k(r(e.panel),w.First)});let f=oe(),y=T(()=>f!==null?(f.value&H.Open)===H.Open:e.popoverState.value===0);function M(s){var u,i;switch(s.key){case C.Escape:if(e.popoverState.value!==0||!r(e.panel)||d.value&&!((u=r(e.panel))!=null&&u.contains(d.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=ne();function S(){let s=r(e.panel);if(!s)return;function u(){x(m.value,{[D.Forwards]:()=>{var n;k(s,w.First)===J.Error&&((n=r(e.afterPanelSentinel))==null||n.focus())},[D.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(){x(m.value,{[D.Forwards]:()=>{let i=r(e.button),n=r(e.panel);if(!i)return;let v=z(),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)}k(E,w.First,{sorted:!1})},[D.Backwards]:()=>{var n;k(s,w.Previous)===J.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(Q,{id:c,ref:e.beforePanelSentinel,features:X.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(Q,{id:O,ref:e.afterPanelSentinel,features:X.Focusable,"data-headlessui-focus-guard":!0,as:"button",type:"button",onFocus:I})])]}},features:A.RenderStrategy|A.Static,visible:y.value,name:"PopoverPanel"})}}}),Ve=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([]),d=T(()=>W(t)),c=Pe();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=d.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:c.mainTreeNodeRef}),()=>R(j,[G({ourProps:{ref:t},theirProps:{...P,...b},slot:{},attrs:b,slots:p,name:"PopoverGroup"}),R(c.MainTreeNode)])}});export{ye as Popover,je as PopoverButton,Ve as PopoverGroup,Ae as PopoverOverlay,We 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, Ref } from 'vue'; | ||
import { type PropType, type Ref } from 'vue'; | ||
export declare let Portal: import("vue").DefineComponent<{ | ||
@@ -3,0 +3,0 @@ as: { |
@@ -1,1 +0,1 @@ | ||
import{Teleport as M,computed as L,defineComponent as s,h as j,inject as f,onMounted as w,onUnmounted as T,provide as y,reactive as I,ref as p,watchEffect as b,watch as R,getCurrentInstance as G}from"vue";import{render as E}from'../../utils/render.js';import{usePortalRoot as O}from'../../internal/portal-force-root.js';import{getOwnerDocument as h}from'../../utils/owner.js';import{dom as D}from'../../utils/dom.js';function x(r){let e=h(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 W=s({name:"Portal",props:{as:{type:[Object,String],default:"div"}},setup(r,{slots:e,attrs:u}){let t=p(null),i=L(()=>h(t)),l=O(),n=f(C,null),o=p(l===!0||n==null?x(t.value):n.resolveTarget()),d=p(!1);w(()=>{d.value=!0}),b(()=>{l||n!=null&&(o.value=n.resolveTarget())});let c=f(m,null),v=!1,H=G();return R(t,()=>{if(v||!c)return;let a=D(t);a&&(T(c.register(a),H),v=!0)}),T(()=>{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 j(M,{to:o.value},E({ourProps:a,theirProps:r,slot:{},attrs:u,slots:e,name:"Portal"}))}}}),m=Symbol("PortalParentContext");function $(){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 y(m,i),()=>{var o;return(o=n.default)==null?void 0:o.call(n)}}})]}let C=Symbol("PortalGroupContext"),k=s({name:"PortalGroup",props:{as:{type:[Object,String],default:"template"},target:{type:Object,default:null}},setup(r,{attrs:e,slots:u}){let t=I({resolveTarget(){return r.target}});return y(C,t),()=>{let{target:i,...l}=r;return E({theirProps:l,ourProps:{},slot:{},attrs:e,slots:u,name:"PortalGroup"})}}});export{W as Portal,k as PortalGroup,$ as useNestedPortals}; | ||
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,7 +16,7 @@ declare function defaultComparator<T>(a: T, z: T): boolean; | ||
modelValue: { | ||
type: (ObjectConstructor | BooleanConstructor | NumberConstructor | StringConstructor)[]; | ||
type: (ObjectConstructor | NumberConstructor | BooleanConstructor | StringConstructor)[]; | ||
default: undefined; | ||
}; | ||
defaultValue: { | ||
type: (ObjectConstructor | BooleanConstructor | NumberConstructor | StringConstructor)[]; | ||
type: (ObjectConstructor | NumberConstructor | BooleanConstructor | StringConstructor)[]; | ||
default: undefined; | ||
@@ -54,7 +54,7 @@ }; | ||
modelValue: { | ||
type: (ObjectConstructor | BooleanConstructor | NumberConstructor | StringConstructor)[]; | ||
type: (ObjectConstructor | NumberConstructor | BooleanConstructor | StringConstructor)[]; | ||
default: undefined; | ||
}; | ||
defaultValue: { | ||
type: (ObjectConstructor | BooleanConstructor | NumberConstructor | StringConstructor)[]; | ||
type: (ObjectConstructor | NumberConstructor | BooleanConstructor | StringConstructor)[]; | ||
default: undefined; | ||
@@ -77,5 +77,5 @@ }; | ||
}, { | ||
id: string; | ||
as: string | Record<string, any>; | ||
disabled: boolean; | ||
id: string; | ||
by: string | Function; | ||
@@ -91,3 +91,3 @@ modelValue: string | number | boolean | Record<string, any>; | ||
value: { | ||
type: (ObjectConstructor | BooleanConstructor | NumberConstructor | StringConstructor)[]; | ||
type: (ObjectConstructor | NumberConstructor | BooleanConstructor | StringConstructor)[]; | ||
}; | ||
@@ -112,3 +112,3 @@ disabled: { | ||
value: { | ||
type: (ObjectConstructor | BooleanConstructor | NumberConstructor | StringConstructor)[]; | ||
type: (ObjectConstructor | NumberConstructor | BooleanConstructor | StringConstructor)[]; | ||
}; | ||
@@ -124,5 +124,5 @@ disabled: { | ||
}>>, { | ||
id: string; | ||
as: string | Record<string, any>; | ||
disabled: boolean; | ||
id: string; | ||
}>; | ||
@@ -160,5 +160,5 @@ export declare let RadioGroupLabel: import("vue").DefineComponent<{ | ||
}>>, { | ||
passive: boolean; | ||
id: string; | ||
as: string | Record<string, any>; | ||
id: string; | ||
passive: boolean; | ||
}>; | ||
@@ -188,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 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{dom as O}from'../../utils/dom.js';import{Keys as g}from'../../keyboard.js';import{focusIn as D,Focus as k,FocusResult as x,sortByDomNode as J}from'../../utils/focus-management.js';import{useId as I}from'../../hooks/use-id.js';import{compact as q,omit as Q,render as P}from'../../utils/render.js';import{Label as X,useLabels as B}from'../label/label.js';import{Description as Y,useDescriptions as V}from'../description/description.js';import{useTreeWalker as Z}from'../../hooks/use-tree-walker.js';import{Hidden as z,Features as ee}from'../../internal/hidden.js';import{attemptSubmit as te,objectToFormEntries as ae}from'../../utils/form.js';import{getOwnerDocument as L}from'../../utils/owner.js';import{useControllable as ne}from'../../hooks/use-controllable.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 ke=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-${I()}`}},inheritAttrs:!1,setup(t,{emit:c,attrs:u,slots:E,expose:d}){let s=h(null),i=h([]),R=B({name:"RadioGroupLabel"}),w=V({name:"RadioGroupDescription"});d({el:s,$el:s});let[f,S]=ne(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=J(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),Z({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:te(e.currentTarget);break;case g.ArrowLeft:case g.ArrowUp:if(e.preventDefault(),e.stopPropagation(),D(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(),D(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?ae({[a]:f.value}).map(([T,G])=>F(z,q({features:ee.Hidden,key:T,as:"input",type:"hidden",hidden:!0,readOnly:!0,form:l,name:T,value:G}))):[],P({ourProps:b,theirProps:{...u,...Q(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 Ee=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-${I()}`}},setup(t,{attrs:c,slots:u,expose:E}){let d=H("RadioGroupOption"),s=B({name:"RadioGroupLabel"}),i=V({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:Boolean(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"})}}}),we=X,Se=Y;export{ke as RadioGroup,Se as RadioGroupDescription,we as RadioGroupLabel,Ee 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}; |
@@ -47,2 +47,10 @@ export declare let SwitchGroup: import("vue").DefineComponent<{ | ||
}; | ||
disabled: { | ||
type: BooleanConstructor; | ||
default: boolean; | ||
}; | ||
tabIndex: { | ||
type: NumberConstructor; | ||
default: number; | ||
}; | ||
}, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, { | ||
@@ -81,7 +89,17 @@ [key: string]: any; | ||
}; | ||
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; | ||
@@ -121,5 +139,5 @@ defaultChecked: boolean; | ||
}>>, { | ||
passive: boolean; | ||
id: string; | ||
as: string | Record<string, any>; | ||
id: string; | ||
passive: boolean; | ||
}>; | ||
@@ -149,4 +167,4 @@ export declare let SwitchDescription: import("vue").DefineComponent<{ | ||
}>>, { | ||
id: string; | ||
as: string | Record<string, any>; | ||
id: string; | ||
}>; |
@@ -1,1 +0,1 @@ | ||
import{Fragment as T,computed as d,defineComponent as m,h,inject as H,provide as M,ref as y,watch as B,onMounted as P}from"vue";import{render as b,compact as j,omit as G}from'../../utils/render.js';import{useId as V}from'../../hooks/use-id.js';import{Keys as v}from'../../keyboard.js';import{Label as F,useLabels as I}from'../label/label.js';import{Description as O,useDescriptions as A}from'../description/description.js';import{useResolveButtonType as $}from'../../hooks/use-resolve-button-type.js';import{Hidden as N,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"),ae=m({name:"SwitchGroup",props:{as:{type:[Object,String],default:"template"}},setup(l,{slots:p,attrs:a}){let o=y(null),f=I({name:"SwitchLabel",props:{htmlFor:d(()=>{var r;return(r=o.value)==null?void 0:r.id}),onClick(r){o.value&&(r.currentTarget.tagName==="LABEL"&&r.preventDefault(),o.value.click(),o.value.focus({preventScroll:!0}))}}}),t=A({name:"SwitchDescription"});return M(S,{switchRef:o,labelledby:f,describedby:t}),()=>b({theirProps:l,ourProps:{},slot:{},slots:p,attrs:a,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},form:{type:String,optional:!0},name:{type:String,optional:!0},value:{type:String,optional:!0},id:{type:String,default:()=>`headlessui-switch-${V()}`}},inheritAttrs:!1,setup(l,{emit:p,attrs:a,slots:o,expose:f}){let t=H(S,null),[i,r]=q(d(()=>l.modelValue),e=>p("update:modelValue",e),d(()=>l.defaultChecked));function s(){r(!i.value)}let w=y(null),u=t===null?w:t.switchRef,g=$(d(()=>({as:l.as,type:a.type})),u);f({el:u,$el:u});function k(e){e.preventDefault(),s()}function C(e){e.key===v.Space?(e.preventDefault(),s()):e.key===v.Enter&&_(e.currentTarget)}function E(e){e.preventDefault()}let c=d(()=>{var e,n;return(n=(e=z(u))==null?void 0:e.closest)==null?void 0:n.call(e,"form")});return P(()=>{B([c],()=>{if(!c.value||l.defaultChecked===void 0)return;function e(){r(l.defaultChecked)}return c.value.addEventListener("reset",e),()=>{var n;(n=c.value)==null||n.removeEventListener("reset",e)}},{immediate:!0})}),()=>{let{id:e,name:n,value:L,form:D,...R}=l,K={checked:i.value},x={id:e,ref:u,role:"switch",type:g.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:k,onKeyup:C,onKeypress:E};return h(T,[n!=null&&i.value!=null?h(N,j({features:U.Hidden,as:"input",type:"checkbox",hidden:!0,readOnly:!0,checked:i.value,form:D,name:n,value:L})):null,b({ourProps:x,theirProps:{...a,...G(R,["modelValue","defaultChecked"])},slot:K,attrs:a,slots:o,name:"Switch"})])}}}),de=F,ce=O;export{ue as Switch,ce as SwitchDescription,ae as SwitchGroup,de 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; | ||
}>; | ||
@@ -173,7 +173,7 @@ export declare let TabPanels: import("vue").DefineComponent<{ | ||
}>>, { | ||
id: string; | ||
tabIndex: number; | ||
as: string | Record<string, any>; | ||
unmount: boolean; | ||
static: boolean; | ||
id: string; | ||
tabIndex: number; | ||
}>; |
@@ -1,1 +0,1 @@ | ||
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 T,watchEffect as _,watch as J}from"vue";import{Features as $,render as O,omit as Q}from'../../utils/render.js';import{useId as q}from'../../hooks/use-id.js';import{Keys as x}from'../../keyboard.js';import{dom as o}from'../../utils/dom.js';import{match as C}from'../../utils/match.js';import{focusIn as R,Focus as I,FocusResult as F,sortByDomNode as L}from'../../utils/focus-management.js';import{useResolveButtonType as V}from'../../hooks/use-resolve-button-type.js';import{FocusSentinel as X}from'../../internal/focus-sentinel.js';import{microTask as Y}from'../../utils/micro-task.js';import{Hidden as Z}from'../../internal/hidden.js';import{getOwnerDocument as ee}from'../../utils/owner.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"),xe=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=T((P=a.selectedIndex)!=null?P:a.defaultIndex),n=T([]),d=T([]),h=c(()=>a.selectedIndex!==null),b=c(()=>h.value?a.selectedIndex:l.value);function m(t){var S;let e=L(r.tabs.value,o),u=L(r.panels.value,o),f=e.filter(p=>{var g;return!((g=o(p))!=null&&g.hasAttribute("disabled"))});if(t<0||t>e.length-1){let p=C(l.value===null?0:Math.sign(t-l.value),{[-1]:()=>1,[0]:()=>C(Math.sign(t),{[-1]:()=>0,[0]:()=>0,[1]:()=>1}),[1]:()=>0}),g=C(p,{[0]:()=>e.indexOf(f[0]),[1]:()=>e.indexOf(f[f.length-1])});g!==-1&&(l.value=g),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=(S=e.indexOf(G))!=null?S: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),h.value||m(t)},registerTab(t){var f;if(n.value.includes(t))return;let e=n.value[l.value];n.value.push(t),n.value=L(n.value,o);let u=(f=n.value.indexOf(e))!=null?f:l.value;u!==-1&&(l.value=u)},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=L(d.value,o))},unregisterPanel(t){let e=d.value.indexOf(t);e!==-1&&d.value.splice(e,1)}};N(U,r);let w=T({tabs:[],panels:[]}),y=T(!1);M(()=>{y.value=!0}),N(j,c(()=>y.value?null:w.value));let E=c(()=>a.selectedIndex);return M(()=>{J([E],()=>{var t;return m((t=a.selectedIndex)!=null?t:a.defaultIndex)},{immediate:!0})}),_(()=>{if(!h.value||b.value==null||r.tabs.value.length<=0)return;let t=L(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(X,{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}}),O({theirProps:{...i,...Q(a,["selectedIndex","defaultIndex","manual","vertical","onChange"])},ourProps:{},slot:t,slots:v,attrs:i,name:"TabGroup"})])}}}),Ie=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 O({ourProps:n,theirProps:a,slot:l,attrs:v,slots:i,name:"TabList"})}}}),ye=D({name:"Tab",props:{as:{type:[Object,String],default:"button"},disabled:{type:[Boolean],default:!1},id:{type:String,default:()=>`headlessui-tabs-tab-${q()}`}},setup(a,{attrs:v,slots:i,expose:s}){let l=k("Tab"),n=T(null);s({el:n,$el:n}),M(()=>l.registerTab(n)),K(()=>l.unregisterTab(n));let d=A(j),h=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?h.value:e}),m=c(()=>b.value===l.selectedIndex.value);function r(e){var f;let u=e();if(u===F.Success&&l.activation.value==="auto"){let S=(f=ee(n))==null?void 0:f.activeElement,p=l.tabs.value.findIndex(g=>o(g)===S);p!==-1&&l.setSelectedIndex(p)}return u}function w(e){let u=l.tabs.value.map(S=>o(S)).filter(Boolean);if(e.key===x.Space||e.key===x.Enter){e.preventDefault(),e.stopPropagation(),l.setSelectedIndex(b.value);return}switch(e.key){case x.Home:case x.PageUp:return e.preventDefault(),e.stopPropagation(),r(()=>R(u,I.First));case x.End:case x.PageDown:return e.preventDefault(),e.stopPropagation(),r(()=>R(u,I.Last))}if(r(()=>C(l.orientation.value,{vertical(){return e.key===x.ArrowUp?R(u,I.Previous|I.WrapAround):e.key===x.ArrowDown?R(u,I.Next|I.WrapAround):F.Error},horizontal(){return e.key===x.ArrowLeft?R(u,I.Previous|I.WrapAround):e.key===x.ArrowRight?R(u,I.Next|I.WrapAround):F.Error}}))===F.Success)return e.preventDefault()}let y=T(!1);function E(){var e;y.value||(y.value=!0,!a.disabled&&((e=o(n))==null||e.focus({preventScroll:!0}),l.setSelectedIndex(b.value),Y(()=>{y.value=!1})))}function P(e){e.preventDefault()}let t=V(c(()=>({as:a.as,type:v.type})),n);return()=>{var p;let e={selected:m.value},{id:u,...f}=a,S={ref:n,onKeydown:w,onMousedown:P,onClick:E,id:u,role:"tab",type:t.value,"aria-controls":(p=o(l.panels.value[b.value]))==null?void 0:p.id,"aria-selected":m.value,tabIndex:m.value?0:-1,disabled:a.disabled?!0:void 0};return O({ourProps:S,theirProps:f,slot:e,attrs:v,slots:i,name:"Tab"})}}}),Se=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 O({theirProps:a,ourProps:{},slot:l,attrs:i,slots:v,name:"TabPanels"})}}}),ge=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-${q()}`},tabIndex:{type:Number,default:0}},setup(a,{attrs:v,slots:i,expose:s}){let l=k("TabPanel"),n=T(null);s({el:n,$el:n}),M(()=>l.registerPanel(n)),K(()=>l.unregisterPanel(n));let d=A(j),h=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?h.value:r}),m=c(()=>b.value===l.selectedIndex.value);return()=>{var t;let r={selected:m.value},{id:w,tabIndex:y,...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?y:-1};return!m.value&&a.unmount&&!a.static?H(Z,{as:"span","aria-hidden":!0,...P}):O({ourProps:P,theirProps:E,slot:r,attrs:v,slots:i,features:$.Static|$.RenderStrategy,visible:m.value,name:"TabPanel"})}}});export{ye as Tab,xe as TabGroup,Ie as TabList,ge as TabPanel,Se 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 w,defineComponent as K,h as k,inject as F,onMounted as C,onUnmounted as z,provide as B,ref as m,watch as ae,watchEffect as x,normalizeClass as le}from"vue";import{useId as ie}from'../../hooks/use-id.js';import{match as O}from'../../utils/match.js';import{env as se}from'../../utils/env.js';import{Features as oe,omit as ue,render as $,RenderStrategy as T}from'../../utils/render.js';import{Reason as q,transition as G}from'./utils/transition.js';import{dom as J}from'../../utils/dom.js';import{useOpenClosedProvider as fe,State as u,useOpenClosed as de,hasOpenClosed as ve}from'../../internal/open-closed.js';function g(e=""){return e.split(" ").filter(t=>t.trim().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=oe.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()&&ve())return()=>k(Se,{...e,onBeforeEnter:r,onAfterEnter:l,onBeforeLeave:f,onAfterLeave:S},s);let d=m(null),b=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(),y={value:!1},P=Q(()=>{!y.value&&i.value!=="hidden"&&(i.value="hidden",H(c),S())});C(()=>{let o=D(c);z(o)}),x(()=>{if(b.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=J(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=J(d);!p||!(p instanceof HTMLElement)||E||(y.value=!0,v.value&&r(),v.value||f(),o(v.value?G(p,j,M,X,_,V=>{y.value=!1,V===q.Finished&&l()}):G(p,Y,Z,ee,_,V=>{y.value=!1,V===q.Finished&&(L(P)||(i.value="hidden",H(c),S()))})))}return C(()=>{ae([v],(o,E,p)=>{te(p),I.value=!1},{immediate:!0})}),B(N,P),fe(w(()=>O(i.value,{["visible"]:u.Open,["hidden"]:u.Closed})|n.value)),()=>{let{appear:o,show:E,enter:p,enterFrom:V,enterTo:Ce,entered:be,leave:ye,leaveFrom:Ee,leaveTo:Ve,...U}=e,ne={ref:d},re={...U,...A.value&&v.value&&se.isServer?{class:le([a.class,U.class,...j,...M])}:{}};return $({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=de(),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=ue(e,["show","appear","unmount","onBeforeEnter","onBeforeLeave","onAfterEnter","onAfterLeave"]),b={unmount:e.unmount};return $({ourProps:{...b,as:"template"},theirProps:{},slot:{},slots:{...s,default:()=>[k(ce,{onBeforeEnter:()=>t("beforeEnter"),onAfterEnter:()=>t("afterEnter"),onBeforeLeave:()=>t("beforeLeave"),onAfterLeave:()=>t("afterLeave"),...a,...b,...d},s.default)]},attrs:{},features:W,visible:r.value==="visible",name:"Transition"})}}});export{he as TransitionChild,Se 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/radio-group/radio-group.js';export*from'./components/switch/switch.js';export*from'./components/tabs/tabs.js';export*from'./components/transitions/transition.js';import{Portal as b,PortalGroup as c}from'./components/portal/portal.js';export{b as Portal,c as PortalGroup}; | ||
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 { ScrollLockStep } from './overflow-store.js'; | ||
import type { ScrollLockStep } from './overflow-store.js'; | ||
export declare function adjustScrollbarPadding(): ScrollLockStep; |
@@ -1,1 +0,1 @@ | ||
function c(){let o;return{before({doc:e}){var l;let n=e.documentElement;o=((l=e.defaultView)!=null?l:window).innerWidth-n.clientWidth},after({doc:e,d:n}){let t=e.documentElement,l=t.clientWidth-t.offsetWidth,r=o-l;n.style(t,"paddingRight",`${r}px`)}}}export{c as adjustScrollbarPadding}; | ||
function d(){let r;return{before({doc:e}){var l;let o=e.documentElement,t=(l=e.defaultView)!=null?l:window;r=Math.max(0,t.innerWidth-o.clientWidth)},after({doc:e,d:o}){let t=e.documentElement,l=Math.max(0,t.clientWidth-t.offsetWidth),n=Math.max(0,r-l);o.style(t,"paddingRight",`${n}px`)}}}export{d as adjustScrollbarPadding}; |
@@ -1,2 +0,2 @@ | ||
import { ScrollLockStep } from './overflow-store.js'; | ||
import type { ScrollLockStep } from './overflow-store.js'; | ||
interface ContainerMetadata { | ||
@@ -3,0 +3,0 @@ containers: (() => HTMLElement[])[]; |
@@ -1,1 +0,1 @@ | ||
import{disposables as f}from'../../utils/disposables.js';import{isIOS as m}from'../../utils/platform.js';function w(){if(!m())return{};let r;return{before(){r=window.pageYOffset},after({doc:n,d:o,meta:s}){function i(e){return s.containers.flatMap(t=>t()).some(t=>t.contains(e))}if(window.getComputedStyle(n.documentElement).scrollBehavior!=="auto"){let e=f();e.style(n.documentElement,"scroll-behavior","auto"),o.add(()=>o.microTask(()=>e.dispose()))}o.style(n.body,"marginTop",`-${r}px`),window.scrollTo(0,0);let l=null;o.addEventListener(n,"click",e=>{if(e.target instanceof HTMLElement)try{let t=e.target.closest("a");if(!t)return;let{hash:c}=new URL(t.href),a=n.querySelector(c);a&&!i(a)&&(l=a)}catch{}},!0),o.addEventListener(n,"touchmove",e=>{e.target instanceof HTMLElement&&!i(e.target)&&e.preventDefault()},{passive:!1}),o.add(()=>{window.scrollTo(0,window.pageYOffset+r),l&&l.isConnected&&(l.scrollIntoView({block:"nearest"}),l=null)})}}}export{w as handleIOSLocking}; | ||
import{disposables as m}from'../../utils/disposables.js';import{isIOS as u}from'../../utils/platform.js';function d(){return u()?{before({doc:r,d:n,meta:c}){function o(a){return c.containers.flatMap(l=>l()).some(l=>l.contains(a))}n.microTask(()=>{var s;if(window.getComputedStyle(r.documentElement).scrollBehavior!=="auto"){let t=m();t.style(r.documentElement,"scrollBehavior","auto"),n.add(()=>n.microTask(()=>t.dispose()))}let a=(s=window.scrollY)!=null?s:window.pageYOffset,l=null;n.addEventListener(r,"click",t=>{if(t.target instanceof HTMLElement)try{let e=t.target.closest("a");if(!e)return;let{hash:f}=new URL(e.href),i=r.querySelector(f);i&&!o(i)&&(l=i)}catch{}},!0),n.addEventListener(r,"touchstart",t=>{if(t.target instanceof HTMLElement)if(o(t.target)){let e=t.target;for(;e.parentElement&&o(e.parentElement);)e=e.parentElement;n.style(e,"overscrollBehavior","contain")}else n.style(t.target,"touchAction","none")}),n.addEventListener(r,"touchmove",t=>{if(t.target instanceof HTMLElement){if(t.target.tagName==="INPUT")return;if(o(t.target)){let e=t.target;for(;e.parentElement&&e.dataset.headlessuiPortal!==""&&!(e.scrollHeight>e.clientHeight||e.scrollWidth>e.clientWidth);)e=e.parentElement;e.dataset.headlessuiPortal===""&&t.preventDefault()}else t.preventDefault()}},{passive:!1}),n.add(()=>{var e;let t=(e=window.scrollY)!=null?e:window.pageYOffset;a!==t&&window.scrollTo(0,a),l&&l.isConnected&&(l.scrollIntoView({block:"nearest"}),l=null)})})}}:{}}export{d as handleIOSLocking}; |
@@ -1,2 +0,2 @@ | ||
import { Disposables } from '../../utils/disposables.js'; | ||
import { type Disposables } from '../../utils/disposables.js'; | ||
interface DocEntry { | ||
@@ -3,0 +3,0 @@ doc: Document; |
@@ -1,2 +0,2 @@ | ||
import { ScrollLockStep } from './overflow-store.js'; | ||
import type { ScrollLockStep } from './overflow-store.js'; | ||
export declare function preventScroll(): ScrollLockStep; |
@@ -1,1 +0,1 @@ | ||
function l(){return{before({doc:e,d:o}){o.style(e.documentElement,"overflow","hidden")}}}export{l as preventScroll}; | ||
function r(){return{before({doc:e,d:o}){o.style(e.documentElement,"overflow","hidden")}}}export{r as preventScroll}; |
@@ -1,3 +0,3 @@ | ||
import { MetaFn } from './overflow-store.js'; | ||
import { Ref } from 'vue'; | ||
import { type Ref } from 'vue'; | ||
import { type MetaFn } from './overflow-store.js'; | ||
export declare function useDocumentOverflowLockedEffect(doc: Ref<Document | null>, shouldBeLocked: Ref<boolean>, meta: MetaFn): import("vue").ComputedRef<boolean>; |
@@ -1,1 +0,1 @@ | ||
import{useStore as p}from'../../hooks/use-store.js';import{overflows as u}from'./overflow-store.js';import{computed as s,watch as v}from"vue";function d(t,a,n){let i=p(u),l=s(()=>{let e=t.value?i.value.get(t.value):void 0;return e?e.count>0:!1});return v([t,a],([e,m],[r],o)=>{if(!e||!m)return;u.dispatch("PUSH",e,n);let f=!1;o(()=>{f||(u.dispatch("POP",r!=null?r:e,n),f=!0)})},{immediate:!0}),l}export{d as useDocumentOverflowLockedEffect}; | ||
import{computed as o,watch as s}from"vue";import{useStore as v}from'../../hooks/use-store.js';import{overflows as u}from'./overflow-store.js';function w(t,a,n){let i=v(u),l=o(()=>{let e=t.value?i.value.get(t.value):void 0;return e?e.count>0:!1});return s([t,a],([e,m],[r],p)=>{if(!e||!m)return;u.dispatch("PUSH",e,n);let f=!1;p(()=>{f||(u.dispatch("POP",r!=null?r:e,n),f=!0)})},{immediate:!0}),l}export{w as useDocumentOverflowLockedEffect}; |
@@ -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{env as m}from'../utils/env.js';function u(e,t,n){m.isServer||r(o=>{document.addEventListener(e,t,n),o(()=>document.removeEventListener(e,t,n))})}export{u 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,2 +0,2 @@ | ||
import { Ref } from 'vue'; | ||
import { type Ref } from 'vue'; | ||
export declare function useInert<TElement extends HTMLElement>(node: Ref<TElement | null>, enabled?: Ref<boolean>): void; |
@@ -1,1 +0,1 @@ | ||
import{ref as m,watchEffect as s}from"vue";import{dom as h}from'../utils/dom.js';let i=new Map,t=new Map;function E(d,f=m(!0)){s(o=>{var a;if(!f.value)return;let e=h(d);if(!e)return;o(function(){var u;if(!e)return;let r=(u=t.get(e))!=null?u:1;if(r===1?t.delete(e):t.set(e,r-1),r!==1)return;let n=i.get(e);n&&(n["aria-hidden"]===null?e.removeAttribute("aria-hidden"):e.setAttribute("aria-hidden",n["aria-hidden"]),e.inert=n.inert,i.delete(e))});let l=(a=t.get(e))!=null?a:0;t.set(e,l+1),l===0&&(i.set(e,{"aria-hidden":e.getAttribute("aria-hidden"),inert:e.inert}),e.setAttribute("aria-hidden","true"),e.inert=!0)})}export{E as useInert}; | ||
import{ref as m,watchEffect as s}from"vue";import{dom as h}from'../utils/dom.js';let i=new Map,t=new Map;function p(d,f=m(!0)){s(o=>{var a;if(!f.value)return;let e=h(d);if(!e)return;o(function(){var u;if(!e)return;let r=(u=t.get(e))!=null?u:1;if(r===1?t.delete(e):t.set(e,r-1),r!==1)return;let n=i.get(e);n&&(n["aria-hidden"]===null?e.removeAttribute("aria-hidden"):e.setAttribute("aria-hidden",n["aria-hidden"]),e.inert=n.inert,i.delete(e))});let l=(a=t.get(e))!=null?a:0;t.set(e,l+1),l===0&&(i.set(e,{"aria-hidden":e.getAttribute("aria-hidden"),inert:e.inert}),e.setAttribute("aria-hidden","true"),e.inert=!0)})}export{p as useInert}; |
@@ -1,2 +0,2 @@ | ||
import { Ref, ComputedRef } from 'vue'; | ||
import { type ComputedRef, type Ref } from 'vue'; | ||
type Container = Ref<HTMLElement | null> | HTMLElement | null; | ||
@@ -3,0 +3,0 @@ type ContainerCollection = Container[] | Set<Container>; |
@@ -1,1 +0,1 @@ | ||
import{computed as s,ref as E}from"vue";import{FocusableMode as d,isFocusableElement as p}from'../utils/focus-management.js';import{dom as C}from'../utils/dom.js';import{useDocumentEvent as i}from'./use-document-event.js';import{useWindowEvent as T}from'./use-window-event.js';import{isMobile as M}from'../utils/platform.js';function F(f,m,l=s(()=>!0)){function a(e,r){if(!l.value||e.defaultPrevented)return;let t=r(e);if(t===null||!t.getRootNode().contains(t))return;let c=function o(n){return typeof n=="function"?o(n()):Array.isArray(n)||n instanceof Set?n:[n]}(f);for(let o of c){if(o===null)continue;let n=o instanceof HTMLElement?o:C(o);if(n!=null&&n.contains(t)||e.composed&&e.composedPath().includes(n))return}return!p(t,d.Loose)&&t.tabIndex!==-1&&e.preventDefault(),m(e,t)}let u=E(null);i("pointerdown",e=>{var r,t;l.value&&(u.value=((t=(r=e.composedPath)==null?void 0:r.call(e))==null?void 0:t[0])||e.target)},!0),i("mousedown",e=>{var r,t;l.value&&(u.value=((t=(r=e.composedPath)==null?void 0:r.call(e))==null?void 0:t[0])||e.target)},!0),i("click",e=>{M()||u.value&&(a(e,()=>u.value),u.value=null)},!0),i("touchend",e=>a(e,()=>e.target instanceof HTMLElement?e.target:null),!0),T("blur",e=>a(e,()=>window.document.activeElement instanceof HTMLIFrameElement?window.document.activeElement:null),!0)}export{F 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<{} | undefined>; | ||
}>, 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,2 +0,2 @@ | ||
import { Ref } from 'vue'; | ||
import { type Ref } from 'vue'; | ||
export declare function useRootContainers({ defaultContainers, portals, mainTreeNodeRef: _mainTreeNodeRef, }?: { | ||
@@ -3,0 +3,0 @@ defaultContainers?: (HTMLElement | null | Ref<HTMLElement | null>)[]; |
@@ -1,1 +0,1 @@ | ||
import{ref as f,h as a}from"vue";import{Hidden as m,Features as d}from'../internal/hidden.js';import{getOwnerDocument as T}from'../utils/owner.js';import{dom as H}from'../utils/dom.js';function p({defaultContainers:t=[],portals:o,mainTreeNodeRef:s}={}){let i=f(null),r=T(i);function u(){var l;let n=[];for(let e of t)e!==null&&(e instanceof HTMLElement?n.push(e):"value"in e&&e.value instanceof HTMLElement&&n.push(e.value));if(o!=null&&o.value)for(let e of o.value)n.push(e);for(let e of(l=r==null?void 0:r.querySelectorAll("html > *, body > *"))!=null?l:[])e!==document.body&&e!==document.head&&e instanceof HTMLElement&&e.id!=="headlessui-portal-root"&&(e.contains(H(i))||n.some(c=>e.contains(c))||n.push(e));return n}return{resolveContainers:u,contains(n){return u().some(l=>l.contains(n))},mainTreeNodeRef:i,MainTreeNode(){return s!=null?null:a(m,{features:d.Hidden,ref:i})}}}function N(){let t=f(null);return{mainTreeNodeRef:t,MainTreeNode(){return a(m,{features:d.Hidden,ref:t})}}}export{N as useMainTreeNode,p as useRootContainers}; | ||
import{h as m,ref as s}from"vue";import{Hidden as d,Features as c}from'../internal/hidden.js';import{dom as T}from'../utils/dom.js';import{getOwnerDocument as E}from'../utils/owner.js';function N({defaultContainers:o=[],portals:i,mainTreeNodeRef:H}={}){let t=s(null),r=E(t);function u(){var l,f,a;let n=[];for(let e of o)e!==null&&(e instanceof HTMLElement?n.push(e):"value"in e&&e.value instanceof HTMLElement&&n.push(e.value));if(i!=null&&i.value)for(let e of i.value)n.push(e);for(let e of(l=r==null?void 0:r.querySelectorAll("html > *, body > *"))!=null?l:[])e!==document.body&&e!==document.head&&e instanceof HTMLElement&&e.id!=="headlessui-portal-root"&&(e.contains(T(t))||e.contains((a=(f=T(t))==null?void 0:f.getRootNode())==null?void 0:a.host)||n.some(M=>e.contains(M))||n.push(e));return n}return{resolveContainers:u,contains(n){return u().some(l=>l.contains(n))},mainTreeNodeRef:t,MainTreeNode(){return H!=null?null:m(d,{features:c.Hidden,ref:t})}}}function v(){let o=s(null);return{mainTreeNodeRef:o,MainTreeNode(){return m(d,{features:c.Hidden,ref:o})}}}export{v as useMainTreeNode,N as useRootContainers}; |
@@ -1,2 +0,2 @@ | ||
import { Store } from '../utils/store.js'; | ||
import type { Store } from '../utils/store.js'; | ||
export declare function useStore<T>(store: Store<T, any>): import("vue").ShallowRef<T>; |
@@ -1,1 +0,1 @@ | ||
import{onUnmounted as o,shallowRef as n}from"vue";function m(t){let e=n(t.getSnapshot());return o(t.subscribe(()=>{e.value=t.getSnapshot()})),e}export{m as useStore}; | ||
import{onUnmounted as o,shallowRef as r}from"vue";function s(t){let e=r(t.getSnapshot());return o(t.subscribe(()=>{e.value=t.getSnapshot()})),e}export{s as useStore}; |
@@ -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,2 +0,2 @@ | ||
import { Ref } from 'vue'; | ||
import { type Ref } from 'vue'; | ||
export declare function useTextValue(element: Ref<HTMLElement | null>): () => string; |
@@ -1,1 +0,1 @@ | ||
import{ref as n}from"vue";import{getTextValue as o}from'../utils/get-text-value.js';import{dom as i}from'../utils/dom.js';function p(a){let t=n(""),r=n("");return()=>{let e=i(a);if(!e)return"";let l=e.innerText;if(t.value===l)return r.value;let u=o(e).trim().toLowerCase();return t.value=l,r.value=u,u}}export{p as useTextValue}; | ||
import{ref as n}from"vue";import{dom as o}from'../utils/dom.js';import{getTextValue as i}from'../utils/get-text-value.js';function p(a){let t=n(""),r=n("");return()=>{let e=o(a);if(!e)return"";let l=e.innerText;if(t.value===l)return r.value;let u=i(e).trim().toLowerCase();return t.value=l,r.value=u,u}}export{p as useTextValue}; |
@@ -1,2 +0,2 @@ | ||
import { ComputedRef } from 'vue'; | ||
import { type ComputedRef } from 'vue'; | ||
type AcceptNode = (node: HTMLElement) => typeof NodeFilter.FILTER_ACCEPT | typeof NodeFilter.FILTER_SKIP | typeof NodeFilter.FILTER_REJECT; | ||
@@ -3,0 +3,0 @@ export declare function useTreeWalker({ container, accept, walk, enabled, }: { |
@@ -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{env as r}from'../utils/env.js';function w(e,n,t){r.isServer||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,2 +8,3 @@ export * from './components/combobox/combobox.js'; | ||
export * from './components/popover/popover.js'; | ||
export { Portal, PortalGroup } from './components/portal/portal.js'; | ||
export * from './components/radio-group/radio-group.js'; | ||
@@ -13,2 +14,1 @@ export * from './components/switch/switch.js'; | ||
export * from './components/transitions/transition.js'; | ||
export { Portal, PortalGroup } from './components/portal/portal.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/radio-group/radio-group.js';export*from'./components/switch/switch.js';export*from'./components/tabs/tabs.js';export*from'./components/transitions/transition.js';import{Portal as b,PortalGroup as c}from'./components/portal/portal.js';export{b as Portal,c as PortalGroup}; | ||
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 a}from"vue";import{render as p}from'../utils/render.js';var s=(e=>(e[e.None=1]="None",e[e.Focusable=2]="Focusable",e[e.Hidden=4]="Hidden",e))(s||{});let m=a({name:"Hidden",props:{as:{type:[Object,String],default:"div"},features:{type:Number,default:1}},setup(d,{slots:o,attrs:i}){return()=>{var t;let{features:e,...r}=d,n={"aria-hidden":(e&2)===2?!0:(t=r["aria-hidden"])!=null?t: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:r,slot:{},attrs:i,slots:o,name:"Hidden"})}}});export{s as Features,m 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,2 +0,2 @@ | ||
import { Ref } from 'vue'; | ||
import { type Ref } from 'vue'; | ||
export declare enum State { | ||
@@ -3,0 +3,0 @@ Open = 1, |
@@ -1,1 +0,1 @@ | ||
import{inject as r,provide as i}from"vue";let n=Symbol("Context");var l=(e=>(e[e.Open=1]="Open",e[e.Closed=2]="Closed",e[e.Closing=4]="Closing",e[e.Opening=8]="Opening",e))(l||{});function C(){return p()!==null}function p(){return r(n,null)}function c(o){i(n,o)}export{l as State,C 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,2 +0,2 @@ | ||
import { Ref } from 'vue'; | ||
import { type Ref } from 'vue'; | ||
type OnUpdate = (message: StackMessage, type: string, element: Ref<HTMLElement | null>) => void; | ||
@@ -3,0 +3,0 @@ export declare enum StackMessage { |
@@ -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}; |
@@ -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 { | ||
@@ -2,0 +3,0 @@ /** Focus the first non-disabled element */ |
@@ -1,1 +0,1 @@ | ||
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,E as getFocusableElements,w as isFocusableElement,_ 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,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 o}from'./dom.js';import{env as t}from'./env.js';function m(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{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}; |
@@ -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 O,cloneVNode as x,Fragment 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 H({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(` | ||
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(` | ||
`));let p=j((h=u.props)!=null?h:{},l),f=x(u,p);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 O(n,Object.assign({},l,d),{default:()=>a})}function b(r){return r.flatMap(t=>t.type===k?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 K(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,K as compact,T as omit,H 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.134c0fb", | ||
"version": "0.0.0-insiders.13b3100", | ||
"description": "A set of completely unstyled, fully accessible UI components for Vue 3, designed to integrate beautifully with Tailwind CSS.", | ||
@@ -14,3 +14,6 @@ "main": "dist/index.cjs", | ||
"exports": { | ||
"types": "./dist/index.d.ts", | ||
"types": { | ||
"import": "./dist/index.d.ts", | ||
"require": "./dist/index.d.cts" | ||
}, | ||
"import": "./dist/headlessui.esm.js", | ||
@@ -38,3 +41,4 @@ "require": "./dist/index.cjs" | ||
"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" | ||
} | ||
} |
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
601363
135
11534
2
4
+ Added@tanstack/virtual-core@3.0.0-beta.60(transitive)
+ Added@tanstack/vue-virtual@3.0.0-beta.60(transitive)