refactor(types): Remove internal __vf field

* fields are merged into the GraphNode / Node interface
* Remove passing props from VueFlow container, use injected state

Signed-off-by: Braks <78412429+bcakmakoglu@users.noreply.github.com>
This commit is contained in:
Braks
2021-12-20 19:29:52 +01:00
parent 3f0b0dbd70
commit f28e10b05a
17 changed files with 219 additions and 478 deletions
+20 -15
View File
@@ -1,19 +1,9 @@
import { DraggableOptions } from '@braks/revue-draggable'
import { XYPosition, Position, SnapGrid, Element, Dimensions, XYZPosition } from './flow'
import { XYPosition, Position, SnapGrid, Element, XYZPosition } from './flow'
import { HandleElement, ValidConnectionFunc } from './components'
export type CoordinateExtent = [[number, number], [number, number]]
export interface VFInternals extends Dimensions {
handleBounds: {
source?: HandleElement[]
target?: HandleElement[]
}
parentNode?: any
isParent?: boolean
position: XYZPosition
}
export type Draggable = Omit<DraggableOptions, 'scale' | 'grid' | 'enableUserSelectHack' | 'enableTransformFix'> | boolean
export interface Node<T = any> extends Element<T> {
@@ -28,18 +18,27 @@ export interface Node<T = any> extends Element<T> {
isValidTargetPos?: ValidConnectionFunc
isValidSourcePos?: ValidConnectionFunc
extent?: 'parent' | CoordinateExtent
parentNode?: string
children?: Node[]
width?: number
height?: number
}
export interface GraphNode<T = any> extends Node<T> {
__vf: VFInternals
handleBounds: {
source?: HandleElement[]
target?: HandleElement[]
}
parentNode?: GraphNode
isParent?: boolean
computedPosition: XYZPosition
selected?: boolean
dragging?: boolean
width: number
height: number
}
export interface NodeProps<T = any> extends GraphNode {
id: string
position: XYPosition
type?: string
data?: T
selected?: boolean
@@ -49,7 +48,13 @@ export interface NodeProps<T = any> extends GraphNode {
dragging?: boolean
isValidTargetPos?: ValidConnectionFunc
isValidSourcePos?: ValidConnectionFunc
__vf: VFInternals
handleBounds: {
source?: HandleElement[]
target?: HandleElement[]
}
parentNode?: GraphNode
isParent?: boolean
position: XYZPosition
}
export type NodeDimensionUpdate = {