tycho-components 0.9.3 → 0.9.5

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.
@@ -1,6 +1,5 @@
1
1
  .app-table-pagination {
2
2
  display: flex;
3
- border-top: none;
4
3
  justify-content: right;
5
4
  padding: var(--spacing-150) var(--spacing-100);
6
5
  border-top: 1px solid var(--border-subtle-2);
@@ -35,7 +34,7 @@
35
34
 
36
35
  .MuiInputBase-root {
37
36
  border-radius: 0px;
38
- font-family: 'Work Sans' !important;
37
+ font-family: "Work Sans" !important;
39
38
 
40
39
  > .MuiSelect-select {
41
40
  display: flex;
@@ -1,6 +1,6 @@
1
- import { PaginationState, SortingState } from '@tanstack/react-table';
2
- import './styles.scss';
3
- import { AppPage } from './types/AppPage';
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>;
@@ -13,6 +13,7 @@ type Props = {
13
13
  onMouseEnter?: (row: any) => void;
14
14
  onMouseLeave?: (row: any) => void;
15
15
  hiddenColumns?: string[];
16
+ numItens?: number[];
16
17
  };
17
- export default function AppTable({ columns, data, pagination, setPagination, sorting, setSorting, className, onClickRow, onMouseEnter, onMouseLeave, hiddenColumns, }: Props): import("react/jsx-runtime").JSX.Element;
18
+ export default function AppTable({ columns, data, pagination, setPagination, sorting, setSorting, className, onClickRow, onMouseEnter, onMouseLeave, hiddenColumns, numItens, }: Props): import("react/jsx-runtime").JSX.Element;
18
19
  export {};
@@ -1,17 +1,17 @@
1
1
  import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
2
- import cx from 'classnames';
3
- import { ThemeProvider } from '@emotion/react';
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 AppPagination from '../AppPagination';
12
- import { tableTheme } from './AppTableTheme';
13
- import './styles.scss';
14
- export default function AppTable({ columns, data, pagination, setPagination, sorting, setSorting, className, onClickRow, onMouseEnter, onMouseLeave, hiddenColumns, }) {
2
+ import cx from "classnames";
3
+ import { ThemeProvider } from "@emotion/react";
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 AppPagination from "../AppPagination";
12
+ import { tableTheme } from "./AppTableTheme";
13
+ import "./styles.scss";
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) => {
17
17
  acc[col] = false;
@@ -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 === 'function'
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('ds-table', {
45
- [className || '']: 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: 'pointer',
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() === 'desc'
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('__') ? cell.id.split('__')[1] : '', children: flexRender(cell.column.columnDef.cell, cell.getContext()) }, cell.id))) }, row.id))) })] }) }), _jsx(AppPagination, { totalElements: totalElements, pagination: pagination, setPagination: setPagination })] }) }));
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
  }
@@ -1,4 +1,4 @@
1
- import { TFunction } from 'i18next';
1
+ import { TFunction } from "i18next";
2
2
  type MessageDispatcher = {
3
3
  key: string;
4
4
  ns?: string;
@@ -1,6 +1,6 @@
1
- import { useContext } from 'react';
2
- import { message, silentLoading, toastLoading } from '../configs/store/actions';
3
- import CommonContext from './CommonContext';
1
+ import { useContext } from "react";
2
+ import { message, silentLoading, toastLoading } from "../configs/store/actions";
3
+ import CommonContext from "./CommonContext";
4
4
  export const useMessageUtils = () => {
5
5
  const { state, dispatch } = useContext(CommonContext);
6
6
  const isSilentLoading = () => {
@@ -17,33 +17,36 @@ export const useMessageUtils = () => {
17
17
  };
18
18
  const dispatchError = ({ err, t, key }) => {
19
19
  if (!err.response) {
20
- const value = t(`${key ?? 'message'}:${err}`);
21
- dispatch(message({ value, type: 'error' }));
20
+ const value = t(`${key ?? "message"}:${err}`);
21
+ dispatch(message({ value, type: "error" }));
22
22
  return;
23
23
  }
24
24
  if (err.response.status === 403) {
25
- dispatch(message({ value: t('error.access.authorization'), type: 'error' }));
25
+ dispatch(message({ value: t("error.access.authorization"), type: "error" }));
26
26
  return;
27
27
  }
28
- let errorKey = '';
29
- if (err.response.data?.description) {
28
+ let errorKey = "";
29
+ if (err.response.data?.message) {
30
+ errorKey = err.response.data.message;
31
+ }
32
+ else if (err.response.data?.description) {
30
33
  errorKey = err.response.data.description;
31
34
  }
32
35
  else if (err.response.data?.errors?.length > 0) {
33
36
  errorKey = err.response.data.errors[0].description;
34
37
  }
35
38
  else {
36
- key = 'common';
37
- errorKey = 'internal.server.error';
39
+ key = "common";
40
+ errorKey = "internal.server.error";
38
41
  }
39
- const value = t(`${key ?? 'message'}:${errorKey}`);
40
- dispatch(message({ value, type: 'error' }));
42
+ const value = t(`${key ?? "message"}:${errorKey}`);
43
+ dispatch(message({ value, type: "error" }));
41
44
  };
42
45
  const dispatchMessage = ({ key, ns, t }) => {
43
46
  const entry = ns ? `${ns}:${key}` : `message:${key}`;
44
- dispatch(message({ value: t(entry), type: 'success' }));
47
+ dispatch(message({ value: t(entry), type: "success" }));
45
48
  };
46
- const dispatchMessageDirect = (value, type = 'success') => {
49
+ const dispatchMessageDirect = (value, type = "success") => {
47
50
  dispatch(message({ value, type }));
48
51
  };
49
52
  return {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "tycho-components",
3
3
  "private": false,
4
- "version": "0.9.3",
4
+ "version": "0.9.5",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "exports": {