This commit is contained in:
nik
2025-10-03 22:27:28 +03:00
parent 829fad0e17
commit 871cf7e792
16520 changed files with 2967597 additions and 3 deletions

View File

@@ -0,0 +1,23 @@
import { type ElementType, type Ref } from 'react';
import type { Props } from '../../types.js';
import { type HasDisplayName, type RefProp } from '../../utils/render.js';
declare let DEFAULT_BUTTON_TAG: "button";
type ButtonRenderPropArg = {
disabled: boolean;
hover: boolean;
focus: boolean;
active: boolean;
autofocus: boolean;
};
type ButtonPropsWeControl = never;
export type ButtonProps<TTag extends ElementType = typeof DEFAULT_BUTTON_TAG> = Props<TTag, ButtonRenderPropArg, ButtonPropsWeControl, {
disabled?: boolean;
autoFocus?: boolean;
type?: 'button' | 'submit' | 'reset';
}>;
declare function ButtonFn<TTag extends ElementType = typeof DEFAULT_BUTTON_TAG>(props: ButtonProps<TTag>, ref: Ref<HTMLElement>): import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>> | null;
export interface _internal_ComponentButton extends HasDisplayName {
<TTag extends ElementType = typeof DEFAULT_BUTTON_TAG>(props: ButtonProps<TTag> & RefProp<typeof ButtonFn>): React.JSX.Element;
}
export declare let Button: _internal_ComponentButton;
export {};

View File

@@ -0,0 +1 @@
"use client";import{useFocusRing as y}from"@react-aria/focus";import{useHover as b}from"@react-aria/interactions";import{useActivePress as P}from'../../hooks/use-active-press.js';import{useSlot as B}from'../../hooks/use-slot.js';import{useDisabled as c}from'../../internal/disabled.js';import{forwardRefWithAs as A,mergeProps as g,useRender as _}from'../../utils/render.js';let R="button";function v(s,n){var r;let p=c(),{disabled:e=p||!1,autoFocus:t=!1,...o}=s,{isFocusVisible:a,focusProps:l}=y({autoFocus:t}),{isHovered:u,hoverProps:i}=b({isDisabled:e}),{pressed:T,pressProps:d}=P({disabled:e}),f=g({ref:n,type:(r=o.type)!=null?r:"button",disabled:e||void 0,autoFocus:t},l,i,d),m=B({disabled:e,hover:u,focus:a,active:T,autofocus:t});return _()({ourProps:f,theirProps:o,slot:m,defaultTag:R,name:"Button"})}let L=A(v);export{L as Button};

View File

@@ -0,0 +1,33 @@
import React, { type ElementType, type Ref } from 'react';
import type { Props } from '../../types.js';
import { type HasDisplayName, type RefProp } from '../../utils/render.js';
declare let DEFAULT_CHECKBOX_TAG: "span";
type CheckboxRenderPropArg = {
checked: boolean;
changing: boolean;
focus: boolean;
active: boolean;
hover: boolean;
autofocus: boolean;
disabled: boolean;
indeterminate: boolean;
};
type CheckboxPropsWeControl = 'aria-checked' | 'aria-describedby' | 'aria-disabled' | 'aria-labelledby' | 'role';
export type CheckboxProps<TTag extends ElementType = typeof DEFAULT_CHECKBOX_TAG, TType = string> = Props<TTag, CheckboxRenderPropArg, CheckboxPropsWeControl, {
value?: TType;
disabled?: boolean;
indeterminate?: boolean;
checked?: boolean;
defaultChecked?: boolean;
autoFocus?: boolean;
form?: string;
name?: string;
onChange?: (checked: boolean) => void;
tabIndex?: number;
}>;
declare function CheckboxFn<TTag extends ElementType = typeof DEFAULT_CHECKBOX_TAG, TType = any>(props: CheckboxProps<TTag, TType>, ref: Ref<HTMLElement>): React.JSX.Element;
export interface _internal_ComponentCheckbox extends HasDisplayName {
<TTag extends ElementType = typeof DEFAULT_CHECKBOX_TAG, TType = string>(props: CheckboxProps<TTag, TType> & RefProp<typeof CheckboxFn>): React.JSX.Element;
}
export declare let Checkbox: _internal_ComponentCheckbox;
export {};

View File

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

View File

@@ -0,0 +1,6 @@
import { type ElementType } from 'react';
import { type ButtonProps, type _internal_ComponentButton } from '../button/button.js';
declare let DEFAULT_BUTTON_TAG: "button";
export type CloseButtonProps<TTag extends ElementType = typeof DEFAULT_BUTTON_TAG> = ButtonProps<TTag>;
export declare let CloseButton: _internal_ComponentButton;
export {};

View File

@@ -0,0 +1 @@
"use client";import n from"react";import{useClose as T}from'../../internal/close-provider.js';import{forwardRefWithAs as p,mergeProps as r}from'../../utils/render.js';import{Button as s}from'../button/button.js';let i="button";function l(t,e){let o=T();return n.createElement(s,{ref:e,...r({onClick:o},t)})}let y=p(l);export{y as CloseButton};

View File

@@ -0,0 +1,2 @@
export type * from '../combobox/combobox.js';
export { ComboboxButton } from '../combobox/combobox.js';

View File

@@ -0,0 +1 @@
import{ComboboxButton as m}from'../combobox/combobox.js';export{m as ComboboxButton};

View File

@@ -0,0 +1,2 @@
export type * from '../combobox/combobox.js';
export { ComboboxInput } from '../combobox/combobox.js';

View File

@@ -0,0 +1 @@
import{ComboboxInput as m}from'../combobox/combobox.js';export{m as ComboboxInput};

View File

@@ -0,0 +1,2 @@
export type * from '../combobox/combobox.js';
export { ComboboxLabel } from '../combobox/combobox.js';

View File

@@ -0,0 +1 @@
import{ComboboxLabel as m}from'../combobox/combobox.js';export{m as ComboboxLabel};

View File

