|
import { mergeToken } from '../../theme/internal'; |
|
import type { AliasToken, FullToken } from '../../theme/internal'; |
|
|
|
export interface SharedComponentToken { |
|
|
|
|
|
|
|
|
|
paddingInline: number; |
|
|
|
|
|
|
|
|
|
paddingInlineSM: number; |
|
|
|
|
|
|
|
|
|
paddingInlineLG: number; |
|
|
|
|
|
|
|
|
|
paddingBlock: number; |
|
|
|
|
|
|
|
|
|
paddingBlockSM: number; |
|
|
|
|
|
|
|
|
|
paddingBlockLG: number; |
|
|
|
|
|
|
|
|
|
addonBg: string; |
|
|
|
|
|
|
|
|
|
hoverBorderColor: string; |
|
|
|
|
|
|
|
|
|
activeBorderColor: string; |
|
|
|
|
|
|
|
|
|
activeShadow: string; |
|
|
|
|
|
|
|
|
|
errorActiveShadow: string; |
|
|
|
|
|
|
|
|
|
warningActiveShadow: string; |
|
|
|
|
|
|
|
|
|
hoverBg: string; |
|
|
|
|
|
|
|
|
|
activeBg: string; |
|
|
|
|
|
|
|
|
|
inputFontSize: number; |
|
|
|
|
|
|
|
|
|
inputFontSizeLG: number; |
|
|
|
|
|
|
|
|
|
inputFontSizeSM: number; |
|
} |
|
|
|
export interface ComponentToken extends SharedComponentToken {} |
|
|
|
export interface SharedInputToken { |
|
inputAffixPadding: number; |
|
} |
|
|
|
export interface InputToken extends FullToken<'Input'>, SharedInputToken {} |
|
|
|
export function initInputToken(token: AliasToken): SharedInputToken { |
|
return mergeToken<InputToken>(token, { |
|
inputAffixPadding: token.paddingXXS, |
|
}); |
|
} |
|
|
|
export const initComponentToken = ( |
|
token: AliasToken & Partial<SharedComponentToken>, |
|
): SharedComponentToken => { |
|
const { |
|
controlHeight, |
|
fontSize, |
|
lineHeight, |
|
lineWidth, |
|
controlHeightSM, |
|
controlHeightLG, |
|
fontSizeLG, |
|
lineHeightLG, |
|
paddingSM, |
|
controlPaddingHorizontalSM, |
|
controlPaddingHorizontal, |
|
colorFillAlter, |
|
colorPrimaryHover, |
|
colorPrimary, |
|
controlOutlineWidth, |
|
controlOutline, |
|
colorErrorOutline, |
|
colorWarningOutline, |
|
colorBgContainer, |
|
inputFontSize, |
|
inputFontSizeLG, |
|
inputFontSizeSM, |
|
} = token; |
|
|
|
const mergedFontSize = inputFontSize || fontSize; |
|
const mergedFontSizeSM = inputFontSizeSM || mergedFontSize; |
|
const mergedFontSizeLG = inputFontSizeLG || fontSizeLG; |
|
|
|
const paddingBlock = |
|
Math.round(((controlHeight - mergedFontSize * lineHeight) / 2) * 10) / 10 - lineWidth; |
|
const paddingBlockSM = |
|
Math.round(((controlHeightSM - mergedFontSizeSM * lineHeight) / 2) * 10) / 10 - lineWidth; |
|
const paddingBlockLG = |
|
Math.ceil(((controlHeightLG - mergedFontSizeLG * lineHeightLG) / 2) * 10) / 10 - lineWidth; |
|
|
|
return { |
|
paddingBlock: Math.max(paddingBlock, 0), |
|
paddingBlockSM: Math.max(paddingBlockSM, 0), |
|
paddingBlockLG: Math.max(paddingBlockLG, 0), |
|
paddingInline: paddingSM - lineWidth, |
|
paddingInlineSM: controlPaddingHorizontalSM - lineWidth, |
|
paddingInlineLG: controlPaddingHorizontal - lineWidth, |
|
addonBg: colorFillAlter, |
|
activeBorderColor: colorPrimary, |
|
hoverBorderColor: colorPrimaryHover, |
|
activeShadow: `0 0 0 ${controlOutlineWidth}px ${controlOutline}`, |
|
errorActiveShadow: `0 0 0 ${controlOutlineWidth}px ${colorErrorOutline}`, |
|
warningActiveShadow: `0 0 0 ${controlOutlineWidth}px ${colorWarningOutline}`, |
|
hoverBg: colorBgContainer, |
|
activeBg: colorBgContainer, |
|
inputFontSize: mergedFontSize, |
|
inputFontSizeLG: mergedFontSizeLG, |
|
inputFontSizeSM: mergedFontSizeSM, |
|
}; |
|
}; |
|
|