2022-05-09 22:20:07 +08:00
|
|
|
import type { CSSObject } from '@ant-design/cssinjs';
|
2022-11-23 20:22:38 +08:00
|
|
|
import type { FullToken, GenerateStyle } from '../../theme/internal';
|
|
|
|
import { genComponentStyleHook, mergeToken } from '../../theme/internal';
|
2022-06-27 14:25:59 +08:00
|
|
|
import type { GlobalToken } from '../../theme/interface';
|
2022-07-11 15:35:58 +08:00
|
|
|
import { clearFix, resetComponent } from '../../style';
|
2022-10-28 16:09:38 +08:00
|
|
|
import { genCompactItemStyle } from '../../style/compact-item';
|
2022-04-06 21:49:30 +08:00
|
|
|
|
|
|
|
export type InputToken<T extends GlobalToken = FullToken<'Input'>> = T & {
|
2022-03-29 15:57:39 +08:00
|
|
|
inputAffixPadding: number;
|
2022-03-09 10:38:02 +08:00
|
|
|
inputPaddingVertical: number;
|
|
|
|
inputPaddingVerticalLG: number;
|
|
|
|
inputPaddingVerticalSM: number;
|
|
|
|
inputPaddingHorizontal: number;
|
2022-12-09 17:52:34 +08:00
|
|
|
inputPaddingHorizontalLG: number;
|
2022-03-29 15:57:39 +08:00
|
|
|
inputPaddingHorizontalSM: number;
|
2022-03-09 10:38:02 +08:00
|
|
|
inputBorderHoverColor: string;
|
|
|
|
inputBorderActiveColor: string;
|
2022-04-06 21:49:30 +08:00
|
|
|
};
|
2022-03-09 10:38:02 +08:00
|
|
|
|
2022-03-29 15:57:39 +08:00
|
|
|
export const genPlaceholderStyle = (color: string): CSSObject => ({
|
2022-03-09 10:38:02 +08:00
|
|
|
// Firefox
|
|
|
|
'&::-moz-placeholder': {
|
|
|
|
opacity: 1,
|
|
|
|
},
|
|
|
|
'&::placeholder': {
|
|
|
|
color,
|
|
|
|
userSelect: 'none', // https://github.com/ant-design/ant-design/pull/32639
|
|
|
|
},
|
|
|
|
'&:placeholder-shown': {
|
|
|
|
textOverflow: 'ellipsis',
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
export const genHoverStyle = (token: InputToken): CSSObject => ({
|
|
|
|
borderColor: token.inputBorderHoverColor,
|
2022-11-01 15:06:38 +08:00
|
|
|
borderInlineEndWidth: token.lineWidth,
|
2022-03-09 10:38:02 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
export const genActiveStyle = (token: InputToken) => ({
|
|
|
|
borderColor: token.inputBorderHoverColor,
|
2022-07-21 17:00:42 +08:00
|
|
|
boxShadow: `0 0 0 ${token.controlOutlineWidth}px ${token.controlOutline}`,
|
2022-11-01 15:06:38 +08:00
|
|
|
borderInlineEndWidth: token.lineWidth,
|
2022-03-09 10:38:02 +08:00
|
|
|
outline: 0,
|
|
|
|
});
|
|
|
|
|
|
|
|
export const genDisabledStyle = (token: InputToken): CSSObject => ({
|
2022-03-22 13:26:29 +08:00
|
|
|
color: token.colorTextDisabled,
|
2022-06-28 20:33:01 +08:00
|
|
|
backgroundColor: token.colorBgContainerDisabled,
|
2022-03-22 13:26:29 +08:00
|
|
|
borderColor: token.colorBorder,
|
2022-03-09 10:38:02 +08:00
|
|
|
boxShadow: 'none',
|
|
|
|
cursor: 'not-allowed',
|
|
|
|
opacity: 1,
|
|
|
|
|
|
|
|
'&:hover': {
|
2022-04-11 16:04:00 +08:00
|
|
|
...genHoverStyle(mergeToken<InputToken>(token, { inputBorderHoverColor: token.colorBorder })),
|
2022-03-09 10:38:02 +08:00
|
|
|
},
|
|
|
|
});
|
|
|
|
|
2022-03-14 20:57:01 +08:00
|
|
|
const genInputLargeStyle = (token: InputToken): CSSObject => {
|
2022-11-08 15:37:35 +08:00
|
|
|
const {
|
|
|
|
inputPaddingVerticalLG,
|
|
|
|
fontSizeLG,
|
|
|
|
lineHeightLG,
|
|
|
|
borderRadiusLG,
|
2022-12-09 17:52:34 +08:00
|
|
|
inputPaddingHorizontalLG,
|
2022-11-08 15:37:35 +08:00
|
|
|
} = token;
|
2022-03-09 10:38:02 +08:00
|
|
|
|
2022-03-14 20:57:01 +08:00
|
|
|
return {
|
2022-12-09 17:52:34 +08:00
|
|
|
padding: `${inputPaddingVerticalLG}px ${inputPaddingHorizontalLG}px`,
|
2022-03-14 20:57:01 +08:00
|
|
|
fontSize: fontSizeLG,
|
2022-11-08 15:37:35 +08:00
|
|
|
lineHeight: lineHeightLG,
|
2022-11-01 15:06:38 +08:00
|
|
|
borderRadius: borderRadiusLG,
|
2022-03-14 20:57:01 +08:00
|
|
|
};
|
|
|
|
};
|
2022-03-09 10:38:02 +08:00
|
|
|
|
2022-03-30 13:54:21 +08:00
|
|
|
export const genInputSmallStyle = (token: InputToken): CSSObject => ({
|
2022-03-25 17:54:57 +08:00
|
|
|
padding: `${token.inputPaddingVerticalSM}px ${token.controlPaddingHorizontalSM - 1}px`,
|
2022-11-01 15:06:38 +08:00
|
|
|
borderRadius: token.borderRadiusSM,
|
2022-03-09 10:38:02 +08:00
|
|
|
});
|
|
|
|
|
2022-03-14 20:57:01 +08:00
|
|
|
export const genStatusStyle = (token: InputToken): CSSObject => {
|
2022-09-20 21:50:36 +08:00
|
|
|
const {
|
2022-11-08 15:37:35 +08:00
|
|
|
componentCls,
|
2022-09-20 21:50:36 +08:00
|
|
|
colorError,
|
|
|
|
colorWarning,
|
|
|
|
colorErrorOutline,
|
|
|
|
colorWarningOutline,
|
|
|
|
colorErrorBorderHover,
|
|
|
|
colorWarningBorderHover,
|
|
|
|
} = token;
|
2022-03-09 10:38:02 +08:00
|
|
|
|
2022-03-14 20:57:01 +08:00
|
|
|
return {
|
|
|
|
'&-status-error:not(&-disabled):not(&-borderless)&': {
|
2022-09-20 21:50:36 +08:00
|
|
|
borderColor: colorError,
|
|
|
|
|
|
|
|
'&:hover': {
|
|
|
|
borderColor: colorErrorBorderHover,
|
2022-03-14 20:57:01 +08:00
|
|
|
},
|
2022-03-09 10:38:02 +08:00
|
|
|
|
2022-03-14 20:57:01 +08:00
|
|
|
'&:focus, &-focused': {
|
2022-04-11 16:04:00 +08:00
|
|
|
...genActiveStyle(
|
|
|
|
mergeToken<InputToken>(token, {
|
|
|
|
inputBorderActiveColor: colorError,
|
|
|
|
inputBorderHoverColor: colorError,
|
2022-07-21 17:00:42 +08:00
|
|
|
controlOutline: colorErrorOutline,
|
2022-04-11 16:04:00 +08:00
|
|
|
}),
|
|
|
|
),
|
2022-03-14 20:57:01 +08:00
|
|
|
},
|
2022-03-09 10:38:02 +08:00
|
|
|
|
2022-11-08 15:37:35 +08:00
|
|
|
[`${componentCls}-prefix`]: {
|
2022-03-22 09:37:37 +08:00
|
|
|
color: colorError,
|
2022-03-14 20:57:01 +08:00
|
|
|
},
|
2022-03-09 10:38:02 +08:00
|
|
|
},
|
2022-03-14 20:57:01 +08:00
|
|
|
'&-status-warning:not(&-disabled):not(&-borderless)&': {
|
2022-09-20 21:50:36 +08:00
|
|
|
borderColor: colorWarning,
|
|
|
|
|
|
|
|
'&:hover': {
|
|
|
|
borderColor: colorWarningBorderHover,
|
2022-03-14 20:57:01 +08:00
|
|
|
},
|
|
|
|
|
|
|
|
'&:focus, &-focused': {
|
2022-04-11 16:04:00 +08:00
|
|
|
...genActiveStyle(
|
|
|
|
mergeToken<InputToken>(token, {
|
|
|
|
inputBorderActiveColor: colorWarning,
|
|
|
|
inputBorderHoverColor: colorWarning,
|
2022-07-21 17:00:42 +08:00
|
|
|
controlOutline: colorWarningOutline,
|
2022-04-11 16:04:00 +08:00
|
|
|
}),
|
|
|
|
),
|
2022-03-14 20:57:01 +08:00
|
|
|
},
|
2022-03-09 10:38:02 +08:00
|
|
|
|
2022-11-08 15:37:35 +08:00
|
|
|
[`${componentCls}-prefix`]: {
|
2022-03-22 09:37:37 +08:00
|
|
|
color: colorWarning,
|
2022-03-14 20:57:01 +08:00
|
|
|
},
|
2022-03-09 10:38:02 +08:00
|
|
|
},
|
2022-03-14 20:57:01 +08:00
|
|
|
};
|
|
|
|
};
|
2022-03-09 10:38:02 +08:00
|
|
|
|
2022-03-14 20:57:01 +08:00
|
|
|
export const genBasicInputStyle = (token: InputToken): CSSObject => ({
|
2022-03-09 10:38:02 +08:00
|
|
|
position: 'relative',
|
|
|
|
display: 'inline-block',
|
|
|
|
width: '100%',
|
|
|
|
minWidth: 0,
|
|
|
|
padding: `${token.inputPaddingVertical}px ${token.inputPaddingHorizontal}px`,
|
2022-03-22 09:37:37 +08:00
|
|
|
color: token.colorText,
|
2022-03-09 10:38:02 +08:00
|
|
|
fontSize: token.fontSize,
|
|
|
|
lineHeight: token.lineHeight,
|
2022-06-28 20:33:01 +08:00
|
|
|
backgroundColor: token.colorBgContainer,
|
2022-03-09 10:38:02 +08:00
|
|
|
backgroundImage: 'none',
|
2022-11-01 15:06:38 +08:00
|
|
|
borderWidth: token.lineWidth,
|
|
|
|
borderStyle: token.lineType,
|
2022-03-22 13:26:29 +08:00
|
|
|
borderColor: token.colorBorder,
|
2022-11-01 15:06:38 +08:00
|
|
|
borderRadius: token.borderRadius,
|
2022-11-17 23:31:41 +08:00
|
|
|
transition: `all ${token.motionDurationMid}`,
|
2022-06-17 18:47:47 +08:00
|
|
|
...genPlaceholderStyle(token.colorTextPlaceholder),
|
2022-03-09 10:38:02 +08:00
|
|
|
|
|
|
|
'&:hover': {
|
|
|
|
...genHoverStyle(token),
|
|
|
|
},
|
|
|
|
|
|
|
|
'&:focus, &-focused': {
|
|
|
|
...genActiveStyle(token),
|
|
|
|
},
|
|
|
|
|
2022-03-14 11:40:13 +08:00
|
|
|
'&-disabled, &[disabled]': {
|
2022-03-09 10:38:02 +08:00
|
|
|
...genDisabledStyle(token),
|
|
|
|
},
|
|
|
|
|
|
|
|
'&-borderless': {
|
|
|
|
'&, &:hover, &:focus, &-focused, &-disabled, &[disabled]': {
|
|
|
|
backgroundColor: 'transparent',
|
|
|
|
border: 'none',
|
|
|
|
boxShadow: 'none',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
// Reset height for `textarea`s
|
|
|
|
'textarea&': {
|
|
|
|
maxWidth: '100%', // prevent textearea resize from coming out of its container
|
|
|
|
height: 'auto',
|
|
|
|
minHeight: token.controlHeight,
|
|
|
|
lineHeight: token.lineHeight,
|
|
|
|
verticalAlign: 'bottom',
|
2022-03-22 20:02:04 +08:00
|
|
|
transition: `all ${token.motionDurationSlow}, height 0s`,
|
2022-11-30 17:32:02 +08:00
|
|
|
resize: 'vertical',
|
2022-03-09 10:38:02 +08:00
|
|
|
},
|
|
|
|
|
|
|
|
// Size
|
|
|
|
'&-lg': {
|
2022-03-14 20:57:01 +08:00
|
|
|
...genInputLargeStyle(token),
|
2022-03-09 10:38:02 +08:00
|
|
|
},
|
|
|
|
'&-sm': {
|
|
|
|
...genInputSmallStyle(token),
|
|
|
|
},
|
|
|
|
|
2022-11-30 17:32:02 +08:00
|
|
|
// RTL
|
2022-03-09 10:38:02 +08:00
|
|
|
'&-rtl': {
|
|
|
|
direction: 'rtl',
|
|
|
|
},
|
2022-11-30 17:32:02 +08:00
|
|
|
|
|
|
|
'&-textarea-rtl': {
|
|
|
|
direction: 'rtl',
|
|
|
|
},
|
2022-03-09 10:38:02 +08:00
|
|
|
});
|
|
|
|
|
2022-03-14 20:57:01 +08:00
|
|
|
export const genInputGroupStyle = (token: InputToken): CSSObject => {
|
2022-11-08 15:37:35 +08:00
|
|
|
const { componentCls, antCls } = token;
|
2022-03-09 10:38:02 +08:00
|
|
|
|
2022-03-14 20:57:01 +08:00
|
|
|
return {
|
|
|
|
position: 'relative',
|
|
|
|
display: 'table',
|
|
|
|
width: '100%',
|
|
|
|
borderCollapse: 'separate',
|
|
|
|
borderSpacing: 0,
|
2022-03-09 10:38:02 +08:00
|
|
|
|
2022-03-14 20:57:01 +08:00
|
|
|
// Undo padding and float of grid classes
|
|
|
|
[`&[class*='col-']`]: {
|
|
|
|
paddingInlineEnd: token.paddingXS,
|
2022-03-09 10:38:02 +08:00
|
|
|
|
2022-03-14 20:57:01 +08:00
|
|
|
'&:last-child': {
|
|
|
|
paddingInlineEnd: 0,
|
|
|
|
},
|
|
|
|
},
|
2022-03-09 10:38:02 +08:00
|
|
|
|
2022-03-14 20:57:01 +08:00
|
|
|
// Sizing options
|
2022-11-08 15:37:35 +08:00
|
|
|
[`&-lg ${componentCls}, &-lg > ${componentCls}-group-addon`]: {
|
2022-03-14 20:57:01 +08:00
|
|
|
...genInputLargeStyle(token),
|
|
|
|
},
|
2022-03-09 10:38:02 +08:00
|
|
|
|
2022-11-08 15:37:35 +08:00
|
|
|
[`&-sm ${componentCls}, &-sm > ${componentCls}-group-addon`]: {
|
2022-03-14 20:57:01 +08:00
|
|
|
...genInputSmallStyle(token),
|
|
|
|
},
|
2022-03-09 10:38:02 +08:00
|
|
|
|
2022-03-14 20:57:01 +08:00
|
|
|
// Fix https://github.com/ant-design/ant-design/issues/5754
|
2022-08-08 15:50:49 +08:00
|
|
|
[`&-lg ${antCls}-select-single ${antCls}-select-selector`]: {
|
2022-03-14 20:57:01 +08:00
|
|
|
height: token.controlHeightLG,
|
|
|
|
},
|
2022-03-09 10:38:02 +08:00
|
|
|
|
2022-08-08 15:50:49 +08:00
|
|
|
[`&-sm ${antCls}-select-single ${antCls}-select-selector`]: {
|
2022-03-14 20:57:01 +08:00
|
|
|
height: token.controlHeightSM,
|
2022-03-09 10:38:02 +08:00
|
|
|
},
|
|
|
|
|
2022-11-08 15:37:35 +08:00
|
|
|
[`> ${componentCls}`]: {
|
2022-03-09 10:38:02 +08:00
|
|
|
display: 'table-cell',
|
|
|
|
|
|
|
|
'&:not(:first-child):not(:last-child)': {
|
|
|
|
borderRadius: 0,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
2022-11-08 15:37:35 +08:00
|
|
|
[`${componentCls}-group`]: {
|
2022-03-14 20:57:01 +08:00
|
|
|
[`&-addon, &-wrap`]: {
|
|
|
|
display: 'table-cell',
|
2022-03-29 15:57:39 +08:00
|
|
|
width: 1,
|
2022-03-14 20:57:01 +08:00
|
|
|
whiteSpace: 'nowrap',
|
|
|
|
verticalAlign: 'middle',
|
|
|
|
|
|
|
|
'&:not(:first-child):not(:last-child)': {
|
|
|
|
borderRadius: 0,
|
|
|
|
},
|
|
|
|
},
|
2022-03-09 10:38:02 +08:00
|
|
|
|
2022-03-14 20:57:01 +08:00
|
|
|
'&-wrap > *': {
|
|
|
|
display: 'block !important',
|
|
|
|
},
|
2022-03-09 10:38:02 +08:00
|
|
|
|
2022-03-14 20:57:01 +08:00
|
|
|
'&-addon': {
|
|
|
|
position: 'relative',
|
|
|
|
padding: `0 ${token.inputPaddingHorizontal}px`,
|
2022-03-22 09:37:37 +08:00
|
|
|
color: token.colorText,
|
2022-03-14 20:57:01 +08:00
|
|
|
fontWeight: 'normal',
|
|
|
|
fontSize: token.fontSize,
|
|
|
|
textAlign: 'center',
|
2022-07-21 17:00:42 +08:00
|
|
|
backgroundColor: token.colorFillAlter,
|
2022-11-01 15:06:38 +08:00
|
|
|
border: `${token.lineWidth}px ${token.lineType} ${token.colorBorder}`,
|
|
|
|
borderRadius: token.borderRadius,
|
2022-03-22 20:02:04 +08:00
|
|
|
transition: `all ${token.motionDurationSlow}`,
|
2022-03-14 20:57:01 +08:00
|
|
|
|
|
|
|
// Reset Select's style in addon
|
2022-08-08 15:50:49 +08:00
|
|
|
[`${antCls}-select`]: {
|
2022-03-14 20:57:01 +08:00
|
|
|
margin: `-${token.inputPaddingVertical + 1}px -${token.inputPaddingHorizontal}px`,
|
|
|
|
|
2022-08-08 15:50:49 +08:00
|
|
|
[`&${antCls}-select-single:not(${antCls}-select-customize-input)`]: {
|
|
|
|
[`${antCls}-select-selector`]: {
|
2022-03-14 20:57:01 +08:00
|
|
|
backgroundColor: 'inherit',
|
2022-11-01 15:06:38 +08:00
|
|
|
border: `${token.lineWidth}px ${token.lineType} transparent`,
|
2022-03-14 20:57:01 +08:00
|
|
|
boxShadow: 'none',
|
|
|
|
},
|
|
|
|
},
|
2022-03-09 10:38:02 +08:00
|
|
|
|
2022-03-14 20:57:01 +08:00
|
|
|
'&-open, &-focused': {
|
2022-08-08 15:50:49 +08:00
|
|
|
[`${antCls}-select-selector`]: {
|
2022-03-22 09:37:37 +08:00
|
|
|
color: token.colorPrimary,
|
2022-03-14 20:57:01 +08:00
|
|
|
},
|
2022-03-09 10:38:02 +08:00
|
|
|
},
|
|
|
|
},
|
|
|
|
|
2022-03-14 20:57:01 +08:00
|
|
|
// https://github.com/ant-design/ant-design/issues/31333
|
2022-08-08 15:50:49 +08:00
|
|
|
[`${antCls}-cascader-picker`]: {
|
2022-03-14 20:57:01 +08:00
|
|
|
margin: `-9px -${token.inputPaddingHorizontal}px`,
|
|
|
|
backgroundColor: 'transparent',
|
2022-08-08 15:50:49 +08:00
|
|
|
[`${antCls}-cascader-input`]: {
|
2022-03-14 20:57:01 +08:00
|
|
|
textAlign: 'start',
|
|
|
|
border: 0,
|
|
|
|
boxShadow: 'none',
|
2022-03-09 10:38:02 +08:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
2022-03-14 20:57:01 +08:00
|
|
|
'&-addon:first-child': {
|
|
|
|
borderInlineEnd: 0,
|
2022-03-09 10:38:02 +08:00
|
|
|
},
|
|
|
|
|
2022-03-14 20:57:01 +08:00
|
|
|
'&-addon:last-child': {
|
|
|
|
borderInlineStart: 0,
|
|
|
|
},
|
2022-03-09 10:38:02 +08:00
|
|
|
},
|
|
|
|
|
2022-11-08 15:37:35 +08:00
|
|
|
[`${componentCls}`]: {
|
2022-03-14 20:57:01 +08:00
|
|
|
float: 'inline-start',
|
|
|
|
width: '100%',
|
|
|
|
marginBottom: 0,
|
|
|
|
textAlign: 'inherit',
|
2022-03-09 10:38:02 +08:00
|
|
|
|
2022-03-14 20:57:01 +08:00
|
|
|
'&:focus': {
|
|
|
|
zIndex: 1, // Fix https://gw.alipayobjects.com/zos/rmsportal/DHNpoqfMXSfrSnlZvhsJ.png
|
|
|
|
borderInlineEndWidth: 1,
|
|
|
|
},
|
2022-03-09 10:38:02 +08:00
|
|
|
|
2022-03-14 20:57:01 +08:00
|
|
|
'&:hover': {
|
|
|
|
zIndex: 1,
|
|
|
|
borderInlineEndWidth: 1,
|
2022-03-09 10:38:02 +08:00
|
|
|
|
2022-11-08 15:37:35 +08:00
|
|
|
[`${componentCls}-search-with-button &`]: {
|
2022-03-14 20:57:01 +08:00
|
|
|
zIndex: 0,
|
|
|
|
},
|
2022-03-09 10:38:02 +08:00
|
|
|
},
|
|
|
|
},
|
|
|
|
|
2022-03-14 20:57:01 +08:00
|
|
|
// Reset rounded corners
|
2022-11-08 15:37:35 +08:00
|
|
|
[`> ${componentCls}:first-child, ${componentCls}-group-addon:first-child`]: {
|
2022-03-09 10:38:02 +08:00
|
|
|
borderStartEndRadius: 0,
|
|
|
|
borderEndEndRadius: 0,
|
|
|
|
|
2022-03-14 20:57:01 +08:00
|
|
|
// Reset Select's style in addon
|
2022-08-08 15:50:49 +08:00
|
|
|
[`${antCls}-select ${antCls}-select-selector`]: {
|
2022-03-14 20:57:01 +08:00
|
|
|
borderStartEndRadius: 0,
|
|
|
|
borderEndEndRadius: 0,
|
|
|
|
},
|
2022-03-09 10:38:02 +08:00
|
|
|
},
|
|
|
|
|
2022-11-08 15:37:35 +08:00
|
|
|
[`> ${componentCls}-affix-wrapper`]: {
|
|
|
|
[`&:not(:first-child) ${componentCls}`]: {
|
2022-03-14 20:57:01 +08:00
|
|
|
borderStartStartRadius: 0,
|
|
|
|
borderEndStartRadius: 0,
|
|
|
|
},
|
2022-03-09 10:38:02 +08:00
|
|
|
|
2022-11-08 15:37:35 +08:00
|
|
|
[`&:not(:last-child) ${componentCls}`]: {
|
2022-03-14 20:57:01 +08:00
|
|
|
borderStartEndRadius: 0,
|
|
|
|
borderEndEndRadius: 0,
|
|
|
|
},
|
|
|
|
},
|
2022-03-09 10:38:02 +08:00
|
|
|
|
2022-11-08 15:37:35 +08:00
|
|
|
[`> ${componentCls}:last-child, ${componentCls}-group-addon:last-child`]: {
|
2022-03-09 10:38:02 +08:00
|
|
|
borderStartStartRadius: 0,
|
|
|
|
borderEndStartRadius: 0,
|
|
|
|
|
2022-03-14 20:57:01 +08:00
|
|
|
// Reset Select's style in addon
|
2022-08-08 15:50:49 +08:00
|
|
|
[`${antCls}-select ${antCls}-select-selector`]: {
|
2022-03-14 20:57:01 +08:00
|
|
|
borderStartStartRadius: 0,
|
|
|
|
borderEndStartRadius: 0,
|
2022-03-09 10:38:02 +08:00
|
|
|
},
|
|
|
|
},
|
|
|
|
|
2022-11-08 15:37:35 +08:00
|
|
|
[`${componentCls}-affix-wrapper`]: {
|
2022-03-14 20:57:01 +08:00
|
|
|
'&:not(:last-child)': {
|
|
|
|
borderStartEndRadius: 0,
|
|
|
|
borderEndEndRadius: 0,
|
2022-11-08 15:37:35 +08:00
|
|
|
[`${componentCls}-search &`]: {
|
2022-11-01 15:06:38 +08:00
|
|
|
borderStartStartRadius: token.borderRadius,
|
|
|
|
borderEndStartRadius: token.borderRadius,
|
2022-03-14 20:57:01 +08:00
|
|
|
},
|
|
|
|
},
|
|
|
|
|
2022-11-08 15:37:35 +08:00
|
|
|
[`&:not(:first-child), ${componentCls}-search &:not(:first-child)`]: {
|
2022-03-14 20:57:01 +08:00
|
|
|
borderStartStartRadius: 0,
|
|
|
|
borderEndStartRadius: 0,
|
|
|
|
},
|
2022-03-09 10:38:02 +08:00
|
|
|
},
|
|
|
|
|
2022-03-14 20:57:01 +08:00
|
|
|
'&&-compact': {
|
|
|
|
display: 'block',
|
|
|
|
...clearFix(),
|
2022-03-09 10:38:02 +08:00
|
|
|
|
2022-11-08 15:37:35 +08:00
|
|
|
[`${componentCls}-group-addon, ${componentCls}-group-wrap, > ${componentCls}`]: {
|
2022-03-14 20:57:01 +08:00
|
|
|
'&:not(:first-child):not(:last-child)': {
|
2022-11-01 15:06:38 +08:00
|
|
|
borderInlineEndWidth: token.lineWidth,
|
2022-03-09 10:38:02 +08:00
|
|
|
|
2022-03-14 20:57:01 +08:00
|
|
|
'&:hover': {
|
|
|
|
zIndex: 1,
|
|
|
|
},
|
2022-03-09 10:38:02 +08:00
|
|
|
|
2022-03-14 20:57:01 +08:00
|
|
|
'&:focus': {
|
|
|
|
zIndex: 1,
|
|
|
|
},
|
2022-03-09 10:38:02 +08:00
|
|
|
},
|
|
|
|
},
|
|
|
|
|
2022-03-14 20:57:01 +08:00
|
|
|
'& > *': {
|
|
|
|
display: 'inline-block',
|
|
|
|
float: 'none',
|
|
|
|
verticalAlign: 'top', // https://github.com/ant-design/ant-design-pro/issues/139
|
|
|
|
borderRadius: 0,
|
|
|
|
},
|
2022-03-09 10:38:02 +08:00
|
|
|
|
2022-11-08 15:37:35 +08:00
|
|
|
[`& > ${componentCls}-affix-wrapper`]: {
|
2022-03-14 20:57:01 +08:00
|
|
|
display: 'inline-flex',
|
|
|
|
},
|
2022-03-09 10:38:02 +08:00
|
|
|
|
2022-08-08 15:50:49 +08:00
|
|
|
[`& > ${antCls}-picker-range`]: {
|
2022-03-14 20:57:01 +08:00
|
|
|
display: 'inline-flex',
|
|
|
|
},
|
2022-03-09 10:38:02 +08:00
|
|
|
|
2022-03-14 20:57:01 +08:00
|
|
|
'& > *:not(:last-child)': {
|
2022-11-01 15:06:38 +08:00
|
|
|
marginInlineEnd: -token.lineWidth,
|
|
|
|
borderInlineEndWidth: token.lineWidth,
|
2022-03-14 20:57:01 +08:00
|
|
|
},
|
2022-03-09 10:38:02 +08:00
|
|
|
|
2022-03-14 20:57:01 +08:00
|
|
|
// Undo float for .ant-input-group .ant-input
|
2022-11-08 15:37:35 +08:00
|
|
|
[`${componentCls}`]: {
|
2022-03-14 20:57:01 +08:00
|
|
|
float: 'none',
|
|
|
|
},
|
2022-03-09 10:38:02 +08:00
|
|
|
|
2022-03-14 20:57:01 +08:00
|
|
|
// reset border for Select, DatePicker, AutoComplete, Cascader, Mention, TimePicker, Input
|
2022-08-08 15:50:49 +08:00
|
|
|
[`& > ${antCls}-select > ${antCls}-select-selector,
|
2022-11-08 15:37:35 +08:00
|
|
|
& > ${antCls}-select-auto-complete ${componentCls},
|
|
|
|
& > ${antCls}-cascader-picker ${componentCls},
|
|
|
|
& > ${componentCls}-group-wrapper ${componentCls}`]: {
|
2022-11-01 15:06:38 +08:00
|
|
|
borderInlineEndWidth: token.lineWidth,
|
2022-03-14 20:57:01 +08:00
|
|
|
borderRadius: 0,
|
2022-03-09 10:38:02 +08:00
|
|
|
|
2022-03-14 20:57:01 +08:00
|
|
|
'&:hover': {
|
|
|
|
zIndex: 1,
|
|
|
|
},
|
|
|
|
|
|
|
|
'&:focus': {
|
|
|
|
zIndex: 1,
|
|
|
|
},
|
2022-03-09 10:38:02 +08:00
|
|
|
},
|
|
|
|
|
2022-08-08 15:50:49 +08:00
|
|
|
[`& > ${antCls}-select-focused`]: {
|
2022-03-09 10:38:02 +08:00
|
|
|
zIndex: 1,
|
|
|
|
},
|
|
|
|
|
2022-03-14 20:57:01 +08:00
|
|
|
// update z-index for arrow icon
|
2022-08-08 15:50:49 +08:00
|
|
|
[`& > ${antCls}-select > ${antCls}-select-arrow`]: {
|
2022-03-14 20:57:01 +08:00
|
|
|
zIndex: 1, // https://github.com/ant-design/ant-design/issues/20371
|
|
|
|
},
|
2022-03-09 10:38:02 +08:00
|
|
|
|
2022-03-14 20:57:01 +08:00
|
|
|
[`& > *:first-child,
|
2022-08-08 15:50:49 +08:00
|
|
|
& > ${antCls}-select:first-child > ${antCls}-select-selector,
|
2022-11-08 15:37:35 +08:00
|
|
|
& > ${antCls}-select-auto-complete:first-child ${componentCls},
|
|
|
|
& > ${antCls}-cascader-picker:first-child ${componentCls}`]: {
|
2022-11-01 15:06:38 +08:00
|
|
|
borderStartStartRadius: token.borderRadius,
|
|
|
|
borderEndStartRadius: token.borderRadius,
|
2022-03-14 20:57:01 +08:00
|
|
|
},
|
2022-03-09 10:38:02 +08:00
|
|
|
|
2022-03-14 20:57:01 +08:00
|
|
|
[`& > *:last-child,
|
2022-08-08 15:50:49 +08:00
|
|
|
& > ${antCls}-select:last-child > ${antCls}-select-selector,
|
2022-11-08 15:37:35 +08:00
|
|
|
& > ${antCls}-cascader-picker:last-child ${componentCls},
|
|
|
|
& > ${antCls}-cascader-picker-focused:last-child ${componentCls}`]: {
|
2022-11-01 15:06:38 +08:00
|
|
|
borderInlineEndWidth: token.lineWidth,
|
|
|
|
borderStartEndRadius: token.borderRadius,
|
|
|
|
borderEndEndRadius: token.borderRadius,
|
2022-03-14 20:57:01 +08:00
|
|
|
},
|
2022-03-09 10:38:02 +08:00
|
|
|
|
2022-03-14 20:57:01 +08:00
|
|
|
// https://github.com/ant-design/ant-design/issues/12493
|
2022-11-08 15:37:35 +08:00
|
|
|
[`& > ${antCls}-select-auto-complete ${componentCls}`]: {
|
2022-03-14 20:57:01 +08:00
|
|
|
verticalAlign: 'top',
|
2022-03-09 10:38:02 +08:00
|
|
|
},
|
|
|
|
|
2022-11-08 15:37:35 +08:00
|
|
|
[`${componentCls}-group-wrapper + ${componentCls}-group-wrapper`]: {
|
2022-11-01 15:06:38 +08:00
|
|
|
marginInlineStart: -token.lineWidth,
|
2022-11-08 15:37:35 +08:00
|
|
|
[`${componentCls}-affix-wrapper`]: {
|
2022-03-09 10:38:02 +08:00
|
|
|
borderRadius: 0,
|
|
|
|
},
|
2022-03-14 20:57:01 +08:00
|
|
|
},
|
2022-03-09 10:38:02 +08:00
|
|
|
|
2022-11-08 15:37:35 +08:00
|
|
|
[`${componentCls}-group-wrapper:not(:last-child)`]: {
|
|
|
|
[`&${componentCls}-search > ${componentCls}-group`]: {
|
|
|
|
[`& > ${componentCls}-group-addon > ${componentCls}-search-button`]: {
|
2022-03-14 20:57:01 +08:00
|
|
|
borderRadius: 0,
|
|
|
|
},
|
|
|
|
|
2022-11-08 15:37:35 +08:00
|
|
|
[`& > ${componentCls}`]: {
|
2022-11-01 15:06:38 +08:00
|
|
|
borderStartStartRadius: token.borderRadius,
|
2022-03-14 20:57:01 +08:00
|
|
|
borderStartEndRadius: 0,
|
|
|
|
borderEndEndRadius: 0,
|
2022-11-01 15:06:38 +08:00
|
|
|
borderEndStartRadius: token.borderRadius,
|
2022-03-14 20:57:01 +08:00
|
|
|
},
|
2022-03-09 10:38:02 +08:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2022-03-14 20:57:01 +08:00
|
|
|
};
|
|
|
|
};
|
2022-03-09 10:38:02 +08:00
|
|
|
|
2022-03-14 20:57:01 +08:00
|
|
|
const genInputStyle: GenerateStyle<InputToken> = (token: InputToken) => {
|
2022-12-12 16:36:46 +08:00
|
|
|
const { componentCls, controlHeightSM, lineWidth } = token;
|
2022-03-29 15:57:39 +08:00
|
|
|
|
|
|
|
const FIXED_CHROME_COLOR_HEIGHT = 16;
|
2022-11-01 15:06:38 +08:00
|
|
|
const colorSmallPadding = (controlHeightSM - lineWidth * 2 - FIXED_CHROME_COLOR_HEIGHT) / 2;
|
2022-03-09 10:38:02 +08:00
|
|
|
|
2022-03-14 20:57:01 +08:00
|
|
|
return {
|
2022-11-08 15:37:35 +08:00
|
|
|
[`${componentCls}`]: {
|
2022-03-14 20:57:01 +08:00
|
|
|
...resetComponent(token),
|
|
|
|
...genBasicInputStyle(token),
|
|
|
|
...genStatusStyle(token),
|
2022-03-09 10:38:02 +08:00
|
|
|
|
2022-03-14 20:57:01 +08:00
|
|
|
'&[type="color"]': {
|
|
|
|
height: token.controlHeight,
|
2022-03-09 10:38:02 +08:00
|
|
|
|
2022-11-08 15:37:35 +08:00
|
|
|
[`&${componentCls}-lg`]: {
|
2022-03-14 20:57:01 +08:00
|
|
|
height: token.controlHeightLG,
|
|
|
|
},
|
2022-11-08 15:37:35 +08:00
|
|
|
[`&${componentCls}-sm`]: {
|
2022-03-29 15:57:39 +08:00
|
|
|
height: controlHeightSM,
|
|
|
|
paddingTop: colorSmallPadding,
|
|
|
|
paddingBottom: colorSmallPadding,
|
2022-03-14 20:57:01 +08:00
|
|
|
},
|
|
|
|
},
|
2022-03-09 10:38:02 +08:00
|
|
|
},
|
2022-03-14 20:57:01 +08:00
|
|
|
};
|
|
|
|
};
|
2022-03-09 10:38:02 +08:00
|
|
|
|
2022-03-14 20:57:01 +08:00
|
|
|
const genAllowClearStyle = (token: InputToken): CSSObject => {
|
2022-11-08 15:37:35 +08:00
|
|
|
const { componentCls } = token;
|
2022-03-14 20:57:01 +08:00
|
|
|
return {
|
|
|
|
// ========================= Input =========================
|
2022-11-08 15:37:35 +08:00
|
|
|
[`${componentCls}-clear-icon`]: {
|
2022-03-14 20:57:01 +08:00
|
|
|
margin: 0,
|
2022-07-21 17:00:42 +08:00
|
|
|
color: token.colorIcon,
|
2022-03-29 15:57:39 +08:00
|
|
|
fontSize: token.fontSizeIcon,
|
|
|
|
verticalAlign: -1,
|
2022-03-14 20:57:01 +08:00
|
|
|
// https://github.com/ant-design/ant-design/pull/18151
|
|
|
|
// https://codesandbox.io/s/wizardly-sun-u10br
|
|
|
|
cursor: 'pointer',
|
2022-03-22 20:02:04 +08:00
|
|
|
transition: `color ${token.motionDurationSlow}`,
|
2022-03-09 10:38:02 +08:00
|
|
|
|
2022-03-14 20:57:01 +08:00
|
|
|
'&:hover': {
|
2022-08-04 16:16:50 +08:00
|
|
|
color: token.colorTextDescription,
|
2022-03-14 20:57:01 +08:00
|
|
|
},
|
2022-03-09 10:38:02 +08:00
|
|
|
|
2022-03-14 20:57:01 +08:00
|
|
|
'&:active': {
|
2022-03-22 09:37:37 +08:00
|
|
|
color: token.colorText,
|
2022-03-14 20:57:01 +08:00
|
|
|
},
|
2022-03-09 10:38:02 +08:00
|
|
|
|
2022-03-14 20:57:01 +08:00
|
|
|
'&-hidden': {
|
|
|
|
visibility: 'hidden',
|
|
|
|
},
|
2022-03-09 10:38:02 +08:00
|
|
|
|
2022-03-14 20:57:01 +08:00
|
|
|
'&-has-suffix': {
|
2022-03-29 15:57:39 +08:00
|
|
|
margin: `0 ${token.inputAffixPadding}px`,
|
2022-03-14 20:57:01 +08:00
|
|
|
},
|
2022-03-09 10:38:02 +08:00
|
|
|
},
|
|
|
|
|
2022-03-14 20:57:01 +08:00
|
|
|
// ======================= TextArea ========================
|
|
|
|
'&-textarea-with-clear-btn': {
|
|
|
|
padding: '0 !important',
|
|
|
|
border: '0 !important',
|
2022-03-09 10:38:02 +08:00
|
|
|
|
2022-11-08 15:37:35 +08:00
|
|
|
[`${componentCls}-clear-icon`]: {
|
2022-03-14 20:57:01 +08:00
|
|
|
position: 'absolute',
|
|
|
|
insetBlockStart: token.paddingXS,
|
|
|
|
insetInlineEnd: token.paddingXS,
|
|
|
|
zIndex: 1,
|
|
|
|
},
|
2022-03-09 10:38:02 +08:00
|
|
|
},
|
2022-03-14 20:57:01 +08:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
const genAffixStyle: GenerateStyle<InputToken> = (token: InputToken) => {
|
|
|
|
const {
|
2022-11-08 15:37:35 +08:00
|
|
|
componentCls,
|
2022-03-29 15:57:39 +08:00
|
|
|
inputAffixPadding,
|
2022-08-04 16:16:50 +08:00
|
|
|
colorTextDescription,
|
2022-03-24 14:30:48 +08:00
|
|
|
motionDurationSlow,
|
2022-07-21 17:00:42 +08:00
|
|
|
colorIcon,
|
|
|
|
colorIconHover,
|
2022-04-06 21:49:30 +08:00
|
|
|
iconCls,
|
2022-03-14 20:57:01 +08:00
|
|
|
} = token;
|
|
|
|
|
|
|
|
return {
|
2022-11-08 15:37:35 +08:00
|
|
|
[`${componentCls}-affix-wrapper`]: {
|
2022-03-14 20:57:01 +08:00
|
|
|
...genBasicInputStyle(token),
|
|
|
|
display: 'inline-flex',
|
2022-03-09 10:38:02 +08:00
|
|
|
|
2022-03-14 20:57:01 +08:00
|
|
|
'&:not(&-disabled):hover': {
|
|
|
|
...genHoverStyle(token),
|
|
|
|
zIndex: 1,
|
2022-11-08 15:37:35 +08:00
|
|
|
[`${componentCls}-search-with-button &`]: {
|
2022-03-14 20:57:01 +08:00
|
|
|
zIndex: 0,
|
|
|
|
},
|
|
|
|
},
|
2022-03-09 10:38:02 +08:00
|
|
|
|
2022-03-14 20:57:01 +08:00
|
|
|
'&-focused, &:focus': {
|
|
|
|
zIndex: 1,
|
|
|
|
},
|
2022-03-09 10:38:02 +08:00
|
|
|
|
2022-03-14 20:57:01 +08:00
|
|
|
'&-disabled': {
|
2022-11-08 15:37:35 +08:00
|
|
|
[`${componentCls}[disabled]`]: {
|
2022-03-14 20:57:01 +08:00
|
|
|
background: 'transparent',
|
|
|
|
},
|
|
|
|
},
|
2022-03-09 10:38:02 +08:00
|
|
|
|
2022-11-08 15:37:35 +08:00
|
|
|
[`> input${componentCls}`]: {
|
2022-03-14 20:57:01 +08:00
|
|
|
padding: 0,
|
2022-10-11 20:29:55 +08:00
|
|
|
fontSize: 'inherit',
|
2022-03-14 20:57:01 +08:00
|
|
|
border: 'none',
|
2022-11-08 15:37:35 +08:00
|
|
|
borderRadius: 0,
|
2022-03-14 20:57:01 +08:00
|
|
|
outline: 'none',
|
2022-03-09 10:38:02 +08:00
|
|
|
|
2022-03-14 20:57:01 +08:00
|
|
|
'&:focus': {
|
|
|
|
boxShadow: 'none !important',
|
|
|
|
},
|
|
|
|
},
|
2022-03-09 10:38:02 +08:00
|
|
|
|
2022-03-14 20:57:01 +08:00
|
|
|
'&::before': {
|
|
|
|
width: 0,
|
|
|
|
visibility: 'hidden',
|
|
|
|
content: '"\\a0"',
|
|
|
|
},
|
2022-03-09 10:38:02 +08:00
|
|
|
|
2022-11-08 15:37:35 +08:00
|
|
|
[`${componentCls}`]: {
|
2022-03-14 20:57:01 +08:00
|
|
|
'&-prefix, &-suffix': {
|
|
|
|
display: 'flex',
|
|
|
|
flex: 'none',
|
|
|
|
alignItems: 'center',
|
2022-03-25 20:08:05 +08:00
|
|
|
|
|
|
|
'> *:not(:last-child)': {
|
2022-03-29 15:57:39 +08:00
|
|
|
marginInlineEnd: token.paddingXS,
|
2022-03-25 20:08:05 +08:00
|
|
|
},
|
2022-03-14 20:57:01 +08:00
|
|
|
},
|
2022-03-09 10:38:02 +08:00
|
|
|
|
2022-03-14 20:57:01 +08:00
|
|
|
'&-show-count-suffix': {
|
2022-08-04 16:16:50 +08:00
|
|
|
color: colorTextDescription,
|
2022-03-14 20:57:01 +08:00
|
|
|
},
|
2022-03-09 10:38:02 +08:00
|
|
|
|
2022-03-14 20:57:01 +08:00
|
|
|
'&-show-count-has-suffix': {
|
2022-03-29 15:57:39 +08:00
|
|
|
marginInlineEnd: token.paddingXXS,
|
2022-03-14 20:57:01 +08:00
|
|
|
},
|
2022-03-09 10:38:02 +08:00
|
|
|
|
2022-03-14 20:57:01 +08:00
|
|
|
'&-prefix': {
|
2022-03-29 15:57:39 +08:00
|
|
|
marginInlineEnd: inputAffixPadding,
|
2022-03-14 20:57:01 +08:00
|
|
|
},
|
2022-03-09 10:38:02 +08:00
|
|
|
|
2022-03-14 20:57:01 +08:00
|
|
|
'&-suffix': {
|
2022-03-29 15:57:39 +08:00
|
|
|
marginInlineStart: inputAffixPadding,
|
2022-03-14 20:57:01 +08:00
|
|
|
},
|
|
|
|
},
|
2022-03-09 10:38:02 +08:00
|
|
|
|
2022-03-14 20:57:01 +08:00
|
|
|
...genAllowClearStyle(token),
|
2022-03-09 10:38:02 +08:00
|
|
|
|
2022-03-14 20:57:01 +08:00
|
|
|
// password
|
2022-11-08 15:37:35 +08:00
|
|
|
[`${iconCls}${componentCls}-password-icon`]: {
|
2022-07-21 17:00:42 +08:00
|
|
|
color: colorIcon,
|
2022-03-14 20:57:01 +08:00
|
|
|
cursor: 'pointer',
|
2022-03-24 14:30:48 +08:00
|
|
|
transition: `all ${motionDurationSlow}`,
|
2022-03-09 10:38:02 +08:00
|
|
|
|
2022-03-14 20:57:01 +08:00
|
|
|
'&:hover': {
|
2022-07-21 17:00:42 +08:00
|
|
|
color: colorIconHover,
|
2022-03-14 20:57:01 +08:00
|
|
|
},
|
|
|
|
},
|
2022-03-09 10:38:02 +08:00
|
|
|
|
2022-03-14 20:57:01 +08:00
|
|
|
// status
|
|
|
|
...genStatusStyle(token),
|
2022-03-09 10:38:02 +08:00
|
|
|
},
|
2022-03-14 20:57:01 +08:00
|
|
|
};
|
|
|
|
};
|
2022-03-09 10:38:02 +08:00
|
|
|
|
2022-03-14 20:57:01 +08:00
|
|
|
const genGroupStyle: GenerateStyle<InputToken> = (token: InputToken) => {
|
2022-11-08 15:37:35 +08:00
|
|
|
const { componentCls, colorError, colorSuccess, borderRadiusLG, borderRadiusSM } = token;
|
2022-03-09 10:38:02 +08:00
|
|
|
|
2022-03-14 20:57:01 +08:00
|
|
|
return {
|
2022-11-08 15:37:35 +08:00
|
|
|
[`${componentCls}-group`]: {
|
2022-03-14 20:57:01 +08:00
|
|
|
// Style for input-group: input with label, with button or dropdown...
|
|
|
|
...resetComponent(token),
|
|
|
|
...genInputGroupStyle(token),
|
|
|
|
|
|
|
|
'&-rtl': {
|
|
|
|
direction: 'rtl',
|
2022-03-09 10:38:02 +08:00
|
|
|
},
|
|
|
|
|
2022-03-14 20:57:01 +08:00
|
|
|
'&-wrapper': {
|
|
|
|
display: 'inline-block',
|
|
|
|
width: '100%',
|
|
|
|
textAlign: 'start',
|
|
|
|
verticalAlign: 'top', // https://github.com/ant-design/ant-design/issues/6403
|
2022-03-09 10:38:02 +08:00
|
|
|
|
2022-03-14 20:57:01 +08:00
|
|
|
'&-rtl': {
|
|
|
|
direction: 'rtl',
|
|
|
|
},
|
2022-08-19 10:10:51 +08:00
|
|
|
|
|
|
|
// Size
|
|
|
|
'&-lg': {
|
|
|
|
[`${componentCls}-group-addon`]: {
|
2022-11-01 15:06:38 +08:00
|
|
|
borderRadius: borderRadiusLG,
|
2022-08-19 10:10:51 +08:00
|
|
|
},
|
|
|
|
},
|
|
|
|
'&-sm': {
|
|
|
|
[`${componentCls}-group-addon`]: {
|
2022-11-01 15:06:38 +08:00
|
|
|
borderRadius: borderRadiusSM,
|
2022-08-19 10:10:51 +08:00
|
|
|
},
|
|
|
|
},
|
2022-03-09 10:38:02 +08:00
|
|
|
|
2022-03-14 20:57:01 +08:00
|
|
|
// Status
|
|
|
|
'&-status-error': {
|
2022-11-08 15:37:35 +08:00
|
|
|
[`${componentCls}-group-addon`]: {
|
2022-03-22 09:37:37 +08:00
|
|
|
color: colorError,
|
|
|
|
borderColor: colorError,
|
2022-03-14 20:57:01 +08:00
|
|
|
},
|
|
|
|
},
|
|
|
|
'&-status-warning': {
|
2022-11-08 15:37:35 +08:00
|
|
|
[`${componentCls}-group-addon:last-child`]: {
|
2022-03-22 09:37:37 +08:00
|
|
|
color: colorSuccess,
|
|
|
|
borderColor: colorSuccess,
|
2022-03-14 20:57:01 +08:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
const genSearchInputStyle: GenerateStyle<InputToken> = (token: InputToken) => {
|
2022-11-08 15:37:35 +08:00
|
|
|
const { componentCls, antCls } = token;
|
|
|
|
const searchPrefixCls = `${componentCls}-search`;
|
2022-03-14 20:57:01 +08:00
|
|
|
return {
|
|
|
|
[searchPrefixCls]: {
|
2022-11-08 15:37:35 +08:00
|
|
|
[`${componentCls}`]: {
|
2022-03-14 20:57:01 +08:00
|
|
|
'&:hover, &:focus': {
|
2022-03-22 20:02:04 +08:00
|
|
|
borderColor: token.colorPrimaryHover,
|
2022-03-14 20:57:01 +08:00
|
|
|
|
2022-11-19 21:49:11 +08:00
|
|
|
[`+ ${componentCls}-group-addon ${searchPrefixCls}-button:not(${antCls}-btn-primary)`]: {
|
|
|
|
borderInlineStartColor: token.colorPrimaryHover,
|
|
|
|
},
|
2022-03-14 20:57:01 +08:00
|
|
|
},
|
|
|
|
},
|
2022-03-09 10:38:02 +08:00
|
|
|
|
2022-11-08 15:37:35 +08:00
|
|
|
[`${componentCls}-affix-wrapper`]: {
|
2022-03-14 20:57:01 +08:00
|
|
|
borderRadius: 0,
|
2022-03-09 10:38:02 +08:00
|
|
|
},
|
|
|
|
|
2022-03-14 20:57:01 +08:00
|
|
|
// fix slight height diff in Firefox:
|
|
|
|
// https://ant.design/components/auto-complete-cn/#components-auto-complete-demo-certain-category
|
2022-11-08 15:37:35 +08:00
|
|
|
[`${componentCls}-lg`]: {
|
2022-11-18 11:51:57 +08:00
|
|
|
lineHeight: token.lineHeightLG - 0.0002,
|
2022-03-14 20:57:01 +08:00
|
|
|
},
|
|
|
|
|
2022-11-08 15:37:35 +08:00
|
|
|
[`> ${componentCls}-group`]: {
|
|
|
|
[`> ${componentCls}-group-addon:last-child`]: {
|
2022-03-14 20:57:01 +08:00
|
|
|
insetInlineStart: -1,
|
|
|
|
padding: 0,
|
|
|
|
border: 0,
|
2022-03-09 10:38:02 +08:00
|
|
|
|
2022-03-14 20:57:01 +08:00
|
|
|
[`${searchPrefixCls}-button`]: {
|
|
|
|
paddingTop: 0,
|
|
|
|
paddingBottom: 0,
|
|
|
|
borderStartStartRadius: 0,
|
2022-11-01 15:06:38 +08:00
|
|
|
borderStartEndRadius: token.borderRadius,
|
|
|
|
borderEndEndRadius: token.borderRadius,
|
2022-03-14 20:57:01 +08:00
|
|
|
borderEndStartRadius: 0,
|
|
|
|
},
|
|
|
|
|
2022-08-08 15:50:49 +08:00
|
|
|
[`${searchPrefixCls}-button:not(${antCls}-btn-primary)`]: {
|
2022-08-04 16:16:50 +08:00
|
|
|
color: token.colorTextDescription,
|
2022-03-14 20:57:01 +08:00
|
|
|
|
2022-09-20 21:50:36 +08:00
|
|
|
'&:hover': {
|
|
|
|
color: token.colorPrimaryHover,
|
|
|
|
},
|
|
|
|
|
|
|
|
'&:active': {
|
|
|
|
color: token.colorPrimaryActive,
|
|
|
|
},
|
|
|
|
|
2022-08-08 15:50:49 +08:00
|
|
|
[`&${antCls}-btn-loading::before`]: {
|
2022-03-14 20:57:01 +08:00
|
|
|
insetInlineStart: 0,
|
|
|
|
insetInlineEnd: 0,
|
|
|
|
insetBlockStart: 0,
|
|
|
|
insetBlockEnd: 0,
|
|
|
|
},
|
|
|
|
},
|
2022-03-09 10:38:02 +08:00
|
|
|
},
|
|
|
|
},
|
|
|
|
|
2022-03-14 20:57:01 +08:00
|
|
|
[`${searchPrefixCls}-button`]: {
|
|
|
|
height: token.controlHeight,
|
2022-03-09 10:38:02 +08:00
|
|
|
|
2022-03-14 20:57:01 +08:00
|
|
|
'&:hover, &:focus': {
|
|
|
|
zIndex: 1,
|
|
|
|
},
|
|
|
|
},
|
2022-03-09 10:38:02 +08:00
|
|
|
|
2022-03-14 20:57:01 +08:00
|
|
|
[`&-large ${searchPrefixCls}-button`]: {
|
|
|
|
height: token.controlHeightLG,
|
|
|
|
},
|
2022-03-09 10:38:02 +08:00
|
|
|
|
2022-03-14 20:57:01 +08:00
|
|
|
[`&-small ${searchPrefixCls}-button`]: {
|
|
|
|
height: token.controlHeightSM,
|
|
|
|
},
|
2022-03-09 10:38:02 +08:00
|
|
|
|
2022-03-14 20:57:01 +08:00
|
|
|
'&-rtl': {
|
|
|
|
direction: 'rtl',
|
|
|
|
},
|
2022-10-28 16:09:38 +08:00
|
|
|
|
|
|
|
// ===================== Compact Item Customized Styles =====================
|
2022-11-08 15:37:35 +08:00
|
|
|
[`&${componentCls}-compact-item`]: {
|
|
|
|
[`&:not(${componentCls}-compact-last-item)`]: {
|
|
|
|
[`${componentCls}-group-addon`]: {
|
|
|
|
[`${componentCls}-search-button`]: {
|
2022-11-01 15:06:38 +08:00
|
|
|
marginInlineEnd: -token.lineWidth,
|
2022-10-28 16:09:38 +08:00
|
|
|
borderRadius: 0,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
2022-11-08 15:37:35 +08:00
|
|
|
[`&:not(${componentCls}-compact-first-item)`]: {
|
|
|
|
[`${componentCls},${componentCls}-affix-wrapper`]: {
|
2022-10-28 16:09:38 +08:00
|
|
|
borderRadius: 0,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
2022-11-08 15:37:35 +08:00
|
|
|
[`> ${componentCls}-group-addon ${componentCls}-search-button,
|
|
|
|
> ${componentCls},
|
|
|
|
${componentCls}-affix-wrapper`]: {
|
2022-10-28 16:09:38 +08:00
|
|
|
'&:hover,&:focus,&:active': {
|
|
|
|
zIndex: 2,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
2022-11-08 15:37:35 +08:00
|
|
|
[`> ${componentCls}-affix-wrapper-focused`]: {
|
2022-10-28 16:09:38 +08:00
|
|
|
zIndex: 2,
|
|
|
|
},
|
|
|
|
},
|
2022-03-14 20:57:01 +08:00
|
|
|
},
|
|
|
|
};
|
|
|
|
};
|
2022-03-09 10:38:02 +08:00
|
|
|
|
2022-04-06 21:49:30 +08:00
|
|
|
export function initInputToken<T extends GlobalToken = GlobalToken>(token: T): InputToken<T> {
|
2022-04-11 16:04:00 +08:00
|
|
|
// @ts-ignore
|
|
|
|
return mergeToken<InputToken<T>>(token, {
|
2022-04-06 21:49:30 +08:00
|
|
|
inputAffixPadding: token.paddingXXS,
|
|
|
|
inputPaddingVertical: Math.max(
|
|
|
|
Math.round(((token.controlHeight - token.fontSize * token.lineHeight) / 2) * 10) / 10 -
|
2022-11-01 15:06:38 +08:00
|
|
|
token.lineWidth,
|
2022-04-06 21:49:30 +08:00
|
|
|
3,
|
|
|
|
),
|
|
|
|
inputPaddingVerticalLG:
|
2022-11-08 15:37:35 +08:00
|
|
|
Math.ceil(((token.controlHeightLG - token.fontSizeLG * token.lineHeightLG) / 2) * 10) / 10 -
|
2022-11-01 15:06:38 +08:00
|
|
|
token.lineWidth,
|
2022-04-06 21:49:30 +08:00
|
|
|
inputPaddingVerticalSM: Math.max(
|
|
|
|
Math.round(((token.controlHeightSM - token.fontSize * token.lineHeight) / 2) * 10) / 10 -
|
2022-11-01 15:06:38 +08:00
|
|
|
token.lineWidth,
|
2022-04-06 21:49:30 +08:00
|
|
|
0,
|
|
|
|
),
|
2022-12-09 17:52:34 +08:00
|
|
|
inputPaddingHorizontal: token.paddingSM - token.lineWidth,
|
|
|
|
inputPaddingHorizontalSM: token.paddingXS - token.lineWidth,
|
|
|
|
inputPaddingHorizontalLG: token.controlPaddingHorizontal - token.lineWidth,
|
2022-04-06 21:49:30 +08:00
|
|
|
inputBorderHoverColor: token.colorPrimaryHover,
|
|
|
|
inputBorderActiveColor: token.colorPrimaryHover,
|
2022-04-11 16:04:00 +08:00
|
|
|
});
|
2022-04-06 21:49:30 +08:00
|
|
|
}
|
2022-03-14 11:40:13 +08:00
|
|
|
|
2022-11-17 23:31:41 +08:00
|
|
|
const genTextAreaStyle: GenerateStyle<InputToken> = (token) => {
|
2022-11-08 15:37:35 +08:00
|
|
|
const { componentCls, inputPaddingHorizontal, paddingLG } = token;
|
|
|
|
const textareaPrefixCls = `${componentCls}-textarea`;
|
2022-03-14 20:57:01 +08:00
|
|
|
|
|
|
|
return {
|
|
|
|
[textareaPrefixCls]: {
|
2022-03-29 15:57:39 +08:00
|
|
|
position: 'relative',
|
|
|
|
|
2022-03-25 20:08:05 +08:00
|
|
|
[`${textareaPrefixCls}-suffix`]: {
|
2022-03-14 20:57:01 +08:00
|
|
|
position: 'absolute',
|
|
|
|
top: 0,
|
|
|
|
insetInlineEnd: inputPaddingHorizontal,
|
|
|
|
bottom: 0,
|
|
|
|
zIndex: 1,
|
|
|
|
display: 'inline-flex',
|
|
|
|
alignItems: 'center',
|
|
|
|
margin: 'auto',
|
|
|
|
},
|
|
|
|
|
|
|
|
[`&-status-error,
|
|
|
|
&-status-warning,
|
|
|
|
&-status-success,
|
|
|
|
&-status-validating`]: {
|
|
|
|
[`&${textareaPrefixCls}-has-feedback`]: {
|
2022-11-08 15:37:35 +08:00
|
|
|
[`${componentCls}`]: {
|
2022-03-14 20:57:01 +08:00
|
|
|
paddingInlineEnd: paddingLG,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2022-03-25 20:08:05 +08:00
|
|
|
|
|
|
|
'&-show-count': {
|
|
|
|
// https://github.com/ant-design/ant-design/issues/33049
|
2022-11-08 15:37:35 +08:00
|
|
|
[`> ${componentCls}`]: {
|
2022-03-25 20:08:05 +08:00
|
|
|
height: '100%',
|
|
|
|
},
|
|
|
|
|
|
|
|
'&::after': {
|
2022-08-04 16:16:50 +08:00
|
|
|
color: token.colorTextDescription,
|
2022-03-25 20:08:05 +08:00
|
|
|
whiteSpace: 'nowrap',
|
|
|
|
content: 'attr(data-count)',
|
|
|
|
pointerEvents: 'none',
|
2022-12-01 20:16:23 +08:00
|
|
|
float: 'right',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
'&-rtl': {
|
|
|
|
'&::after': {
|
|
|
|
float: 'left',
|
2022-03-25 20:08:05 +08:00
|
|
|
},
|
|
|
|
},
|
2022-03-14 20:57:01 +08:00
|
|
|
},
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2022-03-09 10:38:02 +08:00
|
|
|
// ============================== Export ==============================
|
2022-11-17 23:31:41 +08:00
|
|
|
export default genComponentStyleHook('Input', (token) => {
|
2022-04-06 21:49:30 +08:00
|
|
|
const inputToken = initInputToken<FullToken<'Input'>>(token);
|
2022-03-09 10:38:02 +08:00
|
|
|
|
|
|
|
return [
|
2022-04-06 21:49:30 +08:00
|
|
|
genInputStyle(inputToken),
|
|
|
|
genTextAreaStyle(inputToken),
|
|
|
|
genAffixStyle(inputToken),
|
|
|
|
genGroupStyle(inputToken),
|
|
|
|
genSearchInputStyle(inputToken),
|
2022-12-12 16:36:46 +08:00
|
|
|
// =====================================================
|
|
|
|
// == Space Compact ==
|
|
|
|
// =====================================================
|
|
|
|
genCompactItemStyle(inputToken),
|
2022-03-09 10:38:02 +08:00
|
|
|
];
|
2022-04-06 21:49:30 +08:00
|
|
|
});
|