@@ -0,0 +1,2 @@
export type * from '../combobox/combobox.js';
export { ComboboxOption } from '../combobox/combobox.js';

View File

@@ -0,0 +1 @@
import{ComboboxOption as m}from'../combobox/combobox.js';export{m as ComboboxOption};

View File

@@ -0,0 +1,2 @@
export type * from '../combobox/combobox.js';
export { ComboboxOptions } from '../combobox/combobox.js';

View File

@@ -0,0 +1 @@
import{ComboboxOptions as m}from'../combobox/combobox.js';export{m as ComboboxOptions};

View File

@@ -0,0 +1,5 @@
/// <reference types="react" />
import { ComboboxMachine } from './combobox-machine.js';
export declare const ComboboxContext: import("react").Context<ComboboxMachine<unknown> | null>;
export declare function useComboboxMachineContext<T>(component: string): ComboboxMachine<T>;
export declare function useComboboxMachine({ id, virtual, __demoMode, }: Parameters<typeof ComboboxMachine.new>[0]): ComboboxMachine<any>;

View File

@@ -0,0 +1 @@
import{createContext as r,useContext as a,useMemo as m}from"react";import{useOnUnmount as c}from'../../hooks/use-on-unmount.js';import{ComboboxMachine as i}from'./combobox-machine.js';const u=r(null);function p(n){let o=a(u);if(o===null){let e=new Error(`<${n} /> is missing a parent <Combobox /> component.`);throw Error.captureStackTrace&&Error.captureStackTrace(e,b),e}return o}function b({id:n,virtual:o=null,__demoMode:e=!1}){let t=m(()=>i.new({id:n,virtual:o,__demoMode:e}),[]);return c(()=>t.dispose()),t}export{u as ComboboxContext,b as useComboboxMachine,p as useComboboxMachineContext};

View File

@@ -0,0 +1,170 @@
import { Machine } from '../../machine.js';
import type { EnsureArray } from '../../types.js';
import { Focus } from '../../utils/calculate-active-index.js';
import { ElementPositionState } from '../../utils/element-movement.js';
interface MutableRefObject<T> {
current: T;
}
export declare enum ComboboxState {
Open = 0,
Closed = 1
}
export declare enum ValueMode {
Single = 0,
Multi = 1
}
export declare enum ActivationTrigger {
Pointer = 0,
Focus = 1,
Other = 2
}
export type ComboboxOptionDataRef<T> = MutableRefObject<{
disabled: boolean;
value: T;
domRef: MutableRefObject<HTMLElement | null>;
order: number | null;
}>;
export interface State<T> {
id: string;
dataRef: MutableRefObject<{
value: unknown;
defaultValue: unknown;
disabled: boolean;
invalid: boolean;
mode: ValueMode;
immediate: boolean;
onChange: (value: T) => void;
onClose?: () => void;
compare(a: unknown, z: unknown): boolean;
isSelected(value: unknown): boolean;
virtual: {
options: T[];
disabled: (value: T) => boolean;
} | null;
calculateIndex(value: unknown): number;
__demoMode: boolean;
optionsPropsRef: MutableRefObject<{
static: boolean;
hold: boolean;
}>;
}>;
virtual: {
options: T[];
disabled: (value: unknown) => boolean;
} | null;
comboboxState: ComboboxState;
defaultToFirstOption: boolean;
options: {
id: string;
dataRef: ComboboxOptionDataRef<T>;
}[];
activeOptionIndex: number | null;
activationTrigger: ActivationTrigger;
isTyping: boolean;
inputElement: HTMLInputElement | null;
buttonElement: HTMLButtonElement | null;
optionsElement: HTMLElement | null;
inputPositionState: ElementPositionState;
__demoMode: boolean;
}
export declare enum ActionTypes {
OpenCombobox = 0,
CloseCombobox = 1,
GoToOption = 2,
SetTyping = 3,
RegisterOption = 4,
UnregisterOption = 5,
DefaultToFirstOption = 6,
SetActivationTrigger = 7,
UpdateVirtualConfiguration = 8,
SetInputElement = 9,
SetButtonElement = 10,
SetOptionsElement = 11,
MarkInputAsMoved = 12
}
type Actions<T> = {
type: ActionTypes.CloseCombobox;
} | {
type: ActionTypes.OpenCombobox;
} | {
type: ActionTypes.GoToOption;
focus: Focus.Specific;
idx: number;
trigger?: ActivationTrigger;
} | {
type: ActionTypes.SetTyping;
isTyping: boolean;
} | {
type: ActionTypes.GoToOption;
focus: Exclude<Focus, Focus.Specific>;
trigger?: ActivationTrigger;
} | {
type: ActionTypes.RegisterOption;
payload: {
id: string;
dataRef: ComboboxOptionDataRef<T>;
};
} | {
type: ActionTypes.UnregisterOption;
id: string;
} | {
type: ActionTypes.DefaultToFirstOption;
value: boolean;
} | {
type: ActionTypes.SetActivationTrigger;
trigger: ActivationTrigger;
} | {
type: ActionTypes.UpdateVirtualConfiguration;
options: T[];
disabled: ((value: any) => boolean) | null;
} | {
type: ActionTypes.SetInputElement;
element: HTMLInputElement | null;
} | {
type: ActionTypes.SetButtonElement;
element: HTMLButtonElement | null;
} | {
type: ActionTypes.SetOptionsElement;
element: HTMLElement | null;
} | {
type: ActionTypes.MarkInputAsMoved;
};
export declare class ComboboxMachine<T> extends Machine<State<T>, Actions<T>> {
static new<T, TMultiple extends boolean | undefined>({ id, virtual, __demoMode, }: {
id: string;
virtual?: {
options: TMultiple extends true ? EnsureArray<NoInfer<T>> : NoInfer<T>[];
disabled?: (value: TMultiple extends true ? EnsureArray<NoInfer<T>>[number] : NoInfer<T>) => boolean;
} | null;
__demoMode?: boolean;
}): ComboboxMachine<any>;
constructor(initialState: State<T>);
actions: {
onChange: (newValue: T) => void;
registerOption: (id: string, dataRef: ComboboxOptionDataRef<T>) => () => void;
goToOption: (focus: {
focus: Focus.Specific;
idx: number;
} | {
focus: Exclude<Focus, Focus.Specific>;
}, trigger?: ActivationTrigger) => void;
setIsTyping: (isTyping: boolean) => void;
closeCombobox: () => void;
openCombobox: () => void;
setActivationTrigger: (trigger: ActivationTrigger) => void;
selectActiveOption: () => void;
setInputElement: (element: HTMLInputElement | null) => void;
setButtonElement: (element: HTMLButtonElement | null) => void;
setOptionsElement: (element: HTMLElement | null) => void;
};
selectors: {
activeDescendantId: (state: State<T>) => string | undefined;
activeOptionIndex: (state: State<T>) => number | null;
activeOption: (state: State<T>) => T | null;
isActive: (state: State<T>, value: T, id: string) => boolean;
shouldScrollIntoView: (state: State<T>, value: T, id: string) => boolean;
didInputMove(state: State<T>): boolean;
};
reduce(state: Readonly<State<T>>, action: Actions<T>): State<T>;
}
export {};

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,139 @@
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;
invalid: boolean;
activeIndex: number | null;
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<TValue> : 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;
invalid?: 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;
invalid: boolean;
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;
invalid: boolean;
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;
option: any;
};
type OptionsPropsWeControl = 'aria-labelledby' | 'aria-multiselectable' | 'role' | 'tabIndex';
declare let OptionsRenderFeatures: number;
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>): React.JSX.Element;
}
export interface _internal_ComponentComboboxButton extends HasDisplayName {
<TTag extends ElementType = typeof DEFAULT_BUTTON_TAG>(props: ComboboxButtonProps<TTag> & RefProp<typeof ButtonFn>): React.JSX.Element;
}
export interface _internal_ComponentComboboxInput extends HasDisplayName {
<TType, TTag extends ElementType = typeof DEFAULT_INPUT_TAG>(props: ComboboxInputProps<TTag, TType> & RefProp<typeof InputFn>): React.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>): React.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>): React.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 {};

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,19 @@
import { type ElementType, type Ref } from 'react';
import type { Props } from '../../types.js';
import { type HasDisplayName, type RefProp } from '../../utils/render.js';
declare let DEFAULT_DATA_INTERACTIVE_TAG: import("react").ExoticComponent<{
children?: import("react").ReactNode;
}>;
type DataInteractiveRenderPropArg = {
hover: boolean;
focus: boolean;
active: boolean;
};
type DataInteractivePropsWeControl = never;
export type DataInteractiveProps<TTag extends ElementType = typeof DEFAULT_DATA_INTERACTIVE_TAG> = Props<TTag, DataInteractiveRenderPropArg, DataInteractivePropsWeControl, {}>;
declare function DataInteractiveFn<TTag extends ElementType = typeof DEFAULT_DATA_INTERACTIVE_TAG>(props: DataInteractiveProps<TTag>, ref: Ref<HTMLElement>): import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>> | null;
export interface _internal_ComponentDataInteractive extends HasDisplayName {
<TTag extends ElementType = typeof DEFAULT_DATA_INTERACTIVE_TAG>(props: DataInteractiveProps<TTag> & RefProp<typeof DataInteractiveFn>): React.JSX.Element;
}
export declare let DataInteractive: _internal_ComponentDataInteractive;
export {};

