@sajari/sdk-react
Version:
React SDK for the Sajari API
61 lines (60 loc) • 2.67 kB
TypeScript
import { CSSObject } from "@emotion/core";
import * as React from "react";
import { Theme } from "../styles";
import { ResultRendererProps } from "./Results";
export declare type InputMode = "standard" | "typeahead";
export declare type DropdownMode = "none" | "suggestions" | "results";
export interface InputProps {
showClearButton?: boolean;
mode: InputMode;
dropdownMode: DropdownMode;
instantSearch?: boolean;
defaultValue?: string;
ariaLabel?: string;
placeholder?: string;
autoFocus?: boolean;
buttonText?: string;
experimental?: {
voiceToText?: boolean;
};
inputRef?: (element: HTMLInputElement) => void;
onKeyDown?: (event: React.KeyboardEvent<HTMLInputElement>) => void;
onFocus?: (event: React.FocusEvent<HTMLInputElement>) => void;
onBlur?: (event: React.FocusEvent<HTMLInputElement>) => void;
onChange?: (event: React.FormEvent<HTMLInputElement>) => void;
onSearch?: (query: string) => void;
ResultRenderer?: React.ComponentType<ResultRendererProps>;
className?: string;
theme?: Theme;
styles?: {
container?: CSSObject;
input?: (isFocused: boolean) => CSSObject;
typeahead?: CSSObject;
button?: CSSObject;
suggestions?: {
container?: CSSObject;
item?: (isFocused: boolean) => CSSObject;
};
};
}
interface InputState {
typedInputValue: string;
}
export declare class Input extends React.PureComponent<InputProps, InputState> {
static defaultProps: InputProps;
searchButtonRef: React.RefObject<HTMLButtonElement>;
voiceSearchButtonRef: React.RefObject<HTMLButtonElement>;
clearButtonRef: React.RefObject<HTMLButtonElement>;
inputRef: React.RefObject<HTMLInputElement>;
state: {
focused: boolean;
typedInputValue: string;
};
componentDidMount(): void;
getWidth(element: HTMLButtonElement | HTMLInputElement | null | undefined): number;
render(): JSX.Element;
private focusInput;
private stateReducer;
}
declare const _default: React.SFC<import("emotion-theming/types/helper").AddOptionalTo<Pick<InputProps & React.RefAttributes<Input>, "ref" | "key"> & Partial<Pick<InputProps & React.RefAttributes<Input>, "showClearButton" | "mode" | "dropdownMode" | "instantSearch" | "defaultValue" | "ariaLabel" | "placeholder" | "autoFocus" | "buttonText" | "experimental" | "inputRef" | "onKeyDown" | "onFocus" | "onBlur" | "onChange" | "onSearch" | "ResultRenderer" | "className" | "theme" | "styles">> & Partial<Pick<InputProps, never>>, "theme">>;
export default _default;