@@ -7,6 +7,8 @@ import { trans } from "i18n";
7
7
import { useStyle } from "comps/controls/styleControl" ;
8
8
import { ButtonStyle } from "comps/controls/styleControlConstants" ;
9
9
import { Button100 } from "comps/comps/buttonComp/buttonCompConstants" ;
10
+ import { IconControl } from "comps/controls/iconControl" ;
11
+ import { hasIcon } from "comps/utils" ;
10
12
11
13
export const ColumnValueTooltip = trans ( "table.columnValueTooltip" ) ;
12
14
@@ -20,7 +22,7 @@ export const ButtonTypeOptions = [
20
22
value : "default" ,
21
23
} ,
22
24
{
23
- label : trans ( "text" ) ,
25
+ label : trans ( "table. text" ) ,
24
26
value : "text" ,
25
27
} ,
26
28
] as const ;
@@ -32,23 +34,36 @@ export const ButtonComp = (function () {
32
34
onClick : ActionSelectorControlInContext ,
33
35
loading : BoolCodeControl ,
34
36
disabled : BoolCodeControl ,
37
+ prefixIcon : IconControl ,
38
+ suffixIcon : IconControl ,
35
39
} ;
36
40
return new ColumnTypeCompBuilder (
37
41
childrenMap ,
38
42
( props ) => {
39
43
const ButtonStyled = ( ) => {
40
44
const style = useStyle ( ButtonStyle ) ;
45
+ const hasText = ! ! props . text ;
46
+ const hasPrefixIcon = hasIcon ( props . prefixIcon ) ;
47
+ const hasSuffixIcon = hasIcon ( props . suffixIcon ) ;
48
+ const iconOnly = ! hasText && ( hasPrefixIcon || hasSuffixIcon ) ;
49
+
41
50
return (
42
51
< Button100
43
52
type = { props . buttonType }
44
53
onClick = { props . onClick }
45
54
loading = { props . loading }
46
55
disabled = { props . disabled }
47
56
$buttonStyle = { props . buttonType === "primary" ? style : undefined }
48
- style = { { margin : 0 } }
57
+ style = { {
58
+ margin : 0 ,
59
+ width : iconOnly ? 'auto' : undefined ,
60
+ minWidth : iconOnly ? 'auto' : undefined ,
61
+ padding : iconOnly ? '0 8px' : undefined
62
+ } }
63
+ icon = { hasPrefixIcon ? props . prefixIcon : undefined }
49
64
>
50
- { /* prevent the button from disappearing */ }
51
- { ! props . text ? " " : props . text }
65
+ { hasText ? props . text : ( iconOnly ? null : " " ) }
66
+ { hasSuffixIcon && ! props . loading && < span style = { { marginLeft : hasText ? '8px' : 0 } } > { props . suffixIcon } </ span > }
52
67
</ Button100 >
53
68
) ;
54
69
} ;
@@ -62,6 +77,12 @@ export const ButtonComp = (function () {
62
77
label : trans ( "table.columnValue" ) ,
63
78
tooltip : ColumnValueTooltip ,
64
79
} ) }
80
+ { children . prefixIcon . propertyView ( {
81
+ label : trans ( "button.prefixIcon" ) ,
82
+ } ) }
83
+ { children . suffixIcon . propertyView ( {
84
+ label : trans ( "button.suffixIcon" ) ,
85
+ } ) }
65
86
{ children . buttonType . propertyView ( {
66
87
label : trans ( "table.type" ) ,
67
88
radioButton : true ,
0 commit comments