fix(transition): should ship props declarations in production
This commit is contained in:
parent
b8da8b2dfa
commit
42278317e1
@ -1,7 +1,6 @@
|
|||||||
import {
|
import {
|
||||||
getCurrentInstance,
|
getCurrentInstance,
|
||||||
SetupContext,
|
SetupContext,
|
||||||
ComponentOptions,
|
|
||||||
ComponentInternalInstance
|
ComponentInternalInstance
|
||||||
} from '../component'
|
} from '../component'
|
||||||
import {
|
import {
|
||||||
@ -100,6 +99,23 @@ export function useTransitionState(): TransitionState {
|
|||||||
|
|
||||||
const BaseTransitionImpl = {
|
const BaseTransitionImpl = {
|
||||||
name: `BaseTransition`,
|
name: `BaseTransition`,
|
||||||
|
|
||||||
|
props: {
|
||||||
|
mode: String,
|
||||||
|
appear: Boolean,
|
||||||
|
persisted: Boolean,
|
||||||
|
// enter
|
||||||
|
onBeforeEnter: Function,
|
||||||
|
onEnter: Function,
|
||||||
|
onAfterEnter: Function,
|
||||||
|
onEnterCancelled: Function,
|
||||||
|
// leave
|
||||||
|
onBeforeLeave: Function,
|
||||||
|
onLeave: Function,
|
||||||
|
onAfterLeave: Function,
|
||||||
|
onLeaveCancelled: Function
|
||||||
|
},
|
||||||
|
|
||||||
setup(props: BaseTransitionProps, { slots }: SetupContext) {
|
setup(props: BaseTransitionProps, { slots }: SetupContext) {
|
||||||
const instance = getCurrentInstance()!
|
const instance = getCurrentInstance()!
|
||||||
const state = useTransitionState()
|
const state = useTransitionState()
|
||||||
@ -201,24 +217,6 @@ const BaseTransitionImpl = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (__DEV__) {
|
|
||||||
;(BaseTransitionImpl as ComponentOptions).props = {
|
|
||||||
mode: String,
|
|
||||||
appear: Boolean,
|
|
||||||
persisted: Boolean,
|
|
||||||
// enter
|
|
||||||
onBeforeEnter: Function,
|
|
||||||
onEnter: Function,
|
|
||||||
onAfterEnter: Function,
|
|
||||||
onEnterCancelled: Function,
|
|
||||||
// leave
|
|
||||||
onBeforeLeave: Function,
|
|
||||||
onLeave: Function,
|
|
||||||
onAfterLeave: Function,
|
|
||||||
onLeaveCancelled: Function
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// export the public type for h/tsx inference
|
// export the public type for h/tsx inference
|
||||||
// also to avoid inline import() in generated d.ts files
|
// also to avoid inline import() in generated d.ts files
|
||||||
export const BaseTransition = (BaseTransitionImpl as any) as {
|
export const BaseTransition = (BaseTransitionImpl as any) as {
|
||||||
|
@ -37,7 +37,7 @@ export const Transition: FunctionalComponent<TransitionProps> = (
|
|||||||
{ slots }
|
{ slots }
|
||||||
) => h(BaseTransition, resolveTransitionProps(props), slots)
|
) => h(BaseTransition, resolveTransitionProps(props), slots)
|
||||||
|
|
||||||
export const TransitionPropsValidators = {
|
export const TransitionPropsValidators = (Transition.props = {
|
||||||
...(BaseTransition as any).props,
|
...(BaseTransition as any).props,
|
||||||
name: String,
|
name: String,
|
||||||
type: String,
|
type: String,
|
||||||
@ -55,11 +55,7 @@ export const TransitionPropsValidators = {
|
|||||||
leaveFromClass: String,
|
leaveFromClass: String,
|
||||||
leaveActiveClass: String,
|
leaveActiveClass: String,
|
||||||
leaveToClass: String
|
leaveToClass: String
|
||||||
}
|
})
|
||||||
|
|
||||||
if (__DEV__) {
|
|
||||||
Transition.props = TransitionPropsValidators
|
|
||||||
}
|
|
||||||
|
|
||||||
export function resolveTransitionProps({
|
export function resolveTransitionProps({
|
||||||
name = 'v',
|
name = 'v',
|
||||||
|
@ -36,6 +36,12 @@ export type TransitionGroupProps = Omit<TransitionProps, 'mode'> & {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const TransitionGroupImpl = {
|
const TransitionGroupImpl = {
|
||||||
|
props: {
|
||||||
|
...TransitionPropsValidators,
|
||||||
|
tag: String,
|
||||||
|
moveClass: String
|
||||||
|
},
|
||||||
|
|
||||||
setup(props: TransitionGroupProps, { slots }: SetupContext) {
|
setup(props: TransitionGroupProps, { slots }: SetupContext) {
|
||||||
const instance = getCurrentInstance()!
|
const instance = getCurrentInstance()!
|
||||||
const state = useTransitionState()
|
const state = useTransitionState()
|
||||||
@ -130,21 +136,15 @@ const TransitionGroupImpl = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// remove mode props as TransitionGroup doesn't support it
|
||||||
|
delete TransitionGroupImpl.props.mode
|
||||||
|
|
||||||
export const TransitionGroup = (TransitionGroupImpl as unknown) as {
|
export const TransitionGroup = (TransitionGroupImpl as unknown) as {
|
||||||
new (): {
|
new (): {
|
||||||
$props: TransitionGroupProps
|
$props: TransitionGroupProps
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (__DEV__) {
|
|
||||||
const props = ((TransitionGroup as any).props = {
|
|
||||||
...TransitionPropsValidators,
|
|
||||||
tag: String,
|
|
||||||
moveClass: String
|
|
||||||
})
|
|
||||||
delete props.mode
|
|
||||||
}
|
|
||||||
|
|
||||||
function callPendingCbs(c: VNode) {
|
function callPendingCbs(c: VNode) {
|
||||||
const el = c.el as any
|
const el = c.el as any
|
||||||
if (el._moveCb) {
|
if (el._moveCb) {
|
||||||
|
Loading…
Reference in New Issue
Block a user