@backstage/plugin-search-react 1.2.2-next.0 → 1.2.2-next.1

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/dist/index.esm.js CHANGED
@@ -45,10 +45,7 @@ const HighlightedSearchResultText = ({
45
45
  [postTag, preTag, text]
46
46
  );
47
47
  return /* @__PURE__ */ React.createElement(React.Fragment, null, terms.map(
48
- (t, idx) => t.includes(preTag) ? /* @__PURE__ */ React.createElement("mark", {
49
- className: classes.highlight,
50
- key: idx
51
- }, t.replace(new RegExp(`${preTag}|${postTag}`, "g"), "")) : t
48
+ (t, idx) => t.includes(preTag) ? /* @__PURE__ */ React.createElement("mark", { className: classes.highlight, key: idx }, t.replace(new RegExp(`${preTag}|${postTag}`, "g"), "")) : t
52
49
  ));
53
50
  };
54
51
 
@@ -139,18 +136,18 @@ const useSearchContextValue = (initialValue = searchInitialState) => {
139
136
  const LocalSearchContext = (props) => {
140
137
  const { initialState, children } = props;
141
138
  const value = useSearchContextValue(initialState);
142
- return /* @__PURE__ */ React.createElement(AnalyticsContext, {
143
- attributes: { searchTypes: value.types.sort().join(",") }
144
- }, /* @__PURE__ */ React.createElement(SearchContext.Provider, {
145
- value: createVersionedValueMap({ 1: value })
146
- }, children));
139
+ return /* @__PURE__ */ React.createElement(
140
+ AnalyticsContext,
141
+ {
142
+ attributes: { searchTypes: value.types.sort().join(",") }
143
+ },
144
+ /* @__PURE__ */ React.createElement(SearchContext.Provider, { value: createVersionedValueMap({ 1: value }) }, children)
145
+ );
147
146
  };
148
147
  const SearchContextProvider = (props) => {
149
148
  const { initialState, inheritParentContextIfAvailable, children } = props;
150
149
  const hasParentContext = useSearchContextCheck();
151
- return hasParentContext && inheritParentContextIfAvailable ? /* @__PURE__ */ React.createElement(React.Fragment, null, children) : /* @__PURE__ */ React.createElement(LocalSearchContext, {
152
- initialState
153
- }, children);
150
+ return hasParentContext && inheritParentContextIfAvailable ? /* @__PURE__ */ React.createElement(React.Fragment, null, children) : /* @__PURE__ */ React.createElement(LocalSearchContext, { initialState }, children);
154
151
  };
155
152
 
156
153
  const TrackSearch = ({ children }) => {
@@ -165,12 +162,7 @@ const TrackSearch = ({ children }) => {
165
162
  };
166
163
 
167
164
  function withContext$1(Component) {
168
- return forwardRef((props, ref) => /* @__PURE__ */ React.createElement(SearchContextProvider, {
169
- inheritParentContextIfAvailable: true
170
- }, /* @__PURE__ */ React.createElement(Component, {
171
- ...props,
172
- ref
173
- })));
165
+ return forwardRef((props, ref) => /* @__PURE__ */ React.createElement(SearchContextProvider, { inheritParentContextIfAvailable: true }, /* @__PURE__ */ React.createElement(Component, { ...props, ref })));
174
166
  }
175
167
  const SearchBarBase = withContext$1(
176
168
  forwardRef((props, ref) => {
@@ -222,33 +214,24 @@ const SearchBarBase = withContext$1(
222
214
  }
223
215
  }, [onChange, onClear]);
224
216
  const placeholder = defaultPlaceholder != null ? defaultPlaceholder : `Search in ${configApi.getOptionalString("app.title") || "Backstage"}`;
225
- const startAdornment = /* @__PURE__ */ React.createElement(InputAdornment, {
226
- position: "start"
227
- }, /* @__PURE__ */ React.createElement(IconButton, {
228
- "aria-label": "Query",
229
- size: "small",
230
- disabled: true
231
- }, /* @__PURE__ */ React.createElement(SearchIcon, null)));
232
- const endAdornment = /* @__PURE__ */ React.createElement(InputAdornment, {
233
- position: "end"
234
- }, /* @__PURE__ */ React.createElement(IconButton, {
235
- "aria-label": "Clear",
236
- size: "small",
237
- onClick: handleClear
238
- }, /* @__PURE__ */ React.createElement(ClearButton, null)));
239
- return /* @__PURE__ */ React.createElement(TrackSearch, null, /* @__PURE__ */ React.createElement(InputBase, {
240
- "data-testid": "search-bar-next",
241
- ref,
242
- value,
243
- placeholder,
244
- startAdornment,
245
- endAdornment: clearButton ? endAdornment : defaultEndAdornment,
246
- inputProps: { "aria-label": "Search", ...defaultInputProps },
247
- fullWidth,
248
- onChange: handleChange,
249
- onKeyDown: handleKeyDown,
250
- ...rest
251
- }));
217
+ const startAdornment = /* @__PURE__ */ React.createElement(InputAdornment, { position: "start" }, /* @__PURE__ */ React.createElement(IconButton, { "aria-label": "Query", size: "small", disabled: true }, /* @__PURE__ */ React.createElement(SearchIcon, null)));
218
+ const endAdornment = /* @__PURE__ */ React.createElement(InputAdornment, { position: "end" }, /* @__PURE__ */ React.createElement(IconButton, { "aria-label": "Clear", size: "small", onClick: handleClear }, /* @__PURE__ */ React.createElement(ClearButton, null)));
219
+ return /* @__PURE__ */ React.createElement(TrackSearch, null, /* @__PURE__ */ React.createElement(
220
+ InputBase,
221
+ {
222
+ "data-testid": "search-bar-next",
223
+ ref,
224
+ value,
225
+ placeholder,
226
+ startAdornment,
227
+ endAdornment: clearButton ? endAdornment : defaultEndAdornment,
228
+ inputProps: { "aria-label": "Search", ...defaultInputProps },
229
+ fullWidth,
230
+ onChange: handleChange,
231
+ onKeyDown: handleKeyDown,
232
+ ...rest
233
+ }
234
+ ));
252
235
  })
253
236
  );
