@@ -14,7 +14,21 @@ import { CSSProperties } from "react";
14
14
import { RecordConstructorToComp } from "lowcoder-core" ;
15
15
import { ToViewReturn } from "@lowcoder-ee/comps/generators/multi" ;
16
16
import { clickEvent , eventHandlerControl } from "comps/controls/eventHandlerControl" ;
17
+ import { migrateOldData } from "@lowcoder-ee/comps/generators/simpleGenerators" ;
17
18
19
+ export const fixOldActionData = ( oldData : any ) => {
20
+ if ( ! oldData ) return oldData ;
21
+ if ( Boolean ( oldData . onClick ) ) {
22
+ return {
23
+ ...oldData ,
24
+ onClick : [ {
25
+ name : "click" ,
26
+ handler : oldData . onClick ,
27
+ } ] ,
28
+ } ;
29
+ }
30
+ return oldData ;
31
+ }
18
32
export const ColumnValueTooltip = trans ( "table.columnValueTooltip" ) ;
19
33
20
34
export const ButtonTypeOptions = [
@@ -38,7 +52,7 @@ const childrenMap = {
38
52
text : StringControl ,
39
53
buttonType : dropdownControl ( ButtonTypeOptions , "primary" ) ,
40
54
onEvent : eventHandlerControl ( ButtonEventOptions ) ,
41
- onClick : ActionSelectorControlInContext ,
55
+ onClick : eventHandlerControl ( ButtonEventOptions ) , // ActionSelectorControlInContext,
42
56
loading : BoolCodeControl ,
43
57
disabled : BoolCodeControl ,
44
58
prefixIcon : IconControl ,
@@ -53,8 +67,7 @@ const ButtonStyled = React.memo(({ props }: { props: ToViewReturn<RecordConstruc
53
67
const iconOnly = ! hasText && ( hasPrefixIcon || hasSuffixIcon ) ;
54
68
55
69
const handleClick = useCallback ( ( e : React . MouseEvent ) => {
56
- props . onClick ?.( ) ;
57
- // props.onEvent?.("click");
70
+ props . onClick ?.( "click" ) ;
58
71
} , [ props . onClick , props . onEvent ] ) ;
59
72
60
73
const buttonStyle = useMemo ( ( ) => ( {
@@ -81,7 +94,7 @@ const ButtonStyled = React.memo(({ props }: { props: ToViewReturn<RecordConstruc
81
94
) ;
82
95
} ) ;
83
96
84
- export const ButtonComp = ( function ( ) {
97
+ const ButtonCompTmp = ( function ( ) {
85
98
return new ColumnTypeCompBuilder (
86
99
childrenMap ,
87
100
( props ) => < ButtonStyled props = { props } /> ,
@@ -105,12 +118,10 @@ export const ButtonComp = (function () {
105
118
} ) }
106
119
{ loadingPropertyView ( children ) }
107
120
{ disabledPropertyView ( children ) }
108
- { /* {children.onEvent.propertyView()} */ }
109
- { children . onClick . propertyView ( {
110
- label : trans ( "table.action" ) ,
111
- placement : "table" ,
112
- } ) }
121
+ { children . onClick . propertyView ( ) }
113
122
</ >
114
123
) )
115
124
. build ( ) ;
116
125
} ) ( ) ;
126
+
127
+ export const ButtonComp = migrateOldData ( ButtonCompTmp , fixOldActionData ) ;
0 commit comments