UNPKG

@sajari/sdk-react

Version:
59 lines (58 loc) 2.99 kB
import { Result } from "@sajari/sdk-js"; import { ControllerStateAndHelpers, DownshiftProps, DownshiftState, StateChangeOptions as BaseStateChangeOptions } from "downshift"; import * as React from "react"; import { PaginateFn, SearchFn } from "../context/pipeline/context"; export declare type SearchStateAndHelpers = ControllerStateAndHelpers<any> & PipelineProps; export interface PipelineProps { search: SearchFn; instantSearch: SearchFn; paginate: PaginateFn; suggestions: string[]; results: Result[]; completion: string; summary: SummaryInterface | undefined; } export interface PipelineResponseInterface { [k: string]: string | number; } export interface SummaryInterface { queryValues: PipelineResponseInterface; values: PipelineResponseInterface; response: PipelineResponseInterface; } export interface StateChangeOptions<Item> extends BaseStateChangeOptions<Item> { } export interface SearchState<Item> extends DownshiftState<Item> { } declare type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>; export interface SearchProps<Item> extends Omit<DownshiftProps<Item>, "onChange" | "stateReducer" | "children"> { children: (args: SearchStateAndHelpers) => JSX.Element; defaultInputValue?: string; stateReducer?: (state: SearchState<Item>, changes: StateChangeOptions<Item>, pipeline: PipelineProps, defaultInputValue?: string) => Partial<StateChangeOptions<Item>>; onChange?: (selectedItem: Item, stateAndHelper: SearchState<Item> & PipelineProps) => void; } export declare class Search extends React.PureComponent<SearchProps<any>, {}> { static stateChangeTypes: { resetInput: string; unknown: import("downshift").StateChangeTypes.unknown; mouseUp: import("downshift").StateChangeTypes.mouseUp; itemMouseEnter: import("downshift").StateChangeTypes.itemMouseEnter; keyDownArrowUp: import("downshift").StateChangeTypes.keyDownArrowUp; keyDownArrowDown: import("downshift").StateChangeTypes.keyDownArrowDown; keyDownEscape: import("downshift").StateChangeTypes.keyDownEscape; keyDownEnter: import("downshift").StateChangeTypes.keyDownEnter; clickItem: import("downshift").StateChangeTypes.clickItem; blurInput: import("downshift").StateChangeTypes.blurInput; changeInput: import("downshift").StateChangeTypes.changeInput; keyDownSpaceButton: import("downshift").StateChangeTypes.keyDownSpaceButton; clickButton: import("downshift").StateChangeTypes.clickButton; blurButton: import("downshift").StateChangeTypes.blurButton; controlledPropUpdatedSelectedItem: import("downshift").StateChangeTypes.controlledPropUpdatedSelectedItem; touchStart: import("downshift").StateChangeTypes.touchStart; }; state: {}; render(): JSX.Element | null; private stateReducer; private onChange; } export default Search;