254
237
  const SearchBar = withContext$1(
@@ -270,23 +253,26 @@ const SearchBar = withContext$1(
270
253
  },
271
254
  [onChange, setTerm]
272
255
  );
273
- return /* @__PURE__ */ React.createElement(AnalyticsContext, {
274
- attributes: { pluginId: "search", extension: "SearchBar" }
275
- }, /* @__PURE__ */ React.createElement(SearchBarBase, {
276
- ...rest,
277
- ref,
278
- value: term,
279
- onChange: handleChange
280
- }));
256
+ return /* @__PURE__ */ React.createElement(
257
+ AnalyticsContext,
258
+ {
259
+ attributes: { pluginId: "search", extension: "SearchBar" }
260
+ },
261
+ /* @__PURE__ */ React.createElement(
262
+ SearchBarBase,
263
+ {
264
+ ...rest,
265
+ ref,
266
+ value: term,
267
+ onChange: handleChange
268
+ }
269
+ )
270
+ );
281
271
  })
282
272
  );
283
273
 
284
274
  const withContext = (Component) => {
285
- return (props) => /* @__PURE__ */ React.createElement(SearchContextProvider, {
286
- inheritParentContextIfAvailable: true
287
- }, /* @__PURE__ */ React.createElement(Component, {
288
- ...props
289
- }));
275
+ return (props) => /* @__PURE__ */ React.createElement(SearchContextProvider, { inheritParentContextIfAvailable: true }, /* @__PURE__ */ React.createElement(Component, { ...props }));
290
276
  };
291
277
  const SearchAutocomplete = withContext(
292
278
  function SearchAutocompleteComponent(props) {
@@ -332,33 +318,42 @@ const SearchAutocomplete = withContext(
332
318
  InputProps: { ref, endAdornment },
333
319
  InputLabelProps,
334
320
  ...params
335
- }) => /* @__PURE__ */ React.createElement(SearchBar, {
336
- ...params,
337
- ref,
338
- clearButton: false,
339
- value: inputValue,
340
- placeholder: inputPlaceholder,
341
- debounceTime: inputDebounceTime,
342
- endAdornment: loading ? /* @__PURE__ */ React.createElement(CircularProgress, {
343
- "data-testid": "search-autocomplete-progressbar",
344
- color: "inherit",
345
- size: 20
346
- }) : endAdornment
347
- }),
321
+ }) => /* @__PURE__ */ React.createElement(
322
+ SearchBar,
323
+ {
324
+ ...params,
325
+ ref,
326
+ clearButton: false,
327
+ value: inputValue,
328
+ placeholder: inputPlaceholder,
329
+ debounceTime: inputDebounceTime,
330
+ endAdornment: loading ? /* @__PURE__ */ React.createElement(
331
+ CircularProgress,
332
+ {
333
+ "data-testid": "search-autocomplete-progressbar",
334
+ color: "inherit",
335
+ size: 20
336
+ }
337
+ ) : endAdornment
338
+ }
339
+ ),
348
340
  [loading, inputValue, inputPlaceholder, inputDebounceTime]
349
341
  );
350
- return /* @__PURE__ */ React.createElement(Autocomplete, {
351
- ...rest,
352
- "data-testid": dataTestId,
353
- value,
354
- onChange: handleChange,
355
- options,
356
- getOptionLabel,
357
- renderInput,
358
- freeSolo,
359
- fullWidth,
360
- clearOnBlur
361
- });
342
+ return /* @__PURE__ */ React.createElement(
343
+ Autocomplete,
344
+ {
345
+ ...rest,
346
+ "data-testid": dataTestId,
347
+ value,
348
+ onChange: handleChange,
349
+ options,
350
+ getOptionLabel,
351
+ renderInput,
352
+ freeSolo,
353
+ fullWidth,
354
+ clearOnBlur
355
+ }
356
+ );
362
357
  }
363
358
  );
364
359
 
@@ -369,13 +364,16 @@ const SearchAutocompleteDefaultOption = ({
369
364
  secondaryText,
370
365
  secondaryTextTypographyProps,
371
366
  disableTextTypography
372
- }) => /* @__PURE__ */ React.createElement(React.Fragment, null, icon ? /* @__PURE__ */ React.createElement(ListItemIcon, null, icon) : null, /* @__PURE__ */ React.createElement(ListItemText, {
373
- primary: primaryText,
374
- primaryTypographyProps: primaryTextTypographyProps,
375
- secondary: secondaryText,
376
- secondaryTypographyProps: secondaryTextTypographyProps,
377
- disableTypography: disableTextTypography
378
- }));
367
+ }) => /* @__PURE__ */ React.createElement(React.Fragment, null, icon ? /* @__PURE__ */ React.createElement(ListItemIcon, null, icon) : null, /* @__PURE__ */ React.createElement(
368
+ ListItemText,
369
+ {
370
+ primary: primaryText,
371
+ primaryTypographyProps: primaryTextTypographyProps,
372
+ secondary: secondaryText,
373
+ secondaryTypographyProps: secondaryTextTypographyProps,
374
+ disableTypography: disableTextTypography
375
+ }
376
+ ));
379
377
 
380
378
  const useAsyncFilterValues = (fn, inputValue, defaultValues = [], debounce = 250) => {
381
379
  const valuesMemo = useRef({});
@@ -455,32 +453,34 @@ const AutocompleteFilter = (props) => {
455
453
  return { ...others };
456
454
  });
457
455
  };
