New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@headlessui/react

Package Overview
Dependencies
Maintainers
4
Versions
731
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@headlessui/react - npm Package Compare versions

Comparing version 0.0.0-insiders.f2c2d3c to 0.0.0-insiders.f2c80c4

dist/components/button/button.d.ts

187

dist/components/combobox/combobox.d.ts

@@ -1,82 +0,135 @@

import React, { Ref } from 'react';
import { Props } from '../../types';
import { PropsForFeatures } from '../../utils/render';
interface ComboboxRenderPropArg<T> {
import React, { type ElementType, type Ref } from 'react';
import { type ByComparator } from '../../hooks/use-by-comparator.js';
import { type AnchorProps } from '../../internal/floating.js';
import type { EnsureArray, Props } from '../../types.js';
import { type HasDisplayName, type PropsForFeatures, type RefProp } from '../../utils/render.js';
import { type _internal_ComponentLabel } from '../label/label.js';
declare let DEFAULT_COMBOBOX_TAG: React.ExoticComponent<{
children?: React.ReactNode;
}>;
type ComboboxRenderPropArg<TValue, TActive = TValue> = {
open: boolean;
disabled: boolean;
activeIndex: number | null;
activeOption: T | null;
}
interface InputRenderPropArg {
activeOption: TActive | null;
value: TValue;
};
export type ComboboxProps<TValue, TMultiple extends boolean | undefined, TTag extends ElementType = typeof DEFAULT_COMBOBOX_TAG> = Props<TTag, ComboboxRenderPropArg<NoInfer<TValue>>, 'value' | 'defaultValue' | 'multiple' | 'onChange' | 'by', {
value?: TMultiple extends true ? EnsureArray<TValue> : TValue;
defaultValue?: TMultiple extends true ? EnsureArray<NoInfer<TValue>> : NoInfer<TValue>;
onChange?(value: TMultiple extends true ? EnsureArray<NoInfer<TValue>> : NoInfer<TValue> | null): void;
by?: ByComparator<TMultiple extends true ? EnsureArray<NoInfer<TValue>>[number] : NoInfer<TValue>>;
/** @deprecated The `<Combobox />` is now nullable default */
nullable?: boolean;
multiple?: TMultiple;
disabled?: boolean;
form?: string;
name?: string;
immediate?: boolean;
virtual?: {
options: TMultiple extends true ? EnsureArray<NoInfer<TValue>> : NoInfer<TValue>[];
disabled?: (value: TMultiple extends true ? EnsureArray<NoInfer<TValue>>[number] : NoInfer<TValue>) => boolean;
} | null;
onClose?(): void;
__demoMode?: boolean;
}>;
declare function ComboboxFn<TValue, TTag extends ElementType = typeof DEFAULT_COMBOBOX_TAG>(props: ComboboxProps<TValue, boolean | undefined, TTag>, ref: Ref<HTMLElement>): React.JSX.Element;
declare let DEFAULT_INPUT_TAG: "input";
type InputRenderPropArg = {
open: boolean;
disabled: boolean;
}
declare type InputPropsWeControl = 'id' | 'role' | 'aria-labelledby' | 'aria-expanded' | 'aria-activedescendant' | 'onKeyDown' | 'onChange' | 'displayValue';
interface ButtonRenderPropArg {
hover: boolean;
focus: boolean;
autofocus: boolean;
};
type InputPropsWeControl = 'aria-activedescendant' | 'aria-autocomplete' | 'aria-controls' | 'aria-expanded' | 'aria-labelledby' | 'disabled' | 'role';
export type ComboboxInputProps<TTag extends ElementType = typeof DEFAULT_INPUT_TAG, TType = string> = Props<TTag, InputRenderPropArg, InputPropsWeControl, {
defaultValue?: TType;
disabled?: boolean;
displayValue?(item: TType): string;
onChange?(event: React.ChangeEvent<HTMLInputElement>): void;
autoFocus?: boolean;
}>;
declare function InputFn<TTag extends ElementType = typeof DEFAULT_INPUT_TAG, TType = Parameters<typeof ComboboxRoot>[0]['value']>(props: ComboboxInputProps<TTag, TType>, ref: Ref<HTMLInputElement>): React.ReactElement<any, string | React.JSXElementConstructor<any>> | null;
declare let DEFAULT_BUTTON_TAG: "button";
type ButtonRenderPropArg = {
open: boolean;
active: boolean;
disabled: boolean;
}
declare type ButtonPropsWeControl = 'id' | 'type' | 'tabIndex' | 'aria-haspopup' | 'aria-controls' | 'aria-expanded' | 'aria-labelledby' | 'disabled' | 'onClick' | 'onKeyDown';
interface LabelRenderPropArg {
value: any;
focus: boolean;
hover: boolean;
};
type ButtonPropsWeControl = 'aria-controls' | 'aria-expanded' | 'aria-haspopup' | 'aria-labelledby' | 'disabled' | 'tabIndex';
export type ComboboxButtonProps<TTag extends ElementType = typeof DEFAULT_BUTTON_TAG> = Props<TTag, ButtonRenderPropArg, ButtonPropsWeControl, {
autoFocus?: boolean;
disabled?: boolean;
}>;
declare function ButtonFn<TTag extends ElementType = typeof DEFAULT_BUTTON_TAG>(props: ComboboxButtonProps<TTag>, ref: Ref<HTMLButtonElement>): React.ReactElement<any, string | React.JSXElementConstructor<any>> | null;
declare let DEFAULT_OPTIONS_TAG: "div";
type OptionsRenderPropArg = {
open: boolean;
disabled: boolean;
}
declare type LabelPropsWeControl = 'id' | 'ref' | 'onClick';
interface OptionsRenderPropArg {
open: boolean;
}
declare type OptionsPropsWeControl = 'aria-activedescendant' | 'aria-labelledby' | 'hold' | 'id' | 'onKeyDown' | 'role' | 'tabIndex';
option: any;
};
type OptionsPropsWeControl = 'aria-labelledby' | 'aria-multiselectable' | 'role' | 'tabIndex';
declare let OptionsRenderFeatures: number;
interface OptionRenderPropArg {
export type ComboboxOptionsProps<TTag extends ElementType = typeof DEFAULT_OPTIONS_TAG> = Props<TTag, OptionsRenderPropArg, OptionsPropsWeControl, PropsForFeatures<typeof OptionsRenderFeatures> & {
hold?: boolean;
anchor?: AnchorProps;
portal?: boolean;
modal?: boolean;
transition?: boolean;
}>;
declare function OptionsFn<TTag extends ElementType = typeof DEFAULT_OPTIONS_TAG>(props: ComboboxOptionsProps<TTag>, ref: Ref<HTMLElement>): React.JSX.Element;
declare let DEFAULT_OPTION_TAG: "div";
type OptionRenderPropArg = {
focus: boolean;
/** @deprecated use `focus` instead */
active: boolean;
selected: boolean;
disabled: boolean;
};
type OptionPropsWeControl = 'role' | 'tabIndex' | 'aria-disabled' | 'aria-selected';
export type ComboboxOptionProps<TTag extends ElementType = typeof DEFAULT_OPTION_TAG, TType = string> = Props<TTag, OptionRenderPropArg, OptionPropsWeControl, {
disabled?: boolean;
value: TType;
order?: number;
}>;
declare function OptionFn<TTag extends ElementType = typeof DEFAULT_OPTION_TAG, TType = Parameters<typeof ComboboxRoot>[0]['value']>(props: ComboboxOptionProps<TTag, TType>, ref: Ref<HTMLElement>): React.ReactElement<any, string | React.JSXElementConstructor<any>> | null;
export interface _internal_ComponentCombobox extends HasDisplayName {
<TValue, TMultiple extends boolean | undefined = false, TTag extends ElementType = typeof DEFAULT_COMBOBOX_TAG>(props: ComboboxProps<TValue, TMultiple, TTag> & RefProp<typeof ComboboxFn>): JSX.Element;
}
declare type ComboboxOptionPropsWeControl = 'id' | 'role' | 'tabIndex' | 'aria-disabled' | 'aria-selected';
export declare let Combobox: (<TTag extends React.ElementType<any> = React.ExoticComponent<{
children?: React.ReactNode;
}>, TType = string, TActualType = TType extends (infer U)[] ? U : TType>(props: Props<TTag, ComboboxRenderPropArg<TType>, "value" | "name" | "disabled" | "onChange" | "nullable" | "multiple" | "by"> & {
value: TType;
onChange(value: TType): void;
by?: (keyof TType & string) | ((a: TType, z: TType) => boolean) | undefined;
disabled?: boolean | undefined;
__demoMode?: boolean | undefined;
name?: string | undefined;
nullable?: boolean | undefined;
multiple?: boolean | undefined;
}, ref: React.Ref<TTag>) => JSX.Element) & {
displayName: string;
} & {
Input: (<TTag_1 extends React.ElementType<any> = "input", TType_1 = unknown>(props: Props<TTag_1, InputRenderPropArg, InputPropsWeControl> & {
displayValue?(item: TType_1): string;
onChange(event: React.ChangeEvent<HTMLInputElement>): void;
}, ref: Ref<HTMLInputElement>) => React.ReactElement<any, string | React.JSXElementConstructor<any>> | null) & {
displayName: string;
};
Button: (<TTag_2 extends React.ElementType<any> = "button">(props: Props<TTag_2, ButtonRenderPropArg, ButtonPropsWeControl>, ref: Ref<HTMLButtonElement>) => React.ReactElement<any, string | React.JSXElementConstructor<any>> | null) & {
displayName: string;
};
Label: (<TTag_3 extends React.ElementType<any> = "label">(props: Props<TTag_3, LabelRenderPropArg, LabelPropsWeControl>, ref: Ref<HTMLLabelElement>) => React.ReactElement<any, string | React.JSXElementConstructor<any>> | null) & {
displayName: string;
};
Options: (<TTag_4 extends React.ElementType<any> = "ul">(props: Props<TTag_4, OptionsRenderPropArg, OptionsPropsWeControl> & (({
static?: undefined;
} & {
unmount?: boolean | undefined;
}) | ({
unmount?: undefined;
} & {
static?: boolean | undefined;
})) & {
hold?: boolean | undefined;
}, ref: Ref<HTMLUListElement>) => React.ReactElement<any, string | React.JSXElementConstructor<any>> | null) & {
displayName: string;
};
Option: (<TTag_5 extends React.ElementType<any> = "li", TType_2 = unknown>(props: Props<TTag_5, OptionRenderPropArg, "value" | ComboboxOptionPropsWeControl> & {
disabled?: boolean | undefined;
value: TType_2;
}, ref: Ref<HTMLLIElement>) => React.ReactElement<any, string | React.JSXElementConstructor<any>> | null) & {
displayName: string;
};
export interface _internal_ComponentComboboxButton extends HasDisplayName {
<TTag extends ElementType = typeof DEFAULT_BUTTON_TAG>(props: ComboboxButtonProps<TTag> & RefProp<typeof ButtonFn>): JSX.Element;
}
export interface _internal_ComponentComboboxInput extends HasDisplayName {
<TType, TTag extends ElementType = typeof DEFAULT_INPUT_TAG>(props: ComboboxInputProps<TTag, TType> & RefProp<typeof InputFn>): JSX.Element;
}
export interface _internal_ComponentComboboxLabel extends _internal_ComponentLabel {
}
export interface _internal_ComponentComboboxOptions extends HasDisplayName {
<TTag extends ElementType = typeof DEFAULT_OPTIONS_TAG>(props: ComboboxOptionsProps<TTag> & RefProp<typeof OptionsFn>): JSX.Element;
}
export interface _internal_ComponentComboboxOption extends HasDisplayName {
<TTag extends ElementType = typeof DEFAULT_OPTION_TAG, TType = Parameters<typeof ComboboxRoot>[0]['value']>(props: ComboboxOptionProps<TTag, TType> & RefProp<typeof OptionFn>): JSX.Element;
}
declare let ComboboxRoot: _internal_ComponentCombobox;
export declare let ComboboxButton: _internal_ComponentComboboxButton;
export declare let ComboboxInput: _internal_ComponentComboboxInput;
/** @deprecated use `<Label>` instead of `<ComboboxLabel>` */
export declare let ComboboxLabel: _internal_ComponentComboboxLabel;
export declare let ComboboxOptions: _internal_ComponentComboboxOptions;
export declare let ComboboxOption: _internal_ComponentComboboxOption;
export declare let Combobox: _internal_ComponentCombobox & {
/** @deprecated use `<ComboboxInput>` instead of `<Combobox.Input>` */
Input: _internal_ComponentComboboxInput;
/** @deprecated use `<ComboboxButton>` instead of `<Combobox.Button>` */
Button: _internal_ComponentComboboxButton;
/** @deprecated use `<Label>` instead of `<Combobox.Label>` */
Label: _internal_ComponentComboboxLabel;
/** @deprecated use `<ComboboxOptions>` instead of `<Combobox.Options>` */
Options: _internal_ComponentComboboxOptions;
/** @deprecated use `<ComboboxOption>` instead of `<Combobox.Option>` */
Option: _internal_ComponentComboboxOption;
};
export {};

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

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

@@ -1,3 +0,4 @@

import React, { ReactNode, Ref } from 'react';
import { Props } from '../../types';
import React, { type ElementType, type ReactNode, type Ref } from 'react';
import type { Props } from '../../types.js';
import { type HasDisplayName, type RefProp } from '../../utils/render.js';
interface SharedData {

@@ -8,4 +9,6 @@ slot?: {};

}
export declare function useDescribedBy(): string | undefined;
interface DescriptionProviderProps extends SharedData {
children: ReactNode;
value?: string | undefined;
}

@@ -16,5 +19,9 @@ export declare function useDescriptions(): [

];
export declare let Description: (<TTag extends React.ElementType<any> = "p">(props: Props<TTag, {}, "id">, ref: Ref<HTMLParagraphElement>) => React.ReactElement<any, string | React.JSXElementConstructor<any>> | null) & {
displayName: string;
};
declare let DEFAULT_DESCRIPTION_TAG: "p";
export type DescriptionProps<TTag extends ElementType = typeof DEFAULT_DESCRIPTION_TAG> = Props<TTag>;
declare function DescriptionFn<TTag extends ElementType = typeof DEFAULT_DESCRIPTION_TAG>(props: DescriptionProps<TTag>, ref: Ref<HTMLElement>): React.ReactElement<any, string | React.JSXElementConstructor<any>> | null;
export interface _internal_ComponentDescription extends HasDisplayName {
<TTag extends ElementType = typeof DEFAULT_DESCRIPTION_TAG>(props: DescriptionProps<TTag> & RefProp<typeof DescriptionFn>): JSX.Element;
}
export declare let Description: _internal_ComponentDescription;
export {};

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

import f,{createContext as m,useContext as D,useMemo as l,useState as P}from"react";import{useId as T}from"../../hooks/use-id.js";import{forwardRefWithAs as g,render as x}from"../../utils/render.js";import{useIsoMorphicEffect as E}from"../../hooks/use-iso-morphic-effect.js";import{useSyncRefs as h}from"../../hooks/use-sync-refs.js";import{useEvent as v}from"../../hooks/use-event.js";let d=m(null);function u(){let r=D(d);if(r===null){let t=new Error("You used a <Description /> component, but it is not inside a relevant parent.");throw Error.captureStackTrace&&Error.captureStackTrace(t,u),t}return r}function k(){let[r,t]=P([]);return[r.length>0?r.join(" "):void 0,l(()=>function(e){let i=v(n=>(t(o=>[...o,n]),()=>t(o=>{let c=o.slice(),p=c.indexOf(n);return p!==-1&&c.splice(p,1),c}))),s=l(()=>({register:i,slot:e.slot,name:e.name,props:e.props}),[i,e.slot,e.name,e.props]);return f.createElement(d.Provider,{value:s},e.children)},[t])]}let S="p",F=g(function(t,a){let e=u(),i=`headlessui-description-${T()}`,s=h(a);E(()=>e.register(i),[i,e.register]);let n=t,o={ref:s,...e.props,id:i};return x({ourProps:o,theirProps:n,slot:e.slot||{},defaultTag:S,name:e.name||"Description"})});export{F as Description,k as useDescriptions};
"use client";import m,{createContext as T,useContext as u,useMemo as c,useState as P}from"react";import{useEvent as g}from'../../hooks/use-event.js';import{useId as x}from'../../hooks/use-id.js';import{useIsoMorphicEffect as y}from'../../hooks/use-iso-morphic-effect.js';import{useSyncRefs as E}from'../../hooks/use-sync-refs.js';import{useDisabled as v}from'../../internal/disabled.js';import{forwardRefWithAs as R,render as I}from'../../utils/render.js';let a=T(null);a.displayName="DescriptionContext";function f(){let r=u(a);if(r===null){let e=new Error("You used a <Description /> component, but it is not inside a relevant parent.");throw Error.captureStackTrace&&Error.captureStackTrace(e,f),e}return r}function G(){var r,e;return(e=(r=u(a))==null?void 0:r.value)!=null?e:void 0}function U(){let[r,e]=P([]);return[r.length>0?r.join(" "):void 0,c(()=>function(t){let i=g(n=>(e(s=>[...s,n]),()=>e(s=>{let o=s.slice(),p=o.indexOf(n);return p!==-1&&o.splice(p,1),o}))),l=c(()=>({register:i,slot:t.slot,name:t.name,props:t.props,value:t.value}),[i,t.slot,t.name,t.props,t.value]);return m.createElement(a.Provider,{value:l},t.children)},[e])]}let S="p";function C(r,e){let d=x(),t=v(),{id:i=`headlessui-description-${d}`,...l}=r,n=f(),s=E(e);y(()=>n.register(i),[i,n.register]);let o=t||!1,p=c(()=>({...n.slot,disabled:o}),[n.slot,o]),D={ref:s,...n.props,id:i};return I({ourProps:D,theirProps:l,slot:p,defaultTag:S,name:n.name||"Description"})}let _=R(C),w=Object.assign(_,{});export{w as Description,G as useDescribedBy,U as useDescriptions};

@@ -1,56 +0,70 @@

import React, { MutableRefObject, Ref } from 'react';
import { Props } from '../../types';
import { PropsForFeatures } from '../../utils/render';
interface DialogRenderPropArg {
import React, { type ElementType, type MutableRefObject, type Ref } from 'react';
import type { Props } from '../../types.js';
import { type HasDisplayName, type PropsForFeatures, type RefProp } from '../../utils/render.js';
import { type _internal_ComponentDescription } from '../description/description.js';
declare let DEFAULT_DIALOG_TAG: "div";
type DialogRenderPropArg = {
open: boolean;
}
declare type DialogPropsWeControl = 'id' | 'role' | 'aria-modal' | 'aria-describedby' | 'aria-labelledby';
};
type DialogPropsWeControl = 'aria-describedby' | 'aria-labelledby' | 'aria-modal';
declare let DialogRenderFeatures: number;
interface OverlayRenderPropArg {
export type DialogProps<TTag extends ElementType = typeof DEFAULT_DIALOG_TAG> = Props<TTag, DialogRenderPropArg, DialogPropsWeControl, PropsForFeatures<typeof DialogRenderFeatures> & {
open?: boolean;
onClose: (value: boolean) => void;
initialFocus?: MutableRefObject<HTMLElement | null>;
role?: 'dialog' | 'alertdialog';
autoFocus?: boolean;
transition?: boolean;
__demoMode?: boolean;
}>;
declare function DialogFn<TTag extends ElementType = typeof DEFAULT_DIALOG_TAG>(props: DialogProps<TTag>, ref: Ref<HTMLElement>): React.JSX.Element;
declare let DEFAULT_PANEL_TAG: "div";
type PanelRenderPropArg = {
open: boolean;
}
declare type OverlayPropsWeControl = 'id' | 'aria-hidden' | 'onClick';
interface BackdropRenderPropArg {
};
export type DialogPanelProps<TTag extends ElementType = typeof DEFAULT_PANEL_TAG> = Props<TTag, PanelRenderPropArg, never, {
transition?: boolean;
}>;
declare function PanelFn<TTag extends ElementType = typeof DEFAULT_PANEL_TAG>(props: DialogPanelProps<TTag>, ref: Ref<HTMLElement>): React.JSX.Element;
declare let DEFAULT_BACKDROP_TAG: "div";
type BackdropRenderPropArg = {
open: boolean;
}
declare type BackdropPropsWeControl = 'id' | 'aria-hidden' | 'onClick';
interface PanelRenderPropArg {
};
export type DialogBackdropProps<TTag extends ElementType = typeof DEFAULT_BACKDROP_TAG> = Props<TTag, BackdropRenderPropArg, never, {
transition?: boolean;
}>;
declare function BackdropFn<TTag extends ElementType = typeof DEFAULT_BACKDROP_TAG>(props: DialogBackdropProps<TTag>, ref: Ref<HTMLElement>): React.JSX.Element;
declare let DEFAULT_TITLE_TAG: "h2";
type TitleRenderPropArg = {
open: boolean;
};
export type DialogTitleProps<TTag extends ElementType = typeof DEFAULT_TITLE_TAG> = Props<TTag, TitleRenderPropArg>;
declare function TitleFn<TTag extends ElementType = typeof DEFAULT_TITLE_TAG>(props: DialogTitleProps<TTag>, ref: Ref<HTMLElement>): React.ReactElement<any, string | React.JSXElementConstructor<any>> | null;
export interface _internal_ComponentDialog extends HasDisplayName {
<TTag extends ElementType = typeof DEFAULT_DIALOG_TAG>(props: DialogProps<TTag> & RefProp<typeof DialogFn>): JSX.Element;
}
interface TitleRenderPropArg {
open: boolean;
export interface _internal_ComponentDialogPanel extends HasDisplayName {
<TTag extends ElementType = typeof DEFAULT_PANEL_TAG>(props: DialogPanelProps<TTag> & RefProp<typeof PanelFn>): JSX.Element;
}
declare type TitlePropsWeControl = 'id';
export declare let Dialog: (<TTag extends React.ElementType<any> = "div">(props: Props<TTag, DialogRenderPropArg, DialogPropsWeControl> & (({
static?: undefined;
} & {
unmount?: boolean | undefined;
}) | ({
unmount?: undefined;
} & {
static?: boolean | undefined;
})) & {
open?: boolean | undefined;
onClose(value: boolean): void;
initialFocus?: React.MutableRefObject<HTMLElement | null> | undefined;
__demoMode?: boolean | undefined;
}, ref: Ref<HTMLDivElement>) => JSX.Element) & {
displayName: string;
} & {
Backdrop: (<TTag_1 extends React.ElementType<any> = "div">(props: Props<TTag_1, BackdropRenderPropArg, BackdropPropsWeControl>, ref: Ref<HTMLDivElement>) => JSX.Element) & {
displayName: string;
};
Panel: (<TTag_2 extends React.ElementType<any> = "div">(props: Props<TTag_2, PanelRenderPropArg, "1D45E01E-AF44-47C4-988A-19A94EBAF55C">, ref: Ref<HTMLDivElement>) => React.ReactElement<any, string | React.JSXElementConstructor<any>> | null) & {
displayName: string;
};
Overlay: (<TTag_3 extends React.ElementType<any> = "div">(props: Props<TTag_3, OverlayRenderPropArg, OverlayPropsWeControl>, ref: Ref<HTMLDivElement>) => React.ReactElement<any, string | React.JSXElementConstructor<any>> | null) & {
displayName: string;
};
Title: (<TTag_4 extends React.ElementType<any> = "h2">(props: Props<TTag_4, TitleRenderPropArg, "id">, ref: Ref<HTMLHeadingElement>) => React.ReactElement<any, string | React.JSXElementConstructor<any>> | null) & {
displayName: string;
};
Description: (<TTag_5 extends React.ElementType<any> = "p">(props: Props<TTag_5, {}, "id">, ref: React.Ref<HTMLParagraphElement>) => React.ReactElement<any, string | React.JSXElementConstructor<any>> | null) & {
displayName: string;
};
export interface _internal_ComponentDialogBackdrop extends HasDisplayName {
<TTag extends ElementType = typeof DEFAULT_BACKDROP_TAG>(props: DialogBackdropProps<TTag> & RefProp<typeof BackdropFn>): JSX.Element;
}
export interface _internal_ComponentDialogTitle extends HasDisplayName {
<TTag extends ElementType = typeof DEFAULT_TITLE_TAG>(props: DialogTitleProps<TTag> & RefProp<typeof TitleFn>): JSX.Element;
}
export interface _internal_ComponentDialogDescription extends _internal_ComponentDescription {
}
export declare let DialogPanel: _internal_ComponentDialogPanel;
export declare let DialogBackdrop: _internal_ComponentDialogBackdrop;
export declare let DialogTitle: _internal_ComponentDialogTitle;
/** @deprecated use `<Description>` instead of `<DialogDescription>` */
export declare let DialogDescription: _internal_ComponentDialogDescription;
export declare let Dialog: _internal_ComponentDialog & {
/** @deprecated use `<DialogPanel>` instead of `<Dialog.Panel>` */
Panel: _internal_ComponentDialogPanel;
/** @deprecated use `<DialogTitle>` instead of `<Dialog.Title>` */
Title: _internal_ComponentDialogTitle;
/** @deprecated use `<Description>` instead of `<Dialog.Description>` */
Description: _internal_ComponentDialogDescription;
};
export {};

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

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

@@ -1,56 +0,59 @@

import React, { MutableRefObject, Ref } from 'react';
import { Props } from '../../types';
import { PropsForFeatures } from '../../utils/render';
interface DisclosureRenderPropArg {
import React, { type ElementType, type MutableRefObject, type Ref } from 'react';
import type { Props } from '../../types.js';
import { type HasDisplayName, type PropsForFeatures, type RefProp } from '../../utils/render.js';
declare let DEFAULT_DISCLOSURE_TAG: React.ExoticComponent<{
children?: React.ReactNode;
}>;
type DisclosureRenderPropArg = {
open: boolean;
close(focusableElement?: HTMLElement | MutableRefObject<HTMLElement | null>): void;
}
interface ButtonRenderPropArg {
close: (focusableElement?: HTMLElement | MutableRefObject<HTMLElement | null>) => void;
};
type DisclosurePropsWeControl = never;
export type DisclosureProps<TTag extends ElementType = typeof DEFAULT_DISCLOSURE_TAG> = Props<TTag, DisclosureRenderPropArg, DisclosurePropsWeControl, {
defaultOpen?: boolean;
}>;
declare function DisclosureFn<TTag extends ElementType = typeof DEFAULT_DISCLOSURE_TAG>(props: DisclosureProps<TTag>, ref: Ref<HTMLElement>): React.JSX.Element;
declare let DEFAULT_BUTTON_TAG: "button";
type ButtonRenderPropArg = {
open: boolean;
}
declare type ButtonPropsWeControl = 'id' | 'type' | 'aria-expanded' | 'aria-controls' | 'onKeyDown' | 'onClick';
interface PanelRenderPropArg {
hover: boolean;
active: boolean;
disabled: boolean;
focus: boolean;
autofocus: boolean;
};
type ButtonPropsWeControl = 'aria-controls' | 'aria-expanded';
export type DisclosureButtonProps<TTag extends ElementType = typeof DEFAULT_BUTTON_TAG> = Props<TTag, ButtonRenderPropArg, ButtonPropsWeControl, {
disabled?: boolean;
autoFocus?: boolean;
}>;
declare function ButtonFn<TTag extends ElementType = typeof DEFAULT_BUTTON_TAG>(props: DisclosureButtonProps<TTag>, ref: Ref<HTMLButtonElement>): React.ReactElement<any, string | React.JSXElementConstructor<any>> | null;
declare let DEFAULT_PANEL_TAG: "div";
type PanelRenderPropArg = {
open: boolean;
close: (focusableElement?: HTMLElement | MutableRefObject<HTMLElement | null>) => void;
};
type DisclosurePanelPropsWeControl = never;
declare let PanelRenderFeatures: number;
export type DisclosurePanelProps<TTag extends ElementType = typeof DEFAULT_PANEL_TAG> = Props<TTag, PanelRenderPropArg, DisclosurePanelPropsWeControl, {
transition?: boolean;
} & PropsForFeatures<typeof PanelRenderFeatures>>;
declare function PanelFn<TTag extends ElementType = typeof DEFAULT_PANEL_TAG>(props: DisclosurePanelProps<TTag>, ref: Ref<HTMLElement>): React.JSX.Element;
export interface _internal_ComponentDisclosure extends HasDisplayName {
<TTag extends ElementType = typeof DEFAULT_DISCLOSURE_TAG>(props: DisclosureProps<TTag> & RefProp<typeof DisclosureFn>): JSX.Element;
}
declare type PanelPropsWeControl = 'id';
declare let PanelRenderFeatures: number;
export declare let Disclosure: (<TTag extends React.ElementType<any> = React.ExoticComponent<{
children?: React.ReactNode;
}>>(props: Omit<import("../../types").PropsOf<TTag>, "as" | "children" | "refName" | "className"> & {
as?: TTag | undefined;
children?: React.ReactNode | ((bag: DisclosureRenderPropArg) => React.ReactElement<any, string | React.JSXElementConstructor<any>>);
refName?: string | undefined;
} & (import("../../types").PropsOf<TTag> extends {
className?: any;
} ? {
className?: string | ((bag: DisclosureRenderPropArg) => string) | undefined;
} : {}) & {
defaultOpen?: boolean | undefined;
}, ref: React.Ref<TTag>) => JSX.Element) & {
displayName: string;
} & {
Button: (<TTag_1 extends React.ElementType<any> = "button">(props: Props<TTag_1, ButtonRenderPropArg, ButtonPropsWeControl>, ref: Ref<HTMLButtonElement>) => React.ReactElement<any, string | React.JSXElementConstructor<any>> | null) & {
displayName: string;
};
Panel: (<TTag_2 extends React.ElementType<any> = "div">(props: Omit<import("../../types").PropsOf<TTag_2>, ("as" | "children" | "refName" | "className") | "id"> & {
as?: TTag_2 | undefined;
children?: React.ReactNode | ((bag: PanelRenderPropArg) => React.ReactElement<any, string | React.JSXElementConstructor<any>>);
refName?: string | undefined;
} & (import("../../types").PropsOf<TTag_2> extends {
className?: any;
} ? {
className?: string | ((bag: PanelRenderPropArg) => string) | undefined;
} : {}) & (({
static?: undefined;
} & {
unmount?: boolean | undefined;
}) | ({
unmount?: undefined;
} & {
static?: boolean | undefined;
})), ref: Ref<HTMLDivElement>) => JSX.Element) & {
displayName: string;
};
export interface _internal_ComponentDisclosureButton extends HasDisplayName {
<TTag extends ElementType = typeof DEFAULT_BUTTON_TAG>(props: DisclosureButtonProps<TTag> & RefProp<typeof ButtonFn>): JSX.Element;
}
export interface _internal_ComponentDisclosurePanel extends HasDisplayName {
<TTag extends ElementType = typeof DEFAULT_PANEL_TAG>(props: DisclosurePanelProps<TTag> & RefProp<typeof PanelFn>): JSX.Element;
}
export declare let DisclosureButton: _internal_ComponentDisclosureButton;
export declare let DisclosurePanel: _internal_ComponentDisclosurePanel;
export declare let Disclosure: _internal_ComponentDisclosure & {
/** @deprecated use `<DisclosureButton>` instead of `<Disclosure.Button>` */
Button: _internal_ComponentDisclosureButton;
/** @deprecated use `<DisclosurePanel>` instead of `<Disclosure.Panel>` */
Panel: _internal_ComponentDisclosurePanel;
};
export {};

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

import y,{Fragment as j,createContext as L,useContext as k,useEffect as g,useMemo as E,useReducer as N,useRef as R}from"react";import{match as O}from"../../utils/match.js";import{forwardRefWithAs as M,render as x,Features as F}from"../../utils/render.js";import{optionalRef as G,useSyncRefs as v}from"../../hooks/use-sync-refs.js";import{useId as _}from"../../hooks/use-id.js";import{Keys as S}from"../keyboard.js";import{isDisabledReactIssue7711 as W}from"../../utils/bugs.js";import{OpenClosedProvider as $,State as B,useOpenClosed as q}from"../../internal/open-closed.js";import{useResolveButtonType as z}from"../../hooks/use-resolve-button-type.js";import{getOwnerDocument as J}from"../../utils/owner.js";import{useEvent as b}from"../../hooks/use-event.js";var Q=(o=>(o[o.Open=0]="Open",o[o.Closed=1]="Closed",o))(Q||{}),V=(l=>(l[l.ToggleDisclosure=0]="ToggleDisclosure",l[l.CloseDisclosure=1]="CloseDisclosure",l[l.SetButtonId=2]="SetButtonId",l[l.SetPanelId=3]="SetPanelId",l[l.LinkPanel=4]="LinkPanel",l[l.UnlinkPanel=5]="UnlinkPanel",l))(V||{});let X={[0]:e=>({...e,disclosureState:O(e.disclosureState,{[0]:1,[1]:0})}),[1]:e=>e.disclosureState===1?e:{...e,disclosureState:1},[4](e){return e.linkedPanel===!0?e:{...e,linkedPanel:!0}},[5](e){return e.linkedPanel===!1?e:{...e,linkedPanel:!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}}},h=L(null);h.displayName="DisclosureContext";function H(e){let t=k(h);if(t===null){let o=new Error(`<${e} /> is missing a parent <Disclosure /> component.`);throw Error.captureStackTrace&&Error.captureStackTrace(o,H),o}return t}let U=L(null);U.displayName="DisclosureAPIContext";function K(e){let t=k(U);if(t===null){let o=new Error(`<${e} /> is missing a parent <Disclosure /> component.`);throw Error.captureStackTrace&&Error.captureStackTrace(o,K),o}return t}let w=L(null);w.displayName="DisclosurePanelContext";function Y(){return k(w)}function Z(e,t){return O(t.type,X,e,t)}let ee=j,te=M(function(t,o){let{defaultOpen:n=!1,...s}=t,i=`headlessui-disclosure-button-${_()}`,l=`headlessui-disclosure-panel-${_()}`,u=R(null),D=v(o,G(f=>{u.current=f},t.as===void 0||t.as===y.Fragment)),P=R(null),m=R(null),p=N(Z,{disclosureState:n?0:1,linkedPanel:!1,buttonRef:m,panelRef:P,buttonId:i,panelId:l}),[{disclosureState:a},c]=p;g(()=>c({type:2,buttonId:i}),[i,c]),g(()=>c({type:3,panelId:l}),[l,c]);let T=b(f=>{c({type:1});let A=J(u);if(!A)return;let I=(()=>f?f instanceof HTMLElement?f:f.current instanceof HTMLElement?f.current:A.getElementById(i):A.getElementById(i))();I==null||I.focus()}),C=E(()=>({close:T}),[T]),r=E(()=>({open:a===0,close:T}),[a,T]),d={ref:D};return y.createElement(h.Provider,{value:p},y.createElement(U.Provider,{value:C},y.createElement($,{value:O(a,{[0]:B.Open,[1]:B.Closed})},x({ourProps:d,theirProps:s,slot:r,defaultTag:ee,name:"Disclosure"}))))}),ne="button",le=M(function(t,o){let[n,s]=H("Disclosure.Button"),i=Y(),l=i===null?!1:i===n.panelId,u=R(null),D=v(u,o,l?null:n.buttonRef),P=b(r=>{var d;if(l){if(n.disclosureState===1)return;switch(r.key){case S.Space:case S.Enter:r.preventDefault(),r.stopPropagation(),s({type:0}),(d=n.buttonRef.current)==null||d.focus();break}}else switch(r.key){case S.Space:case S.Enter:r.preventDefault(),r.stopPropagation(),s({type:0});break}}),m=b(r=>{switch(r.key){case S.Space:r.preventDefault();break}}),p=b(r=>{var d;W(r.currentTarget)||t.disabled||(l?(s({type:0}),(d=n.buttonRef.current)==null||d.focus()):s({type:0}))}),a=E(()=>({open:n.disclosureState===0}),[n]),c=z(t,u),T=t,C=l?{ref:D,type:c,onKeyDown:P,onClick:p}:{ref:D,id:n.buttonId,type:c,"aria-expanded":t.disabled?void 0:n.disclosureState===0,"aria-controls":n.linkedPanel?n.panelId:void 0,onKeyDown:P,onKeyUp:m,onClick:p};return x({ourProps:C,theirProps:T,slot:a,defaultTag:ne,name:"Disclosure.Button"})}),oe="div",re=F.RenderStrategy|F.Static,se=M(function(t,o){let[n,s]=H("Disclosure.Panel"),{close:i}=K("Disclosure.Panel"),l=v(o,n.panelRef,()=>{n.linkedPanel||s({type:4})}),u=q(),D=(()=>u!==null?u===B.Open:n.disclosureState===0)();g(()=>()=>s({type:5}),[s]),g(()=>{var a;n.disclosureState===1&&((a=t.unmount)!=null?a:!0)&&s({type:5})},[n.disclosureState,t.unmount,s]);let P=E(()=>({open:n.disclosureState===0,close:i}),[n,i]),m=t,p={ref:l,id:n.panelId};return y.createElement(w.Provider,{value:n.panelId},x({ourProps:p,theirProps:m,slot:P,defaultTag:oe,features:re,visible:D,name:"Disclosure.Panel"}))}),ke=Object.assign(te,{Button:le,Panel:se});export{ke as Disclosure};
"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 re}from'../../hooks/use-transition.js';import{CloseProvider as se}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:r},f]=n,s=P(a=>{f({type:1});let T=ce(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()}),E=C(()=>({close:s}),[s]),m=C(()=>({open:o===0,close:s}),[o,s]),D={ref:c};return y.createElement(_.Provider,{value:n},y.createElement(F.Provider,{value:E},y.createElement(se,{value:s},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,r]=M("Disclosure.Button"),f=De(),s=f===null?!1:f===o.panelId,E=W(null),m=L(E,t,P(u=>{if(!s)return r({type:4,element:u})})),D=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;pe(u.currentTarget)||i||(s?(r({type:0}),(S=o.buttonElement)==null||S.focus()):r({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=s?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:r}=V("Disclosure.Panel"),f=X(),[s,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]=re(i,s,D!==null?(D&R.Open)===R.Open:n.disclosureState===0),d=C(()=>({open:n.disclosureState===0,close:r}),[n.disclosureState,r]),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,35 +0,36 @@

import React, { MutableRefObject, Ref } from 'react';
import { Props } from '../../types';
declare enum Features {
import React, { type ElementType, type MutableRefObject, type Ref } from 'react';
import type { Props } from '../../types.js';
import { type HasDisplayName, type RefProp } from '../../utils/render.js';
type Containers = (() => Iterable<HTMLElement>) | MutableRefObject<Set<MutableRefObject<HTMLElement | null>>>;
declare let DEFAULT_FOCUS_TRAP_TAG: "div";
export declare enum FocusTrapFeatures {
/** No features enabled for the focus trap. */
None = 1,
None = 0,
/** Ensure that we move focus initially into the container. */
InitialFocus = 2,
InitialFocus = 1,
/** Ensure that pressing `Tab` and `Shift+Tab` is trapped within the container. */
TabLock = 4,
TabLock = 2,
/** Ensure that programmatically moving focus outside of the container is disallowed. */
FocusLock = 8,
FocusLock = 4,
/** Ensure that we restore the focus when unmounting the focus trap. */
RestoreFocus = 16,
/** Enable all features. */
All = 30
RestoreFocus = 8,
/** Initial focus should look for the `data-autofocus` */
AutoFocus = 16
}
export declare let FocusTrap: (<TTag extends React.ElementType<any> = "div">(props: Omit<import("../../types").PropsOf<TTag>, "as" | "children" | "refName" | "className"> & {
as?: TTag | undefined;
children?: React.ReactNode | ((bag: any) => React.ReactElement<any, string | React.JSXElementConstructor<any>>);
refName?: string | undefined;
} & (import("../../types").PropsOf<TTag> extends {
/** Ensure that programmatically moving focus outside of the container is disallowed. */
className?: any;
} ? {
className?: string | ((bag: any) => string) | undefined;
} : {}) & {
initialFocus?: React.MutableRefObject<HTMLElement | null> | undefined;
features?: Features | undefined;
containers?: React.MutableRefObject<Set<React.MutableRefObject<HTMLElement | null>>> | undefined;
}, ref: Ref<HTMLDivElement>) => JSX.Element) & {
displayName: string;
} & {
features: typeof Features;
type FocusTrapRenderPropArg = {};
type FocusTrapPropsWeControl = never;
export type FocusTrapProps<TTag extends ElementType = typeof DEFAULT_FOCUS_TRAP_TAG> = Props<TTag, FocusTrapRenderPropArg, FocusTrapPropsWeControl, {
initialFocus?: MutableRefObject<HTMLElement | null>;
initialFocusFallback?: MutableRefObject<HTMLElement | null>;
features?: FocusTrapFeatures;
containers?: Containers;
}>;
declare function FocusTrapFn<TTag extends ElementType = typeof DEFAULT_FOCUS_TRAP_TAG>(props: FocusTrapProps<TTag>, ref: Ref<HTMLElement>): React.JSX.Element;
export interface _internal_ComponentFocusTrap extends HasDisplayName {
<TTag extends ElementType = typeof DEFAULT_FOCUS_TRAP_TAG>(props: FocusTrapProps<TTag> & RefProp<typeof FocusTrapFn>): JSX.Element;
}
export declare let FocusTrap: _internal_ComponentFocusTrap & {
/** @deprecated use `FocusTrapFeatures` instead of `FocusTrap.features` */
features: typeof FocusTrapFeatures;
};
export {};

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

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

@@ -1,25 +0,36 @@

import React, { ReactNode, Ref } from 'react';
import { Props } from '../../types';
import React, { type ElementType, type ReactNode, type Ref } from 'react';
import type { Props } from '../../types.js';
import { type HasDisplayName, type RefProp } from '../../utils/render.js';
interface SharedData {
slot?: {};
name?: string;
props?: {};
props?: Record<string, any>;
}
export declare function useLabelContext(): {
value: string | undefined;
register(value: string): () => void;
} & SharedData;
export declare function useLabelledBy(alwaysAvailableIds?: (string | undefined | null)[]): string | undefined;
interface LabelProviderProps extends SharedData {
children: ReactNode;
value?: string | undefined;
}
export declare function useLabels(): [string | undefined, (props: LabelProviderProps) => JSX.Element];
export declare let Label: (<TTag extends React.ElementType<any> = "label">(props: Omit<import("../../types").PropsOf<TTag>, ("as" | "children" | "refName" | "className") | "id"> & {
as?: TTag | undefined;
children?: React.ReactNode | ((bag: {}) => React.ReactElement<any, string | React.JSXElementConstructor<any>>);
refName?: string | undefined;
} & (import("../../types").PropsOf<TTag> extends {
className?: any;
} ? {
className?: string | ((bag: {}) => string) | undefined;
} : {}) & {
passive?: boolean | undefined;
}, ref: Ref<HTMLLabelElement>) => React.ReactElement<any, string | React.JSXElementConstructor<any>> | null) & {
displayName: string;
export declare function useLabels({ inherit }?: {
inherit?: boolean | undefined;
}): [
string | undefined,
(props: LabelProviderProps & {
inherit?: boolean;
}) => JSX.Element
];
declare let DEFAULT_LABEL_TAG: "label";
export type LabelProps<TTag extends ElementType = typeof DEFAULT_LABEL_TAG> = Props<TTag> & {
passive?: boolean;
htmlFor?: string;
};
declare function LabelFn<TTag extends ElementType = typeof DEFAULT_LABEL_TAG>(props: LabelProps<TTag>, ref: Ref<HTMLLabelElement>): React.ReactElement<any, string | React.JSXElementConstructor<any>> | null;
export interface _internal_ComponentLabel extends HasDisplayName {
<TTag extends ElementType = typeof DEFAULT_LABEL_TAG>(props: LabelProps<TTag> & RefProp<typeof LabelFn>): JSX.Element;
}
export declare let Label: _internal_ComponentLabel;
export {};

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

import p,{createContext as m,useContext as L,useMemo as f,useState as b}from"react";import{useId as g}from"../../hooks/use-id.js";import{forwardRefWithAs as x,render as T}from"../../utils/render.js";import{useIsoMorphicEffect as E}from"../../hooks/use-iso-morphic-effect.js";import{useSyncRefs as P}from"../../hooks/use-sync-refs.js";import{useEvent as v}from"../../hooks/use-event.js";let u=m(null);function c(){let o=L(u);if(o===null){let t=new Error("You used a <Label /> component, but it is not inside a relevant parent.");throw Error.captureStackTrace&&Error.captureStackTrace(t,c),t}return o}function M(){let[o,t]=b([]);return[o.length>0?o.join(" "):void 0,f(()=>function(e){let l=v(a=>(t(i=>[...i,a]),()=>t(i=>{let n=i.slice(),d=n.indexOf(a);return d!==-1&&n.splice(d,1),n}))),r=f(()=>({register:l,slot:e.slot,name:e.name,props:e.props}),[l,e.slot,e.name,e.props]);return p.createElement(u.Provider,{value:r},e.children)},[t])]}let h="label",F=x(function(t,s){let{passive:e=!1,...l}=t,r=c(),a=`headlessui-label-${g()}`,i=P(s);E(()=>r.register(a),[a,r.register]);let n={ref:i,...r.props,id:a};return e&&("onClick"in n&&delete n.onClick,"onClick"in l&&delete l.onClick),T({ourProps:n,theirProps:l,slot:r.slot||{},defaultTag:h,name:r.name||"Label"})});export{F as Label,M as useLabels};
"use client";import k,{createContext as D,useContext as h,useMemo as T,useState as R}from"react";import{useEvent as v}from'../../hooks/use-event.js';import{useId as _}from'../../hooks/use-id.js';import{useIsoMorphicEffect as A}from'../../hooks/use-iso-morphic-effect.js';import{useSyncRefs as B}from'../../hooks/use-sync-refs.js';import{useDisabled as F}from'../../internal/disabled.js';import{useProvidedId as S}from'../../internal/id.js';import{forwardRefWithAs as M,render as H}from'../../utils/render.js';let c=D(null);c.displayName="LabelContext";function P(){let r=h(c);if(r===null){let l=new Error("You used a <Label /> component, but it is not inside a relevant parent.");throw Error.captureStackTrace&&Error.captureStackTrace(l,P),l}return r}function I(r){var a,e,o;let l=(e=(a=h(c))==null?void 0:a.value)!=null?e:void 0;return((o=r==null?void 0:r.length)!=null?o:0)>0?[l,...r].filter(Boolean).join(" "):l}function z({inherit:r=!1}={}){let l=I(),[a,e]=R([]),o=r?[l,...a].filter(Boolean):a;return[o.length>0?o.join(" "):void 0,T(()=>function(t){let s=v(i=>(e(p=>[...p,i]),()=>e(p=>{let u=p.slice(),d=u.indexOf(i);return d!==-1&&u.splice(d,1),u}))),m=T(()=>({register:s,slot:t.slot,name:t.name,props:t.props,value:t.value}),[s,t.slot,t.name,t.props,t.value]);return k.createElement(c.Provider,{value:m},t.children)},[e])]}let N="label";function G(r,l){var y;let a=_(),e=P(),o=S(),g=F(),{id:t=`headlessui-label-${a}`,htmlFor:s=o!=null?o:(y=e.props)==null?void 0:y.htmlFor,passive:m=!1,...i}=r,p=B(l);A(()=>e.register(t),[t,e.register]);let u=v(L=>{let b=L.currentTarget;if(b instanceof HTMLLabelElement&&L.preventDefault(),e.props&&"onClick"in e.props&&typeof e.props.onClick=="function"&&e.props.onClick(L),b instanceof HTMLLabelElement){let n=document.getElementById(b.htmlFor);if(n){let E=n.getAttribute("disabled");if(E==="true"||E==="")return;let x=n.getAttribute("aria-disabled");if(x==="true"||x==="")return;(n instanceof HTMLInputElement&&(n.type==="radio"||n.type==="checkbox")||n.role==="radio"||n.role==="checkbox"||n.role==="switch")&&n.click(),n.focus({preventScroll:!0})}}}),d=g||!1,C=T(()=>({...e.slot,disabled:d}),[e.slot,d]),f={ref:p,...e.props,id:t,htmlFor:s,onClick:u};return m&&("onClick"in f&&(delete f.htmlFor,delete f.onClick),"onClick"in i&&delete i.onClick),H({ourProps:f,theirProps:i,slot:C,defaultTag:s?N:"div",name:e.name||"Label"})}let U=M(G),K=Object.assign(U,{});export{K as Label,P as useLabelContext,I as useLabelledBy,z as useLabels};

@@ -1,66 +0,121 @@

import React, { Ref } from 'react';
import { Props } from '../../types';
import { PropsForFeatures } from '../../utils/render';
interface ListboxRenderPropArg {
import React, { type ElementType, type Ref } from 'react';
import { type ByComparator } from '../../hooks/use-by-comparator.js';
import { type AnchorPropsWithSelection } from '../../internal/floating.js';
import type { Props } from '../../types.js';
import { type HasDisplayName, type PropsForFeatures, type RefProp } from '../../utils/render.js';
import { type _internal_ComponentLabel } from '../label/label.js';
declare let DEFAULT_LISTBOX_TAG: React.ExoticComponent<{
children?: React.ReactNode;
}>;
type ListboxRenderPropArg<T> = {
open: boolean;
disabled: boolean;
}
interface ButtonRenderPropArg {
open: boolean;
invalid: boolean;
value: T;
};
export type ListboxProps<TTag extends ElementType = typeof DEFAULT_LISTBOX_TAG, TType = string, TActualType = TType> = Props<TTag, ListboxRenderPropArg<TType>, 'value' | 'defaultValue' | 'onChange' | 'by' | 'disabled' | 'horizontal' | 'name' | 'multiple', {
value?: TType;
defaultValue?: TType;
onChange?(value: TType): void;
by?: ByComparator<TActualType>;
disabled?: boolean;
invalid?: boolean;
horizontal?: boolean;
form?: string;
name?: string;
multiple?: boolean;
__demoMode?: boolean;
}>;
declare function ListboxFn<TTag extends ElementType = typeof DEFAULT_LISTBOX_TAG, TType = string, TActualType = TType extends (infer U)[] ? U : TType>(props: ListboxProps<TTag, TType, TActualType>, ref: Ref<HTMLElement>): React.JSX.Element;
declare let DEFAULT_BUTTON_TAG: "button";
type ButtonRenderPropArg = {
disabled: boolean;
}
declare type ButtonPropsWeControl = 'id' | 'type' | 'aria-haspopup' | 'aria-controls' | 'aria-expanded' | 'aria-labelledby' | 'disabled' | 'onKeyDown' | 'onClick';
interface LabelRenderPropArg {
invalid: boolean;
hover: boolean;
focus: boolean;
autofocus: boolean;
open: boolean;
disabled: boolean;
}
declare type LabelPropsWeControl = 'id' | 'ref' | 'onClick';
interface OptionsRenderPropArg {
active: boolean;
value: any;
};
type ButtonPropsWeControl = 'aria-controls' | 'aria-expanded' | 'aria-haspopup' | 'aria-labelledby' | 'disabled';
export type ListboxButtonProps<TTag extends ElementType = typeof DEFAULT_BUTTON_TAG> = Props<TTag, ButtonRenderPropArg, ButtonPropsWeControl, {
autoFocus?: boolean;
disabled?: boolean;
}>;
declare function ButtonFn<TTag extends ElementType = typeof DEFAULT_BUTTON_TAG>(props: ListboxButtonProps<TTag>, ref: Ref<HTMLButtonElement>): React.ReactElement<any, string | React.JSXElementConstructor<any>> | null;
declare let DEFAULT_OPTIONS_TAG: "div";
type OptionsRenderPropArg = {
open: boolean;
}
declare type OptionsPropsWeControl = 'aria-activedescendant' | 'aria-labelledby' | 'aria-orientation' | 'id' | 'onKeyDown' | 'role' | 'tabIndex';
};
type OptionsPropsWeControl = 'aria-activedescendant' | 'aria-labelledby' | 'aria-multiselectable' | 'aria-orientation' | 'role' | 'tabIndex';
declare let OptionsRenderFeatures: number;
interface OptionRenderPropArg {
export type ListboxOptionsProps<TTag extends ElementType = typeof DEFAULT_OPTIONS_TAG> = Props<TTag, OptionsRenderPropArg, OptionsPropsWeControl, {
anchor?: AnchorPropsWithSelection;
portal?: boolean;
modal?: boolean;
transition?: boolean;
} & PropsForFeatures<typeof OptionsRenderFeatures>>;
declare function OptionsFn<TTag extends ElementType = typeof DEFAULT_OPTIONS_TAG>(props: ListboxOptionsProps<TTag>, ref: Ref<HTMLElement>): React.JSX.Element;
declare let DEFAULT_OPTION_TAG: "div";
type OptionRenderPropArg = {
/** @deprecated use `focus` instead */
active: boolean;
focus: boolean;
selected: boolean;
disabled: boolean;
selectedOption: boolean;
};
type OptionPropsWeControl = 'aria-disabled' | 'aria-selected' | 'role' | 'tabIndex';
export type ListboxOptionProps<TTag extends ElementType = typeof DEFAULT_OPTION_TAG, TType = string> = Props<TTag, OptionRenderPropArg, OptionPropsWeControl, {
disabled?: boolean;
value: TType;
}>;
declare function OptionFn<TTag extends ElementType = typeof DEFAULT_OPTION_TAG, TType = Parameters<typeof ListboxRoot>[0]['value']>(props: ListboxOptionProps<TTag, TType>, ref: Ref<HTMLElement>): React.ReactElement<any, string | React.JSXElementConstructor<any>> | null;
declare let DEFAULT_SELECTED_OPTION_TAG: React.ExoticComponent<{
children?: React.ReactNode;
}>;
type SelectedOptionRenderPropArg = {};
type SelectedOptionPropsWeControl = never;
export type ListboxSelectedOptionProps<TTag extends ElementType = typeof DEFAULT_SELECTED_OPTION_TAG> = Props<TTag, SelectedOptionRenderPropArg, SelectedOptionPropsWeControl, {
options: React.ReactNode;
placeholder?: React.ReactNode;
}>;
declare function SelectedFn<TTag extends ElementType = typeof DEFAULT_SELECTED_OPTION_TAG>(props: ListboxSelectedOptionProps<TTag>, ref: Ref<HTMLElement>): React.JSX.Element;
export interface _internal_ComponentListbox extends HasDisplayName {
<TTag extends ElementType = typeof DEFAULT_LISTBOX_TAG, TType = string, TActualType = TType extends (infer U)[] ? U : TType>(props: ListboxProps<TTag, TType, TActualType> & RefProp<typeof ListboxFn>): JSX.Element;
}
declare type ListboxOptionPropsWeControl = 'id' | 'role' | 'tabIndex' | 'aria-disabled' | 'aria-selected' | 'onPointerLeave' | 'onMouseLeave' | 'onPointerMove' | 'onMouseMove' | 'onFocus';
export declare let Listbox: (<TTag extends React.ElementType<any> = React.ExoticComponent<{
children?: React.ReactNode;
}>, TType = string, TActualType = TType extends (infer U)[] ? U : TType>(props: Props<TTag, ListboxRenderPropArg, "value" | "name" | "disabled" | "onChange" | "multiple" | "by" | "horizontal"> & {
value: TType;
onChange(value: TType): void;
by?: (keyof TType & string) | ((a: TType, z: TType) => boolean) | undefined;
disabled?: boolean | undefined;
horizontal?: boolean | undefined;
name?: string | undefined;
multiple?: boolean | undefined;
}, ref: React.Ref<TTag>) => JSX.Element) & {
displayName: string;
} & {
Button: (<TTag_1 extends React.ElementType<any> = "button">(props: Props<TTag_1, ButtonRenderPropArg, ButtonPropsWeControl>, ref: Ref<HTMLButtonElement>) => React.ReactElement<any, string | React.JSXElementConstructor<any>> | null) & {
displayName: string;
};
Label: (<TTag_2 extends React.ElementType<any> = "label">(props: Props<TTag_2, LabelRenderPropArg, LabelPropsWeControl>, ref: Ref<HTMLElement>) => React.ReactElement<any, string | React.JSXElementConstructor<any>> | null) & {
displayName: string;
};
Options: (<TTag_3 extends React.ElementType<any> = "ul">(props: Props<TTag_3, OptionsRenderPropArg, OptionsPropsWeControl> & (({
static?: undefined;
} & {
unmount?: boolean | undefined;
}) | ({
unmount?: undefined;
} & {
static?: boolean | undefined;
})), ref: Ref<HTMLElement>) => React.ReactElement<any, string | React.JSXElementConstructor<any>> | null) & {
displayName: string;
};
Option: (<TTag_4 extends React.ElementType<any> = "li", TType_1 = unknown>(props: Props<TTag_4, OptionRenderPropArg, "value" | ListboxOptionPropsWeControl> & {
disabled?: boolean | undefined;
value: TType_1;
}, ref: Ref<HTMLElement>) => React.ReactElement<any, string | React.JSXElementConstructor<any>> | null) & {
displayName: string;
};
export interface _internal_ComponentListboxButton extends HasDisplayName {
<TTag extends ElementType = typeof DEFAULT_BUTTON_TAG>(props: ListboxButtonProps<TTag> & RefProp<typeof ButtonFn>): JSX.Element;
}
export interface _internal_ComponentListboxLabel extends _internal_ComponentLabel {
}
export interface _internal_ComponentListboxOptions extends HasDisplayName {
<TTag extends ElementType = typeof DEFAULT_OPTIONS_TAG>(props: ListboxOptionsProps<TTag> & RefProp<typeof OptionsFn>): JSX.Element;
}
export interface _internal_ComponentListboxOption extends HasDisplayName {
<TTag extends ElementType = typeof DEFAULT_OPTION_TAG, TType = Parameters<typeof ListboxRoot>[0]['value']>(props: ListboxOptionProps<TTag, TType> & RefProp<typeof OptionFn>): JSX.Element;
}
export interface _internal_ComponentListboxSelectedOption extends HasDisplayName {
<TTag extends ElementType = typeof DEFAULT_SELECTED_OPTION_TAG>(props: ListboxSelectedOptionProps<TTag> & RefProp<typeof SelectedFn>): JSX.Element;
}
declare let ListboxRoot: _internal_ComponentListbox;
export declare let ListboxButton: _internal_ComponentListboxButton;
/** @deprecated use `<Label>` instead of `<ListboxLabel>` */
export declare let ListboxLabel: _internal_ComponentListboxLabel;
export declare let ListboxOptions: _internal_ComponentListboxOptions;
export declare let ListboxOption: _internal_ComponentListboxOption;
export declare let ListboxSelectedOption: _internal_ComponentListboxSelectedOption;
export declare let Listbox: _internal_ComponentListbox & {
/** @deprecated use `<ListboxButton>` instead of `<Listbox.Button>` */
Button: _internal_ComponentListboxButton;
/** @deprecated use `<Label>` instead of `<Listbox.Label>` */
Label: _internal_ComponentListboxLabel;
/** @deprecated use `<ListboxOptions>` instead of `<Listbox.Options>` */
Options: _internal_ComponentListboxOptions;
/** @deprecated use `<ListboxOption>` instead of `<Listbox.Option>` */
Option: _internal_ComponentListboxOption;
/** @deprecated use `<ListboxSelectedOption>` instead of `<Listbox.SelectedOption>` */
SelectedOption: _internal_ComponentListboxSelectedOption;
};
export {};

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

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

@@ -1,48 +0,117 @@

import React, { Ref } from 'react';
import { Props } from '../../types';
import { PropsForFeatures } from '../../utils/render';
interface MenuRenderPropArg {
import React, { type ElementType, type Ref } from 'react';
import { type AnchorProps } from '../../internal/floating.js';
import type { Props } from '../../types.js';
import { type HasDisplayName, type RefProp } from '../../utils/render.js';
declare let DEFAULT_MENU_TAG: React.ExoticComponent<{
children?: React.ReactNode;
}>;
type MenuRenderPropArg = {
open: boolean;
}
interface ButtonRenderPropArg {
close: () => void;
};
type MenuPropsWeControl = never;
export type MenuProps<TTag extends ElementType = typeof DEFAULT_MENU_TAG> = Props<TTag, MenuRenderPropArg, MenuPropsWeControl, {
__demoMode?: boolean;
}>;
declare function MenuFn<TTag extends ElementType = typeof DEFAULT_MENU_TAG>(props: MenuProps<TTag>, ref: Ref<HTMLElement>): React.JSX.Element;
declare let DEFAULT_BUTTON_TAG: "button";
type ButtonRenderPropArg = {
open: boolean;
}
declare type ButtonPropsWeControl = 'id' | 'type' | 'aria-haspopup' | 'aria-controls' | 'aria-expanded' | 'onKeyDown' | 'onClick';
interface ItemsRenderPropArg {
active: boolean;
hover: boolean;
focus: boolean;
disabled: boolean;
autofocus: boolean;
};
type ButtonPropsWeControl = 'aria-controls' | 'aria-expanded' | 'aria-haspopup';
export type MenuButtonProps<TTag extends ElementType = typeof DEFAULT_BUTTON_TAG> = Props<TTag, ButtonRenderPropArg, ButtonPropsWeControl, {
disabled?: boolean;
autoFocus?: boolean;
}>;
declare function ButtonFn<TTag extends ElementType = typeof DEFAULT_BUTTON_TAG>(props: MenuButtonProps<TTag>, ref: Ref<HTMLButtonElement>): React.ReactElement<any, string | React.JSXElementConstructor<any>> | null;
declare let DEFAULT_ITEMS_TAG: "div";
type ItemsRenderPropArg = {
open: boolean;
}
declare type ItemsPropsWeControl = 'aria-activedescendant' | 'aria-labelledby' | 'id' | 'onKeyDown' | 'role' | 'tabIndex';
declare let ItemsRenderFeatures: number;
interface ItemRenderPropArg {
};
type ItemsPropsWeControl = 'aria-activedescendant' | 'aria-labelledby' | 'role' | 'tabIndex';
export type MenuItemsProps<TTag extends ElementType = typeof DEFAULT_ITEMS_TAG> = Props<TTag, ItemsRenderPropArg, ItemsPropsWeControl, {
anchor?: AnchorProps;
portal?: boolean;
modal?: boolean;
transition?: boolean;
static?: boolean;
unmount?: boolean;
}>;
declare function ItemsFn<TTag extends ElementType = typeof DEFAULT_ITEMS_TAG>(props: MenuItemsProps<TTag>, ref: Ref<HTMLElement>): React.JSX.Element;
declare let DEFAULT_ITEM_TAG: React.ExoticComponent<{
children?: React.ReactNode;
}>;
type ItemRenderPropArg = {
/** @deprecated use `focus` instead */
active: boolean;
focus: boolean;
disabled: boolean;
close: () => void;
};
type ItemPropsWeControl = 'aria-describedby' | 'aria-disabled' | 'aria-labelledby' | 'role' | 'tabIndex';
export type MenuItemProps<TTag extends ElementType = typeof DEFAULT_ITEM_TAG> = Props<TTag, ItemRenderPropArg, ItemPropsWeControl, {
disabled?: boolean;
}>;
declare function ItemFn<TTag extends ElementType = typeof DEFAULT_ITEM_TAG>(props: MenuItemProps<TTag>, ref: Ref<HTMLElement>): React.JSX.Element;
declare let DEFAULT_SECTION_TAG: "div";
type SectionRenderPropArg = {};
type SectionPropsWeControl = 'role' | 'aria-labelledby';
export type MenuSectionProps<TTag extends ElementType = typeof DEFAULT_SECTION_TAG> = Props<TTag, SectionRenderPropArg, SectionPropsWeControl>;
declare function SectionFn<TTag extends ElementType = typeof DEFAULT_SECTION_TAG>(props: MenuSectionProps<TTag>, ref: Ref<HTMLElement>): React.JSX.Element;
declare let DEFAULT_HEADING_TAG: "header";
type HeadingRenderPropArg = {};
type HeadingPropsWeControl = 'role';
export type MenuHeadingProps<TTag extends ElementType = typeof DEFAULT_HEADING_TAG> = Props<TTag, HeadingRenderPropArg, HeadingPropsWeControl>;
declare function HeadingFn<TTag extends ElementType = typeof DEFAULT_HEADING_TAG>(props: MenuHeadingProps<TTag>, ref: Ref<HTMLElement>): React.ReactElement<any, string | React.JSXElementConstructor<any>> | null;
declare let DEFAULT_SEPARATOR_TAG: "div";
type SeparatorRenderPropArg = {};
type SeparatorPropsWeControl = 'role';
export type MenuSeparatorProps<TTag extends ElementType = typeof DEFAULT_SEPARATOR_TAG> = Props<TTag, SeparatorRenderPropArg, SeparatorPropsWeControl>;
declare function SeparatorFn<TTag extends ElementType = typeof DEFAULT_SEPARATOR_TAG>(props: MenuSeparatorProps<TTag>, ref: Ref<HTMLElement>): React.ReactElement<any, string | React.JSXElementConstructor<any>> | null;
export interface _internal_ComponentMenu extends HasDisplayName {
<TTag extends ElementType = typeof DEFAULT_MENU_TAG>(props: MenuProps<TTag> & RefProp<typeof MenuFn>): JSX.Element;
}
declare type MenuItemPropsWeControl = 'id' | 'role' | 'tabIndex' | 'aria-disabled' | 'onPointerLeave' | 'onPointerMove' | 'onMouseLeave' | 'onMouseMove' | 'onFocus';
export declare let Menu: (<TTag extends React.ElementType<any> = React.ExoticComponent<{
children?: React.ReactNode;
}>>(props: Props<TTag, MenuRenderPropArg, "1D45E01E-AF44-47C4-988A-19A94EBAF55C">, ref: Ref<HTMLElement>) => JSX.Element) & {
displayName: string;
} & {
Button: (<TTag_1 extends React.ElementType<any> = "button">(props: Props<TTag_1, ButtonRenderPropArg, ButtonPropsWeControl>, ref: Ref<HTMLButtonElement>) => React.ReactElement<any, string | React.JSXElementConstructor<any>> | null) & {
displayName: string;
};
Items: (<TTag_2 extends React.ElementType<any> = "div">(props: Props<TTag_2, ItemsRenderPropArg, ItemsPropsWeControl> & (({
static?: undefined;
} & {
unmount?: boolean | undefined;
}) | ({
unmount?: undefined;
} & {
static?: boolean | undefined;
})), ref: Ref<HTMLDivElement>) => React.ReactElement<any, string | React.JSXElementConstructor<any>> | null) & {
displayName: string;
};
Item: (<TTag_3 extends React.ElementType<any> = React.ExoticComponent<{
children?: React.ReactNode;
}>>(props: Props<TTag_3, ItemRenderPropArg, MenuItemPropsWeControl> & {
disabled?: boolean | undefined;
}, ref: Ref<HTMLElement>) => React.ReactElement<any, string | React.JSXElementConstructor<any>> | null) & {
displayName: string;
};
export interface _internal_ComponentMenuButton extends HasDisplayName {
<TTag extends ElementType = typeof DEFAULT_BUTTON_TAG>(props: MenuButtonProps<TTag> & RefProp<typeof ButtonFn>): JSX.Element;
}
export interface _internal_ComponentMenuItems extends HasDisplayName {
<TTag extends ElementType = typeof DEFAULT_ITEMS_TAG>(props: MenuItemsProps<TTag> & RefProp<typeof ItemsFn>): JSX.Element;
}
export interface _internal_ComponentMenuItem extends HasDisplayName {
<TTag extends ElementType = typeof DEFAULT_ITEM_TAG>(props: MenuItemProps<TTag> & RefProp<typeof ItemFn>): JSX.Element;
}
export interface _internal_ComponentMenuSection extends HasDisplayName {
<TTag extends ElementType = typeof DEFAULT_SECTION_TAG>(props: MenuSectionProps<TTag> & RefProp<typeof SectionFn>): JSX.Element;
}
export interface _internal_ComponentMenuHeading extends HasDisplayName {
<TTag extends ElementType = typeof DEFAULT_HEADING_TAG>(props: MenuHeadingProps<TTag> & RefProp<typeof HeadingFn>): JSX.Element;
}
export interface _internal_ComponentMenuSeparator extends HasDisplayName {
<TTag extends ElementType = typeof DEFAULT_SEPARATOR_TAG>(props: MenuSeparatorProps<TTag> & RefProp<typeof SeparatorFn>): JSX.Element;
}
export declare let MenuButton: _internal_ComponentMenuButton;
export declare let MenuItems: _internal_ComponentMenuItems;
export declare let MenuItem: _internal_ComponentMenuItem;
export declare let MenuSection: _internal_ComponentMenuSection;
export declare let MenuHeading: _internal_ComponentMenuHeading;
export declare let MenuSeparator: _internal_ComponentMenuSeparator;
export declare let Menu: _internal_ComponentMenu & {
/** @deprecated use `<MenuButton>` instead of `<Menu.Button>` */
Button: _internal_ComponentMenuButton;
/** @deprecated use `<MenuItems>` instead of `<Menu.Items>` */
Items: _internal_ComponentMenuItems;
/** @deprecated use `<MenuItem>` instead of `<Menu.Item>` */
Item: _internal_ComponentMenuItem;
/** @deprecated use `<MenuSection>` instead of `<Menu.Section>` */
Section: _internal_ComponentMenuSection;
/** @deprecated use `<MenuHeading>` instead of `<Menu.Heading>` */
Heading: _internal_ComponentMenuHeading;
/** @deprecated use `<MenuSeparator>` instead of `<Menu.Separator>` */
Separator: _internal_ComponentMenuSeparator;
};
export {};

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

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

@@ -1,60 +0,96 @@

import React, { MutableRefObject, Ref } from 'react';
import { Props } from '../../types';
import { PropsForFeatures } from '../../utils/render';
interface PopoverRenderPropArg {
import React, { type ElementType, type MouseEventHandler, type MutableRefObject, type Ref } from 'react';
import { type AnchorProps } from '../../internal/floating.js';
import type { Props } from '../../types.js';
import { type HasDisplayName, type PropsForFeatures, type RefProp } from '../../utils/render.js';
type MouseEvent<T> = Parameters<MouseEventHandler<T>>[0];
declare let DEFAULT_POPOVER_TAG: "div";
type PopoverRenderPropArg = {
open: boolean;
close(focusableElement?: HTMLElement | MutableRefObject<HTMLElement | null>): void;
}
interface ButtonRenderPropArg {
close: (focusableElement?: HTMLElement | MutableRefObject<HTMLElement | null> | MouseEvent<HTMLElement>) => void;
};
type PopoverPropsWeControl = never;
export type PopoverProps<TTag extends ElementType = typeof DEFAULT_POPOVER_TAG> = Props<TTag, PopoverRenderPropArg, PopoverPropsWeControl, {
__demoMode?: boolean;
}>;
declare function PopoverFn<TTag extends ElementType = typeof DEFAULT_POPOVER_TAG>(props: PopoverProps<TTag>, ref: Ref<HTMLElement>): React.JSX.Element;
declare let DEFAULT_BUTTON_TAG: "button";
type ButtonRenderPropArg = {
open: boolean;
}
declare type ButtonPropsWeControl = 'id' | 'type' | 'aria-expanded' | 'aria-controls' | 'onKeyDown' | 'onClick';
interface OverlayRenderPropArg {
active: boolean;
hover: boolean;
focus: boolean;
disabled: boolean;
autofocus: boolean;
};
type ButtonPropsWeControl = 'aria-controls' | 'aria-expanded';
export type PopoverButtonProps<TTag extends ElementType = typeof DEFAULT_BUTTON_TAG> = Props<TTag, ButtonRenderPropArg, ButtonPropsWeControl, {
disabled?: boolean;
autoFocus?: boolean;
}>;
declare function ButtonFn<TTag extends ElementType = typeof DEFAULT_BUTTON_TAG>(props: PopoverButtonProps<TTag>, ref: Ref<HTMLButtonElement>): React.JSX.Element;
declare let DEFAULT_BACKDROP_TAG: "div";
type BackdropRenderPropArg = {
open: boolean;
}
declare type OverlayPropsWeControl = 'id' | 'aria-hidden' | 'onClick';
declare let OverlayRenderFeatures: number;
interface PanelRenderPropArg {
};
type BackdropPropsWeControl = 'aria-hidden';
declare let BackdropRenderFeatures: number;
export type PopoverBackdropProps<TTag extends ElementType = typeof DEFAULT_BACKDROP_TAG> = Props<TTag, BackdropRenderPropArg, BackdropPropsWeControl, {
transition?: boolean;
} & PropsForFeatures<typeof BackdropRenderFeatures>>;
export type PopoverOverlayProps<TTag extends ElementType = typeof DEFAULT_BACKDROP_TAG> = PopoverBackdropProps<TTag>;
declare function BackdropFn<TTag extends ElementType = typeof DEFAULT_BACKDROP_TAG>(props: PopoverBackdropProps<TTag>, ref: Ref<HTMLElement>): React.ReactElement<any, string | React.JSXElementConstructor<any>> | null;
declare let DEFAULT_PANEL_TAG: "div";
type PanelRenderPropArg = {
open: boolean;
close: (focusableElement?: HTMLElement | MutableRefObject<HTMLElement | null>) => void;
};
type PanelPropsWeControl = 'tabIndex';
export type PopoverPanelProps<TTag extends ElementType = typeof DEFAULT_PANEL_TAG> = Props<TTag, PanelRenderPropArg, PanelPropsWeControl, {
focus?: boolean;
anchor?: AnchorProps;
portal?: boolean;
modal?: boolean;
transition?: boolean;
static?: boolean;
unmount?: boolean;
}>;
declare function PanelFn<TTag extends ElementType = typeof DEFAULT_PANEL_TAG>(props: PopoverPanelProps<TTag>, ref: Ref<HTMLElement>): React.JSX.Element;
declare let DEFAULT_GROUP_TAG: "div";
type GroupRenderPropArg = {};
type GroupPropsWeControl = never;
export type PopoverGroupProps<TTag extends ElementType = typeof DEFAULT_GROUP_TAG> = Props<TTag, GroupRenderPropArg, GroupPropsWeControl>;
declare function GroupFn<TTag extends ElementType = typeof DEFAULT_GROUP_TAG>(props: PopoverGroupProps<TTag>, ref: Ref<HTMLElement>): React.JSX.Element;
export interface _internal_ComponentPopover extends HasDisplayName {
<TTag extends ElementType = typeof DEFAULT_POPOVER_TAG>(props: PopoverProps<TTag> & RefProp<typeof PopoverFn>): JSX.Element;
}
declare type PanelPropsWeControl = 'id' | 'onKeyDown';
declare let PanelRenderFeatures: number;
interface GroupRenderPropArg {
export interface _internal_ComponentPopoverButton extends HasDisplayName {
<TTag extends ElementType = typeof DEFAULT_BUTTON_TAG>(props: PopoverButtonProps<TTag> & RefProp<typeof ButtonFn>): JSX.Element;
}
declare type GroupPropsWeControl = 'id';
export declare let Popover: (<TTag extends React.ElementType<any> = "div">(props: Props<TTag, PopoverRenderPropArg, "1D45E01E-AF44-47C4-988A-19A94EBAF55C">, ref: Ref<HTMLElement>) => JSX.Element) & {
displayName: string;
} & {
Button: (<TTag_1 extends React.ElementType<any> = "button">(props: Props<TTag_1, ButtonRenderPropArg, ButtonPropsWeControl>, ref: Ref<HTMLButtonElement>) => JSX.Element) & {
displayName: string;
};
Overlay: (<TTag_2 extends React.ElementType<any> = "div">(props: Props<TTag_2, OverlayRenderPropArg, OverlayPropsWeControl> & (({
static?: undefined;
} & {
unmount?: boolean | undefined;
}) | ({
unmount?: undefined;
} & {
static?: boolean | undefined;
})), ref: Ref<HTMLDivElement>) => React.ReactElement<any, string | React.JSXElementConstructor<any>> | null) & {
displayName: string;
};
Panel: (<TTag_3 extends React.ElementType<any> = "div">(props: Props<TTag_3, PanelRenderPropArg, PanelPropsWeControl> & (({
static?: undefined;
} & {
unmount?: boolean | undefined;
}) | ({
unmount?: undefined;
} & {
static?: boolean | undefined;
})) & {
focus?: boolean | undefined;
}, ref: Ref<HTMLDivElement>) => JSX.Element) & {
displayName: string;
};
Group: (<TTag_4 extends React.ElementType<any> = "div">(props: Props<TTag_4, GroupRenderPropArg, "id">, ref: Ref<HTMLElement>) => JSX.Element) & {
displayName: string;
};
export interface _internal_ComponentPopoverBackdrop extends HasDisplayName {
<TTag extends ElementType = typeof DEFAULT_BACKDROP_TAG>(props: PopoverBackdropProps<TTag> & RefProp<typeof BackdropFn>): JSX.Element;
}
export interface _internal_ComponentPopoverPanel extends HasDisplayName {
<TTag extends ElementType = typeof DEFAULT_PANEL_TAG>(props: PopoverPanelProps<TTag> & RefProp<typeof PanelFn>): JSX.Element;
}
export interface _internal_ComponentPopoverGroup extends HasDisplayName {
<TTag extends ElementType = typeof DEFAULT_GROUP_TAG>(props: PopoverGroupProps<TTag> & RefProp<typeof GroupFn>): JSX.Element;
}
export declare let PopoverButton: _internal_ComponentPopoverButton;
/** @deprecated use `<PopoverBackdrop>` instead of `<PopoverOverlay>` */
export declare let PopoverOverlay: _internal_ComponentPopoverBackdrop;
export declare let PopoverBackdrop: _internal_ComponentPopoverBackdrop;
export declare let PopoverPanel: _internal_ComponentPopoverPanel;
export declare let PopoverGroup: _internal_ComponentPopoverGroup;
export declare let Popover: _internal_ComponentPopover & {
/** @deprecated use `<PopoverButton>` instead of `<Popover.Button>` */
Button: _internal_ComponentPopoverButton;
/** @deprecated use `<PopoverBackdrop>` instead of `<Popover.Backdrop>` */
Backdrop: _internal_ComponentPopoverBackdrop;
/** @deprecated use `<PopoverOverlay>` instead of `<Popover.Overlay>` */
Overlay: _internal_ComponentPopoverBackdrop;
/** @deprecated use `<PopoverPanel>` instead of `<Popover.Panel>` */
Panel: _internal_ComponentPopoverPanel;
/** @deprecated use `<PopoverGroup>` instead of `<Popover.Group>` */
Group: _internal_ComponentPopoverGroup;
};
export {};

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

import I,{createContext as V,createRef as pe,useContext as $,useEffect as U,useMemo as M,useReducer as fe,useRef as Y,useState as Pe}from"react";import{match as x}from"../../utils/match.js";import{forwardRefWithAs as W,render as j,Features as q}from"../../utils/render.js";import{optionalRef as de,useSyncRefs as H}from"../../hooks/use-sync-refs.js";import{useId as G}from"../../hooks/use-id.js";import{Keys as h}from"../keyboard.js";import{isDisabledReactIssue7711 as se}from"../../utils/bugs.js";import{getFocusableElements as ve,Focus as k,focusIn as _,isFocusableElement as Te,FocusableMode as me}from"../../utils/focus-management.js";import{OpenClosedProvider as ye,State as z,useOpenClosed as ie}from"../../internal/open-closed.js";import{useResolveButtonType as Ee}from"../../hooks/use-resolve-button-type.js";import{useOutsideClick as Se}from"../../hooks/use-outside-click.js";import{getOwnerDocument as be}from"../../utils/owner.js";import{useOwnerDocument as Q}from"../../hooks/use-owner.js";import{useEventListener as ge}from"../../hooks/use-event-listener.js";import{Hidden as X,Features as Z}from"../../internal/hidden.js";import{useEvent as b}from"../../hooks/use-event.js";import{useTabDirection as ue,Direction as w}from"../../hooks/use-tab-direction.js";import"../../utils/micro-task.js";var Ae=(c=>(c[c.Open=0]="Open",c[c.Closed=1]="Closed",c))(Ae||{}),Ce=(n=>(n[n.TogglePopover=0]="TogglePopover",n[n.ClosePopover=1]="ClosePopover",n[n.SetButton=2]="SetButton",n[n.SetButtonId=3]="SetButtonId",n[n.SetPanel=4]="SetPanel",n[n.SetPanelId=5]="SetPanelId",n))(Ce||{});let Re={[0]:r=>({...r,popoverState:x(r.popoverState,{[0]:1,[1]:0})}),[1](r){return r.popoverState===1?r:{...r,popoverState:1}},[2](r,t){return r.button===t.button?r:{...r,button:t.button}},[3](r,t){return r.buttonId===t.buttonId?r:{...r,buttonId:t.buttonId}},[4](r,t){return r.panel===t.panel?r:{...r,panel:t.panel}},[5](r,t){return r.panelId===t.panelId?r:{...r,panelId:t.panelId}}},ee=V(null);ee.displayName="PopoverContext";function J(r){let t=$(ee);if(t===null){let c=new Error(`<${r} /> is missing a parent <Popover /> component.`);throw Error.captureStackTrace&&Error.captureStackTrace(c,J),c}return t}let te=V(null);te.displayName="PopoverAPIContext";function oe(r){let t=$(te);if(t===null){let c=new Error(`<${r} /> is missing a parent <Popover /> component.`);throw Error.captureStackTrace&&Error.captureStackTrace(c,oe),c}return t}let re=V(null);re.displayName="PopoverGroupContext";function ce(){return $(re)}let ne=V(null);ne.displayName="PopoverPanelContext";function Oe(){return $(ne)}function Le(r,t){return x(t.type,Re,r,t)}let Fe="div",Ie=W(function(t,c){var R;let o=`headlessui-popover-button-${G()}`,d=`headlessui-popover-panel-${G()}`,a=Y(null),n=H(c,de(e=>{a.current=e})),g=fe(Le,{popoverState:1,button:null,buttonId:o,panel:null,panelId:d,beforePanelSentinel:pe(),afterPanelSentinel:pe()}),[{popoverState:m,button:l,panel:v,beforePanelSentinel:p,afterPanelSentinel:B},s]=g,T=Q((R=a.current)!=null?R:l);U(()=>s({type:3,buttonId:o}),[o,s]),U(()=>s({type:5,panelId:d}),[d,s]);let f=M(()=>{if(!l||!v)return!1;for(let e of document.querySelectorAll("body > *"))if(Number(e==null?void 0:e.contains(l))^Number(e==null?void 0:e.contains(v)))return!0;return!1},[l,v]),P=M(()=>({buttonId:o,panelId:d,close:()=>s({type:1})}),[o,d,s]),y=ce(),A=y==null?void 0:y.registerPopover,L=b(()=>{var e;return(e=y==null?void 0:y.isFocusWithinPopoverGroup())!=null?e:(T==null?void 0:T.activeElement)&&((l==null?void 0:l.contains(T.activeElement))||(v==null?void 0:v.contains(T.activeElement)))});U(()=>A==null?void 0:A(P),[A,P]),ge(T==null?void 0:T.defaultView,"focus",e=>{var i,S,O,N;m===0&&(L()||!l||!v||(S=(i=p.current)==null?void 0:i.contains)!=null&&S.call(i,e.target)||(N=(O=B.current)==null?void 0:O.contains)!=null&&N.call(O,e.target)||s({type:1}))},!0),Se([l,v],(e,i)=>{s({type:1}),Te(i,me.Loose)||(e.preventDefault(),l==null||l.focus())},m===0);let F=b(e=>{s({type:1});let i=(()=>e?e instanceof HTMLElement?e:e.current instanceof HTMLElement?e.current:l:l)();i==null||i.focus()}),D=M(()=>({close:F,isPortalled:f}),[F,f]),u=M(()=>({open:m===0,close:F}),[m,F]),E=t,C={ref:n};return I.createElement(ee.Provider,{value:g},I.createElement(te.Provider,{value:D},I.createElement(ye,{value:x(m,{[0]:z.Open,[1]:z.Closed})},j({ourProps:C,theirProps:E,slot:u,defaultTag:Fe,name:"Popover"}))))}),Me="button",Be=W(function(t,c){let[o,d]=J("Popover.Button"),{isPortalled:a}=oe("Popover.Button"),n=Y(null),g=`headlessui-focus-sentinel-${G()}`,m=ce(),l=m==null?void 0:m.closeOthers,v=Oe(),p=v===null?!1:v===o.panelId,B=H(n,c,p?null:e=>d({type:2,button:e})),s=H(n,c),T=Q(n),f=b(e=>{var i,S,O;if(p){if(o.popoverState===1)return;switch(e.key){case h.Space:case h.Enter:e.preventDefault(),(S=(i=e.target).click)==null||S.call(i),d({type:1}),(O=o.button)==null||O.focus();break}}else switch(e.key){case h.Space:case h.Enter:e.preventDefault(),e.stopPropagation(),o.popoverState===1&&(l==null||l(o.buttonId)),d({type:0});break;case h.Escape:if(o.popoverState!==0)return l==null?void 0:l(o.buttonId);if(!n.current||(T==null?void 0:T.activeElement)&&!n.current.contains(T.activeElement))return;e.preventDefault(),e.stopPropagation(),d({type:1});break}}),P=b(e=>{p||e.key===h.Space&&e.preventDefault()}),y=b(e=>{var i,S;se(e.currentTarget)||t.disabled||(p?(d({type:1}),(i=o.button)==null||i.focus()):(e.preventDefault(),e.stopPropagation(),o.popoverState===1&&(l==null||l(o.buttonId)),d({type:0}),(S=o.button)==null||S.focus()))}),A=b(e=>{e.preventDefault(),e.stopPropagation()}),L=o.popoverState===0,F=M(()=>({open:L}),[L]),D=Ee(t,n),u=t,E=p?{ref:s,type:D,onKeyDown:f,onClick:y}:{ref:B,id:o.buttonId,type:D,"aria-expanded":t.disabled?void 0:o.popoverState===0,"aria-controls":o.panel?o.panelId:void 0,onKeyDown:f,onKeyUp:P,onClick:y,onMouseDown:A},C=ue(),R=b(()=>{let e=o.panel;if(!e)return;function i(){x(C.current,{[w.Forwards]:()=>_(e,k.First),[w.Backwards]:()=>_(e,k.Last)})}i()});return I.createElement(I.Fragment,null,j({ourProps:E,theirProps:u,slot:F,defaultTag:Me,name:"Popover.Button"}),L&&!p&&a&&I.createElement(X,{id:g,features:Z.Focusable,as:"button",type:"button",onFocus:R}))}),he="div",De=q.RenderStrategy|q.Static,xe=W(function(t,c){let[{popoverState:o},d]=J("Popover.Overlay"),a=H(c),n=`headlessui-popover-overlay-${G()}`,g=ie(),m=(()=>g!==null?g===z.Open:o===0)(),l=b(s=>{if(se(s.currentTarget))return s.preventDefault();d({type:1})}),v=M(()=>({open:o===0}),[o]);return j({ourProps:{ref:a,id:n,"aria-hidden":!0,onClick:l},theirProps:t,slot:v,defaultTag:he,features:De,visible:m,name:"Popover.Overlay"})}),He="div",Ge=q.RenderStrategy|q.Static,ke=W(function(t,c){let{focus:o=!1,...d}=t,[a,n]=J("Popover.Panel"),{close:g,isPortalled:m}=oe("Popover.Panel"),l=`headlessui-focus-sentinel-before-${G()}`,v=`headlessui-focus-sentinel-after-${G()}`,p=Y(null),B=H(p,c,u=>{n({type:4,panel:u})}),s=Q(p),T=ie(),f=(()=>T!==null?T===z.Open:a.popoverState===0)(),P=b(u=>{var E;switch(u.key){case h.Escape:if(a.popoverState!==0||!p.current||(s==null?void 0:s.activeElement)&&!p.current.contains(s.activeElement))return;u.preventDefault(),u.stopPropagation(),n({type:1}),(E=a.button)==null||E.focus();break}});U(()=>{var u;t.static||a.popoverState===1&&((u=t.unmount)!=null?u:!0)&&n({type:4,panel:null})},[a.popoverState,t.unmount,t.static,n]),U(()=>{if(!o||a.popoverState!==0||!p.current)return;let u=s==null?void 0:s.activeElement;p.current.contains(u)||_(p.current,k.First)},[o,p,a.popoverState]);let y=M(()=>({open:a.popoverState===0,close:g}),[a,g]),A={ref:B,id:a.panelId,onKeyDown:P,onBlur:o&&a.popoverState===0?u=>{var C,R,e,i,S;let E=u.relatedTarget;!E||!p.current||(C=p.current)!=null&&C.contains(E)||(n({type:1}),(((e=(R=a.beforePanelSentinel.current)==null?void 0:R.contains)==null?void 0:e.call(R,E))||((S=(i=a.afterPanelSentinel.current)==null?void 0:i.contains)==null?void 0:S.call(i,E)))&&E.focus({preventScroll:!0}))}:void 0,tabIndex:-1},L=ue(),F=b(()=>{let u=p.current;if(!u)return;function E(){x(L.current,{[w.Forwards]:()=>{_(u,k.First)},[w.Backwards]:()=>{var C;(C=a.button)==null||C.focus({preventScroll:!0})}})}E()}),D=b(()=>{let u=p.current;if(!u)return;function E(){x(L.current,{[w.Forwards]:()=>{var O,N,le;if(!a.button)return;let C=ve(),R=C.indexOf(a.button),e=C.slice(0,R+1),S=[...C.slice(R+1),...e];for(let K of S.slice())if(((N=(O=K==null?void 0:K.id)==null?void 0:O.startsWith)==null?void 0:N.call(O,"headlessui-focus-sentinel-"))||((le=a.panel)==null?void 0:le.contains(K))){let ae=S.indexOf(K);ae!==-1&&S.splice(ae,1)}_(S,k.First,!1)},[w.Backwards]:()=>_(u,k.Last)})}E()});return I.createElement(ne.Provider,{value:a.panelId},f&&m&&I.createElement(X,{id:l,ref:a.beforePanelSentinel,features:Z.Focusable,as:"button",type:"button",onFocus:F}),j({ourProps:A,theirProps:d,slot:y,defaultTag:He,features:Ge,visible:f,name:"Popover.Panel"}),f&&m&&I.createElement(X,{id:v,ref:a.afterPanelSentinel,features:Z.Focusable,as:"button",type:"button",onFocus:D}))}),_e="div",we=W(function(t,c){let o=Y(null),d=H(o,c),[a,n]=Pe([]),g=b(f=>{n(P=>{let y=P.indexOf(f);if(y!==-1){let A=P.slice();return A.splice(y,1),A}return P})}),m=b(f=>(n(P=>[...P,f]),()=>g(f))),l=b(()=>{var y;let f=be(o);if(!f)return!1;let P=f.activeElement;return(y=o.current)!=null&&y.contains(P)?!0:a.some(A=>{var L,F;return((L=f.getElementById(A.buttonId))==null?void 0:L.contains(P))||((F=f.getElementById(A.panelId))==null?void 0:F.contains(P))})}),v=b(f=>{for(let P of a)P.buttonId!==f&&P.close()}),p=M(()=>({registerPopover:m,unregisterPopover:g,isFocusWithinPopoverGroup:l,closeOthers:v}),[m,g,l,v]),B=M(()=>({}),[]),s=t,T={ref:d};return I.createElement(re.Provider,{value:p},j({ourProps:T,theirProps:s,slot:B,defaultTag:_e,name:"Popover.Group"}))}),Tt=Object.assign(Ie,{Button:Be,Overlay:xe,Panel:ke,Group:we});export{Tt as Popover};
"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(),g(e=>{if(!i){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,28 +0,36 @@

import React, { MutableRefObject, Ref } from 'react';
import { Props } from '../../types';
interface PortalRenderPropArg {
import React, { type ElementType, type MutableRefObject, type Ref } from 'react';
import type { Props } from '../../types.js';
import { type HasDisplayName, type RefProp } from '../../utils/render.js';
declare let DEFAULT_PORTAL_TAG: React.ExoticComponent<{
children?: React.ReactNode;
}>;
type PortalRenderPropArg = {};
type PortalPropsWeControl = never;
export type PortalProps<TTag extends ElementType = typeof DEFAULT_PORTAL_TAG> = Props<TTag, PortalRenderPropArg, PortalPropsWeControl, {
enabled?: boolean;
}>;
declare function PortalFn<TTag extends ElementType = typeof DEFAULT_PORTAL_TAG>(props: PortalProps<TTag>, ref: Ref<HTMLElement>): React.JSX.Element | null;
declare let DEFAULT_GROUP_TAG: React.ExoticComponent<{
children?: React.ReactNode;
}>;
type GroupRenderPropArg = {};
type GroupPropsWeControl = never;
export type PortalGroupProps<TTag extends ElementType = typeof DEFAULT_GROUP_TAG> = Props<TTag, GroupRenderPropArg, GroupPropsWeControl, {
target: MutableRefObject<HTMLElement | null>;
}>;
declare function GroupFn<TTag extends ElementType = typeof DEFAULT_GROUP_TAG>(props: PortalGroupProps<TTag>, ref: Ref<HTMLElement>): React.JSX.Element;
export declare function useNestedPortals(): readonly [React.MutableRefObject<HTMLElement[]>, ({ children }: {
children: React.ReactNode;
}) => React.JSX.Element];
export interface _internal_ComponentPortal extends HasDisplayName {
<TTag extends ElementType = typeof DEFAULT_PORTAL_TAG>(props: PortalProps<TTag> & RefProp<typeof PortalFn>): JSX.Element;
}
interface GroupRenderPropArg {
export interface _internal_ComponentPortalGroup extends HasDisplayName {
<TTag extends ElementType = typeof DEFAULT_GROUP_TAG>(props: PortalGroupProps<TTag> & RefProp<typeof GroupFn>): JSX.Element;
}
export declare let Portal: (<TTag extends React.ElementType<any> = React.ExoticComponent<{
children?: React.ReactNode;
}>>(props: Props<TTag, PortalRenderPropArg, "1D45E01E-AF44-47C4-988A-19A94EBAF55C">, ref: Ref<HTMLElement>) => React.ReactPortal | null) & {
displayName: string;
} & {
Group: (<TTag_1 extends React.ElementType<any> = React.ExoticComponent<{
children?: React.ReactNode;
}>>(props: Omit<import("../../types").PropsOf<TTag_1>, "as" | "children" | "refName" | "className"> & {
as?: TTag_1 | undefined;
children?: React.ReactNode | ((bag: GroupRenderPropArg) => React.ReactElement<any, string | React.JSXElementConstructor<any>>);
refName?: string | undefined;
} & (import("../../types").PropsOf<TTag_1> extends {
className?: any;
} ? {
className?: string | ((bag: GroupRenderPropArg) => string) | undefined;
} : {}) & {
target: MutableRefObject<HTMLElement | null>;
}, ref: Ref<HTMLElement>) => JSX.Element) & {
displayName: string;
};
export declare let PortalGroup: _internal_ComponentPortalGroup;
export declare let Portal: _internal_ComponentPortal & {
/** @deprecated use `<PortalGroup>` instead of `<Portal.Group>` */
Group: _internal_ComponentPortalGroup;
};
export {};

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

import h,{Fragment as s,createContext as L,useContext as y,useEffect as m,useRef as d,useState as T}from"react";import{createPortal as G}from"react-dom";import{forwardRefWithAs as P,render as R}from"../../utils/render.js";import{useIsoMorphicEffect as M}from"../../hooks/use-iso-morphic-effect.js";import{usePortalRoot as v}from"../../internal/portal-force-root.js";import{useServerHandoffComplete as C}from"../../hooks/use-server-handoff-complete.js";import{optionalRef as O,useSyncRefs as g}from"../../hooks/use-sync-refs.js";import{useOwnerDocument as c}from"../../hooks/use-owner.js";import{microTask as H}from"../../utils/micro-task.js";import{isServer as E}from"../../utils/ssr.js";function x(i){let u=v(),o=y(A),e=c(i),[r,f]=T(()=>{if(!u&&o!==null||E)return null;let n=e==null?void 0:e.getElementById("headlessui-portal-root");if(n)return n;if(e===null)return null;let t=e.createElement("div");return t.setAttribute("id","headlessui-portal-root"),e.body.appendChild(t)});return m(()=>{r!==null&&(e!=null&&e.body.contains(r)||e==null||e.body.appendChild(r))},[r,e]),m(()=>{u||o!==null&&f(o.current)},[o,f,u]),r}let _=s,U=P(function(u,o){let e=u,r=d(null),f=g(O(a=>{r.current=a}),o),n=c(r),t=x(r),[l]=T(()=>{var a;return E?null:(a=n==null?void 0:n.createElement("div"))!=null?a:null}),b=C(),p=d(!1);return M(()=>{if(p.current=!1,!(!t||!l))return t.contains(l)||(l.setAttribute("data-headlessui-portal",""),t.appendChild(l)),()=>{p.current=!0,H(()=>{var a;!p.current||!t||!l||(t.removeChild(l),t.childNodes.length<=0&&((a=t.parentElement)==null||a.removeChild(t)))})}},[t,l]),b?!t||!l?null:G(R({ourProps:{ref:f},theirProps:e,defaultTag:_,name:"Portal"}),l):null}),j=s,A=L(null),F=P(function(u,o){let{target:e,...r}=u,n={ref:g(o)};return h.createElement(A.Provider,{value:e},R({ourProps:n,theirProps:r,defaultTag:j,name:"Popover.Group"}))}),$=Object.assign(U,{Group:F});export{$ as Portal};
"use client";import f,{Fragment as g,createContext as E,useContext as T,useEffect as R,useMemo as c,useRef as A,useState as G}from"react";import{createPortal as H}from"react-dom";import{useEvent as L}from'../../hooks/use-event.js';import{useIsoMorphicEffect as x}from'../../hooks/use-iso-morphic-effect.js';import{useOnUnmount as O}from'../../hooks/use-on-unmount.js';import{useOwnerDocument as _}from'../../hooks/use-owner.js';import{useServerHandoffComplete as h}from'../../hooks/use-server-handoff-complete.js';import{optionalRef as F,useSyncRefs as P}from'../../hooks/use-sync-refs.js';import{usePortalRoot as U}from'../../internal/portal-force-root.js';import{env as C}from'../../utils/env.js';import{forwardRefWithAs as m,render as d}from'../../utils/render.js';function D(p){let r=U(),l=T(v),e=_(p),[o,n]=G(()=>{var t;if(!r&&l!==null)return(t=l.current)!=null?t:null;if(C.isServer)return null;let u=e==null?void 0:e.getElementById("headlessui-portal-root");if(u)return u;if(e===null)return null;let a=e.createElement("div");return a.setAttribute("id","headlessui-portal-root"),e.body.appendChild(a)});return R(()=>{o!==null&&(e!=null&&e.body.contains(o)||e==null||e.body.appendChild(o))},[o,e]),R(()=>{r||l!==null&&n(l.current)},[l,n,r]),o}let M=g,N=m(function(r,l){let e=r,o=A(null),n=P(F(i=>{o.current=i}),l),u=_(o),a=D(o),[t]=G(()=>{var i;return C.isServer?null:(i=u==null?void 0:u.createElement("div"))!=null?i:null}),s=T(y),b=h();return x(()=>{!a||!t||a.contains(t)||(t.setAttribute("data-headlessui-portal",""),a.appendChild(t))},[a,t]),x(()=>{if(t&&s)return s.register(t)},[s,t]),O(()=>{var i;!a||!t||(t instanceof Node&&a.contains(t)&&a.removeChild(t),a.childNodes.length<=0&&((i=a.parentElement)==null||i.removeChild(a)))}),b?!a||!t?null:H(d({ourProps:{ref:n},theirProps:e,slot:{},defaultTag:M,name:"Portal"}),t):null});function S(p,r){let l=P(r),{enabled:e=!0,...o}=p;return e?f.createElement(N,{...o,ref:l}):d({ourProps:{ref:l},theirProps:o,slot:{},defaultTag:M,name:"Portal"})}let j=g,v=E(null);function W(p,r){let{target:l,...e}=p,n={ref:P(r)};return f.createElement(v.Provider,{value:l},d({ourProps:n,theirProps:e,defaultTag:j,name:"Popover.Group"}))}let y=E(null);function ee(){let p=T(y),r=A([]),l=L(n=>(r.current.push(n),p&&p.register(n),()=>e(n))),e=L(n=>{let u=r.current.indexOf(n);u!==-1&&r.current.splice(u,1),p&&p.unregister(n)}),o=c(()=>({register:l,unregister:e,portals:r}),[l,e,r]);return[r,c(()=>function({children:u}){return f.createElement(y.Provider,{value:o},u)},[o])]}let I=m(S),J=m(W),te=Object.assign(I,{Group:J});export{te as Portal,J as PortalGroup,ee as useNestedPortals};

@@ -1,44 +0,85 @@

import React, { Ref } from 'react';
import { Props } from '../../types';
interface RadioGroupRenderPropArg {
}
declare type RadioGroupPropsWeControl = 'role' | 'aria-labelledby' | 'aria-describedby' | 'id';
interface OptionRenderPropArg {
import React, { type ElementType, type Ref } from 'react';
import { type ByComparator } from '../../hooks/use-by-comparator.js';
import type { Props } from '../../types.js';
import { type HasDisplayName, type RefProp } from '../../utils/render.js';
import { type _internal_ComponentDescription } from '../description/description.js';
import { type _internal_ComponentLabel } from '../label/label.js';
declare let DEFAULT_RADIO_GROUP_TAG: "div";
type RadioGroupRenderPropArg<TType> = {
value: TType;
};
type RadioGroupPropsWeControl = 'role' | 'aria-labelledby' | 'aria-describedby';
export type RadioGroupProps<TTag extends ElementType = typeof DEFAULT_RADIO_GROUP_TAG, TType = string> = Props<TTag, RadioGroupRenderPropArg<TType>, RadioGroupPropsWeControl, {
value?: TType;
defaultValue?: TType;
onChange?(value: TType): void;
by?: ByComparator<TType>;
disabled?: boolean;
form?: string;
name?: string;
}>;
declare function RadioGroupFn<TTag extends ElementType = typeof DEFAULT_RADIO_GROUP_TAG, TType = string>(props: RadioGroupProps<TTag, TType>, ref: Ref<HTMLElement>): React.JSX.Element;
declare let DEFAULT_OPTION_TAG: "div";
type OptionRenderPropArg = {
checked: boolean;
/** @deprecated use `focus` instead */
active: boolean;
hover: boolean;
focus: boolean;
autofocus: boolean;
disabled: boolean;
}
declare type RadioPropsWeControl = 'aria-checked' | 'id' | 'onBlur' | 'onClick' | 'onFocus' | 'ref' | 'role' | 'tabIndex';
export declare let RadioGroup: (<TTag extends React.ElementType<any> = "div", TType = string>(props: Props<TTag, RadioGroupRenderPropArg, "value" | "name" | "disabled" | "onChange" | "by" | RadioGroupPropsWeControl> & {
};
type OptionPropsWeControl = 'aria-checked' | 'aria-describedby' | 'aria-labelledby' | 'role' | 'tabIndex';
export type RadioOptionProps<TTag extends ElementType, TType> = Props<TTag, OptionRenderPropArg, OptionPropsWeControl, {
value: TType;
onChange(value: TType): void;
by?: (keyof TType & string) | ((a: TType, z: TType) => boolean) | undefined;
disabled?: boolean | undefined;
name?: string | undefined;
}, ref: Ref<HTMLElement>) => JSX.Element) & {
displayName: string;
} & {
Option: (<TTag_1 extends React.ElementType<any> = "div", TType_1 = unknown>(props: Props<TTag_1, OptionRenderPropArg, "value" | "disabled" | RadioPropsWeControl> & {
value: TType_1;
disabled?: boolean | undefined;
}, ref: Ref<HTMLElement>) => JSX.Element) & {
displayName: string;
};
Label: (<TTag_2 extends React.ElementType<any> = "label">(props: Omit<import("../../types").PropsOf<TTag_2>, ("as" | "children" | "refName" | "className") | "id"> & {
as?: TTag_2 | undefined;
children?: React.ReactNode | ((bag: {}) => React.ReactElement<any, string | React.JSXElementConstructor<any>>);
refName?: string | undefined;
} & (import("../../types").PropsOf<TTag_2> extends {
className?: any;
} ? {
className?: string | ((bag: {}) => string) | undefined;
} : {}) & {
passive?: boolean | undefined;
}, ref: React.Ref<HTMLLabelElement>) => React.ReactElement<any, string | React.JSXElementConstructor<any>> | null) & {
displayName: string;
};
Description: (<TTag_3 extends React.ElementType<any> = "p">(props: Props<TTag_3, {}, "id">, ref: React.Ref<HTMLParagraphElement>) => React.ReactElement<any, string | React.JSXElementConstructor<any>> | null) & {
displayName: string;
};
disabled?: boolean;
autoFocus?: boolean;
}>;
declare function OptionFn<TTag extends ElementType = typeof DEFAULT_OPTION_TAG, TType = Parameters<typeof RadioGroupRoot>[0]['value']>(props: RadioOptionProps<TTag, TType>, ref: Ref<HTMLElement>): React.JSX.Element;
declare let DEFAULT_RADIO_TAG: "span";
type RadioRenderPropArg = {
checked: boolean;
hover: boolean;
focus: boolean;
autofocus: boolean;
disabled: boolean;
};
type RadioPropsWeControl = 'aria-checked' | 'aria-describedby' | 'aria-labelledby' | 'role' | 'tabIndex';
export type RadioProps<TTag extends ElementType = typeof DEFAULT_RADIO_TAG, TType = string> = Props<TTag, RadioRenderPropArg, RadioPropsWeControl, {
value: TType;
disabled?: boolean;
autoFocus?: boolean;
}>;
declare function RadioFn<TTag extends ElementType = typeof DEFAULT_RADIO_TAG, TType = Parameters<typeof RadioGroupRoot>[0]['value']>(props: RadioProps<TTag, TType>, ref: Ref<HTMLElement>): React.ReactElement<any, string | React.JSXElementConstructor<any>> | null;
export interface _internal_ComponentRadioGroup extends HasDisplayName {
<TTag extends ElementType = typeof DEFAULT_RADIO_GROUP_TAG, TType = string>(props: RadioGroupProps<TTag, TType> & RefProp<typeof RadioGroupFn>): JSX.Element;
}
export interface _internal_ComponentRadioOption extends HasDisplayName {
<TTag extends ElementType = typeof DEFAULT_OPTION_TAG, TType = string>(props: RadioOptionProps<TTag, TType> & RefProp<typeof OptionFn>): JSX.Element;
}
export interface _internal_ComponentRadio extends HasDisplayName {
<TTag extends ElementType = typeof DEFAULT_RADIO_TAG, TType = string>(props: RadioProps<TTag, TType> & RefProp<typeof RadioFn>): JSX.Element;
}
export interface _internal_ComponentRadioLabel extends _internal_ComponentLabel {
}
export interface _internal_ComponentRadioDescription extends _internal_ComponentDescription {
}
declare let RadioGroupRoot: _internal_ComponentRadioGroup;
/** @deprecated use `<Radio>` instead of `<RadioGroupOption>` */
export declare let RadioGroupOption: _internal_ComponentRadioOption;
export declare let Radio: _internal_ComponentRadio;
/** @deprecated use `<Label>` instead of `<RadioGroupLabel>` */
export declare let RadioGroupLabel: _internal_ComponentRadioLabel;
/** @deprecated use `<Description>` instead of `<RadioGroupDescription>` */
export declare let RadioGroupDescription: _internal_ComponentRadioDescription;
export declare let RadioGroup: _internal_ComponentRadioGroup & {
/** @deprecated use `<Radio>` instead of `<RadioGroup.Option>` */
Option: _internal_ComponentRadioOption;
/** @deprecated use `<Radio>` instead of `<RadioGroup.Radio>` */
Radio: _internal_ComponentRadio;
/** @deprecated use `<Label>` instead of `<RadioGroup.Label>` */
Label: _internal_ComponentRadioLabel;
/** @deprecated use `<Description>` instead of `<RadioGroup.Description>` */
Description: _internal_ComponentRadioDescription;
};
export {};

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

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

@@ -1,37 +0,58 @@

import React, { ElementType, Ref } from 'react';
import { Props } from '../../types';
import React, { type ElementType, type Ref } from 'react';
import type { Props } from '../../types.js';
import { type HasDisplayName, type RefProp } from '../../utils/render.js';
import { type _internal_ComponentDescription } from '../description/description.js';
import { type _internal_ComponentLabel } from '../label/label.js';
declare let DEFAULT_GROUP_TAG: React.ExoticComponent<{
children?: React.ReactNode;
}>;
declare function Group<TTag extends ElementType = typeof DEFAULT_GROUP_TAG>(props: Props<TTag>): JSX.Element;
interface SwitchRenderPropArg {
export type SwitchGroupProps<TTag extends ElementType = typeof DEFAULT_GROUP_TAG> = Props<TTag>;
declare function GroupFn<TTag extends ElementType = typeof DEFAULT_GROUP_TAG>(props: SwitchGroupProps<TTag>): React.JSX.Element;
declare let DEFAULT_SWITCH_TAG: "button";
type SwitchRenderPropArg = {
checked: boolean;
hover: boolean;
focus: boolean;
active: boolean;
autofocus: boolean;
changing: boolean;
disabled: boolean;
};
type SwitchPropsWeControl = 'aria-checked' | 'aria-describedby' | 'aria-labelledby' | 'role';
export type SwitchProps<TTag extends ElementType = typeof DEFAULT_SWITCH_TAG> = Props<TTag, SwitchRenderPropArg, SwitchPropsWeControl, {
checked?: boolean;
defaultChecked?: boolean;
onChange?(checked: boolean): void;
name?: string;
value?: string;
form?: string;
autoFocus?: boolean;
disabled?: boolean;
tabIndex?: number;
}>;
declare function SwitchFn<TTag extends ElementType = typeof DEFAULT_SWITCH_TAG>(props: SwitchProps<TTag>, ref: Ref<HTMLButtonElement>): React.JSX.Element;
export interface _internal_ComponentSwitch extends HasDisplayName {
<TTag extends ElementType = typeof DEFAULT_SWITCH_TAG>(props: SwitchProps<TTag> & RefProp<typeof SwitchFn>): JSX.Element;
}
declare type SwitchPropsWeControl = 'id' | 'role' | 'tabIndex' | 'aria-checked' | 'aria-labelledby' | 'aria-describedby' | 'onClick' | 'onKeyUp' | 'onKeyPress';
export declare let Switch: (<TTag extends React.ElementType<any> = "button">(props: Props<TTag, SwitchRenderPropArg, "value" | "name" | "onChange" | "checked" | SwitchPropsWeControl> & {
checked: boolean;
onChange(checked: boolean): void;
name?: string | undefined;
value?: string | undefined;
}, ref: Ref<HTMLElement>) => JSX.Element) & {
displayName: string;
} & {
Group: typeof Group;
Label: (<TTag_1 extends React.ElementType<any> = "label">(props: Omit<import("../../types").PropsOf<TTag_1>, ("as" | "children" | "refName" | "className") | "id"> & {
as?: TTag_1 | undefined;
children?: React.ReactNode | ((bag: {}) => React.ReactElement<any, string | React.JSXElementConstructor<any>>);
refName?: string | undefined;
} & (import("../../types").PropsOf<TTag_1> extends {
className?: any;
} ? {
className?: string | ((bag: {}) => string) | undefined;
} : {}) & {
passive?: boolean | undefined;
}, ref: React.Ref<HTMLLabelElement>) => React.ReactElement<any, string | React.JSXElementConstructor<any>> | null) & {
displayName: string;
};
Description: (<TTag_2 extends React.ElementType<any> = "p">(props: Props<TTag_2, {}, "id">, ref: React.Ref<HTMLParagraphElement>) => React.ReactElement<any, string | React.JSXElementConstructor<any>> | null) & {
displayName: string;
};
export interface _internal_ComponentSwitchGroup extends HasDisplayName {
<TTag extends ElementType = typeof DEFAULT_GROUP_TAG>(props: SwitchGroupProps<TTag> & RefProp<typeof GroupFn>): JSX.Element;
}
export interface _internal_ComponentSwitchLabel extends _internal_ComponentLabel {
}
export interface _internal_ComponentSwitchDescription extends _internal_ComponentDescription {
}
/** @deprecated use `<Field>` instead of `<SwitchGroup>` */
export declare let SwitchGroup: _internal_ComponentSwitchGroup;
/** @deprecated use `<Label>` instead of `<SwitchLabel>` */
export declare let SwitchLabel: _internal_ComponentSwitchLabel;
/** @deprecated use `<Description>` instead of `<SwitchDescription>` */
export declare let SwitchDescription: _internal_ComponentSwitchDescription;
export declare let Switch: _internal_ComponentSwitch & {
/** @deprecated use `<Field>` instead of `<Switch.Group>` */
Group: _internal_ComponentSwitchGroup;
/** @deprecated use `<Label>` instead of `<Switch.Label>` */
Label: _internal_ComponentSwitchLabel;
/** @deprecated use `<Description>` instead of `<Switch.Description>` */
Description: _internal_ComponentSwitchDescription;
};
export {};

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

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

@@ -1,63 +0,86 @@

import React, { Ref } from 'react';
import { Props } from '../../types';
import { PropsForFeatures } from '../../utils/render';
interface TabsRenderPropArg {
import React, { type ElementType, type Ref } from 'react';
import type { Props } from '../../types.js';
import { type HasDisplayName, type PropsForFeatures, type RefProp } from '../../utils/render.js';
declare let DEFAULT_TABS_TAG: "div";
type TabsRenderPropArg = {
selectedIndex: number;
}
interface ListRenderPropArg {
};
type TabsPropsWeControl = never;
export type TabGroupProps<TTag extends ElementType = typeof DEFAULT_TABS_TAG> = Props<TTag, TabsRenderPropArg, TabsPropsWeControl, {
defaultIndex?: number;
onChange?: (index: number) => void;
selectedIndex?: number;
vertical?: boolean;
manual?: boolean;
}>;
declare function GroupFn<TTag extends ElementType = typeof DEFAULT_TABS_TAG>(props: TabGroupProps<TTag>, ref: Ref<HTMLElement>): React.JSX.Element;
declare let DEFAULT_LIST_TAG: "div";
type ListRenderPropArg = {
selectedIndex: number;
}
declare type ListPropsWeControl = 'role' | 'aria-orientation';
interface TabRenderPropArg {
};
type ListPropsWeControl = 'aria-orientation' | 'role';
export type TabListProps<TTag extends ElementType = typeof DEFAULT_LIST_TAG> = Props<TTag, ListRenderPropArg, ListPropsWeControl, {}>;
declare function ListFn<TTag extends ElementType = typeof DEFAULT_LIST_TAG>(props: TabListProps<TTag>, ref: Ref<HTMLElement>): React.ReactElement<any, string | React.JSXElementConstructor<any>> | null;
declare let DEFAULT_TAB_TAG: "button";
type TabRenderPropArg = {
hover: boolean;
focus: boolean;
active: boolean;
autofocus: boolean;
selected: boolean;
}
declare type TabPropsWeControl = 'id' | 'role' | 'type' | 'aria-controls' | 'aria-selected' | 'tabIndex';
interface PanelsRenderPropArg {
disabled: boolean;
};
type TabPropsWeControl = 'aria-controls' | 'aria-selected' | 'role' | 'tabIndex';
export type TabProps<TTag extends ElementType = typeof DEFAULT_TAB_TAG> = Props<TTag, TabRenderPropArg, TabPropsWeControl, {
autoFocus?: boolean;
disabled?: boolean;
}>;
declare function TabFn<TTag extends ElementType = typeof DEFAULT_TAB_TAG>(props: TabProps<TTag>, ref: Ref<HTMLElement>): React.ReactElement<any, string | React.JSXElementConstructor<any>> | null;
declare let DEFAULT_PANELS_TAG: "div";
type PanelsRenderPropArg = {
selectedIndex: number;
}
interface PanelRenderPropArg {
};
export type TabPanelsProps<TTag extends ElementType = typeof DEFAULT_PANELS_TAG> = Props<TTag, PanelsRenderPropArg>;
declare function PanelsFn<TTag extends ElementType = typeof DEFAULT_PANELS_TAG>(props: TabPanelsProps<TTag>, ref: Ref<HTMLElement>): React.ReactElement<any, string | React.JSXElementConstructor<any>> | null;
declare let DEFAULT_PANEL_TAG: "div";
type PanelRenderPropArg = {
selected: boolean;
focus: boolean;
};
type PanelPropsWeControl = 'role' | 'aria-labelledby';
declare let PanelRenderFeatures: number;
export type TabPanelProps<TTag extends ElementType = typeof DEFAULT_PANEL_TAG> = Props<TTag, PanelRenderPropArg, PanelPropsWeControl, PropsForFeatures<typeof PanelRenderFeatures> & {
id?: string;
tabIndex?: number;
}>;
declare function PanelFn<TTag extends ElementType = typeof DEFAULT_PANEL_TAG>(props: TabPanelProps<TTag>, ref: Ref<HTMLElement>): React.JSX.Element | null;
export interface _internal_ComponentTab extends HasDisplayName {
<TTag extends ElementType = typeof DEFAULT_TAB_TAG>(props: TabProps<TTag> & RefProp<typeof TabFn>): JSX.Element;
}
declare type PanelPropsWeControl = 'id' | 'role' | 'aria-labelledby' | 'tabIndex';
declare let PanelRenderFeatures: number;
export declare let Tab: (<TTag extends React.ElementType<any> = "button">(props: Props<TTag, TabRenderPropArg, TabPropsWeControl>, ref: Ref<HTMLElement>) => React.ReactElement<any, string | React.JSXElementConstructor<any>> | null) & {
displayName: string;
} & {
Group: (<TTag_1 extends React.ElementType<any> = React.ExoticComponent<{
children?: React.ReactNode;
}>>(props: Omit<import("../../types").PropsOf<TTag_1>, "as" | "children" | "refName" | "className"> & {
as?: TTag_1 | undefined;
children?: React.ReactNode | ((bag: TabsRenderPropArg) => React.ReactElement<any, string | React.JSXElementConstructor<any>>);
refName?: string | undefined;
} & (import("../../types").PropsOf<TTag_1> extends {
className?: any;
} ? {
className?: string | ((bag: TabsRenderPropArg) => string) | undefined;
} : {}) & {
defaultIndex?: number | undefined;
onChange?: ((index: number) => void) | undefined;
selectedIndex?: number | undefined;
vertical?: boolean | undefined;
manual?: boolean | undefined;
}, ref: Ref<HTMLElement>) => JSX.Element) & {
displayName: string;
};
List: (<TTag_2 extends React.ElementType<any> = "div">(props: Props<TTag_2, ListRenderPropArg, ListPropsWeControl> & {}, ref: Ref<HTMLElement>) => React.ReactElement<any, string | React.JSXElementConstructor<any>> | null) & {
displayName: string;
};
Panels: (<TTag_3 extends React.ElementType<any> = "div">(props: Props<TTag_3, PanelsRenderPropArg, "1D45E01E-AF44-47C4-988A-19A94EBAF55C">, ref: Ref<HTMLElement>) => React.ReactElement<any, string | React.JSXElementConstructor<any>> | null) & {
displayName: string;
};
Panel: (<TTag_4 extends React.ElementType<any> = "div">(props: Props<TTag_4, PanelRenderPropArg, PanelPropsWeControl> & (({
static?: undefined;
} & {
unmount?: boolean | undefined;
}) | ({
unmount?: undefined;
} & {
static?: boolean | undefined;
})), ref: Ref<HTMLElement>) => React.ReactElement<any, string | React.JSXElementConstructor<any>> | null) & {
displayName: string;
};
export interface _internal_ComponentTabGroup extends HasDisplayName {
<TTag extends ElementType = typeof DEFAULT_TABS_TAG>(props: TabGroupProps<TTag> & RefProp<typeof GroupFn>): JSX.Element;
}
export interface _internal_ComponentTabList extends HasDisplayName {
<TTag extends ElementType = typeof DEFAULT_LIST_TAG>(props: TabListProps<TTag> & RefProp<typeof ListFn>): JSX.Element;
}
export interface _internal_ComponentTabPanels extends HasDisplayName {
<TTag extends ElementType = typeof DEFAULT_PANELS_TAG>(props: TabPanelsProps<TTag> & RefProp<typeof PanelsFn>): JSX.Element;
}
export interface _internal_ComponentTabPanel extends HasDisplayName {
<TTag extends ElementType = typeof DEFAULT_PANEL_TAG>(props: TabPanelProps<TTag> & RefProp<typeof PanelFn>): JSX.Element;
}
export declare let TabGroup: _internal_ComponentTabGroup;
export declare let TabList: _internal_ComponentTabList;
export declare let TabPanels: _internal_ComponentTabPanels;
export declare let TabPanel: _internal_ComponentTabPanel;
export declare let Tab: _internal_ComponentTab & {
/** @deprecated use `<TabGroup>` instead of `<Tab.Group>` */
Group: _internal_ComponentTabGroup;
/** @deprecated use `<TabList>` instead of `<Tab.List>` */
List: _internal_ComponentTabList;
/** @deprecated use `<TabPanels>` instead of `<Tab.Panels>` */
Panels: _internal_ComponentTabPanels;
/** @deprecated use `<TabPanel>` instead of `<Tab.Panel>` */
Panel: _internal_ComponentTabPanel;
};
export {};

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

import _,{Fragment as Z,createContext as G,useContext as j,useMemo as S,useReducer as ee,useRef as U}from"react";import{render as M,Features as q,forwardRefWithAs as v}from"../../utils/render.js";import{useId as J}from"../../hooks/use-id.js";import{match as Q}from"../../utils/match.js";import{Keys as T}from"../../components/keyboard.js";import{focusIn as L,Focus as b,sortByDomNode as X}from"../../utils/focus-management.js";import{useIsoMorphicEffect as W}from"../../hooks/use-iso-morphic-effect.js";import{useSyncRefs as F}from"../../hooks/use-sync-refs.js";import{useResolveButtonType as te}from"../../hooks/use-resolve-button-type.js";import{useLatestValue as N}from"../../hooks/use-latest-value.js";import{FocusSentinel as re}from"../../internal/focus-sentinel.js";import{useEvent as H}from"../../hooks/use-event.js";import{microTask as ne}from"../../utils/micro-task.js";var ae=(n=>(n[n.SetSelectedIndex=0]="SetSelectedIndex",n[n.RegisterTab=1]="RegisterTab",n[n.UnregisterTab=2]="UnregisterTab",n[n.RegisterPanel=3]="RegisterPanel",n[n.UnregisterPanel=4]="UnregisterPanel",n[n.ForceRerender=5]="ForceRerender",n))(ae||{});let le={[0](e,t){let r=e.tabs.filter(n=>{var l;return!((l=n.current)!=null&&l.hasAttribute("disabled"))});if(t.index<0)return{...e,selectedIndex:e.tabs.indexOf(r[0])};if(t.index>e.tabs.length)return{...e,selectedIndex:e.tabs.indexOf(r[r.length-1])};let s=e.tabs.slice(0,t.index),d=[...e.tabs.slice(t.index),...s].find(n=>r.includes(n));return d?{...e,selectedIndex:e.tabs.indexOf(d)}:e},[1](e,t){return e.tabs.includes(t.tab)?e:{...e,tabs:X([...e.tabs,t.tab],r=>r.current)}},[2](e,t){return{...e,tabs:X(e.tabs.filter(r=>r!==t.tab),r=>r.current)}},[3](e,t){return e.panels.includes(t.panel)?e:{...e,panels:[...e.panels,t.panel]}},[4](e,t){return{...e,panels:e.panels.filter(r=>r!==t.panel)}},[5](e){return{...e}}},B=G(null);B.displayName="TabsSSRContext";function K(e){let t=j(B);if(t===null){let r=new Error(`<${e} /> is missing a parent <Tab.Group /> component.`);throw Error.captureStackTrace&&Error.captureStackTrace(r,K),r}return t}let $=G(null);$.displayName="TabsDataContext";function C(e){let t=j($);if(t===null){let r=new Error(`<${e} /> is missing a parent <Tab.Group /> component.`);throw Error.captureStackTrace&&Error.captureStackTrace(r,C),r}return t}let z=G(null);z.displayName="TabsActionsContext";function V(e){let t=j(z);if(t===null){let r=new Error(`<${e} /> is missing a parent <Tab.Group /> component.`);throw Error.captureStackTrace&&Error.captureStackTrace(r,V),r}return t}function oe(e,t){return Q(t.type,le,e,t)}let se=Z,ie=v(function(t,r){let{defaultIndex:s=0,vertical:f=!1,manual:d=!1,onChange:n,selectedIndex:l=null,...P}=t;const p=f?"vertical":"horizontal",R=d?"manual":"auto";let i=l!==null,g=F(r),[u,o]=ee(oe,{selectedIndex:l!=null?l:s,tabs:[],panels:[]}),y=S(()=>({selectedIndex:u.selectedIndex}),[u.selectedIndex]),h=N(n||(()=>{})),x=N(u.tabs),m=S(()=>({orientation:p,activation:R,...u}),[p,R,u]),A=N(i?t.selectedIndex:u.selectedIndex),w=S(()=>({registerTab(c){return o({type:1,tab:c}),()=>o({type:2,tab:c})},registerPanel(c){return o({type:3,panel:c}),()=>o({type:4,panel:c})},forceRerender(){o({type:5})},change(c){A.current!==c&&h.current(c),i||o({type:0,index:c})}}),[o,i]);W(()=>{o({type:0,index:l!=null?l:s})},[l]);let O=U({tabs:[],panels:[]}),k={ref:g};return _.createElement(B.Provider,{value:O},_.createElement(z.Provider,{value:w},_.createElement($.Provider,{value:m},m.tabs.length<=0&&_.createElement(re,{onFocus:()=>{var c,I;for(let D of x.current)if(((c=D.current)==null?void 0:c.tabIndex)===0)return(I=D.current)==null||I.focus(),!0;return!1}}),M({ourProps:k,theirProps:P,slot:y,defaultTag:se,name:"Tabs"}))))}),ue="div",ce=v(function(t,r){let{orientation:s,selectedIndex:f}=C("Tab.List"),d=F(r);return M({ourProps:{ref:d,role:"tablist","aria-orientation":s},theirProps:t,slot:{selectedIndex:f},defaultTag:ue,name:"Tabs.List"})}),pe="button",de=v(function(t,r){var I,D;let s=`headlessui-tabs-tab-${J()}`,{orientation:f,activation:d,selectedIndex:n,tabs:l,panels:P}=C("Tab"),p=V("Tab"),R=K("Tab"),i=U(null),g=F(i,r,a=>{!a||p.forceRerender()});W(()=>p.registerTab(i),[p,i]);let u=R.current.tabs.indexOf(s);u===-1&&(u=R.current.tabs.push(s)-1);let o=l.indexOf(i);o===-1&&(o=u);let y=o===n,h=H(a=>{let E=l.map(Y=>Y.current).filter(Boolean);if(a.key===T.Space||a.key===T.Enter){a.preventDefault(),a.stopPropagation(),p.change(o);return}switch(a.key){case T.Home:case T.PageUp:return a.preventDefault(),a.stopPropagation(),L(E,b.First);case T.End:case T.PageDown:return a.preventDefault(),a.stopPropagation(),L(E,b.Last)}if(Q(f,{vertical(){if(a.key===T.ArrowUp)return L(E,b.Previous|b.WrapAround);if(a.key===T.ArrowDown)return L(E,b.Next|b.WrapAround)},horizontal(){if(a.key===T.ArrowLeft)return L(E,b.Previous|b.WrapAround);if(a.key===T.ArrowRight)return L(E,b.Next|b.WrapAround)}}))return a.preventDefault()}),x=H(()=>{var a;(a=i.current)==null||a.focus()}),m=U(!1),A=H(()=>{var a;m.current||(m.current=!0,(a=i.current)==null||a.focus(),p.change(o),ne(()=>{m.current=!1}))}),w=H(a=>{a.preventDefault()}),O=S(()=>({selected:y}),[y]),k=t,c={ref:g,onKeyDown:h,onFocus:d==="manual"?x:A,onMouseDown:w,onClick:A,id:s,role:"tab",type:te(t,i),"aria-controls":(D=(I=P[o])==null?void 0:I.current)==null?void 0:D.id,"aria-selected":y,tabIndex:y?0:-1};return M({ourProps:c,theirProps:k,slot:O,defaultTag:pe,name:"Tabs.Tab"})}),fe="div",Te=v(function(t,r){let{selectedIndex:s}=C("Tab.Panels"),f=F(r),d=S(()=>({selectedIndex:s}),[s]);return M({ourProps:{ref:f},theirProps:t,slot:d,defaultTag:fe,name:"Tabs.Panels"})}),be="div",me=q.RenderStrategy|q.Static,Pe=v(function(t,r){var x,m;let{selectedIndex:s,tabs:f,panels:d}=C("Tab.Panel"),n=V("Tab.Panel"),l=K("Tab.Panel"),P=`headlessui-tabs-panel-${J()}`,p=U(null),R=F(p,r,A=>{!A||n.forceRerender()});W(()=>n.registerPanel(p),[n,p]);let i=l.current.panels.indexOf(P);i===-1&&(i=l.current.panels.push(P)-1);let g=d.indexOf(p);g===-1&&(g=i);let u=g===s,o=S(()=>({selected:u}),[u]),y=t,h={ref:R,id:P,role:"tabpanel","aria-labelledby":(m=(x=f[g])==null?void 0:x.current)==null?void 0:m.id,tabIndex:u?0:-1};return M({ourProps:h,theirProps:y,slot:o,defaultTag:be,features:me,visible:u,name:"Tabs.Panel"})}),Ge=Object.assign(de,{Group:ie,List:ce,Panels:Te,Panel:Pe});export{Ge as Tab};
"use client";import{useFocusRing as re}from"@react-aria/focus";import{useHover as fe}from"@react-aria/interactions";import U,{createContext as ne,useContext as ae,useMemo as S,useReducer as be,useRef as q,useState as me}from"react";import{useActivePress as Pe}from'../../hooks/use-active-press.js';import{useEvent as F}from'../../hooks/use-event.js';import{useId as le}from'../../hooks/use-id.js';import{useIsoMorphicEffect as W}from'../../hooks/use-iso-morphic-effect.js';import{useLatestValue as j}from'../../hooks/use-latest-value.js';import{useResolveButtonType as ye}from'../../hooks/use-resolve-button-type.js';import{useSyncRefs as H}from'../../hooks/use-sync-refs.js';import{FocusSentinel as xe}from'../../internal/focus-sentinel.js';import{Hidden as ge}from'../../internal/hidden.js';import{Focus as P,FocusResult as K,focusIn as v,sortByDomNode as w}from'../../utils/focus-management.js';import{match as O}from'../../utils/match.js';import{microTask as Ae}from'../../utils/micro-task.js';import{getOwnerDocument as Ee}from'../../utils/owner.js';import{RenderFeatures as oe,forwardRefWithAs as N,mergeProps as se,render as k}from'../../utils/render.js';import{StableCollection as Le,useStableCollectionIndex as ie}from'../../utils/stable-collection.js';import{Keys as y}from'../keyboard.js';var Re=(t=>(t[t.Forwards=0]="Forwards",t[t.Backwards=1]="Backwards",t))(Re||{}),_e=(l=>(l[l.Less=-1]="Less",l[l.Equal=0]="Equal",l[l.Greater=1]="Greater",l))(_e||{}),De=(n=>(n[n.SetSelectedIndex=0]="SetSelectedIndex",n[n.RegisterTab=1]="RegisterTab",n[n.UnregisterTab=2]="UnregisterTab",n[n.RegisterPanel=3]="RegisterPanel",n[n.UnregisterPanel=4]="UnregisterPanel",n))(De||{});let Se={[0](e,r){var d;let t=w(e.tabs,u=>u.current),l=w(e.panels,u=>u.current),a=t.filter(u=>{var T;return!((T=u.current)!=null&&T.hasAttribute("disabled"))}),n={...e,tabs:t,panels:l};if(r.index<0||r.index>t.length-1){let u=O(Math.sign(r.index-e.selectedIndex),{[-1]:()=>1,[0]:()=>O(Math.sign(r.index),{[-1]:()=>0,[0]:()=>0,[1]:()=>1}),[1]:()=>0});if(a.length===0)return n;let T=O(u,{[0]:()=>t.indexOf(a[0]),[1]:()=>t.indexOf(a[a.length-1])});return{...n,selectedIndex:T===-1?e.selectedIndex:T}}let p=t.slice(0,r.index),x=[...t.slice(r.index),...p].find(u=>a.includes(u));if(!x)return n;let f=(d=t.indexOf(x))!=null?d:e.selectedIndex;return f===-1&&(f=e.selectedIndex),{...n,selectedIndex:f}},[1](e,r){if(e.tabs.includes(r.tab))return e;let t=e.tabs[e.selectedIndex],l=w([...e.tabs,r.tab],n=>n.current),a=e.selectedIndex;return e.info.current.isControlled||(a=l.indexOf(t),a===-1&&(a=e.selectedIndex)),{...e,tabs:l,selectedIndex:a}},[2](e,r){return{...e,tabs:e.tabs.filter(t=>t!==r.tab)}},[3](e,r){return e.panels.includes(r.panel)?e:{...e,panels:w([...e.panels,r.panel],t=>t.current)}},[4](e,r){return{...e,panels:e.panels.filter(t=>t!==r.panel)}}},z=ne(null);z.displayName="TabsDataContext";function C(e){let r=ae(z);if(r===null){let t=new Error(`<${e} /> is missing a parent <Tab.Group /> component.`);throw Error.captureStackTrace&&Error.captureStackTrace(t,C),t}return r}let V=ne(null);V.displayName="TabsActionsContext";function Q(e){let r=ae(V);if(r===null){let t=new Error(`<${e} /> is missing a parent <Tab.Group /> component.`);throw Error.captureStackTrace&&Error.captureStackTrace(t,Q),t}return r}function Fe(e,r){return O(r.type,Se,e,r)}let Ie="div";function he(e,r){let{defaultIndex:t=0,vertical:l=!1,manual:a=!1,onChange:n,selectedIndex:p=null,..._}=e;const x=l?"vertical":"horizontal",f=a?"manual":"auto";let d=p!==null,u=j({isControlled:d}),T=H(r),[s,c]=be(Fe,{info:u,selectedIndex:p!=null?p:t,tabs:[],panels:[]}),I=S(()=>({selectedIndex:s.selectedIndex}),[s.selectedIndex]),m=j(n||(()=>{})),M=j(s.tabs),D=S(()=>({orientation:x,activation:f,...s}),[x,f,s]),b=F(i=>(c({type:1,tab:i}),()=>c({type:2,tab:i}))),g=F(i=>(c({type:3,panel:i}),()=>c({type:4,panel:i}))),A=F(i=>{L.current!==i&&m.current(i),d||c({type:0,index:i})}),L=j(d?e.selectedIndex:s.selectedIndex),G=S(()=>({registerTab:b,registerPanel:g,change:A}),[]);W(()=>{c({type:0,index:p!=null?p:t})},[p]),W(()=>{if(L.current===void 0||s.tabs.length<=0)return;let i=w(s.tabs,R=>R.current);i.some((R,B)=>s.tabs[B]!==R)&&A(i.indexOf(s.tabs[L.current]))});let J={ref:T};return U.createElement(Le,null,U.createElement(V.Provider,{value:G},U.createElement(z.Provider,{value:D},D.tabs.length<=0&&U.createElement(xe,{onFocus:()=>{var i,h;for(let R of M.current)if(((i=R.current)==null?void 0:i.tabIndex)===0)return(h=R.current)==null||h.focus(),!0;return!1}}),k({ourProps:J,theirProps:_,slot:I,defaultTag:Ie,name:"Tabs"}))))}let ve="div";function Ce(e,r){let{orientation:t,selectedIndex:l}=C("Tab.List"),a=H(r),n=S(()=>({selectedIndex:l}),[l]);return k({ourProps:{ref:a,role:"tablist","aria-orientation":t},theirProps:e,slot:n,defaultTag:ve,name:"Tabs.List"})}let Me="button";function Ge(e,r){var Z,ee;let t=le(),{id:l=`headlessui-tabs-tab-${t}`,disabled:a=!1,autoFocus:n=!1,...p}=e,{orientation:_,activation:x,selectedIndex:f,tabs:d,panels:u}=C("Tab"),T=Q("Tab"),s=C("Tab"),[c,I]=me(null),m=q(null),M=H(m,r,I);W(()=>T.registerTab(m),[T,m]);let D=ie("tabs"),b=d.indexOf(m);b===-1&&(b=D);let g=b===f,A=F(o=>{var X;let E=o();if(E===K.Success&&x==="auto"){let $=(X=Ee(m))==null?void 0:X.activeElement,te=s.tabs.findIndex(ce=>ce.current===$);te!==-1&&T.change(te)}return E}),L=F(o=>{let E=d.map($=>$.current).filter(Boolean);if(o.key===y.Space||o.key===y.Enter){o.preventDefault(),o.stopPropagation(),T.change(b);return}switch(o.key){case y.Home:case y.PageUp:return o.preventDefault(),o.stopPropagation(),A(()=>v(E,P.First));case y.End:case y.PageDown:return o.preventDefault(),o.stopPropagation(),A(()=>v(E,P.Last))}if(A(()=>O(_,{vertical(){return o.key===y.ArrowUp?v(E,P.Previous|P.WrapAround):o.key===y.ArrowDown?v(E,P.Next|P.WrapAround):K.Error},horizontal(){return o.key===y.ArrowLeft?v(E,P.Previous|P.WrapAround):o.key===y.ArrowRight?v(E,P.Next|P.WrapAround):K.Error}}))===K.Success)return o.preventDefault()}),G=q(!1),J=F(()=>{var o;G.current||(G.current=!0,(o=m.current)==null||o.focus({preventScroll:!0}),T.change(b),Ae(()=>{G.current=!1}))}),i=F(o=>{o.preventDefault()}),{isFocusVisible:h,focusProps:R}=re({autoFocus:n}),{isHovered:B,hoverProps:pe}=fe({isDisabled:a}),{pressed:Y,pressProps:ue}=Pe({disabled:a}),Te=S(()=>({selected:g,hover:B,active:Y,focus:h,autofocus:n,disabled:a}),[g,B,h,Y,n,a]),de=se({ref:M,onKeyDown:L,onMouseDown:i,onClick:J,id:l,role:"tab",type:ye(e,c),"aria-controls":(ee=(Z=u[b])==null?void 0:Z.current)==null?void 0:ee.id,"aria-selected":g,tabIndex:g?0:-1,disabled:a||void 0,autoFocus:n},R,pe,ue);return k({ourProps:de,theirProps:p,slot:Te,defaultTag:Me,name:"Tabs.Tab"})}let Ue="div";function He(e,r){let{selectedIndex:t}=C("Tab.Panels"),l=H(r),a=S(()=>({selectedIndex:t}),[t]);return k({ourProps:{ref:l},theirProps:e,slot:a,defaultTag:Ue,name:"Tabs.Panels"})}let we="div",Oe=oe.RenderStrategy|oe.Static;function Ne(e,r){var b,g,A,L;let t=le(),{id:l=`headlessui-tabs-panel-${t}`,tabIndex:a=0,...n}=e,{selectedIndex:p,tabs:_,panels:x}=C("Tab.Panel"),f=Q("Tab.Panel"),d=q(null),u=H(d,r);W(()=>f.registerPanel(d),[f,d]);let T=ie("panels"),s=x.indexOf(d);s===-1&&(s=T);let c=s===p,{isFocusVisible:I,focusProps:m}=re(),M=S(()=>({selected:c,focus:I}),[c,I]),D=se({ref:u,id:l,role:"tabpanel","aria-labelledby":(g=(b=_[s])==null?void 0:b.current)==null?void 0:g.id,tabIndex:c?a:-1},m);return!c&&((A=n.unmount)==null||A)&&!((L=n.static)!=null&&L)?U.createElement(ge,{"aria-hidden":"true",...D}):k({ourProps:D,theirProps:n,slot:M,defaultTag:we,features:Oe,visible:c,name:"Tabs.Panel"})}let ke=N(Ge),Be=N(he),We=N(Ce),je=N(He),Ke=N(Ne),ut=Object.assign(ke,{Group:Be,List:We,Panels:je,Panel:Ke});export{ut as Tab,Be as TabGroup,We as TabList,Ke as TabPanel,je as TabPanels};

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

import React, { MutableRefObject, Ref } from 'react';
import { Props } from '../../types';
import { Features, PropsForFeatures } from '../../utils/render';
export interface TransitionClasses {
enter?: string;
enterFrom?: string;
enterTo?: string;
entered?: string;
leave?: string;
leaveFrom?: string;
leaveTo?: string;
}
export interface TransitionEvents {
beforeEnter?: () => void;
afterEnter?: () => void;
beforeLeave?: () => void;
afterLeave?: () => void;
}
declare type TransitionChildProps<TTag> = Props<TTag, TransitionChildRenderPropArg> & PropsForFeatures<typeof TransitionChildRenderFeatures> & TransitionClasses & TransitionEvents & {
appear?: boolean;
};
declare type TransitionChildRenderPropArg = MutableRefObject<HTMLDivElement>;
declare let TransitionChildRenderFeatures: Features;
export declare let Transition: (<TTag extends React.ElementType<any> = "div">(props: TransitionChildProps<TTag> & {
show?: boolean | undefined;
appear?: boolean | undefined;
}, ref: Ref<HTMLElement>) => JSX.Element) & {
displayName: string;
} & {
Child: (<TTag_1 extends React.ElementType<any> = "div">(props: TransitionChildProps<TTag_1>, ref: MutableRefObject<HTMLElement>) => JSX.Element) & {
displayName: string;
};
Root: (<TTag extends React.ElementType<any> = "div">(props: TransitionChildProps<TTag> & {
show?: boolean | undefined;
appear?: boolean | undefined;
}, ref: Ref<HTMLElement>) => JSX.Element) & {
displayName: string;
};
};
export {};
export * from '../transition/transition.js';

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

import T,{Fragment as q,createContext as z,useContext as j,useEffect as S,useMemo as J,useRef as c,useState as k}from"react";import{Features as de,forwardRefWithAs as G,render as K,RenderStrategy as m}from"../../utils/render.js";import{OpenClosedProvider as fe,State as V,useOpenClosed as Q}from"../../internal/open-closed.js";import{match as R}from"../../utils/match.js";import{microTask as Te}from"../../utils/micro-task.js";import{useId as pe}from"../../hooks/use-id.js";import{useIsMounted as me}from"../../hooks/use-is-mounted.js";import{useIsoMorphicEffect as ce}from"../../hooks/use-iso-morphic-effect.js";import{useLatestValue as I}from"../../hooks/use-latest-value.js";import{useServerHandoffComplete as X}from"../../hooks/use-server-handoff-complete.js";import{useSyncRefs as Y}from"../../hooks/use-sync-refs.js";import{useTransition as he}from"../../hooks/use-transition.js";import{useEvent as Z}from"../../hooks/use-event.js";function h(e=""){return e.split(" ").filter(n=>n.trim().length>1)}let N=z(null);N.displayName="TransitionContext";var ge=(t=>(t.Visible="visible",t.Hidden="hidden",t))(ge||{});function ve(){let e=j(N);if(e===null)throw new Error("A <Transition.Child /> is used but it is missing a parent <Transition /> or <Transition.Root />.");return e}function Ce(){let e=j(L);if(e===null)throw new Error("A <Transition.Child /> is used but it is missing a parent <Transition /> or <Transition.Root />.");return e}let L=z(null);L.displayName="NestingContext";function w(e){return"children"in e?w(e.children):e.current.filter(({state:n})=>n==="visible").length>0}function $(e){let n=I(e),t=c([]),r=me(),i=Z((l,s=m.Hidden)=>{let a=t.current.findIndex(({id:u})=>u===l);a!==-1&&(R(s,{[m.Unmount](){t.current.splice(a,1)},[m.Hidden](){t.current[a].state="hidden"}}),Te(()=>{var u;!w(t)&&r.current&&((u=n.current)==null||u.call(n))}))}),g=Z(l=>{let s=t.current.find(({id:a})=>a===l);return s?s.state!=="visible"&&(s.state="visible"):t.current.push({id:l,state:"visible"}),()=>i(l,m.Unmount)});return J(()=>({children:t,register:g,unregister:i}),[g,i,t])}function be(){}let Se=["beforeEnter","afterEnter","beforeLeave","afterLeave"];function ee(e){var t;let n={};for(let r of Se)n[r]=(t=e[r])!=null?t:be;return n}function Ee(e){let n=c(ee(e));return S(()=>{n.current=ee(e)},[e]),n}let xe="div",te=de.RenderStrategy,re=G(function(n,t){let{beforeEnter:r,afterEnter:i,beforeLeave:g,afterLeave:l,enter:s,enterFrom:a,enterTo:u,entered:A,leave:v,leaveFrom:E,leaveTo:x,...y}=n,d=c(null),D=Y(d,t),C=y.unmount?m.Unmount:m.Hidden,{show:o,appear:b,initial:ne}=ve(),[p,F]=k(o?"visible":"hidden"),{register:H,unregister:P}=Ce(),O=c(null),f=pe();S(()=>{if(!!f)return H(f)},[H,f]),S(()=>{if(C===m.Hidden&&!!f){if(o&&p!=="visible"){F("visible");return}R(p,{["hidden"]:()=>P(f),["visible"]:()=>H(f)})}},[p,f,H,P,o,C]);let ie=I({enter:h(s),enterFrom:h(a),enterTo:h(u),entered:h(A),leave:h(v),leaveFrom:h(E),leaveTo:h(x)}),se=Ee({beforeEnter:r,afterEnter:i,beforeLeave:g,afterLeave:l}),M=X();S(()=>{if(M&&p==="visible"&&d.current===null)throw new Error("Did you forget to passthrough the `ref` to the actual DOM node?")},[d,p,M]);let _=ne&&!b,oe=(()=>!M||_||O.current===o?"idle":o?"enter":"leave")(),U=c(!1),W=$(()=>{U.current||(F("hidden"),P(f))});he({container:d,classes:ie,events:se,direction:oe,onStart:I(()=>{U.current=!0}),onStop:I(ue=>{U.current=!1,ue==="leave"&&!w(W)&&(F("hidden"),P(f))})}),S(()=>{!_||(C===m.Hidden?O.current=null:O.current=o)},[o,_,p]);let le=y,ae={ref:D};return T.createElement(L.Provider,{value:W},T.createElement(fe,{value:R(p,{["visible"]:V.Open,["hidden"]:V.Closed})},K({ourProps:ae,theirProps:le,defaultTag:xe,features:te,visible:p==="visible",name:"Transition.Child"})))}),B=G(function(n,t){let{show:r,appear:i=!1,unmount:g,...l}=n,s=c(null),a=Y(s,t);X();let u=Q();if(r===void 0&&u!==null&&(r=R(u,{[V.Open]:!0,[V.Closed]:!1})),![!0,!1].includes(r))throw new Error("A <Transition /> is used but it is missing a `show={true | false}` prop.");let[A,v]=k(r?"visible":"hidden"),E=$(()=>{v("hidden")}),[x,y]=k(!0),d=c([r]);ce(()=>{x!==!1&&d.current[d.current.length-1]!==r&&(d.current.push(r),y(!1))},[d,r]);let D=J(()=>({show:r,appear:i,initial:x}),[r,i,x]);S(()=>{if(r)v("visible");else if(!w(E))v("hidden");else{let o=s.current;if(!o)return;let b=o.getBoundingClientRect();b.x===0&&b.y===0&&b.width===0&&b.height===0&&v("hidden")}},[r,E]);let C={unmount:g};return T.createElement(L.Provider,{value:E},T.createElement(N.Provider,{value:D},K({ourProps:{...C,as:q,children:T.createElement(re,{ref:a,...C,...l})},theirProps:{},defaultTag:q,features:te,visible:A==="visible",name:"Transition"})))}),ye=G(function(n,t){let r=j(N)!==null,i=Q()!==null;return T.createElement(T.Fragment,null,!r&&i?T.createElement(B,{ref:t,...n}):T.createElement(re,{ref:t,...n}))}),We=Object.assign(B,{Child:ye,Root:B});export{We as Transition};
export*from'../transition/transition.js';

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

export*from"./components/combobox/combobox.js";export*from"./components/dialog/dialog.js";export*from"./components/disclosure/disclosure.js";export*from"./components/focus-trap/focus-trap.js";export*from"./components/listbox/listbox.js";export*from"./components/menu/menu.js";export*from"./components/popover/popover.js";export*from"./components/portal/portal.js";export*from"./components/radio-group/radio-group.js";export*from"./components/switch/switch.js";export*from"./components/tabs/tabs.js";export*from"./components/transitions/transition.js";
export*from'./components/button/button.js';export*from'./components/checkbox/checkbox.js';export*from'./components/close-button/close-button.js';export*from'./components/combobox/combobox.js';export*from'./components/data-interactive/data-interactive.js';import{Description as x}from'./components/description/description.js';export*from'./components/dialog/dialog.js';export*from'./components/disclosure/disclosure.js';export*from'./components/field/field.js';export*from'./components/fieldset/fieldset.js';export*from'./components/focus-trap/focus-trap.js';export*from'./components/input/input.js';import{Label as n}from'./components/label/label.js';export*from'./components/legend/legend.js';export*from'./components/listbox/listbox.js';export*from'./components/menu/menu.js';export*from'./components/popover/popover.js';import{Portal as d}from'./components/portal/portal.js';export*from'./components/radio-group/radio-group.js';export*from'./components/select/select.js';export*from'./components/switch/switch.js';export*from'./components/tabs/tabs.js';export*from'./components/textarea/textarea.js';import{useClose as w}from'./internal/close-provider.js';export*from'./components/transition/transition.js';export{x as Description,n as Label,d as Portal,w as useClose};

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

import{useState as s}from"react";import{useIsoMorphicEffect as f}from"./use-iso-morphic-effect.js";import{useLatestValue as m}from"./use-latest-value.js";function i(e,o){let[u,t]=s(e),r=m(e);return f(()=>t(r.current),[r,t,...o]),u}export{i as useComputed};
import{useState as s}from"react";import{useIsoMorphicEffect as f}from'./use-iso-morphic-effect.js';import{useLatestValue as m}from'./use-latest-value.js';function i(e,o){let[u,t]=s(e),r=m(e);return f(()=>t(r.current),[r,t,...o]),u}export{i as useComputed};

@@ -0,10 +1,25 @@

/**
* The `useDisposables` hook returns a `disposables` object that is disposed
* when the component is unmounted.
*/
export declare function useDisposables(): {
enqueue(fn: Function): void;
addEventListener<TEventName extends keyof WindowEventMap>(element: HTMLElement, name: TEventName, listener: (event: WindowEventMap[TEventName]) => any, options?: boolean | AddEventListenerOptions | undefined): () => void;
addEventListener<TEventName extends keyof WindowEventMap>(element: Window | Document | HTMLElement, name: TEventName, listener: (event: WindowEventMap[TEventName]) => any, options?: boolean | AddEventListenerOptions | undefined): () => void;
requestAnimationFrame(callback: FrameRequestCallback): () => void;
nextFrame(callback: FrameRequestCallback): () => void;
setTimeout(callback: (...args: any[]) => void, ms?: number | undefined, ...args: any[]): () => void;
microTask(cb: () => void): () => void;
style(node: HTMLElement, property: string, value: string): () => void;
group(cb: (d: {
addEventListener<TEventName extends keyof WindowEventMap>(element: Window | Document | HTMLElement, name: TEventName, listener: (event: WindowEventMap[TEventName]) => any, options?: boolean | AddEventListenerOptions | undefined): () => void;
requestAnimationFrame(callback: FrameRequestCallback): () => void;
nextFrame(callback: FrameRequestCallback): () => void;
setTimeout(callback: (...args: any[]) => void, ms?: number | undefined, ...args: any[]): () => void;
microTask(cb: () => void): () => void;
style(node: HTMLElement, property: string, value: string): () => void;
group(cb: any): () => void;
add(cb: () => void): () => void;
dispose(): void;
}) => void): () => void;
add(cb: () => void): () => void;
dispose(): void;
workQueue(): Promise<void>;
};

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

import{useState as s,useEffect as o}from"react";import{disposables as t}from"../utils/disposables.js";function p(){let[e]=s(t);return o(()=>()=>e.dispose(),[e]),e}export{p as useDisposables};
import{useEffect as s,useState as o}from"react";import{disposables as t}from'../utils/disposables.js';function p(){let[e]=o(t);return s(()=>()=>e.dispose(),[e]),e}export{p as useDisposables};

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

export declare function useDocumentEvent<TType extends keyof DocumentEventMap>(type: TType, listener: (ev: DocumentEventMap[TType]) => any, options?: boolean | AddEventListenerOptions): void;
export declare function useDocumentEvent<TType extends keyof DocumentEventMap>(enabled: boolean, type: TType, listener: (ev: DocumentEventMap[TType]) => any, options?: boolean | AddEventListenerOptions): void;

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

import{useEffect as m}from"react";import{useLatestValue as c}from"./use-latest-value.js";function d(e,r,n){let o=c(r);m(()=>{function t(u){o.current(u)}return document.addEventListener(e,t,n),()=>document.removeEventListener(e,t,n)},[e,n])}export{d as useDocumentEvent};
import{useEffect as c}from"react";import{useLatestValue as a}from'./use-latest-value.js';function i(t,e,o,n){let u=a(o);c(()=>{if(!t)return;function r(m){u.current(m)}return document.addEventListener(e,r,n),()=>document.removeEventListener(e,r,n)},[t,e,n])}export{i as useDocumentEvent};

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

import{useEffect as d}from"react";import{useLatestValue as s}from"./use-latest-value.js";function E(n,e,a,t){let i=s(a);d(()=>{n=n!=null?n:window;function r(o){i.current(o)}return n.addEventListener(e,r,t),()=>n.removeEventListener(e,r,t)},[n,e,t])}export{E as useEventListener};
import{useEffect as d}from"react";import{useLatestValue as s}from'./use-latest-value.js';function E(n,e,a,t){let i=s(a);d(()=>{n=n!=null?n:window;function r(o){i.current(o)}return n.addEventListener(e,r,t),()=>n.removeEventListener(e,r,t)},[n,e,t])}export{E as useEventListener};

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

import a from"react";import{useLatestValue as n}from"./use-latest-value.js";let o=function(t){let e=n(t);return a.useCallback((...r)=>e.current(...r),[e])};export{o as useEvent};
import a from"react";import{useLatestValue as n}from'./use-latest-value.js';let o=function(t){let e=n(t);return a.useCallback((...r)=>e.current(...r),[e])};export{o as useEvent};
export declare function useFlags(initialFlags?: number): {
flags: number;
setFlag: (flag: number) => void;
addFlag: (flag: number) => void;

@@ -3,0 +5,0 @@ hasFlag: (flag: number) => boolean;

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

import{useState as m,useCallback as t}from"react";function b(g=0){let[r,l]=m(g),u=t(e=>l(a=>a|e),[r]),n=t(e=>Boolean(r&e),[r]),o=t(e=>l(a=>a&~e),[l]),s=t(e=>l(a=>a^e),[l]);return{addFlag:u,hasFlag:n,removeFlag:o,toggleFlag:s}}export{b as useFlags};
import{useCallback as r,useState as b}from"react";function c(u=0){let[t,l]=b(u),g=r(e=>l(e),[t]),s=r(e=>l(a=>a|e),[t]),m=r(e=>(t&e)===e,[t]),n=r(e=>l(a=>a&~e),[l]),F=r(e=>l(a=>a^e),[l]);return{flags:t,setFlag:g,addFlag:s,hasFlag:m,removeFlag:n,toggleFlag:F}}export{c as useFlags};

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

export declare let useId: any;
export { useId } from 'react';

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

var u;import t from"react";import{useIsoMorphicEffect as d}from"./use-iso-morphic-effect.js";import{useServerHandoffComplete as f}from"./use-server-handoff-complete.js";let l=0;function r(){return++l}let I=(u=t.useId)!=null?u:function(){let n=f(),[e,o]=t.useState(n?r:null);return d(()=>{e===null&&o(r())},[e]),e!=null?""+e:void 0};export{I as useId};
import{useId as r}from"react";export{r as useId};

@@ -1,2 +0,29 @@

import { MutableRefObject } from 'react';
export declare function useInertOthers<TElement extends HTMLElement>(container: MutableRefObject<TElement | null>, enabled?: boolean): void;
/**
* Mark all elements on the page as inert, except for the ones that are allowed.
*
* We move up the tree from the allowed elements, and mark all their siblings as
* inert. If any of the children happens to be a parent of one of the elements,
* then that child will not be marked as inert.
*
* E.g.:
*
* ```html
* <body> <!-- Stop at body -->
* <header></header> <!-- Inert, sibling of parent -->
* <main> <!-- Not inert, parent of allowed element -->
* <div>Sidebar</div> <!-- Inert, sibling of parent -->
* <div> <!-- Not inert, parent of allowed element -->
* <listbox> <!-- Not inert, parent of allowed element -->
* <button></button> <!-- Not inert, allowed element -->
* <options></options> <!-- Not inert, allowed element -->
* </listbox>
* </div>
* </main>
* <footer></footer> <!-- Inert, sibling of parent -->
* </body>
* ```
*/
export declare function useInertOthers(enabled: boolean, { allowed, disallowed, }?: {
allowed?: () => (HTMLElement | null)[];
disallowed?: () => (HTMLElement | null)[];
}): void;

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

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

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

import{useRef as r,useEffect as t}from"react";function n(){let e=r(!0);return t(()=>(e.current=!1,()=>{e.current=!0}),[]),e.current}export{n as useIsInitialRender};
import{useEffect as r,useRef as t}from"react";function n(){let e=t(!0);return r(()=>(e.current=!1,()=>{e.current=!0}),[]),e.current}export{n as useIsInitialRender};

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

import{useRef as r}from"react";import{useIsoMorphicEffect as t}from"./use-iso-morphic-effect.js";function f(){let e=r(!1);return t(()=>(e.current=!0,()=>{e.current=!1}),[]),e}export{f as useIsMounted};
import{useRef as r}from"react";import{useIsoMorphicEffect as t}from'./use-iso-morphic-effect.js';function f(){let e=r(!1);return t(()=>(e.current=!0,()=>{e.current=!1}),[]),e}export{f as useIsMounted};

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

import { useEffect } from 'react';
export declare let useIsoMorphicEffect: typeof useEffect;
import { type DependencyList, type EffectCallback } from 'react';
export declare let useIsoMorphicEffect: (effect: EffectCallback, deps?: DependencyList | undefined) => void;

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

import{useLayoutEffect as e,useEffect as f}from"react";import{isServer as o}from"../utils/ssr.js";let s=o?f:e;export{s as useIsoMorphicEffect};
import{useEffect as f,useLayoutEffect as c}from"react";import{env as i}from'../utils/env.js';let n=(e,t)=>{i.isServer?f(e,t):c(e,t)};export{n as useIsoMorphicEffect};

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

import{useRef as t}from"react";import{useIsoMorphicEffect as o}from"./use-iso-morphic-effect.js";function s(e){let r=t(e);return o(()=>{r.current=e},[e]),r}export{s as useLatestValue};
import{useRef as t}from"react";import{useIsoMorphicEffect as o}from'./use-iso-morphic-effect.js';function s(e){let r=t(e);return o(()=>{r.current=e},[e]),r}export{s as useLatestValue};

@@ -1,6 +0,5 @@

import { MutableRefObject } from 'react';
declare type Container = MutableRefObject<HTMLElement | null> | HTMLElement | null;
declare type ContainerCollection = Container[] | Set<Container>;
declare type ContainerInput = Container | ContainerCollection;
export declare function useOutsideClick(containers: ContainerInput | (() => ContainerInput), cb: (event: MouseEvent | PointerEvent | FocusEvent, target: HTMLElement) => void, enabled?: boolean): void;
type Container = HTMLElement | null;
type ContainerCollection = Container[] | Set<Container>;
type ContainerInput = Container | ContainerCollection;
export declare function useOutsideClick(enabled: boolean, containers: ContainerInput | (() => ContainerInput), cb: (event: MouseEvent | PointerEvent | FocusEvent | TouchEvent, target: HTMLElement) => void): void;
export {};

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

import{useEffect as C,useRef as a}from"react";import{FocusableMode as d,isFocusableElement as v}from"../utils/focus-management.js";import{useDocumentEvent as o}from"./use-document-event.js";function L(f,m,i=!0){let l=a(!1);C(()=>{requestAnimationFrame(()=>{l.current=i})},[i]);function c(t,E){if(!l.current||t.defaultPrevented)return;let s=function r(e){return typeof e=="function"?r(e()):Array.isArray(e)||e instanceof Set?e:[e]}(f),n=E(t);if(n!==null&&!!n.ownerDocument.documentElement.contains(n)){for(let r of s){if(r===null)continue;let e=r instanceof HTMLElement?r:r.current;if(e!=null&&e.contains(n))return}return!v(n,d.Loose)&&n.tabIndex!==-1&&t.preventDefault(),m(t,n)}}let u=a(null);o("mousedown",t=>{l.current&&(u.current=t.target)},!0),o("click",t=>{!u.current||(c(t,()=>u.current),u.current=null)},!0),o("blur",t=>c(t,()=>window.document.activeElement instanceof HTMLIFrameElement?window.document.activeElement:null),!0)}export{L as useOutsideClick};
import{useCallback as T,useRef as d}from"react";import{FocusableMode as y,isFocusableElement as M}from'../utils/focus-management.js';import{isMobile as g}from'../utils/platform.js';import{useDocumentEvent as c}from'./use-document-event.js';import{useIsTopLayer as L}from'./use-is-top-layer.js';import{useLatestValue as b}from'./use-latest-value.js';import{useWindowEvent as P}from'./use-window-event.js';const E=30;function R(p,f,C){let u=L(p,"outside-click"),m=b(C),s=T(function(e,n){if(e.defaultPrevented)return;let r=n(e);if(r===null||!r.getRootNode().contains(r)||!r.isConnected)return;let h=function l(o){return typeof o=="function"?l(o()):Array.isArray(o)||o instanceof Set?o:[o]}(f);for(let l of h)if(l!==null&&(l.contains(r)||e.composed&&e.composedPath().includes(l)))return;return!M(r,y.Loose)&&r.tabIndex!==-1&&e.preventDefault(),m.current(e,r)},[m,f]),i=d(null);c(u,"pointerdown",t=>{var e,n;i.current=((n=(e=t.composedPath)==null?void 0:e.call(t))==null?void 0:n[0])||t.target},!0),c(u,"mousedown",t=>{var e,n;i.current=((n=(e=t.composedPath)==null?void 0:e.call(t))==null?void 0:n[0])||t.target},!0),c(u,"click",t=>{g()||i.current&&(s(t,()=>i.current),i.current=null)},!0);let a=d({x:0,y:0});c(u,"touchstart",t=>{a.current.x=t.touches[0].clientX,a.current.y=t.touches[0].clientY},!0),c(u,"touchend",t=>{let e={x:t.changedTouches[0].clientX,y:t.changedTouches[0].clientY};if(!(Math.abs(e.x-a.current.x)>=E||Math.abs(e.y-a.current.y)>=E))return s(t,()=>t.target instanceof HTMLElement?t.target:null)},!0),P(u,"blur",t=>s(t,()=>window.document.activeElement instanceof HTMLIFrameElement?window.document.activeElement:null),!0)}export{R as useOutsideClick};

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

import { getOwnerDocument } from '../utils/owner';
import { getOwnerDocument } from '../utils/owner.js';
export declare function useOwnerDocument(...args: Parameters<typeof getOwnerDocument>): Document | null;

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

import{useMemo as t}from"react";import{getOwnerDocument as o}from"../utils/owner.js";function n(...e){return t(()=>o(...e),[...e])}export{n as useOwnerDocument};
import{useMemo as t}from"react";import{getOwnerDocument as o}from'../utils/owner.js';function n(...e){return t(()=>o(...e),[...e])}export{n as useOwnerDocument};

@@ -1,5 +0,4 @@

import { MutableRefObject } from 'react';
export declare function useResolveButtonType<TTag>(props: {
type?: string;
as?: TTag;
}, ref: MutableRefObject<HTMLElement | null>): string | undefined;
}, element: HTMLElement | null): string | undefined;

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

import{useState as o}from"react";import{useIsoMorphicEffect as r}from"./use-iso-morphic-effect.js";function i(t){var n;if(t.type)return t.type;let e=(n=t.as)!=null?n:"button";if(typeof e=="string"&&e.toLowerCase()==="button")return"button"}function s(t,e){let[n,u]=o(()=>i(t));return r(()=>{u(i(t))},[t.type,t.as]),r(()=>{n||!e.current||e.current instanceof HTMLButtonElement&&!e.current.hasAttribute("type")&&u("button")},[n,e]),n}export{s as useResolveButtonType};
import{useMemo as a}from"react";function e(t,u){return a(()=>{var n;if(t.type)return t.type;let r=(n=t.as)!=null?n:"button";if(typeof r=="string"&&r.toLowerCase()==="button"||(u==null?void 0:u.tagName)==="BUTTON"&&!u.hasAttribute("type"))return"button"},[t.type,t.as,u])}export{e as useResolveButtonType};

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

import{useState as o,useEffect as t}from"react";let r={serverHandoffComplete:!1};function a(){let[e,f]=o(r.serverHandoffComplete);return t(()=>{e!==!0&&f(!0)},[e]),t(()=>{r.serverHandoffComplete===!1&&(r.serverHandoffComplete=!0)},[]),e}export{a as useServerHandoffComplete};
import*as t from"react";import{env as f}from'../utils/env.js';function s(){let r=typeof document=="undefined";return"useSyncExternalStore"in t?(o=>o.useSyncExternalStore)(t)(()=>()=>{},()=>!1,()=>!r):!1}function l(){let r=s(),[e,n]=t.useState(f.isHandoffComplete);return e&&f.isHandoffComplete===!1&&n(!1),t.useEffect(()=>{e!==!0&&n(!0)},[e]),t.useEffect(()=>f.handoff(),[]),r?!1:e}export{l as useServerHandoffComplete};

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

import{useRef as l,useEffect as i}from"react";import{useEvent as r}from"./use-event.js";let u=Symbol();function T(t,n=!0){return Object.assign(t,{[u]:n})}function y(...t){let n=l(t);i(()=>{n.current=t},[t]);let c=r(e=>{for(let o of n.current)o!=null&&(typeof o=="function"?o(e):o.current=e)});return t.every(e=>e==null||(e==null?void 0:e[u]))?void 0:c}export{T as optionalRef,y as useSyncRefs};
import{useEffect as l,useRef as i}from"react";import{useEvent as r}from'./use-event.js';let u=Symbol();function T(t,n=!0){return Object.assign(t,{[u]:n})}function y(...t){let n=i(t);l(()=>{n.current=t},[t]);let c=r(e=>{for(let o of n.current)o!=null&&(typeof o=="function"?o(e):o.current=e)});return t.every(e=>e==null||(e==null?void 0:e[u]))?void 0:c}export{T as optionalRef,y as useSyncRefs};

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

import{useRef as t}from"react";import{useWindowEvent as a}from"./use-window-event.js";var s=(r=>(r[r.Forwards=0]="Forwards",r[r.Backwards=1]="Backwards",r))(s||{});function n(){let e=t(0);return a("keydown",o=>{o.key==="Tab"&&(e.current=o.shiftKey?1:0)},!0),e}export{s as Direction,n as useTabDirection};
import{useRef as o}from"react";import{useWindowEvent as t}from'./use-window-event.js';var a=(r=>(r[r.Forwards=0]="Forwards",r[r.Backwards=1]="Backwards",r))(a||{});function u(){let e=o(0);return t(!0,"keydown",r=>{r.key==="Tab"&&(e.current=r.shiftKey?1:0)},!0),e}export{a as Direction,u as useTabDirection};

@@ -1,24 +0,12 @@

import { MutableRefObject } from 'react';
interface TransitionArgs {
container: MutableRefObject<HTMLElement | null>;
classes: MutableRefObject<{
enter: string[];
enterFrom: string[];
enterTo: string[];
leave: string[];
leaveFrom: string[];
leaveTo: string[];
entered: string[];
}>;
events: MutableRefObject<{
beforeEnter: () => void;
afterEnter: () => void;
beforeLeave: () => void;
afterLeave: () => void;
}>;
direction: 'enter' | 'leave' | 'idle';
onStart: MutableRefObject<(direction: TransitionArgs['direction']) => void>;
onStop: MutableRefObject<(direction: TransitionArgs['direction']) => void>;
}
export declare function useTransition({ container, direction, classes, events, onStart, onStop, }: TransitionArgs): void;
type TransitionData = {
closed?: boolean;
enter?: boolean;
leave?: boolean;
transition?: boolean;
};
export declare function transitionDataAttributes(data: TransitionData): Record<string, string>;
export declare function useTransition(enabled: boolean, element: HTMLElement | null, show: boolean, events?: {
start?(show: boolean): void;
end?(show: boolean): void;
}): [visible: boolean, data: TransitionData];
export {};

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

import{Reason as s,transition as g}from"../components/transitions/utils/transition.js";import{disposables as E}from"../utils/disposables.js";import{match as n}from"../utils/match.js";import{useDisposables as M}from"./use-disposables.js";import{useEvent as a}from"./use-event.js";import{useIsMounted as T}from"./use-is-mounted.js";import{useIsoMorphicEffect as R}from"./use-iso-morphic-effect.js";import{useLatestValue as j}from"./use-latest-value.js";function H({container:u,direction:o,classes:c,events:t,onStart:d,onStop:l}){let f=T(),m=M(),e=j(o),b=a(()=>n(e.current,{enter:()=>t.current.beforeEnter(),leave:()=>t.current.beforeLeave(),idle:()=>{}})),p=a(()=>n(e.current,{enter:()=>t.current.afterEnter(),leave:()=>t.current.afterLeave(),idle:()=>{}}));R(()=>{let r=E();m.add(r.dispose);let i=u.current;if(!!i&&e.current!=="idle"&&!!f.current)return r.dispose(),b(),d.current(e.current),r.add(g(i,c.current,e.current==="enter",v=>{r.dispose(),n(v,{[s.Ended](){p(),l.current(e.current)},[s.Cancelled]:()=>{}})})),r.dispose},[o])}export{H as useTransition};
var T,b;import{useRef as c,useState as S}from"react";import{disposables as m}from'../utils/disposables.js';import{useDisposables as g}from'./use-disposables.js';import{useFlags as y}from'./use-flags.js';import{useIsoMorphicEffect as A}from'./use-iso-morphic-effect.js';typeof process!="undefined"&&typeof globalThis!="undefined"&&typeof Element!="undefined"&&((T=process==null?void 0:process.env)==null?void 0:T["NODE_ENV"])==="test"&&typeof((b=Element==null?void 0:Element.prototype)==null?void 0:b.getAnimations)=="undefined"&&(Element.prototype.getAnimations=function(){return console.warn(["Headless UI has polyfilled `Element.prototype.getAnimations` for your tests.","Please install a proper polyfill e.g. `jsdom-testing-mocks`, to silence these warnings.","","Example usage:","```js","import { mockAnimationsApi } from 'jsdom-testing-mocks'","mockAnimationsApi()","```"].join(`
`)),[]});var L=(r=>(r[r.None=0]="None",r[r.Closed=1]="Closed",r[r.Enter=2]="Enter",r[r.Leave=4]="Leave",r))(L||{});function R(t){let n={};for(let e in t)t[e]===!0&&(n[`data-${e}`]="");return n}function x(t,n,e,i){let[r,o]=S(e),{hasFlag:s,addFlag:a,removeFlag:l}=y(t&&r?3:0),u=c(!1),f=c(!1),E=g();return A(()=>{var d;if(t){if(e&&o(!0),!n){e&&a(3);return}return(d=i==null?void 0:i.start)==null||d.call(i,e),C(n,{inFlight:u,prepare(){f.current?f.current=!1:f.current=u.current,u.current=!0,!f.current&&(e?(a(3),l(4)):(a(4),l(2)))},run(){f.current?e?(l(3),a(4)):(l(4),a(3)):e?l(1):a(1)},done(){var p;f.current&&typeof n.getAnimations=="function"&&n.getAnimations().length>0||(u.current=!1,l(7),e||o(!1),(p=i==null?void 0:i.end)==null||p.call(i,e))}})}},[t,e,n,E]),t?[r,{closed:s(1),enter:s(2),leave:s(4),transition:s(2)||s(4)}]:[e,{closed:void 0,enter:void 0,leave:void 0,transition:void 0}]}function C(t,{prepare:n,run:e,done:i,inFlight:r}){let o=m();return j(t,{prepare:n,inFlight:r}),o.nextFrame(()=>{e(),o.requestAnimationFrame(()=>{o.add(M(t,i))})}),o.dispose}function M(t,n){var o,s;let e=m();if(!t)return e.dispose;let i=!1;e.add(()=>{i=!0});let r=(s=(o=t.getAnimations)==null?void 0:o.call(t).filter(a=>a instanceof CSSTransition))!=null?s:[];return r.length===0?(n(),e.dispose):(Promise.allSettled(r.map(a=>a.finished)).then(()=>{i||n()}),e.dispose)}function j(t,{inFlight:n,prepare:e}){if(n!=null&&n.current){e();return}let i=t.style.transition;t.style.transition="none",e(),t.offsetHeight,t.style.transition=i}export{R as transitionDataAttributes,x as useTransition};

@@ -1,8 +0,7 @@

declare type AcceptNode = (node: HTMLElement) => typeof NodeFilter.FILTER_ACCEPT | typeof NodeFilter.FILTER_SKIP | typeof NodeFilter.FILTER_REJECT;
export declare function useTreeWalker({ container, accept, walk, enabled, }: {
type AcceptNode = (node: HTMLElement) => typeof NodeFilter.FILTER_ACCEPT | typeof NodeFilter.FILTER_SKIP | typeof NodeFilter.FILTER_REJECT;
export declare function useTreeWalker(enabled: boolean, { container, accept, walk, }: {
container: HTMLElement | null;
accept: AcceptNode;
walk(node: HTMLElement): void;
enabled?: boolean;
}): void;
export {};

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

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

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

export declare function useWatch<T>(cb: (values: T[]) => void | (() => void), dependencies: T[]): void;
export declare function useWatch<T extends any[]>(cb: (newValues: [...T], oldValues: [...T]) => void | (() => void), dependencies: [...T]): void;

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

import{useEffect as l,useRef as a}from"react";import{useEvent as c}from"./use-event.js";function m(o,t){let r=a([]),e=c(o);l(()=>{for(let[u,f]of t.entries())if(r.current[u]!==f){let i=e(t);return r.current=t,i}},[e,...t])}export{m as useWatch};
import{useEffect as f,useRef as s}from"react";import{useEvent as i}from'./use-event.js';function m(u,t){let e=s([]),r=i(u);f(()=>{let o=[...e.current];for(let[a,l]of t.entries())if(e.current[a]!==l){let n=r(t,o);return e.current=t,n}},[r,...t])}export{m as useWatch};

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

export declare function useWindowEvent<TType extends keyof WindowEventMap>(type: TType, listener: (ev: WindowEventMap[TType]) => any, options?: boolean | AddEventListenerOptions): void;
export declare function useWindowEvent<TType extends keyof WindowEventMap>(enabled: boolean, type: TType, listener: (ev: WindowEventMap[TType]) => any, options?: boolean | AddEventListenerOptions): void;

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

import{useEffect as d}from"react";import{useLatestValue as a}from"./use-latest-value.js";function s(e,r,n){let o=a(r);d(()=>{function t(i){o.current(i)}return window.addEventListener(e,t,n),()=>window.removeEventListener(e,t,n)},[e,n])}export{s as useWindowEvent};
import{useEffect as a}from"react";import{useLatestValue as f}from'./use-latest-value.js';function s(t,e,o,n){let i=f(o);a(()=>{if(!t)return;function r(d){i.current(d)}return window.addEventListener(e,r,n),()=>window.removeEventListener(e,r,n)},[t,e,n])}export{s as useWindowEvent};

@@ -1,12 +0,25 @@

export * from './components/combobox/combobox';
export * from './components/dialog/dialog';
export * from './components/disclosure/disclosure';
export * from './components/focus-trap/focus-trap';
export * from './components/listbox/listbox';
export * from './components/menu/menu';
export * from './components/popover/popover';
export * from './components/portal/portal';
export * from './components/radio-group/radio-group';
export * from './components/switch/switch';
export * from './components/tabs/tabs';
export * from './components/transitions/transition';
export * from './components/button/button.js';
export * from './components/checkbox/checkbox.js';
export * from './components/close-button/close-button.js';
export * from './components/combobox/combobox.js';
export * from './components/data-interactive/data-interactive.js';
export { Description, type DescriptionProps } from './components/description/description.js';
export * from './components/dialog/dialog.js';
export * from './components/disclosure/disclosure.js';
export * from './components/field/field.js';
export * from './components/fieldset/fieldset.js';
export * from './components/focus-trap/focus-trap.js';
export * from './components/input/input.js';
export { Label, type LabelProps } from './components/label/label.js';
export * from './components/legend/legend.js';
export * from './components/listbox/listbox.js';
export * from './components/menu/menu.js';
export * from './components/popover/popover.js';
export { Portal } from './components/portal/portal.js';
export * from './components/radio-group/radio-group.js';
export * from './components/select/select.js';
export * from './components/switch/switch.js';
export * from './components/tabs/tabs.js';
export * from './components/textarea/textarea.js';
export { useClose } from './internal/close-provider.js';
export * from './components/transition/transition.js';

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

export*from"./components/combobox/combobox.js";export*from"./components/dialog/dialog.js";export*from"./components/disclosure/disclosure.js";export*from"./components/focus-trap/focus-trap.js";export*from"./components/listbox/listbox.js";export*from"./components/menu/menu.js";export*from"./components/popover/popover.js";export*from"./components/portal/portal.js";export*from"./components/radio-group/radio-group.js";export*from"./components/switch/switch.js";export*from"./components/tabs/tabs.js";export*from"./components/transitions/transition.js";
export*from'./components/button/button.js';export*from'./components/checkbox/checkbox.js';export*from'./components/close-button/close-button.js';export*from'./components/combobox/combobox.js';export*from'./components/data-interactive/data-interactive.js';import{Description as x}from'./components/description/description.js';export*from'./components/dialog/dialog.js';export*from'./components/disclosure/disclosure.js';export*from'./components/field/field.js';export*from'./components/fieldset/fieldset.js';export*from'./components/focus-trap/focus-trap.js';export*from'./components/input/input.js';import{Label as n}from'./components/label/label.js';export*from'./components/legend/legend.js';export*from'./components/listbox/listbox.js';export*from'./components/menu/menu.js';export*from'./components/popover/popover.js';import{Portal as d}from'./components/portal/portal.js';export*from'./components/radio-group/radio-group.js';export*from'./components/select/select.js';export*from'./components/switch/switch.js';export*from'./components/tabs/tabs.js';export*from'./components/textarea/textarea.js';import{useClose as w}from'./internal/close-provider.js';export*from'./components/transition/transition.js';export{x as Description,n as Label,d as Portal,w as useClose};

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

/// <reference types="react" />
import React from 'react';
interface FocusSentinelProps {
onFocus(): boolean;
}
export declare function FocusSentinel({ onFocus }: FocusSentinelProps): JSX.Element | null;
export declare function FocusSentinel({ onFocus }: FocusSentinelProps): React.JSX.Element | null;
export {};

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

import i,{useState as s}from"react";import{Hidden as c,Features as l}from"./hidden.js";function p({onFocus:n}){let[r,o]=s(!0);return r?i.createElement(c,{as:"button",type:"button",features:l.Focusable,onFocus:a=>{a.preventDefault();let e,u=50;function t(){if(u--<=0){e&&cancelAnimationFrame(e);return}if(n()){o(!1),cancelAnimationFrame(e);return}e=requestAnimationFrame(t)}e=requestAnimationFrame(t)}}):null}export{p as FocusSentinel};
import s,{useState as c}from"react";import{useIsMounted as m}from'../hooks/use-is-mounted.js';import{Hidden as f,HiddenFeatures as l}from'./hidden.js';function b({onFocus:n}){let[r,o]=c(!0),u=m();return r?s.createElement(f,{as:"button",type:"button",features:l.Focusable,onFocus:a=>{a.preventDefault();let e,i=50;function t(){if(i--<=0){e&&cancelAnimationFrame(e);return}if(n()){if(cancelAnimationFrame(e),!u.current)return;o(!1);return}e=requestAnimationFrame(t)}e=requestAnimationFrame(t)}}):null}export{b as FocusSentinel};

@@ -1,4 +0,6 @@

import { ElementType, Ref } from 'react';
import { Props } from '../types';
export declare enum Features {
import type { ElementType, Ref } from 'react';
import type { Props } from '../types.js';
import { type HasDisplayName, type RefProp } from '../utils/render.js';
declare let DEFAULT_VISUALLY_HIDDEN_TAG: "span";
export declare enum HiddenFeatures {
None = 1,

@@ -8,14 +10,12 @@ Focusable = 2,

}
export declare let Hidden: (<TTag extends ElementType<any> = "div">(props: Omit<import("../types").PropsOf<TTag>, "as" | "children" | "refName" | "className"> & {
as?: TTag | undefined;
children?: import("react").ReactNode | ((bag: any) => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>);
refName?: string | undefined;
} & (import("../types").PropsOf<TTag> extends {
className?: any;
} ? {
className?: string | ((bag: any) => string) | undefined;
} : {}) & {
features?: Features | undefined;
}, ref: Ref<HTMLElement>) => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>> | null) & {
displayName: string;
};
type HiddenRenderPropArg = {};
type HiddenPropsWeControl = never;
export type HiddenProps<TTag extends ElementType = typeof DEFAULT_VISUALLY_HIDDEN_TAG> = Props<TTag, HiddenRenderPropArg, HiddenPropsWeControl, {
features?: HiddenFeatures;
}>;
declare function VisuallyHidden<TTag extends ElementType = typeof DEFAULT_VISUALLY_HIDDEN_TAG>(props: HiddenProps<TTag>, ref: Ref<HTMLElement>): import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>> | null;
interface ComponentHidden extends HasDisplayName {
<TTag extends ElementType = typeof DEFAULT_VISUALLY_HIDDEN_TAG>(props: HiddenProps<TTag> & RefProp<typeof VisuallyHidden>): JSX.Element;
}
export declare let Hidden: ComponentHidden;
export {};

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

import{forwardRefWithAs as n,render as i}from"../utils/render.js";let a="div";var s=(e=>(e[e.None=1]="None",e[e.Focusable=2]="Focusable",e[e.Hidden=4]="Hidden",e))(s||{});let h=n(function(t,o){let{features:e=1,...r}=t,d={ref:o,"aria-hidden":(e&2)===2?!0:void 0,style:{position:"absolute",width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0",...(e&4)===4&&(e&2)!==2&&{display:"none"}}};return i({ourProps:d,theirProps:r,slot:{},defaultTag:a,name:"Hidden"})});export{s as Features,h as Hidden};
import{forwardRefWithAs as i,render as p}from'../utils/render.js';let a="span";var s=(e=>(e[e.None=1]="None",e[e.Focusable=2]="Focusable",e[e.Hidden=4]="Hidden",e))(s||{});function l(t,r){var n;let{features:d=1,...e}=t,o={ref:r,"aria-hidden":(d&2)===2?!0:(n=e["aria-hidden"])!=null?n:void 0,hidden:(d&4)===4?!0:void 0,style:{position:"fixed",top:1,left:1,width:1,height:0,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0",...(d&4)===4&&(d&2)!==2&&{display:"none"}}};return p({ourProps:o,theirProps:e,slot:{},defaultTag:a,name:"Hidden"})}let T=i(l);export{T as Hidden,s as HiddenFeatures};

@@ -1,5 +0,7 @@

import { ReactNode, ReactElement } from 'react';
import React, { type ReactElement, type ReactNode } from 'react';
export declare enum State {
Open = 0,
Closed = 1
Open = 1,
Closed = 2,
Closing = 4,
Opening = 8
}

@@ -12,2 +14,5 @@ export declare function useOpenClosed(): State | null;

export declare function OpenClosedProvider({ value, children }: Props): ReactElement;
export declare function ResetOpenClosedProvider({ children }: {
children: React.ReactNode;
}): ReactElement;
export {};

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

import r,{createContext as l,useContext as d}from"react";let o=l(null);o.displayName="OpenClosedContext";var p=(e=>(e[e.Open=0]="Open",e[e.Closed=1]="Closed",e))(p||{});function s(){return d(o)}function C({value:t,children:n}){return r.createElement(o.Provider,{value:t},n)}export{C as OpenClosedProvider,p as State,s as useOpenClosed};
import r,{createContext as l,useContext as d}from"react";let n=l(null);n.displayName="OpenClosedContext";var i=(e=>(e[e.Open=1]="Open",e[e.Closed=2]="Closed",e[e.Closing=4]="Closing",e[e.Opening=8]="Opening",e))(i||{});function u(){return d(n)}function c({value:o,children:t}){return r.createElement(n.Provider,{value:o},t)}function s({children:o}){return r.createElement(n.Provider,{value:null},o)}export{c as OpenClosedProvider,s as ResetOpenClosedProvider,i as State,u as useOpenClosed};

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

import { ReactNode } from 'react';
import React, { type ReactNode } from 'react';
export declare function usePortalRoot(): boolean;

@@ -7,3 +7,3 @@ interface ForcePortalRootProps {

}
export declare function ForcePortalRoot(props: ForcePortalRootProps): JSX.Element;
export declare function ForcePortalRoot(props: ForcePortalRootProps): React.JSX.Element;
export {};

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

import t,{createContext as r,useContext as c}from"react";let e=r(!1);function l(){return c(e)}function P(o){return t.createElement(e.Provider,{value:o.force},o.children)}export{P as ForcePortalRoot,l as usePortalRoot};
import t,{createContext as r,useContext as c}from"react";let e=r(!1);function a(){return c(e)}function l(o){return t.createElement(e.Provider,{value:o.force},o.children)}export{l as ForcePortalRoot,a as usePortalRoot};

@@ -1,11 +0,10 @@

import { ReactNode, ReactElement } from 'react';
declare let __: "1D45E01E-AF44-47C4-988A-19A94EBAF55C";
export declare type __ = typeof __;
export declare type Expand<T> = T extends infer O ? {
import type { JSXElementConstructor, ReactElement, ReactNode } from 'react';
export type ReactTag = keyof JSX.IntrinsicElements | JSXElementConstructor<any>;
export type Expand<T> = T extends infer O ? {
[K in keyof O]: O[K];
} : never;
export declare type PropsOf<TTag = any> = TTag extends React.ElementType ? React.ComponentProps<TTag> : never;
declare type PropsWeControl = 'as' | 'children' | 'refName' | 'className';
declare type CleanProps<TTag, TOmitableProps extends keyof any = __> = TOmitableProps extends __ ? Omit<PropsOf<TTag>, PropsWeControl> : Omit<PropsOf<TTag>, TOmitableProps | PropsWeControl>;
declare type OurProps<TTag, TSlot = any> = {
export type PropsOf<TTag extends ReactTag> = TTag extends React.ElementType ? Omit<React.ComponentProps<TTag>, 'ref'> : never;
type PropsWeControl = 'as' | 'children' | 'refName' | 'className';
type CleanProps<TTag extends ReactTag, TOmittableProps extends PropertyKey = never> = Omit<PropsOf<TTag>, TOmittableProps | PropsWeControl>;
type OurProps<TTag extends ReactTag, TSlot> = {
as?: TTag;

@@ -15,12 +14,8 @@ children?: ReactNode | ((bag: TSlot) => ReactElement);

};
declare type ClassNameOverride<TTag, TSlot = any> = PropsOf<TTag> extends {
className?: any;
} ? {
className?: string | ((bag: TSlot) => string);
type HasProperty<T extends object, K extends PropertyKey> = T extends never ? never : K extends keyof T ? true : never;
type ClassNameOverride<TTag extends ReactTag, TSlot = {}> = true extends HasProperty<PropsOf<TTag>, 'className'> ? {
className?: PropsOf<TTag>['className'] | ((bag: TSlot) => string);
} : {};
export declare type Props<TTag, TSlot = any, TOmitableProps extends keyof any = __> = CleanProps<TTag, TOmitableProps> & OurProps<TTag, TSlot> & ClassNameOverride<TTag, TSlot>;
declare type Without<T, U> = {
[P in Exclude<keyof T, keyof U>]?: never;
};
export declare type XOR<T, U> = T | U extends __ ? never : T extends __ ? U : U extends __ ? T : T | U extends object ? (Without<T, U> & U) | (Without<U, T> & T) : T | U;
export type Props<TTag extends ReactTag, TSlot = {}, TOmittableProps extends PropertyKey = never, Overrides = {}> = CleanProps<TTag, TOmittableProps | keyof Overrides> & OurProps<TTag, TSlot> & ClassNameOverride<TTag, TSlot> & Overrides;
export type EnsureArray<T> = T extends any[] ? T : Expand<T>[];
export {};

@@ -23,4 +23,4 @@ export declare enum Focus {

resolveActiveIndex(): number | null;
resolveId(item: TItem): string;
resolveDisabled(item: TItem): boolean;
resolveId(item: TItem, index: number, items: TItem[]): string;
resolveDisabled(item: TItem, index: number, items: TItem[]): boolean;
}): number | null;

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

function f(r){throw new Error("Unexpected object: "+r)}var a=(e=>(e[e.First=0]="First",e[e.Previous=1]="Previous",e[e.Next=2]="Next",e[e.Last=3]="Last",e[e.Specific=4]="Specific",e[e.Nothing=5]="Nothing",e))(a||{});function x(r,n){let t=n.resolveItems();if(t.length<=0)return null;let l=n.resolveActiveIndex(),s=l!=null?l:-1,d=(()=>{switch(r.focus){case 0:return t.findIndex(e=>!n.resolveDisabled(e));case 1:{let e=t.slice().reverse().findIndex((i,c,u)=>s!==-1&&u.length-c-1>=s?!1:!n.resolveDisabled(i));return e===-1?e:t.length-1-e}case 2:return t.findIndex((e,i)=>i<=s?!1:!n.resolveDisabled(e));case 3:{let e=t.slice().reverse().findIndex(i=>!n.resolveDisabled(i));return e===-1?e:t.length-1-e}case 4:return t.findIndex(e=>n.resolveId(e)===r.id);case 5:return null;default:f(r)}})();return d===-1?l:d}export{a as Focus,x as calculateActiveIndex};
function u(l){throw new Error("Unexpected object: "+l)}var c=(i=>(i[i.First=0]="First",i[i.Previous=1]="Previous",i[i.Next=2]="Next",i[i.Last=3]="Last",i[i.Specific=4]="Specific",i[i.Nothing=5]="Nothing",i))(c||{});function f(l,n){let t=n.resolveItems();if(t.length<=0)return null;let r=n.resolveActiveIndex(),s=r!=null?r:-1;switch(l.focus){case 0:{for(let e=0;e<t.length;++e)if(!n.resolveDisabled(t[e],e,t))return e;return r}case 1:{s===-1&&(s=t.length);for(let e=s-1;e>=0;--e)if(!n.resolveDisabled(t[e],e,t))return e;return r}case 2:{for(let e=s+1;e<t.length;++e)if(!n.resolveDisabled(t[e],e,t))return e;return r}case 3:{for(let e=t.length-1;e>=0;--e)if(!n.resolveDisabled(t[e],e,t))return e;return r}case 4:{for(let e=0;e<t.length;++e)if(n.resolveId(t[e],e,t)===l.id)return e;return r}case 5:return null;default:u(l)}}export{c as Focus,f as calculateActiveIndex};

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

function e(...n){return n.filter(Boolean).join(" ")}export{e as classNames};
function t(...r){return Array.from(new Set(r.flatMap(n=>typeof n=="string"?n.split(" "):[]))).filter(Boolean).join(" ")}export{t as classNames};

@@ -0,10 +1,24 @@

export type Disposables = ReturnType<typeof disposables>;
/**
* Disposables are a way to manage event handlers and functions like
* `setTimeout` and `requestAnimationFrame` that need to be cleaned up when they
* are no longer needed.
*
*
* When you register a disposable function, it is added to a collection of
* disposables. Each disposable in the collection provides a `dispose` clean up
* function that can be called when it's no longer needed. There is also a
* `dispose` function on the collection itself that can be used to clean up all
* pending disposables in that collection.
*/
export declare function disposables(): {
enqueue(fn: Function): void;
addEventListener<TEventName extends keyof WindowEventMap>(element: HTMLElement, name: TEventName, listener: (event: WindowEventMap[TEventName]) => any, options?: boolean | AddEventListenerOptions | undefined): () => void;
addEventListener<TEventName extends keyof WindowEventMap>(element: HTMLElement | Window | Document, name: TEventName, listener: (event: WindowEventMap[TEventName]) => any, options?: boolean | AddEventListenerOptions): () => void;
requestAnimationFrame(callback: FrameRequestCallback): () => void;
nextFrame(callback: FrameRequestCallback): () => void;
setTimeout(callback: (...args: any[]) => void, ms?: number | undefined, ...args: any[]): () => void;
microTask(cb: () => void): () => void;
style(node: HTMLElement, property: string, value: string): () => void;
group(cb: (d: typeof this) => void): () => void;
add(cb: () => void): () => void;
dispose(): void;
workQueue(): Promise<void>;
};

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

function o(){let a=[],i=[],n={enqueue(e){i.push(e)},addEventListener(e,t,r,s){return e.addEventListener(t,r,s),n.add(()=>e.removeEventListener(t,r,s))},requestAnimationFrame(...e){let t=requestAnimationFrame(...e);return n.add(()=>cancelAnimationFrame(t))},nextFrame(...e){return n.requestAnimationFrame(()=>n.requestAnimationFrame(...e))},setTimeout(...e){let t=setTimeout(...e);return n.add(()=>clearTimeout(t))},add(e){return a.push(e),()=>{let t=a.indexOf(e);if(t>=0){let[r]=a.splice(t,1);r()}}},dispose(){for(let e of a.splice(0))e()},async workQueue(){for(let e of i.splice(0))await e()}};return n}export{o as disposables};
import{microTask as i}from'./micro-task.js';function o(){let n=[],r={addEventListener(e,t,s,a){return e.addEventListener(t,s,a),r.add(()=>e.removeEventListener(t,s,a))},requestAnimationFrame(...e){let t=requestAnimationFrame(...e);return r.add(()=>cancelAnimationFrame(t))},nextFrame(...e){return r.requestAnimationFrame(()=>r.requestAnimationFrame(...e))},setTimeout(...e){let t=setTimeout(...e);return r.add(()=>clearTimeout(t))},microTask(...e){let t={current:!0};return i(()=>{t.current&&e[0]()}),r.add(()=>{t.current=!1})},style(e,t,s){let a=e.style.getPropertyValue(t);return Object.assign(e.style,{[t]:s}),this.add(()=>{Object.assign(e.style,{[t]:a})})},group(e){let t=o();return e(t),this.add(()=>t.dispose())},add(e){return n.includes(e)||n.push(e),()=>{let t=n.indexOf(e);if(t>=0)for(let s of n.splice(t,1))s()}},dispose(){for(let e of n.splice(0))e()}};return r}export{o as disposables};

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

import type { MutableRefObject } from 'react';
export declare let focusableSelector: string;
export declare enum Focus {

@@ -13,3 +15,5 @@ /** Focus the first non-disabled element */

/** Prevent scrolling the focusable elements into view */
NoScroll = 32
NoScroll = 32,
/** Focus the first focusable element with the `data-autofocus` attribute. */
AutoFocus = 64
}

@@ -27,2 +31,3 @@ export declare enum FocusResult {

export declare function getFocusableElements(container?: HTMLElement | null): HTMLElement[];
export declare function getAutoFocusableElements(container?: HTMLElement | null): HTMLElement[];
export declare enum FocusableMode {

@@ -35,5 +40,10 @@ /** The element itself must be focusable. */

export declare function isFocusableElement(element: HTMLElement, mode?: FocusableMode): boolean;
export declare function restoreFocusIfNecessary(element: HTMLElement | null): void;
export declare function focusElement(element: HTMLElement | null): void;
export declare function sortByDomNode<T>(nodes: T[], resolveKey?: (item: T) => HTMLElement | null): T[];
export declare function focusFrom(current: HTMLElement | null, focus: Focus): FocusResult;
export declare function focusIn(container: HTMLElement | HTMLElement[], focus: Focus, sorted?: boolean, active?: HTMLElement | null): FocusResult;
export declare function focusIn(container: HTMLElement | HTMLElement[], focus: Focus, { sorted, relativeTo, skipElements, }?: Partial<{
sorted: boolean;
relativeTo: HTMLElement | null;
skipElements: (HTMLElement | MutableRefObject<HTMLElement | null>)[];
}>): FocusResult;

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

import{match as x}from"./match.js";import{getOwnerDocument as p}from"./owner.js";let m=["[contentEditable=true]","[tabindex]","a[href]","area[href]","button:not([disabled])","iframe","input:not([disabled])","select:not([disabled])","textarea:not([disabled])"].map(e=>`${e}:not([tabindex='-1'])`).join(",");var L=(n=>(n[n.First=1]="First",n[n.Previous=2]="Previous",n[n.Next=4]="Next",n[n.Last=8]="Last",n[n.WrapAround=16]="WrapAround",n[n.NoScroll=32]="NoScroll",n))(L||{}),T=(o=>(o[o.Error=0]="Error",o[o.Overflow=1]="Overflow",o[o.Success=2]="Success",o[o.Underflow=3]="Underflow",o))(T||{}),N=(t=>(t[t.Previous=-1]="Previous",t[t.Next=1]="Next",t))(N||{});function c(e=document.body){return e==null?[]:Array.from(e.querySelectorAll(m))}var b=(t=>(t[t.Strict=0]="Strict",t[t.Loose=1]="Loose",t))(b||{});function H(e,r=0){var t;return e===((t=p(e))==null?void 0:t.body)?!1:x(r,{[0](){return e.matches(m)},[1](){let l=e;for(;l!==null;){if(l.matches(m))return!0;l=l.parentElement}return!1}})}function P(e){e==null||e.focus({preventScroll:!0})}let M=["textarea","input"].join(",");function h(e){var r,t;return(t=(r=e==null?void 0:e.matches)==null?void 0:r.call(e,M))!=null?t:!1}function w(e,r=t=>t){return e.slice().sort((t,l)=>{let o=r(t),s=r(l);if(o===null||s===null)return 0;let n=o.compareDocumentPosition(s);return n&Node.DOCUMENT_POSITION_FOLLOWING?-1:n&Node.DOCUMENT_POSITION_PRECEDING?1:0})}function A(e,r){return F(c(),r,!0,e)}function F(e,r,t=!0,l=null){let o=Array.isArray(e)?e.length>0?e[0].ownerDocument:document:e.ownerDocument,s=Array.isArray(e)?t?w(e):e:c(e);l=l!=null?l:o.activeElement;let n=(()=>{if(r&5)return 1;if(r&10)return-1;throw new Error("Missing Focus.First, Focus.Previous, Focus.Next or Focus.Last")})(),d=(()=>{if(r&1)return 0;if(r&2)return Math.max(0,s.indexOf(l))-1;if(r&4)return Math.max(0,s.indexOf(l))+1;if(r&8)return s.length-1;throw new Error("Missing Focus.First, Focus.Previous, Focus.Next or Focus.Last")})(),E=r&32?{preventScroll:!0}:{},f=0,i=s.length,u;do{if(f>=i||f+i<=0)return 0;let a=d+f;if(r&16)a=(a+i)%i;else{if(a<0)return 3;if(a>=i)return 1}u=s[a],u==null||u.focus(E),f+=n}while(u!==o.activeElement);return r&6&&h(u)&&u.select(),u.hasAttribute("tabindex")||u.setAttribute("tabindex","0"),2}export{L as Focus,T as FocusResult,b as FocusableMode,P as focusElement,A as focusFrom,F as focusIn,c as getFocusableElements,H as isFocusableElement,w as sortByDomNode};
import{disposables as N}from'./disposables.js';import{match as L}from'./match.js';import{getOwnerDocument as E}from'./owner.js';let f=["[contentEditable=true]","[tabindex]","a[href]","area[href]","button:not([disabled])","iframe","input:not([disabled])","select:not([disabled])","textarea:not([disabled])"].map(e=>`${e}:not([tabindex='-1'])`).join(","),p=["[data-autofocus]"].map(e=>`${e}:not([tabindex='-1'])`).join(",");var F=(n=>(n[n.First=1]="First",n[n.Previous=2]="Previous",n[n.Next=4]="Next",n[n.Last=8]="Last",n[n.WrapAround=16]="WrapAround",n[n.NoScroll=32]="NoScroll",n[n.AutoFocus=64]="AutoFocus",n))(F||{}),T=(o=>(o[o.Error=0]="Error",o[o.Overflow=1]="Overflow",o[o.Success=2]="Success",o[o.Underflow=3]="Underflow",o))(T||{}),y=(t=>(t[t.Previous=-1]="Previous",t[t.Next=1]="Next",t))(y||{});function b(e=document.body){return e==null?[]:Array.from(e.querySelectorAll(f)).sort((r,t)=>Math.sign((r.tabIndex||Number.MAX_SAFE_INTEGER)-(t.tabIndex||Number.MAX_SAFE_INTEGER)))}function S(e=document.body){return e==null?[]:Array.from(e.querySelectorAll(p)).sort((r,t)=>Math.sign((r.tabIndex||Number.MAX_SAFE_INTEGER)-(t.tabIndex||Number.MAX_SAFE_INTEGER)))}var h=(t=>(t[t.Strict=0]="Strict",t[t.Loose=1]="Loose",t))(h||{});function A(e,r=0){var t;return e===((t=E(e))==null?void 0:t.body)?!1:L(r,{[0](){return e.matches(f)},[1](){let u=e;for(;u!==null;){if(u.matches(f))return!0;u=u.parentElement}return!1}})}function G(e){let r=E(e);N().nextFrame(()=>{r&&!A(r.activeElement,0)&&I(e)})}var H=(t=>(t[t.Keyboard=0]="Keyboard",t[t.Mouse=1]="Mouse",t))(H||{});typeof window!="undefined"&&typeof document!="undefined"&&(document.addEventListener("keydown",e=>{e.metaKey||e.altKey||e.ctrlKey||(document.documentElement.dataset.headlessuiFocusVisible="")},!0),document.addEventListener("click",e=>{e.detail===1?delete document.documentElement.dataset.headlessuiFocusVisible:e.detail===0&&(document.documentElement.dataset.headlessuiFocusVisible="")},!0));function I(e){e==null||e.focus({preventScroll:!0})}let w=["textarea","input"].join(",");function O(e){var r,t;return(t=(r=e==null?void 0:e.matches)==null?void 0:r.call(e,w))!=null?t:!1}function _(e,r=t=>t){return e.slice().sort((t,u)=>{let o=r(t),c=r(u);if(o===null||c===null)return 0;let l=o.compareDocumentPosition(c);return l&Node.DOCUMENT_POSITION_FOLLOWING?-1:l&Node.DOCUMENT_POSITION_PRECEDING?1:0})}function j(e,r){return P(b(),r,{relativeTo:e})}function P(e,r,{sorted:t=!0,relativeTo:u=null,skipElements:o=[]}={}){let c=Array.isArray(e)?e.length>0?e[0].ownerDocument:document:e.ownerDocument,l=Array.isArray(e)?t?_(e):e:r&64?S(e):b(e);o.length>0&&l.length>1&&(l=l.filter(s=>!o.some(a=>a!=null&&"current"in a?(a==null?void 0:a.current)===s:a===s))),u=u!=null?u:c.activeElement;let n=(()=>{if(r&5)return 1;if(r&10)return-1;throw new Error("Missing Focus.First, Focus.Previous, Focus.Next or Focus.Last")})(),x=(()=>{if(r&1)return 0;if(r&2)return Math.max(0,l.indexOf(u))-1;if(r&4)return Math.max(0,l.indexOf(u))+1;if(r&8)return l.length-1;throw new Error("Missing Focus.First, Focus.Previous, Focus.Next or Focus.Last")})(),M=r&32?{preventScroll:!0}:{},m=0,d=l.length,i;do{if(m>=d||m+d<=0)return 0;let s=x+m;if(r&16)s=(s+d)%d;else{if(s<0)return 3;if(s>=d)return 1}i=l[s],i==null||i.focus(M),m+=n}while(i!==c.activeElement);return r&6&&O(i)&&i.select(),2}export{F as Focus,T as FocusResult,h as FocusableMode,I as focusElement,j as focusFrom,P as focusIn,f as focusableSelector,S as getAutoFocusableElements,b as getFocusableElements,A as isFocusableElement,G as restoreFocusIfNecessary,_ as sortByDomNode};

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

declare type Entries = [string, string][];
type Entries = [string, string][];
export declare function objectToFormEntries(source?: Record<string, any>, parentKey?: string | null, entries?: Entries): Entries;
export declare function attemptSubmit(element: HTMLElement): void;
export declare function attemptSubmit(elementInForm: HTMLElement): void;
export {};

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

function e(n={},r=null,t=[]){for(let[i,o]of Object.entries(n))f(t,s(r,i),o);return t}function s(n,r){return n?n+"["+r+"]":r}function f(n,r,t){if(Array.isArray(t))for(let[i,o]of t.entries())f(n,s(r,i.toString()),o);else t instanceof Date?n.push([r,t.toISOString()]):typeof t=="boolean"?n.push([r,t?"1":"0"]):typeof t=="string"?n.push([r,t]):typeof t=="number"?n.push([r,`${t}`]):t==null?n.push([r,""]):e(t,r,n)}function p(n){var t;let r=(t=n==null?void 0:n.form)!=null?t:n.closest("form");if(!!r){for(let i of r.elements)if(i.tagName==="INPUT"&&i.type==="submit"||i.tagName==="BUTTON"&&i.type==="submit"||i.nodeName==="INPUT"&&i.type==="image"){i.click();return}}}export{p as attemptSubmit,e as objectToFormEntries};
function e(i={},s=null,t=[]){for(let[r,n]of Object.entries(i))o(t,f(s,r),n);return t}function f(i,s){return i?i+"["+s+"]":s}function o(i,s,t){if(Array.isArray(t))for(let[r,n]of t.entries())o(i,f(s,r.toString()),n);else t instanceof Date?i.push([s,t.toISOString()]):typeof t=="boolean"?i.push([s,t?"1":"0"]):typeof t=="string"?i.push([s,t]):typeof t=="number"?i.push([s,`${t}`]):t==null?i.push([s,""]):e(t,s,i)}function p(i){var t,r;let s=(t=i==null?void 0:i.form)!=null?t:i.closest("form");if(s){for(let n of s.elements)if(n!==i&&(n.tagName==="INPUT"&&n.type==="submit"||n.tagName==="BUTTON"&&n.type==="submit"||n.nodeName==="INPUT"&&n.type==="image")){n.click();return}(r=s.requestSubmit)==null||r.call(s)}}export{p as attemptSubmit,e as objectToFormEntries};

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

import { MutableRefObject } from 'react';
import type { MutableRefObject } from 'react';
export declare function getOwnerDocument<T extends Element | MutableRefObject<Element | null>>(element: T | null | undefined): Document | null;

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

import{isServer as n}from"./ssr.js";function e(r){return n?null:r instanceof Node?r.ownerDocument:r!=null&&r.hasOwnProperty("current")&&r.current instanceof Node?r.current.ownerDocument:document}export{e as getOwnerDocument};
import{env as n}from'./env.js';function u(r){return n.isServer?null:r instanceof Node?r.ownerDocument:r!=null&&r.hasOwnProperty("current")&&r.current instanceof Node?r.current.ownerDocument:document}export{u as getOwnerDocument};

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

import { ElementType, ReactElement } from 'react';
import { Props, XOR, __, Expand } from '../types';
export declare enum Features {
import { type ElementType, type ReactElement, type Ref } from 'react';
import type { Expand, Props } from '../types.js';
export declare enum RenderFeatures {
/** No features at all */

@@ -24,12 +24,13 @@ None = 0,

}
declare type PropsForFeature<TPassedInFeatures extends Features, TForFeature extends Features, TProps> = {
[P in TPassedInFeatures]: P extends TForFeature ? TProps : __;
}[TPassedInFeatures];
export declare type PropsForFeatures<T extends Features> = XOR<PropsForFeature<T, Features.Static, {
type UnionToIntersection<T> = (T extends any ? (x: T) => any : never) extends (x: infer R) => any ? R : never;
type PropsForFeature<TPassedInFeatures extends RenderFeatures, TForFeature extends RenderFeatures, TProps> = TPassedInFeatures extends TForFeature ? TProps : {};
export type PropsForFeatures<T extends RenderFeatures> = Expand<UnionToIntersection<PropsForFeature<T, RenderFeatures.Static, {
static?: boolean;
}>, PropsForFeature<T, Features.RenderStrategy, {
}> | PropsForFeature<T, RenderFeatures.RenderStrategy, {
unmount?: boolean;
}>>;
export declare function render<TFeature extends Features, TTag extends ElementType, TSlot>({ ourProps, theirProps, slot, defaultTag, features, visible, name, }: {
ourProps: Expand<Props<TTag, TSlot, any> & PropsForFeatures<TFeature>>;
}>>>;
export declare function render<TFeature extends RenderFeatures, TTag extends ElementType, TSlot>({ ourProps, theirProps, slot, defaultTag, features, visible, name, mergeRefs, }: {
ourProps: Expand<Props<TTag, TSlot, any> & PropsForFeatures<TFeature>> & {
ref?: Ref<HTMLElement | ElementType>;
};
theirProps: Expand<Props<TTag, TSlot, any>>;

@@ -41,4 +42,26 @@ slot?: TSlot;

name: string;
mergeRefs?: ReturnType<typeof useMergeRefsFn>;
}): ReactElement<any, string | import("react").JSXElementConstructor<any>> | null;
/**
* This is a singleton hook. **You can ONLY call the returned
* function *once* to produce expected results.** If you need
* to call `mergeRefs()` multiple times you need to create a
* separate function for each invocation. This happens as we
* store the list of `refs` to update and always return the
* same function that refers to that list of refs.
*
* You shouldn't normally read refs during render but this
* should actually be okay because React itself is calling
* the `function` that updates these refs and can only do
* so once the ref that contains the list is updated.
*/
export declare function useMergeRefsFn(): (...refs: any[]) => ((value: any) => void) | undefined;
export type HasDisplayName = {
displayName: string;
};
export type RefProp<T extends Function> = T extends (props: any, ref: Ref<infer RefType>) => any ? {
ref?: Ref<RefType>;
} : never;
export declare function mergeProps<T extends Props<any, any>[]>(...listOfProps: T): Props<any, any>;
/**
* This is a hack, but basically we want to keep the full 'API' of the component, but we do want to

@@ -45,0 +68,0 @@ * wrap it in a forwardRef so that we _can_ passthrough the ref

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

import{Fragment as c,cloneElement as P,createElement as b,forwardRef as E,isValidElement as x}from"react";import{match as S}from"./match.js";var R=(r=>(r[r.None=0]="None",r[r.RenderStrategy=1]="RenderStrategy",r[r.Static=2]="Static",r))(R||{}),j=(e=>(e[e.Unmount=0]="Unmount",e[e.Hidden=1]="Hidden",e))(j||{});function U({ourProps:a,theirProps:t,slot:e,defaultTag:r,features:s,visible:n=!0,name:l}){let o=T(t,a);if(n)return p(o,e,r,l);let d=s!=null?s:0;if(d&2){let{static:i=!1,...u}=o;if(i)return p(u,e,r,l)}if(d&1){let{unmount:i=!0,...u}=o;return S(i?0:1,{[0](){return null},[1](){return p({...u,hidden:!0,style:{display:"none"}},e,r,l)}})}return p(o,e,r,l)}function p(a,t={},e,r){let{as:s=e,children:n,refName:l="ref",...o}=m(a,["unmount","static"]),d=a.ref!==void 0?{[l]:a.ref}:{},i=typeof n=="function"?n(t):n;o.className&&typeof o.className=="function"&&(o.className=o.className(t));let u={};if(t){let f=!1,y=[];for(let[h,g]of Object.entries(t))typeof g=="boolean"&&(f=!0),g===!0&&y.push(h);f&&(u["data-headlessui-state"]=y.join(" "))}if(s===c&&Object.keys(F(o)).length>0){if(!x(i)||Array.isArray(i)&&i.length>1)throw new Error(['Passing props on "Fragment"!',"",`The current component <${r} /> is rendering a "Fragment".`,"However we need to passthrough the following props:",Object.keys(o).map(f=>` - ${f}`).join(`
`),"","You can apply a few solutions:",['Add an `as="..."` prop, to ensure that we render an actual element instead of a "Fragment".',"Render a single element as the child so that we can forward the props onto that element."].map(f=>` - ${f}`).join(`
import{Fragment as R,cloneElement as P,createElement as E,forwardRef as j,isValidElement as v,useCallback as S,useRef as w}from"react";import{classNames as x}from'./class-names.js';import{match as k}from'./match.js';var M=(a=>(a[a.None=0]="None",a[a.RenderStrategy=1]="RenderStrategy",a[a.Static=2]="Static",a))(M||{}),O=(e=>(e[e.Unmount=0]="Unmount",e[e.Hidden=1]="Hidden",e))(O||{});function H({ourProps:r,theirProps:n,slot:e,defaultTag:a,features:s,visible:t=!0,name:l,mergeRefs:i}){i=i!=null?i:A;let o=N(n,r);if(t)return b(o,e,a,l,i);let y=s!=null?s:0;if(y&2){let{static:f=!1,...u}=o;if(f)return b(u,e,a,l,i)}if(y&1){let{unmount:f=!0,...u}=o;return k(f?0:1,{[0](){return null},[1](){return b({...u,hidden:!0,style:{display:"none"}},e,a,l,i)}})}return b(o,e,a,l,i)}function b(r,n={},e,a,s){let{as:t=e,children:l,refName:i="ref",...o}=h(r,["unmount","static"]),y=r.ref!==void 0?{[i]:r.ref}:{},f=typeof l=="function"?l(n):l;"className"in o&&o.className&&typeof o.className=="function"&&(o.className=o.className(n)),o["aria-labelledby"]&&o["aria-labelledby"]===o.id&&(o["aria-labelledby"]=void 0);let u={};if(n){let d=!1,p=[];for(let[c,T]of Object.entries(n))typeof T=="boolean"&&(d=!0),T===!0&&p.push(c.replace(/([A-Z])/g,g=>`-${g.toLowerCase()}`));if(d){u["data-headlessui-state"]=p.join(" ");for(let c of p)u[`data-${c}`]=""}}if(t===R&&(Object.keys(m(o)).length>0||Object.keys(m(u)).length>0))if(!v(f)||Array.isArray(f)&&f.length>1){if(Object.keys(m(o)).length>0)throw new Error(['Passing props on "Fragment"!',"",`The current component <${a} /> is rendering a "Fragment".`,"However we need to passthrough the following props:",Object.keys(m(o)).concat(Object.keys(m(u))).map(d=>` - ${d}`).join(`
`),"","You can apply a few solutions:",['Add an `as="..."` prop, to ensure that we render an actual element instead of a "Fragment".',"Render a single element as the child so that we can forward the props onto that element."].map(d=>` - ${d}`).join(`
`)].join(`
`));return P(i,Object.assign({},T(i.props,F(m(o,["ref"]))),u,d))}return b(s,Object.assign({},m(o,["ref"]),s!==c&&d,s!==c&&u),i)}function T(...a){var r;if(a.length===0)return{};if(a.length===1)return a[0];let t={},e={};for(let s of a)for(let n in s)n.startsWith("on")&&typeof s[n]=="function"?((r=e[n])!=null||(e[n]=[]),e[n].push(s[n])):t[n]=s[n];if(t.disabled||t["aria-disabled"])return Object.assign(t,Object.fromEntries(Object.keys(e).map(s=>[s,void 0])));for(let s in e)Object.assign(t,{[s](n,...l){let o=e[s];for(let d of o){if((n instanceof Event||(n==null?void 0:n.nativeEvent)instanceof Event)&&n.defaultPrevented)return;d(n,...l)}}});return t}function $(a){var t;return Object.assign(E(a),{displayName:(t=a.displayName)!=null?t:a.name})}function F(a){let t=Object.assign({},a);for(let e in t)t[e]===void 0&&delete t[e];return t}function m(a,t=[]){let e=Object.assign({},a);for(let r of t)r in e&&delete e[r];return e}export{R as Features,j as RenderStrategy,F as compact,$ as forwardRefWithAs,U as render};
`))}else{let d=f.props,p=d==null?void 0:d.className,c=typeof p=="function"?(...F)=>x(p(...F),o.className):x(p,o.className),T=c?{className:c}:{},g=N(f.props,m(h(o,["ref"])));for(let F in u)F in g&&delete u[F];return P(f,Object.assign({},g,u,y,{ref:s(f.ref,y.ref)},T))}return E(t,Object.assign({},h(o,["ref"]),t!==R&&y,t!==R&&u),f)}function I(){let r=w([]),n=S(e=>{for(let a of r.current)a!=null&&(typeof a=="function"?a(e):a.current=e)},[]);return(...e)=>{if(!e.every(a=>a==null))return r.current=e,n}}function A(...r){return r.every(n=>n==null)?void 0:n=>{for(let e of r)e!=null&&(typeof e=="function"?e(n):e.current=n)}}function N(...r){var a;if(r.length===0)return{};if(r.length===1)return r[0];let n={},e={};for(let s of r)for(let t in s)t.startsWith("on")&&typeof s[t]=="function"?((a=e[t])!=null||(e[t]=[]),e[t].push(s[t])):n[t]=s[t];if(n.disabled||n["aria-disabled"])for(let s in e)/^(on(?:Click|Pointer|Mouse|Key)(?:Down|Up|Press)?)$/.test(s)&&(e[s]=[t=>{var l;return(l=t==null?void 0:t.preventDefault)==null?void 0:l.call(t)}]);for(let s in e)Object.assign(n,{[s](t,...l){let i=e[s];for(let o of i){if((t instanceof Event||(t==null?void 0:t.nativeEvent)instanceof Event)&&t.defaultPrevented)return;o(t,...l)}}});return n}function D(...r){var a;if(r.length===0)return{};if(r.length===1)return r[0];let n={},e={};for(let s of r)for(let t in s)t.startsWith("on")&&typeof s[t]=="function"?((a=e[t])!=null||(e[t]=[]),e[t].push(s[t])):n[t]=s[t];for(let s in e)Object.assign(n,{[s](...t){let l=e[s];for(let i of l)i==null||i(...t)}});return n}function W(r){var n;return Object.assign(j(r),{displayName:(n=r.displayName)!=null?n:r.name})}function m(r){let n=Object.assign({},r);for(let e in n)n[e]===void 0&&delete n[e];return n}function h(r,n=[]){let e=Object.assign({},r);for(let a of n)a in e&&delete e[a];return e}export{M as RenderFeatures,O as RenderStrategy,m as compact,W as forwardRefWithAs,D as mergeProps,H as render,I as useMergeRefsFn};
{
"name": "@headlessui/react",
"version": "0.0.0-insiders.f2c2d3c",
"version": "0.0.0-insiders.f2c80c4",
"description": "A set of completely unstyled, fully accessible UI components for React, designed to integrate beautifully with Tailwind CSS.",

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

"exports": {
"types": {
"import": "./dist/index.d.ts",
"require": "./dist/index.d.cts"
},
"import": "./dist/headlessui.esm.js",
"require": "./dist/index.cjs",
"types": "./dist/index.d.ts"
"require": "./dist/index.cjs"
},

@@ -38,18 +41,25 @@ "type": "module",

"lint": "../../scripts/lint.sh",
"playground": "yarn workspace playground-react dev",
"lint-types": "npm run attw -P --workspaces --if-present",
"playground": "npm run dev --workspace=playground-react",
"clean": "rimraf ./dist"
},
"peerDependencies": {
"react": "^16 || ^17 || ^18",
"react-dom": "^16 || ^17 || ^18"
"react": "^18",
"react-dom": "^18"
},
"devDependencies": {
"@testing-library/react": "^13.0.0",
"@types/react": "^17.0.43",
"@types/react-dom": "^17.0.14",
"esbuild": "^0.11.18",
"react": "^18.0.0",
"react-dom": "^18.0.0",
"snapshot-diff": "^0.8.1"
"@testing-library/react": "^15.0.7",
"@types/react": "^18.3.3",
"@types/react-dom": "^18.3.0",
"jsdom-testing-mocks": "^1.13.1",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"snapshot-diff": "^0.10.0"
},
"dependencies": {
"@floating-ui/react": "^0.26.16",
"@react-aria/focus": "^3.17.1",
"@react-aria/interactions": "^3.21.3",
"@tanstack/react-virtual": "^3.8.1"
}
}

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