tycho-components 0.19.0 → 0.19.1
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.
- package/dist/AppPagination/AppPagination.d.ts +1 -2
- package/dist/AppPagination/AppPagination.js +11 -7
- package/dist/AppPagination/styles.scss +80 -13
- package/dist/AppTable/AppTable.d.ts +3 -3
- package/dist/AppTable/AppTable.js +20 -20
- package/dist/AppTable/styles.scss +8 -0
- package/dist/configs/Localization.d.ts +198 -201
- package/dist/configs/localization/CommonTexts.d.ts +199 -202
- package/dist/configs/localization/CommonTexts.js +199 -202
- package/package.json +1 -1
|
@@ -5,9 +5,8 @@ type Props<TData> = {
|
|
|
5
5
|
pagination: PaginationState;
|
|
6
6
|
setPagination: (p: PaginationState) => void;
|
|
7
7
|
hideItensPage?: boolean;
|
|
8
|
-
hidePageTotal?: boolean;
|
|
9
8
|
numItens?: number[];
|
|
10
9
|
size?: 'medium' | 'small';
|
|
11
10
|
};
|
|
12
|
-
export default function AppPagination<TData>({ totalElements, pagination, setPagination, hideItensPage,
|
|
11
|
+
export default function AppPagination<TData>({ totalElements, pagination, setPagination, hideItensPage, numItens, size, }: Props<TData>): import("react/jsx-runtime").JSX.Element;
|
|
13
12
|
export {};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { MenuItem, Select } from '@mui/material';
|
|
3
|
-
import { Trans, useTranslation } from 'react-i18next';
|
|
4
3
|
import classNames from 'classnames';
|
|
4
|
+
import { Trans, useTranslation } from 'react-i18next';
|
|
5
5
|
import { IconButton } from 'tycho-storybook';
|
|
6
6
|
import './styles.scss';
|
|
7
|
-
export default function AppPagination({ totalElements, pagination, setPagination, hideItensPage,
|
|
7
|
+
export default function AppPagination({ totalElements, pagination, setPagination, hideItensPage, numItens = [10, 25, 50], size = 'medium', }) {
|
|
8
8
|
const { t } = useTranslation('common');
|
|
9
9
|
const numPages = Math.ceil(totalElements / pagination.pageSize);
|
|
10
10
|
const currentPage = pagination.pageIndex + 1;
|
|
@@ -18,11 +18,15 @@ export default function AppPagination({ totalElements, pagination, setPagination
|
|
|
18
18
|
};
|
|
19
19
|
return (_jsxs("div", { className: classNames('app-table-pagination', {
|
|
20
20
|
small: size === 'small',
|
|
21
|
-
}), 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, size: size === 'small' ? 'small' : 'medium', 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: {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
21
|
+
}), children: [_jsxs("div", { className: "itens-container", 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, size: size === 'small' ? 'small' : 'medium', 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: {
|
|
22
|
+
first: getFirstElementNumber(),
|
|
23
|
+
last: getLastElementNumber(),
|
|
24
|
+
total: totalElements,
|
|
25
|
+
} }) }) })] }), _jsxs("div", { className: "pages-navigation", children: [_jsx(IconButton, { size: size, mode: "tonal", onClick: () => setPageIndex(pagination.pageIndex - 1), disabled: pagination.pageIndex === 0, name: "chevron_backward" }), _jsx("div", { className: "pages-total", children: Array.from({ length: numPages }, (_, index) => {
|
|
26
|
+
const pageNum = index + 1;
|
|
27
|
+
const isActive = pageNum === currentPage;
|
|
28
|
+
return (_jsx("button", { type: "button", className: classNames('page-number', { active: isActive }), onClick: () => setPageIndex(index), "aria-current": isActive ? 'page' : undefined, children: pageNum }, pageNum));
|
|
29
|
+
}) }), _jsx(IconButton, { size: size, mode: "tonal", onClick: () => setPageIndex(pagination.pageIndex + 1), disabled: pagination.pageIndex >= numPages - 1, name: "chevron_forward" })] })] }));
|
|
26
30
|
}
|
|
27
31
|
const menuProps = {
|
|
28
32
|
PaperProps: {
|
|
@@ -1,28 +1,79 @@
|
|
|
1
1
|
.app-table-pagination {
|
|
2
2
|
display: flex;
|
|
3
|
-
justify-content: right;
|
|
4
3
|
padding: var(--spacing-150) var(--spacing-100);
|
|
5
4
|
border-top: 1px solid var(--border-subtle-2);
|
|
6
5
|
|
|
7
|
-
.itens-
|
|
6
|
+
.itens-container {
|
|
8
7
|
display: flex;
|
|
9
8
|
align-items: center;
|
|
10
|
-
margin-right: 16px;
|
|
11
9
|
gap: 16px;
|
|
12
|
-
}
|
|
13
10
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
11
|
+
.itens-page {
|
|
12
|
+
display: flex;
|
|
13
|
+
align-items: center;
|
|
14
|
+
margin-right: 16px;
|
|
15
|
+
gap: 16px;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.itens-total {
|
|
19
|
+
display: flex;
|
|
20
|
+
align-items: center;
|
|
21
|
+
margin-right: auto;
|
|
22
|
+
}
|
|
18
23
|
}
|
|
19
24
|
|
|
20
25
|
.pages-total {
|
|
21
26
|
display: flex;
|
|
22
27
|
align-items: center;
|
|
28
|
+
gap: 4px;
|
|
29
|
+
flex-wrap: nowrap;
|
|
30
|
+
width: 200px;
|
|
31
|
+
max-width: 100%;
|
|
32
|
+
overflow-x: auto;
|
|
33
|
+
overflow-y: hidden;
|
|
34
|
+
padding-bottom: 2px;
|
|
35
|
+
scrollbar-width: thin;
|
|
36
|
+
|
|
37
|
+
&::-webkit-scrollbar {
|
|
38
|
+
height: 6px;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
&::-webkit-scrollbar-thumb {
|
|
42
|
+
background-color: var(--border-subtle-2);
|
|
43
|
+
border-radius: 3px;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.page-number {
|
|
47
|
+
flex-shrink: 0;
|
|
48
|
+
display: inline-flex;
|
|
49
|
+
align-items: center;
|
|
50
|
+
justify-content: center;
|
|
51
|
+
min-width: 36px;
|
|
52
|
+
height: 40px;
|
|
53
|
+
padding: 0 var(--spacing-50);
|
|
54
|
+
margin: 0;
|
|
55
|
+
border: none;
|
|
56
|
+
border-radius: 0;
|
|
57
|
+
font-family: 'Work Sans', sans-serif;
|
|
58
|
+
@include button-small;
|
|
59
|
+
color: var(--text-on-color-dark);
|
|
60
|
+
background-color: var(--button-secondary-default);
|
|
61
|
+
cursor: pointer;
|
|
62
|
+
|
|
63
|
+
&:hover:not(.active) {
|
|
64
|
+
filter: brightness(1.05);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
&.active {
|
|
68
|
+
background-color: var(--button-primary-default);
|
|
69
|
+
color: var(--text-on-color-light);
|
|
70
|
+
cursor: default;
|
|
71
|
+
}
|
|
23
72
|
|
|
24
|
-
|
|
25
|
-
|
|
73
|
+
&:focus-visible {
|
|
74
|
+
outline: 2px solid var(--border-focus);
|
|
75
|
+
outline-offset: 2px;
|
|
76
|
+
}
|
|
26
77
|
}
|
|
27
78
|
}
|
|
28
79
|
|
|
@@ -30,11 +81,12 @@
|
|
|
30
81
|
display: flex;
|
|
31
82
|
align-items: center;
|
|
32
83
|
gap: 4px;
|
|
84
|
+
margin-left: auto;
|
|
33
85
|
}
|
|
34
86
|
|
|
35
87
|
.MuiInputBase-root {
|
|
36
88
|
border-radius: 0px;
|
|
37
|
-
font-family:
|
|
89
|
+
font-family: 'Work Sans' !important;
|
|
38
90
|
|
|
39
91
|
> .MuiSelect-select {
|
|
40
92
|
display: flex;
|
|
@@ -68,8 +120,11 @@
|
|
|
68
120
|
}
|
|
69
121
|
|
|
70
122
|
.pages-total {
|
|
71
|
-
|
|
72
|
-
|
|
123
|
+
width: 160px;
|
|
124
|
+
|
|
125
|
+
.page-number {
|
|
126
|
+
min-width: 28px;
|
|
127
|
+
height: 32px;
|
|
73
128
|
}
|
|
74
129
|
}
|
|
75
130
|
|
|
@@ -84,3 +139,15 @@
|
|
|
84
139
|
}
|
|
85
140
|
}
|
|
86
141
|
}
|
|
142
|
+
|
|
143
|
+
@media (max-width: 768px) {
|
|
144
|
+
.app-table-pagination {
|
|
145
|
+
flex-direction: column;
|
|
146
|
+
|
|
147
|
+
.pages-navigation {
|
|
148
|
+
justify-content: center;
|
|
149
|
+
margin-top: 16px;
|
|
150
|
+
margin-right: auto;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { PaginationState, SortingState } from
|
|
2
|
-
import
|
|
3
|
-
import { AppPage } from
|
|
1
|
+
import { PaginationState, SortingState } from '@tanstack/react-table';
|
|
2
|
+
import './styles.scss';
|
|
3
|
+
import { AppPage } from './types/AppPage';
|
|
4
4
|
type Props = {
|
|
5
5
|
columns: any;
|
|
6
6
|
data: AppPage<any>;
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import AppPagination from
|
|
12
|
-
import { tableTheme } from
|
|
13
|
-
import
|
|
2
|
+
import { ThemeProvider } from '@emotion/react';
|
|
3
|
+
import Table from '@mui/material/Table';
|
|
4
|
+
import TableBody from '@mui/material/TableBody';
|
|
5
|
+
import TableCell from '@mui/material/TableCell';
|
|
6
|
+
import TableContainer from '@mui/material/TableContainer';
|
|
7
|
+
import TableHead from '@mui/material/TableHead';
|
|
8
|
+
import TableRow from '@mui/material/TableRow';
|
|
9
|
+
import { flexRender, getCoreRowModel, getPaginationRowModel, getSortedRowModel, useReactTable, } from '@tanstack/react-table';
|
|
10
|
+
import cx from 'classnames';
|
|
11
|
+
import AppPagination from '../AppPagination';
|
|
12
|
+
import { tableTheme } from './AppTableTheme';
|
|
13
|
+
import './styles.scss';
|
|
14
14
|
export default function AppTable({ columns, data, pagination, setPagination, sorting, setSorting, className, onClickRow, onMouseEnter, onMouseLeave, hiddenColumns, numItens, }) {
|
|
15
15
|
const { content, totalPages, totalElements } = data;
|
|
16
16
|
const columnVisibility = hiddenColumns?.reduce((acc, col) => {
|
|
@@ -31,7 +31,7 @@ export default function AppTable({ columns, data, pagination, setPagination, sor
|
|
|
31
31
|
getPaginationRowModel: getPaginationRowModel(),
|
|
32
32
|
getSortedRowModel: getSortedRowModel(),
|
|
33
33
|
onSortingChange: (updaterOrValue) => {
|
|
34
|
-
const newSorting = typeof updaterOrValue ===
|
|
34
|
+
const newSorting = typeof updaterOrValue === 'function'
|
|
35
35
|
? updaterOrValue(sorting)
|
|
36
36
|
: updaterOrValue;
|
|
37
37
|
if (newSorting &&
|
|
@@ -41,8 +41,8 @@ export default function AppTable({ columns, data, pagination, setPagination, sor
|
|
|
41
41
|
}
|
|
42
42
|
},
|
|
43
43
|
});
|
|
44
|
-
const tableClass = cx(
|
|
45
|
-
[className ||
|
|
44
|
+
const tableClass = cx('ds-table', {
|
|
45
|
+
[className || '']: className || '',
|
|
46
46
|
});
|
|
47
47
|
return (_jsx(ThemeProvider, { theme: tableTheme, children: _jsxs("div", { className: tableClass, children: [_jsx(TableContainer, { children: _jsxs(Table, { children: [_jsx(TableHead, { children: table.getHeaderGroups().map((headerGroup) => (_jsx(TableRow, { children: headerGroup.headers.map((header) => {
|
|
48
48
|
const toggleSortingHandler = header.column.getToggleSortingHandler();
|
|
@@ -51,12 +51,12 @@ export default function AppTable({ columns, data, pagination, setPagination, sor
|
|
|
51
51
|
toggleSortingHandler(event);
|
|
52
52
|
}
|
|
53
53
|
}, style: {
|
|
54
|
-
cursor:
|
|
54
|
+
cursor: 'pointer',
|
|
55
55
|
width: `${header.column.columnDef.size}%`,
|
|
56
56
|
}, children: [flexRender(header.column.columnDef.header, header.getContext()), header.column.getIsSorted()
|
|
57
|
-
? header.column.getIsSorted() ===
|
|
58
|
-
?
|
|
59
|
-
:
|
|
57
|
+
? header.column.getIsSorted() === 'desc'
|
|
58
|
+
? ' 🔽'
|
|
59
|
+
: ' 🔼'
|
|
60
60
|
: null] }, header.id));
|
|
61
|
-
}) }, headerGroup.id))) }), _jsx(TableBody, { children: table.getRowModel().rows.map((row) => (_jsx(TableRow, { onMouseEnter: () => onMouseEnter && onMouseEnter(row), onMouseLeave: () => onMouseLeave && onMouseLeave(row), children: row.getVisibleCells().map((cell) => (_jsx(TableCell, { onClick: () => onClickRow && onClickRow(row.original, cell.column), className: cell.id.includes(
|
|
61
|
+
}) }, headerGroup.id))) }), _jsx(TableBody, { children: table.getRowModel().rows.map((row) => (_jsx(TableRow, { onMouseEnter: () => onMouseEnter && onMouseEnter(row), onMouseLeave: () => onMouseLeave && onMouseLeave(row), children: row.getVisibleCells().map((cell) => (_jsx(TableCell, { onClick: () => onClickRow && onClickRow(row.original, cell.column), className: cell.id.includes('__') ? cell.id.split('__')[1] : '', children: flexRender(cell.column.columnDef.cell, cell.getContext()) }, cell.id))) }, row.id))) })] }) }), _jsx(AppPagination, { totalElements: totalElements, pagination: pagination, setPagination: setPagination, numItens: numItens })] }) }));
|
|
62
62
|
}
|