index.js 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584
  1. import _extends from "@babel/runtime/helpers/esm/extends";
  2. import { genBasicInputStyle, genInputSmallStyle, initInputToken } from '../../input/style';
  3. import { genComponentStyleHook, mergeToken } from '../../theme/internal';
  4. import { genFocusOutline, genFocusStyle, resetComponent } from '../../style';
  5. const genPaginationDisabledStyle = token => {
  6. const {
  7. componentCls
  8. } = token;
  9. return {
  10. [`${componentCls}-disabled`]: {
  11. '&, &:hover': {
  12. cursor: 'not-allowed',
  13. [`${componentCls}-item-link`]: {
  14. color: token.colorTextDisabled,
  15. cursor: 'not-allowed'
  16. }
  17. },
  18. '&:focus-visible': {
  19. cursor: 'not-allowed',
  20. [`${componentCls}-item-link`]: {
  21. color: token.colorTextDisabled,
  22. cursor: 'not-allowed'
  23. }
  24. }
  25. },
  26. [`&${componentCls}-disabled`]: {
  27. cursor: 'not-allowed',
  28. [`&${componentCls}-mini`]: {
  29. [`
  30. &:hover ${componentCls}-item:not(${componentCls}-item-active),
  31. &:active ${componentCls}-item:not(${componentCls}-item-active),
  32. &:hover ${componentCls}-item-link,
  33. &:active ${componentCls}-item-link
  34. `]: {
  35. backgroundColor: 'transparent'
  36. }
  37. },
  38. [`${componentCls}-item`]: {
  39. cursor: 'not-allowed',
  40. '&:hover, &:active': {
  41. backgroundColor: 'transparent'
  42. },
  43. a: {
  44. color: token.colorTextDisabled,
  45. backgroundColor: 'transparent',
  46. border: 'none',
  47. cursor: 'not-allowed'
  48. },
  49. '&-active': {
  50. borderColor: token.colorBorder,
  51. backgroundColor: token.paginationItemDisabledBgActive,
  52. '&:hover, &:active': {
  53. backgroundColor: token.paginationItemDisabledBgActive
  54. },
  55. a: {
  56. color: token.paginationItemDisabledColorActive
  57. }
  58. }
  59. },
  60. [`${componentCls}-item-link`]: {
  61. color: token.colorTextDisabled,
  62. cursor: 'not-allowed',
  63. '&:hover, &:active': {
  64. backgroundColor: 'transparent'
  65. },
  66. [`${componentCls}-simple&`]: {
  67. backgroundColor: 'transparent',
  68. '&:hover, &:active': {
  69. backgroundColor: 'transparent'
  70. }
  71. }
  72. },
  73. [`${componentCls}-simple-pager`]: {
  74. color: token.colorTextDisabled
  75. },
  76. [`${componentCls}-jump-prev, ${componentCls}-jump-next`]: {
  77. [`${componentCls}-item-link-icon`]: {
  78. opacity: 0
  79. },
  80. [`${componentCls}-item-ellipsis`]: {
  81. opacity: 1
  82. }
  83. }
  84. },
  85. [`&${componentCls}-simple`]: {
  86. [`${componentCls}-prev, ${componentCls}-next`]: {
  87. [`&${componentCls}-disabled ${componentCls}-item-link`]: {
  88. '&:hover, &:active': {
  89. backgroundColor: 'transparent'
  90. }
  91. }
  92. }
  93. }
  94. };
  95. };
  96. const genPaginationMiniStyle = token => {
  97. const {
  98. componentCls
  99. } = token;
  100. return {
  101. [`&${componentCls}-mini ${componentCls}-total-text, &${componentCls}-mini ${componentCls}-simple-pager`]: {
  102. height: token.paginationItemSizeSM,
  103. lineHeight: `${token.paginationItemSizeSM}px`
  104. },
  105. [`&${componentCls}-mini ${componentCls}-item`]: {
  106. minWidth: token.paginationItemSizeSM,
  107. height: token.paginationItemSizeSM,
  108. margin: 0,
  109. lineHeight: `${token.paginationItemSizeSM - 2}px`
  110. },
  111. [`&${componentCls}-mini ${componentCls}-item:not(${componentCls}-item-active)`]: {
  112. backgroundColor: 'transparent',
  113. borderColor: 'transparent',
  114. '&:hover': {
  115. backgroundColor: token.colorBgTextHover
  116. },
  117. '&:active': {
  118. backgroundColor: token.colorBgTextActive
  119. }
  120. },
  121. [`&${componentCls}-mini ${componentCls}-prev, &${componentCls}-mini ${componentCls}-next`]: {
  122. minWidth: token.paginationItemSizeSM,
  123. height: token.paginationItemSizeSM,
  124. margin: 0,
  125. lineHeight: `${token.paginationItemSizeSM}px`,
  126. [`&:hover ${componentCls}-item-link`]: {
  127. backgroundColor: token.colorBgTextHover
  128. },
  129. [`&:active ${componentCls}-item-link`]: {
  130. backgroundColor: token.colorBgTextActive
  131. },
  132. [`&${componentCls}-disabled:hover ${componentCls}-item-link`]: {
  133. backgroundColor: 'transparent'
  134. }
  135. },
  136. [`
  137. &${componentCls}-mini ${componentCls}-prev ${componentCls}-item-link,
  138. &${componentCls}-mini ${componentCls}-next ${componentCls}-item-link
  139. `]: {
  140. backgroundColor: 'transparent',
  141. borderColor: 'transparent',
  142. '&::after': {
  143. height: token.paginationItemSizeSM,
  144. lineHeight: `${token.paginationItemSizeSM}px`
  145. }
  146. },
  147. [`&${componentCls}-mini ${componentCls}-jump-prev, &${componentCls}-mini ${componentCls}-jump-next`]: {
  148. height: token.paginationItemSizeSM,
  149. marginInlineEnd: 0,
  150. lineHeight: `${token.paginationItemSizeSM}px`
  151. },
  152. [`&${componentCls}-mini ${componentCls}-options`]: {
  153. marginInlineStart: token.paginationMiniOptionsMarginInlineStart,
  154. [`&-size-changer`]: {
  155. top: token.paginationMiniOptionsSizeChangerTop
  156. },
  157. [`&-quick-jumper`]: {
  158. height: token.paginationItemSizeSM,
  159. lineHeight: `${token.paginationItemSizeSM}px`,
  160. input: _extends(_extends({}, genInputSmallStyle(token)), {
  161. width: token.paginationMiniQuickJumperInputWidth,
  162. height: token.controlHeightSM
  163. })
  164. }
  165. }
  166. };
  167. };
  168. const genPaginationSimpleStyle = token => {
  169. const {
  170. componentCls
  171. } = token;
  172. return {
  173. [`
  174. &${componentCls}-simple ${componentCls}-prev,
  175. &${componentCls}-simple ${componentCls}-next
  176. `]: {
  177. height: token.paginationItemSizeSM,
  178. lineHeight: `${token.paginationItemSizeSM}px`,
  179. verticalAlign: 'top',
  180. [`${componentCls}-item-link`]: {
  181. height: token.paginationItemSizeSM,
  182. backgroundColor: 'transparent',
  183. border: 0,
  184. '&:hover': {
  185. backgroundColor: token.colorBgTextHover
  186. },
  187. '&:active': {
  188. backgroundColor: token.colorBgTextActive
  189. },
  190. '&::after': {
  191. height: token.paginationItemSizeSM,
  192. lineHeight: `${token.paginationItemSizeSM}px`
  193. }
  194. }
  195. },
  196. [`&${componentCls}-simple ${componentCls}-simple-pager`]: {
  197. display: 'inline-block',
  198. height: token.paginationItemSizeSM,
  199. marginInlineEnd: token.marginXS,
  200. input: {
  201. boxSizing: 'border-box',
  202. height: '100%',
  203. marginInlineEnd: token.marginXS,
  204. padding: `0 ${token.paginationItemPaddingInline}px`,
  205. textAlign: 'center',
  206. backgroundColor: token.paginationItemInputBg,
  207. border: `${token.lineWidth}px ${token.lineType} ${token.colorBorder}`,
  208. borderRadius: token.borderRadius,
  209. outline: 'none',
  210. transition: `border-color ${token.motionDurationMid}`,
  211. color: 'inherit',
  212. '&:hover': {
  213. borderColor: token.colorPrimary
  214. },
  215. '&:focus': {
  216. borderColor: token.colorPrimaryHover,
  217. boxShadow: `${token.inputOutlineOffset}px 0 ${token.controlOutlineWidth}px ${token.controlOutline}`
  218. },
  219. '&[disabled]': {
  220. color: token.colorTextDisabled,
  221. backgroundColor: token.colorBgContainerDisabled,
  222. borderColor: token.colorBorder,
  223. cursor: 'not-allowed'
  224. }
  225. }
  226. }
  227. };
  228. };
  229. const genPaginationJumpStyle = token => {
  230. const {
  231. componentCls
  232. } = token;
  233. return {
  234. [`${componentCls}-jump-prev, ${componentCls}-jump-next`]: {
  235. outline: 0,
  236. [`${componentCls}-item-container`]: {
  237. position: 'relative',
  238. [`${componentCls}-item-link-icon`]: {
  239. color: token.colorPrimary,
  240. fontSize: token.fontSizeSM,
  241. opacity: 0,
  242. transition: `all ${token.motionDurationMid}`,
  243. '&-svg': {
  244. top: 0,
  245. insetInlineEnd: 0,
  246. bottom: 0,
  247. insetInlineStart: 0,
  248. margin: 'auto'
  249. }
  250. },
  251. [`${componentCls}-item-ellipsis`]: {
  252. position: 'absolute',
  253. top: 0,
  254. insetInlineEnd: 0,
  255. bottom: 0,
  256. insetInlineStart: 0,
  257. display: 'block',
  258. margin: 'auto',
  259. color: token.colorTextDisabled,
  260. fontFamily: 'Arial, Helvetica, sans-serif',
  261. letterSpacing: token.paginationEllipsisLetterSpacing,
  262. textAlign: 'center',
  263. textIndent: token.paginationEllipsisTextIndent,
  264. opacity: 1,
  265. transition: `all ${token.motionDurationMid}`
  266. }
  267. },
  268. '&:hover': {
  269. [`${componentCls}-item-link-icon`]: {
  270. opacity: 1
  271. },
  272. [`${componentCls}-item-ellipsis`]: {
  273. opacity: 0
  274. }
  275. },
  276. '&:focus-visible': _extends({
  277. [`${componentCls}-item-link-icon`]: {
  278. opacity: 1
  279. },
  280. [`${componentCls}-item-ellipsis`]: {
  281. opacity: 0
  282. }
  283. }, genFocusOutline(token))
  284. },
  285. [`
  286. ${componentCls}-prev,
  287. ${componentCls}-jump-prev,
  288. ${componentCls}-jump-next
  289. `]: {
  290. marginInlineEnd: token.marginXS
  291. },
  292. [`
  293. ${componentCls}-prev,
  294. ${componentCls}-next,
  295. ${componentCls}-jump-prev,
  296. ${componentCls}-jump-next
  297. `]: {
  298. display: 'inline-block',
  299. minWidth: token.paginationItemSize,
  300. height: token.paginationItemSize,
  301. color: token.colorText,
  302. fontFamily: token.paginationFontFamily,
  303. lineHeight: `${token.paginationItemSize}px`,
  304. textAlign: 'center',
  305. verticalAlign: 'middle',
  306. listStyle: 'none',
  307. borderRadius: token.borderRadius,
  308. cursor: 'pointer',
  309. transition: `all ${token.motionDurationMid}`
  310. },
  311. [`${componentCls}-prev, ${componentCls}-next`]: {
  312. fontFamily: 'Arial, Helvetica, sans-serif',
  313. outline: 0,
  314. button: {
  315. color: token.colorText,
  316. cursor: 'pointer',
  317. userSelect: 'none'
  318. },
  319. [`${componentCls}-item-link`]: {
  320. display: 'block',
  321. width: '100%',
  322. height: '100%',
  323. padding: 0,
  324. fontSize: token.fontSizeSM,
  325. textAlign: 'center',
  326. backgroundColor: 'transparent',
  327. border: `${token.lineWidth}px ${token.lineType} transparent`,
  328. borderRadius: token.borderRadius,
  329. outline: 'none',
  330. transition: `all ${token.motionDurationMid}`
  331. },
  332. [`&:focus-visible ${componentCls}-item-link`]: _extends({}, genFocusOutline(token)),
  333. [`&:hover ${componentCls}-item-link`]: {
  334. backgroundColor: token.colorBgTextHover
  335. },
  336. [`&:active ${componentCls}-item-link`]: {
  337. backgroundColor: token.colorBgTextActive
  338. },
  339. [`&${componentCls}-disabled:hover`]: {
  340. [`${componentCls}-item-link`]: {
  341. backgroundColor: 'transparent'
  342. }
  343. }
  344. },
  345. [`${componentCls}-slash`]: {
  346. marginInlineEnd: token.paginationSlashMarginInlineEnd,
  347. marginInlineStart: token.paginationSlashMarginInlineStart
  348. },
  349. [`${componentCls}-options`]: {
  350. display: 'inline-block',
  351. marginInlineStart: token.margin,
  352. verticalAlign: 'middle',
  353. '&-size-changer.-select': {
  354. display: 'inline-block',
  355. width: 'auto'
  356. },
  357. '&-quick-jumper': {
  358. display: 'inline-block',
  359. height: token.controlHeight,
  360. marginInlineStart: token.marginXS,
  361. lineHeight: `${token.controlHeight}px`,
  362. verticalAlign: 'top',
  363. input: _extends(_extends({}, genBasicInputStyle(token)), {
  364. width: token.controlHeightLG * 1.25,
  365. height: token.controlHeight,
  366. boxSizing: 'border-box',
  367. margin: 0,
  368. marginInlineStart: token.marginXS,
  369. marginInlineEnd: token.marginXS
  370. })
  371. }
  372. }
  373. };
  374. };
  375. const genPaginationItemStyle = token => {
  376. const {
  377. componentCls
  378. } = token;
  379. return {
  380. [`${componentCls}-item`]: _extends(_extends({
  381. display: 'inline-block',
  382. minWidth: token.paginationItemSize,
  383. height: token.paginationItemSize,
  384. marginInlineEnd: token.marginXS,
  385. fontFamily: token.paginationFontFamily,
  386. lineHeight: `${token.paginationItemSize - 2}px`,
  387. textAlign: 'center',
  388. verticalAlign: 'middle',
  389. listStyle: 'none',
  390. backgroundColor: 'transparent',
  391. border: `${token.lineWidth}px ${token.lineType} transparent`,
  392. borderRadius: token.borderRadius,
  393. outline: 0,
  394. cursor: 'pointer',
  395. userSelect: 'none',
  396. a: {
  397. display: 'block',
  398. padding: `0 ${token.paginationItemPaddingInline}px`,
  399. color: token.colorText,
  400. transition: 'none',
  401. '&:hover': {
  402. textDecoration: 'none'
  403. }
  404. },
  405. [`&:not(${componentCls}-item-active)`]: {
  406. '&:hover': {
  407. transition: `all ${token.motionDurationMid}`,
  408. backgroundColor: token.colorBgTextHover
  409. },
  410. '&:active': {
  411. backgroundColor: token.colorBgTextActive
  412. }
  413. }
  414. }, genFocusStyle(token)), {
  415. '&-active': {
  416. fontWeight: token.paginationFontWeightActive,
  417. backgroundColor: token.paginationItemBgActive,
  418. borderColor: token.colorPrimary,
  419. a: {
  420. color: token.colorPrimary
  421. },
  422. '&:hover': {
  423. borderColor: token.colorPrimaryHover
  424. },
  425. '&:hover a': {
  426. color: token.colorPrimaryHover
  427. }
  428. }
  429. })
  430. };
  431. };
  432. const genPaginationStyle = token => {
  433. const {
  434. componentCls
  435. } = token;
  436. return {
  437. [componentCls]: _extends(_extends(_extends(_extends(_extends(_extends(_extends(_extends({}, resetComponent(token)), {
  438. 'ul, ol': {
  439. margin: 0,
  440. padding: 0,
  441. listStyle: 'none'
  442. },
  443. '&::after': {
  444. display: 'block',
  445. clear: 'both',
  446. height: 0,
  447. overflow: 'hidden',
  448. visibility: 'hidden',
  449. content: '""'
  450. },
  451. [`${componentCls}-total-text`]: {
  452. display: 'inline-block',
  453. height: token.paginationItemSize,
  454. marginInlineEnd: token.marginXS,
  455. lineHeight: `${token.paginationItemSize - 2}px`,
  456. verticalAlign: 'middle'
  457. }
  458. }), genPaginationItemStyle(token)), genPaginationJumpStyle(token)), genPaginationSimpleStyle(token)), genPaginationMiniStyle(token)), genPaginationDisabledStyle(token)), {
  459. // media query style
  460. [`@media only screen and (max-width: ${token.screenLG}px)`]: {
  461. [`${componentCls}-item`]: {
  462. '&-after-jump-prev, &-before-jump-next': {
  463. display: 'none'
  464. }
  465. }
  466. },
  467. [`@media only screen and (max-width: ${token.screenSM}px)`]: {
  468. [`${componentCls}-options`]: {
  469. display: 'none'
  470. }
  471. }
  472. }),
  473. // rtl style
  474. [`&${token.componentCls}-rtl`]: {
  475. direction: 'rtl'
  476. }
  477. };
  478. };
  479. const genBorderedStyle = token => {
  480. const {
  481. componentCls
  482. } = token;
  483. return {
  484. [`${componentCls}${componentCls}-disabled`]: {
  485. '&, &:hover': {
  486. [`${componentCls}-item-link`]: {
  487. borderColor: token.colorBorder
  488. }
  489. },
  490. '&:focus-visible': {
  491. [`${componentCls}-item-link`]: {
  492. borderColor: token.colorBorder
  493. }
  494. },
  495. [`${componentCls}-item, ${componentCls}-item-link`]: {
  496. backgroundColor: token.colorBgContainerDisabled,
  497. borderColor: token.colorBorder,
  498. [`&:hover:not(${componentCls}-item-active)`]: {
  499. backgroundColor: token.colorBgContainerDisabled,
  500. borderColor: token.colorBorder,
  501. a: {
  502. color: token.colorTextDisabled
  503. }
  504. },
  505. [`&${componentCls}-item-active`]: {
  506. backgroundColor: token.paginationItemDisabledBgActive
  507. }
  508. },
  509. [`${componentCls}-prev, ${componentCls}-next`]: {
  510. '&:hover button': {
  511. backgroundColor: token.colorBgContainerDisabled,
  512. borderColor: token.colorBorder,
  513. color: token.colorTextDisabled
  514. },
  515. [`${componentCls}-item-link`]: {
  516. backgroundColor: token.colorBgContainerDisabled,
  517. borderColor: token.colorBorder
  518. }
  519. }
  520. },
  521. [componentCls]: {
  522. [`${componentCls}-prev, ${componentCls}-next`]: {
  523. '&:hover button': {
  524. borderColor: token.colorPrimaryHover,
  525. backgroundColor: token.paginationItemBg
  526. },
  527. [`${componentCls}-item-link`]: {
  528. backgroundColor: token.paginationItemLinkBg,
  529. borderColor: token.colorBorder
  530. },
  531. [`&:hover ${componentCls}-item-link`]: {
  532. borderColor: token.colorPrimary,
  533. backgroundColor: token.paginationItemBg,
  534. color: token.colorPrimary
  535. },
  536. [`&${componentCls}-disabled`]: {
  537. [`${componentCls}-item-link`]: {
  538. borderColor: token.colorBorder,
  539. color: token.colorTextDisabled
  540. }
  541. }
  542. },
  543. [`${componentCls}-item`]: {
  544. backgroundColor: token.paginationItemBg,
  545. border: `${token.lineWidth}px ${token.lineType} ${token.colorBorder}`,
  546. [`&:hover:not(${componentCls}-item-active)`]: {
  547. borderColor: token.colorPrimary,
  548. backgroundColor: token.paginationItemBg,
  549. a: {
  550. color: token.colorPrimary
  551. }
  552. },
  553. '&-active': {
  554. borderColor: token.colorPrimary
  555. }
  556. }
  557. }
  558. };
  559. };
  560. // ============================== Export ==============================
  561. export default genComponentStyleHook('Pagination', token => {
  562. const paginationToken = mergeToken(token, {
  563. paginationItemSize: token.controlHeight,
  564. paginationFontFamily: token.fontFamily,
  565. paginationItemBg: token.colorBgContainer,
  566. paginationItemBgActive: token.colorBgContainer,
  567. paginationFontWeightActive: token.fontWeightStrong,
  568. paginationItemSizeSM: token.controlHeightSM,
  569. paginationItemInputBg: token.colorBgContainer,
  570. paginationMiniOptionsSizeChangerTop: 0,
  571. paginationItemDisabledBgActive: token.controlItemBgActiveDisabled,
  572. paginationItemDisabledColorActive: token.colorTextDisabled,
  573. paginationItemLinkBg: token.colorBgContainer,
  574. inputOutlineOffset: '0 0',
  575. paginationMiniOptionsMarginInlineStart: token.marginXXS / 2,
  576. paginationMiniQuickJumperInputWidth: token.controlHeightLG * 1.1,
  577. paginationItemPaddingInline: token.marginXXS * 1.5,
  578. paginationEllipsisLetterSpacing: token.marginXXS / 2,
  579. paginationSlashMarginInlineStart: token.marginXXS,
  580. paginationSlashMarginInlineEnd: token.marginSM,
  581. paginationEllipsisTextIndent: '0.13em' // magic for ui experience
  582. }, initInputToken(token));
  583. return [genPaginationStyle(paginationToken), token.wireframe && genBorderedStyle(paginationToken)];
  584. });