Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@headlessui/react

Package Overview
Dependencies
Maintainers
4
Versions
727
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@headlessui/react - npm Package Compare versions

Comparing version 0.0.0-insiders.300e9eb to 0.0.0-insiders.3070ad9

dist/hooks/use-default-value.d.ts

2

dist/components/checkbox/checkbox.js

@@ -1,1 +0,1 @@

"use client";import{useFocusRing as G}from"@react-aria/focus";import{useHover as S}from"@react-aria/interactions";import n,{useCallback as W,useMemo as N,useState as w}from"react";import{useActivePress as J}from'../../hooks/use-active-press.js';import{useControllable as V}from'../../hooks/use-controllable.js';import{useDisposables as $}from'../../hooks/use-disposables.js';import{useEvent as s}from'../../hooks/use-event.js';import{useId as j}from'../../hooks/use-id.js';import{useDisabled as q}from'../../internal/disabled.js';import{FormFields as z}from'../../internal/form-fields.js';import{useProvidedId as Q}from'../../internal/id.js';import{isDisabledReactIssue7711 as Y}from'../../utils/bugs.js';import{attemptSubmit as Z}from'../../utils/form.js';import{forwardRefWithAs as ee,mergeProps as oe,render as te}from'../../utils/render.js';import{useDescribedBy as re}from'../description/description.js';import{Keys as y}from'../keyboard.js';import{useLabelledBy as ae}from'../label/label.js';let se="span";function le(T,h){let C=j(),k=Q(),x=q(),{id:g=k||`headlessui-checkbox-${C}`,disabled:o=x||!1,autoFocus:l=!1,checked:E,defaultChecked:i=!1,onChange:v,name:d,value:P,form:D,indeterminate:a=!1,...R}=T,[r,t]=V(E,v,i),A=ae(),F=re(),K=$(),[p,c]=w(!1),m=s(()=>{c(!0),t==null||t(!r),K.nextFrame(()=>{c(!1)})}),_=s(e=>{if(Y(e.currentTarget))return e.preventDefault();e.preventDefault(),m()}),H=s(e=>{e.key===y.Space?(e.preventDefault(),m()):e.key===y.Enter&&Z(e.currentTarget)}),B=s(e=>e.preventDefault()),{isFocusVisible:b,focusProps:L}=G({autoFocus:l}),{isHovered:u,hoverProps:I}=S({isDisabled:o}),{pressed:f,pressProps:M}=J({disabled:o}),U=oe({ref:h,id:g,role:"checkbox","aria-checked":a?"mixed":r?"true":"false","aria-labelledby":A,"aria-describedby":F,"aria-disabled":o?!0:void 0,indeterminate:a?"true":void 0,tabIndex:0,onKeyUp:o?void 0:H,onKeyPress:o?void 0:B,onClick:o?void 0:_},L,I,M),O=N(()=>({checked:r,disabled:o,hover:u,focus:b,active:f,indeterminate:a,changing:p,autofocus:l}),[r,a,o,u,b,f,p,l]),X=W(()=>t==null?void 0:t(i),[t]);return n.createElement(n.Fragment,null,d!=null&&n.createElement(z,{disabled:o,data:{[d]:P||"on"},overrides:{type:"checkbox",checked:r},form:D,onReset:X}),te({ourProps:U,theirProps:R,slot:O,defaultTag:se,name:"Checkbox"}))}let ve=ee(le);export{ve as Checkbox};
"use client";import{useFocusRing as S}from"@react-aria/focus";import{useHover as W}from"@react-aria/interactions";import i,{useCallback as N,useMemo as V,useState as w}from"react";import{useActivePress as J}from'../../hooks/use-active-press.js';import{useControllable as $}from'../../hooks/use-controllable.js';import{useDefaultValue as j}from'../../hooks/use-default-value.js';import{useDisposables as q}from'../../hooks/use-disposables.js';import{useEvent as l}from'../../hooks/use-event.js';import{useId as z}from'../../hooks/use-id.js';import{useDisabled as Q}from'../../internal/disabled.js';import{FormFields as Y}from'../../internal/form-fields.js';import{useProvidedId as Z}from'../../internal/id.js';import{isDisabledReactIssue7711 as ee}from'../../utils/bugs.js';import{attemptSubmit as oe}from'../../utils/form.js';import{forwardRefWithAs as te,mergeProps as re,render as ae}from'../../utils/render.js';import{useDescribedBy as ne}from'../description/description.js';import{Keys as y}from'../keyboard.js';import{useLabelledBy as le}from'../label/label.js';let se="span";function ie(T,h){let C=z(),k=Z(),x=Q(),{id:g=k||`headlessui-checkbox-${C}`,disabled:e=x||!1,autoFocus:s=!1,checked:E,defaultChecked:v,onChange:P,name:d,value:D,form:R,indeterminate:n=!1,...A}=T,r=j(v),[a,t]=$(E,P,r!=null?r:!1),F=le(),K=ne(),_=q(),[p,c]=w(!1),u=l(()=>{c(!0),t==null||t(!a),_.nextFrame(()=>{c(!1)})}),H=l(o=>{if(ee(o.currentTarget))return o.preventDefault();o.preventDefault(),u()}),B=l(o=>{o.key===y.Space?(o.preventDefault(),u()):o.key===y.Enter&&oe(o.currentTarget)}),L=l(o=>o.preventDefault()),{isFocusVisible:m,focusProps:I}=S({autoFocus:s}),{isHovered:f,hoverProps:M}=W({isDisabled:e}),{pressed:b,pressProps:U}=J({disabled:e}),O=re({ref:h,id:g,role:"checkbox","aria-checked":n?"mixed":a?"true":"false","aria-labelledby":F,"aria-describedby":K,"aria-disabled":e?!0:void 0,indeterminate:n?"true":void 0,tabIndex:e?void 0:0,onKeyUp:e?void 0:B,onKeyPress:e?void 0:L,onClick:e?void 0:H},I,M,U),X=V(()=>({checked:a,disabled:e,hover:f,focus:m,active:b,indeterminate:n,changing:p,autofocus:s}),[a,n,e,f,m,b,p,s]),G=N(()=>{if(r!==void 0)return t==null?void 0:t(r)},[t,r]);return i.createElement(i.Fragment,null,d!=null&&i.createElement(Y,{disabled:e,data:{[d]:D||"on"},overrides:{type:"checkbox",checked:a},form:R,onReset:G}),ae({ourProps:O,theirProps:A,slot:X,defaultTag:se,name:"Checkbox"}))}let Re=te(ie);export{Re as Checkbox};

@@ -1,1 +0,1 @@