458
- const renderInput = (params) => /* @__PURE__ */ React.createElement(TextField, {
459
- ...params,
460
- name: "search",
461
- variant: "outlined",
462
- label,
463
- fullWidth: true
464
- });
465
- const renderTags = (tagValue, getTagProps) => tagValue.map((option, index) => /* @__PURE__ */ React.createElement(Chip, {
466
- label: option,
467
- color: "primary",
468
- ...getTagProps({ index })
469
- }));
470
- return /* @__PURE__ */ React.createElement(Autocomplete, {
471
- filterSelectedOptions,
472
- limitTags,
473
- multiple,
474
- className,
475
- id: `${multiple ? "multi-" : ""}select-filter-${name}--select`,
476
- options: values || [],
477
- loading,
478
- value: filterValue,
479
- onChange: handleChange,
480
- onInputChange: (_, newValue) => setInputValue(newValue),
481
- renderInput,
482
- renderTags
483
- });
456
+ const renderInput = (params) => /* @__PURE__ */ React.createElement(
457
+ TextField,
458
+ {
459
+ ...params,
460
+ name: "search",
461
+ variant: "outlined",
462
+ label,
463
+ fullWidth: true
464
+ }
465
+ );
466
+ const renderTags = (tagValue, getTagProps) => tagValue.map((option, index) => /* @__PURE__ */ React.createElement(Chip, { label: option, color: "primary", ...getTagProps({ index }) }));
467
+ return /* @__PURE__ */ React.createElement(
468
+ Autocomplete,
469
+ {
470
+ filterSelectedOptions,
471
+ limitTags,
472
+ multiple,
473
+ className,
474
+ id: `${multiple ? "multi-" : ""}select-filter-${name}--select`,
475
+ options: values || [],
476
+ loading,
477
+ value: filterValue,
478
+ onChange: handleChange,
479
+ onInputChange: (_, newValue) => setInputValue(newValue),
480
+ renderInput,
481
+ renderTags
482
+ }
483
+ );
484
484
  };
485
485
 
486
486
  const useStyles$2 = makeStyles({
@@ -519,29 +519,38 @@ const CheckboxFilter = (props) => {
519
519
  return items.length ? { ...others, [name]: items } : others;
520
520
  });
521
521
  };
522
- return /* @__PURE__ */ React.createElement(FormControl, {
523
- className,
524
- disabled: loading,
525
- fullWidth: true,
526
- "data-testid": "search-checkboxfilter-next"
527
- }, label ? /* @__PURE__ */ React.createElement(FormLabel, {
528
- className: classes.label
529
- }, label) : null, values.map((value) => {
530
- var _a;
531
- return /* @__PURE__ */ React.createElement(FormControlLabel, {
532
- key: value,
533
- control: /* @__PURE__ */ React.createElement(Checkbox, {
534
- color: "primary",
535
- tabIndex: -1,
536
- inputProps: { "aria-labelledby": value },
537
- value,
538
- name: value,
539
- onChange: handleChange,
540
- checked: ((_a = filters[name]) != null ? _a : []).includes(value)
541
- }),
542
- label: value
543
- });
544
- }));
522
+ return /* @__PURE__ */ React.createElement(
523
+ FormControl,
524
+ {
525
+ className,
526
+ disabled: loading,
527
+ fullWidth: true,
528
+ "data-testid": "search-checkboxfilter-next"
529
+ },
530
+ label ? /* @__PURE__ */ React.createElement(FormLabel, { className: classes.label }, label) : null,
531
+ values.map((value) => {
532
+ var _a;
533
+ return /* @__PURE__ */ React.createElement(
534
+ FormControlLabel,
535
+ {
536
+ key: value,
537
+ control: /* @__PURE__ */ React.createElement(
538
+ Checkbox,
539
+ {
540
+ color: "primary",
541
+ tabIndex: -1,
542
+ inputProps: { "aria-labelledby": value },
543
+ value,
544
+ name: value,
545
+ onChange: handleChange,
546
+ checked: ((_a = filters[name]) != null ? _a : []).includes(value)
547
+ }
548
+ ),
549
+ label: value
550
+ }
551
+ );
552
+ })
553
+ );
545
554
  };
546
555
  const SelectFilter = (props) => {
547
556
  const {
@@ -572,44 +581,35 @@ const SelectFilter = (props) => {
572
581
  return value ? { ...others, [name]: value } : others;
573
582
  });
574
583
  };
575
- return /* @__PURE__ */ React.createElement(FormControl, {
576
- disabled: loading,
577
- className,
578
- variant: "filled",
579
- fullWidth: true,
580
- "data-testid": "search-selectfilter-next"
581
- }, label ? /* @__PURE__ */ React.createElement(InputLabel, {
582
- className: classes.label,
583
- margin: "dense"
584
- }, label) : null, /* @__PURE__ */ React.createElement(Select, {
585
- variant: "outlined",
586
- value: filters[name] || "",
587
- onChange: handleChange
588
- }, /* @__PURE__ */ React.createElement(MenuItem, {
589
- value: ""
590
- }, /* @__PURE__ */ React.createElement("em", null, "All")), values.map((value) => /* @__PURE__ */ React.createElement(MenuItem, {
591
- key: value,
592
- value
593
- }, value))));
584
+ return /* @__PURE__ */ React.createElement(
585
+ FormControl,
586
+ {
587
+ disabled: loading,
588
+ className,
589
+ variant: "filled",
590
+ fullWidth: true,
591
+ "data-testid": "search-selectfilter-next"
592
+ },
593
+ label ? /* @__PURE__ */ React.createElement(InputLabel, { className: classes.label, margin: "dense" }, label) : null,
594
+ /* @__PURE__ */ React.createElement(
595
+ Select,
596
+ {
597
+ variant: "outlined",
598
+ value: filters[name] || "",
599
+ onChange: handleChange
600
+ },
601
+ /* @__PURE__ */ React.createElement(MenuItem, { value: "" }, /* @__PURE__ */ React.createElement("em", null, "All")),
602
+ values.map((value) => /* @__PURE__ */ React.createElement(MenuItem, { key: value, value }, value))
603
+ )
604
+ );
594
605
  };
