1
1
import React , { useState , useRef , useEffect , useCallback , useMemo } from "react" ;
2
2
import { default as Menu } from "antd/es/menu" ;
3
3
import { ColumnTypeCompBuilder } from "comps/comps/tableComp/column/columnTypeCompBuilder" ;
4
- import { ActionSelectorControlInContext } from "comps/controls/actionSelector/actionSelectorControl" ;
5
4
import { BoolCodeControl , StringControl } from "comps/controls/codeControl" ;
6
5
import { manualOptionsControl } from "comps/controls/optionsControl" ;
7
6
import { MultiCompBuilder } from "comps/generators" ;
@@ -10,6 +9,9 @@ import { trans } from "i18n";
10
9
import styled from "styled-components" ;
11
10
import { ColumnLink } from "comps/comps/tableComp/column/columnTypeComps/columnLinkComp" ;
12
11
import { LightActiveTextColor , PrimaryColor } from "constants/style" ;
12
+ import { clickEvent , eventHandlerControl } from "comps/controls/eventHandlerControl" ;
13
+ import { migrateOldData } from "@lowcoder-ee/comps/generators/simpleGenerators" ;
14
+ import { fixOldActionData } from "comps/comps/tableComp/column/simpleColumnTypeComps" ;
13
15
14
16
const MenuLinkWrapper = styled . div `
15
17
> a {
@@ -37,11 +39,13 @@ const MenuWrapper = styled.div`
37
39
}
38
40
` ;
39
41
42
+ const LinkEventOptions = [ clickEvent ] as const ;
43
+
40
44
// Memoized menu item component
41
45
const MenuItem = React . memo ( ( { option, index } : { option : any ; index : number } ) => {
42
46
const handleClick = useCallback ( ( ) => {
43
47
if ( ! option . disabled && option . onClick ) {
44
- option . onClick ( ) ;
48
+ option . onClick ( "click" ) ;
45
49
}
46
50
} , [ option . disabled , option . onClick ] ) ;
47
51
@@ -58,10 +62,10 @@ const MenuItem = React.memo(({ option, index }: { option: any; index: number })
58
62
59
63
MenuItem . displayName = 'MenuItem' ;
60
64
61
- const OptionItem = new MultiCompBuilder (
65
+ const OptionItemTmp = new MultiCompBuilder (
62
66
{
63
67
label : StringControl ,
64
- onClick : ActionSelectorControlInContext ,
68
+ onClick : eventHandlerControl ( LinkEventOptions ) ,
65
69
hidden : BoolCodeControl ,
66
70
disabled : BoolCodeControl ,
67
71
} ,
@@ -73,17 +77,16 @@ const OptionItem = new MultiCompBuilder(
73
77
return (
74
78
< >
75
79
{ children . label . propertyView ( { label : trans ( "label" ) } ) }
76
- { children . onClick . propertyView ( {
77
- label : trans ( "table.action" ) ,
78
- placement : "table" ,
79
- } ) }
80
80
{ hiddenPropertyView ( children ) }
81
81
{ disabledPropertyView ( children ) }
82
+ { children . onClick . propertyView ( ) }
82
83
</ >
83
84
) ;
84
85
} )
85
86
. build ( ) ;
86
87
88
+ const OptionItem = migrateOldData ( OptionItemTmp , fixOldActionData ) ;
89
+
87
90
// Memoized menu component
88
91
const LinksMenu = React . memo ( ( { options } : { options : any [ ] } ) => {
89
92
const mountedRef = useRef ( true ) ;
@@ -114,7 +117,7 @@ const LinksMenu = React.memo(({ options }: { options: any[] }) => {
114
117
115
118
LinksMenu . displayName = 'LinksMenu' ;
116
119
117
- export const ColumnLinksComp = ( function ( ) {
120
+ const ColumnLinksCompTmp = ( function ( ) {
118
121
const childrenMap = {
119
122
options : manualOptionsControl ( OptionItem , {
120
123
initOptions : [ { label : trans ( "table.option1" ) } ] ,
@@ -137,3 +140,5 @@ export const ColumnLinksComp = (function () {
137
140
) )
138
141
. build ( ) ;
139
142
} ) ( ) ;
143
+
144
+ export const ColumnLinksComp = migrateOldData ( ColumnLinksCompTmp , fixOldActionData ) ;
0 commit comments