11import { Section , sectionNames } from "lowcoder-design" ;
22import { BoolControl } from "comps/controls/boolControl" ;
33import { 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" ;
55import { NameConfig } from "comps/generators/withExposing" ;
66import styled , { css } from "styled-components" ;
77import { UICompBuilder , withDefault } from "../../generators" ;
@@ -16,18 +16,22 @@ import { changeEvent, eventHandlerControl } from "comps/controls/eventHandlerCon
1616import { jsonObjectExposingStateControl , stringExposingStateControl } from "comps/controls/codeStateControl" ;
1717import { dropdownControl } from "comps/controls/dropdownControl" ;
1818import { ArrayOrJSONObjectControl } from "comps/controls/codeControl" ;
19- import { JSONObject } from "@lowcoder-ee/util/jsonTypes" ;
2019
21- export function getStyle ( style :ColorPickerStyleType ) {
20+ export function getStyle ( style :InputLikeStyleType ) {
2221return css `
2322border-radius : ${ style . radius } ;
2423& : 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 } ;
2631background-color : ${ style . background } ;
27- color : ${ style . text } ;
28- font-weight : ${ style . textWeight } ;
29- font-family : ${ style . fontFamily } ;
3032border-color : ${ style . border } ;
33+ padding : ${ style . padding } ;
34+ margin : ${ style . margin } ;
3135& : focus ,
3236& .ant-input-affix-wrapper-focused {
3337border-color : ${ style . accent } ;
@@ -38,15 +42,31 @@ export function getStyle(style: ColorPickerStyleType) {
3842 .ant-input-clear-icon svg : hover {
3943opacity : 0.65 ;
4044 }
45+ .ant-color-picker-trigger-text {
46+ font-size : ${ style . textSize } ;
47+ }
4148 }
4249 ` ;
4350}
4451
45- const ColorPickerWrapper = styled ( ColorPicker ) < { $style :ColorPickerStyleType } > `
46- width: 100%;
52+ const ColorPickerWrapper = styled ( ColorPicker ) < {
53+ $style :InputLikeStyleType ;
54+ $disabledStyle ?:DisabledInputStyleType ;
55+ } > `
4756 display: flex;
4857 justify-content: flex-start;
58+ box-shadow:${ ( props ) =>
59+ `${ props . $style ?. boxShadow } ${ props . $style ?. boxShadowColor } ` } ;
4960${ ( 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+ }
5070` ;
5171
5272const colorPickerTriggerOption = [
@@ -61,20 +81,25 @@ export const colorPickerEvent = eventHandlerControl([
6181const childrenMap = {
6282 ...textInputChildren ,
6383value :stringExposingStateControl ( 'value' , '#3377ff' ) ,
64- style :styleControl ( ColorPickerStyle , 'style' ) ,
6584color :jsonObjectExposingStateControl ( 'color' , { } ) ,
6685trigger :dropdownControl ( colorPickerTriggerOption , 'click' ) ,
6786disabledAlpha :BoolControl ,
6887showPresets :BoolControl ,
6988onEvent :colorPickerEvent ,
7089presets :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' ) ,
7195} ;
7296
7397export const ColorPickerComp = new UICompBuilder ( childrenMap , ( props ) => {
7498return props . label ( {
7599children :(
76100< ColorPickerWrapper
77- $style = { props . style }
101+ $style = { props . inputFieldStyle }
102+ $disabledStyle = { props . disabledStyle }
78103value = { props ?. value ?. value }
79104disabledAlpha = { props . disabledAlpha }
80105showText = { value => value . toHexString ( ) . toUpperCase ( ) }
@@ -94,6 +119,9 @@ export const ColorPickerComp = new UICompBuilder(childrenMap, (props) => {
94119/>
95120) ,
96121style :props . style ,
122+ labelStyle :props . labelStyle ,
123+ inputFieldStyle :props . inputFieldStyle ,
124+ animationStyle :props . animationStyle ,
97125} ) ;
98126} )
99127. setPropertyViewFn ( ( children ) => {
@@ -121,6 +149,10 @@ export const ColorPickerComp = new UICompBuilder(childrenMap, (props) => {
121149< Section name = { sectionNames . layout } > { hiddenPropertyView ( children ) } </ Section >
122150
123151< 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 >
124156</ >
125157) ;
126158} )