View File

@@ -0,0 +1 @@
"use client";import{useFocusRing as c}from"@react-aria/focus";import{useHover as A}from"@react-aria/interactions";import{Fragment as D}from"react";import{useActivePress as f}from'../../hooks/use-active-press.js';import{useSlot as v}from'../../hooks/use-slot.js';import{forwardRefWithAs as I,mergeProps as y,useRender as P}from'../../utils/render.js';let E=D;function d(t,r){let{...a}=t,e=!1,{isFocusVisible:o,focusProps:n}=c(),{isHovered:p,hoverProps:s}=A({isDisabled:e}),{pressed:i,pressProps:T}=f({disabled:e}),l=y({ref:r},n,s,T),m=v({hover:p,focus:o,active:i});return P()({ourProps:l,theirProps:a,slot:m,defaultTag:E,name:"DataInteractive"})}let b=I(d);export{b as DataInteractive};

View File

@@ -0,0 +1,25 @@
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?: {};
}
export declare function useDescribedBy(): string | undefined;
interface DescriptionProviderProps extends SharedData {
children: ReactNode;
value?: string | undefined;
}
export declare function useDescriptions(): [
string | undefined,
(props: DescriptionProviderProps) => React.JSX.Element
];
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>): React.JSX.Element;
}
export declare let Description: _internal_ComponentDescription;
export {};

View File

