-
Notifications
You must be signed in to change notification settings - Fork 900
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(*): Prepare for upgrading to react 16 (#4947)
- Loading branch information
Justin Reynolds
committed
Mar 2, 2018
1 parent
4c3cbb5
commit 0b9ebba
Showing
31 changed files
with
577 additions
and
472 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
48 changes: 33 additions & 15 deletions
48
app/scripts/modules/core/src/application/search/PaginationControls.tsx
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,29 +1,47 @@ | ||
import * as React from 'react'; | ||
import { SelectCallback, Pagination } from 'react-bootstrap'; | ||
|
||
import { createUltimatePagination, ITEM_TYPES } from 'react-ultimate-pagination'; | ||
export interface IPaginationControlsProps { | ||
onPageChanged: SelectCallback; | ||
activePage: number; | ||
totalPages: number; | ||
} | ||
|
||
export const PaginationControls = ({ onPageChanged, activePage, totalPages }: IPaginationControlsProps) => { | ||
const ButtonComponent = (props: any) => { | ||
const { eventKey, children, ...restProps } = props; | ||
return <a {...restProps}>{children}</a> | ||
}; | ||
const Item = (props: { value: string, disabled?: boolean, isActive?: boolean, onClick: (event: React.MouseEvent<HTMLAnchorElement>) => void }) => ( | ||
<li className={`${props.isActive ? 'active' : ''} ${props.disabled ? 'disabled' : ''}`}> | ||
<a className={`${!props.disabled ? 'clickable' : ''}`} onClick={props.onClick}>{props.value}</a> | ||
</li> | ||
); | ||
|
||
const Paging = createUltimatePagination({ | ||
WrapperComponent: Pagination, | ||
itemTypeToComponent: { | ||
[ITEM_TYPES.PAGE]: ({ value, isActive, onClick }) => ( | ||
<Item value={value} isActive={isActive} onClick={onClick} /> | ||
), | ||
[ITEM_TYPES.ELLIPSIS]: ({ isActive, onClick }) => ( | ||
<Item value={`\u2026`} disabled={isActive} onClick={onClick} /> | ||
), | ||
[ITEM_TYPES.FIRST_PAGE_LINK]: ({ isActive, onClick }) => ( | ||
<Item value={`\u00ab`} disabled={isActive} onClick={onClick} /> | ||
), | ||
[ITEM_TYPES.PREVIOUS_PAGE_LINK]: ({ isActive, onClick }) => ( | ||
<Item value={`\u2039`} disabled={isActive} onClick={onClick} /> | ||
), | ||
[ITEM_TYPES.NEXT_PAGE_LINK]: ({ isActive, onClick }) => ( | ||
<Item value={`\u203a`} disabled={isActive} onClick={onClick} /> | ||
), | ||
[ITEM_TYPES.LAST_PAGE_LINK]: ({ isActive, onClick }) => ( | ||
<Item value={`\u00bb`} disabled={isActive} onClick={onClick} /> | ||
), | ||
}, | ||
}) | ||
return ( | ||
<Pagination | ||
buttonComponentClass={ButtonComponent} | ||
className="clickable" | ||
ellipsis={true} | ||
next={true} | ||
prev={true} | ||
onSelect={onPageChanged} | ||
activePage={activePage} | ||
items={totalPages} | ||
maxButtons={10} | ||
<Paging | ||
onChange={onPageChanged} | ||
currentPage={activePage} | ||
totalPages={totalPages} | ||
/> | ||
) | ||
}; |
34 changes: 34 additions & 0 deletions
34
app/scripts/modules/core/src/application/search/react-ultimate-pagination.d.ts
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,34 @@ | ||
declare module 'react-ultimate-pagination' { | ||
export interface ItemTypeToComponent { | ||
PAGE: React.ComponentType<{ value: any, isActive: boolean, onClick: any }>; | ||
ELLIPSIS: React.ComponentType<{ value: any, isActive: boolean, onClick: any }>; | ||
FIRST_PAGE_LINK: React.ComponentType<{ value: any, isActive: boolean, onClick: any }>; | ||
PREVIOUS_PAGE_LINK: React.ComponentType<{ value: any, isActive: boolean, onClick: any }>; | ||
NEXT_PAGE_LINK: React.ComponentType<{ value: any, isActive: boolean, onClick: any }>; | ||
LAST_PAGE_LINK: React.ComponentType<{ value: any, isActive: boolean, onClick: any }>; | ||
} | ||
|
||
export interface IUltimatePaginationProps { | ||
currentPage: number; | ||
totalPages: number; | ||
boundaryPagesRange?: number; | ||
siblingPagesRange?: number; | ||
hideEllipsis?: boolean; | ||
hidePreviousAndNextPageLinks?: boolean; | ||
hideFirstAndLastPageLinks?: boolean; | ||
onChange?: Function; | ||
disabled?: boolean; | ||
} | ||
|
||
export function createUltimatePagination(options: {itemTypeToComponent: ItemTypeToComponent, WrapperComponent: React.ComponentClass = 'div'}): React.ComponentClass<IUltimatePaginationProps>; | ||
export interface ItemTypes { | ||
PAGE: 'PAGE'; | ||
ELLIPSIS: 'ELLIPSIS'; | ||
FIRST_PAGE_LINK: 'FIRST_PAGE_LINK'; | ||
PREVIOUS_PAGE_LINK: 'PREVIOUS_PAGE_LINK'; | ||
NEXT_PAGE_LINK: 'NEXT_PAGE_LINK'; | ||
LAST_PAGE_LINK: 'LAST_PAGE_LINK'; | ||
} | ||
|
||
export declare const ITEM_TYPES: ItemTypes; | ||
} |
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
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
Oops, something went wrong.