index.js 19 KB

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