@@ -10,40 +10,26 @@ export type Placement = 'left' | 'top' | 'right' | 'bottom';
10
10
export interface DrawerProps
11
11
extends Omit < DrawerPopupProps , 'prefixCls' | 'inline' | 'scrollLocker' > {
12
12
prefixCls ?: string ;
13
-
14
13
open ?: boolean ;
15
14
onClose ?: ( e : React . MouseEvent | React . KeyboardEvent ) => void ;
16
15
destroyOnClose ?: boolean ;
17
16
getContainer ?: PortalProps [ 'getContainer' ] ;
18
17
}
19
18
20
- // Default Value.
21
- // Since spread with default value will make this all over components.
22
- // Let's maintain this in one place.
23
- const defaultProps = {
24
- open : false ,
25
- prefixCls : 'rc-drawer' ,
26
- placement : 'right' as Placement ,
27
- autoFocus : true ,
28
- keyboard : true ,
29
- width : 378 ,
30
- mask : true ,
31
- maskClosable : true ,
32
- } ;
33
-
34
- const Drawer : React . FC < DrawerProps > = drawerProps => {
35
- const props = {
36
- ...defaultProps ,
37
- ...drawerProps ,
38
- } ;
19
+ const Drawer : React . FC < DrawerProps > = props => {
39
20
const {
40
- open,
21
+ open = false ,
22
+ prefixCls = 'rc-drawer' ,
23
+ placement = 'right' as Placement ,
24
+ autoFocus = true ,
25
+ keyboard = true ,
26
+ width = 378 ,
27
+ mask = true ,
28
+ maskClosable = true ,
41
29
getContainer,
42
30
forceRender,
43
- prefixCls,
44
31
afterOpenChange,
45
32
destroyOnClose,
46
- mask,
47
33
} = props ;
48
34
49
35
const [ animatedVisible , setAnimatedVisible ] = React . useState ( false ) ;
@@ -65,9 +51,17 @@ const Drawer: React.FC<DrawerProps> = drawerProps => {
65
51
return null ;
66
52
}
67
53
68
- const sharedDrawerProps = {
54
+ const drawerPopupProps = {
69
55
...props ,
56
+ open,
70
57
prefixCls,
58
+ placement,
59
+ autoFocus,
60
+ keyboard,
61
+ width,
62
+ mask,
63
+ maskClosable,
64
+ inline : getContainer === false ,
71
65
afterOpenChange : internalAfterOpenChange ,
72
66
} ;
73
67
@@ -78,7 +72,7 @@ const Drawer: React.FC<DrawerProps> = drawerProps => {
78
72
getContainer = { getContainer }
79
73
autoLock = { mask && ( open || animatedVisible ) }
80
74
>
81
- < DrawerPopup { ...sharedDrawerProps } inline = { getContainer === false } />
75
+ < DrawerPopup { ...drawerPopupProps } />
82
76
</ Portal >
83
77
) ;
84
78
} ;
0 commit comments