"use client";import{useFocusRing as ve}from"@react-aria/focus";import{useHover as Oe}from"@react-aria/interactions";import{useVirtualizer as Le}from"@tanstack/react-virtual";import D,{Fragment as Ce,createContext as be,createRef as we,useCallback as ye,useContext as ce,useMemo as G,useReducer as Be,useRef as j,useState as Re}from"react";import{useActivePress as ke}from'../../hooks/use-active-press.js';import{useByComparator as Ne}from'../../hooks/use-by-comparator.js';import{useControllable as Ue}from'../../hooks/use-controllable.js';import{useDisposables as Se}from'../../hooks/use-disposables.js';import{useElementSize as Pe}from'../../hooks/use-element-size.js';import{useEvent as x}from'../../hooks/use-event.js';import{useFrameDebounce as He}from'../../hooks/use-frame-debounce.js';import{useId as ie}from'../../hooks/use-id.js';import{useInertOthers as Ge}from'../../hooks/use-inert-others.js';import{useIsoMorphicEffect as K}from'../../hooks/use-iso-morphic-effect.js';import{useLatestValue as je}from'../../hooks/use-latest-value.js';import{useOnDisappear as Ke}from'../../hooks/use-on-disappear.js';import{useOutsideClick as We}from'../../hooks/use-outside-click.js';import{useOwnerDocument as Ie}from'../../hooks/use-owner.js';import{useRefocusableInput as Ae}from'../../hooks/use-refocusable-input.js';import{useResolveButtonType as ze}from'../../hooks/use-resolve-button-type.js';import{useScrollLock as $e}from'../../hooks/use-scroll-lock.js';import{useSyncRefs as ae}from'../../hooks/use-sync-refs.js';import{useTrackedPointer as Xe}from'../../hooks/use-tracked-pointer.js';import{useTreeWalker as Je}from'../../hooks/use-tree-walker.js';import{useWatch as Ee}from'../../hooks/use-watch.js';import{useDisabled as qe}from'../../internal/disabled.js';import{FloatingProvider as Ye,useFloatingPanel as Qe,useFloatingPanelProps as Ze,useFloatingReference as eo,useResolvedAnchor as oo}from'../../internal/floating.js';import{FormFields as to}from'../../internal/form-fields.js';import{useProvidedId as no}from'../../internal/id.js';import{OpenClosedProvider as ro,State as le,useOpenClosed as io}from'../../internal/open-closed.js';import{history as _e}from'../../utils/active-element-history.js';import{isDisabledReactIssue7711 as ao}from'../../utils/bugs.js';import{Focus as S,calculateActiveIndex as Fe}from'../../utils/calculate-active-index.js';import{disposables as he}from'../../utils/disposables.js';import{sortByDomNode as lo}from'../../utils/focus-management.js';import{match as q}from'../../utils/match.js';import{isMobile as uo}from'../../utils/platform.js';import{RenderFeatures as Me,forwardRefWithAs as Q,mergeProps as fe,render as Z}from'../../utils/render.js';import{useDescribedBy as po}from'../description/description.js';import{Keys as M}from'../keyboard.js';import{Label as so,useLabelledBy as me,useLabels as bo}from'../label/label.js';import{MouseButton as De}from'../mouse.js';import{Portal as co}from'../portal/portal.js';var fo=(e=>(e[e.Open=0]="Open",e[e.Closed=1]="Closed",e))(fo||{}),mo=(e=>(e[e.Single=0]="Single",e[e.Multi=1]="Multi",e))(mo||{}),xo=(t=>(t[t.Pointer=0]="Pointer",t[t.Focus=1]="Focus",t[t.Other=2]="Other",t))(xo||{}),To=(i=>(i[i.OpenCombobox=0]="OpenCombobox",i[i.CloseCombobox=1]="CloseCombobox",i[i.GoToOption=2]="GoToOption",i[i.RegisterOption=3]="RegisterOption",i[i.UnregisterOption=4]="UnregisterOption",i[i.SetActivationTrigger=5]="SetActivationTrigger",i[i.UpdateVirtualOptions=6]="UpdateVirtualOptions",i))(To||{});function xe(o,r=e=>e){let e=o.activeOptionIndex!==null?o.options[o.activeOptionIndex]:null,t=r(o.options.slice()),p=t.length>0&&t[0].dataRef.current.order!==null?t.sort((b,i)=>b.dataRef.current.order-i.dataRef.current.order):lo(t,b=>b.dataRef.current.domRef.current),f=e?p.indexOf(e):null;return f===-1&&(f=null),{options:p,activeOptionIndex:f}}let go={[1](o){var r;return(r=o.dataRef.current)!=null&&r.disabled||o.comboboxState===1?o:{...o,activeOptionIndex:null,comboboxState:1,activationTrigger:2,__demoMode:!1}},[0](o){var r,e;if((r=o.dataRef.current)!=null&&r.disabled||o.comboboxState===0)return o;if((e=o.dataRef.current)!=null&&e.value){let t=o.dataRef.current.calculateIndex(o.dataRef.current.value);if(t!==-1)return{...o,activeOptionIndex:t,comboboxState:0,__demoMode:!1}}return{...o,comboboxState:0,__demoMode:!1}},[2](o,r){var f,b,i,m,n;if((f=o.dataRef.current)!=null&&f.disabled||(b=o.dataRef.current)!=null&&b.optionsRef.current&&!((i=o.dataRef.current)!=null&&i.optionsPropsRef.current.static)&&o.comboboxState===1)return o;if(o.virtual){let u=r.focus===S.Specific?r.idx:Fe(r,{resolveItems:()=>o.virtual.options,resolveActiveIndex:()=>{var A,_;return(_=(A=o.activeOptionIndex)!=null?A:o.virtual.options.findIndex(s=>!o.virtual.disabled(s)))!=null?_:null},resolveDisabled:o.virtual.disabled,resolveId(){throw new Error("Function not implemented.")}}),c=(m=r.trigger)!=null?m:2;return o.activeOptionIndex===u&&o.activationTrigger===c?o:{...o,activeOptionIndex:u,activationTrigger:c,__demoMode:!1}}let e=xe(o);if(e.activeOptionIndex===null){let u=e.options.findIndex(c=>!c.dataRef.current.disabled);u!==-1&&(e.activeOptionIndex=u)}let t=r.focus===S.Specific?r.idx:Fe(r,{resolveItems:()=>e.options,resolveActiveIndex:()=>e.activeOptionIndex,resolveId:u=>u.id,resolveDisabled:u=>u.dataRef.current.disabled}),p=(n=r.trigger)!=null?n:2;return o.activeOptionIndex===t&&o.activationTrigger===p?o:{...o,...e,activeOptionIndex:t,activationTrigger:p,__demoMode:!1}},[3]:(o,r)=>{var f,b,i;if((f=o.dataRef.current)!=null&&f.virtual)return{...o,options:[...o.options,r.payload]};let e=r.payload,t=xe(o,m=>(m.push(e),m));o.activeOptionIndex===null&&(b=o.dataRef.current)!=null&&b.isSelected(r.payload.dataRef.current.value)&&(t.activeOptionIndex=t.options.indexOf(e));let p={...o,...t,activationTrigger:2};return(i=o.dataRef.current)!=null&&i.__demoMode&&o.dataRef.current.value===void 0&&(p.activeOptionIndex=0),p},[4]:(o,r)=>{var t;if((t=o.dataRef.current)!=null&&t.virtual)return{...o,options:o.options.filter(p=>p.id!==r.id)};let e=xe(o,p=>{let f=p.findIndex(b=>b.id===r.id);return f!==-1&&p.splice(f,1),p});return{...o,...e,activationTrigger:2}},[5]:(o,r)=>o.activationTrigger===r.trigger?o:{...o,activationTrigger:r.trigger},[6]:(o,r)=>{var t;if(((t=o.virtual)==null?void 0:t.options)===r.options)return o;let e=o.activeOptionIndex;if(o.activeOptionIndex!==null){let p=r.options.indexOf(o.virtual.options[o.activeOptionIndex]);p!==-1?e=p:e=null}return{...o,activeOptionIndex:e,virtual:Object.assign({},o.virtual,{options:r.options})}}},Te=be(null);Te.displayName="ComboboxActionsContext";function ee(o){let r=ce(Te);if(r===null){let e=new Error(`<${o} /> is missing a parent <Combobox /> component.`);throw Error.captureStackTrace&&Error.captureStackTrace(e,ee),e}return r}let Ve=be(null);function vo(o){var m;let r=Y("VirtualProvider"),[e,t]=G(()=>{let n=r.optionsRef.current;if(!n)return[0,0];let u=window.getComputedStyle(n);return[parseFloat(u.paddingBlockStart||u.paddingTop),parseFloat(u.paddingBlockEnd||u.paddingBottom)]},[r.optionsRef.current]),p=Le({scrollPaddingStart:e,scrollPaddingEnd:t,count:r.virtual.options.length,estimateSize(){return 40},getScrollElement(){var n;return(n=r.optionsRef.current)!=null?n:null},overscan:12}),[f,b]=Re(0);K(()=>{b(n=>n+1)},[(m=r.virtual)==null?void 0:m.options]);let i=p.getVirtualItems();return i.length===0?null:D.createElement(Ve.Provider,{value:p},D.createElement("div",{style:{position:"relative",width:"100%",height:`${p.getTotalSize()}px`},ref:n=>{if(n){if(typeof process!="undefined"&&process.env.JEST_WORKER_ID!==void 0||r.activationTrigger===0)return;r.activeOptionIndex!==null&&r.virtual.options.length>r.activeOptionIndex&&p.scrollToIndex(r.activeOptionIndex)}}},i.map(n=>{var u;return D.createElement(Ce,{key:n.key},D.cloneElement((u=o.children)==null?void 0:u.call(o,{option:r.virtual.options[n.index],open:r.comboboxState===0}),{key:`${f}-${n.key}`,"data-index":n.index,"aria-setsize":r.virtual.options.length,"aria-posinset":n.index+1,style:{position:"absolute",top:0,left:0,transform:`translateY(${n.start}px)`,overflowAnchor:"none"}}))})))}let ue=be(null);ue.displayName="ComboboxDataContext";function Y(o){let r=ce(ue);if(r===null){let e=new Error(`<${o} /> is missing a parent <Combobox /> component.`);throw Error.captureStackTrace&&Error.captureStackTrace(e,Y),e}return r}function Oo(o,r){return q(r.type,go,o,r)}let Co=Ce;function yo(o,r){var R,h;let e=qe(),{value:t,defaultValue:p,onChange:f,form:b,name:i,by:m,disabled:n=e||!1,onClose:u,__demoMode:c=!1,multiple:A=!1,immediate:_=!1,virtual:s=null,nullable:T,...w}=o,[C=A?[]:void 0,v]=Ue(t,f,p),[y,E]=Be(Oo,{dataRef:we(),comboboxState:c?0:1,options:[],virtual:s?{options:s.options,disabled:(R=s.disabled)!=null?R:()=>!1}:null,activeOptionIndex:null,activationTrigger:2,__demoMode:c}),F=j(!1),N=j({static:!1,hold:!1}),V=j(null),O=j(null),W=j(null),L=Ne(m),P=x(d=>s?m===null?s.options.indexOf(d):s.options.findIndex(g=>L(g,d)):y.options.findIndex(g=>L(g.dataRef.current.value,d))),$=ye(d=>q(a.mode,{[1]:()=>C.some(g=>L(g,d)),[0]:()=>L(C,d)}),[C]),z=x(d=>y.activeOptionIndex===P(d)),a=G(()=>({...y,immediate:_,optionsPropsRef:N,inputRef:V,buttonRef:O,optionsRef:W,value:C,defaultValue:p,disabled:n,mode:A?1:0,virtual:y.virtual,get activeOptionIndex(){if(F.current&&y.activeOptionIndex===null&&(s?s.options.length>0:y.options.length>0)){if(s){let g=s.options.findIndex(U=>{var re,ge;return!((ge=(re=s==null?void 0:s.disabled)==null?void 0:re.call(s,U))!=null&&ge)});if(g!==-1)return g}let d=y.options.findIndex(g=>!g.dataRef.current.disabled);if(d!==-1)return d}return y.activeOptionIndex},calculateIndex:P,compare:L,isSelected:$,isActive:z}),[C,p,n,A,c,y,s]);K(()=>{s&&E({type:6,options:s.options})},[s,s==null?void 0:s.options]),K(()=>{y.dataRef.current=a},[a]),We([a.buttonRef,a.inputRef,a.optionsRef],()=>J.closeCombobox(),a.comboboxState===0);let H=G(()=>{var d,g,U;return{open:a.comboboxState===0,disabled:n,activeIndex:a.activeOptionIndex,activeOption:a.activeOptionIndex===null?null:a.virtual?a.virtual.options[(d=a.activeOptionIndex)!=null?d:0]:(U=(g=a.options[a.activeOptionIndex])==null?void 0:g.dataRef.current.value)!=null?U:null,value:C}},[a,n,C]),pe=x(()=>{if(a.activeOptionIndex!==null){if(a.virtual)X(a.virtual.options[a.activeOptionIndex]);else{let{dataRef:d}=a.options[a.activeOptionIndex];X(d.current.value)}J.goToOption(S.Specific,a.activeOptionIndex)}}),se=x(()=>{E({type:0}),F.current=!0}),de=x(()=>{E({type:1}),F.current=!1,u==null||u()}),oe=x((d,g,U)=>(F.current=!1,d===S.Specific?E({type:2,focus:S.Specific,idx:g,trigger:U}):E({type:2,focus:d,trigger:U}))),te=x((d,g)=>(E({type:3,payload:{id:d,dataRef:g}}),()=>{a.isActive(g.current.value)&&(F.current=!0),E({type:4,id:d})})),X=x(d=>q(a.mode,{[0](){return v==null?void 0:v(d)},[1](){let g=a.value.slice(),U=g.findIndex(re=>L(re,d));return U===-1?g.push(d):g.splice(U,1),v==null?void 0:v(g)}})),ne=x(d=>{E({type:5,trigger:d})}),J=G(()=>({onChange:X,registerOption:te,goToOption:oe,closeCombobox:de,openCombobox:se,setActivationTrigger:ne,selectActiveOption:pe}),[]),[l,B]=bo(),I=r===null?{}:{ref:r},k=ye(()=>v==null?void 0:v(p),[v]);return D.createElement(B,{value:l,props:{htmlFor:(h=a.inputRef.current)==null?void 0:h.id},slot:{open:a.comboboxState===0,disabled:n}},D.createElement(Ye,null,D.createElement(Te.Provider,{value:J},D.createElement(ue.Provider,{value:a},D.createElement(ro,{value:q(a.comboboxState,{[0]:le.Open,[1]:le.Closed})},i!=null&&D.createElement(to,{disabled:n,data:C!=null?{[i]:C}:{},form:b,onReset:k}),Z({ourProps:I,theirProps:w,slot:H,defaultTag:Co,name:"Combobox"}))))))}let Ro="input";function So(o,r){var oe,te,X,ne,J;let e=Y("Combobox.Input"),t=ee("Combobox.Input"),p=ie(),f=no(),{id:b=f||`headlessui-combobox-input-${p}`,onChange:i,displayValue:m,disabled:n=e.disabled||!1,autoFocus:u=!1,type:c="text",...A}=o,_=ae(e.inputRef,r,eo()),s=Ie(e.inputRef),T=j(!1),w=Se(),C=x(()=>{t.onChange(null),e.optionsRef.current&&(e.optionsRef.current.scrollTop=0),t.goToOption(S.Nothing)}),v=G(()=>{var l;return typeof m=="function"&&e.value!==void 0?(l=m(e.value))!=null?l:"":typeof e.value=="string"?e.value:""},[e.value,m]);Ee(([l,B],[I,k])=>{if(T.current)return;let R=e.inputRef.current;R&&((k===0&&B===1||l!==I)&&(R.value=l),requestAnimationFrame(()=>{if(T.current||!R||(s==null?void 0:s.activeElement)!==R)return;let{selectionStart:h,selectionEnd:d}=R;Math.abs((d!=null?d:0)-(h!=null?h:0))===0&&h===0&&R.setSelectionRange(R.value.length,R.value.length)}))},[v,e.comboboxState,s]),Ee(([l],[B])=>{if(l===0&&B===1){if(T.current)return;let I=e.inputRef.current;if(!I)return;let k=I.value,{selectionStart:R,selectionEnd:h,selectionDirection:d}=I;I.value="",I.value=k,d!==null?I.setSelectionRange(R,h,d):I.setSelectionRange(R,h)}},[e.comboboxState]);let y=j(!1),E=x(()=>{y.current=!0}),F=x(()=>{w.nextFrame(()=>{y.current=!1})}),N=He(),V=x(l=>{switch(T.current=!0,N(()=>{T.current=!1}),l.key){case M.Enter:if(T.current=!1,e.comboboxState!==0||y.current)return;if(l.preventDefault(),l.stopPropagation(),e.activeOptionIndex===null){t.closeCombobox();return}t.selectActiveOption(),e.mode===0&&t.closeCombobox();break;case M.ArrowDown:return T.current=!1,l.preventDefault(),l.stopPropagation(),q(e.comboboxState,{[0]:()=>t.goToOption(S.Next),[1]:()=>t.openCombobox()});case M.ArrowUp:return T.current=!1,l.preventDefault(),l.stopPropagation(),q(e.comboboxState,{[0]:()=>t.goToOption(S.Previous),[1]:()=>{t.openCombobox(),w.nextFrame(()=>{e.value||t.goToOption(S.Last)})}});case M.Home:if(l.shiftKey)break;return T.current=!1,l.preventDefault(),l.stopPropagation(),t.goToOption(S.First);case M.PageUp:return T.current=!1,l.preventDefault(),l.stopPropagation(),t.goToOption(S.First);case M.End:if(l.shiftKey)break;return T.current=!1,l.preventDefault(),l.stopPropagation(),t.goToOption(S.Last);case M.PageDown:return T.current=!1,l.preventDefault(),l.stopPropagation(),t.goToOption(S.Last);case M.Escape:return T.current=!1,e.comboboxState!==0?void 0:(l.preventDefault(),e.optionsRef.current&&!e.optionsPropsRef.current.static&&l.stopPropagation(),e.mode===0&&e.value===null&&C(),t.closeCombobox());case M.Tab:if(T.current=!1,e.comboboxState!==0)return;e.mode===0&&e.activationTrigger!==1&&t.selectActiveOption(),t.closeCombobox();break}}),O=x(l=>{i==null||i(l),e.mode===0&&l.target.value===""&&C(),t.openCombobox()}),W=x(l=>{var I,k,R;let B=(I=l.relatedTarget)!=null?I:_e.find(h=>h!==l.currentTarget);if(T.current=!1,!((k=e.optionsRef.current)!=null&&k.contains(B))&&!((R=e.buttonRef.current)!=null&&R.contains(B))&&e.comboboxState===0)return l.preventDefault(),e.mode===0&&e.value===null&&C(),t.closeCombobox()}),L=x(l=>{var I,k,R;let B=(I=l.relatedTarget)!=null?I:_e.find(h=>h!==l.currentTarget);(k=e.buttonRef.current)!=null&&k.contains(B)||(R=e.optionsRef.current)!=null&&R.contains(B)||e.disabled||e.immediate&&e.comboboxState!==0&&(t.openCombobox(),w.nextFrame(()=>{t.setActivationTrigger(1)}))}),P=me(),$=po(),{isFocused:z,focusProps:a}=ve({autoFocus:u}),{isHovered:H,hoverProps:pe}=Oe({isDisabled:n}),se=G(()=>({open:e.comboboxState===0,disabled:n,hover:H,focus:z,autofocus:u}),[e,H,z,u,n]),de=fe({ref:_,id:b,role:"combobox",type:c,"aria-controls":(oe=e.optionsRef.current)==null?void 0:oe.id,"aria-expanded":e.comboboxState===0,"aria-activedescendant":e.activeOptionIndex===null?void 0:e.virtual?(te=e.options.find(l=>!l.dataRef.current.disabled&&e.compare(l.dataRef.current.value,e.virtual.options[e.activeOptionIndex])))==null?void 0:te.id:(X=e.options[e.activeOptionIndex])==null?void 0:X.id,"aria-labelledby":P,"aria-describedby":$,"aria-autocomplete":"list",defaultValue:(J=(ne=o.defaultValue)!=null?ne:e.defaultValue!==void 0?m==null?void 0:m(e.defaultValue):null)!=null?J:e.defaultValue,disabled:n||void 0,autoFocus:u,onCompositionStart:E,onCompositionEnd:F,onKeyDown:V,onChange:O,onFocus:L,onBlur:W},a,pe);return Z({ourProps:de,theirProps:A,slot:se,defaultTag:Ro,name:"Combobox.Input"})}let Po="button";function Io(o,r){var V;let e=Y("Combobox.Button"),t=ee("Combobox.Button"),p=ae(e.buttonRef,r),f=ie(),{id:b=`headlessui-combobox-button-${f}`,disabled:i=e.disabled||!1,autoFocus:m=!1,...n}=o,u=Se(),c=Ae(e.inputRef),A=x(O=>{switch(O.key){case M.Space:case M.Enter:return O.preventDefault(),O.stopPropagation(),e.comboboxState===1&&t.openCombobox(),u.nextFrame(()=>c());case M.ArrowDown:return O.preventDefault(),O.stopPropagation(),e.comboboxState===1&&(t.openCombobox(),u.nextFrame(()=>{e.value||t.goToOption(S.First)})),u.nextFrame(()=>c());case M.ArrowUp:return O.preventDefault(),O.stopPropagation(),e.comboboxState===1&&(t.openCombobox(),u.nextFrame(()=>{e.value||t.goToOption(S.Last)})),u.nextFrame(()=>c());case M.Escape:return e.comboboxState!==0?void 0:(O.preventDefault(),e.optionsRef.current&&!e.optionsPropsRef.current.static&&O.stopPropagation(),t.closeCombobox(),u.nextFrame(()=>c()));default:return}}),_=x(O=>{O.preventDefault(),!ao(O.currentTarget)&&(O.button===De.Left&&(e.comboboxState===0?t.closeCombobox():t.openCombobox()),c())}),s=me([b]),{isFocusVisible:T,focusProps:w}=ve({autoFocus:m}),{isHovered:C,hoverProps:v}=Oe({isDisabled:i}),{pressed:y,pressProps:E}=ke({disabled:i}),F=G(()=>({open:e.comboboxState===0,active:y||e.comboboxState===0,disabled:i,value:e.value,hover:C,focus:T}),[e,C,T,y,i]),N=fe({ref:p,id:b,type:ze(o,e.buttonRef),tabIndex:-1,"aria-haspopup":"listbox","aria-controls":(V=e.optionsRef.current)==null?void 0:V.id,"aria-expanded":e.comboboxState===0,"aria-labelledby":s,disabled:i||void 0,autoFocus:m,onMouseDown:_,onKeyDown:A},w,v,E);return Z({ourProps:N,theirProps:n,slot:F,defaultTag:Po,name:"Combobox.Button"})}let Ao="div",Eo=Me.RenderStrategy|Me.Static;function _o(o,r){var L;let e=ie(),{id:t=`headlessui-combobox-options-${e}`,hold:p=!1,anchor:f,portal:b=!1,modal:i=!0,...m}=o,n=Y("Combobox.Options"),u=ee("Combobox.Options"),c=oo(f);c&&(b=!0);let[A,_]=Qe(c),s=Ze(),T=ae(n.optionsRef,r,c?A:null),w=Ie(n.optionsRef),C=io(),v=(()=>C!==null?(C&le.Open)===le.Open:n.comboboxState===0)();Ke(n.inputRef,u.closeCombobox,v),$e(w,n.__demoMode?!1:i&&n.comboboxState===0),Ge({allowed:x(()=>[n.inputRef.current,n.buttonRef.current,n.optionsRef.current])},n.__demoMode?!1:i&&n.comboboxState===0),K(()=>{var P;n.optionsPropsRef.current.static=(P=o.static)!=null?P:!1},[n.optionsPropsRef,o.static]),K(()=>{n.optionsPropsRef.current.hold=p},[n.optionsPropsRef,p]),Je({container:n.optionsRef.current,enabled:n.comboboxState===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")}});let y=me([(L=n.buttonRef.current)==null?void 0:L.id]),E=G(()=>({open:n.comboboxState===0,option:void 0}),[n]),F=x(()=>{u.setActivationTrigger(0)}),N=fe(c?s():{},{"aria-labelledby":y,role:"listbox","aria-multiselectable":n.mode===1?!0:void 0,id:t,ref:T,style:{..._,"--input-width":Pe(n.inputRef,!0).width,"--button-width":Pe(n.buttonRef,!0).width},onWheel:F});n.virtual&&v&&Object.assign(m,{children:D.createElement(vo,null,m.children)});let[V,O]=Re(n.value);n.value!==V&&n.comboboxState===0&&n.mode!==1&&O(n.value);let W=x(P=>n.compare(V,P));return D.createElement(co,{enabled:b?o.static||v:!1},D.createElement(ue.Provider,{value:n.mode===1?n:{...n,isSelected:W}},Z({ourProps:N,theirProps:m,slot:E,defaultTag:Ao,features:Eo,visible:v,name:"Combobox.Options"})))}let Fo="div";function ho(o,r){var P,$,z;let e=Y("Combobox.Option"),t=ee("Combobox.Option"),p=ie(),{id:f=`headlessui-combobox-option-${p}`,value:b,disabled:i=($=(P=e.virtual)==null?void 0:P.disabled(b))!=null?$:!1,order:m=null,...n}=o,u=Ae(e.inputRef),c=e.virtual?e.activeOptionIndex===e.calculateIndex(b):e.activeOptionIndex===null?!1:((z=e.options[e.activeOptionIndex])==null?void 0:z.id)===f,A=e.isSelected(b),_=j(null),s=je({disabled:i,value:b,domRef:_,order:m}),T=ce(Ve),w=ae(r,_,T?T.measureElement:null),C=x(()=>t.onChange(b));K(()=>t.registerOption(f,s),[s,f]);let v=j(!(e.virtual||e.__demoMode));K(()=>{if(!e.virtual&&!e.__demoMode)return he().requestAnimationFrame(()=>{v.current=!0})},[e.virtual,e.__demoMode]),K(()=>{if(v.current&&e.comboboxState===0&&c&&e.activationTrigger!==0)return he().requestAnimationFrame(()=>{var a,H;(H=(a=_.current)==null?void 0:a.scrollIntoView)==null||H.call(a,{block:"nearest"})})},[_,c,e.comboboxState,e.activationTrigger,e.activeOptionIndex]);let y=x(a=>{a.preventDefault(),a.button===De.Left&&(i||(C(),uo()||requestAnimationFrame(()=>u()),e.mode===0&&t.closeCombobox()))}),E=x(()=>{if(i)return t.goToOption(S.Nothing);let a=e.calculateIndex(b);t.goToOption(S.Specific,a)}),F=Xe(),N=x(a=>F.update(a)),V=x(a=>{if(!F.wasMoved(a)||i||c)return;let H=e.calculateIndex(b);t.goToOption(S.Specific,H,0)}),O=x(a=>{F.wasMoved(a)&&(i||c&&(e.optionsPropsRef.current.hold||t.goToOption(S.Nothing)))}),W=G(()=>({active:c,focus:c,selected:A,disabled:i}),[c,A,i]);return Z({ourProps:{id:f,ref:w,role:"option",tabIndex:i===!0?void 0:-1,"aria-disabled":i===!0?!0:void 0,"aria-selected":A,disabled:void 0,onMouseDown:y,onFocus:E,onPointerEnter:N,onMouseEnter:N,onPointerMove:V,onMouseMove:V,onPointerLeave:O,onMouseLeave:O},theirProps:n,slot:W,defaultTag:Fo,name:"Combobox.Option"})}let Mo=Q(yo),Do=Q(Io),Vo=Q(So),Lo=so,wo=Q(_o),Bo=Q(ho),Et=Object.assign(Mo,{Input:Vo,Button:Do,Label:Lo,Options:wo,Option:Bo});export{Et as Combobox,Do as ComboboxButton,Vo as ComboboxInput,Lo as ComboboxLabel,Bo as ComboboxOption,wo as ComboboxOptions};
"use client";import{useFocusRing as Ce}from"@react-aria/focus";import{useHover as ye}from"@react-aria/interactions";import{useVirtualizer as Be}from"@tanstack/react-virtual";import B,{Fragment as Re,createContext as ce,createRef as ke,useCallback as Se,useContext as fe,useMemo as K,useReducer as Ne,useRef as W,useState as Pe}from"react";import{useActivePress as Ue}from'../../hooks/use-active-press.js';import{useByComparator as He}from'../../hooks/use-by-comparator.js';import{useControllable as Ge}from'../../hooks/use-controllable.js';import{useDefaultValue as je}from'../../hooks/use-default-value.js';import{useDisposables as Ae}from'../../hooks/use-disposables.js';import{useElementSize as Ie}from'../../hooks/use-element-size.js';import{useEvent as x}from'../../hooks/use-event.js';import{useFrameDebounce as Ke}from'../../hooks/use-frame-debounce.js';import{useId as le}from'../../hooks/use-id.js';import{useInertOthers as We}from'../../hooks/use-inert-others.js';import{useIsoMorphicEffect as $}from'../../hooks/use-iso-morphic-effect.js';import{useLatestValue as ze}from'../../hooks/use-latest-value.js';import{useOnDisappear as $e}from'../../hooks/use-on-disappear.js';import{useOutsideClick as Xe}from'../../hooks/use-outside-click.js';import{useOwnerDocument as Ee}from'../../hooks/use-owner.js';import{useRefocusableInput as _e}from'../../hooks/use-refocusable-input.js';import{useResolveButtonType as Je}from'../../hooks/use-resolve-button-type.js';import{useScrollLock as qe}from'../../hooks/use-scroll-lock.js';import{useSyncRefs as ue}from'../../hooks/use-sync-refs.js';import{useTrackedPointer as Ye}from'../../hooks/use-tracked-pointer.js';import{useTreeWalker as Qe}from'../../hooks/use-tree-walker.js';import{useWatch as Fe}from'../../hooks/use-watch.js';import{useDisabled as Ze}from'../../internal/disabled.js';import{FloatingProvider as eo,useFloatingPanel as oo,useFloatingPanelProps as to,useFloatingReference as no,useResolvedAnchor as ro}from'../../internal/floating.js';import{FormFields as io}from'../../internal/form-fields.js';import{useProvidedId as ao}from'../../internal/id.js';import{OpenClosedProvider as lo,State as pe,useOpenClosed as uo}from'../../internal/open-closed.js';import{history as he}from'../../utils/active-element-history.js';import{isDisabledReactIssue7711 as po}from'../../utils/bugs.js';import{Focus as R,calculateActiveIndex as De}from'../../utils/calculate-active-index.js';import{disposables as Me}from'../../utils/disposables.js';import{sortByDomNode as so}from'../../utils/focus-management.js';import{match as Y}from'../../utils/match.js';import{isMobile as bo}from'../../utils/platform.js';import{RenderFeatures as Ve,forwardRefWithAs as Z,mergeProps as me,render as ee}from'../../utils/render.js';import{useDescribedBy as co}from'../description/description.js';import{Keys as M}from'../keyboard.js';import{Label as fo,useLabelledBy as xe,useLabels as mo}from'../label/label.js';import{MouseButton as Le}from'../mouse.js';import{Portal as xo}from'../portal/portal.js';var To=(e=>(e[e.Open=0]="Open",e[e.Closed=1]="Closed",e))(To||{}),go=(e=>(e[e.Single=0]="Single",e[e.Multi=1]="Multi",e))(go||{}),vo=(t=>(t[t.Pointer=0]="Pointer",t[t.Focus=1]="Focus",t[t.Other=2]="Other",t))(vo||{}),Oo=(i=>(i[i.OpenCombobox=0]="OpenCombobox",i[i.CloseCombobox=1]="CloseCombobox",i[i.GoToOption=2]="GoToOption",i[i.RegisterOption=3]="RegisterOption",i[i.UnregisterOption=4]="UnregisterOption",i[i.SetActivationTrigger=5]="SetActivationTrigger",i[i.UpdateVirtualConfiguration=6]="UpdateVirtualConfiguration",i))(Oo||{});function Te(o,r=e=>e){let e=o.activeOptionIndex!==null?o.options[o.activeOptionIndex]:null,t=r(o.options.slice()),c=t.length>0&&t[0].dataRef.current.order!==null?t.sort((d,i)=>d.dataRef.current.order-i.dataRef.current.order):so(t,d=>d.dataRef.current.domRef.current),s=e?c.indexOf(e):null;return s===-1&&(s=null),{options:c,activeOptionIndex:s}}let Co={[1](o){var r;return(r=o.dataRef.current)!=null&&r.disabled||o.comboboxState===1?o:{...o,activeOptionIndex:null,comboboxState:1,activationTrigger:2,__demoMode:!1}},[0](o){var r,e;if((r=o.dataRef.current)!=null&&r.disabled||o.comboboxState===0)return o;if((e=o.dataRef.current)!=null&&e.value){let t=o.dataRef.current.calculateIndex(o.dataRef.current.value);if(t!==-1)return{...o,activeOptionIndex:t,comboboxState:0,__demoMode:!1}}return{...o,comboboxState:0,__demoMode:!1}},[2](o,r){var s,d,i,m,n;if((s=o.dataRef.current)!=null&&s.disabled||(d=o.dataRef.current)!=null&&d.optionsRef.current&&!((i=o.dataRef.current)!=null&&i.optionsPropsRef.current.static)&&o.comboboxState===1)return o;if(o.virtual){let{options:p,disabled:f}=o.virtual,_=r.focus===R.Specific?r.idx:De(r,{resolveItems:()=>p,resolveActiveIndex:()=>{var u,T;return(T=(u=o.activeOptionIndex)!=null?u:p.findIndex(V=>!f(V)))!=null?T:null},resolveDisabled:f,resolveId(){throw new Error("Function not implemented.")}}),F=(m=r.trigger)!=null?m:2;return o.activeOptionIndex===_&&o.activationTrigger===F?o:{...o,activeOptionIndex:_,activationTrigger:F,__demoMode:!1}}let e=Te(o);if(e.activeOptionIndex===null){let p=e.options.findIndex(f=>!f.dataRef.current.disabled);p!==-1&&(e.activeOptionIndex=p)}let t=r.focus===R.Specific?r.idx:De(r,{resolveItems:()=>e.options,resolveActiveIndex:()=>e.activeOptionIndex,resolveId:p=>p.id,resolveDisabled:p=>p.dataRef.current.disabled}),c=(n=r.trigger)!=null?n:2;return o.activeOptionIndex===t&&o.activationTrigger===c?o:{...o,...e,activeOptionIndex:t,activationTrigger:c,__demoMode:!1}},[3]:(o,r)=>{var s,d,i;if((s=o.dataRef.current)!=null&&s.virtual)return{...o,options:[...o.options,r.payload]};let e=r.payload,t=Te(o,m=>(m.push(e),m));o.activeOptionIndex===null&&(d=o.dataRef.current)!=null&&d.isSelected(r.payload.dataRef.current.value)&&(t.activeOptionIndex=t.options.indexOf(e));let c={...o,...t,activationTrigger:2};return(i=o.dataRef.current)!=null&&i.__demoMode&&o.dataRef.current.value===void 0&&(c.activeOptionIndex=0),c},[4]:(o,r)=>{var t;if((t=o.dataRef.current)!=null&&t.virtual)return{...o,options:o.options.filter(c=>c.id!==r.id)};let e=Te(o,c=>{let s=c.findIndex(d=>d.id===r.id);return s!==-1&&c.splice(s,1),c});return{...o,...e,activationTrigger:2}},[5]:(o,r)=>o.activationTrigger===r.trigger?o:{...o,activationTrigger:r.trigger},[6]:(o,r)=>{var t,c;if(o.virtual===null)return{...o,virtual:{options:r.options,disabled:(t=r.disabled)!=null?t:()=>!1}};if(o.virtual.options===r.options&&o.virtual.disabled===r.disabled)return o;let e=o.activeOptionIndex;if(o.activeOptionIndex!==null){let s=r.options.indexOf(o.virtual.options[o.activeOptionIndex]);s!==-1?e=s:e=null}return{...o,activeOptionIndex:e,virtual:{options:r.options,disabled:(c=r.disabled)!=null?c:()=>!1}}}},ge=ce(null);ge.displayName="ComboboxActionsContext";function oe(o){let r=fe(ge);if(r===null){let e=new Error(`<${o} /> is missing a parent <Combobox /> component.`);throw Error.captureStackTrace&&Error.captureStackTrace(e,oe),e}return r}let we=ce(null);function yo(o){let r=Q("VirtualProvider"),{options:e}=r.virtual,[t,c]=K(()=>{let n=r.optionsRef.current;if(!n)return[0,0];let p=window.getComputedStyle(n);return[parseFloat(p.paddingBlockStart||p.paddingTop),parseFloat(p.paddingBlockEnd||p.paddingBottom)]},[r.optionsRef.current]),s=Be({scrollPaddingStart:t,scrollPaddingEnd:c,count:e.length,estimateSize(){return 40},getScrollElement(){var n;return(n=r.optionsRef.current)!=null?n:null},overscan:12}),[d,i]=Pe(0);$(()=>{i(n=>n+1)},[e]);let m=s.getVirtualItems();return m.length===0?null:B.createElement(we.Provider,{value:s},B.createElement("div",{style:{position:"relative",width:"100%",height:`${s.getTotalSize()}px`},ref:n=>{if(n){if(typeof process!="undefined"&&process.env.JEST_WORKER_ID!==void 0||r.activationTrigger===0)return;r.activeOptionIndex!==null&&e.length>r.activeOptionIndex&&s.scrollToIndex(r.activeOptionIndex)}}},m.map(n=>{var p;return B.createElement(Re,{key:n.key},B.cloneElement((p=o.children)==null?void 0:p.call(o,{option:e[n.index],open:r.comboboxState===0}),{key:`${d}-${n.key}`,"data-index":n.index,"aria-setsize":e.length,"aria-posinset":n.index+1,style:{position:"absolute",top:0,left:0,transform:`translateY(${n.start}px)`,overflowAnchor:"none"}}))})))}let se=ce(null);se.displayName="ComboboxDataContext";function Q(o){let r=fe(se);if(r===null){let e=new Error(`<${o} /> is missing a parent <Combobox /> component.`);throw Error.captureStackTrace&&Error.captureStackTrace(e,Q),e}return r}function Ro(o,r){return Y(r.type,Co,o,r)}let So=Re;function Po(o,r){var j,ve;let e=Ze(),{value:t,defaultValue:c,onChange:s,form:d,name:i,by:m,disabled:n=e||!1,onClose:p,__demoMode:f=!1,multiple:_=!1,immediate:F=!1,virtual:u=null,nullable:T,...V}=o,S=je(c),[O=_?[]:void 0,C]=Ge(t,s,S),[P,A]=Ne(Ro,{dataRef:ke(),comboboxState:f?0:1,options:[],virtual:u?{options:u.options,disabled:(j=u.disabled)!=null?j:()=>!1}:null,activeOptionIndex:null,activationTrigger:2,__demoMode:f}),D=W(!1),k=W({static:!1,hold:!1}),v=W(null),X=W(null),J=W(null),h=He(m),G=x(b=>u?m===null?u.options.indexOf(b):u.options.findIndex(g=>h(g,b)):P.options.findIndex(g=>h(g.dataRef.current.value,b))),U=Se(b=>Y(a.mode,{[1]:()=>O.some(g=>h(g,b)),[0]:()=>h(O,b)}),[O]),I=x(b=>P.activeOptionIndex===G(b)),a=K(()=>({...P,immediate:F,optionsPropsRef:k,inputRef:v,buttonRef:X,optionsRef:J,value:O,defaultValue:S,disabled:n,mode:_?1:0,virtual:u?P.virtual:null,get activeOptionIndex(){if(D.current&&P.activeOptionIndex===null&&(u?u.options.length>0:P.options.length>0)){if(u){let g=u.options.findIndex(H=>{var ae,Oe;return!((Oe=(ae=u.disabled)==null?void 0:ae.call(u,H))!=null&&Oe)});if(g!==-1)return g}let b=P.options.findIndex(g=>!g.dataRef.current.disabled);if(b!==-1)return b}return P.activeOptionIndex},calculateIndex:G,compare:h,isSelected:U,isActive:I}),[O,S,n,_,f,P,u]);$(()=>{var b;u&&A({type:6,options:u.options,disabled:(b=u.disabled)!=null?b:null})},[u,u==null?void 0:u.options,u==null?void 0:u.disabled]),$(()=>{P.dataRef.current=a},[a]);let z=a.comboboxState===0;Xe(z,[a.buttonRef,a.inputRef,a.optionsRef],()=>L.closeCombobox());let de=K(()=>{var b,g,H;return{open:a.comboboxState===0,disabled:n,activeIndex:a.activeOptionIndex,activeOption:a.activeOptionIndex===null?null:a.virtual?a.virtual.options[(b=a.activeOptionIndex)!=null?b:0]:(H=(g=a.options[a.activeOptionIndex])==null?void 0:g.dataRef.current.value)!=null?H:null,value:O}},[a,n,O]),be=x(()=>{if(a.activeOptionIndex!==null){if(a.virtual)q(a.virtual.options[a.activeOptionIndex]);else{let{dataRef:b}=a.options[a.activeOptionIndex];q(b.current.value)}L.goToOption(R.Specific,a.activeOptionIndex)}}),te=x(()=>{A({type:0}),D.current=!0}),ne=x(()=>{A({type:1}),D.current=!1,p==null||p()}),re=x((b,g,H)=>(D.current=!1,b===R.Specific?A({type:2,focus:R.Specific,idx:g,trigger:H}):A({type:2,focus:b,trigger:H}))),ie=x((b,g)=>(A({type:3,payload:{id:b,dataRef:g}}),()=>{a.isActive(g.current.value)&&(D.current=!0),A({type:4,id:b})})),q=x(b=>Y(a.mode,{[0](){return C==null?void 0:C(b)},[1](){let g=a.value.slice(),H=g.findIndex(ae=>h(ae,b));return H===-1?g.push(b):g.splice(H,1),C==null?void 0:C(g)}})),l=x(b=>{A({type:5,trigger:b})}),L=K(()=>({onChange:q,registerOption:ie,goToOption:re,closeCombobox:ne,openCombobox:te,setActivationTrigger:l,selectActiveOption:be}),[]),[E,N]=mo(),y=r===null?{}:{ref:r},w=Se(()=>{if(S!==void 0)return C==null?void 0:C(S)},[C,S]);return B.createElement(N,{value:E,props:{htmlFor:(ve=a.inputRef.current)==null?void 0:ve.id},slot:{open:a.comboboxState===0,disabled:n}},B.createElement(eo,null,B.createElement(ge.Provider,{value:L},B.createElement(se.Provider,{value:a},B.createElement(lo,{value:Y(a.comboboxState,{[0]:pe.Open,[1]:pe.Closed})},i!=null&&B.createElement(io,{disabled:n,data:O!=null?{[i]:O}:{},form:d,onReset:w}),ee({ourProps:y,theirProps:V,slot:de,defaultTag:So,name:"Combobox"}))))))}let Ao="input";function Io(o,r){var te,ne,re,ie,q;let e=Q("Combobox.Input"),t=oe("Combobox.Input"),c=le(),s=ao(),{id:d=s||`headlessui-combobox-input-${c}`,onChange:i,displayValue:m,disabled:n=e.disabled||!1,autoFocus:p=!1,type:f="text",..._}=o,F=ue(e.inputRef,r,no()),u=Ee(e.inputRef),T=W(!1),V=Ae(),S=x(()=>{t.onChange(null),e.optionsRef.current&&(e.optionsRef.current.scrollTop=0),t.goToOption(R.Nothing)}),O=K(()=>{var l;return typeof m=="function"&&e.value!==void 0?(l=m(e.value))!=null?l:"":typeof e.value=="string"?e.value:""},[e.value,m]);Fe(([l,L],[E,N])=>{if(T.current)return;let y=e.inputRef.current;y&&((N===0&&L===1||l!==E)&&(y.value=l),requestAnimationFrame(()=>{if(T.current||!y||(u==null?void 0:u.activeElement)!==y)return;let{selectionStart:w,selectionEnd:j}=y;Math.abs((j!=null?j:0)-(w!=null?w:0))===0&&w===0&&y.setSelectionRange(y.value.length,y.value.length)}))},[O,e.comboboxState,u]),Fe(([l],[L])=>{if(l===0&&L===1){if(T.current)return;let E=e.inputRef.current;if(!E)return;let N=E.value,{selectionStart:y,selectionEnd:w,selectionDirection:j}=E;E.value="",E.value=N,j!==null?E.setSelectionRange(y,w,j):E.setSelectionRange(y,w)}},[e.comboboxState]);let C=W(!1),P=x(()=>{C.current=!0}),A=x(()=>{V.nextFrame(()=>{C.current=!1})}),D=Ke(),k=x(l=>{switch(T.current=!0,D(()=>{T.current=!1}),l.key){case M.Enter:if(T.current=!1,e.comboboxState!==0||C.current)return;if(l.preventDefault(),l.stopPropagation(),e.activeOptionIndex===null){t.closeCombobox();return}t.selectActiveOption(),e.mode===0&&t.closeCombobox();break;case M.ArrowDown:return T.current=!1,l.preventDefault(),l.stopPropagation(),Y(e.comboboxState,{[0]:()=>t.goToOption(R.Next),[1]:()=>t.openCombobox()});case M.ArrowUp:return T.current=!1,l.preventDefault(),l.stopPropagation(),Y(e.comboboxState,{[0]:()=>t.goToOption(R.Previous),[1]:()=>{t.openCombobox(),V.nextFrame(()=>{e.value||t.goToOption(R.Last)})}});case M.Home:if(l.shiftKey)break;return T.current=!1,l.preventDefault(),l.stopPropagation(),t.goToOption(R.First);case M.PageUp:return T.current=!1,l.preventDefault(),l.stopPropagation(),t.goToOption(R.First);case M.End:if(l.shiftKey)break;return T.current=!1,l.preventDefault(),l.stopPropagation(),t.goToOption(R.Last);case M.PageDown:return T.current=!1,l.preventDefault(),l.stopPropagation(),t.goToOption(R.Last);case M.Escape:return T.current=!1,e.comboboxState!==0?void 0:(l.preventDefault(),e.optionsRef.current&&!e.optionsPropsRef.current.static&&l.stopPropagation(),e.mode===0&&e.value===null&&S(),t.closeCombobox());case M.Tab:if(T.current=!1,e.comboboxState!==0)return;e.mode===0&&e.activationTrigger!==1&&t.selectActiveOption(),t.closeCombobox();break}}),v=x(l=>{i==null||i(l),e.mode===0&&l.target.value===""&&S(),t.openCombobox()}),X=x(l=>{var E,N,y;let L=(E=l.relatedTarget)!=null?E:he.find(w=>w!==l.currentTarget);if(T.current=!1,!((N=e.optionsRef.current)!=null&&N.contains(L))&&!((y=e.buttonRef.current)!=null&&y.contains(L))&&e.comboboxState===0)return l.preventDefault(),e.mode===0&&e.value===null&&S(),t.closeCombobox()}),J=x(l=>{var E,N,y;let L=(E=l.relatedTarget)!=null?E:he.find(w=>w!==l.currentTarget);(N=e.buttonRef.current)!=null&&N.contains(L)||(y=e.optionsRef.current)!=null&&y.contains(L)||e.disabled||e.immediate&&e.comboboxState!==0&&(t.openCombobox(),V.nextFrame(()=>{t.setActivationTrigger(1)}))}),h=xe(),G=co(),{isFocused:U,focusProps:I}=Ce({autoFocus:p}),{isHovered:a,hoverProps:z}=ye({isDisabled:n}),de=K(()=>({open:e.comboboxState===0,disabled:n,hover:a,focus:U,autofocus:p}),[e,a,U,p,n]),be=me({ref:F,id:d,role:"combobox",type:f,"aria-controls":(te=e.optionsRef.current)==null?void 0:te.id,"aria-expanded":e.comboboxState===0,"aria-activedescendant":e.activeOptionIndex===null?void 0:e.virtual?(ne=e.options.find(l=>!l.dataRef.current.disabled&&e.compare(l.dataRef.current.value,e.virtual.options[e.activeOptionIndex])))==null?void 0:ne.id:(re=e.options[e.activeOptionIndex])==null?void 0:re.id,"aria-labelledby":h,"aria-describedby":G,"aria-autocomplete":"list",defaultValue:(q=(ie=o.defaultValue)!=null?ie:e.defaultValue!==void 0?m==null?void 0:m(e.defaultValue):null)!=null?q:e.defaultValue,disabled:n||void 0,autoFocus:p,onCompositionStart:P,onCompositionEnd:A,onKeyDown:k,onChange:v,onFocus:J,onBlur:X},I,z);return ee({ourProps:be,theirProps:_,slot:de,defaultTag:Ao,name:"Combobox.Input"})}let Eo="button";function _o(o,r){var k;let e=Q("Combobox.Button"),t=oe("Combobox.Button"),c=ue(e.buttonRef,r),s=le(),{id:d=`headlessui-combobox-button-${s}`,disabled:i=e.disabled||!1,autoFocus:m=!1,...n}=o,p=Ae(),f=_e(e.inputRef),_=x(v=>{switch(v.key){case M.Space:case M.Enter:return v.preventDefault(),v.stopPropagation(),e.comboboxState===1&&t.openCombobox(),p.nextFrame(()=>f());case M.ArrowDown:return v.preventDefault(),v.stopPropagation(),e.comboboxState===1&&(t.openCombobox(),p.nextFrame(()=>{e.value||t.goToOption(R.First)})),p.nextFrame(()=>f());case M.ArrowUp:return v.preventDefault(),v.stopPropagation(),e.comboboxState===1&&(t.openCombobox(),p.nextFrame(()=>{e.value||t.goToOption(R.Last)})),p.nextFrame(()=>f());case M.Escape:return e.comboboxState!==0?void 0:(v.preventDefault(),e.optionsRef.current&&!e.optionsPropsRef.current.static&&v.stopPropagation(),t.closeCombobox(),p.nextFrame(()=>f()));default:return}}),F=x(v=>{v.preventDefault(),!po(v.currentTarget)&&(v.button===Le.Left&&(e.comboboxState===0?t.closeCombobox():t.openCombobox()),f())}),u=xe([d]),{isFocusVisible:T,focusProps:V}=Ce({autoFocus:m}),{isHovered:S,hoverProps:O}=ye({isDisabled:i}),{pressed:C,pressProps:P}=Ue({disabled:i}),A=K(()=>({open:e.comboboxState===0,active:C||e.comboboxState===0,disabled:i,value:e.value,hover:S,focus:T}),[e,S,T,C,i]),D=me({ref:c,id:d,type:Je(o,e.buttonRef),tabIndex:-1,"aria-haspopup":"listbox","aria-controls":(k=e.optionsRef.current)==null?void 0:k.id,"aria-expanded":e.comboboxState===0,"aria-labelledby":u,disabled:i||void 0,autoFocus:m,onMouseDown:F,onKeyDown:_},V,O,P);return ee({ourProps:D,theirProps:n,slot:A,defaultTag:Eo,name:"Combobox.Button"})}let Fo="div",ho=Ve.RenderStrategy|Ve.Static;function Do(o,r){var U;let e=le(),{id:t=`headlessui-combobox-options-${e}`,hold:c=!1,anchor:s,portal:d=!1,modal:i=!0,...m}=o,n=Q("Combobox.Options"),p=oe("Combobox.Options"),f=ro(s);f&&(d=!0);let[_,F]=oo(f),u=to(),T=ue(n.optionsRef,r,f?_:null),V=Ee(n.optionsRef),S=uo(),O=(()=>S!==null?(S&pe.Open)===pe.Open:n.comboboxState===0)();$e(O,n.inputRef,p.closeCombobox);let C=n.__demoMode?!1:i&&n.comboboxState===0;qe(C,V);let P=n.__demoMode?!1:i&&n.comboboxState===0;We(P,{allowed:x(()=>[n.inputRef.current,n.buttonRef.current,n.optionsRef.current])}),$(()=>{var I;n.optionsPropsRef.current.static=(I=o.static)!=null?I:!1},[n.optionsPropsRef,o.static]),$(()=>{n.optionsPropsRef.current.hold=c},[n.optionsPropsRef,c]),Qe(n.comboboxState===0,{container:n.optionsRef.current,accept(I){return I.getAttribute("role")==="option"?NodeFilter.FILTER_REJECT:I.hasAttribute("role")?NodeFilter.FILTER_SKIP:NodeFilter.FILTER_ACCEPT},walk(I){I.setAttribute("role","none")}});let A=xe([(U=n.buttonRef.current)==null?void 0:U.id]),D=K(()=>({open:n.comboboxState===0,option:void 0}),[n]),k=x(()=>{p.setActivationTrigger(0)}),v=x(I=>{I.preventDefault(),p.setActivationTrigger(0)}),X=me(f?u():{},{"aria-labelledby":A,role:"listbox","aria-multiselectable":n.mode===1?!0:void 0,id:t,ref:T,style:{...m.style,...F,"--input-width":Ie(n.inputRef,!0).width,"--button-width":Ie(n.buttonRef,!0).width},onWheel:n.activationTrigger===0?void 0:k,onMouseDown:v});n.virtual&&O&&Object.assign(m,{children:B.createElement(yo,null,m.children)});let[J,h]=Pe(n.value);n.value!==J&&n.comboboxState===0&&n.mode!==1&&h(n.value);let G=x(I=>n.compare(J,I));return B.createElement(xo,{enabled:d?o.static||O:!1},B.createElement(se.Provider,{value:n.mode===1?n:{...n,isSelected:G}},ee({ourProps:X,theirProps:m,slot:D,defaultTag:Fo,features:ho,visible:O,name:"Combobox.Options"})))}let Mo="div";function Vo(o,r){var h,G,U,I;let e=Q("Combobox.Option"),t=oe("Combobox.Option"),c=le(),{id:s=`headlessui-combobox-option-${c}`,value:d,disabled:i=(U=(G=(h=e.virtual)==null?void 0:h.disabled)==null?void 0:G.call(h,d))!=null?U:!1,order:m=null,...n}=o,p=_e(e.inputRef),f=e.virtual?e.activeOptionIndex===e.calculateIndex(d):e.activeOptionIndex===null?!1:((I=e.options[e.activeOptionIndex])==null?void 0:I.id)===s,_=e.isSelected(d),F=W(null),u=ze({disabled:i,value:d,domRef:F,order:m}),T=fe(we),V=ue(r,F,T?T.measureElement:null),S=x(()=>t.onChange(d));$(()=>t.registerOption(s,u),[u,s]);let O=W(!(e.virtual||e.__demoMode));$(()=>{if(!e.virtual&&!e.__demoMode)return Me().requestAnimationFrame(()=>{O.current=!0})},[e.virtual,e.__demoMode]),$(()=>{if(O.current&&e.comboboxState===0&&f&&e.activationTrigger!==0)return Me().requestAnimationFrame(()=>{var a,z;(z=(a=F.current)==null?void 0:a.scrollIntoView)==null||z.call(a,{block:"nearest"})})},[F,f,e.comboboxState,e.activationTrigger,e.activeOptionIndex]);let C=x(a=>{a.preventDefault(),a.button===Le.Left&&(i||(S(),bo()||requestAnimationFrame(()=>p()),e.mode===0&&t.closeCombobox()))}),P=x(()=>{if(i)return t.goToOption(R.Nothing);let a=e.calculateIndex(d);t.goToOption(R.Specific,a)}),A=Ye(),D=x(a=>A.update(a)),k=x(a=>{if(!A.wasMoved(a)||i||f)return;let z=e.calculateIndex(d);t.goToOption(R.Specific,z,0)}),v=x(a=>{A.wasMoved(a)&&(i||f&&(e.optionsPropsRef.current.hold||t.goToOption(R.Nothing)))}),X=K(()=>({active:f,focus:f,selected:_,disabled:i}),[f,_,i]);return ee({ourProps:{id:s,ref:V,role:"option",tabIndex:i===!0?void 0:-1,"aria-disabled":i===!0?!0:void 0,"aria-selected":_,disabled:void 0,onMouseDown:C,onFocus:P,onPointerEnter:D,onMouseEnter:D,onPointerMove:k,onMouseMove:k,onPointerLeave:v,onMouseLeave:v},theirProps:n,slot:X,defaultTag:Mo,name:"Combobox.Option"})}let Lo=Z(Po),wo=Z(_o),Bo=Z(Io),ko=fo,No=Z(Do),Uo=Z(Vo),Dt=Object.assign(Lo,{Input:Bo,Button:wo,Label:ko,Options:No,Option:Uo});export{Dt as Combobox,wo as ComboboxButton,Bo as ComboboxInput,ko as ComboboxLabel,Uo as ComboboxOption,No as ComboboxOptions};

@@ -1,1 +0,1 @@

"use client";import l,{createContext as me,createRef as De,useContext as Y,useEffect as ce,useMemo as _,useReducer as Pe,useRef as J,useState as ye}from"react";import{useEvent as D}from'../../hooks/use-event.js';import{useEventListener as Ee}from'../../hooks/use-event-listener.js';import{useId as L}from'../../hooks/use-id.js';import{useInertOthers as Ce}from'../../hooks/use-inert-others.js';import{useIsTouchDevice as Ae}from'../../hooks/use-is-touch-device.js';import{useOnDisappear as _e}from'../../hooks/use-on-disappear.js';import{useOutsideClick as Fe}from'../../hooks/use-outside-click.js';import{useOwnerDocument as Re}from'../../hooks/use-owner.js';import{useRootContainers as be}from'../../hooks/use-root-containers.js';import{useScrollLock as Se}from'../../hooks/use-scroll-lock.js';import{useServerHandoffComplete as ve}from'../../hooks/use-server-handoff-complete.js';import{useSyncRefs as h}from'../../hooks/use-sync-refs.js';import{CloseProvider as xe}from'../../internal/close-provider.js';import{HoistFormFields as Le}from'../../internal/form-fields.js';import{State as F,useOpenClosed as he}from'../../internal/open-closed.js';import{ForcePortalRoot as X}from'../../internal/portal-force-root.js';import{StackMessage as B,StackProvider as Oe}from'../../internal/stack-context.js';import{match as O}from'../../utils/match.js';import{RenderFeatures as K,forwardRefWithAs as I,render as w}from'../../utils/render.js';import{Description as V,useDescriptions as Ie}from'../description/description.js';import{FocusTrap as we,FocusTrapFeatures as T}from'../focus-trap/focus-trap.js';import{Keys as Me}from'../keyboard.js';import{Portal as q,useNestedPortals as Ge}from'../portal/portal.js';var He=(r=>(r[r.Open=0]="Open",r[r.Closed=1]="Closed",r))(He||{}),Ne=(t=>(t[t.SetTitleId=0]="SetTitleId",t))(Ne||{});let ke={[0](o,t){return o.titleId===t.id?o:{...o,titleId:t.id}}},R=me(null);R.displayName="DialogContext";function M(o){let t=Y(R);if(t===null){let r=new Error(`<${o} /> is missing a parent <Dialog /> component.`);throw Error.captureStackTrace&&Error.captureStackTrace(r,M),r}return t}function Ue(o,t){return O(t.type,ke,o,t)}let $e="div",je=K.RenderStrategy|K.Static;function We(o,t){let r=L(),{id:u=`headlessui-dialog-${r}`,open:i,onClose:s,initialFocus:d,role:a="dialog",autoFocus:c=!0,__demoMode:f=!1,...G}=o,[b,H]=ye(0),N=J(!1);a=function(){return a==="dialog"||a==="alertdialog"?a:(N.current||(N.current=!0,console.warn(`Invalid role [${a}] passed to <Dialog />. Only \`dialog\` and and \`alertdialog\` are supported. Using \`dialog\` instead.`)),"dialog")}();let P=he();i===void 0&&P!==null&&(i=(P&F.Open)===F.Open);let p=J(null),z=h(p,t),y=Re(p),k=o.hasOwnProperty("open")||P!==null,U=o.hasOwnProperty("onClose");if(!k&&!U)throw new Error("You have to provide an `open` and an `onClose` prop to the `Dialog` component.");if(!k)throw new Error("You provided an `onClose` prop to the `Dialog`, but forgot an `open` prop.");if(!U)throw new Error("You provided an `open` prop to the `Dialog`, but forgot an `onClose` prop.");if(typeof i!="boolean")throw new Error(`You provided an \`open\` prop to the \`Dialog\`, but the value is not a boolean. Received: ${i}`);if(typeof s!="function")throw new Error(`You provided an \`onClose\` prop to the \`Dialog\`, but the value is not a function. Received: ${s}`);let n=i?0:1,[E,Q]=Pe(Ue,{titleId:null,descriptionId:null,panelRef:De()}),m=D(()=>s(!1)),$=D(e=>Q({type:0,id:e})),S=ve()?n===0:!1,C=b>1,Z=Y(R)!==null,[ee,te]=Ge(),oe={get current(){var e;return(e=E.panelRef.current)!=null?e:p.current}},{resolveContainers:v,mainTreeNodeRef:re,MainTreeNode:le}=be({portals:ee,defaultContainers:[oe]}),ne=C?"parent":"leaf",j=P!==null?(P&F.Closing)===F.Closing:!1,ae=(()=>C||j?!1:S)();Ce({allowed:D(()=>{var e,g;return[(g=(e=p.current)==null?void 0:e.closest("[data-headlessui-portal]"))!=null?g:null]}),disallowed:D(()=>{var e,g;return[(g=(e=re.current)==null?void 0:e.closest("body > *:not(#headlessui-portal-root)"))!=null?g:null]})},f?!1:ae);let ie=(()=>!(!S||C))();Fe(v,e=>{e.preventDefault(),m()},ie);let se=(()=>!(C||n!==0))();Ee(y==null?void 0:y.defaultView,"keydown",e=>{se&&(e.defaultPrevented||e.key===Me.Escape&&(e.preventDefault(),e.stopPropagation(),m()))});let pe=(()=>!(j||n!==0||Z))();Se(y,f?!1:pe,v),_e(p,m,n===0);let[ue,de]=Ie(),fe=_(()=>[{dialogState:n,close:m,setTitleId:$},E],[n,E,m,$]),W=_(()=>({open:n===0}),[n]),ge={ref:z,id:u,role:a,tabIndex:-1,"aria-modal":n===0?!0:void 0,"aria-labelledby":E.titleId,"aria-describedby":ue},Te=!Ae(),A=S?O(ne,{parent:T.RestoreFocus,leaf:T.All&~T.FocusLock}):T.None;return c&&(A|=T.AutoFocus),Te||(A&=~T.InitialFocus),f&&(A=T.None),l.createElement(Oe,{type:"Dialog",enabled:n===0,element:p,onUpdate:D((e,g)=>{g==="Dialog"&&O(e,{[B.Add]:()=>H(x=>x+1),[B.Remove]:()=>H(x=>x-1)})})},l.createElement(X,{force:!0},l.createElement(q,null,l.createElement(R.Provider,{value:fe},l.createElement(q.Group,{target:p},l.createElement(X,{force:!1},l.createElement(de,{slot:W,name:"Dialog.Description"},l.createElement(te,null,l.createElement(we,{initialFocus:d,initialFocusFallback:f?void 0:p,containers:v,features:A},l.createElement(xe,{value:m},w({ourProps:ge,theirProps:G,slot:W,defaultTag:$e,features:je,visible:n===0,name:"Dialog"})))))))))),l.createElement(Le,null,l.createElement(le,null)))}let Ye="div";function Je(o,t){let r=L(),{id:u=`headlessui-dialog-panel-${r}`,...i}=o,[{dialogState:s},d]=M("Dialog.Panel"),a=h(t,d.panelRef),c=_(()=>({open:s===0}),[s]),f=D(b=>{b.stopPropagation()});return w({ourProps:{ref:a,id:u,onClick:f},theirProps:i,slot:c,defaultTag:Ye,name:"Dialog.Panel"})}let Xe="h2";function Be(o,t){let r=L(),{id:u=`headlessui-dialog-title-${r}`,...i}=o,[{dialogState:s,setTitleId:d}]=M("Dialog.Title"),a=h(t);ce(()=>(d(u),()=>d(null)),[u,d]);let c=_(()=>({open:s===0}),[s]);return w({ourProps:{ref:a,id:u},theirProps:i,slot:c,defaultTag:Xe,name:"Dialog.Title"})}let Ke=I(We),Ve=I(Je),qe=I(Be),At=V,_t=Object.assign(Ke,{Panel:Ve,Title:qe,Description:V});export{_t as Dialog,At as DialogDescription,Ve as DialogPanel,qe as DialogTitle};
"use client";import n,{createContext as te,createRef as oe,useContext as le,useEffect as ne,useMemo as F,useReducer as re,useRef as U}from"react";import{useEscape as ae}from'../../hooks/use-escape.js';import{useEvent as y}from'../../hooks/use-event.js';import{useId as v}from'../../hooks/use-id.js';import{useInertOthers as ie}from'../../hooks/use-inert-others.js';import{useIsTouchDevice as se}from'../../hooks/use-is-touch-device.js';import{useOnDisappear as pe}from'../../hooks/use-on-disappear.js';import{useOutsideClick as de}from'../../hooks/use-outside-click.js';import{useOwnerDocument as ue}from'../../hooks/use-owner.js';import{useRootContainers as fe}from'../../hooks/use-root-containers.js';import{useScrollLock as Te}from'../../hooks/use-scroll-lock.js';import{useServerHandoffComplete as ge}from'../../hooks/use-server-handoff-complete.js';import{useSyncRefs as x}from'../../hooks/use-sync-refs.js';import{CloseProvider as ce}from'../../internal/close-provider.js';import{HoistFormFields as me}from'../../internal/form-fields.js';import{State as b,useOpenClosed as De}from'../../internal/open-closed.js';import{ForcePortalRoot as k}from'../../internal/portal-force-root.js';import{match as Pe}from'../../utils/match.js';import{RenderFeatures as $,forwardRefWithAs as L,render as h}from'../../utils/render.js';import{Description as j,useDescriptions as ye}from'../description/description.js';import{FocusTrap as Ee,FocusTrapFeatures as E}from'../focus-trap/focus-trap.js';import{Portal as _e,PortalGroup as Ae,useNestedPortals as Ce}from'../portal/portal.js';var Fe=(l=>(l[l.Open=0]="Open",l[l.Closed=1]="Closed",l))(Fe||{}),be=(e=>(e[e.SetTitleId=0]="SetTitleId",e))(be||{});let Re={[0](t,e){return t.titleId===e.id?t:{...t,titleId:e.id}}},O=te(null);O.displayName="DialogContext";function I(t){let e=le(O);if(e===null){let l=new Error(`<${t} /> is missing a parent <Dialog /> component.`);throw Error.captureStackTrace&&Error.captureStackTrace(l,I),l}return e}function ve(t,e){return Pe(e.type,Re,t,e)}let xe="div",Le=$.RenderStrategy|$.Static;function he(t,e){let l=v(),{id:s=`headlessui-dialog-${l}`,open:a,onClose:i,initialFocus:p,role:r="dialog",autoFocus:c=!0,__demoMode:d=!1,...S}=t,_=U(!1);r=function(){return r==="dialog"||r==="alertdialog"?r:(_.current||(_.current=!0,console.warn(`Invalid role [${r}] passed to <Dialog />. Only \`dialog\` and and \`alertdialog\` are supported. Using \`dialog\` instead.`)),"dialog")}();let m=De();a===void 0&&m!==null&&(a=(m&b.Open)===b.Open);let u=U(null),W=x(u,e),A=ue(u),M=t.hasOwnProperty("open")||m!==null,w=t.hasOwnProperty("onClose");if(!M&&!w)throw new Error("You have to provide an `open` and an `onClose` prop to the `Dialog` component.");if(!M)throw new Error("You provided an `onClose` prop to the `Dialog`, but forgot an `open` prop.");if(!w)throw new Error("You provided an `open` prop to the `Dialog`, but forgot an `onClose` prop.");if(typeof a!="boolean")throw new Error(`You provided an \`open\` prop to the \`Dialog\`, but the value is not a boolean. Received: ${a}`);if(typeof i!="function")throw new Error(`You provided an \`onClose\` prop to the \`Dialog\`, but the value is not a function. Received: ${i}`);let f=a?0:1,[C,Y]=re(ve,{titleId:null,descriptionId:null,panelRef:oe()}),T=y(()=>i(!1)),G=y(o=>Y({type:0,id:o})),g=ge()?f===0:!1,[J,X]=Ce(),B={get current(){var o;return(o=C.panelRef.current)!=null?o:u.current}},{resolveContainers:R,mainTreeNodeRef:V,MainTreeNode:q}=fe({portals:J,defaultContainers:[B]}),H=m!==null?(m&b.Closing)===b.Closing:!1;ie(d||H?!1:g,{allowed:y(()=>{var o,P;return[(P=(o=u.current)==null?void 0:o.closest("[data-headlessui-portal]"))!=null?P:null]}),disallowed:y(()=>{var o,P;return[(P=(o=V.current)==null?void 0:o.closest("body > *:not(#headlessui-portal-root)"))!=null?P:null]})}),de(g,R,o=>{o.preventDefault(),T()}),ae(g,A==null?void 0:A.defaultView,o=>{o.preventDefault(),o.stopPropagation(),document.activeElement&&"blur"in document.activeElement&&typeof document.activeElement.blur=="function"&&document.activeElement.blur(),T()}),Te(d||H?!1:g,A,R),pe(g,u,T);let[z,K]=ye(),Q=F(()=>[{dialogState:f,close:T,setTitleId:G},C],[f,C,T,G]),N=F(()=>({open:f===0}),[f]),Z={ref:W,id:s,role:r,tabIndex:-1,"aria-modal":d?void 0:f===0?!0:void 0,"aria-labelledby":C.titleId,"aria-describedby":z},ee=!se(),D=E.None;return g&&!d&&(D|=E.RestoreFocus,D|=E.TabLock,c&&(D|=E.AutoFocus),ee&&(D|=E.InitialFocus)),n.createElement(n.Fragment,null,n.createElement(k,{force:!0},n.createElement(_e,null,n.createElement(O.Provider,{value:Q},n.createElement(Ae,{target:u},n.createElement(k,{force:!1},n.createElement(K,{slot:N},n.createElement(X,null,n.createElement(Ee,{initialFocus:p,initialFocusFallback:u,containers:R,features:D},n.createElement(ce,{value:T},h({ourProps:Z,theirProps:S,slot:N,defaultTag:xe,features:Le,visible:f===0,name:"Dialog"})))))))))),n.createElement(me,null,n.createElement(q,null)))}let Oe="div";function Ie(t,e){let l=v(),{id:s=`headlessui-dialog-panel-${l}`,...a}=t,[{dialogState:i},p]=I("Dialog.Panel"),r=x(e,p.panelRef),c=F(()=>({open:i===0}),[i]),d=y(_=>{_.stopPropagation()});return h({ourProps:{ref:r,id:s,onClick:d},theirProps:a,slot:c,defaultTag:Oe,name:"Dialog.Panel"})}let Se="h2";function Me(t,e){let l=v(),{id:s=`headlessui-dialog-title-${l}`,...a}=t,[{dialogState:i,setTitleId:p}]=I("Dialog.Title"),r=x(e);ne(()=>(p(s),()=>p(null)),[s,p]);let c=F(()=>({open:i===0}),[i]);return h({ourProps:{ref:r,id:s},theirProps:a,slot:c,defaultTag:Se,name:"Dialog.Title"})}let we=L(he),Ge=L(Ie),He=L(Me),pt=j,dt=Object.assign(we,{Panel:Ge,Title:He,Description:j});export{dt as Dialog,pt as DialogDescription,Ge as DialogPanel,He as DialogTitle};
import { type ElementType } from 'react';
import type { Props } from '../../types.js';
import { type HasDisplayName } from '../../utils/render.js';
declare let DEFAULT_FIELDSET_TAG: "div";
declare let DEFAULT_FIELDSET_TAG: "fieldset";
type FieldsetRenderPropArg = {};
type FieldsetPropsWeControl = 'aria-controls';
type FieldsetPropsWeControl = 'aria-labelledby' | 'aria-disabled' | 'role';
export type FieldsetProps<TTag extends ElementType = typeof DEFAULT_FIELDSET_TAG> = Props<TTag, FieldsetRenderPropArg, FieldsetPropsWeControl, {

@@ -8,0 +8,0 @@ disabled?: boolean;

@@ -1,1 +0,1 @@

"use client";import t,{useMemo as a}from"react";import{DisabledProvider as n,useDisabled as T}from'../../internal/disabled.js';import{forwardRefWithAs as m,render as F}from'../../utils/render.js';import{useLabels as y}from'../label/label.js';let f="div";function E(r,l){let o=T(),{disabled:e=o||!1,...s}=r,[i,d]=y(),p=a(()=>({disabled:e}),[e]);return t.createElement(n,{value:e},t.createElement(d,null,F({ourProps:{ref:l,role:"group","aria-labelledby":i,"aria-disabled":e||void 0},theirProps:s,slot:p,defaultTag:f,name:"Fieldset"})))}let L=m(E);export{L as Fieldset};
"use client";import o,{useMemo as y}from"react";import{useResolvedTag as F}from'../../hooks/use-resolved-tag.js';import{useSyncRefs as b}from'../../hooks/use-sync-refs.js';import{DisabledProvider as E,useDisabled as P}from'../../internal/disabled.js';import{forwardRefWithAs as u,render as g}from'../../utils/render.js';import{useLabels as D}from'../label/label.js';let d="fieldset";function A(t,i){var s;let a=P(),{disabled:e=a||!1,...p}=t,[n,T]=F((s=t.as)!=null?s:d),l=b(i,T),[r,f]=D(),m=y(()=>({disabled:e}),[e]);return o.createElement(E,{value:e},o.createElement(f,null,g({ourProps:n==="fieldset"?{ref:l,"aria-labelledby":r,disabled:e||void 0}:{ref:l,role:"group","aria-labelledby":r,"aria-disabled":e||void 0},theirProps:p,slot:m,defaultTag:d,name:"Fieldset"})))}let C=u(A);export{C as Fieldset};

@@ -8,15 +8,13 @@ import React, { type ElementType, type MutableRefObject, type Ref } from 'react';

/** No features enabled for the focus trap. */
None = 1,
None = 0,
/** Ensure that we move focus initially into the container. */
InitialFocus = 2,
InitialFocus = 1,
/** Ensure that pressing `Tab` and `Shift+Tab` is trapped within the container. */
TabLock = 4,
TabLock = 2,
/** Ensure that programmatically moving focus outside of the container is disallowed. */
FocusLock = 8,
FocusLock = 4,
/** Ensure that we restore the focus when unmounting the focus trap. */
RestoreFocus = 16,
RestoreFocus = 8,
/** Initial focus should look for the `data-autofocus` */
AutoFocus = 32,
/** Enable all features. */
All = 30
AutoFocus = 16
}

@@ -23,0 +21,0 @@ type FocusTrapRenderPropArg = {};

@@ -1,1 +0,1 @@

"use client";import d,{useRef as L}from"react";import{useDisposables as I}from'../../hooks/use-disposables.js';import{useEvent as g}from'../../hooks/use-event.js';import{useEventListener as G}from'../../hooks/use-event-listener.js';import{useIsMounted as v}from'../../hooks/use-is-mounted.js';import{useOnUnmount as W}from'../../hooks/use-on-unmount.js';import{useOwnerDocument as k}from'../../hooks/use-owner.js';import{useServerHandoffComplete as K}from'../../hooks/use-server-handoff-complete.js';import{useSyncRefs as V}from'../../hooks/use-sync-refs.js';import{Direction as M,useTabDirection as q}from'../../hooks/use-tab-direction.js';import{useWatch as y}from'../../hooks/use-watch.js';import{Hidden as F,HiddenFeatures as P}from'../../internal/hidden.js';import{history as R}from'../../utils/active-element-history.js';import{Focus as T,FocusResult as O,focusElement as f,focusIn as i}from'../../utils/focus-management.js';import{match as C}from'../../utils/match.js';import{microTask as _}from'../../utils/micro-task.js';import{forwardRefWithAs as J,render as X}from'../../utils/render.js';function S(t){if(!t)return new Set;if(typeof t=="function")return new Set(t());let o=new Set;for(let e of t.current)e.current instanceof HTMLElement&&o.add(e.current);return o}let z="div";var h=(r=>(r[r.None=1]="None",r[r.InitialFocus=2]="InitialFocus",r[r.TabLock=4]="TabLock",r[r.FocusLock=8]="FocusLock",r[r.RestoreFocus=16]="RestoreFocus",r[r.AutoFocus=32]="AutoFocus",r[r.All=30]="All",r))(h||{});function Q(t,o){let e=L(null),n=V(e,o),{initialFocus:c,initialFocusFallback:p,containers:u,features:r=30,...l}=t;K()||(r=1);let s=k(e);$({ownerDocument:s},!!(r&16));let U=D({ownerDocument:s,container:e,initialFocus:c,initialFocusFallback:p},r);w({ownerDocument:s,container:e,containers:u,previousActiveElement:U},!!(r&8));let b=q(),A=g(a=>{let m=e.current;if(!m)return;(N=>N())(()=>{C(b.current,{[M.Forwards]:()=>{i(m,T.First,{skipElements:[a.relatedTarget,p]})},[M.Backwards]:()=>{i(m,T.Last,{skipElements:[a.relatedTarget,p]})}})})}),B=I(),H=L(!1),x={ref:n,onKeyDown(a){a.key=="Tab"&&(H.current=!0,B.requestAnimationFrame(()=>{H.current=!1}))},onBlur(a){if(!(r&8))return;let m=S(u);e.current instanceof HTMLElement&&m.add(e.current);let E=a.relatedTarget;E instanceof HTMLElement&&E.dataset.headlessuiFocusGuard!=="true"&&(j(m,E)||(H.current?i(e.current,C(b.current,{[M.Forwards]:()=>T.Next,[M.Backwards]:()=>T.Previous})|T.WrapAround,{relativeTo:a.target}):a.target instanceof HTMLElement&&f(a.target)))}};return d.createElement(d.Fragment,null,!!(r&4)&&d.createElement(F,{as:"button",type:"button","data-headlessui-focus-guard":!0,onFocus:A,features:P.Focusable}),X({ourProps:x,theirProps:l,defaultTag:z,name:"FocusTrap"}),!!(r&4)&&d.createElement(F,{as:"button",type:"button","data-headlessui-focus-guard":!0,onFocus:A,features:P.Focusable}))}let Y=J(Q),Le=Object.assign(Y,{features:h});function Z(t=!0){let o=L(R.slice());return y(([e],[n])=>{n===!0&&e===!1&&_(()=>{o.current.splice(0)}),n===!1&&e===!0&&(o.current=R.slice())},[t,R,o]),g(()=>{var e;return(e=o.current.find(n=>n!=null&&n.isConnected))!=null?e:null})}function $({ownerDocument:t},o){let e=Z(o);y(()=>{o||(t==null?void 0:t.activeElement)===(t==null?void 0:t.body)&&f(e())},[o]),W(()=>{o&&f(e())})}function D({ownerDocument:t,container:o,initialFocus:e,initialFocusFallback:n},c){let p=!!(c&2),u=L(null),r=v();return y(()=>{if(!p){n!=null&&n.current&&f(n.current);return}let l=o.current;l&&_(()=>{if(!r.current)return;let s=t==null?void 0:t.activeElement;if(e!=null&&e.current){if((e==null?void 0:e.current)===s){u.current=s;return}}else if(l.contains(s)){u.current=s;return}if(e!=null&&e.current)f(e.current);else{if(c&32){if(i(l,T.First|T.AutoFocus)!==O.Error)return}else if(i(l,T.First)!==O.Error)return;if(n!=null&&n.current&&(f(n.current),(t==null?void 0:t.activeElement)===n.current))return;console.warn("There are no focusable elements inside the <FocusTrap />")}u.current=t==null?void 0:t.activeElement})},[n,p,c]),u}function w({ownerDocument:t,container:o,containers:e,previousActiveElement:n},c){let p=v();G(t==null?void 0:t.defaultView,"focus",u=>{if(!c||!p.current)return;let r=S(e);o.current instanceof HTMLElement&&r.add(o.current);let l=n.current;if(!l)return;let s=u.target;s&&s instanceof HTMLElement?j(r,s)?(n.current=s,f(s)):(u.preventDefault(),u.stopPropagation(),f(l)):f(n.current)},!0)}function j(t,o){for(let e of t)if(e.contains(o))return!0;return!1}export{Le as FocusTrap,h as FocusTrapFeatures};
"use client";import L,{useRef as M}from"react";import{useDisposables as G}from'../../hooks/use-disposables.js';import{useEvent as A}from'../../hooks/use-event.js';import{useEventListener as W}from'../../hooks/use-event-listener.js';import{useIsMounted as P}from'../../hooks/use-is-mounted.js';import{useIsTopLayer as O}from'../../hooks/use-is-top-layer.js';import{useOnUnmount as K}from'../../hooks/use-on-unmount.js';import{useOwnerDocument as V}from'../../hooks/use-owner.js';import{useServerHandoffComplete as q}from'../../hooks/use-server-handoff-complete.js';import{useSyncRefs as J}from'../../hooks/use-sync-refs.js';import{Direction as H,useTabDirection as X}from'../../hooks/use-tab-direction.js';import{useWatch as y}from'../../hooks/use-watch.js';import{Hidden as C,HiddenFeatures as _}from'../../internal/hidden.js';import{history as b}from'../../utils/active-element-history.js';import{Focus as T,FocusResult as S,focusElement as p,focusIn as E}from'../../utils/focus-management.js';import{match as h}from'../../utils/match.js';import{microTask as j}from'../../utils/micro-task.js';import{forwardRefWithAs as z,render as Q}from'../../utils/render.js';function U(o){if(!o)return new Set;if(typeof o=="function")return new Set(o());let e=new Set;for(let t of o.current)t.current instanceof HTMLElement&&e.add(t.current);return e}let Y="div";var x=(n=>(n[n.None=0]="None",n[n.InitialFocus=1]="InitialFocus",n[n.TabLock=2]="TabLock",n[n.FocusLock=4]="FocusLock",n[n.RestoreFocus=8]="RestoreFocus",n[n.AutoFocus=16]="AutoFocus",n))(x||{});function Z(o,e){let t=M(null),r=J(t,e),{initialFocus:s,initialFocusFallback:a,containers:n,features:u=15,...f}=o;q()||(u=0);let l=V(t);w(u,{ownerDocument:l});let i=ee(u,{ownerDocument:l,container:t,initialFocus:s,initialFocusFallback:a});te(u,{ownerDocument:l,container:t,containers:n,previousActiveElement:i});let R=X(),g=A(c=>{let m=t.current;if(!m)return;(B=>B())(()=>{h(R.current,{[H.Forwards]:()=>{E(m,T.First,{skipElements:[c.relatedTarget,a]})},[H.Backwards]:()=>{E(m,T.Last,{skipElements:[c.relatedTarget,a]})}})})}),v=O(!!(u&2),"focus-trap#tab-lock"),N=G(),F=M(!1),k={ref:r,onKeyDown(c){c.key=="Tab"&&(F.current=!0,N.requestAnimationFrame(()=>{F.current=!1}))},onBlur(c){if(!(u&4))return;let m=U(n);t.current instanceof HTMLElement&&m.add(t.current);let d=c.relatedTarget;d instanceof HTMLElement&&d.dataset.headlessuiFocusGuard!=="true"&&(I(m,d)||(F.current?E(t.current,h(R.current,{[H.Forwards]:()=>T.Next,[H.Backwards]:()=>T.Previous})|T.WrapAround,{relativeTo:c.target}):c.target instanceof HTMLElement&&p(c.target)))}};return L.createElement(L.Fragment,null,v&&L.createElement(C,{as:"button",type:"button","data-headlessui-focus-guard":!0,onFocus:g,features:_.Focusable}),Q({ourProps:k,theirProps:f,defaultTag:Y,name:"FocusTrap"}),v&&L.createElement(C,{as:"button",type:"button","data-headlessui-focus-guard":!0,onFocus:g,features:_.Focusable}))}let $=z(Z),Fe=Object.assign($,{features:x});function D(o=!0){let e=M(b.slice());return y(([t],[r])=>{r===!0&&t===!1&&j(()=>{e.current.splice(0)}),r===!1&&t===!0&&(e.current=b.slice())},[o,b,e]),A(()=>{var t;return(t=e.current.find(r=>r!=null&&r.isConnected))!=null?t:null})}function w(o,{ownerDocument:e}){let t=!!(o&8),r=D(t);y(()=>{t||(e==null?void 0:e.activeElement)===(e==null?void 0:e.body)&&p(r())},[t]),K(()=>{t&&p(r())})}function ee(o,{ownerDocument:e,container:t,initialFocus:r,initialFocusFallback:s}){let a=M(null),n=O(!!(o&1),"focus-trap#initial-focus"),u=P();return y(()=>{if(o===0)return;if(!n){s!=null&&s.current&&p(s.current);return}let f=t.current;f&&j(()=>{if(!u.current)return;let l=e==null?void 0:e.activeElement;if(r!=null&&r.current){if((r==null?void 0:r.current)===l){a.current=l;return}}else if(f.contains(l)){a.current=l;return}if(r!=null&&r.current)p(r.current);else{if(o&16){if(E(f,T.First|T.AutoFocus)!==S.Error)return}else if(E(f,T.First)!==S.Error)return;if(s!=null&&s.current&&(p(s.current),(e==null?void 0:e.activeElement)===s.current))return;console.warn("There are no focusable elements inside the <FocusTrap />")}a.current=e==null?void 0:e.activeElement})},[s,n,o]),a}function te(o,{ownerDocument:e,container:t,containers:r,previousActiveElement:s}){let a=P(),n=!!(o&4);W(e==null?void 0:e.defaultView,"focus",u=>{if(!n||!a.current)return;let f=U(r);t.current instanceof HTMLElement&&f.add(t.current);let l=s.current;if(!l)return;let i=u.target;i&&i instanceof HTMLElement?I(f,i)?(s.current=i,p(i)):(u.preventDefault(),u.stopPropagation(),p(l)):p(s.current)},!0)}function I(o,e){for(let t of o)if(t.contains(e))return!0;return!1}export{Fe as FocusTrap,x as FocusTrapFeatures};

@@ -1,1 +0,1 @@

"use client";import{useFocusRing as Re}from"@react-aria/focus";import{useHover as Pe}from"@react-aria/interactions";import _,{Fragment as pe,createContext as ee,createRef as Ae,useCallback as ue,useContext as te,useEffect as de,useMemo as U,useReducer as Ee,useRef as H,useState as he}from"react";import{useActivePress as De}from'../../hooks/use-active-press.js';import{useByComparator as _e}from'../../hooks/use-by-comparator.js';import{useComputed as Ie}from'../../hooks/use-computed.js';import{useControllable as Ce}from'../../hooks/use-controllable.js';import{useDidElementMove as Fe}from'../../hooks/use-did-element-move.js';import{useDisposables as X}from'../../hooks/use-disposables.js';import{useElementSize as Me}from'../../hooks/use-element-size.js';import{useEvent as f}from'../../hooks/use-event.js';import{useId as oe}from'../../hooks/use-id.js';import{useInertOthers as we}from'../../hooks/use-inert-others.js';import{useIsoMorphicEffect as ne}from'../../hooks/use-iso-morphic-effect.js';import{useLatestValue as Be}from'../../hooks/use-latest-value.js';import{useOnDisappear as ke}from'../../hooks/use-on-disappear.js';import{useOutsideClick as Ue}from'../../hooks/use-outside-click.js';import{useOwnerDocument as Ne}from'../../hooks/use-owner.js';import{useResolveButtonType as Ge}from'../../hooks/use-resolve-button-type.js';import{useScrollLock as He}from'../../hooks/use-scroll-lock.js';import{useSyncRefs as K}from'../../hooks/use-sync-refs.js';import{useTextValue as Ve}from'../../hooks/use-text-value.js';import{useTrackedPointer as Ke}from'../../hooks/use-tracked-pointer.js';import{useDisabled as je}from'../../internal/disabled.js';import{FloatingProvider as ze,useFloatingPanel as We,useFloatingPanelProps as Qe,useFloatingReference as Xe,useFloatingReferenceProps as Je,useResolvedAnchor as $e}from'../../internal/floating.js';import{FormFields as qe}from'../../internal/form-fields.js';import{useProvidedId as Ye}from'../../internal/id.js';import{OpenClosedProvider as Ze,State as J,useOpenClosed as et}from'../../internal/open-closed.js';import{isDisabledReactIssue7711 as tt}from'../../utils/bugs.js';import{Focus as m,calculateActiveIndex as ie}from'../../utils/calculate-active-index.js';import{disposables as re}from'../../utils/disposables.js';import{FocusableMode as ot,isFocusableElement as nt,sortByDomNode as it}from'../../utils/focus-management.js';import{attemptSubmit as rt}from'../../utils/form.js';import{match as V}from'../../utils/match.js';import{getOwnerDocument as at}from'../../utils/owner.js';import{RenderFeatures as ce,forwardRefWithAs as j,mergeProps as fe,render as z}from'../../utils/render.js';import{useDescribedBy as lt}from'../description/description.js';import{Keys as S}from'../keyboard.js';import{Label as st,useLabelledBy as pt,useLabels as ut}from'../label/label.js';import{Portal as dt}from'../portal/portal.js';var ct=(o=>(o[o.Open=0]="Open",o[o.Closed=1]="Closed",o))(ct||{}),ft=(o=>(o[o.Single=0]="Single",o[o.Multi=1]="Multi",o))(ft||{}),bt=(o=>(o[o.Pointer=0]="Pointer",o[o.Other=1]="Other",o))(bt||{}),Tt=(i=>(i[i.OpenListbox=0]="OpenListbox",i[i.CloseListbox=1]="CloseListbox",i[i.GoToOption=2]="GoToOption",i[i.Search=3]="Search",i[i.ClearSearch=4]="ClearSearch",i[i.RegisterOption=5]="RegisterOption",i[i.UnregisterOption=6]="UnregisterOption",i))(Tt||{});function ae(e,a=o=>o){let o=e.activeOptionIndex!==null?e.options[e.activeOptionIndex]:null,n=it(a(e.options.slice()),x=>x.dataRef.current.domRef.current),p=o?n.indexOf(o):null;return p===-1&&(p=null),{options:n,activeOptionIndex:p}}let xt={[1](e){return e.dataRef.current.disabled||e.listboxState===1?e:{...e,activeOptionIndex:null,listboxState:1,__demoMode:!1}},[0](e){if(e.dataRef.current.disabled||e.listboxState===0)return e;let a=e.activeOptionIndex,{isSelected:o}=e.dataRef.current,n=e.options.findIndex(p=>o(p.dataRef.current.value));return n!==-1&&(a=n),{...e,listboxState:0,activeOptionIndex:a,__demoMode:!1}},[2](e,a){var x,O,i,l,t;if(e.dataRef.current.disabled||e.listboxState===1)return e;let o={...e,searchQuery:"",activationTrigger:(x=a.trigger)!=null?x:1,__demoMode:!1};if(a.focus===m.Nothing)return{...o,activeOptionIndex:null};if(a.focus===m.Specific)return{...o,activeOptionIndex:e.options.findIndex(r=>r.id===a.id)};if(a.focus===m.Previous){let r=e.activeOptionIndex;if(r!==null){let A=e.options[r].dataRef.current.domRef,d=ie(a,{resolveItems:()=>e.options,resolveActiveIndex:()=>e.activeOptionIndex,resolveId:u=>u.id,resolveDisabled:u=>u.dataRef.current.disabled});if(d!==null){let u=e.options[d].dataRef.current.domRef;if(((O=A.current)==null?void 0:O.previousElementSibling)===u.current||((i=u.current)==null?void 0:i.previousElementSibling)===null)return{...o,activeOptionIndex:d}}}}else if(a.focus===m.Next){let r=e.activeOptionIndex;if(r!==null){let A=e.options[r].dataRef.current.domRef,d=ie(a,{resolveItems:()=>e.options,resolveActiveIndex:()=>e.activeOptionIndex,resolveId:u=>u.id,resolveDisabled:u=>u.dataRef.current.disabled});if(d!==null){let u=e.options[d].dataRef.current.domRef;if(((l=A.current)==null?void 0:l.nextElementSibling)===u.current||((t=u.current)==null?void 0:t.nextElementSibling)===null)return{...o,activeOptionIndex:d}}}}let n=ae(e),p=ie(a,{resolveItems:()=>n.options,resolveActiveIndex:()=>n.activeOptionIndex,resolveId:r=>r.id,resolveDisabled:r=>r.dataRef.current.disabled});return{...o,...n,activeOptionIndex:p}},[3]:(e,a)=>{if(e.dataRef.current.disabled||e.listboxState===1)return e;let n=e.searchQuery!==""?0:1,p=e.searchQuery+a.value.toLowerCase(),O=(e.activeOptionIndex!==null?e.options.slice(e.activeOptionIndex+n).concat(e.options.slice(0,e.activeOptionIndex+n)):e.options).find(l=>{var t;return!l.dataRef.current.disabled&&((t=l.dataRef.current.textValue)==null?void 0:t.startsWith(p))}),i=O?e.options.indexOf(O):-1;return i===-1||i===e.activeOptionIndex?{...e,searchQuery:p}:{...e,searchQuery:p,activeOptionIndex:i,activationTrigger:1}},[4](e){return e.dataRef.current.disabled||e.listboxState===1||e.searchQuery===""?e:{...e,searchQuery:""}},[5]:(e,a)=>{let o={id:a.id,dataRef:a.dataRef},n=ae(e,p=>[...p,o]);return e.activeOptionIndex===null&&e.dataRef.current.isSelected(a.dataRef.current.value)&&(n.activeOptionIndex=n.options.indexOf(o)),{...e,...n}},[6]:(e,a)=>{let o=ae(e,n=>{let p=n.findIndex(x=>x.id===a.id);return p!==-1&&n.splice(p,1),n});return{...e,...o,activationTrigger:1}}},le=ee(null);le.displayName="ListboxActionsContext";function $(e){let a=te(le);if(a===null){let o=new Error(`<${e} /> is missing a parent <Listbox /> component.`);throw Error.captureStackTrace&&Error.captureStackTrace(o,$),o}return a}let q=ee(null);q.displayName="ListboxDataContext";function W(e){let a=te(q);if(a===null){let o=new Error(`<${e} /> is missing a parent <Listbox /> component.`);throw Error.captureStackTrace&&Error.captureStackTrace(o,W),o}return a}function mt(e,a){return V(a.type,xt,e,a)}let Ot=pe;function yt(e,a){var se;let o=je(),{value:n,defaultValue:p,form:x,name:O,onChange:i,by:l,invalid:t=!1,disabled:r=o||!1,horizontal:A=!1,multiple:d=!1,__demoMode:u=!1,...h}=e;const N=A?"horizontal":"vertical";let B=K(a),[E=d?[]:void 0,y]=Ce(n,i,p),[D,g]=Ee(mt,{dataRef:Ae(),listboxState:u?0:1,options:[],searchQuery:"",activeOptionIndex:null,activationTrigger:1,optionsVisible:!1,__demoMode:u}),C=H({static:!1,hold:!1}),k=H(null),F=H(null),b=H(new Map),R=_e(l),w=ue(T=>V(c.mode,{[1]:()=>E.some(L=>R(L,T)),[0]:()=>R(E,T)}),[E]),c=U(()=>({...D,value:E,disabled:r,invalid:t,mode:d?1:0,orientation:N,compare:R,isSelected:w,optionsPropsRef:C,buttonRef:k,optionsRef:F,listRef:b}),[E,r,t,d,D,b]);ne(()=>{D.dataRef.current=c},[c]),Ue([c.buttonRef,c.optionsRef],(T,L)=>{var I;g({type:1}),nt(L,ot.Loose)||(T.preventDefault(),(I=c.buttonRef.current)==null||I.focus())},c.listboxState===0);let v=U(()=>({open:c.listboxState===0,disabled:r,invalid:t,value:E}),[c,r,E,t]),G=f(T=>{let L=c.options.find(I=>I.id===T);L&&Z(L.dataRef.current.value)}),Y=f(()=>{if(c.activeOptionIndex!==null){let{dataRef:T,id:L}=c.options[c.activeOptionIndex];Z(T.current.value),g({type:2,focus:m.Specific,id:L})}}),Q=f(()=>g({type:0})),s=f(()=>g({type:1})),P=X(),M=f((T,L,I)=>{P.dispose(),P.microTask(()=>T===m.Specific?g({type:2,focus:m.Specific,id:L,trigger:I}):g({type:2,focus:T,trigger:I}))}),Te=f((T,L)=>(g({type:5,id:T,dataRef:L}),()=>g({type:6,id:T}))),Z=f(T=>V(c.mode,{[0](){return y==null?void 0:y(T)},[1](){let L=c.value.slice(),I=L.findIndex(Se=>R(Se,T));return I===-1?L.push(T):L.splice(I,1),y==null?void 0:y(L)}})),xe=f(T=>g({type:3,value:T})),me=f(()=>g({type:4})),Oe=U(()=>({onChange:Z,registerOption:Te,goToOption:M,closeListbox:s,openListbox:Q,selectActiveOption:Y,selectOption:G,search:xe,clearSearch:me}),[]),[ye,ve]=ut({inherit:!0}),ge={ref:B},Le=ue(()=>y==null?void 0:y(p),[y]);return _.createElement(ve,{value:ye,props:{htmlFor:(se=c.buttonRef.current)==null?void 0:se.id},slot:{open:c.listboxState===0,disabled:r}},_.createElement(ze,null,_.createElement(le.Provider,{value:Oe},_.createElement(q.Provider,{value:c},_.createElement(Ze,{value:V(c.listboxState,{[0]:J.Open,[1]:J.Closed})},O!=null&&E!=null&&_.createElement(qe,{disabled:r,data:{[O]:E},form:x,onReset:Le}),z({ourProps:ge,theirProps:h,slot:v,defaultTag:Ot,name:"Listbox"}))))))}let vt="button";function gt(e,a){var c;let o=W("Listbox.Button"),n=$("Listbox.Button"),p=oe(),x=Ye(),{id:O=x||`headlessui-listbox-button-${p}`,disabled:i=o.disabled||!1,autoFocus:l=!1,...t}=e,r=K(o.buttonRef,a,Xe()),A=Je(),d=X(),u=f(v=>{switch(v.key){case S.Enter:rt(v.currentTarget);break;case S.Space:case S.ArrowDown:v.preventDefault(),n.openListbox(),d.nextFrame(()=>{o.value||n.goToOption(m.First)});break;case S.ArrowUp:v.preventDefault(),n.openListbox(),d.nextFrame(()=>{o.value||n.goToOption(m.Last)});break}}),h=f(v=>{switch(v.key){case S.Space:v.preventDefault();break}}),N=f(v=>{if(tt(v.currentTarget))return v.preventDefault();o.listboxState===0?(n.closeListbox(),d.nextFrame(()=>{var G;return(G=o.buttonRef.current)==null?void 0:G.focus({preventScroll:!0})})):(v.preventDefault(),n.openListbox())}),B=f(v=>v.preventDefault()),E=pt([O]),y=lt(),{isFocusVisible:D,focusProps:g}=Re({autoFocus:l}),{isHovered:C,hoverProps:k}=Pe({isDisabled:i}),{pressed:F,pressProps:b}=De({disabled:i}),R=U(()=>({open:o.listboxState===0,active:F||o.listboxState===0,disabled:i,invalid:o.invalid,value:o.value,hover:C,focus:D,autofocus:l}),[o.listboxState,o.value,i,C,D,F,o.invalid,l]),w=fe(A(),{ref:r,id:O,type:Ge(e,o.buttonRef),"aria-haspopup":"listbox","aria-controls":(c=o.optionsRef.current)==null?void 0:c.id,"aria-expanded":o.listboxState===0,"aria-labelledby":E,"aria-describedby":y,disabled:i||void 0,autoFocus:l,onKeyDown:u,onKeyUp:h,onKeyPress:B,onClick:N},g,k,b);return z({ourProps:w,theirProps:t,slot:R,defaultTag:vt,name:"Listbox.Button"})}let be=ee(!1),Lt="div",St=ce.RenderStrategy|ce.Static;function Rt(e,a){var Q;let o=oe(),{id:n=`headlessui-listbox-options-${o}`,anchor:p,portal:x=!1,modal:O=!0,...i}=e,l=$e(p);l&&(x=!0);let t=W("Listbox.Options"),r=$("Listbox.Options"),A=Ne(t.optionsRef),d=et(),u=(()=>d!==null?(d&J.Open)===J.Open:t.listboxState===0)();ke(t.buttonRef,r.closeListbox,u),He(A,t.__demoMode?!1:O&&t.listboxState===0),we({allowed:f(()=>[t.buttonRef.current,t.optionsRef.current])},t.__demoMode?!1:O&&t.listboxState===0);let h=H(null);de(()=>{var P;if(!((P=l==null?void 0:l.to)!=null&&P.includes("selection")))return;if(!u){h.current=null;return}let s=Array.from(t.listRef.current.values());h.current=s.findIndex(M=>(M==null?void 0:M.dataset.selected)===""),h.current===-1&&(h.current=s.findIndex(M=>(M==null?void 0:M.dataset.disabled)===void 0),r.goToOption(m.First))},[u,t.listRef]);let B=Fe(t.buttonRef,t.listboxState!==0)?!1:u,E=(()=>{if(l==null)return;if(t.listRef.current.size<=0)return{...l,inner:void 0};let s=Array.from(t.listRef.current.values());return{...l,inner:{listRef:{current:s},index:h.current}}})(),[y,D]=We(E),g=Qe(),C=K(t.optionsRef,a,l?y:null),k=X(),F=X();de(()=>{var P;let s=t.optionsRef.current;s&&t.listboxState===0&&s!==((P=at(s))==null?void 0:P.activeElement)&&(s==null||s.focus({preventScroll:!0}))},[t.listboxState,t.optionsRef,t.optionsRef.current]);let b=f(s=>{switch(F.dispose(),s.key){case S.Space:if(t.searchQuery!=="")return s.preventDefault(),s.stopPropagation(),r.search(s.key);case S.Enter:if(s.preventDefault(),s.stopPropagation(),t.activeOptionIndex!==null){let{dataRef:P}=t.options[t.activeOptionIndex];r.onChange(P.current.value)}t.mode===0&&(r.closeListbox(),re().nextFrame(()=>{var P;return(P=t.buttonRef.current)==null?void 0:P.focus({preventScroll:!0})}));break;case V(t.orientation,{vertical:S.ArrowDown,horizontal:S.ArrowRight}):return s.preventDefault(),s.stopPropagation(),r.goToOption(m.Next);case V(t.orientation,{vertical:S.ArrowUp,horizontal:S.ArrowLeft}):return s.preventDefault(),s.stopPropagation(),r.goToOption(m.Previous);case S.Home:case S.PageUp:return s.preventDefault(),s.stopPropagation(),r.goToOption(m.First);case S.End:case S.PageDown:return s.preventDefault(),s.stopPropagation(),r.goToOption(m.Last);case S.Escape:return s.preventDefault(),s.stopPropagation(),r.closeListbox(),k.nextFrame(()=>{var P;return(P=t.buttonRef.current)==null?void 0:P.focus({preventScroll:!0})});case S.Tab:s.preventDefault(),s.stopPropagation();break;default:s.key.length===1&&(r.search(s.key),F.setTimeout(()=>r.clearSearch(),350));break}}),R=Ie(()=>{var s;return(s=t.buttonRef.current)==null?void 0:s.id},[t.buttonRef.current]),w=U(()=>({open:t.listboxState===0}),[t]),c=fe(l?g():{},{id:n,ref:C,"aria-activedescendant":t.activeOptionIndex===null||(Q=t.options[t.activeOptionIndex])==null?void 0:Q.id,"aria-multiselectable":t.mode===1?!0:void 0,"aria-labelledby":R,"aria-orientation":t.orientation,onKeyDown:b,role:"listbox",tabIndex:0,style:{...D,"--button-width":Me(t.buttonRef,!0).width}}),[v,G]=he(t.value);t.value!==v&&t.listboxState===0&&t.mode!==1&&G(t.value);let Y=f(s=>t.compare(v,s));return _.createElement(dt,{enabled:x?e.static||u:!1},_.createElement(q.Provider,{value:t.mode===1?t:{...t,isSelected:Y}},z({ourProps:c,theirProps:i,slot:w,defaultTag:Lt,features:St,visible:B,name:"Listbox.Options"})))}let Pt="div";function At(e,a){let o=oe(),{id:n=`headlessui-listbox-option-${o}`,disabled:p=!1,value:x,...O}=e,i=te(be)===!0,l=W("Listbox.Option"),t=$("Listbox.Option"),r=l.activeOptionIndex!==null?l.options[l.activeOptionIndex].id===n:!1,A=l.isSelected(x),d=H(null),u=Ve(d),h=Be({disabled:p,value:x,domRef:d,get textValue(){return u()}}),N=K(a,d,b=>{b?l.listRef.current.set(n,b):l.listRef.current.delete(n)});ne(()=>{if(l.__demoMode||l.listboxState!==0||!r||l.activationTrigger===0)return;let b=re();return b.requestAnimationFrame(()=>{var R,w;(w=(R=d.current)==null?void 0:R.scrollIntoView)==null||w.call(R,{block:"nearest"})}),b.dispose},[d,r,l.__demoMode,l.listboxState,l.activationTrigger,l.activeOptionIndex]),ne(()=>{if(!i)return t.registerOption(n,h)},[h,n,i]);let B=f(b=>{if(p)return b.preventDefault();t.onChange(x),l.mode===0&&(t.closeListbox(),re().nextFrame(()=>{var R;return(R=l.buttonRef.current)==null?void 0:R.focus({preventScroll:!0})}))}),E=f(()=>{if(p)return t.goToOption(m.Nothing);t.goToOption(m.Specific,n)}),y=Ke(),D=f(b=>{y.update(b),!p&&(r||t.goToOption(m.Specific,n,0))}),g=f(b=>{y.wasMoved(b)&&(p||r||t.goToOption(m.Specific,n,0))}),C=f(b=>{y.wasMoved(b)&&(p||r&&t.goToOption(m.Nothing))}),k=U(()=>({active:r,focus:r,selected:A,disabled:p,selectedOption:A&&i}),[r,A,p,i]),F=i?{}:{id:n,ref:N,role:"option",tabIndex:p===!0?void 0:-1,"aria-disabled":p===!0?!0:void 0,"aria-selected":A,disabled:void 0,onClick:B,onFocus:E,onPointerEnter:D,onMouseEnter:D,onPointerMove:g,onMouseMove:g,onPointerLeave:C,onMouseLeave:C};return!A&&i?null:z({ourProps:F,theirProps:O,slot:k,defaultTag:Pt,name:"Listbox.Option"})}let Et=pe;function ht(e,a){let{options:o,placeholder:n,...p}=e,O={ref:K(a)},i=W("ListboxSelectedOption"),l=U(()=>({}),[]),t=i.value===void 0||i.value===null||i.mode===1&&Array.isArray(i.value)&&i.value.length===0;return _.createElement(be.Provider,{value:!0},z({ourProps:O,theirProps:{...p,children:_.createElement(_.Fragment,null,n&&t?n:o)},slot:l,defaultTag:Et,name:"ListboxSelectedOption"}))}let Dt=j(yt),_t=j(gt),It=st,Ct=j(Rt),Ft=j(At),Mt=j(ht),Lo=Object.assign(Dt,{Button:_t,Label:It,Options:Ct,Option:Ft,SelectedOption:Mt});export{Lo as Listbox,_t as ListboxButton,It as ListboxLabel,Ft as ListboxOption,Ct as ListboxOptions,Mt as ListboxSelectedOption};
"use client";import{useFocusRing as Ae}from"@react-aria/focus";import{useHover as Ee}from"@react-aria/interactions";import D,{Fragment as ce,createContext as ne,createRef as he,useCallback as fe,useContext as ie,useEffect as be,useMemo as U,useReducer as De,useRef as V,useState as _e}from"react";import{useActivePress as Ie}from'../../hooks/use-active-press.js';import{useByComparator as Ce}from'../../hooks/use-by-comparator.js';import{useComputed as Fe}from'../../hooks/use-computed.js';import{useControllable as Me}from'../../hooks/use-controllable.js';import{useDefaultValue as we}from'../../hooks/use-default-value.js';import{useDidElementMove as Be}from'../../hooks/use-did-element-move.js';import{useDisposables as J}from'../../hooks/use-disposables.js';import{useElementSize as ke}from'../../hooks/use-element-size.js';import{useEvent as f}from'../../hooks/use-event.js';import{useId as re}from'../../hooks/use-id.js';import{useInertOthers as Ue}from'../../hooks/use-inert-others.js';import{useIsoMorphicEffect as le}from'../../hooks/use-iso-morphic-effect.js';import{useLatestValue as Ne}from'../../hooks/use-latest-value.js';import{useOnDisappear as Ge}from'../../hooks/use-on-disappear.js';import{useOutsideClick as Ve}from'../../hooks/use-outside-click.js';import{useOwnerDocument as He}from'../../hooks/use-owner.js';import{useResolveButtonType as Ke}from'../../hooks/use-resolve-button-type.js';import{useScrollLock as je}from'../../hooks/use-scroll-lock.js';import{useSyncRefs as K}from'../../hooks/use-sync-refs.js';import{useTextValue as ze}from'../../hooks/use-text-value.js';import{useTrackedPointer as We}from'../../hooks/use-tracked-pointer.js';import{useDisabled as Qe}from'../../internal/disabled.js';import{FloatingProvider as Xe,useFloatingPanel as Je,useFloatingPanelProps as $e,useFloatingReference as qe,useFloatingReferenceProps as Ye,useResolvedAnchor as Ze}from'../../internal/floating.js';import{FormFields as et}from'../../internal/form-fields.js';import{useProvidedId as tt}from'../../internal/id.js';import{OpenClosedProvider as ot,State as $,useOpenClosed as nt}from'../../internal/open-closed.js';import{isDisabledReactIssue7711 as it}from'../../utils/bugs.js';import{Focus as m,calculateActiveIndex as ae}from'../../utils/calculate-active-index.js';import{disposables as se}from'../../utils/disposables.js';import{FocusableMode as rt,isFocusableElement as lt,sortByDomNode as at}from'../../utils/focus-management.js';import{attemptSubmit as st}from'../../utils/form.js';import{match as H}from'../../utils/match.js';import{getOwnerDocument as pt}from'../../utils/owner.js';import{RenderFeatures as Te,forwardRefWithAs as j,mergeProps as xe,render as z}from'../../utils/render.js';import{useDescribedBy as ut}from'../description/description.js';import{Keys as L}from'../keyboard.js';import{Label as dt,useLabelledBy as ct,useLabels as ft}from'../label/label.js';import{Portal as bt}from'../portal/portal.js';var Tt=(o=>(o[o.Open=0]="Open",o[o.Closed=1]="Closed",o))(Tt||{}),xt=(o=>(o[o.Single=0]="Single",o[o.Multi=1]="Multi",o))(xt||{}),mt=(o=>(o[o.Pointer=0]="Pointer",o[o.Other=1]="Other",o))(mt||{}),Ot=(n=>(n[n.OpenListbox=0]="OpenListbox",n[n.CloseListbox=1]="CloseListbox",n[n.GoToOption=2]="GoToOption",n[n.Search=3]="Search",n[n.ClearSearch=4]="ClearSearch",n[n.RegisterOption=5]="RegisterOption",n[n.UnregisterOption=6]="UnregisterOption",n))(Ot||{});function pe(e,l=o=>o){let o=e.activeOptionIndex!==null?e.options[e.activeOptionIndex]:null,i=at(l(e.options.slice()),T=>T.dataRef.current.domRef.current),p=o?i.indexOf(o):null;return p===-1&&(p=null),{options:i,activeOptionIndex:p}}let yt={[1](e){return e.dataRef.current.disabled||e.listboxState===1?e:{...e,activeOptionIndex:null,listboxState:1,__demoMode:!1}},[0](e){if(e.dataRef.current.disabled||e.listboxState===0)return e;let l=e.activeOptionIndex,{isSelected:o}=e.dataRef.current,i=e.options.findIndex(p=>o(p.dataRef.current.value));return i!==-1&&(l=i),{...e,listboxState:0,activeOptionIndex:l,__demoMode:!1}},[2](e,l){var T,O,n,a,t;if(e.dataRef.current.disabled||e.listboxState===1)return e;let o={...e,searchQuery:"",activationTrigger:(T=l.trigger)!=null?T:1,__demoMode:!1};if(l.focus===m.Nothing)return{...o,activeOptionIndex:null};if(l.focus===m.Specific)return{...o,activeOptionIndex:e.options.findIndex(r=>r.id===l.id)};if(l.focus===m.Previous){let r=e.activeOptionIndex;if(r!==null){let R=e.options[r].dataRef.current.domRef,c=ae(l,{resolveItems:()=>e.options,resolveActiveIndex:()=>e.activeOptionIndex,resolveId:d=>d.id,resolveDisabled:d=>d.dataRef.current.disabled});if(c!==null){let d=e.options[c].dataRef.current.domRef;if(((O=R.current)==null?void 0:O.previousElementSibling)===d.current||((n=d.current)==null?void 0:n.previousElementSibling)===null)return{...o,activeOptionIndex:c}}}}else if(l.focus===m.Next){let r=e.activeOptionIndex;if(r!==null){let R=e.options[r].dataRef.current.domRef,c=ae(l,{resolveItems:()=>e.options,resolveActiveIndex:()=>e.activeOptionIndex,resolveId:d=>d.id,resolveDisabled:d=>d.dataRef.current.disabled});if(c!==null){let d=e.options[c].dataRef.current.domRef;if(((a=R.current)==null?void 0:a.nextElementSibling)===d.current||((t=d.current)==null?void 0:t.nextElementSibling)===null)return{...o,activeOptionIndex:c}}}}let i=pe(e),p=ae(l,{resolveItems:()=>i.options,resolveActiveIndex:()=>i.activeOptionIndex,resolveId:r=>r.id,resolveDisabled:r=>r.dataRef.current.disabled});return{...o,...i,activeOptionIndex:p}},[3]:(e,l)=>{if(e.dataRef.current.disabled||e.listboxState===1)return e;let i=e.searchQuery!==""?0:1,p=e.searchQuery+l.value.toLowerCase(),O=(e.activeOptionIndex!==null?e.options.slice(e.activeOptionIndex+i).concat(e.options.slice(0,e.activeOptionIndex+i)):e.options).find(a=>{var t;return!a.dataRef.current.disabled&&((t=a.dataRef.current.textValue)==null?void 0:t.startsWith(p))}),n=O?e.options.indexOf(O):-1;return n===-1||n===e.activeOptionIndex?{...e,searchQuery:p}:{...e,searchQuery:p,activeOptionIndex:n,activationTrigger:1}},[4](e){return e.dataRef.current.disabled||e.listboxState===1||e.searchQuery===""?e:{...e,searchQuery:""}},[5]:(e,l)=>{let o={id:l.id,dataRef:l.dataRef},i=pe(e,p=>[...p,o]);return e.activeOptionIndex===null&&e.dataRef.current.isSelected(l.dataRef.current.value)&&(i.activeOptionIndex=i.options.indexOf(o)),{...e,...i}},[6]:(e,l)=>{let o=pe(e,i=>{let p=i.findIndex(T=>T.id===l.id);return p!==-1&&i.splice(p,1),i});return{...e,...o,activationTrigger:1}}},ue=ne(null);ue.displayName="ListboxActionsContext";function q(e){let l=ie(ue);if(l===null){let o=new Error(`<${e} /> is missing a parent <Listbox /> component.`);throw Error.captureStackTrace&&Error.captureStackTrace(o,q),o}return l}let Y=ne(null);Y.displayName="ListboxDataContext";function W(e){let l=ie(Y);if(l===null){let o=new Error(`<${e} /> is missing a parent <Listbox /> component.`);throw Error.captureStackTrace&&Error.captureStackTrace(o,W),o}return l}function vt(e,l){return H(l.type,yt,e,l)}let gt=ce;function Lt(e,l){var de;let o=Qe(),{value:i,defaultValue:p,form:T,name:O,onChange:n,by:a,invalid:t=!1,disabled:r=o||!1,horizontal:R=!1,multiple:c=!1,__demoMode:d=!1,...M}=e;const B=R?"horizontal":"vertical";let h=K(l),_=we(p),[S=c?[]:void 0,y]=Me(i,n,_),[I,v]=De(vt,{dataRef:he(),listboxState:d?0:1,options:[],searchQuery:"",activeOptionIndex:null,activationTrigger:1,optionsVisible:!1,__demoMode:d}),k=V({static:!1,hold:!1}),w=V(null),x=V(null),A=V(new Map),E=Ce(a),N=fe(b=>H(u.mode,{[1]:()=>S.some(g=>E(g,b)),[0]:()=>E(S,b)}),[S]),u=U(()=>({...I,value:S,disabled:r,invalid:t,mode:c?1:0,orientation:B,compare:E,isSelected:N,optionsPropsRef:k,buttonRef:w,optionsRef:x,listRef:A}),[S,r,t,c,I,A]);le(()=>{I.dataRef.current=u},[u]);let G=u.listboxState===0;Ve(G,[u.buttonRef,u.optionsRef],(b,g)=>{var C;v({type:1}),lt(g,rt.Loose)||(b.preventDefault(),(C=u.buttonRef.current)==null||C.focus())});let Z=U(()=>({open:u.listboxState===0,disabled:r,invalid:t,value:S}),[u,r,S,t]),Q=f(b=>{let g=u.options.find(C=>C.id===b);g&&oe(g.dataRef.current.value)}),ee=f(()=>{if(u.activeOptionIndex!==null){let{dataRef:b,id:g}=u.options[u.activeOptionIndex];oe(b.current.value),v({type:2,focus:m.Specific,id:g})}}),te=f(()=>v({type:0})),X=f(()=>v({type:1})),s=J(),P=f((b,g,C)=>{s.dispose(),s.microTask(()=>b===m.Specific?v({type:2,focus:m.Specific,id:g,trigger:C}):v({type:2,focus:b,trigger:C}))}),F=f((b,g)=>(v({type:5,id:b,dataRef:g}),()=>v({type:6,id:b}))),oe=f(b=>H(u.mode,{[0](){return y==null?void 0:y(b)},[1](){let g=u.value.slice(),C=g.findIndex(Pe=>E(Pe,b));return C===-1?g.push(b):g.splice(C,1),y==null?void 0:y(g)}})),Oe=f(b=>v({type:3,value:b})),ye=f(()=>v({type:4})),ve=U(()=>({onChange:oe,registerOption:F,goToOption:P,closeListbox:X,openListbox:te,selectActiveOption:ee,selectOption:Q,search:Oe,clearSearch:ye}),[]),[ge,Le]=ft({inherit:!0}),Se={ref:h},Re=fe(()=>{if(_!==void 0)return y==null?void 0:y(_)},[y,_]);return D.createElement(Le,{value:ge,props:{htmlFor:(de=u.buttonRef.current)==null?void 0:de.id},slot:{open:u.listboxState===0,disabled:r}},D.createElement(Xe,null,D.createElement(ue.Provider,{value:ve},D.createElement(Y.Provider,{value:u},D.createElement(ot,{value:H(u.listboxState,{[0]:$.Open,[1]:$.Closed})},O!=null&&S!=null&&D.createElement(et,{disabled:r,data:{[O]:S},form:T,onReset:Re}),z({ourProps:Se,theirProps:M,slot:Z,defaultTag:gt,name:"Listbox"}))))))}let St="button";function Rt(e,l){var N;let o=W("Listbox.Button"),i=q("Listbox.Button"),p=re(),T=tt(),{id:O=T||`headlessui-listbox-button-${p}`,disabled:n=o.disabled||!1,autoFocus:a=!1,...t}=e,r=K(o.buttonRef,l,qe()),R=Ye(),c=J(),d=f(u=>{switch(u.key){case L.Enter:st(u.currentTarget);break;case L.Space:case L.ArrowDown:u.preventDefault(),i.openListbox(),c.nextFrame(()=>{o.value||i.goToOption(m.First)});break;case L.ArrowUp:u.preventDefault(),i.openListbox(),c.nextFrame(()=>{o.value||i.goToOption(m.Last)});break}}),M=f(u=>{switch(u.key){case L.Space:u.preventDefault();break}}),B=f(u=>{if(it(u.currentTarget))return u.preventDefault();o.listboxState===0?(i.closeListbox(),c.nextFrame(()=>{var G;return(G=o.buttonRef.current)==null?void 0:G.focus({preventScroll:!0})})):(u.preventDefault(),i.openListbox())}),h=f(u=>u.preventDefault()),_=ct([O]),S=ut(),{isFocusVisible:y,focusProps:I}=Ae({autoFocus:a}),{isHovered:v,hoverProps:k}=Ee({isDisabled:n}),{pressed:w,pressProps:x}=Ie({disabled:n}),A=U(()=>({open:o.listboxState===0,active:w||o.listboxState===0,disabled:n,invalid:o.invalid,value:o.value,hover:v,focus:y,autofocus:a}),[o.listboxState,o.value,n,v,y,w,o.invalid,a]),E=xe(R(),{ref:r,id:O,type:Ke(e,o.buttonRef),"aria-haspopup":"listbox","aria-controls":(N=o.optionsRef.current)==null?void 0:N.id,"aria-expanded":o.listboxState===0,"aria-labelledby":_,"aria-describedby":S,disabled:n||void 0,autoFocus:a,onKeyDown:d,onKeyUp:M,onKeyPress:h,onClick:B},I,k,x);return z({ourProps:E,theirProps:t,slot:A,defaultTag:St,name:"Listbox.Button"})}let me=ne(!1),Pt="div",At=Te.RenderStrategy|Te.Static;function Et(e,l){var X;let o=re(),{id:i=`headlessui-listbox-options-${o}`,anchor:p,portal:T=!1,modal:O=!0,...n}=e,a=Ze(p);a&&(T=!0);let t=W("Listbox.Options"),r=q("Listbox.Options"),R=He(t.optionsRef),c=nt(),d=(()=>c!==null?(c&$.Open)===$.Open:t.listboxState===0)();Ge(d,t.buttonRef,r.closeListbox);let M=t.__demoMode?!1:O&&t.listboxState===0;je(M,R);let B=t.__demoMode?!1:O&&t.listboxState===0;Ue(B,{allowed:f(()=>[t.buttonRef.current,t.optionsRef.current])});let h=V(null);be(()=>{var P;if(!((P=a==null?void 0:a.to)!=null&&P.includes("selection")))return;if(!d){h.current=null;return}let s=Array.from(t.listRef.current.values());h.current=s.findIndex(F=>(F==null?void 0:F.dataset.selected)===""),h.current===-1&&(h.current=s.findIndex(F=>(F==null?void 0:F.dataset.disabled)===void 0),r.goToOption(m.First))},[d,t.listRef]);let _=t.listboxState!==0,y=Be(_,t.buttonRef)?!1:d,I=(()=>{if(a==null)return;if(t.listRef.current.size<=0)return{...a,inner:void 0};let s=Array.from(t.listRef.current.values());return{...a,inner:{listRef:{current:s},index:h.current}}})(),[v,k]=Je(I),w=$e(),x=K(t.optionsRef,l,a?v:null),A=J(),E=J();be(()=>{var P;let s=t.optionsRef.current;s&&t.listboxState===0&&s!==((P=pt(s))==null?void 0:P.activeElement)&&(s==null||s.focus({preventScroll:!0}))},[t.listboxState,t.optionsRef,t.optionsRef.current]);let N=f(s=>{switch(E.dispose(),s.key){case L.Space:if(t.searchQuery!=="")return s.preventDefault(),s.stopPropagation(),r.search(s.key);case L.Enter:if(s.preventDefault(),s.stopPropagation(),t.activeOptionIndex!==null){let{dataRef:P}=t.options[t.activeOptionIndex];r.onChange(P.current.value)}t.mode===0&&(r.closeListbox(),se().nextFrame(()=>{var P;return(P=t.buttonRef.current)==null?void 0:P.focus({preventScroll:!0})}));break;case H(t.orientation,{vertical:L.ArrowDown,horizontal:L.ArrowRight}):return s.preventDefault(),s.stopPropagation(),r.goToOption(m.Next);case H(t.orientation,{vertical:L.ArrowUp,horizontal:L.ArrowLeft}):return s.preventDefault(),s.stopPropagation(),r.goToOption(m.Previous);case L.Home:case L.PageUp:return s.preventDefault(),s.stopPropagation(),r.goToOption(m.First);case L.End:case L.PageDown:return s.preventDefault(),s.stopPropagation(),r.goToOption(m.Last);case L.Escape:return s.preventDefault(),s.stopPropagation(),r.closeListbox(),A.nextFrame(()=>{var P;return(P=t.buttonRef.current)==null?void 0:P.focus({preventScroll:!0})});case L.Tab:s.preventDefault(),s.stopPropagation();break;default:s.key.length===1&&(r.search(s.key),E.setTimeout(()=>r.clearSearch(),350));break}}),u=Fe(()=>{var s;return(s=t.buttonRef.current)==null?void 0:s.id},[t.buttonRef.current]),G=U(()=>({open:t.listboxState===0}),[t]),Z=xe(a?w():{},{id:i,ref:x,"aria-activedescendant":t.activeOptionIndex===null||(X=t.options[t.activeOptionIndex])==null?void 0:X.id,"aria-multiselectable":t.mode===1?!0:void 0,"aria-labelledby":u,"aria-orientation":t.orientation,onKeyDown:N,role:"listbox",tabIndex:0,style:{...n.style,...k,"--button-width":ke(t.buttonRef,!0).width}}),[Q,ee]=_e(t.value);t.value!==Q&&t.listboxState===0&&t.mode!==1&&ee(t.value);let te=f(s=>t.compare(Q,s));return D.createElement(bt,{enabled:T?e.static||d:!1},D.createElement(Y.Provider,{value:t.mode===1?t:{...t,isSelected:te}},z({ourProps:Z,theirProps:n,slot:G,defaultTag:Pt,features:At,visible:y,name:"Listbox.Options"})))}let ht="div";function Dt(e,l){let o=re(),{id:i=`headlessui-listbox-option-${o}`,disabled:p=!1,value:T,...O}=e,n=ie(me)===!0,a=W("Listbox.Option"),t=q("Listbox.Option"),r=a.activeOptionIndex!==null?a.options[a.activeOptionIndex].id===i:!1,R=a.isSelected(T),c=V(null),d=ze(c),M=Ne({disabled:p,value:T,domRef:c,get textValue(){return d()}}),B=K(l,c,x=>{x?a.listRef.current.set(i,x):a.listRef.current.delete(i)});le(()=>{if(a.__demoMode||a.listboxState!==0||!r||a.activationTrigger===0)return;let x=se();return x.requestAnimationFrame(()=>{var A,E;(E=(A=c.current)==null?void 0:A.scrollIntoView)==null||E.call(A,{block:"nearest"})}),x.dispose},[c,r,a.__demoMode,a.listboxState,a.activationTrigger,a.activeOptionIndex]),le(()=>{if(!n)return t.registerOption(i,M)},[M,i,n]);let h=f(x=>{if(p)return x.preventDefault();t.onChange(T),a.mode===0&&(t.closeListbox(),se().nextFrame(()=>{var A;return(A=a.buttonRef.current)==null?void 0:A.focus({preventScroll:!0})}))}),_=f(()=>{if(p)return t.goToOption(m.Nothing);t.goToOption(m.Specific,i)}),S=We(),y=f(x=>{S.update(x),!p&&(r||t.goToOption(m.Specific,i,0))}),I=f(x=>{S.wasMoved(x)&&(p||r||t.goToOption(m.Specific,i,0))}),v=f(x=>{S.wasMoved(x)&&(p||r&&t.goToOption(m.Nothing))}),k=U(()=>({active:r,focus:r,selected:R,disabled:p,selectedOption:R&&n}),[r,R,p,n]),w=n?{}:{id:i,ref:B,role:"option",tabIndex:p===!0?void 0:-1,"aria-disabled":p===!0?!0:void 0,"aria-selected":R,disabled:void 0,onClick:h,onFocus:_,onPointerEnter:y,onMouseEnter:y,onPointerMove:I,onMouseMove:I,onPointerLeave:v,onMouseLeave:v};return!R&&n?null:z({ourProps:w,theirProps:O,slot:k,defaultTag:ht,name:"Listbox.Option"})}let _t=ce;function It(e,l){let{options:o,placeholder:i,...p}=e,O={ref:K(l)},n=W("ListboxSelectedOption"),a=U(()=>({}),[]),t=n.value===void 0||n.value===null||n.mode===1&&Array.isArray(n.value)&&n.value.length===0;return D.createElement(me.Provider,{value:!0},z({ourProps:O,theirProps:{...p,children:D.createElement(D.Fragment,null,i&&t?i:o)},slot:a,defaultTag:_t,name:"ListboxSelectedOption"}))}let Ct=j(Lt),Ft=j(Rt),Mt=dt,wt=j(Et),Bt=j(Dt),kt=j(It),Ao=Object.assign(Ct,{Button:Ft,Label:Mt,Options:wt,Option:Bt,SelectedOption:kt});export{Ao as Listbox,Ft as ListboxButton,Mt as ListboxLabel,Bt as ListboxOption,wt as ListboxOptions,kt as ListboxSelectedOption};

@@ -1,1 +0,1 @@

"use client";import{useFocusRing as re}from"@react-aria/focus";import{useHover as oe}from"@react-aria/interactions";import R,{Fragment as V,createContext as ae,createRef as X,useContext as ie,useEffect as se,useMemo as U,useReducer as le,useRef as $}from"react";import{useActivePress as ue}from'../../hooks/use-active-press.js';import{useDidElementMove as pe}from'../../hooks/use-did-element-move.js';import{useDisposables as q}from'../../hooks/use-disposables.js';import{useElementSize as de}from'../../hooks/use-element-size.js';import{useEvent as A}from'../../hooks/use-event.js';import{useId as H}from'../../hooks/use-id.js';import{useInertOthers as me}from'../../hooks/use-inert-others.js';import{useIsoMorphicEffect as N}from'../../hooks/use-iso-morphic-effect.js';import{useOnDisappear as ce}from'../../hooks/use-on-disappear.js';import{useOutsideClick as fe}from'../../hooks/use-outside-click.js';import{useOwnerDocument as Te}from'../../hooks/use-owner.js';import{useResolveButtonType as ye}from'../../hooks/use-resolve-button-type.js';import{useScrollLock as ge}from'../../hooks/use-scroll-lock.js';import{useSyncRefs as B}from'../../hooks/use-sync-refs.js';import{useTextValue as Ie}from'../../hooks/use-text-value.js';import{useTrackedPointer as Me}from'../../hooks/use-tracked-pointer.js';import{useTreeWalker as Ae}from'../../hooks/use-tree-walker.js';import{FloatingProvider as Pe,useFloatingPanel as Se,useFloatingPanelProps as be,useFloatingReference as Ee,useFloatingReferenceProps as Re,useResolvedAnchor as xe}from'../../internal/floating.js';import{OpenClosedProvider as ve,State as k,useOpenClosed as _e}from'../../internal/open-closed.js';import{isDisabledReactIssue7711 as De}from'../../utils/bugs.js';import{Focus as y,calculateActiveIndex as K}from'../../utils/calculate-active-index.js';import{disposables as W}from'../../utils/disposables.js';import{Focus as z,FocusableMode as he,focusFrom as Fe,isFocusableElement as Ce,restoreFocusIfNecessary as Y,sortByDomNode as Oe}from'../../utils/focus-management.js';import{match as Z}from'../../utils/match.js';import{RenderFeatures as ee,forwardRefWithAs as x,mergeProps as te,render as v}from'../../utils/render.js';import{useDescriptions as Le}from'../description/description.js';import{Keys as T}from'../keyboard.js';import{useLabelContext as Ge,useLabels as ne}from'../label/label.js';import{Portal as Ue}from'../portal/portal.js';var He=(r=>(r[r.Open=0]="Open",r[r.Closed=1]="Closed",r))(He||{}),Ne=(r=>(r[r.Pointer=0]="Pointer",r[r.Other=1]="Other",r))(Ne||{}),Be=(n=>(n[n.OpenMenu=0]="OpenMenu",n[n.CloseMenu=1]="CloseMenu",n[n.GoToItem=2]="GoToItem",n[n.Search=3]="Search",n[n.ClearSearch=4]="ClearSearch",n[n.RegisterItem=5]="RegisterItem",n[n.UnregisterItem=6]="UnregisterItem",n))(Be||{});function j(e,a=r=>r){let r=e.activeItemIndex!==null?e.items[e.activeItemIndex]:null,s=Oe(a(e.items.slice()),p=>p.dataRef.current.domRef.current),o=r?s.indexOf(r):null;return o===-1&&(o=null),{items:s,activeItemIndex:o}}let ke={[1](e){return e.menuState===1?e:{...e,activeItemIndex:null,menuState:1}},[0](e){return e.menuState===0?e:{...e,__demoMode:!1,menuState:0}},[2]:(e,a)=>{var p,d,n,u,t;if(e.menuState===1)return e;let r={...e,searchQuery:"",activationTrigger:(p=a.trigger)!=null?p:1,__demoMode:!1};if(a.focus===y.Nothing)return{...r,activeItemIndex:null};if(a.focus===y.Specific)return{...r,activeItemIndex:e.items.findIndex(l=>l.id===a.id)};if(a.focus===y.Previous){let l=e.activeItemIndex;if(l!==null){let g=e.items[l].dataRef.current.domRef,c=K(a,{resolveItems:()=>e.items,resolveActiveIndex:()=>e.activeItemIndex,resolveId:m=>m.id,resolveDisabled:m=>m.dataRef.current.disabled});if(c!==null){let m=e.items[c].dataRef.current.domRef;if(((d=g.current)==null?void 0:d.previousElementSibling)===m.current||((n=m.current)==null?void 0:n.previousElementSibling)===null)return{...r,activeItemIndex:c}}}}else if(a.focus===y.Next){let l=e.activeItemIndex;if(l!==null){let g=e.items[l].dataRef.current.domRef,c=K(a,{resolveItems:()=>e.items,resolveActiveIndex:()=>e.activeItemIndex,resolveId:m=>m.id,resolveDisabled:m=>m.dataRef.current.disabled});if(c!==null){let m=e.items[c].dataRef.current.domRef;if(((u=g.current)==null?void 0:u.nextElementSibling)===m.current||((t=m.current)==null?void 0:t.nextElementSibling)===null)return{...r,activeItemIndex:c}}}}let s=j(e),o=K(a,{resolveItems:()=>s.items,resolveActiveIndex:()=>s.activeItemIndex,resolveId:l=>l.id,resolveDisabled:l=>l.dataRef.current.disabled});return{...r,...s,activeItemIndex:o}},[3]:(e,a)=>{let s=e.searchQuery!==""?0:1,o=e.searchQuery+a.value.toLowerCase(),d=(e.activeItemIndex!==null?e.items.slice(e.activeItemIndex+s).concat(e.items.slice(0,e.activeItemIndex+s)):e.items).find(u=>{var t;return((t=u.dataRef.current.textValue)==null?void 0:t.startsWith(o))&&!u.dataRef.current.disabled}),n=d?e.items.indexOf(d):-1;return n===-1||n===e.activeItemIndex?{...e,searchQuery:o}:{...e,searchQuery:o,activeItemIndex:n,activationTrigger:1}},[4](e){return e.searchQuery===""?e:{...e,searchQuery:"",searchActiveItemIndex:null}},[5]:(e,a)=>{let r=j(e,s=>[...s,{id:a.id,dataRef:a.dataRef}]);return{...e,...r}},[6]:(e,a)=>{let r=j(e,s=>{let o=s.findIndex(p=>p.id===a.id);return o!==-1&&s.splice(o,1),s});return{...e,...r,activationTrigger:1}}},Q=ae(null);Q.displayName="MenuContext";function w(e){let a=ie(Q);if(a===null){let r=new Error(`<${e} /> is missing a parent <Menu /> component.`);throw Error.captureStackTrace&&Error.captureStackTrace(r,w),r}return a}function we(e,a){return Z(a.type,ke,e,a)}let Ke=V;function We(e,a){let{__demoMode:r=!1,...s}=e,o=le(we,{__demoMode:r,menuState:r?0:1,buttonRef:X(),itemsRef:X(),items:[],searchQuery:"",activeItemIndex:null,activationTrigger:1}),[{menuState:p,itemsRef:d,buttonRef:n},u]=o,t=B(a);fe([n,d],(m,E)=>{var I;u({type:1}),Ce(E,he.Loose)||(m.preventDefault(),(I=n.current)==null||I.focus())},p===0);let l=A(()=>{u({type:1})}),g=U(()=>({open:p===0,close:l}),[p,l]),c={ref:t};return R.createElement(Pe,null,R.createElement(Q.Provider,{value:o},R.createElement(ve,{value:Z(p,{[0]:k.Open,[1]:k.Closed})},v({ourProps:c,theirProps:s,slot:g,defaultTag:Ke,name:"Menu"}))))}let je="button";function Qe(e,a){var D;let r=H(),{id:s=`headlessui-menu-button-${r}`,disabled:o=!1,autoFocus:p=!1,...d}=e,[n,u]=w("Menu.Button"),t=Re(),l=B(n.buttonRef,a,Ee()),g=q(),c=A(f=>{switch(f.key){case T.Space:case T.Enter:case T.ArrowDown:f.preventDefault(),f.stopPropagation(),u({type:0}),g.nextFrame(()=>u({type:2,focus:y.First}));break;case T.ArrowUp:f.preventDefault(),f.stopPropagation(),u({type:0}),g.nextFrame(()=>u({type:2,focus:y.Last}));break}}),m=A(f=>{switch(f.key){case T.Space:f.preventDefault();break}}),E=A(f=>{if(De(f.currentTarget))return f.preventDefault();o||(n.menuState===0?(u({type:1}),g.nextFrame(()=>{var h;return(h=n.buttonRef.current)==null?void 0:h.focus({preventScroll:!0})})):(f.preventDefault(),u({type:0})))}),{isFocusVisible:I,focusProps:P}=re({autoFocus:p}),{isHovered:S,hoverProps:b}=oe({isDisabled:o}),{pressed:_,pressProps:F}=ue({disabled:o}),C=U(()=>({open:n.menuState===0,active:_||n.menuState===0,disabled:o,hover:S,focus:I,autofocus:p}),[n,S,I,_,o,p]),O=te(t(),{ref:l,id:s,type:ye(e,n.buttonRef),"aria-haspopup":"menu","aria-controls":(D=n.itemsRef.current)==null?void 0:D.id,"aria-expanded":n.menuState===0,disabled:o||void 0,autoFocus:p,onKeyDown:c,onKeyUp:m,onClick:E},P,b,F);return v({ourProps:O,theirProps:d,slot:C,defaultTag:je,name:"Menu.Button"})}let Je="div",Ve=ee.RenderStrategy|ee.Static;function Xe(e,a){var h,M;let r=H(),{id:s=`headlessui-menu-items-${r}`,anchor:o,portal:p=!1,modal:d=!0,...n}=e,u=xe(o),[t,l]=w("Menu.Items"),[g,c]=Se(u),m=be(),E=B(t.itemsRef,a,u?g:null),I=Te(t.itemsRef);u&&(p=!0);let P=q(),S=_e(),b=(()=>S!==null?(S&k.Open)===k.Open:t.menuState===0)();ce(t.buttonRef,()=>l({type:1}),b),ge(I,t.__demoMode?!1:d&&t.menuState===0),me({allowed:A(()=>[t.buttonRef.current,t.itemsRef.current])},t.__demoMode?!1:d&&t.menuState===0);let F=pe(t.buttonRef,t.menuState!==0)?!1:b;se(()=>{let i=t.itemsRef.current;i&&t.menuState===0&&i!==(I==null?void 0:I.activeElement)&&i.focus({preventScroll:!0})},[t.menuState,t.itemsRef,I,t.itemsRef.current]),Ae({container:t.itemsRef.current,enabled:t.menuState===0,accept(i){return i.getAttribute("role")==="menuitem"?NodeFilter.FILTER_REJECT:i.hasAttribute("role")?NodeFilter.FILTER_SKIP:NodeFilter.FILTER_ACCEPT},walk(i){i.setAttribute("role","none")}});let C=A(i=>{var L,J;switch(P.dispose(),i.key){case T.Space:if(t.searchQuery!=="")return i.preventDefault(),i.stopPropagation(),l({type:3,value:i.key});case T.Enter:if(i.preventDefault(),i.stopPropagation(),l({type:1}),t.activeItemIndex!==null){let{dataRef:G}=t.items[t.activeItemIndex];(J=(L=G.current)==null?void 0:L.domRef.current)==null||J.click()}Y(t.buttonRef.current);break;case T.ArrowDown:return i.preventDefault(),i.stopPropagation(),l({type:2,focus:y.Next});case T.ArrowUp:return i.preventDefault(),i.stopPropagation(),l({type:2,focus:y.Previous});case T.Home:case T.PageUp:return i.preventDefault(),i.stopPropagation(),l({type:2,focus:y.First});case T.End:case T.PageDown:return i.preventDefault(),i.stopPropagation(),l({type:2,focus:y.Last});case T.Escape:i.preventDefault(),i.stopPropagation(),l({type:1}),W().nextFrame(()=>{var G;return(G=t.buttonRef.current)==null?void 0:G.focus({preventScroll:!0})});break;case T.Tab:i.preventDefault(),i.stopPropagation(),l({type:1}),W().microTask(()=>{Fe(t.buttonRef.current,i.shiftKey?z.Previous:z.Next)});break;default:i.key.length===1&&(l({type:3,value:i.key}),P.setTimeout(()=>l({type:4}),350));break}}),O=A(i=>{switch(i.key){case T.Space:i.preventDefault();break}}),D=U(()=>({open:t.menuState===0}),[t]),f=te(u?m():{},{"aria-activedescendant":t.activeItemIndex===null||(h=t.items[t.activeItemIndex])==null?void 0:h.id,"aria-labelledby":(M=t.buttonRef.current)==null?void 0:M.id,id:s,onKeyDown:C,onKeyUp:O,role:"menu",tabIndex:0,ref:E,style:{...c,"--button-width":de(t.buttonRef,!0).width}});return R.createElement(Ue,{enabled:p?e.static||b:!1},v({ourProps:f,theirProps:n,slot:D,defaultTag:Je,features:Ve,visible:F,name:"Menu.Items"}))}let $e=V;function qe(e,a){let r=H(),{id:s=`headlessui-menu-item-${r}`,disabled:o=!1,...p}=e,[d,n]=w("Menu.Item"),u=d.activeItemIndex!==null?d.items[d.activeItemIndex].id===s:!1,t=$(null),l=B(a,t);N(()=>{if(d.__demoMode||d.menuState!==0||!u||d.activationTrigger===0)return;let M=W();return M.requestAnimationFrame(()=>{var i,L;(L=(i=t.current)==null?void 0:i.scrollIntoView)==null||L.call(i,{block:"nearest"})}),M.dispose},[d.__demoMode,t,u,d.menuState,d.activationTrigger,d.activeItemIndex]);let g=Ie(t),c=$({disabled:o,domRef:t,get textValue(){return g()}});N(()=>{c.current.disabled=o},[c,o]),N(()=>(n({type:5,id:s,dataRef:c}),()=>n({type:6,id:s})),[c,s]);let m=A(()=>{n({type:1})}),E=A(M=>{if(o)return M.preventDefault();n({type:1}),Y(d.buttonRef.current)}),I=A(()=>{if(o)return n({type:2,focus:y.Nothing});n({type:2,focus:y.Specific,id:s})}),P=Me(),S=A(M=>{P.update(M),!o&&(u||n({type:2,focus:y.Specific,id:s,trigger:0}))}),b=A(M=>{P.wasMoved(M)&&(o||u||n({type:2,focus:y.Specific,id:s,trigger:0}))}),_=A(M=>{P.wasMoved(M)&&(o||u&&n({type:2,focus:y.Nothing}))}),[F,C]=ne(),[O,D]=Le(),f=U(()=>({active:u,focus:u,disabled:o,close:m}),[u,o,m]);return R.createElement(C,null,R.createElement(D,null,v({ourProps:{id:s,ref:l,role:"menuitem",tabIndex:o===!0?void 0:-1,"aria-disabled":o===!0?!0:void 0,"aria-labelledby":F,"aria-describedby":O,disabled:void 0,onClick:E,onFocus:I,onPointerEnter:S,onMouseEnter:S,onPointerMove:b,onMouseMove:b,onPointerLeave:_,onMouseLeave:_},theirProps:p,slot:f,defaultTag:$e,name:"Menu.Item"})))}let ze="div";function Ye(e,a){let[r,s]=ne();return R.createElement(s,null,v({ourProps:{ref:a,"aria-labelledby":r,role:"group"},theirProps:e,slot:{},defaultTag:ze,name:"Menu.Section"}))}let Ze="header";function et(e,a){let r=H(),{id:s=`headlessui-menu-heading-${r}`,...o}=e,p=Ge();N(()=>p.register(s),[s,p.register]);let d={id:s,ref:a,role:"presentation",...p.props};return v({ourProps:d,theirProps:o,slot:{},defaultTag:Ze,name:"Menu.Heading"})}let tt="div";function nt(e,a){return v({ourProps:{ref:a,role:"separator"},theirProps:e,slot:{},defaultTag:tt,name:"Menu.Separator"})}let rt=x(We),ot=x(Qe),at=x(Xe),it=x(qe),st=x(Ye),lt=x(et),ut=x(nt),Kt=Object.assign(rt,{Button:ot,Items:at,Item:it,Section:st,Heading:lt,Separator:ut});export{Kt as Menu,ot as MenuButton,lt as MenuHeading,it as MenuItem,at as MenuItems,st as MenuSection,ut as MenuSeparator};
"use client";import{useFocusRing as ie}from"@react-aria/focus";import{useHover as se}from"@react-aria/interactions";import x,{Fragment as q,createContext as le,createRef as z,useContext as ue,useEffect as pe,useMemo as H,useReducer as de,useRef as Y}from"react";import{useActivePress as me}from'../../hooks/use-active-press.js';import{useDidElementMove as ce}from'../../hooks/use-did-element-move.js';import{useDisposables as Z}from'../../hooks/use-disposables.js';import{useElementSize as fe}from'../../hooks/use-element-size.js';import{useEvent as I}from'../../hooks/use-event.js';import{useId as N}from'../../hooks/use-id.js';import{useInertOthers as Te}from'../../hooks/use-inert-others.js';import{useIsoMorphicEffect as k}from'../../hooks/use-iso-morphic-effect.js';import{useOnDisappear as ye}from'../../hooks/use-on-disappear.js';import{useOutsideClick as ge}from'../../hooks/use-outside-click.js';import{useOwnerDocument as Ie}from'../../hooks/use-owner.js';import{useResolveButtonType as Me}from'../../hooks/use-resolve-button-type.js';import{useScrollLock as Ae}from'../../hooks/use-scroll-lock.js';import{useSyncRefs as B}from'../../hooks/use-sync-refs.js';import{useTextValue as Pe}from'../../hooks/use-text-value.js';import{useTrackedPointer as be}from'../../hooks/use-tracked-pointer.js';import{useTreeWalker as Se}from'../../hooks/use-tree-walker.js';import{FloatingProvider as Ee,useFloatingPanel as Re,useFloatingPanelProps as xe,useFloatingReference as ve,useFloatingReferenceProps as _e,useResolvedAnchor as De}from'../../internal/floating.js';import{OpenClosedProvider as he,State as w,useOpenClosed as Fe}from'../../internal/open-closed.js';import{isDisabledReactIssue7711 as Ce}from'../../utils/bugs.js';import{Focus as y,calculateActiveIndex as W}from'../../utils/calculate-active-index.js';import{disposables as j}from'../../utils/disposables.js';import{Focus as ee,FocusableMode as Oe,focusFrom as Le,isFocusableElement as Ge,restoreFocusIfNecessary as te,sortByDomNode as Ue}from'../../utils/focus-management.js';import{match as ne}from'../../utils/match.js';import{RenderFeatures as re,forwardRefWithAs as v,mergeProps as oe,render as _}from'../../utils/render.js';import{useDescriptions as He}from'../description/description.js';import{Keys as T}from'../keyboard.js';import{useLabelContext as Ne,useLabels as ae}from'../label/label.js';import{Portal as ke}from'../portal/portal.js';var Be=(r=>(r[r.Open=0]="Open",r[r.Closed=1]="Closed",r))(Be||{}),we=(r=>(r[r.Pointer=0]="Pointer",r[r.Other=1]="Other",r))(we||{}),Ke=(n=>(n[n.OpenMenu=0]="OpenMenu",n[n.CloseMenu=1]="CloseMenu",n[n.GoToItem=2]="GoToItem",n[n.Search=3]="Search",n[n.ClearSearch=4]="ClearSearch",n[n.RegisterItem=5]="RegisterItem",n[n.UnregisterItem=6]="UnregisterItem",n))(Ke||{});function Q(e,a=r=>r){let r=e.activeItemIndex!==null?e.items[e.activeItemIndex]:null,i=Ue(a(e.items.slice()),p=>p.dataRef.current.domRef.current),o=r?i.indexOf(r):null;return o===-1&&(o=null),{items:i,activeItemIndex:o}}let We={[1](e){return e.menuState===1?e:{...e,activeItemIndex:null,menuState:1}},[0](e){return e.menuState===0?e:{...e,__demoMode:!1,menuState:0}},[2]:(e,a)=>{var p,d,n,l,t;if(e.menuState===1)return e;let r={...e,searchQuery:"",activationTrigger:(p=a.trigger)!=null?p:1,__demoMode:!1};if(a.focus===y.Nothing)return{...r,activeItemIndex:null};if(a.focus===y.Specific)return{...r,activeItemIndex:e.items.findIndex(u=>u.id===a.id)};if(a.focus===y.Previous){let u=e.activeItemIndex;if(u!==null){let g=e.items[u].dataRef.current.domRef,c=W(a,{resolveItems:()=>e.items,resolveActiveIndex:()=>e.activeItemIndex,resolveId:m=>m.id,resolveDisabled:m=>m.dataRef.current.disabled});if(c!==null){let m=e.items[c].dataRef.current.domRef;if(((d=g.current)==null?void 0:d.previousElementSibling)===m.current||((n=m.current)==null?void 0:n.previousElementSibling)===null)return{...r,activeItemIndex:c}}}}else if(a.focus===y.Next){let u=e.activeItemIndex;if(u!==null){let g=e.items[u].dataRef.current.domRef,c=W(a,{resolveItems:()=>e.items,resolveActiveIndex:()=>e.activeItemIndex,resolveId:m=>m.id,resolveDisabled:m=>m.dataRef.current.disabled});if(c!==null){let m=e.items[c].dataRef.current.domRef;if(((l=g.current)==null?void 0:l.nextElementSibling)===m.current||((t=m.current)==null?void 0:t.nextElementSibling)===null)return{...r,activeItemIndex:c}}}}let i=Q(e),o=W(a,{resolveItems:()=>i.items,resolveActiveIndex:()=>i.activeItemIndex,resolveId:u=>u.id,resolveDisabled:u=>u.dataRef.current.disabled});return{...r,...i,activeItemIndex:o}},[3]:(e,a)=>{let i=e.searchQuery!==""?0:1,o=e.searchQuery+a.value.toLowerCase(),d=(e.activeItemIndex!==null?e.items.slice(e.activeItemIndex+i).concat(e.items.slice(0,e.activeItemIndex+i)):e.items).find(l=>{var t;return((t=l.dataRef.current.textValue)==null?void 0:t.startsWith(o))&&!l.dataRef.current.disabled}),n=d?e.items.indexOf(d):-1;return n===-1||n===e.activeItemIndex?{...e,searchQuery:o}:{...e,searchQuery:o,activeItemIndex:n,activationTrigger:1}},[4](e){return e.searchQuery===""?e:{...e,searchQuery:"",searchActiveItemIndex:null}},[5]:(e,a)=>{let r=Q(e,i=>[...i,{id:a.id,dataRef:a.dataRef}]);return{...e,...r}},[6]:(e,a)=>{let r=Q(e,i=>{let o=i.findIndex(p=>p.id===a.id);return o!==-1&&i.splice(o,1),i});return{...e,...r,activationTrigger:1}}},J=le(null);J.displayName="MenuContext";function K(e){let a=ue(J);if(a===null){let r=new Error(`<${e} /> is missing a parent <Menu /> component.`);throw Error.captureStackTrace&&Error.captureStackTrace(r,K),r}return a}function je(e,a){return ne(a.type,We,e,a)}let Qe=q;function Je(e,a){let{__demoMode:r=!1,...i}=e,o=de(je,{__demoMode:r,menuState:r?0:1,buttonRef:z(),itemsRef:z(),items:[],searchQuery:"",activeItemIndex:null,activationTrigger:1}),[{menuState:p,itemsRef:d,buttonRef:n},l]=o,t=B(a);ge(p===0,[n,d],(E,M)=>{var P;l({type:1}),Ge(M,Oe.Loose)||(E.preventDefault(),(P=n.current)==null||P.focus())});let g=I(()=>{l({type:1})}),c=H(()=>({open:p===0,close:g}),[p,g]),m={ref:t};return x.createElement(Ee,null,x.createElement(J.Provider,{value:o},x.createElement(he,{value:ne(p,{[0]:w.Open,[1]:w.Closed})},_({ourProps:m,theirProps:i,slot:c,defaultTag:Qe,name:"Menu"}))))}let Ve="button";function Xe(e,a){var D;let r=N(),{id:i=`headlessui-menu-button-${r}`,disabled:o=!1,autoFocus:p=!1,...d}=e,[n,l]=K("Menu.Button"),t=_e(),u=B(n.buttonRef,a,ve()),g=Z(),c=I(f=>{switch(f.key){case T.Space:case T.Enter:case T.ArrowDown:f.preventDefault(),f.stopPropagation(),l({type:0}),g.nextFrame(()=>l({type:2,focus:y.First}));break;case T.ArrowUp:f.preventDefault(),f.stopPropagation(),l({type:0}),g.nextFrame(()=>l({type:2,focus:y.Last}));break}}),m=I(f=>{switch(f.key){case T.Space:f.preventDefault();break}}),E=I(f=>{if(Ce(f.currentTarget))return f.preventDefault();o||(n.menuState===0?(l({type:1}),g.nextFrame(()=>{var O;return(O=n.buttonRef.current)==null?void 0:O.focus({preventScroll:!0})})):(f.preventDefault(),l({type:0})))}),{isFocusVisible:M,focusProps:P}=ie({autoFocus:p}),{isHovered:b,hoverProps:S}=se({isDisabled:o}),{pressed:R,pressProps:F}=me({disabled:o}),C=H(()=>({open:n.menuState===0,active:R||n.menuState===0,disabled:o,hover:b,focus:M,autofocus:p}),[n,b,M,R,o,p]),G=oe(t(),{ref:u,id:i,type:Me(e,n.buttonRef),"aria-haspopup":"menu","aria-controls":(D=n.itemsRef.current)==null?void 0:D.id,"aria-expanded":n.menuState===0,disabled:o||void 0,autoFocus:p,onKeyDown:c,onKeyUp:m,onClick:E},P,S,F);return _({ourProps:G,theirProps:d,slot:C,defaultTag:Ve,name:"Menu.Button"})}let $e="div",qe=re.RenderStrategy|re.Static;function ze(e,a){var L,V;let r=N(),{id:i=`headlessui-menu-items-${r}`,anchor:o,portal:p=!1,modal:d=!0,...n}=e,l=De(o),[t,u]=K("Menu.Items"),[g,c]=Re(l),m=xe(),E=B(t.itemsRef,a,l?g:null),M=Ie(t.itemsRef);l&&(p=!0);let P=Z(),b=Fe(),S=(()=>b!==null?(b&w.Open)===w.Open:t.menuState===0)();ye(S,t.buttonRef,()=>{u({type:1})});let R=t.__demoMode?!1:d&&t.menuState===0;Ae(R,M);let F=t.__demoMode?!1:d&&t.menuState===0;Te(F,{allowed:I(()=>[t.buttonRef.current,t.itemsRef.current])});let C=t.menuState!==0,D=ce(C,t.buttonRef)?!1:S;pe(()=>{let s=t.itemsRef.current;s&&t.menuState===0&&s!==(M==null?void 0:M.activeElement)&&s.focus({preventScroll:!0})},[t.menuState,t.itemsRef,M,t.itemsRef.current]),Se(t.menuState===0,{container:t.itemsRef.current,accept(s){return s.getAttribute("role")==="menuitem"?NodeFilter.FILTER_REJECT:s.hasAttribute("role")?NodeFilter.FILTER_SKIP:NodeFilter.FILTER_ACCEPT},walk(s){s.setAttribute("role","none")}});let f=I(s=>{var X,$;switch(P.dispose(),s.key){case T.Space:if(t.searchQuery!=="")return s.preventDefault(),s.stopPropagation(),u({type:3,value:s.key});case T.Enter:if(s.preventDefault(),s.stopPropagation(),u({type:1}),t.activeItemIndex!==null){let{dataRef:U}=t.items[t.activeItemIndex];($=(X=U.current)==null?void 0:X.domRef.current)==null||$.click()}te(t.buttonRef.current);break;case T.ArrowDown:return s.preventDefault(),s.stopPropagation(),u({type:2,focus:y.Next});case T.ArrowUp:return s.preventDefault(),s.stopPropagation(),u({type:2,focus:y.Previous});case T.Home:case T.PageUp:return s.preventDefault(),s.stopPropagation(),u({type:2,focus:y.First});case T.End:case T.PageDown:return s.preventDefault(),s.stopPropagation(),u({type:2,focus:y.Last});case T.Escape:s.preventDefault(),s.stopPropagation(),u({type:1}),j().nextFrame(()=>{var U;return(U=t.buttonRef.current)==null?void 0:U.focus({preventScroll:!0})});break;case T.Tab:s.preventDefault(),s.stopPropagation(),u({type:1}),j().microTask(()=>{Le(t.buttonRef.current,s.shiftKey?ee.Previous:ee.Next)});break;default:s.key.length===1&&(u({type:3,value:s.key}),P.setTimeout(()=>u({type:4}),350));break}}),O=I(s=>{switch(s.key){case T.Space:s.preventDefault();break}}),A=H(()=>({open:t.menuState===0}),[t]),h=oe(l?m():{},{"aria-activedescendant":t.activeItemIndex===null||(L=t.items[t.activeItemIndex])==null?void 0:L.id,"aria-labelledby":(V=t.buttonRef.current)==null?void 0:V.id,id:i,onKeyDown:f,onKeyUp:O,role:"menu",tabIndex:0,ref:E,style:{...n.style,...c,"--button-width":fe(t.buttonRef,!0).width}});return x.createElement(ke,{enabled:p?e.static||S:!1},_({ourProps:h,theirProps:n,slot:A,defaultTag:$e,features:qe,visible:D,name:"Menu.Items"}))}let Ye=q;function Ze(e,a){let r=N(),{id:i=`headlessui-menu-item-${r}`,disabled:o=!1,...p}=e,[d,n]=K("Menu.Item"),l=d.activeItemIndex!==null?d.items[d.activeItemIndex].id===i:!1,t=Y(null),u=B(a,t);k(()=>{if(d.__demoMode||d.menuState!==0||!l||d.activationTrigger===0)return;let A=j();return A.requestAnimationFrame(()=>{var h,L;(L=(h=t.current)==null?void 0:h.scrollIntoView)==null||L.call(h,{block:"nearest"})}),A.dispose},[d.__demoMode,t,l,d.menuState,d.activationTrigger,d.activeItemIndex]);let g=Pe(t),c=Y({disabled:o,domRef:t,get textValue(){return g()}});k(()=>{c.current.disabled=o},[c,o]),k(()=>(n({type:5,id:i,dataRef:c}),()=>n({type:6,id:i})),[c,i]);let m=I(()=>{n({type:1})}),E=I(A=>{if(o)return A.preventDefault();n({type:1}),te(d.buttonRef.current)}),M=I(()=>{if(o)return n({type:2,focus:y.Nothing});n({type:2,focus:y.Specific,id:i})}),P=be(),b=I(A=>{P.update(A),!o&&(l||n({type:2,focus:y.Specific,id:i,trigger:0}))}),S=I(A=>{P.wasMoved(A)&&(o||l||n({type:2,focus:y.Specific,id:i,trigger:0}))}),R=I(A=>{P.wasMoved(A)&&(o||l&&n({type:2,focus:y.Nothing}))}),[F,C]=ae(),[G,D]=He(),f=H(()=>({active:l,focus:l,disabled:o,close:m}),[l,o,m]);return x.createElement(C,null,x.createElement(D,null,_({ourProps:{id:i,ref:u,role:"menuitem",tabIndex:o===!0?void 0:-1,"aria-disabled":o===!0?!0:void 0,"aria-labelledby":F,"aria-describedby":G,disabled:void 0,onClick:E,onFocus:M,onPointerEnter:b,onMouseEnter:b,onPointerMove:S,onMouseMove:S,onPointerLeave:R,onMouseLeave:R},theirProps:p,slot:f,defaultTag:Ye,name:"Menu.Item"})))}let et="div";function tt(e,a){let[r,i]=ae();return x.createElement(i,null,_({ourProps:{ref:a,"aria-labelledby":r,role:"group"},theirProps:e,slot:{},defaultTag:et,name:"Menu.Section"}))}let nt="header";function rt(e,a){let r=N(),{id:i=`headlessui-menu-heading-${r}`,...o}=e,p=Ne();k(()=>p.register(i),[i,p.register]);let d={id:i,ref:a,role:"presentation",...p.props};return _({ourProps:d,theirProps:o,slot:{},defaultTag:nt,name:"Menu.Heading"})}let ot="div";function at(e,a){return _({ourProps:{ref:a,role:"separator"},theirProps:e,slot:{},defaultTag:ot,name:"Menu.Separator"})}let it=v(Je),st=v(Xe),lt=v(ze),ut=v(Ze),pt=v(tt),dt=v(rt),mt=v(at),Qt=Object.assign(it,{Button:st,Items:lt,Item:ut,Section:pt,Heading:dt,Separator:mt});export{Qt as Menu,st as MenuButton,dt as MenuHeading,ut as MenuItem,lt as MenuItems,pt as MenuSection,mt as MenuSeparator};

@@ -1,1 +0,1 @@

"use client";import{useFocusRing as Re}from"@react-aria/focus";import{useHover as Oe}from"@react-aria/interactions";import b,{createContext as Z,createRef as me,useContext as ee,useEffect as te,useMemo as B,useReducer as Ce,useRef as q,useState as ye}from"react";import{useActivePress as Fe}from'../../hooks/use-active-press.js';import{useElementSize as _e}from'../../hooks/use-element-size.js';import{useEvent as A}from'../../hooks/use-event.js';import{useEventListener as Me}from'../../hooks/use-event-listener.js';import{useId as oe}from'../../hooks/use-id.js';import{useIsoMorphicEffect as xe}from'../../hooks/use-iso-morphic-effect.js';import{useLatestValue as Ee}from'../../hooks/use-latest-value.js';import{useOnDisappear as Le}from'../../hooks/use-on-disappear.js';import{useOutsideClick as Ie}from'../../hooks/use-outside-click.js';import{useOwnerDocument as pe}from'../../hooks/use-owner.js';import{useResolveButtonType as he}from'../../hooks/use-resolve-button-type.js';import{useMainTreeNode as Be,useRootContainers as De}from'../../hooks/use-root-containers.js';import{useScrollLock as Ge}from'../../hooks/use-scroll-lock.js';import{optionalRef as He,useSyncRefs as X}from'../../hooks/use-sync-refs.js';import{Direction as N,useTabDirection as be}from'../../hooks/use-tab-direction.js';import{CloseProvider as Ne}from'../../internal/close-provider.js';import{FloatingProvider as Ue,useFloatingPanel as ke,useFloatingPanelProps as we,useFloatingReference as We,useResolvedAnchor as Ve}from'../../internal/floating.js';import{Hidden as se,HiddenFeatures as ue}from'../../internal/hidden.js';import{OpenClosedProvider as Ke,State as Y,useOpenClosed as ge}from'../../internal/open-closed.js';import{isDisabledReactIssue7711 as Se}from'../../utils/bugs.js';import{Focus as U,FocusResult as ie,FocusableMode as je,focusIn as w,getFocusableElements as fe,isFocusableElement as $e}from'../../utils/focus-management.js';import{match as W}from'../../utils/match.js';import'../../utils/micro-task.js';import{getOwnerDocument as Je}from'../../utils/owner.js';import{RenderFeatures as re,forwardRefWithAs as z,mergeProps as Pe,render as Q,useMergeRefsFn as Xe}from'../../utils/render.js';import{Keys as V}from'../keyboard.js';import{Portal as Ye,useNestedPortals as qe}from'../portal/portal.js';var ze=(u=>(u[u.Open=0]="Open",u[u.Closed=1]="Closed",u))(ze||{}),Qe=(i=>(i[i.TogglePopover=0]="TogglePopover",i[i.ClosePopover=1]="ClosePopover",i[i.SetButton=2]="SetButton",i[i.SetButtonId=3]="SetButtonId",i[i.SetPanel=4]="SetPanel",i[i.SetPanelId=5]="SetPanelId",i))(Qe||{});let Ze={[0]:t=>({...t,popoverState:W(t.popoverState,{[0]:1,[1]:0}),__demoMode:!1}),[1](t){return t.popoverState===1?t:{...t,popoverState:1,__demoMode:!1}},[2](t,a){return t.button===a.button?t:{...t,button:a.button}},[3](t,a){return t.buttonId===a.buttonId?t:{...t,buttonId:a.buttonId}},[4](t,a){return t.panel===a.panel?t:{...t,panel:a.panel}},[5](t,a){return t.panelId===a.panelId?t:{...t,panelId:a.panelId}}},de=Z(null);de.displayName="PopoverContext";function ne(t){let a=ee(de);if(a===null){let u=new Error(`<${t} /> is missing a parent <Popover /> component.`);throw Error.captureStackTrace&&Error.captureStackTrace(u,ne),u}return a}let le=Z(null);le.displayName="PopoverAPIContext";function ce(t){let a=ee(le);if(a===null){let u=new Error(`<${t} /> is missing a parent <Popover /> component.`);throw Error.captureStackTrace&&Error.captureStackTrace(u,ce),u}return a}let ve=Z(null);ve.displayName="PopoverGroupContext";function Ae(){return ee(ve)}let ae=Z(null);ae.displayName="PopoverPanelContext";function et(){return ee(ae)}function tt(t,a){return W(a.type,Ze,t,a)}let ot="div";function rt(t,a){var d;let{__demoMode:u=!1,...R}=t,y=q(null),g=X(a,He(o=>{y.current=o})),i=q([]),l=Ce(tt,{__demoMode:u,popoverState:u?0:1,buttons:i,button:null,buttonId:null,panel:null,panelId:null,beforePanelSentinel:me(),afterPanelSentinel:me()}),[{popoverState:f,button:e,buttonId:P,panel:v,panelId:C,beforePanelSentinel:E,afterPanelSentinel:K},r]=l,p=pe((d=y.current)!=null?d:e),F=B(()=>{if(!e||!v)return!1;for(let S of document.querySelectorAll("body > *"))if(Number(S==null?void 0:S.contains(e))^Number(S==null?void 0:S.contains(v)))return!0;let o=fe(),s=o.indexOf(e),c=(s+o.length-1)%o.length,O=(s+1)%o.length,n=o[c],m=o[O];return!v.contains(n)&&!v.contains(m)},[e,v]),_=Ee(P),M=Ee(C),L=B(()=>({buttonId:_,panelId:M,close:()=>r({type:1})}),[_,M,r]),T=Ae(),h=T==null?void 0:T.registerPopover,j=A(()=>{var o;return(o=T==null?void 0:T.isFocusWithinPopoverGroup())!=null?o:(p==null?void 0:p.activeElement)&&((e==null?void 0:e.contains(p.activeElement))||(v==null?void 0:v.contains(p.activeElement)))});te(()=>h==null?void 0:h(L),[h,L]);let[x,$]=qe(),D=De({mainTreeNodeRef:T==null?void 0:T.mainTreeNodeRef,portals:x,defaultContainers:[e,v]});Me(p==null?void 0:p.defaultView,"focus",o=>{var s,c,O,n;o.target!==window&&o.target instanceof HTMLElement&&f===0&&(j()||e&&v&&(D.contains(o.target)||(c=(s=E.current)==null?void 0:s.contains)!=null&&c.call(s,o.target)||(n=(O=K.current)==null?void 0:O.contains)!=null&&n.call(O,o.target)||r({type:1})))},!0),Ie(D.resolveContainers,(o,s)=>{r({type:1}),$e(s,je.Loose)||(o.preventDefault(),e==null||e.focus())},f===0);let I=A(o=>{r({type:1});let s=(()=>o?o instanceof HTMLElement?o:"current"in o&&o.current instanceof HTMLElement?o.current:e:e)();s==null||s.focus()}),k=B(()=>({close:I,isPortalled:F}),[I,F]),J=B(()=>({open:f===0,close:I}),[f,I]),G={ref:g};return b.createElement(Ue,null,b.createElement(ae.Provider,{value:null},b.createElement(de.Provider,{value:l},b.createElement(le.Provider,{value:k},b.createElement(Ne,{value:I},b.createElement(Ke,{value:W(f,{[0]:Y.Open,[1]:Y.Closed})},b.createElement($,null,Q({ourProps:G,theirProps:R,slot:J,defaultTag:ot,name:"Popover"}),b.createElement(D.MainTreeNode,null))))))))}let nt="button";function lt(t,a){let u=oe(),{id:R=`headlessui-popover-button-${u}`,disabled:y=!1,autoFocus:g=!1,...i}=t,[l,f]=ne("Popover.Button"),{isPortalled:e}=ce("Popover.Button"),P=q(null),v=`headlessui-focus-sentinel-${oe()}`,C=Ae(),E=C==null?void 0:C.closeOthers,r=et()!==null;te(()=>{if(!r)return f({type:3,buttonId:R}),()=>{f({type:3,buttonId:null})}},[r,R,f]);let[p]=ye(()=>Symbol()),F=X(P,a,We(),r?null:n=>{if(n)l.buttons.current.push(p);else{let m=l.buttons.current.indexOf(p);m!==-1&&l.buttons.current.splice(m,1)}l.buttons.current.length>1&&console.warn("You are already using a <Popover.Button /> but only 1 <Popover.Button /> is supported."),n&&f({type:2,button:n})}),_=X(P,a),M=pe(P),L=A(n=>{var m,S,H;if(r){if(l.popoverState===1)return;switch(n.key){case V.Space:case V.Enter:n.preventDefault(),(S=(m=n.target).click)==null||S.call(m),f({type:1}),(H=l.button)==null||H.focus();break}}else switch(n.key){case V.Space:case V.Enter:n.preventDefault(),n.stopPropagation(),l.popoverState===1&&(E==null||E(l.buttonId)),f({type:0});break;case V.Escape:if(l.popoverState!==0)return E==null?void 0:E(l.buttonId);if(!P.current||M!=null&&M.activeElement&&!P.current.contains(M.activeElement))return;n.preventDefault(),n.stopPropagation(),f({type:1});break}}),T=A(n=>{r||n.key===V.Space&&n.preventDefault()}),h=A(n=>{var m,S;Se(n.currentTarget)||y||(r?(f({type:1}),(m=l.button)==null||m.focus()):(n.preventDefault(),n.stopPropagation(),l.popoverState===1&&(E==null||E(l.buttonId)),f({type:0}),(S=l.button)==null||S.focus()))}),j=A(n=>{n.preventDefault(),n.stopPropagation()}),{isFocusVisible:x,focusProps:$}=Re({autoFocus:g}),{isHovered:D,hoverProps:I}=Oe({isDisabled:y}),{pressed:k,pressProps:J}=Fe({disabled:y}),G=l.popoverState===0,d=B(()=>({open:G,active:k||G,disabled:y,hover:D,focus:x,autofocus:g}),[G,D,x,k,y,g]),o=he(t,P),s=r?Pe({ref:_,type:o,onKeyDown:L,onClick:h,disabled:y||void 0,autoFocus:g},$,I,J):Pe({ref:F,id:l.buttonId,type:o,"aria-expanded":l.popoverState===0,"aria-controls":l.panel?l.panelId:void 0,disabled:y||void 0,autoFocus:g,onKeyDown:L,onKeyUp:T,onClick:h,onMouseDown:j},$,I,J),c=be(),O=A(()=>{let n=l.panel;if(!n)return;function m(){W(c.current,{[N.Forwards]:()=>w(n,U.First),[N.Backwards]:()=>w(n,U.Last)})===ie.Error&&w(fe().filter(H=>H.dataset.headlessuiFocusGuard!=="true"),W(c.current,{[N.Forwards]:U.Next,[N.Backwards]:U.Previous}),{relativeTo:l.button})}m()});return b.createElement(b.Fragment,null,Q({ourProps:s,theirProps:i,slot:d,defaultTag:nt,name:"Popover.Button"}),G&&!r&&e&&b.createElement(se,{id:v,features:ue.Focusable,"data-headlessui-focus-guard":!0,as:"button",type:"button",onFocus:O}))}let at="div",pt=re.RenderStrategy|re.Static;function st(t,a){let u=oe(),{id:R=`headlessui-popover-overlay-${u}`,...y}=t,[{popoverState:g},i]=ne("Popover.Overlay"),l=X(a),f=ge(),e=(()=>f!==null?(f&Y.Open)===Y.Open:g===0)(),P=A(E=>{if(Se(E.currentTarget))return E.preventDefault();i({type:1})}),v=B(()=>({open:g===0}),[g]);return Q({ourProps:{ref:l,id:R,"aria-hidden":!0,onClick:P},theirProps:y,slot:v,defaultTag:at,features:pt,visible:e,name:"Popover.Overlay"})}let ut="div",it=re.RenderStrategy|re.Static;function ft(t,a){let u=oe(),{id:R=`headlessui-popover-panel-${u}`,focus:y=!1,anchor:g,portal:i=!1,modal:l=!1,...f}=t,[e,P]=ne("Popover.Panel"),{close:v,isPortalled:C}=ce("Popover.Panel"),E=`headlessui-focus-sentinel-before-${u}`,K=`headlessui-focus-sentinel-after-${u}`,r=q(null),p=Ve(g),[F,_]=ke(p),M=we();p&&(i=!0);let L=X(r,a,p?F:null,d=>{P({type:4,panel:d})}),T=pe(r),h=Xe();xe(()=>(P({type:5,panelId:R}),()=>{P({type:5,panelId:null})}),[R,P]);let j=ge(),x=(()=>j!==null?(j&Y.Open)===Y.Open:e.popoverState===0)();Le(e.button,()=>P({type:1}),x),Ge(T,e.__demoMode?!1:l&&x);let $=A(d=>{var o;switch(d.key){case V.Escape:if(e.popoverState!==0||!r.current||T!=null&&T.activeElement&&!r.current.contains(T.activeElement))return;d.preventDefault(),d.stopPropagation(),P({type:1}),(o=e.button)==null||o.focus();break}});te(()=>{var d;t.static||e.popoverState===1&&((d=t.unmount)==null||d)&&P({type:4,panel:null})},[e.popoverState,t.unmount,t.static,P]),te(()=>{if(e.__demoMode||!y||e.popoverState!==0||!r.current)return;let d=T==null?void 0:T.activeElement;r.current.contains(d)||w(r.current,U.First)},[e.__demoMode,y,r,e.popoverState]);let D=B(()=>({open:e.popoverState===0,close:v}),[e,v]),I=Pe(p?M():{},{ref:L,id:R,onKeyDown:$,onBlur:y&&e.popoverState===0?d=>{var s,c,O,n,m;let o=d.relatedTarget;o&&r.current&&((s=r.current)!=null&&s.contains(o)||(P({type:1}),((O=(c=e.beforePanelSentinel.current)==null?void 0:c.contains)!=null&&O.call(c,o)||(m=(n=e.afterPanelSentinel.current)==null?void 0:n.contains)!=null&&m.call(n,o))&&o.focus({preventScroll:!0})))}:void 0,tabIndex:-1,style:{..._,"--button-width":_e(e.button,!0).width}}),k=be(),J=A(()=>{let d=r.current;if(!d)return;function o(){W(k.current,{[N.Forwards]:()=>{var c;w(d,U.First)===ie.Error&&((c=e.afterPanelSentinel.current)==null||c.focus())},[N.Backwards]:()=>{var s;(s=e.button)==null||s.focus({preventScroll:!0})}})}o()}),G=A(()=>{let d=r.current;if(!d)return;function o(){W(k.current,{[N.Forwards]:()=>{var S;if(!e.button)return;let s=fe(),c=s.indexOf(e.button),O=s.slice(0,c+1),m=[...s.slice(c+1),...O];for(let H of m.slice())if(H.dataset.headlessuiFocusGuard==="true"||(S=e.panel)!=null&&S.contains(H)){let Te=m.indexOf(H);Te!==-1&&m.splice(Te,1)}w(m,U.First,{sorted:!1})},[N.Backwards]:()=>{var c;w(d,U.Previous)===ie.Error&&((c=e.button)==null||c.focus())}})}o()});return b.createElement(ae.Provider,{value:R},b.createElement(le.Provider,{value:{close:v,isPortalled:C}},b.createElement(Ye,{enabled:i?t.static||x:!1},x&&C&&b.createElement(se,{id:E,ref:e.beforePanelSentinel,features:ue.Focusable,"data-headlessui-focus-guard":!0,as:"button",type:"button",onFocus:J}),Q({mergeRefs:h,ourProps:I,theirProps:f,slot:D,defaultTag:ut,features:it,visible:x,name:"Popover.Panel"}),x&&C&&b.createElement(se,{id:K,ref:e.afterPanelSentinel,features:ue.Focusable,"data-headlessui-focus-guard":!0,as:"button",type:"button",onFocus:G}))))}let Pt="div";function dt(t,a){let u=q(null),R=X(u,a),[y,g]=ye([]),i=Be(),l=A(r=>{g(p=>{let F=p.indexOf(r);if(F!==-1){let _=p.slice();return _.splice(F,1),_}return p})}),f=A(r=>(g(p=>[...p,r]),()=>l(r))),e=A(()=>{var F;let r=Je(u);if(!r)return!1;let p=r.activeElement;return(F=u.current)!=null&&F.contains(p)?!0:y.some(_=>{var M,L;return((M=r.getElementById(_.buttonId.current))==null?void 0:M.contains(p))||((L=r.getElementById(_.panelId.current))==null?void 0:L.contains(p))})}),P=A(r=>{for(let p of y)p.buttonId.current!==r&&p.close()}),v=B(()=>({registerPopover:f,unregisterPopover:l,isFocusWithinPopoverGroup:e,closeOthers:P,mainTreeNodeRef:i.mainTreeNodeRef}),[f,l,e,P,i.mainTreeNodeRef]),C=B(()=>({}),[]),E=t,K={ref:R};return b.createElement(ve.Provider,{value:v},Q({ourProps:K,theirProps:E,slot:C,defaultTag:Pt,name:"Popover.Group"}),b.createElement(i.MainTreeNode,null))}let ct=z(rt),vt=z(lt),Tt=z(st),mt=z(ft),yt=z(dt),qt=Object.assign(ct,{Button:vt,Overlay:Tt,Panel:mt,Group:yt});export{qt as Popover,vt as PopoverButton,yt as PopoverGroup,Tt as PopoverOverlay,mt as PopoverPanel};
"use client";import{useFocusRing as Oe}from"@react-aria/focus";import{useHover as Ce}from"@react-aria/interactions";import b,{createContext as ee,createRef as se,useContext as te,useEffect as oe,useMemo as G,useReducer as Fe,useRef as z,useState as Ee}from"react";import{useActivePress as Me}from'../../hooks/use-active-press.js';import{useElementSize as _e}from'../../hooks/use-element-size.js';import{useEvent as A}from'../../hooks/use-event.js';import{useEventListener as xe}from'../../hooks/use-event-listener.js';import{useId as re}from'../../hooks/use-id.js';import{useIsoMorphicEffect as Le}from'../../hooks/use-iso-morphic-effect.js';import{useLatestValue as be}from'../../hooks/use-latest-value.js';import{useOnDisappear as Ie}from'../../hooks/use-on-disappear.js';import{useOutsideClick as Be}from'../../hooks/use-outside-click.js';import{useOwnerDocument as ue}from'../../hooks/use-owner.js';import{useResolveButtonType as he}from'../../hooks/use-resolve-button-type.js';import{useMainTreeNode as De,useRootContainers as Ge}from'../../hooks/use-root-containers.js';import{useScrollLock as He}from'../../hooks/use-scroll-lock.js';import{optionalRef as Ne,useSyncRefs as J}from'../../hooks/use-sync-refs.js';import{Direction as k,useTabDirection as ge}from'../../hooks/use-tab-direction.js';import{CloseProvider as ke}from'../../internal/close-provider.js';import{FloatingProvider as Ue,useFloatingPanel as we,useFloatingPanelProps as We,useFloatingReference as Ve,useResolvedAnchor as je}from'../../internal/floating.js';import{Hidden as ie,HiddenFeatures as fe}from'../../internal/hidden.js';import{OpenClosedProvider as Ke,State as X,useOpenClosed as Se}from'../../internal/open-closed.js';import{isDisabledReactIssue7711 as Ae}from'../../utils/bugs.js';import{Focus as U,FocusResult as Pe,FocusableMode as $e,focusIn as w,getFocusableElements as de,isFocusableElement as Je}from'../../utils/focus-management.js';import{match as W}from'../../utils/match.js';import'../../utils/micro-task.js';import{getOwnerDocument as Xe}from'../../utils/owner.js';import{RenderFeatures as ne,forwardRefWithAs as Q,mergeProps as ce,render as Z,useMergeRefsFn as Ye}from'../../utils/render.js';import{Keys as V}from'../keyboard.js';import{Portal as qe,useNestedPortals as ze}from'../portal/portal.js';var Qe=(u=>(u[u.Open=0]="Open",u[u.Closed=1]="Closed",u))(Qe||{}),Ze=(i=>(i[i.TogglePopover=0]="TogglePopover",i[i.ClosePopover=1]="ClosePopover",i[i.SetButton=2]="SetButton",i[i.SetButtonId=3]="SetButtonId",i[i.SetPanel=4]="SetPanel",i[i.SetPanelId=5]="SetPanelId",i))(Ze||{});let et={[0]:t=>({...t,popoverState:W(t.popoverState,{[0]:1,[1]:0}),__demoMode:!1}),[1](t){return t.popoverState===1?t:{...t,popoverState:1,__demoMode:!1}},[2](t,a){return t.button===a.button?t:{...t,button:a.button}},[3](t,a){return t.buttonId===a.buttonId?t:{...t,buttonId:a.buttonId}},[4](t,a){return t.panel===a.panel?t:{...t,panel:a.panel}},[5](t,a){return t.panelId===a.panelId?t:{...t,panelId:a.panelId}}},ve=ee(null);ve.displayName="PopoverContext";function le(t){let a=te(ve);if(a===null){let u=new Error(`<${t} /> is missing a parent <Popover /> component.`);throw Error.captureStackTrace&&Error.captureStackTrace(u,le),u}return a}let ae=ee(null);ae.displayName="PopoverAPIContext";function Te(t){let a=te(ae);if(a===null){let u=new Error(`<${t} /> is missing a parent <Popover /> component.`);throw Error.captureStackTrace&&Error.captureStackTrace(u,Te),u}return a}let me=ee(null);me.displayName="PopoverGroupContext";function Re(){return te(me)}let pe=ee(null);pe.displayName="PopoverPanelContext";function tt(){return te(pe)}function ot(t,a){return W(a.type,et,t,a)}let rt="div";function nt(t,a){var g;let{__demoMode:u=!1,...C}=t,T=z(null),S=J(a,Ne(o=>{T.current=o})),i=z([]),l=Fe(ot,{__demoMode:u,popoverState:u?0:1,buttons:i,button:null,buttonId:null,panel:null,panelId:null,beforePanelSentinel:se(),afterPanelSentinel:se(),afterButtonSentinel:se()}),[{popoverState:f,button:e,buttonId:P,panel:v,panelId:_,beforePanelSentinel:y,afterPanelSentinel:j,afterButtonSentinel:n},s]=l,E=ue((g=T.current)!=null?g:e),x=G(()=>{if(!e||!v)return!1;for(let M of document.querySelectorAll("body > *"))if(Number(M==null?void 0:M.contains(e))^Number(M==null?void 0:M.contains(v)))return!0;let o=de(),p=o.indexOf(e),r=(p+o.length-1)%o.length,c=(p+1)%o.length,m=o[r],O=o[c];return!v.contains(m)&&!v.contains(O)},[e,v]),L=be(P),h=be(_),F=G(()=>({buttonId:L,panelId:h,close:()=>s({type:1})}),[L,h,s]),R=Re(),D=R==null?void 0:R.registerPopover,I=A(()=>{var o;return(o=R==null?void 0:R.isFocusWithinPopoverGroup())!=null?o:(E==null?void 0:E.activeElement)&&((e==null?void 0:e.contains(E.activeElement))||(v==null?void 0:v.contains(E.activeElement)))});oe(()=>D==null?void 0:D(F),[D,F]);let[K,$]=ze(),H=Ge({mainTreeNodeRef:R==null?void 0:R.mainTreeNodeRef,portals:K,defaultContainers:[e,v]});xe(E==null?void 0:E.defaultView,"focus",o=>{var p,r,c,m,O,M;o.target!==window&&o.target instanceof HTMLElement&&f===0&&(I()||e&&v&&(H.contains(o.target)||(r=(p=y.current)==null?void 0:p.contains)!=null&&r.call(p,o.target)||(m=(c=j.current)==null?void 0:c.contains)!=null&&m.call(c,o.target)||(M=(O=n.current)==null?void 0:O.contains)!=null&&M.call(O,o.target)||s({type:1})))},!0),Be(f===0,H.resolveContainers,(o,p)=>{s({type:1}),Je(p,$e.Loose)||(o.preventDefault(),e==null||e.focus())});let B=A(o=>{s({type:1});let p=(()=>o?o instanceof HTMLElement?o:"current"in o&&o.current instanceof HTMLElement?o.current:e:e)();p==null||p.focus()}),N=G(()=>({close:B,isPortalled:x}),[B,x]),q=G(()=>({open:f===0,close:B}),[f,B]),d={ref:S};return b.createElement(Ue,null,b.createElement(pe.Provider,{value:null},b.createElement(ve.Provider,{value:l},b.createElement(ae.Provider,{value:N},b.createElement(ke,{value:B},b.createElement(Ke,{value:W(f,{[0]:X.Open,[1]:X.Closed})},b.createElement($,null,Z({ourProps:d,theirProps:C,slot:q,defaultTag:rt,name:"Popover"}),b.createElement(H.MainTreeNode,null))))))))}let lt="button";function at(t,a){let u=re(),{id:C=`headlessui-popover-button-${u}`,disabled:T=!1,autoFocus:S=!1,...i}=t,[l,f]=le("Popover.Button"),{isPortalled:e}=Te("Popover.Button"),P=z(null),v=`headlessui-focus-sentinel-${re()}`,_=Re(),y=_==null?void 0:_.closeOthers,n=tt()!==null;oe(()=>{if(!n)return f({type:3,buttonId:C}),()=>{f({type:3,buttonId:null})}},[n,C,f]);let[s]=Ee(()=>Symbol()),E=J(P,a,Ve(),n?null:r=>{if(r)l.buttons.current.push(s);else{let c=l.buttons.current.indexOf(s);c!==-1&&l.buttons.current.splice(c,1)}l.buttons.current.length>1&&console.warn("You are already using a <Popover.Button /> but only 1 <Popover.Button /> is supported."),r&&f({type:2,button:r})}),x=J(P,a),L=ue(P),h=A(r=>{var c,m,O;if(n){if(l.popoverState===1)return;switch(r.key){case V.Space:case V.Enter:r.preventDefault(),(m=(c=r.target).click)==null||m.call(c),f({type:1}),(O=l.button)==null||O.focus();break}}else switch(r.key){case V.Space:case V.Enter:r.preventDefault(),r.stopPropagation(),l.popoverState===1&&(y==null||y(l.buttonId)),f({type:0});break;case V.Escape:if(l.popoverState!==0)return y==null?void 0:y(l.buttonId);if(!P.current||L!=null&&L.activeElement&&!P.current.contains(L.activeElement))return;r.preventDefault(),r.stopPropagation(),f({type:1});break}}),F=A(r=>{n||r.key===V.Space&&r.preventDefault()}),R=A(r=>{var c,m;Ae(r.currentTarget)||T||(n?(f({type:1}),(c=l.button)==null||c.focus()):(r.preventDefault(),r.stopPropagation(),l.popoverState===1&&(y==null||y(l.buttonId)),f({type:0}),(m=l.button)==null||m.focus()))}),D=A(r=>{r.preventDefault(),r.stopPropagation()}),{isFocusVisible:I,focusProps:K}=Oe({autoFocus:S}),{isHovered:$,hoverProps:H}=Ce({isDisabled:T}),{pressed:Y,pressProps:B}=Me({disabled:T}),N=l.popoverState===0,q=G(()=>({open:N,active:Y||N,disabled:T,hover:$,focus:I,autofocus:S}),[N,$,I,Y,T,S]),d=he(t,P),g=n?ce({ref:x,type:d,onKeyDown:h,onClick:R,disabled:T||void 0,autoFocus:S},K,H,B):ce({ref:E,id:l.buttonId,type:d,"aria-expanded":l.popoverState===0,"aria-controls":l.panel?l.panelId:void 0,disabled:T||void 0,autoFocus:S,onKeyDown:h,onKeyUp:F,onClick:R,onMouseDown:D},K,H,B),o=ge(),p=A(()=>{let r=l.panel;if(!r)return;function c(){W(o.current,{[k.Forwards]:()=>w(r,U.First),[k.Backwards]:()=>w(r,U.Last)})===Pe.Error&&w(de().filter(O=>O.dataset.headlessuiFocusGuard!=="true"),W(o.current,{[k.Forwards]:U.Next,[k.Backwards]:U.Previous}),{relativeTo:l.button})}c()});return b.createElement(b.Fragment,null,Z({ourProps:g,theirProps:i,slot:q,defaultTag:lt,name:"Popover.Button"}),N&&!n&&e&&b.createElement(ie,{id:v,ref:l.afterButtonSentinel,features:fe.Focusable,"data-headlessui-focus-guard":!0,as:"button",type:"button",onFocus:p}))}let pt="div",st=ne.RenderStrategy|ne.Static;function ut(t,a){let u=re(),{id:C=`headlessui-popover-overlay-${u}`,...T}=t,[{popoverState:S},i]=le("Popover.Overlay"),l=J(a),f=Se(),e=(()=>f!==null?(f&X.Open)===X.Open:S===0)(),P=A(y=>{if(Ae(y.currentTarget))return y.preventDefault();i({type:1})}),v=G(()=>({open:S===0}),[S]);return Z({ourProps:{ref:l,id:C,"aria-hidden":!0,onClick:P},theirProps:T,slot:v,defaultTag:pt,features:st,visible:e,name:"Popover.Overlay"})}let it="div",ft=ne.RenderStrategy|ne.Static;function Pt(t,a){let u=re(),{id:C=`headlessui-popover-panel-${u}`,focus:T=!1,anchor:S,portal:i=!1,modal:l=!1,...f}=t,[e,P]=le("Popover.Panel"),{close:v,isPortalled:_}=Te("Popover.Panel"),y=`headlessui-focus-sentinel-before-${u}`,j=`headlessui-focus-sentinel-after-${u}`,n=z(null),s=je(S),[E,x]=we(s),L=We();s&&(i=!0);let h=J(n,a,s?E:null,d=>{P({type:4,panel:d})}),F=ue(n),R=Ye();Le(()=>(P({type:5,panelId:C}),()=>{P({type:5,panelId:null})}),[C,P]);let D=Se(),I=(()=>D!==null?(D&X.Open)===X.Open:e.popoverState===0)();Ie(I,e.button,()=>{P({type:1})});let K=e.__demoMode?!1:l&&I;He(K,F);let $=A(d=>{var g;switch(d.key){case V.Escape:if(e.popoverState!==0||!n.current||F!=null&&F.activeElement&&!n.current.contains(F.activeElement))return;d.preventDefault(),d.stopPropagation(),P({type:1}),(g=e.button)==null||g.focus();break}});oe(()=>{var d;t.static||e.popoverState===1&&((d=t.unmount)==null||d)&&P({type:4,panel:null})},[e.popoverState,t.unmount,t.static,P]),oe(()=>{if(e.__demoMode||!T||e.popoverState!==0||!n.current)return;let d=F==null?void 0:F.activeElement;n.current.contains(d)||w(n.current,U.First)},[e.__demoMode,T,n,e.popoverState]);let H=G(()=>({open:e.popoverState===0,close:v}),[e,v]),Y=ce(s?L():{},{ref:h,id:C,onKeyDown:$,onBlur:T&&e.popoverState===0?d=>{var o,p,r,c,m;let g=d.relatedTarget;g&&n.current&&((o=n.current)!=null&&o.contains(g)||(P({type:1}),((r=(p=e.beforePanelSentinel.current)==null?void 0:p.contains)!=null&&r.call(p,g)||(m=(c=e.afterPanelSentinel.current)==null?void 0:c.contains)!=null&&m.call(c,g))&&g.focus({preventScroll:!0})))}:void 0,tabIndex:-1,style:{...f.style,...x,"--button-width":_e(e.button,!0).width}}),B=ge(),N=A(()=>{let d=n.current;if(!d)return;function g(){W(B.current,{[k.Forwards]:()=>{var p;w(d,U.First)===Pe.Error&&((p=e.afterPanelSentinel.current)==null||p.focus())},[k.Backwards]:()=>{var o;(o=e.button)==null||o.focus({preventScroll:!0})}})}g()}),q=A(()=>{let d=n.current;if(!d)return;function g(){W(B.current,{[k.Forwards]:()=>{var O;if(!e.button)return;let o=de(),p=o.indexOf(e.button),r=o.slice(0,p+1),m=[...o.slice(p+1),...r];for(let M of m.slice())if(M.dataset.headlessuiFocusGuard==="true"||(O=e.panel)!=null&&O.contains(M)){let ye=m.indexOf(M);ye!==-1&&m.splice(ye,1)}w(m,U.First,{sorted:!1})},[k.Backwards]:()=>{var p;w(d,U.Previous)===Pe.Error&&((p=e.button)==null||p.focus())}})}g()});return b.createElement(pe.Provider,{value:C},b.createElement(ae.Provider,{value:{close:v,isPortalled:_}},b.createElement(qe,{enabled:i?t.static||I:!1},I&&_&&b.createElement(ie,{id:y,ref:e.beforePanelSentinel,features:fe.Focusable,"data-headlessui-focus-guard":!0,as:"button",type:"button",onFocus:N}),Z({mergeRefs:R,ourProps:Y,theirProps:f,slot:H,defaultTag:it,features:ft,visible:I,name:"Popover.Panel"}),I&&_&&b.createElement(ie,{id:j,ref:e.afterPanelSentinel,features:fe.Focusable,"data-headlessui-focus-guard":!0,as:"button",type:"button",onFocus:q}))))}let dt="div";function ct(t,a){let u=z(null),C=J(u,a),[T,S]=Ee([]),i=De(),l=A(n=>{S(s=>{let E=s.indexOf(n);if(E!==-1){let x=s.slice();return x.splice(E,1),x}return s})}),f=A(n=>(S(s=>[...s,n]),()=>l(n))),e=A(()=>{var E;let n=Xe(u);if(!n)return!1;let s=n.activeElement;return(E=u.current)!=null&&E.contains(s)?!0:T.some(x=>{var L,h;return((L=n.getElementById(x.buttonId.current))==null?void 0:L.contains(s))||((h=n.getElementById(x.panelId.current))==null?void 0:h.contains(s))})}),P=A(n=>{for(let s of T)s.buttonId.current!==n&&s.close()}),v=G(()=>({registerPopover:f,unregisterPopover:l,isFocusWithinPopoverGroup:e,closeOthers:P,mainTreeNodeRef:i.mainTreeNodeRef}),[f,l,e,P,i.mainTreeNodeRef]),_=G(()=>({}),[]),y=t,j={ref:C};return b.createElement(me.Provider,{value:v},Z({ourProps:j,theirProps:y,slot:_,defaultTag:dt,name:"Popover.Group"}),b.createElement(i.MainTreeNode,null))}let vt=Q(nt),Tt=Q(at),mt=Q(ut),yt=Q(Pt),Et=Q(ct),zt=Object.assign(vt,{Button:Tt,Overlay:mt,Panel:yt,Group:Et});export{zt as Popover,Tt as PopoverButton,Et as PopoverGroup,mt as PopoverOverlay,yt as PopoverPanel};

@@ -1,1 +0,1 @@

"use client";import{useFocusRing as Q}from"@react-aria/focus";import{useHover as Y}from"@react-aria/interactions";import G,{createContext as Z,useCallback as ye,useContext as ee,useMemo as x,useReducer as me,useRef as W}from"react";import{useByComparator as Re}from'../../hooks/use-by-comparator.js';import{useControllable as be}from'../../hooks/use-controllable.js';import{useEvent as S}from'../../hooks/use-event.js';import{useId as B}from'../../hooks/use-id.js';import{useIsoMorphicEffect as te}from'../../hooks/use-iso-morphic-effect.js';import{useLatestValue as oe}from'../../hooks/use-latest-value.js';import{useSyncRefs as K}from'../../hooks/use-sync-refs.js';import{useDisabled as re}from'../../internal/disabled.js';import{FormFields as ge}from'../../internal/form-fields.js';import{useProvidedId as Oe}from'../../internal/id.js';import{isDisabledReactIssue7711 as ie}from'../../utils/bugs.js';import{Focus as w,FocusResult as ne,focusIn as ae,sortByDomNode as Pe}from'../../utils/focus-management.js';import{attemptSubmit as ve}from'../../utils/form.js';import{match as De}from'../../utils/match.js';import{getOwnerDocument as Ae}from'../../utils/owner.js';import{forwardRefWithAs as $,mergeProps as pe,render as j}from'../../utils/render.js';import{Description as _e,useDescribedBy as Ee,useDescriptions as le}from'../description/description.js';import{Keys as I}from'../keyboard.js';import{Label as Ge,useLabelledBy as xe,useLabels as se}from'../label/label.js';var Ce=(e=>(e[e.RegisterOption=0]="RegisterOption",e[e.UnregisterOption=1]="UnregisterOption",e))(Ce||{});let he={[0](o,t){let e=[...o.options,{id:t.id,element:t.element,propsRef:t.propsRef}];return{...o,options:Pe(e,a=>a.element.current)}},[1](o,t){let e=o.options.slice(),a=o.options.findIndex(O=>O.id===t.id);return a===-1?o:(e.splice(a,1),{...o,options:e})}},V=Z(null);V.displayName="RadioGroupDataContext";function J(o){let t=ee(V);if(t===null){let e=new Error(`<${o} /> is missing a parent <RadioGroup /> component.`);throw Error.captureStackTrace&&Error.captureStackTrace(e,J),e}return t}let X=Z(null);X.displayName="RadioGroupActionsContext";function z(o){let t=ee(X);if(t===null){let e=new Error(`<${o} /> is missing a parent <RadioGroup /> component.`);throw Error.captureStackTrace&&Error.captureStackTrace(e,z),e}return t}function Le(o,t){return De(t.type,he,o,t)}let ke="div";function Fe(o,t){let e=B(),a=re(),{id:O=`headlessui-radiogroup-${e}`,value:T,defaultValue:y,form:p,name:d,onChange:u,by:c,disabled:m=a||!1,...R}=o,f=Re(c),[P,C]=me(Le,{options:[]}),n=P.options,[U,h]=se(),[v,L]=le(),D=W(null),M=K(D,t),[r,A]=be(T,u,y),k=x(()=>n.find(i=>!i.propsRef.current.disabled),[n]),b=x(()=>n.some(i=>f(i.propsRef.current.value,r)),[n,r]),l=S(i=>{var s;if(m||f(i,r))return!1;let F=(s=n.find(H=>f(H.propsRef.current.value,i)))==null?void 0:s.propsRef.current;return F!=null&&F.disabled?!1:(A==null||A(i),!0)}),_=S(i=>{let F=D.current;if(!F)return;let s=Ae(F),H=n.filter(g=>g.propsRef.current.disabled===!1).map(g=>g.element.current);switch(i.key){case I.Enter:ve(i.currentTarget);break;case I.ArrowLeft:case I.ArrowUp:if(i.preventDefault(),i.stopPropagation(),ae(H,w.Previous|w.WrapAround)===ne.Success){let E=n.find(N=>N.element.current===(s==null?void 0:s.activeElement));E&&l(E.propsRef.current.value)}break;case I.ArrowRight:case I.ArrowDown:if(i.preventDefault(),i.stopPropagation(),ae(H,w.Next|w.WrapAround)===ne.Success){let E=n.find(N=>N.element.current===(s==null?void 0:s.activeElement));E&&l(E.propsRef.current.value)}break;case I.Space:{i.preventDefault(),i.stopPropagation();let g=n.find(E=>E.element.current===(s==null?void 0:s.activeElement));g&&l(g.propsRef.current.value)}break}}),q=S(i=>(C({type:0,...i}),()=>C({type:1,id:i.id}))),de=x(()=>({value:r,firstOption:k,containsCheckedOption:b,disabled:m,compare:f,...P}),[r,k,b,m,f,P]),ue=x(()=>({registerOption:q,change:l}),[q,l]),ce={ref:M,id:O,role:"radiogroup","aria-labelledby":U,"aria-describedby":v,onKeyDown:_},fe=x(()=>({value:r}),[r]),Te=ye(()=>l(y),[l]);return G.createElement(L,{name:"RadioGroup.Description"},G.createElement(h,{name:"RadioGroup.Label"},G.createElement(X.Provider,{value:ue},G.createElement(V.Provider,{value:de},d!=null&&G.createElement(ge,{disabled:m,data:{[d]:r||"on"},overrides:{type:"radio",checked:r!=null},form:p,onReset:Te}),j({ourProps:ce,theirProps:R,slot:fe,defaultTag:ke,name:"RadioGroup"})))))}let Ie="div";function Ue(o,t){var b;let e=J("RadioGroup.Option"),a=z("RadioGroup.Option"),O=B(),{id:T=`headlessui-radiogroup-option-${O}`,value:y,disabled:p=e.disabled||!1,autoFocus:d=!1,...u}=o,c=W(null),m=K(c,t),[R,f]=se(),[P,C]=le(),n=oe({value:y,disabled:p});te(()=>a.registerOption({id:T,element:c,propsRef:n}),[T,a,c,n]);let U=S(l=>{var _;if(ie(l.currentTarget))return l.preventDefault();a.change(y)&&((_=c.current)==null||_.focus())}),h=((b=e.firstOption)==null?void 0:b.id)===T,{isFocusVisible:v,focusProps:L}=Q({autoFocus:d}),{isHovered:D,hoverProps:M}=Y({isDisabled:p}),r=e.compare(e.value,y),A=pe({ref:m,id:T,role:"radio","aria-checked":r?"true":"false","aria-labelledby":R,"aria-describedby":P,"aria-disabled":p?!0:void 0,tabIndex:(()=>p?-1:r||!e.containsCheckedOption&&h?0:-1)(),onClick:p?void 0:U,autoFocus:d},L,M),k=x(()=>({checked:r,disabled:p,active:v,hover:D,focus:v,autofocus:d}),[r,p,D,v,d]);return G.createElement(C,{name:"RadioGroup.Description"},G.createElement(f,{name:"RadioGroup.Label"},j({ourProps:A,theirProps:u,slot:k,defaultTag:Ie,name:"RadioGroup.Option"})))}let Me="span";function Se(o,t){var b;let e=J("Radio"),a=z("Radio"),O=B(),T=Oe(),y=re(),{id:p=T||`headlessui-radio-${O}`,value:d,disabled:u=e.disabled||y||!1,autoFocus:c=!1,...m}=o,R=W(null),f=K(R,t),P=xe(),C=Ee(),n=oe({value:d,disabled:u});te(()=>a.registerOption({id:p,element:R,propsRef:n}),[p,a,R,n]);let U=S(l=>{var _;if(ie(l.currentTarget))return l.preventDefault();a.change(d)&&((_=R.current)==null||_.focus())}),{isFocusVisible:h,focusProps:v}=Q({autoFocus:c}),{isHovered:L,hoverProps:D}=Y({isDisabled:u}),M=((b=e.firstOption)==null?void 0:b.id)===p,r=e.compare(e.value,d),A=pe({ref:f,id:p,role:"radio","aria-checked":r?"true":"false","aria-labelledby":P,"aria-describedby":C,"aria-disabled":u?!0:void 0,tabIndex:(()=>u?-1:r||!e.containsCheckedOption&&M?0:-1)(),autoFocus:c,onClick:u?void 0:U},v,D),k=x(()=>({checked:r,disabled:u,hover:L,focus:h,autofocus:c}),[r,u,L,h,c]);return j({ourProps:A,theirProps:m,slot:k,defaultTag:Me,name:"Radio"})}let He=$(Fe),we=$(Ue),Ne=$(Se),We=Ge,Be=_e,ut=Object.assign(He,{Option:we,Radio:Ne,Label:We,Description:Be});export{Ne as Radio,ut as RadioGroup,Be as RadioGroupDescription,We as RadioGroupLabel,we as RadioGroupOption};
"use client";import{useFocusRing as Q}from"@react-aria/focus";import{useHover as Y}from"@react-aria/interactions";import G,{createContext as Z,useCallback as ye,useContext as ee,useMemo as x,useReducer as Re,useRef as W}from"react";import{useByComparator as be}from'../../hooks/use-by-comparator.js';import{useControllable as ge}from'../../hooks/use-controllable.js';import{useDefaultValue as Oe}from'../../hooks/use-default-value.js';import{useEvent as S}from'../../hooks/use-event.js';import{useId as B}from'../../hooks/use-id.js';import{useIsoMorphicEffect as te}from'../../hooks/use-iso-morphic-effect.js';import{useLatestValue as oe}from'../../hooks/use-latest-value.js';import{useSyncRefs as V}from'../../hooks/use-sync-refs.js';import{useDisabled as re}from'../../internal/disabled.js';import{FormFields as Pe}from'../../internal/form-fields.js';import{useProvidedId as ve}from'../../internal/id.js';import{isDisabledReactIssue7711 as ie}from'../../utils/bugs.js';import{Focus as w,FocusResult as ne,focusIn as ae,sortByDomNode as De}from'../../utils/focus-management.js';import{attemptSubmit as Ae}from'../../utils/form.js';import{match as _e}from'../../utils/match.js';import{getOwnerDocument as Ee}from'../../utils/owner.js';import{forwardRefWithAs as K,mergeProps as pe,render as $}from'../../utils/render.js';import{Description as Ge,useDescribedBy as xe,useDescriptions as le}from'../description/description.js';import{Keys as F}from'../keyboard.js';import{Label as Ce,useLabelledBy as he,useLabels as se}from'../label/label.js';var Le=(e=>(e[e.RegisterOption=0]="RegisterOption",e[e.UnregisterOption=1]="UnregisterOption",e))(Le||{});let ke={[0](o,t){let e=[...o.options,{id:t.id,element:t.element,propsRef:t.propsRef}];return{...o,options:De(e,a=>a.element.current)}},[1](o,t){let e=o.options.slice(),a=o.options.findIndex(O=>O.id===t.id);return a===-1?o:(e.splice(a,1),{...o,options:e})}},j=Z(null);j.displayName="RadioGroupDataContext";function J(o){let t=ee(j);if(t===null){let e=new Error(`<${o} /> is missing a parent <RadioGroup /> component.`);throw Error.captureStackTrace&&Error.captureStackTrace(e,J),e}return t}let X=Z(null);X.displayName="RadioGroupActionsContext";function z(o){let t=ee(X);if(t===null){let e=new Error(`<${o} /> is missing a parent <RadioGroup /> component.`);throw Error.captureStackTrace&&Error.captureStackTrace(e,z),e}return t}function Fe(o,t){return _e(t.type,ke,o,t)}let Ie="div";function Ue(o,t){let e=B(),a=re(),{id:O=`headlessui-radiogroup-${e}`,value:m,form:P,name:i,onChange:f,by:c,disabled:p=a||!1,defaultValue:I,...y}=o,T=be(c),[v,C]=Re(Fe,{options:[]}),n=v.options,[U,h]=se(),[D,L]=le(),A=W(null),M=V(A,t),l=Oe(I),[s,_]=ge(m,f,l),R=x(()=>n.find(r=>!r.propsRef.current.disabled),[n]),b=x(()=>n.some(r=>T(r.propsRef.current.value,s)),[n,s]),d=S(r=>{var u;if(p||T(r,s))return!1;let k=(u=n.find(H=>T(H.propsRef.current.value,r)))==null?void 0:u.propsRef.current;return k!=null&&k.disabled?!1:(_==null||_(r),!0)}),de=S(r=>{let k=A.current;if(!k)return;let u=Ee(k),H=n.filter(g=>g.propsRef.current.disabled===!1).map(g=>g.element.current);switch(r.key){case F.Enter:Ae(r.currentTarget);break;case F.ArrowLeft:case F.ArrowUp:if(r.preventDefault(),r.stopPropagation(),ae(H,w.Previous|w.WrapAround)===ne.Success){let E=n.find(N=>N.element.current===(u==null?void 0:u.activeElement));E&&d(E.propsRef.current.value)}break;case F.ArrowRight:case F.ArrowDown:if(r.preventDefault(),r.stopPropagation(),ae(H,w.Next|w.WrapAround)===ne.Success){let E=n.find(N=>N.element.current===(u==null?void 0:u.activeElement));E&&d(E.propsRef.current.value)}break;case F.Space:{r.preventDefault(),r.stopPropagation();let g=n.find(E=>E.element.current===(u==null?void 0:u.activeElement));g&&d(g.propsRef.current.value)}break}}),q=S(r=>(C({type:0,...r}),()=>C({type:1,id:r.id}))),ue=x(()=>({value:s,firstOption:R,containsCheckedOption:b,disabled:p,compare:T,...v}),[s,R,b,p,T,v]),ce=x(()=>({registerOption:q,change:d}),[q,d]),fe={ref:M,id:O,role:"radiogroup","aria-labelledby":U,"aria-describedby":D,onKeyDown:de},Te=x(()=>({value:s}),[s]),me=ye(()=>{if(l!==void 0)return d(l)},[d,l]);return G.createElement(L,{name:"RadioGroup.Description"},G.createElement(h,{name:"RadioGroup.Label"},G.createElement(X.Provider,{value:ce},G.createElement(j.Provider,{value:ue},i!=null&&G.createElement(Pe,{disabled:p,data:{[i]:s||"on"},overrides:{type:"radio",checked:s!=null},form:P,onReset:me}),$({ourProps:fe,theirProps:y,slot:Te,defaultTag:Ie,name:"RadioGroup"})))))}let Me="div";function Se(o,t){var R;let e=J("RadioGroup.Option"),a=z("RadioGroup.Option"),O=B(),{id:m=`headlessui-radiogroup-option-${O}`,value:P,disabled:i=e.disabled||!1,autoFocus:f=!1,...c}=o,p=W(null),I=V(p,t),[y,T]=se(),[v,C]=le(),n=oe({value:P,disabled:i});te(()=>a.registerOption({id:m,element:p,propsRef:n}),[m,a,p,n]);let U=S(b=>{var d;if(ie(b.currentTarget))return b.preventDefault();a.change(P)&&((d=p.current)==null||d.focus())}),h=((R=e.firstOption)==null?void 0:R.id)===m,{isFocusVisible:D,focusProps:L}=Q({autoFocus:f}),{isHovered:A,hoverProps:M}=Y({isDisabled:i}),l=e.compare(e.value,P),s=pe({ref:I,id:m,role:"radio","aria-checked":l?"true":"false","aria-labelledby":y,"aria-describedby":v,"aria-disabled":i?!0:void 0,tabIndex:(()=>i?-1:l||!e.containsCheckedOption&&h?0:-1)(),onClick:i?void 0:U,autoFocus:f},L,M),_=x(()=>({checked:l,disabled:i,active:D,hover:A,focus:D,autofocus:f}),[l,i,A,D,f]);return G.createElement(C,{name:"RadioGroup.Description"},G.createElement(T,{name:"RadioGroup.Label"},$({ourProps:s,theirProps:c,slot:_,defaultTag:Me,name:"RadioGroup.Option"})))}let He="span";function we(o,t){var R;let e=J("Radio"),a=z("Radio"),O=B(),m=ve(),P=re(),{id:i=m||`headlessui-radio-${O}`,value:f,disabled:c=e.disabled||P||!1,autoFocus:p=!1,...I}=o,y=W(null),T=V(y,t),v=he(),C=xe(),n=oe({value:f,disabled:c});te(()=>a.registerOption({id:i,element:y,propsRef:n}),[i,a,y,n]);let U=S(b=>{var d;if(ie(b.currentTarget))return b.preventDefault();a.change(f)&&((d=y.current)==null||d.focus())}),{isFocusVisible:h,focusProps:D}=Q({autoFocus:p}),{isHovered:L,hoverProps:A}=Y({isDisabled:c}),M=((R=e.firstOption)==null?void 0:R.id)===i,l=e.compare(e.value,f),s=pe({ref:T,id:i,role:"radio","aria-checked":l?"true":"false","aria-labelledby":v,"aria-describedby":C,"aria-disabled":c?!0:void 0,tabIndex:(()=>c?-1:l||!e.containsCheckedOption&&M?0:-1)(),autoFocus:p,onClick:c?void 0:U},D,A),_=x(()=>({checked:l,disabled:c,hover:L,focus:h,autofocus:p}),[l,c,L,h,p]);return $({ourProps:s,theirProps:I,slot:_,defaultTag:He,name:"Radio"})}let Ne=K(Ue),We=K(Se),Be=K(we),Ve=Ce,Ke=Ge,Tt=Object.assign(Ne,{Option:We,Radio:Be,Label:Ve,Description:Ke});export{Be as Radio,Tt as RadioGroup,Ke as RadioGroupDescription,Ve as RadioGroupLabel,We as RadioGroupOption};

@@ -44,2 +44,3 @@ import React, { type ElementType, type Ref } from 'react';

}
/** @deprecated use `<Field>` instead of `<SwitchGroup>` */
export declare let SwitchGroup: _internal_ComponentSwitchGroup;

@@ -51,3 +52,3 @@ /** @deprecated use `<Label>` instead of `<SwitchLabel>` */

export declare let Switch: _internal_ComponentSwitch & {
/** @deprecated use `<SwitchGroup>` instead of `<Switch.Group>` */
/** @deprecated use `<Field>` instead of `<Switch.Group>` */
Group: _internal_ComponentSwitchGroup;

@@ -54,0 +55,0 @@ /** @deprecated use `<Label>` instead of `<Switch.Label>` */

@@ -1,1 +0,1 @@

"use client";import{useFocusRing as V}from"@react-aria/focus";import{useHover as $}from"@react-aria/interactions";import l,{Fragment as q,createContext as z,useCallback as Q,useContext as Y,useMemo as C,useRef as Z,useState as L}from"react";import{useActivePress as ee}from'../../hooks/use-active-press.js';import{useControllable as te}from'../../hooks/use-controllable.js';import{useDisposables as oe}from'../../hooks/use-disposables.js';import{useEvent as m}from'../../hooks/use-event.js';import{useId as re}from'../../hooks/use-id.js';import{useResolveButtonType as ne}from'../../hooks/use-resolve-button-type.js';import{useSyncRefs as le}from'../../hooks/use-sync-refs.js';import{useDisabled as ie}from'../../internal/disabled.js';import{FormFields as ae}from'../../internal/form-fields.js';import{useProvidedId as se}from'../../internal/id.js';import{isDisabledReactIssue7711 as pe}from'../../utils/bugs.js';import{attemptSubmit as ce}from'../../utils/form.js';import{forwardRefWithAs as ue,mergeProps as de,render as G}from'../../utils/render.js';import{Description as me,useDescribedBy as fe,useDescriptions as be}from'../description/description.js';import{Keys as R}from'../keyboard.js';import{Label as he,useLabelledBy as Te,useLabels as ye}from'../label/label.js';let y=z(null);y.displayName="GroupContext";let Se=q;function we(n){var i;let[o,s]=L(null),[f,b]=ye(),[h,t]=be(),p=C(()=>({switch:o,setSwitch:s}),[o,s]),c={},T=n;return l.createElement(t,{name:"Switch.Description",value:h},l.createElement(b,{name:"Switch.Label",value:f,props:{htmlFor:(i=p.switch)==null?void 0:i.id,onClick(u){o&&(u.currentTarget instanceof HTMLLabelElement&&u.preventDefault(),o.click(),o.focus({preventScroll:!0}))}}},l.createElement(y.Provider,{value:p},G({ourProps:c,theirProps:T,slot:{},defaultTag:Se,name:"Switch.Group"}))))}let _e="button";function Pe(n,o){var x;let s=re(),f=se(),b=ie(),{id:h=f||`headlessui-switch-${s}`,disabled:t=b||!1,checked:p,defaultChecked:c=!1,onChange:T,name:i,value:u,form:A,autoFocus:d=!1,...F}=n,S=Y(y),w=Z(null),k=le(w,o,S===null?null:S.setSwitch),[a,r]=te(p,T,c),H=oe(),[_,P]=L(!1),E=m(()=>{P(!0),r==null||r(!a),H.nextFrame(()=>{P(!1)})}),M=m(e=>{if(pe(e.currentTarget))return e.preventDefault();e.preventDefault(),E()}),U=m(e=>{e.key===R.Space?(e.preventDefault(),E()):e.key===R.Enter&&ce(e.currentTarget)}),I=m(e=>e.preventDefault()),B=Te(),K=fe(),{isFocusVisible:g,focusProps:W}=V({autoFocus:d}),{isHovered:D,hoverProps:O}=$({isDisabled:t}),{pressed:v,pressProps:N}=ee({disabled:t}),J=C(()=>({checked:a,disabled:t,hover:D,focus:g,active:v,autofocus:d,changing:_}),[a,D,g,v,t,_,d]),X=de({id:h,ref:k,role:"switch",type:ne(n,w),tabIndex:n.tabIndex===-1?0:(x=n.tabIndex)!=null?x:0,"aria-checked":a,"aria-labelledby":B,"aria-describedby":K,disabled:t||void 0,autoFocus:d,onClick:M,onKeyUp:U,onKeyPress:I},W,O,N),j=Q(()=>r==null?void 0:r(c),[r]);return l.createElement(l.Fragment,null,i!=null&&l.createElement(ae,{disabled:t,data:{[i]:u||"on"},overrides:{type:"checkbox",checked:a},form:A,onReset:j}),G({ourProps:X,theirProps:F,slot:J,defaultTag:_e,name:"Switch"}))}let Ee=ue(Pe),ge=we,De=he,ve=me,je=Object.assign(Ee,{Group:ge,Label:De,Description:ve});export{je as Switch,ve as SwitchDescription,ge as SwitchGroup,De as SwitchLabel};
"use client";import{useFocusRing as $}from"@react-aria/focus";import{useHover as q}from"@react-aria/interactions";import i,{Fragment as z,createContext as Q,useCallback as Y,useContext as Z,useMemo as L,useRef as ee,useState as G}from"react";import{useActivePress as te}from'../../hooks/use-active-press.js';import{useControllable as oe}from'../../hooks/use-controllable.js';import{useDefaultValue as re}from'../../hooks/use-default-value.js';import{useDisposables as ne}from'../../hooks/use-disposables.js';import{useEvent as m}from'../../hooks/use-event.js';import{useId as le}from'../../hooks/use-id.js';import{useResolveButtonType as ie}from'../../hooks/use-resolve-button-type.js';import{useSyncRefs as ae}from'../../hooks/use-sync-refs.js';import{useDisabled as se}from'../../internal/disabled.js';import{FormFields as pe}from'../../internal/form-fields.js';import{useProvidedId as ce}from'../../internal/id.js';import{isDisabledReactIssue7711 as ue}from'../../utils/bugs.js';import{attemptSubmit as de}from'../../utils/form.js';import{forwardRefWithAs as me,mergeProps as fe,render as R}from'../../utils/render.js';import{Description as be,useDescribedBy as he,useDescriptions as Te}from'../description/description.js';import{Keys as A}from'../keyboard.js';import{Label as ye,useLabelledBy as Se,useLabels as we}from'../label/label.js';let S=Q(null);S.displayName="GroupContext";let _e=z;function Pe(n){var a;let[o,p]=G(null),[f,b]=we(),[h,t]=Te(),c=L(()=>({switch:o,setSwitch:p}),[o,p]),T={},y=n;return i.createElement(t,{name:"Switch.Description",value:h},i.createElement(b,{name:"Switch.Label",value:f,props:{htmlFor:(a=c.switch)==null?void 0:a.id,onClick(u){o&&(u.currentTarget instanceof HTMLLabelElement&&u.preventDefault(),o.click(),o.focus({preventScroll:!0}))}}},i.createElement(S.Provider,{value:c},R({ourProps:T,theirProps:y,slot:{},defaultTag:_e,name:"Switch.Group"}))))}let Ee="button";function De(n,o){var C;let p=le(),f=ce(),b=se(),{id:h=f||`headlessui-switch-${p}`,disabled:t=b||!1,checked:c,defaultChecked:T,onChange:y,name:a,value:u,form:F,autoFocus:d=!1,...k}=n,w=Z(S),_=ee(null),H=ae(_,o,w===null?null:w.setSwitch),l=re(T),[s,r]=oe(c,y,l!=null?l:!1),M=ne(),[P,E]=G(!1),D=m(()=>{E(!0),r==null||r(!s),M.nextFrame(()=>{E(!1)})}),U=m(e=>{if(ue(e.currentTarget))return e.preventDefault();e.preventDefault(),D()}),I=m(e=>{e.key===A.Space?(e.preventDefault(),D()):e.key===A.Enter&&de(e.currentTarget)}),B=m(e=>e.preventDefault()),K=Se(),W=he(),{isFocusVisible:g,focusProps:O}=$({autoFocus:d}),{isHovered:v,hoverProps:N}=q({isDisabled:t}),{pressed:x,pressProps:J}=te({disabled:t}),V=L(()=>({checked:s,disabled:t,hover:v,focus:g,active:x,autofocus:d,changing:P}),[s,v,g,x,t,P,d]),X=fe({id:h,ref:H,role:"switch",type:ie(n,_),tabIndex:n.tabIndex===-1?0:(C=n.tabIndex)!=null?C:0,"aria-checked":s,"aria-labelledby":K,"aria-describedby":W,disabled:t||void 0,autoFocus:d,onClick:U,onKeyUp:I,onKeyPress:B},O,N,J),j=Y(()=>{if(l!==void 0)return r==null?void 0:r(l)},[r,l]);return i.createElement(i.Fragment,null,a!=null&&i.createElement(pe,{disabled:t,data:{[a]:u||"on"},overrides:{type:"checkbox",checked:s},form:F,onReset:j}),R({ourProps:X,theirProps:k,slot:V,defaultTag:Ee,name:"Switch"}))}let ge=me(De),ve=Pe,xe=ye,Ce=be,qe=Object.assign(ge,{Group:ve,Label:xe,Description:Ce});export{qe as Switch,Ce as SwitchDescription,ve as SwitchGroup,xe as SwitchLabel};

@@ -1,1 +0,1 @@

"use client";import T,{Fragment as B,createContext as oe,useContext as z,useMemo as se,useRef as E,useState as K}from"react";import{useDisposables as be}from'../../hooks/use-disposables.js';import{useEvent as S}from'../../hooks/use-event.js';import{useFlags as Ee}from'../../hooks/use-flags.js';import{useIsMounted as Se}from'../../hooks/use-is-mounted.js';import{useIsoMorphicEffect as I}from'../../hooks/use-iso-morphic-effect.js';import{useLatestValue as O}from'../../hooks/use-latest-value.js';import{useOnDisappear as Ne}from'../../hooks/use-on-disappear.js';import{useServerHandoffComplete as ae}from'../../hooks/use-server-handoff-complete.js';import{useSyncRefs as le}from'../../hooks/use-sync-refs.js';import{useTransition as ye}from'../../hooks/use-transition.js';import{OpenClosedProvider as Re,State as N,useOpenClosed as ue}from'../../internal/open-closed.js';import{classNames as Q}from'../../utils/class-names.js';import{match as D}from'../../utils/match.js';import{RenderFeatures as Pe,RenderStrategy as x,forwardRefWithAs as Y,render as Te}from'../../utils/render.js';function y(t=""){return t.split(/\s+/).filter(n=>n.length>1)}function de(t){var n;return!!(t.enter||t.enterFrom||t.enterTo||t.leave||t.leaveFrom||t.leaveTo)||((n=t.as)!=null?n:me)!==B||T.Children.count(t.children)===1}let W=oe(null);W.displayName="TransitionContext";var xe=(r=>(r.Visible="visible",r.Hidden="hidden",r))(xe||{});function Fe(){let t=z(W);if(t===null)throw new Error("A <Transition.Child /> is used but it is missing a parent <Transition /> or <Transition.Root />.");return t}function _e(){let t=z(k);if(t===null)throw new Error("A <Transition.Child /> is used but it is missing a parent <Transition /> or <Transition.Root />.");return t}let k=oe(null);k.displayName="NestingContext";function q(t){return"children"in t?q(t.children):t.current.filter(({el:n})=>n.current!==null).filter(({state:n})=>n==="visible").length>0}function fe(t,n){let r=O(t),a=E([]),H=Se(),L=be(),d=S((i,e=x.Hidden)=>{let o=a.current.findIndex(({el:s})=>s===i);o!==-1&&(D(e,{[x.Unmount](){a.current.splice(o,1)},[x.Hidden](){a.current[o].state="hidden"}}),L.microTask(()=>{var s;!q(a)&&H.current&&((s=r.current)==null||s.call(r))}))}),F=S(i=>{let e=a.current.find(({el:o})=>o===i);return e?e.state!=="visible"&&(e.state="visible"):a.current.push({el:i,state:"visible"}),()=>d(i,x.Unmount)}),R=E([]),f=E(Promise.resolve()),C=E({enter:[],leave:[],idle:[]}),m=S((i,e,o)=>{R.current.splice(0),n&&(n.chains.current[e]=n.chains.current[e].filter(([s])=>s!==i)),n==null||n.chains.current[e].push([i,new Promise(s=>{R.current.push(s)})]),n==null||n.chains.current[e].push([i,new Promise(s=>{Promise.all(C.current[e].map(([g,c])=>c)).then(()=>s())})]),e==="enter"?f.current=f.current.then(()=>n==null?void 0:n.wait.current).then(()=>o(e)):o(e)}),h=S((i,e,o)=>{Promise.all(C.current[e].splice(0).map(([s,g])=>g)).then(()=>{var s;(s=R.current.shift())==null||s()}).then(()=>o(e))});return se(()=>({children:a,register:F,unregister:d,onStart:m,onStop:h,wait:f,chains:C}),[F,d,a,m,h,C,f])}let me=B,ce=Pe.RenderStrategy;function De(t,n){var ne,re,ie;let{beforeEnter:r,afterEnter:a,beforeLeave:H,afterLeave:L,enter:d,enterFrom:F,enterTo:R,entered:f,leave:C,leaveFrom:m,leaveTo:h,...i}=t,e=E(null),o=de(t),s=le(...o?[e,n]:n===null?[]:[n]),g=(ne=i.unmount)==null||ne?x.Unmount:x.Hidden,{show:c,appear:V,initial:v}=Fe(),[P,J]=K(c?"visible":"hidden"),$=_e(),{register:w,unregister:M}=$;I(()=>w(e),[w,e]),I(()=>{if(g===x.Hidden&&e.current){if(c&&P!=="visible"){J("visible");return}return D(P,{["hidden"]:()=>M(e),["visible"]:()=>w(e)})}},[P,e,w,M,c,g]);let _=O({base:y(i.className),enter:y(d),enterFrom:y(F),enterTo:y(R),entered:y(f),leave:y(C),leaveFrom:y(m),leaveTo:y(h)}),U=O({beforeEnter:r,afterEnter:a,beforeLeave:H,afterLeave:L}),X=ae();I(()=>{if(o&&X&&P==="visible"&&e.current===null)throw new Error("Did you forget to passthrough the `ref` to the actual DOM node?")},[e,P,X,o]);let Ce=v&&!V,ee=V&&c&&v,te=(()=>ee?"enter":!X||Ce?"idle":c?"enter":"leave")(),A=Ee(0),he=S(b=>D(b,{enter:()=>{var l,u;A.addFlag(N.Opening),(u=(l=U.current).beforeEnter)==null||u.call(l)},leave:()=>{var l,u;A.addFlag(N.Closing),(u=(l=U.current).beforeLeave)==null||u.call(l)},idle:()=>{}})),ge=S(b=>D(b,{enter:()=>{var l,u;A.removeFlag(N.Opening),(u=(l=U.current).afterEnter)==null||u.call(l)},leave:()=>{var l,u;A.removeFlag(N.Closing),(u=(l=U.current).afterLeave)==null||u.call(l)},idle:()=>{}})),j=E(!1),G=fe(()=>{j.current||(J("hidden"),M(e))},$);ye({container:e,classes:_,direction:te,onStart:O(b=>{j.current=!0,G.onStart(e,b,he)}),onStop:O(b=>{j.current=!1,G.onStop(e,b,ge),b==="leave"&&!q(G)&&(J("hidden"),M(e))})});let p=i,ve={ref:s};return ee?p={...p,className:Q(i.className,..._.current.enter,..._.current.enterFrom)}:j.current?(p.className=Q(i.className,(re=e.current)==null?void 0:re.className),p.className===""&&delete p.className):(p.className=Q(i.className,(ie=e.current)==null?void 0:ie.className,...D(te,{enter:[..._.current.enterTo,..._.current.entered],leave:_.current.leaveTo,idle:[]})),p.className===""&&delete p.className),T.createElement(k.Provider,{value:G},T.createElement(Re,{value:D(P,{["visible"]:N.Open,["hidden"]:N.Closed})|A.flags},Te({ourProps:ve,theirProps:p,defaultTag:me,features:ce,visible:P==="visible",name:"Transition.Child"})))}function He(t,n){let{show:r,appear:a=!1,unmount:H=!0,...L}=t,d=E(null),F=de(t),R=le(...F?[d,n]:n===null?[]:[n]);ae();let f=ue();if(r===void 0&&f!==null&&(r=(f&N.Open)===N.Open),r===void 0)throw new Error("A <Transition /> is used but it is missing a `show={true | false}` prop.");let[C,m]=K(r?"visible":"hidden"),h=fe(()=>{r||m("hidden")}),[i,e]=K(!0),o=E([r]);I(()=>{i!==!1&&o.current[o.current.length-1]!==r&&(o.current.push(r),e(!1))},[o,r]);let s=se(()=>({show:r,appear:a,initial:i}),[r,a,i]);Ne(d,()=>m("hidden")),I(()=>{r?m("visible"):!q(h)&&d.current!==null&&m("hidden")},[r,h]);let g={unmount:H},c=S(()=>{var v;i&&e(!1),(v=t.beforeEnter)==null||v.call(t)}),V=S(()=>{var v;i&&e(!1),(v=t.beforeLeave)==null||v.call(t)});return T.createElement(k.Provider,{value:h},T.createElement(W.Provider,{value:s},Te({ourProps:{...g,as:B,children:T.createElement(pe,{ref:R,...g,...L,beforeEnter:c,beforeLeave:V})},theirProps:{},defaultTag:B,features:ce,visible:C==="visible",name:"Transition"})))}function Le(t,n){let r=z(W)!==null,a=ue()!==null;return T.createElement(T.Fragment,null,!r&&a?T.createElement(Z,{ref:n,...t}):T.createElement(pe,{ref:n,...t}))}let Z=Y(He),pe=Y(De),Ae=Y(Le),Ke=Object.assign(Z,{Child:Ae,Root:Z});export{Ke as Transition,Ae as TransitionChild};
"use client";import T,{Fragment as B,createContext as oe,useContext as z,useMemo as se,useRef as E,useState as K}from"react";import{useDisposables as be}from'../../hooks/use-disposables.js';import{useEvent as S}from'../../hooks/use-event.js';import{useFlags as Ee}from'../../hooks/use-flags.js';import{useIsMounted as Se}from'../../hooks/use-is-mounted.js';import{useIsoMorphicEffect as I}from'../../hooks/use-iso-morphic-effect.js';import{useLatestValue as O}from'../../hooks/use-latest-value.js';import{useOnDisappear as Ne}from'../../hooks/use-on-disappear.js';import{useServerHandoffComplete as ae}from'../../hooks/use-server-handoff-complete.js';import{useSyncRefs as le}from'../../hooks/use-sync-refs.js';import{useTransition as ye}from'../../hooks/use-transition.js';import{OpenClosedProvider as Re,State as N,useOpenClosed as ue}from'../../internal/open-closed.js';import{classNames as Q}from'../../utils/class-names.js';import{match as D}from'../../utils/match.js';import{RenderFeatures as Pe,RenderStrategy as x,forwardRefWithAs as Y,render as Te}from'../../utils/render.js';function y(t=""){return t.split(/\s+/).filter(n=>n.length>1)}function de(t){var n;return!!(t.enter||t.enterFrom||t.enterTo||t.leave||t.leaveFrom||t.leaveTo)||((n=t.as)!=null?n:me)!==B||T.Children.count(t.children)===1}let W=oe(null);W.displayName="TransitionContext";var xe=(r=>(r.Visible="visible",r.Hidden="hidden",r))(xe||{});function Fe(){let t=z(W);if(t===null)throw new Error("A <Transition.Child /> is used but it is missing a parent <Transition /> or <Transition.Root />.");return t}function _e(){let t=z(k);if(t===null)throw new Error("A <Transition.Child /> is used but it is missing a parent <Transition /> or <Transition.Root />.");return t}let k=oe(null);k.displayName="NestingContext";function q(t){return"children"in t?q(t.children):t.current.filter(({el:n})=>n.current!==null).filter(({state:n})=>n==="visible").length>0}function fe(t,n){let r=O(t),a=E([]),H=Se(),L=be(),d=S((i,e=x.Hidden)=>{let o=a.current.findIndex(({el:s})=>s===i);o!==-1&&(D(e,{[x.Unmount](){a.current.splice(o,1)},[x.Hidden](){a.current[o].state="hidden"}}),L.microTask(()=>{var s;!q(a)&&H.current&&((s=r.current)==null||s.call(r))}))}),F=S(i=>{let e=a.current.find(({el:o})=>o===i);return e?e.state!=="visible"&&(e.state="visible"):a.current.push({el:i,state:"visible"}),()=>d(i,x.Unmount)}),R=E([]),f=E(Promise.resolve()),C=E({enter:[],leave:[],idle:[]}),m=S((i,e,o)=>{R.current.splice(0),n&&(n.chains.current[e]=n.chains.current[e].filter(([s])=>s!==i)),n==null||n.chains.current[e].push([i,new Promise(s=>{R.current.push(s)})]),n==null||n.chains.current[e].push([i,new Promise(s=>{Promise.all(C.current[e].map(([g,c])=>c)).then(()=>s())})]),e==="enter"?f.current=f.current.then(()=>n==null?void 0:n.wait.current).then(()=>o(e)):o(e)}),h=S((i,e,o)=>{Promise.all(C.current[e].splice(0).map(([s,g])=>g)).then(()=>{var s;(s=R.current.shift())==null||s()}).then(()=>o(e))});return se(()=>({children:a,register:F,unregister:d,onStart:m,onStop:h,wait:f,chains:C}),[F,d,a,m,h,C,f])}let me=B,ce=Pe.RenderStrategy;function De(t,n){var ne,re,ie;let{beforeEnter:r,afterEnter:a,beforeLeave:H,afterLeave:L,enter:d,enterFrom:F,enterTo:R,entered:f,leave:C,leaveFrom:m,leaveTo:h,...i}=t,e=E(null),o=de(t),s=le(...o?[e,n]:n===null?[]:[n]),g=(ne=i.unmount)==null||ne?x.Unmount:x.Hidden,{show:c,appear:V,initial:v}=Fe(),[P,J]=K(c?"visible":"hidden"),$=_e(),{register:w,unregister:M}=$;I(()=>w(e),[w,e]),I(()=>{if(g===x.Hidden&&e.current){if(c&&P!=="visible"){J("visible");return}return D(P,{["hidden"]:()=>M(e),["visible"]:()=>w(e)})}},[P,e,w,M,c,g]);let _=O({base:y(i.className),enter:y(d),enterFrom:y(F),enterTo:y(R),entered:y(f),leave:y(C),leaveFrom:y(m),leaveTo:y(h)}),U=O({beforeEnter:r,afterEnter:a,beforeLeave:H,afterLeave:L}),X=ae();I(()=>{if(o&&X&&P==="visible"&&e.current===null)throw new Error("Did you forget to passthrough the `ref` to the actual DOM node?")},[e,P,X,o]);let Ce=v&&!V,ee=V&&c&&v,te=(()=>ee?"enter":!X||Ce?"idle":c?"enter":"leave")(),A=Ee(0),he=S(b=>D(b,{enter:()=>{var l,u;A.addFlag(N.Opening),(u=(l=U.current).beforeEnter)==null||u.call(l)},leave:()=>{var l,u;A.addFlag(N.Closing),(u=(l=U.current).beforeLeave)==null||u.call(l)},idle:()=>{}})),ge=S(b=>D(b,{enter:()=>{var l,u;A.removeFlag(N.Opening),(u=(l=U.current).afterEnter)==null||u.call(l)},leave:()=>{var l,u;A.removeFlag(N.Closing),(u=(l=U.current).afterLeave)==null||u.call(l)},idle:()=>{}})),j=E(!1),G=fe(()=>{j.current||(J("hidden"),M(e))},$);ye({container:e,classes:_,direction:te,onStart:O(b=>{j.current=!0,G.onStart(e,b,he)}),onStop:O(b=>{j.current=!1,G.onStop(e,b,ge),b==="leave"&&!q(G)&&(J("hidden"),M(e))})});let p=i,ve={ref:s};return ee?p={...p,className:Q(i.className,..._.current.enter,..._.current.enterFrom)}:j.current?(p.className=Q(i.className,(re=e.current)==null?void 0:re.className),p.className===""&&delete p.className):(p.className=Q(i.className,(ie=e.current)==null?void 0:ie.className,...D(te,{enter:[..._.current.enterTo,..._.current.entered],leave:_.current.leaveTo,idle:[]})),p.className===""&&delete p.className),T.createElement(k.Provider,{value:G},T.createElement(Re,{value:D(P,{["visible"]:N.Open,["hidden"]:N.Closed})|A.flags},Te({ourProps:ve,theirProps:p,defaultTag:me,features:ce,visible:P==="visible",name:"Transition.Child"})))}function He(t,n){let{show:r,appear:a=!1,unmount:H=!0,...L}=t,d=E(null),F=de(t),R=le(...F?[d,n]:n===null?[]:[n]);ae();let f=ue();if(r===void 0&&f!==null&&(r=(f&N.Open)===N.Open),r===void 0)throw new Error("A <Transition /> is used but it is missing a `show={true | false}` prop.");let[C,m]=K(r?"visible":"hidden"),h=fe(()=>{r||m("hidden")}),[i,e]=K(!0),o=E([r]);I(()=>{i!==!1&&o.current[o.current.length-1]!==r&&(o.current.push(r),e(!1))},[o,r]);let s=se(()=>({show:r,appear:a,initial:i}),[r,a,i]);Ne(r,d,()=>m("hidden")),I(()=>{r?m("visible"):!q(h)&&d.current!==null&&m("hidden")},[r,h]);let g={unmount:H},c=S(()=>{var v;i&&e(!1),(v=t.beforeEnter)==null||v.call(t)}),V=S(()=>{var v;i&&e(!1),(v=t.beforeLeave)==null||v.call(t)});return T.createElement(k.Provider,{value:h},T.createElement(W.Provider,{value:s},Te({ourProps:{...g,as:B,children:T.createElement(pe,{ref:R,...g,...L,beforeEnter:c,beforeLeave:V})},theirProps:{},defaultTag:B,features:ce,visible:C==="visible",name:"Transition"})))}function Le(t,n){let r=z(W)!==null,a=ue()!==null;return T.createElement(T.Fragment,null,!r&&a?T.createElement(Z,{ref:n,...t}):T.createElement(pe,{ref:n,...t}))}let Z=Y(He),pe=Y(De),Ae=Y(Le),Ke=Object.assign(Z,{Child:Ae,Root:Z});export{Ke as Transition,Ae as TransitionChild};

@@ -1,1 +0,1 @@

export declare function useDocumentOverflowLockedEffect(doc: Document | null, shouldBeLocked: boolean, meta?: (meta: Record<string, any>) => Record<string, any>): boolean;
export declare function useDocumentOverflowLockedEffect(shouldBeLocked: boolean, doc: Document | null, meta?: (meta: Record<string, any>) => Record<string, any>): boolean;

@@ -1,1 +0,1 @@

import{useStore as s}from'../../hooks/use-store.js';import{useIsoMorphicEffect as u}from'../use-iso-morphic-effect.js';import{overflows as t}from'./overflow-store.js';function a(e,r,n=()=>({containers:[]})){let f=s(t),o=e?f.get(e):void 0,i=o?o.count>0:!1;return u(()=>{if(!(!e||!r))return t.dispatch("PUSH",e,n),()=>t.dispatch("POP",e,n)},[r,e]),i}export{a as useDocumentOverflowLockedEffect};
import{useStore as s}from'../../hooks/use-store.js';import{useIsoMorphicEffect as u}from'../use-iso-morphic-effect.js';import{overflows as t}from'./overflow-store.js';function a(r,e,n=()=>({containers:[]})){let f=s(t),o=e?f.get(e):void 0,i=o?o.count>0:!1;return u(()=>{if(!(!e||!r))return t.dispatch("PUSH",e,n),()=>t.dispatch("POP",e,n)},[r,e]),i}export{a as useDocumentOverflowLockedEffect};
import { type MutableRefObject } from 'react';
export declare function useDidElementMove(element: MutableRefObject<HTMLElement | null>, enabled?: boolean): boolean;
export declare function useDidElementMove(enabled: boolean, element: MutableRefObject<HTMLElement | null>): boolean;

@@ -1,1 +0,1 @@

import{useRef as o}from"react";import{useIsoMorphicEffect as f}from'./use-iso-morphic-effect.js';function p(e,r=!0){let t=o({left:0,top:0});if(f(()=>{let u=e.current;if(!u)return;let l=u.getBoundingClientRect();l&&(t.current=l)},[r]),e.current==null||!r||e.current===document.activeElement)return!1;let n=e.current.getBoundingClientRect();return n.top!==t.current.top||n.left!==t.current.left}export{p as useDidElementMove};
import{useRef as o}from"react";import{useIsoMorphicEffect as f}from'./use-iso-morphic-effect.js';function p(r,e){let t=o({left:0,top:0});if(f(()=>{let u=e.current;if(!u)return;let l=u.getBoundingClientRect();l&&(t.current=l)},[r]),e.current==null||!r||e.current===document.activeElement)return!1;let n=e.current.getBoundingClientRect();return n.top!==t.current.top||n.left!==t.current.left}export{p as useDidElementMove};

@@ -26,5 +26,5 @@ /**

*/
export declare function useInertOthers({ allowed, disallowed, }?: {
export declare function useInertOthers(enabled: boolean, { allowed, disallowed, }?: {
allowed?: () => (HTMLElement | null)[];
disallowed?: () => (HTMLElement | null)[];
}, enabled?: boolean): void;
}): void;

@@ -1,1 +0,1 @@

import{disposables as m}from'../utils/disposables.js';import{getOwnerDocument as M}from'../utils/owner.js';import{useIsoMorphicEffect as g}from'./use-iso-morphic-effect.js';let f=new Map,u=new Map;function l(t){var r;let e=(r=u.get(t))!=null?r:0;return u.set(t,e+1),e!==0?()=>p(t):(f.set(t,{"aria-hidden":t.getAttribute("aria-hidden"),inert:t.inert}),t.setAttribute("aria-hidden","true"),t.inert=!0,()=>p(t))}function p(t){var n;let e=(n=u.get(t))!=null?n:1;if(e===1?u.delete(t):u.set(t,e-1),e!==1)return;let r=f.get(t);r&&(r["aria-hidden"]===null?t.removeAttribute("aria-hidden"):t.setAttribute("aria-hidden",r["aria-hidden"]),t.inert=r.inert,f.delete(t))}function T({allowed:t,disallowed:e}={},r=!0){g(()=>{var s,c;if(!r)return;let n=m();for(let i of(s=e==null?void 0:e())!=null?s:[])i&&n.add(l(i));let a=(c=t==null?void 0:t())!=null?c:[];for(let i of a){if(!i)continue;let d=M(i);if(!d)continue;let o=i.parentElement;for(;o&&o!==d.body;){for(let h of o.children)a.some(E=>h.contains(E))||n.add(l(h));o=o.parentElement}}return n.dispose},[r,t,e])}export{T as useInertOthers};
import{disposables as M}from'../utils/disposables.js';import{getOwnerDocument as b}from'../utils/owner.js';import{useIsTopLayer as L}from'./use-is-top-layer.js';import{useIsoMorphicEffect as T}from'./use-iso-morphic-effect.js';let f=new Map,u=new Map;function h(t){var e;let r=(e=u.get(t))!=null?e:0;return u.set(t,r+1),r!==0?()=>m(t):(f.set(t,{"aria-hidden":t.getAttribute("aria-hidden"),inert:t.inert}),t.setAttribute("aria-hidden","true"),t.inert=!0,()=>m(t))}function m(t){var i;let r=(i=u.get(t))!=null?i:1;if(r===1?u.delete(t):u.set(t,r-1),r!==1)return;let e=f.get(t);e&&(e["aria-hidden"]===null?t.removeAttribute("aria-hidden"):t.setAttribute("aria-hidden",e["aria-hidden"]),t.inert=e.inert,f.delete(t))}function y(t,{allowed:r,disallowed:e}={}){let i=L(t,"inert-others");T(()=>{var d,c;if(!i)return;let a=M();for(let n of(d=e==null?void 0:e())!=null?d:[])n&&a.add(h(n));let s=(c=r==null?void 0:r())!=null?c:[];for(let n of s){if(!n)continue;let l=b(n);if(!l)continue;let o=n.parentElement;for(;o&&o!==l.body;){for(let p of o.children)s.some(E=>p.contains(E))||a.add(h(p));o=o.parentElement}}return a.dispose},[i,r,e])}export{y as useInertOthers};

@@ -9,2 +9,2 @@ import { type MutableRefObject } from 'react';

*/
export declare function useOnDisappear(ref: MutableRefObject<HTMLElement | null> | HTMLElement | null, cb: () => void, enabled?: boolean): void;
export declare function useOnDisappear(enabled: boolean, ref: MutableRefObject<HTMLElement | null> | HTMLElement | null, cb: () => void): void;

@@ -1,1 +0,1 @@

import{useEffect as o}from"react";import{disposables as u}from'../utils/disposables.js';import{useLatestValue as c}from'./use-latest-value.js';function m(n,l,s=!0){let i=c(t=>{let e=t.getBoundingClientRect();e.x===0&&e.y===0&&e.width===0&&e.height===0&&l()});o(()=>{if(!s)return;let t=n===null?null:n instanceof HTMLElement?n:n.current;if(!t)return;let e=u();if(typeof ResizeObserver!="undefined"){let r=new ResizeObserver(()=>i.current(t));r.observe(t),e.add(()=>r.disconnect())}if(typeof IntersectionObserver!="undefined"){let r=new IntersectionObserver(()=>i.current(t));r.observe(t),e.add(()=>r.disconnect())}return()=>e.dispose()},[n,i,s])}export{m as useOnDisappear};
import{useEffect as o}from"react";import{disposables as u}from'../utils/disposables.js';import{useLatestValue as c}from'./use-latest-value.js';function m(s,n,l){let i=c(t=>{let e=t.getBoundingClientRect();e.x===0&&e.y===0&&e.width===0&&e.height===0&&l()});o(()=>{if(!s)return;let t=n===null?null:n instanceof HTMLElement?n:n.current;if(!t)return;let e=u();if(typeof ResizeObserver!="undefined"){let r=new ResizeObserver(()=>i.current(t));r.observe(t),e.add(()=>r.disconnect())}if(typeof IntersectionObserver!="undefined"){let r=new IntersectionObserver(()=>i.current(t));r.observe(t),e.add(()=>r.disconnect())}return()=>e.dispose()},[n,i,s])}export{m as useOnDisappear};

@@ -5,3 +5,3 @@ import { type MutableRefObject } from 'react';

type ContainerInput = Container | ContainerCollection;
export declare function useOutsideClick(containers: ContainerInput | (() => ContainerInput), cb: (event: MouseEvent | PointerEvent | FocusEvent | TouchEvent, target: HTMLElement) => void, enabled?: boolean): void;
export declare function useOutsideClick(enabled: boolean, containers: ContainerInput | (() => ContainerInput), cb: (event: MouseEvent | PointerEvent | FocusEvent | TouchEvent, target: HTMLElement) => void): void;
export {};

@@ -1,1 +0,1 @@

import{useEffect as d,useRef as f}from"react";import{FocusableMode as p,isFocusableElement as C}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 T}from'./use-window-event.js';function w(s,m,a=!0){let i=f(!1);d(()=>{requestAnimationFrame(()=>{i.current=a})},[a]);function c(e,r){if(!i.current||e.defaultPrevented)return;let t=r(e);if(t===null||!t.getRootNode().contains(t)||!t.isConnected)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:u.current;if(n!=null&&n.contains(t)||e.composed&&e.composedPath().includes(n))return}return!C(t,p.Loose)&&t.tabIndex!==-1&&e.preventDefault(),m(e,t)}let o=f(null);l("pointerdown",e=>{var r,t;i.current&&(o.current=((t=(r=e.composedPath)==null?void 0:r.call(e))==null?void 0:t[0])||e.target)},!0),l("mousedown",e=>{var r,t;i.current&&(o.current=((t=(r=e.composedPath)==null?void 0:r.call(e))==null?void 0:t[0])||e.target)},!0),l("click",e=>{M()||o.current&&(c(e,()=>o.current),o.current=null)},!0),l("touchend",e=>c(e,()=>e.target instanceof HTMLElement?e.target:null),!0),T("blur",e=>c(e,()=>window.document.activeElement instanceof HTMLIFrameElement?window.document.activeElement:null),!0)}export{w as useOutsideClick};
import{useEffect as p,useRef as f}from"react";import{FocusableMode as C,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{useIsTopLayer as b}from'./use-is-top-layer.js';import{useWindowEvent as L}from'./use-window-event.js';function I(s,m,E){let a=b(s,"outside-click"),i=f(!1);p(()=>{requestAnimationFrame(()=>{i.current=a})},[a]);function c(e,r){if(!i.current||e.defaultPrevented)return;let t=r(e);if(t===null||!t.getRootNode().contains(t)||!t.isConnected)return;let d=function o(n){return typeof n=="function"?o(n()):Array.isArray(n)||n instanceof Set?n:[n]}(m);for(let o of d){if(o===null)continue;let n=o instanceof HTMLElement?o:o.current;if(n!=null&&n.contains(t)||e.composed&&e.composedPath().includes(n))return}return!T(t,C.Loose)&&t.tabIndex!==-1&&e.preventDefault(),E(e,t)}let u=f(null);l("pointerdown",e=>{var r,t;i.current&&(u.current=((t=(r=e.composedPath)==null?void 0:r.call(e))==null?void 0:t[0])||e.target)},!0),l("mousedown",e=>{var r,t;i.current&&(u.current=((t=(r=e.composedPath)==null?void 0:r.call(e))==null?void 0:t[0])||e.target)},!0),l("click",e=>{M()||u.current&&(c(e,()=>u.current),u.current=null)},!0),l("touchend",e=>c(e,()=>e.target instanceof HTMLElement?e.target:null),!0),L("blur",e=>c(e,()=>window.document.activeElement instanceof HTMLIFrameElement?window.document.activeElement:null),!0)}export{I as useOutsideClick};

@@ -1,1 +0,1 @@

export declare function useScrollLock(ownerDocument: Document | null, enabled: boolean, resolveAllowedContainers?: () => HTMLElement[]): void;
export declare function useScrollLock(enabled: boolean, ownerDocument: Document | null, resolveAllowedContainers?: () => HTMLElement[]): void;

@@ -1,1 +0,1 @@

import{useDocumentOverflowLockedEffect as l}from'./document-overflow/use-document-overflow.js';function u(e,n,c=()=>[document.body]){l(e,n,t=>{var o;return{containers:[...(o=t.containers)!=null?o:[],c]}})}export{u as useScrollLock};
import{useDocumentOverflowLockedEffect as l}from'./document-overflow/use-document-overflow.js';import{useIsTopLayer as m}from'./use-is-top-layer.js';function f(e,c,n=()=>[document.body]){let r=m(e,"scroll-lock");l(r,c,t=>{var o;return{containers:[...(o=t.containers)!=null?o:[],n]}})}export{f as useScrollLock};
type AcceptNode = (node: HTMLElement) => typeof NodeFilter.FILTER_ACCEPT | typeof NodeFilter.FILTER_SKIP | typeof NodeFilter.FILTER_REJECT;
export declare function useTreeWalker({ container, accept, walk, enabled, }: {
export declare function useTreeWalker(enabled: boolean, { container, accept, walk, }: {
container: HTMLElement | null;
accept: AcceptNode;
walk(node: HTMLElement): void;
enabled?: boolean;
}): void;
export {};

@@ -1,1 +0,1 @@

import{useEffect as m,useRef as E}from"react";import{getOwnerDocument as T}from'../utils/owner.js';import{useIsoMorphicEffect as N}from'./use-iso-morphic-effect.js';function F({container:e,accept:t,walk:r,enabled:c=!0}){let o=E(t),l=E(r);m(()=>{o.current=t,l.current=r},[t,r]),N(()=>{if(!e||!c)return;let n=T(e);if(!n)return;let f=o.current,p=l.current,d=Object.assign(i=>f(i),{acceptNode:f}),u=n.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,d,!1);for(;u.nextNode();)p(u.currentNode)},[e,c,o,l])}export{F as useTreeWalker};
import{useEffect as T,useRef as E}from"react";import{getOwnerDocument as d}from'../utils/owner.js';import{useIsoMorphicEffect as N}from'./use-iso-morphic-effect.js';function F(c,{container:e,accept:t,walk:r}){let o=E(t),l=E(r);T(()=>{o.current=t,l.current=r},[t,r]),N(()=>{if(!e||!c)return;let n=d(e);if(!n)return;let f=o.current,p=l.current,i=Object.assign(m=>f(m),{acceptNode:f}),u=n.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,i,!1);for(;u.nextNode();)p(u.currentNode)},[e,c,o,l])}export{F as useTreeWalker};

@@ -1,1 +0,1 @@

import*as r from"react";const s=r.createContext(null);function a(){return{groups:new Map,get(n,t){var c;let e=this.groups.get(n);e||(e=new Map,this.groups.set(n,e));let l=(c=e.get(t))!=null?c:0;e.set(t,l+1);let o=Array.from(e.keys()).indexOf(t);function i(){let u=e.get(t);u>1?e.set(t,u-1):e.delete(t)}return[o,i]}}}function C({children:n}){let t=r.useRef(a());return r.createElement(s.Provider,{value:t},n)}function d(n){let t=r.useContext(s);if(!t)throw new Error("You must wrap your component in a <StableCollection>");let e=f(),[l,o]=t.current.get(n,e);return r.useEffect(()=>o,[]),l}function f(){var l,o,i;let n=(i=(o=(l=r.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED)==null?void 0:l.ReactCurrentOwner)==null?void 0:o.current)!=null?i:null;if(!n)return Symbol();let t=[],e=n;for(;e;)t.push(e.index),e=e.return;return"$."+t.join(".")}export{C as StableCollection,d as useStableCollectionIndex};
import*as l from"react";const s=l.createContext(null);function a(){return{groups:new Map,get(o,e){var i;let t=this.groups.get(o);t||(t=new Map,this.groups.set(o,t));let n=(i=t.get(e))!=null?i:0;t.set(e,n+1);let r=Array.from(t.keys()).indexOf(e);function u(){let c=t.get(e);c>1?t.set(e,c-1):t.delete(e)}return[r,u]}}}function f({children:o}){let e=l.useRef(a());return l.createElement(s.Provider,{value:e},o)}function C(o){let e=l.useContext(s);if(!e)throw new Error("You must wrap your component in a <StableCollection>");let t=l.useId(),[n,r]=e.current.get(o,t);return l.useEffect(()=>r,[]),n}export{f as StableCollection,C as useStableCollectionIndex};
{
"name": "@headlessui/react",
"version": "0.0.0-insiders.300e9eb",
"version": "0.0.0-insiders.3070ad9",
"description": "A set of completely unstyled, fully accessible UI components for React, designed to integrate beautifully with Tailwind CSS.",

@@ -49,4 +49,4 @@ "main": "dist/index.cjs",

"devDependencies": {
"@testing-library/react": "^15.0.5",
"@types/react": "^18.3.1",
"@testing-library/react": "^15.0.7",
"@types/react": "^18.3.3",
"@types/react-dom": "^18.3.0",

@@ -58,7 +58,7 @@ "react": "^18.3.1",

"dependencies": {
"@floating-ui/react": "^0.26.13",
"@floating-ui/react": "^0.26.16",
"@tanstack/react-virtual": "3.5.0",
"@react-aria/focus": "^3.16.2",
"@react-aria/interactions": "^3.21.1"
"@react-aria/focus": "^3.17.1",
"@react-aria/interactions": "^3.21.3"
}
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc