Improve SearchContext api report

Signed-off-by: Vincenzo Scamporlino <me@vinzscam.dev>
This commit is contained in:
Vincenzo Scamporlino
2022-02-04 20:53:01 +01:00
parent eb1386e284
commit f903743142
5 changed files with 36 additions and 11 deletions
+11 -7
View File
@@ -145,9 +145,17 @@ export const SearchContextProvider: ({
initialState,
children,
}: React_2.PropsWithChildren<{
initialState?: SettableSearchContext | undefined;
initialState?: SearchContextState | undefined;
}>) => JSX.Element;
// @public
export type SearchContextState = {
term: string;
types: string[];
filters: JsonObject;
pageCursor?: string;
};
// Warning: (ae-missing-release-tag) "SearchFilter" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
@@ -201,6 +209,7 @@ export type SearchFilterWrapperProps = SearchFilterComponentProps & {
// @public (undocumented)
export const SearchModal: ({
open,
hidden,
toggleModal,
}: SearchModalProps) => JSX.Element;
@@ -208,9 +217,8 @@ export const SearchModal: ({
//
// @public (undocumented)
export interface SearchModalProps {
// (undocumented)
hidden?: boolean;
open?: boolean;
// (undocumented)
toggleModal: () => void;
}
@@ -319,8 +327,4 @@ export type SidebarSearchProps = {
//
// @public (undocumented)
export const useSearch: () => SearchContextValue;
// Warnings were encountered during analysis:
//
// src/components/SearchContext/SearchContext.d.ts:23:5 - (ae-forgotten-export) The symbol "SettableSearchContext" needs to be exported by the entry point index.d.ts
```
@@ -37,9 +37,14 @@ type SearchContextValue = {
setPageCursor: React.Dispatch<React.SetStateAction<string | undefined>>;
fetchNextPage?: React.DispatchWithoutAction;
fetchPreviousPage?: React.DispatchWithoutAction;
} & SettableSearchContext;
} & SearchContextState;
type SettableSearchContext = {
/**
* The initial state of `SearchContextProvider`.
*
* @public
*/
export type SearchContextState = {
term: string;
types: string[];
filters: JsonObject;
@@ -50,7 +55,7 @@ export const SearchContext = createContext<SearchContextValue | undefined>(
undefined,
);
const searchInitialState: SettableSearchContext = {
const searchInitialState: SearchContextState = {
term: '',
pageCursor: undefined,
filters: {},
@@ -60,7 +65,7 @@ const searchInitialState: SettableSearchContext = {
export const SearchContextProvider = ({
initialState = searchInitialState,
children,
}: PropsWithChildren<{ initialState?: SettableSearchContext }>) => {
}: PropsWithChildren<{ initialState?: SearchContextState }>) => {
const searchApi = useApi(searchApiRef);
const [pageCursor, setPageCursor] = useState<string | undefined>(
initialState.pageCursor,
@@ -19,3 +19,5 @@ export {
SearchContext,
useSearch,
} from './SearchContext';
export type { SearchContextState } from './SearchContext';
@@ -38,8 +38,21 @@ import { Link, useContent } from '@backstage/core-components';
import { rootRouteRef } from '../../plugin';
export interface SearchModalProps {
/**
* If true, it renders the modal.
*/
open?: boolean;
/**
* This is supposed to be used together with the open prop.
* If `hidden` is true, it hides the modal.
* If `open` is false, the value of `hidden` has no effect on the modal.
* Use `open` for controlling whether the modal should be rendered or not.
*/
hidden?: boolean;
/**
* a function invoked when a search item is pressed or when the dialog
* should be closed.
*/
toggleModal: () => void;
}
+1
View File
@@ -32,6 +32,7 @@ export type {
SearchBarProps,
} from './components/SearchBar';
export { SearchContextProvider, useSearch } from './components/SearchContext';
export type { SearchContextState } from './components/SearchContext';
export { SearchFilter, SearchFilterNext } from './components/SearchFilter';
export type {
SearchAutocompleteFilterProps,