-
-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #472 from xyflow/docs/new-connection-callbacks
Document new connection callback API and `useConnection` hook.
- Loading branch information
Showing
5 changed files
with
127 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
sites/reactflow.dev/src/page-data/reference/types/InternalNode.fields.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import { type PropsTableProps } from 'xy-shared'; | ||
|
||
export const internalNodeFields: PropsTableProps = { | ||
props: [ | ||
{ name: 'id', type: 'string' }, | ||
{ name: 'position', type: 'XYPosition' }, | ||
{ name: 'data', type: 'T' }, | ||
{ name: 'type?', type: 'U' }, | ||
{ name: 'sourcePosition?', type: 'Position' }, | ||
{ name: 'targetPosition?', type: 'Position' }, | ||
{ | ||
name: 'hidden?', | ||
type: 'boolean', | ||
description: `Whether or not the node should be visible on the canvas.`, | ||
}, | ||
{ name: 'selected?', type: 'boolean' }, | ||
{ | ||
name: 'dragging?', | ||
type: 'boolean', | ||
description: `Whether or not the node is currently being dragged.`, | ||
}, | ||
{ | ||
name: 'draggable?', | ||
type: 'boolean', | ||
description: `Whether or not the node is able to be dragged.`, | ||
}, | ||
{ name: 'selectable?', type: 'boolean' }, | ||
{ name: 'connectable?', type: 'boolean' }, | ||
{ name: 'resizing?', type: 'boolean' }, | ||
{ name: 'deletable?', type: 'boolean' }, | ||
{ name: 'dragHandle?', type: 'string' }, | ||
{ name: 'width?', type: 'number | null' }, | ||
{ name: 'height?', type: 'number | null' }, | ||
{ name: 'parentNode?', type: 'string' }, | ||
{ name: 'parentId?', type: 'string' }, | ||
{ name: 'zIndex?', type: 'number' }, | ||
{ name: 'extent?', type: '"parent" | CoordinateExtent' }, | ||
{ | ||
name: 'expandParent?', | ||
type: 'boolean', | ||
description: `When true, the parent node will automatically expand if this | ||
node is dragged to the edge of the parent node's bounds.`, | ||
}, | ||
{ name: 'positionAbsolute?', type: 'XYPosition' }, | ||
{ name: 'ariaLabel?', type: 'string' }, | ||
{ name: 'focusable?', type: 'boolean' }, | ||
{ name: 'style?', type: 'React.CSSProperties' }, | ||
{ name: 'className?', type: 'string' }, | ||
{ name: 'handles?', type: 'NodeHandle[]' }, | ||
{ name: 'origin?', type: 'NodeOrigin' }, | ||
{ | ||
name: 'measured?', | ||
type: '{ width?: number, height?: number }', | ||
}, | ||
{ name: 'internals', type: 'object' }, | ||
{ name: 'internals.positionAbsolute', type: 'XYPosition' }, | ||
{ name: 'internals.z', type: 'number' }, | ||
{ name: 'internals.userNode', type: 'NodeType' }, | ||
{ name: 'internals.handleBounds?', type: 'NodeHandleBounds' }, | ||
{ name: 'internals.bounds?', type: 'NodeBounds' }, | ||
], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
sites/reactflow.dev/src/pages/api-reference/types/internal-node.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
--- | ||
title: InternalNode | ||
description: | ||
'The InternalNode is an extension of the base Node type with additional properties | ||
React Flow uses internally for rendering. .' | ||
--- | ||
|
||
import { Callout } from 'nextra/components'; | ||
import { PropsTable } from '@/components/props-table'; | ||
import { internalNodeFields } from '@/page-data/reference/types/InternalNode.fields.ts'; | ||
|
||
# InternalNode | ||
|
||
[Source on GitHub](https://github.com/xyflow/xyflow/blob/99985b52026cf4ac65a1033178cf8c2bea4e14fa/packages/system/src/types/nodes.ts#L68) | ||
|
||
The `InternalNode` type is identical to the base [`Node`](/api-references/types/node) | ||
type but is extended with some additional properties used internall by React | ||
Flow. Some functions and callbacks that return nodes may return an `InternalNode`. | ||
|
||
```ts | ||
export type InternalNodeBase<NodeType extends NodeBase = NodeBase> = NodeType & { | ||
measured: { | ||
width?: number; | ||
height?: number; | ||
}; | ||
internals: { | ||
positionAbsolute: XYPosition; | ||
z: number; | ||
userNode: NodeType; | ||
handleBounds?: NodeHandleBounds; | ||
bounds?: NodeBounds; | ||
}; | ||
}; | ||
``` | ||
|
||
## Fields | ||
|
||
<PropsTable {...internalNodeFields} /> |