@@ -25,7 +25,7 @@ import {
2525} from '../../utils'
2626import { NodeId , NodeRef , Slots } from '../../context'
2727import { isInputDOMNode , useDrag , useNode , useNodeHooks , useUpdateNodePositions , useVueFlow } from '../../composables'
28- import type { NodeComponent } from '../../types'
28+ import type { BuiltInNode , NodeComponent } from '../../types'
2929
3030interface Props {
3131 id : string
@@ -36,7 +36,7 @@ const NodeWrapper = defineComponent({
3636 name : 'Node' ,
3737 compatConfig : { MODE : 3 } ,
3838 props : [ 'id' , 'resizeObserver' ] ,
39- setup ( props : Props ) {
39+ setup < NodeType extends Node > ( props : Props ) {
4040 const {
4141 id : vueFlowId ,
4242 noPanClassName,
@@ -92,7 +92,7 @@ const NodeWrapper = defineComponent({
9292 return slot
9393 }
9494
95- let nodeType = node . template || getNodeTypes . value [ name ]
95+ let nodeType = getNodeTypes . value [ name ]
9696
9797 if ( typeof nodeType === 'string' ) {
9898 if ( instance ) {
@@ -112,7 +112,7 @@ const NodeWrapper = defineComponent({
112112 return false
113113 } )
114114
115- const { emit, on } = useNodeHooks ( node , emits )
115+ const { emit } = useNodeHooks ( emits )
116116
117117 const dragging = useDrag ( {
118118 id : props . id ,
@@ -139,15 +139,15 @@ const NodeWrapper = defineComponent({
139139 const getStyle = computed ( ( ) => {
140140 const styles = ( node . style instanceof Function ? node . style ( node ) : node . style ) || { }
141141
142- const width = node . width instanceof Function ? node . width ( node ) : node . width
143- const height = node . height instanceof Function ? node . height ( node ) : node . height
142+ const width = node . width
143+ const height = node . height
144144
145145 if ( width ) {
146- styles . width = typeof width === 'string' ? width : `${ width } px`
146+ styles . width = `${ width } px`
147147 }
148148
149149 if ( height ) {
150- styles . height = typeof height === 'string' ? height : `${ height } px`
150+ styles . height = `${ height } px`
151151 }
152152
153153 return styles
@@ -228,7 +228,7 @@ const NodeWrapper = defineComponent({
228228 // if extent is parent, we need dimensions to properly clamp the position
229229 if (
230230 node . extent === 'parent' ||
231- ( typeof node . extent === 'object' && 'range' in node . extent && node . extent . range === 'parent' )
231+ ( ! ! node . extent && typeof node . extent === 'object' && 'range' in node . extent && node . extent . range === 'parent' )
232232 ) {
233233 until ( ( ) => isInit )
234234 . toBe ( true )
@@ -282,28 +282,29 @@ const NodeWrapper = defineComponent({
282282 'onKeydown' : onKeyDown ,
283283 } ,
284284 [
285- h ( nodeCmp . value === false ? getNodeTypes . value . default : ( nodeCmp . value as any ) , {
286- id : node . id ,
287- type : node . type ,
288- data : node . data ,
289- events : { ...node . events , ...on } ,
290- selected : node . selected ,
291- resizing : node . resizing ,
292- dragging : dragging . value ,
293- connectable : isConnectable . value ,
294- position : node . computedPosition ,
295- dimensions : node . dimensions ,
296- isValidTargetPos : node . isValidTargetPos ,
297- isValidSourcePos : node . isValidSourcePos ,
298- parent : node . parentNode ,
299- parentNodeId : node . parentNode ,
300- zIndex : node . computedPosition . z ?? zIndex . value ,
301- targetPosition : node . targetPosition ,
302- sourcePosition : node . sourcePosition ,
303- label : node . label ,
304- dragHandle : node . dragHandle ,
305- onUpdateNodeInternals : updateInternals ,
306- } ) ,
285+ h (
286+ nodeCmp . value === false
287+ ? ( getNodeTypes . value . default as NodeComponent < BuiltInNode > )
288+ : ( nodeCmp . value as NodeComponent < NodeType > ) ,
289+ {
290+ id : node . id ,
291+ type : node . type ,
292+ data : node . data ,
293+ selected : node . selected ,
294+ resizing : node . resizing ,
295+ dragging : dragging . value ,
296+ connectable : isConnectable . value ,
297+ position : node . computedPosition ,
298+ dimensions : node . dimensions ,
299+ parent : node . parentNode ,
300+ parentNodeId : node . parentNode ,
301+ zIndex : node . computedPosition . z ?? zIndex . value ,
302+ targetPosition : node . targetPosition ,
303+ sourcePosition : node . sourcePosition ,
304+ dragHandle : node . dragHandle ,
305+ onUpdateNodeInternals : updateInternals ,
306+ } ,
307+ ) ,
307308 ] ,
308309 )
309310 }
0 commit comments