Skip to content
This repository has been archived by the owner on Nov 14, 2023. It is now read-only.

Commit

Permalink
fix: fix export
Browse files Browse the repository at this point in the history
Signed-off-by: csonchen <cson_chensheng@163.com>
  • Loading branch information
csonchen committed May 26, 2023
1 parent c6affde commit e95f991
Show file tree
Hide file tree
Showing 4 changed files with 101 additions and 117 deletions.
59 changes: 59 additions & 0 deletions src/components/Pagination/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import React from 'react';
import { Pagination as BSPagination } from 'react-bootstrap';
import { PaginationProps } from '../../interface';

export default class Pagination extends React.Component<PaginationProps> {
initPageItems = () => {
const { items, activePage, maxButtons = 5, onSelectChange } = this.props;
const pageItems: JSX.Element[] = [];
let startPage;
let endPage;
if (maxButtons < items) {
startPage = Math.max(
Math.min(activePage - Math.floor(maxButtons / 2), items - maxButtons + 1),
1,
);
endPage = startPage + maxButtons - 1;
} else {
startPage = 1;
endPage = items;
}
for (let number = startPage; number <= endPage; number++) {
pageItems.push(
<BSPagination.Item
key={number}
active={number === activePage}
onClick={() => onSelectChange(number)}
>
{number}
</BSPagination.Item>,
);
}
return pageItems;
};

render() {
const {
first,
prev,
next,
last,
activePage,
items,
maxButtons,
onSelectChange,
...restProps
} = this.props;
const pageItems = this.initPageItems();

return (
<BSPagination {...restProps}>
{first && <BSPagination.First onClick={() => onSelectChange(1)} />}
{prev && <BSPagination.Prev onClick={() => onSelectChange(activePage - 1)} />}
{pageItems}
{next && <BSPagination.Next onClick={() => onSelectChange(activePage + 1)} />}
{last && <BSPagination.Last onClick={() => onSelectChange(items)} />}
</BSPagination>
);
}
}
2 changes: 1 addition & 1 deletion src/components/RangePicker/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ export default class RangePicker extends React.PureComponent<RangePickerProps, R
<div className="RangePicker__duration">
{ranges.map(({ title, value }) => {
return (
<Button key={value} onClick={() => this.handleRangeClick(value)}>
<Button variant="link" key={value} onClick={() => this.handleRangeClick(value)}>
{this.lang === 'en' ? value : title}
</Button>
);
Expand Down
143 changes: 28 additions & 115 deletions src/components/index.tsx
Original file line number Diff line number Diff line change
@@ -1,115 +1,28 @@
import Alert from './Alert';
import Badge from './Badge';
import Button from './Button';
import DatePicker from './DatePicker';
import Dropdown from './Dropdown';
import DropdownButton from './DropdownButton';
import Icon from './Icon';
import InputDropdown from './InputDropdown';
import Loader from './Loader';
import Navigation from './Navigation';
import Notification from './/Notification/Notification';
import NotificationList from './Notification/NotificationList';
import Modal from './Modal';
import Panel from './Panel';
import Popover from './Popover';
import RangePicker from './RangePicker';
import Steps from './Steps';
import SubMenu from './SubMenu';
import Switch from './Switch';
import Tabs from './Tabs';
import TimePicker from './TimePicker';
import Tooltip from './Tooltip';
import Tree from './Tree';
import UsageBar from './UsageBar';
import VirtualList from './VirtualList';
import VirtualSelectBox from './VirtualSelectBox';
import {
Breadcrumb,
BreadcrumbItem,
Button as BsButton,
ButtonGroup,
ButtonToolbar,
Container,
Col,
Collapse,
Form,
FormCheck,
FormControl,
FormGroup,
FormLabel,
InputGroup,
ListGroup,
ListGroupItem,
Nav,
Navbar,
NavItem,
NavDropdown,
Overlay,
OverlayTrigger,
Pagination,
ProgressBar,
Row,
SplitButton,
Tab,
ToggleButtonGroup,
ToggleButton,
} from 'react-bootstrap';

export {
Alert,
Badge,
Breadcrumb,
BreadcrumbItem,
BsButton,
Button,
ButtonGroup,
ButtonToolbar,
Collapse,
Container,
Col,
DatePicker,
Dropdown,
DropdownButton,
Form,
FormCheck,
FormControl,
FormGroup,
FormLabel,
Icon,
InputDropdown,
InputGroup,
Loader,
ListGroup,
ListGroupItem,
Nav,
Navbar,
NavDropdown,
NavItem,
Navigation,
NotificationList,
Notification,
Modal,
Overlay,
OverlayTrigger,
ProgressBar,
Pagination,
Panel,
Popover,
RangePicker,
Row,
SplitButton,
Steps,
SubMenu,
Switch,
Tab,
Tabs,
TimePicker,
Tooltip,
Tree,
ToggleButtonGroup,
ToggleButton,
UsageBar,
VirtualList,
VirtualSelectBox,
};
export * from 'react-bootstrap';
export { default as Alert } from './Alert';
export { default as Badge } from './Badge';
export { default as Button } from './Button';
export { default as DatePicker } from './DatePicker';
export { default as Dropdown } from './Dropdown';
export { default as DropdownButton } from './DropdownButton';
export { default as Icon } from './Icon';
export { default as InputDropdown } from './InputDropdown';
export { default as Loader } from './Loader';
export { default as Navigation } from './Navigation';
export { default as Notification } from './/Notification/Notification';
export { default as NotificationList } from './Notification/NotificationList';
export { default as Modal } from './Modal';
export { default as Panel } from './Panel';
export { default as Pagination } from './Pagination';
export { default as Popover } from './Popover';
export { default as RangePicker } from './RangePicker';
export { default as Steps } from './Steps';
export { default as SubMenu } from './SubMenu';
export { default as Switch } from './Switch';
export { default as Tabs } from './Tabs';
export { default as TimePicker } from './TimePicker';
export { default as Tooltip } from './Tooltip';
export { default as Tree } from './Tree';
export { default as UsageBar } from './UsageBar';
export { default as VirtualList } from './VirtualList';
export { default as VirtualSelectBox } from './VirtualSelectBox';
14 changes: 13 additions & 1 deletion src/interface.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
ModalProps as BsModalProps,
DropdownButtonProps as BsDropdownButtonProps,
DropdownProps as BsDropdownProps,
PaginationProps as BsPaginationProps,
} from 'react-bootstrap';
import { ButtonProps as BaseButtonProps } from '@restart/ui/Button';
import { ButtonVariant } from 'react-bootstrap/esm/types';
Expand Down Expand Up @@ -130,7 +131,7 @@ export interface TabsProps {
unmountOnExit?: boolean;
transition?: boolean;
mountOnEnter?: boolean;
className?: string
className?: string;
}

export interface StepsProps {
Expand Down Expand Up @@ -464,3 +465,14 @@ export interface ButtonProps extends BaseButtonProps {
export interface HeaderToggleProps {
eventKey: string | any;
}

export interface PaginationProps extends BsPaginationProps {
prev?: boolean;
next?: boolean;
first?: boolean;
last?: boolean;
maxButtons?: number;
items: number;
activePage: number;
onSelectChange: (activePage: number) => void;
}

0 comments on commit e95f991

Please sign in to comment.