@baseplate-dev/ui-components
Version:
Shared UI component library
73 lines • 3.4 kB
TypeScript
import * as React from 'react';
interface ComboboxContextValue {
selectedValue: string | undefined | null;
selectedLabel: string | undefined | null;
onSelect: (value: string | null, label: string | undefined) => void;
searchQuery: string;
setSearchQuery: (query: string) => void;
setIsOpen: (open: boolean) => void;
isOpen: boolean;
inputId: string;
listRef: React.RefObject<HTMLDivElement | null>;
shouldShowItem: (label: string | null) => boolean;
disabled: boolean;
}
interface ComboboxOption {
label?: string;
value: string | null;
}
export interface ComboboxProps {
children: React.ReactNode;
value?: ComboboxOption | null;
onChange?: (value: ComboboxOption) => void;
searchQuery?: string;
onSearchQueryChange?: (query: string) => void;
label?: string;
disabled?: boolean;
}
/**
* A control that allows users to select an option from a list of options and type to search.
*/
declare function Combobox({ children, value: controlledValue, onChange, searchQuery: defaultSearchQuery, onSearchQueryChange, label, disabled, }: ComboboxProps): React.JSX.Element;
export declare function useComboboxContext(): ComboboxContextValue;
interface ComboboxInputProps extends Omit<React.ComponentPropsWithRef<'input'>, 'value'> {
selectedLabel?: string;
}
declare function ComboboxInput({ className, placeholder, ref, ...rest }: ComboboxInputProps): React.ReactElement;
interface ComboboxContentProps extends React.RefAttributes<HTMLDivElement> {
children?: React.ReactNode;
className?: string;
maxHeight?: string;
style?: React.CSSProperties;
}
declare function ComboboxContent({ children, className, maxHeight, style, ...rest }: ComboboxContentProps): React.JSX.Element;
type ComboboxEmptyProps = React.HTMLAttributes<HTMLDivElement>;
declare function ComboboxEmpty({ className, ...props }: ComboboxEmptyProps): React.ReactElement;
type ComboboxLoadingProps = React.HTMLAttributes<HTMLDivElement>;
declare function ComboboxLoading({ className, ...props }: ComboboxLoadingProps): React.ReactElement;
declare const ComboboxGroup: React.ForwardRefExoticComponent<{
children?: React.ReactNode;
} & Omit<Pick<Pick<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "key" | keyof React.HTMLAttributes<HTMLDivElement>> & {
ref?: React.Ref<HTMLDivElement>;
} & {
asChild?: boolean;
}, "key" | "asChild" | keyof React.HTMLAttributes<HTMLDivElement>>, "heading" | "value"> & {
heading?: React.ReactNode;
value?: string;
forceMount?: boolean;
} & React.RefAttributes<HTMLDivElement>>;
interface ComboboxItemProps extends Omit<React.ComponentPropsWithRef<'div'>, 'onSelect'> {
disabled?: boolean;
value: string | null;
label?: string;
}
declare function ComboboxItem({ value, className, label, children, ref, ...rest }: ComboboxItemProps): React.ReactElement;
interface ComboboxActionProps extends Omit<React.ComponentPropsWithRef<'div'>, 'onSelect' | 'onClick'> {
disabled?: boolean;
value: string;
label?: string;
onClick?: () => void;
}
declare function ComboboxAction({ value, className, children, onClick, ref, ...rest }: ComboboxActionProps): React.ReactElement;
export { Combobox, ComboboxAction, ComboboxContent, ComboboxEmpty, ComboboxGroup, ComboboxInput, ComboboxItem, ComboboxLoading, };
//# sourceMappingURL=combobox.d.ts.map