Skip to content

Commit 3650c12

Browse files
committed
fix(types): provide types for built-in components
close #13002
1 parent 83d9535 commit 3650c12

File tree

2 files changed

+65
-0
lines changed

2 files changed

+65
-0
lines changed

types/built-in-components.d.ts

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
import { DefineComponent } from './v3-define-component'
2+
3+
type Hook<T = () => void> = T | T[]
4+
5+
export interface TransitionProps {
6+
name?: string
7+
appear?: boolean
8+
css?: boolean
9+
mode?: 'in-out' | 'out-in' | 'default'
10+
type?: 'transition' | 'animation'
11+
12+
duration?:
13+
| number
14+
| string
15+
| {
16+
enter: number
17+
leave: number
18+
}
19+
20+
// classes
21+
enterClass?: string
22+
enterActiveClass?: string
23+
enterToClass?: string
24+
appearClass?: string
25+
appearActiveClass?: string
26+
appearToClass?: string
27+
leaveClass?: string
28+
leaveActiveClass?: string
29+
leaveToClass?: string
30+
31+
// event hooks
32+
onBeforeEnter?: Hook<(el: Element) => void>
33+
onEnter?: Hook<(el: Element, done: () => void) => void>
34+
onAfterEnter?: Hook<(el: Element) => void>
35+
onEnterCancelled?: Hook<(el: Element) => void>
36+
onBeforeLeave?: Hook<(el: Element) => void>
37+
onLeave?: Hook<(el: Element, done: () => void) => void>
38+
onAfterLeave?: Hook<(el: Element) => void>
39+
onLeaveCancelled?: Hook<(el: Element) => void>
40+
onBeforeAppear?: Hook<(el: Element) => void>
41+
onAppear?: Hook<(el: Element, done: () => void) => void>
42+
onAfterAppear?: Hook<(el: Element) => void>
43+
onAppearCancelled?: Hook<(el: Element) => void>
44+
}
45+
46+
export declare const Transition: DefineComponent<TransitionProps>
47+
48+
export type TransitionGroupProps = Omit<TransitionProps, 'mode'> & {
49+
tag?: string
50+
moveClass?: string
51+
}
52+
53+
export declare const TransitionGroup: DefineComponent<TransitionGroupProps>
54+
55+
type MatchPattern = string | RegExp | (string | RegExp)[]
56+
57+
export interface KeepAliveProps {
58+
include?: MatchPattern
59+
exclude?: MatchPattern
60+
max?: number | string
61+
}
62+
63+
export declare const KeepAlive: DefineComponent<KeepAliveProps>

types/index.d.ts

+2
Original file line numberDiff line numberDiff line change
@@ -71,3 +71,5 @@ export {
7171
FunctionDirective,
7272
Directive
7373
} from './v3-directive'
74+
75+
export * from './built-in-components'

0 commit comments

Comments
 (0)