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 2.1.3 to 2.1.4

2

dist/components/combobox/combobox.js

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

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

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

"use client";import{useFocusRing as Q}from"@react-aria/focus";import{useHover as Y}from"@react-aria/interactions";import y,{Fragment as G,createContext as C,useContext as R,useEffect as K,useMemo as A,useReducer as Z,useRef as W}from"react";import{useActivePress as ee}from'../../hooks/use-active-press.js';import{useEvent as P}from'../../hooks/use-event.js';import{useId as j}from'../../hooks/use-id.js';import{useResolveButtonType as te}from'../../hooks/use-resolve-button-type.js';import{optionalRef as ne,useSyncRefs as I}from'../../hooks/use-sync-refs.js';import{transitionDataAttributes as oe,useTransition as le}from'../../hooks/use-transition.js';import{CloseProvider as re}from'../../internal/close-provider.js';import{OpenClosedProvider as se,ResetOpenClosedProvider as ue,State as b,useOpenClosed as ie}from'../../internal/open-closed.js';import{isDisabledReactIssue7711 as ae}from'../../utils/bugs.js';import{match as x}from'../../utils/match.js';import{getOwnerDocument as pe}from'../../utils/owner.js';import{RenderFeatures as $,forwardRefWithAs as L,mergeProps as J,render as B,useMergeRefsFn as X}from'../../utils/render.js';import{startTransition as ce}from'../../utils/start-transition.js';import{Keys as g}from'../keyboard.js';var de=(l=>(l[l.Open=0]="Open",l[l.Closed=1]="Closed",l))(de||{}),Te=(n=>(n[n.ToggleDisclosure=0]="ToggleDisclosure",n[n.CloseDisclosure=1]="CloseDisclosure",n[n.SetButtonId=2]="SetButtonId",n[n.SetPanelId=3]="SetPanelId",n[n.SetButtonElement=4]="SetButtonElement",n[n.SetPanelElement=5]="SetPanelElement",n))(Te||{});let fe={[0]:e=>({...e,disclosureState:x(e.disclosureState,{[0]:1,[1]:0})}),[1]:e=>e.disclosureState===1?e:{...e,disclosureState:1},[2](e,t){return e.buttonId===t.buttonId?e:{...e,buttonId:t.buttonId}},[3](e,t){return e.panelId===t.panelId?e:{...e,panelId:t.panelId}},[4](e,t){return e.buttonElement===t.element?e:{...e,buttonElement:t.element}},[5](e,t){return e.panelElement===t.element?e:{...e,panelElement:t.element}}},v=C(null);v.displayName="DisclosureContext";function O(e){let t=R(v);if(t===null){let l=new Error(`<${e} /> is missing a parent <Disclosure /> component.`);throw Error.captureStackTrace&&Error.captureStackTrace(l,O),l}return t}let _=C(null);_.displayName="DisclosureAPIContext";function V(e){let t=R(_);if(t===null){let l=new Error(`<${e} /> is missing a parent <Disclosure /> component.`);throw Error.captureStackTrace&&Error.captureStackTrace(l,V),l}return t}let M=C(null);M.displayName="DisclosurePanelContext";function me(){return R(M)}function De(e,t){return x(t.type,fe,e,t)}let ye=G;function Pe(e,t){let{defaultOpen:l=!1,...p}=e,i=W(null),c=I(t,ne(a=>{i.current=a},e.as===void 0||e.as===G)),n=Z(De,{disclosureState:l?0:1,buttonElement:null,panelElement:null,buttonId:null,panelId:null}),[{disclosureState:o,buttonId:r},f]=n,s=P(a=>{f({type:1});let T=pe(i);if(!T||!r)return;let d=(()=>a?a instanceof HTMLElement?a:a.current instanceof HTMLElement?a.current:T.getElementById(r):T.getElementById(r))();d==null||d.focus()}),m=A(()=>({close:s}),[s]),D=A(()=>({open:o===0,close:s}),[o,s]),E={ref:c};return y.createElement(v.Provider,{value:n},y.createElement(_.Provider,{value:m},y.createElement(re,{value:s},y.createElement(se,{value:x(o,{[0]:b.Open,[1]:b.Closed})},B({ourProps:E,theirProps:p,slot:D,defaultTag:ye,name:"Disclosure"})))))}let Ee="button";function Se(e,t){let l=j(),{id:p=`headlessui-disclosure-button-${l}`,disabled:i=!1,autoFocus:c=!1,...n}=e,[o,r]=O("Disclosure.Button"),f=me(),s=f===null?!1:f===o.panelId,m=W(null),D=I(m,t,s?null:P(u=>r({type:4,element:u}))),E=X();K(()=>{if(!s)return r({type:2,buttonId:p}),()=>{r({type:2,buttonId:null})}},[p,r,s]);let a=P(u=>{var S;if(s){if(o.disclosureState===1)return;switch(u.key){case g.Space:case g.Enter:u.preventDefault(),u.stopPropagation(),r({type:0}),(S=o.buttonElement)==null||S.focus();break}}else switch(u.key){case g.Space:case g.Enter:u.preventDefault(),u.stopPropagation(),r({type:0});break}}),T=P(u=>{switch(u.key){case g.Space:u.preventDefault();break}}),d=P(u=>{var S;ae(u.currentTarget)||i||(s?(r({type:0}),(S=o.buttonElement)==null||S.focus()):r({type:0}))}),{isFocusVisible:F,focusProps:H}=Q({autoFocus:c}),{isHovered:h,hoverProps:U}=Y({isDisabled:i}),{pressed:N,pressProps:k}=ee({disabled:i}),q=A(()=>({open:o.disclosureState===0,hover:h,active:N,disabled:i,focus:F,autofocus:c}),[o,h,N,F,i,c]),w=te(e,o.buttonElement),z=s?J({ref:D,type:w,disabled:i||void 0,autoFocus:c,onKeyDown:a,onClick:d},H,U,k):J({ref:D,id:p,type:w,"aria-expanded":o.disclosureState===0,"aria-controls":o.panelElement?o.panelId:void 0,disabled:i||void 0,autoFocus:c,onKeyDown:a,onKeyUp:T,onClick:d},H,U,k);return B({mergeRefs:E,ourProps:z,theirProps:n,slot:q,defaultTag:Ee,name:"Disclosure.Button"})}let ge="div",Ae=$.RenderStrategy|$.Static;function be(e,t){let l=j(),{id:p=`headlessui-disclosure-panel-${l}`,transition:i=!1,...c}=e,[n,o]=O("Disclosure.Panel"),{close:r}=V("Disclosure.Panel"),f=X(),s=I(t,P(d=>{ce(()=>o({type:5,element:d}))}));K(()=>(o({type:3,panelId:p}),()=>{o({type:3,panelId:null})}),[p,o]);let m=ie(),[D,E]=le(i,n.panelElement,m!==null?(m&b.Open)===b.Open:n.disclosureState===0),a=A(()=>({open:n.disclosureState===0,close:r}),[n.disclosureState,r]),T={ref:s,id:p,...oe(E)};return y.createElement(ue,null,y.createElement(M.Provider,{value:n.panelId},B({mergeRefs:f,ourProps:T,theirProps:c,slot:a,defaultTag:ge,features:Ae,visible:D,name:"Disclosure.Panel"})))}let Ce=L(Pe),Re=L(Se),Ie=L(be),je=Object.assign(Ce,{Button:Re,Panel:Ie});export{je as Disclosure,Re as DisclosureButton,Ie as DisclosurePanel};
"use client";import{useFocusRing as Q}from"@react-aria/focus";import{useHover as Y}from"@react-aria/interactions";import y,{Fragment as G,createContext as I,useContext as x,useEffect as K,useMemo as C,useReducer as Z,useRef as W,useState as ee}from"react";import{useActivePress as te}from'../../hooks/use-active-press.js';import{useEvent as P}from'../../hooks/use-event.js';import{useId as j}from'../../hooks/use-id.js';import{useResolveButtonType as ne}from'../../hooks/use-resolve-button-type.js';import{optionalRef as oe,useSyncRefs as L}from'../../hooks/use-sync-refs.js';import{transitionDataAttributes as le,useTransition as se}from'../../hooks/use-transition.js';import{CloseProvider as re}from'../../internal/close-provider.js';import{OpenClosedProvider as ue,ResetOpenClosedProvider as ie,State as R,useOpenClosed as ae}from'../../internal/open-closed.js';import{isDisabledReactIssue7711 as pe}from'../../utils/bugs.js';import{match as B}from'../../utils/match.js';import{getOwnerDocument as ce}from'../../utils/owner.js';import{RenderFeatures as $,forwardRefWithAs as v,mergeProps as J,render as O,useMergeRefsFn as X}from'../../utils/render.js';import{startTransition as de}from'../../utils/start-transition.js';import{Keys as g}from'../keyboard.js';var Te=(l=>(l[l.Open=0]="Open",l[l.Closed=1]="Closed",l))(Te||{}),fe=(n=>(n[n.ToggleDisclosure=0]="ToggleDisclosure",n[n.CloseDisclosure=1]="CloseDisclosure",n[n.SetButtonId=2]="SetButtonId",n[n.SetPanelId=3]="SetPanelId",n[n.SetButtonElement=4]="SetButtonElement",n[n.SetPanelElement=5]="SetPanelElement",n))(fe||{});let me={[0]:e=>({...e,disclosureState:B(e.disclosureState,{[0]:1,[1]:0})}),[1]:e=>e.disclosureState===1?e:{...e,disclosureState:1},[2](e,t){return e.buttonId===t.buttonId?e:{...e,buttonId:t.buttonId}},[3](e,t){return e.panelId===t.panelId?e:{...e,panelId:t.panelId}},[4](e,t){return e.buttonElement===t.element?e:{...e,buttonElement:t.element}},[5](e,t){return e.panelElement===t.element?e:{...e,panelElement:t.element}}},_=I(null);_.displayName="DisclosureContext";function M(e){let t=x(_);if(t===null){let l=new Error(`<${e} /> is missing a parent <Disclosure /> component.`);throw Error.captureStackTrace&&Error.captureStackTrace(l,M),l}return t}let F=I(null);F.displayName="DisclosureAPIContext";function V(e){let t=x(F);if(t===null){let l=new Error(`<${e} /> is missing a parent <Disclosure /> component.`);throw Error.captureStackTrace&&Error.captureStackTrace(l,V),l}return t}let H=I(null);H.displayName="DisclosurePanelContext";function De(){return x(H)}function ye(e,t){return B(t.type,me,e,t)}let Pe=G;function Ee(e,t){let{defaultOpen:l=!1,...p}=e,i=W(null),c=L(t,oe(a=>{i.current=a},e.as===void 0||e.as===G)),n=Z(ye,{disclosureState:l?0:1,buttonElement:null,panelElement:null,buttonId:null,panelId:null}),[{disclosureState:o,buttonId:s},f]=n,r=P(a=>{f({type:1});let T=ce(i);if(!T||!s)return;let d=(()=>a?a instanceof HTMLElement?a:a.current instanceof HTMLElement?a.current:T.getElementById(s):T.getElementById(s))();d==null||d.focus()}),E=C(()=>({close:r}),[r]),m=C(()=>({open:o===0,close:r}),[o,r]),D={ref:c};return y.createElement(_.Provider,{value:n},y.createElement(F.Provider,{value:E},y.createElement(re,{value:r},y.createElement(ue,{value:B(o,{[0]:R.Open,[1]:R.Closed})},O({ourProps:D,theirProps:p,slot:m,defaultTag:Pe,name:"Disclosure"})))))}let Se="button";function ge(e,t){let l=j(),{id:p=`headlessui-disclosure-button-${l}`,disabled:i=!1,autoFocus:c=!1,...n}=e,[o,s]=M("Disclosure.Button"),f=De(),r=f===null?!1:f===o.panelId,E=W(null),m=L(E,t,r?null:P(u=>s({type:4,element:u}))),D=X();K(()=>{if(!r)return s({type:2,buttonId:p}),()=>{s({type:2,buttonId:null})}},[p,s,r]);let a=P(u=>{var S;if(r){if(o.disclosureState===1)return;switch(u.key){case g.Space:case g.Enter:u.preventDefault(),u.stopPropagation(),s({type:0}),(S=o.buttonElement)==null||S.focus();break}}else switch(u.key){case g.Space:case g.Enter:u.preventDefault(),u.stopPropagation(),s({type:0});break}}),T=P(u=>{switch(u.key){case g.Space:u.preventDefault();break}}),d=P(u=>{var S;pe(u.currentTarget)||i||(r?(s({type:0}),(S=o.buttonElement)==null||S.focus()):s({type:0}))}),{isFocusVisible:A,focusProps:b}=Q({autoFocus:c}),{isHovered:h,hoverProps:U}=Y({isDisabled:i}),{pressed:N,pressProps:k}=te({disabled:i}),q=C(()=>({open:o.disclosureState===0,hover:h,active:N,disabled:i,focus:A,autofocus:c}),[o,h,N,A,i,c]),w=ne(e,o.buttonElement),z=r?J({ref:m,type:w,disabled:i||void 0,autoFocus:c,onKeyDown:a,onClick:d},b,U,k):J({ref:m,id:p,type:w,"aria-expanded":o.disclosureState===0,"aria-controls":o.panelElement?o.panelId:void 0,disabled:i||void 0,autoFocus:c,onKeyDown:a,onKeyUp:T,onClick:d},b,U,k);return O({mergeRefs:D,ourProps:z,theirProps:n,slot:q,defaultTag:Se,name:"Disclosure.Button"})}let Ae="div",be=$.RenderStrategy|$.Static;function Ce(e,t){let l=j(),{id:p=`headlessui-disclosure-panel-${l}`,transition:i=!1,...c}=e,[n,o]=M("Disclosure.Panel"),{close:s}=V("Disclosure.Panel"),f=X(),[r,E]=ee(null),m=L(t,P(b=>{de(()=>o({type:5,element:b}))}),E);K(()=>(o({type:3,panelId:p}),()=>{o({type:3,panelId:null})}),[p,o]);let D=ae(),[a,T]=se(i,r,D!==null?(D&R.Open)===R.Open:n.disclosureState===0),d=C(()=>({open:n.disclosureState===0,close:s}),[n.disclosureState,s]),A={ref:m,id:p,...le(T)};return y.createElement(ie,null,y.createElement(H.Provider,{value:n.panelId},O({mergeRefs:f,ourProps:A,theirProps:c,slot:d,defaultTag:Ae,features:be,visible:a,name:"Disclosure.Panel"})))}let Re=v(Ee),Ie=v(ge),xe=v(Ce),$e=Object.assign(Re,{Button:Ie,Panel:xe});export{$e as Disclosure,Ie as DisclosureButton,xe as DisclosurePanel};

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

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

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

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

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

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

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

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

@@ -5,0 +5,0 @@ "main": "dist/index.cjs",

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