@@ -0,0 +1 @@
"use client";import m,{createContext as D,useContext as d,useMemo as u,useState as T}from"react";import{useEvent as P}from'../../hooks/use-event.js';import{useId as g}from'../../hooks/use-id.js';import{useIsoMorphicEffect as x}from'../../hooks/use-iso-morphic-effect.js';import{useSlot as y}from'../../hooks/use-slot.js';import{useSyncRefs as E}from'../../hooks/use-sync-refs.js';import{useDisabled as v}from'../../internal/disabled.js';import{forwardRefWithAs as R,useRender as S}from'../../utils/render.js';let a=D(null);a.displayName="DescriptionContext";function f(){let r=d(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 w(){var r,e;return(e=(r=d(a))==null?void 0:r.value)!=null?e:void 0}function H(){let[r,e]=T([]);return[r.length>0?r.join(" "):void 0,u(()=>function(t){let i=P(n=>(e(o=>[...o,n]),()=>e(o=>{let s=o.slice(),p=s.indexOf(n);return p!==-1&&s.splice(p,1),s}))),l=u(()=>({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 I="p";function C(r,e){let c=g(),t=v(),{id:i=`headlessui-description-${c}`,...l}=r,n=f(),o=E(e);x(()=>n.register(i),[i,n.register]);let s=y({...n.slot,disabled:t||!1}),p={ref:o,...n.props,id:i};return S()({ourProps:p,theirProps:l,slot:s,defaultTag:I,name:n.name||"Description"})}let _=R(C),M=Object.assign(_,{});export{M as Description,w as useDescribedBy,H as useDescriptions};

View File

@@ -0,0 +1,2 @@
export type * from '../dialog/dialog.js';
export { DialogDescription } from '../dialog/dialog.js';

View File

@@ -0,0 +1 @@
import{DialogDescription as r}from'../dialog/dialog.js';export{r as DialogDescription};

View File

@@ -0,0 +1,2 @@
export type * from '../dialog/dialog.js';
export { DialogPanel } from '../dialog/dialog.js';

View File

@@ -0,0 +1 @@
import{DialogPanel as e}from'../dialog/dialog.js';export{e as DialogPanel};

View File

@@ -0,0 +1,2 @@
export type * from '../dialog/dialog.js';
export { DialogTitle } from '../dialog/dialog.js';

View File

@@ -0,0 +1 @@
import{DialogTitle as i}from'../dialog/dialog.js';export{i as DialogTitle};

View File

@@ -0,0 +1,70 @@
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;
};
type DialogPropsWeControl = 'aria-describedby' | 'aria-labelledby' | 'aria-modal';
declare let DialogRenderFeatures: number;
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;
};
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;
};
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>): React.JSX.Element;
}
export interface _internal_ComponentDialogPanel extends HasDisplayName {
<TTag extends ElementType = typeof DEFAULT_PANEL_TAG>(props: DialogPanelProps<TTag> & RefProp<typeof PanelFn>): React.JSX.Element;
}
export interface _internal_ComponentDialogBackdrop extends HasDisplayName {
<TTag extends ElementType = typeof DEFAULT_BACKDROP_TAG>(props: DialogBackdropProps<TTag> & RefProp<typeof BackdropFn>): React.JSX.Element;
}
export interface _internal_ComponentDialogTitle extends HasDisplayName {
<TTag extends ElementType = typeof DEFAULT_TITLE_TAG>(props: DialogTitleProps<TTag> & RefProp<typeof TitleFn>): React.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 {};

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,2 @@
export type * from '../disclosure/disclosure.js';
export { DisclosureButton } from '../disclosure/disclosure.js';

View File

@@ -0,0 +1 @@
import{DisclosureButton as e}from'../disclosure/disclosure.js';export{e as DisclosureButton};

View File

@@ -0,0 +1,2 @@
export type * from '../disclosure/disclosure.js';
export { DisclosurePanel } from '../disclosure/disclosure.js';

View File

@@ -0,0 +1 @@
import{DisclosurePanel as r}from'../disclosure/disclosure.js';export{r as DisclosurePanel};

View File

@@ -0,0 +1,59 @@
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;
};
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;
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>): React.JSX.Element;
}
export interface _internal_ComponentDisclosureButton extends HasDisplayName {
<TTag extends ElementType = typeof DEFAULT_BUTTON_TAG>(props: DisclosureButtonProps<TTag> & RefProp<typeof ButtonFn>): React.JSX.Element;
}
export interface _internal_ComponentDisclosurePanel extends HasDisplayName {
<TTag extends ElementType = typeof DEFAULT_PANEL_TAG>(props: DisclosurePanelProps<TTag> & RefProp<typeof PanelFn>): React.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 {};

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,14 @@
import React, { type ElementType } from 'react';
import type { Props } from '../../types.js';
import { type HasDisplayName } from '../../utils/render.js';
declare let DEFAULT_FIELD_TAG: "div";
type FieldRenderPropArg = {};
type FieldPropsWeControl = never;
export type FieldProps<TTag extends ElementType = typeof DEFAULT_FIELD_TAG> = Props<TTag, FieldRenderPropArg, FieldPropsWeControl, {
disabled?: boolean;
}>;
export interface _internal_ComponentField extends HasDisplayName {
<TTag extends ElementType = typeof DEFAULT_FIELD_TAG>(props: FieldProps<TTag>): React.JSX.Element;
}
export declare let Field: _internal_ComponentField;
export {};

View File

@@ -0,0 +1 @@
"use client";import e from"react";import{useId as f}from'../../hooks/use-id.js';import{useSlot as P}from'../../hooks/use-slot.js';import{DisabledProvider as y,useDisabled as u}from'../../internal/disabled.js';import{FormFieldsProvider as D}from'../../internal/form-fields.js';import{IdProvider as v}from'../../internal/id.js';import{forwardRefWithAs as b,useRender as E}from'../../utils/render.js';import{useDescriptions as A}from'../description/description.js';import{useLabels as L}from'../label/label.js';let _="div";function c(d,l){let t=`headlessui-control-${f()}`,[p,s]=L(),[n,a]=A(),m=u(),{disabled:r=m||!1,...o}=d,i=P({disabled:r}),F={ref:l,disabled:r||void 0,"aria-disabled":r||void 0},T=E();return e.createElement(y,{value:r},e.createElement(s,{value:p},e.createElement(a,{value:n},e.createElement(v,{id:t},T({ourProps:F,theirProps:{...o,children:e.createElement(D,null,typeof o.children=="function"?o.children(i):o.children)},slot:i,defaultTag:_,name:"Field"})))))}let W=b(c);export{W as Field};

View File

@@ -0,0 +1,14 @@
import React, { type ElementType } from 'react';
import type { Props } from '../../types.js';
import { type HasDisplayName } from '../../utils/render.js';
declare let DEFAULT_FIELDSET_TAG: "fieldset";
type FieldsetRenderPropArg = {};
type FieldsetPropsWeControl = 'aria-labelledby' | 'aria-disabled' | 'role';
export type FieldsetProps<TTag extends ElementType = typeof DEFAULT_FIELDSET_TAG> = Props<TTag, FieldsetRenderPropArg, FieldsetPropsWeControl, {
disabled?: boolean;
}>;
export interface _internal_ComponentFieldset extends HasDisplayName {
<TTag extends ElementType = typeof DEFAULT_FIELDSET_TAG>(props: FieldsetProps<TTag>): React.JSX.Element;
}
export declare let Fieldset: _internal_ComponentFieldset;
export {};

View File

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

View File

@@ -0,0 +1,2 @@
export type * from '../focus-trap/focus-trap.js';
export { FocusTrapFeatures } from '../focus-trap/focus-trap.js';

View File

@@ -0,0 +1 @@
import{FocusTrapFeatures as p}from'../focus-trap/focus-trap.js';export{p as FocusTrapFeatures};

View File

@@ -0,0 +1,36 @@
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<Element>) | MutableRefObject<Set<MutableRefObject<Element | null>>>;
declare let DEFAULT_FOCUS_TRAP_TAG: "div";
export declare enum FocusTrapFeatures {
/** No features enabled for the focus trap. */
None = 0,
/** Ensure that we move focus initially into the container. */
InitialFocus = 1,
/** Ensure that pressing `Tab` and `Shift+Tab` is trapped within the container. */
TabLock = 2,
/** Ensure that programmatically moving focus outside of the container is disallowed. */
FocusLock = 4,
/** Ensure that we restore the focus when unmounting the focus trap. */
RestoreFocus = 8,
/** Initial focus should look for the `data-autofocus` */
AutoFocus = 16
}
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>): React.JSX.Element;
}
export declare let FocusTrap: _internal_ComponentFocusTrap & {
/** @deprecated use `FocusTrapFeatures` instead of `FocusTrap.features` */
features: typeof FocusTrapFeatures;
};
export {};

