DocSpace-client/packages/shared/components/paging/Paging.tsx
Vladimir Khvan 719ffe2b60 Merge branch 'develop' into feature/data-migration
Conflicts:
	packages/client/src/routes/portalSettings.js
	packages/client/src/store/DialogsStore.js
	packages/client/src/store/index.js
	packages/common/constants/index.js
	packages/components/file-input/index.js
	packages/components/paging/index.js
	packages/components/progress-bar/index.js
	packages/components/row/index.js
	packages/components/table-container/TableGroupMenu.js
	packages/components/themes/base.js
	packages/shared/api/settings/index.ts
	packages/shared/components/paging/Paging.styled.ts
	packages/shared/components/table/sub-components/TableHeaderCell.tsx
	packages/shared/utils/catalogIconHelper.ts
	public/locales/en/Common.json
2024-02-13 16:16:29 +05:00

97 lines
2.4 KiB
TypeScript

import React from "react";
import { ButtonSize, Button } from "../button";
import { ComboBox, TOption } from "../combobox";
import { StyledPage, StyledOnPage, StyledPaging } from "./Paging.styled";
import { PagingProps } from "./Paging.types";
const Paging = (props: PagingProps) => {
// console.log("Paging render");
const {
previousLabel,
nextLabel,
previousAction,
nextAction,
pageItems,
countItems,
openDirection,
disablePrevious = false,
disableNext = false,
disableHover = false,
selectedPageItem,
selectedCountItem,
id,
className,
style,
showCountItem = true,
onSelectPage,
onSelectCount,
} = props;
const onSelectPageAction = (option: TOption) => {
onSelectPage?.(option);
};
const onSelectCountAction = (option: TOption) => {
onSelectCount?.(option);
};
const setDropDownMaxHeight =
pageItems && pageItems.length > 6 ? { dropDownMaxHeight: 200 } : {};
return (
<StyledPaging id={id} className={className} style={style}>
<Button
className="prev-button not-selectable"
size={ButtonSize.small}
scale
label={previousLabel}
onClick={previousAction}
isDisabled={disablePrevious}
disableHover={disableHover}
/>
{pageItems && (
<StyledPage>
<ComboBox
isDisabled={disablePrevious && disableNext}
className="manualWidth"
directionY={openDirection}
options={pageItems}
onSelect={onSelectPageAction}
scaledOptions={pageItems.length < 6}
selectedOption={selectedPageItem}
{...setDropDownMaxHeight}
/>
</StyledPage>
)}
<Button
className="next-button not-selectable"
size={ButtonSize.small}
scale
label={nextLabel}
onClick={nextAction}
isDisabled={disableNext}
disableHover={disableHover}
/>
{showCountItem
? countItems && (
<StyledOnPage>
<ComboBox
className="hideDisabled"
directionY={openDirection}
directionX="right"
options={countItems}
scaledOptions
onSelect={onSelectCountAction}
selectedOption={selectedCountItem}
/>
</StyledOnPage>
)
: null}
</StyledPaging>
);
};
export { Paging };