index.js 17 KB

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