index.js 11 KB

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