1
- import { default as Divider , DividerProps } from 'antd/es/divider' ;
2
- import { StringControl } from 'comps/controls/codeControl' ;
3
- import { BoolControl } from 'comps/controls/boolControl' ;
4
- import { alignControl } from 'comps/controls/alignControl' ;
5
- import { UICompBuilder } from 'comps/generators' ;
6
- import { NameConfig , NameConfigHidden } from 'comps/generators/withExposing' ;
7
- import { Section , sectionNames } from 'lowcoder-design' ;
8
- import _ from 'lodash' ;
9
- import styled from 'styled-components' ;
10
- import { styleControl } from 'comps/controls/styleControl' ;
11
- import {
12
- AnimationStyle ,
13
- AnimationStyleType ,
14
- DividerStyle ,
15
- DividerStyleType ,
16
- heightCalculator ,
17
- widthCalculator ,
18
- } from 'comps/controls/styleControlConstants' ;
19
- import { migrateOldData } from 'comps/generators/simpleGenerators' ;
20
- import { hiddenPropertyView } from 'comps/utils/propertyUtils' ;
21
- import { trans } from 'i18n' ;
1
+ import { default as Divider , DividerProps } from "antd/es/divider" ;
2
+ import { StringControl } from "comps/controls/codeControl" ;
3
+ import { BoolControl } from "comps/controls/boolControl" ;
4
+ import { alignControl } from "comps/controls/alignControl" ;
5
+ import { UICompBuilder } from "comps/generators" ;
6
+ import { NameConfig , NameConfigHidden } from "comps/generators/withExposing" ;
7
+ import { Section , sectionNames } from "lowcoder-design" ;
8
+ import _ from "lodash" ;
9
+ import styled from "styled-components" ;
10
+ import { styleControl } from "comps/controls/styleControl" ;
11
+ import { AnimationStyle , AnimationStyleType , DividerStyle , DividerStyleType , heightCalculator , widthCalculator } from "comps/controls/styleControlConstants" ;
12
+ import { migrateOldData } from "comps/generators/simpleGenerators" ;
13
+ import { hiddenPropertyView } from "comps/utils/propertyUtils" ;
14
+ import { trans } from "i18n" ;
22
15
23
- import { useContext } from ' react' ;
24
- import { EditorContext } from ' comps/editorState' ;
16
+ import { useContext } from " react" ;
17
+ import { EditorContext } from " comps/editorState" ;
25
18
26
19
type IProps = DividerProps & {
27
20
$style : DividerStyleType ;
28
21
dashed : boolean ;
29
- $animationStyle : AnimationStyleType ;
22
+ $animationStyle :AnimationStyleType ;
30
23
} ;
31
24
32
25
// TODO: find out how to set border style when text is active
33
26
// TODO: enable type "vertical" https://ant.design/components/divider
34
27
35
- const StyledDivider = styled ( Divider ) < IProps > `
28
+ const StyledDivider = styled ( Divider ) < IProps > `
36
29
margin-top: 3.5px;
37
30
.ant-divider-inner-text {
38
31
height: 32px;
@@ -41,37 +34,27 @@ const StyledDivider = styled(Divider)<IProps>`
41
34
font-size: ${ ( props ) => props . $style . textSize } ;
42
35
font-weight: ${ ( props ) => props . $style . textWeight } ;
43
36
font-family: ${ ( props ) => props . $style . fontFamily } ;
44
- text-transform: ${ ( props ) => props . $style . textTransform } ;
45
- text-decoration: ${ ( props ) => props . $style . textDecoration } ;
46
- font-style: ${ ( props ) => props . $style . fontStyle } ;
37
+ text-transform:${ ( props ) => props . $style . textTransform } ;
38
+ text-decoration:${ ( props ) => props . $style . textDecoration } ;
39
+ font-style:${ ( props ) => props . $style . fontStyle }
47
40
}
48
- ${ ( props ) => props . $animationStyle }
49
- min-width: 0;
41
+ ${ props => props . $animationStyle }
42
+ min-width: 0;
50
43
width: ${ ( props ) => {
51
44
return widthCalculator ( props . $style . margin ) ;
52
- } } ;
45
+ } } ;
53
46
min-height: ${ ( props ) => {
54
47
return heightCalculator ( props . $style . margin ) ;
55
- } } ;
48
+ } } ;
56
49
margin: ${ ( props ) => {
57
50
return props . $style . margin ;
58
- } } ;
51
+ } } ;
59
52
padding: ${ ( props ) => props . $style . padding } ;
60
-
61
- border-top: ${ ( props ) =>
62
- props . $style . borderWidth && props . $style . borderWidth != '0px'
63
- ? props . $style . borderWidth
64
- : '1px' }
65
- ${ ( props ) => ( props . dashed ? 'dashed' : 'solid' ) }
66
- ${ ( props ) => props . $style . border } ;
67
- '' .ant-divider-inner-text::before,
68
- .ant-divider-inner-text::after {
69
- border-block-start: ${ ( props ) =>
70
- props . $style . borderWidth && props . $style . borderWidth != '0px'
71
- ? props . $style . borderWidth
72
- : '1px' }
73
- ${ ( props ) => ( props . dashed ? 'dashed' : 'solid' ) }
74
- ${ ( props ) => props . $style . border } !important;
53
+
54
+ border-top: ${ ( props ) => ( props . $style . borderWidth && props . $style . borderWidth != "0px" ? props . $style . borderWidth : "1px" ) } ${ ( props ) => ( props . dashed ? "dashed" : "solid" ) } ${ ( props ) => props . $style . border } ;
55
+ ""
56
+ .ant-divider-inner-text::before, .ant-divider-inner-text::after {
57
+ border-block-start: ${ ( props ) => ( props . $style . borderWidth && props . $style . borderWidth != "0px" ? props . $style . borderWidth : "1px" ) } ${ ( props ) => ( props . dashed ? "dashed" : "solid" ) } ${ ( props ) => props . $style . border } !important;
75
58
border-block-start-color: inherit;
76
59
border-block-end: 0;
77
60
}
@@ -92,18 +75,20 @@ const childrenMap = {
92
75
} ;
93
76
94
77
function fixOldStyleData ( oldData : any ) {
95
- if ( oldData && oldData . hasOwnProperty ( ' color' ) ) {
78
+ if ( oldData && oldData . hasOwnProperty ( " color" ) ) {
96
79
return {
97
80
...oldData ,
98
81
style : {
99
82
color : oldData . color ,
100
- text : '' ,
83
+ text : "" ,
101
84
} ,
102
85
} ;
103
86
}
104
87
return oldData ;
105
88
}
106
89
90
+
91
+
107
92
// Compatible with historical style data 2022-8-26
108
93
export const DividerComp = migrateOldData (
109
94
new UICompBuilder ( childrenMap , ( props ) => {
@@ -122,30 +107,26 @@ export const DividerComp = migrateOldData(
122
107
return (
123
108
< >
124
109
< Section name = { sectionNames . basic } >
125
- { children . title . propertyView ( { label : trans ( ' divider.title' ) } ) }
110
+ { children . title . propertyView ( { label : trans ( " divider.title" ) } ) }
126
111
</ Section >
127
112
128
- { [ 'logic' , 'both' ] . includes (
129
- useContext ( EditorContext ) . editorModeStatus
130
- ) && (
113
+ { [ "logic" , "both" ] . includes ( useContext ( EditorContext ) . editorModeStatus ) && (
131
114
< Section name = { sectionNames . interaction } >
132
115
{ hiddenPropertyView ( children ) }
133
116
</ Section >
134
117
) }
135
118
136
- { [ 'layout' , 'both' ] . includes (
137
- useContext ( EditorContext ) . editorModeStatus
138
- ) && (
119
+ { [ "layout" , "both" ] . includes ( useContext ( EditorContext ) . editorModeStatus ) && (
139
120
< >
140
121
< Section name = { sectionNames . layout } >
141
122
{ ! _ . isEmpty ( children . title . getView ( ) ) &&
142
123
children . align . propertyView ( {
143
- label : trans ( ' divider.align' ) ,
124
+ label : trans ( " divider.align" ) ,
144
125
radioButton : true ,
145
126
} ) }
146
127
</ Section >
147
128
< Section name = { sectionNames . style } >
148
- { children . dashed . propertyView ( { label : trans ( ' divider.dashed' ) } ) }
129
+ { children . dashed . propertyView ( { label : trans ( " divider.dashed" ) } ) }
149
130
{ children . style . getPropertyView ( ) }
150
131
</ Section >
151
132
< Section name = { sectionNames . animationStyle } >
@@ -157,9 +138,9 @@ export const DividerComp = migrateOldData(
157
138
) ;
158
139
} )
159
140
. setExposeStateConfigs ( [
160
- new NameConfig ( ' dashed' , trans ( ' divider.dashedDesc' ) ) ,
161
- new NameConfig ( ' title' , trans ( ' divider.titleDesc' ) ) ,
162
- new NameConfig ( ' align' , trans ( ' divider.alignDesc' ) ) ,
141
+ new NameConfig ( " dashed" , trans ( " divider.dashedDesc" ) ) ,
142
+ new NameConfig ( " title" , trans ( " divider.titleDesc" ) ) ,
143
+ new NameConfig ( " align" , trans ( " divider.alignDesc" ) ) ,
163
144
NameConfigHidden ,
164
145
] )
165
146
. build ( ) ,
0 commit comments