Merge pull request #5565 from xyflow/minimapnode-svelte-id
Add node id to MiniMapNodeProps and MiniMapNode in Svelte Flow
This commit is contained in:
5
.changeset/neat-rules-hammer.md
Normal file
5
.changeset/neat-rules-hammer.md
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'@xyflow/svelte': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Pass nodeId to MiniMapNode
|
||||||
@@ -1,22 +1,25 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
let {
|
import type { MiniMapNodeProps } from '@xyflow/svelte';
|
||||||
x,
|
|
||||||
y,
|
let { id, x, y, width, height, selected }: MiniMapNodeProps = $props();
|
||||||
width,
|
|
||||||
height,
|
|
||||||
selected,
|
|
||||||
}: {
|
|
||||||
x: number;
|
|
||||||
y: number;
|
|
||||||
width: number;
|
|
||||||
height: number;
|
|
||||||
selected?: boolean;
|
|
||||||
} = $props();
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<circle
|
<circle
|
||||||
cx={x + width / 2}
|
cx={x + width / 2}
|
||||||
cy={y + height / 2}
|
cy={y + height / 2}
|
||||||
r={Math.min(width, height) - 2}
|
r={Math.min(width, height) - 2}
|
||||||
fill={selected ? "#ff6b6b" : "#ffcc00"}
|
fill={selected ? '#ff6b6b' : '#ffcc00'}
|
||||||
/>
|
/>
|
||||||
|
<text
|
||||||
|
x={x + width / 2}
|
||||||
|
y={y + height / 2}
|
||||||
|
text-anchor="middle"
|
||||||
|
dominant-baseline="middle"
|
||||||
|
fill="blue"
|
||||||
|
stroke-width="0.5"
|
||||||
|
font-size="100"
|
||||||
|
font-family="Arial, sans-serif"
|
||||||
|
font-weight="bold"
|
||||||
|
>
|
||||||
|
{id}
|
||||||
|
</text>
|
||||||
|
|||||||
@@ -121,6 +121,7 @@
|
|||||||
{#if node && nodeHasDimensions(node) && !node.hidden}
|
{#if node && nodeHasDimensions(node) && !node.hidden}
|
||||||
{@const nodeDimesions = getNodeDimensions(node)}
|
{@const nodeDimesions = getNodeDimensions(node)}
|
||||||
<MinimapNode
|
<MinimapNode
|
||||||
|
id={node.id}
|
||||||
x={node.internals.positionAbsolute.x}
|
x={node.internals.positionAbsolute.x}
|
||||||
y={node.internals.positionAbsolute.y}
|
y={node.internals.positionAbsolute.y}
|
||||||
{...nodeDimesions}
|
{...nodeDimesions}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
import type { MiniMapNodeProps } from './types';
|
import type { MiniMapNodeProps } from './types';
|
||||||
|
|
||||||
let {
|
let {
|
||||||
|
id,
|
||||||
x,
|
x,
|
||||||
y,
|
y,
|
||||||
width,
|
width,
|
||||||
@@ -17,6 +18,7 @@
|
|||||||
class: className,
|
class: className,
|
||||||
nodeComponent
|
nodeComponent
|
||||||
}: {
|
}: {
|
||||||
|
id: string;
|
||||||
x: number;
|
x: number;
|
||||||
y: number;
|
y: number;
|
||||||
width: number;
|
width: number;
|
||||||
@@ -36,6 +38,7 @@
|
|||||||
{@const CustomComponent = nodeComponent}
|
{@const CustomComponent = nodeComponent}
|
||||||
|
|
||||||
<CustomComponent
|
<CustomComponent
|
||||||
|
{id}
|
||||||
{x}
|
{x}
|
||||||
{y}
|
{y}
|
||||||
{width}
|
{width}
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ export type GetMiniMapNodeAttribute = (node: Node) => string;
|
|||||||
* @public
|
* @public
|
||||||
*/
|
*/
|
||||||
export type MiniMapNodeProps = {
|
export type MiniMapNodeProps = {
|
||||||
|
id: string;
|
||||||
x: number;
|
x: number;
|
||||||
y: number;
|
y: number;
|
||||||
width: number;
|
width: number;
|
||||||
|
|||||||
Reference in New Issue
Block a user