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,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,164 @@
import { Machine } from '../../machine.js';
import type { EnsureArray } from '../../types.js';
import { Focus } from '../../utils/calculate-active-index.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;
__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
}
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;
};
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;
};
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<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;
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