@@ -6,7 +6,7 @@ import { AutoHeightControl } from "comps/controls/autoHeightControl";
66import { BoolControl } from "comps/controls/boolControl" ;
77import { StringControl } from "comps/controls/codeControl" ;
88import { booleanExposingStateControl } from "comps/controls/codeStateControl" ;
9- import { PositionControl , LeftRightControl } from "comps/controls/dropdownControl" ;
9+ import { PositionControl , LeftRightControl , HorizontalAlignmentControl } from "comps/controls/dropdownControl" ;
1010import { closeEvent , eventHandlerControl } from "comps/controls/eventHandlerControl" ;
1111import { styleControl } from "comps/controls/styleControl" ;
1212import { DrawerStyle } from "comps/controls/styleControlConstants" ;
@@ -24,6 +24,7 @@ import styled from "styled-components";
2424import { useUserViewMode } from "util/hooks" ;
2525import { isNumeric } from "util/stringUtils" ;
2626import { NameConfig , withExposingConfigs } from "../generators/withExposing" ;
27+ import { title } from "process" ;
2728
2829const EventOptions = [ closeEvent ] as const ;
2930
@@ -33,12 +34,23 @@ const DEFAULT_PADDING = 16;
3334const DrawerWrapper = styled . div `
3435 // Shield the mouse events of the lower layer, the mask can be closed in the edit mode to prevent the lower layer from sliding
3536 pointer-events: auto;
37+ .ant-drawer-header-title {
38+ margin: 0px 20px !important;
39+ font-size: 16px;
40+ }
3641` ;
3742
38- const ButtonStyle = styled ( Button ) < { $closePosition ?: string } > `
43+ const StyledDrawer = styled ( Drawer ) < { $titleAlign ?: string } > `
44+ .ant-drawer-header-title {
45+ margin: 0px 20px !important;
46+ text-align: ${ ( props ) => props . $titleAlign || "center" } ;
47+ }
48+ ` ;
49+
50+ const ButtonStyle = styled ( Button ) < { $closePosition ?: string , $title ? :string } > `
3951 position: absolute;
4052 ${ ( props ) => props . $closePosition === "right" ? "right: 0;" : "left: 0;" }
41- top: 0 ;
53+ top: ${ ( props ) => props . $title !== "" ? "2px" : "0px" } ;
4254 z-index: 10;
4355 font-weight: 700;
4456 box-shadow: none;
@@ -69,44 +81,15 @@ function transToPxSize(size: string | number) {
6981 return isNumeric ( size ) ? size + "px" : ( size as string ) ;
7082}
7183
72- const ClosePlacementOptions = [
73- {
74- label : trans ( "drawer.left" ) ,
75- value : "left" ,
76- } ,
77- {
78- label : trans ( "drawer.right" ) ,
79- value : "right" ,
80- } ,
81- ] as const ;
82-
83- const PlacementOptions = [
84- {
85- label : trans ( "drawer.top" ) ,
86- value : "top" ,
87- } ,
88- {
89- label : trans ( "drawer.right" ) ,
90- value : "right" ,
91- } ,
92- {
93- label : trans ( "drawer.bottom" ) ,
94- value : "bottom" ,
95- } ,
96- {
97- label : trans ( "drawer.left" ) ,
98- value : "left" ,
99- } ,
100- ] as const ;
101-
102-
10384let TmpDrawerComp = ( function ( ) {
10485 return new ContainerCompBuilder (
10586 {
10687 visible : booleanExposingStateControl ( "visible" ) ,
10788 onEvent : eventHandlerControl ( EventOptions ) ,
10889 width : StringControl ,
10990 height : StringControl ,
91+ title : StringControl ,
92+ titleAlign : HorizontalAlignmentControl ,
11093 autoHeight : AutoHeightControl ,
11194 style : styleControl ( DrawerStyle ) ,
11295 placement : PositionControl ,
@@ -135,7 +118,7 @@ let TmpDrawerComp = (function () {
135118 return (
136119 < BackgroundColorContext . Provider value = { props . style . background } >
137120 < DrawerWrapper >
138- < Drawer
121+ < StyledDrawer
139122 resizable = { resizable }
140123 onResizeStop = { onResizeStop }
141124 rootStyle = { props . visible . value ? { overflow : "auto" , pointerEvents : "auto" } : { } }
@@ -149,6 +132,8 @@ let TmpDrawerComp = (function () {
149132 backgroundColor : props . style . background
150133 }
151134 } }
135+ title = { props . title }
136+ $titleAlign = { props . titleAlign }
152137 closable = { false }
153138 placement = { props . placement }
154139 open = { props . visible . value }
@@ -188,7 +173,7 @@ let TmpDrawerComp = (function () {
188173 hintPlaceholder = { HintPlaceHolder }
189174 bgColor = { props . style . background }
190175 />
191- </ Drawer >
176+ </ StyledDrawer >
192177 </ DrawerWrapper >
193178 </ BackgroundColorContext . Provider >
194179 ) ;
@@ -197,6 +182,8 @@ let TmpDrawerComp = (function () {
197182 . setPropertyViewFn ( ( children ) => (
198183 < >
199184 < Section name = { sectionNames . basic } >
185+ { children . title . propertyView ( { label : trans ( "drawer.title" ) } ) }
186+ { children . title . getView ( ) && children . titleAlign . propertyView ( { label : trans ( "drawer.titleAlign" ) , radioButton : true } ) }
200187 { children . closePosition . propertyView ( { label : trans ( "drawer.closePosition" ) , radioButton : true } ) }
201188 { children . placement . propertyView ( { label : trans ( "drawer.placement" ) , radioButton : true } ) }
202189 { [ "top" , "bottom" ] . includes ( children . placement . getView ( ) )
0 commit comments