@backstage/plugin-search 1.4.25-next.1 → 1.4.25-next.2
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 +21 -0
- package/README.md +1 -1
- package/dist/alpha.d.ts +3 -3
- package/dist/alpha.esm.js +103 -80
- package/dist/alpha.esm.js.map +1 -1
- package/dist/components/HomePageComponent/HomePageSearchBar.esm.js +3 -2
- package/dist/components/HomePageComponent/HomePageSearchBar.esm.js.map +1 -1
- package/dist/components/SearchModal/SearchModal.esm.js +59 -47
- package/dist/components/SearchModal/SearchModal.esm.js.map +1 -1
- package/dist/components/SearchModal/useSearchModal.esm.js +3 -2
- package/dist/components/SearchModal/useSearchModal.esm.js.map +1 -1
- package/dist/components/SearchPage/SearchPage.esm.js +6 -2
- package/dist/components/SearchPage/SearchPage.esm.js.map +1 -1
- package/dist/components/SearchType/SearchType.Accordion.esm.js +60 -49
- package/dist/components/SearchType/SearchType.Accordion.esm.js.map +1 -1
- package/dist/components/SearchType/SearchType.Tabs.esm.js +14 -13
- package/dist/components/SearchType/SearchType.Tabs.esm.js.map +1 -1
- package/dist/components/SearchType/SearchType.esm.js +30 -25
- package/dist/components/SearchType/SearchType.esm.js.map +1 -1
- package/dist/components/SidebarSearch/SidebarSearch.esm.js +3 -2
- package/dist/components/SidebarSearch/SidebarSearch.esm.js.map +1 -1
- package/dist/components/SidebarSearchModal/SidebarSearchModal.esm.js +22 -19
- package/dist/components/SidebarSearchModal/SidebarSearchModal.esm.js.map +1 -1
- package/dist/index.d.ts +11 -11
- package/package.json +14 -14
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { useEffect } from 'react';
|
|
2
3
|
import usePrevious from 'react-use/esm/usePrevious';
|
|
3
4
|
import qs from 'qs';
|
|
4
5
|
import { useOutlet, useLocation } from 'react-router-dom';
|
|
@@ -52,7 +53,10 @@ const UrlUpdater = () => {
|
|
|
52
53
|
};
|
|
53
54
|
const SearchPage = () => {
|
|
54
55
|
const outlet = useOutlet();
|
|
55
|
-
return /* @__PURE__ */
|
|
56
|
+
return /* @__PURE__ */ jsxs(SearchContextProvider, { children: [
|
|
57
|
+
/* @__PURE__ */ jsx(UrlUpdater, {}),
|
|
58
|
+
outlet
|
|
59
|
+
] });
|
|
56
60
|
};
|
|
57
61
|
|
|
58
62
|
export { SearchPage, UrlUpdater };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SearchPage.esm.js","sources":["../../../src/components/SearchPage/SearchPage.tsx"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport
|
|
1
|
+
{"version":3,"file":"SearchPage.esm.js","sources":["../../../src/components/SearchPage/SearchPage.tsx"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { useEffect } from 'react';\nimport usePrevious from 'react-use/esm/usePrevious';\nimport qs from 'qs';\nimport { useLocation, useOutlet } from 'react-router-dom';\nimport {\n SearchContextProvider,\n useSearch,\n} from '@backstage/plugin-search-react';\nimport { JsonObject } from '@backstage/types';\n\nexport const UrlUpdater = () => {\n const location = useLocation();\n const {\n term,\n setTerm,\n types,\n setTypes,\n pageCursor,\n setPageCursor,\n filters,\n setFilters,\n } = useSearch();\n\n const prevQueryParams = usePrevious(location.search);\n useEffect(() => {\n // Only respond to changes to url query params\n if (location.search === prevQueryParams) {\n return;\n }\n\n const query =\n qs.parse(location.search.substring(1), { arrayLimit: 0 }) || {};\n\n if (query.filters) {\n setFilters(query.filters as JsonObject);\n }\n\n if (query.query) {\n setTerm(query.query as string);\n }\n\n if (query.pageCursor) {\n setPageCursor(query.pageCursor as string);\n }\n\n if (query.types) {\n setTypes(query.types as string[]);\n }\n }, [prevQueryParams, location, setTerm, setTypes, setPageCursor, setFilters]);\n\n useEffect(() => {\n const newParams = qs.stringify(\n {\n query: term,\n types,\n pageCursor,\n filters,\n },\n { arrayFormat: 'brackets' },\n );\n const newUrl = `${window.location.pathname}?${newParams}`;\n\n // We directly manipulate window history here in order to not re-render\n // infinitely (state => location => state => etc). The intention of this\n // code is just to ensure the right query/filters are loaded when a user\n // clicks the \"back\" button after clicking a result.\n window.history.replaceState(null, document.title, newUrl);\n }, [term, types, pageCursor, filters]);\n\n return null;\n};\n\n/**\n * @public\n */\nexport const SearchPage = () => {\n const outlet = useOutlet();\n\n return (\n <SearchContextProvider>\n <UrlUpdater />\n {outlet}\n </SearchContextProvider>\n );\n};\n"],"names":[],"mappings":";;;;;;;AA0BO,MAAM,aAAa,MAAM;AAC9B,EAAA,MAAM,WAAW,WAAY,EAAA;AAC7B,EAAM,MAAA;AAAA,IACJ,IAAA;AAAA,IACA,OAAA;AAAA,IACA,KAAA;AAAA,IACA,QAAA;AAAA,IACA,UAAA;AAAA,IACA,aAAA;AAAA,IACA,OAAA;AAAA,IACA;AAAA,MACE,SAAU,EAAA;AAEd,EAAM,MAAA,eAAA,GAAkB,WAAY,CAAA,QAAA,CAAS,MAAM,CAAA;AACnD,EAAA,SAAA,CAAU,MAAM;AAEd,IAAI,IAAA,QAAA,CAAS,WAAW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A,oBAAA,GAAA,CAAC,UAAW,EAAA,EAAA,CAAA;AAAA,IACX;AAAA,GACH,EAAA,CAAA;AAEJ;;;;"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
2
|
+
import { useState, useEffect, Fragment, cloneElement } from 'react';
|
|
2
3
|
import { useApi } from '@backstage/core-plugin-api';
|
|
3
4
|
import { useSearch, searchApiRef } from '@backstage/plugin-search-react';
|
|
4
5
|
import Accordion from '@material-ui/core/Accordion';
|
|
@@ -68,7 +69,7 @@ const SearchTypeAccordion = (props) => {
|
|
|
68
69
|
{
|
|
69
70
|
value: "",
|
|
70
71
|
name: "All",
|
|
71
|
-
icon: /* @__PURE__ */
|
|
72
|
+
icon: /* @__PURE__ */ jsx(AllIcon, {})
|
|
72
73
|
},
|
|
73
74
|
...givenTypes
|
|
74
75
|
];
|
|
@@ -93,54 +94,64 @@ const SearchTypeAccordion = (props) => {
|
|
|
93
94
|
);
|
|
94
95
|
return Object.fromEntries(counts);
|
|
95
96
|
}, [filters, showCounts, term, types]);
|
|
96
|
-
return /* @__PURE__ */
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
expanded,
|
|
101
|
-
onChange: toggleExpanded
|
|
102
|
-
},
|
|
103
|
-
/* @__PURE__ */ React.createElement(
|
|
104
|
-
AccordionSummary,
|
|
105
|
-
{
|
|
106
|
-
classes: {
|
|
107
|
-
root: classes.accordionSummary,
|
|
108
|
-
content: classes.accordionSummaryContent
|
|
109
|
-
},
|
|
110
|
-
expandIcon: /* @__PURE__ */ React.createElement(ExpandMoreIcon, { className: classes.icon }),
|
|
111
|
-
IconButtonProps: { size: "small" }
|
|
112
|
-
},
|
|
113
|
-
expanded ? "Collapse" : definedTypes.filter((t) => t.value === selected)[0].name
|
|
114
|
-
),
|
|
115
|
-
/* @__PURE__ */ React.createElement(AccordionDetails, { classes: { root: classes.accordionDetails } }, /* @__PURE__ */ React.createElement(
|
|
116
|
-
List,
|
|
97
|
+
return /* @__PURE__ */ jsxs(Box, { children: [
|
|
98
|
+
/* @__PURE__ */ jsx(Typography, { variant: "body2", component: "h2", children: name }),
|
|
99
|
+
/* @__PURE__ */ jsxs(
|
|
100
|
+
Accordion,
|
|
117
101
|
{
|
|
118
|
-
className: classes.
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
102
|
+
className: classes.accordion,
|
|
103
|
+
expanded,
|
|
104
|
+
onChange: toggleExpanded,
|
|
105
|
+
children: [
|
|
106
|
+
/* @__PURE__ */ jsx(
|
|
107
|
+
AccordionSummary,
|
|
108
|
+
{
|
|
109
|
+
classes: {
|
|
110
|
+
root: classes.accordionSummary,
|
|
111
|
+
content: classes.accordionSummaryContent
|
|
112
|
+
},
|
|
113
|
+
expandIcon: /* @__PURE__ */ jsx(ExpandMoreIcon, { className: classes.icon }),
|
|
114
|
+
IconButtonProps: { size: "small" },
|
|
115
|
+
children: expanded ? "Collapse" : definedTypes.filter((t) => t.value === selected)[0].name
|
|
116
|
+
}
|
|
117
|
+
),
|
|
118
|
+
/* @__PURE__ */ jsx(AccordionDetails, { classes: { root: classes.accordionDetails }, children: /* @__PURE__ */ jsx(
|
|
119
|
+
List,
|
|
120
|
+
{
|
|
121
|
+
className: classes.list,
|
|
122
|
+
component: "nav",
|
|
123
|
+
"aria-label": "filter by type",
|
|
124
|
+
disablePadding: true,
|
|
125
|
+
dense: true,
|
|
126
|
+
children: definedTypes.map((type) => /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
127
|
+
/* @__PURE__ */ jsx(Divider, {}),
|
|
128
|
+
/* @__PURE__ */ jsxs(
|
|
129
|
+
ListItem,
|
|
130
|
+
{
|
|
131
|
+
selected: types[0] === type.value || types.length === 0 && type.value === "",
|
|
132
|
+
onClick: handleClick(type.value),
|
|
133
|
+
button: true,
|
|
134
|
+
children: [
|
|
135
|
+
/* @__PURE__ */ jsx(ListItemIcon, { children: cloneElement(type.icon, {
|
|
136
|
+
className: classes.listItemIcon
|
|
137
|
+
}) }),
|
|
138
|
+
/* @__PURE__ */ jsx(
|
|
139
|
+
ListItemText,
|
|
140
|
+
{
|
|
141
|
+
primary: type.name,
|
|
142
|
+
secondary: resultCounts && resultCounts[type.value]
|
|
143
|
+
}
|
|
144
|
+
)
|
|
145
|
+
]
|
|
146
|
+
}
|
|
147
|
+
)
|
|
148
|
+
] }, type.value))
|
|
149
|
+
}
|
|
150
|
+
) })
|
|
151
|
+
]
|
|
152
|
+
}
|
|
153
|
+
)
|
|
154
|
+
] });
|
|
144
155
|
};
|
|
145
156
|
|
|
146
157
|
export { SearchTypeAccordion };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SearchType.Accordion.esm.js","sources":["../../../src/components/SearchType/SearchType.Accordion.tsx"],"sourcesContent":["/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React, { cloneElement, Fragment, useEffect, useState } from 'react';\nimport { useApi } from '@backstage/core-plugin-api';\nimport { searchApiRef, useSearch } from '@backstage/plugin-search-react';\nimport Accordion from '@material-ui/core/Accordion';\nimport AccordionSummary from '@material-ui/core/AccordionSummary';\nimport AccordionDetails from '@material-ui/core/AccordionDetails';\nimport Box from '@material-ui/core/Box';\nimport Divider from '@material-ui/core/Divider';\nimport List from '@material-ui/core/List';\nimport ListItem from '@material-ui/core/ListItem';\nimport ListItemIcon from '@material-ui/core/ListItemIcon';\nimport ListItemText from '@material-ui/core/ListItemText';\nimport { makeStyles } from '@material-ui/core/styles';\nimport ExpandMoreIcon from '@material-ui/icons/ExpandMore';\nimport Typography from '@material-ui/core/Typography';\nimport AllIcon from '@material-ui/icons/FontDownload';\nimport useAsync from 'react-use/esm/useAsync';\n\nconst useStyles = makeStyles(theme => ({\n icon: {\n color: theme.palette.text.primary,\n },\n list: {\n width: '100%',\n },\n listItemIcon: {\n width: '24px',\n height: '24px',\n },\n accordion: {\n backgroundColor: theme.palette.background.paper,\n },\n accordionSummary: {\n minHeight: 'auto',\n '&.Mui-expanded': {\n minHeight: 'auto',\n },\n },\n accordionSummaryContent: {\n margin: theme.spacing(2, 0),\n '&.Mui-expanded': {\n margin: theme.spacing(2, 0),\n },\n },\n accordionDetails: {\n padding: theme.spacing(0, 0, 1),\n },\n}));\n\n/**\n * @public\n */\nexport type SearchTypeAccordionProps = {\n name: string;\n types: Array<{\n value: string;\n name: string;\n icon: JSX.Element;\n }>;\n defaultValue?: string;\n showCounts?: boolean;\n};\n\nexport const SearchTypeAccordion = (props: SearchTypeAccordionProps) => {\n const classes = useStyles();\n const { filters, setPageCursor, setTypes, term, types } = useSearch();\n const searchApi = useApi(searchApiRef);\n const [expanded, setExpanded] = useState(true);\n const { defaultValue, name, showCounts, types: givenTypes } = props;\n\n const toggleExpanded = () => setExpanded(prevState => !prevState);\n const handleClick = (type: string) => {\n return () => {\n setTypes(type !== '' ? [type] : []);\n setPageCursor(undefined);\n };\n };\n\n // Handle any provided defaultValue\n useEffect(() => {\n if (defaultValue) {\n setTypes([defaultValue]);\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n const definedTypes = [\n {\n value: '',\n name: 'All',\n icon: <AllIcon />,\n },\n ...givenTypes,\n ];\n const selected = types[0] || '';\n\n const { value: resultCounts } = useAsync(async () => {\n if (!showCounts) {\n return {};\n }\n\n const counts = await Promise.all(\n definedTypes\n .map(t => t.value)\n .map(async type => {\n const { numberOfResults } = await searchApi.query({\n term,\n types: type ? [type] : [],\n filters:\n types.includes(type) || (!types.length && !type) ? filters : {},\n pageLimit: 0,\n });\n\n return [\n type,\n numberOfResults !== undefined\n ? `${\n numberOfResults >= 10000 ? `>10000` : numberOfResults\n } results`\n : ' -- ',\n ];\n }),\n );\n\n return Object.fromEntries(counts);\n }, [filters, showCounts, term, types]);\n\n return (\n <Box>\n <Typography variant=\"body2\" component=\"h2\">\n {name}\n </Typography>\n <Accordion\n className={classes.accordion}\n expanded={expanded}\n onChange={toggleExpanded}\n >\n <AccordionSummary\n classes={{\n root: classes.accordionSummary,\n content: classes.accordionSummaryContent,\n }}\n expandIcon={<ExpandMoreIcon className={classes.icon} />}\n IconButtonProps={{ size: 'small' }}\n >\n {expanded\n ? 'Collapse'\n : definedTypes.filter(t => t.value === selected)[0]!.name}\n </AccordionSummary>\n <AccordionDetails classes={{ root: classes.accordionDetails }}>\n <List\n className={classes.list}\n component=\"nav\"\n aria-label=\"filter by type\"\n disablePadding\n dense\n >\n {definedTypes.map(type => (\n <Fragment key={type.value}>\n <Divider />\n <ListItem\n selected={\n types[0] === type.value ||\n (types.length === 0 && type.value === '')\n }\n onClick={handleClick(type.value)}\n button\n >\n <ListItemIcon>\n {cloneElement(type.icon, {\n className: classes.listItemIcon,\n })}\n </ListItemIcon>\n <ListItemText\n primary={type.name}\n secondary={resultCounts && resultCounts[type.value]}\n />\n </ListItem>\n </Fragment>\n ))}\n </List>\n </AccordionDetails>\n </Accordion>\n </Box>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAkCA,MAAM,SAAA,GAAY,WAAW,CAAU,KAAA,MAAA;AAAA,EACrC,IAAM,EAAA;AAAA,IACJ,KAAA,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AW,OAAQ,CAAA,IAAA;AAAA,QACnB,SAAU,EAAA,KAAA;AAAA,QACV,YAAW,EAAA,gBAAA;AAAA,QACX,cAAc,EAAA,IAAA;AAAA,QACd,KAAK,EAAA;AAAA,OAAA;AAAA,MAEJ,YAAA,CAAa,GAAI,CAAA,CAAA,IAAA,qBACf,KAAA,CAAA,aAAA,CAAA,QAAA,EAAA,EAAS,KAAK,IAAK,CAAA,KAAA,EAAA,kBACjB,KAAA,CAAA,aAAA,CAAA,OAAA,EAAA,IAAQ,CACT,kBAAA,KAAA,CAAA,aAAA;AAAA,QAAC,QAAA;AAAA,QAAA;AAAA,UACC,QAAA,EACE,KAAM,CAAA,CAAC,CAAM,KAAA,IAAA,CAAK,SACjB,KAAM,CAAA,MAAA,KAAW,CAAK,IAAA,IAAA,CAAK,KAAU,KAAA,EAAA;AAAA,UAExC,OAAA,EAAS,WAAY,CAAA,IAAA,CAAK,KAAK,CAAA;AAAA,UAC/B,MAAM,EAAA;AAAA,SAAA;AAAA,wBAEL,KAAA,CAAA,aAAA,CAAA,YAAA,EAAA,IAAA,EACE,YAAa,CAAA,IAAA,CAAK,IAAM,EAAA;AAAA,UACvB,WAAW,OAAQ,CAAA;AAAA,SACpB,CACH,CAAA;AAAA,wBACA,KAAA,CAAA,aAAA;AAAA,UAAC,YAAA;AAAA,UAAA;AAAA,YACC,SAAS,IAAK,CAAA,IAAA;AAAA,YACd,SAAW,EAAA,YAAA,IAAgB,YAAa,CAAA,IAAA,CAAK,KAAK;AAAA;AAAA;AACpD,OAEJ,CACD;AAAA,KAEL;AAAA,GAEJ,CAAA;AAEJ;;;;"}
|
|
1
|
+
{"version":3,"file":"SearchType.Accordion.esm.js","sources":["../../../src/components/SearchType/SearchType.Accordion.tsx"],"sourcesContent":["/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { cloneElement, Fragment, useEffect, useState } from 'react';\nimport { useApi } from '@backstage/core-plugin-api';\nimport { searchApiRef, useSearch } from '@backstage/plugin-search-react';\nimport Accordion from '@material-ui/core/Accordion';\nimport AccordionSummary from '@material-ui/core/AccordionSummary';\nimport AccordionDetails from '@material-ui/core/AccordionDetails';\nimport Box from '@material-ui/core/Box';\nimport Divider from '@material-ui/core/Divider';\nimport List from '@material-ui/core/List';\nimport ListItem from '@material-ui/core/ListItem';\nimport ListItemIcon from '@material-ui/core/ListItemIcon';\nimport ListItemText from '@material-ui/core/ListItemText';\nimport { makeStyles } from '@material-ui/core/styles';\nimport ExpandMoreIcon from '@material-ui/icons/ExpandMore';\nimport Typography from '@material-ui/core/Typography';\nimport AllIcon from '@material-ui/icons/FontDownload';\nimport useAsync from 'react-use/esm/useAsync';\n\nconst useStyles = makeStyles(theme => ({\n icon: {\n color: theme.palette.text.primary,\n },\n list: {\n width: '100%',\n },\n listItemIcon: {\n width: '24px',\n height: '24px',\n },\n accordion: {\n backgroundColor: theme.palette.background.paper,\n },\n accordionSummary: {\n minHeight: 'auto',\n '&.Mui-expanded': {\n minHeight: 'auto',\n },\n },\n accordionSummaryContent: {\n margin: theme.spacing(2, 0),\n '&.Mui-expanded': {\n margin: theme.spacing(2, 0),\n },\n },\n accordionDetails: {\n padding: theme.spacing(0, 0, 1),\n },\n}));\n\n/**\n * @public\n */\nexport type SearchTypeAccordionProps = {\n name: string;\n types: Array<{\n value: string;\n name: string;\n icon: JSX.Element;\n }>;\n defaultValue?: string;\n showCounts?: boolean;\n};\n\nexport const SearchTypeAccordion = (props: SearchTypeAccordionProps) => {\n const classes = useStyles();\n const { filters, setPageCursor, setTypes, term, types } = useSearch();\n const searchApi = useApi(searchApiRef);\n const [expanded, setExpanded] = useState(true);\n const { defaultValue, name, showCounts, types: givenTypes } = props;\n\n const toggleExpanded = () => setExpanded(prevState => !prevState);\n const handleClick = (type: string) => {\n return () => {\n setTypes(type !== '' ? [type] : []);\n setPageCursor(undefined);\n };\n };\n\n // Handle any provided defaultValue\n useEffect(() => {\n if (defaultValue) {\n setTypes([defaultValue]);\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n const definedTypes = [\n {\n value: '',\n name: 'All',\n icon: <AllIcon />,\n },\n ...givenTypes,\n ];\n const selected = types[0] || '';\n\n const { value: resultCounts } = useAsync(async () => {\n if (!showCounts) {\n return {};\n }\n\n const counts = await Promise.all(\n definedTypes\n .map(t => t.value)\n .map(async type => {\n const { numberOfResults } = await searchApi.query({\n term,\n types: type ? [type] : [],\n filters:\n types.includes(type) || (!types.length && !type) ? filters : {},\n pageLimit: 0,\n });\n\n return [\n type,\n numberOfResults !== undefined\n ? `${\n numberOfResults >= 10000 ? `>10000` : numberOfResults\n } results`\n : ' -- ',\n ];\n }),\n );\n\n return Object.fromEntries(counts);\n }, [filters, showCounts, term, types]);\n\n return (\n <Box>\n <Typography variant=\"body2\" component=\"h2\">\n {name}\n </Typography>\n <Accordion\n className={classes.accordion}\n expanded={expanded}\n onChange={toggleExpanded}\n >\n <AccordionSummary\n classes={{\n root: classes.accordionSummary,\n content: classes.accordionSummaryContent,\n }}\n expandIcon={<ExpandMoreIcon className={classes.icon} />}\n IconButtonProps={{ size: 'small' }}\n >\n {expanded\n ? 'Collapse'\n : definedTypes.filter(t => t.value === selected)[0]!.name}\n </AccordionSummary>\n <AccordionDetails classes={{ root: classes.accordionDetails }}>\n <List\n className={classes.list}\n component=\"nav\"\n aria-label=\"filter by type\"\n disablePadding\n dense\n >\n {definedTypes.map(type => (\n <Fragment key={type.value}>\n <Divider />\n <ListItem\n selected={\n types[0] === type.value ||\n (types.length === 0 && type.value === '')\n }\n onClick={handleClick(type.value)}\n button\n >\n <ListItemIcon>\n {cloneElement(type.icon, {\n className: classes.listItemIcon,\n })}\n </ListItemIcon>\n <ListItemText\n primary={type.name}\n secondary={resultCounts && resultCounts[type.value]}\n />\n </ListItem>\n </Fragment>\n ))}\n </List>\n </AccordionDetails>\n </Accordion>\n </Box>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;AAkCA,MAAM,SAAA,GAAY,WAAW,CAAU,KAAA,MAAA;AAAA,EACrC,IAAM,EAAA;AAAA,IACJ,KAAA,EAAO,KAAM,CAAA,OAAA,CAAQ,IAAK,CAAA;AAAA,GAC5B;AAAA,EACA,IAAM,EAAA;AAAA,IACJ,KAAO,EAAA;AAAA,GACT;AAAA,EACA,YAAc,EAAA;AAAA,IACZ,KAAO,EAAA,MAAA;AAAA,IACP,MAAQ,EAAA;AAAA,GACV;AAAA,EACA,SAAW,EAAA;AAAA,IACT,eAAA,EAAiB,KAAM,CAAA,OAAA,CAAQ,UAAW,CAAA;AAAA,GAC5C;AAAA,EACA,gBAAkB,EAAA;AAAA,IAChB,SAAW,EAAA,MAAA;AAAA,IACX,gBAAkB,EAAA;AAAA,MAChB,SAAW,EAAA;AAAA;AACb,GACF;AAAA,EACA,uBAAyB,EAAA;AAAA,IACvB,MAAQ,EAAA,KAAA,CAAM,OAAQ,CAAA,CAAA,EAAG,CAAC,CAAA;AAAA,IAC1B,gBAAkB,EAAA;AAAA,MAChB,MAAQ,EAAA,KAAA,CAAM,OAAQ,CAAA,CAAA,EAAG,CAAC;AAAA;AAC5B,GACF;AAAA,EACA,gBAAkB,EAAA;AAAA,IAChB,OAAS,EAAA,KAAA,CAAM,OAAQ,CAAA,CAAA,EAAG,GAAG,CAAC;AAAA;AAElC,CAAE,CAAA,CAAA;AAgBW,MAAA,mBAAA,GAAsB,CAAC,KAAoC,KAAA;AACtE,EAAA,MAAM,UAAU,SAAU,EAAA;AAC1B,EAAA,MAAM,EAAE,OAAS,EAAA,aAAA,EAAe,UAAU,IAAM,EAAA,KAAA,KAA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AAAA;AAAA;AACpD;AAAA;AAAA;AACF,eAnBa,EAAA,EAAA,IAAA,CAAK,KAoBpB,CACD;AAAA;AAAA,WAEL,EAAA;AAAA;AAAA;AAAA;AACF,GACF,EAAA,CAAA;AAEJ;;;;"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { useEffect } from 'react';
|
|
2
3
|
import { useSearch } from '@backstage/plugin-search-react';
|
|
3
4
|
import Tab from '@material-ui/core/Tab';
|
|
4
5
|
import Tabs from '@material-ui/core/Tabs';
|
|
@@ -36,24 +37,24 @@ const SearchTypeTabs = (props) => {
|
|
|
36
37
|
},
|
|
37
38
|
...givenTypes
|
|
38
39
|
];
|
|
39
|
-
return /* @__PURE__ */
|
|
40
|
+
return /* @__PURE__ */ jsx(
|
|
40
41
|
Tabs,
|
|
41
42
|
{
|
|
42
43
|
"aria-label": "List of search types tabs",
|
|
43
44
|
className: classes.tabs,
|
|
44
45
|
indicatorColor: "primary",
|
|
45
46
|
value: types.length === 0 ? "" : types[0],
|
|
46
|
-
onChange: changeTab
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
47
|
+
onChange: changeTab,
|
|
48
|
+
children: definedTypes.map((type, idx) => /* @__PURE__ */ jsx(
|
|
49
|
+
Tab,
|
|
50
|
+
{
|
|
51
|
+
className: classes.tab,
|
|
52
|
+
label: type.name,
|
|
53
|
+
value: type.value
|
|
54
|
+
},
|
|
55
|
+
idx
|
|
56
|
+
))
|
|
57
|
+
}
|
|
57
58
|
);
|
|
58
59
|
};
|
|
59
60
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SearchType.Tabs.esm.js","sources":["../../../src/components/SearchType/SearchType.Tabs.tsx"],"sourcesContent":["/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport
|
|
1
|
+
{"version":3,"file":"SearchType.Tabs.esm.js","sources":["../../../src/components/SearchType/SearchType.Tabs.tsx"],"sourcesContent":["/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { ChangeEvent, useEffect } from 'react';\nimport { useSearch } from '@backstage/plugin-search-react';\nimport Tab from '@material-ui/core/Tab';\nimport Tabs from '@material-ui/core/Tabs';\nimport { makeStyles } from '@material-ui/core/styles';\nimport { Theme } from '@material-ui/core/styles';\n\nconst useStyles = makeStyles((theme: Theme) => ({\n tabs: {\n borderBottom: `1px solid ${theme.palette.textVerySubtle}`,\n },\n tab: {\n height: '50px',\n fontWeight: theme.typography.fontWeightBold,\n fontSize: theme.typography.pxToRem(13),\n color: theme.palette.text.primary,\n minWidth: '130px',\n },\n}));\n\n/**\n * @public\n */\nexport type SearchTypeTabsProps = {\n types: Array<{\n value: string;\n name: string;\n }>;\n defaultValue?: string;\n};\n\nexport const SearchTypeTabs = (props: SearchTypeTabsProps) => {\n const classes = useStyles();\n const { setPageCursor, setTypes, types } = useSearch();\n const { defaultValue, types: givenTypes } = props;\n\n const changeTab = (_: ChangeEvent<{}>, newType: string) => {\n setTypes(newType !== '' ? [newType] : []);\n setPageCursor(undefined);\n };\n\n // Handle any provided defaultValue\n useEffect(() => {\n if (defaultValue) {\n setTypes([defaultValue]);\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n const definedTypes = [\n {\n value: '',\n name: 'All',\n },\n ...givenTypes,\n ];\n\n return (\n <Tabs\n aria-label=\"List of search types tabs\"\n className={classes.tabs}\n indicatorColor=\"primary\"\n value={types.length === 0 ? '' : types[0]}\n onChange={changeTab}\n >\n {definedTypes.map((type, idx) => (\n <Tab\n key={idx}\n className={classes.tab}\n label={type.name}\n value={type.value}\n />\n ))}\n </Tabs>\n );\n};\n"],"names":[],"mappings":";;;;;;;AAuBA,MAAM,SAAA,GAAY,UAAW,CAAA,CAAC,KAAkB,MAAA;AAAA,EAC9C,IAAM,EAAA;AAAA,IACJ,YAAc,EAAA,CAAA,UAAA,EAAa,KAAM,CAAA,OAAA,CAAQ,cAAc,CAAA;AAAA,GACzD;AAAA,EACA,GAAK,EAAA;AAAA,IACH,MAAQ,EAAA,MAAA;AAAA,IACR,UAAA,EAAY,MAAM,UAAW,CAAA,cAAA;AAAA,IAC7B,QAAU,EAAA,KAAA,CAAM,UAAW,CAAA,OAAA,CAAQ,EAAE,CAAA;AAAA,IACrC,KAAA,EAAO,KAAM,CAAA,OAAA,CAAQ,IAAK,CAAA,OAAA;AAAA,IAC1B,QAAU,EAAA;AAAA;AAEd,CAAE,CAAA,CAAA;AAaW,MAAA,cAAA,GAAiB,CAAC,KAA+B,KAAA;AAC5D,EAAA,MAAM,UAAU,SAAU,EAAA;AAC1B,EAAA,MAAM,EAAE,aAAA,EAAe,QAAU,EAAA,KAAA,KAAU,SAAU,EAAA;AACrD,EAAA,MAAM,EAAE,YAAA,EAAc,KAAO,EAAA,UAAA,EAAe,GAAA,KAAA;AAE5C,EAAM,MAAA,SAAA,GAAY,CAAC,CAAA,EAAoB,OAAoB,KAAA;AACzD,IAAA,QAAA,CAAS,YAAY,EAAK,GAAA,CAAC,OAAO,CAAA,GAAI,EAAE,CAAA;AACxC,IAAA,aAAA,CAAc,KAAS,CAAA,CAAA;AAAA,GACzB;AAGA,EAAA,SAAA,CAAU,MAAM;AACd,IAAA,IAAI,YAAc,EAAA;AAChB,MAAS,QAAA,CAAA,CAAC,YAAY,CAAC,CAAA;AAAA;AACzB,GAEF,EAAG,EAAE,CAAA;AAEL,EAAA,MAAM,YAAe,GAAA;AAAA,IACnB;AAAA,MACE,KAAO,EAAA,EAAA;AAAA,MACP,IAAM,EAAA;AAAA,KACR;AAAA,IACA,GAAG;AAAA,GACL;AAEA,EACE,uBAAA,GAAA;AAAA,IAAC,IAAA;AAAA,IAAA;AAAA,MACC,YAAW,EAAA,2BAAA;AAAA,MACX,WAAW,OAAQ,CAAA,IAAA;AAAA,MACnB,cAAe,EAAA,SAAA;AAAA,MACf,OAAO,KAAM,CAAA,MAAA,KAAW,CAAI,GAAA,EAAA,GAAK,MAAM,CAAC,CAAA;AAAA,MACxC,QAAU,EAAA,SAAA;AAAA,MAET,QAAa,EAAA,YAAA,CAAA,GAAA,CAAI,CAAC,IAAA,EAAM,GACvB,qBAAA,GAAA;AAAA,QAAC,GAAA;AAAA,QAAA;AAAA,UAEC,WAAW,OAAQ,CAAA,GAAA;AAAA,UACnB,OAAO,IAAK,CAAA,IAAA;AAAA,UACZ,OAAO,IAAK,CAAA;AAAA,SAAA;AAAA,QAHP;AAAA,OAKR;AAAA;AAAA,GACH;AAEJ;;;;"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
1
2
|
import Checkbox from '@material-ui/core/Checkbox';
|
|
2
3
|
import Chip from '@material-ui/core/Chip';
|
|
3
4
|
import FormControl from '@material-ui/core/FormControl';
|
|
@@ -6,7 +7,6 @@ import ListItemText from '@material-ui/core/ListItemText';
|
|
|
6
7
|
import MenuItem from '@material-ui/core/MenuItem';
|
|
7
8
|
import Select from '@material-ui/core/Select';
|
|
8
9
|
import { makeStyles } from '@material-ui/core/styles';
|
|
9
|
-
import React from 'react';
|
|
10
10
|
import useEffectOnce from 'react-use/esm/useEffectOnce';
|
|
11
11
|
import { SearchTypeAccordion } from './SearchType.Accordion.esm.js';
|
|
12
12
|
import { SearchTypeTabs } from './SearchType.Tabs.esm.js';
|
|
@@ -42,42 +42,47 @@ const SearchType = (props) => {
|
|
|
42
42
|
const value = e.target.value;
|
|
43
43
|
setTypes(value);
|
|
44
44
|
};
|
|
45
|
-
return /* @__PURE__ */
|
|
45
|
+
return /* @__PURE__ */ jsxs(
|
|
46
46
|
FormControl,
|
|
47
47
|
{
|
|
48
48
|
className,
|
|
49
49
|
variant: "filled",
|
|
50
50
|
fullWidth: true,
|
|
51
|
-
"data-testid": "search-typefilter-next"
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
{
|
|
57
|
-
multiple: true,
|
|
58
|
-
variant: "outlined",
|
|
59
|
-
value: types,
|
|
60
|
-
onChange: handleChange,
|
|
61
|
-
placeholder: "All Results",
|
|
62
|
-
renderValue: (selected) => /* @__PURE__ */ React.createElement("div", { className: classes.chips }, selected.map((value) => /* @__PURE__ */ React.createElement(
|
|
63
|
-
Chip,
|
|
51
|
+
"data-testid": "search-typefilter-next",
|
|
52
|
+
children: [
|
|
53
|
+
/* @__PURE__ */ jsx(InputLabel, { className: classes.label, margin: "dense", children: name }),
|
|
54
|
+
/* @__PURE__ */ jsx(
|
|
55
|
+
Select,
|
|
64
56
|
{
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
57
|
+
multiple: true,
|
|
58
|
+
variant: "outlined",
|
|
59
|
+
value: types,
|
|
60
|
+
onChange: handleChange,
|
|
61
|
+
placeholder: "All Results",
|
|
62
|
+
renderValue: (selected) => /* @__PURE__ */ jsx("div", { className: classes.chips, children: selected.map((value) => /* @__PURE__ */ jsx(
|
|
63
|
+
Chip,
|
|
64
|
+
{
|
|
65
|
+
label: value,
|
|
66
|
+
className: classes.chip,
|
|
67
|
+
size: "small"
|
|
68
|
+
},
|
|
69
|
+
value
|
|
70
|
+
)) }),
|
|
71
|
+
children: values.map((value) => /* @__PURE__ */ jsxs(MenuItem, { value, children: [
|
|
72
|
+
/* @__PURE__ */ jsx(Checkbox, { checked: types.indexOf(value) > -1 }),
|
|
73
|
+
/* @__PURE__ */ jsx(ListItemText, { primary: value })
|
|
74
|
+
] }, value))
|
|
69
75
|
}
|
|
70
|
-
)
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
)
|
|
76
|
+
)
|
|
77
|
+
]
|
|
78
|
+
}
|
|
74
79
|
);
|
|
75
80
|
};
|
|
76
81
|
SearchType.Accordion = (props) => {
|
|
77
|
-
return /* @__PURE__ */
|
|
82
|
+
return /* @__PURE__ */ jsx(SearchTypeAccordion, { ...props });
|
|
78
83
|
};
|
|
79
84
|
SearchType.Tabs = (props) => {
|
|
80
|
-
return /* @__PURE__ */
|
|
85
|
+
return /* @__PURE__ */ jsx(SearchTypeTabs, { ...props });
|
|
81
86
|
};
|
|
82
87
|
|
|
83
88
|
export { SearchType };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SearchType.esm.js","sources":["../../../src/components/SearchType/SearchType.tsx"],"sourcesContent":["/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport Checkbox from '@material-ui/core/Checkbox';\nimport Chip from '@material-ui/core/Chip';\nimport FormControl from '@material-ui/core/FormControl';\nimport InputLabel from '@material-ui/core/InputLabel';\nimport ListItemText from '@material-ui/core/ListItemText';\nimport MenuItem from '@material-ui/core/MenuItem';\nimport Select from '@material-ui/core/Select';\nimport { makeStyles } from '@material-ui/core/styles';\nimport
|
|
1
|
+
{"version":3,"file":"SearchType.esm.js","sources":["../../../src/components/SearchType/SearchType.tsx"],"sourcesContent":["/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport Checkbox from '@material-ui/core/Checkbox';\nimport Chip from '@material-ui/core/Chip';\nimport FormControl from '@material-ui/core/FormControl';\nimport InputLabel from '@material-ui/core/InputLabel';\nimport ListItemText from '@material-ui/core/ListItemText';\nimport MenuItem from '@material-ui/core/MenuItem';\nimport Select from '@material-ui/core/Select';\nimport { makeStyles } from '@material-ui/core/styles';\nimport { ChangeEvent } from 'react';\nimport useEffectOnce from 'react-use/esm/useEffectOnce';\nimport {\n SearchTypeAccordion,\n SearchTypeAccordionProps,\n} from './SearchType.Accordion';\nimport { SearchTypeTabs, SearchTypeTabsProps } from './SearchType.Tabs';\nimport { useSearch } from '@backstage/plugin-search-react';\n\nconst useStyles = makeStyles(theme => ({\n label: {\n textTransform: 'capitalize',\n },\n chips: {\n display: 'flex',\n flexWrap: 'wrap',\n marginTop: theme.spacing(1),\n },\n chip: {\n margin: 2,\n },\n}));\n\n/**\n * Props for {@link SearchType}.\n *\n * @public\n */\nexport type SearchTypeProps = {\n className?: string;\n name: string;\n values?: string[];\n defaultValue?: string[] | string | null;\n};\n\n/**\n * @public\n */\nconst SearchType = (props: SearchTypeProps) => {\n const { className, defaultValue, name, values = [] } = props;\n const classes = useStyles();\n const { types, setTypes } = useSearch();\n\n useEffectOnce(() => {\n if (!types.length) {\n if (defaultValue && Array.isArray(defaultValue)) {\n setTypes(defaultValue);\n } else if (defaultValue) {\n setTypes([defaultValue]);\n }\n }\n });\n\n const handleChange = (e: ChangeEvent<{ value: unknown }>) => {\n const value = e.target.value as string[];\n setTypes(value as string[]);\n };\n\n return (\n <FormControl\n className={className}\n variant=\"filled\"\n fullWidth\n data-testid=\"search-typefilter-next\"\n >\n <InputLabel className={classes.label} margin=\"dense\">\n {name}\n </InputLabel>\n <Select\n multiple\n variant=\"outlined\"\n value={types}\n onChange={handleChange}\n placeholder=\"All Results\"\n renderValue={selected => (\n <div className={classes.chips}>\n {(selected as string[]).map(value => (\n <Chip\n key={value}\n label={value}\n className={classes.chip}\n size=\"small\"\n />\n ))}\n </div>\n )}\n >\n {values.map((value: string) => (\n <MenuItem key={value} value={value}>\n <Checkbox checked={types.indexOf(value) > -1} />\n <ListItemText primary={value} />\n </MenuItem>\n ))}\n </Select>\n </FormControl>\n );\n};\n\n/**\n * A control surface for the search query's \"types\" property, displayed as a\n * single-select collapsible accordion suitable for use in faceted search UIs.\n * @public\n */\nSearchType.Accordion = (props: SearchTypeAccordionProps) => {\n return <SearchTypeAccordion {...props} />;\n};\n\n/**\n * A control surface for the search query's \"types\" property, displayed as a\n * tabs suitable for use in faceted search UIs.\n * @public\n */\nSearchType.Tabs = (props: SearchTypeTabsProps) => {\n return <SearchTypeTabs {...props} />;\n};\n\nexport { SearchType };\nexport type { SearchTypeAccordionProps, SearchTypeTabsProps };\n"],"names":[],"mappings":";;;;;;;;;;;;;;AAgCA,MAAM,SAAA,GAAY,WAAW,CAAU,KAAA,MAAA;AAAA,EACrC,KAAO,EAAA;AAAA,IACL,aAAe,EAAA;AAAA,GACjB;AAAA,EACA,KAAO,EAAA;AAAA,IACL,OAAS,EAAA,MAAA;AAAA,IACT,QAAU,EAAA,MAAA;AAAA,IACV,SAAA,EAAW,KAAM,CAAA,OAAA,CAAQ,CAAC;AAAA,GAC5B;AAAA,EACA,IAAM,EAAA;AAAA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ACZ,WAAA,EAAa,8BACV,GAAA,CAAA,KAAA,EAAA,EAAI,WAAW,OAAQ,CAAA,KAAA,EACpB,QAAsB,EAAA,QAAA,CAAA,GAAA,CAAI,CAC1B,KAAA,qBAAA,GAAA;AAAA,cAAC,IAAA;AAAA,cAAA;AAAA,gBAEC,KAAO,EAAA,KAAA;AAAA,gBACP,WAAW,OAAQ,CAAA,IAAA;AAAA,gBACnB,IAAK,EAAA;AAAA,eAAA;AAAA,cAHA;AAAA,aAKR,CACH,EAAA,CAAA;AAAA,YAGD,iBAAO,GAAI,CAAA,CAAC,KACX,qBAAA,IAAA,CAAC,YAAqB,KACpB,EAAA,QAAA,EAAA;AAAA,8BAAA,GAAA,CAAC,YAAS,OAAS,EAAA,KAAA,CAAM,OAAQ,CAAA,KAAK,IAAI,CAAI,CAAA,EAAA,CAAA;AAAA,8BAC9C,GAAA,CAAC,YAAa,EAAA,EAAA,OAAA,EAAS,KAAO,EAAA;AAAA,aAAA,EAAA,EAFjB,KAGf,CACD;AAAA;AAAA;AACH;AAAA;AAAA,GACF;AAEJ;AAOA,UAAW,CAAA,SAAA,GAAY,CAAC,KAAoC,KAAA;AAC1D,EAAO,uBAAA,GAAA,CAAC,mBAAqB,EAAA,EAAA,GAAG,KAAO,EAAA,CAAA;AACzC,CAAA;AAOA,UAAW,CAAA,IAAA,GAAO,CAAC,KAA+B,KAAA;AAChD,EAAO,uBAAA,GAAA,CAAC,cAAgB,EAAA,EAAA,GAAG,KAAO,EAAA,CAAA;AACpC,CAAA;;;;"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
1
2
|
import qs from 'qs';
|
|
2
|
-
import
|
|
3
|
+
import { useCallback } from 'react';
|
|
3
4
|
import { useNavigate } from 'react-router-dom';
|
|
4
5
|
import { rootRouteRef } from '../../plugin.esm.js';
|
|
5
6
|
import { useRouteRef } from '@backstage/core-plugin-api';
|
|
@@ -17,7 +18,7 @@ const SidebarSearch = (props) => {
|
|
|
17
18
|
},
|
|
18
19
|
[focusContent, navigate, searchRoute]
|
|
19
20
|
);
|
|
20
|
-
return /* @__PURE__ */
|
|
21
|
+
return /* @__PURE__ */ jsx(
|
|
21
22
|
SidebarSearchField,
|
|
22
23
|
{
|
|
23
24
|
icon: props.icon,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SidebarSearch.esm.js","sources":["../../../src/components/SidebarSearch/SidebarSearch.tsx"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport qs from 'qs';\nimport
|
|
1
|
+
{"version":3,"file":"SidebarSearch.esm.js","sources":["../../../src/components/SidebarSearch/SidebarSearch.tsx"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport qs from 'qs';\nimport { useCallback } from 'react';\nimport { useNavigate } from 'react-router-dom';\nimport { rootRouteRef } from '../../plugin';\n\nimport { useRouteRef, IconComponent } from '@backstage/core-plugin-api';\nimport { SidebarSearchField, useContent } from '@backstage/core-components';\n\n/**\n * Props for {@link SidebarSearch}.\n *\n * @public\n */\nexport type SidebarSearchProps = {\n icon?: IconComponent;\n};\n\n/**\n * @public\n */\nexport const SidebarSearch = (props: SidebarSearchProps) => {\n const searchRoute = useRouteRef(rootRouteRef);\n const { focusContent } = useContent();\n const navigate = useNavigate();\n const handleSearch = useCallback(\n (query: string): void => {\n const queryString = qs.stringify({ query }, { addQueryPrefix: true });\n focusContent();\n navigate(`${searchRoute()}${queryString}`);\n },\n [focusContent, navigate, searchRoute],\n );\n\n return (\n <SidebarSearchField\n icon={props.icon}\n onSearch={handleSearch}\n to=\"/search\"\n />\n );\n};\n"],"names":[],"mappings":";;;;;;;;AAmCa,MAAA,aAAA,GAAgB,CAAC,KAA8B,KAAA;AAC1D,EAAM,MAAA,WAAA,GAAc,YAAY,YAAY,CAAA;AAC5C,EAAM,MAAA,EAAE,YAAa,EAAA,GAAI,UAAW,EAAA;AACpC,EAAA,MAAM,WAAW,WAAY,EAAA;AAC7B,EAAA,MAAM,YAAe,GAAA,WAAA;AAAA,IACnB,CAAC,KAAwB,KAAA;AACvB,MAAM,MAAA,WAAA,GAAc,GAAG,SAAU,CAAA,EAAE,OAAS,EAAA,EAAE,cAAgB,EAAA,IAAA,EAAM,CAAA;AACpE,MAAa,YAAA,EAAA;AACb,MAAA,QAAA,CAAS,CAAG,EAAA,WAAA,EAAa,CAAA,EAAG,WAAW,CAAE,CAAA,CAAA;AAAA,KAC3C;AAAA,IACA,CAAC,YAAc,EAAA,QAAA,EAAU,WAAW;AAAA,GACtC;AAEA,EACE,uBAAA,GAAA;AAAA,IAAC,kBAAA;AAAA,IAAA;AAAA,MACC,MAAM,KAAM,CAAA,IAAA;AAAA,MACZ,QAAU,EAAA,YAAA;AAAA,MACV,EAAG,EAAA;AAAA;AAAA,GACL;AAEJ;;;;"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
2
2
|
import SearchIcon from '@material-ui/icons/Search';
|
|
3
3
|
import { SidebarItem } from '@backstage/core-components';
|
|
4
4
|
import { SearchModal } from '../SearchModal/SearchModal.esm.js';
|
|
@@ -7,26 +7,29 @@ import { SearchModalProvider, useSearchModal } from '../SearchModal/useSearchMod
|
|
|
7
7
|
const SidebarSearchModalContent = (props) => {
|
|
8
8
|
const { state, toggleModal } = useSearchModal();
|
|
9
9
|
const Icon = props.icon ? props.icon : SearchIcon;
|
|
10
|
-
return /* @__PURE__ */
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
10
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
11
|
+
/* @__PURE__ */ jsx(
|
|
12
|
+
SidebarItem,
|
|
13
|
+
{
|
|
14
|
+
className: "search-icon",
|
|
15
|
+
icon: Icon,
|
|
16
|
+
text: "Search",
|
|
17
|
+
onClick: toggleModal
|
|
18
|
+
}
|
|
19
|
+
),
|
|
20
|
+
/* @__PURE__ */ jsx(
|
|
21
|
+
SearchModal,
|
|
22
|
+
{
|
|
23
|
+
...state,
|
|
24
|
+
toggleModal,
|
|
25
|
+
resultItemComponents: props.resultItemComponents,
|
|
26
|
+
children: props.children
|
|
27
|
+
}
|
|
28
|
+
)
|
|
29
|
+
] });
|
|
27
30
|
};
|
|
28
31
|
const SidebarSearchModal = (props) => {
|
|
29
|
-
return /* @__PURE__ */
|
|
32
|
+
return /* @__PURE__ */ jsx(SearchModalProvider, { children: /* @__PURE__ */ jsx(SidebarSearchModalContent, { ...props }) });
|
|
30
33
|
};
|
|
31
34
|
|
|
32
35
|
export { SidebarSearchModal };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SidebarSearchModal.esm.js","sources":["../../../src/components/SidebarSearchModal/SidebarSearchModal.tsx"],"sourcesContent":["/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport
|
|
1
|
+
{"version":3,"file":"SidebarSearchModal.esm.js","sources":["../../../src/components/SidebarSearchModal/SidebarSearchModal.tsx"],"sourcesContent":["/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport SearchIcon from '@material-ui/icons/Search';\nimport { SidebarItem } from '@backstage/core-components';\nimport { IconComponent } from '@backstage/core-plugin-api';\nimport {\n SearchModal,\n SearchModalProps,\n SearchModalProvider,\n useSearchModal,\n} from '../SearchModal';\n\n/**\n * Props for {@link SidebarSearchModal}.\n *\n * @public\n */\nexport type SidebarSearchModalProps = Pick<\n SearchModalProps,\n 'children' | 'resultItemComponents'\n> & {\n icon?: IconComponent;\n};\n\nconst SidebarSearchModalContent = (props: SidebarSearchModalProps) => {\n const { state, toggleModal } = useSearchModal();\n const Icon = props.icon ? props.icon : SearchIcon;\n\n return (\n <>\n <SidebarItem\n className=\"search-icon\"\n icon={Icon}\n text=\"Search\"\n onClick={toggleModal}\n />\n <SearchModal\n {...state}\n toggleModal={toggleModal}\n resultItemComponents={props.resultItemComponents}\n children={props.children}\n />\n </>\n );\n};\n\nexport const SidebarSearchModal = (props: SidebarSearchModalProps) => {\n return (\n <SearchModalProvider>\n <SidebarSearchModalContent {...props} />\n </SearchModalProvider>\n );\n};\n"],"names":[],"mappings":";;;;;;AAqCA,MAAM,yBAAA,GAA4B,CAAC,KAAmC,KAAA;AACpE,EAAA,MAAM,EAAE,KAAA,EAAO,WAAY,EAAA,GAAI,cAAe,EAAA;AAC9C,EAAA,MAAM,IAAO,GAAA,KAAA,CAAM,IAAO,GAAA,KAAA,CAAM,IAAO,GAAA,UAAA;AAEvC,EAAA,uBAEI,IAAA,CAAA,QAAA,EAAA,EAAA,QAAA,EAAA;AAAA,oBAAA,GAAA;AAAA,MAAC,WAAA;AAAA,MAAA;AAAA,QACC,SAAU,EAAA,aAAA;AAAA,QACV,IAAM,EAAA,IAAA;AAAA,QACN,IAAK,EAAA,QAAA;AAAA,QACL,OAAS,EAAA;AAAA;AAAA,KACX;AAAA,oBACA,GAAA;AAAA,MAAC,WAAA;AAAA,MAAA;AAAA,QACE,GAAG,KAAA;AAAA,QACJ,WAAA;AAAA,QACA,sBAAsB,KAAM,CAAA,oBAAA;AAAA,QAC5B,UAAU,KAAM,CAAA;AAAA;AAAA;AAClB,GACF,EAAA,CAAA;AAEJ,CAAA;AAEa,MAAA,kBAAA,GAAqB,CAAC,KAAmC,KAAA;AACpE,EAAA,2BACG,mBACC,EAAA,EAAA,QAAA,kBAAA,GAAA,CAAC,yBAA2B,EAAA,EAAA,GAAG,OAAO,CACxC,EAAA,CAAA;AAEJ;;;;"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { SearchBarBaseProps } from '@backstage/plugin-search-react';
|
|
2
|
-
import * as
|
|
3
|
-
import
|
|
2
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
3
|
+
import { ReactNode } from 'react';
|
|
4
4
|
import { SearchResultSet } from '@backstage/plugin-search-common';
|
|
5
5
|
import * as _backstage_core_plugin_api from '@backstage/core-plugin-api';
|
|
6
6
|
import { IconComponent } from '@backstage/core-plugin-api';
|
|
@@ -58,7 +58,7 @@ interface SearchModalProps {
|
|
|
58
58
|
/**
|
|
59
59
|
* @public
|
|
60
60
|
*/
|
|
61
|
-
declare const SearchModal: (props: SearchModalProps) =>
|
|
61
|
+
declare const SearchModal: (props: SearchModalProps) => react_jsx_runtime.JSX.Element;
|
|
62
62
|
|
|
63
63
|
/**
|
|
64
64
|
* The state of the search modal, as well as functions for changing the modal's
|
|
@@ -117,7 +117,7 @@ type SearchModalProviderProps = {
|
|
|
117
117
|
*
|
|
118
118
|
* @public
|
|
119
119
|
*/
|
|
120
|
-
declare const SearchModalProvider: (props: SearchModalProviderProps) =>
|
|
120
|
+
declare const SearchModalProvider: (props: SearchModalProviderProps) => react_jsx_runtime.JSX.Element;
|
|
121
121
|
/**
|
|
122
122
|
* Use this hook to manage the state of {@link SearchModal}
|
|
123
123
|
* and change its visibility. Monitors route changes setting the hidden state
|
|
@@ -134,7 +134,7 @@ declare function useSearchModal(initialState?: boolean): SearchModalValue;
|
|
|
134
134
|
/**
|
|
135
135
|
* @public
|
|
136
136
|
*/
|
|
137
|
-
declare const SearchPage$1: () =>
|
|
137
|
+
declare const SearchPage$1: () => react_jsx_runtime.JSX.Element;
|
|
138
138
|
|
|
139
139
|
/**
|
|
140
140
|
* @public
|
|
@@ -176,19 +176,19 @@ type SearchTypeProps = {
|
|
|
176
176
|
* @public
|
|
177
177
|
*/
|
|
178
178
|
declare const SearchType: {
|
|
179
|
-
(props: SearchTypeProps):
|
|
179
|
+
(props: SearchTypeProps): react_jsx_runtime.JSX.Element;
|
|
180
180
|
/**
|
|
181
181
|
* A control surface for the search query's "types" property, displayed as a
|
|
182
182
|
* single-select collapsible accordion suitable for use in faceted search UIs.
|
|
183
183
|
* @public
|
|
184
184
|
*/
|
|
185
|
-
Accordion(props: SearchTypeAccordionProps):
|
|
185
|
+
Accordion(props: SearchTypeAccordionProps): react_jsx_runtime.JSX.Element;
|
|
186
186
|
/**
|
|
187
187
|
* A control surface for the search query's "types" property, displayed as a
|
|
188
188
|
* tabs suitable for use in faceted search UIs.
|
|
189
189
|
* @public
|
|
190
190
|
*/
|
|
191
|
-
Tabs(props: SearchTypeTabsProps):
|
|
191
|
+
Tabs(props: SearchTypeTabsProps): react_jsx_runtime.JSX.Element;
|
|
192
192
|
};
|
|
193
193
|
|
|
194
194
|
/**
|
|
@@ -202,7 +202,7 @@ type SidebarSearchProps = {
|
|
|
202
202
|
/**
|
|
203
203
|
* @public
|
|
204
204
|
*/
|
|
205
|
-
declare const SidebarSearch: (props: SidebarSearchProps) =>
|
|
205
|
+
declare const SidebarSearch: (props: SidebarSearchProps) => react_jsx_runtime.JSX.Element;
|
|
206
206
|
|
|
207
207
|
/**
|
|
208
208
|
* Props for {@link SidebarSearchModal}.
|
|
@@ -222,7 +222,7 @@ declare const searchPlugin: _backstage_core_plugin_api.BackstagePlugin<{
|
|
|
222
222
|
/**
|
|
223
223
|
* @public
|
|
224
224
|
*/
|
|
225
|
-
declare const SearchPage: () =>
|
|
225
|
+
declare const SearchPage: () => react_jsx_runtime.JSX.Element;
|
|
226
226
|
/**
|
|
227
227
|
* @public
|
|
228
228
|
*/
|
|
@@ -230,6 +230,6 @@ declare const SidebarSearchModal: (props: SidebarSearchModalProps) => JSX.Elemen
|
|
|
230
230
|
/**
|
|
231
231
|
* @public
|
|
232
232
|
*/
|
|
233
|
-
declare const HomePageSearchBar: (props: HomePageSearchBarProps) =>
|
|
233
|
+
declare const HomePageSearchBar: (props: HomePageSearchBarProps) => react_jsx_runtime.JSX.Element;
|
|
234
234
|
|
|
235
235
|
export { HomePageSearchBar, type HomePageSearchBarProps, SearchPage$1 as Router, SearchModal, type SearchModalChildrenProps, type SearchModalProps, SearchModalProvider, type SearchModalProviderProps, type SearchModalValue, SearchPage, SearchType, type SearchTypeAccordionProps, type SearchTypeProps, type SearchTypeTabsProps, SidebarSearch, SidebarSearchModal, type SidebarSearchModalProps, type SidebarSearchProps, searchPlugin as plugin, searchPlugin, useSearchModal };
|