-
-
Notifications
You must be signed in to change notification settings - Fork 330
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor pagination for readability and maintainability
--- For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/react-component/pagination?shareId=XXXX-XXXX-XXXX-XXXX).
- Loading branch information
Showing
5 changed files
with
76 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import React from 'react'; | ||
import type { PaginationProps } from '../interface'; | ||
|
||
const Simple: React.FC<PaginationProps> = ({ | ||
locale, | ||
prefixCls, | ||
current, | ||
allPages, | ||
disabled, | ||
internalInputVal, | ||
handleKeyDown, | ||
handleKeyUp, | ||
handleBlur, | ||
handleGoTO, | ||
goButton, | ||
showTitle, | ||
}) => { | ||
const isReadOnly = typeof simple === 'object' ? simple.readOnly : !simple; | ||
let gotoButton: any = goButton; | ||
Check warning Code scanning / CodeQL Useless assignment to local variable Warning
The initial value of gotoButton is unused, since it is always overwritten.
|
||
|
||
if (goButton) { | ||
if (typeof goButton === 'boolean') { | ||
gotoButton = ( | ||
<button type="button" onClick={handleGoTO} onKeyUp={handleGoTO}> | ||
{locale.jump_to_confirm} | ||
</button> | ||
); | ||
} else { | ||
gotoButton = ( | ||
<span onClick={handleGoTO} onKeyUp={handleGoTO}> | ||
{goButton} | ||
</span> | ||
); | ||
} | ||
|
||
gotoButton = ( | ||
<li | ||
title={showTitle ? `${locale.jump_to}${current}/${allPages}` : null} | ||
className={`${prefixCls}-simple-pager`} | ||
> | ||
{gotoButton} | ||
</li> | ||
); | ||
Check warning Code scanning / CodeQL Useless assignment to local variable Warning
The value assigned to gotoButton here is unused.
|
||
} | ||
|
||
return ( | ||
<li | ||
title={showTitle ? `${current}/${allPages}` : null} | ||
className={`${prefixCls}-simple-pager`} | ||
> | ||
{isReadOnly ? ( | ||
internalInputVal | ||
) : ( | ||
<input | ||
type="text" | ||
value={internalInputVal} | ||
disabled={disabled} | ||
onKeyDown={handleKeyDown} | ||
onKeyUp={handleKeyUp} | ||
onChange={handleKeyUp} | ||
onBlur={handleBlur} | ||
size={3} | ||
/> | ||
)} | ||
<span className={`${prefixCls}-slash`}>/</span> | ||
{allPages} | ||
</li> | ||
); | ||
}; | ||
|
||
export default Simple; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
export { default } from './Pagination'; | ||
export { default } from './components/Pagination'; | ||
export type { PaginationLocale, PaginationProps } from './interface'; |