From 77f4320cd0d9fb2ee8d4e343391a188ce46bdf84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vi=CC=81ctor=20CG?= Date: Mon, 5 Aug 2024 12:48:18 +0200 Subject: [PATCH] refactor(animation-factory): improve type infer --- .../create-directional-animation-factory.ts | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/packages/x-components/src/components/animations/create-directional-animation-factory.ts b/packages/x-components/src/components/animations/create-directional-animation-factory.ts index fc75ad5500..68c1919ffd 100644 --- a/packages/x-components/src/components/animations/create-directional-animation-factory.ts +++ b/packages/x-components/src/components/animations/create-directional-animation-factory.ts @@ -1,4 +1,4 @@ -import { defineComponent, h, Transition } from 'vue'; +import { DefineComponent, defineComponent, h, Transition } from 'vue'; export type AnimationOrigin = | 'top' @@ -21,18 +21,16 @@ export type AnimationOrigin = */ export function createDirectionalAnimationFactory( animationName: string -): ReturnType { - return (animationOrigin: AnimationOrigin = 'top') => +): (animationOrigin?: AnimationOrigin) => DefineComponent { + return (animationOrigin = 'top') => defineComponent({ name: `transition-${animationName}-${animationOrigin}`, - inheritAttrs: false, - setup(_, { attrs, slots }) { + setup(_, { slots }) { return () => h( Transition, { - name: `x-${animationName}--${animationOrigin} x-${animationName}-`, - ...attrs + name: `x-${animationName}--${animationOrigin} x-${animationName}-` }, // Vue recommends using function for better performance. () => slots.default?.() ?? ''