UNPKG

@bryancode/react-select

Version:

A customizable modular select built for React JS

43 lines (42 loc) 2.22 kB
import React, { ChangeEvent, CSSProperties } from 'react'; import { Configuration, InjectableComponents, OptionInterface, SelectRef } from "./types"; import { DropdownIcon, EmptyList, OptionContainer, Option } from './components'; export interface SelectProps<Option = OptionInterface> { placeholder?: string; value?: string | number; className?: string; selectClassName?: string; options?: Option[]; config?: Configuration; components?: InjectableComponents<OptionInterface>; onEmpty?: (text: string) => void; onChange?: (option?: OptionInterface) => void; onTextChange?: (text: string) => void; } export declare const positionContainerInElement: (rect: DOMRect) => CSSProperties; export declare function useSelect(props: SelectProps, outside?: boolean): { model: { open: boolean; text: string; current: OptionInterface<string, any> | undefined; containerClassNames: string; selectClassNames: string; filteredOptions: OptionInterface<string, any>[]; components: { Content: React.FC<import("./types").ContentRendererProps<OptionInterface<string, any>>> | React.ForwardRefExoticComponent<import("./types").ContentRendererProps<OptionInterface<string, any>> & React.RefAttributes<HTMLInputElement>>; Icon: React.FC<import("./types").DropdownIconProps> | typeof DropdownIcon; Container: React.FC<import("./types").OptionContainerProps<OptionInterface<string, any>>> | typeof OptionContainer; EmptyListComponent: React.FC<{}> | typeof EmptyList; OptionComponent: React.FC<import("./types").OptionProps<OptionInterface<string, any>>> | typeof Option; }; }; operations: { handleInputChange: (event: ChangeEvent<HTMLInputElement>) => void; toogleOpen: () => void; openDropdown: () => void; clearText: () => void; handleOptionSelected: (option: OptionInterface) => void; }; }; declare const _default: React.ForwardRefExoticComponent<SelectProps<OptionInterface<string, any>> & React.RefAttributes<SelectRef<OptionInterface<string, any>>>>; export default _default;