@@ -6,7 +6,7 @@ import { AutoHeightControl } from "comps/controls/autoHeightControl";
6
6
import { BoolControl } from "comps/controls/boolControl" ;
7
7
import { StringControl } from "comps/controls/codeControl" ;
8
8
import { booleanExposingStateControl } from "comps/controls/codeStateControl" ;
9
- import { PositionControl , LeftRightControl } from "comps/controls/dropdownControl" ;
9
+ import { PositionControl , LeftRightControl , HorizontalAlignmentControl } from "comps/controls/dropdownControl" ;
10
10
import { closeEvent , eventHandlerControl } from "comps/controls/eventHandlerControl" ;
11
11
import { styleControl } from "comps/controls/styleControl" ;
12
12
import { DrawerStyle } from "comps/controls/styleControlConstants" ;
@@ -24,6 +24,7 @@ import styled from "styled-components";
24
24
import { useUserViewMode } from "util/hooks" ;
25
25
import { isNumeric } from "util/stringUtils" ;
26
26
import { NameConfig , withExposingConfigs } from "../generators/withExposing" ;
27
+ import { title } from "process" ;
27
28
28
29
const EventOptions = [ closeEvent ] as const ;
29
30
@@ -33,12 +34,23 @@ const DEFAULT_PADDING = 16;
33
34
const DrawerWrapper = styled . div `
34
35
// Shield the mouse events of the lower layer, the mask can be closed in the edit mode to prevent the lower layer from sliding
35
36
pointer-events: auto;
37
+ .ant-drawer-header-title {
38
+ margin: 0px 20px !important;
39
+ font-size: 16px;
40
+ }
36
41
` ;
37
42
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 } > `
39
51
position: absolute;
40
52
${ ( props ) => props . $closePosition === "right" ? "right: 0;" : "left: 0;" }
41
- top: 0 ;
53
+ top: ${ ( props ) => props . $title !== "" ? "2px" : "0px" } ;
42
54
z-index: 10;
43
55
font-weight: 700;
44
56
box-shadow: none;
@@ -69,44 +81,15 @@ function transToPxSize(size: string | number) {
69
81
return isNumeric ( size ) ? size + "px" : ( size as string ) ;
70
82
}
71
83
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
-
103
84
let TmpDrawerComp = ( function ( ) {
104
85
return new ContainerCompBuilder (
105
86
{
106
87
visible : booleanExposingStateControl ( "visible" ) ,
107
88
onEvent : eventHandlerControl ( EventOptions ) ,
108
89
width : StringControl ,
109
90
height : StringControl ,
91
+ title : StringControl ,
92
+ titleAlign : HorizontalAlignmentControl ,
110
93
autoHeight : AutoHeightControl ,
111
94
style : styleControl ( DrawerStyle ) ,
112
95
placement : PositionControl ,
@@ -135,7 +118,7 @@ let TmpDrawerComp = (function () {
135
118
return (
136
119
< BackgroundColorContext . Provider value = { props . style . background } >
137
120
< DrawerWrapper >
138
- < Drawer
121
+ < StyledDrawer
139
122
resizable = { resizable }
140
123
onResizeStop = { onResizeStop }
141
124
rootStyle = { props . visible . value ? { overflow : "auto" , pointerEvents : "auto" } : { } }
@@ -149,6 +132,8 @@ let TmpDrawerComp = (function () {
149
132
backgroundColor : props . style . background
150
133
}
151
134
} }
135
+ title = { props . title }
136
+ $titleAlign = { props . titleAlign }
152
137
closable = { false }
153
138
placement = { props . placement }
154
139
open = { props . visible . value }
@@ -188,7 +173,7 @@ let TmpDrawerComp = (function () {
188
173
hintPlaceholder = { HintPlaceHolder }
189
174
bgColor = { props . style . background }
190
175
/>
191
- </ Drawer >
176
+ </ StyledDrawer >
192
177
</ DrawerWrapper >
193
178
</ BackgroundColorContext . Provider >
194
179
) ;
@@ -197,6 +182,8 @@ let TmpDrawerComp = (function () {
197
182
. setPropertyViewFn ( ( children ) => (
198
183
< >
199
184
< 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 } ) }
200
187
{ children . closePosition . propertyView ( { label : trans ( "drawer.closePosition" ) , radioButton : true } ) }
201
188
{ children . placement . propertyView ( { label : trans ( "drawer.placement" ) , radioButton : true } ) }
202
189
{ [ "top" , "bottom" ] . includes ( children . placement . getView ( ) )
0 commit comments