tycho-components 0.0.16 → 0.0.17-SNAPSHOT-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 +7 -15
- package/dist/AppPagination/AppPagination.js +18 -63
- package/dist/AppPagination/styles.scss +65 -0
- package/dist/AppPlaceholder/style.scss +1 -1
- package/dist/AppTable/AppListTable.d.ts +13 -0
- package/dist/AppTable/AppListTable.js +27 -0
- package/dist/AppTable/AppTable.d.ts +16 -0
- package/dist/AppTable/AppTable.js +69 -0
- package/dist/AppTable/AppTableTheme.d.ts +1 -0
- package/dist/AppTable/AppTableTheme.js +45 -0
- package/dist/AppTable/AppTableUtils.d.ts +8 -0
- package/dist/AppTable/AppTableUtils.js +24 -0
- package/dist/AppTable/index.d.ts +2 -0
- package/dist/AppTable/index.js +2 -0
- package/dist/AppTable/styles.scss +41 -0
- package/dist/AppTable/types/AppPage.d.ts +24 -0
- package/dist/AppTable/types/AppPage.js +17 -0
- package/dist/AppTable/types/AppPageable.d.ts +21 -0
- package/dist/AppTable/types/AppPageable.js +26 -0
- package/dist/configs/Localization.d.ts +6 -0
- package/dist/configs/localization/CommonTexts.d.ts +9 -0
- package/dist/configs/localization/CommonTexts.js +10 -1
- package/dist/index.d.ts +5 -0
- package/dist/index.js +3 -0
- package/package.json +3 -2
- package/dist/AppPagination/style.scss +0 -59
|
@@ -1,17 +1,9 @@
|
|
|
1
|
-
import '
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
nextPage: () => void;
|
|
8
|
-
pageIndex: number;
|
|
9
|
-
pageOptions: number[];
|
|
10
|
-
setPageSize: (p: number) => void;
|
|
11
|
-
pageSize: number;
|
|
12
|
-
multiple?: number;
|
|
13
|
-
total: number;
|
|
14
|
-
hideTotal?: boolean;
|
|
1
|
+
import { PaginationState } from '@tanstack/react-table';
|
|
2
|
+
import './styles.scss';
|
|
3
|
+
type Props<TData> = {
|
|
4
|
+
totalElements: number;
|
|
5
|
+
pagination: PaginationState;
|
|
6
|
+
setPagination: (p: PaginationState) => void;
|
|
15
7
|
};
|
|
16
|
-
export default function AppPagination({
|
|
8
|
+
export default function AppPagination<TData>({ totalElements, pagination, setPagination, }: Props<TData>): import("react/jsx-runtime").JSX.Element;
|
|
17
9
|
export {};
|
|
@@ -1,68 +1,23 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
import './style.scss';
|
|
8
|
-
const minPages = 5;
|
|
9
|
-
export default function AppPagination({ gotoPage, canPreviousPage, canNextPage, previousPage, nextPage, pageIndex, pageOptions, setPageSize, pageSize, multiple, total, hideTotal, }) {
|
|
2
|
+
import { MenuItem, Select } from '@mui/material';
|
|
3
|
+
import { Trans, useTranslation } from 'react-i18next';
|
|
4
|
+
import { IconButton } from 'tycho-storybook';
|
|
5
|
+
import './styles.scss';
|
|
6
|
+
export default function AppPagination({ totalElements, pagination, setPagination, }) {
|
|
10
7
|
const { t } = useTranslation('common');
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
value: (i + 1) * multiple,
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
return arrayPagination;
|
|
8
|
+
const numPages = Math.ceil(totalElements / pagination.pageSize);
|
|
9
|
+
const currentPage = pagination.pageIndex + 1;
|
|
10
|
+
const getFirstElementNumber = () => pagination.pageIndex * pagination.pageSize + 1;
|
|
11
|
+
const getLastElementNumber = () => Math.min((pagination.pageIndex + 1) * pagination.pageSize, totalElements);
|
|
12
|
+
const setPageSize = (p) => {
|
|
13
|
+
setPagination({ ...pagination, pageSize: p });
|
|
21
14
|
};
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
const renderButton = (pageOption) => {
|
|
25
|
-
if (pageOption === undefined)
|
|
26
|
-
return null;
|
|
27
|
-
if (pageOption === -1 || pageOption === -2) {
|
|
28
|
-
return (_jsx("button", { type: "button", className: "page-ellipsis", children: "..." }, pageOption.valueOf()));
|
|
29
|
-
}
|
|
30
|
-
return (_jsx("button", { type: "button", onClick: () => {
|
|
31
|
-
gotoPage(pageOption);
|
|
32
|
-
}, className: alterColorPageSelected(pageOption), children: pageOption + 1 }, pageOption.valueOf()));
|
|
15
|
+
const setPageIndex = (p) => {
|
|
16
|
+
setPagination({ ...pagination, pageIndex: p });
|
|
33
17
|
};
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
if (pageIndex > 1)
|
|
40
|
-
arr.push(-1);
|
|
41
|
-
if (pageIndex >= pageOptions.length - 3) {
|
|
42
|
-
for (let i = pageOptions.length - 3; i < pageOptions.length; i += 1) {
|
|
43
|
-
if (i !== pageOptions.length - 1) {
|
|
44
|
-
arr.push(i);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
else {
|
|
49
|
-
for (let i = 0; i < 3; i += 1) {
|
|
50
|
-
if (pageIndex + i !== 0) {
|
|
51
|
-
arr.push(pageIndex + i);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
// check for need of ... and add last
|
|
56
|
-
if (pageIndex < pageOptions.length - 3)
|
|
57
|
-
arr.push(-2);
|
|
58
|
-
arr.push(pageOptions[pageOptions.length - 1]);
|
|
59
|
-
setButtons(arr);
|
|
60
|
-
}
|
|
61
|
-
else {
|
|
62
|
-
setButtons(pageOptions.slice());
|
|
63
|
-
}
|
|
64
|
-
}, [pageIndex]);
|
|
65
|
-
return (_jsxs("div", { className: "pagination-container", children: [_jsxs("div", { className: "select", children: [multiple && (_jsx(AppSelect, { options: getPageSizeOptions(), value: getPageSizeOptions().find((p) => p.value === pageSize), emptyValue: false, onChange: (e) => {
|
|
66
|
-
setPageSize(e);
|
|
67
|
-
} })), !hideTotal && (_jsxs("span", { className: "total", children: [t('pagination.label.total'), ": ", total] }))] }), _jsxs("div", { className: "pages", children: [_jsx("button", { type: "button", onClick: () => previousPage(), disabled: !canPreviousPage, className: "page-item-chevron", children: _jsx(FontAwesomeIcon, { icon: faChevronLeft }) }), buttons?.map((pageOption, idx) => renderButton(pageOption)), _jsx("button", { type: "button", onClick: () => nextPage(), disabled: !canNextPage, className: "page-item-chevron", children: _jsx(FontAwesomeIcon, { icon: faChevronRight }) })] })] }));
|
|
18
|
+
return (_jsxs("div", { className: "app-table-pagination", children: [_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: {
|
|
19
|
+
first: getFirstElementNumber(),
|
|
20
|
+
last: getLastElementNumber(),
|
|
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" })] })] }));
|
|
68
23
|
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
.app-table-pagination {
|
|
2
|
+
display: flex;
|
|
3
|
+
height: 56px;
|
|
4
|
+
border-top: none;
|
|
5
|
+
justify-content: right;
|
|
6
|
+
|
|
7
|
+
.itens-page {
|
|
8
|
+
display: flex;
|
|
9
|
+
align-items: center;
|
|
10
|
+
padding: var(--spacing-150) var(--spacing-100);
|
|
11
|
+
|
|
12
|
+
> span {
|
|
13
|
+
margin-right: 16px;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.itens-total {
|
|
18
|
+
display: flex;
|
|
19
|
+
align-items: center;
|
|
20
|
+
margin-right: auto;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.pages-total {
|
|
24
|
+
display: flex;
|
|
25
|
+
align-items: center;
|
|
26
|
+
> span {
|
|
27
|
+
padding: var(--spacing-100);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.pages-navigation {
|
|
32
|
+
display: flex;
|
|
33
|
+
align-items: center;
|
|
34
|
+
padding: var(--spacing-100);
|
|
35
|
+
gap: 4px;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.MuiInputBase-root {
|
|
39
|
+
border-radius: 0px;
|
|
40
|
+
font-family: 'Work Sans' !important;
|
|
41
|
+
|
|
42
|
+
> .MuiSelect-select {
|
|
43
|
+
display: flex;
|
|
44
|
+
align-items: center;
|
|
45
|
+
padding: var(--spacing-0) var(--spacing-100);
|
|
46
|
+
height: 40px;
|
|
47
|
+
border-radius: 0px;
|
|
48
|
+
background-color: var(--button-secondary-default);
|
|
49
|
+
@include button-small;
|
|
50
|
+
color: var(--text-on-color-dark);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
> .MuiSelect-icon {
|
|
54
|
+
position: relative;
|
|
55
|
+
width: 20px;
|
|
56
|
+
height: 40px;
|
|
57
|
+
background-color: var(--button-secondary-default);
|
|
58
|
+
margin-left: 8px;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
> .MuiOutlinedInput-notchedOutline {
|
|
62
|
+
display: none;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ColumnDef } from '@tanstack/react-table';
|
|
2
|
+
import './styles.scss';
|
|
3
|
+
type Props = {
|
|
4
|
+
columns: ColumnDef<any, any>[];
|
|
5
|
+
data: any[];
|
|
6
|
+
className?: string;
|
|
7
|
+
onClickRow?: (row: any) => void;
|
|
8
|
+
onMouseEnter?: (row: any) => void;
|
|
9
|
+
onMouseLeave?: (row: any) => void;
|
|
10
|
+
hiddenColumns?: string[];
|
|
11
|
+
};
|
|
12
|
+
export default function AppListTable({ columns, data, className, onClickRow, onMouseEnter, onMouseLeave, hiddenColumns, }: Props): import("react/jsx-runtime").JSX.Element;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Paper, TableBody, TableCell, TableContainer, TableHead, TableRow, } from '@mui/material';
|
|
3
|
+
import { flexRender, getCoreRowModel, useReactTable, } from '@tanstack/react-table';
|
|
4
|
+
import { Table, ThemeProvider } from 'react-bootstrap';
|
|
5
|
+
import { tableTheme } from './AppTableTheme';
|
|
6
|
+
import './styles.scss';
|
|
7
|
+
export default function AppListTable({ columns, data, className = '', onClickRow, onMouseEnter, onMouseLeave, hiddenColumns, }) {
|
|
8
|
+
const columnVisibility = hiddenColumns?.reduce((acc, key) => {
|
|
9
|
+
acc[key] = false;
|
|
10
|
+
return acc;
|
|
11
|
+
}, {});
|
|
12
|
+
const table = useReactTable({
|
|
13
|
+
data,
|
|
14
|
+
columns,
|
|
15
|
+
state: {
|
|
16
|
+
columnVisibility,
|
|
17
|
+
},
|
|
18
|
+
getCoreRowModel: getCoreRowModel(),
|
|
19
|
+
});
|
|
20
|
+
const handleClickRow = (row) => {
|
|
21
|
+
if (onClickRow)
|
|
22
|
+
onClickRow(row.original);
|
|
23
|
+
};
|
|
24
|
+
return (_jsx(ThemeProvider, { theme: tableTheme, children: _jsx(Paper, { className: `ds-table ${className}`, children: _jsx(TableContainer, { children: _jsxs(Table, { children: [_jsx(TableHead, { children: table.getHeaderGroups().map((headerGroup) => (_jsx(TableRow, { children: headerGroup.headers.map((header) => (_jsx(TableCell, { style: { width: header.getSize() }, children: header.isPlaceholder
|
|
25
|
+
? null
|
|
26
|
+
: flexRender(header.column.columnDef.header, header.getContext()) }, header.id))) }, headerGroup.id))) }), _jsx(TableBody, { children: table.getRowModel().rows.map((row) => (_jsx(TableRow, { onClick: () => handleClickRow(row), onMouseEnter: () => onMouseEnter?.(row), onMouseLeave: () => onMouseLeave?.(row), children: row.getVisibleCells().map((cell) => (_jsx(TableCell, { children: flexRender(cell.column.columnDef.cell, cell.getContext()) }, cell.id))) }, row.id))) })] }) }) }) }));
|
|
27
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import './styles.scss';
|
|
2
|
+
import { AppPage } from './types/AppPage';
|
|
3
|
+
import { AppPageable } from './types/AppPageable';
|
|
4
|
+
type Props = {
|
|
5
|
+
columns: any;
|
|
6
|
+
data: AppPage<any>;
|
|
7
|
+
pageable: AppPageable;
|
|
8
|
+
setPageable: (p: AppPageable) => void;
|
|
9
|
+
className?: string;
|
|
10
|
+
onClickRow?: (row: any, col: any) => void;
|
|
11
|
+
onMouseEnter?: (row: any) => void;
|
|
12
|
+
onMouseLeave?: (row: any) => void;
|
|
13
|
+
hiddenColumns?: string[];
|
|
14
|
+
};
|
|
15
|
+
export default function AppTable({ columns, data, className, onClickRow, onMouseEnter, onMouseLeave, pageable, setPageable, hiddenColumns, }: Props): import("react/jsx-runtime").JSX.Element;
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { ThemeProvider } from '@emotion/react';
|
|
3
|
+
import Paper from '@mui/material/Paper';
|
|
4
|
+
import Table from '@mui/material/Table';
|
|
5
|
+
import TableBody from '@mui/material/TableBody';
|
|
6
|
+
import TableCell from '@mui/material/TableCell';
|
|
7
|
+
import TableContainer from '@mui/material/TableContainer';
|
|
8
|
+
import TableHead from '@mui/material/TableHead';
|
|
9
|
+
import TableRow from '@mui/material/TableRow';
|
|
10
|
+
import { flexRender, getCoreRowModel, getPaginationRowModel, getSortedRowModel, useReactTable, } from '@tanstack/react-table';
|
|
11
|
+
import { useEffect, useState } from 'react';
|
|
12
|
+
import AppPagination from '../AppPagination';
|
|
13
|
+
import { tableTheme } from './AppTableTheme';
|
|
14
|
+
import './styles.scss';
|
|
15
|
+
import DateUtils from '../functions/DateUtils';
|
|
16
|
+
export default function AppTable({ columns, data, className, onClickRow, onMouseEnter, onMouseLeave, pageable, setPageable, hiddenColumns, }) {
|
|
17
|
+
const { content, totalPages, totalElements } = data;
|
|
18
|
+
const [pagination, setPagination] = useState({
|
|
19
|
+
pageIndex: pageable.page,
|
|
20
|
+
pageSize: pageable.size,
|
|
21
|
+
});
|
|
22
|
+
const columnVisibility = hiddenColumns?.reduce((acc, col) => {
|
|
23
|
+
acc[col] = false;
|
|
24
|
+
return acc;
|
|
25
|
+
}, {});
|
|
26
|
+
const table = useReactTable({
|
|
27
|
+
data: content || [],
|
|
28
|
+
columns,
|
|
29
|
+
pageCount: totalPages,
|
|
30
|
+
state: {
|
|
31
|
+
pagination: { pageIndex: pageable.page, pageSize: pageable.size },
|
|
32
|
+
sorting: pageable.sort || [],
|
|
33
|
+
columnVisibility,
|
|
34
|
+
},
|
|
35
|
+
manualPagination: true,
|
|
36
|
+
manualSorting: true,
|
|
37
|
+
getCoreRowModel: getCoreRowModel(),
|
|
38
|
+
getPaginationRowModel: getPaginationRowModel(),
|
|
39
|
+
getSortedRowModel: getSortedRowModel(),
|
|
40
|
+
});
|
|
41
|
+
useEffect(() => {
|
|
42
|
+
const sort = table.getState().sorting.length > 0
|
|
43
|
+
? table.getState().sorting
|
|
44
|
+
: undefined;
|
|
45
|
+
if (pageable.size !== pagination.pageSize) {
|
|
46
|
+
setPagination({ pageSize: pagination.pageSize, pageIndex: 0 });
|
|
47
|
+
setPageable({
|
|
48
|
+
size: pagination.pageSize,
|
|
49
|
+
page: 0,
|
|
50
|
+
sort,
|
|
51
|
+
seed: DateUtils.millis(),
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
else if (pageable.page !== pagination.pageIndex ||
|
|
55
|
+
pageable.sort !== sort) {
|
|
56
|
+
setPageable({
|
|
57
|
+
size: pagination.pageSize,
|
|
58
|
+
page: pagination.pageIndex,
|
|
59
|
+
sort,
|
|
60
|
+
seed: DateUtils.millis(),
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
}, [pagination, table.getState().sorting]);
|
|
64
|
+
return (_jsx(ThemeProvider, { theme: tableTheme, children: _jsxs(Paper, { className: `ds-table ${className}`, children: [_jsx(TableContainer, { children: _jsxs(Table, { children: [_jsx(TableHead, { children: table.getHeaderGroups().map((headerGroup) => (_jsx(TableRow, { children: headerGroup.headers.map((header) => (_jsxs(TableCell, { onClick: header.column.getToggleSortingHandler(), style: { width: `${header.column.columnDef.size}%` }, children: [flexRender(header.column.columnDef.header, header.getContext()), header.column.getIsSorted()
|
|
65
|
+
? header.column.getIsSorted() === 'desc'
|
|
66
|
+
? ' 🔽'
|
|
67
|
+
: ' 🔼'
|
|
68
|
+
: null] }, header.id))) }, 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 })] }) }));
|
|
69
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const tableTheme: (outerTheme: any) => import("@mui/material/styles").Theme;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { createTheme } from '@mui/material/styles';
|
|
2
|
+
export const tableTheme = (outerTheme) => createTheme({
|
|
3
|
+
...outerTheme,
|
|
4
|
+
components: {
|
|
5
|
+
MuiPaper: {
|
|
6
|
+
styleOverrides: {
|
|
7
|
+
root: {
|
|
8
|
+
borderRadius: '4px',
|
|
9
|
+
overflow: 'hidden',
|
|
10
|
+
boxShadow: 'none',
|
|
11
|
+
},
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
MuiTable: {
|
|
15
|
+
styleOverrides: {
|
|
16
|
+
root: {
|
|
17
|
+
minWidth: 650,
|
|
18
|
+
border: 0,
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
MuiTableCell: {
|
|
23
|
+
styleOverrides: {
|
|
24
|
+
head: {
|
|
25
|
+
backgroundColor: '#F9FAFB',
|
|
26
|
+
fontWeight: 'bold',
|
|
27
|
+
padding: '4px 0px 4px 12px',
|
|
28
|
+
height: '48px',
|
|
29
|
+
},
|
|
30
|
+
body: {
|
|
31
|
+
cursor: 'pointer',
|
|
32
|
+
padding: '4px 0px 4px 12px',
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
MuiTablePagination: {
|
|
37
|
+
styleOverrides: {
|
|
38
|
+
root: {
|
|
39
|
+
display: 'flex',
|
|
40
|
+
justifyContent: 'flex-end',
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
});
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
declare const AppTableUtils: {
|
|
2
|
+
limitCharacters: (attr: string, props: any, max: number) => any;
|
|
3
|
+
addCenteredHeader: (header: string) => import("react/jsx-runtime").JSX.Element;
|
|
4
|
+
addCenteredCell: (attr: string, props: any) => import("react/jsx-runtime").JSX.Element;
|
|
5
|
+
addEnumBadge: (attr: string, props: any, append: string, t: any) => import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
addSimpleCell: (value: any) => import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
};
|
|
8
|
+
export default AppTableUtils;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
const limitCharacters = (attr, props, max) => {
|
|
3
|
+
const value = props.row.original[attr];
|
|
4
|
+
if (!value)
|
|
5
|
+
return '';
|
|
6
|
+
return value.length > max ? `${value.substr(0, max)}...` : value;
|
|
7
|
+
};
|
|
8
|
+
const addCenteredHeader = (header) => (_jsx("div", { className: "text-center", children: header }));
|
|
9
|
+
const addCenteredCell = (attr, props) => (_jsx("div", { className: "text-center", children: props.row.original[attr] }));
|
|
10
|
+
const addEnumBadge = (attr, props, append, t) => {
|
|
11
|
+
const value = props[attr].toLowerCase();
|
|
12
|
+
return (_jsx("span", { className: `badge badge-enum ${attr}-${value}`, children: t(`${append}${value}`) }));
|
|
13
|
+
};
|
|
14
|
+
const addSimpleCell = (value) => {
|
|
15
|
+
return _jsx("div", { className: "text-center", children: value });
|
|
16
|
+
};
|
|
17
|
+
const AppTableUtils = {
|
|
18
|
+
limitCharacters,
|
|
19
|
+
addCenteredHeader,
|
|
20
|
+
addCenteredCell,
|
|
21
|
+
addEnumBadge,
|
|
22
|
+
addSimpleCell,
|
|
23
|
+
};
|
|
24
|
+
export default AppTableUtils;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
.ds-table {
|
|
2
|
+
.MuiTableRow-root {
|
|
3
|
+
height: 56px;
|
|
4
|
+
|
|
5
|
+
&:hover {
|
|
6
|
+
background-color: var(--layer-hover-1);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
&.MuiTableRow-head {
|
|
10
|
+
height: 48px;
|
|
11
|
+
|
|
12
|
+
.MuiTableCell-head {
|
|
13
|
+
@include tag-medium-2;
|
|
14
|
+
color: var(--text-primary);
|
|
15
|
+
font-family: 'Lora';
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.MuiTableCell-body {
|
|
20
|
+
@include label-medium-1;
|
|
21
|
+
color: var(--text-primary);
|
|
22
|
+
font-family: 'Work Sans';
|
|
23
|
+
cursor: pointer;
|
|
24
|
+
|
|
25
|
+
&.actions-button {
|
|
26
|
+
padding: 0px;
|
|
27
|
+
text-align: center;
|
|
28
|
+
|
|
29
|
+
> .ds-button {
|
|
30
|
+
display: inline-block;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.text-center {
|
|
36
|
+
text-align: center;
|
|
37
|
+
display: flex;
|
|
38
|
+
justify-content: center;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export type AppPage<Type> = {
|
|
2
|
+
content: Type[];
|
|
3
|
+
totalElements: number;
|
|
4
|
+
totalPages: number;
|
|
5
|
+
number: number;
|
|
6
|
+
size: number;
|
|
7
|
+
seed: number;
|
|
8
|
+
};
|
|
9
|
+
export declare const EMPTY_PAGE: {
|
|
10
|
+
content: never[];
|
|
11
|
+
totalElements: number;
|
|
12
|
+
totalPages: number;
|
|
13
|
+
number: number;
|
|
14
|
+
size: number;
|
|
15
|
+
seed: number;
|
|
16
|
+
};
|
|
17
|
+
export declare const EMPTY_GRID_PAGE: {
|
|
18
|
+
content: never[];
|
|
19
|
+
totalElements: number;
|
|
20
|
+
totalPages: number;
|
|
21
|
+
number: number;
|
|
22
|
+
size: number;
|
|
23
|
+
seed: number;
|
|
24
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { EMPTY_GRID_PAGEABLE, EMPTY_PAGEABLE } from './AppPageable';
|
|
2
|
+
export const EMPTY_PAGE = {
|
|
3
|
+
content: [],
|
|
4
|
+
totalElements: 0,
|
|
5
|
+
totalPages: 0,
|
|
6
|
+
number: 0,
|
|
7
|
+
size: EMPTY_PAGEABLE.size,
|
|
8
|
+
seed: 0,
|
|
9
|
+
};
|
|
10
|
+
export const EMPTY_GRID_PAGE = {
|
|
11
|
+
content: [],
|
|
12
|
+
totalElements: 0,
|
|
13
|
+
totalPages: 0,
|
|
14
|
+
number: 0,
|
|
15
|
+
size: EMPTY_GRID_PAGEABLE.size,
|
|
16
|
+
seed: 0,
|
|
17
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { SortingState } from '@tanstack/react-table';
|
|
2
|
+
export type AppPageable = {
|
|
3
|
+
page: number;
|
|
4
|
+
size: number;
|
|
5
|
+
seed?: number;
|
|
6
|
+
sort?: SortingState;
|
|
7
|
+
filter?: any;
|
|
8
|
+
};
|
|
9
|
+
export declare const EMPTY_PAGEABLE: {
|
|
10
|
+
page: number;
|
|
11
|
+
size: number;
|
|
12
|
+
seed: number;
|
|
13
|
+
filter: {};
|
|
14
|
+
};
|
|
15
|
+
export declare const EMPTY_GRID_PAGEABLE: {
|
|
16
|
+
page: number;
|
|
17
|
+
size: number;
|
|
18
|
+
seed: number;
|
|
19
|
+
filter: {};
|
|
20
|
+
};
|
|
21
|
+
export declare function convertPageable(pageable: AppPageable): any;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export const EMPTY_PAGEABLE = {
|
|
2
|
+
page: 0,
|
|
3
|
+
size: 10,
|
|
4
|
+
seed: 1,
|
|
5
|
+
filter: {},
|
|
6
|
+
};
|
|
7
|
+
export const EMPTY_GRID_PAGEABLE = {
|
|
8
|
+
page: 0,
|
|
9
|
+
size: 12,
|
|
10
|
+
seed: 1,
|
|
11
|
+
filter: {},
|
|
12
|
+
};
|
|
13
|
+
export function convertPageable(pageable) {
|
|
14
|
+
const request = {
|
|
15
|
+
page: pageable.page,
|
|
16
|
+
size: pageable.size,
|
|
17
|
+
};
|
|
18
|
+
if (pageable.sort) {
|
|
19
|
+
const sort = [];
|
|
20
|
+
pageable.sort.forEach((item, index) => {
|
|
21
|
+
sort.push(`${item.id},${item.desc ? 'desc' : 'asc'}`);
|
|
22
|
+
});
|
|
23
|
+
request.sort = sort;
|
|
24
|
+
}
|
|
25
|
+
return request;
|
|
26
|
+
}
|
|
@@ -19,6 +19,9 @@ export declare const commonResources: {
|
|
|
19
19
|
'user.status.visitor': string;
|
|
20
20
|
'update.success': string;
|
|
21
21
|
'internal.server.error': string;
|
|
22
|
+
'table.label.rows-page': string;
|
|
23
|
+
'table.label.pages': string;
|
|
24
|
+
'table.label.items': string;
|
|
22
25
|
};
|
|
23
26
|
participants: {
|
|
24
27
|
'label.title': string;
|
|
@@ -150,6 +153,9 @@ export declare const commonResources: {
|
|
|
150
153
|
'user.status.visitor': string;
|
|
151
154
|
'update.success': string;
|
|
152
155
|
'internal.server.error': string;
|
|
156
|
+
'table.label.rows-page': string;
|
|
157
|
+
'table.label.pages': string;
|
|
158
|
+
'table.label.items': string;
|
|
153
159
|
};
|
|
154
160
|
participants: {
|
|
155
161
|
'label.title': string;
|
|
@@ -18,6 +18,9 @@ export declare const CommonTexts: {
|
|
|
18
18
|
'user.status.visitor': string;
|
|
19
19
|
'update.success': string;
|
|
20
20
|
'internal.server.error': string;
|
|
21
|
+
'table.label.rows-page': string;
|
|
22
|
+
'table.label.pages': string;
|
|
23
|
+
'table.label.items': string;
|
|
21
24
|
};
|
|
22
25
|
'pt-BR': {
|
|
23
26
|
'button.confirm': string;
|
|
@@ -38,6 +41,9 @@ export declare const CommonTexts: {
|
|
|
38
41
|
'user.status.visitor': string;
|
|
39
42
|
'update.success': string;
|
|
40
43
|
'internal.server.error': string;
|
|
44
|
+
'table.label.rows-page': string;
|
|
45
|
+
'table.label.pages': string;
|
|
46
|
+
'table.label.items': string;
|
|
41
47
|
};
|
|
42
48
|
it: {
|
|
43
49
|
'button.confirm': string;
|
|
@@ -58,5 +64,8 @@ export declare const CommonTexts: {
|
|
|
58
64
|
'user.status.visitor': string;
|
|
59
65
|
'update.success': string;
|
|
60
66
|
'internal.server.error': string;
|
|
67
|
+
'table.label.rows-page': string;
|
|
68
|
+
'table.label.pages': string;
|
|
69
|
+
'table.label.items': string;
|
|
61
70
|
};
|
|
62
71
|
};
|
|
@@ -4,7 +4,7 @@ export const CommonTexts = {
|
|
|
4
4
|
'button.cancel': 'Cancel',
|
|
5
5
|
'button.remove': 'Remove',
|
|
6
6
|
'select.empty': 'Select',
|
|
7
|
-
'pagination.label.showing': '
|
|
7
|
+
'pagination.label.showing': '',
|
|
8
8
|
'pagination.label.results': 'results per page',
|
|
9
9
|
'pagination.label.total': 'Total',
|
|
10
10
|
'generic.placeholder': 'Type here',
|
|
@@ -18,6 +18,9 @@ export const CommonTexts = {
|
|
|
18
18
|
'user.status.visitor': 'Visitor',
|
|
19
19
|
'update.success': 'saved!',
|
|
20
20
|
'internal.server.error': 'An unexpected error occurred. Contact the administrator.',
|
|
21
|
+
'table.label.rows-page': 'Items per page',
|
|
22
|
+
'table.label.pages': 'of {{value}} pages',
|
|
23
|
+
'table.label.items': '{{first}} - {{last}} of {{total}} items',
|
|
21
24
|
},
|
|
22
25
|
'pt-BR': {
|
|
23
26
|
'button.confirm': 'Confirmar',
|
|
@@ -38,6 +41,9 @@ export const CommonTexts = {
|
|
|
38
41
|
'user.status.visitor': 'Visitante',
|
|
39
42
|
'update.success': 'salvo!',
|
|
40
43
|
'internal.server.error': 'Ocorreu um erro inesperado. Entre em contato com o administrador.',
|
|
44
|
+
'table.label.rows-page': 'Itens por página',
|
|
45
|
+
'table.label.pages': 'de {{value}} páginas',
|
|
46
|
+
'table.label.items': '{{first}} - {{last}} de {{total}} itens',
|
|
41
47
|
},
|
|
42
48
|
it: {
|
|
43
49
|
'button.confirm': 'Conferma',
|
|
@@ -58,5 +64,8 @@ export const CommonTexts = {
|
|
|
58
64
|
'user.status.visitor': 'Visitatore',
|
|
59
65
|
'update.success': 'salvato!',
|
|
60
66
|
'internal.server.error': "Si è verificato un errore inaspettato. Contatta l'amministratore.",
|
|
67
|
+
'table.label.rows-page': 'Elementi per pagina',
|
|
68
|
+
'table.label.pages': 'di {{value}} pagine',
|
|
69
|
+
'table.label.items': '{{first}} - {{last}} di {{total}} elementi',
|
|
61
70
|
},
|
|
62
71
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -10,6 +10,8 @@ export { default as AppPagination } from './AppPagination';
|
|
|
10
10
|
export { default as AppPicture } from './AppPicture';
|
|
11
11
|
export { default as AppPlaceholder } from './AppPlaceholder';
|
|
12
12
|
export { default as AppSelect } from './AppSelect';
|
|
13
|
+
export { default as AppTable } from './AppTable';
|
|
14
|
+
export { default as AppListTable } from './AppTable';
|
|
13
15
|
export { default as AppToast } from './AppToast';
|
|
14
16
|
export { default as CommentComponent } from './Comments';
|
|
15
17
|
export { default as Header } from './Header';
|
|
@@ -33,6 +35,8 @@ export { default as ImageUtils } from './functions/ImageUtils';
|
|
|
33
35
|
export { default as SecurityUtils } from './functions/SecurityUtils';
|
|
34
36
|
export { default as UsabilityUtils } from './functions/UsabilityUtils';
|
|
35
37
|
export type { AppEditableField } from './AppEditable/AppEditableField';
|
|
38
|
+
export type { AppPage } from './AppTable/types/AppPage';
|
|
39
|
+
export type { AppPageable } from './AppTable/types/AppPageable';
|
|
36
40
|
export type { Comment } from './Comments/types/Comment';
|
|
37
41
|
export type { Corpus } from './configs/Corpus';
|
|
38
42
|
export type { CorpusImage } from './configs/CorpusImage';
|
|
@@ -44,3 +48,4 @@ export type { KeyboardLayout } from './VirtualKeyboard/KeyboardCustomLayout';
|
|
|
44
48
|
export type { UploadedFile } from './AppDropzone/UploadedFile';
|
|
45
49
|
export type { User } from './configs/User';
|
|
46
50
|
export type { UserStatus } from './configs/User';
|
|
51
|
+
export { convertPageable, EMPTY_PAGEABLE, EMPTY_GRID_PAGEABLE, } from './AppTable/types/AppPageable';
|
package/dist/index.js
CHANGED
|
@@ -10,6 +10,8 @@ export { default as AppPagination } from './AppPagination';
|
|
|
10
10
|
export { default as AppPicture } from './AppPicture';
|
|
11
11
|
export { default as AppPlaceholder } from './AppPlaceholder';
|
|
12
12
|
export { default as AppSelect } from './AppSelect';
|
|
13
|
+
export { default as AppTable } from './AppTable';
|
|
14
|
+
export { default as AppListTable } from './AppTable';
|
|
13
15
|
export { default as AppToast } from './AppToast';
|
|
14
16
|
export { default as CommentComponent } from './Comments';
|
|
15
17
|
export { default as Header } from './Header';
|
|
@@ -32,3 +34,4 @@ export { default as FormUtils } from './functions/FormUtils';
|
|
|
32
34
|
export { default as ImageUtils } from './functions/ImageUtils';
|
|
33
35
|
export { default as SecurityUtils } from './functions/SecurityUtils';
|
|
34
36
|
export { default as UsabilityUtils } from './functions/UsabilityUtils';
|
|
37
|
+
export { convertPageable, EMPTY_PAGEABLE, EMPTY_GRID_PAGEABLE, } from './AppTable/types/AppPageable';
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tycho-components",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.17-SNAPSHOT-1",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"exports": {
|
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
"@fortawesome/free-regular-svg-icons": "^6.4.2",
|
|
21
21
|
"@fortawesome/free-solid-svg-icons": "^6.4.2",
|
|
22
22
|
"@fortawesome/react-fontawesome": "^0.2.0",
|
|
23
|
+
"@tanstack/react-table": "^8.20.6",
|
|
23
24
|
"axios": "^1.7.7",
|
|
24
25
|
"classnames": "^2.5.1",
|
|
25
26
|
"date-fns": "^2.29.1",
|
|
@@ -48,7 +49,7 @@
|
|
|
48
49
|
"react-hook-form": "^7.45.2",
|
|
49
50
|
"react-i18next": "^13.0.2",
|
|
50
51
|
"react-router-dom": "^6.14.2",
|
|
51
|
-
"tycho-storybook": "0.1.7",
|
|
52
|
+
"tycho-storybook": "0.1.7-r2",
|
|
52
53
|
"yup": "^1.2.0"
|
|
53
54
|
},
|
|
54
55
|
"devDependencies": {
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
.pagination-container {
|
|
2
|
-
display: flex;
|
|
3
|
-
align-items: center;
|
|
4
|
-
|
|
5
|
-
> .pages {
|
|
6
|
-
display: flex;
|
|
7
|
-
margin-left: auto;
|
|
8
|
-
|
|
9
|
-
.page-item,
|
|
10
|
-
.page-item-chevron,
|
|
11
|
-
.page-ellipsis {
|
|
12
|
-
height: 30px;
|
|
13
|
-
width: 35px;
|
|
14
|
-
margin-left: 4px;
|
|
15
|
-
border-radius: var(--radius-100);
|
|
16
|
-
background-color: var(--background-default);
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
.page-item-chevron {
|
|
20
|
-
border: none;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
.page-ellipsis {
|
|
24
|
-
cursor: default;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
.page-item,
|
|
28
|
-
.page-ellipsis {
|
|
29
|
-
@include button-small;
|
|
30
|
-
border: 1px solid var(--border-subtle-3);
|
|
31
|
-
background-color: var(--button-secondary-default);
|
|
32
|
-
color: var(--text-secondary);
|
|
33
|
-
align-items: center;
|
|
34
|
-
|
|
35
|
-
&.selected {
|
|
36
|
-
background: var(--button-primary-default);
|
|
37
|
-
color: var(--text-on-color-light);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
&:hover {
|
|
41
|
-
background: var(--button-secondary-hover);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
.select {
|
|
47
|
-
display: flex;
|
|
48
|
-
align-items: center;
|
|
49
|
-
gap: 16px;
|
|
50
|
-
|
|
51
|
-
.form-select {
|
|
52
|
-
width: auto;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
.total {
|
|
56
|
-
@include label-medium-2;
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
}
|