vertical.js 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.default = void 0;
  6. var _cssinjs = require("@ant-design/cssinjs");
  7. var _style = require("../../style");
  8. const getVerticalInlineStyle = token => {
  9. const {
  10. componentCls,
  11. itemHeight,
  12. itemMarginInline,
  13. padding,
  14. menuArrowSize,
  15. marginXS,
  16. itemMarginBlock,
  17. itemWidth,
  18. itemPaddingInline
  19. } = token;
  20. const paddingWithArrow = token.calc(menuArrowSize).add(padding).add(marginXS).equal();
  21. return {
  22. [`${componentCls}-item`]: {
  23. position: 'relative',
  24. overflow: 'hidden'
  25. },
  26. [`${componentCls}-item, ${componentCls}-submenu-title`]: {
  27. height: itemHeight,
  28. lineHeight: (0, _cssinjs.unit)(itemHeight),
  29. paddingInline: itemPaddingInline,
  30. overflow: 'hidden',
  31. textOverflow: 'ellipsis',
  32. marginInline: itemMarginInline,
  33. marginBlock: itemMarginBlock,
  34. width: itemWidth
  35. },
  36. [`> ${componentCls}-item,
  37. > ${componentCls}-submenu > ${componentCls}-submenu-title`]: {
  38. height: itemHeight,
  39. lineHeight: (0, _cssinjs.unit)(itemHeight)
  40. },
  41. [`${componentCls}-item-group-list ${componentCls}-submenu-title,
  42. ${componentCls}-submenu-title`]: {
  43. paddingInlineEnd: paddingWithArrow
  44. }
  45. };
  46. };
  47. const getVerticalStyle = token => {
  48. const {
  49. componentCls,
  50. iconCls,
  51. itemHeight,
  52. colorTextLightSolid,
  53. dropdownWidth,
  54. controlHeightLG,
  55. motionEaseOut,
  56. paddingXL,
  57. itemMarginInline,
  58. fontSizeLG,
  59. motionDurationFast,
  60. motionDurationSlow,
  61. paddingXS,
  62. boxShadowSecondary,
  63. collapsedWidth,
  64. collapsedIconSize
  65. } = token;
  66. const inlineItemStyle = {
  67. height: itemHeight,
  68. lineHeight: (0, _cssinjs.unit)(itemHeight),
  69. listStylePosition: 'inside',
  70. listStyleType: 'disc'
  71. };
  72. return [{
  73. [componentCls]: {
  74. '&-inline, &-vertical': Object.assign({
  75. [`&${componentCls}-root`]: {
  76. boxShadow: 'none'
  77. }
  78. }, getVerticalInlineStyle(token))
  79. },
  80. [`${componentCls}-submenu-popup`]: {
  81. [`${componentCls}-vertical`]: Object.assign(Object.assign({}, 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 - ${(0, _cssinjs.unit)(token.calc(controlHeightLG).mul(2.5).equal())})`,
  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 ${motionDurationFast} ${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: collapsedWidth,
  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% - ${(0, _cssinjs.unit)(token.calc(collapsedIconSize).div(2).equal())} - ${(0, _cssinjs.unit)(itemMarginInline)})`,
  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: collapsedIconSize,
  166. lineHeight: (0, _cssinjs.unit)(itemHeight),
  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`]: Object.assign(Object.assign({}, _style.textEllipsis), {
  186. paddingInline: paddingXS
  187. })
  188. }
  189. }];
  190. };
  191. var _default = exports.default = getVerticalStyle;