Skip to content

Commit

Permalink
feat: Exported the useAutoComplete hook
Browse files Browse the repository at this point in the history
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 cac5cd1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
3 changes: 3 additions & 0 deletions packages/autocomplete/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
10 changes: 5 additions & 5 deletions packages/autocomplete/src/useAutoComplete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ type EventHandlers = Pick<
"onBlur" | "onFocus" | "onChange" | "onClick" | "onKeyDown"
>;

type RequiredAutoCompleteProps = Required<
export type RequiredAutoCompleteProps = Required<
Pick<
AutoCompleteProps,
| "data"
Expand All @@ -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,
Expand All @@ -69,7 +69,7 @@ interface AutoCompleteOptions
defaultValue?: string;
}

interface ReturnValue {
export interface AutoCompleteReturnValue {
ref: (instance: HTMLInputElement | null) => void;
match: string;
value: string;
Expand Down Expand Up @@ -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) => {
Expand Down

0 comments on commit cac5cd1

Please sign in to comment.