@@ -22,18 +22,18 @@ import {
22
22
getButtonStyle ,
23
23
} from "./buttonCompConstants" ;
24
24
import { styleControl } from "@lowcoder-ee/comps/controls/styleControl" ;
25
+ import { dropdownControl } from "@lowcoder-ee/comps/controls/dropdownControl" ;
25
26
26
27
const StyledDropdownButton = styled ( DropdownButton ) `
27
28
width: 100%;
28
29
29
30
.ant-btn-group {
30
31
width: 100%;
31
-
32
32
}
33
33
` ;
34
34
35
35
const LeftButtonWrapper = styled . div < { $buttonStyle : DropdownStyleType } > `
36
- width: calc(100%) ;
36
+ flex: 1 ;
37
37
${ ( props ) => `margin: ${ props . $buttonStyle . margin } ;` }
38
38
margin-right: 0;
39
39
.ant-btn span {
@@ -42,12 +42,11 @@ const LeftButtonWrapper = styled.div<{ $buttonStyle: DropdownStyleType }>`
42
42
}
43
43
44
44
.ant-btn {
45
- ${ ( props ) => getButtonStyle ( props . $buttonStyle ) }
45
+ ${ ( props ) => getButtonStyle ( props . $buttonStyle as any ) }
46
46
margin: 0 !important;
47
47
height: 100%;
48
48
&.ant-btn-default {
49
49
margin: 0 !important;
50
-
51
50
${ ( props ) => `border-radius: ${ props . $buttonStyle . radius } 0 0 ${ props . $buttonStyle . radius } ;` }
52
51
${ ( props ) => `text-transform: ${ props . $buttonStyle . textTransform } ;` }
53
52
${ ( props ) => `font-weight: ${ props . $buttonStyle . textWeight } ;` }
@@ -65,11 +64,11 @@ const LeftButtonWrapper = styled.div<{ $buttonStyle: DropdownStyleType }>`
65
64
` ;
66
65
67
66
const RightButtonWrapper = styled . div < { $buttonStyle : DropdownStyleType } > `
68
- // width: 32px;
67
+ width: 32px;
69
68
${ ( props ) => `margin: ${ props . $buttonStyle . margin } ;` }
70
69
margin-left: -1px;
71
70
.ant-btn {
72
- ${ ( props ) => getButtonStyle ( props . $buttonStyle ) }
71
+ ${ ( props ) => getButtonStyle ( props . $buttonStyle as any ) }
73
72
margin: 0 !important;
74
73
height: 100%;
75
74
&.ant-btn-default {
@@ -80,10 +79,16 @@ const RightButtonWrapper = styled.div<{ $buttonStyle: DropdownStyleType }>`
80
79
}
81
80
` ;
82
81
82
+ const triggerOptions = [
83
+ { label : "Hover" , value : "hover" } ,
84
+ { label : "Click" , value : "click" } ,
85
+ ] as const ;
86
+
83
87
const DropdownTmpComp = ( function ( ) {
84
88
const childrenMap = {
85
89
text : withDefault ( StringControl , trans ( "menu" ) ) ,
86
90
onlyMenu : BoolControl ,
91
+ triggerMode : dropdownControl ( triggerOptions , "hover" ) ,
87
92
options : DropdownOptionControl ,
88
93
disabled : BoolCodeControl ,
89
94
onEvent : ButtonEventHandlerControl ,
@@ -121,15 +126,17 @@ const DropdownTmpComp = (function () {
121
126
< Dropdown
122
127
disabled = { props . disabled }
123
128
dropdownRender = { ( ) => menu }
129
+ trigger = { [ props . triggerMode ] }
124
130
>
125
- < Button100 $buttonStyle = { props . style } disabled = { props . disabled } >
131
+ < Button100 $buttonStyle = { props . style as any } disabled = { props . disabled } >
126
132
{ props . text || " " /* Avoid button disappearing */ }
127
133
</ Button100 >
128
134
</ Dropdown >
129
135
) : (
130
136
< StyledDropdownButton
131
137
disabled = { props . disabled }
132
138
dropdownRender = { ( ) => menu }
139
+ trigger = { [ props . triggerMode ] }
133
140
onClick = { ( ) => props . onEvent ( "click" ) }
134
141
buttonsRender = { ( [ left , right ] ) => [
135
142
< LeftButtonWrapper $buttonStyle = { props . style } >
@@ -170,6 +177,10 @@ const DropdownTmpComp = (function () {
170
177
< >
171
178
< Section name = { sectionNames . layout } >
172
179
{ children . text . propertyView ( { label : trans ( "label" ) } ) }
180
+ { children . triggerMode . propertyView ( {
181
+ label : trans ( "dropdown.triggerMode" ) ,
182
+ radioButton : true ,
183
+ } ) }
173
184
{ children . onlyMenu . propertyView ( { label : trans ( "dropdown.onlyMenu" ) } ) }
174
185
</ Section >
175
186
< Section name = { sectionNames . style } > { children . style . getPropertyView ( ) } </ Section >
0 commit comments