1- import type { Directive , DirectiveBinding , VNode } from 'vue'
1+ import type { Directive , DirectiveBinding , Ref , VNode } from 'vue'
22import defu from 'defu'
33import { ref , unref } from 'vue'
44import { motionState } from '../features/state'
@@ -7,7 +7,7 @@ import { useMotion } from '../useMotion'
77import { resolveVariants } from '../utils/directive'
88import { variantToStyle } from '../utils/transform'
99
10- export function directive ( variants ? : MotionVariants ) : Directive < HTMLElement | SVGElement > {
10+ export function directive < T extends string > ( variants : MotionVariants < T > = { } ) : Directive < HTMLElement | SVGElement > {
1111 const register = ( el : HTMLElement | SVGElement , binding : DirectiveBinding , node : VNode < any , HTMLElement | SVGElement , Record < string , any > > ) => {
1212 // Get instance key if possible (binding value or element key in case of v-for's)
1313 const key = ( binding . value && typeof binding . value === 'string' ? binding . value : node . key ) as string
@@ -16,13 +16,13 @@ export function directive(variants?: MotionVariants): Directive<HTMLElement | SV
1616 if ( key && motionState [ key ] ) motionState [ key ] . stop ( )
1717
1818 // Initialize variants with argument
19- const variantsRef = ref < MotionVariants > ( variants || { } )
19+ const variantsRef = ref ( variants ) as Ref < MotionVariants < T > >
2020
2121 // Set variants from v-motion binding
2222 if ( typeof binding . value === 'object' ) variantsRef . value = binding . value
2323
2424 // Resolve variants from node props
25- resolveVariants ( node , variantsRef )
25+ resolveVariants < T > ( node , variantsRef )
2626
2727 // Create motion instance
2828 const motionInstance = useMotion ( el , variantsRef )
0 commit comments