@backstage/plugin-app-react 0.1.1-next.0 → 0.2.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
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @backstage/plugin-app-react
|
|
2
2
|
|
|
3
|
+
## 0.2.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- a2133be: Added new `NavContentNavItem`, `NavContentNavItems`, and `navItems` prop to `NavContentComponentProps` for auto-discovering navigation items from page extensions. The new `navItems` collection supports `take(id)` and `rest()` methods for placing specific items in custom sidebar positions, as well as `withComponent(Component)` which returns a `NavContentNavItemsWithComponent` for rendering items directly as elements. The existing `items` prop is now deprecated in favor of `navItems`.
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- ef6916e: Added `IconElement` type as a replacement for the deprecated `IconComponent`. The `IconsApi` now has a new `icon()` method that returns `IconElement`, while the existing `getIcon()` method is deprecated. The `IconBundleBlueprint` now accepts both `IconComponent` and `IconElement` values.
|
|
12
|
+
- 409af72: Internal refactor to move implementation of blueprints from `@backstage/frontend-plugin-api` to this package.
|
|
13
|
+
- Updated dependencies
|
|
14
|
+
- @backstage/frontend-plugin-api@0.14.0
|
|
15
|
+
- @backstage/core-plugin-api@1.12.3
|
|
16
|
+
|
|
3
17
|
## 0.1.1-next.0
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
|
@@ -5,9 +5,7 @@ const IconBundleBlueprint = createExtensionBlueprint({
|
|
|
5
5
|
kind: "icon-bundle",
|
|
6
6
|
attachTo: { id: "api:app/icons", input: "icons" },
|
|
7
7
|
output: [iconsDataRef],
|
|
8
|
-
factory: (params) => [
|
|
9
|
-
iconsDataRef(params.icons)
|
|
10
|
-
],
|
|
8
|
+
factory: (params) => [iconsDataRef(params.icons)],
|
|
11
9
|
dataRefs: {
|
|
12
10
|
icons: iconsDataRef
|
|
13
11
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IconBundleBlueprint.esm.js","sources":["../../src/blueprints/IconBundleBlueprint.ts"],"sourcesContent":["/*\n * Copyright 2026 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 { IconComponent } from '@backstage/frontend-plugin-api';\nimport {\n createExtensionBlueprint,\n createExtensionDataRef,\n} from '@backstage/frontend-plugin-api';\n\nconst iconsDataRef = createExtensionDataRef<{\n [key in string]: IconComponent;\n}>().with({ id: 'core.icons' });\n\n/**\n * Creates an extension that adds icon bundles to your app. This blueprint is limited to use by the app plugin.\n *\n * @public\n */\nexport const IconBundleBlueprint = createExtensionBlueprint({\n kind: 'icon-bundle',\n attachTo: { id: 'api:app/icons', input: 'icons' },\n output: [iconsDataRef],\n factory: (params: {
|
|
1
|
+
{"version":3,"file":"IconBundleBlueprint.esm.js","sources":["../../src/blueprints/IconBundleBlueprint.ts"],"sourcesContent":["/*\n * Copyright 2026 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 { IconComponent, IconElement } from '@backstage/frontend-plugin-api';\nimport {\n createExtensionBlueprint,\n createExtensionDataRef,\n} from '@backstage/frontend-plugin-api';\n\nconst iconsDataRef = createExtensionDataRef<{\n [key in string]: IconComponent | IconElement;\n}>().with({ id: 'core.icons' });\n\n/**\n * Creates an extension that adds icon bundles to your app. This blueprint is limited to use by the app plugin.\n *\n * @public\n */\nexport const IconBundleBlueprint = createExtensionBlueprint({\n kind: 'icon-bundle',\n attachTo: { id: 'api:app/icons', input: 'icons' },\n output: [iconsDataRef],\n factory: (params: {\n icons: { [key in string]: IconComponent | IconElement };\n }) => [iconsDataRef(params.icons)],\n dataRefs: {\n icons: iconsDataRef,\n },\n});\n"],"names":[],"mappings":";;AAsBA,MAAM,eAAe,sBAAA,EAElB,CAAE,KAAK,EAAE,EAAA,EAAI,cAAc,CAAA;AAOvB,MAAM,sBAAsB,wBAAA,CAAyB;AAAA,EAC1D,IAAA,EAAM,aAAA;AAAA,EACN,QAAA,EAAU,EAAE,EAAA,EAAI,eAAA,EAAiB,OAAO,OAAA,EAAQ;AAAA,EAChD,MAAA,EAAQ,CAAC,YAAY,CAAA;AAAA,EACrB,SAAS,CAAC,MAAA,KAEJ,CAAC,YAAA,CAAa,MAAA,CAAO,KAAK,CAAC,CAAA;AAAA,EACjC,QAAA,EAAU;AAAA,IACR,KAAA,EAAO;AAAA;AAEX,CAAC;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NavContentBlueprint.esm.js","sources":["../../src/blueprints/NavContentBlueprint.ts"],"sourcesContent":["/*\n * Copyright 2026 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 { IconComponent
|
|
1
|
+
{"version":3,"file":"NavContentBlueprint.esm.js","sources":["../../src/blueprints/NavContentBlueprint.ts"],"sourcesContent":["/*\n * Copyright 2026 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 { ComponentType } from 'react';\nimport {\n AppNode,\n IconComponent,\n IconElement,\n RouteRef,\n} from '@backstage/frontend-plugin-api';\nimport {\n createExtensionBlueprint,\n createExtensionDataRef,\n} from '@backstage/frontend-plugin-api';\n\n/**\n * A navigation item auto-discovered from a page extension in the app.\n *\n * @public\n */\nexport interface NavContentNavItem {\n /** The app node of the page extension that this nav item points to */\n node: AppNode;\n /** The resolved route path */\n href: string;\n /** The display title */\n title: string;\n /** The display icon */\n icon: IconElement;\n /** The route ref of the source page */\n routeRef: RouteRef;\n}\n\n/**\n * A pre-bound renderer that wraps {@link NavContentNavItems} with a component,\n * so that `take` and `rest` return rendered elements directly.\n *\n * @public\n */\nexport interface NavContentNavItemsWithComponent {\n /** Render and take a specific item by extension ID. Returns null if not found. */\n take(id: string): JSX.Element | null;\n /** Render all remaining items not yet taken, optionally sorted. */\n rest(options?: { sortBy?: 'title' }): JSX.Element[];\n}\n\n/**\n * A collection of nav items that supports picking specific items by ID\n * and retrieving whatever remains. Created fresh for each render.\n *\n * @public\n */\nexport interface NavContentNavItems {\n /** Take an item by extension ID, removing it from the collection. */\n take(id: string): NavContentNavItem | undefined;\n /** All items not yet taken. */\n rest(): NavContentNavItem[];\n /** Create a copy of the collection preserving the current taken state. */\n clone(): NavContentNavItems;\n /** Create a renderer that wraps take/rest to return pre-rendered elements. */\n withComponent(\n Component: ComponentType<NavContentNavItem>,\n ): NavContentNavItemsWithComponent;\n}\n\n/**\n * The props for the {@link NavContentComponent}.\n *\n * @public\n */\nexport interface NavContentComponentProps {\n /**\n * Nav items auto-discovered from page extensions, with take/rest semantics\n * for placing specific items in specific positions.\n */\n navItems: NavContentNavItems;\n\n /**\n * Flat list of nav items for simple rendering. Use `navItems` for more\n * control over item placement.\n *\n * @deprecated Use `navItems` instead.\n */\n items: Array<{\n icon: IconComponent;\n title: string;\n routeRef: RouteRef<undefined>;\n to: string;\n text: string;\n }>;\n}\n\n/**\n * A component that renders the nav bar content, to be passed to the {@link NavContentBlueprint}.\n *\n * @public\n */\nexport type NavContentComponent = (\n props: NavContentComponentProps,\n) => JSX.Element | null;\n\nconst componentDataRef = createExtensionDataRef<NavContentComponent>().with({\n id: 'core.nav-content.component',\n});\n\n/**\n * Creates an extension that replaces the entire nav bar with your own component. This blueprint is limited to use by the app plugin.\n *\n * @public\n */\nexport const NavContentBlueprint = createExtensionBlueprint({\n kind: 'nav-content',\n attachTo: { id: 'app/nav', input: 'content' },\n output: [componentDataRef],\n dataRefs: {\n component: componentDataRef,\n },\n *factory(params: { component: NavContentComponent }) {\n yield componentDataRef(params.component);\n },\n});\n"],"names":[],"mappings":";;AAkHA,MAAM,gBAAA,GAAmB,sBAAA,EAA4C,CAAE,IAAA,CAAK;AAAA,EAC1E,EAAA,EAAI;AACN,CAAC,CAAA;AAOM,MAAM,sBAAsB,wBAAA,CAAyB;AAAA,EAC1D,IAAA,EAAM,aAAA;AAAA,EACN,QAAA,EAAU,EAAE,EAAA,EAAI,SAAA,EAAW,OAAO,SAAA,EAAU;AAAA,EAC5C,MAAA,EAAQ,CAAC,gBAAgB,CAAA;AAAA,EACzB,QAAA,EAAU;AAAA,IACR,SAAA,EAAW;AAAA,GACb;AAAA,EACA,CAAC,QAAQ,MAAA,EAA4C;AACnD,IAAA,MAAM,gBAAA,CAAiB,OAAO,SAAS,CAAA;AAAA,EACzC;AACF,CAAC;;;;"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as _backstage_frontend_plugin_api from '@backstage/frontend-plugin-api';
|
|
2
|
-
import { IconComponent, RouteRef, IdentityApi, SwappableComponentRef, AppTheme, TranslationResource, TranslationMessages } from '@backstage/frontend-plugin-api';
|
|
2
|
+
import { IconComponent, IconElement, AppNode, RouteRef, IdentityApi, SwappableComponentRef, AppTheme, TranslationResource, TranslationMessages } from '@backstage/frontend-plugin-api';
|
|
3
3
|
import { ReactNode, ComponentType } from 'react';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -39,21 +39,68 @@ declare const AppRootWrapperBlueprint: _backstage_frontend_plugin_api.ExtensionB
|
|
|
39
39
|
declare const IconBundleBlueprint: _backstage_frontend_plugin_api.ExtensionBlueprint<{
|
|
40
40
|
kind: "icon-bundle";
|
|
41
41
|
params: {
|
|
42
|
-
icons: { [key in string]: IconComponent; };
|
|
42
|
+
icons: { [key in string]: IconComponent | IconElement; };
|
|
43
43
|
};
|
|
44
44
|
output: _backstage_frontend_plugin_api.ExtensionDataRef<{
|
|
45
|
-
[x: string]: IconComponent;
|
|
45
|
+
[x: string]: IconComponent | IconElement;
|
|
46
46
|
}, "core.icons", {}>;
|
|
47
47
|
inputs: {};
|
|
48
48
|
config: {};
|
|
49
49
|
configInput: {};
|
|
50
50
|
dataRefs: {
|
|
51
51
|
icons: _backstage_frontend_plugin_api.ConfigurableExtensionDataRef<{
|
|
52
|
-
[x: string]: IconComponent;
|
|
52
|
+
[x: string]: IconComponent | IconElement;
|
|
53
53
|
}, "core.icons", {}>;
|
|
54
54
|
};
|
|
55
55
|
}>;
|
|
56
56
|
|
|
57
|
+
/**
|
|
58
|
+
* A navigation item auto-discovered from a page extension in the app.
|
|
59
|
+
*
|
|
60
|
+
* @public
|
|
61
|
+
*/
|
|
62
|
+
interface NavContentNavItem {
|
|
63
|
+
/** The app node of the page extension that this nav item points to */
|
|
64
|
+
node: AppNode;
|
|
65
|
+
/** The resolved route path */
|
|
66
|
+
href: string;
|
|
67
|
+
/** The display title */
|
|
68
|
+
title: string;
|
|
69
|
+
/** The display icon */
|
|
70
|
+
icon: IconElement;
|
|
71
|
+
/** The route ref of the source page */
|
|
72
|
+
routeRef: RouteRef;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* A pre-bound renderer that wraps {@link NavContentNavItems} with a component,
|
|
76
|
+
* so that `take` and `rest` return rendered elements directly.
|
|
77
|
+
*
|
|
78
|
+
* @public
|
|
79
|
+
*/
|
|
80
|
+
interface NavContentNavItemsWithComponent {
|
|
81
|
+
/** Render and take a specific item by extension ID. Returns null if not found. */
|
|
82
|
+
take(id: string): JSX.Element | null;
|
|
83
|
+
/** Render all remaining items not yet taken, optionally sorted. */
|
|
84
|
+
rest(options?: {
|
|
85
|
+
sortBy?: 'title';
|
|
86
|
+
}): JSX.Element[];
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* A collection of nav items that supports picking specific items by ID
|
|
90
|
+
* and retrieving whatever remains. Created fresh for each render.
|
|
91
|
+
*
|
|
92
|
+
* @public
|
|
93
|
+
*/
|
|
94
|
+
interface NavContentNavItems {
|
|
95
|
+
/** Take an item by extension ID, removing it from the collection. */
|
|
96
|
+
take(id: string): NavContentNavItem | undefined;
|
|
97
|
+
/** All items not yet taken. */
|
|
98
|
+
rest(): NavContentNavItem[];
|
|
99
|
+
/** Create a copy of the collection preserving the current taken state. */
|
|
100
|
+
clone(): NavContentNavItems;
|
|
101
|
+
/** Create a renderer that wraps take/rest to return pre-rendered elements. */
|
|
102
|
+
withComponent(Component: ComponentType<NavContentNavItem>): NavContentNavItemsWithComponent;
|
|
103
|
+
}
|
|
57
104
|
/**
|
|
58
105
|
* The props for the {@link NavContentComponent}.
|
|
59
106
|
*
|
|
@@ -61,12 +108,15 @@ declare const IconBundleBlueprint: _backstage_frontend_plugin_api.ExtensionBluep
|
|
|
61
108
|
*/
|
|
62
109
|
interface NavContentComponentProps {
|
|
63
110
|
/**
|
|
64
|
-
*
|
|
65
|
-
*
|
|
111
|
+
* Nav items auto-discovered from page extensions, with take/rest semantics
|
|
112
|
+
* for placing specific items in specific positions.
|
|
113
|
+
*/
|
|
114
|
+
navItems: NavContentNavItems;
|
|
115
|
+
/**
|
|
116
|
+
* Flat list of nav items for simple rendering. Use `navItems` for more
|
|
117
|
+
* control over item placement.
|
|
66
118
|
*
|
|
67
|
-
*
|
|
68
|
-
* include a resolved route path as `to`, and duplicated `title` as `text` to
|
|
69
|
-
* simplify rendering.
|
|
119
|
+
* @deprecated Use `navItems` instead.
|
|
70
120
|
*/
|
|
71
121
|
items: Array<{
|
|
72
122
|
icon: IconComponent;
|
|
@@ -238,4 +288,4 @@ declare const TranslationBlueprint: _backstage_frontend_plugin_api.ExtensionBlue
|
|
|
238
288
|
}>;
|
|
239
289
|
|
|
240
290
|
export { AppRootWrapperBlueprint, IconBundleBlueprint, NavContentBlueprint, RouterBlueprint, SignInPageBlueprint, SwappableComponentBlueprint, ThemeBlueprint, TranslationBlueprint };
|
|
241
|
-
export type { NavContentComponent, NavContentComponentProps, SignInPageProps };
|
|
291
|
+
export type { NavContentComponent, NavContentComponentProps, NavContentNavItem, NavContentNavItems, NavContentNavItemsWithComponent, SignInPageProps };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@backstage/plugin-app-react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Web library for the app plugin",
|
|
5
5
|
"backstage": {
|
|
6
6
|
"role": "web-library",
|
|
@@ -39,26 +39,26 @@
|
|
|
39
39
|
"test": "backstage-cli package test"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@backstage/core-plugin-api": "1.12.
|
|
43
|
-
"@backstage/frontend-plugin-api": "0.14.0
|
|
42
|
+
"@backstage/core-plugin-api": "^1.12.3",
|
|
43
|
+
"@backstage/frontend-plugin-api": "^0.14.0",
|
|
44
44
|
"@material-ui/core": "^4.9.13"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
|
-
"@backstage/cli": "0.35.
|
|
48
|
-
"@backstage/frontend-test-utils": "0.
|
|
49
|
-
"@backstage/test-utils": "1.7.15
|
|
47
|
+
"@backstage/cli": "^0.35.4",
|
|
48
|
+
"@backstage/frontend-test-utils": "^0.5.0",
|
|
49
|
+
"@backstage/test-utils": "^1.7.15",
|
|
50
50
|
"@testing-library/jest-dom": "^6.0.0",
|
|
51
51
|
"@testing-library/react": "^16.0.0",
|
|
52
52
|
"@types/react": "^18.0.0",
|
|
53
53
|
"react": "^18.0.2",
|
|
54
54
|
"react-dom": "^18.0.2",
|
|
55
|
-
"react-router-dom": "^6.
|
|
55
|
+
"react-router-dom": "^6.30.2"
|
|
56
56
|
},
|
|
57
57
|
"peerDependencies": {
|
|
58
58
|
"@types/react": "^17.0.0 || ^18.0.0",
|
|
59
59
|
"react": "^17.0.0 || ^18.0.0",
|
|
60
60
|
"react-dom": "^17.0.0 || ^18.0.0",
|
|
61
|
-
"react-router-dom": "^6.
|
|
61
|
+
"react-router-dom": "^6.30.2"
|
|
62
62
|
},
|
|
63
63
|
"peerDependenciesMeta": {
|
|
64
64
|
"@types/react": {
|