index.js 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872
  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 _motion = _interopRequireDefault(require("./motion"));
  11. const genCardStyle = token => {
  12. const {
  13. componentCls,
  14. tabsCardPadding,
  15. cardBg,
  16. cardGutter,
  17. colorBorderSecondary,
  18. itemSelectedColor
  19. } = token;
  20. return {
  21. [`${componentCls}-card`]: {
  22. [`> ${componentCls}-nav, > div > ${componentCls}-nav`]: {
  23. [`${componentCls}-tab`]: {
  24. margin: 0,
  25. padding: tabsCardPadding,
  26. background: cardBg,
  27. border: `${(0, _cssinjs.unit)(token.lineWidth)} ${token.lineType} ${colorBorderSecondary}`,
  28. transition: `all ${token.motionDurationSlow} ${token.motionEaseInOut}`
  29. },
  30. [`${componentCls}-tab-active`]: {
  31. color: itemSelectedColor,
  32. background: token.colorBgContainer
  33. },
  34. [`${componentCls}-tab-focus:has(${componentCls}-tab-btn:focus-visible)`]: (0, _style.genFocusOutline)(token, -3),
  35. [`& ${componentCls}-tab${componentCls}-tab-focus ${componentCls}-tab-btn:focus-visible`]: {
  36. outline: 'none'
  37. },
  38. [`${componentCls}-ink-bar`]: {
  39. visibility: 'hidden'
  40. }
  41. },
  42. // ========================== Top & Bottom ==========================
  43. [`&${componentCls}-top, &${componentCls}-bottom`]: {
  44. [`> ${componentCls}-nav, > div > ${componentCls}-nav`]: {
  45. [`${componentCls}-tab + ${componentCls}-tab`]: {
  46. marginLeft: {
  47. _skip_check_: true,
  48. value: (0, _cssinjs.unit)(cardGutter)
  49. }
  50. }
  51. }
  52. },
  53. [`&${componentCls}-top`]: {
  54. [`> ${componentCls}-nav, > div > ${componentCls}-nav`]: {
  55. [`${componentCls}-tab`]: {
  56. borderRadius: `${(0, _cssinjs.unit)(token.borderRadiusLG)} ${(0, _cssinjs.unit)(token.borderRadiusLG)} 0 0`
  57. },
  58. [`${componentCls}-tab-active`]: {
  59. borderBottomColor: token.colorBgContainer
  60. }
  61. }
  62. },
  63. [`&${componentCls}-bottom`]: {
  64. [`> ${componentCls}-nav, > div > ${componentCls}-nav`]: {
  65. [`${componentCls}-tab`]: {
  66. borderRadius: `0 0 ${(0, _cssinjs.unit)(token.borderRadiusLG)} ${(0, _cssinjs.unit)(token.borderRadiusLG)}`
  67. },
  68. [`${componentCls}-tab-active`]: {
  69. borderTopColor: token.colorBgContainer
  70. }
  71. }
  72. },
  73. // ========================== Left & Right ==========================
  74. [`&${componentCls}-left, &${componentCls}-right`]: {
  75. [`> ${componentCls}-nav, > div > ${componentCls}-nav`]: {
  76. [`${componentCls}-tab + ${componentCls}-tab`]: {
  77. marginTop: (0, _cssinjs.unit)(cardGutter)
  78. }
  79. }
  80. },
  81. [`&${componentCls}-left`]: {
  82. [`> ${componentCls}-nav, > div > ${componentCls}-nav`]: {
  83. [`${componentCls}-tab`]: {
  84. borderRadius: {
  85. _skip_check_: true,
  86. value: `${(0, _cssinjs.unit)(token.borderRadiusLG)} 0 0 ${(0, _cssinjs.unit)(token.borderRadiusLG)}`
  87. }
  88. },
  89. [`${componentCls}-tab-active`]: {
  90. borderRightColor: {
  91. _skip_check_: true,
  92. value: token.colorBgContainer
  93. }
  94. }
  95. }
  96. },
  97. [`&${componentCls}-right`]: {
  98. [`> ${componentCls}-nav, > div > ${componentCls}-nav`]: {
  99. [`${componentCls}-tab`]: {
  100. borderRadius: {
  101. _skip_check_: true,
  102. value: `0 ${(0, _cssinjs.unit)(token.borderRadiusLG)} ${(0, _cssinjs.unit)(token.borderRadiusLG)} 0`
  103. }
  104. },
  105. [`${componentCls}-tab-active`]: {
  106. borderLeftColor: {
  107. _skip_check_: true,
  108. value: token.colorBgContainer
  109. }
  110. }
  111. }
  112. }
  113. }
  114. };
  115. };
  116. const genDropdownStyle = token => {
  117. const {
  118. componentCls,
  119. itemHoverColor,
  120. dropdownEdgeChildVerticalPadding
  121. } = token;
  122. return {
  123. [`${componentCls}-dropdown`]: Object.assign(Object.assign({}, (0, _style.resetComponent)(token)), {
  124. position: 'absolute',
  125. top: -9999,
  126. left: {
  127. _skip_check_: true,
  128. value: -9999
  129. },
  130. zIndex: token.zIndexPopup,
  131. display: 'block',
  132. '&-hidden': {
  133. display: 'none'
  134. },
  135. [`${componentCls}-dropdown-menu`]: {
  136. maxHeight: token.tabsDropdownHeight,
  137. margin: 0,
  138. padding: `${(0, _cssinjs.unit)(dropdownEdgeChildVerticalPadding)} 0`,
  139. overflowX: 'hidden',
  140. overflowY: 'auto',
  141. textAlign: {
  142. _skip_check_: true,
  143. value: 'left'
  144. },
  145. listStyleType: 'none',
  146. backgroundColor: token.colorBgContainer,
  147. backgroundClip: 'padding-box',
  148. borderRadius: token.borderRadiusLG,
  149. outline: 'none',
  150. boxShadow: token.boxShadowSecondary,
  151. '&-item': Object.assign(Object.assign({}, _style.textEllipsis), {
  152. display: 'flex',
  153. alignItems: 'center',
  154. minWidth: token.tabsDropdownWidth,
  155. margin: 0,
  156. padding: `${(0, _cssinjs.unit)(token.paddingXXS)} ${(0, _cssinjs.unit)(token.paddingSM)}`,
  157. color: token.colorText,
  158. fontWeight: 'normal',
  159. fontSize: token.fontSize,
  160. lineHeight: token.lineHeight,
  161. cursor: 'pointer',
  162. transition: `all ${token.motionDurationSlow}`,
  163. '> span': {
  164. flex: 1,
  165. whiteSpace: 'nowrap'
  166. },
  167. '&-remove': {
  168. flex: 'none',
  169. marginLeft: {
  170. _skip_check_: true,
  171. value: token.marginSM
  172. },
  173. color: token.colorIcon,
  174. fontSize: token.fontSizeSM,
  175. background: 'transparent',
  176. border: 0,
  177. cursor: 'pointer',
  178. '&:hover': {
  179. color: itemHoverColor
  180. }
  181. },
  182. '&:hover': {
  183. background: token.controlItemBgHover
  184. },
  185. '&-disabled': {
  186. '&, &:hover': {
  187. color: token.colorTextDisabled,
  188. background: 'transparent',
  189. cursor: 'not-allowed'
  190. }
  191. }
  192. })
  193. }
  194. })
  195. };
  196. };
  197. const genPositionStyle = token => {
  198. const {
  199. componentCls,
  200. margin,
  201. colorBorderSecondary,
  202. horizontalMargin,
  203. verticalItemPadding,
  204. verticalItemMargin,
  205. calc
  206. } = token;
  207. return {
  208. // ========================== Top & Bottom ==========================
  209. [`${componentCls}-top, ${componentCls}-bottom`]: {
  210. flexDirection: 'column',
  211. [`> ${componentCls}-nav, > div > ${componentCls}-nav`]: {
  212. margin: horizontalMargin,
  213. '&::before': {
  214. position: 'absolute',
  215. right: {
  216. _skip_check_: true,
  217. value: 0
  218. },
  219. left: {
  220. _skip_check_: true,
  221. value: 0
  222. },
  223. borderBottom: `${(0, _cssinjs.unit)(token.lineWidth)} ${token.lineType} ${colorBorderSecondary}`,
  224. content: "''"
  225. },
  226. [`${componentCls}-ink-bar`]: {
  227. height: token.lineWidthBold,
  228. '&-animated': {
  229. transition: `width ${token.motionDurationSlow}, left ${token.motionDurationSlow},
  230. right ${token.motionDurationSlow}`
  231. }
  232. },
  233. [`${componentCls}-nav-wrap`]: {
  234. '&::before, &::after': {
  235. top: 0,
  236. bottom: 0,
  237. width: token.controlHeight
  238. },
  239. '&::before': {
  240. left: {
  241. _skip_check_: true,
  242. value: 0
  243. },
  244. boxShadow: token.boxShadowTabsOverflowLeft
  245. },
  246. '&::after': {
  247. right: {
  248. _skip_check_: true,
  249. value: 0
  250. },
  251. boxShadow: token.boxShadowTabsOverflowRight
  252. },
  253. [`&${componentCls}-nav-wrap-ping-left::before`]: {
  254. opacity: 1
  255. },
  256. [`&${componentCls}-nav-wrap-ping-right::after`]: {
  257. opacity: 1
  258. }
  259. }
  260. }
  261. },
  262. [`${componentCls}-top`]: {
  263. [`> ${componentCls}-nav,
  264. > div > ${componentCls}-nav`]: {
  265. '&::before': {
  266. bottom: 0
  267. },
  268. [`${componentCls}-ink-bar`]: {
  269. bottom: 0
  270. }
  271. }
  272. },
  273. [`${componentCls}-bottom`]: {
  274. [`> ${componentCls}-nav, > div > ${componentCls}-nav`]: {
  275. order: 1,
  276. marginTop: margin,
  277. marginBottom: 0,
  278. '&::before': {
  279. top: 0
  280. },
  281. [`${componentCls}-ink-bar`]: {
  282. top: 0
  283. }
  284. },
  285. [`> ${componentCls}-content-holder, > div > ${componentCls}-content-holder`]: {
  286. order: 0
  287. }
  288. },
  289. // ========================== Left & Right ==========================
  290. [`${componentCls}-left, ${componentCls}-right`]: {
  291. [`> ${componentCls}-nav, > div > ${componentCls}-nav`]: {
  292. flexDirection: 'column',
  293. minWidth: calc(token.controlHeight).mul(1.25).equal(),
  294. // >>>>>>>>>>> Tab
  295. [`${componentCls}-tab`]: {
  296. padding: verticalItemPadding,
  297. textAlign: 'center'
  298. },
  299. [`${componentCls}-tab + ${componentCls}-tab`]: {
  300. margin: verticalItemMargin
  301. },
  302. // >>>>>>>>>>> Nav
  303. [`${componentCls}-nav-wrap`]: {
  304. flexDirection: 'column',
  305. '&::before, &::after': {
  306. right: {
  307. _skip_check_: true,
  308. value: 0
  309. },
  310. left: {
  311. _skip_check_: true,
  312. value: 0
  313. },
  314. height: token.controlHeight
  315. },
  316. '&::before': {
  317. top: 0,
  318. boxShadow: token.boxShadowTabsOverflowTop
  319. },
  320. '&::after': {
  321. bottom: 0,
  322. boxShadow: token.boxShadowTabsOverflowBottom
  323. },
  324. [`&${componentCls}-nav-wrap-ping-top::before`]: {
  325. opacity: 1
  326. },
  327. [`&${componentCls}-nav-wrap-ping-bottom::after`]: {
  328. opacity: 1
  329. }
  330. },
  331. // >>>>>>>>>>> Ink Bar
  332. [`${componentCls}-ink-bar`]: {
  333. width: token.lineWidthBold,
  334. '&-animated': {
  335. transition: `height ${token.motionDurationSlow}, top ${token.motionDurationSlow}`
  336. }
  337. },
  338. [`${componentCls}-nav-list, ${componentCls}-nav-operations`]: {
  339. flex: '1 0 auto',
  340. // fix safari scroll problem
  341. flexDirection: 'column'
  342. }
  343. }
  344. },
  345. [`${componentCls}-left`]: {
  346. [`> ${componentCls}-nav, > div > ${componentCls}-nav`]: {
  347. [`${componentCls}-ink-bar`]: {
  348. right: {
  349. _skip_check_: true,
  350. value: 0
  351. }
  352. }
  353. },
  354. [`> ${componentCls}-content-holder, > div > ${componentCls}-content-holder`]: {
  355. marginLeft: {
  356. _skip_check_: true,
  357. value: (0, _cssinjs.unit)(calc(token.lineWidth).mul(-1).equal())
  358. },
  359. borderLeft: {
  360. _skip_check_: true,
  361. value: `${(0, _cssinjs.unit)(token.lineWidth)} ${token.lineType} ${token.colorBorder}`
  362. },
  363. [`> ${componentCls}-content > ${componentCls}-tabpane`]: {
  364. paddingLeft: {
  365. _skip_check_: true,
  366. value: token.paddingLG
  367. }
  368. }
  369. }
  370. },
  371. [`${componentCls}-right`]: {
  372. [`> ${componentCls}-nav, > div > ${componentCls}-nav`]: {
  373. order: 1,
  374. [`${componentCls}-ink-bar`]: {
  375. left: {
  376. _skip_check_: true,
  377. value: 0
  378. }
  379. }
  380. },
  381. [`> ${componentCls}-content-holder, > div > ${componentCls}-content-holder`]: {
  382. order: 0,
  383. marginRight: {
  384. _skip_check_: true,
  385. value: calc(token.lineWidth).mul(-1).equal()
  386. },
  387. borderRight: {
  388. _skip_check_: true,
  389. value: `${(0, _cssinjs.unit)(token.lineWidth)} ${token.lineType} ${token.colorBorder}`
  390. },
  391. [`> ${componentCls}-content > ${componentCls}-tabpane`]: {
  392. paddingRight: {
  393. _skip_check_: true,
  394. value: token.paddingLG
  395. }
  396. }
  397. }
  398. }
  399. };
  400. };
  401. const genSizeStyle = token => {
  402. const {
  403. componentCls,
  404. cardPaddingSM,
  405. cardPaddingLG,
  406. cardHeightSM,
  407. cardHeightLG,
  408. horizontalItemPaddingSM,
  409. horizontalItemPaddingLG
  410. } = token;
  411. return {
  412. // >>>>> shared
  413. [componentCls]: {
  414. '&-small': {
  415. [`> ${componentCls}-nav`]: {
  416. [`${componentCls}-tab`]: {
  417. padding: horizontalItemPaddingSM,
  418. fontSize: token.titleFontSizeSM
  419. }
  420. }
  421. },
  422. '&-large': {
  423. [`> ${componentCls}-nav`]: {
  424. [`${componentCls}-tab`]: {
  425. padding: horizontalItemPaddingLG,
  426. fontSize: token.titleFontSizeLG,
  427. lineHeight: token.lineHeightLG
  428. }
  429. }
  430. }
  431. },
  432. // >>>>> card
  433. [`${componentCls}-card`]: {
  434. // Small
  435. [`&${componentCls}-small`]: {
  436. [`> ${componentCls}-nav`]: {
  437. [`${componentCls}-tab`]: {
  438. padding: cardPaddingSM
  439. },
  440. [`${componentCls}-nav-add`]: {
  441. minWidth: cardHeightSM,
  442. minHeight: cardHeightSM
  443. }
  444. },
  445. [`&${componentCls}-bottom`]: {
  446. [`> ${componentCls}-nav ${componentCls}-tab`]: {
  447. borderRadius: `0 0 ${(0, _cssinjs.unit)(token.borderRadius)} ${(0, _cssinjs.unit)(token.borderRadius)}`
  448. }
  449. },
  450. [`&${componentCls}-top`]: {
  451. [`> ${componentCls}-nav ${componentCls}-tab`]: {
  452. borderRadius: `${(0, _cssinjs.unit)(token.borderRadius)} ${(0, _cssinjs.unit)(token.borderRadius)} 0 0`
  453. }
  454. },
  455. [`&${componentCls}-right`]: {
  456. [`> ${componentCls}-nav ${componentCls}-tab`]: {
  457. borderRadius: {
  458. _skip_check_: true,
  459. value: `0 ${(0, _cssinjs.unit)(token.borderRadius)} ${(0, _cssinjs.unit)(token.borderRadius)} 0`
  460. }
  461. }
  462. },
  463. [`&${componentCls}-left`]: {
  464. [`> ${componentCls}-nav ${componentCls}-tab`]: {
  465. borderRadius: {
  466. _skip_check_: true,
  467. value: `${(0, _cssinjs.unit)(token.borderRadius)} 0 0 ${(0, _cssinjs.unit)(token.borderRadius)}`
  468. }
  469. }
  470. }
  471. },
  472. // Large
  473. [`&${componentCls}-large`]: {
  474. [`> ${componentCls}-nav`]: {
  475. [`${componentCls}-tab`]: {
  476. padding: cardPaddingLG
  477. },
  478. [`${componentCls}-nav-add`]: {
  479. minWidth: cardHeightLG,
  480. minHeight: cardHeightLG
  481. }
  482. }
  483. }
  484. }
  485. };
  486. };
  487. const genTabStyle = token => {
  488. const {
  489. componentCls,
  490. itemActiveColor,
  491. itemHoverColor,
  492. iconCls,
  493. tabsHorizontalItemMargin,
  494. horizontalItemPadding,
  495. itemSelectedColor,
  496. itemColor
  497. } = token;
  498. const tabCls = `${componentCls}-tab`;
  499. return {
  500. [tabCls]: {
  501. position: 'relative',
  502. WebkitTouchCallout: 'none',
  503. WebkitTapHighlightColor: 'transparent',
  504. display: 'inline-flex',
  505. alignItems: 'center',
  506. padding: horizontalItemPadding,
  507. fontSize: token.titleFontSize,
  508. background: 'transparent',
  509. border: 0,
  510. outline: 'none',
  511. cursor: 'pointer',
  512. color: itemColor,
  513. '&-btn, &-remove': {
  514. '&:focus:not(:focus-visible), &:active': {
  515. color: itemActiveColor
  516. }
  517. },
  518. '&-btn': {
  519. outline: 'none',
  520. transition: `all ${token.motionDurationSlow}`,
  521. [`${tabCls}-icon:not(:last-child)`]: {
  522. marginInlineEnd: token.marginSM
  523. }
  524. },
  525. '&-remove': Object.assign({
  526. flex: 'none',
  527. lineHeight: 1,
  528. marginRight: {
  529. _skip_check_: true,
  530. value: token.calc(token.marginXXS).mul(-1).equal()
  531. },
  532. marginLeft: {
  533. _skip_check_: true,
  534. value: token.marginXS
  535. },
  536. color: token.colorIcon,
  537. fontSize: token.fontSizeSM,
  538. background: 'transparent',
  539. border: 'none',
  540. outline: 'none',
  541. cursor: 'pointer',
  542. transition: `all ${token.motionDurationSlow}`,
  543. '&:hover': {
  544. color: token.colorTextHeading
  545. }
  546. }, (0, _style.genFocusStyle)(token)),
  547. '&:hover': {
  548. color: itemHoverColor
  549. },
  550. [`&${tabCls}-active ${tabCls}-btn`]: {
  551. color: itemSelectedColor,
  552. textShadow: token.tabsActiveTextShadow
  553. },
  554. [`&${tabCls}-focus ${tabCls}-btn:focus-visible`]: (0, _style.genFocusOutline)(token),
  555. [`&${tabCls}-disabled`]: {
  556. color: token.colorTextDisabled,
  557. cursor: 'not-allowed'
  558. },
  559. [`&${tabCls}-disabled ${tabCls}-btn, &${tabCls}-disabled ${componentCls}-remove`]: {
  560. '&:focus, &:active': {
  561. color: token.colorTextDisabled
  562. }
  563. },
  564. [`& ${tabCls}-remove ${iconCls}`]: {
  565. margin: 0,
  566. verticalAlign: 'middle'
  567. },
  568. [`${iconCls}:not(:last-child)`]: {
  569. marginRight: {
  570. _skip_check_: true,
  571. value: token.marginSM
  572. }
  573. }
  574. },
  575. [`${tabCls} + ${tabCls}`]: {
  576. margin: {
  577. _skip_check_: true,
  578. value: tabsHorizontalItemMargin
  579. }
  580. }
  581. };
  582. };
  583. const genRtlStyle = token => {
  584. const {
  585. componentCls,
  586. tabsHorizontalItemMarginRTL,
  587. iconCls,
  588. cardGutter,
  589. calc
  590. } = token;
  591. const rtlCls = `${componentCls}-rtl`;
  592. return {
  593. [rtlCls]: {
  594. direction: 'rtl',
  595. [`${componentCls}-nav`]: {
  596. [`${componentCls}-tab`]: {
  597. margin: {
  598. _skip_check_: true,
  599. value: tabsHorizontalItemMarginRTL
  600. },
  601. [`${componentCls}-tab:last-of-type`]: {
  602. marginLeft: {
  603. _skip_check_: true,
  604. value: 0
  605. }
  606. },
  607. [iconCls]: {
  608. marginRight: {
  609. _skip_check_: true,
  610. value: 0
  611. },
  612. marginLeft: {
  613. _skip_check_: true,
  614. value: (0, _cssinjs.unit)(token.marginSM)
  615. }
  616. },
  617. [`${componentCls}-tab-remove`]: {
  618. marginRight: {
  619. _skip_check_: true,
  620. value: (0, _cssinjs.unit)(token.marginXS)
  621. },
  622. marginLeft: {
  623. _skip_check_: true,
  624. value: (0, _cssinjs.unit)(calc(token.marginXXS).mul(-1).equal())
  625. },
  626. [iconCls]: {
  627. margin: 0
  628. }
  629. }
  630. }
  631. },
  632. [`&${componentCls}-left`]: {
  633. [`> ${componentCls}-nav`]: {
  634. order: 1
  635. },
  636. [`> ${componentCls}-content-holder`]: {
  637. order: 0
  638. }
  639. },
  640. [`&${componentCls}-right`]: {
  641. [`> ${componentCls}-nav`]: {
  642. order: 0
  643. },
  644. [`> ${componentCls}-content-holder`]: {
  645. order: 1
  646. }
  647. },
  648. // ====================== Card ======================
  649. [`&${componentCls}-card${componentCls}-top, &${componentCls}-card${componentCls}-bottom`]: {
  650. [`> ${componentCls}-nav, > div > ${componentCls}-nav`]: {
  651. [`${componentCls}-tab + ${componentCls}-tab`]: {
  652. marginRight: {
  653. _skip_check_: true,
  654. value: cardGutter
  655. },
  656. marginLeft: {
  657. _skip_check_: true,
  658. value: 0
  659. }
  660. }
  661. }
  662. }
  663. },
  664. [`${componentCls}-dropdown-rtl`]: {
  665. direction: 'rtl'
  666. },
  667. [`${componentCls}-menu-item`]: {
  668. [`${componentCls}-dropdown-rtl`]: {
  669. textAlign: {
  670. _skip_check_: true,
  671. value: 'right'
  672. }
  673. }
  674. }
  675. };
  676. };
  677. const genTabsStyle = token => {
  678. const {
  679. componentCls,
  680. tabsCardPadding,
  681. cardHeight,
  682. cardGutter,
  683. itemHoverColor,
  684. itemActiveColor,
  685. colorBorderSecondary
  686. } = token;
  687. return {
  688. [componentCls]: Object.assign(Object.assign(Object.assign(Object.assign({}, (0, _style.resetComponent)(token)), {
  689. display: 'flex',
  690. // ========================== Navigation ==========================
  691. [`> ${componentCls}-nav, > div > ${componentCls}-nav`]: {
  692. position: 'relative',
  693. display: 'flex',
  694. flex: 'none',
  695. alignItems: 'center',
  696. [`${componentCls}-nav-wrap`]: {
  697. position: 'relative',
  698. display: 'flex',
  699. flex: 'auto',
  700. alignSelf: 'stretch',
  701. overflow: 'hidden',
  702. whiteSpace: 'nowrap',
  703. transform: 'translate(0)',
  704. // Fix chrome render bug
  705. // >>>>> Ping shadow
  706. '&::before, &::after': {
  707. position: 'absolute',
  708. zIndex: 1,
  709. opacity: 0,
  710. transition: `opacity ${token.motionDurationSlow}`,
  711. content: "''",
  712. pointerEvents: 'none'
  713. }
  714. },
  715. [`${componentCls}-nav-list`]: {
  716. position: 'relative',
  717. display: 'flex',
  718. transition: `opacity ${token.motionDurationSlow}`
  719. },
  720. // >>>>>>>> Operations
  721. [`${componentCls}-nav-operations`]: {
  722. display: 'flex',
  723. alignSelf: 'stretch'
  724. },
  725. [`${componentCls}-nav-operations-hidden`]: {
  726. position: 'absolute',
  727. visibility: 'hidden',
  728. pointerEvents: 'none'
  729. },
  730. [`${componentCls}-nav-more`]: {
  731. position: 'relative',
  732. padding: tabsCardPadding,
  733. background: 'transparent',
  734. border: 0,
  735. color: token.colorText,
  736. '&::after': {
  737. position: 'absolute',
  738. right: {
  739. _skip_check_: true,
  740. value: 0
  741. },
  742. bottom: 0,
  743. left: {
  744. _skip_check_: true,
  745. value: 0
  746. },
  747. height: token.calc(token.controlHeightLG).div(8).equal(),
  748. transform: 'translateY(100%)',
  749. content: "''"
  750. }
  751. },
  752. [`${componentCls}-nav-add`]: Object.assign({
  753. minWidth: cardHeight,
  754. minHeight: cardHeight,
  755. marginLeft: {
  756. _skip_check_: true,
  757. value: cardGutter
  758. },
  759. background: 'transparent',
  760. border: `${(0, _cssinjs.unit)(token.lineWidth)} ${token.lineType} ${colorBorderSecondary}`,
  761. borderRadius: `${(0, _cssinjs.unit)(token.borderRadiusLG)} ${(0, _cssinjs.unit)(token.borderRadiusLG)} 0 0`,
  762. outline: 'none',
  763. cursor: 'pointer',
  764. color: token.colorText,
  765. transition: `all ${token.motionDurationSlow} ${token.motionEaseInOut}`,
  766. '&:hover': {
  767. color: itemHoverColor
  768. },
  769. '&:active, &:focus:not(:focus-visible)': {
  770. color: itemActiveColor
  771. }
  772. }, (0, _style.genFocusStyle)(token, -3))
  773. },
  774. [`${componentCls}-extra-content`]: {
  775. flex: 'none'
  776. },
  777. // ============================ InkBar ============================
  778. [`${componentCls}-ink-bar`]: {
  779. position: 'absolute',
  780. background: token.inkBarColor,
  781. pointerEvents: 'none'
  782. }
  783. }), genTabStyle(token)), {
  784. // =========================== TabPanes ===========================
  785. [`${componentCls}-content`]: {
  786. position: 'relative',
  787. width: '100%'
  788. },
  789. [`${componentCls}-content-holder`]: {
  790. flex: 'auto',
  791. minWidth: 0,
  792. minHeight: 0
  793. },
  794. [`${componentCls}-tabpane`]: Object.assign(Object.assign({}, (0, _style.genFocusStyle)(token)), {
  795. '&-hidden': {
  796. display: 'none'
  797. }
  798. })
  799. }),
  800. [`${componentCls}-centered`]: {
  801. [`> ${componentCls}-nav, > div > ${componentCls}-nav`]: {
  802. [`${componentCls}-nav-wrap`]: {
  803. [`&:not([class*='${componentCls}-nav-wrap-ping']) > ${componentCls}-nav-list`]: {
  804. margin: 'auto'
  805. }
  806. }
  807. }
  808. }
  809. };
  810. };
  811. const prepareComponentToken = token => {
  812. const {
  813. cardHeight,
  814. cardHeightSM,
  815. cardHeightLG,
  816. controlHeight,
  817. controlHeightLG
  818. } = token;
  819. const mergedCardHeight = cardHeight || controlHeightLG;
  820. const mergedCardHeightSM = cardHeightSM || controlHeight;
  821. // `controlHeight` missing XL variable, so we directly write it here:
  822. const mergedCardHeightLG = cardHeightLG || controlHeightLG + 8;
  823. return {
  824. zIndexPopup: token.zIndexPopupBase + 50,
  825. cardBg: token.colorFillAlter,
  826. // We can not pass this as valid value,
  827. // Since `cardHeight` will lock nav add button height.
  828. cardHeight: mergedCardHeight,
  829. cardHeightSM: mergedCardHeightSM,
  830. cardHeightLG: mergedCardHeightLG,
  831. // Initialize with empty string, because cardPadding will be calculated with cardHeight by default.
  832. cardPadding: `${(mergedCardHeight - token.fontHeight) / 2 - token.lineWidth}px ${token.padding}px`,
  833. cardPaddingSM: `${(mergedCardHeightSM - token.fontHeight) / 2 - token.lineWidth}px ${token.paddingXS}px`,
  834. cardPaddingLG: `${(mergedCardHeightLG - token.fontHeightLG) / 2 - token.lineWidth}px ${token.padding}px`,
  835. titleFontSize: token.fontSize,
  836. titleFontSizeLG: token.fontSizeLG,
  837. titleFontSizeSM: token.fontSize,
  838. inkBarColor: token.colorPrimary,
  839. horizontalMargin: `0 0 ${token.margin}px 0`,
  840. horizontalItemGutter: 32,
  841. // Fixed Value
  842. // Initialize with empty string, because horizontalItemMargin will be calculated with horizontalItemGutter by default.
  843. horizontalItemMargin: ``,
  844. horizontalItemMarginRTL: ``,
  845. horizontalItemPadding: `${token.paddingSM}px 0`,
  846. horizontalItemPaddingSM: `${token.paddingXS}px 0`,
  847. horizontalItemPaddingLG: `${token.padding}px 0`,
  848. verticalItemPadding: `${token.paddingXS}px ${token.paddingLG}px`,
  849. verticalItemMargin: `${token.margin}px 0 0 0`,
  850. itemColor: token.colorText,
  851. itemSelectedColor: token.colorPrimary,
  852. itemHoverColor: token.colorPrimaryHover,
  853. itemActiveColor: token.colorPrimaryActive,
  854. cardGutter: token.marginXXS / 2
  855. };
  856. };
  857. // ============================== Export ==============================
  858. exports.prepareComponentToken = prepareComponentToken;
  859. var _default = exports.default = (0, _internal.genStyleHooks)('Tabs', token => {
  860. const tabsToken = (0, _internal.mergeToken)(token, {
  861. // `cardPadding` is empty by default, so we could calculate with dynamic `cardHeight`
  862. tabsCardPadding: token.cardPadding,
  863. dropdownEdgeChildVerticalPadding: token.paddingXXS,
  864. tabsActiveTextShadow: '0 0 0.25px currentcolor',
  865. tabsDropdownHeight: 200,
  866. tabsDropdownWidth: 120,
  867. tabsHorizontalItemMargin: `0 0 0 ${(0, _cssinjs.unit)(token.horizontalItemGutter)}`,
  868. tabsHorizontalItemMarginRTL: `0 0 0 ${(0, _cssinjs.unit)(token.horizontalItemGutter)}`
  869. });
  870. return [genSizeStyle(tabsToken), genRtlStyle(tabsToken), genPositionStyle(tabsToken), genDropdownStyle(tabsToken), genCardStyle(tabsToken), genTabsStyle(tabsToken), (0, _motion.default)(tabsToken)];
  871. }, prepareComponentToken);