UNPKG

antd

Version:

An enterprise-class UI design language and React components implementation

65 lines (64 loc) 2.24 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.initComponentToken = void 0; exports.initInputToken = initInputToken; var _internal = require("../../theme/internal"); function initInputToken(token) { return (0, _internal.mergeToken)(token, { inputAffixPadding: token.paddingXXS }); } const initComponentToken = token => { 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 }; }; exports.initComponentToken = initComponentToken;