595
606
  const SearchFilter = ({
596
607
  component: Element,
597
608
  ...props
598
- }) => /* @__PURE__ */ React.createElement(Element, {
599
- ...props
600
- });
601
- SearchFilter.Checkbox = (props) => /* @__PURE__ */ React.createElement(SearchFilter, {
602
- ...props,
603
- component: CheckboxFilter
604
- });
605
- SearchFilter.Select = (props) => /* @__PURE__ */ React.createElement(SearchFilter, {
606
- ...props,
607
- component: SelectFilter
608
- });
609
- SearchFilter.Autocomplete = (props) => /* @__PURE__ */ React.createElement(SearchFilter, {
610
- ...props,
611
- component: AutocompleteFilter
612
- });
609
+ }) => /* @__PURE__ */ React.createElement(Element, { ...props });
610
+ SearchFilter.Checkbox = (props) => /* @__PURE__ */ React.createElement(SearchFilter, { ...props, component: CheckboxFilter });
611
+ SearchFilter.Select = (props) => /* @__PURE__ */ React.createElement(SearchFilter, { ...props, component: SelectFilter });
612
+ SearchFilter.Autocomplete = (props) => /* @__PURE__ */ React.createElement(SearchFilter, { ...props, component: AutocompleteFilter });
613
613
 
