wca-designsystem 0.0.13 → 0.0.15

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/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.0.13",
2
+ "version": "0.0.15",
3
3
  "license": "MIT",
4
4
  "main": "dist/index.js",
5
5
  "typings": "dist/index.d.ts",
@@ -1,13 +1,16 @@
1
- import React from "react";
2
- import Paginacao from ".";
3
- import { render } from "../../../test/render";
1
+ import React from 'react';
2
+ import Paginacao from '.';
3
+ import { render } from '../../../test/render';
4
4
 
5
- describe("Paginação", () => {
6
- test("Renderizando corretamente", () => {
5
+ describe('Paginação', () => {
6
+ test('Renderizando corretamente', () => {
7
7
  const { getByText } = render(
8
- <Paginacao tabelaPaginacao={{ pageIndex: 30, pageSize: 100 }} />
8
+ <Paginacao
9
+ setPagination={() => console.log('aqui')}
10
+ tabelaPaginacao={{ pageIndex: 30, pageSize: 100 }}
11
+ />
9
12
  );
10
13
 
11
- expect(getByText("Anterior")).toBeDefined();
14
+ expect(getByText('Anterior')).toBeDefined();
12
15
  });
13
16
  });
@@ -1,13 +1,14 @@
1
1
  import React from 'react';
2
2
  import * as S from './styles';
3
3
  import { theme } from '../../../styles/theme';
4
- import { useSearchParams } from 'react-router-dom';
5
4
  import Botao from '../../atomos/Botao';
6
5
  import SelectCustomizado from '../../atomos/Select';
6
+ import { MRT_PaginationState } from 'mantine-react-table';
7
7
 
8
8
  export type PaginacaoProps = {
9
9
  tamanhoPaginacao?: number;
10
10
  quantidadeRegistros?: number;
11
+ setPagination: React.Dispatch<React.SetStateAction<MRT_PaginationState>>;
11
12
  tabelaPaginacao: {
12
13
  pageIndex: number;
13
14
  pageSize: number;
@@ -17,41 +18,31 @@ export type PaginacaoProps = {
17
18
  const Paginacao = ({
18
19
  tabelaPaginacao,
19
20
  tamanhoPaginacao,
21
+ setPagination,
20
22
  quantidadeRegistros,
21
23
  }: PaginacaoProps) => {
22
- const [, setSearchParams] = useSearchParams();
23
-
24
24
  function nextPage() {
25
25
  if (tabelaPaginacao.pageIndex + 1 > tabelaPaginacao.pageSize) {
26
26
  return;
27
27
  }
28
- setSearchParams((params) => {
29
- params.set('pagina', String(tabelaPaginacao.pageIndex + 1));
30
- return params;
31
- });
28
+ setPagination({ pageIndex: tabelaPaginacao.pageIndex + 1, pageSize: 10 });
32
29
  }
33
30
 
34
31
  function previousPage() {
35
32
  if (tabelaPaginacao.pageIndex <= 0) {
36
33
  return;
37
34
  }
38
- setSearchParams((params) => {
39
- params.set('pagina', String(tabelaPaginacao.pageIndex - 1));
40
- return params;
41
- });
35
+ setPagination({ pageIndex: tabelaPaginacao.pageIndex - 1, pageSize: 10 });
42
36
  }
43
37
 
44
38
  function changePage(e: number) {
45
- setSearchParams((params) => {
46
- params.set('pagina', String(e));
47
- return params;
48
- });
39
+ setPagination({ pageIndex: e, pageSize: 10 });
49
40
  }
50
41
 
51
42
  function changeLinhas(e: string) {
52
- setSearchParams((params) => {
53
- params.set('linhas', String(e));
54
- return params;
43
+ setPagination({
44
+ pageIndex: tabelaPaginacao.pageIndex,
45
+ pageSize: Number(e),
55
46
  });
56
47
  }
57
48
 
@@ -149,7 +149,9 @@ const TabelaHeader = <T extends MRT_RowData>({
149
149
  <div className="mostrar-colunas">
150
150
  <MRT_ToggleFiltersButton
151
151
  table={table!}
152
- onClick={() => setToogleBuscarColuna(!toogleBuscarColuna)}
152
+ onClick={() => {
153
+ setToogleBuscarColuna(!toogleBuscarColuna);
154
+ }}
153
155
  />
154
156
  </div>
155
157
  </S.TabelaHeaderIcons>