♻️ Rename 'MiniMapNode' prop to 'nodeComponent' for greater consistency.
This commit is contained in:
@@ -55,6 +55,9 @@ function MiniMap({
|
|||||||
nodeClassName = '',
|
nodeClassName = '',
|
||||||
nodeBorderRadius = 5,
|
nodeBorderRadius = 5,
|
||||||
nodeStrokeWidth = 2,
|
nodeStrokeWidth = 2,
|
||||||
|
// We need to rename the prop to be `CapitalCase` so that JSX will render it as
|
||||||
|
// a component properly.
|
||||||
|
nodeComponent: NodeComponent = MiniMapNode,
|
||||||
maskColor = 'rgb(240, 240, 240, 0.6)',
|
maskColor = 'rgb(240, 240, 240, 0.6)',
|
||||||
maskStrokeColor = 'none',
|
maskStrokeColor = 'none',
|
||||||
maskStrokeWidth = 1,
|
maskStrokeWidth = 1,
|
||||||
@@ -64,9 +67,6 @@ function MiniMap({
|
|||||||
pannable = false,
|
pannable = false,
|
||||||
zoomable = false,
|
zoomable = false,
|
||||||
ariaLabel = 'React Flow mini map',
|
ariaLabel = 'React Flow mini map',
|
||||||
// Rename the field to avoid clashes with the default `MiniMapNode` component.
|
|
||||||
// Fallback to that component if none is provided.
|
|
||||||
MiniMapNode: CustomMiniMapNode = MiniMapNode,
|
|
||||||
}: MiniMapProps) {
|
}: MiniMapProps) {
|
||||||
const store = useStoreApi();
|
const store = useStoreApi();
|
||||||
const svg = useRef<SVGSVGElement>(null);
|
const svg = useRef<SVGSVGElement>(null);
|
||||||
@@ -179,7 +179,7 @@ function MiniMap({
|
|||||||
const { x, y } = getNodePositionWithOrigin(node, nodeOrigin).positionAbsolute;
|
const { x, y } = getNodePositionWithOrigin(node, nodeOrigin).positionAbsolute;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<CustomMiniMapNode
|
<NodeComponent
|
||||||
key={node.id}
|
key={node.id}
|
||||||
x={x}
|
x={x}
|
||||||
y={y}
|
y={y}
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ export type MiniMapProps<NodeData = any> = Omit<HTMLAttributes<SVGSVGElement>, '
|
|||||||
nodeClassName?: string | GetMiniMapNodeAttribute<NodeData>;
|
nodeClassName?: string | GetMiniMapNodeAttribute<NodeData>;
|
||||||
nodeBorderRadius?: number;
|
nodeBorderRadius?: number;
|
||||||
nodeStrokeWidth?: number;
|
nodeStrokeWidth?: number;
|
||||||
|
nodeComponent?: ComponentType<MiniMapNodeProps>;
|
||||||
maskColor?: string;
|
maskColor?: string;
|
||||||
maskStrokeColor?: string;
|
maskStrokeColor?: string;
|
||||||
maskStrokeWidth?: number;
|
maskStrokeWidth?: number;
|
||||||
@@ -19,7 +20,6 @@ export type MiniMapProps<NodeData = any> = Omit<HTMLAttributes<SVGSVGElement>, '
|
|||||||
pannable?: boolean;
|
pannable?: boolean;
|
||||||
zoomable?: boolean;
|
zoomable?: boolean;
|
||||||
ariaLabel?: string | null;
|
ariaLabel?: string | null;
|
||||||
MiniMapNode?: ComponentType<MiniMapNodeProps>;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export interface MiniMapNodeProps {
|
export interface MiniMapNodeProps {
|
||||||
|
|||||||
Reference in New Issue
Block a user