tycho-components 0.0.17-SNAPSHOT-4 → 0.0.17-SNAPSHOT-6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5,6 +5,7 @@ type Props<TData> = {
5
5
  pagination: PaginationState;
6
6
  setPagination: (p: PaginationState) => void;
7
7
  hideItensPage?: boolean;
8
+ numItens?: number[];
8
9
  };
9
- export default function AppPagination<TData>({ totalElements, pagination, setPagination, hideItensPage, }: Props<TData>): import("react/jsx-runtime").JSX.Element;
10
+ export default function AppPagination<TData>({ totalElements, pagination, setPagination, hideItensPage, numItens, }: Props<TData>): import("react/jsx-runtime").JSX.Element;
10
11
  export {};
@@ -1,9 +1,9 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { MenuItem, Select } from '@mui/material';
2
+ import { Select, MenuItem } from '@mui/material';
3
3
  import { Trans, useTranslation } from 'react-i18next';
4
4
  import { IconButton } from 'tycho-storybook';
5
5
  import './styles.scss';
6
- export default function AppPagination({ totalElements, pagination, setPagination, hideItensPage, }) {
6
+ export default function AppPagination({ totalElements, pagination, setPagination, hideItensPage, numItens = [10, 25, 50], }) {
7
7
  const { t } = useTranslation('common');
8
8
  const numPages = Math.ceil(totalElements / pagination.pageSize);
9
9
  const currentPage = pagination.pageIndex + 1;
@@ -15,9 +15,16 @@ export default function AppPagination({ totalElements, pagination, setPagination
15
15
  const setPageIndex = (p) => {
16
16
  setPagination({ ...pagination, pageIndex: p });
17
17
  };
18
- return (_jsxs("div", { className: "app-table-pagination", children: [!hideItensPage && (_jsxs("div", { className: "itens-page", children: [_jsx("span", { children: t('table.label.rows-page') }), _jsx(Select, { value: pagination.pageSize, onChange: (e) => setPageSize(e.target.value), children: [10, 25, 50].map((size) => (_jsx(MenuItem, { value: size, children: size }, size))) })] })), _jsx("div", { className: "itens-total", children: _jsx("span", { children: _jsx(Trans, { t: t, i18nKey: "table.label.items", values: {
18
+ return (_jsxs("div", { className: "app-table-pagination", children: [!hideItensPage && (_jsxs("div", { className: "itens-page", children: [_jsx("span", { children: t('table.label.rows-page') }), _jsx(Select, { value: pagination.pageSize, onChange: (e) => setPageSize(e.target.value), MenuProps: menuProps, children: numItens.map((size) => (_jsx(MenuItem, { value: size, children: size }, size))) })] })), _jsx("div", { className: "itens-total", children: _jsx("span", { children: _jsx(Trans, { t: t, i18nKey: "table.label.items", values: {
19
19
  first: getFirstElementNumber(),
20
20
  last: getLastElementNumber(),
21
21
  total: totalElements,
22
- } }) }) }), _jsxs("div", { className: "pages-total", children: [_jsx(Select, { value: currentPage, onChange: (e) => setPageIndex(e.target.value - 1), children: Array.from({ length: numPages }, (_, index) => (_jsx(MenuItem, { value: index + 1, children: index + 1 }, index + 1))) }), _jsx("span", { children: _jsx(Trans, { t: t, i18nKey: "table.label.pages", values: { value: numPages } }) })] }), _jsxs("div", { className: "pages-navigation", children: [_jsx(IconButton, { size: "medium", mode: "tonal", onClick: () => setPageIndex(pagination.pageIndex - 1), disabled: pagination.pageIndex === 0, name: "chevron_backward" }), _jsx(IconButton, { size: "medium", mode: "tonal", onClick: () => setPageIndex(pagination.pageIndex + 1), disabled: pagination.pageIndex >= numPages - 1, name: "chevron_forward" })] })] }));
22
+ } }) }) }), _jsxs("div", { className: "pages-total", children: [_jsx(Select, { value: currentPage, onChange: (e) => setPageIndex(e.target.value - 1), MenuProps: menuProps, children: Array.from({ length: numPages }, (_, index) => (_jsx(MenuItem, { value: index + 1, children: index + 1 }, index + 1))) }), _jsx("span", { children: _jsx(Trans, { t: t, i18nKey: "table.label.pages", values: { value: numPages } }) })] }), _jsxs("div", { className: "pages-navigation", children: [_jsx(IconButton, { size: "medium", mode: "tonal", onClick: () => setPageIndex(pagination.pageIndex - 1), disabled: pagination.pageIndex === 0, name: "chevron_backward" }), _jsx(IconButton, { size: "medium", mode: "tonal", onClick: () => setPageIndex(pagination.pageIndex + 1), disabled: pagination.pageIndex >= numPages - 1, name: "chevron_forward" })] })] }));
23
23
  }
24
+ const menuProps = {
25
+ PaperProps: {
26
+ style: {
27
+ maxHeight: 400,
28
+ },
29
+ },
30
+ };
@@ -3,6 +3,7 @@
3
3
  height: 56px;
4
4
  border-top: none;
5
5
  justify-content: right;
6
+ width: 100%;
6
7
 
7
8
  .itens-page {
8
9
  display: flex;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "tycho-components",
3
3
  "private": false,
4
- "version": "0.0.17-SNAPSHOT-4",
4
+ "version": "0.0.17-SNAPSHOT-6",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "exports": {
@@ -49,7 +49,7 @@
49
49
  "react-hook-form": "^7.45.2",
50
50
  "react-i18next": "^13.0.2",
51
51
  "react-router-dom": "^6.14.2",
52
- "tycho-storybook": "0.1.7-r2",
52
+ "tycho-storybook": "0.1.7-r3",
53
53
  "yup": "^1.2.0"
54
54
  },
55
55
  "devDependencies": {