@backstage/plugin-search-react 1.1.0-next.2 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +356 -0
- package/dist/index.d.ts +314 -14
- package/dist/index.esm.js +353 -43
- package/dist/index.esm.js.map +1 -1
- package/package.json +10 -8
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import * as _backstage_core_plugin_api from '@backstage/core-plugin-api';
|
|
3
|
-
import { SearchQuery, SearchResultSet, SearchResult, SearchDocument, ResultHighlight } from '@backstage/plugin-search-common';
|
|
3
|
+
import { SearchQuery, SearchResultSet, SearchResult as SearchResult$1, SearchDocument, ResultHighlight } from '@backstage/plugin-search-common';
|
|
4
4
|
import React, { ForwardRefExoticComponent, ReactNode, ReactElement, PropsWithChildren } from 'react';
|
|
5
|
-
import { InputBaseProps, ListItemTextProps } from '@material-ui/core';
|
|
5
|
+
import { InputBaseProps, ListItemTextProps, ListProps, TypographyProps } from '@material-ui/core';
|
|
6
6
|
import { AutocompleteProps } from '@material-ui/lab';
|
|
7
|
-
import { JsonObject } from '@backstage/types';
|
|
8
7
|
import { AsyncState } from 'react-use/lib/useAsync';
|
|
8
|
+
import { JsonValue, JsonObject } from '@backstage/types';
|
|
9
|
+
import { LinkProps } from '@backstage/core-components';
|
|
9
10
|
|
|
10
11
|
/**
|
|
11
12
|
* @public
|
|
@@ -186,31 +187,330 @@ declare const SearchFilter: {
|
|
|
186
187
|
};
|
|
187
188
|
|
|
188
189
|
/**
|
|
189
|
-
* Props for {@link
|
|
190
|
-
*
|
|
190
|
+
* Props for {@link SearchResultContext}
|
|
191
191
|
* @public
|
|
192
192
|
*/
|
|
193
|
-
declare type
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
193
|
+
declare type SearchResultContextProps = {
|
|
194
|
+
/**
|
|
195
|
+
* A child function that receives an asynchronous result set and returns a react element.
|
|
196
|
+
*/
|
|
197
|
+
children: (state: AsyncState<SearchResultSet>) => JSX.Element;
|
|
197
198
|
};
|
|
198
199
|
/**
|
|
199
|
-
*
|
|
200
|
-
*
|
|
200
|
+
* Provides context-based results to a child function.
|
|
201
|
+
* @param props - see {@link SearchResultContextProps}.
|
|
202
|
+
* @example
|
|
203
|
+
* ```
|
|
204
|
+
* <SearchResultContext>
|
|
205
|
+
* {({ loading, error, value }) => (
|
|
206
|
+
* <List>
|
|
207
|
+
* {value?.map(({ document }) => (
|
|
208
|
+
* <DefaultSearchResultListItem
|
|
209
|
+
* key={document.location}
|
|
210
|
+
* result={document}
|
|
211
|
+
* />
|
|
212
|
+
* ))}
|
|
213
|
+
* </List>
|
|
214
|
+
* )}
|
|
215
|
+
* </SearchResultContext>
|
|
216
|
+
* ```
|
|
217
|
+
* @public
|
|
218
|
+
*/
|
|
219
|
+
declare const SearchResultContext: (props: SearchResultContextProps) => JSX.Element;
|
|
220
|
+
/**
|
|
221
|
+
* Props for {@link SearchResultApi}
|
|
201
222
|
* @public
|
|
202
223
|
*/
|
|
203
|
-
declare
|
|
224
|
+
declare type SearchResultApiProps = SearchResultContextProps & {
|
|
225
|
+
query: Partial<SearchQuery>;
|
|
226
|
+
};
|
|
227
|
+
/**
|
|
228
|
+
* Request results through the search api and provide them to a child function.
|
|
229
|
+
* @param props - see {@link SearchResultApiProps}.
|
|
230
|
+
* @example
|
|
231
|
+
* ```
|
|
232
|
+
* <SearchResultApi>
|
|
233
|
+
* {({ loading, error, value }) => (
|
|
234
|
+
* <List>
|
|
235
|
+
* {value?.map(({ document }) => (
|
|
236
|
+
* <DefaultSearchResultListItem
|
|
237
|
+
* key={document.location}
|
|
238
|
+
* result={document}
|
|
239
|
+
* />
|
|
240
|
+
* ))}
|
|
241
|
+
* </List>
|
|
242
|
+
* )}
|
|
243
|
+
* </SearchResultApi>
|
|
244
|
+
* ```
|
|
245
|
+
* @public
|
|
246
|
+
*/
|
|
247
|
+
declare const SearchResultApi: (props: SearchResultApiProps) => JSX.Element;
|
|
248
|
+
/**
|
|
249
|
+
* Props for {@link SearchResultState}
|
|
250
|
+
* @public
|
|
251
|
+
*/
|
|
252
|
+
declare type SearchResultStateProps = SearchResultContextProps & Partial<SearchResultApiProps>;
|
|
253
|
+
/**
|
|
254
|
+
* Call a child render function passing a search state as an argument.
|
|
255
|
+
* @remarks By default, results are taken from context, but when a "query" prop is set, results are requested from the search api.
|
|
256
|
+
* @param props - see {@link SearchResultStateProps}.
|
|
257
|
+
* @example
|
|
258
|
+
* Consuming results from context:
|
|
259
|
+
* ```
|
|
260
|
+
* <SearchResultState>
|
|
261
|
+
* {({ loading, error, value }) => (
|
|
262
|
+
* <List>
|
|
263
|
+
* {value?.map(({ document }) => (
|
|
264
|
+
* <DefaultSearchResultListItem
|
|
265
|
+
* key={document.location}
|
|
266
|
+
* result={document}
|
|
267
|
+
* />
|
|
268
|
+
* ))}
|
|
269
|
+
* </List>
|
|
270
|
+
* )}
|
|
271
|
+
* </SearchResultState>
|
|
272
|
+
* ```
|
|
273
|
+
* @example
|
|
274
|
+
* Requesting results using the search api:
|
|
275
|
+
* ```
|
|
276
|
+
* <SearchResultState query={{ term: 'documentation' }}>
|
|
277
|
+
* {({ loading, error, value }) => (
|
|
278
|
+
* <List>
|
|
279
|
+
* {value?.map(({ document }) => (
|
|
280
|
+
* <DefaultSearchResultListItem
|
|
281
|
+
* key={document.location}
|
|
282
|
+
* result={document}
|
|
283
|
+
* />
|
|
284
|
+
* ))}
|
|
285
|
+
* </List>
|
|
286
|
+
* )}
|
|
287
|
+
* </SearchResultState>
|
|
288
|
+
* ```
|
|
289
|
+
* @public
|
|
290
|
+
*/
|
|
291
|
+
declare const SearchResultState: (props: SearchResultStateProps) => JSX.Element;
|
|
292
|
+
/**
|
|
293
|
+
* Props for {@link SearchResult}
|
|
294
|
+
* @public
|
|
295
|
+
*/
|
|
296
|
+
declare type SearchResultProps = Pick<SearchResultStateProps, 'query'> & {
|
|
297
|
+
children: (resultSet: SearchResultSet) => JSX.Element;
|
|
298
|
+
};
|
|
204
299
|
/**
|
|
300
|
+
* Renders results from a parent search context or api.
|
|
301
|
+
* @remarks default components for loading, error and empty variants are returned.
|
|
302
|
+
* @param props - see {@link SearchResultProps}.
|
|
205
303
|
* @public
|
|
206
304
|
*/
|
|
207
|
-
declare const
|
|
305
|
+
declare const SearchResultComponent: (props: SearchResultProps) => JSX.Element;
|
|
306
|
+
/**
|
|
307
|
+
* A component returning the search result from a parent search context or api.
|
|
308
|
+
* @param props - see {@link SearchResultProps}.
|
|
309
|
+
* @public
|
|
310
|
+
*/
|
|
311
|
+
declare const SearchResult: (props: SearchResultProps) => JSX.Element;
|
|
208
312
|
|
|
209
313
|
/**
|
|
210
314
|
* @public
|
|
211
315
|
*/
|
|
212
316
|
declare const SearchResultPager: () => JSX.Element;
|
|
213
317
|
|
|
318
|
+
/**
|
|
319
|
+
* Props for {@link SearchResultListLayout}
|
|
320
|
+
* @public
|
|
321
|
+
*/
|
|
322
|
+
declare type SearchResultListLayoutProps = ListProps & {
|
|
323
|
+
/**
|
|
324
|
+
* Search results to be rendered as a list.
|
|
325
|
+
*/
|
|
326
|
+
resultItems?: SearchResult$1[];
|
|
327
|
+
/**
|
|
328
|
+
* Function to customize how result items are rendered.
|
|
329
|
+
*/
|
|
330
|
+
renderResultItem?: (resultItem: SearchResult$1) => JSX.Element;
|
|
331
|
+
/**
|
|
332
|
+
* If defined, will render a default error panel.
|
|
333
|
+
*/
|
|
334
|
+
error?: Error;
|
|
335
|
+
/**
|
|
336
|
+
* If defined, will render a default loading progress.
|
|
337
|
+
*/
|
|
338
|
+
loading?: boolean;
|
|
339
|
+
};
|
|
340
|
+
/**
|
|
341
|
+
* Default layout for rendering search results in a list.
|
|
342
|
+
* @param props - See {@link SearchResultListLayoutProps}.
|
|
343
|
+
* @public
|
|
344
|
+
*/
|
|
345
|
+
declare const SearchResultListLayout: (props: SearchResultListLayoutProps) => JSX.Element;
|
|
346
|
+
/**
|
|
347
|
+
* Props for {@link SearchResultList}.
|
|
348
|
+
* @public
|
|
349
|
+
*/
|
|
350
|
+
declare type SearchResultListProps = Omit<SearchResultListLayoutProps, 'loading' | 'error' | 'resultItems'> & {
|
|
351
|
+
/**
|
|
352
|
+
* A search query used for requesting the results to be listed.
|
|
353
|
+
*/
|
|
354
|
+
query: Partial<SearchQuery>;
|
|
355
|
+
};
|
|
356
|
+
/**
|
|
357
|
+
* Given a query, search for results and render them as a list.
|
|
358
|
+
* @param props - See {@link SearchResultListProps}.
|
|
359
|
+
* @public
|
|
360
|
+
*/
|
|
361
|
+
declare const SearchResultList: (props: SearchResultListProps) => JSX.Element;
|
|
362
|
+
|
|
363
|
+
/**
|
|
364
|
+
* Props for {@link SearchResultGroupFilterFieldLayout}
|
|
365
|
+
* @public
|
|
366
|
+
*/
|
|
367
|
+
declare type SearchResultGroupFilterFieldLayoutProps = PropsWithChildren<{
|
|
368
|
+
label: string;
|
|
369
|
+
value?: JsonValue;
|
|
370
|
+
onDelete: () => void;
|
|
371
|
+
}>;
|
|
372
|
+
/**
|
|
373
|
+
* Default layout for a search group filter field.
|
|
374
|
+
* @param props - See {@link SearchResultGroupFilterFieldLayoutProps}.
|
|
375
|
+
* @public
|
|
376
|
+
*/
|
|
377
|
+
declare const SearchResultGroupFilterFieldLayout: (props: SearchResultGroupFilterFieldLayoutProps) => JSX.Element;
|
|
378
|
+
/**
|
|
379
|
+
* Common props for a result group filter field.
|
|
380
|
+
* @public
|
|
381
|
+
*/
|
|
382
|
+
declare type SearchResultGroupFilterFieldPropsWith<T> = T & SearchResultGroupFilterFieldLayoutProps & {
|
|
383
|
+
onChange: (value: JsonValue) => void;
|
|
384
|
+
};
|
|
385
|
+
/**
|
|
386
|
+
* Props for {@link SearchResultGroupTextFilterField}.
|
|
387
|
+
* @public
|
|
388
|
+
*/
|
|
389
|
+
declare type SearchResultGroupTextFilterFieldProps = SearchResultGroupFilterFieldPropsWith<{}>;
|
|
390
|
+
/**
|
|
391
|
+
* A text field that can be used as filter on search result groups.
|
|
392
|
+
* @param props - See {@link SearchResultGroupTextFilterFieldProps}.
|
|
393
|
+
* @example
|
|
394
|
+
* ```
|
|
395
|
+
* <SearchResultGroupTextFilterField
|
|
396
|
+
* id="lifecycle"
|
|
397
|
+
* label="Lifecycle"
|
|
398
|
+
* value={value}
|
|
399
|
+
* onChange={handleChangeFilter}
|
|
400
|
+
* onDelete={handleDeleteFilter}
|
|
401
|
+
* />
|
|
402
|
+
* ```
|
|
403
|
+
* @public
|
|
404
|
+
*/
|
|
405
|
+
declare const SearchResultGroupTextFilterField: (props: SearchResultGroupTextFilterFieldProps) => JSX.Element;
|
|
406
|
+
/**
|
|
407
|
+
* Props for {@link SearchResultGroupTextFilterField}.
|
|
408
|
+
* @public
|
|
409
|
+
*/
|
|
410
|
+
declare type SearchResultGroupSelectFilterFieldProps = SearchResultGroupFilterFieldPropsWith<{
|
|
411
|
+
children: ReactNode;
|
|
412
|
+
}>;
|
|
413
|
+
/**
|
|
414
|
+
* A select field that can be used as filter on search result groups.
|
|
415
|
+
* @param props - See {@link SearchResultGroupSelectFilterFieldProps}.
|
|
416
|
+
* @example
|
|
417
|
+
* ```
|
|
418
|
+
* <SearchResultGroupSelectFilterField
|
|
419
|
+
* id="lifecycle"
|
|
420
|
+
* label="Lifecycle"
|
|
421
|
+
* value={filters.lifecycle}
|
|
422
|
+
* onChange={handleChangeFilter}
|
|
423
|
+
* onDelete={handleDeleteFilter}
|
|
424
|
+
* >
|
|
425
|
+
* <MenuItem value="experimental">Experimental</MenuItem>
|
|
426
|
+
* <MenuItem value="production">Production</MenuItem>
|
|
427
|
+
* </SearchResultGroupSelectFilterField>
|
|
428
|
+
* ```
|
|
429
|
+
* @public
|
|
430
|
+
*/
|
|
431
|
+
declare const SearchResultGroupSelectFilterField: (props: SearchResultGroupSelectFilterFieldProps) => JSX.Element;
|
|
432
|
+
/**
|
|
433
|
+
* Props for {@link SearchResultGroupLayout}
|
|
434
|
+
* @public
|
|
435
|
+
*/
|
|
436
|
+
declare type SearchResultGroupLayoutProps<FilterOption> = ListProps & {
|
|
437
|
+
/**
|
|
438
|
+
* Icon that representing a result group.
|
|
439
|
+
*/
|
|
440
|
+
icon: JSX.Element;
|
|
441
|
+
/**
|
|
442
|
+
* The results group title content, it could be a text or an element.
|
|
443
|
+
*/
|
|
444
|
+
title: ReactNode;
|
|
445
|
+
/**
|
|
446
|
+
* Props for the results group title.
|
|
447
|
+
*/
|
|
448
|
+
titleProps?: Partial<TypographyProps>;
|
|
449
|
+
/**
|
|
450
|
+
* The results group link content, it could be a text or an element.
|
|
451
|
+
*/
|
|
452
|
+
link?: ReactNode;
|
|
453
|
+
/**
|
|
454
|
+
* Props for the results group link, the "to" prop defaults to "/search".
|
|
455
|
+
*/
|
|
456
|
+
linkProps?: Partial<LinkProps>;
|
|
457
|
+
/**
|
|
458
|
+
* A generic filter options that is rendered on the "Add filter" dropdown.
|
|
459
|
+
*/
|
|
460
|
+
filterOptions?: FilterOption[];
|
|
461
|
+
/**
|
|
462
|
+
* Function to customize how filter options are rendered.
|
|
463
|
+
* @remarks Defaults to a menu item where its value and label bounds to the option string.
|
|
464
|
+
*/
|
|
465
|
+
renderFilterOption?: (filterOption: FilterOption) => JSX.Element;
|
|
466
|
+
/**
|
|
467
|
+
* A list of search filter keys, also known as filter field names.
|
|
468
|
+
*/
|
|
469
|
+
filterFields?: string[];
|
|
470
|
+
/**
|
|
471
|
+
* Function to customize how filter chips are rendered.
|
|
472
|
+
*/
|
|
473
|
+
renderFilterField?: (key: string) => JSX.Element | null;
|
|
474
|
+
/**
|
|
475
|
+
* Search results to be rendered as a group.
|
|
476
|
+
*/
|
|
477
|
+
resultItems?: SearchResult$1[];
|
|
478
|
+
/**
|
|
479
|
+
* Function to customize how result items are rendered.
|
|
480
|
+
*/
|
|
481
|
+
renderResultItem?: (resultItem: SearchResult$1) => JSX.Element;
|
|
482
|
+
/**
|
|
483
|
+
* If defined, will render a default error panel.
|
|
484
|
+
*/
|
|
485
|
+
error?: Error;
|
|
486
|
+
/**
|
|
487
|
+
* If defined, will render a default loading progress.
|
|
488
|
+
*/
|
|
489
|
+
loading?: boolean;
|
|
490
|
+
};
|
|
491
|
+
/**
|
|
492
|
+
* Default layout for rendering search results in a group.
|
|
493
|
+
* @param props - See {@link SearchResultGroupLayoutProps}.
|
|
494
|
+
* @public
|
|
495
|
+
*/
|
|
496
|
+
declare function SearchResultGroupLayout<FilterOption>(props: SearchResultGroupLayoutProps<FilterOption>): JSX.Element;
|
|
497
|
+
/**
|
|
498
|
+
* Props for {@link SearchResultGroup}.
|
|
499
|
+
* @public
|
|
500
|
+
*/
|
|
501
|
+
declare type SearchResultGroupProps<FilterOption> = Omit<SearchResultGroupLayoutProps<FilterOption>, 'loading' | 'error' | 'resultItems' | 'filterFields'> & {
|
|
502
|
+
/**
|
|
503
|
+
* A search query used for requesting the results to be grouped.
|
|
504
|
+
*/
|
|
505
|
+
query: Partial<SearchQuery>;
|
|
506
|
+
};
|
|
507
|
+
/**
|
|
508
|
+
* Given a query, search for results and render them as a group.
|
|
509
|
+
* @param props - See {@link SearchResultGroupProps}.
|
|
510
|
+
* @public
|
|
511
|
+
*/
|
|
512
|
+
declare function SearchResultGroup<FilterOption>(props: SearchResultGroupProps<FilterOption>): JSX.Element;
|
|
513
|
+
|
|
214
514
|
/**
|
|
215
515
|
* Props for {@link DefaultResultListItem}
|
|
216
516
|
*
|
|
@@ -295,4 +595,4 @@ declare type SearchContextProviderProps = PropsWithChildren<{
|
|
|
295
595
|
*/
|
|
296
596
|
declare const SearchContextProvider: (props: SearchContextProviderProps) => JSX.Element;
|
|
297
597
|
|
|
298
|
-
export { AutocompleteFilter, CheckboxFilter, HigherOrderDefaultResultListItem as DefaultResultListItem, DefaultResultListItemProps, HighlightedSearchResultText, HighlightedSearchResultTextProps, MockSearchApi, SearchApi, SearchAutocomplete, SearchAutocompleteComponent, SearchAutocompleteDefaultOption, SearchAutocompleteDefaultOptionProps, SearchAutocompleteFilterProps, SearchAutocompleteProps, SearchBar, SearchBarBase, SearchBarBaseProps, SearchBarProps, SearchContextProvider, SearchContextProviderProps, SearchContextState, SearchContextValue, SearchFilter, SearchFilterComponentProps, SearchFilterWrapperProps,
|
|
598
|
+
export { AutocompleteFilter, CheckboxFilter, HigherOrderDefaultResultListItem as DefaultResultListItem, DefaultResultListItemProps, HighlightedSearchResultText, HighlightedSearchResultTextProps, MockSearchApi, SearchApi, SearchAutocomplete, SearchAutocompleteComponent, SearchAutocompleteDefaultOption, SearchAutocompleteDefaultOptionProps, SearchAutocompleteFilterProps, SearchAutocompleteProps, SearchBar, SearchBarBase, SearchBarBaseProps, SearchBarProps, SearchContextProvider, SearchContextProviderProps, SearchContextState, SearchContextValue, SearchFilter, SearchFilterComponentProps, SearchFilterWrapperProps, SearchResult, SearchResultApi, SearchResultApiProps, SearchResultComponent, SearchResultContext, SearchResultContextProps, SearchResultGroup, SearchResultGroupFilterFieldLayout, SearchResultGroupFilterFieldLayoutProps, SearchResultGroupFilterFieldPropsWith, SearchResultGroupLayout, SearchResultGroupLayoutProps, SearchResultGroupProps, SearchResultGroupSelectFilterField, SearchResultGroupSelectFilterFieldProps, SearchResultGroupTextFilterField, SearchResultGroupTextFilterFieldProps, SearchResultList, SearchResultListLayout, SearchResultListLayoutProps, SearchResultListProps, SearchResultPager, SearchResultProps, SearchResultState, SearchResultStateProps, SelectFilter, searchApiRef, useSearch, useSearchContextCheck };
|