@@ -22,6 +22,12 @@ export enum DrawerType {
2222 Normal = 'normal' ,
2323}
2424
25+ enum DrawerSize {
26+ Small = 720 ,
27+ Default = 1000 ,
28+ Large = 1256 ,
29+ }
30+
2531interface BaseDrawerProps extends Omit < AntdDrawerProps , 'placement' | 'children' > {
2632 size ?: 'small' | 'default' | 'large' ;
2733 loading ?: boolean ;
@@ -56,9 +62,9 @@ function isControlled<T extends readOnlyTab>(props: DrawerProps<T>): props is Dr
5662}
5763
5864const getWidthFromSize = ( size : DrawerProps [ 'size' ] ) => {
59- if ( size === 'small' ) return 720 ;
60- if ( size === 'large' ) return 1256 ;
61- return 1000 ;
65+ if ( size === 'small' ) return ` ${ ( DrawerSize . Small / 1440 ) * 100 } %` ;
66+ if ( size === 'large' ) return ` ${ ( DrawerSize . Large / 1440 ) * 100 } %` ;
67+ return ` ${ ( DrawerSize . Default / 1440 ) * 100 } %` ;
6268} ;
6369
6470const isValidBanner = ( banner : DrawerProps [ 'banner' ] ) : banner is AlertProps [ 'message' ] => {
@@ -67,7 +73,7 @@ const isValidBanner = (banner: DrawerProps['banner']): banner is AlertProps['mes
6773} ;
6874
6975const Drawer = < T extends readOnlyTab > ( props : DrawerProps < T > ) => {
70- const slidePrefixCls = 'dtc-drawer' ;
76+ const drawerPrefixCls = 'dtc-drawer' ;
7177
7278 const {
7379 open,
@@ -89,7 +95,7 @@ const Drawer = <T extends readOnlyTab>(props: DrawerProps<T>) => {
8995 const finalWidth = width ?? getWidthFromSize ( size ) ;
9096 const isFormType = type === DrawerType . Form ;
9197
92- const [ internalTabKey , setInternalTabKey ] = useState ( '' ) ;
98+ const [ internalTabKey , setInternalTabKey ] = useState < TabKey < T > > ( '' ) ;
9399
94100 useEffect ( ( ) => {
95101 open &&
@@ -102,7 +108,7 @@ const Drawer = <T extends readOnlyTab>(props: DrawerProps<T>) => {
102108 const renderButton = ( ) => {
103109 return (
104110 < img
105- className = { `${ slidePrefixCls } -icon` }
111+ className = { `${ drawerPrefixCls } -icon` }
106112 onClick = { onClose }
107113 src = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAABwCAYAAAAE0LDPAAAAAXNSR0IArs4c6QAAAnlJREFUaEPtmk9IVHEQx78jufpw7ykouuEaBG6dEmrXOmRRt476VgvyEngKlNqQMu3PoSU7iCBq4CW2olNdRMRr7HasnnZb0y57WGODzUDjt/RIonbeyzfQYd51h/m8+c7395u3MOSs5Xexr4dKRLt5AhYJtbPRaNO7velo/4Bf6YhoB8B0R3vzNSLaNr8ECnBRRLTc0d583kBEAJU3J5o6HG0ZkgTs1OBATAxgqqghTIoCiPBeFABQSRggZFOxg/anC0ElYq9JlUglYhVgA9RFKhGrABugLlKJWAXYAHWRSsQqwAaoi1QiVgE2gHVRejKDUKgWQ1cvmj/XbMLfA3jA42dwVvPo7+tBd/xo8ICNzQLG7y3AskIYvz2IcEO9LwhbgcmWebGCpeUcEvEYBvrOBg8ol7cxOjaP4lYJqZEkIm2NniGeKjDZ3mQ/YPbJa7S1NiI1YntuuGeAgTx8lMHqx3XYvWdwOnHMUxW+AJufC7hzdwH1VggTt64gHLZYiC+Ayfb85QoWl3KIn+jEpeS54AHlb98xOjaHYrGEG8M2DkWaqkJ8V2CyZd86mJl7hdaWg7h5PVm14f8EMJD0zxM+ePkCuo4f+WsV/ycgm3MwMy8k0d4mp4ZtRIJusmvTxMlODNgB21T8oLlXRbK3B6cS3maDZxeJXnbudb315Wvl9AZ+XbsDpzseQ3/QA+fTRgET9wVHpvmqcNbWK6PSjEy/D9vkB+mnaLDq5D5b/L6x7+8iBbBNVolUItYDKpFKxCrABqiLVCJWATZAXaQSsQqwAeoilYhVgA1QFzESCS8wia9giS6Rma1B0TU40UU+sVVEoWXK6uugPwBjVkdxauLcgwAAAABJRU5ErkJggg=="
108114 alt = "closeBtn"
@@ -122,19 +128,19 @@ const Drawer = <T extends readOnlyTab>(props: DrawerProps<T>) => {
122128 mask = { isFormType ? true : mask }
123129 maskClosable = { isFormType ? false : maskClosable }
124130 width = { finalWidth }
125- prefixCls = { slidePrefixCls }
131+ prefixCls = { drawerPrefixCls }
126132 onClose = { onClose }
127133 { ...rest }
128134 { ...motionProps }
129135 >
130136 { ! isFormType && renderButton ( ) }
131- < Spin wrapperClassName = { `${ slidePrefixCls } -nested-loading` } spinning = { loading } >
137+ < Spin wrapperClassName = { `${ drawerPrefixCls } -nested-loading` } spinning = { loading } >
132138 { title && (
133- < div className = { `${ slidePrefixCls } -header` } >
139+ < div className = { `${ drawerPrefixCls } -header` } >
134140 { title }
135141 { isFormType && (
136142 < CloseOutlined
137- className = { `${ slidePrefixCls } -header--icon` }
143+ className = { `${ drawerPrefixCls } -header--icon` }
138144 onClick = { onClose }
139145 />
140146 ) }
@@ -152,23 +158,23 @@ const Drawer = <T extends readOnlyTab>(props: DrawerProps<T>) => {
152158 destroyInactiveTabPane
153159 activeKey = { currentKey }
154160 onChange = { handleChangeKey }
155- className = { `${ slidePrefixCls } -tabs` }
161+ className = { `${ drawerPrefixCls } -tabs` }
156162 >
157163 { props . tabs ?. map ( ( tab : { key : string ; title : React . ReactNode } ) => (
158164 < Tabs . TabPane tab = { tab . title } key = { tab . key } />
159165 ) ) }
160166 </ Tabs >
161167 ) }
162168 < div
163- className = { classNames ( `${ slidePrefixCls } -body` , bodyClassName ) }
169+ className = { classNames ( `${ drawerPrefixCls } -body` , bodyClassName ) }
164170 style = { bodyStyle }
165171 >
166172 { isFunction ( props )
167173 ? props . children ?.( currentKey ?? '' )
168174 : ( props . children as React . ReactNode ) }
169175 </ div >
170176 { footer ? (
171- < div className = { classNames ( `${ slidePrefixCls } -footer` ) } > { footer } </ div >
177+ < div className = { classNames ( `${ drawerPrefixCls } -footer` ) } > { footer } </ div >
172178 ) : null }
173179 </ Spin >
174180 </ RcDrawer >
0 commit comments