@backstage/plugin-search-react 1.7.10-next.1 → 1.7.11-next.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 +29 -0
- package/alpha/package.json +1 -1
- package/dist/alpha.d.ts +1 -1
- package/dist/alpha.esm.js +1 -5
- package/dist/alpha.esm.js.map +1 -1
- package/dist/api.esm.js +16 -0
- package/dist/api.esm.js.map +1 -0
- package/dist/components/DefaultResultListItem/DefaultResultListItem.esm.js +70 -0
- package/dist/components/DefaultResultListItem/DefaultResultListItem.esm.js.map +1 -0
- package/dist/components/HighlightedSearchResultText/HighlightedSearchResultText.esm.js +23 -0
- package/dist/components/HighlightedSearchResultText/HighlightedSearchResultText.esm.js.map +1 -0
- package/dist/components/SearchAutocomplete/SearchAutocomplete.esm.js +107 -0
- package/dist/components/SearchAutocomplete/SearchAutocomplete.esm.js.map +1 -0
- package/dist/components/SearchAutocomplete/SearchAutocompleteDefaultOption.esm.js +27 -0
- package/dist/components/SearchAutocomplete/SearchAutocompleteDefaultOption.esm.js.map +1 -0
- package/dist/components/SearchBar/SearchBar.esm.js +161 -0
- package/dist/components/SearchBar/SearchBar.esm.js.map +1 -0
- package/dist/components/SearchFilter/SearchFilter.Autocomplete.esm.js +72 -0
- package/dist/components/SearchFilter/SearchFilter.Autocomplete.esm.js.map +1 -0
- package/dist/components/SearchFilter/SearchFilter.esm.js +157 -0
- package/dist/components/SearchFilter/SearchFilter.esm.js.map +1 -0
- package/dist/components/SearchFilter/hooks.esm.js +52 -0
- package/dist/components/SearchFilter/hooks.esm.js.map +1 -0
- package/dist/components/SearchPagination/SearchPagination.esm.js +82 -0
- package/dist/components/SearchPagination/SearchPagination.esm.js.map +1 -0
- package/dist/components/SearchResult/SearchResult.esm.js +70 -0
- package/dist/components/SearchResult/SearchResult.esm.js.map +1 -0
- package/dist/components/SearchResultGroup/SearchResultGroup.esm.js +259 -0
- package/dist/components/SearchResultGroup/SearchResultGroup.esm.js.map +1 -0
- package/dist/components/SearchResultList/SearchResultList.esm.js +67 -0
- package/dist/components/SearchResultList/SearchResultList.esm.js.map +1 -0
- package/dist/components/SearchResultPager/SearchResultPager.esm.js +44 -0
- package/dist/components/SearchResultPager/SearchResultPager.esm.js.map +1 -0
- package/dist/context/SearchContext.esm.js +126 -0
- package/dist/context/SearchContext.esm.js.map +1 -0
- package/dist/extensions.esm.js +123 -0
- package/dist/extensions.esm.js.map +1 -0
- package/dist/index.d.ts +5 -2
- package/dist/index.esm.js +15 -1132
- package/dist/index.esm.js.map +1 -1
- package/package.json +13 -13
- package/dist/esm/extensions-mFM2-9nX.esm.js +0 -200
- package/dist/esm/extensions-mFM2-9nX.esm.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,34 @@
|
|
|
1
1
|
# @backstage/plugin-search-react
|
|
2
2
|
|
|
3
|
+
## 1.7.11-next.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies
|
|
8
|
+
- @backstage/theme@0.5.4-next.0
|
|
9
|
+
- @backstage/core-components@0.14.5-next.0
|
|
10
|
+
- @backstage/core-plugin-api@1.9.2
|
|
11
|
+
- @backstage/frontend-plugin-api@0.6.5-next.0
|
|
12
|
+
- @backstage/types@1.1.1
|
|
13
|
+
- @backstage/version-bridge@1.0.8
|
|
14
|
+
- @backstage/plugin-search-common@1.2.11
|
|
15
|
+
|
|
16
|
+
## 1.7.10
|
|
17
|
+
|
|
18
|
+
### Patch Changes
|
|
19
|
+
|
|
20
|
+
- 8d50bd3: add mui imports eslint rule
|
|
21
|
+
- abfbcfc: Updated dependency `@testing-library/react` to `^15.0.0`.
|
|
22
|
+
- cb1e3b0: Updated dependency `@testing-library/dom` to `^10.0.0`.
|
|
23
|
+
- Updated dependencies
|
|
24
|
+
- @backstage/core-components@0.14.4
|
|
25
|
+
- @backstage/core-plugin-api@1.9.2
|
|
26
|
+
- @backstage/frontend-plugin-api@0.6.4
|
|
27
|
+
- @backstage/theme@0.5.3
|
|
28
|
+
- @backstage/version-bridge@1.0.8
|
|
29
|
+
- @backstage/types@1.1.1
|
|
30
|
+
- @backstage/plugin-search-common@1.2.11
|
|
31
|
+
|
|
3
32
|
## 1.7.10-next.1
|
|
4
33
|
|
|
5
34
|
### Patch Changes
|
package/alpha/package.json
CHANGED
package/dist/alpha.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import * as _backstage_frontend_plugin_api from '@backstage/frontend-plugin-api';
|
|
3
3
|
import { PortableSchema } from '@backstage/frontend-plugin-api';
|
|
4
|
-
import { ListItemProps } from '@material-ui/core';
|
|
4
|
+
import { ListItemProps } from '@material-ui/core/ListItem';
|
|
5
5
|
import { SearchDocument, SearchResult } from '@backstage/plugin-search-common';
|
|
6
6
|
|
|
7
7
|
/** @alpha */
|
package/dist/alpha.esm.js
CHANGED
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
import React, { lazy } from 'react';
|
|
2
2
|
import { createExtensionDataRef, createSchemaFromZod, createExtension, ExtensionBoundary } from '@backstage/frontend-plugin-api';
|
|
3
|
-
import {
|
|
4
|
-
import '@backstage/core-plugin-api';
|
|
5
|
-
import '@material-ui/core';
|
|
6
|
-
import '@material-ui/core/Typography';
|
|
7
|
-
import '@backstage/core-components';
|
|
3
|
+
import { SearchResultListItemExtension } from './extensions.esm.js';
|
|
8
4
|
|
|
9
5
|
function createSearchResultListItemExtension(options) {
|
|
10
6
|
var _a;
|
package/dist/alpha.esm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"alpha.esm.js","sources":["../src/alpha.tsx"],"sourcesContent":["/*\n * Copyright 2023 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, { lazy } from 'react';\n\nimport { ListItemProps } from '@material-ui/core';\n\nimport {\n ExtensionBoundary,\n PortableSchema,\n createExtension,\n createExtensionDataRef,\n createSchemaFromZod,\n} from '@backstage/frontend-plugin-api';\nimport { SearchDocument, SearchResult } from '@backstage/plugin-search-common';\n\nimport { SearchResultListItemExtension } from './extensions';\n\n/** @alpha */\nexport type BaseSearchResultListItemProps<T = {}> = T & {\n rank?: number;\n result?: SearchDocument;\n} & Omit<ListItemProps, 'button'>;\n\n/** @alpha */\nexport type SearchResultItemExtensionComponent = <\n P extends BaseSearchResultListItemProps,\n>(\n props: P,\n) => JSX.Element | null;\n\n/** @alpha */\nexport type SearchResultItemExtensionPredicate = (\n result: SearchResult,\n) => boolean;\n\n/** @alpha */\nexport type SearchResultItemExtensionOptions<\n TConfig extends { noTrack?: boolean },\n> = {\n /**\n * The extension namespace.\n */\n namespace?: string;\n /**\n * The extension name.\n */\n name?: string;\n /**\n * The extension attachment point (e.g., search modal or page).\n */\n attachTo?: { id: string; input: string };\n /**\n * Optional extension config schema.\n */\n configSchema?: PortableSchema<TConfig>;\n /**\n * The extension component.\n */\n component: (options: {\n config: TConfig;\n }) => Promise<SearchResultItemExtensionComponent>;\n /**\n * When an extension defines a predicate, it returns true if the result should be rendered by that extension.\n * Defaults to a predicate that returns true, which means it renders all sorts of results.\n */\n predicate?: SearchResultItemExtensionPredicate;\n};\n\n/** @alpha */\nexport function createSearchResultListItemExtension<\n TConfig extends { noTrack?: boolean },\n>(options: SearchResultItemExtensionOptions<TConfig>) {\n const configSchema =\n 'configSchema' in options\n ? options.configSchema\n : (createSchemaFromZod(z =>\n z.object({\n noTrack: z.boolean().default(false),\n }),\n ) as PortableSchema<TConfig>);\n\n return createExtension({\n kind: 'search-result-list-item',\n namespace: options.namespace,\n name: options.name,\n attachTo: options.attachTo ?? {\n id: 'page:search',\n input: 'items',\n },\n configSchema,\n output: {\n item: createSearchResultListItemExtension.itemDataRef,\n },\n factory({ config, node }) {\n const ExtensionComponent = lazy(() =>\n options\n .component({ config })\n .then(component => ({ default: component })),\n ) as unknown as SearchResultItemExtensionComponent;\n\n return {\n item: {\n predicate: options.predicate,\n component: props => (\n <ExtensionBoundary node={node}>\n <SearchResultListItemExtension\n rank={props.rank}\n result={props.result}\n noTrack={config.noTrack}\n >\n <ExtensionComponent {...props} />\n </SearchResultListItemExtension>\n </ExtensionBoundary>\n ),\n },\n };\n },\n });\n}\n\n/** @alpha */\nexport namespace createSearchResultListItemExtension {\n export const itemDataRef = createExtensionDataRef<{\n predicate?: SearchResultItemExtensionPredicate;\n component: SearchResultItemExtensionComponent;\n }>('search.search-result-list-item.item');\n}\n"],"names":["createSearchResultListItemExtension"],"mappings":"
|
|
1
|
+
{"version":3,"file":"alpha.esm.js","sources":["../src/alpha.tsx"],"sourcesContent":["/*\n * Copyright 2023 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, { lazy } from 'react';\n\nimport { ListItemProps } from '@material-ui/core/ListItem';\n\nimport {\n ExtensionBoundary,\n PortableSchema,\n createExtension,\n createExtensionDataRef,\n createSchemaFromZod,\n} from '@backstage/frontend-plugin-api';\nimport { SearchDocument, SearchResult } from '@backstage/plugin-search-common';\n\nimport { SearchResultListItemExtension } from './extensions';\n\n/** @alpha */\nexport type BaseSearchResultListItemProps<T = {}> = T & {\n rank?: number;\n result?: SearchDocument;\n} & Omit<ListItemProps, 'button'>;\n\n/** @alpha */\nexport type SearchResultItemExtensionComponent = <\n P extends BaseSearchResultListItemProps,\n>(\n props: P,\n) => JSX.Element | null;\n\n/** @alpha */\nexport type SearchResultItemExtensionPredicate = (\n result: SearchResult,\n) => boolean;\n\n/** @alpha */\nexport type SearchResultItemExtensionOptions<\n TConfig extends { noTrack?: boolean },\n> = {\n /**\n * The extension namespace.\n */\n namespace?: string;\n /**\n * The extension name.\n */\n name?: string;\n /**\n * The extension attachment point (e.g., search modal or page).\n */\n attachTo?: { id: string; input: string };\n /**\n * Optional extension config schema.\n */\n configSchema?: PortableSchema<TConfig>;\n /**\n * The extension component.\n */\n component: (options: {\n config: TConfig;\n }) => Promise<SearchResultItemExtensionComponent>;\n /**\n * When an extension defines a predicate, it returns true if the result should be rendered by that extension.\n * Defaults to a predicate that returns true, which means it renders all sorts of results.\n */\n predicate?: SearchResultItemExtensionPredicate;\n};\n\n/** @alpha */\nexport function createSearchResultListItemExtension<\n TConfig extends { noTrack?: boolean },\n>(options: SearchResultItemExtensionOptions<TConfig>) {\n const configSchema =\n 'configSchema' in options\n ? options.configSchema\n : (createSchemaFromZod(z =>\n z.object({\n noTrack: z.boolean().default(false),\n }),\n ) as PortableSchema<TConfig>);\n\n return createExtension({\n kind: 'search-result-list-item',\n namespace: options.namespace,\n name: options.name,\n attachTo: options.attachTo ?? {\n id: 'page:search',\n input: 'items',\n },\n configSchema,\n output: {\n item: createSearchResultListItemExtension.itemDataRef,\n },\n factory({ config, node }) {\n const ExtensionComponent = lazy(() =>\n options\n .component({ config })\n .then(component => ({ default: component })),\n ) as unknown as SearchResultItemExtensionComponent;\n\n return {\n item: {\n predicate: options.predicate,\n component: props => (\n <ExtensionBoundary node={node}>\n <SearchResultListItemExtension\n rank={props.rank}\n result={props.result}\n noTrack={config.noTrack}\n >\n <ExtensionComponent {...props} />\n </SearchResultListItemExtension>\n </ExtensionBoundary>\n ),\n },\n };\n },\n });\n}\n\n/** @alpha */\nexport namespace createSearchResultListItemExtension {\n export const itemDataRef = createExtensionDataRef<{\n predicate?: SearchResultItemExtensionPredicate;\n component: SearchResultItemExtensionComponent;\n }>('search.search-result-list-item.item');\n}\n"],"names":["createSearchResultListItemExtension"],"mappings":";;;;AAmFO,SAAS,oCAEd,OAAoD,EAAA;AArFtD,EAAA,IAAA,EAAA,CAAA;AAsFE,EAAA,MAAM,YACJ,GAAA,cAAA,IAAkB,OACd,GAAA,OAAA,CAAQ,YACP,GAAA,mBAAA;AAAA,IAAoB,CAAA,CAAA,KACnB,EAAE,MAAO,CAAA;AAAA,MACP,OAAS,EAAA,CAAA,CAAE,OAAQ,EAAA,CAAE,QAAQ,KAAK,CAAA;AAAA,KACnC,CAAA;AAAA,GACH,CAAA;AAEN,EAAA,OAAO,eAAgB,CAAA;AAAA,IACrB,IAAM,EAAA,yBAAA;AAAA,IACN,WAAW,OAAQ,CAAA,SAAA;AAAA,IACnB,MAAM,OAAQ,CAAA,IAAA;AAAA,IACd,QAAA,EAAA,CAAU,EAAQ,GAAA,OAAA,CAAA,QAAA,KAAR,IAAoB,GAAA,EAAA,GAAA;AAAA,MAC5B,EAAI,EAAA,aAAA;AAAA,MACJ,KAAO,EAAA,OAAA;AAAA,KACT;AAAA,IACA,YAAA;AAAA,IACA,MAAQ,EAAA;AAAA,MACN,MAAM,mCAAoC,CAAA,WAAA;AAAA,KAC5C;AAAA,IACA,OAAQ,CAAA,EAAE,MAAQ,EAAA,IAAA,EAAQ,EAAA;AACxB,MAAA,MAAM,kBAAqB,GAAA,IAAA;AAAA,QAAK,MAC9B,OAAA,CACG,SAAU,CAAA,EAAE,MAAO,EAAC,CACpB,CAAA,IAAA,CAAK,CAAc,SAAA,MAAA,EAAE,OAAS,EAAA,SAAA,EAAY,CAAA,CAAA;AAAA,OAC/C,CAAA;AAEA,MAAO,OAAA;AAAA,QACL,IAAM,EAAA;AAAA,UACJ,WAAW,OAAQ,CAAA,SAAA;AAAA,UACnB,SAAW,EAAA,CAAA,KAAA,qBACR,KAAA,CAAA,aAAA,CAAA,iBAAA,EAAA,EAAkB,IACjB,EAAA,kBAAA,KAAA,CAAA,aAAA;AAAA,YAAC,6BAAA;AAAA,YAAA;AAAA,cACC,MAAM,KAAM,CAAA,IAAA;AAAA,cACZ,QAAQ,KAAM,CAAA,MAAA;AAAA,cACd,SAAS,MAAO,CAAA,OAAA;AAAA,aAAA;AAAA,4BAEhB,KAAA,CAAA,aAAA,CAAC,kBAAoB,EAAA,EAAA,GAAG,KAAO,EAAA,CAAA;AAAA,WAEnC,CAAA;AAAA,SAEJ;AAAA,OACF,CAAA;AAAA,KACF;AAAA,GACD,CAAA,CAAA;AACH,CAAA;AAAA,CAGO,CAAUA,oCAAV,KAAA;AACE,EAAMA,oCAAAA,CAAA,WAAc,GAAA,sBAAA,CAGxB,qCAAqC,CAAA,CAAA;AAAA,CAJzB,EAAA,mCAAA,KAAA,mCAAA,GAAA,EAAA,CAAA,CAAA;;;;"}
|
package/dist/api.esm.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { createApiRef } from '@backstage/core-plugin-api';
|
|
2
|
+
|
|
3
|
+
const searchApiRef = createApiRef({
|
|
4
|
+
id: "plugin.search.queryservice"
|
|
5
|
+
});
|
|
6
|
+
class MockSearchApi {
|
|
7
|
+
constructor(mockedResults) {
|
|
8
|
+
this.mockedResults = mockedResults;
|
|
9
|
+
}
|
|
10
|
+
query() {
|
|
11
|
+
return Promise.resolve(this.mockedResults || { results: [] });
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export { MockSearchApi, searchApiRef };
|
|
16
|
+
//# sourceMappingURL=api.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.esm.js","sources":["../src/api.ts"],"sourcesContent":["/*\n * Copyright 2022 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 { SearchQuery, SearchResultSet } from '@backstage/plugin-search-common';\nimport { createApiRef } from '@backstage/core-plugin-api';\n\n/**\n * @public\n */\nexport const searchApiRef = createApiRef<SearchApi>({\n id: 'plugin.search.queryservice',\n});\n\n/**\n * @public\n */\nexport interface SearchApi {\n query(query: SearchQuery): Promise<SearchResultSet>;\n}\n\n/**\n * @public\n *\n * Search Api Mock that can be used in tests and storybooks\n */\nexport class MockSearchApi implements SearchApi {\n constructor(public mockedResults?: SearchResultSet) {}\n\n query(): Promise<SearchResultSet> {\n return Promise.resolve(this.mockedResults || { results: [] });\n }\n}\n"],"names":[],"mappings":";;AAsBO,MAAM,eAAe,YAAwB,CAAA;AAAA,EAClD,EAAI,EAAA,4BAAA;AACN,CAAC,EAAA;AAcM,MAAM,aAAmC,CAAA;AAAA,EAC9C,YAAmB,aAAiC,EAAA;AAAjC,IAAA,IAAA,CAAA,aAAA,GAAA,aAAA,CAAA;AAAA,GAAkC;AAAA,EAErD,KAAkC,GAAA;AAChC,IAAO,OAAA,OAAA,CAAQ,QAAQ,IAAK,CAAA,aAAA,IAAiB,EAAE,OAAS,EAAA,IAAI,CAAA,CAAA;AAAA,GAC9D;AACF;;;;"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { AnalyticsContext } from '@backstage/core-plugin-api';
|
|
3
|
+
import { HighlightedSearchResultText } from '../HighlightedSearchResultText/HighlightedSearchResultText.esm.js';
|
|
4
|
+
import ListItemIcon from '@material-ui/core/ListItemIcon';
|
|
5
|
+
import ListItemText from '@material-ui/core/ListItemText';
|
|
6
|
+
import Box from '@material-ui/core/Box';
|
|
7
|
+
import Typography from '@material-ui/core/Typography';
|
|
8
|
+
import { Link } from '@backstage/core-components';
|
|
9
|
+
|
|
10
|
+
const DefaultResultListItemComponent = ({
|
|
11
|
+
result,
|
|
12
|
+
highlight,
|
|
13
|
+
icon,
|
|
14
|
+
secondaryAction,
|
|
15
|
+
lineClamp = 5
|
|
16
|
+
}) => {
|
|
17
|
+
if (!result)
|
|
18
|
+
return null;
|
|
19
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, icon && /* @__PURE__ */ React.createElement(ListItemIcon, null, icon), /* @__PURE__ */ React.createElement(
|
|
20
|
+
ListItemText,
|
|
21
|
+
{
|
|
22
|
+
primaryTypographyProps: { variant: "h6" },
|
|
23
|
+
primary: /* @__PURE__ */ React.createElement(Link, { noTrack: true, to: result.location }, (highlight == null ? void 0 : highlight.fields.title) ? /* @__PURE__ */ React.createElement(
|
|
24
|
+
HighlightedSearchResultText,
|
|
25
|
+
{
|
|
26
|
+
text: (highlight == null ? void 0 : highlight.fields.title) || "",
|
|
27
|
+
preTag: (highlight == null ? void 0 : highlight.preTag) || "",
|
|
28
|
+
postTag: (highlight == null ? void 0 : highlight.postTag) || ""
|
|
29
|
+
}
|
|
30
|
+
) : result.title),
|
|
31
|
+
secondary: /* @__PURE__ */ React.createElement(
|
|
32
|
+
Typography,
|
|
33
|
+
{
|
|
34
|
+
component: "span",
|
|
35
|
+
style: {
|
|
36
|
+
display: "-webkit-box",
|
|
37
|
+
WebkitBoxOrient: "vertical",
|
|
38
|
+
WebkitLineClamp: lineClamp,
|
|
39
|
+
overflow: "hidden"
|
|
40
|
+
},
|
|
41
|
+
color: "textSecondary",
|
|
42
|
+
variant: "body2"
|
|
43
|
+
},
|
|
44
|
+
(highlight == null ? void 0 : highlight.fields.text) ? /* @__PURE__ */ React.createElement(
|
|
45
|
+
HighlightedSearchResultText,
|
|
46
|
+
{
|
|
47
|
+
text: highlight.fields.text,
|
|
48
|
+
preTag: highlight.preTag,
|
|
49
|
+
postTag: highlight.postTag
|
|
50
|
+
}
|
|
51
|
+
) : result.text
|
|
52
|
+
)
|
|
53
|
+
}
|
|
54
|
+
), secondaryAction && /* @__PURE__ */ React.createElement(Box, { alignItems: "flex-end" }, secondaryAction));
|
|
55
|
+
};
|
|
56
|
+
const HigherOrderDefaultResultListItem = (props) => {
|
|
57
|
+
return /* @__PURE__ */ React.createElement(
|
|
58
|
+
AnalyticsContext,
|
|
59
|
+
{
|
|
60
|
+
attributes: {
|
|
61
|
+
pluginId: "search",
|
|
62
|
+
extension: "DefaultResultListItem"
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
/* @__PURE__ */ React.createElement(DefaultResultListItemComponent, { ...props })
|
|
66
|
+
);
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
export { HigherOrderDefaultResultListItem as DefaultResultListItem, DefaultResultListItemComponent };
|
|
70
|
+
//# sourceMappingURL=DefaultResultListItem.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DefaultResultListItem.esm.js","sources":["../../../src/components/DefaultResultListItem/DefaultResultListItem.tsx"],"sourcesContent":["/*\n * Copyright 2022 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, { ReactNode } from 'react';\nimport { AnalyticsContext } from '@backstage/core-plugin-api';\nimport {\n ResultHighlight,\n SearchDocument,\n} from '@backstage/plugin-search-common';\nimport { HighlightedSearchResultText } from '../HighlightedSearchResultText';\nimport ListItemIcon from '@material-ui/core/ListItemIcon';\nimport ListItemText from '@material-ui/core/ListItemText';\nimport Box from '@material-ui/core/Box';\nimport Typography from '@material-ui/core/Typography';\nimport { Link } from '@backstage/core-components';\n\n/**\n * Props for {@link DefaultResultListItem}\n *\n * @public\n */\nexport type DefaultResultListItemProps = {\n icon?: ReactNode;\n secondaryAction?: ReactNode;\n result?: SearchDocument;\n highlight?: ResultHighlight;\n rank?: number;\n lineClamp?: number;\n toggleModal?: () => void;\n};\n\n/**\n * A default result list item.\n *\n * @public\n */\nexport const DefaultResultListItemComponent = ({\n result,\n highlight,\n icon,\n secondaryAction,\n lineClamp = 5,\n}: DefaultResultListItemProps) => {\n if (!result) return null;\n\n return (\n <>\n {icon && <ListItemIcon>{icon}</ListItemIcon>}\n <ListItemText\n primaryTypographyProps={{ variant: 'h6' }}\n primary={\n <Link noTrack to={result.location}>\n {highlight?.fields.title ? (\n <HighlightedSearchResultText\n text={highlight?.fields.title || ''}\n preTag={highlight?.preTag || ''}\n postTag={highlight?.postTag || ''}\n />\n ) : (\n result.title\n )}\n </Link>\n }\n secondary={\n <Typography\n component=\"span\"\n style={{\n display: '-webkit-box',\n WebkitBoxOrient: 'vertical',\n WebkitLineClamp: lineClamp,\n overflow: 'hidden',\n }}\n color=\"textSecondary\"\n variant=\"body2\"\n >\n {highlight?.fields.text ? (\n <HighlightedSearchResultText\n text={highlight.fields.text}\n preTag={highlight.preTag}\n postTag={highlight.postTag}\n />\n ) : (\n result.text\n )}\n </Typography>\n }\n />\n {secondaryAction && <Box alignItems=\"flex-end\">{secondaryAction}</Box>}\n </>\n );\n};\n\n/**\n * @public\n */\nconst HigherOrderDefaultResultListItem = (\n props: DefaultResultListItemProps,\n) => {\n return (\n <AnalyticsContext\n attributes={{\n pluginId: 'search',\n extension: 'DefaultResultListItem',\n }}\n >\n <DefaultResultListItemComponent {...props} />\n </AnalyticsContext>\n );\n};\n\nexport { HigherOrderDefaultResultListItem as DefaultResultListItem };\n"],"names":[],"mappings":";;;;;;;;;AAiDO,MAAM,iCAAiC,CAAC;AAAA,EAC7C,MAAA;AAAA,EACA,SAAA;AAAA,EACA,IAAA;AAAA,EACA,eAAA;AAAA,EACA,SAAY,GAAA,CAAA;AACd,CAA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AA,GAAA,KAAA,CAAA,GAAA,SAAA,CAAW,OAAO,IACjB,oBAAA,KAAA,CAAA,aAAA;AAAA,UAAC,2BAAA;AAAA,UAAA;AAAA,YACC,IAAA,EAAM,UAAU,MAAO,CAAA,IAAA;AAAA,YACvB,QAAQ,SAAU,CAAA,MAAA;AAAA,YAClB,SAAS,SAAU,CAAA,OAAA;AAAA,WAAA;AAAA,YAGrB,MAAO,CAAA,IAAA;AAAA,OAEX;AAAA,KAAA;AAAA,KAGH,eAAmB,oBAAA,KAAA,CAAA,aAAA,CAAC,OAAI,UAAW,EAAA,UAAA,EAAA,EAAY,eAAgB,CAClE,CAAA,CAAA;AAEJ,EAAA;AAKM,MAAA,gCAAA,GAAmC,CACvC,KACG,KAAA;AACH,EACE,uBAAA,KAAA,CAAA,aAAA;AAAA,IAAC,gBAAA;AAAA,IAAA;AAAA,MACC,UAAY,EAAA;AAAA,QACV,QAAU,EAAA,QAAA;AAAA,QACV,SAAW,EAAA,uBAAA;AAAA,OACb;AAAA,KAAA;AAAA,oBAEA,KAAA,CAAA,aAAA,CAAC,8BAAgC,EAAA,EAAA,GAAG,KAAO,EAAA,CAAA;AAAA,GAC7C,CAAA;AAEJ;;;;"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import React, { useMemo } from 'react';
|
|
2
|
+
import { makeStyles } from '@material-ui/core/styles';
|
|
3
|
+
|
|
4
|
+
const useStyles = makeStyles(
|
|
5
|
+
() => ({
|
|
6
|
+
highlight: {}
|
|
7
|
+
}),
|
|
8
|
+
{ name: "BackstageHighlightedSearchResultText" }
|
|
9
|
+
);
|
|
10
|
+
const HighlightedSearchResultText = (props) => {
|
|
11
|
+
const { text, preTag, postTag } = props;
|
|
12
|
+
const classes = useStyles();
|
|
13
|
+
const terms = useMemo(
|
|
14
|
+
() => text.split(new RegExp(`(${preTag}.+?${postTag})`)),
|
|
15
|
+
[postTag, preTag, text]
|
|
16
|
+
);
|
|
17
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, terms.map(
|
|
18
|
+
(t, idx) => t.includes(preTag) ? /* @__PURE__ */ React.createElement("mark", { className: classes.highlight, key: idx }, t.replace(new RegExp(`${preTag}|${postTag}`, "g"), "")) : t
|
|
19
|
+
));
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export { HighlightedSearchResultText };
|
|
23
|
+
//# sourceMappingURL=HighlightedSearchResultText.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HighlightedSearchResultText.esm.js","sources":["../../../src/components/HighlightedSearchResultText/HighlightedSearchResultText.tsx"],"sourcesContent":["/*\n * Copyright 2022 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, { useMemo } from 'react';\nimport { makeStyles } from '@material-ui/core/styles';\n\nconst useStyles = makeStyles(\n () => ({\n highlight: {},\n }),\n { name: 'BackstageHighlightedSearchResultText' },\n);\n\n/**\n * Props for {@link HighlightedSearchResultText}.\n *\n * @public\n */\nexport type HighlightedSearchResultTextProps = {\n text: string;\n preTag: string;\n postTag: string;\n};\n\n/**\n * @public\n */\nexport const HighlightedSearchResultText = (\n props: HighlightedSearchResultTextProps,\n) => {\n const { text, preTag, postTag } = props;\n\n const classes = useStyles();\n const terms = useMemo(\n () => text.split(new RegExp(`(${preTag}.+?${postTag})`)),\n [postTag, preTag, text],\n );\n\n return (\n <>\n {terms.map((t, idx) =>\n t.includes(preTag) ? (\n <mark className={classes.highlight} key={idx}>\n {t.replace(new RegExp(`${preTag}|${postTag}`, 'g'), '')}\n </mark>\n ) : (\n t\n ),\n )}\n </>\n );\n};\n"],"names":[],"mappings":";;;AAmBA,MAAM,SAAY,GAAA,UAAA;AAAA,EAChB,OAAO;AAAA,IACL,WAAW,EAAC;AAAA,GACd,CAAA;AAAA,EACA,EAAE,MAAM,sCAAuC,EAAA;AACjD,CAAA,CAAA;AAgBa,MAAA,2BAAA,GAA8B,CACzC,KACG,KAAA;AACH,EAAA,MAAM,EAAE,IAAA,EAAM,MAAQ,EAAA,OAAA,EAAY,GAAA,KAAA,CAAA;AAElC,EAAA,MAAM,UAAU,SAAU,EAAA,CAAA;AAC1B,EAAA,MAAM,KAAQ,GAAA,OAAA;AAAA,IACZ,MAAM,IAAK,CAAA,KAAA,CAAM,IAAI,MAAA,CAAO,IAAI,MAAM,CAAA,GAAA,EAAM,OAAO,CAAA,CAAA,CAAG,CAAC,CAAA;AAAA,IACvD,CAAC,OAAS,EAAA,MAAA,EAAQ,IAAI,CAAA;AAAA,GACxB,CAAA;AAEA,EAAA,iEAEK,KAAM,CAAA,GAAA;AAAA,IAAI,CAAC,CAAG,EAAA,GAAA,KACb,CAAE,CAAA,QAAA,CAAS,MAAM,CAAA,mBACd,KAAA,CAAA,aAAA,CAAA,MAAA,EAAA,EAAK,SAAW,EAAA,OAAA,CAAQ,SAAW,EAAA,GAAA,EAAK,GACtC,EAAA,EAAA,CAAA,CAAE,OAAQ,CAAA,IAAI,MAAO,CAAA,CAAA,EAAG,MAAM,CAAA,CAAA,EAAI,OAAO,CAAA,CAAA,EAAI,GAAG,CAAA,EAAG,EAAE,CACxD,CAEA,GAAA,CAAA;AAAA,GAGN,CAAA,CAAA;AAEJ;;;;"}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import React, { useCallback, useMemo } from 'react';
|
|
2
|
+
import CircularProgress from '@material-ui/core/CircularProgress';
|
|
3
|
+
import { makeStyles } from '@material-ui/core/styles';
|
|
4
|
+
import Autocomplete from '@material-ui/lab/Autocomplete';
|
|
5
|
+
import { SearchContextProvider, useSearch } from '../../context/SearchContext.esm.js';
|
|
6
|
+
import { SearchBar } from '../SearchBar/SearchBar.esm.js';
|
|
7
|
+
|
|
8
|
+
const useStyles = makeStyles((theme) => ({
|
|
9
|
+
loading: {
|
|
10
|
+
right: theme.spacing(1),
|
|
11
|
+
position: "absolute"
|
|
12
|
+
}
|
|
13
|
+
}));
|
|
14
|
+
const withContext = (Component) => {
|
|
15
|
+
return (props) => /* @__PURE__ */ React.createElement(SearchContextProvider, { inheritParentContextIfAvailable: true }, /* @__PURE__ */ React.createElement(Component, { ...props }));
|
|
16
|
+
};
|
|
17
|
+
const SearchAutocompleteLoadingAdornment = () => {
|
|
18
|
+
const classes = useStyles();
|
|
19
|
+
return /* @__PURE__ */ React.createElement(
|
|
20
|
+
CircularProgress,
|
|
21
|
+
{
|
|
22
|
+
className: classes.loading,
|
|
23
|
+
"data-testid": "search-autocomplete-progressbar",
|
|
24
|
+
color: "inherit",
|
|
25
|
+
size: 20
|
|
26
|
+
}
|
|
27
|
+
);
|
|
28
|
+
};
|
|
29
|
+
const SearchAutocomplete = withContext(
|
|
30
|
+
function SearchAutocompleteComponent(props) {
|
|
31
|
+
const {
|
|
32
|
+
loading,
|
|
33
|
+
value,
|
|
34
|
+
onChange = () => {
|
|
35
|
+
},
|
|
36
|
+
options = [],
|
|
37
|
+
getOptionLabel = (option) => String(option),
|
|
38
|
+
inputPlaceholder,
|
|
39
|
+
inputDebounceTime,
|
|
40
|
+
freeSolo = true,
|
|
41
|
+
fullWidth = true,
|
|
42
|
+
clearOnBlur = false,
|
|
43
|
+
"data-testid": dataTestId = "search-autocomplete",
|
|
44
|
+
...rest
|
|
45
|
+
} = props;
|
|
46
|
+
const { setTerm } = useSearch();
|
|
47
|
+
const getInputValue = useCallback(
|
|
48
|
+
(option) => {
|
|
49
|
+
if (!option)
|
|
50
|
+
return "";
|
|
51
|
+
if (typeof option === "string")
|
|
52
|
+
return option;
|
|
53
|
+
return getOptionLabel(option);
|
|
54
|
+
},
|
|
55
|
+
[getOptionLabel]
|
|
56
|
+
);
|
|
57
|
+
const inputValue = useMemo(
|
|
58
|
+
() => getInputValue(value),
|
|
59
|
+
[value, getInputValue]
|
|
60
|
+
);
|
|
61
|
+
const handleChange = useCallback(
|
|
62
|
+
(event, option, reason, details) => {
|
|
63
|
+
setTerm(getInputValue(option));
|
|
64
|
+
onChange(event, option, reason, details);
|
|
65
|
+
},
|
|
66
|
+
[getInputValue, setTerm, onChange]
|
|
67
|
+
);
|
|
68
|
+
const renderInput = useCallback(
|
|
69
|
+
({
|
|
70
|
+
InputProps: { ref, className, endAdornment },
|
|
71
|
+
InputLabelProps,
|
|
72
|
+
...params
|
|
73
|
+
}) => /* @__PURE__ */ React.createElement(
|
|
74
|
+
SearchBar,
|
|
75
|
+
{
|
|
76
|
+
...params,
|
|
77
|
+
ref,
|
|
78
|
+
clearButton: false,
|
|
79
|
+
value: inputValue,
|
|
80
|
+
placeholder: inputPlaceholder,
|
|
81
|
+
debounceTime: inputDebounceTime,
|
|
82
|
+
endAdornment: loading ? /* @__PURE__ */ React.createElement(SearchAutocompleteLoadingAdornment, null) : endAdornment,
|
|
83
|
+
InputProps: { className }
|
|
84
|
+
}
|
|
85
|
+
),
|
|
86
|
+
[loading, inputValue, inputPlaceholder, inputDebounceTime]
|
|
87
|
+
);
|
|
88
|
+
return /* @__PURE__ */ React.createElement(
|
|
89
|
+
Autocomplete,
|
|
90
|
+
{
|
|
91
|
+
...rest,
|
|
92
|
+
"data-testid": dataTestId,
|
|
93
|
+
value,
|
|
94
|
+
onChange: handleChange,
|
|
95
|
+
options,
|
|
96
|
+
getOptionLabel,
|
|
97
|
+
renderInput,
|
|
98
|
+
freeSolo,
|
|
99
|
+
fullWidth,
|
|
100
|
+
clearOnBlur
|
|
101
|
+
}
|
|
102
|
+
);
|
|
103
|
+
}
|
|
104
|
+
);
|
|
105
|
+
|
|
106
|
+
export { SearchAutocomplete };
|
|
107
|
+
//# sourceMappingURL=SearchAutocomplete.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SearchAutocomplete.esm.js","sources":["../../../src/components/SearchAutocomplete/SearchAutocomplete.tsx"],"sourcesContent":["/*\n * Copyright 2022 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, { ChangeEvent, useCallback, useMemo } from 'react';\n\nimport CircularProgress from '@material-ui/core/CircularProgress';\nimport { makeStyles } from '@material-ui/core/styles';\nimport Autocomplete, {\n AutocompleteProps,\n AutocompleteRenderInputParams,\n} from '@material-ui/lab/Autocomplete';\nimport {\n AutocompleteChangeDetails,\n AutocompleteChangeReason,\n} from '@material-ui/lab/useAutocomplete';\n\nimport { SearchContextProvider, useSearch } from '../../context';\nimport { SearchBar, SearchBarProps } from '../SearchBar';\n\nconst useStyles = makeStyles(theme => ({\n loading: {\n right: theme.spacing(1),\n position: 'absolute',\n },\n}));\n\n/**\n * Props for {@link SearchAutocomplete}.\n *\n * @public\n */\nexport type SearchAutocompleteProps<Option> = Omit<\n AutocompleteProps<Option, undefined, undefined, boolean>,\n 'renderInput' | 'disableClearable' | 'multiple'\n> & {\n 'data-testid'?: string;\n inputPlaceholder?: SearchBarProps['placeholder'];\n inputDebounceTime?: SearchBarProps['debounceTime'];\n};\n\n/**\n * Type for {@link SearchAutocomplete}.\n *\n * @public\n */\nexport type SearchAutocompleteComponent = <Option>(\n props: SearchAutocompleteProps<Option>,\n) => JSX.Element;\n\nconst withContext = (\n Component: SearchAutocompleteComponent,\n): SearchAutocompleteComponent => {\n return props => (\n <SearchContextProvider inheritParentContextIfAvailable>\n <Component {...props} />\n </SearchContextProvider>\n );\n};\n\nconst SearchAutocompleteLoadingAdornment = () => {\n const classes = useStyles();\n return (\n <CircularProgress\n className={classes.loading}\n data-testid=\"search-autocomplete-progressbar\"\n color=\"inherit\"\n size={20}\n />\n );\n};\n\n/**\n * Recommended search autocomplete when you use the Search Provider or Search Context.\n *\n * @public\n */\nexport const SearchAutocomplete = withContext(\n function SearchAutocompleteComponent<Option>(\n props: SearchAutocompleteProps<Option>,\n ) {\n const {\n loading,\n value,\n onChange = () => {},\n options = [],\n getOptionLabel = (option: Option) => String(option),\n inputPlaceholder,\n inputDebounceTime,\n freeSolo = true,\n fullWidth = true,\n clearOnBlur = false,\n 'data-testid': dataTestId = 'search-autocomplete',\n ...rest\n } = props;\n\n const { setTerm } = useSearch();\n\n const getInputValue = useCallback(\n (option?: null | string | Option) => {\n if (!option) return '';\n if (typeof option === 'string') return option;\n return getOptionLabel(option);\n },\n [getOptionLabel],\n );\n\n const inputValue = useMemo(\n () => getInputValue(value),\n [value, getInputValue],\n );\n\n const handleChange = useCallback(\n (\n event: ChangeEvent<{}>,\n option: null | string | Option,\n reason: AutocompleteChangeReason,\n details?: AutocompleteChangeDetails<Option>,\n ) => {\n setTerm(getInputValue(option));\n onChange(event, option, reason, details);\n },\n [getInputValue, setTerm, onChange],\n );\n\n const renderInput = useCallback(\n ({\n InputProps: { ref, className, endAdornment },\n InputLabelProps,\n ...params\n }: AutocompleteRenderInputParams) => (\n <SearchBar\n {...params}\n ref={ref}\n clearButton={false}\n value={inputValue}\n placeholder={inputPlaceholder}\n debounceTime={inputDebounceTime}\n endAdornment={\n loading ? <SearchAutocompleteLoadingAdornment /> : endAdornment\n }\n InputProps={{ className }}\n />\n ),\n [loading, inputValue, inputPlaceholder, inputDebounceTime],\n );\n\n return (\n <Autocomplete\n {...rest}\n data-testid={dataTestId}\n value={value}\n onChange={handleChange}\n options={options}\n getOptionLabel={getOptionLabel}\n renderInput={renderInput}\n freeSolo={freeSolo}\n fullWidth={fullWidth}\n clearOnBlur={clearOnBlur}\n />\n );\n },\n);\n"],"names":[],"mappings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,CAAA,kCAAA,EAAA,IAAmC,CAAK,GAAA,YAAA;AAAA,UAErD,UAAA,EAAY,EAAE,SAAU,EAAA;AAAA,SAAA;AAAA,OAC1B;AAAA,MAEF,CAAC,OAAA,EAAS,UAAY,EAAA,gBAAA,EAAkB,iBAAiB,CAAA;AAAA,KAC3D,CAAA;AAEA,IACE,uBAAA,KAAA,CAAA,aAAA;AAAA,MAAC,YAAA;AAAA,MAAA;AAAA,QACE,GAAG,IAAA;AAAA,QACJ,aAAa,EAAA,UAAA;AAAA,QACb,KAAA;AAAA,QACA,QAAU,EAAA,YAAA;AAAA,QACV,OAAA;AAAA,QACA,cAAA;AAAA,QACA,WAAA;AAAA,QACA,QAAA;AAAA,QACA,SAAA;AAAA,QACA,WAAA;AAAA,OAAA;AAAA,KACF,CAAA;AAAA,GAEJ;AACF;;;;"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import ListItemIcon from '@material-ui/core/ListItemIcon';
|
|
3
|
+
import ListItemText from '@material-ui/core/ListItemText';
|
|
4
|
+
|
|
5
|
+
const SearchAutocompleteDefaultOption = (props) => {
|
|
6
|
+
const {
|
|
7
|
+
icon,
|
|
8
|
+
primaryText,
|
|
9
|
+
primaryTextTypographyProps,
|
|
10
|
+
secondaryText,
|
|
11
|
+
secondaryTextTypographyProps,
|
|
12
|
+
disableTextTypography
|
|
13
|
+
} = props;
|
|
14
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, icon ? /* @__PURE__ */ React.createElement(ListItemIcon, null, icon) : null, /* @__PURE__ */ React.createElement(
|
|
15
|
+
ListItemText,
|
|
16
|
+
{
|
|
17
|
+
primary: primaryText,
|
|
18
|
+
primaryTypographyProps: primaryTextTypographyProps,
|
|
19
|
+
secondary: secondaryText,
|
|
20
|
+
secondaryTypographyProps: secondaryTextTypographyProps,
|
|
21
|
+
disableTypography: disableTextTypography
|
|
22
|
+
}
|
|
23
|
+
));
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export { SearchAutocompleteDefaultOption };
|
|
27
|
+
//# sourceMappingURL=SearchAutocompleteDefaultOption.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SearchAutocompleteDefaultOption.esm.js","sources":["../../../src/components/SearchAutocomplete/SearchAutocompleteDefaultOption.tsx"],"sourcesContent":["/*\n * Copyright 2022 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, { ReactNode } from 'react';\nimport ListItemIcon from '@material-ui/core/ListItemIcon';\nimport ListItemText, {\n ListItemTextProps,\n} from '@material-ui/core/ListItemText';\n\n/**\n * Props for {@link SearchAutocompleteDefaultOption}.\n *\n * @public\n */\nexport type SearchAutocompleteDefaultOptionProps = {\n icon?: ReactNode;\n primaryText: ListItemTextProps['primary'];\n primaryTextTypographyProps?: ListItemTextProps['primaryTypographyProps'];\n secondaryText?: ListItemTextProps['secondary'];\n secondaryTextTypographyProps?: ListItemTextProps['secondaryTypographyProps'];\n disableTextTypography?: ListItemTextProps['disableTypography'];\n};\n\n/**\n * A default search autocomplete option component.\n *\n * @public\n */\nexport const SearchAutocompleteDefaultOption = (\n props: SearchAutocompleteDefaultOptionProps,\n) => {\n const {\n icon,\n primaryText,\n primaryTextTypographyProps,\n secondaryText,\n secondaryTextTypographyProps,\n disableTextTypography,\n } = props;\n\n return (\n <>\n {icon ? <ListItemIcon>{icon}</ListItemIcon> : null}\n <ListItemText\n primary={primaryText}\n primaryTypographyProps={primaryTextTypographyProps}\n secondary={secondaryText}\n secondaryTypographyProps={secondaryTextTypographyProps}\n disableTypography={disableTextTypography}\n />\n </>\n );\n};\n"],"names":[],"mappings":";;;;AAyCa,MAAA,+BAAA,GAAkC,CAC7C,KACG,KAAA;AACH,EAAM,MAAA;AAAA,IACJ,IAAA;AAAA,IACA,WAAA;AAAA,IACA,0BAAA;AAAA,IACA,aAAA;AAAA,IACA,4BAAA;AAAA,IACA,qBAAA;AAAA,GACE,GAAA,KAAA,CAAA;AAEJ,EAAA,iEAEK,IAAO,mBAAA,KAAA,CAAA,aAAA,CAAC,YAAc,EAAA,IAAA,EAAA,IAAK,IAAkB,IAC9C,kBAAA,KAAA,CAAA,aAAA;AAAA,IAAC,YAAA;AAAA,IAAA;AAAA,MACC,OAAS,EAAA,WAAA;AAAA,MACT,sBAAwB,EAAA,0BAAA;AAAA,MACxB,SAAW,EAAA,aAAA;AAAA,MACX,wBAA0B,EAAA,4BAAA;AAAA,MAC1B,iBAAmB,EAAA,qBAAA;AAAA,KAAA;AAAA,GAEvB,CAAA,CAAA;AAEJ;;;;"}
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import { useApi, configApiRef, AnalyticsContext } from '@backstage/core-plugin-api';
|
|
2
|
+
import IconButton from '@material-ui/core/IconButton';
|
|
3
|
+
import InputAdornment from '@material-ui/core/InputAdornment';
|
|
4
|
+
import TextField from '@material-ui/core/TextField';
|
|
5
|
+
import Button from '@material-ui/core/Button';
|
|
6
|
+
import SearchIcon from '@material-ui/icons/Search';
|
|
7
|
+
import React, { forwardRef, useState, useRef, useEffect, useCallback } from 'react';
|
|
8
|
+
import useDebounce from 'react-use/esm/useDebounce';
|
|
9
|
+
import { useSearch, SearchContextProvider } from '../../context/SearchContext.esm.js';
|
|
10
|
+
|
|
11
|
+
function withContext(Component) {
|
|
12
|
+
return forwardRef((props, ref) => /* @__PURE__ */ React.createElement(SearchContextProvider, { inheritParentContextIfAvailable: true }, /* @__PURE__ */ React.createElement(Component, { ...props, ref })));
|
|
13
|
+
}
|
|
14
|
+
const SearchBarBase = withContext(
|
|
15
|
+
forwardRef((props, ref) => {
|
|
16
|
+
const {
|
|
17
|
+
onChange,
|
|
18
|
+
onKeyDown = () => {
|
|
19
|
+
},
|
|
20
|
+
onClear = () => {
|
|
21
|
+
},
|
|
22
|
+
onSubmit = () => {
|
|
23
|
+
},
|
|
24
|
+
debounceTime = 200,
|
|
25
|
+
clearButton = true,
|
|
26
|
+
fullWidth = true,
|
|
27
|
+
value: defaultValue,
|
|
28
|
+
label,
|
|
29
|
+
placeholder,
|
|
30
|
+
inputProps = {},
|
|
31
|
+
InputProps = {},
|
|
32
|
+
endAdornment,
|
|
33
|
+
...rest
|
|
34
|
+
} = props;
|
|
35
|
+
const configApi = useApi(configApiRef);
|
|
36
|
+
const [value, setValue] = useState("");
|
|
37
|
+
const forwardedValueRef = useRef("");
|
|
38
|
+
useEffect(() => {
|
|
39
|
+
setValue((prevValue) => {
|
|
40
|
+
if (prevValue === forwardedValueRef.current) {
|
|
41
|
+
return String(defaultValue);
|
|
42
|
+
}
|
|
43
|
+
return prevValue;
|
|
44
|
+
});
|
|
45
|
+
}, [defaultValue, forwardedValueRef]);
|
|
46
|
+
useDebounce(
|
|
47
|
+
() => {
|
|
48
|
+
forwardedValueRef.current = value;
|
|
49
|
+
onChange(value);
|
|
50
|
+
},
|
|
51
|
+
debounceTime,
|
|
52
|
+
[value]
|
|
53
|
+
);
|
|
54
|
+
const handleChange = useCallback(
|
|
55
|
+
(e) => {
|
|
56
|
+
setValue(e.target.value);
|
|
57
|
+
},
|
|
58
|
+
[setValue]
|
|
59
|
+
);
|
|
60
|
+
const handleKeyDown = useCallback(
|
|
61
|
+
(e) => {
|
|
62
|
+
if (onKeyDown)
|
|
63
|
+
onKeyDown(e);
|
|
64
|
+
if (onSubmit && e.key === "Enter") {
|
|
65
|
+
onSubmit();
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
[onKeyDown, onSubmit]
|
|
69
|
+
);
|
|
70
|
+
const handleClear = useCallback(() => {
|
|
71
|
+
forwardedValueRef.current = "";
|
|
72
|
+
onChange("");
|
|
73
|
+
setValue("");
|
|
74
|
+
if (onClear) {
|
|
75
|
+
onClear();
|
|
76
|
+
}
|
|
77
|
+
}, [onChange, onClear]);
|
|
78
|
+
const ariaLabel = label ? void 0 : "Search";
|
|
79
|
+
const inputPlaceholder = placeholder != null ? placeholder : `Search in ${configApi.getOptionalString("app.title") || "Backstage"}`;
|
|
80
|
+
const startAdornment = /* @__PURE__ */ React.createElement(InputAdornment, { position: "start" }, /* @__PURE__ */ React.createElement(IconButton, { "aria-label": "Query", size: "small", disabled: true }, /* @__PURE__ */ React.createElement(SearchIcon, null)));
|
|
81
|
+
const clearButtonEndAdornment = /* @__PURE__ */ React.createElement(InputAdornment, { position: "end" }, /* @__PURE__ */ React.createElement(
|
|
82
|
+
Button,
|
|
83
|
+
{
|
|
84
|
+
"aria-label": "Clear",
|
|
85
|
+
size: "small",
|
|
86
|
+
onClick: handleClear,
|
|
87
|
+
onKeyDown: (event) => {
|
|
88
|
+
if (event.key === "Enter") {
|
|
89
|
+
event.stopPropagation();
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
"Clear"
|
|
94
|
+
));
|
|
95
|
+
return /* @__PURE__ */ React.createElement(
|
|
96
|
+
TextField,
|
|
97
|
+
{
|
|
98
|
+
id: "search-bar-text-field",
|
|
99
|
+
"data-testid": "search-bar-next",
|
|
100
|
+
variant: "outlined",
|
|
101
|
+
margin: "normal",
|
|
102
|
+
inputRef: ref,
|
|
103
|
+
value,
|
|
104
|
+
label,
|
|
105
|
+
placeholder: inputPlaceholder,
|
|
106
|
+
InputProps: {
|
|
107
|
+
startAdornment,
|
|
108
|
+
endAdornment: clearButton ? clearButtonEndAdornment : endAdornment,
|
|
109
|
+
...InputProps
|
|
110
|
+
},
|
|
111
|
+
inputProps: {
|
|
112
|
+
"aria-label": ariaLabel,
|
|
113
|
+
...inputProps
|
|
114
|
+
},
|
|
115
|
+
fullWidth,
|
|
116
|
+
onChange: handleChange,
|
|
117
|
+
onKeyDown: handleKeyDown,
|
|
118
|
+
...rest
|
|
119
|
+
}
|
|
120
|
+
);
|
|
121
|
+
})
|
|
122
|
+
);
|
|
123
|
+
const SearchBar = withContext(
|
|
124
|
+
forwardRef((props, ref) => {
|
|
125
|
+
const { value: initialValue = "", onChange, ...rest } = props;
|
|
126
|
+
const { term, setTerm } = useSearch();
|
|
127
|
+
useEffect(() => {
|
|
128
|
+
if (initialValue) {
|
|
129
|
+
setTerm(String(initialValue));
|
|
130
|
+
}
|
|
131
|
+
}, [initialValue, setTerm]);
|
|
132
|
+
const handleChange = useCallback(
|
|
133
|
+
(newValue) => {
|
|
134
|
+
if (onChange) {
|
|
135
|
+
onChange(newValue);
|
|
136
|
+
} else {
|
|
137
|
+
setTerm(newValue);
|
|
138
|
+
}
|
|
139
|
+
},
|
|
140
|
+
[onChange, setTerm]
|
|
141
|
+
);
|
|
142
|
+
return /* @__PURE__ */ React.createElement(
|
|
143
|
+
AnalyticsContext,
|
|
144
|
+
{
|
|
145
|
+
attributes: { pluginId: "search", extension: "SearchBar" }
|
|
146
|
+
},
|
|
147
|
+
/* @__PURE__ */ React.createElement(
|
|
148
|
+
SearchBarBase,
|
|
149
|
+
{
|
|
150
|
+
...rest,
|
|
151
|
+
ref,
|
|
152
|
+
value: term,
|
|
153
|
+
onChange: handleChange
|
|
154
|
+
}
|
|
155
|
+
)
|
|
156
|
+
);
|
|
157
|
+
})
|
|
158
|
+
);
|
|
159
|
+
|
|
160
|
+
export { SearchBar, SearchBarBase };
|
|
161
|
+
//# sourceMappingURL=SearchBar.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SearchBar.esm.js","sources":["../../../src/components/SearchBar/SearchBar.tsx"],"sourcesContent":["/*\n * Copyright 2022 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 {\n AnalyticsContext,\n configApiRef,\n useApi,\n} from '@backstage/core-plugin-api';\nimport IconButton from '@material-ui/core/IconButton';\nimport InputAdornment from '@material-ui/core/InputAdornment';\nimport TextField from '@material-ui/core/TextField';\nimport Button from '@material-ui/core/Button';\nimport { TextFieldProps } from '@material-ui/core/TextField';\nimport SearchIcon from '@material-ui/icons/Search';\nimport React, {\n ChangeEvent,\n ComponentType,\n forwardRef,\n ForwardRefExoticComponent,\n KeyboardEvent,\n useCallback,\n useEffect,\n useRef,\n useState,\n} from 'react';\nimport useDebounce from 'react-use/esm/useDebounce';\n\nimport { SearchContextProvider, useSearch } from '../../context';\n\nfunction withContext<T>(Component: ComponentType<T>) {\n return forwardRef<HTMLDivElement, T>((props, ref) => (\n <SearchContextProvider inheritParentContextIfAvailable>\n <Component {...props} ref={ref} />\n </SearchContextProvider>\n ));\n}\n\n/**\n * Props for {@link SearchBarBase}.\n *\n * @public\n */\nexport type SearchBarBaseProps = Omit<TextFieldProps, 'onChange'> & {\n debounceTime?: number;\n clearButton?: boolean;\n onClear?: () => void;\n onSubmit?: () => void;\n onChange: (value: string) => void;\n endAdornment?: React.ReactNode;\n};\n\n/**\n * All search boxes exported by the search plugin are based on the <SearchBarBase />,\n * and this one is based on the <InputBase /> component from Material UI.\n * Recommended if you don't use Search Provider or Search Context.\n *\n * @public\n */\nexport const SearchBarBase: ForwardRefExoticComponent<SearchBarBaseProps> =\n withContext(\n forwardRef((props, ref) => {\n const {\n onChange,\n onKeyDown = () => {},\n onClear = () => {},\n onSubmit = () => {},\n debounceTime = 200,\n clearButton = true,\n fullWidth = true,\n value: defaultValue,\n label,\n placeholder,\n inputProps = {},\n InputProps = {},\n endAdornment,\n ...rest\n } = props;\n\n const configApi = useApi(configApiRef);\n const [value, setValue] = useState<string>('');\n const forwardedValueRef = useRef<string>('');\n\n useEffect(() => {\n setValue(prevValue => {\n // We only update the value if our current value is the same as it was\n // for the most recent onChange call. Otherwise it means that the users\n // has continued typing and we should not replace their input.\n if (prevValue === forwardedValueRef.current) {\n return String(defaultValue);\n }\n return prevValue;\n });\n }, [defaultValue, forwardedValueRef]);\n\n useDebounce(\n () => {\n forwardedValueRef.current = value;\n onChange(value);\n },\n debounceTime,\n [value],\n );\n\n const handleChange = useCallback(\n (e: ChangeEvent<HTMLInputElement>) => {\n setValue(e.target.value);\n },\n [setValue],\n );\n\n const handleKeyDown = useCallback(\n (e: KeyboardEvent<HTMLDivElement>) => {\n if (onKeyDown) onKeyDown(e);\n if (onSubmit && e.key === 'Enter') {\n onSubmit();\n }\n },\n [onKeyDown, onSubmit],\n );\n\n const handleClear = useCallback(() => {\n forwardedValueRef.current = '';\n onChange('');\n setValue('');\n if (onClear) {\n onClear();\n }\n }, [onChange, onClear]);\n\n const ariaLabel: string | undefined = label ? undefined : 'Search';\n\n const inputPlaceholder =\n placeholder ??\n `Search in ${configApi.getOptionalString('app.title') || 'Backstage'}`;\n\n const startAdornment = (\n <InputAdornment position=\"start\">\n <IconButton aria-label=\"Query\" size=\"small\" disabled>\n <SearchIcon />\n </IconButton>\n </InputAdornment>\n );\n\n const clearButtonEndAdornment = (\n <InputAdornment position=\"end\">\n <Button\n aria-label=\"Clear\"\n size=\"small\"\n onClick={handleClear}\n onKeyDown={event => {\n if (event.key === 'Enter') {\n // write your functionality here\n event.stopPropagation();\n }\n }}\n >\n Clear\n </Button>\n </InputAdornment>\n );\n\n return (\n <TextField\n id=\"search-bar-text-field\"\n data-testid=\"search-bar-next\"\n variant=\"outlined\"\n margin=\"normal\"\n inputRef={ref}\n value={value}\n label={label}\n placeholder={inputPlaceholder}\n InputProps={{\n startAdornment,\n endAdornment: clearButton ? clearButtonEndAdornment : endAdornment,\n ...InputProps,\n }}\n inputProps={{\n 'aria-label': ariaLabel,\n ...inputProps,\n }}\n fullWidth={fullWidth}\n onChange={handleChange}\n onKeyDown={handleKeyDown}\n {...rest}\n />\n );\n }),\n );\n\n/**\n * Props for {@link SearchBar}.\n *\n * @public\n */\nexport type SearchBarProps = Partial<SearchBarBaseProps>;\n\n/**\n * Recommended search bar when you use the Search Provider or Search Context.\n *\n * @public\n */\nexport const SearchBar: ForwardRefExoticComponent<SearchBarProps> = withContext(\n forwardRef((props, ref) => {\n const { value: initialValue = '', onChange, ...rest } = props;\n\n const { term, setTerm } = useSearch();\n\n useEffect(() => {\n if (initialValue) {\n setTerm(String(initialValue));\n }\n }, [initialValue, setTerm]);\n\n const handleChange = useCallback(\n (newValue: string) => {\n if (onChange) {\n onChange(newValue);\n } else {\n setTerm(newValue);\n }\n },\n [onChange, setTerm],\n );\n\n return (\n <AnalyticsContext\n attributes={{ pluginId: 'search', extension: 'SearchBar' }}\n >\n <SearchBarBase\n {...rest}\n ref={ref}\n value={term}\n onChange={handleChange}\n />\n </AnalyticsContext>\n );\n }),\n);\n"],"names":[],"mappings":";;;;;;;;;;AA0CA,SAAS,YAAe,SAA6B,EAAA;AACnD,EAAA,OAAO,UAA8B,CAAA,CAAC,KAAO,EAAA,GAAA,yCAC1C,qBAAsB,EAAA,EAAA,+BAAA,EAA+B,IACpD,EAAA,kBAAA,KAAA,CAAA,aAAA,CAAC,SAAW,EAAA,EAAA,GAAG,KAAO,EAAA,GAAA,EAAU,CAClC,CACD,CAAA,CAAA;AACH,CAAA;AAuBO,MAAM,aACX,GAAA,WAAA;AAAA,EACE,UAAA,CAAW,CAAC,KAAA,EAAO,GAAQ,KAAA;AACzB,IAAM,MAAA;AAAA,MACJ,QAAA;AAAA,MACA,YAAY,MAAM;AAAA,OAAC;AAAA,MACnB,UAAU,MAAM;AAAA,OAAC;AAAA,MACjB,WAAW,MAAM;AAAA,OAAC;AAAA,MAClB,YAAe,GAAA,GAAA;AAAA,MACf,WAAc,GAAA,IAAA;AAAA,MACd,SAAY,G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