@backstage/plugin-search-react 1.7.14-next.2 → 1.7.14

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 CHANGED
@@ -1,5 +1,35 @@
1
1
  # @backstage/plugin-search-react
2
2
 
3
+ ## 1.7.14
4
+
5
+ ### Patch Changes
6
+
7
+ - 7bd27e1: Deprecate the old pattern of `create*Extension`, and replace it with the equivalent Blueprint implementation instead.
8
+ - 31bfc44: Updated alpha definitions of extension data references.
9
+ - 3123c16: Fix package metadata
10
+ - 6349099: Added config input type to the extensions
11
+ - Updated dependencies
12
+ - @backstage/frontend-plugin-api@0.7.0
13
+ - @backstage/core-components@0.14.10
14
+ - @backstage/plugin-search-common@1.2.14
15
+ - @backstage/core-plugin-api@1.9.3
16
+ - @backstage/theme@0.5.6
17
+ - @backstage/types@1.1.1
18
+ - @backstage/version-bridge@1.0.8
19
+
20
+ ## 1.7.14-next.3
21
+
22
+ ### Patch Changes
23
+
24
+ - Updated dependencies
25
+ - @backstage/frontend-plugin-api@0.7.0-next.3
26
+ - @backstage/core-components@0.14.10-next.0
27
+ - @backstage/core-plugin-api@1.9.3
28
+ - @backstage/theme@0.5.6
29
+ - @backstage/types@1.1.1
30
+ - @backstage/version-bridge@1.0.8
31
+ - @backstage/plugin-search-common@1.2.14-next.1
32
+
3
33
  ## 1.7.14-next.2
4
34
 
5
35
  ### Patch Changes
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backstage/plugin-search-react__alpha",
3
- "version": "1.7.14-next.2",
3
+ "version": "1.7.14",
4
4
  "main": "../dist/alpha.esm.js",
5
5
  "module": "../dist/alpha.esm.js",
6
6
  "types": "../dist/alpha.d.ts"