View File

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

View File

@@ -0,0 +1,23 @@
import { type ElementType, type Ref } from 'react';
import type { Props } from '../../types.js';
import { type HasDisplayName, type RefProp } from '../../utils/render.js';
declare let DEFAULT_INPUT_TAG: "input";
type InputRenderPropArg = {
disabled: boolean;
hover: boolean;
focus: boolean;
autofocus: boolean;
invalid: boolean;
};
type InputPropsWeControl = 'aria-labelledby' | 'aria-describedby';
export type InputProps<TTag extends ElementType = typeof DEFAULT_INPUT_TAG> = Props<TTag, InputRenderPropArg, InputPropsWeControl, {
disabled?: boolean;
invalid?: boolean;
autoFocus?: boolean;
}>;
declare function InputFn<TTag extends ElementType = typeof DEFAULT_INPUT_TAG>(props: InputProps<TTag>, ref: Ref<HTMLElement>): import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>> | null;
export interface _internal_ComponentInput extends HasDisplayName {
<TTag extends ElementType = typeof DEFAULT_INPUT_TAG>(props: InputProps<TTag> & RefProp<typeof InputFn>): React.JSX.Element;
}
export declare let Input: _internal_ComponentInput;
export {};

View File

@@ -0,0 +1 @@
"use client";import{useFocusRing as P}from"@react-aria/focus";import{useHover as c}from"@react-aria/interactions";import{useId as g}from'../../hooks/use-id.js';import{useSlot as v}from'../../hooks/use-slot.js';import{useDisabled as A}from'../../internal/disabled.js';import{useProvidedId as _}from'../../internal/id.js';import{forwardRefWithAs as R,mergeProps as D,useRender as E}from'../../utils/render.js';import{useDescribedBy as F}from'../description/description.js';import{useLabelledBy as U}from'../label/label.js';let x="input";function h(r,p){let n=g(),s=_(),a=A(),{id:l=s||`headlessui-input-${n}`,disabled:e=a||!1,autoFocus:o=!1,invalid:t=!1,...i}=r,d=U(),u=F(),{isFocused:f,focusProps:m}=P({autoFocus:o}),{isHovered:T,hoverProps:b}=c({isDisabled:e}),y=D({ref:p,id:l,"aria-labelledby":d,"aria-describedby":u,"aria-invalid":t?"true":void 0,disabled:e||void 0,autoFocus:o},m,b),I=v({disabled:e,invalid:t,hover:T,focus:f,autofocus:o});return E()({ourProps:y,theirProps:i,slot:I,defaultTag:x,name:"Input"})}let X=R(h);export{X as Input};

View File

@@ -0,0 +1,16 @@
export declare enum Keys {
Space = " ",
Enter = "Enter",
Escape = "Escape",
Backspace = "Backspace",
Delete = "Delete",
ArrowLeft = "ArrowLeft",
ArrowUp = "ArrowUp",
ArrowRight = "ArrowRight",
ArrowDown = "ArrowDown",
Home = "Home",
End = "End",
PageUp = "PageUp",
PageDown = "PageDown",
Tab = "Tab"
}

View File

@@ -0,0 +1 @@
var o=(r=>(r.Space=" ",r.Enter="Enter",r.Escape="Escape",r.Backspace="Backspace",r.Delete="Delete",r.ArrowLeft="ArrowLeft",r.ArrowUp="ArrowUp",r.ArrowRight="ArrowRight",r.ArrowDown="ArrowDown",r.Home="Home",r.End="End",r.PageUp="PageUp",r.PageDown="PageDown",r.Tab="Tab",r))(o||{});export{o as Keys};

View File

@@ -0,0 +1,36 @@
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?: 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({ inherit }?: {
inherit?: boolean | undefined;
}): [
string | undefined,
(props: LabelProviderProps & {
inherit?: boolean;
}) => React.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>): React.JSX.Element;
}
export declare let Label: _internal_ComponentLabel;
export {};

View File

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

View File

