@@ -4,19 +4,23 @@ import {
4
4
ColumnTypeCompBuilder ,
5
5
ColumnTypeViewFn ,
6
6
} from "comps/comps/tableComp/column/columnTypeCompBuilder" ;
7
- import { ActionSelectorControlInContext } from "comps/controls/actionSelector/actionSelectorControl" ;
8
7
import { BoolCodeControl , StringControl } from "comps/controls/codeControl" ;
9
8
import { trans } from "i18n" ;
10
9
import { disabledPropertyView } from "comps/utils/propertyUtils" ;
11
10
import styled , { css } from "styled-components" ;
12
11
import { styleControl } from "comps/controls/styleControl" ;
13
12
import { TableColumnLinkStyle } from "comps/controls/styleControlConstants" ;
13
+ import { clickEvent , eventHandlerControl } from "comps/controls/eventHandlerControl" ;
14
+ import { migrateOldData } from "@lowcoder-ee/comps/generators/simpleGenerators" ;
15
+ import { fixOldActionData } from "comps/comps/tableComp/column/simpleColumnTypeComps" ;
14
16
15
17
export const ColumnValueTooltip = trans ( "table.columnValueTooltip" ) ;
16
18
19
+ const LinkEventOptions = [ clickEvent ] as const ;
20
+
17
21
const childrenMap = {
18
22
text : StringControl ,
19
- onClick : ActionSelectorControlInContext ,
23
+ onClick : eventHandlerControl ( LinkEventOptions ) ,
20
24
disabled : BoolCodeControl ,
21
25
style : styleControl ( TableColumnLinkStyle ) ,
22
26
} ;
@@ -34,11 +38,10 @@ const StyledLink = styled.a<{ $disabled: boolean }>`
34
38
` ;
35
39
36
40
// Memoized link component
37
- export const ColumnLink = React . memo ( ( { disabled, label, onClick } : { disabled : boolean ; label : string ; onClick ?: ( ) => void } ) => {
41
+ export const ColumnLink = React . memo ( ( { disabled, label, onClick } : { disabled : boolean ; label : string ; onClick ?: ( eventName : string ) => void } ) => {
38
42
const handleClick = useCallback ( ( ) => {
39
- if ( ! disabled && onClick ) {
40
- onClick ( ) ;
41
- }
43
+ if ( disabled ) return ;
44
+ onClick ?.( "click" ) ;
42
45
} , [ disabled , onClick ] ) ;
43
46
44
47
return (
@@ -101,7 +104,7 @@ LinkEdit.displayName = 'LinkEdit';
101
104
102
105
const getBaseValue : ColumnTypeViewFn < typeof childrenMap , string , string > = ( props ) => props . text ;
103
106
104
- export const LinkComp = ( function ( ) {
107
+ const LinkCompTmp = ( function ( ) {
105
108
return new ColumnTypeCompBuilder (
106
109
childrenMap ,
107
110
( props , dispatch ) => {
@@ -125,10 +128,7 @@ export const LinkComp = (function () {
125
128
tooltip : ColumnValueTooltip ,
126
129
} ) }
127
130
{ disabledPropertyView ( children ) }
128
- { children . onClick . propertyView ( {
129
- label : trans ( "table.action" ) ,
130
- placement : "table" ,
131
- } ) }
131
+ { children . onClick . propertyView ( ) }
132
132
</ >
133
133
) )
134
134
. setStylePropertyViewFn ( ( children ) => (
@@ -138,3 +138,5 @@ export const LinkComp = (function () {
138
138
) )
139
139
. build ( ) ;
140
140
} ) ( ) ;
141
+
142
+ export const LinkComp = migrateOldData ( LinkCompTmp , fixOldActionData ) ;
0 commit comments