@@ -14,7 +14,21 @@ import { CSSProperties } from "react";
1414import { RecordConstructorToComp } from "lowcoder-core" ;
1515import { ToViewReturn } from "@lowcoder-ee/comps/generators/multi" ;
1616import { clickEvent , eventHandlerControl } from "comps/controls/eventHandlerControl" ;
17+ import { migrateOldData } from "@lowcoder-ee/comps/generators/simpleGenerators" ;
1718
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+ }
1832export const ColumnValueTooltip = trans ( "table.columnValueTooltip" ) ;
1933
2034export const ButtonTypeOptions = [
@@ -38,7 +52,7 @@ const childrenMap = {
3852text :StringControl ,
3953buttonType :dropdownControl ( ButtonTypeOptions , "primary" ) ,
4054onEvent :eventHandlerControl ( ButtonEventOptions ) ,
41- onClick :ActionSelectorControlInContext ,
55+ onClick :eventHandlerControl ( ButtonEventOptions ) , // ActionSelectorControlInContext,
4256loading :BoolCodeControl ,
4357disabled :BoolCodeControl ,
4458prefixIcon :IconControl ,
@@ -53,8 +67,7 @@ const ButtonStyled = React.memo(({ props }: { props: ToViewReturn<RecordConstruc
5367const iconOnly = ! hasText && ( hasPrefixIcon || hasSuffixIcon ) ;
5468
5569const handleClick = useCallback ( ( e :React . MouseEvent ) => {
56- props . onClick ?.( ) ;
57- // props.onEvent?.("click");
70+ props . onClick ?.( "click" ) ;
5871} , [ props . onClick , props . onEvent ] ) ;
5972
6073const buttonStyle = useMemo ( ( ) => ( {
@@ -81,7 +94,7 @@ const ButtonStyled = React.memo(({ props }: { props: ToViewReturn<RecordConstruc
8194) ;
8295} ) ;
8396
84- export const ButtonComp = ( function ( ) {
97+ const ButtonCompTmp = ( function ( ) {
8598return new ColumnTypeCompBuilder (
8699childrenMap ,
87100( props ) => < ButtonStyled props = { props } /> ,
@@ -105,12 +118,10 @@ export const ButtonComp = (function () {
105118} ) }
106119{ loadingPropertyView ( children ) }
107120{ disabledPropertyView ( children ) }
108- { /* {children.onEvent.propertyView()} */ }
109- { children . onClick . propertyView ( {
110- label :trans ( "table.action" ) ,
111- placement :"table" ,
112- } ) }
121+ { children . onClick . propertyView ( ) }
113122</ >
114123) )
115124. build ( ) ;
116125} ) ( ) ;
126+
127+ export const ButtonComp = migrateOldData ( ButtonCompTmp , fixOldActionData ) ;