@red-hat-developer-hub/backstage-plugin-global-floating-action-button 0.0.3 → 0.0.4
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 +6 -0
- package/README.md +57 -3
- package/dist/components/DynamicGlobalFloatingActionButton.esm.js +17 -0
- package/dist/components/DynamicGlobalFloatingActionButton.esm.js.map +1 -0
- package/dist/components/FAB.esm.js +15 -2
- package/dist/components/FAB.esm.js.map +1 -1
- package/dist/components/FABWithSubmenu.esm.js +1 -1
- package/dist/components/FABWithSubmenu.esm.js.map +1 -1
- package/dist/components/FloatingButton.esm.js +4 -4
- package/dist/components/FloatingButton.esm.js.map +1 -1
- package/dist/components/NullComponent.esm.js +7 -0
- package/dist/components/NullComponent.esm.js.map +1 -0
- package/dist/hooks/useFabMountPoints.esm.js +10 -0
- package/dist/hooks/useFabMountPoints.esm.js.map +1 -0
- package/dist/index.d.ts +27 -1
- package/dist/index.esm.js +1 -1
- package/dist/plugin.esm.js +22 -1
- package/dist/plugin.esm.js.map +1 -1
- package/dist/types.esm.js.map +1 -1
- package/package.json +3 -1
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -10,7 +10,59 @@ This plugin has been added to the example app in this workspace, meaning it can
|
|
|
10
10
|
|
|
11
11
|
### Installation
|
|
12
12
|
|
|
13
|
-
####
|
|
13
|
+
#### Installing as a dynamic plugin?
|
|
14
|
+
|
|
15
|
+
The sections below are relevant for static plugins. If the plugin is expected to be installed as a dynamic one:
|
|
16
|
+
|
|
17
|
+
- Follow https://github.com/redhat-developer/rhdh/blob/main/docs/dynamic-plugins/installing-plugins.md
|
|
18
|
+
- Add content of `app-config.dynamic.yaml` into `app-config.local.yaml`.
|
|
19
|
+
- To configure a plugin as a Floating Action Button (FAB), you need to specify the `global.floatingactionbutton/component` mount point in your plugin configuration, as shown below using the bulk-import plugin as an example:
|
|
20
|
+
|
|
21
|
+
```yaml
|
|
22
|
+
dynamicPlugins:
|
|
23
|
+
frontend:
|
|
24
|
+
red-hat-developer-hub.backstage-plugin-bulk-import:
|
|
25
|
+
# start of fab config
|
|
26
|
+
mountPoints:
|
|
27
|
+
- mountPoint: global.floatingactionbutton/component
|
|
28
|
+
importName: BulkImportPage # It is necessary to specify an importName because mount point without an associated component is not allowed.
|
|
29
|
+
config:
|
|
30
|
+
slot: 'page-end'
|
|
31
|
+
icon: bulkImportIcon
|
|
32
|
+
label: 'Bulk import'
|
|
33
|
+
toolTip: 'Register multiple repositories in bulk'
|
|
34
|
+
to: /bulk-import/repositories
|
|
35
|
+
# end of fab config
|
|
36
|
+
appIcons:
|
|
37
|
+
- name: bulkImportIcon
|
|
38
|
+
importName: BulkImportIcon
|
|
39
|
+
dynamicRoutes:
|
|
40
|
+
- path: /bulk-import/repositories
|
|
41
|
+
importName: BulkImportPage
|
|
42
|
+
menuItem:
|
|
43
|
+
icon: bulkImportIcon
|
|
44
|
+
text: Bulk import
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
- To configure a Floating Action Button (FAB) that opens an external link, specify the `global.floatingactionbutton/component` mount point in the `backstage-plugin-global-floating-action-button` plugin, as shown below:
|
|
48
|
+
|
|
49
|
+
```yaml
|
|
50
|
+
dynamicPlugins:
|
|
51
|
+
frontend:
|
|
52
|
+
red-hat-developer-hub.backstage-plugin-global-floating-action-button:
|
|
53
|
+
mountPoints:
|
|
54
|
+
- mountPoint: application/listener
|
|
55
|
+
importName: DynamicGlobalFloatingActionButton
|
|
56
|
+
- mountPoint: global.floatingactionbutton/component
|
|
57
|
+
importName: NullComponent # It is necessary to specify an importName because mount point without an associated component is not allowed.
|
|
58
|
+
config:
|
|
59
|
+
icon: github
|
|
60
|
+
label: 'Git'
|
|
61
|
+
toolTip: 'Github'
|
|
62
|
+
to: https://github.com/redhat-developer/rhdh-plugins
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
#### Static Installation
|
|
14
66
|
|
|
15
67
|
1. Install the Global floating action button plugin using the following command:
|
|
16
68
|
|
|
@@ -29,7 +81,8 @@ This plugin has been added to the example app in this workspace, meaning it can
|
|
|
29
81
|
|
|
30
82
|
export const Root = ({ children }: PropsWithChildren<{}>) => (
|
|
31
83
|
<SidebarPage>
|
|
32
|
-
|
|
84
|
+
{/* ... */}
|
|
85
|
+
{/* highlight-add-start */}
|
|
33
86
|
<GlobalFloatingActionButton
|
|
34
87
|
floatingButtons={[
|
|
35
88
|
{
|
|
@@ -48,7 +101,8 @@ This plugin has been added to the example app in this workspace, meaning it can
|
|
|
48
101
|
},
|
|
49
102
|
]}
|
|
50
103
|
/>
|
|
51
|
-
/* highlight-add-end */
|
|
104
|
+
{/* highlight-add-end */}
|
|
105
|
+
{/* ... */}
|
|
52
106
|
</SidebarPage>
|
|
53
107
|
);
|
|
54
108
|
```
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React__default from 'react';
|
|
2
|
+
import { useFabMountPoints } from '../hooks/useFabMountPoints.esm.js';
|
|
3
|
+
import { GlobalFloatingActionButton } from './GlobalFloatingActionButton.esm.js';
|
|
4
|
+
|
|
5
|
+
const DynamicGlobalFloatingActionButton = () => {
|
|
6
|
+
const allFabMountPoints = useFabMountPoints();
|
|
7
|
+
const floatingButtons = (allFabMountPoints || []).map(
|
|
8
|
+
(fab) => fab?.config
|
|
9
|
+
);
|
|
10
|
+
if (floatingButtons?.length === 0) {
|
|
11
|
+
return null;
|
|
12
|
+
}
|
|
13
|
+
return /* @__PURE__ */ React__default.createElement(GlobalFloatingActionButton, { floatingButtons });
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export { DynamicGlobalFloatingActionButton };
|
|
17
|
+
//# sourceMappingURL=DynamicGlobalFloatingActionButton.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DynamicGlobalFloatingActionButton.esm.js","sources":["../../src/components/DynamicGlobalFloatingActionButton.tsx"],"sourcesContent":["/*\n * Copyright Red Hat, Inc.\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 { useFabMountPoints } from '../hooks/useFabMountPoints';\nimport { GlobalFloatingActionButton } from './GlobalFloatingActionButton';\nimport { FloatingActionButton } from '../types';\n\n/**\n * Dynamic Global Floating Action Button\n *\n * @public\n */\nexport const DynamicGlobalFloatingActionButton = () => {\n const allFabMountPoints = useFabMountPoints();\n\n const floatingButtons = (allFabMountPoints || []).map(\n fab => fab?.config,\n ) as FloatingActionButton[];\n\n if (floatingButtons?.length === 0) {\n return null;\n }\n\n return <GlobalFloatingActionButton floatingButtons={floatingButtons} />;\n};\n"],"names":["React"],"mappings":";;;;AA2BO,MAAM,oCAAoC,MAAM;AACrD,EAAA,MAAM,oBAAoB,iBAAkB,EAAA;AAE5C,EAAM,MAAA,eAAA,GAAA,CAAmB,iBAAqB,IAAA,EAAI,EAAA,GAAA;AAAA,IAChD,SAAO,GAAK,EAAA;AAAA,GACd;AAEA,EAAI,IAAA,eAAA,EAAiB,WAAW,CAAG,EAAA;AACjC,IAAO,OAAA,IAAA;AAAA;AAGT,EAAO,uBAAAA,cAAA,CAAA,aAAA,CAAC,8BAA2B,eAAkC,EAAA,CAAA;AACvE;;;;"}
|
|
@@ -49,7 +49,20 @@ const FAB = ({
|
|
|
49
49
|
const isExternal = isExternalUri(actionButton.to);
|
|
50
50
|
const newWindow = isExternal && !!/^https?:/.exec(actionButton.to);
|
|
51
51
|
const navigateTo = () => actionButton.to && !isExternal ? navigate(actionButton.to) : "";
|
|
52
|
-
|
|
52
|
+
if (!actionButton.label) {
|
|
53
|
+
console.warn(
|
|
54
|
+
"Label is missing from your FAB component. A label is required for the aria-label attribute.",
|
|
55
|
+
actionButton
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
const labelText = (actionButton.label || "").length > 20 ? `${actionButton.label.slice(0, actionButton.label.length)}...` : actionButton.label;
|
|
59
|
+
if (!actionButton.icon) {
|
|
60
|
+
console.warn(
|
|
61
|
+
"Icon is missing from your FAB component. An icon is required to render a FAB button.",
|
|
62
|
+
actionButton
|
|
63
|
+
);
|
|
64
|
+
return null;
|
|
65
|
+
}
|
|
53
66
|
const getColor = () => {
|
|
54
67
|
if (actionButton.color) {
|
|
55
68
|
return actionButton.color;
|
|
@@ -75,7 +88,7 @@ const FAB = ({
|
|
|
75
88
|
size: size || actionButton.size || "medium",
|
|
76
89
|
color: getColor(),
|
|
77
90
|
"aria-label": actionButton.label,
|
|
78
|
-
"data-testid": actionButton.label.replace(" ", "-").toLocaleLowerCase("en-US"),
|
|
91
|
+
"data-testid": (actionButton.label || "").replace(" ", "-").toLocaleLowerCase("en-US"),
|
|
79
92
|
onClick: actionButton.onClick || navigateTo,
|
|
80
93
|
...isExternal ? { href: actionButton.to } : {}
|
|
81
94
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FAB.esm.js","sources":["../../src/components/FAB.tsx"],"sourcesContent":["/*\n * Copyright Red Hat, Inc.\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 * as React from 'react';\nimport { useNavigate } from 'react-router-dom';\nimport { makeStyles } from '@mui/styles';\nimport Fab from '@mui/material/Fab';\nimport Tooltip from '@mui/material/Tooltip';\nimport Typography from '@mui/material/Typography';\nimport OpenInNewIcon from '@mui/icons-material/OpenInNew';\nimport { FabIcon } from './FabIcon';\nimport { FloatingActionButton, Slot } from '../types';\nimport { slotOptions } from '../utils';\n\nconst useStyles = makeStyles(() => ({\n openInNew: { paddingBottom: '5px', paddingTop: '3px' },\n}));\n\nconst FABLabel = ({\n label,\n slot,\n showExternalIcon,\n icon,\n order,\n}: {\n label: string;\n slot: Slot;\n showExternalIcon: boolean;\n icon: string | React.ReactElement;\n order: { externalIcon?: number; icon?: number };\n}) => {\n const styles = useStyles();\n const marginStyle = slotOptions[slot].margin;\n return (\n <Typography sx={{ display: 'flex' }}>\n {showExternalIcon && (\n <OpenInNewIcon\n className={styles.openInNew}\n sx={{ ...marginStyle, order: order.externalIcon }}\n />\n )}\n {label && (\n <Typography\n sx={{\n ...marginStyle,\n color: '#151515',\n order: 2,\n }}\n >\n {label}\n </Typography>\n )}\n <Typography sx={{ mb: -1, order: order.icon }}>\n <FabIcon icon={icon} />\n </Typography>\n </Typography>\n );\n};\n\nexport const FAB = ({\n actionButton,\n size,\n className,\n}: {\n actionButton: FloatingActionButton;\n size?: 'small' | 'medium' | 'large';\n className?: string;\n}) => {\n const navigate = useNavigate();\n const isExternalUri = (uri: string) => /^([a-z+.-]+):/.test(uri);\n const isExternal = isExternalUri(actionButton.to!);\n const newWindow = isExternal && !!/^https?:/.exec(actionButton.to!);\n const navigateTo = () =>\n actionButton.to && !isExternal ? navigate(actionButton.to) : '';\n const labelText =\n actionButton.label.length > 20\n ? `${actionButton.label.slice(0, actionButton.label.length)}...`\n : actionButton.label;\n const getColor = () => {\n if (actionButton.color) {\n return actionButton.color;\n }\n if (!className) {\n return 'info';\n }\n return undefined;\n };\n\n const displayOnRight =\n actionButton.slot === Slot.PAGE_END || !actionButton.slot;\n\n return (\n <Tooltip\n title={actionButton.toolTip}\n placement={\n slotOptions[actionButton.slot || Slot.PAGE_END].tooltipDirection\n }\n >\n <div className={className}>\n <Fab\n {...(newWindow ? { target: '_blank', rel: 'noopener' } : {})}\n style={{ color: '#1f1f1f' }}\n variant={\n actionButton.showLabel || isExternal ? 'extended' : 'circular'\n }\n size={size || actionButton.size || 'medium'}\n color={getColor()}\n aria-label={actionButton.label}\n data-testid={actionButton.label\n .replace(' ', '-')\n .toLocaleLowerCase('en-US')}\n onClick={actionButton.onClick || navigateTo}\n {...(isExternal ? { href: actionButton.to } : {})}\n >\n <FABLabel\n showExternalIcon={isExternal}\n icon={actionButton.icon}\n label={actionButton.showLabel ? labelText : ''}\n order={\n displayOnRight\n ? { externalIcon: isExternal ? 1 : -1, icon: 3 }\n : { externalIcon: isExternal ? 3 : -1, icon: 1 }\n }\n slot={actionButton.slot || Slot.PAGE_END}\n />\n </Fab>\n </div>\n </Tooltip>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;AA2BA,MAAM,SAAA,GAAY,WAAW,OAAO;AAAA,EAClC,SAAW,EAAA,EAAE,aAAe,EAAA,KAAA,EAAO,YAAY,KAAM;AACvD,CAAE,CAAA,CAAA;AAEF,MAAM,WAAW,CAAC;AAAA,EAChB,KAAA;AAAA,EACA,IAAA;AAAA,EACA,gBAAA;AAAA,EACA,IAAA;AAAA,EACA;AACF,CAMM,KAAA;AACJ,EAAA,MAAM,SAAS,SAAU,EAAA;AACzB,EAAM,MAAA,WAAA,GAAc,WAAY,CAAA,IAAI,CAAE,CAAA,MAAA;AACtC,EAAA,2CACG,UAAW,EAAA,EAAA,EAAA,EAAI,EAAE,OAAS,EAAA,MAAA,MACxB,gBACC,oBAAA,KAAA,CAAA,aAAA;AAAA,IAAC,aAAA;AAAA,IAAA;AAAA,MACC,WAAW,MAAO,CAAA,SAAA;AAAA,MAClB,IAAI,EAAE,GAAG,WAAa,EAAA,KAAA,EAAO,MAAM,YAAa;AAAA;AAAA,KAGnD,KACC,oBAAA,KAAA,CAAA,aAAA;AAAA,IAAC,UAAA;AAAA,IAAA;AAAA,MACC,EAAI,EAAA;AAAA,QACF,GAAG,WAAA;AAAA,QACH,KAAO,EAAA,SAAA;AAAA,QACP,KAAO,EAAA;AAAA;AACT,KAAA;AAAA,IAEC;AAAA,GAGL,kBAAA,KAAA,CAAA,aAAA,CAAC,UAAW,EAAA,EAAA,EAAA,EAAI,EAAE,EAAI,EAAA,CAAA,CAAA,EAAI,KAAO,EAAA,KAAA,CAAM,MACrC,EAAA,kBAAA,KAAA,CAAA,aAAA,CAAC,OAAQ,EAAA,EAAA,IAAA,EAAY,CACvB,CACF,CAAA;AAEJ,CAAA;AAEO,MAAM,MAAM,CAAC;AAAA,EAClB,YAAA;AAAA,EACA,IAAA;AAAA,EACA;AACF,CAIM,KAAA;AACJ,EAAA,MAAM,WAAW,WAAY,EAAA;AAC7B,EAAA,MAAM,aAAgB,GAAA,CAAC,GAAgB,KAAA,eAAA,CAAgB,KAAK,GAAG,CAAA;AAC/D,EAAM,MAAA,UAAA,GAAa,aAAc,CAAA,YAAA,CAAa,EAAG,CAAA;AACjD,EAAA,MAAM,YAAY,UAAc,IAAA,CAAC,CAAC,UAAW,CAAA,IAAA,CAAK,aAAa,EAAG,CAAA;AAClE,EAAM,MAAA,UAAA,GAAa,MACjB,YAAa,CAAA,EAAA,IAAM,CAAC,UAAa,GAAA,QAAA,CAAS,YAAa,CAAA,EAAE,CAAI,GAAA,EAAA;
|
|
1
|
+
{"version":3,"file":"FAB.esm.js","sources":["../../src/components/FAB.tsx"],"sourcesContent":["/*\n * Copyright Red Hat, Inc.\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 * as React from 'react';\nimport { useNavigate } from 'react-router-dom';\nimport { makeStyles } from '@mui/styles';\nimport Fab from '@mui/material/Fab';\nimport Tooltip from '@mui/material/Tooltip';\nimport Typography from '@mui/material/Typography';\nimport OpenInNewIcon from '@mui/icons-material/OpenInNew';\nimport { FabIcon } from './FabIcon';\nimport { FloatingActionButton, Slot } from '../types';\nimport { slotOptions } from '../utils';\n\nconst useStyles = makeStyles(() => ({\n openInNew: { paddingBottom: '5px', paddingTop: '3px' },\n}));\n\nconst FABLabel = ({\n label,\n slot,\n showExternalIcon,\n icon,\n order,\n}: {\n label: string;\n slot: Slot;\n showExternalIcon: boolean;\n icon: string | React.ReactElement;\n order: { externalIcon?: number; icon?: number };\n}) => {\n const styles = useStyles();\n const marginStyle = slotOptions[slot].margin;\n return (\n <Typography sx={{ display: 'flex' }}>\n {showExternalIcon && (\n <OpenInNewIcon\n className={styles.openInNew}\n sx={{ ...marginStyle, order: order.externalIcon }}\n />\n )}\n {label && (\n <Typography\n sx={{\n ...marginStyle,\n color: '#151515',\n order: 2,\n }}\n >\n {label}\n </Typography>\n )}\n <Typography sx={{ mb: -1, order: order.icon }}>\n <FabIcon icon={icon} />\n </Typography>\n </Typography>\n );\n};\n\nexport const FAB = ({\n actionButton,\n size,\n className,\n}: {\n actionButton: FloatingActionButton;\n size?: 'small' | 'medium' | 'large';\n className?: string;\n}) => {\n const navigate = useNavigate();\n const isExternalUri = (uri: string) => /^([a-z+.-]+):/.test(uri);\n const isExternal = isExternalUri(actionButton.to!);\n const newWindow = isExternal && !!/^https?:/.exec(actionButton.to!);\n const navigateTo = () =>\n actionButton.to && !isExternal ? navigate(actionButton.to) : '';\n\n if (!actionButton.label) {\n // eslint-disable-next-line no-console\n console.warn(\n 'Label is missing from your FAB component. A label is required for the aria-label attribute.',\n actionButton,\n );\n }\n\n const labelText =\n (actionButton.label || '').length > 20\n ? `${actionButton.label.slice(0, actionButton.label.length)}...`\n : actionButton.label;\n\n if (!actionButton.icon) {\n // eslint-disable-next-line no-console\n console.warn(\n 'Icon is missing from your FAB component. An icon is required to render a FAB button.',\n actionButton,\n );\n return null;\n }\n\n const getColor = () => {\n if (actionButton.color) {\n return actionButton.color;\n }\n if (!className) {\n return 'info';\n }\n return undefined;\n };\n\n const displayOnRight =\n actionButton.slot === Slot.PAGE_END || !actionButton.slot;\n\n return (\n <Tooltip\n title={actionButton.toolTip}\n placement={\n slotOptions[actionButton.slot || Slot.PAGE_END].tooltipDirection\n }\n >\n <div className={className}>\n <Fab\n {...(newWindow ? { target: '_blank', rel: 'noopener' } : {})}\n style={{ color: '#1f1f1f' }}\n variant={\n actionButton.showLabel || isExternal ? 'extended' : 'circular'\n }\n size={size || actionButton.size || 'medium'}\n color={getColor()}\n aria-label={actionButton.label}\n data-testid={(actionButton.label || '')\n .replace(' ', '-')\n .toLocaleLowerCase('en-US')}\n onClick={actionButton.onClick || navigateTo}\n {...(isExternal ? { href: actionButton.to } : {})}\n >\n <FABLabel\n showExternalIcon={isExternal}\n icon={actionButton.icon}\n label={actionButton.showLabel ? labelText : ''}\n order={\n displayOnRight\n ? { externalIcon: isExternal ? 1 : -1, icon: 3 }\n : { externalIcon: isExternal ? 3 : -1, icon: 1 }\n }\n slot={actionButton.slot || Slot.PAGE_END}\n />\n </Fab>\n </div>\n </Tooltip>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;AA2BA,MAAM,SAAA,GAAY,WAAW,OAAO;AAAA,EAClC,SAAW,EAAA,EAAE,aAAe,EAAA,KAAA,EAAO,YAAY,KAAM;AACvD,CAAE,CAAA,CAAA;AAEF,MAAM,WAAW,CAAC;AAAA,EAChB,KAAA;AAAA,EACA,IAAA;AAAA,EACA,gBAAA;AAAA,EACA,IAAA;AAAA,EACA;AACF,CAMM,KAAA;AACJ,EAAA,MAAM,SAAS,SAAU,EAAA;AACzB,EAAM,MAAA,WAAA,GAAc,WAAY,CAAA,IAAI,CAAE,CAAA,MAAA;AACtC,EAAA,2CACG,UAAW,EAAA,EAAA,EAAA,EAAI,EAAE,OAAS,EAAA,MAAA,MACxB,gBACC,oBAAA,KAAA,CAAA,aAAA;AAAA,IAAC,aAAA;AAAA,IAAA;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AA,QACzB,aAAA,EAAA,CAAc,aAAa,KAAS,IAAA,EAAA,EACjC,QAAQ,GAAK,EAAA,GAAG,CAChB,CAAA,iBAAA,CAAkB,OAAO,CAAA;AAAA,QAC5B,OAAA,EAAS,aAAa,OAAW,IAAA,UAAA;AAAA,QAChC,GAAI,UAAa,GAAA,EAAE,MAAM,YAAa,CAAA,EAAA,KAAO;AAAC,OAAA;AAAA,sBAE/C,KAAA,CAAA,aAAA;AAAA,QAAC,QAAA;AAAA,QAAA;AAAA,UACC,gBAAkB,EAAA,UAAA;AAAA,UAClB,MAAM,YAAa,CAAA,IAAA;AAAA,UACnB,KAAA,EAAO,YAAa,CAAA,SAAA,GAAY,SAAY,GAAA,EAAA;AAAA,UAC5C,OACE,cACI,GAAA,EAAE,YAAc,EAAA,UAAA,GAAa,IAAI,CAAI,CAAA,EAAA,IAAA,EAAM,CAAE,EAAA,GAC7C,EAAE,YAAc,EAAA,UAAA,GAAa,CAAI,GAAA,CAAA,CAAA,EAAI,MAAM,CAAE,EAAA;AAAA,UAEnD,IAAA,EAAM,YAAa,CAAA,IAAA,IAAQ,IAAK,CAAA;AAAA;AAAA;AAClC,KAEJ;AAAA,GACF;AAEJ;;;;"}
|
|
@@ -13,7 +13,7 @@ import { slotOptions } from '../utils.esm.js';
|
|
|
13
13
|
const useStyles = makeStyles((theme) => ({
|
|
14
14
|
button: {
|
|
15
15
|
paddingTop: "10px",
|
|
16
|
-
color: theme.palette.grey[500]
|
|
16
|
+
color: theme && Object.keys(theme).length > 0 ? theme.palette.grey[500] : "#9e9e9e"
|
|
17
17
|
},
|
|
18
18
|
menuButtonStyle: {
|
|
19
19
|
color: "#1f1f1f"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FABWithSubmenu.esm.js","sources":["../../src/components/FABWithSubmenu.tsx"],"sourcesContent":["/*\n * Copyright Red Hat, Inc.\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 * as React from 'react';\nimport { useLocation } from 'react-router-dom';\nimport { makeStyles } from '@mui/styles';\nimport Fab from '@mui/material/Fab';\nimport Tooltip from '@mui/material/Tooltip';\nimport { useTheme } from '@mui/material/styles';\nimport CloseIcon from '@mui/icons-material/Close';\nimport MenuIcon from '@mui/icons-material/Menu';\nimport Collapse from '@mui/material/Collapse';\nimport { FAB } from './FAB';\nimport { slotOptions } from '../utils';\nimport { FloatingActionButton, Slot } from '../types';\n\nconst useStyles = makeStyles(theme => ({\n button: {\n paddingTop: '10px',\n color
|
|
1
|
+
{"version":3,"file":"FABWithSubmenu.esm.js","sources":["../../src/components/FABWithSubmenu.tsx"],"sourcesContent":["/*\n * Copyright Red Hat, Inc.\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 * as React from 'react';\nimport { useLocation } from 'react-router-dom';\nimport { makeStyles } from '@mui/styles';\nimport Fab from '@mui/material/Fab';\nimport Tooltip from '@mui/material/Tooltip';\nimport { useTheme } from '@mui/material/styles';\nimport CloseIcon from '@mui/icons-material/Close';\nimport MenuIcon from '@mui/icons-material/Menu';\nimport Collapse from '@mui/material/Collapse';\nimport { FAB } from './FAB';\nimport { slotOptions } from '../utils';\nimport { FloatingActionButton, Slot } from '../types';\n\nconst useStyles = makeStyles(theme => ({\n button: {\n paddingTop: '10px',\n color:\n theme && Object.keys(theme).length > 0\n ? theme.palette.grey[500]\n : '#9e9e9e',\n },\n menuButtonStyle: {\n color: '#1f1f1f',\n },\n}));\n\nexport const FABWithSubmenu = ({\n fabs,\n slot,\n}: {\n fabs: FloatingActionButton[];\n slot: Slot;\n}) => {\n const styles = useStyles();\n const theme = useTheme();\n const { pathname } = useLocation();\n const [isMenuOpen, setIsMenuOpen] = React.useState(false);\n\n React.useEffect(() => {\n return () => {\n setIsMenuOpen(false);\n };\n }, [pathname]);\n\n const handleClick = () => {\n setIsMenuOpen(prev => !prev);\n };\n return (\n <>\n <Tooltip title=\"Menu\" placement={slotOptions[slot].tooltipDirection}>\n <Fab\n size=\"medium\"\n color=\"info\"\n onClick={handleClick}\n aria-label=\"Menu\"\n variant=\"circular\"\n data-testid=\"fab-with-submenu\"\n >\n {isMenuOpen ? (\n <CloseIcon className={styles.menuButtonStyle} />\n ) : (\n <MenuIcon className={styles.menuButtonStyle} />\n )}\n </Fab>\n </Tooltip>\n <Collapse\n style={{ textAlign: slotOptions[slot].textAlign }}\n in={isMenuOpen}\n mountOnEnter\n unmountOnExit\n orientation=\"vertical\"\n easing={{\n enter: theme.transitions.easing.easeOut,\n exit: theme.transitions.easing.sharp,\n }}\n >\n <>\n {fabs?.map(fb => {\n return (\n <FAB\n actionButton={fb}\n size=\"medium\"\n key={fb.label}\n className={styles.button}\n />\n );\n })}\n </>\n </Collapse>\n </>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;AA6BA,MAAM,SAAA,GAAY,WAAW,CAAU,KAAA,MAAA;AAAA,EACrC,MAAQ,EAAA;AAAA,IACN,UAAY,EAAA,MAAA;AAAA,IACZ,KACE,EAAA,KAAA,IAAS,MAAO,CAAA,IAAA,CAAK,KAAK,CAAA,CAAE,MAAS,GAAA,CAAA,GACjC,KAAM,CAAA,OAAA,CAAQ,IAAK,CAAA,GAAG,CACtB,GAAA;AAAA,GACR;AAAA,EACA,eAAiB,EAAA;AAAA,IACf,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,IAAC,QAAA;AAAA,IAAA;AAAA,MACC,OAAO,EAAE,SAAA,EAAW,WAAY,CAAA,IAAI,EAAE,SAAU,EAAA;AAAA,MAChD,EAAI,EAAA,UAAA;AAAA,MACJ,YAAY,EAAA,IAAA;AAAA,MACZ,aAAa,EAAA,IAAA;AAAA,MACb,WAAY,EAAA,UAAA;AAAA,MACZ,MAAQ,EAAA;AAAA,QACN,KAAA,EAAO,KAAM,CAAA,WAAA,CAAY,MAAO,CAAA,OAAA;AAAA,QAChC,IAAA,EAAM,KAAM,CAAA,WAAA,CAAY,MAAO,CAAA;AAAA;AACjC,KAAA;AAAA,oBAEA,KAAA,CAAA,aAAA,CAAA,KAAA,CAAA,QAAA,EAAA,IAAA,EACG,IAAM,EAAA,GAAA,CAAI,CAAM,EAAA,KAAA;AACf,MACE,uBAAA,KAAA,CAAA,aAAA;AAAA,QAAC,GAAA;AAAA,QAAA;AAAA,UACC,YAAc,EAAA,EAAA;AAAA,UACd,IAAK,EAAA,QAAA;AAAA,UACL,KAAK,EAAG,CAAA,KAAA;AAAA,UACR,WAAW,MAAO,CAAA;AAAA;AAAA,OACpB;AAAA,KAEH,CACH;AAAA,GAEJ,CAAA;AAEJ;;;;"}
|
|
@@ -14,13 +14,13 @@ const useStyles = makeStyles((theme) => ({
|
|
|
14
14
|
gap: "10px"
|
|
15
15
|
},
|
|
16
16
|
"page-end": {
|
|
17
|
-
bottom: theme.spacing(2),
|
|
18
|
-
right: theme.spacing(2),
|
|
17
|
+
bottom: theme && Object.keys(theme).length > 0 ? theme?.spacing(2) : "16px",
|
|
18
|
+
right: theme && Object.keys(theme).length > 0 ? theme?.spacing(2) : "16px",
|
|
19
19
|
alignItems: "end"
|
|
20
20
|
},
|
|
21
21
|
"bottom-left": {
|
|
22
|
-
bottom: theme.spacing(2),
|
|
23
|
-
paddingLeft: theme.spacing(2),
|
|
22
|
+
bottom: theme && Object.keys(theme).length > 0 ? theme?.spacing(2) : "16px",
|
|
23
|
+
paddingLeft: theme && Object.keys(theme).length > 0 ? theme?.spacing(2) : "16px",
|
|
24
24
|
alignItems: "start"
|
|
25
25
|
}
|
|
26
26
|
}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FloatingButton.esm.js","sources":["../../src/components/FloatingButton.tsx"],"sourcesContent":["/*\n * Copyright Red Hat, Inc.\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 * as React from 'react';\nimport { useLocation } from 'react-router-dom';\nimport classnames from 'classnames';\n\nimport { makeStyles } from '@mui/styles';\nimport { FABWithSubmenu } from './FABWithSubmenu';\nimport { FAB } from './FAB';\nimport { FloatingActionButton, Slot } from '../types';\nimport { filterAndSortButtons } from '../utils';\n\nconst useStyles = makeStyles(theme => ({\n fabContainer: {\n zIndex: 200,\n display: 'flex',\n position: 'fixed',\n gap: '10px',\n },\n 'page-end': {\n bottom: theme.spacing(2),\n right: theme.spacing(2),\n alignItems: 'end',\n },\n 'bottom-left': {\n bottom: theme.spacing(2),\n paddingLeft
|
|
1
|
+
{"version":3,"file":"FloatingButton.esm.js","sources":["../../src/components/FloatingButton.tsx"],"sourcesContent":["/*\n * Copyright Red Hat, Inc.\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 * as React from 'react';\nimport { useLocation } from 'react-router-dom';\nimport classnames from 'classnames';\n\nimport { makeStyles } from '@mui/styles';\nimport { FABWithSubmenu } from './FABWithSubmenu';\nimport { FAB } from './FAB';\nimport { FloatingActionButton, Slot } from '../types';\nimport { filterAndSortButtons } from '../utils';\n\nconst useStyles = makeStyles(theme => ({\n fabContainer: {\n zIndex: 200,\n display: 'flex',\n position: 'fixed',\n gap: '10px',\n },\n 'page-end': {\n bottom: theme && Object.keys(theme).length > 0 ? theme?.spacing(2) : '16px',\n right: theme && Object.keys(theme).length > 0 ? theme?.spacing(2) : '16px',\n alignItems: 'end',\n },\n 'bottom-left': {\n bottom: theme && Object.keys(theme).length > 0 ? theme?.spacing(2) : '16px',\n paddingLeft:\n theme && Object.keys(theme).length > 0 ? theme?.spacing(2) : '16px',\n alignItems: 'start',\n },\n}));\n\nexport const FloatingButton = ({\n floatingButtons,\n slot,\n}: {\n floatingButtons: FloatingActionButton[];\n slot: Slot;\n}) => {\n const { pathname } = useLocation();\n const [subMenuDirection, setSubMenuDirection] = React.useState<\n 'column' | 'column-reverse'\n >('column');\n const fabButton = useStyles();\n\n React.useEffect(() => {\n const floatingButtonElement = document.getElementById('floating-button');\n const screenHeight = window.innerHeight;\n if (floatingButtonElement) {\n const { top } = floatingButtonElement?.getBoundingClientRect();\n if (top < screenHeight / 2) {\n setSubMenuDirection('column');\n } else {\n setSubMenuDirection('column-reverse');\n }\n }\n }, [pathname]);\n\n const fabs = React.useMemo(\n () => filterAndSortButtons(floatingButtons, pathname),\n [floatingButtons, pathname],\n );\n\n if (fabs?.length === 0) {\n return null;\n }\n return (\n <div\n className={classnames(fabButton.fabContainer, fabButton[slot])}\n style={{\n flexDirection: subMenuDirection,\n }}\n id=\"floating-button\"\n data-testId=\"floating-button\"\n >\n {fabs.length > 1 ? (\n <FABWithSubmenu fabs={fabs} slot={slot} />\n ) : (\n <FAB actionButton={fabs[0]} />\n )}\n </div>\n );\n};\n"],"names":[],"mappings":";;;;;;;;AA0BA,MAAM,SA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cesContent":["/*\n * Copyright Red Hat, Inc.\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\n/**\n * Null Component\n *\n * Mount point without a component is not considered. So adding this that doesn't return anything.\n * @public\n */\n\nexport const NullComponent = () => {\n // eslint-disable-next-line no-console\n console.info('NullComponent rendered.');\n return null;\n};\n"],"names":[],"mappings":"AAuBO,MAAM,gBAAgB,MAAM;AAEjC,EAAA,OAAA,CAAQ,KAAK,yBAAyB,CAAA;AACtC,EAAO,OAAA,IAAA;AACT;;;;"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { useScalprum } from '@scalprum/react-core';
|
|
2
|
+
|
|
3
|
+
const useFabMountPoints = () => {
|
|
4
|
+
const scalprum = useScalprum();
|
|
5
|
+
const fabMountPoints = scalprum?.api?.dynamicRootConfig?.mountPoints?.["global.floatingactionbutton/component"];
|
|
6
|
+
return fabMountPoints;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export { useFabMountPoints };
|
|
10
|
+
//# sourceMappingURL=useFabMountPoints.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useFabMountPoints.esm.js","sources":["../../src/hooks/useFabMountPoints.ts"],"sourcesContent":["/*\n * Copyright Red Hat, Inc.\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 { useScalprum } from '@scalprum/react-core';\n\nimport { FABMountPoint } from '../types';\n\ninterface ScalprumState {\n api?: {\n dynamicRootConfig?: {\n mountPoints?: {\n 'global.floatingactionbutton/component': FABMountPoint[];\n };\n };\n };\n}\n\nexport const useFabMountPoints = (): FABMountPoint[] | undefined => {\n const scalprum = useScalprum<ScalprumState>();\n const fabMountPoints =\n scalprum?.api?.dynamicRootConfig?.mountPoints?.[\n 'global.floatingactionbutton/component'\n ];\n\n return fabMountPoints;\n};\n"],"names":[],"mappings":";;AA8BO,MAAM,oBAAoB,MAAmC;AAClE,EAAA,MAAM,WAAW,WAA2B,EAAA;AAC5C,EAAA,MAAM,cACJ,GAAA,QAAA,EAAU,GAAK,EAAA,iBAAA,EAAmB,cAChC,uCACF,CAAA;AAEF,EAAO,OAAA,cAAA;AACT;;;;"}
|
package/dist/index.d.ts
CHANGED
|
@@ -45,6 +45,14 @@ type FloatingActionButtonWithPositions = Array<{
|
|
|
45
45
|
slot: Slot;
|
|
46
46
|
actions: FloatingActionButton[];
|
|
47
47
|
}>;
|
|
48
|
+
/**
|
|
49
|
+
* FAB Mount Point
|
|
50
|
+
*
|
|
51
|
+
* @public
|
|
52
|
+
*/
|
|
53
|
+
type FABMountPoint = {
|
|
54
|
+
config?: FloatingActionButton;
|
|
55
|
+
};
|
|
48
56
|
|
|
49
57
|
/**
|
|
50
58
|
* Global Floating Action Button Plugin
|
|
@@ -52,6 +60,12 @@ type FloatingActionButtonWithPositions = Array<{
|
|
|
52
60
|
* @public
|
|
53
61
|
*/
|
|
54
62
|
declare const globalFloatingActionButtonPlugin: _backstage_core_plugin_api.BackstagePlugin<{}, {}, {}>;
|
|
63
|
+
/**
|
|
64
|
+
* Dynamic Global Floating Action Button Plugin
|
|
65
|
+
*
|
|
66
|
+
* @public
|
|
67
|
+
*/
|
|
68
|
+
declare const dynamicGlobalFloatingActionButtonPlugin: _backstage_core_plugin_api.BackstagePlugin<{}, {}, {}>;
|
|
55
69
|
/**
|
|
56
70
|
* Global Floating Action Button
|
|
57
71
|
*
|
|
@@ -60,5 +74,17 @@ declare const globalFloatingActionButtonPlugin: _backstage_core_plugin_api.Backs
|
|
|
60
74
|
declare const GlobalFloatingActionButton: ({ floatingButtons, }: {
|
|
61
75
|
floatingButtons: FloatingActionButton[];
|
|
62
76
|
}) => react.JSX.Element;
|
|
77
|
+
/**
|
|
78
|
+
* Dynamic Global Floating Action Button
|
|
79
|
+
*
|
|
80
|
+
* @public
|
|
81
|
+
*/
|
|
82
|
+
declare const DynamicGlobalFloatingActionButton: React.ComponentType;
|
|
83
|
+
/**
|
|
84
|
+
* Null Component
|
|
85
|
+
*
|
|
86
|
+
* @public
|
|
87
|
+
*/
|
|
88
|
+
declare const NullComponent: React.ComponentType;
|
|
63
89
|
|
|
64
|
-
export { type FloatingActionButton, type FloatingActionButtonWithPositions, GlobalFloatingActionButton, Slot, globalFloatingActionButtonPlugin };
|
|
90
|
+
export { DynamicGlobalFloatingActionButton, type FABMountPoint, type FloatingActionButton, type FloatingActionButtonWithPositions, GlobalFloatingActionButton, NullComponent, Slot, dynamicGlobalFloatingActionButtonPlugin, globalFloatingActionButtonPlugin };
|
package/dist/index.esm.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { GlobalFloatingActionButton, globalFloatingActionButtonPlugin } from './plugin.esm.js';
|
|
1
|
+
export { DynamicGlobalFloatingActionButton, GlobalFloatingActionButton, NullComponent, dynamicGlobalFloatingActionButtonPlugin, globalFloatingActionButtonPlugin } from './plugin.esm.js';
|
|
2
2
|
export { Slot } from './types.esm.js';
|
|
3
3
|
//# sourceMappingURL=index.esm.js.map
|
package/dist/plugin.esm.js
CHANGED
|
@@ -3,6 +3,9 @@ import { createPlugin, createComponentExtension } from '@backstage/core-plugin-a
|
|
|
3
3
|
const globalFloatingActionButtonPlugin = createPlugin({
|
|
4
4
|
id: "global-floating-action-button"
|
|
5
5
|
});
|
|
6
|
+
const dynamicGlobalFloatingActionButtonPlugin = createPlugin({
|
|
7
|
+
id: "dynamic-global-floating-action-button"
|
|
8
|
+
});
|
|
6
9
|
const GlobalFloatingActionButton = globalFloatingActionButtonPlugin.provide(
|
|
7
10
|
createComponentExtension({
|
|
8
11
|
name: "GlobalFloatingActionButton",
|
|
@@ -13,6 +16,24 @@ const GlobalFloatingActionButton = globalFloatingActionButtonPlugin.provide(
|
|
|
13
16
|
}
|
|
14
17
|
})
|
|
15
18
|
);
|
|
19
|
+
const DynamicGlobalFloatingActionButton = dynamicGlobalFloatingActionButtonPlugin.provide(
|
|
20
|
+
createComponentExtension({
|
|
21
|
+
name: "DynamicGlobalFloatingActionButton",
|
|
22
|
+
component: {
|
|
23
|
+
lazy: () => import('./components/DynamicGlobalFloatingActionButton.esm.js').then(
|
|
24
|
+
(m) => m.DynamicGlobalFloatingActionButton
|
|
25
|
+
)
|
|
26
|
+
}
|
|
27
|
+
})
|
|
28
|
+
);
|
|
29
|
+
const NullComponent = dynamicGlobalFloatingActionButtonPlugin.provide(
|
|
30
|
+
createComponentExtension({
|
|
31
|
+
name: "NullComponent",
|
|
32
|
+
component: {
|
|
33
|
+
lazy: () => import('./components/NullComponent.esm.js').then((m) => m.NullComponent)
|
|
34
|
+
}
|
|
35
|
+
})
|
|
36
|
+
);
|
|
16
37
|
|
|
17
|
-
export { GlobalFloatingActionButton, globalFloatingActionButtonPlugin };
|
|
38
|
+
export { DynamicGlobalFloatingActionButton, GlobalFloatingActionButton, NullComponent, dynamicGlobalFloatingActionButtonPlugin, globalFloatingActionButtonPlugin };
|
|
18
39
|
//# sourceMappingURL=plugin.esm.js.map
|
package/dist/plugin.esm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.esm.js","sources":["../src/plugin.ts"],"sourcesContent":["/*\n * Copyright Red Hat, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n createComponentExtension,\n createPlugin,\n} from '@backstage/core-plugin-api';\n\n/**\n * Global Floating Action Button Plugin\n *\n * @public\n */\nexport const globalFloatingActionButtonPlugin = createPlugin({\n id: 'global-floating-action-button',\n});\n\n/**\n * Global Floating Action Button\n *\n * @public\n */\nexport const GlobalFloatingActionButton =\n globalFloatingActionButtonPlugin.provide(\n createComponentExtension({\n name: 'GlobalFloatingActionButton',\n component: {\n lazy: () =>\n import('./components/GlobalFloatingActionButton').then(\n m => m.GlobalFloatingActionButton,\n ),\n },\n }),\n );\n"],"names":[],"mappings":";;AA0BO,MAAM,mCAAmC,YAAa,CAAA;AAAA,EAC3D,EAAI,EAAA;AACN,CAAC;AAOM,MAAM,6BACX,gCAAiC,CAAA,OAAA;AAAA,EAC/B,wBAAyB,CAAA;AAAA,IACvB,IAAM,EAAA,4BAAA;AAAA,IACN,SAAW,EAAA;AAAA,MACT,IAAM,EAAA,MACJ,OAAO,gDAAyC,CAAE,CAAA,IAAA;AAAA,QAChD,OAAK,CAAE,CAAA;AAAA;AACT;AACJ,GACD;AACH;;;;"}
|
|
1
|
+
{"version":3,"file":"plugin.esm.js","sources":["../src/plugin.ts"],"sourcesContent":["/*\n * Copyright Red Hat, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n createComponentExtension,\n createPlugin,\n} from '@backstage/core-plugin-api';\n\n/**\n * Global Floating Action Button Plugin\n *\n * @public\n */\nexport const globalFloatingActionButtonPlugin = createPlugin({\n id: 'global-floating-action-button',\n});\n\n/**\n * Dynamic Global Floating Action Button Plugin\n *\n * @public\n */\nexport const dynamicGlobalFloatingActionButtonPlugin = createPlugin({\n id: 'dynamic-global-floating-action-button',\n});\n\n/**\n * Global Floating Action Button\n *\n * @public\n */\nexport const GlobalFloatingActionButton =\n globalFloatingActionButtonPlugin.provide(\n createComponentExtension({\n name: 'GlobalFloatingActionButton',\n component: {\n lazy: () =>\n import('./components/GlobalFloatingActionButton').then(\n m => m.GlobalFloatingActionButton,\n ),\n },\n }),\n );\n\n/**\n * Dynamic Global Floating Action Button\n *\n * @public\n */\nexport const DynamicGlobalFloatingActionButton: React.ComponentType =\n dynamicGlobalFloatingActionButtonPlugin.provide(\n createComponentExtension({\n name: 'DynamicGlobalFloatingActionButton',\n component: {\n lazy: () =>\n import('./components/DynamicGlobalFloatingActionButton').then(\n m => m.DynamicGlobalFloatingActionButton,\n ),\n },\n }),\n );\n\n/**\n * Null Component\n *\n * @public\n */\nexport const NullComponent: React.ComponentType =\n dynamicGlobalFloatingActionButtonPlugin.provide(\n createComponentExtension({\n name: 'NullComponent',\n component: {\n lazy: () =>\n import('./components/NullComponent').then(m => m.NullComponent),\n },\n }),\n );\n"],"names":[],"mappings":";;AA0BO,MAAM,mCAAmC,YAAa,CAAA;AAAA,EAC3D,EAAI,EAAA;AACN,CAAC;AAOM,MAAM,0CAA0C,YAAa,CAAA;AAAA,EAClE,EAAI,EAAA;AACN,CAAC;AAOM,MAAM,6BACX,gCAAiC,CAAA,OAAA;AAAA,EAC/B,wBAAyB,CAAA;AAAA,IACvB,IAAM,EAAA,4BAAA;AAAA,IACN,SAAW,EAAA;AAAA,MACT,IAAM,EAAA,MACJ,OAAO,gDAAyC,CAAE,CAAA,IAAA;AAAA,QAChD,OAAK,CAAE,CAAA;AAAA;AACT;AACJ,GACD;AACH;AAOK,MAAM,oCACX,uCAAwC,CAAA,OAAA;AAAA,EACtC,wBAAyB,CAAA;AAAA,IACvB,IAAM,EAAA,mCAAA;AAAA,IACN,SAAW,EAAA;AAAA,MACT,IAAM,EAAA,MACJ,OAAO,uDAAgD,CAAE,CAAA,IAAA;AAAA,QACvD,OAAK,CAAE,CAAA;AAAA;AACT;AACJ,GACD;AACH;AAOK,MAAM,gBACX,uCAAwC,CAAA,OAAA;AAAA,EACtC,wBAAyB,CAAA;AAAA,IACvB,IAAM,EAAA,eAAA;AAAA,IACN,SAAW,EAAA;AAAA,MACT,IAAA,EAAM,MACJ,OAAO,mCAA4B,EAAE,IAAK,CAAA,CAAA,CAAA,KAAK,EAAE,aAAa;AAAA;AAClE,GACD;AACH;;;;"}
|
package/dist/types.esm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.esm.js","sources":["../src/types.ts"],"sourcesContent":["/*\n * Copyright Red Hat, Inc.\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\n/**\n * Slot\n *\n * @public\n */\nexport enum Slot {\n /**\n * Positions the floating action button in the bottom-right corner of the page\n */\n PAGE_END = 'page-end',\n /**\n * Positions the floating action button at the bottom center of the page\n */\n BOTTOM_LEFT = 'bottom-left',\n}\n\n/**\n * Floating Action Button\n *\n * @public\n */\nexport type FloatingActionButton = {\n slot?: Slot;\n label: string;\n showLabel?: boolean;\n icon: string | React.ReactElement;\n size?: 'small' | 'medium' | 'large';\n color?:\n | 'default'\n | 'error'\n | 'info'\n | 'inherit'\n | 'primary'\n | 'secondary'\n | 'success'\n | 'warning';\n onClick?: React.MouseEventHandler;\n to?: string;\n toolTip?: string;\n priority?: number;\n visibleOnPaths?: string[];\n excludeOnPaths?: string[];\n};\n\n/**\n * Floating Action Button With Positions\n *\n * @public\n */\nexport type FloatingActionButtonWithPositions = Array<{\n slot: Slot;\n actions: FloatingActionButton[];\n}>;\n"],"names":["Slot"],"mappings":"AAqBY,IAAA,IAAA,qBAAAA,KAAL,KAAA;AAIL,EAAAA,MAAA,UAAW,CAAA,GAAA,UAAA;AAIX,EAAAA,MAAA,aAAc,CAAA,GAAA,aAAA;AARJ,EAAAA,OAAAA,KAAAA;AAAA,CAAA,EAAA,IAAA,IAAA,EAAA;;;;"}
|
|
1
|
+
{"version":3,"file":"types.esm.js","sources":["../src/types.ts"],"sourcesContent":["/*\n * Copyright Red Hat, Inc.\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\n/**\n * Slot\n *\n * @public\n */\nexport enum Slot {\n /**\n * Positions the floating action button in the bottom-right corner of the page\n */\n PAGE_END = 'page-end',\n /**\n * Positions the floating action button at the bottom center of the page\n */\n BOTTOM_LEFT = 'bottom-left',\n}\n\n/**\n * Floating Action Button\n *\n * @public\n */\nexport type FloatingActionButton = {\n slot?: Slot;\n label: string;\n showLabel?: boolean;\n icon: string | React.ReactElement;\n size?: 'small' | 'medium' | 'large';\n color?:\n | 'default'\n | 'error'\n | 'info'\n | 'inherit'\n | 'primary'\n | 'secondary'\n | 'success'\n | 'warning';\n onClick?: React.MouseEventHandler;\n to?: string;\n toolTip?: string;\n priority?: number;\n visibleOnPaths?: string[];\n excludeOnPaths?: string[];\n};\n\n/**\n * Floating Action Button With Positions\n *\n * @public\n */\nexport type FloatingActionButtonWithPositions = Array<{\n slot: Slot;\n actions: FloatingActionButton[];\n}>;\n\n/**\n * FAB Mount Point\n *\n * @public\n */\nexport type FABMountPoint = {\n config?: FloatingActionButton;\n};\n"],"names":["Slot"],"mappings":"AAqBY,IAAA,IAAA,qBAAAA,KAAL,KAAA;AAIL,EAAAA,MAAA,UAAW,CAAA,GAAA,UAAA;AAIX,EAAAA,MAAA,aAAc,CAAA,GAAA,aAAA;AARJ,EAAAA,OAAAA,KAAAA;AAAA,CAAA,EAAA,IAAA,IAAA,EAAA;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@red-hat-developer-hub/backstage-plugin-global-floating-action-button",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.4",
|
|
4
4
|
"main": "dist/index.esm.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -39,6 +39,7 @@
|
|
|
39
39
|
"@mui/icons-material": "^5.15.17",
|
|
40
40
|
"@mui/material": "^5.15.17",
|
|
41
41
|
"@mui/styles": "5.16.13",
|
|
42
|
+
"@scalprum/react-core": "0.9.3",
|
|
42
43
|
"classnames": "^2.5.1",
|
|
43
44
|
"react-use": "^17.2.4"
|
|
44
45
|
},
|
|
@@ -49,6 +50,7 @@
|
|
|
49
50
|
"devDependencies": {
|
|
50
51
|
"@backstage/cli": "^0.28.0",
|
|
51
52
|
"@backstage/dev-utils": "^1.1.2",
|
|
53
|
+
"@openshift/dynamic-plugin-sdk": "5.0.1",
|
|
52
54
|
"@testing-library/jest-dom": "^6.0.0",
|
|
53
55
|
"@testing-library/react": "^14.0.0",
|
|
54
56
|
"react": "^16.13.1 || ^17.0.0 || ^18.0.0"
|