1
- import { default as Button } from "antd/es/button" ;
2
- import { ButtonCompWrapper , buttonRefMethods } from "comps/comps/buttonComp/buttonCompConstants" ;
3
- import { BoolCodeControl , StringControl } from "comps/controls/codeControl" ;
4
- import { ButtonEventHandlerControl } from "comps/controls/eventHandlerControl" ;
5
- import { styleControl } from "comps/controls/styleControl" ;
6
- import { LinkStyle , LinkStyleType } from "comps/controls/styleControlConstants" ;
7
- import { withDefault } from "comps/generators" ;
8
- import { migrateOldData } from "comps/generators/simpleGenerators" ;
9
- import { UICompBuilder } from "comps/generators/uiCompBuilder" ;
10
- import { Section , sectionNames } from "lowcoder-design" ;
11
- import styled from "styled-components" ;
12
- import { CommonNameConfig , NameConfig , withExposingConfigs } from "../../generators/withExposing" ;
1
+ import { default as Button } from 'antd/es/button' ;
2
+ import {
3
+ ButtonCompWrapper ,
4
+ buttonRefMethods ,
5
+ } from 'comps/comps/buttonComp/buttonCompConstants' ;
6
+ import { BoolCodeControl , StringControl } from 'comps/controls/codeControl' ;
7
+ import { ButtonEventHandlerControl } from 'comps/controls/eventHandlerControl' ;
8
+ import { styleControl } from 'comps/controls/styleControl' ;
9
+ import {
10
+ AnimationStyle ,
11
+ AnimationStyleType ,
12
+ LinkStyle ,
13
+ LinkStyleType ,
14
+ } from 'comps/controls/styleControlConstants' ;
15
+ import { withDefault } from 'comps/generators' ;
16
+ import { migrateOldData } from 'comps/generators/simpleGenerators' ;
17
+ import { UICompBuilder } from 'comps/generators/uiCompBuilder' ;
18
+ import { Section , sectionNames } from 'lowcoder-design' ;
19
+ import styled from 'styled-components' ;
20
+ import {
21
+ CommonNameConfig ,
22
+ NameConfig ,
23
+ withExposingConfigs ,
24
+ } from '../../generators/withExposing' ;
13
25
import {
14
26
hiddenPropertyView ,
15
27
disabledPropertyView ,
16
28
loadingPropertyView ,
17
- } from " comps/utils/propertyUtils" ;
18
- import { trans } from " i18n" ;
19
- import { IconControl } from " comps/controls/iconControl" ;
20
- import { hasIcon } from " comps/utils" ;
21
- import { RefControl } from " comps/controls/refControl" ;
29
+ } from ' comps/utils/propertyUtils' ;
30
+ import { trans } from ' i18n' ;
31
+ import { IconControl } from ' comps/controls/iconControl' ;
32
+ import { hasIcon } from ' comps/utils' ;
33
+ import { RefControl } from ' comps/controls/refControl' ;
22
34
23
- import { EditorContext } from " comps/editorState" ;
24
- import React , { useContext } from " react" ;
35
+ import { EditorContext } from ' comps/editorState' ;
36
+ import React , { useContext } from ' react' ;
25
37
26
- const Link = styled ( Button ) < { $style : LinkStyleType } > `
38
+ const Link = styled ( Button ) < {
39
+ $style : LinkStyleType ;
40
+ $animationStyle : AnimationStyleType ;
41
+ } > `
42
+ ${ ( props ) => props . $animationStyle }
27
43
${ ( props ) => `
28
44
color: ${ props . $style . text } ;
29
45
margin: ${ props . $style . margin } ;
@@ -33,9 +49,9 @@ const Link = styled(Button) <{ $style: LinkStyleType }>`
33
49
font-family:${ props . $style . fontFamily } ;
34
50
font-weight:${ props . $style . textWeight } ;
35
51
border: ${ props . $style . borderWidth } solid ${ props . $style . border } ;
36
- border-radius:${ props . $style . radius ? props . $style . radius : '0px' } ;
37
- text-transform:${ props . $style . textTransform ? props . $style . textTransform : '' } ;
38
- text-decoration:${ props . $style . textDecoration ? props . $style . textDecoration : '' } !important;
52
+ border-radius:${ props . $style . radius ? props . $style . radius : '0px' } ;
53
+ text-transform:${ props . $style . textTransform ? props . $style . textTransform : '' } ;
54
+ text-decoration:${ props . $style . textDecoration ? props . $style . textDecoration : '' } !important;
39
55
background-color: ${ props . $style . background } ;
40
56
&:hover {
41
57
color: ${ props . $style . hoverText } !important;
@@ -45,7 +61,7 @@ const Link = styled(Button) <{ $style: LinkStyleType }>`
45
61
}
46
62
` }
47
63
48
- &.ant-btn {
64
+ &.ant-btn {
49
65
display: inline-flex;
50
66
align-items: center;
51
67
> span {
@@ -66,7 +82,7 @@ const IconWrapper = styled.span`
66
82
* compatible with old data 2022-08-26
67
83
*/
68
84
function fixOldData ( oldData : any ) {
69
- if ( oldData && oldData . hasOwnProperty ( " color" ) ) {
85
+ if ( oldData && oldData . hasOwnProperty ( ' color' ) ) {
70
86
return {
71
87
text : oldData . color ,
72
88
} ;
@@ -76,33 +92,40 @@ function fixOldData(oldData: any) {
76
92
77
93
const LinkTmpComp = ( function ( ) {
78
94
const childrenMap = {
79
- text : withDefault ( StringControl , trans ( " link.link" ) ) ,
95
+ text : withDefault ( StringControl , trans ( ' link.link' ) ) ,
80
96
onEvent : ButtonEventHandlerControl ,
81
97
disabled : BoolCodeControl ,
82
98
loading : BoolCodeControl ,
83
99
style : migrateOldData ( styleControl ( LinkStyle ) , fixOldData ) ,
100
+ animationStyle : styleControl ( AnimationStyle ) ,
84
101
prefixIcon : IconControl ,
85
102
suffixIcon : IconControl ,
86
103
viewRef : RefControl < HTMLElement > ,
87
104
} ;
88
105
return new UICompBuilder ( childrenMap , ( props ) => {
89
106
// chrome86 bug: button children should not contain only empty span
90
- const hasChildren = hasIcon ( props . prefixIcon ) || ! ! props . text || hasIcon ( props . suffixIcon ) ;
107
+ const hasChildren =
108
+ hasIcon ( props . prefixIcon ) || ! ! props . text || hasIcon ( props . suffixIcon ) ;
91
109
return (
92
110
< ButtonCompWrapper disabled = { props . disabled } >
93
111
< Link
112
+ $animationStyle = { props . animationStyle }
94
113
ref = { props . viewRef }
95
114
$style = { props . style }
96
115
loading = { props . loading }
97
116
disabled = { props . disabled }
98
- onClick = { ( ) => props . onEvent ( " click" ) }
99
- type = { " link" }
117
+ onClick = { ( ) => props . onEvent ( ' click' ) }
118
+ type = { ' link' }
100
119
>
101
120
{ hasChildren && (
102
121
< span >
103
- { hasIcon ( props . prefixIcon ) && < IconWrapper > { props . prefixIcon } </ IconWrapper > }
122
+ { hasIcon ( props . prefixIcon ) && (
123
+ < IconWrapper > { props . prefixIcon } </ IconWrapper >
124
+ ) }
104
125
{ ! ! props . text && props . text }
105
- { hasIcon ( props . suffixIcon ) && < IconWrapper > { props . suffixIcon } </ IconWrapper > }
126
+ { hasIcon ( props . suffixIcon ) && (
127
+ < IconWrapper > { props . suffixIcon } </ IconWrapper >
128
+ ) }
106
129
</ span >
107
130
) }
108
131
</ Link >
@@ -113,24 +136,39 @@ const LinkTmpComp = (function () {
113
136
return (
114
137
< >
115
138
< Section name = { sectionNames . basic } >
116
- { children . text . propertyView ( { label : trans ( " text" ) } ) }
139
+ { children . text . propertyView ( { label : trans ( ' text' ) } ) }
117
140
</ Section >
118
141
119
- { ( useContext ( EditorContext ) . editorModeStatus === "logic" || useContext ( EditorContext ) . editorModeStatus === "both" ) && (
120
- < > < Section name = { sectionNames . interaction } >
121
- { children . onEvent . getPropertyView ( ) }
122
- { disabledPropertyView ( children ) }
123
- { hiddenPropertyView ( children ) }
124
- { loadingPropertyView ( children ) }
125
- </ Section >
142
+ { ( useContext ( EditorContext ) . editorModeStatus === 'logic' ||
143
+ useContext ( EditorContext ) . editorModeStatus === 'both' ) && (
144
+ < >
145
+ < Section name = { sectionNames . interaction } >
146
+ { children . onEvent . getPropertyView ( ) }
147
+ { disabledPropertyView ( children ) }
148
+ { hiddenPropertyView ( children ) }
149
+ { loadingPropertyView ( children ) }
150
+ </ Section >
126
151
< Section name = { sectionNames . advanced } >
127
- { children . prefixIcon . propertyView ( { label : trans ( "button.prefixIcon" ) } ) }
128
- { children . suffixIcon . propertyView ( { label : trans ( "button.suffixIcon" ) } ) }
129
- </ Section > </ >
152
+ { children . prefixIcon . propertyView ( {
153
+ label : trans ( 'button.prefixIcon' ) ,
154
+ } ) }
155
+ { children . suffixIcon . propertyView ( {
156
+ label : trans ( 'button.suffixIcon' ) ,
157
+ } ) }
158
+ </ Section >
159
+ </ >
130
160
) }
131
161
132
- { ( useContext ( EditorContext ) . editorModeStatus === "layout" || useContext ( EditorContext ) . editorModeStatus === "both" ) && (
133
- < > < Section name = { sectionNames . style } > { children . style . getPropertyView ( ) } </ Section > </ >
162
+ { ( useContext ( EditorContext ) . editorModeStatus === 'layout' ||
163
+ useContext ( EditorContext ) . editorModeStatus === 'both' ) && (
164
+ < >
165
+ < Section name = { sectionNames . style } >
166
+ { children . style . getPropertyView ( ) }
167
+ </ Section >
168
+ < Section name = { sectionNames . animationStyle } >
169
+ { children . animationStyle . getPropertyView ( ) }
170
+ </ Section >
171
+ </ >
134
172
) }
135
173
</ >
136
174
) ;
@@ -140,7 +178,7 @@ const LinkTmpComp = (function () {
140
178
} ) ( ) ;
141
179
142
180
export const LinkComp = withExposingConfigs ( LinkTmpComp , [
143
- new NameConfig ( " text" , trans ( " link.textDesc" ) ) ,
144
- new NameConfig ( " loading" , trans ( " link.loadingDesc" ) ) ,
181
+ new NameConfig ( ' text' , trans ( ' link.textDesc' ) ) ,
182
+ new NameConfig ( ' loading' , trans ( ' link.loadingDesc' ) ) ,
145
183
...CommonNameConfig ,
146
184
] ) ;
0 commit comments