@@ -0,0 +1,12 @@
import React, { type ElementType } from 'react';
import type { Props } from '../../types.js';
import { type HasDisplayName } from '../../utils/render.js';
declare let DEFAULT_LEGEND_TAG: import('../label/label.js')._internal_ComponentLabel;
type LegendRenderPropArg = {};
type LegendPropsWeControl = never;
export type LegendProps<TTag extends ElementType = typeof DEFAULT_LEGEND_TAG> = Props<TTag, LegendRenderPropArg, LegendPropsWeControl, {}>;
export interface _internal_ComponentLegend extends HasDisplayName {
<TTag extends ElementType = typeof DEFAULT_LEGEND_TAG>(props: LegendProps<TTag>): React.JSX.Element;
}
export declare let Legend: _internal_ComponentLegend;
export {};

View File

@@ -0,0 +1 @@
"use client";import p from"react";import{forwardRefWithAs as r}from'../../utils/render.js';import{Label as e}from'../label/label.js';let a=e;function o(t,n){return p.createElement(e,{as:"div",ref:n,...t})}let d=r(o);export{d as Legend};

View File

@@ -0,0 +1,2 @@
export type * from '../listbox/listbox.js';
export { ListboxButton } from '../listbox/listbox.js';

View File

@@ -0,0 +1 @@
import{ListboxButton as x}from'../listbox/listbox.js';export{x as ListboxButton};

View File

@@ -0,0 +1,2 @@
export type * from '../listbox/listbox.js';
export { ListboxLabel } from '../listbox/listbox.js';

View File

@@ -0,0 +1 @@
import{ListboxLabel as x}from'../listbox/listbox.js';export{x as ListboxLabel};

View File

@@ -0,0 +1,2 @@
export type * from '../listbox/listbox.js';
export { ListboxOption } from '../listbox/listbox.js';

View File

@@ -0,0 +1 @@
import{ListboxOption as x}from'../listbox/listbox.js';export{x as ListboxOption};

View File

@@ -0,0 +1,2 @@
export type * from '../listbox/listbox.js';
export { ListboxOptions } from '../listbox/listbox.js';

View File

@@ -0,0 +1 @@
import{ListboxOptions as x}from'../listbox/listbox.js';export{x as ListboxOptions};

View File

@@ -0,0 +1,2 @@
export type * from '../listbox/listbox.js';
export { ListboxSelectedOption } from '../listbox/listbox.js';

View File

@@ -0,0 +1 @@
import{ListboxSelectedOption as e}from'../listbox/listbox.js';export{e as ListboxSelectedOption};

View File

@@ -0,0 +1,8 @@
/// <reference types="react" />
import { ListboxMachine } from './listbox-machine.js';
export declare const ListboxContext: import("react").Context<ListboxMachine<unknown> | null>;
export declare function useListboxMachineContext<T>(component: string): ListboxMachine<T>;
export declare function useListboxMachine({ id, __demoMode, }: {
id: string;
__demoMode?: boolean;
}): ListboxMachine<unknown>;

View File

@@ -0,0 +1 @@
import{createContext as n,useContext as r,useMemo as i}from"react";import{useOnUnmount as s}from'../../hooks/use-on-unmount.js';import{ListboxMachine as a}from'./listbox-machine.js';const c=n(null);function p(o){let e=r(c);if(e===null){let t=new Error(`<${o} /> is missing a parent <Listbox /> component.`);throw Error.captureStackTrace&&Error.captureStackTrace(t,u),t}return e}function u({id:o,__demoMode:e=!1}){let t=i(()=>a.new({id:o,__demoMode:e}),[]);return s(()=>t.dispose()),t}export{c as ListboxContext,u as useListboxMachine,p as useListboxMachineContext};

View File

