Skip to content

[Feat]: #1466 Add disabled/placeholder styles for the main components #1815

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Prev Previous commit
Next Next commit
[Fix]: #1466 add disabled styles for the components / refactor
  • Loading branch information
iamfaran committed Jun 27, 2025
commit 54cc9b92ebfa807bf04a897ef66c31706ab4351f
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { default as Button } from "antd/es/button";
import { styleControl } from "comps/controls/styleControl";
import { ButtonStyleType, ButtonStyle, DisabledButtonStyle } from "comps/controls/styleControlConstants";
import { ButtonStyleType, ButtonStyle, DisabledButtonStyle, DisabledButtonStyleType } from "comps/controls/styleControlConstants";
import { migrateOldData } from "comps/generators/simpleGenerators";
import styled, { css } from "styled-components";
import { genActiveColor, genHoverColor } from "lowcoder-design";
import { refMethods } from "comps/generators/withMethodExposing";
import { blurMethod, clickMethod, focusWithOptions } from "comps/utils/methodUtils";

export function getButtonStyle(buttonStyle: ButtonStyleType, disabledStyle?: any) {
export function getButtonStyle(buttonStyle: ButtonStyleType, disabledStyle: DisabledButtonStyleType = {} as any) {
const hoverColor = buttonStyle.background && genHoverColor(buttonStyle.background);
const activeColor = buttonStyle.background && genActiveColor(buttonStyle.background);
return css`
Expand Down Expand Up @@ -52,8 +52,8 @@ export function getButtonStyle(buttonStyle: ButtonStyleType, disabledStyle?: any
/* Disabled state styling */
&:disabled,
&.ant-btn-disabled {
color: ${disabledStyle?.disabledText || buttonStyle.text};
background: ${disabledStyle?.disabledBackground || buttonStyle.background};
color: ${disabledStyle.disabledText};
background: ${disabledStyle.disabledBackground};
cursor: not-allowed;
}
}
Expand All @@ -62,7 +62,7 @@ export function getButtonStyle(buttonStyle: ButtonStyleType, disabledStyle?: any

export const Button100 = styled(Button)<{
$buttonStyle?: ButtonStyleType;
$disabledStyle?: any;
$disabledStyle?: DisabledButtonStyleType;
}>`
${(props) => props.$buttonStyle && getButtonStyle(props.$buttonStyle, props.$disabledStyle)}
width: 100%;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import {
} from "../../generators/withExposing";
import { IForm } from "../formComp/formDataConstants";
import { SimpleNameComp } from "../simpleNameComp";
import { Button100, ButtonStyleControl } from "./videobuttonCompConstants";
import { Button100, ButtonStyleControl, DisabledButtonStyleControl } from "./videobuttonCompConstants";
import { RefControl } from "comps/controls/refControl";
import { AutoHeightControl } from "comps/controls/autoHeightControl";
import {
Expand Down Expand Up @@ -195,6 +195,7 @@ const childrenMap = {
aspectRatio: withDefault(StringControl, "1 / 1"),
onEvent: ButtonEventHandlerControl,
disabled: BoolCodeControl,
disabledStyle: DisabledButtonStyleControl,
loading: BoolCodeControl,
form: SelectFormControl,
sourceMode: dropdownControl(ModeOptions, "standard"),
Expand Down Expand Up @@ -267,6 +268,7 @@ let ButtonTmpComp = (function () {
<Tooltip title={props.tooltip}>
<Button100
ref={props.viewRef}
$disabledStyle={props.disabledStyle}
$buttonStyle={props.style}
loading={props.loading}
style={
Expand Down Expand Up @@ -358,6 +360,9 @@ let ButtonTmpComp = (function () {
<Section name={sectionNames.style}>
{children.style.getPropertyView()}
</Section>
<Section name="Disabled">
{children.disabledStyle.getPropertyView()}
</Section>
</>
)}
</>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { styleControl } from "@lowcoder-ee/comps/controls/styleControl";
import { ButtonStyle } from "@lowcoder-ee/comps/controls/styleControlConstants";
import { ButtonStyle, DisabledButtonStyle } from "@lowcoder-ee/comps/controls/styleControlConstants";
import { migrateOldData } from "@lowcoder-ee/comps/generators/simpleGenerators";
import { refMethods } from "@lowcoder-ee/comps/generators/withMethodExposing";
import { blurMethod, clickMethod, focusWithOptions } from "@lowcoder-ee/comps/utils/methodUtils";
Expand All @@ -8,7 +8,7 @@ import { genActiveColor, genHoverColor } from "components/colorSelect/colorUtils
import styled, { css } from "styled-components";
// import { genActiveColor, genHoverColor } from "lowcoder-design";

export function getButtonStyle(buttonStyle: any) {
export function getButtonStyle(buttonStyle: any, disabledStyle: any) {
const hoverColor = buttonStyle.background && genHoverColor(buttonStyle.background);
const activeColor = buttonStyle.background && genActiveColor(buttonStyle.background);
return css`
Expand Down Expand Up @@ -42,13 +42,20 @@ export function getButtonStyle(buttonStyle: any) {
? activeColor
: buttonStyle.border};
}

}
&:disabled,
&.ant-btn-disabled {
color: ${disabledStyle.disabledText};
background: ${disabledStyle.disabledBackground};
cursor: not-allowed;
}
}
`;
}

export const Button100 = styled(Button)<{ $buttonStyle?: any }>`
${(props) => props.$buttonStyle && getButtonStyle(props.$buttonStyle)}
export const Button100 = styled(Button)<{ $buttonStyle?: any; $disabledStyle?: any }>`
${(props) => props.$buttonStyle && getButtonStyle(props.$buttonStyle, props.$disabledStyle)}
width: 100%;
height: auto;
display: inline-flex;
Expand Down Expand Up @@ -98,6 +105,12 @@ export const ButtonStyleControl = migrateOldData(
fixOldData
);

export const DisabledButtonTmpStyleControl = styleControl(DisabledButtonStyle);
export const DisabledButtonStyleControl = migrateOldData(
DisabledButtonTmpStyleControl,
fixOldData
);

export const buttonRefMethods = refMethods([
focusWithOptions,
blurMethod,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,7 @@ const getStyle = (style: InputLikeStyleType) => {
&:hover {
border-color: ${style.accent};
}

&::-webkit-input-placeholder {
color: ${style.text};
opacity: 0.4;
}

.ant-input-number {
margin: 0;

Expand All @@ -92,6 +88,26 @@ const getStyle = (style: InputLikeStyleType) => {
font-weight:${style.textWeight} !important;
font-size:${style.textSize} !important;
font-style:${style.fontStyle} !important;

&::-webkit-input-placeholder {
color: ${style.placeholder};
opacity: 1;
}

&::-moz-placeholder {
color: ${style.placeholder};
opacity: 1;
}

&:-ms-input-placeholder {
color: ${style.placeholder};
opacity: 1;
}

&::placeholder {
color: ${style.placeholder};
opacity: 1;
}
}

.ant-input-number-handler-wrap {
Expand Down Expand Up @@ -131,13 +147,14 @@ const InputNumber = styled(AntdInputNumber)<{
/* Disabled state styling */
&:disabled,
&.ant-input-number-disabled {
color: ${(props) => props.$disabledStyle?.disabledText || props.$style.text} !important;
background: ${(props) => props.$disabledStyle?.disabledBackground || props.$style.background} !important;
color: ${(props) => props.$disabledStyle?.disabledText};
background: ${(props) => props.$disabledStyle?.disabledBackground};
border-color: ${(props) => props.$disabledStyle?.disabledBorder};
cursor: not-allowed;

.ant-input-number-input {
color: ${(props) => props.$disabledStyle?.disabledText || props.$style.text} !important;
background: ${(props) => props.$disabledStyle?.disabledBackground || props.$style.background} !important;
color: ${(props) => props.$disabledStyle?.disabledText};
background: ${(props) => props.$disabledStyle?.disabledBackground};
}

}
Expand Down Expand Up @@ -280,7 +297,7 @@ const childrenMap = {
animationStyle: styleControl(AnimationStyle , 'animationStyle'),
prefixIcon: IconControl,
inputFieldStyle: styleControl(InputLikeStyle , 'inputFieldStyle'),
disabledInputStyle: styleControl(DisabledInputStyle, 'disabledInputStyle'),
disabledStyle: styleControl(DisabledInputStyle, 'disabledStyle'),
// validation
required: BoolControl,
showValidationWhenEmpty: BoolControl,
Expand Down Expand Up @@ -397,7 +414,7 @@ const CustomInputNumber = (props: RecordConstructorToView<typeof childrenMap>) =
stringMode={true}
precision={props.precision}
$style={props.inputFieldStyle}
$disabledStyle={props.disabledInputStyle}
$disabledStyle={props.disabledStyle}
prefix={hasIcon(props.prefixIcon) ? props.prefixIcon : props.prefixText.value}
tabIndex={typeof props.tabIndex === 'number' ? props.tabIndex : undefined}
onPressEnter={() => {
Expand Down Expand Up @@ -489,8 +506,8 @@ let NumberInputTmpComp = (function () {
<Section name={sectionNames.inputFieldStyle}>
{children.inputFieldStyle.getPropertyView()}
</Section>
<Section name={"Disabled Input Style"}>
{children.disabledInputStyle.getPropertyView()}
<Section name={"Disabled Style"}>
{children.disabledStyle.getPropertyView()}
</Section>
<Section name={sectionNames.animationStyle} hasTooltip={true}>
{children.animationStyle.getPropertyView()}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,9 @@ const InputStyle = styled(Input)<{
/* Disabled state styling */
&:disabled,
&.ant-input-disabled {
color: ${(props) => props.$disabledStyle?.disabledText || props.$style.text} !important;
background: ${(props) => props.$disabledStyle?.disabledBackground || props.$style.background} !important;
color: ${(props) => props.$disabledStyle?.disabledText};
background: ${(props) => props.$disabledStyle?.disabledBackground};
border-color: ${(props) => props.$disabledStyle?.disabledBorder};
cursor: not-allowed;
}
`;
Expand All @@ -70,7 +71,7 @@ const childrenMap = {
suffixIcon: IconControl,
inputFieldStyle: styleControl(InputLikeStyle, 'inputFieldStyle'),
animationStyle: styleControl(AnimationStyle, 'animationStyle'),
disabledInputStyle: styleControl(DisabledInputStyle, 'disabledInputStyle'),
disabledStyle: styleControl(DisabledInputStyle, 'disabledStyle'),
tabIndex: NumberControl,
};

Expand All @@ -85,7 +86,7 @@ let InputBasicComp = new UICompBuilder(childrenMap, (props) => {
showCount={props.showCount}
allowClear={props.allowClear}
$style={props.inputFieldStyle}
$disabledStyle={props.disabledInputStyle}
$disabledStyle={props.disabledStyle}
prefix={hasIcon(props.prefixIcon) && props.prefixIcon}
suffix={hasIcon(props.suffixIcon) && props.suffixIcon}
tabIndex={typeof props.tabIndex === 'number' ? props.tabIndex : undefined}
Expand Down Expand Up @@ -127,7 +128,7 @@ let InputBasicComp = new UICompBuilder(childrenMap, (props) => {
<Section name={sectionNames.style}>{children.style.getPropertyView()}</Section>
<Section name={sectionNames.labelStyle}>{children.labelStyle.getPropertyView()}</Section>
<Section name={sectionNames.inputFieldStyle}>{children.inputFieldStyle.getPropertyView()}</Section>
<Section name={"Disabled Input Style"}>{children.disabledInputStyle.getPropertyView()}</Section>
<Section name={"Disabled Input Style"}>{children.disabledStyle.getPropertyView()}</Section>
<Section name={sectionNames.animationStyle} hasTooltip={true}>{children.animationStyle.getPropertyView()}</Section>
</>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,9 @@ const TextAreaStyled = styled(TextArea)<{
/* Disabled state styling */
&:disabled,
&.ant-input-disabled {
color: ${(props) => props.$disabledStyle?.disabledText || props.$style.text} !important;
background: ${(props) => props.$disabledStyle?.disabledBackground || props.$style.background} !important;
color: ${(props) => props.$disabledStyle?.disabledText};
background: ${(props) => props.$disabledStyle?.disabledBackground};
border-color: ${(props) => props.$disabledStyle?.disabledBorder};
cursor: not-allowed;
}
`;
Expand Down Expand Up @@ -91,7 +92,7 @@ let TextAreaTmpComp = (function () {
textAreaScrollBar: withDefault(BoolControl, false),
inputFieldStyle: styleControl(InputLikeStyle , 'inputFieldStyle'),
animationStyle: styleControl(AnimationStyle, 'animationStyle'),
disabledInputStyle: styleControl(DisabledInputStyle, 'disabledInputStyle'),
disabledStyle: styleControl(DisabledInputStyle, 'disabledStyle'),
tabIndex: NumberControl
};
return new UICompBuilder(childrenMap, (props) => {
Expand All @@ -108,7 +109,7 @@ let TextAreaTmpComp = (function () {
allowClear={props.allowClear}
style={{ height: "100% !important", resize: "vertical" }}
$style={props.inputFieldStyle}
$disabledStyle={props.disabledInputStyle}
$disabledStyle={props.disabledStyle}
tabIndex={typeof props.tabIndex === 'number' ? props.tabIndex : undefined}
/>
</Wrapper>
Expand Down Expand Up @@ -152,7 +153,7 @@ let TextAreaTmpComp = (function () {
<Section name={sectionNames.style}>{children.style.getPropertyView()}</Section>
<Section name={sectionNames.labelStyle}>{children.labelStyle.getPropertyView()}</Section>
<Section name={sectionNames.inputFieldStyle}>{children.inputFieldStyle.getPropertyView()}</Section>
<Section name={"Disabled Input Style"}>{children.disabledInputStyle.getPropertyView()}</Section>
<Section name={"Disabled Style"}>{children.disabledStyle.getPropertyView()}</Section>
<Section name={sectionNames.animationStyle} hasTooltip={true}>{children.animationStyle.getPropertyView()}</Section>
</>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -978,37 +978,29 @@ const DISABLED_TEXT = {
label: trans("style.disabledText"),
depName: "disabledBackground",
depType: DEP_TYPE.CONTRAST_TEXT,
transformer: contrastText,
transformer: (color: string) => lightenColor(color, 0.8),
} as const;


export const DISABLED_BORDER = {
name: "disabledBorder",
label: trans("style.disabledBorder"),
color: SECOND_SURFACE_COLOR,
} as const;

// Re-export for reuse in other components if needed
export const DISABLED_STYLE_FIELDS = [
DISABLED_BACKGROUND,
DISABLED_TEXT,
DISABLED_BORDER,
] as const;

// Add disabled style constants specifically for text input components
const DISABLED_INPUT_BACKGROUND = {
name: "disabledBackground",
label: trans("style.disabledBackground"),
color: SECOND_SURFACE_COLOR,
} as const;
// Helper to quickly create a component-specific disabled style list by
// extending the two generic disabled tokens above.
export const withDisabled = <Extra extends readonly SingleColorConfig[] = []>(
extra: Extra = [] as unknown as Extra,
) => [...DISABLED_STYLE_FIELDS, ...extra] as const;


const DISABLED_INPUT_TEXT = {
name: "disabledText",
label: trans("style.disabledText"),
depName: "disabledInputBackground",
depType: DEP_TYPE.CONTRAST_TEXT,
transformer: contrastText,
} as const;

// Re-export for reuse in textInput components
export const DISABLED_INPUT_STYLE_FIELDS = [
DISABLED_INPUT_BACKGROUND,
DISABLED_INPUT_TEXT,
] as const;

// Add disabled style constants specifically for slider components
const DISABLED_SLIDER_FILL = {
name: "disabledFill",
Expand Down Expand Up @@ -1052,9 +1044,11 @@ export const ButtonStyle = [
] as const;

// Create separate disabled style control
export const DisabledButtonStyle = [
...DISABLED_STYLE_FIELDS,
] as const;
export const DisabledButtonStyle = withDisabled();


// For input components
export const DisabledInputStyle = withDisabled();

export const DropdownStyle = [
getBackground(),
Expand Down Expand Up @@ -1330,10 +1324,6 @@ export const InputLikeStyle = [
...ACCENT_VALIDATE,
] as const;

// Create separate disabled style control for text inputs
export const DisabledInputStyle = [
...DISABLED_INPUT_STYLE_FIELDS,
] as const;

// added by Mousheng

Expand Down