token.js 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.prepareComponentToken = void 0;
  6. const prepareComponentToken = token => {
  7. const {
  8. fontSize,
  9. lineHeight,
  10. lineWidth,
  11. controlHeight,
  12. controlHeightSM,
  13. controlHeightLG,
  14. paddingXXS,
  15. controlPaddingHorizontal,
  16. zIndexPopupBase,
  17. colorText,
  18. fontWeightStrong,
  19. controlItemBgActive,
  20. controlItemBgHover,
  21. colorBgContainer,
  22. colorFillSecondary,
  23. colorBgContainerDisabled,
  24. colorTextDisabled,
  25. colorPrimaryHover,
  26. colorPrimary,
  27. controlOutline
  28. } = token;
  29. // Item height default use `controlHeight - 2 * paddingXXS`,
  30. // but some case `paddingXXS=0`.
  31. // Let's fallback it.
  32. const dblPaddingXXS = paddingXXS * 2;
  33. const dblLineWidth = lineWidth * 2;
  34. const multipleItemHeight = Math.min(controlHeight - dblPaddingXXS, controlHeight - dblLineWidth);
  35. const multipleItemHeightSM = Math.min(controlHeightSM - dblPaddingXXS, controlHeightSM - dblLineWidth);
  36. const multipleItemHeightLG = Math.min(controlHeightLG - dblPaddingXXS, controlHeightLG - dblLineWidth);
  37. // FIXED_ITEM_MARGIN is a hardcode calculation since calc not support rounding
  38. const INTERNAL_FIXED_ITEM_MARGIN = Math.floor(paddingXXS / 2);
  39. return {
  40. INTERNAL_FIXED_ITEM_MARGIN,
  41. zIndexPopup: zIndexPopupBase + 50,
  42. optionSelectedColor: colorText,
  43. optionSelectedFontWeight: fontWeightStrong,
  44. optionSelectedBg: controlItemBgActive,
  45. optionActiveBg: controlItemBgHover,
  46. optionPadding: `${(controlHeight - fontSize * lineHeight) / 2}px ${controlPaddingHorizontal}px`,
  47. optionFontSize: fontSize,
  48. optionLineHeight: lineHeight,
  49. optionHeight: controlHeight,
  50. selectorBg: colorBgContainer,
  51. clearBg: colorBgContainer,
  52. singleItemHeightLG: controlHeightLG,
  53. multipleItemBg: colorFillSecondary,
  54. multipleItemBorderColor: 'transparent',
  55. multipleItemHeight,
  56. multipleItemHeightSM,
  57. multipleItemHeightLG,
  58. multipleSelectorBgDisabled: colorBgContainerDisabled,
  59. multipleItemColorDisabled: colorTextDisabled,
  60. multipleItemBorderColorDisabled: 'transparent',
  61. showArrowPaddingInlineEnd: Math.ceil(token.fontSize * 1.25),
  62. hoverBorderColor: colorPrimaryHover,
  63. activeBorderColor: colorPrimary,
  64. activeOutlineColor: controlOutline,
  65. selectAffixPadding: paddingXXS
  66. };
  67. };
  68. exports.prepareComponentToken = prepareComponentToken;