Skip to content

Commit

Permalink
feat: enhance Motion component props and update constants
Browse files Browse the repository at this point in the history
- Added type extraction for component props in NameSpace.ts to improve type safety.
- Updated MotionComponentProps to include extracted public prop types.
- Included 'motion' in the components array in index.ts for better consistency.
  • Loading branch information
rick-hup committed Jan 14, 2025
1 parent 454497b commit f05545f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
11 changes: 9 additions & 2 deletions packages/motion/src/components/motion/NameSpace.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
import type { DefineComponent, IntrinsicElementAttributes } from 'vue'
import type { DefineComponent, ExtractPropTypes, ExtractPublicPropTypes, IntrinsicElementAttributes } from 'vue'
import { defineComponent, h } from 'vue'
import Motion from './Motion.vue'
import type { MotionProps } from './Motion.vue'

type ComponentProps<T> = T extends DefineComponent<
ExtractPropTypes<infer Props>,
any,
any
>
? ExtractPublicPropTypes<Props>
: never
type MotionComponentProps = IntrinsicElementAttributes & {
create: <T extends DefineComponent>(T) => DefineComponent<MotionProps<any, unknown>>
create: <T extends DefineComponent>(T) => DefineComponent<MotionProps<any, unknown> & ComponentProps<T>>
}
type MotionKeys = keyof MotionComponentProps

Expand Down
1 change: 1 addition & 0 deletions packages/motion/src/constants/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const components = {
motion: [
'motion',
'Motion',
'AnimatePresence',
'LayoutGroup',
Expand Down

0 comments on commit f05545f

Please sign in to comment.