Skip to content

Commit

Permalink
fix(build): ensure BaseTransition functions can be tree-shaken
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Feb 2, 2023
1 parent a5dcbad commit 3a6f5eb
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 22 deletions.
42 changes: 22 additions & 20 deletions packages/runtime-core/src/components/BaseTransition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,29 +111,31 @@ export function useTransitionState(): TransitionState {

const TransitionHookValidator = [Function, Array]

export const BaseTransitionPropsValidators = {
mode: String,
appear: Boolean,
persisted: Boolean,
// enter
onBeforeEnter: TransitionHookValidator,
onEnter: TransitionHookValidator,
onAfterEnter: TransitionHookValidator,
onEnterCancelled: TransitionHookValidator,
// leave
onBeforeLeave: TransitionHookValidator,
onLeave: TransitionHookValidator,
onAfterLeave: TransitionHookValidator,
onLeaveCancelled: TransitionHookValidator,
// appear
onBeforeAppear: TransitionHookValidator,
onAppear: TransitionHookValidator,
onAfterAppear: TransitionHookValidator,
onAppearCancelled: TransitionHookValidator
}

const BaseTransitionImpl: ComponentOptions = {
name: `BaseTransition`,

props: {
mode: String,
appear: Boolean,
persisted: Boolean,
// enter
onBeforeEnter: TransitionHookValidator,
onEnter: TransitionHookValidator,
onAfterEnter: TransitionHookValidator,
onEnterCancelled: TransitionHookValidator,
// leave
onBeforeLeave: TransitionHookValidator,
onLeave: TransitionHookValidator,
onAfterLeave: TransitionHookValidator,
onLeaveCancelled: TransitionHookValidator,
// appear
onBeforeAppear: TransitionHookValidator,
onAppear: TransitionHookValidator,
onAfterAppear: TransitionHookValidator,
onAppearCancelled: TransitionHookValidator
},
props: BaseTransitionPropsValidators,

setup(props: BaseTransitionProps, { slots }: SetupContext) {
const instance = getCurrentInstance()!
Expand Down
3 changes: 2 additions & 1 deletion packages/runtime-core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ export { Suspense, SuspenseProps } from './components/Suspense'
export { KeepAlive, KeepAliveProps } from './components/KeepAlive'
export {
BaseTransition,
BaseTransitionProps
BaseTransitionPropsValidators,
type BaseTransitionProps
} from './components/BaseTransition'
// For using custom directives
export { withDirectives } from './directives'
Expand Down
3 changes: 2 additions & 1 deletion packages/runtime-dom/src/components/Transition.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {
BaseTransition,
BaseTransitionProps,
BaseTransitionPropsValidators,
h,
assertNumber,
FunctionalComponent,
Expand Down Expand Up @@ -74,7 +75,7 @@ const DOMTransitionPropsValidators = {
export const TransitionPropsValidators = (Transition.props =
/*#__PURE__*/ extend(
{},
(BaseTransition as any).props,
BaseTransitionPropsValidators as any,
DOMTransitionPropsValidators
))

Expand Down

0 comments on commit 3a6f5eb

Please sign in to comment.