import { HTMLAttributes, ReactElement } from 'react';
/**
* Search initial state model
*
* @author Nazarii Baran
*/
type SearchState = {
readonly selectedFilter?: string;
readonly selectedMoreFilters: boolean;
readonly isSearchFocused: boolean;
};
/**
* Search actions
*/
type SearchAction = {
type: 'SELECT_FILTER' | 'MORE_FILTERS' | 'FOCUS_SEARCH';
value?: string | boolean;
};
/**
* Filter model
*
* @author Nazarii Baran, Malik Alimoekhamedov
* @typedef
*/
type FilterModel = {
/** Title is required for Search Item components. */
readonly title: string;
/** Indicates if, at least, one filter value was modified. */
readonly isDirty?: boolean;
readonly component: ReactElement;
readonly onReset?: () => void;
};
/**
* Props for the 'Search' component.
*
* @author Nazarii Baran, Malik Alimoekhamedov
* @interface
*/
interface SearchProps extends HTMLAttributes {
readonly moreFiltersClassname?: string;
readonly isLoading?: boolean;
readonly filters?: {
/** Featured filters are extracted into their own items. */
readonly featured?: Record;
/** Standard filters are grouped into 'More Filters'. */
readonly standard?: Record;
};
readonly standardFiltersLabel?: string;
readonly searchButtonProps: {
readonly label?: string;
readonly onClick: () => void;
};
readonly resetButtonProps: {
readonly label?: string;
readonly onClick?: () => void;
};
readonly searchFieldProps: {
readonly onChange: (value: string) => void;
readonly onFocus?: (focused: boolean) => void;
readonly placeholder?: string;
readonly value: string;
};
readonly isLifted?: boolean;
readonly getMoreFilterToggleState?: (isToggled: boolean) => void;
}
export type { SearchProps, SearchState, SearchAction, FilterModel };