@uva-glass/component-library
Version:
React components UvA
28 lines (27 loc) • 893 B
TypeScript
import { PropsWithChildren } from 'react';
export type SelectValue = string | number | null;
export type OptionValue = {
value: SelectValue;
label: string;
selectedLabel?: string;
disabled?: boolean;
};
export interface SelectListboxContext {
options: OptionValue[];
selectedValue: OptionValue;
setSelectedValue: (v: OptionValue) => void;
isOpen: boolean;
setIsOpen: (v: boolean) => void;
toggleListbox: () => void;
getValue: (value: SelectValue) => OptionValue;
activeIndex: number;
setActiveIndex: (v: number) => void;
listboxId: string;
}
interface Props {
options: OptionValue[];
defaultValue: SelectValue;
}
export declare const SelectProvider: ({ options, defaultValue, children }: PropsWithChildren<Props>) => import("react/jsx-runtime").JSX.Element;
export declare const useSelect: () => SelectListboxContext;
export {};