Last
Some checks are pending
Deploy Volleyball CMS / deploy (push) Waiting to run

This commit is contained in:
2025-06-02 18:56:22 +02:00
parent 8f62885a45
commit 33181acf83
1443 changed files with 286102 additions and 12 deletions

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,151 @@
import { Machine } from '../../machine.js';
import { Focus } from '../../utils/calculate-active-index.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;
buttonElement: HTMLButtonElement | null;
optionsElement: HTMLElement | null;
pendingShouldSort: boolean;
pendingFocus: {
focus: Exclude<Focus, Focus.Specific>;
} | {
focus: Focus.Specific;
id: string;
};
}
export declare enum ActionTypes {
OpenListbox = 0,
CloseListbox = 1,
GoToOption = 2,
Search = 3,
ClearSearch = 4,
RegisterOptions = 5,
UnregisterOptions = 6,
SetButtonElement = 7,
SetOptionsElement = 8,
SortOptions = 9
}
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.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;
};
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: (id: string) => 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;
shouldScrollIntoView(state: State<T>, id: string): 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