File tree Expand file tree Collapse file tree 8 files changed +117
-15
lines changed Expand file tree Collapse file tree 8 files changed +117
-15
lines changed Original file line number Diff line number Diff line change @@ -71,7 +71,7 @@ ReactDOM.render(<Pagination />, container);
71
71
| showQuickJumper | show quick goto jumper | Bool / Object | false / {goButton: true} |
72
72
| showTotal | show total records and range | Function(total, [ from, to] ) | - |
73
73
| className | className of pagination | String | - |
74
- | simple | when set, show simple pager | Object | null |
74
+ | simple | when set, show simple pager | Bool / { readOnly?: boolean; } | - |
75
75
| locale | to set l10n config | Object | [ zh_CN] ( https://github.com/react-component/pagination/blob/master/src/locale/zh_CN.js ) |
76
76
| style | the style of pagination | Object | {} |
77
77
| showLessItems | show less page items | Bool | false |
Original file line number Diff line number Diff line change 210
210
}
211
211
212
212
&-slash {
213
- margin : 0 10px 0 5 px ;
213
+ margin : 0 10px 0 12 px ;
214
214
}
215
215
216
216
&-options {
262
262
}
263
263
264
264
&-simple &-simple-pager {
265
- display : inline-block ;
265
+ display : flex ;
266
+ align-items : center ;
266
267
height : @pagination-item-size-sm ;
267
268
margin-right : 8px ;
268
269
269
270
input {
270
271
box-sizing : border-box ;
271
272
height : 100% ;
272
- margin-right : 8px ;
273
273
padding : 0 6px ;
274
274
text-align : center ;
275
275
background-color : @pagination-item-input-bg ;
Original file line number Diff line number Diff line change @@ -16,6 +16,13 @@ export default () => {
16
16
onChange = { setPageIndex }
17
17
/>
18
18
< br />
19
+ < Pagination
20
+ simple = { { readOnly : true } }
21
+ current = { pageIndex }
22
+ total = { 50 }
23
+ onChange = { setPageIndex }
24
+ />
25
+ < br />
19
26
< Pagination simple defaultCurrent = { 1 } total = { 50 } />
20
27
< br />
21
28
< Pagination
Original file line number Diff line number Diff line change @@ -345,6 +345,7 @@ const Pagination: React.FC<PaginationProps> = (props) => {
345
345
346
346
// ================== Simple ==================
347
347
// FIXME: ts type
348
+ const isReadOnly = typeof simple === 'object' ? simple . readOnly : ! simple ;
348
349
let gotoButton : any = goButton ;
349
350
let simplePager : React . ReactNode = null ;
350
351
@@ -380,16 +381,20 @@ const Pagination: React.FC<PaginationProps> = (props) => {
380
381
title = { showTitle ? `${ current } /${ allPages } ` : null }
381
382
className = { `${ prefixCls } -simple-pager` }
382
383
>
383
- < input
384
- type = "text"
385
- value = { internalInputVal }
386
- disabled = { disabled }
387
- onKeyDown = { handleKeyDown }
388
- onKeyUp = { handleKeyUp }
389
- onChange = { handleKeyUp }
390
- onBlur = { handleBlur }
391
- size = { 3 }
392
- />
384
+ { isReadOnly ? (
385
+ internalInputVal
386
+ ) : (
387
+ < input
388
+ type = "text"
389
+ value = { internalInputVal }
390
+ disabled = { disabled }
391
+ onKeyDown = { handleKeyDown }
392
+ onKeyUp = { handleKeyUp }
393
+ onChange = { handleKeyUp }
394
+ onBlur = { handleBlur }
395
+ size = { 3 }
396
+ />
397
+ ) }
393
398
< span className = { `${ prefixCls } -slash` } > /</ span >
394
399
{ allPages }
395
400
</ li >
Original file line number Diff line number Diff line change @@ -37,7 +37,7 @@ export interface PaginationData {
37
37
showPrevNextJumpers : boolean ;
38
38
showQuickJumper : boolean | object ;
39
39
showTitle : boolean ;
40
- simple : boolean ;
40
+ simple : boolean | { readOnly ?: boolean ; } ;
41
41
disabled : boolean ;
42
42
43
43
locale : PaginationLocale ;
Original file line number Diff line number Diff line change @@ -3375,6 +3375,46 @@ exports[`Example simple 1`] = `
3375
3375
</li >
3376
3376
</ul >
3377
3377
<br />
3378
+ <ul
3379
+ class = " rc-pagination rc-pagination-simple"
3380
+ >
3381
+ <li
3382
+ aria-disabled = " true"
3383
+ class = " rc-pagination-prev rc-pagination-disabled"
3384
+ title = " 上一页"
3385
+ >
3386
+ <button
3387
+ aria-label = " prev page"
3388
+ class = " rc-pagination-item-link"
3389
+ disabled = " "
3390
+ type = " button"
3391
+ />
3392
+ </li >
3393
+ <li
3394
+ class = " rc-pagination-simple-pager"
3395
+ title = " 1/5"
3396
+ >
3397
+ 1
3398
+ <span
3399
+ class = " rc-pagination-slash"
3400
+ >
3401
+ /
3402
+ </span >
3403
+ 5
3404
+ </li >
3405
+ <li
3406
+ aria-disabled = " false"
3407
+ class = " rc-pagination-next"
3408
+ title = " 下一页"
3409
+ >
3410
+ <button
3411
+ aria-label = " next page"
3412
+ class = " rc-pagination-item-link"
3413
+ type = " button"
3414
+ />
3415
+ </li >
3416
+ </ul >
3417
+ <br />
3378
3418
<ul
3379
3419
class = " rc-pagination rc-pagination-simple"
3380
3420
>
Original file line number Diff line number Diff line change @@ -67,3 +67,48 @@ exports[`simple Pagination props: showQuickJumper should render normally quick-j
67
67
</span >
68
68
</div >
69
69
` ;
70
+
71
+ exports [` simple Pagination should support simple is readOnly value 1` ] = `
72
+ <div >
73
+ <ul
74
+ class = " rc-pagination rc-pagination-simple"
75
+ >
76
+ <li
77
+ aria-disabled = " true"
78
+ class = " rc-pagination-prev rc-pagination-disabled"
79
+ title = " 上一页"
80
+ >
81
+ <button
82
+ aria-label = " prev page"
83
+ class = " rc-pagination-item-link"
84
+ disabled = " "
85
+ type = " button"
86
+ />
87
+ </li >
88
+ <li
89
+ class = " rc-pagination-simple-pager"
90
+ title = " 1/0"
91
+ >
92
+ 1
93
+ <span
94
+ class = " rc-pagination-slash"
95
+ >
96
+ /
97
+ </span >
98
+ 0
99
+ </li >
100
+ <li
101
+ aria-disabled = " true"
102
+ class = " rc-pagination-next rc-pagination-disabled"
103
+ title = " 下一页"
104
+ >
105
+ <button
106
+ aria-label = " next page"
107
+ class = " rc-pagination-item-link"
108
+ disabled = " "
109
+ type = " button"
110
+ />
111
+ </li >
112
+ </ul >
113
+ </div >
114
+ ` ;
Original file line number Diff line number Diff line change @@ -299,4 +299,9 @@ describe('simple Pagination', () => {
299
299
expect ( quickJumper ) . toMatchSnapshot ( ) ;
300
300
} ) ;
301
301
} ) ;
302
+
303
+ it ( 'should support simple is readOnly value' , ( ) => {
304
+ const { container } = render ( < Pagination simple = { { readOnly : true } } /> ) ;
305
+ expect ( container ) . toMatchSnapshot ( ) ;
306
+ } ) ;
302
307
} ) ;
You can’t perform that action at this time.
0 commit comments