index.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312
  1. "use strict";
  2. var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
  3. Object.defineProperty(exports, "__esModule", {
  4. value: true
  5. });
  6. exports.prepareComponentToken = exports.default = void 0;
  7. var _cssinjs = require("@ant-design/cssinjs");
  8. var _style = require("../../style");
  9. var _internal = require("../../theme/internal");
  10. var _customIcon = _interopRequireDefault(require("./custom-icon"));
  11. var _horizontal = _interopRequireDefault(require("./horizontal"));
  12. var _inline = _interopRequireDefault(require("./inline"));
  13. var _labelPlacement = _interopRequireDefault(require("./label-placement"));
  14. var _nav = _interopRequireDefault(require("./nav"));
  15. var _progress = _interopRequireDefault(require("./progress"));
  16. var _progressDot = _interopRequireDefault(require("./progress-dot"));
  17. var _rtl = _interopRequireDefault(require("./rtl"));
  18. var _small = _interopRequireDefault(require("./small"));
  19. var _vertical = _interopRequireDefault(require("./vertical"));
  20. const STEP_ITEM_STATUS_WAIT = 'wait';
  21. const STEP_ITEM_STATUS_PROCESS = 'process';
  22. const STEP_ITEM_STATUS_FINISH = 'finish';
  23. const STEP_ITEM_STATUS_ERROR = 'error';
  24. const genStepsItemStatusStyle = (status, token) => {
  25. const prefix = `${token.componentCls}-item`;
  26. const iconColorKey = `${status}IconColor`;
  27. const titleColorKey = `${status}TitleColor`;
  28. const descriptionColorKey = `${status}DescriptionColor`;
  29. const tailColorKey = `${status}TailColor`;
  30. const iconBgColorKey = `${status}IconBgColor`;
  31. const iconBorderColorKey = `${status}IconBorderColor`;
  32. const dotColorKey = `${status}DotColor`;
  33. return {
  34. [`${prefix}-${status} ${prefix}-icon`]: {
  35. backgroundColor: token[iconBgColorKey],
  36. borderColor: token[iconBorderColorKey],
  37. [`> ${token.componentCls}-icon`]: {
  38. color: token[iconColorKey],
  39. [`${token.componentCls}-icon-dot`]: {
  40. background: token[dotColorKey]
  41. }
  42. }
  43. },
  44. [`${prefix}-${status}${prefix}-custom ${prefix}-icon`]: {
  45. [`> ${token.componentCls}-icon`]: {
  46. color: token[dotColorKey]
  47. }
  48. },
  49. [`${prefix}-${status} > ${prefix}-container > ${prefix}-content > ${prefix}-title`]: {
  50. color: token[titleColorKey],
  51. '&::after': {
  52. backgroundColor: token[tailColorKey]
  53. }
  54. },
  55. [`${prefix}-${status} > ${prefix}-container > ${prefix}-content > ${prefix}-description`]: {
  56. color: token[descriptionColorKey]
  57. },
  58. [`${prefix}-${status} > ${prefix}-container > ${prefix}-tail::after`]: {
  59. backgroundColor: token[tailColorKey]
  60. }
  61. };
  62. };
  63. const genStepsItemStyle = token => {
  64. const {
  65. componentCls,
  66. motionDurationSlow
  67. } = token;
  68. const stepsItemCls = `${componentCls}-item`; // .ant-steps-item
  69. const stepItemIconCls = `${stepsItemCls}-icon`;
  70. return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({
  71. [stepsItemCls]: {
  72. position: 'relative',
  73. display: 'inline-block',
  74. flex: 1,
  75. overflow: 'hidden',
  76. verticalAlign: 'top',
  77. '&:last-child': {
  78. flex: 'none',
  79. [`> ${stepsItemCls}-container > ${stepsItemCls}-tail, > ${stepsItemCls}-container > ${stepsItemCls}-content > ${stepsItemCls}-title::after`]: {
  80. display: 'none'
  81. }
  82. }
  83. },
  84. [`${stepsItemCls}-container`]: {
  85. outline: 'none',
  86. [`&:focus-visible ${stepItemIconCls}`]: (0, _style.genFocusOutline)(token)
  87. },
  88. [`${stepItemIconCls}, ${stepsItemCls}-content`]: {
  89. display: 'inline-block',
  90. verticalAlign: 'top'
  91. },
  92. [stepItemIconCls]: {
  93. width: token.iconSize,
  94. height: token.iconSize,
  95. marginTop: 0,
  96. marginBottom: 0,
  97. marginInlineStart: 0,
  98. marginInlineEnd: token.marginXS,
  99. fontSize: token.iconFontSize,
  100. fontFamily: token.fontFamily,
  101. lineHeight: (0, _cssinjs.unit)(token.iconSize),
  102. textAlign: 'center',
  103. borderRadius: token.iconSize,
  104. border: `${(0, _cssinjs.unit)(token.lineWidth)} ${token.lineType} transparent`,
  105. transition: `background-color ${motionDurationSlow}, border-color ${motionDurationSlow}`,
  106. [`${componentCls}-icon`]: {
  107. position: 'relative',
  108. top: token.iconTop,
  109. color: token.colorPrimary,
  110. lineHeight: 1
  111. }
  112. },
  113. [`${stepsItemCls}-tail`]: {
  114. position: 'absolute',
  115. top: token.calc(token.iconSize).div(2).equal(),
  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: (0, _cssinjs.unit)(token.titleLineHeight),
  135. '&::after': {
  136. position: 'absolute',
  137. top: token.calc(token.titleLineHeight).div(2).equal(),
  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(STEP_ITEM_STATUS_WAIT, token)), genStepsItemStatusStyle(STEP_ITEM_STATUS_PROCESS, token)), {
  158. [`${stepsItemCls}-process > ${stepsItemCls}-container > ${stepsItemCls}-title`]: {
  159. fontWeight: token.fontWeightStrong
  160. }
  161. }), genStepsItemStatusStyle(STEP_ITEM_STATUS_FINISH, token)), genStepsItemStatusStyle(STEP_ITEM_STATUS_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.descriptionMaxWidth,
  223. whiteSpace: 'normal'
  224. }
  225. }
  226. }
  227. };
  228. };
  229. const genStepsStyle = token => {
  230. const {
  231. componentCls
  232. } = token; // .ant-steps
  233. return {
  234. [componentCls]: Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, (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, _horizontal.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. const prepareComponentToken = token => ({
  244. titleLineHeight: token.controlHeight,
  245. customIconSize: token.controlHeight,
  246. customIconTop: 0,
  247. customIconFontSize: token.controlHeightSM,
  248. iconSize: token.controlHeight,
  249. iconTop: -0.5,
  250. // magic for ui experience
  251. iconFontSize: token.fontSize,
  252. iconSizeSM: token.fontSizeHeading3,
  253. dotSize: token.controlHeight / 4,
  254. dotCurrentSize: token.controlHeightLG / 4,
  255. navArrowColor: token.colorTextDisabled,
  256. navContentMaxWidth: 'unset',
  257. descriptionMaxWidth: 140,
  258. waitIconColor: token.wireframe ? token.colorTextDisabled : token.colorTextLabel,
  259. waitIconBgColor: token.wireframe ? token.colorBgContainer : token.colorFillContent,
  260. waitIconBorderColor: token.wireframe ? token.colorTextDisabled : 'transparent',
  261. finishIconBgColor: token.wireframe ? token.colorBgContainer : token.controlItemBgActive,
  262. finishIconBorderColor: token.wireframe ? token.colorPrimary : token.controlItemBgActive
  263. });
  264. exports.prepareComponentToken = prepareComponentToken;
  265. var _default = exports.default = (0, _internal.genStyleHooks)('Steps', token => {
  266. const {
  267. colorTextDisabled,
  268. controlHeightLG,
  269. colorTextLightSolid,
  270. colorText,
  271. colorPrimary,
  272. colorTextDescription,
  273. colorTextQuaternary,
  274. colorError,
  275. colorBorderSecondary,
  276. colorSplit
  277. } = token;
  278. const stepsToken = (0, _internal.mergeToken)(token, {
  279. // Steps component less variable
  280. processIconColor: colorTextLightSolid,
  281. processTitleColor: colorText,
  282. processDescriptionColor: colorText,
  283. processIconBgColor: colorPrimary,
  284. processIconBorderColor: colorPrimary,
  285. processDotColor: colorPrimary,
  286. processTailColor: colorSplit,
  287. waitTitleColor: colorTextDescription,
  288. waitDescriptionColor: colorTextDescription,
  289. waitTailColor: colorSplit,
  290. waitDotColor: colorTextDisabled,
  291. finishIconColor: colorPrimary,
  292. finishTitleColor: colorText,
  293. finishDescriptionColor: colorTextDescription,
  294. finishTailColor: colorPrimary,
  295. finishDotColor: colorPrimary,
  296. errorIconColor: colorTextLightSolid,
  297. errorTitleColor: colorError,
  298. errorDescriptionColor: colorError,
  299. errorTailColor: colorSplit,
  300. errorIconBgColor: colorError,
  301. errorIconBorderColor: colorError,
  302. errorDotColor: colorError,
  303. stepsNavActiveColor: colorPrimary,
  304. stepsProgressSize: controlHeightLG,
  305. // Steps inline variable
  306. inlineDotSize: 6,
  307. inlineTitleColor: colorTextQuaternary,
  308. inlineTailColor: colorBorderSecondary
  309. });
  310. return genStepsStyle(stepsToken);
  311. }, prepareComponentToken);