@@ -0,0 +1,41 @@
1
+ import React, { lazy } from 'react';
2
+ import { createExtensionBlueprint, ExtensionBoundary } from '@backstage/frontend-plugin-api';
3
+ import { searchResultListItemDataRef } from './types.esm.js';
4
+ import { SearchResultListItemExtension } from '../../extensions.esm.js';
5
+
6
+ const SearchResultListItemBlueprint = createExtensionBlueprint({
7
+ kind: "search-result-list-item",
8
+ attachTo: {
9
+ id: "page:search",
10
+ input: "items"
11
+ },
12
+ config: {
13
+ schema: {
14
+ noTrack: (z) => z.boolean().default(false)
15
+ }
16
+ },
17
+ output: [searchResultListItemDataRef],
18
+ dataRefs: {
19
+ item: searchResultListItemDataRef
20
+ },
21
+ *factory(params, { config, node }) {
22
+ const ExtensionComponent = lazy(
23
+ () => params.component({ config }).then((component) => ({ default: component }))
24
+ );
25
+ yield searchResultListItemDataRef({
26
+ predicate: params.predicate,
27
+ component: (props) => /* @__PURE__ */ React.createElement(ExtensionBoundary, { node }, /* @__PURE__ */ React.createElement(
28
+ SearchResultListItemExtension,
29
+ {
30
+ rank: props.rank,
31
+ result: props.result,
32
+ noTrack: config.noTrack
33
+ },
34
+ /* @__PURE__ */ React.createElement(ExtensionComponent, { ...props })
35
+ ))
36
+ });
37
+ }
38
+ });
39
+
40
+ export { SearchResultListItemBlueprint };
41
+ //# sourceMappingURL=SearchResultListItemBlueprint.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SearchResultListItemBlueprint.esm.js","sources":["../../../src/alpha/blueprints/SearchResultListItemBlueprint.tsx"],"sourcesContent":["/*\n * Copyright 2024 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';\nimport {\n createExtensionBlueprint,\n ExtensionBoundary,\n} from '@backstage/frontend-plugin-api';\nimport {\n SearchResultItemExtensionComponent,\n SearchResultItemExtensionPredicate,\n searchResultListItemDataRef,\n} from './types';\nimport {\n SearchResultListItemExtension,\n SearchResultListItemExtensionProps,\n} from '../../extensions';\n\n/** @alpha */\nexport interface SearchResultListItemBlueprintParams {\n /**\n * The extension component.\n */\n component: (options: {\n config: { noTrack?: boolean };\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/**\n * @alpha\n * Creates SearchResultListItem extensions\n */\nexport const SearchResultListItemBlueprint = createExtensionBlueprint({\n kind: 'search-result-list-item',\n attachTo: {\n id: 'page:search',\n input: 'items',\n },\n config: {\n schema: {\n noTrack: z => z.boolean().default(false),\n },\n },\n output: [searchResultListItemDataRef],\n dataRefs: {\n item: searchResultListItemDataRef,\n },\n *factory(params: SearchResultListItemBlueprintParams, { config, node }) {\n const ExtensionComponent = lazy(() =>\n params.component({ config }).then(component => ({ default: component })),\n );\n\n yield searchResultListItemDataRef({\n predicate: params.predicate,\n component: (props: SearchResultListItemExtensionProps) => (\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"],"names":[],"mappings":";;;;;AAkDO,MAAM,gCAAgC,wBAAyB,CAAA;AAAA,EACpE,IAAM,EAAA,yBAAA;AAAA,EACN,QAAU,EAAA;AAAA,IACR,EAAI,EAAA,aAAA;AAAA,IACJ,KAAO,EAAA,OAAA;AAAA,GACT;AAAA,EACA,MAAQ,EAAA;AAAA,IACN,MAAQ,EAAA;AAAA,MACN,SAAS,CAAK,CAAA,KAAA,CAAA,CAAE,OAAQ,EAAA,CAAE,QAAQ,KAAK,CAAA;AAAA,KACzC;AAAA,GACF;AAAA,EACA,MAAA,EAAQ,CAAC,2BAA2B,CAAA;AAAA,EACpC,QAAU,EAAA;AAAA,IACR,IAAM,EAAA,2BAAA;AAAA,GACR;AAAA,EACA,CAAC,OAAQ,CAAA,MAAA,EAA6C,EAAE,MAAA,EAAQ,MAAQ,EAAA;AACtE,IAAA,MAAM,kBAAqB,GAAA,IAAA;AAAA,MAAK,MAC9B,MAAA,CAAO,SAAU,CAAA,EAAE,MAAO,EAAC,CAAE,CAAA,IAAA,CAAK,CAAc,SAAA,MAAA,EAAE,OAAS,EAAA,SAAA,EAAY,CAAA,CAAA;AAAA,KACzE,CAAA;AAEA,IAAA,MAAM,2BAA4B,CAAA;AAAA,MAChC,WAAW,MAAO,CAAA,SAAA;AAAA,MAClB,SAAW,EAAA,CAAC,KACV,qBAAA,KAAA,CAAA,aAAA,CAAC,qBAAkB,IACjB,EAAA,kBAAA,KAAA,CAAA,aAAA;AAAA,QAAC,6BAAA;AAAA,QAAA;AAAA,UACC,MAAM,KAAM,CAAA,IAAA;AAAA,UACZ,QAAQ,KAAM,CAAA,MAAA;AAAA,UACd,SAAS,MAAO,CAAA,OAAA;AAAA,SAAA;AAAA,wBAEhB,KAAA,CAAA,aAAA,CAAC,kBAAoB,EAAA,EAAA,GAAG,KAAO,EAAA,CAAA;AAAA,OAEnC,CAAA;AAAA,KAEH,CAAA,CAAA;AAAA,GACH;AACF,CAAC;;;;"}
@@ -0,0 +1,6 @@
1
+ import { createExtensionDataRef } from '@backstage/frontend-plugin-api';
2
+
3
+ const searchResultListItemDataRef = createExtensionDataRef().with({ id: "search.search-result-list-item.item" });
4
+
5
+ export { searchResultListItemDataRef };
6
+ //# sourceMappingURL=types.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.esm.js","sources":["../../../src/alpha/blueprints/types.ts"],"sourcesContent":["/*\n * Copyright 2024 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 { ListItemProps } from '@material-ui/core/ListItem';\nimport { SearchDocument, SearchResult } from '@backstage/plugin-search-common';\nimport { createExtensionDataRef } from '@backstage/frontend-plugin-api';\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\nexport const searchResultListItemDataRef = createExtensionDataRef<{\n predicate?: SearchResultItemExtensionPredicate;\n component: SearchResultItemExtensionComponent;\n}>().with({ id: 'search.search-result-list-item.item' });\n"],"names":[],"mappings":";;AAsCO,MAAM,8BAA8B,sBAGxC,EAAA,CAAE,KAAK,EAAE,EAAA,EAAI,uCAAuC;;;;"}
@@ -0,0 +1,50 @@
1
+ import React, { lazy } from 'react';
2
+ import { createSchemaFromZod, createExtension, ExtensionBoundary } from '@backstage/frontend-plugin-api';
3
+ import { SearchResultListItemExtension } from '../extensions.esm.js';
4
+ import { searchResultListItemDataRef } from './blueprints/types.esm.js';
5
+
6
+ function createSearchResultListItemExtension(options) {
7
+ const configSchema = "configSchema" in options ? options.configSchema : createSchemaFromZod(
8
+ (z) => z.object({
9
+ noTrack: z.boolean().default(false)
10
+ })
11
+ );
12
+ return createExtension({
13
+ kind: "search-result-list-item",
14
+ namespace: options.namespace,
15
+ name: options.name,
16
+ attachTo: options.attachTo ?? {
17
+ id: "page:search",
18
+ input: "items"
19
+ },
20
+ configSchema,
21
+ output: {
22
+ item: createSearchResultListItemExtension.itemDataRef
23
+ },
24
+ factory({ config, node }) {
25
+ const ExtensionComponent = lazy(
26
+ () => options.component({ config }).then((component) => ({ default: component }))
27
+ );
28
+ return {
29
+ item: {
30
+ predicate: options.predicate,
31
+ component: (props) => /* @__PURE__ */ React.createElement(ExtensionBoundary, { node }, /* @__PURE__ */ React.createElement(
32
+ SearchResultListItemExtension,
33
+ {
34
+ rank: props.rank,
35
+ result: props.result,
36
+ noTrack: config.noTrack
37
+ },
38
+ /* @__PURE__ */ React.createElement(ExtensionComponent, { ...props })
39
+ ))
40
+ }
41
+ };
42
+ }
43
+ });
44
+ }
45
+ ((createSearchResultListItemExtension2) => {
46
+ createSearchResultListItemExtension2.itemDataRef = searchResultListItemDataRef;
47
+ })(createSearchResultListItemExtension || (createSearchResultListItemExtension = {}));
48
+
49
+ export { createSearchResultListItemExtension };
50
+ //# sourceMappingURL=extensions.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"extensions.esm.js","sources":["../../src/alpha/extensions.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';\nimport {\n ExtensionBoundary,\n PortableSchema,\n createExtension,\n createSchemaFromZod,\n} from '@backstage/frontend-plugin-api';\nimport {\n SearchResultItemExtensionComponent,\n SearchResultItemExtensionPredicate,\n} from './blueprints';\nimport { SearchResultListItemExtension } from '../extensions';\nimport { searchResultListItemDataRef } from './blueprints/types';\n\n/**\n * @alpha\n * @deprecated Use {@link SearchResultListItemBlueprint} instead\n */\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/**\n * Creates items for the search result list.\n *\n * @alpha\n * @deprecated Use {@link SearchResultListItemBlueprint} instead\n */\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/**\n * @alpha\n * @deprecated Use {@link SearchResultListItemBlueprint} instead\n */\nexport namespace createSearchResultListItemExtension {\n /**\n * @deprecated Use {@link SearchResultListItemBlueprint#dataRefs.item} instead\n */\n export const itemDataRef = searchResultListItemDataRef;\n}\n"],"names":["createSearchResultListItemExtension"],"mappings":";;;;;AAwEO,SAAS,oCAEd,OAAoD,EAAA;AACpD,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,EAAU,QAAQ,QAAY,IAAA;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,CAMO,CAAUA,oCAAV,KAAA;AAIE,EAAMA,qCAAA,WAAc,GAAA,2BAAA,CAAA;AAAA,CAJZ,EAAA,mCAAA,KAAA,mCAAA,GAAA,EAAA,CAAA,CAAA;;;;"}
package/dist/alpha.d.ts CHANGED
@@ -13,7 +13,49 @@ type BaseSearchResultListItemProps<T = {}> = T & {
13
13
  type SearchResultItemExtensionComponent = <P extends BaseSearchResultListItemProps>(props: P) => JSX.Element | null;
14
14
  /** @alpha */
15
15
  type SearchResultItemExtensionPredicate = (result: SearchResult) => boolean;
16
+
16
17
  /** @alpha */
18
+ interface SearchResultListItemBlueprintParams {
19
+ /**
20
+ * The extension component.
21
+ */
22
+ component: (options: {
23
+ config: {
24
+ noTrack?: boolean;
25
+ };
26
+ }) => Promise<SearchResultItemExtensionComponent>;
27
+ /**
28
+ * When an extension defines a predicate, it returns true if the result should be rendered by that extension.
29
+ * Defaults to a predicate that returns true, which means it renders all sorts of results.
30
+ */
31
+ predicate?: SearchResultItemExtensionPredicate;
32
+ }
33
+ /**
34
+ * @alpha
35
+ * Creates SearchResultListItem extensions
36
+ */
37
+ declare const SearchResultListItemBlueprint: _backstage_frontend_plugin_api.ExtensionBlueprint<{
38
+ kind: "search-result-list-item";
39
+ namespace: undefined;
40
+ name: undefined;
41
+ }, SearchResultListItemBlueprintParams, _backstage_frontend_plugin_api.ConfigurableExtensionDataRef<{
42
+ predicate?: SearchResultItemExtensionPredicate | undefined;
43
+ component: SearchResultItemExtensionComponent;
44
+ }, "search.search-result-list-item.item", {}>, {}, {
45
+ noTrack: boolean;
46
+ }, {
47
+ noTrack?: boolean | undefined;
48
+ }, {
49
+ item: _backstage_frontend_plugin_api.ConfigurableExtensionDataRef<{
50
+ predicate?: SearchResultItemExtensionPredicate | undefined;
51
+ component: SearchResultItemExtensionComponent;
52
+ }, "search.search-result-list-item.item", {}>;
53
+ }>;
54
+
55
+ /**
56
+ * @alpha
57
+ * @deprecated Use {@link SearchResultListItemBlueprint} instead
58
+ */
17
59
  type SearchResultItemExtensionOptions<TConfig extends {
18
60
  noTrack?: boolean;
19
61
  }> = {
@@ -48,16 +90,31 @@ type SearchResultItemExtensionOptions<TConfig extends {
48
90
  */
49
91
  predicate?: SearchResultItemExtensionPredicate;
50
92
  };
51
- /** @alpha */
93
+ /**
94
+ * Creates items for the search result list.
95
+ *
96
+ * @alpha
97
+ * @deprecated Use {@link SearchResultListItemBlueprint} instead
98
+ */
52
99
  declare function createSearchResultListItemExtension<TConfig extends {
53
100
  noTrack?: boolean;
54
- }>(options: SearchResultItemExtensionOptions<TConfig>): _backstage_frontend_plugin_api.ExtensionDefinition<TConfig & {}, TConfig & {}>;
55
- /** @alpha */
101
+ }>(options: SearchResultItemExtensionOptions<TConfig>): _backstage_frontend_plugin_api.ExtensionDefinition<TConfig, TConfig, never, never, {
102
+ kind?: string | undefined;
103
+ namespace?: string | undefined;
104
+ name?: string | undefined;
105
+ }>;
106
+ /**
107
+ * @alpha
108
+ * @deprecated Use {@link SearchResultListItemBlueprint} instead
109
+ */
56
110
  declare namespace createSearchResultListItemExtension {
111
+ /**
112
+ * @deprecated Use {@link SearchResultListItemBlueprint#dataRefs.item} instead
113
+ */
57
114
  const itemDataRef: _backstage_frontend_plugin_api.ConfigurableExtensionDataRef<{
58
115
  predicate?: SearchResultItemExtensionPredicate | undefined;
59
116
  component: SearchResultItemExtensionComponent;
60
117
  }, "search.search-result-list-item.item", {}>;
61
118
  }
62
119
 
63
- export { type BaseSearchResultListItemProps, type SearchResultItemExtensionComponent, type SearchResultItemExtensionOptions, type SearchResultItemExtensionPredicate, createSearchResultListItemExtension };
120
+ export { type BaseSearchResultListItemProps, type SearchResultItemExtensionComponent, type SearchResultItemExtensionOptions, type SearchResultItemExtensionPredicate, SearchResultListItemBlueprint, type SearchResultListItemBlueprintParams, createSearchResultListItemExtension };
package/dist/alpha.esm.js CHANGED
@@ -1,49 +1,3 @@
1
- import React, { lazy } from 'react';
2
- import { createExtensionDataRef, createSchemaFromZod, createExtension, ExtensionBoundary } from '@backstage/frontend-plugin-api';
3
- import { SearchResultListItemExtension } from './extensions.esm.js';
4
-
5
- function createSearchResultListItemExtension(options) {
6
- const configSchema = "configSchema" in options ? options.configSchema : createSchemaFromZod(
7
- (z) => z.object({
8
- noTrack: z.boolean().default(false)
9
- })
10
- );
11
- return createExtension({
12
- kind: "search-result-list-item",
13
- namespace: options.namespace,
14
- name: options.name,
15
- attachTo: options.attachTo ?? {
16
- id: "page:search",
17
- input: "items"
18
- },
19
- configSchema,
20
- output: {
21
- item: createSearchResultListItemExtension.itemDataRef
22
- },
23
- factory({ config, node }) {
24
- const ExtensionComponent = lazy(
25
- () => options.component({ config }).then((component) => ({ default: component }))
26
- );
27
- return {
28
- item: {
29
- predicate: options.predicate,
30
- component: (props) => /* @__PURE__ */ React.createElement(ExtensionBoundary, { node }, /* @__PURE__ */ React.createElement(
31
- SearchResultListItemExtension,
32
- {
33
- rank: props.rank,
34
- result: props.result,
35
- noTrack: config.noTrack
36
- },
37
- /* @__PURE__ */ React.createElement(ExtensionComponent, { ...props })
38
- ))
39
- }
40
- };
41
- }
42
- });
43
- }
44
- ((createSearchResultListItemExtension2) => {
45
- createSearchResultListItemExtension2.itemDataRef = createExtensionDataRef().with({ id: "search.search-result-list-item.item" });
46
- })(createSearchResultListItemExtension || (createSearchResultListItemExtension = {}));
47
-
48
- export { createSearchResultListItemExtension };
1
+ export { createSearchResultListItemExtension } from './alpha/extensions.esm.js';
2
+ export { SearchResultListItemBlueprint } from './alpha/blueprints/SearchResultListItemBlueprint.esm.js';
49
3
  //# sourceMappingURL=alpha.esm.js.map
@@ -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/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 }>().with({ id: 'search.search-result-list-item.item' });\n}\n"],"names":["createSearchResultListItemExtension"],"mappings":";;;;AAmFO,SAAS,oCAEd,OAAoD,EAAA;AACpD,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,EAAU,QAAQ,QAAY,IAAA;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,cAAc,sBAGxB,EAAA,CAAE,KAAK,EAAE,EAAA,EAAI,uCAAuC,CAAA,CAAA;AAAA,CAJxC,EAAA,mCAAA,KAAA,mCAAA,GAAA,EAAA,CAAA,CAAA;;;;"}
1
+ {"version":3,"file":"alpha.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backstage/plugin-search-react",
3
- "version": "1.7.14-next.2",
3
+ "version": "1.7.14",
4
4
  "backstage": {
5
5
  "role": "web-library",
6
6
  "pluginId": "search",
@@ -55,10 +55,10 @@
55
55
  "test": "backstage-cli package test"
56
56
  },
57
57
  "dependencies": {
58
- "@backstage/core-components": "^0.14.10-next.0",
58
+ "@backstage/core-components": "^0.14.10",
59
59
  "@backstage/core-plugin-api": "^1.9.3",
60
- "@backstage/frontend-plugin-api": "^0.7.0-next.2",
61
- "@backstage/plugin-search-common": "^1.2.14-next.1",
60
+ "@backstage/frontend-plugin-api": "^0.7.0",
61
+ "@backstage/plugin-search-common": "^1.2.14",
62
62
  "@backstage/theme": "^0.5.6",
63
63
  "@backstage/types": "^1.1.1",
64
64
  "@backstage/version-bridge": "^1.0.8",
@@ -71,11 +71,11 @@
71
71
  "react-use": "^17.3.2"
72
72
  },
73
73
  "devDependencies": {
74
- "@backstage/cli": "^0.27.0-next.3",
75
- "@backstage/core-app-api": "^1.14.2-next.0",
76
- "@backstage/frontend-app-api": "^0.7.5-next.2",
77
- "@backstage/frontend-test-utils": "^0.1.12-next.2",
78
- "@backstage/test-utils": "^1.5.10-next.2",
74
+ "@backstage/cli": "^0.27.0",
75
+ "@backstage/core-app-api": "^1.14.2",
76
+ "@backstage/frontend-app-api": "^0.8.0",
77
+ "@backstage/frontend-test-utils": "^0.1.12",
78
+ "@backstage/test-utils": "^1.5.10",
79
79
  "@testing-library/dom": "^10.0.0",
80
80
  "@testing-library/jest-dom": "^6.0.0",
81
81
  "@testing-library/react": "^15.0.0",