@@ -0,0 +1,163 @@
import { Machine } from '../../machine.js';
import { Focus } from '../../utils/calculate-active-index.js';
import { ElementPositionState } from '../../utils/element-movement.js';
interface MutableRefObject<T> {
current: T;
}
export declare enum ListboxStates {
Open = 0,
Closed = 1
}
export declare enum ValueMode {
Single = 0,
Multi = 1
}
export declare enum ActivationTrigger {
Pointer = 0,
Other = 1
}
type ListboxOptionDataRef<T> = MutableRefObject<{
textValue?: string;
disabled: boolean;
value: T;
domRef: MutableRefObject<HTMLElement | null>;
}>;
interface State<T> {
id: string;
__demoMode: boolean;
dataRef: MutableRefObject<{
value: unknown;
disabled: boolean;
invalid: boolean;
mode: ValueMode;
orientation: 'horizontal' | 'vertical';
onChange: (value: T) => void;
compare(a: unknown, z: unknown): boolean;
isSelected(value: unknown): boolean;
optionsPropsRef: MutableRefObject<{
static: boolean;
hold: boolean;
}>;
listRef: MutableRefObject<Map<string, HTMLElement | null>>;
}>;
listboxState: ListboxStates;
options: {
id: string;
dataRef: ListboxOptionDataRef<T>;
}[];
searchQuery: string;
activeOptionIndex: number | null;
activationTrigger: ActivationTrigger;
frozenValue: boolean;
buttonElement: HTMLButtonElement | null;
optionsElement: HTMLElement | null;
pendingShouldSort: boolean;
pendingFocus: {
focus: Exclude<Focus, Focus.Specific>;
} | {
focus: Focus.Specific;
id: string;
};
buttonPositionState: ElementPositionState;
}
export declare enum ActionTypes {
OpenListbox = 0,
CloseListbox = 1,
GoToOption = 2,
Search = 3,
ClearSearch = 4,
SelectOption = 5,
RegisterOptions = 6,
UnregisterOptions = 7,
SetButtonElement = 8,
SetOptionsElement = 9,
SortOptions = 10,
MarkButtonAsMoved = 11
}
type Actions<T> = {
type: ActionTypes.CloseListbox;
} | {
type: ActionTypes.OpenListbox;
focus: {
focus: Exclude<Focus, Focus.Specific>;
} | {
focus: Focus.Specific;
id: string;
};
} | {
type: ActionTypes.GoToOption;
focus: Focus.Specific;
id: string;
trigger?: ActivationTrigger;
} | {
type: ActionTypes.GoToOption;
focus: Exclude<Focus, Focus.Specific>;
trigger?: ActivationTrigger;
} | {
type: ActionTypes.Search;
value: string;
} | {
type: ActionTypes.ClearSearch;
} | {
type: ActionTypes.SelectOption;
value: T;
} | {
type: ActionTypes.RegisterOptions;
options: {
id: string;
dataRef: ListboxOptionDataRef<T>;
}[];
} | {
type: ActionTypes.UnregisterOptions;
options: string[];
} | {
type: ActionTypes.SetButtonElement;
element: HTMLButtonElement | null;
} | {
type: ActionTypes.SetOptionsElement;
element: HTMLElement | null;
} | {
type: ActionTypes.SortOptions;
} | {
type: ActionTypes.MarkButtonAsMoved;
};
export declare class ListboxMachine<T> extends Machine<State<T>, Actions<T>> {
static new({ id, __demoMode }: {
id: string;
__demoMode?: boolean;
}): ListboxMachine<unknown>;
constructor(initialState: State<T>);
actions: {
onChange: (newValue: T) => void;
registerOption: (id: string, dataRef: ListboxOptionDataRef<T>) => void;
unregisterOption: (id: string) => void;
goToOption: (focus: {
focus: Focus.Specific;
id: string;
} | {
focus: Exclude<Focus, Focus.Specific>;
}, trigger?: ActivationTrigger | undefined) => void;
closeListbox: () => void;
openListbox: (focus: {
focus: Exclude<Focus, Focus.Specific>;
} | {
focus: Focus.Specific;
id: string;
}) => void;
selectActiveOption: () => void;
selectOption: (value: T) => void;
search: (value: string) => void;
clearSearch: () => void;
setButtonElement: (element: HTMLButtonElement | null) => void;
setOptionsElement: (element: HTMLElement | null) => void;
};
selectors: {
activeDescendantId(state: State<T>): string | undefined;
isActive(state: State<T>, id: string): boolean;
hasFrozenValue(state: State<T>): boolean;
shouldScrollIntoView(state: State<T>, id: string): boolean;
didButtonMove(state: State<T>): boolean;
};
reduce(state: Readonly<State<T>>, action: Actions<T>): State<T>;
}
export {};

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,121 @@
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;
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;
invalid: boolean;
hover: boolean;
focus: boolean;
autofocus: boolean;
open: boolean;
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;
};
type OptionsPropsWeControl = 'aria-activedescendant' | 'aria-labelledby' | 'aria-multiselectable' | 'aria-orientation' | 'role' | 'tabIndex';
declare let OptionsRenderFeatures: number;
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>): React.JSX.Element;
}
export interface _internal_ComponentListboxButton extends HasDisplayName {
<TTag extends ElementType = typeof DEFAULT_BUTTON_TAG>(props: ListboxButtonProps<TTag> & RefProp<typeof ButtonFn>): React.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>): React.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>): React.JSX.Element;
}
export interface _internal_ComponentListboxSelectedOption extends HasDisplayName {
<TTag extends ElementType = typeof DEFAULT_SELECTED_OPTION_TAG>(props: ListboxSelectedOptionProps<TTag> & RefProp<typeof SelectedFn>): React.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 {};

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,2 @@
export type * from '../menu/menu.js';
export { MenuButton } from '../menu/menu.js';

View File

@@ -0,0 +1 @@
import{MenuButton as t}from'../menu/menu.js';export{t as MenuButton};

View File

@@ -0,0 +1,2 @@
export type * from '../menu/menu.js';
export { MenuHeading } from '../menu/menu.js';

View File

@@ -0,0 +1 @@
import{MenuHeading as n}from'../menu/menu.js';export{n as MenuHeading};

View File

@@ -0,0 +1,2 @@
export type * from '../menu/menu.js';
export { MenuItem } from '../menu/menu.js';

View File

@@ -0,0 +1 @@
import{MenuItem as o}from'../menu/menu.js';export{o as MenuItem};

View File

@@ -0,0 +1,2 @@
export type * from '../menu/menu.js';
export { MenuItems } from '../menu/menu.js';

View File

@@ -0,0 +1 @@
import{MenuItems as o}from'../menu/menu.js';export{o as MenuItems};

View File

@@ -0,0 +1,2 @@
export type * from '../menu/menu.js';
export { MenuSection } from '../menu/menu.js';

View File

@@ -0,0 +1 @@
import{MenuSection as m}from'../menu/menu.js';export{m as MenuSection};

View File

@@ -0,0 +1,2 @@
export type * from '../menu/menu.js';
export { MenuSeparator } from '../menu/menu.js';

View File

@@ -0,0 +1 @@
import{MenuSeparator as o}from'../menu/menu.js';export{o as MenuSeparator};

View File

@@ -0,0 +1,8 @@
/// <reference types="react" />
import { MenuMachine } from './menu-machine.js';
export declare const MenuContext: import("react").Context<MenuMachine | null>;
export declare function useMenuMachineContext(component: string): MenuMachine;
export declare function useMenuMachine({ id, __demoMode }: {
id: string;
__demoMode?: boolean;
}): MenuMachine;

View File

@@ -0,0 +1 @@
import{createContext as r,useContext as o,useMemo as u}from"react";import{useOnUnmount as i}from'../../hooks/use-on-unmount.js';import{MenuMachine as c}from'./menu-machine.js';const a=r(null);function p(t){let n=o(a);if(n===null){let e=new Error(`<${t} /> is missing a parent <Menu /> component.`);throw Error.captureStackTrace&&Error.captureStackTrace(e,s),e}return n}function s({id:t,__demoMode:n=!1}){let e=u(()=>c.new({id:t,__demoMode:n}),[]);return i(()=>e.dispose()),e}export{a as MenuContext,s as useMenuMachine,p as useMenuMachineContext};

View File

@@ -0,0 +1,118 @@
import { Machine } from '../../machine.js';
import { Focus } from '../../utils/calculate-active-index.js';
import { ElementPositionState } from '../../utils/element-movement.js';
export declare enum MenuState {
Open = 0,
Closed = 1
}
export declare enum ActivationTrigger {
Pointer = 0,
Other = 1
}
export type MenuItemDataRef = {
current: {
textValue?: string;
disabled: boolean;
domRef: {
current: HTMLElement | null;
};
};
};
export interface State {
id: string;
__demoMode: boolean;
menuState: MenuState;
buttonElement: HTMLButtonElement | null;
itemsElement: HTMLElement | null;
items: {
id: string;
dataRef: MenuItemDataRef;
}[];
searchQuery: string;
activeItemIndex: number | null;
activationTrigger: ActivationTrigger;
pendingShouldSort: boolean;
pendingFocus: {
focus: Exclude<Focus, Focus.Specific>;
} | {
focus: Focus.Specific;
id: string;
};
buttonPositionState: ElementPositionState;
}
export declare enum ActionTypes {
OpenMenu = 0,
CloseMenu = 1,
GoToItem = 2,
Search = 3,
ClearSearch = 4,
RegisterItems = 5,
UnregisterItems = 6,
SetButtonElement = 7,
SetItemsElement = 8,
SortItems = 9,
MarkButtonAsMoved = 10
}
export type Actions = {
type: ActionTypes.CloseMenu;
} | {
type: ActionTypes.OpenMenu;
focus: {
focus: Exclude<Focus, Focus.Specific>;
} | {
focus: Focus.Specific;
id: string;
};
trigger?: ActivationTrigger;
} | {
type: ActionTypes.GoToItem;
focus: Focus.Specific;
id: string;
trigger?: ActivationTrigger;
} | {
type: ActionTypes.GoToItem;
focus: Exclude<Focus, Focus.Specific>;
trigger?: ActivationTrigger;
} | {
type: ActionTypes.Search;
value: string;
} | {
type: ActionTypes.ClearSearch;
} | {
type: ActionTypes.RegisterItems;
items: {
id: string;
dataRef: MenuItemDataRef;
}[];
} | {
type: ActionTypes.UnregisterItems;
items: string[];
} | {
type: ActionTypes.SetButtonElement;
element: HTMLButtonElement | null;
} | {
type: ActionTypes.SetItemsElement;
element: HTMLElement | null;
} | {
type: ActionTypes.SortItems;
} | {
type: ActionTypes.MarkButtonAsMoved;
};
export declare class MenuMachine extends Machine<State, Actions> {
static new({ id, __demoMode }: {
id: string;
__demoMode?: boolean;
}): MenuMachine;
constructor(initialState: State);
reduce(state: Readonly<State>, action: Actions): State;
actions: {
registerItem: (id: string, dataRef: MenuItemDataRef) => void;
unregisterItem: (id: string) => void;
};
selectors: {
activeDescendantId(state: State): string | undefined;
isActive(state: State, id: string): boolean;
shouldScrollIntoView(state: State, id: string): boolean;
didButtonMove(state: State): boolean;
};
}

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,117 @@
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;
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;
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;
};
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>): React.JSX.Element;
}
export interface _internal_ComponentMenuButton extends HasDisplayName {
<TTag extends ElementType = typeof DEFAULT_BUTTON_TAG>(props: MenuButtonProps<TTag> & RefProp<typeof ButtonFn>): React.JSX.Element;
}
export interface _internal_ComponentMenuItems extends HasDisplayName {
<TTag extends ElementType = typeof DEFAULT_ITEMS_TAG>(props: MenuItemsProps<TTag> & RefProp<typeof ItemsFn>): React.JSX.Element;
}
export interface _internal_ComponentMenuItem extends HasDisplayName {
<TTag extends ElementType = typeof DEFAULT_ITEM_TAG>(props: MenuItemProps<TTag> & RefProp<typeof ItemFn>): React.JSX.Element;
}
export interface _internal_ComponentMenuSection extends HasDisplayName {
<TTag extends ElementType = typeof DEFAULT_SECTION_TAG>(props: MenuSectionProps<TTag> & RefProp<typeof SectionFn>): React.JSX.Element;
}
export interface _internal_ComponentMenuHeading extends HasDisplayName {
<TTag extends ElementType = typeof DEFAULT_HEADING_TAG>(props: MenuHeadingProps<TTag> & RefProp<typeof HeadingFn>): React.JSX.Element;
}
export interface _internal_ComponentMenuSeparator extends HasDisplayName {
<TTag extends ElementType = typeof DEFAULT_SEPARATOR_TAG>(props: MenuSeparatorProps<TTag> & RefProp<typeof SeparatorFn>): React.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 {};

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,4 @@
export declare enum MouseButton {
Left = 0,
Right = 2
}

View File

@@ -0,0 +1 @@
var g=(f=>(f[f.Left=0]="Left",f[f.Right=2]="Right",f))(g||{});export{g as MouseButton};

View File

@@ -0,0 +1,2 @@
export type * from '../popover/popover.js';
export { PopoverBackdrop } from '../popover/popover.js';

View File

@@ -0,0 +1 @@
import{PopoverBackdrop as r}from'../popover/popover.js';export{r as PopoverBackdrop};

View File

@@ -0,0 +1,2 @@
export type * from '../popover/popover.js';
export { PopoverButton } from '../popover/popover.js';

View File

@@ -0,0 +1 @@
import{PopoverButton as r}from'../popover/popover.js';export{r as PopoverButton};

View File

@@ -0,0 +1,2 @@
export type * from '../popover/popover.js';
export { PopoverGroup } from '../popover/popover.js';

View File

@@ -0,0 +1 @@
import{PopoverGroup as r}from'../popover/popover.js';export{r as PopoverGroup};

View File

@@ -0,0 +1,2 @@
export type * from '../popover/popover.js';
export { PopoverOverlay } from '../popover/popover.js';

View File

@@ -0,0 +1 @@
import{PopoverOverlay as r}from'../popover/popover.js';export{r as PopoverOverlay};

Some files were not shown because too many files have changed in this diff Show More