@backstage/plugin-search 0.8.2-next.2 → 0.9.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 +20 -0
- package/README.md +8 -5
- package/dist/esm/{index-c08cd99a.esm.js → index-2180028e.esm.js} +9 -10
- package/dist/esm/index-2180028e.esm.js.map +1 -0
- package/dist/esm/{index-b9062edb.esm.js → index-5aaf3de8.esm.js} +9 -10
- package/dist/esm/index-5aaf3de8.esm.js.map +1 -0
- package/dist/esm/{index-c59424ea.esm.js → index-8388a95e.esm.js} +70 -431
- package/dist/esm/index-8388a95e.esm.js.map +1 -0
- package/dist/esm/{index-1c96b52b.esm.js → index-8a1f0d37.esm.js} +8 -9
- package/dist/esm/index-8a1f0d37.esm.js.map +1 -0
- package/dist/index.d.ts +120 -60
- package/dist/index.esm.js +8 -9
- package/dist/index.esm.js.map +1 -1
- package/package.json +12 -12
- package/dist/esm/index-1c96b52b.esm.js.map +0 -1
- package/dist/esm/index-763c3ecb.esm.js +0 -31
- package/dist/esm/index-763c3ecb.esm.js.map +0 -1
- package/dist/esm/index-b4559d0a.esm.js +0 -31
- package/dist/esm/index-b4559d0a.esm.js.map +0 -1
- package/dist/esm/index-b9062edb.esm.js.map +0 -1
- package/dist/esm/index-c08cd99a.esm.js.map +0 -1
- package/dist/esm/index-c59424ea.esm.js.map +0 -1
- package/dist/esm/index-ff98c685.esm.js +0 -31
- package/dist/esm/index-ff98c685.esm.js.map +0 -1
|
@@ -1,34 +1,33 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, { useCallback, useContext, useState, useEffect, Fragment, cloneElement } from 'react';
|
|
2
2
|
import FilterListIcon from '@material-ui/icons/FilterList';
|
|
3
|
-
import { makeStyles, IconButton, Typography, Card, CardHeader, Button, Divider, CardContent, Select, MenuItem, List, ListItem, Checkbox, ListItemText,
|
|
4
|
-
import
|
|
5
|
-
import { useAnalytics, useApi, configApiRef, createRouteRef, createPlugin, createApiFactory, discoveryApiRef, identityApiRef, createRoutableExtension, createComponentExtension, useRouteRef } from '@backstage/core-plugin-api';
|
|
6
|
-
import SearchIcon from '@material-ui/icons/Search';
|
|
7
|
-
import ClearButton from '@material-ui/icons/Clear';
|
|
8
|
-
import { useSearch, useSearchContextCheck, SearchContextProvider, HighlightedSearchResultText, searchApiRef } from '@backstage/plugin-search-react';
|
|
9
|
-
import { Autocomplete, Alert } from '@material-ui/lab';
|
|
10
|
-
import useAsyncFn from 'react-use/lib/useAsyncFn';
|
|
3
|
+
import { makeStyles, IconButton, Typography, Card, CardHeader, Button, Divider, CardContent, Select, MenuItem, List, ListItem, Checkbox, ListItemText, Dialog, useTheme, DialogTitle, Paper, DialogContent, Grid, DialogActions, Accordion, AccordionSummary, AccordionDetails, ListItemIcon, Tabs, Tab, FormControl, InputLabel, Chip } from '@material-ui/core';
|
|
4
|
+
import { SearchBarBase as SearchBarBase$1, useSearch, CheckboxFilter, SelectFilter, AutocompleteFilter, searchApiRef, SearchResult as SearchResult$2, DefaultResultListItem as DefaultResultListItem$1, SearchContextProvider, SearchBar as SearchBar$2, SearchResultPager as SearchResultPager$1 } from '@backstage/plugin-search-react';
|
|
11
5
|
import LaunchIcon from '@material-ui/icons/Launch';
|
|
12
6
|
import { makeStyles as makeStyles$1 } from '@material-ui/core/styles';
|
|
13
|
-
import {
|
|
14
|
-
import
|
|
15
|
-
import ArrowForwardIosIcon from '@material-ui/icons/ArrowForwardIos';
|
|
7
|
+
import { createRouteRef, createPlugin, createApiFactory, discoveryApiRef, identityApiRef, createRoutableExtension, createComponentExtension, useRouteRef, useApi } from '@backstage/core-plugin-api';
|
|
8
|
+
import { useContent, Link, Progress, EmptyState, Table, useQueryParamState, Page, Header, Content, SidebarSearchField } from '@backstage/core-components';
|
|
16
9
|
import { ResponseError } from '@backstage/errors';
|
|
17
10
|
import qs from 'qs';
|
|
18
11
|
import { createVersionedContext, createVersionedValueMap } from '@backstage/version-bridge';
|
|
19
12
|
import usePrevious from 'react-use/lib/usePrevious';
|
|
20
13
|
import { useOutlet, useLocation } from 'react-router';
|
|
21
|
-
import
|
|
14
|
+
import useDebounce from 'react-use/lib/useDebounce';
|
|
15
|
+
import InputBase from '@material-ui/core/InputBase';
|
|
22
16
|
import IconButton$1 from '@material-ui/core/IconButton';
|
|
17
|
+
import SearchIcon from '@material-ui/icons/Search';
|
|
18
|
+
import ClearButton from '@material-ui/icons/Clear';
|
|
19
|
+
import { Alert } from '@material-ui/lab';
|
|
23
20
|
import useAsync from 'react-use/lib/useAsync';
|
|
24
21
|
import { catalogApiRef } from '@backstage/plugin-catalog-react';
|
|
25
22
|
import { DEFAULT_NAMESPACE } from '@backstage/catalog-model';
|
|
23
|
+
import ArrowBackIosIcon from '@material-ui/icons/ArrowBackIos';
|
|
24
|
+
import ArrowForwardIosIcon from '@material-ui/icons/ArrowForwardIos';
|
|
26
25
|
import useEffectOnce from 'react-use/lib/useEffectOnce';
|
|
27
26
|
import ExpandMoreIcon from '@material-ui/icons/ExpandMore';
|
|
28
27
|
import AllIcon from '@material-ui/icons/FontDownload';
|
|
29
28
|
import { useNavigate } from 'react-router-dom';
|
|
30
29
|
|
|
31
|
-
const useStyles$
|
|
30
|
+
const useStyles$a = makeStyles((theme) => ({
|
|
32
31
|
filters: {
|
|
33
32
|
width: "250px",
|
|
34
33
|
display: "flex"
|
|
@@ -41,7 +40,7 @@ const FiltersButton$1 = ({
|
|
|
41
40
|
numberOfSelectedFilters,
|
|
42
41
|
handleToggleFilters
|
|
43
42
|
}) => {
|
|
44
|
-
const classes = useStyles$
|
|
43
|
+
const classes = useStyles$a();
|
|
45
44
|
return /* @__PURE__ */ React.createElement("div", {
|
|
46
45
|
className: classes.filters
|
|
47
46
|
}, /* @__PURE__ */ React.createElement(IconButton, {
|
|
@@ -53,7 +52,7 @@ const FiltersButton$1 = ({
|
|
|
53
52
|
}, "Filters (", numberOfSelectedFilters ? numberOfSelectedFilters : 0, ")"));
|
|
54
53
|
};
|
|
55
54
|
|
|
56
|
-
const useStyles$
|
|
55
|
+
const useStyles$9 = makeStyles((theme) => ({
|
|
57
56
|
filters: {
|
|
58
57
|
background: "transparent",
|
|
59
58
|
boxShadow: "0px 0px 0px 0px"
|
|
@@ -72,7 +71,7 @@ const Filters$1 = ({
|
|
|
72
71
|
updateSelected,
|
|
73
72
|
updateChecked
|
|
74
73
|
}) => {
|
|
75
|
-
const classes = useStyles$
|
|
74
|
+
const classes = useStyles$9();
|
|
76
75
|
return /* @__PURE__ */ React.createElement(Card, {
|
|
77
76
|
className: classes.filters
|
|
78
77
|
}, /* @__PURE__ */ React.createElement(CardHeader, {
|
|
@@ -126,76 +125,7 @@ const Filters$1 = ({
|
|
|
126
125
|
}))))));
|
|
127
126
|
};
|
|
128
127
|
|
|
129
|
-
const
|
|
130
|
-
const analytics = useAnalytics();
|
|
131
|
-
const { term } = useSearch();
|
|
132
|
-
useEffect(() => {
|
|
133
|
-
if (term) {
|
|
134
|
-
analytics.captureEvent("search", term);
|
|
135
|
-
}
|
|
136
|
-
}, [analytics, term]);
|
|
137
|
-
return /* @__PURE__ */ React.createElement(React.Fragment, null, children);
|
|
138
|
-
};
|
|
139
|
-
|
|
140
|
-
const SearchBarBase = ({
|
|
141
|
-
onChange,
|
|
142
|
-
onKeyDown,
|
|
143
|
-
onSubmit,
|
|
144
|
-
debounceTime = 200,
|
|
145
|
-
clearButton = true,
|
|
146
|
-
fullWidth = true,
|
|
147
|
-
value: defaultValue,
|
|
148
|
-
inputProps: defaultInputProps = {},
|
|
149
|
-
endAdornment: defaultEndAdornment,
|
|
150
|
-
...props
|
|
151
|
-
}) => {
|
|
152
|
-
const configApi = useApi(configApiRef);
|
|
153
|
-
const [value, setValue] = useState(defaultValue);
|
|
154
|
-
const hasSearchContext = useSearchContextCheck();
|
|
155
|
-
useEffect(() => {
|
|
156
|
-
setValue((prevValue) => prevValue !== defaultValue ? defaultValue : prevValue);
|
|
157
|
-
}, [defaultValue]);
|
|
158
|
-
useDebounce(() => onChange(value), debounceTime, [value]);
|
|
159
|
-
const handleChange = useCallback((e) => {
|
|
160
|
-
setValue(e.target.value);
|
|
161
|
-
}, [setValue]);
|
|
162
|
-
const handleKeyDown = useCallback((e) => {
|
|
163
|
-
if (onKeyDown)
|
|
164
|
-
onKeyDown(e);
|
|
165
|
-
if (onSubmit && e.key === "Enter") {
|
|
166
|
-
onSubmit();
|
|
167
|
-
}
|
|
168
|
-
}, [onKeyDown, onSubmit]);
|
|
169
|
-
const handleClear = useCallback(() => {
|
|
170
|
-
onChange("");
|
|
171
|
-
}, [onChange]);
|
|
172
|
-
const placeholder = `Search in ${configApi.getOptionalString("app.title") || "Backstage"}`;
|
|
173
|
-
const startAdornment = /* @__PURE__ */ React.createElement(InputAdornment, {
|
|
174
|
-
position: "start"
|
|
175
|
-
}, /* @__PURE__ */ React.createElement(IconButton, {
|
|
176
|
-
"aria-label": "Query",
|
|
177
|
-
disabled: true
|
|
178
|
-
}, /* @__PURE__ */ React.createElement(SearchIcon, null)));
|
|
179
|
-
const endAdornment = /* @__PURE__ */ React.createElement(InputAdornment, {
|
|
180
|
-
position: "end"
|
|
181
|
-
}, /* @__PURE__ */ React.createElement(IconButton, {
|
|
182
|
-
"aria-label": "Clear",
|
|
183
|
-
onClick: handleClear
|
|
184
|
-
}, /* @__PURE__ */ React.createElement(ClearButton, null)));
|
|
185
|
-
const searchBar = /* @__PURE__ */ React.createElement(TrackSearch, null, /* @__PURE__ */ React.createElement(InputBase, {
|
|
186
|
-
"data-testid": "search-bar-next",
|
|
187
|
-
value,
|
|
188
|
-
placeholder,
|
|
189
|
-
startAdornment,
|
|
190
|
-
endAdornment: clearButton ? endAdornment : defaultEndAdornment,
|
|
191
|
-
inputProps: { "aria-label": "Search", ...defaultInputProps },
|
|
192
|
-
fullWidth,
|
|
193
|
-
onChange: handleChange,
|
|
194
|
-
onKeyDown: handleKeyDown,
|
|
195
|
-
...props
|
|
196
|
-
}));
|
|
197
|
-
return hasSearchContext ? searchBar : /* @__PURE__ */ React.createElement(SearchContextProvider, null, searchBar);
|
|
198
|
-
};
|
|
128
|
+
const SearchBarBase = SearchBarBase$1;
|
|
199
129
|
const SearchBar$1 = ({ onChange, ...props }) => {
|
|
200
130
|
const { term, setTerm } = useSearch();
|
|
201
131
|
const handleChange = useCallback((newValue) => {
|
|
@@ -212,202 +142,6 @@ const SearchBar$1 = ({ onChange, ...props }) => {
|
|
|
212
142
|
});
|
|
213
143
|
};
|
|
214
144
|
|
|
215
|
-
const useAsyncFilterValues = (fn, inputValue, defaultValues = [], debounce = 250) => {
|
|
216
|
-
const valuesMemo = useRef({});
|
|
217
|
-
const definiteFn = fn || (() => Promise.resolve([]));
|
|
218
|
-
const [state, callback] = useAsyncFn(definiteFn, [inputValue], {
|
|
219
|
-
loading: true
|
|
220
|
-
});
|
|
221
|
-
useDebounce(() => {
|
|
222
|
-
if (valuesMemo.current[inputValue] === void 0) {
|
|
223
|
-
valuesMemo.current[inputValue] = callback(inputValue).then((values) => {
|
|
224
|
-
valuesMemo.current[inputValue] = values;
|
|
225
|
-
return values;
|
|
226
|
-
});
|
|
227
|
-
}
|
|
228
|
-
}, debounce, [callback, inputValue]);
|
|
229
|
-
if (defaultValues.length) {
|
|
230
|
-
return {
|
|
231
|
-
loading: false,
|
|
232
|
-
value: defaultValues
|
|
233
|
-
};
|
|
234
|
-
}
|
|
235
|
-
const possibleValue = valuesMemo.current[inputValue];
|
|
236
|
-
if (Array.isArray(possibleValue)) {
|
|
237
|
-
return {
|
|
238
|
-
loading: false,
|
|
239
|
-
value: possibleValue
|
|
240
|
-
};
|
|
241
|
-
}
|
|
242
|
-
return state;
|
|
243
|
-
};
|
|
244
|
-
const useDefaultFilterValue = (name, defaultValue) => {
|
|
245
|
-
const { setFilters } = useSearch();
|
|
246
|
-
useEffect(() => {
|
|
247
|
-
if (defaultValue && [defaultValue].flat().length > 0) {
|
|
248
|
-
setFilters((prevFilters) => ({
|
|
249
|
-
...prevFilters,
|
|
250
|
-
[name]: defaultValue
|
|
251
|
-
}));
|
|
252
|
-
}
|
|
253
|
-
}, []);
|
|
254
|
-
};
|
|
255
|
-
|
|
256
|
-
const AutocompleteFilter = (props) => {
|
|
257
|
-
const {
|
|
258
|
-
className,
|
|
259
|
-
defaultValue,
|
|
260
|
-
name,
|
|
261
|
-
values: givenValues,
|
|
262
|
-
valuesDebounceMs,
|
|
263
|
-
label,
|
|
264
|
-
filterSelectedOptions,
|
|
265
|
-
limitTags,
|
|
266
|
-
multiple
|
|
267
|
-
} = props;
|
|
268
|
-
const [inputValue, setInputValue] = useState("");
|
|
269
|
-
useDefaultFilterValue(name, defaultValue);
|
|
270
|
-
const asyncValues = typeof givenValues === "function" ? givenValues : void 0;
|
|
271
|
-
const defaultValues = typeof givenValues === "function" ? void 0 : givenValues;
|
|
272
|
-
const { value: values, loading } = useAsyncFilterValues(asyncValues, inputValue, defaultValues, valuesDebounceMs);
|
|
273
|
-
const { filters, setFilters } = useSearch();
|
|
274
|
-
const filterValue = filters[name] || (multiple ? [] : null);
|
|
275
|
-
const handleChange = (_, newValue) => {
|
|
276
|
-
setFilters((prevState) => {
|
|
277
|
-
const { [name]: filter, ...others } = prevState;
|
|
278
|
-
if (newValue) {
|
|
279
|
-
return { ...others, [name]: newValue };
|
|
280
|
-
}
|
|
281
|
-
return { ...others };
|
|
282
|
-
});
|
|
283
|
-
};
|
|
284
|
-
const renderInput = (params) => /* @__PURE__ */ React.createElement(TextField, {
|
|
285
|
-
...params,
|
|
286
|
-
name: "search",
|
|
287
|
-
variant: "outlined",
|
|
288
|
-
label,
|
|
289
|
-
fullWidth: true
|
|
290
|
-
});
|
|
291
|
-
const renderTags = (tagValue, getTagProps) => tagValue.map((option, index) => /* @__PURE__ */ React.createElement(Chip, {
|
|
292
|
-
label: option,
|
|
293
|
-
color: "primary",
|
|
294
|
-
...getTagProps({ index })
|
|
295
|
-
}));
|
|
296
|
-
return /* @__PURE__ */ React.createElement(Autocomplete, {
|
|
297
|
-
filterSelectedOptions,
|
|
298
|
-
limitTags,
|
|
299
|
-
multiple,
|
|
300
|
-
className,
|
|
301
|
-
id: `${multiple ? "multi-" : ""}select-filter-${name}--select`,
|
|
302
|
-
options: values || [],
|
|
303
|
-
loading,
|
|
304
|
-
value: filterValue,
|
|
305
|
-
onChange: handleChange,
|
|
306
|
-
onInputChange: (_, newValue) => setInputValue(newValue),
|
|
307
|
-
renderInput,
|
|
308
|
-
renderTags
|
|
309
|
-
});
|
|
310
|
-
};
|
|
311
|
-
|
|
312
|
-
const useStyles$9 = makeStyles({
|
|
313
|
-
label: {
|
|
314
|
-
textTransform: "capitalize"
|
|
315
|
-
}
|
|
316
|
-
});
|
|
317
|
-
const CheckboxFilter = (props) => {
|
|
318
|
-
const {
|
|
319
|
-
className,
|
|
320
|
-
defaultValue,
|
|
321
|
-
label,
|
|
322
|
-
name,
|
|
323
|
-
values: givenValues = [],
|
|
324
|
-
valuesDebounceMs
|
|
325
|
-
} = props;
|
|
326
|
-
const classes = useStyles$9();
|
|
327
|
-
const { filters, setFilters } = useSearch();
|
|
328
|
-
useDefaultFilterValue(name, defaultValue);
|
|
329
|
-
const asyncValues = typeof givenValues === "function" ? givenValues : void 0;
|
|
330
|
-
const defaultValues = typeof givenValues === "function" ? void 0 : givenValues;
|
|
331
|
-
const { value: values = [], loading } = useAsyncFilterValues(asyncValues, "", defaultValues, valuesDebounceMs);
|
|
332
|
-
const handleChange = (e) => {
|
|
333
|
-
const {
|
|
334
|
-
target: { value, checked }
|
|
335
|
-
} = e;
|
|
336
|
-
setFilters((prevFilters) => {
|
|
337
|
-
const { [name]: filter, ...others } = prevFilters;
|
|
338
|
-
const rest = (filter || []).filter((i) => i !== value);
|
|
339
|
-
const items = checked ? [...rest, value] : rest;
|
|
340
|
-
return items.length ? { ...others, [name]: items } : others;
|
|
341
|
-
});
|
|
342
|
-
};
|
|
343
|
-
return /* @__PURE__ */ React.createElement(FormControl, {
|
|
344
|
-
className,
|
|
345
|
-
disabled: loading,
|
|
346
|
-
fullWidth: true,
|
|
347
|
-
"data-testid": "search-checkboxfilter-next"
|
|
348
|
-
}, label ? /* @__PURE__ */ React.createElement(FormLabel, {
|
|
349
|
-
className: classes.label
|
|
350
|
-
}, label) : null, values.map((value) => {
|
|
351
|
-
var _a;
|
|
352
|
-
return /* @__PURE__ */ React.createElement(FormControlLabel, {
|
|
353
|
-
key: value,
|
|
354
|
-
control: /* @__PURE__ */ React.createElement(Checkbox, {
|
|
355
|
-
color: "primary",
|
|
356
|
-
tabIndex: -1,
|
|
357
|
-
inputProps: { "aria-labelledby": value },
|
|
358
|
-
value,
|
|
359
|
-
name: value,
|
|
360
|
-
onChange: handleChange,
|
|
361
|
-
checked: ((_a = filters[name]) != null ? _a : []).includes(value)
|
|
362
|
-
}),
|
|
363
|
-
label: value
|
|
364
|
-
});
|
|
365
|
-
}));
|
|
366
|
-
};
|
|
367
|
-
const SelectFilter = (props) => {
|
|
368
|
-
const {
|
|
369
|
-
className,
|
|
370
|
-
defaultValue,
|
|
371
|
-
label,
|
|
372
|
-
name,
|
|
373
|
-
values: givenValues,
|
|
374
|
-
valuesDebounceMs
|
|
375
|
-
} = props;
|
|
376
|
-
const classes = useStyles$9();
|
|
377
|
-
useDefaultFilterValue(name, defaultValue);
|
|
378
|
-
const asyncValues = typeof givenValues === "function" ? givenValues : void 0;
|
|
379
|
-
const defaultValues = typeof givenValues === "function" ? void 0 : givenValues;
|
|
380
|
-
const { value: values = [], loading } = useAsyncFilterValues(asyncValues, "", defaultValues, valuesDebounceMs);
|
|
381
|
-
const { filters, setFilters } = useSearch();
|
|
382
|
-
const handleChange = (e) => {
|
|
383
|
-
const {
|
|
384
|
-
target: { value }
|
|
385
|
-
} = e;
|
|
386
|
-
setFilters((prevFilters) => {
|
|
387
|
-
const { [name]: filter, ...others } = prevFilters;
|
|
388
|
-
return value ? { ...others, [name]: value } : others;
|
|
389
|
-
});
|
|
390
|
-
};
|
|
391
|
-
return /* @__PURE__ */ React.createElement(FormControl, {
|
|
392
|
-
disabled: loading,
|
|
393
|
-
className,
|
|
394
|
-
variant: "filled",
|
|
395
|
-
fullWidth: true,
|
|
396
|
-
"data-testid": "search-selectfilter-next"
|
|
397
|
-
}, label ? /* @__PURE__ */ React.createElement(InputLabel, {
|
|
398
|
-
className: classes.label,
|
|
399
|
-
margin: "dense"
|
|
400
|
-
}, label) : null, /* @__PURE__ */ React.createElement(Select, {
|
|
401
|
-
variant: "outlined",
|
|
402
|
-
value: filters[name] || "",
|
|
403
|
-
onChange: handleChange
|
|
404
|
-
}, /* @__PURE__ */ React.createElement(MenuItem, {
|
|
405
|
-
value: ""
|
|
406
|
-
}, /* @__PURE__ */ React.createElement("em", null, "All")), values.map((value) => /* @__PURE__ */ React.createElement(MenuItem, {
|
|
407
|
-
key: value,
|
|
408
|
-
value
|
|
409
|
-
}, value))));
|
|
410
|
-
};
|
|
411
145
|
const SearchFilter = ({
|
|
412
146
|
component: Element,
|
|
413
147
|
...props
|
|
@@ -426,94 +160,6 @@ SearchFilter.Autocomplete = (props) => /* @__PURE__ */ React.createElement(Searc
|
|
|
426
160
|
...props,
|
|
427
161
|
component: AutocompleteFilter
|
|
428
162
|
});
|
|
429
|
-
const SearchFilterNext = SearchFilter;
|
|
430
|
-
|
|
431
|
-
const DefaultResultListItem$1 = ({
|
|
432
|
-
result,
|
|
433
|
-
highlight,
|
|
434
|
-
icon,
|
|
435
|
-
secondaryAction,
|
|
436
|
-
lineClamp = 5
|
|
437
|
-
}) => {
|
|
438
|
-
return /* @__PURE__ */ React.createElement(Link, {
|
|
439
|
-
to: result.location
|
|
440
|
-
}, /* @__PURE__ */ React.createElement(ListItem, {
|
|
441
|
-
alignItems: "center"
|
|
442
|
-
}, icon && /* @__PURE__ */ React.createElement(ListItemIcon, null, icon), /* @__PURE__ */ React.createElement(ListItemText, {
|
|
443
|
-
primaryTypographyProps: { variant: "h6" },
|
|
444
|
-
primary: (highlight == null ? void 0 : highlight.fields.title) ? /* @__PURE__ */ React.createElement(HighlightedSearchResultText, {
|
|
445
|
-
text: highlight.fields.title,
|
|
446
|
-
preTag: highlight.preTag,
|
|
447
|
-
postTag: highlight.postTag
|
|
448
|
-
}) : result.title,
|
|
449
|
-
secondary: /* @__PURE__ */ React.createElement("span", {
|
|
450
|
-
style: {
|
|
451
|
-
display: "-webkit-box",
|
|
452
|
-
WebkitBoxOrient: "vertical",
|
|
453
|
-
WebkitLineClamp: lineClamp,
|
|
454
|
-
overflow: "hidden"
|
|
455
|
-
}
|
|
456
|
-
}, (highlight == null ? void 0 : highlight.fields.text) ? /* @__PURE__ */ React.createElement(HighlightedSearchResultText, {
|
|
457
|
-
text: highlight.fields.text,
|
|
458
|
-
preTag: highlight.preTag,
|
|
459
|
-
postTag: highlight.postTag
|
|
460
|
-
}) : result.text)
|
|
461
|
-
}), secondaryAction && /* @__PURE__ */ React.createElement(Box, {
|
|
462
|
-
alignItems: "flex-end"
|
|
463
|
-
}, secondaryAction)), /* @__PURE__ */ React.createElement(Divider, null));
|
|
464
|
-
};
|
|
465
|
-
|
|
466
|
-
const SearchResultComponent = ({ children }) => {
|
|
467
|
-
const {
|
|
468
|
-
result: { loading, error, value }
|
|
469
|
-
} = useSearch();
|
|
470
|
-
if (loading) {
|
|
471
|
-
return /* @__PURE__ */ React.createElement(Progress, null);
|
|
472
|
-
}
|
|
473
|
-
if (error) {
|
|
474
|
-
return /* @__PURE__ */ React.createElement(ResponseErrorPanel, {
|
|
475
|
-
title: "Error encountered while fetching search results",
|
|
476
|
-
error
|
|
477
|
-
});
|
|
478
|
-
}
|
|
479
|
-
if (!(value == null ? void 0 : value.results.length)) {
|
|
480
|
-
return /* @__PURE__ */ React.createElement(EmptyState, {
|
|
481
|
-
missing: "data",
|
|
482
|
-
title: "Sorry, no results were found"
|
|
483
|
-
});
|
|
484
|
-
}
|
|
485
|
-
return /* @__PURE__ */ React.createElement(React.Fragment, null, children({ results: value.results }));
|
|
486
|
-
};
|
|
487
|
-
|
|
488
|
-
const useStyles$8 = makeStyles((theme) => ({
|
|
489
|
-
root: {
|
|
490
|
-
display: "flex",
|
|
491
|
-
justifyContent: "space-between",
|
|
492
|
-
gap: theme.spacing(2),
|
|
493
|
-
margin: theme.spacing(2, 0)
|
|
494
|
-
}
|
|
495
|
-
}));
|
|
496
|
-
const SearchResultPager = () => {
|
|
497
|
-
const { fetchNextPage, fetchPreviousPage } = useSearch();
|
|
498
|
-
const classes = useStyles$8();
|
|
499
|
-
if (!fetchNextPage && !fetchPreviousPage) {
|
|
500
|
-
return /* @__PURE__ */ React.createElement(React.Fragment, null);
|
|
501
|
-
}
|
|
502
|
-
return /* @__PURE__ */ React.createElement("nav", {
|
|
503
|
-
"arial-label": "pagination navigation",
|
|
504
|
-
className: classes.root
|
|
505
|
-
}, /* @__PURE__ */ React.createElement(Button, {
|
|
506
|
-
"aria-label": "previous page",
|
|
507
|
-
disabled: !fetchPreviousPage,
|
|
508
|
-
onClick: fetchPreviousPage,
|
|
509
|
-
startIcon: /* @__PURE__ */ React.createElement(ArrowBackIosIcon, null)
|
|
510
|
-
}, "Previous"), /* @__PURE__ */ React.createElement(Button, {
|
|
511
|
-
"aria-label": "next page",
|
|
512
|
-
disabled: !fetchNextPage,
|
|
513
|
-
onClick: fetchNextPage,
|
|
514
|
-
endIcon: /* @__PURE__ */ React.createElement(ArrowForwardIosIcon, null)
|
|
515
|
-
}, "Next"));
|
|
516
|
-
};
|
|
517
163
|
|
|
518
164
|
class SearchClient {
|
|
519
165
|
constructor(options) {
|
|
@@ -537,9 +183,6 @@ class SearchClient {
|
|
|
537
183
|
const rootRouteRef = createRouteRef({
|
|
538
184
|
id: "search"
|
|
539
185
|
});
|
|
540
|
-
const rootNextRouteRef = createRouteRef({
|
|
541
|
-
id: "search:next"
|
|
542
|
-
});
|
|
543
186
|
const searchPlugin = createPlugin({
|
|
544
187
|
id: "search",
|
|
545
188
|
apis: [
|
|
@@ -552,64 +195,30 @@ const searchPlugin = createPlugin({
|
|
|
552
195
|
})
|
|
553
196
|
],
|
|
554
197
|
routes: {
|
|
555
|
-
root: rootRouteRef
|
|
556
|
-
nextRoot: rootNextRouteRef
|
|
198
|
+
root: rootRouteRef
|
|
557
199
|
}
|
|
558
200
|
});
|
|
559
201
|
const SearchPage$1 = searchPlugin.provide(createRoutableExtension({
|
|
560
202
|
name: "SearchPage",
|
|
561
|
-
component: () => import('./index-
|
|
203
|
+
component: () => import('./index-5aaf3de8.esm.js').then((m) => m.SearchPage),
|
|
562
204
|
mountPoint: rootRouteRef
|
|
563
205
|
}));
|
|
564
|
-
const
|
|
565
|
-
name: "SearchPageNext",
|
|
566
|
-
component: () => import('./index-b9062edb.esm.js').then((m) => m.SearchPage),
|
|
567
|
-
mountPoint: rootNextRouteRef
|
|
568
|
-
}));
|
|
569
|
-
searchPlugin.provide(createComponentExtension({
|
|
570
|
-
name: "SearchBar",
|
|
571
|
-
component: {
|
|
572
|
-
lazy: () => import('./index-b4559d0a.esm.js').then((m) => m.SearchBar)
|
|
573
|
-
}
|
|
574
|
-
}));
|
|
575
|
-
const SearchBarNext = searchPlugin.provide(createComponentExtension({
|
|
576
|
-
name: "SearchBarNext",
|
|
577
|
-
component: {
|
|
578
|
-
lazy: () => import('./index-b4559d0a.esm.js').then((m) => m.SearchBar)
|
|
579
|
-
}
|
|
580
|
-
}));
|
|
581
|
-
const SearchResult$1 = searchPlugin.provide(createComponentExtension({
|
|
582
|
-
name: "SearchResult",
|
|
583
|
-
component: {
|
|
584
|
-
lazy: () => import('./index-ff98c685.esm.js').then((m) => m.SearchResult)
|
|
585
|
-
}
|
|
586
|
-
}));
|
|
587
|
-
searchPlugin.provide(createComponentExtension({
|
|
588
|
-
name: "SearchResultNext",
|
|
589
|
-
component: {
|
|
590
|
-
lazy: () => import('./index-ff98c685.esm.js').then((m) => m.SearchResult)
|
|
591
|
-
}
|
|
592
|
-
}));
|
|
206
|
+
const SearchResult$1 = SearchResult$2;
|
|
593
207
|
const SidebarSearchModal = searchPlugin.provide(createComponentExtension({
|
|
594
208
|
name: "SidebarSearchModal",
|
|
595
209
|
component: {
|
|
596
|
-
lazy: () => import('./index-
|
|
597
|
-
}
|
|
598
|
-
}));
|
|
599
|
-
const DefaultResultListItem = searchPlugin.provide(createComponentExtension({
|
|
600
|
-
name: "DefaultResultListItem",
|
|
601
|
-
component: {
|
|
602
|
-
lazy: () => import('./index-763c3ecb.esm.js').then((m) => m.DefaultResultListItem)
|
|
210
|
+
lazy: () => import('./index-8a1f0d37.esm.js').then((m) => m.SidebarSearchModal)
|
|
603
211
|
}
|
|
604
212
|
}));
|
|
213
|
+
const DefaultResultListItem = DefaultResultListItem$1;
|
|
605
214
|
const HomePageSearchBar = searchPlugin.provide(createComponentExtension({
|
|
606
215
|
name: "HomePageSearchBar",
|
|
607
216
|
component: {
|
|
608
|
-
lazy: () => import('./index-
|
|
217
|
+
lazy: () => import('./index-2180028e.esm.js').then((m) => m.HomePageSearchBar)
|
|
609
218
|
}
|
|
610
219
|
}));
|
|
611
220
|
|
|
612
|
-
const useStyles$
|
|
221
|
+
const useStyles$8 = makeStyles$1((theme) => ({
|
|
613
222
|
container: {
|
|
614
223
|
borderRadius: 30,
|
|
615
224
|
display: "flex",
|
|
@@ -624,7 +233,7 @@ const useStyles$7 = makeStyles$1((theme) => ({
|
|
|
624
233
|
}));
|
|
625
234
|
const Modal = ({ toggleModal }) => {
|
|
626
235
|
const getSearchLink = useRouteRef(rootRouteRef);
|
|
627
|
-
const classes = useStyles$
|
|
236
|
+
const classes = useStyles$8();
|
|
628
237
|
const { term } = useSearch();
|
|
629
238
|
const { focusContent } = useContent();
|
|
630
239
|
const { transitions } = useTheme();
|
|
@@ -637,7 +246,7 @@ const Modal = ({ toggleModal }) => {
|
|
|
637
246
|
};
|
|
638
247
|
return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(DialogTitle, null, /* @__PURE__ */ React.createElement(Paper, {
|
|
639
248
|
className: classes.container
|
|
640
|
-
}, /* @__PURE__ */ React.createElement(SearchBar$
|
|
249
|
+
}, /* @__PURE__ */ React.createElement(SearchBar$2, {
|
|
641
250
|
className: classes.input
|
|
642
251
|
}))), /* @__PURE__ */ React.createElement(DialogContent, null, /* @__PURE__ */ React.createElement(Grid, {
|
|
643
252
|
container: true,
|
|
@@ -656,7 +265,7 @@ const Modal = ({ toggleModal }) => {
|
|
|
656
265
|
className: classes.viewResultsLink
|
|
657
266
|
}, "View Full Results"), /* @__PURE__ */ React.createElement(LaunchIcon, {
|
|
658
267
|
color: "primary"
|
|
659
|
-
})))), /* @__PURE__ */ React.createElement(Divider, null), /* @__PURE__ */ React.createElement(
|
|
268
|
+
})))), /* @__PURE__ */ React.createElement(Divider, null), /* @__PURE__ */ React.createElement(SearchResult$2, null, ({ results }) => /* @__PURE__ */ React.createElement(List, null, results.map(({ document, highlight }) => /* @__PURE__ */ React.createElement("div", {
|
|
660
269
|
role: "button",
|
|
661
270
|
tabIndex: 0,
|
|
662
271
|
key: `${document.location}-btn`,
|
|
@@ -674,7 +283,7 @@ const Modal = ({ toggleModal }) => {
|
|
|
674
283
|
}, /* @__PURE__ */ React.createElement(Grid, {
|
|
675
284
|
item: true,
|
|
676
285
|
xs: 12
|
|
677
|
-
}, /* @__PURE__ */ React.createElement(SearchResultPager, null)))));
|
|
286
|
+
}, /* @__PURE__ */ React.createElement(SearchResultPager$1, null)))));
|
|
678
287
|
};
|
|
679
288
|
const SearchModal = ({
|
|
680
289
|
open = true,
|
|
@@ -683,7 +292,7 @@ const SearchModal = ({
|
|
|
683
292
|
children
|
|
684
293
|
}) => {
|
|
685
294
|
var _a;
|
|
686
|
-
const classes = useStyles$
|
|
295
|
+
const classes = useStyles$8();
|
|
687
296
|
return /* @__PURE__ */ React.createElement(Dialog, {
|
|
688
297
|
classes: {
|
|
689
298
|
paperFullWidth: classes.paperFullWidth
|
|
@@ -728,7 +337,7 @@ function useSearchModal(initialState = false) {
|
|
|
728
337
|
return (parentContextValue == null ? void 0 : parentContextValue.state) ? parentContextValue : { state, toggleModal, setOpen };
|
|
729
338
|
}
|
|
730
339
|
|
|
731
|
-
const useStyles$
|
|
340
|
+
const useStyles$7 = makeStyles$1(() => ({
|
|
732
341
|
root: {
|
|
733
342
|
display: "flex",
|
|
734
343
|
alignItems: "center"
|
|
@@ -742,7 +351,7 @@ const SearchBar = ({
|
|
|
742
351
|
handleSearch,
|
|
743
352
|
handleClearSearchBar
|
|
744
353
|
}) => {
|
|
745
|
-
const classes = useStyles$
|
|
354
|
+
const classes = useStyles$7();
|
|
746
355
|
return /* @__PURE__ */ React.createElement(Paper, {
|
|
747
356
|
component: "form",
|
|
748
357
|
onSubmit: (e) => handleSearch(e),
|
|
@@ -751,7 +360,7 @@ const SearchBar = ({
|
|
|
751
360
|
disabled: true,
|
|
752
361
|
type: "submit",
|
|
753
362
|
"aria-label": "search"
|
|
754
|
-
}, /* @__PURE__ */ React.createElement(SearchIcon, null)), /* @__PURE__ */ React.createElement(InputBase
|
|
363
|
+
}, /* @__PURE__ */ React.createElement(SearchIcon, null)), /* @__PURE__ */ React.createElement(InputBase, {
|
|
755
364
|
className: classes.input,
|
|
756
365
|
placeholder: "Search in Backstage",
|
|
757
366
|
value: searchQuery,
|
|
@@ -763,7 +372,7 @@ const SearchBar = ({
|
|
|
763
372
|
}, /* @__PURE__ */ React.createElement(ClearButton, null)));
|
|
764
373
|
};
|
|
765
374
|
|
|
766
|
-
const useStyles$
|
|
375
|
+
const useStyles$6 = makeStyles((theme) => ({
|
|
767
376
|
filters: {
|
|
768
377
|
width: "250px",
|
|
769
378
|
display: "flex"
|
|
@@ -776,7 +385,7 @@ const FiltersButton = ({
|
|
|
776
385
|
numberOfSelectedFilters,
|
|
777
386
|
handleToggleFilters
|
|
778
387
|
}) => {
|
|
779
|
-
const classes = useStyles$
|
|
388
|
+
const classes = useStyles$6();
|
|
780
389
|
return /* @__PURE__ */ React.createElement("div", {
|
|
781
390
|
className: classes.filters
|
|
782
391
|
}, /* @__PURE__ */ React.createElement(IconButton, {
|
|
@@ -788,7 +397,7 @@ const FiltersButton = ({
|
|
|
788
397
|
}, "Filters (", numberOfSelectedFilters ? numberOfSelectedFilters : 0, ")"));
|
|
789
398
|
};
|
|
790
399
|
|
|
791
|
-
const useStyles$
|
|
400
|
+
const useStyles$5 = makeStyles((theme) => ({
|
|
792
401
|
filters: {
|
|
793
402
|
background: "transparent",
|
|
794
403
|
boxShadow: "0px 0px 0px 0px"
|
|
@@ -807,7 +416,7 @@ const Filters = ({
|
|
|
807
416
|
updateSelected,
|
|
808
417
|
updateChecked
|
|
809
418
|
}) => {
|
|
810
|
-
const classes = useStyles$
|
|
419
|
+
const classes = useStyles$5();
|
|
811
420
|
return /* @__PURE__ */ React.createElement(Card, {
|
|
812
421
|
className: classes.filters
|
|
813
422
|
}, /* @__PURE__ */ React.createElement(CardHeader, {
|
|
@@ -861,7 +470,7 @@ const Filters = ({
|
|
|
861
470
|
}))))));
|
|
862
471
|
};
|
|
863
472
|
|
|
864
|
-
const useStyles$
|
|
473
|
+
const useStyles$4 = makeStyles((theme) => ({
|
|
865
474
|
searchQuery: {
|
|
866
475
|
color: theme.palette.text.primary,
|
|
867
476
|
background: theme.palette.background.default,
|
|
@@ -909,7 +518,7 @@ const TableHeader = ({
|
|
|
909
518
|
numberOfResults,
|
|
910
519
|
handleToggleFilters
|
|
911
520
|
}) => {
|
|
912
|
-
const classes = useStyles$
|
|
521
|
+
const classes = useStyles$4();
|
|
913
522
|
return /* @__PURE__ */ React.createElement("div", {
|
|
914
523
|
className: classes.tableHeader
|
|
915
524
|
}, /* @__PURE__ */ React.createElement(FiltersButton, {
|
|
@@ -1135,6 +744,36 @@ const SearchPage = () => {
|
|
|
1135
744
|
return /* @__PURE__ */ React.createElement(SearchContextProvider, null, /* @__PURE__ */ React.createElement(UrlUpdater, null), outlet || /* @__PURE__ */ React.createElement(LegacySearchPage, null));
|
|
1136
745
|
};
|
|
1137
746
|
|
|
747
|
+
const useStyles$3 = makeStyles((theme) => ({
|
|
748
|
+
root: {
|
|
749
|
+
display: "flex",
|
|
750
|
+
justifyContent: "space-between",
|
|
751
|
+
gap: theme.spacing(2),
|
|
752
|
+
margin: theme.spacing(2, 0)
|
|
753
|
+
}
|
|
754
|
+
}));
|
|
755
|
+
const SearchResultPager = () => {
|
|
756
|
+
const { fetchNextPage, fetchPreviousPage } = useSearch();
|
|
757
|
+
const classes = useStyles$3();
|
|
758
|
+
if (!fetchNextPage && !fetchPreviousPage) {
|
|
759
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null);
|
|
760
|
+
}
|
|
761
|
+
return /* @__PURE__ */ React.createElement("nav", {
|
|
762
|
+
"arial-label": "pagination navigation",
|
|
763
|
+
className: classes.root
|
|
764
|
+
}, /* @__PURE__ */ React.createElement(Button, {
|
|
765
|
+
"aria-label": "previous page",
|
|
766
|
+
disabled: !fetchPreviousPage,
|
|
767
|
+
onClick: fetchPreviousPage,
|
|
768
|
+
startIcon: /* @__PURE__ */ React.createElement(ArrowBackIosIcon, null)
|
|
769
|
+
}, "Previous"), /* @__PURE__ */ React.createElement(Button, {
|
|
770
|
+
"aria-label": "next page",
|
|
771
|
+
disabled: !fetchNextPage,
|
|
772
|
+
onClick: fetchNextPage,
|
|
773
|
+
endIcon: /* @__PURE__ */ React.createElement(ArrowForwardIosIcon, null)
|
|
774
|
+
}, "Next"));
|
|
775
|
+
};
|
|
776
|
+
|
|
1138
777
|
const useStyles$2 = makeStyles((theme) => ({
|
|
1139
778
|
card: {
|
|
1140
779
|
backgroundColor: "rgba(0, 0, 0, .11)"
|
|
@@ -1374,5 +1013,5 @@ const SidebarSearch = (props) => {
|
|
|
1374
1013
|
});
|
|
1375
1014
|
};
|
|
1376
1015
|
|
|
1377
|
-
export { DefaultResultListItem
|
|
1378
|
-
//# sourceMappingURL=index-
|
|
1016
|
+
export { DefaultResultListItem as D, Filters$1 as F, HomePageSearchBar as H, SearchPage as S, SearchModalProvider as a, SearchModal as b, FiltersButton$1 as c, SearchBar$1 as d, SearchBarBase as e, SearchFilter as f, SearchResultPager as g, SearchType as h, SidebarSearch as i, SearchPage$1 as j, SearchResult$1 as k, SidebarSearchModal as l, rootRouteRef as r, searchPlugin as s, useSearchModal as u };
|
|
1017
|
+
//# sourceMappingURL=index-8388a95e.esm.js.map
|