|
1 | 1 | import { default as Button } from "antd/es/button"; |
2 | 2 | import { styleControl } from "comps/controls/styleControl"; |
3 | | -import { ButtonStyleType, ButtonStyle } from "comps/controls/styleControlConstants"; |
| 3 | +import { ButtonStyleType, ButtonStyle, DisabledButtonStyle } from "comps/controls/styleControlConstants"; |
4 | 4 | import { migrateOldData } from "comps/generators/simpleGenerators"; |
5 | 5 | import styled, { css } from "styled-components"; |
6 | 6 | import { genActiveColor, genHoverColor } from "lowcoder-design"; |
7 | 7 | import { refMethods } from "comps/generators/withMethodExposing"; |
8 | 8 | import { blurMethod, clickMethod, focusWithOptions } from "comps/utils/methodUtils"; |
9 | 9 |
|
10 | | -export function getButtonStyle(buttonStyle: ButtonStyleType) { |
| 10 | +export function getButtonStyle(buttonStyle: ButtonStyleType, disabledStyle?: any) { |
11 | 11 | const hoverColor = buttonStyle.background && genHoverColor(buttonStyle.background); |
12 | 12 | const activeColor = buttonStyle.background && genActiveColor(buttonStyle.background); |
13 | 13 | return css` |
@@ -52,19 +52,22 @@ export function getButtonStyle(buttonStyle: ButtonStyleType) { |
52 | 52 | /* Disabled state styling */ |
53 | 53 | &:disabled, |
54 | 54 | &.ant-btn-disabled { |
55 | | - color: ${buttonStyle.disabledText || buttonStyle.text}; |
56 | | - background: ${buttonStyle.disabledBackground || buttonStyle.background}; |
| 55 | + color: ${disabledStyle?.disabledText || buttonStyle.text}; |
| 56 | + background: ${disabledStyle?.disabledBackground || buttonStyle.background}; |
57 | 57 | border-color: ${ |
58 | | - buttonStyle.disabledBorder || buttonStyle.border |
| 58 | + disabledStyle?.disabledBorder || buttonStyle.border |
59 | 59 | } !important; |
60 | 60 | cursor: not-allowed; |
61 | 61 | } |
62 | 62 | } |
63 | 63 | `; |
64 | 64 | } |
65 | 65 |
|
66 | | -export const Button100 = styled(Button)<{ $buttonStyle?: ButtonStyleType }>` |
67 | | - ${(props) => props.$buttonStyle && getButtonStyle(props.$buttonStyle)} |
| 66 | +export const Button100 = styled(Button)<{ |
| 67 | + $buttonStyle?: ButtonStyleType; |
| 68 | + $disabledStyle?: any; |
| 69 | +}>` |
| 70 | + ${(props) => props.$buttonStyle && getButtonStyle(props.$buttonStyle, props.$disabledStyle)} |
68 | 71 | width: 100%; |
69 | 72 | height: auto; |
70 | 73 | display: inline-flex; |
@@ -116,6 +119,10 @@ function fixOldData(oldData: any) { |
116 | 119 | const ButtonTmpStyleControl = styleControl(ButtonStyle, 'style'); |
117 | 120 | export const ButtonStyleControl = migrateOldData(ButtonTmpStyleControl, fixOldData); |
118 | 121 |
|
| 122 | +// Create disabled style control |
| 123 | +const DisabledButtonTmpStyleControl = styleControl(DisabledButtonStyle, 'disabledStyle'); |
| 124 | +export const DisabledButtonStyleControl = migrateOldData(DisabledButtonTmpStyleControl, fixOldData); |
| 125 | + |
119 | 126 | export const buttonRefMethods = refMethods<HTMLElement>([ |
120 | 127 | focusWithOptions, |
121 | 128 | blurMethod, |
|
0 commit comments