@helpwave/hightide
Version:
helpwave's component and theming library
42 lines (39 loc) • 1.62 kB
text/typescript
import * as react_jsx_runtime from 'react/jsx-runtime';
import { ReactNode } from 'react';
import { LabelProps } from './Label.mjs';
import { MenuProps, MenuBag } from './Menu.mjs';
import { UseSearchProps } from '../../hooks/useSearch.mjs';
import '../../util/PropsWithFunctionChildren.mjs';
import '../../hooks/usePopoverPosition.mjs';
type SelectOption<T> = {
label: ReactNode;
value: T;
searchTags?: string[];
disabled?: boolean;
className?: string;
};
type SelectBag<T> = MenuBag & {
selected?: T;
search: string;
};
type SelectProps<T> = Omit<MenuProps<HTMLButtonElement>, 'trigger' | 'children'> & {
value?: T;
label?: LabelProps;
options: SelectOption<T>[];
onChange: (value: T) => void;
hintText?: string;
selectedDisplayOverwrite?: ReactNode;
searchOptions?: Omit<UseSearchProps<SelectOption<T>>, 'list' | 'searchMapping'>;
additionalItems?: (bag: SelectBag<T>) => ReactNode;
className?: string;
triggerClassName?: string;
hintTextClassName?: string;
};
/**
* A Select Component for selecting form a list of options
*
* The State is managed by the parent
*/
declare const Select: <T>({ value, label, options, onChange, hintText, selectedDisplayOverwrite, searchOptions, additionalItems, className, triggerClassName, hintTextClassName, ...menuProps }: SelectProps<T>) => react_jsx_runtime.JSX.Element;
declare const SelectUncontrolled: <T>({ options, onChange, value, hintText, ...props }: SelectProps<T>) => react_jsx_runtime.JSX.Element;
export { Select, type SelectBag, type SelectOption, type SelectProps, SelectUncontrolled };