@backstage/core-components 0.18.2-next.2 → 0.18.2-next.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @backstage/core-components
2
2
 
3
+ ## 0.18.2-next.3
4
+
5
+ ### Patch Changes
6
+
7
+ - 431130c: Added `renderEdge` prop to `<DependencyGraph />` component in `@backstage/core-components` to allow custom rendering of graph edges.
8
+
3
9
  ## 0.18.2-next.2
4
10
 
5
11
  ### Patch Changes
@@ -58,6 +58,7 @@ function DependencyGraph(props) {
58
58
  labelOffset = 10,
59
59
  edgeRanks = 1,
60
60
  edgeWeight = 1,
61
+ renderEdge,
61
62
  renderLabel,
62
63
  defs,
63
64
  zoom = "enabled",
@@ -299,6 +300,7 @@ function DependencyGraph(props) {
299
300
  graphEdges.map((e) => {
300
301
  const edge = graph.current.edge(e);
301
302
  if (!edge) return null;
303
+ if (renderEdge) return renderEdge({ edge, id: e });
302
304
  return /* @__PURE__ */ jsx(
303
305
  Edge,
304
306
  {
@@ -1 +1 @@
1
- {"version":3,"file":"DependencyGraph.esm.js","sources":["../../../src/components/DependencyGraph/DependencyGraph.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 {\n SVGProps,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport useMeasure from 'react-use/esm/useMeasure';\nimport classNames from 'classnames';\nimport { once } from 'lodash';\nimport * as d3Zoom from 'd3-zoom';\nimport * as d3Selection from 'd3-selection';\nimport useTheme from '@material-ui/core/styles/useTheme';\nimport dagre from '@dagrejs/dagre';\nimport debounce from 'lodash/debounce';\nimport { DependencyGraphTypes as Types } from './types';\nimport { Node } from './Node';\nimport { Edge, GraphEdge } from './Edge';\nimport { ARROW_MARKER_ID } from './constants';\nimport IconButton from '@material-ui/core/IconButton';\nimport FullscreenIcon from '@material-ui/icons/Fullscreen';\nimport FullscreenExitIcon from '@material-ui/icons/FullscreenExit';\nimport { FullScreen, useFullScreenHandle } from 'react-full-screen';\nimport { makeStyles, Theme } from '@material-ui/core/styles';\nimport Tooltip from '@material-ui/core/Tooltip';\nimport { useTranslationRef } from '@backstage/core-plugin-api/alpha';\nimport { coreComponentsTranslationRef } from '../../translation';\n\nconst useStyles = makeStyles((theme: Theme) => ({\n fullscreenButton: {\n position: 'absolute',\n right: 0,\n },\n root: {\n overflow: 'hidden',\n minHeight: '100%',\n minWidth: '100%',\n },\n fixedHeight: {\n maxHeight: '100%',\n },\n fullscreen: {\n backgroundColor: theme.palette.background.paper,\n },\n}));\n\n/**\n * Properties of {@link DependencyGraph}\n *\n * @public\n * @remarks\n * `<NodeData>` and `<EdgeData>` are useful when rendering custom or edge labels\n */\nexport interface DependencyGraphProps<NodeData, EdgeData>\n extends SVGProps<SVGSVGElement> {\n /**\n * Edges of graph\n */\n edges: Types.DependencyEdge<EdgeData>[];\n /**\n * Nodes of Graph\n */\n nodes: Types.DependencyNode<NodeData>[];\n /**\n * Graph {@link DependencyGraphTypes.Direction | direction}\n *\n * @remarks\n *\n * Default: `DependencyGraphTypes.Direction.TOP_BOTTOM`\n */\n direction?: Types.Direction;\n /**\n * Node {@link DependencyGraphTypes.Alignment | alignment}\n */\n align?: Types.Alignment;\n /**\n * Margin between nodes on each rank\n *\n * @remarks\n *\n * Default: 50\n */\n nodeMargin?: number;\n /**\n * Margin between edges\n *\n * @remarks\n *\n * Default: 10\n */\n edgeMargin?: number;\n /**\n * Margin between each rank\n *\n * @remarks\n *\n * Default: 50\n */\n rankMargin?: number;\n /**\n * Margin on left and right of whole graph\n *\n * @remarks\n *\n * Default: 0\n */\n paddingX?: number;\n /**\n * Margin on top and bottom of whole graph\n *\n * @remarks\n *\n * Default: 0\n */\n paddingY?: number;\n /**\n * Heuristic used to find set of edges that will make graph acyclic\n */\n acyclicer?: 'greedy';\n /**\n * {@link DependencyGraphTypes.Ranker | Algorithm} used to rank nodes\n *\n * @remarks\n *\n * Default: `DependencyGraphTypes.Ranker.NETWORK_SIMPLEX`\n */\n ranker?: Types.Ranker;\n /**\n * {@link DependencyGraphTypes.LabelPosition | Position} of label in relation to edge\n *\n * @remarks\n *\n * Default: `DependencyGraphTypes.LabelPosition.RIGHT`\n */\n labelPosition?: Types.LabelPosition;\n /**\n * How much to move label away from edge\n *\n * @remarks\n *\n * Applies only when {@link DependencyGraphProps.labelPosition} is `DependencyGraphTypes.LabelPosition.LEFT` or\n * `DependencyGraphTypes.LabelPosition.RIGHT`\n */\n labelOffset?: number;\n /**\n * Minimum number of ranks to keep between connected nodes\n */\n edgeRanks?: number;\n /**\n * Weight applied to edges in graph\n */\n edgeWeight?: number;\n /**\n * Custom node rendering component\n */\n renderNode?: Types.RenderNodeFunction<NodeData>;\n /**\n * Custom label rendering component\n */\n renderLabel?: Types.RenderLabelFunction<EdgeData>;\n /**\n * {@link https://developer.mozilla.org/en-US/docs/Web/SVG/Element/defs | Defs} shared by rendered SVG to be used by\n * {@link DependencyGraphProps.renderNode} and/or {@link DependencyGraphProps.renderLabel}\n */\n defs?: JSX.Element | JSX.Element[];\n /**\n * Controls zoom behavior of graph\n *\n * @remarks\n *\n * Default: `enabled`\n */\n zoom?: 'enabled' | 'disabled' | 'enable-on-click';\n /**\n * A factory for curve generators addressing both lines and areas.\n *\n * @remarks\n *\n * Default: 'curveMonotoneX'\n */\n curve?: 'curveStepBefore' | 'curveMonotoneX';\n /**\n * Controls if the arrow heads should be rendered or not.\n *\n * Default: false\n */\n showArrowHeads?: boolean;\n /**\n * Controls if the graph should be contained or grow\n *\n * @remarks\n *\n * Default: 'grow'\n */\n fit?: 'grow' | 'contain';\n /**\n * Controls if user can toggle fullscreen mode\n *\n * @remarks\n *\n * Default: true\n */\n allowFullscreen?: boolean;\n}\n\nconst WORKSPACE_ID = 'workspace';\nconst DEPENDENCY_GRAPH_SVG = 'dependency-graph';\n\n/**\n * Graph component used to visualize relations between entities\n *\n * @public\n */\nexport function DependencyGraph<NodeData, EdgeData>(\n props: DependencyGraphProps<NodeData, EdgeData>,\n) {\n const {\n edges,\n nodes,\n renderNode,\n direction = Types.Direction.TOP_BOTTOM,\n align,\n nodeMargin = 50,\n edgeMargin = 10,\n rankMargin = 50,\n paddingX = 0,\n paddingY = 0,\n acyclicer,\n ranker = Types.Ranker.NETWORK_SIMPLEX,\n labelPosition = Types.LabelPosition.RIGHT,\n labelOffset = 10,\n edgeRanks = 1,\n edgeWeight = 1,\n renderLabel,\n defs,\n zoom = 'enabled',\n curve = 'curveMonotoneX',\n showArrowHeads = false,\n fit = 'grow',\n allowFullscreen = true,\n ...svgProps\n } = props;\n const theme = useTheme();\n const [containerWidth, setContainerWidth] = useState<number>(100);\n const [containerHeight, setContainerHeight] = useState<number>(100);\n const fullScreenHandle = useFullScreenHandle();\n const styles = useStyles();\n const { t } = useTranslationRef(coreComponentsTranslationRef);\n\n const graph = useRef<dagre.graphlib.Graph<Types.DependencyNode<NodeData>>>(\n new dagre.graphlib.Graph(),\n );\n const [graphWidth, setGraphWidth] = useState<number>(\n graph.current.graph()?.width || 0,\n );\n const [graphHeight, setGraphHeight] = useState<number>(\n graph.current.graph()?.height || 0,\n );\n const [graphNodes, setGraphNodes] = useState<string[]>([]);\n const [graphEdges, setGraphEdges] = useState<dagre.Edge[]>([]);\n\n const maxWidth = Math.max(graphWidth, containerWidth);\n const maxHeight = Math.max(graphHeight, containerHeight);\n\n const [_measureRef] = useMeasure();\n const measureRef = once(_measureRef);\n\n const scalableHeight =\n fit === 'grow' && !fullScreenHandle.active ? maxHeight : '100%';\n\n const containerRef = useMemo(\n () =>\n debounce((root: HTMLDivElement) => {\n if (!root) {\n return;\n }\n measureRef(root);\n\n // Set up zooming + panning\n const node: SVGSVGElement = root.querySelector(\n `svg#${DEPENDENCY_GRAPH_SVG}`,\n ) as SVGSVGElement;\n if (!node) {\n return;\n }\n const container = d3Selection.select<SVGSVGElement, null>(node);\n const workspace = d3Selection.select(node.getElementById(WORKSPACE_ID));\n\n function enableZoom() {\n container.call(\n d3Zoom\n .zoom<SVGSVGElement, null>()\n .scaleExtent([1, Infinity])\n .on('zoom', event => {\n event.transform.x = Math.min(\n 0,\n Math.max(\n event.transform.x,\n maxWidth - maxWidth * event.transform.k,\n ),\n );\n event.transform.y = Math.min(\n 0,\n Math.max(\n event.transform.y,\n maxHeight - maxHeight * event.transform.k,\n ),\n );\n workspace.attr('transform', event.transform);\n }),\n );\n }\n\n if (zoom === 'enabled') {\n enableZoom();\n } else if (zoom === 'enable-on-click') {\n container.on('click', () => enableZoom());\n }\n\n const { width: newContainerWidth, height: newContainerHeight } =\n root.getBoundingClientRect();\n if (\n containerWidth !== newContainerWidth &&\n newContainerWidth <= maxWidth\n ) {\n setContainerWidth(newContainerWidth);\n }\n if (\n containerHeight !== newContainerHeight &&\n newContainerHeight <= maxHeight\n ) {\n setContainerHeight(newContainerHeight);\n }\n }, 100),\n [measureRef, containerHeight, containerWidth, maxWidth, maxHeight, zoom],\n );\n\n const setNodesAndEdges = useCallback(() => {\n // Cleaning up lingering nodes and edges\n const currentGraphNodes = graph.current.nodes();\n const currentGraphEdges = graph.current.edges();\n\n currentGraphNodes.forEach(nodeId => {\n const remainingNode = nodes.some(node => node.id === nodeId);\n if (!remainingNode) {\n graph.current.removeNode(nodeId);\n }\n });\n\n currentGraphEdges.forEach(e => {\n const remainingEdge = edges.some(\n edge => edge.from === e.v && edge.to === e.w,\n );\n if (!remainingEdge) {\n graph.current.removeEdge(e.v, e.w);\n }\n });\n\n // Adding/updating nodes and edges\n nodes.forEach(node => {\n const existingNode = graph.current\n .nodes()\n .find(nodeId => node.id === nodeId);\n\n if (existingNode && graph.current.node(existingNode)) {\n const { width, height, x, y } = graph.current.node(existingNode);\n graph.current.setNode(existingNode, { ...node, width, height, x, y });\n } else {\n graph.current.setNode(node.id, { ...node, width: 0, height: 0 });\n }\n });\n\n edges.forEach(e => {\n graph.current.setEdge(e.from, e.to, {\n ...e,\n label: e.label,\n width: 0,\n height: 0,\n labelpos: labelPosition,\n labeloffset: labelOffset,\n weight: edgeWeight,\n minlen: edgeRanks,\n });\n });\n }, [edges, nodes, labelPosition, labelOffset, edgeWeight, edgeRanks]);\n\n const updateGraph = useMemo(\n () =>\n debounce(\n () => {\n dagre.layout(graph.current);\n const { height, width } = graph.current.graph();\n const newHeight = Math.max(0, height || 0);\n const newWidth = Math.max(0, width || 0);\n setGraphWidth(newWidth);\n setGraphHeight(newHeight);\n\n setGraphNodes(graph.current.nodes());\n setGraphEdges(graph.current.edges());\n },\n 250,\n { leading: true },\n ),\n [],\n );\n\n useEffect(() => {\n graph.current.setGraph({\n rankdir: direction,\n align,\n nodesep: nodeMargin,\n edgesep: edgeMargin,\n ranksep: rankMargin,\n marginx: paddingX,\n marginy: paddingY,\n acyclicer,\n ranker,\n });\n\n setNodesAndEdges();\n updateGraph();\n\n return updateGraph.cancel;\n }, [\n acyclicer,\n align,\n direction,\n edgeMargin,\n paddingX,\n paddingY,\n nodeMargin,\n rankMargin,\n ranker,\n setNodesAndEdges,\n updateGraph,\n ]);\n\n const setNode = useCallback(\n (id: string, node: Types.DependencyNode<NodeData>) => {\n graph.current.setNode(id, node);\n updateGraph();\n return graph.current;\n },\n [updateGraph],\n );\n\n const setEdge = useCallback(\n (id: dagre.Edge, edge: Types.DependencyEdge<EdgeData>) => {\n graph.current.setEdge(id, edge);\n updateGraph();\n return graph.current;\n },\n [updateGraph],\n );\n\n return (\n <FullScreen\n handle={fullScreenHandle}\n className={classNames(\n fullScreenHandle.active ? styles.fullscreen : styles.root,\n )}\n >\n {allowFullscreen && (\n <Tooltip title={t('dependencyGraph.fullscreenTooltip')}>\n <IconButton\n className={styles.fullscreenButton}\n onClick={\n fullScreenHandle.active\n ? fullScreenHandle.exit\n : fullScreenHandle.enter\n }\n >\n {fullScreenHandle.active ? (\n <FullscreenExitIcon />\n ) : (\n <FullscreenIcon />\n )}\n </IconButton>\n </Tooltip>\n )}\n\n <div ref={containerRef} style={{ width: '100%', height: '100%' }}>\n <svg\n {...svgProps}\n width=\"100%\"\n height={scalableHeight}\n viewBox={`0 0 ${maxWidth} ${maxHeight}`}\n id={DEPENDENCY_GRAPH_SVG}\n >\n <defs>\n <marker\n id={ARROW_MARKER_ID}\n viewBox=\"0 0 24 24\"\n markerWidth=\"14\"\n markerHeight=\"14\"\n refX=\"16\"\n refY=\"12\"\n orient=\"auto\"\n markerUnits=\"strokeWidth\"\n >\n <path\n fill={theme.palette.textSubtle}\n d=\"M8.59 16.59L13.17 12 8.59 7.41 10 6l6 6-6 6-1.41-1.41z\"\n />\n </marker>\n {defs}\n </defs>\n <g id={WORKSPACE_ID}>\n <svg\n width={graphWidth}\n height={graphHeight}\n y={maxHeight / 2 - graphHeight / 2}\n x={maxWidth / 2 - graphWidth / 2}\n viewBox={`-25 -25 ${graphWidth + 50} ${graphHeight + 50}`}\n >\n {graphEdges.map(e => {\n const edge = graph.current.edge(e) as GraphEdge<EdgeData>;\n if (!edge) return null;\n return (\n <Edge\n key={`${e.v}-${e.w}`}\n id={e}\n setEdge={setEdge}\n render={renderLabel}\n edge={edge}\n curve={curve}\n showArrowHeads={showArrowHeads}\n />\n );\n })}\n {graphNodes.map((id: string) => {\n const node = graph.current.node(id);\n if (!node) return null;\n return (\n <Node\n key={id}\n setNode={setNode}\n render={renderNode}\n node={node}\n />\n );\n })}\n </svg>\n </g>\n </svg>\n </div>\n </FullScreen>\n );\n}\n"],"names":["Types"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AA6CA,MAAM,SAAA,GAAY,UAAA,CAAW,CAAC,KAAA,MA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;AAAA,oBAEJ,CAAC;AAAA;AAAA;AAAA,eACH,EACF;AAAA;AAAA;AAAA,SACF,EACF;AAAA;AAAA;AAAA,GACF;AAEJ;;;;"}
1
+ {"version":3,"file":"DependencyGraph.esm.js","sources":["../../../src/components/DependencyGraph/DependencyGraph.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 {\n SVGProps,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport useMeasure from 'react-use/esm/useMeasure';\nimport classNames from 'classnames';\nimport { once } from 'lodash';\nimport * as d3Zoom from 'd3-zoom';\nimport * as d3Selection from 'd3-selection';\nimport useTheme from '@material-ui/core/styles/useTheme';\nimport dagre from '@dagrejs/dagre';\nimport debounce from 'lodash/debounce';\nimport { DependencyGraphTypes as Types } from './types';\nimport { Node } from './Node';\nimport { Edge, GraphEdge } from './Edge';\nimport { ARROW_MARKER_ID } from './constants';\nimport IconButton from '@material-ui/core/IconButton';\nimport FullscreenIcon from '@material-ui/icons/Fullscreen';\nimport FullscreenExitIcon from '@material-ui/icons/FullscreenExit';\nimport { FullScreen, useFullScreenHandle } from 'react-full-screen';\nimport { makeStyles, Theme } from '@material-ui/core/styles';\nimport Tooltip from '@material-ui/core/Tooltip';\nimport { useTranslationRef } from '@backstage/core-plugin-api/alpha';\nimport { coreComponentsTranslationRef } from '../../translation';\n\nconst useStyles = makeStyles((theme: Theme) => ({\n fullscreenButton: {\n position: 'absolute',\n right: 0,\n },\n root: {\n overflow: 'hidden',\n minHeight: '100%',\n minWidth: '100%',\n },\n fixedHeight: {\n maxHeight: '100%',\n },\n fullscreen: {\n backgroundColor: theme.palette.background.paper,\n },\n}));\n\n/**\n * Properties of {@link DependencyGraph}\n *\n * @public\n * @remarks\n * `<NodeData>` and `<EdgeData>` are useful when rendering custom or edge labels\n */\nexport interface DependencyGraphProps<NodeData, EdgeData>\n extends SVGProps<SVGSVGElement> {\n /**\n * Edges of graph\n */\n edges: Types.DependencyEdge<EdgeData>[];\n /**\n * Nodes of Graph\n */\n nodes: Types.DependencyNode<NodeData>[];\n /**\n * Graph {@link DependencyGraphTypes.Direction | direction}\n *\n * @remarks\n *\n * Default: `DependencyGraphTypes.Direction.TOP_BOTTOM`\n */\n direction?: Types.Direction;\n /**\n * Node {@link DependencyGraphTypes.Alignment | alignment}\n */\n align?: Types.Alignment;\n /**\n * Margin between nodes on each rank\n *\n * @remarks\n *\n * Default: 50\n */\n nodeMargin?: number;\n /**\n * Margin between edges\n *\n * @remarks\n *\n * Default: 10\n */\n edgeMargin?: number;\n /**\n * Margin between each rank\n *\n * @remarks\n *\n * Default: 50\n */\n rankMargin?: number;\n /**\n * Margin on left and right of whole graph\n *\n * @remarks\n *\n * Default: 0\n */\n paddingX?: number;\n /**\n * Margin on top and bottom of whole graph\n *\n * @remarks\n *\n * Default: 0\n */\n paddingY?: number;\n /**\n * Heuristic used to find set of edges that will make graph acyclic\n */\n acyclicer?: 'greedy';\n /**\n * {@link DependencyGraphTypes.Ranker | Algorithm} used to rank nodes\n *\n * @remarks\n *\n * Default: `DependencyGraphTypes.Ranker.NETWORK_SIMPLEX`\n */\n ranker?: Types.Ranker;\n /**\n * {@link DependencyGraphTypes.LabelPosition | Position} of label in relation to edge\n *\n * @remarks\n *\n * Default: `DependencyGraphTypes.LabelPosition.RIGHT`\n */\n labelPosition?: Types.LabelPosition;\n /**\n * How much to move label away from edge\n *\n * @remarks\n *\n * Applies only when {@link DependencyGraphProps.labelPosition} is `DependencyGraphTypes.LabelPosition.LEFT` or\n * `DependencyGraphTypes.LabelPosition.RIGHT`\n */\n labelOffset?: number;\n /**\n * Minimum number of ranks to keep between connected nodes\n */\n edgeRanks?: number;\n /**\n * Weight applied to edges in graph\n */\n edgeWeight?: number;\n /**\n * Custom edge rendering component\n */\n renderEdge?: Types.RenderEdgeFunction<EdgeData>;\n /**\n * Custom node rendering component\n */\n renderNode?: Types.RenderNodeFunction<NodeData>;\n /**\n * Custom label rendering component\n */\n renderLabel?: Types.RenderLabelFunction<EdgeData>;\n /**\n * {@link https://developer.mozilla.org/en-US/docs/Web/SVG/Element/defs | Defs} shared by rendered SVG to be used by\n * {@link DependencyGraphProps.renderNode} and/or {@link DependencyGraphProps.renderLabel}\n */\n defs?: JSX.Element | JSX.Element[];\n /**\n * Controls zoom behavior of graph\n *\n * @remarks\n *\n * Default: `enabled`\n */\n zoom?: 'enabled' | 'disabled' | 'enable-on-click';\n /**\n * A factory for curve generators addressing both lines and areas.\n *\n * @remarks\n *\n * Default: 'curveMonotoneX'\n */\n curve?: 'curveStepBefore' | 'curveMonotoneX';\n /**\n * Controls if the arrow heads should be rendered or not.\n *\n * Default: false\n */\n showArrowHeads?: boolean;\n /**\n * Controls if the graph should be contained or grow\n *\n * @remarks\n *\n * Default: 'grow'\n */\n fit?: 'grow' | 'contain';\n /**\n * Controls if user can toggle fullscreen mode\n *\n * @remarks\n *\n * Default: true\n */\n allowFullscreen?: boolean;\n}\n\nconst WORKSPACE_ID = 'workspace';\nconst DEPENDENCY_GRAPH_SVG = 'dependency-graph';\n\n/**\n * Graph component used to visualize relations between entities\n *\n * @public\n */\nexport function DependencyGraph<NodeData, EdgeData>(\n props: DependencyGraphProps<NodeData, EdgeData>,\n) {\n const {\n edges,\n nodes,\n renderNode,\n direction = Types.Direction.TOP_BOTTOM,\n align,\n nodeMargin = 50,\n edgeMargin = 10,\n rankMargin = 50,\n paddingX = 0,\n paddingY = 0,\n acyclicer,\n ranker = Types.Ranker.NETWORK_SIMPLEX,\n labelPosition = Types.LabelPosition.RIGHT,\n labelOffset = 10,\n edgeRanks = 1,\n edgeWeight = 1,\n renderEdge,\n renderLabel,\n defs,\n zoom = 'enabled',\n curve = 'curveMonotoneX',\n showArrowHeads = false,\n fit = 'grow',\n allowFullscreen = true,\n ...svgProps\n } = props;\n const theme = useTheme();\n const [containerWidth, setContainerWidth] = useState<number>(100);\n const [containerHeight, setContainerHeight] = useState<number>(100);\n const fullScreenHandle = useFullScreenHandle();\n const styles = useStyles();\n const { t } = useTranslationRef(coreComponentsTranslationRef);\n\n const graph = useRef<dagre.graphlib.Graph<Types.DependencyNode<NodeData>>>(\n new dagre.graphlib.Graph(),\n );\n const [graphWidth, setGraphWidth] = useState<number>(\n graph.current.graph()?.width || 0,\n );\n const [graphHeight, setGraphHeight] = useState<number>(\n graph.current.graph()?.height || 0,\n );\n const [graphNodes, setGraphNodes] = useState<string[]>([]);\n const [graphEdges, setGraphEdges] = useState<dagre.Edge[]>([]);\n\n const maxWidth = Math.max(graphWidth, containerWidth);\n const maxHeight = Math.max(graphHeight, containerHeight);\n\n const [_measureRef] = useMeasure();\n const measureRef = once(_measureRef);\n\n const scalableHeight =\n fit === 'grow' && !fullScreenHandle.active ? maxHeight : '100%';\n\n const containerRef = useMemo(\n () =>\n debounce((root: HTMLDivElement) => {\n if (!root) {\n return;\n }\n measureRef(root);\n\n // Set up zooming + panning\n const node: SVGSVGElement = root.querySelector(\n `svg#${DEPENDENCY_GRAPH_SVG}`,\n ) as SVGSVGElement;\n if (!node) {\n return;\n }\n const container = d3Selection.select<SVGSVGElement, null>(node);\n const workspace = d3Selection.select(node.getElementById(WORKSPACE_ID));\n\n function enableZoom() {\n container.call(\n d3Zoom\n .zoom<SVGSVGElement, null>()\n .scaleExtent([1, Infinity])\n .on('zoom', event => {\n event.transform.x = Math.min(\n 0,\n Math.max(\n event.transform.x,\n maxWidth - maxWidth * event.transform.k,\n ),\n );\n event.transform.y = Math.min(\n 0,\n Math.max(\n event.transform.y,\n maxHeight - maxHeight * event.transform.k,\n ),\n );\n workspace.attr('transform', event.transform);\n }),\n );\n }\n\n if (zoom === 'enabled') {\n enableZoom();\n } else if (zoom === 'enable-on-click') {\n container.on('click', () => enableZoom());\n }\n\n const { width: newContainerWidth, height: newContainerHeight } =\n root.getBoundingClientRect();\n if (\n containerWidth !== newContainerWidth &&\n newContainerWidth <= maxWidth\n ) {\n setContainerWidth(newContainerWidth);\n }\n if (\n containerHeight !== newContainerHeight &&\n newContainerHeight <= maxHeight\n ) {\n setContainerHeight(newContainerHeight);\n }\n }, 100),\n [measureRef, containerHeight, containerWidth, maxWidth, maxHeight, zoom],\n );\n\n const setNodesAndEdges = useCallback(() => {\n // Cleaning up lingering nodes and edges\n const currentGraphNodes = graph.current.nodes();\n const currentGraphEdges = graph.current.edges();\n\n currentGraphNodes.forEach(nodeId => {\n const remainingNode = nodes.some(node => node.id === nodeId);\n if (!remainingNode) {\n graph.current.removeNode(nodeId);\n }\n });\n\n currentGraphEdges.forEach(e => {\n const remainingEdge = edges.some(\n edge => edge.from === e.v && edge.to === e.w,\n );\n if (!remainingEdge) {\n graph.current.removeEdge(e.v, e.w);\n }\n });\n\n // Adding/updating nodes and edges\n nodes.forEach(node => {\n const existingNode = graph.current\n .nodes()\n .find(nodeId => node.id === nodeId);\n\n if (existingNode && graph.current.node(existingNode)) {\n const { width, height, x, y } = graph.current.node(existingNode);\n graph.current.setNode(existingNode, { ...node, width, height, x, y });\n } else {\n graph.current.setNode(node.id, { ...node, width: 0, height: 0 });\n }\n });\n\n edges.forEach(e => {\n graph.current.setEdge(e.from, e.to, {\n ...e,\n label: e.label,\n width: 0,\n height: 0,\n labelpos: labelPosition,\n labeloffset: labelOffset,\n weight: edgeWeight,\n minlen: edgeRanks,\n });\n });\n }, [edges, nodes, labelPosition, labelOffset, edgeWeight, edgeRanks]);\n\n const updateGraph = useMemo(\n () =>\n debounce(\n () => {\n dagre.layout(graph.current);\n const { height, width } = graph.current.graph();\n const newHeight = Math.max(0, height || 0);\n const newWidth = Math.max(0, width || 0);\n setGraphWidth(newWidth);\n setGraphHeight(newHeight);\n\n setGraphNodes(graph.current.nodes());\n setGraphEdges(graph.current.edges());\n },\n 250,\n { leading: true },\n ),\n [],\n );\n\n useEffect(() => {\n graph.current.setGraph({\n rankdir: direction,\n align,\n nodesep: nodeMargin,\n edgesep: edgeMargin,\n ranksep: rankMargin,\n marginx: paddingX,\n marginy: paddingY,\n acyclicer,\n ranker,\n });\n\n setNodesAndEdges();\n updateGraph();\n\n return updateGraph.cancel;\n }, [\n acyclicer,\n align,\n direction,\n edgeMargin,\n paddingX,\n paddingY,\n nodeMargin,\n rankMargin,\n ranker,\n setNodesAndEdges,\n updateGraph,\n ]);\n\n const setNode = useCallback(\n (id: string, node: Types.DependencyNode<NodeData>) => {\n graph.current.setNode(id, node);\n updateGraph();\n return graph.current;\n },\n [updateGraph],\n );\n\n const setEdge = useCallback(\n (id: dagre.Edge, edge: Types.DependencyEdge<EdgeData>) => {\n graph.current.setEdge(id, edge);\n updateGraph();\n return graph.current;\n },\n [updateGraph],\n );\n\n return (\n <FullScreen\n handle={fullScreenHandle}\n className={classNames(\n fullScreenHandle.active ? styles.fullscreen : styles.root,\n )}\n >\n {allowFullscreen && (\n <Tooltip title={t('dependencyGraph.fullscreenTooltip')}>\n <IconButton\n className={styles.fullscreenButton}\n onClick={\n fullScreenHandle.active\n ? fullScreenHandle.exit\n : fullScreenHandle.enter\n }\n >\n {fullScreenHandle.active ? (\n <FullscreenExitIcon />\n ) : (\n <FullscreenIcon />\n )}\n </IconButton>\n </Tooltip>\n )}\n\n <div ref={containerRef} style={{ width: '100%', height: '100%' }}>\n <svg\n {...svgProps}\n width=\"100%\"\n height={scalableHeight}\n viewBox={`0 0 ${maxWidth} ${maxHeight}`}\n id={DEPENDENCY_GRAPH_SVG}\n >\n <defs>\n <marker\n id={ARROW_MARKER_ID}\n viewBox=\"0 0 24 24\"\n markerWidth=\"14\"\n markerHeight=\"14\"\n refX=\"16\"\n refY=\"12\"\n orient=\"auto\"\n markerUnits=\"strokeWidth\"\n >\n <path\n fill={theme.palette.textSubtle}\n d=\"M8.59 16.59L13.17 12 8.59 7.41 10 6l6 6-6 6-1.41-1.41z\"\n />\n </marker>\n {defs}\n </defs>\n <g id={WORKSPACE_ID}>\n <svg\n width={graphWidth}\n height={graphHeight}\n y={maxHeight / 2 - graphHeight / 2}\n x={maxWidth / 2 - graphWidth / 2}\n viewBox={`-25 -25 ${graphWidth + 50} ${graphHeight + 50}`}\n >\n {graphEdges.map(e => {\n const edge = graph.current.edge(e) as GraphEdge<EdgeData>;\n if (!edge) return null;\n if (renderEdge) return renderEdge({ edge, id: e });\n\n return (\n <Edge\n key={`${e.v}-${e.w}`}\n id={e}\n setEdge={setEdge}\n render={renderLabel}\n edge={edge}\n curve={curve}\n showArrowHeads={showArrowHeads}\n />\n );\n })}\n {graphNodes.map((id: string) => {\n const node = graph.current.node(id);\n if (!node) return null;\n return (\n <Node\n key={id}\n setNode={setNode}\n render={renderNode}\n node={node}\n />\n );\n })}\n </svg>\n </g>\n </svg>\n </div>\n </FullScreen>\n );\n}\n"],"names":["Types"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AA6CA,MAAM,SAAA,GAAY,UAAA,CAAW,CAAC,KAAA,MAAkB;AAAA,EAC9C,gBAAA,EAAkB;AAAA,IAChB,QAAA,EAAU,UAAA;AAAA,IACV,KAAA,EAAO;AAAA,GACT;AAAA,EACA,IAAA,EAAM;AAAA,IACJ,QAAA,EAAU,QAAA;AAAA,IACV,SAAA,EAAW,MAAA;AAAA,IACX,QAAA,EAAU;AAAA,GACZ;AAAA,EACA,WAAA,EAAa;AAAA,IACX,SAAA,EAAW;AAAA,GACb;AAAA,EACA,UAAA,EAAY;AAAA,IACV,eAAA,EAAiB,KAAA,CAAM,OAAA,CAAQ,UAAA,CAAW;AAAA;AAE9C,CAAA,CAAE,CAAA;AAqKF,MAAM,YAAA,GAAe,WAAA;AACrB,MAAM,oBAAA,GAAuB,kBAAA;AAOtB,SAAS,gBACd,KAAA,EACA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,MAAM,IAAA,GAAO,KAAA,CAAM,OAAA,CAAQ,IAAA,CAAK,CAAC,CAAA;AACjC,sBAAA,IAAI,CAAC,MAAM,OAAO,IAAA;AAClB,sBAAA,IAAI,YAAY,OAAO,UAAA,CAAW,EAAE,IAAA,EAAM,EAAA,EAAI,GAAG,CAAA;AAEjD,sBAAA,uBACE,GAAA;AAAA,wBAAC,IAAA;AAAA,wBAAA;AAAA,0BAEC,EAAA,EAAI,CAAA;AAAA,0BACJ,OAAA;AAAA,0BACA,MAAA,EAAQ,WAAA;AAAA,0BACR,IAAA;AAAA,0BACA,KAAA;AAAA,0BACA;AAAA,yBAAA;AAAA,wBANK,CAAA,EAAG,CAAA,CAAE,CAAC,CAAA,CAAA,EAAI,EAAE,CAAC,CAAA;AAAA,uBAOpB;AAAA,oBAEJ,CAAC,CAAA;AAAA,oBACA,UAAA,CAAW,GAAA,CAAI,CAAC,EAAA,KAAe;AAC9B,sBAAA,MAAM,IAAA,GAAO,KAAA,CAAM,OAAA,CAAQ,IAAA,CAAK,EAAE,CAAA;AAClC,sBAAA,IAAI,CAAC,MAAM,OAAO,IAAA;AAClB,sBAAA,uBACE,GAAA;AAAA,wBAAC,IAAA;AAAA,wBAAA;AAAA,0BAEC,OAAA;AAAA,0BACA,MAAA,EAAQ,UAAA;AAAA,0BACR;AAAA,yBAAA;AAAA,wBAHK;AAAA,uBAIP;AAAA,oBAEJ,CAAC;AAAA;AAAA;AAAA,eACH,EACF;AAAA;AAAA;AAAA,SACF,EACF;AAAA;AAAA;AAAA,GACF;AAEJ;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"types.esm.js","sources":["../../../src/components/DependencyGraph/types.ts"],"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\n/**\n * Types used to customize and provide data to {@link DependencyGraph}\n *\n * @packageDocumentation\n */\n\nimport { ReactNode } from 'react';\n\n/**\n * Types for the {@link DependencyGraph} component.\n *\n * @public\n */\nexport namespace DependencyGraphTypes {\n /**\n * Edge of {@link DependencyGraph}\n *\n * @public\n */\n export type DependencyEdge<T = {}> = T & {\n /**\n * ID of {@link DependencyNode} from where the Edge start\n */\n from: string;\n /**\n * ID of {@link DependencyNode} to where the Edge goes to\n */\n to: string;\n /**\n * Label assigned and rendered with the Edge\n */\n label?: string;\n /**\n * Distance to a root entity\n */\n distance?: number;\n };\n\n /**\n * Properties of {@link DependencyGraphTypes.RenderLabelFunction} for {@link DependencyGraphTypes.DependencyEdge}\n *\n * @public\n */\n export type RenderLabelProps<T = unknown> = { edge: DependencyEdge<T> };\n\n /**\n * Custom React component for edge labels\n *\n * @public\n */\n export type RenderLabelFunction<T = {}> = (\n props: RenderLabelProps<T>,\n ) => ReactNode;\n\n /**\n * Node of {@link DependencyGraph}\n *\n * @public\n */\n export type DependencyNode<T = {}> = T & {\n id: string;\n };\n\n /**\n * Properties of {@link DependencyGraphTypes.RenderNodeFunction} for {@link DependencyGraphTypes.DependencyNode}\n *\n * @public\n */\n export type RenderNodeProps<T = unknown> = { node: DependencyNode<T> };\n\n /**\n * Custom React component for graph {@link DependencyGraphTypes.DependencyNode}\n *\n * @public\n */\n export type RenderNodeFunction<T = {}> = (\n props: RenderNodeProps<T>,\n ) => ReactNode;\n\n /**\n * Graph direction\n *\n * @public\n */\n export enum Direction {\n /**\n * Top to Bottom\n */\n TOP_BOTTOM = 'TB',\n /**\n * Bottom to Top\n */\n BOTTOM_TOP = 'BT',\n /**\n * Left to Right\n */\n LEFT_RIGHT = 'LR',\n /**\n * Right to Left\n */\n RIGHT_LEFT = 'RL',\n }\n\n /**\n * Node alignment\n *\n * @public\n */\n export enum Alignment {\n /**\n * Up Left\n */\n UP_LEFT = 'UL',\n /**\n * Up Right\n */\n UP_RIGHT = 'UR',\n /**\n * Down Left\n */\n DOWN_LEFT = 'DL',\n /**\n * Down Right\n */\n DOWN_RIGHT = 'DR',\n }\n\n /**\n * Algorithm used to rand nodes in graph\n *\n * @public\n */\n export enum Ranker {\n /**\n * {@link https://en.wikipedia.org/wiki/Network_simplex_algorithm | Network Simplex} algorithm\n */\n NETWORK_SIMPLEX = 'network-simplex',\n /**\n * Tight Tree algorithm\n */\n TIGHT_TREE = 'tight-tree',\n /**\n * Longest path algorithm\n *\n * @remarks\n *\n * Simplest and fastest\n */\n LONGEST_PATH = 'longest-path',\n }\n\n /**\n * Position of label in relation to the edge\n *\n * @public\n */\n export enum LabelPosition {\n LEFT = 'l',\n RIGHT = 'r',\n CENTER = 'c',\n }\n}\n"],"names":["DependencyGraphTypes","Direction","Alignment","Ranker","LabelPosition"],"mappings":"AA6BO,IAAU;AAAA,CAAV,CAAUA,qBAAAA,KAAV;AAuEE,EAAA,CAAA,CAAKC,UAAAA,KAAL;AAIL,IAAAA,WAAA,YAAA,CAAA,GAAa,IAAA;AAIb,IAAAA,WAAA,YAAA,CAAA,GAAa,IAAA;AAIb,IAAAA,WAAA,YAAA,CAAA,GAAa,IAAA;AAIb,IAAAA,WAAA,YAAA,CAAA,GAAa,IAAA;AAAA,EAAA,CAAA,EAhBHD,qBAAAA,CAAA,SAAA,KAAAA,qBAAAA,CAAA,SAAA,GAAA,EAAA,CAAA,CAAA;AAwBL,EAAA,CAAA,CAAKE,UAAAA,KAAL;AAIL,IAAAA,WAAA,SAAA,CAAA,GAAU,IAAA;AAIV,IAAAA,WAAA,UAAA,CAAA,GAAW,IAAA;AAIX,IAAAA,WAAA,WAAA,CAAA,GAAY,IAAA;AAIZ,IAAAA,WAAA,YAAA,CAAA,GAAa,IAAA;AAAA,EAAA,CAAA,EAhBHF,qBAAAA,CAAA,SAAA,KAAAA,qBAAAA,CAAA,SAAA,GAAA,EAAA,CAAA,CAAA;AAwBL,EAAA,CAAA,CAAKG,OAAAA,KAAL;AAIL,IAAAA,QAAA,iBAAA,CAAA,GAAkB,iBAAA;AAIlB,IAAAA,QAAA,YAAA,CAAA,GAAa,YAAA;AAQb,IAAAA,QAAA,cAAA,CAAA,GAAe,cAAA;AAAA,EAAA,CAAA,EAhBLH,qBAAAA,CAAA,MAAA,KAAAA,qBAAAA,CAAA,MAAA,GAAA,EAAA,CAAA,CAAA;AAwBL,EAAA,CAAA,CAAKI,cAAAA,KAAL;AACL,IAAAA,eAAA,MAAA,CAAA,GAAO,GAAA;AACP,IAAAA,eAAA,OAAA,CAAA,GAAQ,GAAA;AACR,IAAAA,eAAA,QAAA,CAAA,GAAS,GAAA;AAAA,EAAA,CAAA,EAHCJ,qBAAAA,CAAA,aAAA,KAAAA,qBAAAA,CAAA,aAAA,GAAA,EAAA,CAAA,CAAA;AAAA,CAAA,EA/IG,oBAAA,KAAA,oBAAA,GAAA,EAAA,CAAA,CAAA;;;;"}
1
+ {"version":3,"file":"types.esm.js","sources":["../../../src/components/DependencyGraph/types.ts"],"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\n/**\n * Types used to customize and provide data to {@link DependencyGraph}\n *\n * @packageDocumentation\n */\n\nimport { ReactNode } from 'react';\n\n/**\n * Types for the {@link DependencyGraph} component.\n *\n * @public\n */\nexport namespace DependencyGraphTypes {\n /**\n * Edge of {@link DependencyGraph}\n *\n * @public\n */\n export type DependencyEdge<T = {}> = T & {\n /**\n * ID of {@link DependencyNode} from where the Edge start\n */\n from: string;\n /**\n * ID of {@link DependencyNode} to where the Edge goes to\n */\n to: string;\n /**\n * Label assigned and rendered with the Edge\n */\n label?: string;\n /**\n * Distance to a root entity\n */\n distance?: number;\n };\n\n /**\n * Properties of {@link DependencyGraphTypes.RenderLabelFunction} for {@link DependencyGraphTypes.DependencyEdge}\n *\n * @public\n */\n export type RenderLabelProps<T = unknown> = { edge: DependencyEdge<T> };\n\n /**\n * Custom React component for edge labels\n *\n * @public\n */\n export type RenderLabelFunction<T = {}> = (\n props: RenderLabelProps<T>,\n ) => ReactNode;\n\n /**\n * Node of {@link DependencyGraph}\n *\n * @public\n */\n export type DependencyNode<T = {}> = T & {\n id: string;\n };\n\n /**\n * Properties of {@link DependencyGraphTypes.RenderNodeFunction} for {@link DependencyGraphTypes.DependencyNode}\n *\n * @public\n */\n export type RenderNodeProps<T = unknown> = { node: DependencyNode<T> };\n\n /**\n * Custom React component for graph {@link DependencyGraphTypes.DependencyNode}\n *\n * @public\n */\n export type RenderNodeFunction<T = {}> = (\n props: RenderNodeProps<T>,\n ) => ReactNode;\n\n /**\n * Properties of {@link DependencyGraphTypes.RenderEdgeFunction} for {@link DependencyGraphTypes.DependencyEdge}\n *\n * @public\n */\n export type RenderEdgeProps<T = {}> = {\n edge: T & {\n points: { x: number; y: number }[];\n label?: string;\n labeloffset?: number;\n labelpos?: string;\n width?: number;\n height?: number;\n weight?: number;\n minlen?: number;\n showArrowHeads?: boolean;\n from?: string;\n to?: string;\n relations?: string[];\n };\n id: {\n v: string;\n w: string;\n name?: string | undefined;\n };\n };\n\n /**\n * Custom React component for graph {@link DependencyGraphTypes.DependencyEdge}\n *\n * @public\n */\n export type RenderEdgeFunction<T = {}> = (\n props: RenderEdgeProps<T>,\n ) => ReactNode;\n\n /**\n * Graph direction\n *\n * @public\n */\n export enum Direction {\n /**\n * Top to Bottom\n */\n TOP_BOTTOM = 'TB',\n /**\n * Bottom to Top\n */\n BOTTOM_TOP = 'BT',\n /**\n * Left to Right\n */\n LEFT_RIGHT = 'LR',\n /**\n * Right to Left\n */\n RIGHT_LEFT = 'RL',\n }\n\n /**\n * Node alignment\n *\n * @public\n */\n export enum Alignment {\n /**\n * Up Left\n */\n UP_LEFT = 'UL',\n /**\n * Up Right\n */\n UP_RIGHT = 'UR',\n /**\n * Down Left\n */\n DOWN_LEFT = 'DL',\n /**\n * Down Right\n */\n DOWN_RIGHT = 'DR',\n }\n\n /**\n * Algorithm used to rand nodes in graph\n *\n * @public\n */\n export enum Ranker {\n /**\n * {@link https://en.wikipedia.org/wiki/Network_simplex_algorithm | Network Simplex} algorithm\n */\n NETWORK_SIMPLEX = 'network-simplex',\n /**\n * Tight Tree algorithm\n */\n TIGHT_TREE = 'tight-tree',\n /**\n * Longest path algorithm\n *\n * @remarks\n *\n * Simplest and fastest\n */\n LONGEST_PATH = 'longest-path',\n }\n\n /**\n * Position of label in relation to the edge\n *\n * @public\n */\n export enum LabelPosition {\n LEFT = 'l',\n RIGHT = 'r',\n CENTER = 'c',\n }\n}\n"],"names":["DependencyGraphTypes","Direction","Alignment","Ranker","LabelPosition"],"mappings":"AA6BO,IAAU;AAAA,CAAV,CAAUA,qBAAAA,KAAV;AA2GE,EAAA,CAAA,CAAKC,UAAAA,KAAL;AAIL,IAAAA,WAAA,YAAA,CAAA,GAAa,IAAA;AAIb,IAAAA,WAAA,YAAA,CAAA,GAAa,IAAA;AAIb,IAAAA,WAAA,YAAA,CAAA,GAAa,IAAA;AAIb,IAAAA,WAAA,YAAA,CAAA,GAAa,IAAA;AAAA,EAAA,CAAA,EAhBHD,qBAAAA,CAAA,SAAA,KAAAA,qBAAAA,CAAA,SAAA,GAAA,EAAA,CAAA,CAAA;AAwBL,EAAA,CAAA,CAAKE,UAAAA,KAAL;AAIL,IAAAA,WAAA,SAAA,CAAA,GAAU,IAAA;AAIV,IAAAA,WAAA,UAAA,CAAA,GAAW,IAAA;AAIX,IAAAA,WAAA,WAAA,CAAA,GAAY,IAAA;AAIZ,IAAAA,WAAA,YAAA,CAAA,GAAa,IAAA;AAAA,EAAA,CAAA,EAhBHF,qBAAAA,CAAA,SAAA,KAAAA,qBAAAA,CAAA,SAAA,GAAA,EAAA,CAAA,CAAA;AAwBL,EAAA,CAAA,CAAKG,OAAAA,KAAL;AAIL,IAAAA,QAAA,iBAAA,CAAA,GAAkB,iBAAA;AAIlB,IAAAA,QAAA,YAAA,CAAA,GAAa,YAAA;AAQb,IAAAA,QAAA,cAAA,CAAA,GAAe,cAAA;AAAA,EAAA,CAAA,EAhBLH,qBAAAA,CAAA,MAAA,KAAAA,qBAAAA,CAAA,MAAA,GAAA,EAAA,CAAA,CAAA;AAwBL,EAAA,CAAA,CAAKI,cAAAA,KAAL;AACL,IAAAA,eAAA,MAAA,CAAA,GAAO,GAAA;AACP,IAAAA,eAAA,OAAA,CAAA,GAAQ,GAAA;AACR,IAAAA,eAAA,QAAA,CAAA,GAAS,GAAA;AAAA,EAAA,CAAA,EAHCJ,qBAAAA,CAAA,aAAA,KAAAA,qBAAAA,CAAA,aAAA,GAAA,EAAA,CAAA,CAAA;AAAA,CAAA,EAnLG,oBAAA,KAAA,oBAAA,GAAA,EAAA,CAAA,CAAA;;;;"}
package/dist/index.d.ts CHANGED
@@ -379,6 +379,41 @@ declare namespace DependencyGraphTypes {
379
379
  * @public
380
380
  */
381
381
  type RenderNodeFunction<T = {}> = (props: RenderNodeProps<T>) => ReactNode;
382
+ /**
383
+ * Properties of {@link DependencyGraphTypes.RenderEdgeFunction} for {@link DependencyGraphTypes.DependencyEdge}
384
+ *
385
+ * @public
386
+ */
387
+ type RenderEdgeProps<T = {}> = {
388
+ edge: T & {
389
+ points: {
390
+ x: number;
391
+ y: number;
392
+ }[];
393
+ label?: string;
394
+ labeloffset?: number;
395
+ labelpos?: string;
396
+ width?: number;
397
+ height?: number;
398
+ weight?: number;
399
+ minlen?: number;
400
+ showArrowHeads?: boolean;
401
+ from?: string;
402
+ to?: string;
403
+ relations?: string[];
404
+ };
405
+ id: {
406
+ v: string;
407
+ w: string;
408
+ name?: string | undefined;
409
+ };
410
+ };
411
+ /**
412
+ * Custom React component for graph {@link DependencyGraphTypes.DependencyEdge}
413
+ *
414
+ * @public
415
+ */
416
+ type RenderEdgeFunction<T = {}> = (props: RenderEdgeProps<T>) => ReactNode;
382
417
  /**
383
418
  * Graph direction
384
419
  *
@@ -565,6 +600,10 @@ interface DependencyGraphProps<NodeData, EdgeData> extends SVGProps<SVGSVGElemen
565
600
  * Weight applied to edges in graph
566
601
  */
567
602
  edgeWeight?: number;
603
+ /**
604
+ * Custom edge rendering component
605
+ */
606
+ renderEdge?: DependencyGraphTypes.RenderEdgeFunction<EdgeData>;
568
607
  /**
569
608
  * Custom node rendering component
570
609
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backstage/core-components",
3
- "version": "0.18.2-next.2",
3
+ "version": "0.18.2-next.3",
4
4
  "description": "Core components used by Backstage plugins and apps",
5
5
  "backstage": {
6
6
  "role": "web-library"
@@ -108,7 +108,7 @@
108
108
  },
109
109
  "devDependencies": {
110
110
  "@backstage/app-defaults": "1.7.1-next.2",
111
- "@backstage/cli": "0.34.4-next.2",
111
+ "@backstage/cli": "0.34.4-next.3",
112
112
  "@backstage/core-app-api": "1.19.1-next.0",
113
113
  "@backstage/test-utils": "1.7.12-next.1",
114
114
  "@testing-library/dom": "^10.0.0",