1
1
import { Section , sectionNames } from "lowcoder-design" ;
2
2
import { BoolControl } from "comps/controls/boolControl" ;
3
3
import { styleControl } from "comps/controls/styleControl" ;
4
- import { ColorPickerStyle , ColorPickerStyleType } from "comps/controls/styleControlConstants" ;
4
+ import { AnimationStyle , ColorPickerStyle , ColorPickerStyleType , DisabledInputStyle , DisabledInputStyleType , InputFieldStyle , InputLikeStyle , InputLikeStyleType , LabelStyle } from "comps/controls/styleControlConstants" ;
5
5
import { NameConfig } from "comps/generators/withExposing" ;
6
6
import styled , { css } from "styled-components" ;
7
7
import { UICompBuilder , withDefault } from "../../generators" ;
@@ -16,18 +16,22 @@ import { changeEvent, eventHandlerControl } from "comps/controls/eventHandlerCon
16
16
import { jsonObjectExposingStateControl , stringExposingStateControl } from "comps/controls/codeStateControl" ;
17
17
import { dropdownControl } from "comps/controls/dropdownControl" ;
18
18
import { ArrayOrJSONObjectControl } from "comps/controls/codeControl" ;
19
- import { JSONObject } from "@lowcoder-ee/util/jsonTypes" ;
20
19
21
- export function getStyle ( style : ColorPickerStyleType ) {
20
+ export function getStyle ( style : InputLikeStyleType ) {
22
21
return css `
23
22
border-radius : ${ style . radius } ;
24
23
& : not (.ant-input-disabled , .ant-input-affix-wrapper-disabled ),
25
- input {
24
+ .ant-color-picker-trigger {
25
+ color : ${ style . text } ;
26
+ font-weight : ${ style . textWeight } ;
27
+ font-family : ${ style . fontFamily } ;
28
+ font-style : ${ style . fontStyle } ;
29
+ text-transform : ${ style . textTransform } ;
30
+ text-decoration : ${ style . textDecoration } ;
26
31
background-color : ${ style . background } ;
27
- color : ${ style . text } ;
28
- font-weight : ${ style . textWeight } ;
29
- font-family : ${ style . fontFamily } ;
30
32
border-color : ${ style . border } ;
33
+ padding : ${ style . padding } ;
34
+ margin : ${ style . margin } ;
31
35
& : focus ,
32
36
& .ant-input-affix-wrapper-focused {
33
37
border-color : ${ style . accent } ;
@@ -38,15 +42,31 @@ export function getStyle(style: ColorPickerStyleType) {
38
42
.ant-input-clear-icon svg : hover {
39
43
opacity : 0.65 ;
40
44
}
45
+ .ant-color-picker-trigger-text {
46
+ font-size : ${ style . textSize } ;
47
+ }
41
48
}
42
49
` ;
43
50
}
44
51
45
- const ColorPickerWrapper = styled ( ColorPicker ) < { $style : ColorPickerStyleType } > `
46
- width: 100%;
52
+ const ColorPickerWrapper = styled ( ColorPicker ) < {
53
+ $style : InputLikeStyleType ;
54
+ $disabledStyle ?: DisabledInputStyleType ;
55
+ } > `
47
56
display: flex;
48
57
justify-content: flex-start;
58
+ box-shadow: ${ ( props ) =>
59
+ `${ props . $style ?. boxShadow } ${ props . $style ?. boxShadowColor } ` } ;
49
60
${ ( props ) => props . $style && getStyle ( props . $style ) }
61
+
62
+ /* Disabled state styling */
63
+ &:disabled,
64
+ &.ant-input-disabled {
65
+ color: ${ ( props ) => props . $disabledStyle ?. disabledText } ;
66
+ background: ${ ( props ) => props . $disabledStyle ?. disabledBackground } ;
67
+ border-color: ${ ( props ) => props . $disabledStyle ?. disabledBorder } ;
68
+ cursor: not-allowed;
69
+ }
50
70
` ;
51
71
52
72
const colorPickerTriggerOption = [
@@ -61,20 +81,25 @@ export const colorPickerEvent = eventHandlerControl([
61
81
const childrenMap = {
62
82
...textInputChildren ,
63
83
value : stringExposingStateControl ( 'value' , '#3377ff' ) ,
64
- style : styleControl ( ColorPickerStyle , 'style' ) ,
65
84
color : jsonObjectExposingStateControl ( 'color' , { } ) ,
66
85
trigger : dropdownControl ( colorPickerTriggerOption , 'click' ) ,
67
86
disabledAlpha : BoolControl ,
68
87
showPresets : BoolControl ,
69
88
onEvent : colorPickerEvent ,
70
89
presets : withDefault ( ArrayOrJSONObjectControl , JSON . stringify ( presets , null , 2 ) ) ,
90
+ style : styleControl ( InputFieldStyle , 'style' ) ,
91
+ labelStyle :styleControl ( LabelStyle , 'labelStyle' ) ,
92
+ inputFieldStyle : styleControl ( InputLikeStyle , 'inputFieldStyle' ) ,
93
+ animationStyle : styleControl ( AnimationStyle , 'animationStyle' ) ,
94
+ disabledStyle : styleControl ( DisabledInputStyle , 'disabledStyle' ) ,
71
95
} ;
72
96
73
97
export const ColorPickerComp = new UICompBuilder ( childrenMap , ( props ) => {
74
98
return props . label ( {
75
99
children : (
76
100
< ColorPickerWrapper
77
- $style = { props . style }
101
+ $style = { props . inputFieldStyle }
102
+ $disabledStyle = { props . disabledStyle }
78
103
value = { props ?. value ?. value }
79
104
disabledAlpha = { props . disabledAlpha }
80
105
showText = { value => value . toHexString ( ) . toUpperCase ( ) }
@@ -94,6 +119,9 @@ export const ColorPickerComp = new UICompBuilder(childrenMap, (props) => {
94
119
/>
95
120
) ,
96
121
style : props . style ,
122
+ labelStyle : props . labelStyle ,
123
+ inputFieldStyle :props . inputFieldStyle ,
124
+ animationStyle :props . animationStyle ,
97
125
} ) ;
98
126
} )
99
127
. setPropertyViewFn ( ( children ) => {
@@ -121,6 +149,10 @@ export const ColorPickerComp = new UICompBuilder(childrenMap, (props) => {
121
149
< Section name = { sectionNames . layout } > { hiddenPropertyView ( children ) } </ Section >
122
150
123
151
< Section name = { sectionNames . style } > { children . style . getPropertyView ( ) } </ Section >
152
+ < Section name = { sectionNames . labelStyle } > { children . labelStyle . getPropertyView ( ) } </ Section >
153
+ < Section name = { sectionNames . inputFieldStyle } > { children . inputFieldStyle . getPropertyView ( ) } </ Section >
154
+ < Section name = { trans ( "prop.disabledStyle" ) } > { children . disabledStyle . getPropertyView ( ) } </ Section >
155
+ < Section name = { sectionNames . animationStyle } hasTooltip = { true } > { children . animationStyle . getPropertyView ( ) } </ Section >
124
156
</ >
125
157
) ;
126
158
} )
0 commit comments