vertical.js 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  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("../../style");
  9. const getVerticalInlineStyle = token => {
  10. const {
  11. componentCls,
  12. menuItemHeight,
  13. itemMarginInline,
  14. padding,
  15. menuArrowSize,
  16. marginXS,
  17. marginXXS
  18. } = token;
  19. const paddingWithArrow = padding + menuArrowSize + marginXS;
  20. return {
  21. [`${componentCls}-item`]: {
  22. position: 'relative'
  23. },
  24. [`${componentCls}-item, ${componentCls}-submenu-title`]: {
  25. height: menuItemHeight,
  26. lineHeight: `${menuItemHeight}px`,
  27. paddingInline: padding,
  28. overflow: 'hidden',
  29. textOverflow: 'ellipsis',
  30. marginInline: itemMarginInline,
  31. marginBlock: marginXXS,
  32. width: `calc(100% - ${itemMarginInline * 2}px)`
  33. },
  34. // disable margin collapsed
  35. [`${componentCls}-submenu`]: {
  36. paddingBottom: 0.02
  37. },
  38. [`> ${componentCls}-item,
  39. > ${componentCls}-submenu > ${componentCls}-submenu-title`]: {
  40. height: menuItemHeight,
  41. lineHeight: `${menuItemHeight}px`
  42. },
  43. [`${componentCls}-item-group-list ${componentCls}-submenu-title,
  44. ${componentCls}-submenu-title`]: {
  45. paddingInlineEnd: paddingWithArrow
  46. }
  47. };
  48. };
  49. const getVerticalStyle = token => {
  50. const {
  51. componentCls,
  52. iconCls,
  53. menuItemHeight,
  54. colorTextLightSolid,
  55. dropdownWidth,
  56. controlHeightLG,
  57. motionDurationMid,
  58. motionEaseOut,
  59. paddingXL,
  60. fontSizeSM,
  61. fontSizeLG,
  62. motionDurationSlow,
  63. paddingXS,
  64. boxShadowSecondary
  65. } = token;
  66. const inlineItemStyle = {
  67. height: menuItemHeight,
  68. lineHeight: `${menuItemHeight}px`,
  69. listStylePosition: 'inside',
  70. listStyleType: 'disc'
  71. };
  72. return [{
  73. [componentCls]: {
  74. [`&-inline, &-vertical`]: (0, _extends2.default)({
  75. [`&${componentCls}-root`]: {
  76. boxShadow: 'none'
  77. }
  78. }, getVerticalInlineStyle(token))
  79. },
  80. [`${componentCls}-submenu-popup`]: {
  81. [`${componentCls}-vertical`]: (0, _extends2.default)((0, _extends2.default)({}, getVerticalInlineStyle(token)), {
  82. boxShadow: boxShadowSecondary
  83. })
  84. }
  85. },
  86. // Vertical only
  87. {
  88. [`${componentCls}-submenu-popup ${componentCls}-vertical${componentCls}-sub`]: {
  89. minWidth: dropdownWidth,
  90. maxHeight: `calc(100vh - ${controlHeightLG * 2.5}px)`,
  91. padding: '0',
  92. overflow: 'hidden',
  93. borderInlineEnd: 0,
  94. // https://github.com/ant-design/ant-design/issues/22244
  95. // https://github.com/ant-design/ant-design/issues/26812
  96. "&:not([class*='-active'])": {
  97. overflowX: 'hidden',
  98. overflowY: 'auto'
  99. }
  100. }
  101. },
  102. // Inline Only
  103. {
  104. [`${componentCls}-inline`]: {
  105. width: '100%',
  106. // Motion enhance for first level
  107. [`&${componentCls}-root`]: {
  108. [`${componentCls}-item, ${componentCls}-submenu-title`]: {
  109. display: 'flex',
  110. alignItems: 'center',
  111. transition: [`border-color ${motionDurationSlow}`, `background ${motionDurationSlow}`, `padding ${motionDurationMid} ${motionEaseOut}`].join(','),
  112. [`> ${componentCls}-title-content`]: {
  113. flex: 'auto',
  114. minWidth: 0,
  115. overflow: 'hidden',
  116. textOverflow: 'ellipsis'
  117. },
  118. '> *': {
  119. flex: 'none'
  120. }
  121. }
  122. },
  123. // >>>>> Sub
  124. [`${componentCls}-sub${componentCls}-inline`]: {
  125. padding: 0,
  126. border: 0,
  127. borderRadius: 0,
  128. boxShadow: 'none',
  129. [`& > ${componentCls}-submenu > ${componentCls}-submenu-title`]: inlineItemStyle,
  130. [`& ${componentCls}-item-group-title`]: {
  131. paddingInlineStart: paddingXL
  132. }
  133. },
  134. // >>>>> Item
  135. [`${componentCls}-item`]: inlineItemStyle
  136. }
  137. },
  138. // Inline Collapse Only
  139. {
  140. [`${componentCls}-inline-collapsed`]: {
  141. width: menuItemHeight * 2,
  142. [`&${componentCls}-root`]: {
  143. [`${componentCls}-item, ${componentCls}-submenu ${componentCls}-submenu-title`]: {
  144. [`> ${componentCls}-inline-collapsed-noicon`]: {
  145. fontSize: fontSizeLG,
  146. textAlign: 'center'
  147. }
  148. }
  149. },
  150. [`> ${componentCls}-item,
  151. > ${componentCls}-item-group > ${componentCls}-item-group-list > ${componentCls}-item,
  152. > ${componentCls}-item-group > ${componentCls}-item-group-list > ${componentCls}-submenu > ${componentCls}-submenu-title,
  153. > ${componentCls}-submenu > ${componentCls}-submenu-title`]: {
  154. insetInlineStart: 0,
  155. paddingInline: `calc(50% - ${fontSizeSM}px)`,
  156. textOverflow: 'clip',
  157. [`
  158. ${componentCls}-submenu-arrow,
  159. ${componentCls}-submenu-expand-icon
  160. `]: {
  161. opacity: 0
  162. },
  163. [`${componentCls}-item-icon, ${iconCls}`]: {
  164. margin: 0,
  165. fontSize: fontSizeLG,
  166. lineHeight: `${menuItemHeight}px`,
  167. '+ span': {
  168. display: 'inline-block',
  169. opacity: 0
  170. }
  171. }
  172. },
  173. [`${componentCls}-item-icon, ${iconCls}`]: {
  174. display: 'inline-block'
  175. },
  176. '&-tooltip': {
  177. pointerEvents: 'none',
  178. [`${componentCls}-item-icon, ${iconCls}`]: {
  179. display: 'none'
  180. },
  181. 'a, a:hover': {
  182. color: colorTextLightSolid
  183. }
  184. },
  185. [`${componentCls}-item-group-title`]: (0, _extends2.default)((0, _extends2.default)({}, _style.textEllipsis), {
  186. paddingInline: paddingXS
  187. })
  188. }
  189. }];
  190. };
  191. var _default = exports.default = getVerticalStyle;