@backstage/core-components 0.0.0-nightly-20250114022708 → 0.0.0-nightly-20250125022643
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 +17 -4
- package/dist/components/StructuredMetadataTable/StructuredMetadataTable.esm.js +24 -4
- package/dist/components/StructuredMetadataTable/StructuredMetadataTable.esm.js.map +1 -1
- package/dist/index.d.ts +7 -1
- package/dist/layout/ContentHeader/ContentHeader.esm.js +21 -1
- package/dist/layout/ContentHeader/ContentHeader.esm.js.map +1 -1
- package/package.json +9 -8
package/CHANGELOG.md
CHANGED
|
@@ -1,13 +1,26 @@
|
|
|
1
1
|
# @backstage/core-components
|
|
2
2
|
|
|
3
|
-
## 0.0.0-nightly-
|
|
3
|
+
## 0.0.0-nightly-20250125022643
|
|
4
4
|
|
|
5
5
|
### Patch Changes
|
|
6
6
|
|
|
7
|
+
- 9c9f4ff: Added `nestedValuesAsYaml` option to `StructuredMetadataTable` to render data as yaml.
|
|
7
8
|
- Updated dependencies
|
|
8
|
-
- @backstage/
|
|
9
|
-
- @backstage/
|
|
10
|
-
- @backstage/errors@
|
|
9
|
+
- @backstage/config@1.3.2
|
|
10
|
+
- @backstage/core-plugin-api@1.10.3
|
|
11
|
+
- @backstage/errors@1.2.7
|
|
12
|
+
- @backstage/theme@0.6.3
|
|
13
|
+
- @backstage/version-bridge@1.0.10
|
|
14
|
+
|
|
15
|
+
## 0.16.3
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- 4ec6f7b: Allow passing component for `ContentHeader` description
|
|
20
|
+
- Updated dependencies
|
|
21
|
+
- @backstage/core-plugin-api@1.10.3
|
|
22
|
+
- @backstage/config@1.3.2
|
|
23
|
+
- @backstage/errors@1.2.7
|
|
11
24
|
- @backstage/theme@0.6.3
|
|
12
25
|
- @backstage/version-bridge@1.0.10
|
|
13
26
|
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import React__default, { Fragment } from 'react';
|
|
2
|
-
import { createStyles, withStyles } from '@material-ui/core/styles';
|
|
3
2
|
import startCase from 'lodash/startCase';
|
|
4
3
|
import Typography from '@material-ui/core/Typography';
|
|
5
4
|
import { MetadataList, MetadataTable, MetadataTableItem, MetadataListItem } from './MetadataTable.esm.js';
|
|
5
|
+
import { CodeSnippet } from '../CodeSnippet/CodeSnippet.esm.js';
|
|
6
|
+
import jsyaml from 'js-yaml';
|
|
7
|
+
import { createStyles, withStyles } from '@material-ui/core/styles';
|
|
6
8
|
|
|
7
9
|
const listStyle = createStyles({
|
|
8
10
|
root: {
|
|
@@ -37,8 +39,25 @@ function toValue(value, options, nested) {
|
|
|
37
39
|
if (React__default.isValidElement(value)) {
|
|
38
40
|
return /* @__PURE__ */ React__default.createElement(Fragment, null, value);
|
|
39
41
|
}
|
|
40
|
-
if (value !== null && typeof value === "object"
|
|
41
|
-
|
|
42
|
+
if (value !== null && typeof value === "object") {
|
|
43
|
+
if (options.nestedValuesAsYaml) {
|
|
44
|
+
return /* @__PURE__ */ React__default.createElement(
|
|
45
|
+
CodeSnippet,
|
|
46
|
+
{
|
|
47
|
+
language: "yaml",
|
|
48
|
+
text: jsyaml.dump(value),
|
|
49
|
+
customStyle: {
|
|
50
|
+
background: "transparent",
|
|
51
|
+
lineHeight: "1.4",
|
|
52
|
+
padding: "0",
|
|
53
|
+
margin: 0
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
if (!Array.isArray(value)) {
|
|
59
|
+
return renderMap(value, options, nested);
|
|
60
|
+
}
|
|
42
61
|
}
|
|
43
62
|
if (Array.isArray(value)) {
|
|
44
63
|
return renderList(value, options, nested);
|
|
@@ -60,9 +79,10 @@ function mapToItems(info, options) {
|
|
|
60
79
|
return Object.keys(info).map((key) => /* @__PURE__ */ React__default.createElement(TableItem, { key, title: key, value: info[key], options }));
|
|
61
80
|
}
|
|
62
81
|
function StructuredMetadataTable(props) {
|
|
63
|
-
const { metadata, dense = true, options
|
|
82
|
+
const { metadata, dense = true, options } = props;
|
|
64
83
|
const metadataItems = mapToItems(metadata, {
|
|
65
84
|
titleFormat: startCase,
|
|
85
|
+
nestedValuesAsYaml: options?.nestedValuesAsYaml ?? false,
|
|
66
86
|
...options
|
|
67
87
|
});
|
|
68
88
|
return /* @__PURE__ */ React__default.createElement(MetadataTable, { dense }, metadataItems);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StructuredMetadataTable.esm.js","sources":["../../../src/components/StructuredMetadataTable/StructuredMetadataTable.tsx"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React, { Fragment, ReactElement } from 'react';\nimport {\n
|
|
1
|
+
{"version":3,"file":"StructuredMetadataTable.esm.js","sources":["../../../src/components/StructuredMetadataTable/StructuredMetadataTable.tsx"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React, { Fragment, ReactElement } from 'react';\nimport startCase from 'lodash/startCase';\nimport Typography from '@material-ui/core/Typography';\n\nimport {\n MetadataList,\n MetadataListItem,\n MetadataTable,\n MetadataTableItem,\n} from './MetadataTable';\nimport { CodeSnippet } from '../CodeSnippet';\nimport jsyaml from 'js-yaml';\nimport {\n Theme,\n createStyles,\n WithStyles,\n withStyles,\n} from '@material-ui/core/styles';\n\nexport type StructuredMetadataTableListClassKey = 'root';\n\nconst listStyle = createStyles({\n root: {\n margin: '0 0',\n listStyleType: 'none',\n },\n});\n\nexport type StructuredMetadataTableNestedListClassKey = 'root';\nconst nestedListStyle = (theme: Theme) =>\n createStyles({\n root: {\n ...listStyle.root,\n paddingLeft: theme.spacing(1),\n },\n });\n\ninterface StyleProps extends WithStyles {\n children?: React.ReactNode;\n}\n// Sub Components\nconst StyledList = withStyles(listStyle, {\n name: 'BackstageStructuredMetadataTableList',\n})(({ classes, children }: StyleProps) => (\n <MetadataList classes={classes}>{children}</MetadataList>\n));\nconst StyledNestedList = withStyles(nestedListStyle, {\n name: 'BackstageStructuredMetadataTableNestedList',\n})(({ classes, children }: StyleProps) => (\n <MetadataList classes={classes}>{children}</MetadataList>\n));\n\nfunction renderList(list: Array<any>, options: Options, nested: boolean) {\n const values = list.map((item: any, index: number) => (\n <MetadataListItem key={index}>\n {toValue(item, options, nested)}\n </MetadataListItem>\n ));\n return nested ? (\n <StyledNestedList>{values}</StyledNestedList>\n ) : (\n <StyledList>{values}</StyledList>\n );\n}\n\nfunction renderMap(\n map: { [key: string]: any },\n options: Options,\n nested: boolean,\n) {\n const values = Object.keys(map).map(key => {\n const value = toValue(map[key], options, true);\n return (\n <MetadataListItem key={key}>\n <Typography variant=\"body2\" component=\"span\">\n {`${options.titleFormat(key)}: `}\n </Typography>\n {value}\n </MetadataListItem>\n );\n });\n\n return nested ? (\n <StyledNestedList>{values}</StyledNestedList>\n ) : (\n <StyledList>{values}</StyledList>\n );\n}\n\nfunction toValue(\n value: ReactElement | object | Array<any> | boolean,\n options: Options,\n nested: boolean,\n) {\n if (React.isValidElement(value)) {\n return <Fragment>{value}</Fragment>;\n }\n if (value !== null && typeof value === 'object') {\n if (options.nestedValuesAsYaml) {\n return (\n <CodeSnippet\n language=\"yaml\"\n text={jsyaml.dump(value)}\n customStyle={{\n background: 'transparent',\n lineHeight: '1.4',\n padding: '0',\n margin: 0,\n }}\n />\n );\n }\n if (!Array.isArray(value)) {\n return renderMap(value, options, nested);\n }\n }\n\n if (Array.isArray(value)) {\n return renderList(value, options, nested);\n }\n\n if (typeof value === 'boolean') {\n return <Fragment>{value ? '✅' : '❌'}</Fragment>;\n }\n return (\n <Typography variant=\"body2\" component=\"span\">\n {value}\n </Typography>\n );\n}\nconst ItemValue = ({ value, options }: { value: any; options: Options }) => (\n <Fragment>{toValue(value, options, false)}</Fragment>\n);\n\nconst TableItem = ({\n title,\n value,\n options,\n}: {\n title: string;\n value: any;\n options: Options;\n}) => {\n return (\n <MetadataTableItem title={options.titleFormat(title)}>\n <ItemValue value={value} options={options} />\n </MetadataTableItem>\n );\n};\n\nfunction mapToItems(info: { [key: string]: string }, options: Options) {\n return Object.keys(info).map(key => (\n <TableItem key={key} title={key} value={info[key]} options={options} />\n ));\n}\n\n/** @public */\nexport interface StructuredMetadataTableProps {\n metadata: { [key: string]: any };\n dense?: boolean;\n options?: {\n /**\n * Function to format the keys from the `metadata` object. Defaults to\n * startCase from the lodash library.\n * @param key - A key within the `metadata`\n * @returns Formatted key\n */\n titleFormat?: (key: string) => string;\n nestedValuesAsYaml?: boolean;\n };\n}\n\ntype Options = Required<NonNullable<StructuredMetadataTableProps['options']>>;\n\n/** @public */\nexport function StructuredMetadataTable(props: StructuredMetadataTableProps) {\n const { metadata, dense = true, options } = props;\n const metadataItems = mapToItems(metadata, {\n titleFormat: startCase,\n nestedValuesAsYaml: options?.nestedValuesAsYaml ?? false,\n ...options,\n });\n return <MetadataTable dense={dense}>{metadataItems}</MetadataTable>;\n}\n"],"names":["React"],"mappings":";;;;;;;;AAqCA,MAAM,YAAY,YAAa,CAAA;AAAA,EAC7B,IAAM,EAAA;AAAA,IACJ,MAAQ,EAAA,KAAA;AAAA,IACR,aAAe,EAAA;AAAA;AAEn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AAA,GAAgB,WAAW,QAAU,EAAA;AAAA,IACzC,WAAa,EAAA,SAAA;AAAA,IACb,kBAAA,EAAoB,SAAS,kBAAsB,IAAA,KAAA;AAAA,IACnD,GAAG;AAAA,GACJ,CAAA;AACD,EAAO,uBAAAA,cAAA,CAAA,aAAA,CAAC,aAAc,EAAA,EAAA,KAAA,EAAA,EAAe,aAAc,CAAA;AACrD;;;;"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1113,6 +1113,7 @@ interface StructuredMetadataTableProps {
|
|
|
1113
1113
|
* @returns Formatted key
|
|
1114
1114
|
*/
|
|
1115
1115
|
titleFormat?: (key: string) => string;
|
|
1116
|
+
nestedValuesAsYaml?: boolean;
|
|
1116
1117
|
};
|
|
1117
1118
|
}
|
|
1118
1119
|
/** @public */
|
|
@@ -1338,10 +1339,15 @@ type ContentHeaderTitleProps = {
|
|
|
1338
1339
|
title?: string;
|
|
1339
1340
|
className?: string;
|
|
1340
1341
|
};
|
|
1342
|
+
type ContentHeaderDescriptionProps = {
|
|
1343
|
+
description?: string;
|
|
1344
|
+
className?: string;
|
|
1345
|
+
};
|
|
1341
1346
|
type ContentHeaderProps = {
|
|
1342
1347
|
title?: ContentHeaderTitleProps['title'];
|
|
1343
1348
|
titleComponent?: ReactNode;
|
|
1344
|
-
description?:
|
|
1349
|
+
description?: ContentHeaderDescriptionProps['description'];
|
|
1350
|
+
descriptionComponent?: ReactNode;
|
|
1345
1351
|
textAlign?: 'left' | 'right' | 'center';
|
|
1346
1352
|
};
|
|
1347
1353
|
/**
|
|
@@ -49,17 +49,37 @@ const ContentHeaderTitle = ({ title, className }) => /* @__PURE__ */ React__defa
|
|
|
49
49
|
},
|
|
50
50
|
title
|
|
51
51
|
);
|
|
52
|
+
const ContentHeaderDescription = ({
|
|
53
|
+
description,
|
|
54
|
+
className
|
|
55
|
+
}) => description ? /* @__PURE__ */ React__default.createElement(
|
|
56
|
+
Typography,
|
|
57
|
+
{
|
|
58
|
+
variant: "body2",
|
|
59
|
+
className,
|
|
60
|
+
"data-testid": "header-description"
|
|
61
|
+
},
|
|
62
|
+
description
|
|
63
|
+
) : null;
|
|
52
64
|
function ContentHeader(props) {
|
|
53
65
|
const {
|
|
54
66
|
description,
|
|
55
67
|
title,
|
|
56
68
|
titleComponent: TitleComponent = void 0,
|
|
57
69
|
children,
|
|
70
|
+
descriptionComponent: DescriptionComponent = void 0,
|
|
58
71
|
textAlign = "left"
|
|
59
72
|
} = props;
|
|
60
73
|
const classes = useStyles({ textAlign })();
|
|
61
74
|
const renderedTitle = TitleComponent ? TitleComponent : /* @__PURE__ */ React__default.createElement(ContentHeaderTitle, { title, className: classes.title });
|
|
62
|
-
|
|
75
|
+
const renderedDescription = DescriptionComponent ? DescriptionComponent : /* @__PURE__ */ React__default.createElement(
|
|
76
|
+
ContentHeaderDescription,
|
|
77
|
+
{
|
|
78
|
+
description,
|
|
79
|
+
className: classes.description
|
|
80
|
+
}
|
|
81
|
+
);
|
|
82
|
+
return /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, /* @__PURE__ */ React__default.createElement(Helmet, { title }), /* @__PURE__ */ React__default.createElement(Box, { className: classes.container }, /* @__PURE__ */ React__default.createElement(Box, { className: classes.leftItemsBox }, renderedTitle, renderedDescription), /* @__PURE__ */ React__default.createElement(Box, { className: classes.rightItemsBox }, children)));
|
|
63
83
|
}
|
|
64
84
|
|
|
65
85
|
export { ContentHeader };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContentHeader.esm.js","sources":["../../../src/layout/ContentHeader/ContentHeader.tsx"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport Box from '@material-ui/core/Box';\nimport { makeStyles } from '@material-ui/core/styles';\nimport Typography from '@material-ui/core/Typography';\nimport React, { PropsWithChildren, ReactNode } from 'react';\nimport { Helmet } from 'react-helmet';\n\n/**\n * TODO: favoriteable capability\n */\n\n/** @public */\nexport type ContentHeaderClassKey =\n | 'container'\n | 'leftItemsBox'\n | 'rightItemsBox'\n | 'description'\n | 'title';\n\nconst useStyles = (props: ContentHeaderProps) =>\n makeStyles(\n theme => ({\n container: {\n width: '100%',\n display: 'flex',\n flexDirection: 'row',\n flexWrap: 'wrap',\n justifyContent: 'flex-end',\n alignItems: 'center',\n marginBottom: theme.spacing(2),\n textAlign: props.textAlign,\n },\n leftItemsBox: {\n flex: '1 1 auto',\n minWidth: 0,\n overflow: 'visible',\n },\n rightItemsBox: {\n flex: '0 1 auto',\n display: 'flex',\n flexDirection: 'row',\n flexWrap: 'wrap',\n alignItems: 'center',\n marginLeft: theme.spacing(1),\n minWidth: 0,\n overflow: 'visible',\n },\n description: {},\n title: {\n display: 'inline-flex',\n marginBottom: 0,\n },\n }),\n { name: 'BackstageContentHeader' },\n );\n\ntype ContentHeaderTitleProps = {\n title?: string;\n className?: string;\n};\n\nconst ContentHeaderTitle = ({ title, className }: ContentHeaderTitleProps) => (\n <Typography\n variant=\"h4\"\n component=\"h2\"\n className={className}\n data-testid=\"header-title\"\n >\n {title}\n </Typography>\n);\n\ntype ContentHeaderProps = {\n title?: ContentHeaderTitleProps['title'];\n titleComponent?: ReactNode;\n description?:
|
|
1
|
+
{"version":3,"file":"ContentHeader.esm.js","sources":["../../../src/layout/ContentHeader/ContentHeader.tsx"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport Box from '@material-ui/core/Box';\nimport { makeStyles } from '@material-ui/core/styles';\nimport Typography from '@material-ui/core/Typography';\nimport React, { PropsWithChildren, ReactNode } from 'react';\nimport { Helmet } from 'react-helmet';\n\n/**\n * TODO: favoriteable capability\n */\n\n/** @public */\nexport type ContentHeaderClassKey =\n | 'container'\n | 'leftItemsBox'\n | 'rightItemsBox'\n | 'description'\n | 'title';\n\nconst useStyles = (props: ContentHeaderProps) =>\n makeStyles(\n theme => ({\n container: {\n width: '100%',\n display: 'flex',\n flexDirection: 'row',\n flexWrap: 'wrap',\n justifyContent: 'flex-end',\n alignItems: 'center',\n marginBottom: theme.spacing(2),\n textAlign: props.textAlign,\n },\n leftItemsBox: {\n flex: '1 1 auto',\n minWidth: 0,\n overflow: 'visible',\n },\n rightItemsBox: {\n flex: '0 1 auto',\n display: 'flex',\n flexDirection: 'row',\n flexWrap: 'wrap',\n alignItems: 'center',\n marginLeft: theme.spacing(1),\n minWidth: 0,\n overflow: 'visible',\n },\n description: {},\n title: {\n display: 'inline-flex',\n marginBottom: 0,\n },\n }),\n { name: 'BackstageContentHeader' },\n );\n\ntype ContentHeaderTitleProps = {\n title?: string;\n className?: string;\n};\n\nconst ContentHeaderTitle = ({ title, className }: ContentHeaderTitleProps) => (\n <Typography\n variant=\"h4\"\n component=\"h2\"\n className={className}\n data-testid=\"header-title\"\n >\n {title}\n </Typography>\n);\n\ntype ContentHeaderDescriptionProps = {\n description?: string;\n className?: string;\n};\n\nconst ContentHeaderDescription = ({\n description,\n className,\n}: ContentHeaderDescriptionProps) =>\n description ? (\n <Typography\n variant=\"body2\"\n className={className}\n data-testid=\"header-description\"\n >\n {description}\n </Typography>\n ) : null;\n\ntype ContentHeaderProps = {\n title?: ContentHeaderTitleProps['title'];\n titleComponent?: ReactNode;\n description?: ContentHeaderDescriptionProps['description'];\n descriptionComponent?: ReactNode;\n textAlign?: 'left' | 'right' | 'center';\n};\n\n/**\n * A header at the top inside a {@link Content}.\n *\n * @public\n *\n */\n\nexport function ContentHeader(props: PropsWithChildren<ContentHeaderProps>) {\n const {\n description,\n title,\n titleComponent: TitleComponent = undefined,\n children,\n descriptionComponent: DescriptionComponent = undefined,\n textAlign = 'left',\n } = props;\n const classes = useStyles({ textAlign })();\n\n const renderedTitle = TitleComponent ? (\n TitleComponent\n ) : (\n <ContentHeaderTitle title={title} className={classes.title} />\n );\n\n const renderedDescription = DescriptionComponent ? (\n DescriptionComponent\n ) : (\n <ContentHeaderDescription\n description={description}\n className={classes.description}\n />\n );\n\n return (\n <>\n <Helmet title={title} />\n <Box className={classes.container}>\n <Box className={classes.leftItemsBox}>\n {renderedTitle}\n {renderedDescription}\n </Box>\n <Box className={classes.rightItemsBox}>{children}</Box>\n </Box>\n </>\n );\n}\n"],"names":["React"],"mappings":";;;;;;AAiCA,MAAM,SAAA,GAAY,CAAC,KACjB,KAAA,UAAA;AAAA,EACE,CAAU,KAAA,MAAA;AAAA,IACR,SAAW,EAAA;AAAA,MACT,KAAO,EAAA,MAAA;AAAA,MACP,OAAS,EAAA,MAAA;AAAA,MACT,aAAe,EAAA,KAAA;AAAA,MACf,QAAU,EAAA,MAAA;AAAA,MACV,cAAgB,EAAA,UAAA;AAAA,MAChB,UAAY,EAAA,QAAA;AAAA,MACZ,YAAA,EAAc,KAAM,CAAA,OAAA,CAAQ,CAAC,CAAA;AAAA,MAC7B,WAAW,KAAM,CAAA;AAAA,KACnB;AAAA,IACA,YAAc,EAAA;AAAA,MACZ,IAAM,EAAA,UAAA;AAAA,MACN,QAAU,EAAA,CAAA;AAAA,MACV,QAAU,EAAA;AAAA,KACZ;AAAA,IACA,aAAe,EAAA;AAAA,MACb,IAAM,EAAA,UAAA;AAAA,MACN,OAAS,EAAA,MAAA;AAAA,MACT,aAAe,EAAA,KAAA;AAAA,MACf,QAAU,EA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EAAA,SAAA,EAAW,QAAQ,KAAO,EAAA,CAAA;AAG9D,EAAM,MAAA,mBAAA,GAAsB,uBAC1B,oBAEA,mBAAAA,cAAA,CAAA,aAAA;AAAA,IAAC,wBAAA;AAAA,IAAA;AAAA,MACC,WAAA;AAAA,MACA,WAAW,OAAQ,CAAA;AAAA;AAAA,GACrB;AAGF,EACE,uBAAAA,cAAA,CAAA,aAAA,CAAAA,cAAA,CAAA,QAAA,EAAA,IAAA,kBACGA,cAAA,CAAA,aAAA,CAAA,MAAA,EAAA,EAAO,KAAc,EAAA,CAAA,+CACrB,GAAI,EAAA,EAAA,SAAA,EAAW,OAAQ,CAAA,SAAA,EAAA,kBACrBA,cAAA,CAAA,aAAA,CAAA,GAAA,EAAA,EAAI,WAAW,OAAQ,CAAA,YAAA,EAAA,EACrB,aACA,EAAA,mBACH,CACA,kBAAAA,cAAA,CAAA,aAAA,CAAC,GAAI,EAAA,EAAA,SAAA,EAAW,OAAQ,CAAA,aAAA,EAAA,EAAgB,QAAS,CACnD,CACF,CAAA;AAEJ;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@backstage/core-components",
|
|
3
|
-
"version": "0.0.0-nightly-
|
|
3
|
+
"version": "0.0.0-nightly-20250125022643",
|
|
4
4
|
"description": "Core components used by Backstage plugins and apps",
|
|
5
5
|
"backstage": {
|
|
6
6
|
"role": "web-library"
|
|
@@ -66,9 +66,9 @@
|
|
|
66
66
|
"test": "backstage-cli package test"
|
|
67
67
|
},
|
|
68
68
|
"dependencies": {
|
|
69
|
-
"@backstage/config": "
|
|
70
|
-
"@backstage/core-plugin-api": "
|
|
71
|
-
"@backstage/errors": "
|
|
69
|
+
"@backstage/config": "1.3.2",
|
|
70
|
+
"@backstage/core-plugin-api": "1.10.3",
|
|
71
|
+
"@backstage/errors": "1.2.7",
|
|
72
72
|
"@backstage/theme": "0.6.3",
|
|
73
73
|
"@backstage/version-bridge": "1.0.10",
|
|
74
74
|
"@date-io/core": "^1.3.13",
|
|
@@ -85,6 +85,7 @@
|
|
|
85
85
|
"d3-shape": "^3.0.0",
|
|
86
86
|
"d3-zoom": "^3.0.0",
|
|
87
87
|
"dagre": "^0.8.5",
|
|
88
|
+
"js-yaml": "^4.1.0",
|
|
88
89
|
"linkify-react": "4.1.3",
|
|
89
90
|
"linkifyjs": "4.1.3",
|
|
90
91
|
"lodash": "^4.17.21",
|
|
@@ -105,10 +106,10 @@
|
|
|
105
106
|
"zod": "^3.22.4"
|
|
106
107
|
},
|
|
107
108
|
"devDependencies": {
|
|
108
|
-
"@backstage/app-defaults": "0.0.0-nightly-
|
|
109
|
-
"@backstage/cli": "0.0.0-nightly-
|
|
110
|
-
"@backstage/core-app-api": "
|
|
111
|
-
"@backstage/test-utils": "
|
|
109
|
+
"@backstage/app-defaults": "0.0.0-nightly-20250125022643",
|
|
110
|
+
"@backstage/cli": "0.0.0-nightly-20250125022643",
|
|
111
|
+
"@backstage/core-app-api": "1.15.4",
|
|
112
|
+
"@backstage/test-utils": "1.7.4",
|
|
112
113
|
"@testing-library/dom": "^10.0.0",
|
|
113
114
|
"@testing-library/jest-dom": "^6.0.0",
|
|
114
115
|
"@testing-library/user-event": "^14.0.0",
|