614
614
  const SearchResultContext = (props) => {
615
615
  const { children } = props;
@@ -628,41 +628,39 @@ const SearchResultApi = (props) => {
628
628
  };
629
629
  const SearchResultState = (props) => {
630
630
  const { query, children } = props;
631
- return query ? /* @__PURE__ */ React.createElement(SearchResultApi, {
632
- query
633
- }, children) : /* @__PURE__ */ React.createElement(SearchResultContext, null, children);
631
+ return query ? /* @__PURE__ */ React.createElement(SearchResultApi, { query }, children) : /* @__PURE__ */ React.createElement(SearchResultContext, null, children);
634
632
  };
635
633
  const SearchResultComponent = (props) => {
636
634
  const { query, children } = props;
637
- return /* @__PURE__ */ React.createElement(SearchResultState, {
638
- query
639
- }, ({ loading, error, value }) => {
635
+ return /* @__PURE__ */ React.createElement(SearchResultState, { query }, ({ loading, error, value }) => {
640
636
  if (loading) {
641
637
  return /* @__PURE__ */ React.createElement(Progress, null);
642
638
  }
643
639
  if (error) {
644
- return /* @__PURE__ */ React.createElement(ResponseErrorPanel, {
645
- title: "Error encountered while fetching search results",
646
- error
647
- });
640
+ return /* @__PURE__ */ React.createElement(
641
+ ResponseErrorPanel,
642
+ {
643
+ title: "Error encountered while fetching search results",
644
+ error
645
+ }
646
+ );
648
647
  }
649
648
  if (!(value == null ? void 0 : value.results.length)) {
650
- return /* @__PURE__ */ React.createElement(EmptyState, {
651
- missing: "data",
652
- title: "Sorry, no results were found"
653
- });
649
+ return /* @__PURE__ */ React.createElement(EmptyState, { missing: "data", title: "Sorry, no results were found" });
654
650
  }
655
651
  return children(value);
656
652
  });
657
653
  };
658
- const SearchResult = (props) => /* @__PURE__ */ React.createElement(AnalyticsContext, {
659
- attributes: {
660
- pluginId: "search",
661
- extension: "SearchResult"
662
- }
663
- }, /* @__PURE__ */ React.createElement(SearchResultComponent, {
664
- ...props
665
- }));
654
+ const SearchResult = (props) => /* @__PURE__ */ React.createElement(
655
+ AnalyticsContext,
656
+ {
657
+ attributes: {
658
+ pluginId: "search",
659
+ extension: "SearchResult"
660
+ }
661
+ },
662
+ /* @__PURE__ */ React.createElement(SearchResultComponent, { ...props })
663
+ );
666
664
 
667
665
  const useStyles$1 = makeStyles((theme) => ({
668
666
  root: {
@@ -678,20 +676,25 @@ const SearchResultPager = () => {
678
676
  if (!fetchNextPage && !fetchPreviousPage) {
679
677
  return /* @__PURE__ */ React.createElement(React.Fragment, null);
680
678
  }
681
- return /* @__PURE__ */ React.createElement("nav", {
682
- "aria-label": "pagination navigation",
683
- className: classes.root
684
- }, /* @__PURE__ */ React.createElement(Button, {
685
- "aria-label": "previous page",
686
- disabled: !fetchPreviousPage,
687
- onClick: fetchPreviousPage,
688
- startIcon: /* @__PURE__ */ React.createElement(ArrowBackIosIcon, null)
689
- }, "Previous"), /* @__PURE__ */ React.createElement(Button, {
690
- "aria-label": "next page",
691
- disabled: !fetchNextPage,
692
- onClick: fetchNextPage,
693
- endIcon: /* @__PURE__ */ React.createElement(ArrowForwardIosIcon, null)
694
- }, "Next"));
679
+ return /* @__PURE__ */ React.createElement("nav", { "aria-label": "pagination navigation", className: classes.root }, /* @__PURE__ */ React.createElement(
680
+ Button,
681
+ {
682
+ "aria-label": "previous page",
683
+ disabled: !fetchPreviousPage,
684
+ onClick: fetchPreviousPage,
685
+ startIcon: /* @__PURE__ */ React.createElement(ArrowBackIosIcon, null)
686
+ },
687
+ "Previous"
688
+ ), /* @__PURE__ */ React.createElement(
689
+ Button,
690
+ {
691
+ "aria-label": "next page",
692
+ disabled: !fetchNextPage,
693
+ onClick: fetchNextPage,
694
+ endIcon: /* @__PURE__ */ React.createElement(ArrowForwardIosIcon, null)
695
+ },
696
+ "Next"
697
+ ));
695
698
  };
696
699
 
697
700
  const encodePageCursor = (pageCursor) => {
@@ -728,28 +731,34 @@ const SearchPaginationBase = (props) => {
728
731
  },
729
732
  [onPageLimitChange]
730
733
  );
731
- return /* @__PURE__ */ React.createElement(TablePagination, {
732
- ...rest,
733
- component: "div",
734
- count,
735
- page,
736
- onPageChange: handlePageChange,
737
- rowsPerPage,
738
- labelRowsPerPage,
739
- labelDisplayedRows,
740
- rowsPerPageOptions,
741
- onRowsPerPageChange: handleRowsPerPageChange
742
- });
734
+ return /* @__PURE__ */ React.createElement(
735
+ TablePagination,
736
+ {
737
+ ...rest,
738
+ component: "div",
739
+ count,
740
+ page,
741
+ onPageChange: handlePageChange,
742
+ rowsPerPage,
743
+ labelRowsPerPage,
744
+ labelDisplayedRows,
745
+ rowsPerPageOptions,
746
+ onRowsPerPageChange: handleRowsPerPageChange
747
+ }
748
+ );
743
749
  };
744
750
  const SearchPagination = (props) => {
745
751
  const { pageLimit, setPageLimit, pageCursor, setPageCursor } = useSearch();
746
- return /* @__PURE__ */ React.createElement(SearchPaginationBase, {
747
- ...props,
748
- limit: pageLimit,
749
- onLimitChange: setPageLimit,
750
- cursor: pageCursor,
751
- onCursorChange: setPageCursor
752
- });
752
+ return /* @__PURE__ */ React.createElement(
753
+ SearchPaginationBase,
754
+ {
755
+ ...props,
756
+ limit: pageLimit,
757
+ onLimitChange: setPageLimit,
758
+ cursor: pageCursor,
759
+ onCursorChange: setPageCursor
760
+ }
761
+ );
753
762
  };
754
763
 
755
764
  const DefaultResultListItemComponent = ({
@@ -767,44 +776,51 @@ const DefaultResultListItemComponent = ({
767
776
  value: rank
768
777
  });
769
778
  };
770
- return /* @__PURE__ */ React.createElement(Link, {
771
- noTrack: true,
772
- to: result.location,
773
- onClick: handleClick
774
- }, /* @__PURE__ */ React.createElement(ListItem, {
775
- alignItems: "center"
776
- }, icon && /* @__PURE__ */ React.createElement(ListItemIcon, null, icon), /* @__PURE__ */ React.createElement(ListItemText, {
777
- primaryTypographyProps: { variant: "h6" },
778
- primary: (highlight == null ? void 0 : highlight.fields.title) ? /* @__PURE__ */ React.createElement(HighlightedSearchResultText, {
779
- text: highlight.fields.title,
780
- preTag: highlight.preTag,
781
- postTag: highlight.postTag
782
- }) : result.title,
783
- secondary: /* @__PURE__ */ React.createElement("span", {
784
- style: {
785
- display: "-webkit-box",
786
- WebkitBoxOrient: "vertical",
787
- WebkitLineClamp: lineClamp,
788
- overflow: "hidden"
789
- }
790
- }, (highlight == null ? void 0 : highlight.fields.text) ? /* @__PURE__ */ React.createElement(HighlightedSearchResultText, {
791
- text: highlight.fields.text,
792
- preTag: highlight.preTag,
793
- postTag: highlight.postTag
794
- }) : result.text)
795
- }), secondaryAction && /* @__PURE__ */ React.createElement(Box, {
796
- alignItems: "flex-end"
797
- }, secondaryAction)), /* @__PURE__ */ React.createElement(Divider, null));
779
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(ListItem, { alignItems: "center" }, icon && /* @__PURE__ */ React.createElement(ListItemIcon, null, icon), /* @__PURE__ */ React.createElement(
780
+ ListItemText,
781
+ {
782
+ primaryTypographyProps: { variant: "h6" },
783
+ primary: /* @__PURE__ */ React.createElement(Link, { noTrack: true, to: result.location, onClick: handleClick }, (highlight == null ? void 0 : highlight.fields.title) ? /* @__PURE__ */ React.createElement(
784
+ HighlightedSearchResultText,
785
+ {
786
+ text: (highlight == null ? void 0 : highlight.fields.title) || "",
787
+ preTag: (highlight == null ? void 0 : highlight.preTag) || "",
788
+ postTag: (highlight == null ? void 0 : highlight.postTag) || ""
789
+ }
790
+ ) : result.title),
791
+ secondary: /* @__PURE__ */ React.createElement(
792
+ "span",
793
+ {
794
+ style: {
795
+ display: "-webkit-box",
796
+ WebkitBoxOrient: "vertical",
797
+ WebkitLineClamp: lineClamp,
798
+ overflow: "hidden"
799
+ }
800
+ },
801
+ (highlight == null ? void 0 : highlight.fields.text) ? /* @__PURE__ */ React.createElement(
802
+ HighlightedSearchResultText,
803
+ {
804
+ text: highlight.fields.text,
805
+ preTag: highlight.preTag,
806
+ postTag: highlight.postTag
807
+ }
808
+ ) : result.text
809
+ )
810
+ }
811
+ ), secondaryAction && /* @__PURE__ */ React.createElement(Box, { alignItems: "flex-end" }, secondaryAction)), /* @__PURE__ */ React.createElement(Divider, null));
798
812
  };
799
813
  const HigherOrderDefaultResultListItem = (props) => {
800
- return /* @__PURE__ */ React.createElement(AnalyticsContext, {
801
- attributes: {
802
- pluginId: "search",
803
- extension: "DefaultResultListItem"
804
- }
805
- }, /* @__PURE__ */ React.createElement(DefaultResultListItemComponent, {
806
- ...props
807
- }));
814
+ return /* @__PURE__ */ React.createElement(
815
+ AnalyticsContext,
816
+ {
817
+ attributes: {
818
+ pluginId: "search",
819
+ extension: "DefaultResultListItem"
820
+ }
821
+ },
822
+ /* @__PURE__ */ React.createElement(DefaultResultListItemComponent, { ...props })
823
+ );
808
824
  };
809
825
 
810
826
  const SearchResultListLayout = (props) => {
@@ -812,44 +828,50 @@ const SearchResultListLayout = (props) => {
812
828
  loading,
813
829
  error,
814
830
  resultItems,
815
- renderResultItem = (resultItem) => /* @__PURE__ */ React.createElement(HigherOrderDefaultResultListItem, {
816
- key: resultItem.document.location,
817
- result: resultItem.document
818
- }),
819
- noResultsComponent = /* @__PURE__ */ React.createElement(EmptyState, {
820
- missing: "data",
821
- title: "Sorry, no results were found"
822
- }),
831
+ renderResultItem = (resultItem) => /* @__PURE__ */ React.createElement(
832
+ HigherOrderDefaultResultListItem,
833
+ {
834
+ key: resultItem.document.location,
835
+ result: resultItem.document
836
+ }
837
+ ),
838
+ noResultsComponent = /* @__PURE__ */ React.createElement(EmptyState, { missing: "data", title: "Sorry, no results were found" }),
823
839
  ...rest
824
840
  } = props;
825
- return /* @__PURE__ */ React.createElement(List, {
826
- ...rest
827
- }, loading ? /* @__PURE__ */ React.createElement(Progress, null) : null, !loading && error ? /* @__PURE__ */ React.createElement(ResponseErrorPanel, {
828
- title: "Error encountered while fetching search results",
829
- error
830
- }) : null, !loading && !error && (resultItems == null ? void 0 : resultItems.length) ? resultItems.map(renderResultItem) : null, !loading && !error && !(resultItems == null ? void 0 : resultItems.length) ? /* @__PURE__ */ React.createElement(ListItem, null, noResultsComponent) : null);
841
+ return /* @__PURE__ */ React.createElement(List, { ...rest }, loading ? /* @__PURE__ */ React.createElement(Progress, null) : null, !loading && error ? /* @__PURE__ */ React.createElement(
842
+ ResponseErrorPanel,
843
+ {
844
+ title: "Error encountered while fetching search results",
845
+ error
846
+ }
847
+ ) : null, !loading && !error && (resultItems == null ? void 0 : resultItems.length) ? resultItems.map(renderResultItem) : null, !loading && !error && !(resultItems == null ? void 0 : resultItems.length) ? /* @__PURE__ */ React.createElement(ListItem, null, noResultsComponent) : null);
831
848
  };
832
849
  const SearchResultList = (props) => {
833
850
  const { query, disableRenderingWithNoResults, ...rest } = props;
834
- return /* @__PURE__ */ React.createElement(AnalyticsContext, {
835
- attributes: {
836
- pluginId: "search",
837
- extension: "SearchResultList"
838
- }
839
- }, /* @__PURE__ */ React.createElement(SearchResultState, {
840
- query
841
- }, ({ loading, error, value }) => {
842
- var _a;
843
- if (!((_a = value == null ? void 0 : value.results) == null ? void 0 : _a.length) && disableRenderingWithNoResults) {
844
- return null;
845
- }
846
- return /* @__PURE__ */ React.createElement(SearchResultListLayout, {
847
- ...rest,
848
- loading,
849
- error,
850
- resultItems: value == null ? void 0 : value.results
851
- });
852
- }));
851
+ return /* @__PURE__ */ React.createElement(
852
+ AnalyticsContext,
853
+ {
854
+ attributes: {
855
+ pluginId: "search",
856
+ extension: "SearchResultList"
857
+ }
858
+ },
859
+ /* @__PURE__ */ React.createElement(SearchResultState, { query }, ({ loading, error, value }) => {
860
+ var _a;
861
+ if (!((_a = value == null ? void 0 : value.results) == null ? void 0 : _a.length) && disableRenderingWithNoResults) {
862
+ return null;
863
+ }
864
+ return /* @__PURE__ */ React.createElement(
865
+ SearchResultListLayout,
866
+ {
867
+ ...rest,
868
+ loading,
869
+ error,
870
+ resultItems: value == null ? void 0 : value.results
871
+ }
872
+ );
873
+ })
874
+ );
853
875
  };
854
876
 
855
877
  const useStyles = makeStyles((theme) => ({
@@ -883,12 +905,15 @@ const useStyles = makeStyles((theme) => ({
883
905
  const SearchResultGroupFilterFieldLayout = (props) => {
884
906
  const classes = useStyles();
885
907
  const { label, children, ...rest } = props;
886
- return /* @__PURE__ */ React.createElement(Chip, {
887
- ...rest,
888
- className: classes.listSubheaderFilter,
889
- variant: "outlined",
890
- label: /* @__PURE__ */ React.createElement(React.Fragment, null, label, ": ", children)
891
- });
908
+ return /* @__PURE__ */ React.createElement(
909
+ Chip,
910
+ {
911
+ ...rest,
912
+ className: classes.listSubheaderFilter,
913
+ variant: "outlined",
914
+ label: /* @__PURE__ */ React.createElement(React.Fragment, null, label, ": ", children)
915
+ }
916
+ );
892
917
  };
893
918
  const NullIcon = () => null;
894
919
  const useSearchResultGroupTextFilterStyles = makeStyles((theme) => ({
@@ -916,17 +941,18 @@ const SearchResultGroupTextFilterField = (props) => {
916
941
  },
917
942
  [onChange]
918
943
  );
919
- return /* @__PURE__ */ React.createElement(SearchResultGroupFilterFieldLayout, {
920
- label,
921
- onDelete
922
- }, /* @__PURE__ */ React.createElement(Typography, {
923
- role: "textbox",
924
- component: "span",
925
- className: classes.root,
926
- onChange: handleChange,
927
- contentEditable: true,
928
- suppressContentEditableWarning: true
929
- }, value));
944
+ return /* @__PURE__ */ React.createElement(SearchResultGroupFilterFieldLayout, { label, onDelete }, /* @__PURE__ */ React.createElement(
945
+ Typography,
946
+ {
947
+ role: "textbox",
948
+ component: "span",
949
+ className: classes.root,
950
+ onChange: handleChange,
951
+ contentEditable: true,
952
+ suppressContentEditableWarning: true
953
+ },
954
+ value
955
+ ));
930
956
  };
931
957
  const useSearchResultGroupSelectFilterStyles = makeStyles((theme) => ({
932
958
  root: {
@@ -955,18 +981,18 @@ const SearchResultGroupSelectFilterField = (props) => {
955
981
  },
956
982
  [onChange]
957
983
  );
958
- return /* @__PURE__ */ React.createElement(SearchResultGroupFilterFieldLayout, {
959
- label,
960
- onDelete
961
- }, /* @__PURE__ */ React.createElement(Select, {
962
- className: classes.root,
963
- value,
964
- onChange: handleChange,
965
- input: /* @__PURE__ */ React.createElement(InputBase, null),
966
- IconComponent: NullIcon
967
- }, /* @__PURE__ */ React.createElement(MenuItem, {
968
- value: "none"
969
- }, "None"), children));
984
+ return /* @__PURE__ */ React.createElement(SearchResultGroupFilterFieldLayout, { label, onDelete }, /* @__PURE__ */ React.createElement(
985
+ Select,
986
+ {
987
+ className: classes.root,
988
+ value,
989
+ onChange: handleChange,
990
+ input: /* @__PURE__ */ React.createElement(InputBase, null),
991
+ IconComponent: NullIcon
992
+ },
993
+ /* @__PURE__ */ React.createElement(MenuItem, { value: "none" }, "None"),
994
+ children
995
+ ));
970
996
  };
971
997
  function SearchResultGroupLayout(props) {
972
998
  const classes = useStyles();
@@ -977,26 +1003,21 @@ function SearchResultGroupLayout(props) {
977
1003
  icon,
978
1004
  title,
979
1005
  titleProps = {},
980
- link = /* @__PURE__ */ React.createElement(React.Fragment, null, "See all", /* @__PURE__ */ React.createElement(ArrowForwardIosIcon, {
981
- className: classes.listSubheaderLinkIcon
982
- })),
1006
+ link = /* @__PURE__ */ React.createElement(React.Fragment, null, "See all", /* @__PURE__ */ React.createElement(ArrowForwardIosIcon, { className: classes.listSubheaderLinkIcon })),
983
1007
  linkProps = {},
984
1008
  filterOptions,
985
- renderFilterOption = (filterOption) => /* @__PURE__ */ React.createElement(MenuItem, {
986
- key: String(filterOption),
987
- value: String(filterOption)
988
- }, filterOption),
1009
+ renderFilterOption = (filterOption) => /* @__PURE__ */ React.createElement(MenuItem, { key: String(filterOption), value: String(filterOption) }, filterOption),
989
1010
  filterFields,
990
1011
  renderFilterField,
991
1012
  resultItems,
992
- renderResultItem = (resultItem) => /* @__PURE__ */ React.createElement(HigherOrderDefaultResultListItem, {
993
- key: resultItem.document.location,
994
- result: resultItem.document
995
- }),
996
- noResultsComponent = /* @__PURE__ */ React.createElement(EmptyState, {
997
- missing: "data",
998
- title: "Sorry, no results were found"
999
- }),
1013
+ renderResultItem = (resultItem) => /* @__PURE__ */ React.createElement(
1014
+ HigherOrderDefaultResultListItem,
1015
+ {
1016
+ key: resultItem.document.location,
1017
+ result: resultItem.document
1018
+ }
1019
+ ),
1020
+ noResultsComponent = /* @__PURE__ */ React.createElement(EmptyState, { missing: "data", title: "Sorry, no results were found" }),
1000
1021
  ...rest
1001
1022
  } = props;
1002
1023
  const handleClick = useCallback((e) => {
@@ -1005,43 +1026,49 @@ function SearchResultGroupLayout(props) {
1005
1026
  const handleClose = useCallback(() => {
1006
1027
  setAnchorEl(null);
1007
1028
  }, []);
1008
- return /* @__PURE__ */ React.createElement(List, {
1009
- ...rest
1010
- }, /* @__PURE__ */ React.createElement(ListSubheader, {
1011
- className: classes.listSubheader
1012
- }, icon, /* @__PURE__ */ React.createElement(Typography, {
1013
- className: classes.listSubheaderName,
1014
- component: "strong",
1015
- ...titleProps
1016
- }, title), filterOptions ? /* @__PURE__ */ React.createElement(Chip, {
1017
- className: classes.listSubheaderChip,
1018
- component: "button",
1019
- icon: /* @__PURE__ */ React.createElement(AddIcon, null),
1020
- variant: "outlined",
1021
- label: "Add filter",
1022
- "aria-controls": "filters-menu",
1023
- "aria-haspopup": "true",
1024
- onClick: handleClick
1025
- }) : null, filterOptions ? /* @__PURE__ */ React.createElement(Menu, {
1026
- id: "filters-menu",
1027
- anchorEl,
1028
- open: Boolean(anchorEl),
1029
- onClose: handleClose,
1030
- onClick: handleClose,
1031
- keepMounted: true
1032
- }, filterOptions.map(renderFilterOption)) : null, filterFields == null ? void 0 : filterFields.map(
1029
+ return /* @__PURE__ */ React.createElement(List, { ...rest }, /* @__PURE__ */ React.createElement(ListSubheader, { className: classes.listSubheader }, icon, /* @__PURE__ */ React.createElement(
1030
+ Typography,
1031
+ {
1032
+ className: classes.listSubheaderName,
1033
+ component: "strong",
1034
+ ...titleProps
1035
+ },
1036
+ title
1037
+ ), filterOptions ? /* @__PURE__ */ React.createElement(
1038
+ Chip,
1039
+ {
1040
+ className: classes.listSubheaderChip,
1041
+ component: "button",
1042
+ icon: /* @__PURE__ */ React.createElement(AddIcon, null),
1043
+ variant: "outlined",
1044
+ label: "Add filter",
1045
+ "aria-controls": "filters-menu",
1046
+ "aria-haspopup": "true",
1047
+ onClick: handleClick
1048
+ }
1049
+ ) : null, filterOptions ? /* @__PURE__ */ React.createElement(
1050
+ Menu,
1051
+ {
1052
+ id: "filters-menu",
1053
+ anchorEl,
1054
+ open: Boolean(anchorEl),
1055
+ onClose: handleClose,
1056
+ onClick: handleClose,
1057
+ keepMounted: true
1058
+ },
1059
+ filterOptions.map(renderFilterOption)
1060
+ ) : null, filterFields == null ? void 0 : filterFields.map(
1033
1061
  (filterField) => {
1034
1062
  var _a;
1035
1063
  return (_a = renderFilterField == null ? void 0 : renderFilterField(filterField)) != null ? _a : null;
1036
1064
  }
1037
- ), /* @__PURE__ */ React.createElement(Link, {
1038
- className: classes.listSubheaderLink,
1039
- to: "/search",
1040
- ...linkProps
1041
- }, link)), loading ? /* @__PURE__ */ React.createElement(Progress, null) : null, !loading && error ? /* @__PURE__ */ React.createElement(ResponseErrorPanel, {
1042
- title: "Error encountered while fetching search results",
1043
- error
1044
- }) : null, !loading && !error && (resultItems == null ? void 0 : resultItems.length) ? resultItems.map(renderResultItem) : null, !loading && !error && !(resultItems == null ? void 0 : resultItems.length) ? /* @__PURE__ */ React.createElement(ListItem, null, noResultsComponent) : null);
1065
+ ), /* @__PURE__ */ React.createElement(Link, { className: classes.listSubheaderLink, to: "/search", ...linkProps }, link)), loading ? /* @__PURE__ */ React.createElement(Progress, null) : null, !loading && error ? /* @__PURE__ */ React.createElement(
1066
+ ResponseErrorPanel,
1067
+ {
1068
+ title: "Error encountered while fetching search results",
1069
+ error
1070
+ }
1071
+ ) : null, !loading && !error && (resultItems == null ? void 0 : resultItems.length) ? resultItems.map(renderResultItem) : null, !loading && !error && !(resultItems == null ? void 0 : resultItems.length) ? /* @__PURE__ */ React.createElement(ListItem, null, noResultsComponent) : null);
1045
1072
  }
1046
1073
  function SearchResultGroup(props) {
1047
1074
  const {
@@ -1059,27 +1086,32 @@ function SearchResultGroup(props) {
1059
1086
  },
1060
1087
  { arrayFormat: "brackets" }
1061
1088
  )}`;
1062
- return /* @__PURE__ */ React.createElement(AnalyticsContext, {
1063
- attributes: {
1064
- pluginId: "search",
1065
- extension: "SearchResultGroup"
1066
- }
1067
- }, /* @__PURE__ */ React.createElement(SearchResultState, {
1068
- query
1069
- }, ({ loading, error, value }) => {
1070
- var _a, _b;
1071
- if (!((_a = value == null ? void 0 : value.results) == null ? void 0 : _a.length) && disableRenderingWithNoResults) {
1072
- return null;
1073
- }
1074
- return /* @__PURE__ */ React.createElement(SearchResultGroupLayout, {
1075
- ...rest,
1076
- loading,
1077
- error,
1078
- linkProps: { to, ...linkProps },
1079
- resultItems: value == null ? void 0 : value.results,
1080
- filterFields: Object.keys((_b = query.filters) != null ? _b : {})
1081
- });
1082
- }));
1089
+ return /* @__PURE__ */ React.createElement(
1090
+ AnalyticsContext,
1091
+ {
1092
+ attributes: {
1093
+ pluginId: "search",
1094
+ extension: "SearchResultGroup"
1095
+ }
1096
+ },
1097
+ /* @__PURE__ */ React.createElement(SearchResultState, { query }, ({ loading, error, value }) => {
1098
+ var _a, _b;
1099
+ if (!((_a = value == null ? void 0 : value.results) == null ? void 0 : _a.length) && disableRenderingWithNoResults) {
1100
+ return null;
1101
+ }
1102
+ return /* @__PURE__ */ React.createElement(
1103
+ SearchResultGroupLayout,
1104
+ {
1105
+ ...rest,
1106
+ loading,
1107
+ error,
1108
+ linkProps: { to, ...linkProps },
1109
+ resultItems: value == null ? void 0 : value.results,
1110
+ filterFields: Object.keys((_b = query.filters) != null ? _b : {})
1111
+ }
1112
+ );
1113
+ })
1114
+ );
1083
1115
  }
1084
1116
 
1085
1117
  export { AutocompleteFilter, CheckboxFilter, HigherOrderDefaultResultListItem as DefaultResultListItem, HighlightedSearchResultText, MockSearchApi, SearchAutocomplete, SearchAutocompleteDefaultOption, SearchBar, SearchBarBase, SearchContextProvider, SearchFilter, SearchPagination, SearchPaginationBase, SearchResult, SearchResultApi, SearchResultComponent, SearchResultContext, SearchResultGroup, SearchResultGroupFilterFieldLayout, SearchResultGroupLayout, SearchResultGroupSelectFilterField, SearchResultGroupTextFilterField, SearchResultList, SearchResultListLayout, SearchResultPager, SearchResultState, SelectFilter, searchApiRef, useSearch, useSearchContextCheck };