index.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312
  1. import _extends from "@babel/runtime/helpers/esm/extends";
  2. import { genComponentStyleHook, mergeToken } from '../../theme/internal';
  3. import genStepsCustomIconStyle from './custom-icon';
  4. import genStepsLabelPlacementStyle from './label-placement';
  5. import genStepsNavStyle from './nav';
  6. import genStepsProgressStyle from './progress';
  7. import genStepsProgressDotStyle from './progress-dot';
  8. import genStepsRTLStyle from './rtl';
  9. import genStepsSmallStyle from './small';
  10. import genStepsVerticalStyle from './vertical';
  11. import genStepsInlineStyle from './inline';
  12. import { resetComponent } from '../../style';
  13. var StepItemStatusEnum;
  14. (function (StepItemStatusEnum) {
  15. StepItemStatusEnum["wait"] = "wait";
  16. StepItemStatusEnum["process"] = "process";
  17. StepItemStatusEnum["finish"] = "finish";
  18. StepItemStatusEnum["error"] = "error";
  19. })(StepItemStatusEnum || (StepItemStatusEnum = {}));
  20. const genStepsItemStatusStyle = (status, token) => {
  21. const prefix = `${token.componentCls}-item`;
  22. const iconColorKey = `${status}IconColor`;
  23. const titleColorKey = `${status}TitleColor`;
  24. const descriptionColorKey = `${status}DescriptionColor`;
  25. const tailColorKey = `${status}TailColor`;
  26. const iconBgColorKey = `${status}IconBgColor`;
  27. const iconBorderColorKey = `${status}IconBorderColor`;
  28. const dotColorKey = `${status}DotColor`;
  29. return {
  30. [`${prefix}-${status} ${prefix}-icon`]: {
  31. backgroundColor: token[iconBgColorKey],
  32. borderColor: token[iconBorderColorKey],
  33. [`> ${token.componentCls}-icon`]: {
  34. color: token[iconColorKey],
  35. [`${token.componentCls}-icon-dot`]: {
  36. background: token[dotColorKey]
  37. }
  38. }
  39. },
  40. [`${prefix}-${status}${prefix}-custom ${prefix}-icon`]: {
  41. [`> ${token.componentCls}-icon`]: {
  42. color: token[dotColorKey]
  43. }
  44. },
  45. [`${prefix}-${status} > ${prefix}-container > ${prefix}-content > ${prefix}-title`]: {
  46. color: token[titleColorKey],
  47. '&::after': {
  48. backgroundColor: token[tailColorKey]
  49. }
  50. },
  51. [`${prefix}-${status} > ${prefix}-container > ${prefix}-content > ${prefix}-description`]: {
  52. color: token[descriptionColorKey]
  53. },
  54. [`${prefix}-${status} > ${prefix}-container > ${prefix}-tail::after`]: {
  55. backgroundColor: token[tailColorKey]
  56. }
  57. };
  58. };
  59. const genStepsItemStyle = token => {
  60. const {
  61. componentCls,
  62. motionDurationSlow
  63. } = token;
  64. const stepsItemCls = `${componentCls}-item`; // .ant-steps-item
  65. return _extends(_extends(_extends(_extends(_extends(_extends({
  66. [stepsItemCls]: {
  67. position: 'relative',
  68. display: 'inline-block',
  69. flex: 1,
  70. overflow: 'hidden',
  71. verticalAlign: 'top',
  72. '&:last-child': {
  73. flex: 'none',
  74. [`> ${stepsItemCls}-container > ${stepsItemCls}-tail, > ${stepsItemCls}-container > ${stepsItemCls}-content > ${stepsItemCls}-title::after`]: {
  75. display: 'none'
  76. }
  77. }
  78. },
  79. [`${stepsItemCls}-container`]: {
  80. outline: 'none'
  81. },
  82. [`${stepsItemCls}-icon, ${stepsItemCls}-content`]: {
  83. display: 'inline-block',
  84. verticalAlign: 'top'
  85. },
  86. [`${stepsItemCls}-icon`]: {
  87. width: token.stepsIconSize,
  88. height: token.stepsIconSize,
  89. marginTop: 0,
  90. marginBottom: 0,
  91. marginInlineStart: 0,
  92. marginInlineEnd: token.marginXS,
  93. fontSize: token.stepsIconFontSize,
  94. fontFamily: token.fontFamily,
  95. lineHeight: `${token.stepsIconSize}px`,
  96. textAlign: 'center',
  97. borderRadius: token.stepsIconSize,
  98. border: `${token.lineWidth}px ${token.lineType} transparent`,
  99. transition: `background-color ${motionDurationSlow}, border-color ${motionDurationSlow}`,
  100. [`${componentCls}-icon`]: {
  101. position: 'relative',
  102. top: token.stepsIconTop,
  103. color: token.colorPrimary,
  104. lineHeight: 1
  105. }
  106. },
  107. [`${stepsItemCls}-tail`]: {
  108. position: 'absolute',
  109. top: token.stepsIconSize / 2 - token.paddingXXS,
  110. insetInlineStart: 0,
  111. width: '100%',
  112. '&::after': {
  113. display: 'inline-block',
  114. width: '100%',
  115. height: token.lineWidth,
  116. background: token.colorSplit,
  117. borderRadius: token.lineWidth,
  118. transition: `background ${motionDurationSlow}`,
  119. content: '""'
  120. }
  121. },
  122. [`${stepsItemCls}-title`]: {
  123. position: 'relative',
  124. display: 'inline-block',
  125. paddingInlineEnd: token.padding,
  126. color: token.colorText,
  127. fontSize: token.fontSizeLG,
  128. lineHeight: `${token.stepsTitleLineHeight}px`,
  129. '&::after': {
  130. position: 'absolute',
  131. top: token.stepsTitleLineHeight / 2,
  132. insetInlineStart: '100%',
  133. display: 'block',
  134. width: 9999,
  135. height: token.lineWidth,
  136. background: token.processTailColor,
  137. content: '""'
  138. }
  139. },
  140. [`${stepsItemCls}-subtitle`]: {
  141. display: 'inline',
  142. marginInlineStart: token.marginXS,
  143. color: token.colorTextDescription,
  144. fontWeight: 'normal',
  145. fontSize: token.fontSize
  146. },
  147. [`${stepsItemCls}-description`]: {
  148. color: token.colorTextDescription,
  149. fontSize: token.fontSize
  150. }
  151. }, genStepsItemStatusStyle(StepItemStatusEnum.wait, token)), genStepsItemStatusStyle(StepItemStatusEnum.process, token)), {
  152. [`${stepsItemCls}-process > ${stepsItemCls}-container > ${stepsItemCls}-title`]: {
  153. fontWeight: token.fontWeightStrong
  154. }
  155. }), genStepsItemStatusStyle(StepItemStatusEnum.finish, token)), genStepsItemStatusStyle(StepItemStatusEnum.error, token)), {
  156. [`${stepsItemCls}${componentCls}-next-error > ${componentCls}-item-title::after`]: {
  157. background: token.colorError
  158. },
  159. [`${stepsItemCls}-disabled`]: {
  160. cursor: 'not-allowed'
  161. }
  162. });
  163. };
  164. // ============================= Clickable ===========================
  165. const genStepsClickableStyle = token => {
  166. const {
  167. componentCls,
  168. motionDurationSlow
  169. } = token;
  170. return {
  171. [`& ${componentCls}-item`]: {
  172. [`&:not(${componentCls}-item-active)`]: {
  173. [`& > ${componentCls}-item-container[role='button']`]: {
  174. cursor: 'pointer',
  175. [`${componentCls}-item`]: {
  176. [`&-title, &-subtitle, &-description, &-icon ${componentCls}-icon`]: {
  177. transition: `color ${motionDurationSlow}`
  178. }
  179. },
  180. '&:hover': {
  181. [`${componentCls}-item`]: {
  182. [`&-title, &-subtitle, &-description`]: {
  183. color: token.colorPrimary
  184. }
  185. }
  186. }
  187. },
  188. [`&:not(${componentCls}-item-process)`]: {
  189. [`& > ${componentCls}-item-container[role='button']:hover`]: {
  190. [`${componentCls}-item`]: {
  191. '&-icon': {
  192. borderColor: token.colorPrimary,
  193. [`${componentCls}-icon`]: {
  194. color: token.colorPrimary
  195. }
  196. }
  197. }
  198. }
  199. }
  200. }
  201. },
  202. [`&${componentCls}-horizontal:not(${componentCls}-label-vertical)`]: {
  203. [`${componentCls}-item`]: {
  204. paddingInlineStart: token.padding,
  205. whiteSpace: 'nowrap',
  206. '&:first-child': {
  207. paddingInlineStart: 0
  208. },
  209. [`&:last-child ${componentCls}-item-title`]: {
  210. paddingInlineEnd: 0
  211. },
  212. '&-tail': {
  213. display: 'none'
  214. },
  215. '&-description': {
  216. maxWidth: token.descriptionWidth,
  217. whiteSpace: 'normal'
  218. }
  219. }
  220. }
  221. };
  222. };
  223. const genStepsStyle = token => {
  224. const {
  225. componentCls
  226. } = token; // .ant-steps
  227. return {
  228. [componentCls]: _extends(_extends(_extends(_extends(_extends(_extends(_extends(_extends(_extends(_extends(_extends(_extends(_extends({}, resetComponent(token)), {
  229. display: 'flex',
  230. width: '100%',
  231. fontSize: 0,
  232. textAlign: 'initial'
  233. }), genStepsItemStyle(token)), genStepsClickableStyle(token)), genStepsCustomIconStyle(token)), genStepsSmallStyle(token)), genStepsVerticalStyle(token)), genStepsLabelPlacementStyle(token)), genStepsProgressDotStyle(token)), genStepsNavStyle(token)), genStepsRTLStyle(token)), genStepsProgressStyle(token)), genStepsInlineStyle(token))
  234. };
  235. };
  236. // ============================== Export ==============================
  237. export default genComponentStyleHook('Steps', token => {
  238. const {
  239. wireframe,
  240. colorTextDisabled,
  241. fontSizeHeading3,
  242. fontSize,
  243. controlHeight,
  244. controlHeightLG,
  245. colorTextLightSolid,
  246. colorText,
  247. colorPrimary,
  248. colorTextLabel,
  249. colorTextDescription,
  250. colorTextQuaternary,
  251. colorFillContent,
  252. controlItemBgActive,
  253. colorError,
  254. colorBgContainer,
  255. colorBorderSecondary
  256. } = token;
  257. const stepsIconSize = token.controlHeight;
  258. const processTailColor = token.colorSplit;
  259. const stepsToken = mergeToken(token, {
  260. // Steps variable default.less
  261. processTailColor,
  262. stepsNavArrowColor: colorTextDisabled,
  263. stepsIconSize,
  264. stepsIconCustomSize: stepsIconSize,
  265. stepsIconCustomTop: 0,
  266. stepsIconCustomFontSize: controlHeightLG / 2,
  267. stepsIconTop: -0.5,
  268. stepsIconFontSize: fontSize,
  269. stepsTitleLineHeight: controlHeight,
  270. stepsSmallIconSize: fontSizeHeading3,
  271. stepsDotSize: controlHeight / 4,
  272. stepsCurrentDotSize: controlHeightLG / 4,
  273. stepsNavContentMaxWidth: 'auto',
  274. // Steps component less variable
  275. processIconColor: colorTextLightSolid,
  276. processTitleColor: colorText,
  277. processDescriptionColor: colorText,
  278. processIconBgColor: colorPrimary,
  279. processIconBorderColor: colorPrimary,
  280. processDotColor: colorPrimary,
  281. waitIconColor: wireframe ? colorTextDisabled : colorTextLabel,
  282. waitTitleColor: colorTextDescription,
  283. waitDescriptionColor: colorTextDescription,
  284. waitTailColor: processTailColor,
  285. waitIconBgColor: wireframe ? colorBgContainer : colorFillContent,
  286. waitIconBorderColor: wireframe ? colorTextDisabled : 'transparent',
  287. waitDotColor: colorTextDisabled,
  288. finishIconColor: colorPrimary,
  289. finishTitleColor: colorText,
  290. finishDescriptionColor: colorTextDescription,
  291. finishTailColor: colorPrimary,
  292. finishIconBgColor: wireframe ? colorBgContainer : controlItemBgActive,
  293. finishIconBorderColor: wireframe ? colorPrimary : controlItemBgActive,
  294. finishDotColor: colorPrimary,
  295. errorIconColor: colorTextLightSolid,
  296. errorTitleColor: colorError,
  297. errorDescriptionColor: colorError,
  298. errorTailColor: processTailColor,
  299. errorIconBgColor: colorError,
  300. errorIconBorderColor: colorError,
  301. errorDotColor: colorError,
  302. stepsNavActiveColor: colorPrimary,
  303. stepsProgressSize: controlHeightLG,
  304. // Steps inline variable
  305. inlineDotSize: 6,
  306. inlineTitleColor: colorTextQuaternary,
  307. inlineTailColor: colorBorderSecondary
  308. });
  309. return [genStepsStyle(stepsToken)];
  310. }, {
  311. descriptionWidth: 140
  312. });