index.js 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. "use strict";
  2. var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
  3. Object.defineProperty(exports, "__esModule", {
  4. value: true
  5. });
  6. exports.default = void 0;
  7. var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
  8. var _style = require("../../checkbox/style");
  9. var _internal = require("../../theme/internal");
  10. var _style2 = require("../../style");
  11. var _compactItem = require("../../style/compact-item");
  12. // =============================== Base ===============================
  13. const genBaseStyle = token => {
  14. const {
  15. prefixCls,
  16. componentCls,
  17. antCls
  18. } = token;
  19. const cascaderMenuItemCls = `${componentCls}-menu-item`;
  20. const iconCls = `
  21. &${cascaderMenuItemCls}-expand ${cascaderMenuItemCls}-expand-icon,
  22. ${cascaderMenuItemCls}-loading-icon
  23. `;
  24. const itemPaddingVertical = Math.round((token.controlHeight - token.fontSize * token.lineHeight) / 2);
  25. return [
  26. // =====================================================
  27. // == Control ==
  28. // =====================================================
  29. {
  30. [componentCls]: {
  31. width: token.controlWidth
  32. }
  33. },
  34. // =====================================================
  35. // == Popup ==
  36. // =====================================================
  37. {
  38. [`${componentCls}-dropdown`]: [
  39. // ==================== Checkbox ====================
  40. (0, _style.getStyle)(`${prefixCls}-checkbox`, token), {
  41. [`&${antCls}-select-dropdown`]: {
  42. padding: 0
  43. }
  44. }, {
  45. [componentCls]: {
  46. // ================== Checkbox ==================
  47. '&-checkbox': {
  48. top: 0,
  49. marginInlineEnd: token.paddingXS
  50. },
  51. // ==================== Menu ====================
  52. // >>> Menus
  53. '&-menus': {
  54. display: 'flex',
  55. flexWrap: 'nowrap',
  56. alignItems: 'flex-start',
  57. [`&${componentCls}-menu-empty`]: {
  58. [`${componentCls}-menu`]: {
  59. width: '100%',
  60. height: 'auto',
  61. [cascaderMenuItemCls]: {
  62. color: token.colorTextDisabled
  63. }
  64. }
  65. }
  66. },
  67. // >>> Menu
  68. '&-menu': {
  69. flexGrow: 1,
  70. minWidth: token.controlItemWidth,
  71. height: token.dropdownHeight,
  72. margin: 0,
  73. padding: token.paddingXXS,
  74. overflow: 'auto',
  75. verticalAlign: 'top',
  76. listStyle: 'none',
  77. '-ms-overflow-style': '-ms-autohiding-scrollbar',
  78. '&:not(:last-child)': {
  79. borderInlineEnd: `${token.lineWidth}px ${token.lineType} ${token.colorSplit}`
  80. },
  81. '&-item': (0, _extends2.default)((0, _extends2.default)({}, _style2.textEllipsis), {
  82. display: 'flex',
  83. flexWrap: 'nowrap',
  84. alignItems: 'center',
  85. padding: `${itemPaddingVertical}px ${token.paddingSM}px`,
  86. lineHeight: token.lineHeight,
  87. cursor: 'pointer',
  88. transition: `all ${token.motionDurationMid}`,
  89. borderRadius: token.borderRadiusSM,
  90. '&:hover': {
  91. background: token.controlItemBgHover
  92. },
  93. '&-disabled': {
  94. color: token.colorTextDisabled,
  95. cursor: 'not-allowed',
  96. '&:hover': {
  97. background: 'transparent'
  98. },
  99. [iconCls]: {
  100. color: token.colorTextDisabled
  101. }
  102. },
  103. [`&-active:not(${cascaderMenuItemCls}-disabled)`]: {
  104. [`&, &:hover`]: {
  105. fontWeight: token.fontWeightStrong,
  106. backgroundColor: token.controlItemBgActive
  107. }
  108. },
  109. '&-content': {
  110. flex: 'auto'
  111. },
  112. [iconCls]: {
  113. marginInlineStart: token.paddingXXS,
  114. color: token.colorTextDescription,
  115. fontSize: token.fontSizeIcon
  116. },
  117. '&-keyword': {
  118. color: token.colorHighlight
  119. }
  120. })
  121. }
  122. }
  123. }]
  124. },
  125. // =====================================================
  126. // == RTL ==
  127. // =====================================================
  128. {
  129. [`${componentCls}-dropdown-rtl`]: {
  130. direction: 'rtl'
  131. }
  132. },
  133. // =====================================================
  134. // == Space Compact ==
  135. // =====================================================
  136. (0, _compactItem.genCompactItemStyle)(token)];
  137. };
  138. // ============================== Export ==============================
  139. var _default = exports.default = (0, _internal.genComponentStyleHook)('Cascader', token => [genBaseStyle(token)], {
  140. controlWidth: 184,
  141. controlItemWidth: 111,
  142. dropdownHeight: 180
  143. });