Skip to content
Permalink
Browse files
feat: Exported the useAutoComplete hook
This isn't really documented, but might be helpful for different
situations if the AutoComplete component doesn't meet your needs.
  • Loading branch information
mlaursen committed Jul 12, 2020
1 parent e7a82ac commit cac5cd16a1452130ba600833c8ad1180d7ec4918
Showing 2 changed files with 8 additions and 5 deletions.
@@ -3,6 +3,9 @@ export { default as AutoComplete } from "./AutoComplete";
export { default as HighlightedResult } from "./HighlightedResult";
export * from "./HighlightedResult";

export { default as useAutoComplete } from "./useAutoComplete";
export * from "./useAutoComplete";

export {
isResultOf,
getResultId as DEFAULT_GET_RESULT_ID,
@@ -37,7 +37,7 @@ type EventHandlers = Pick<
"onBlur" | "onFocus" | "onChange" | "onClick" | "onKeyDown"
>;

type RequiredAutoCompleteProps = Required<
export type RequiredAutoCompleteProps = Required<
Pick<
AutoCompleteProps,
| "data"
@@ -51,12 +51,12 @@ type RequiredAutoCompleteProps = Required<
>
>;

type OptionalAutoCompleteProps = Pick<
export type OptionalAutoCompleteProps = Pick<
AutoCompleteProps,
"onAutoComplete" | "disableShowOnFocus"
>;

interface AutoCompleteOptions
export interface AutoCompleteOptions
extends EventHandlers,
OptionalAutoCompleteProps,
RequiredAutoCompleteProps,
@@ -69,7 +69,7 @@ interface AutoCompleteOptions
defaultValue?: string;
}

interface ReturnValue {
export interface AutoCompleteReturnValue {
ref: (instance: HTMLInputElement | null) => void;
match: string;
value: string;
@@ -128,7 +128,7 @@ export default function useAutoComplete({
disableShowOnFocus: propDisableShowOnFocus,
isListAutocomplete,
isInlineAutocomplete,
}: AutoCompleteOptions): ReturnValue {
}: AutoCompleteOptions): AutoCompleteReturnValue {
const inputRef = useRef<HTMLInputElement | null>(null);
const ref = useCallback(
(instance: HTMLInputElement | null) => {

0 comments on commit cac5cd1

Please sign in to comment.