@backstage/plugin-home 0.4.6 → 0.4.7
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 +9 -0
- package/dist/esm/{index-64b176b7.esm.js → index-05c74847.esm.js} +1 -1
- package/dist/esm/{index-64b176b7.esm.js.map → index-05c74847.esm.js.map} +1 -1
- package/dist/esm/{index-1baf251a.esm.js → index-22929ade.esm.js} +4 -4
- package/dist/esm/{index-1baf251a.esm.js.map → index-22929ade.esm.js.map} +1 -1
- package/dist/esm/{index-57301ff6.esm.js → index-8ff3197b.esm.js} +3 -3
- package/dist/esm/{index-57301ff6.esm.js.map → index-8ff3197b.esm.js.map} +1 -1
- package/dist/index.esm.js +11 -11
- package/dist/index.esm.js.map +1 -1
- package/package.json +13 -12
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# @backstage/plugin-home
|
|
2
2
|
|
|
3
|
+
## 0.4.7
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- cd450844f6: Moved React dependencies to `peerDependencies` and allow both React v16 and v17 to be used.
|
|
8
|
+
- Updated dependencies
|
|
9
|
+
- @backstage/core-components@0.8.0
|
|
10
|
+
- @backstage/core-plugin-api@0.3.0
|
|
11
|
+
|
|
3
12
|
## 0.4.6
|
|
4
13
|
|
|
5
14
|
### Patch Changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index-
|
|
1
|
+
{"version":3,"file":"index-05c74847.esm.js","sources":["../../src/components/HomepageCompositionRoot.tsx"],"sourcesContent":["/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React, { ReactNode } from 'react';\nimport { useOutlet } from 'react-router';\n\nexport const HomepageCompositionRoot = (props: {\n title?: string;\n children?: ReactNode;\n}) => {\n const outlet = useOutlet();\n const children = props.children ?? outlet;\n return <>{children}</>;\n};\n"],"names":[],"mappings":";;;;;;;;MAmBa,0BAA0B,CAAC,UAGlC;AAtBN;AAuBE,QAAM,SAAS;AACf,QAAM,WAAW,YAAM,aAAN,YAAkB;AACnC,mEAAU;AAAA;;;;"}
|
|
@@ -47,7 +47,7 @@ const useRandomJoke = () => {
|
|
|
47
47
|
};
|
|
48
48
|
|
|
49
49
|
const Actions = () => {
|
|
50
|
-
const {rerollJoke} = useRandomJoke();
|
|
50
|
+
const { rerollJoke } = useRandomJoke();
|
|
51
51
|
return /* @__PURE__ */ React.createElement(Button, {
|
|
52
52
|
variant: "contained",
|
|
53
53
|
color: "primary",
|
|
@@ -56,14 +56,14 @@ const Actions = () => {
|
|
|
56
56
|
};
|
|
57
57
|
|
|
58
58
|
const Content = () => {
|
|
59
|
-
const {joke, loading} = useRandomJoke();
|
|
59
|
+
const { joke, loading } = useRandomJoke();
|
|
60
60
|
if (loading)
|
|
61
61
|
return /* @__PURE__ */ React.createElement("p", null, "Loading...");
|
|
62
62
|
return /* @__PURE__ */ React.createElement("div", null, /* @__PURE__ */ React.createElement("p", null, joke.setup), /* @__PURE__ */ React.createElement("p", null, joke.punchline));
|
|
63
63
|
};
|
|
64
64
|
|
|
65
65
|
const Settings = () => {
|
|
66
|
-
const {type, handleChangeType} = useRandomJoke();
|
|
66
|
+
const { type, handleChangeType } = useRandomJoke();
|
|
67
67
|
const JOKE_TYPES = ["any", "programming"];
|
|
68
68
|
return /* @__PURE__ */ React.createElement(FormControl, {
|
|
69
69
|
component: "fieldset"
|
|
@@ -82,4 +82,4 @@ const Settings = () => {
|
|
|
82
82
|
};
|
|
83
83
|
|
|
84
84
|
export { Actions, Content, ContextProvider, Settings };
|
|
85
|
-
//# sourceMappingURL=index-
|
|
85
|
+
//# sourceMappingURL=index-22929ade.esm.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index-
|
|
1
|
+
{"version":3,"file":"index-22929ade.esm.js","sources":["../../src/homePageComponents/RandomJoke/Context.tsx","../../src/homePageComponents/RandomJoke/Actions.tsx","../../src/homePageComponents/RandomJoke/Content.tsx","../../src/homePageComponents/RandomJoke/Settings.tsx"],"sourcesContent":["/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React, { createContext } from 'react';\n\nexport type JokeType = 'any' | 'programming';\n\ntype Joke = {\n setup: string;\n punchline: string;\n};\n\ntype RandomJokeContextValue = {\n loading: boolean;\n joke: Joke;\n type: JokeType;\n rerollJoke: Function;\n handleChangeType: Function;\n};\n\nconst Context = createContext<RandomJokeContextValue | undefined>(undefined);\n\nconst getNewJoke = (type: string): Promise<Joke> =>\n fetch(\n `https://official-joke-api.appspot.com/jokes${\n type !== 'any' ? `/${type}` : ''\n }/random`,\n )\n .then(res => res.json())\n .then(data => (Array.isArray(data) ? data[0] : data));\n\nexport const ContextProvider = ({\n children,\n defaultCategory,\n}: {\n children: JSX.Element;\n defaultCategory?: JokeType;\n}) => {\n const [loading, setLoading] = React.useState(true);\n const [joke, setJoke] = React.useState<Joke>({\n setup: '',\n punchline: '',\n });\n const [type, setType] = React.useState<JokeType>(\n defaultCategory || ('programming' as JokeType),\n );\n\n const rerollJoke = React.useCallback(() => {\n setLoading(true);\n getNewJoke(type).then(newJoke => setJoke(newJoke));\n }, [type]);\n\n const handleChangeType = (newType: JokeType) => {\n setType(newType);\n };\n\n React.useEffect(() => {\n setLoading(false);\n }, [joke]);\n\n React.useEffect(() => {\n rerollJoke();\n }, [rerollJoke]);\n\n const value: RandomJokeContextValue = {\n loading,\n joke,\n type,\n rerollJoke,\n handleChangeType,\n };\n\n return <Context.Provider value={value}>{children}</Context.Provider>;\n};\n\nexport const useRandomJoke = () => {\n const value = React.useContext(Context);\n\n if (value === undefined) {\n throw new Error('useRandomJoke must be used within a RandomJokeProvider');\n }\n\n return value;\n};\n\nexport default Context;\n","/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React from 'react';\n\nimport { Button } from '@material-ui/core';\nimport { useRandomJoke } from './Context';\n\nexport const Actions = () => {\n const { rerollJoke } = useRandomJoke();\n return (\n <Button variant=\"contained\" color=\"primary\" onClick={() => rerollJoke()}>\n Reroll\n </Button>\n );\n};\n","/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React from 'react';\nimport { useRandomJoke } from './Context';\n\nexport const Content = () => {\n const { joke, loading } = useRandomJoke();\n\n if (loading) return <p>Loading...</p>;\n\n return (\n <div>\n <p>{joke.setup}</p>\n <p>{joke.punchline}</p>\n </div>\n );\n};\n","/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport {\n FormControl,\n FormLabel,\n RadioGroup,\n FormControlLabel,\n Radio,\n} from '@material-ui/core';\nimport React from 'react';\nimport { useRandomJoke, JokeType } from './Context';\nimport upperFirst from 'lodash/upperFirst';\n\nexport const Settings = () => {\n const { type, handleChangeType } = useRandomJoke();\n const JOKE_TYPES: JokeType[] = ['any' as JokeType, 'programming' as JokeType];\n return (\n <FormControl component=\"fieldset\">\n <FormLabel component=\"legend\">Joke Type</FormLabel>\n <RadioGroup\n aria-label=\"joke type\"\n value={type}\n onChange={e => handleChangeType(e.target.value)}\n >\n {JOKE_TYPES.map(t => (\n <FormControlLabel\n key={t}\n value={t}\n control={<Radio />}\n label={upperFirst(t)}\n />\n ))}\n </RadioGroup>\n </FormControl>\n );\n};\n"],"names":[],"mappings":";;;;AAiCA,MAAM,UAAU,cAAkD;AAElE,MAAM,aAAa,CAAC,SAClB,MACE,8CACE,SAAS,QAAQ,IAAI,SAAS,aAG/B,KAAK,SAAO,IAAI,QAChB,KAAK,UAAS,MAAM,QAAQ,QAAQ,KAAK,KAAK;MAEtC,kBAAkB,CAAC;AAAA,EAC9B;AAAA,EACA;AAAA,MAII;AACJ,QAAM,CAAC,SAAS,cAAc,MAAM,SAAS;AAC7C,QAAM,CAAC,MAAM,WAAW,MAAM,SAAe;AAAA,IAC3C,OAAO;AAAA,IACP,WAAW;AAAA;AAEb,QAAM,CAAC,MAAM,WAAW,MAAM,SAC5B,mBAAoB;AAGtB,QA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@@ -62,9 +62,9 @@ const ComponentTabs = ({
|
|
|
62
62
|
}, tabs.map((t) => /* @__PURE__ */ React.createElement(Tab, {
|
|
63
63
|
key: t.label,
|
|
64
64
|
label: t.label
|
|
65
|
-
}))), tabs.map(({Component}, idx) => /* @__PURE__ */ React.createElement("div", {
|
|
65
|
+
}))), tabs.map(({ Component }, idx) => /* @__PURE__ */ React.createElement("div", {
|
|
66
66
|
key: idx,
|
|
67
|
-
...idx !== value ? {style: {display: "none"}} : {}
|
|
67
|
+
...idx !== value ? { style: { display: "none" } } : {}
|
|
68
68
|
}, /* @__PURE__ */ React.createElement(Component, null))));
|
|
69
69
|
};
|
|
70
70
|
|
|
@@ -80,4 +80,4 @@ const ComponentTab = ({
|
|
|
80
80
|
};
|
|
81
81
|
|
|
82
82
|
export { ComponentAccordion, ComponentTab, ComponentTabs };
|
|
83
|
-
//# sourceMappingURL=index-
|
|
83
|
+
//# sourceMappingURL=index-8ff3197b.esm.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index-
|
|
1
|
+
{"version":3,"file":"index-8ff3197b.esm.js","sources":["../../src/componentRenderers/ComponentAccordion.tsx","../../src/componentRenderers/ComponentTabs/ComponentTabs.tsx","../../src/componentRenderers/ComponentTabs/ComponentTab.tsx"],"sourcesContent":["/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React from 'react';\nimport {\n Accordion,\n AccordionDetails,\n AccordionSummary,\n Typography,\n IconButton,\n Theme,\n} from '@material-ui/core';\nimport { makeStyles } from '@material-ui/core/styles';\nimport ExpandMoreIcon from '@material-ui/icons/ExpandMore';\nimport SettingsIcon from '@material-ui/icons/Settings';\n\nimport { SettingsModal } from '../components';\n\nconst useStyles = makeStyles((theme: Theme) => ({\n settingsIconButton: {\n padding: theme.spacing(0, 1, 0, 0),\n },\n}));\n\nexport const ComponentAccordion = ({\n title,\n Content,\n Actions,\n Settings,\n ContextProvider,\n ...childProps\n}: {\n title: string;\n Content: () => JSX.Element;\n Actions?: () => JSX.Element;\n Settings?: () => JSX.Element;\n ContextProvider?: (props: any) => JSX.Element;\n}) => {\n const classes = useStyles();\n const [settingsIsExpanded, setSettingsIsExpanded] = React.useState(false);\n const [isExpanded, setIsExpanded] = React.useState(false);\n\n const handleOpenSettings = (e: any) => {\n e.stopPropagation();\n setSettingsIsExpanded(prevState => !prevState);\n };\n\n const innerContent = (\n <>\n {Settings && (\n <SettingsModal\n open={settingsIsExpanded}\n close={() => setSettingsIsExpanded(false)}\n componentName={title}\n >\n <Settings />\n </SettingsModal>\n )}\n <Accordion\n expanded={isExpanded}\n onChange={(_e: any, expanded: boolean) => setIsExpanded(expanded)}\n >\n <AccordionSummary expandIcon={<ExpandMoreIcon />}>\n {Settings && (\n <IconButton\n onClick={handleOpenSettings}\n className={classes.settingsIconButton}\n >\n <SettingsIcon />\n </IconButton>\n )}\n <Typography>{title}</Typography>\n </AccordionSummary>\n <AccordionDetails>\n <div>\n <Content />\n {Actions && <Actions />}\n </div>\n </AccordionDetails>\n </Accordion>\n </>\n );\n\n return ContextProvider ? (\n <ContextProvider {...childProps}>{innerContent}</ContextProvider>\n ) : (\n innerContent\n );\n};\n","/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React from 'react';\nimport { Tabs, Tab } from '@material-ui/core';\nimport { InfoCard } from '@backstage/core-components';\n\ntype TabType = {\n label: string;\n Component: () => JSX.Element;\n};\n\nexport const ComponentTabs = ({\n title,\n tabs,\n}: {\n title: string;\n tabs: TabType[];\n}) => {\n const [value, setValue] = React.useState(0);\n\n const handleChange = (_event: any, newValue: number) => {\n setValue(newValue);\n };\n\n return (\n <InfoCard title={title}>\n <Tabs value={value} onChange={handleChange}>\n {tabs.map(t => (\n <Tab key={t.label} label={t.label} />\n ))}\n </Tabs>\n {tabs.map(({ Component }, idx) => (\n <div\n key={idx}\n {...(idx !== value ? { style: { display: 'none' } } : {})}\n >\n <Component />\n </div>\n ))}\n </InfoCard>\n );\n};\n","/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React from 'react';\n\nexport const ComponentTab = ({\n title,\n Content,\n ContextProvider,\n ...childProps\n}: {\n title: string;\n Content: () => JSX.Element;\n ContextProvider?: (props: any) => JSX.Element;\n}) => {\n return ContextProvider ? (\n <ContextProvider {...childProps}>\n <Content />\n </ContextProvider>\n ) : (\n <Content />\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;AA+BA,MAAM,YAAY,WAAW,CAAC;AAAkB,EAC9C,oBAAoB;AAAA,IAClB,SAAS,MAAM,QAAQ,GAAG,GAAG,GAAG;AAAA;AAAA;MAIvB,qBAAqB,CAAC;AAAA,EACjC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,KACG;AAAA,MAOC;AACJ,QAAM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AAAA,yCAClB,SAAD,6CAGD,SAAD;AAAA;;;;"}
|
package/dist/index.esm.js
CHANGED
|
@@ -46,7 +46,7 @@ function getTimes(clockConfigs) {
|
|
|
46
46
|
label = "GMT";
|
|
47
47
|
}
|
|
48
48
|
const time = d.toLocaleTimeString(lang, options);
|
|
49
|
-
clocks.push({time, label});
|
|
49
|
+
clocks.push({ time, label });
|
|
50
50
|
}
|
|
51
51
|
return clocks;
|
|
52
52
|
}
|
|
@@ -82,14 +82,14 @@ function createCardExtension({
|
|
|
82
82
|
return createReactExtension({
|
|
83
83
|
name,
|
|
84
84
|
component: {
|
|
85
|
-
lazy: () => components().then(({Content, Actions, Settings, ContextProvider}) => {
|
|
85
|
+
lazy: () => components().then(({ Content, Actions, Settings, ContextProvider }) => {
|
|
86
86
|
const CardExtension = ({
|
|
87
87
|
Renderer,
|
|
88
88
|
title: overrideTitle,
|
|
89
89
|
...childProps
|
|
90
90
|
}) => {
|
|
91
91
|
const app = useApp();
|
|
92
|
-
const {Progress} = app.getComponents();
|
|
92
|
+
const { Progress } = app.getComponents();
|
|
93
93
|
const [settingsOpen, setSettingsOpen] = React.useState(false);
|
|
94
94
|
if (Renderer) {
|
|
95
95
|
return /* @__PURE__ */ React.createElement(Suspense, {
|
|
@@ -98,9 +98,9 @@ function createCardExtension({
|
|
|
98
98
|
title: overrideTitle || title,
|
|
99
99
|
...{
|
|
100
100
|
Content,
|
|
101
|
-
...Actions ? {Actions} : {},
|
|
102
|
-
...Settings ? {Settings} : {},
|
|
103
|
-
...ContextProvider ? {ContextProvider} : {},
|
|
101
|
+
...Actions ? { Actions } : {},
|
|
102
|
+
...Settings ? { Settings } : {},
|
|
103
|
+
...ContextProvider ? { ContextProvider } : {},
|
|
104
104
|
...childProps
|
|
105
105
|
}
|
|
106
106
|
}));
|
|
@@ -147,25 +147,25 @@ const homePlugin = createPlugin({
|
|
|
147
147
|
});
|
|
148
148
|
const HomepageCompositionRoot = homePlugin.provide(createRoutableExtension({
|
|
149
149
|
name: "HomepageCompositionRoot",
|
|
150
|
-
component: () => import('./esm/index-
|
|
150
|
+
component: () => import('./esm/index-05c74847.esm.js').then((m) => m.HomepageCompositionRoot),
|
|
151
151
|
mountPoint: rootRouteRef
|
|
152
152
|
}));
|
|
153
153
|
const ComponentAccordion = homePlugin.provide(createComponentExtension({
|
|
154
154
|
name: "ComponentAccordion",
|
|
155
155
|
component: {
|
|
156
|
-
lazy: () => import('./esm/index-
|
|
156
|
+
lazy: () => import('./esm/index-8ff3197b.esm.js').then((m) => m.ComponentAccordion)
|
|
157
157
|
}
|
|
158
158
|
}));
|
|
159
159
|
const ComponentTabs = homePlugin.provide(createComponentExtension({
|
|
160
160
|
name: "ComponentTabs",
|
|
161
161
|
component: {
|
|
162
|
-
lazy: () => import('./esm/index-
|
|
162
|
+
lazy: () => import('./esm/index-8ff3197b.esm.js').then((m) => m.ComponentTabs)
|
|
163
163
|
}
|
|
164
164
|
}));
|
|
165
165
|
const ComponentTab = homePlugin.provide(createComponentExtension({
|
|
166
166
|
name: "ComponentTab",
|
|
167
167
|
component: {
|
|
168
|
-
lazy: () => import('./esm/index-
|
|
168
|
+
lazy: () => import('./esm/index-8ff3197b.esm.js').then((m) => m.ComponentTab)
|
|
169
169
|
}
|
|
170
170
|
}));
|
|
171
171
|
const WelcomeTitle = homePlugin.provide(createComponentExtension({
|
|
@@ -177,7 +177,7 @@ const WelcomeTitle = homePlugin.provide(createComponentExtension({
|
|
|
177
177
|
const HomePageRandomJoke = homePlugin.provide(createCardExtension({
|
|
178
178
|
name: "HomePageRandomJoke",
|
|
179
179
|
title: "Random Joke",
|
|
180
|
-
components: () => import('./esm/index-
|
|
180
|
+
components: () => import('./esm/index-22929ade.esm.js')
|
|
181
181
|
}));
|
|
182
182
|
|
|
183
183
|
export { ComponentAccordion, ComponentTab, ComponentTabs, HeaderWorldClock, HomePageRandomJoke, HomepageCompositionRoot, SettingsModal, WelcomeTitle, createCardExtension, homePlugin };
|
package/dist/index.esm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.esm.js","sources":["../src/components/SettingsModal.tsx","../src/components/HeaderWorldClock/HeaderWorldClock.tsx","../src/extensions.tsx","../src/routes.ts","../src/plugin.ts"],"sourcesContent":["/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React from 'react';\nimport {\n Button,\n Dialog,\n DialogActions,\n DialogContent,\n DialogTitle,\n} from '@material-ui/core';\n\nexport const SettingsModal = ({\n open,\n close,\n componentName,\n children,\n}: {\n open: boolean;\n close: Function;\n componentName: string;\n children: JSX.Element;\n}) => {\n return (\n <Dialog open={open} onClose={() => close()}>\n <DialogTitle>Settings - {componentName}</DialogTitle>\n <DialogContent>{children}</DialogContent>\n <DialogActions>\n <Button onClick={() => close()} color=\"primary\" variant=\"contained\">\n Close\n </Button>\n </DialogActions>\n </Dialog>\n );\n};\n","/*\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 from 'react';\nimport { HeaderLabel } from '@backstage/core-components';\n\nconst timeFormat: Intl.DateTimeFormatOptions = {\n hour: '2-digit',\n minute: '2-digit',\n};\n\ntype TimeObj = {\n time: string;\n label: string;\n};\n\nexport type ClockConfig = {\n label: string;\n timeZone: string;\n};\n\nfunction getTimes(clockConfigs: ClockConfig[]) {\n const d = new Date();\n const lang = window.navigator.language;\n\n const clocks: TimeObj[] = [];\n\n if (!clockConfigs) {\n return clocks;\n }\n\n for (const clockConfig of clockConfigs) {\n let label = clockConfig.label;\n\n const options: Intl.DateTimeFormatOptions = {\n timeZone: clockConfig.timeZone,\n ...timeFormat,\n };\n\n try {\n new Date().toLocaleString(lang, options);\n } catch (e) {\n // eslint-disable-next-line no-console\n console.warn(\n `The timezone ${options.timeZone} is invalid. Defaulting to GMT`,\n );\n options.timeZone = 'GMT';\n label = 'GMT';\n }\n\n const time = d.toLocaleTimeString(lang, options);\n clocks.push({ time, label });\n }\n\n return clocks;\n}\n\nexport const HeaderWorldClock = ({\n clockConfigs,\n}: {\n clockConfigs: ClockConfig[];\n}) => {\n const defaultTimes: TimeObj[] = [];\n const [clocks, setTimes] = React.useState(defaultTimes);\n\n React.useEffect(() => {\n setTimes(getTimes(clockConfigs));\n\n const intervalId = setInterval(() => {\n setTimes(getTimes(clockConfigs));\n }, 1000);\n\n return () => {\n clearInterval(intervalId);\n };\n }, [clockConfigs]);\n\n if (clocks.length !== 0) {\n return (\n <>\n {clocks.map(clock => (\n <HeaderLabel\n label={clock.label}\n value={clock.time}\n key={clock.label}\n />\n ))}\n </>\n );\n }\n return null;\n};\n","/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React, { Suspense } from 'react';\nimport { IconButton } from '@material-ui/core';\nimport SettingsIcon from '@material-ui/icons/Settings';\nimport { InfoCard } from '@backstage/core-components';\nimport { SettingsModal } from './components';\nimport { createReactExtension, useApp } from '@backstage/core-plugin-api';\n\nexport type ComponentRenderer = {\n Renderer?: (props: RendererProps) => JSX.Element;\n};\n\ntype ComponentParts = {\n Content: () => JSX.Element;\n Actions?: () => JSX.Element;\n Settings?: () => JSX.Element;\n ContextProvider?: (props: any) => JSX.Element;\n};\n\ntype RendererProps = { title: string } & ComponentParts;\n\nexport function createCardExtension<T>({\n title,\n components,\n name,\n}: {\n title: string;\n components: () => Promise<ComponentParts>;\n name?: string;\n}) {\n return createReactExtension({\n name,\n component: {\n lazy: () =>\n components().then(({ Content, Actions, Settings, ContextProvider }) => {\n const CardExtension = ({\n Renderer,\n title: overrideTitle,\n ...childProps\n }: ComponentRenderer & { title?: string } & T) => {\n const app = useApp();\n const { Progress } = app.getComponents();\n const [settingsOpen, setSettingsOpen] = React.useState(false);\n\n if (Renderer) {\n return (\n <Suspense fallback={<Progress />}>\n <Renderer\n title={overrideTitle || title}\n {...{\n Content,\n ...(Actions ? { Actions } : {}),\n ...(Settings ? { Settings } : {}),\n ...(ContextProvider ? { ContextProvider } : {}),\n ...childProps,\n }}\n />\n </Suspense>\n );\n }\n\n const cardProps = {\n title: overrideTitle ?? title,\n ...(Settings\n ? {\n action: (\n <IconButton onClick={() => setSettingsOpen(true)}>\n <SettingsIcon>Settings</SettingsIcon>\n </IconButton>\n ),\n }\n : {}),\n ...(Actions\n ? {\n actions: <Actions />,\n }\n : {}),\n };\n\n const innerContent = (\n <InfoCard {...cardProps}>\n {Settings && (\n <SettingsModal\n open={settingsOpen}\n componentName={title}\n close={() => setSettingsOpen(false)}\n >\n <Settings />\n </SettingsModal>\n )}\n <Content />\n </InfoCard>\n );\n\n return (\n <Suspense fallback={<Progress />}>\n {ContextProvider ? (\n <ContextProvider {...childProps}>\n {innerContent}\n </ContextProvider>\n ) : (\n innerContent\n )}\n </Suspense>\n );\n };\n return CardExtension;\n }),\n },\n });\n}\n","/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { createRouteRef } from '@backstage/core-plugin-api';\n\nexport const rootRouteRef = createRouteRef({\n id: 'home',\n});\n","/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport {\n createComponentExtension,\n createPlugin,\n createRoutableExtension,\n} from '@backstage/core-plugin-api';\nimport { createCardExtension } from './extensions';\n\nimport { rootRouteRef } from './routes';\n\nexport const homePlugin = createPlugin({\n id: 'home',\n routes: {\n root: rootRouteRef,\n },\n});\n\nexport const HomepageCompositionRoot = homePlugin.provide(\n createRoutableExtension({\n name: 'HomepageCompositionRoot',\n component: () =>\n import('./components').then(m => m.HomepageCompositionRoot),\n mountPoint: rootRouteRef,\n }),\n);\n\nexport const ComponentAccordion = homePlugin.provide(\n createComponentExtension({\n name: 'ComponentAccordion',\n component: {\n lazy: () =>\n import('./componentRenderers').then(m => m.ComponentAccordion),\n },\n }),\n);\nexport const ComponentTabs = homePlugin.provide(\n createComponentExtension({\n name: 'ComponentTabs',\n component: {\n lazy: () => import('./componentRenderers').then(m => m.ComponentTabs),\n },\n }),\n);\nexport const ComponentTab = homePlugin.provide(\n createComponentExtension({\n name: 'ComponentTab',\n component: {\n lazy: () => import('./componentRenderers').then(m => m.ComponentTab),\n },\n }),\n);\n\n/**\n * A component to display a playful greeting for the user.\n *\n * @public\n */\nexport const WelcomeTitle = homePlugin.provide(\n createComponentExtension({\n name: 'WelcomeTitle',\n component: {\n lazy: () =>\n import('./homePageComponents/WelcomeTitle').then(m => m.WelcomeTitle),\n },\n }),\n);\n\nexport const HomePageRandomJoke = homePlugin.provide(\n createCardExtension<{ defaultCategory?: 'any' | 'programming' }>({\n name: 'HomePageRandomJoke',\n title: 'Random Joke',\n components: () => import('./homePageComponents/RandomJoke'),\n }),\n);\n"],"names":[],"mappings":";;;;;;;MAyBa,gBAAgB,CAAC;AAAA,EAC5B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,MAMI;AACJ,6CACG,QAAD;AAAA,IAAQ;AAAA,IAAY,SAAS,MAAM;AAAA,yCAChC,aAAD,MAAa,eAAY,oDACxB,eAAD,MAAgB,+CACf,eAAD,0CACG,QAAD;AAAA,IAAQ,SAAS,MAAM;AAAA,IAAS,OAAM;AAAA,IAAU,SAAQ;AAAA,KAAY;AAAA;;ACtB5E,MAAM,aAAyC;AAAA,EAC7C,MAAM;AAAA,EACN,QAAQ;AAAA;AAaV,kBAAkB,cAA6B;AAC7C,QAAM,IAAI,IAAI;AACd,QAAM,OAAO,OAAO,UAAU;AAE9B,QAAM,SAAoB;AAE1B,MAAI,CAAC,cAAc;AACjB,WAAO;AAAA;AAGT,aAAW,eAAe,cAAc;AACtC,QAAI,QAAQ,YAAY;AAExB,UAAM,UAAsC;AAAA,MAC1C,UAAU,YAAY;AAAA,SACnB;AAAA;AAGL,QAAI;AACF,UAAI,OAAO,eAAe,MAAM;AAAA,aACzB,GAAP;AAEA,cAAQ,KACN,gBAAgB,QAAQ;AAE1B,cAAQ,WAAW;AACnB,cAAQ;AAAA;AAGV,UAAM,OAAO,EAAE,mBAAmB,MAAM;AACxC,WAAO,KAAK,CAAE,MAAM;AAAA;AAGtB,SAAO;AAAA;MAGI,mBAAmB,CAAC;AAAA,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js","sources":["../src/components/SettingsModal.tsx","../src/components/HeaderWorldClock/HeaderWorldClock.tsx","../src/extensions.tsx","../src/routes.ts","../src/plugin.ts"],"sourcesContent":["/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React from 'react';\nimport {\n Button,\n Dialog,\n DialogActions,\n DialogContent,\n DialogTitle,\n} from '@material-ui/core';\n\nexport const SettingsModal = ({\n open,\n close,\n componentName,\n children,\n}: {\n open: boolean;\n close: Function;\n componentName: string;\n children: JSX.Element;\n}) => {\n return (\n <Dialog open={open} onClose={() => close()}>\n <DialogTitle>Settings - {componentName}</DialogTitle>\n <DialogContent>{children}</DialogContent>\n <DialogActions>\n <Button onClick={() => close()} color=\"primary\" variant=\"contained\">\n Close\n </Button>\n </DialogActions>\n </Dialog>\n );\n};\n","/*\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 from 'react';\nimport { HeaderLabel } from '@backstage/core-components';\n\nconst timeFormat: Intl.DateTimeFormatOptions = {\n hour: '2-digit',\n minute: '2-digit',\n};\n\ntype TimeObj = {\n time: string;\n label: string;\n};\n\nexport type ClockConfig = {\n label: string;\n timeZone: string;\n};\n\nfunction getTimes(clockConfigs: ClockConfig[]) {\n const d = new Date();\n const lang = window.navigator.language;\n\n const clocks: TimeObj[] = [];\n\n if (!clockConfigs) {\n return clocks;\n }\n\n for (const clockConfig of clockConfigs) {\n let label = clockConfig.label;\n\n const options: Intl.DateTimeFormatOptions = {\n timeZone: clockConfig.timeZone,\n ...timeFormat,\n };\n\n try {\n new Date().toLocaleString(lang, options);\n } catch (e) {\n // eslint-disable-next-line no-console\n console.warn(\n `The timezone ${options.timeZone} is invalid. Defaulting to GMT`,\n );\n options.timeZone = 'GMT';\n label = 'GMT';\n }\n\n const time = d.toLocaleTimeString(lang, options);\n clocks.push({ time, label });\n }\n\n return clocks;\n}\n\nexport const HeaderWorldClock = ({\n clockConfigs,\n}: {\n clockConfigs: ClockConfig[];\n}) => {\n const defaultTimes: TimeObj[] = [];\n const [clocks, setTimes] = React.useState(defaultTimes);\n\n React.useEffect(() => {\n setTimes(getTimes(clockConfigs));\n\n const intervalId = setInterval(() => {\n setTimes(getTimes(clockConfigs));\n }, 1000);\n\n return () => {\n clearInterval(intervalId);\n };\n }, [clockConfigs]);\n\n if (clocks.length !== 0) {\n return (\n <>\n {clocks.map(clock => (\n <HeaderLabel\n label={clock.label}\n value={clock.time}\n key={clock.label}\n />\n ))}\n </>\n );\n }\n return null;\n};\n","/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React, { Suspense } from 'react';\nimport { IconButton } from '@material-ui/core';\nimport SettingsIcon from '@material-ui/icons/Settings';\nimport { InfoCard } from '@backstage/core-components';\nimport { SettingsModal } from './components';\nimport { createReactExtension, useApp } from '@backstage/core-plugin-api';\n\nexport type ComponentRenderer = {\n Renderer?: (props: RendererProps) => JSX.Element;\n};\n\ntype ComponentParts = {\n Content: () => JSX.Element;\n Actions?: () => JSX.Element;\n Settings?: () => JSX.Element;\n ContextProvider?: (props: any) => JSX.Element;\n};\n\ntype RendererProps = { title: string } & ComponentParts;\n\nexport function createCardExtension<T>({\n title,\n components,\n name,\n}: {\n title: string;\n components: () => Promise<ComponentParts>;\n name?: string;\n}) {\n return createReactExtension({\n name,\n component: {\n lazy: () =>\n components().then(({ Content, Actions, Settings, ContextProvider }) => {\n const CardExtension = ({\n Renderer,\n title: overrideTitle,\n ...childProps\n }: ComponentRenderer & { title?: string } & T) => {\n const app = useApp();\n const { Progress } = app.getComponents();\n const [settingsOpen, setSettingsOpen] = React.useState(false);\n\n if (Renderer) {\n return (\n <Suspense fallback={<Progress />}>\n <Renderer\n title={overrideTitle || title}\n {...{\n Content,\n ...(Actions ? { Actions } : {}),\n ...(Settings ? { Settings } : {}),\n ...(ContextProvider ? { ContextProvider } : {}),\n ...childProps,\n }}\n />\n </Suspense>\n );\n }\n\n const cardProps = {\n title: overrideTitle ?? title,\n ...(Settings\n ? {\n action: (\n <IconButton onClick={() => setSettingsOpen(true)}>\n <SettingsIcon>Settings</SettingsIcon>\n </IconButton>\n ),\n }\n : {}),\n ...(Actions\n ? {\n actions: <Actions />,\n }\n : {}),\n };\n\n const innerContent = (\n <InfoCard {...cardProps}>\n {Settings && (\n <SettingsModal\n open={settingsOpen}\n componentName={title}\n close={() => setSettingsOpen(false)}\n >\n <Settings />\n </SettingsModal>\n )}\n <Content />\n </InfoCard>\n );\n\n return (\n <Suspense fallback={<Progress />}>\n {ContextProvider ? (\n <ContextProvider {...childProps}>\n {innerContent}\n </ContextProvider>\n ) : (\n innerContent\n )}\n </Suspense>\n );\n };\n return CardExtension;\n }),\n },\n });\n}\n","/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { createRouteRef } from '@backstage/core-plugin-api';\n\nexport const rootRouteRef = createRouteRef({\n id: 'home',\n});\n","/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport {\n createComponentExtension,\n createPlugin,\n createRoutableExtension,\n} from '@backstage/core-plugin-api';\nimport { createCardExtension } from './extensions';\n\nimport { rootRouteRef } from './routes';\n\nexport const homePlugin = createPlugin({\n id: 'home',\n routes: {\n root: rootRouteRef,\n },\n});\n\nexport const HomepageCompositionRoot = homePlugin.provide(\n createRoutableExtension({\n name: 'HomepageCompositionRoot',\n component: () =>\n import('./components').then(m => m.HomepageCompositionRoot),\n mountPoint: rootRouteRef,\n }),\n);\n\nexport const ComponentAccordion = homePlugin.provide(\n createComponentExtension({\n name: 'ComponentAccordion',\n component: {\n lazy: () =>\n import('./componentRenderers').then(m => m.ComponentAccordion),\n },\n }),\n);\nexport const ComponentTabs = homePlugin.provide(\n createComponentExtension({\n name: 'ComponentTabs',\n component: {\n lazy: () => import('./componentRenderers').then(m => m.ComponentTabs),\n },\n }),\n);\nexport const ComponentTab = homePlugin.provide(\n createComponentExtension({\n name: 'ComponentTab',\n component: {\n lazy: () => import('./componentRenderers').then(m => m.ComponentTab),\n },\n }),\n);\n\n/**\n * A component to display a playful greeting for the user.\n *\n * @public\n */\nexport const WelcomeTitle = homePlugin.provide(\n createComponentExtension({\n name: 'WelcomeTitle',\n component: {\n lazy: () =>\n import('./homePageComponents/WelcomeTitle').then(m => m.WelcomeTitle),\n },\n }),\n);\n\nexport const HomePageRandomJoke = homePlugin.provide(\n createCardExtension<{ defaultCategory?: 'any' | 'programming' }>({\n name: 'HomePageRandomJoke',\n title: 'Random Joke',\n components: () => import('./homePageComponents/RandomJoke'),\n }),\n);\n"],"names":[],"mappings":";;;;;;;MAyBa,gBAAgB,CAAC;AAAA,EAC5B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,MAMI;AACJ,6CACG,QAAD;AAAA,IAAQ;AAAA,IAAY,SAAS,MAAM;AAAA,yCAChC,aAAD,MAAa,eAAY,oDACxB,eAAD,MAAgB,+CACf,eAAD,0CACG,QAAD;AAAA,IAAQ,SAAS,MAAM;AAAA,IAAS,OAAM;AAAA,IAAU,SAAQ;AAAA,KAAY;AAAA;;ACtB5E,MAAM,aAAyC;AAAA,EAC7C,MAAM;AAAA,EACN,QAAQ;AAAA;AAaV,kBAAkB,cAA6B;AAC7C,QAAM,IAAI,IAAI;AACd,QAAM,OAAO,OAAO,UAAU;AAE9B,QAAM,SAAoB;AAE1B,MAAI,CAAC,cAAc;AACjB,WAAO;AAAA;AAGT,aAAW,eAAe,cAAc;AACtC,QAAI,QAAQ,YAAY;AAExB,UAAM,UAAsC;AAAA,MAC1C,UAAU,YAAY;AAAA,SACnB;AAAA;AAGL,QAAI;AACF,UAAI,OAAO,eAAe,MAAM;AAAA,aACzB,GAAP;AAEA,cAAQ,KACN,gBAAgB,QAAQ;AAE1B,cAAQ,WAAW;AACnB,cAAQ;AAAA;AAGV,UAAM,OAAO,EAAE,mBAAmB,MAAM;AACxC,WAAO,KAAK,EAAE,MAAM;AAAA;AAGtB,SAAO;AAAA;MAGI,mBAAmB,CAAC;AAAA,EAC/B;AAAA,MAGI;AACJ,QAAM,eAA0B;AAChC,QAAM,CAAC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
1
|
{
|
|
2
2
|
"name": "@backstage/plugin-home",
|
|
3
3
|
"description": "A Backstage plugin that helps you build a home page",
|
|
4
|
-
"version": "0.4.
|
|
4
|
+
"version": "0.4.7",
|
|
5
5
|
"main": "dist/index.esm.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"license": "Apache-2.0",
|
|
@@ -21,24 +21,25 @@
|
|
|
21
21
|
"clean": "backstage-cli clean"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@backstage/core-components": "^0.
|
|
25
|
-
"@backstage/core-plugin-api": "^0.
|
|
26
|
-
"@backstage/theme": "^0.2.
|
|
24
|
+
"@backstage/core-components": "^0.8.0",
|
|
25
|
+
"@backstage/core-plugin-api": "^0.3.0",
|
|
26
|
+
"@backstage/theme": "^0.2.14",
|
|
27
27
|
"@material-ui/core": "^4.12.2",
|
|
28
28
|
"@material-ui/icons": "^4.9.1",
|
|
29
29
|
"@material-ui/lab": "4.0.0-alpha.57",
|
|
30
|
-
"@types/react": "*",
|
|
31
30
|
"lodash": "^4.17.21",
|
|
32
|
-
"react": "^16.13.1",
|
|
33
|
-
"react-dom": "^16.13.1",
|
|
34
31
|
"react-router": "6.0.0-beta.0",
|
|
35
32
|
"react-use": "^17.2.4"
|
|
36
33
|
},
|
|
34
|
+
"peerDependencies": {
|
|
35
|
+
"@types/react": "^16.13.1 || ^17.0.0",
|
|
36
|
+
"react": "^16.13.1 || ^17.0.0"
|
|
37
|
+
},
|
|
37
38
|
"devDependencies": {
|
|
38
|
-
"@backstage/cli": "^0.
|
|
39
|
-
"@backstage/core-app-api": "^0.
|
|
40
|
-
"@backstage/dev-utils": "^0.2.
|
|
41
|
-
"@backstage/test-utils": "^0.1.
|
|
39
|
+
"@backstage/cli": "^0.10.1",
|
|
40
|
+
"@backstage/core-app-api": "^0.2.0",
|
|
41
|
+
"@backstage/dev-utils": "^0.2.14",
|
|
42
|
+
"@backstage/test-utils": "^0.1.24",
|
|
42
43
|
"@testing-library/jest-dom": "^5.10.1",
|
|
43
44
|
"@testing-library/react": "^11.2.5",
|
|
44
45
|
"@testing-library/user-event": "^13.1.8",
|
|
@@ -50,5 +51,5 @@
|
|
|
50
51
|
"files": [
|
|
51
52
|
"dist"
|
|
52
53
|
],
|
|
53
|
-
"gitHead": "
|
|
54
|
+
"gitHead": "562be0b43016294e27af3ad024191bb86b13b1c1"
|
|
54
55
|
}
|