wca-designsystem 1.0.89 → 1.0.91

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": "1.0.89",
2
+ "version": "1.0.91",
3
3
  "license": "MIT",
4
4
  "main": "dist/index.js",
5
5
  "typings": "dist/index.d.ts",
@@ -1,4 +1,4 @@
1
- import React, { useCallback } from 'react'
1
+ import React, { useCallback, useMemo } from 'react'
2
2
  import * as S from './styles'
3
3
  import InputDeTexto from '../../atomos/InputDeTexto'
4
4
  import SelectCustomizado from '../../atomos/Select'
@@ -54,6 +54,18 @@ const TabelaHeader = <T extends { id: string | number; children?: Array<T> }>({
54
54
  })
55
55
  setFormatedColumns(columnsFormated)
56
56
  }, [])
57
+
58
+ const defaultOrderData = [
59
+ { value: 'Maior', label: 'Ordenar por: Decrescente' },
60
+ { value: 'Menor', label: 'Ordenar por: Crescente' },
61
+ ];
62
+
63
+ const orderData = useMemo(() => {
64
+ if (!ordenarPor) return defaultOrderData;
65
+ return defaultOrderData.map((opt) =>
66
+ opt.value === ordenarPor.value ? { ...opt, label: ordenarPor.label } : opt
67
+ );
68
+ }, [ordenarPor]);
57
69
 
58
70
  const columnsToHide = ['expand', 'select', 'acoes']
59
71
  return (
@@ -70,10 +82,7 @@ const TabelaHeader = <T extends { id: string | number; children?: Array<T> }>({
70
82
  {hasOrder && (
71
83
  <SelectCustomizado
72
84
  tipo="table"
73
- data={[
74
- { value: 'Maior', label: 'Ordenar por: Decrescente' },
75
- { value: 'Menor', label: 'Ordenar por: Crescente' },
76
- ]}
85
+ data={orderData}
77
86
  onChange={(_value, option) => setOrdenarPor!(option)}
78
87
  allowDeselect={false}
79
88
  value={ordenarPor ? ordenarPor.value : 'Maior'}
@@ -301,6 +301,6 @@ TabelaProps.args = {
301
301
  setGlobalFilter: () => console.log('aqui'),
302
302
  setPagination: () => console.log('aqui'),
303
303
  quantidadeDeRegistros: 10,
304
- tamanhoPaginacao: 97,
304
+ tamanhoPaginacao: 12,
305
305
  setSimples: () => console.log('aqui'),
306
306
  }
@@ -28,10 +28,10 @@ const Paginacao = ({
28
28
  quantidadeRegistros,
29
29
  qtdRegistrosPagina,
30
30
  }: PaginacaoProps) => {
31
+
31
32
  function nextPage() {
32
- if (tabelaPaginacao.pageIndex + 1 > tabelaPaginacao.pageSize) {
33
- return;
34
- }
33
+ if (tabelaPaginacao.pageIndex >= tamanhoPaginacao!) return;
34
+
35
35
  setPagination({
36
36
  pageIndex: tabelaPaginacao.pageIndex + 1,
37
37
  pageSize: tabelaPaginacao.pageSize ?? 10,
@@ -39,18 +39,17 @@ const Paginacao = ({
39
39
  }
40
40
 
41
41
  function previousPage() {
42
- if (tabelaPaginacao.pageIndex <= 0) {
43
- return;
44
- }
42
+ if (tabelaPaginacao.pageIndex <= 1) return;
43
+
45
44
  setPagination({
46
45
  pageIndex: tabelaPaginacao.pageIndex - 1,
47
46
  pageSize: tabelaPaginacao.pageSize ?? 10,
48
47
  });
49
48
  }
50
49
 
51
- function changePage(e: number) {
50
+ function changePage(pagina: number) {
52
51
  setPagination({
53
- pageIndex: e,
52
+ pageIndex: pagina,
54
53
  pageSize: tabelaPaginacao.pageSize ?? 10,
55
54
  });
56
55
  }