@finos/legend-application-marketplace
Version:
Legend Marketplace application core
38 lines • 2.78 kB
JavaScript
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
/**
* Copyright (c) 2026-present, Goldman Sachs
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { observer } from 'mobx-react-lite';
import { useCallback } from 'react';
import { Box, MenuItem, Pagination, Select, Typography, } from '@mui/material';
export const PaginationControls = observer((props) => {
const { totalItems, itemsPerPage, page, onPageChange, onItemsPerPageChange, disabled = false, pageSizeOptions = [12, 24, 36, 48], } = props;
const totalPages = Math.ceil(totalItems / itemsPerPage);
const handlePageChange = useCallback((_, newPage) => {
onPageChange(newPage);
}, [onPageChange]);
const handleItemsPerPageChange = useCallback((event) => {
onItemsPerPageChange(Number(event.target.value));
}, [onItemsPerPageChange]);
if (totalItems === 0) {
return null;
}
return (_jsxs(Box, { className: "legend-marketplace-pagination-container", children: [_jsxs(Box, { className: "legend-marketplace-pagination-page-size", children: [_jsx(Typography, { variant: "body2", sx: { fontSize: '2rem' }, children: "Items per page:" }), _jsx(Select, { value: itemsPerPage, onChange: handleItemsPerPageChange, size: "medium", disabled: disabled, children: pageSizeOptions.map((option) => (_jsx(MenuItem, { value: option, children: option }, option))) })] }), _jsx(Box, { className: "legend-marketplace-pagination-info", children: _jsxs(Typography, { variant: "body2", children: ["Showing ", _jsx("strong", { children: (page - 1) * itemsPerPage + 1 }), " to", ' ', _jsx("strong", { children: Math.min(page * itemsPerPage, totalItems) }), " of", ' ', _jsx("strong", { children: totalItems }), " results"] }) }), _jsx(Box, { className: "legend-marketplace-pagination-controls", children: totalPages > 1 && (_jsx(Pagination, { count: totalPages, page: page, onChange: handlePageChange, color: "primary", showFirstButton: true, showLastButton: true, disabled: disabled, siblingCount: 1, boundaryCount: 2, size: "large", sx: {
'& .MuiPaginationItem-root': {
fontSize: '1.5rem',
},
} })) })] }));
});
//# sourceMappingURL=PaginationControls.js.map