wca-designsystem 0.0.7 → 0.0.9
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 +1 -1
- package/src/components/atomos/InputDeArquivo/InputDeArquivo.stories.tsx +16 -0
- package/src/components/atomos/InputDeArquivo/InputDeArquivo.test.tsx +12 -0
- package/src/components/atomos/InputDeArquivo/index.tsx +39 -0
- package/src/components/atomos/InputDeArquivo/styles.ts +43 -0
- package/src/components/atomos/InputDeTexto/index.tsx +11 -3
- package/src/components/atomos/InputDeTexto/styles.ts +16 -5
- package/src/components/atomos/Select/index.tsx +21 -10
- package/src/components/atomos/Select/styles.ts +24 -3
- package/src/components/molecules/Paginacao/index.tsx +17 -7
- package/src/components/molecules/Paginacao/styles.ts +26 -22
- package/src/components/organismos/Tabela/Tabela.stories.tsx +117 -5
- package/src/components/organismos/Tabela/Tabela.test.tsx +4 -7
- package/src/components/organismos/Tabela/index.tsx +39 -54
- package/src/components/organismos/Tabela/styles.ts +4 -3
- package/src/hooks/users/index.tsx +24 -22
package/package.json
CHANGED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
import InputDeArquivo from '.';
|
|
3
|
+
|
|
4
|
+
const meta: Meta<typeof InputDeArquivo> = {
|
|
5
|
+
component: InputDeArquivo,
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
export default meta;
|
|
9
|
+
|
|
10
|
+
type Story = StoryObj<typeof InputDeArquivo>;
|
|
11
|
+
|
|
12
|
+
export const Primary: Story = {
|
|
13
|
+
args: {
|
|
14
|
+
labelAbaixo: 'exemplo',
|
|
15
|
+
},
|
|
16
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render } from '../../../test/render';
|
|
3
|
+
import InputDeArquivo from './index';
|
|
4
|
+
|
|
5
|
+
describe('InputDeArquivo rendering', () => {
|
|
6
|
+
it('renders without crashing', () => {
|
|
7
|
+
const { getByTestId } = render(<InputDeArquivo labelAbaixo="exemplo" />);
|
|
8
|
+
|
|
9
|
+
const inputDeArquivo = getByTestId('label-abaixo');
|
|
10
|
+
expect(inputDeArquivo).toBeDefined();
|
|
11
|
+
});
|
|
12
|
+
});
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import * as S from './styles';
|
|
3
|
+
import { FileInput, FileInputProps } from '@mantine/core';
|
|
4
|
+
import download from '../../../assets/imagens/icons/Download.svg';
|
|
5
|
+
import Icone from '../Icone';
|
|
6
|
+
import { theme } from '../../../styles/theme';
|
|
7
|
+
|
|
8
|
+
interface InputDeArquivoProps extends FileInputProps {
|
|
9
|
+
labelAbaixo?: string;
|
|
10
|
+
}
|
|
11
|
+
const InputDeArquivo = ({ labelAbaixo, ...props }: InputDeArquivoProps) => {
|
|
12
|
+
return (
|
|
13
|
+
<S.InputDeArquivoWrapper>
|
|
14
|
+
<FileInput
|
|
15
|
+
{...props}
|
|
16
|
+
leftSection={
|
|
17
|
+
<S.InputDeArquivoSelecionar>
|
|
18
|
+
<Icone
|
|
19
|
+
svg={download}
|
|
20
|
+
fill={theme.colors.redSti}
|
|
21
|
+
width={16}
|
|
22
|
+
height={16}
|
|
23
|
+
/>
|
|
24
|
+
<label>Escolher arquivo</label>
|
|
25
|
+
</S.InputDeArquivoSelecionar>
|
|
26
|
+
}
|
|
27
|
+
placeholder="Nenhum arquivo escolhido"
|
|
28
|
+
leftSectionPointerEvents="none"
|
|
29
|
+
/>
|
|
30
|
+
{labelAbaixo?.length! > 0 && (
|
|
31
|
+
<label className="label-abaixo" data-testid={'label-abaixo'}>
|
|
32
|
+
{labelAbaixo}
|
|
33
|
+
</label>
|
|
34
|
+
)}
|
|
35
|
+
</S.InputDeArquivoWrapper>
|
|
36
|
+
);
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export default InputDeArquivo;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import styled, { css } from 'styled-components';
|
|
2
|
+
|
|
3
|
+
export const InputDeArquivoWrapper = styled.div`
|
|
4
|
+
${({ theme }) => css`
|
|
5
|
+
.mantine-InputPlaceholder-placeholder {
|
|
6
|
+
padding-left: 105px;
|
|
7
|
+
color: ${theme.colors.gray['700']};
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
button {
|
|
11
|
+
div {
|
|
12
|
+
padding-left: 105px;
|
|
13
|
+
color: ${theme.colors.gray['700']};
|
|
14
|
+
font-weight: 500;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.label-abaixo {
|
|
19
|
+
color: ${theme.colors.gray['700']};
|
|
20
|
+
font-size: ${theme.sizes.xSmall};
|
|
21
|
+
font-family: 'Ubunto Mono', monospace;
|
|
22
|
+
}
|
|
23
|
+
`}
|
|
24
|
+
`;
|
|
25
|
+
|
|
26
|
+
export const InputDeArquivoSelecionar = styled.div`
|
|
27
|
+
${({ theme }) => css`
|
|
28
|
+
min-width: 132px;
|
|
29
|
+
position: absolute;
|
|
30
|
+
left: 0;
|
|
31
|
+
display: flex;
|
|
32
|
+
justify-content: center;
|
|
33
|
+
align-items: center;
|
|
34
|
+
gap: 8px;
|
|
35
|
+
padding: 8px;
|
|
36
|
+
background-color: ${theme.colors.gray['500']};
|
|
37
|
+
|
|
38
|
+
label {
|
|
39
|
+
color: ${theme.colors.redSti};
|
|
40
|
+
font-size: ${theme.sizes.small};
|
|
41
|
+
}
|
|
42
|
+
`}
|
|
43
|
+
`;
|
|
@@ -8,14 +8,22 @@ import { theme } from '../../../styles/theme';
|
|
|
8
8
|
|
|
9
9
|
export interface InputDeTextoProps extends TextInputProps {
|
|
10
10
|
tipo: 'table' | 'round' | 'login' | 'password';
|
|
11
|
+
labelAbaixo?: string;
|
|
11
12
|
}
|
|
12
13
|
|
|
13
|
-
const InputDeTexto = ({ tipo, ...props }: InputDeTextoProps) => {
|
|
14
|
+
const InputDeTexto = ({ tipo, labelAbaixo, ...props }: InputDeTextoProps) => {
|
|
14
15
|
/* Renderiza conforme o tipo que você escolher */
|
|
15
16
|
const renderInputTexto: any = useCallback(
|
|
16
17
|
(tipo: 'table' | 'round' | 'login' | 'password') => {
|
|
17
18
|
const selectsTipos = {
|
|
18
|
-
round:
|
|
19
|
+
round: (
|
|
20
|
+
<S.InputDeTextoRoundWrapper>
|
|
21
|
+
<S.InputDeTextoRound radius={8} {...props} data-testid="round" />
|
|
22
|
+
{labelAbaixo?.length! > 0 && (
|
|
23
|
+
<label className="label-abaixo">{labelAbaixo}</label>
|
|
24
|
+
)}
|
|
25
|
+
</S.InputDeTextoRoundWrapper>
|
|
26
|
+
),
|
|
19
27
|
table: <S.InputDeTextoTabela {...props} data-testid="table" />,
|
|
20
28
|
login: (
|
|
21
29
|
<S.InputDeTextoLogin
|
|
@@ -71,7 +79,7 @@ const InputDeTexto = ({ tipo, ...props }: InputDeTextoProps) => {
|
|
|
71
79
|
};
|
|
72
80
|
return selectsTipos[tipo];
|
|
73
81
|
},
|
|
74
|
-
[tipo, props]
|
|
82
|
+
[tipo, labelAbaixo, props]
|
|
75
83
|
);
|
|
76
84
|
|
|
77
85
|
return <>{renderInputTexto(tipo)}</>;
|
|
@@ -1,15 +1,26 @@
|
|
|
1
|
-
import { PasswordInput, TextInput } from
|
|
2
|
-
import styled, { css } from
|
|
1
|
+
import { PasswordInput, TextInput } from '@mantine/core';
|
|
2
|
+
import styled, { css } from 'styled-components';
|
|
3
|
+
|
|
4
|
+
export const InputDeTextoRoundWrapper = styled.div`
|
|
5
|
+
${({ theme }) => css`
|
|
6
|
+
.label-abaixo {
|
|
7
|
+
color: ${theme.colors.gray['700']};
|
|
8
|
+
font-size: ${theme.sizes.xSmall};
|
|
9
|
+
font-family: 'Ubunto Mono', monospace;
|
|
10
|
+
}
|
|
11
|
+
`}
|
|
12
|
+
`;
|
|
3
13
|
|
|
4
14
|
export const InputDeTextoRound = styled(TextInput)`
|
|
5
15
|
${() => css`
|
|
6
16
|
font-weight: 400;
|
|
17
|
+
border-radius: 8px;
|
|
7
18
|
`}
|
|
8
19
|
`;
|
|
9
20
|
|
|
10
21
|
export const RightSelect = styled.div`
|
|
11
22
|
${({ theme }) => css`
|
|
12
|
-
background-color: ${theme.colors.gray[
|
|
23
|
+
background-color: ${theme.colors.gray['500']};
|
|
13
24
|
position: absolute;
|
|
14
25
|
top: 0;
|
|
15
26
|
bottom: 0;
|
|
@@ -65,7 +76,7 @@ export const InputDeTextoLogin = styled(TextInput)`
|
|
|
65
76
|
padding-left: 45px;
|
|
66
77
|
|
|
67
78
|
&::placeholder {
|
|
68
|
-
color: ${theme.colors.gray[
|
|
79
|
+
color: ${theme.colors.gray['500']};
|
|
69
80
|
}
|
|
70
81
|
}
|
|
71
82
|
`}
|
|
@@ -90,7 +101,7 @@ export const InputDePassword = styled(PasswordInput)`
|
|
|
90
101
|
padding-left: 45px;
|
|
91
102
|
|
|
92
103
|
&::placeholder {
|
|
93
|
-
color: ${theme.colors.gray[
|
|
104
|
+
color: ${theme.colors.gray['500']};
|
|
94
105
|
}
|
|
95
106
|
}
|
|
96
107
|
`}
|
|
@@ -8,23 +8,34 @@ import { theme } from '../../../styles/theme';
|
|
|
8
8
|
|
|
9
9
|
export interface SelectCustomizadoProps extends SelectProps {
|
|
10
10
|
tipo: 'table' | 'round';
|
|
11
|
+
labelAbaixo?: string;
|
|
11
12
|
}
|
|
12
13
|
|
|
13
|
-
const SelectCustomizado = ({
|
|
14
|
+
const SelectCustomizado = ({
|
|
15
|
+
tipo,
|
|
16
|
+
labelAbaixo,
|
|
17
|
+
...props
|
|
18
|
+
}: SelectCustomizadoProps) => {
|
|
14
19
|
/* Renderiza conforme o tipo que você escolher */
|
|
15
20
|
const renderSelect = useCallback(
|
|
16
21
|
(tipo: 'table' | 'round') => {
|
|
17
22
|
const selectsTipos = {
|
|
18
23
|
round: (
|
|
19
|
-
<S.
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
24
|
+
<S.SelectRoundWrapper>
|
|
25
|
+
<S.SelectRound
|
|
26
|
+
{...props}
|
|
27
|
+
data-testid="round"
|
|
28
|
+
radius={8}
|
|
29
|
+
rightSection={
|
|
30
|
+
<S.RightSelect>
|
|
31
|
+
<Icone svg={arrowDown} fill={theme.colors.gray['700']} />
|
|
32
|
+
</S.RightSelect>
|
|
33
|
+
}
|
|
34
|
+
/>
|
|
35
|
+
{labelAbaixo?.length! > 0 && (
|
|
36
|
+
<label className="label-abaixo">{labelAbaixo}</label>
|
|
37
|
+
)}
|
|
38
|
+
</S.SelectRoundWrapper>
|
|
28
39
|
),
|
|
29
40
|
table: (
|
|
30
41
|
<S.SelectTabela
|
|
@@ -1,9 +1,29 @@
|
|
|
1
1
|
import { Select } from '@mantine/core';
|
|
2
2
|
import styled, { css } from 'styled-components';
|
|
3
3
|
|
|
4
|
+
export const SelectRoundWrapper = styled.div`
|
|
5
|
+
${({ theme }) => css`
|
|
6
|
+
.label-abaixo {
|
|
7
|
+
color: ${theme.colors.gray['700']};
|
|
8
|
+
font-size: ${theme.sizes.xSmall};
|
|
9
|
+
font-family: 'Ubunto Mono', monospace;
|
|
10
|
+
}
|
|
11
|
+
`}
|
|
12
|
+
`;
|
|
13
|
+
|
|
4
14
|
export const SelectRound = styled(Select)`
|
|
5
15
|
${() => css`
|
|
6
16
|
font-weight: 400;
|
|
17
|
+
|
|
18
|
+
&[data-expanded='true'] {
|
|
19
|
+
border: none; /* Remover a borda quando o select está expandido */
|
|
20
|
+
outline: none;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.mantine-Select-root {
|
|
24
|
+
border: none; /* Remover a borda em outros estados */
|
|
25
|
+
outline: none;
|
|
26
|
+
}
|
|
7
27
|
`}
|
|
8
28
|
`;
|
|
9
29
|
|
|
@@ -13,10 +33,12 @@ export const RightSelect = styled.div`
|
|
|
13
33
|
position: absolute;
|
|
14
34
|
top: 0;
|
|
15
35
|
bottom: 0;
|
|
16
|
-
right:
|
|
36
|
+
right: 0px;
|
|
17
37
|
display: flex;
|
|
18
38
|
align-items: center;
|
|
19
|
-
|
|
39
|
+
justify-content: center;
|
|
40
|
+
width: 40px;
|
|
41
|
+
border-radius: 0 8px 8px 0;
|
|
20
42
|
`}
|
|
21
43
|
`;
|
|
22
44
|
|
|
@@ -26,7 +48,6 @@ export const SelectTabela = styled(Select)`
|
|
|
26
48
|
|
|
27
49
|
input {
|
|
28
50
|
min-height: 25px;
|
|
29
|
-
/* max-width: 200px; */
|
|
30
51
|
height: 25px;
|
|
31
52
|
box-shadow: 0px 2px 3px 0px ${theme.colors.blue};
|
|
32
53
|
border: none;
|
|
@@ -7,6 +7,7 @@ import SelectCustomizado from '../../atomos/Select';
|
|
|
7
7
|
import Botao from '../../atomos/Botao';
|
|
8
8
|
|
|
9
9
|
export type PaginacaoProps<T extends PaginationProps> = {
|
|
10
|
+
tamanhoPaginacao?: number;
|
|
10
11
|
tabelaPaginacao: {
|
|
11
12
|
pageIndex: number;
|
|
12
13
|
pageSize: number;
|
|
@@ -25,16 +26,22 @@ const Paginacao = ({
|
|
|
25
26
|
data,
|
|
26
27
|
handlePaginationChange,
|
|
27
28
|
tabelaPaginacao,
|
|
29
|
+
tamanhoPaginacao,
|
|
28
30
|
}: PaginacaoProps<any>) => {
|
|
29
31
|
return (
|
|
30
32
|
<S.PaginacaoWrapper>
|
|
31
33
|
<div className="pagination-header">
|
|
32
34
|
<p>
|
|
33
|
-
Exibindo
|
|
35
|
+
Exibindo{' '}
|
|
36
|
+
{tabelaPaginacao.pageSize > data.length
|
|
37
|
+
? data.length
|
|
38
|
+
: tabelaPaginacao.pageSize}{' '}
|
|
39
|
+
de {data.length}
|
|
34
40
|
</p>
|
|
35
41
|
<div className="select-wrapper">
|
|
36
42
|
<SelectCustomizado
|
|
37
43
|
tipo="round"
|
|
44
|
+
disabled={data.length > tabelaPaginacao.pageIndex}
|
|
38
45
|
onChange={(e) =>
|
|
39
46
|
handlePaginationChange({
|
|
40
47
|
pageIndex: tabelaPaginacao.pageIndex,
|
|
@@ -46,12 +53,12 @@ const Paginacao = ({
|
|
|
46
53
|
/>
|
|
47
54
|
</div>
|
|
48
55
|
</div>
|
|
49
|
-
<
|
|
56
|
+
<S.PaginationButtons>
|
|
50
57
|
<Botao
|
|
51
58
|
data-testid="Anterior"
|
|
52
59
|
className="button-pagination"
|
|
53
60
|
tipo="default"
|
|
54
|
-
disabled={tabelaPaginacao.pageIndex ===
|
|
61
|
+
disabled={tabelaPaginacao.pageIndex === 0}
|
|
55
62
|
onClick={() => {
|
|
56
63
|
handlePaginationChange({
|
|
57
64
|
pageIndex: tabelaPaginacao.pageIndex - 1,
|
|
@@ -62,20 +69,23 @@ const Paginacao = ({
|
|
|
62
69
|
Anterior
|
|
63
70
|
</Botao>
|
|
64
71
|
<S.PaginationMantine
|
|
65
|
-
value={
|
|
72
|
+
value={
|
|
73
|
+
tabelaPaginacao.pageIndex === 0 ? 1 : tabelaPaginacao.pageIndex + 1
|
|
74
|
+
}
|
|
66
75
|
onChange={(e) => {
|
|
67
76
|
handlePaginationChange({
|
|
68
|
-
pageIndex: e,
|
|
77
|
+
pageIndex: e === 1 ? 0 : e - 1,
|
|
69
78
|
pageSize: tabelaPaginacao.pageSize,
|
|
70
79
|
});
|
|
71
80
|
}}
|
|
72
|
-
total={
|
|
81
|
+
total={tamanhoPaginacao!}
|
|
73
82
|
withControls={false}
|
|
74
83
|
color={theme.colors.blue}
|
|
75
84
|
/>
|
|
76
85
|
<Botao
|
|
77
86
|
data-testid="Proximo"
|
|
78
87
|
tipo={'default'}
|
|
88
|
+
disabled={tamanhoPaginacao === tabelaPaginacao.pageIndex + 1}
|
|
79
89
|
onClick={() => {
|
|
80
90
|
handlePaginationChange({
|
|
81
91
|
pageIndex: tabelaPaginacao.pageIndex + 1,
|
|
@@ -86,7 +96,7 @@ const Paginacao = ({
|
|
|
86
96
|
>
|
|
87
97
|
Proximo
|
|
88
98
|
</Botao>
|
|
89
|
-
</
|
|
99
|
+
</S.PaginationButtons>
|
|
90
100
|
</S.PaginacaoWrapper>
|
|
91
101
|
);
|
|
92
102
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Pagination } from
|
|
2
|
-
import styled, { css } from
|
|
1
|
+
import { Pagination } from '@mantine/core';
|
|
2
|
+
import styled, { css } from 'styled-components';
|
|
3
3
|
|
|
4
4
|
export const PaginacaoWrapper = styled.div`
|
|
5
5
|
${({ theme }) => css`
|
|
@@ -17,26 +17,9 @@ export const PaginacaoWrapper = styled.div`
|
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
.select-wrapper {
|
|
20
|
-
width:
|
|
20
|
+
width: 85px;
|
|
21
21
|
margin-left: 15px;
|
|
22
22
|
}
|
|
23
|
-
|
|
24
|
-
.pagination {
|
|
25
|
-
display: flex;
|
|
26
|
-
align-items: center;
|
|
27
|
-
gap: 0.5rem;
|
|
28
|
-
|
|
29
|
-
.button-pagination {
|
|
30
|
-
height: 32px;
|
|
31
|
-
border: none;
|
|
32
|
-
color: ${theme.colors.blue};
|
|
33
|
-
background-color: ${theme.colors.white};
|
|
34
|
-
border-radius: 5px;
|
|
35
|
-
font-weight: 500;
|
|
36
|
-
font-size: ${theme.sizes.small};
|
|
37
|
-
padding: 0 15px;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
23
|
`}
|
|
41
24
|
`;
|
|
42
25
|
|
|
@@ -45,13 +28,34 @@ export const PaginationMantine = styled(Pagination)`
|
|
|
45
28
|
margin: 15px 0;
|
|
46
29
|
|
|
47
30
|
button {
|
|
48
|
-
color: ${theme.colors.gray[
|
|
31
|
+
color: ${theme.colors.gray['700']};
|
|
49
32
|
font-weight: 500;
|
|
50
33
|
font-size: ${theme.sizes.meddium};
|
|
51
34
|
|
|
52
|
-
&[data-active=
|
|
35
|
+
&[data-active='true'] {
|
|
53
36
|
color: ${theme.colors.white};
|
|
54
37
|
}
|
|
55
38
|
}
|
|
56
39
|
`}
|
|
57
40
|
`;
|
|
41
|
+
|
|
42
|
+
export const PaginationButtons = styled.div`
|
|
43
|
+
${({ theme }) => css`
|
|
44
|
+
display: flex;
|
|
45
|
+
align-items: center;
|
|
46
|
+
justify-content: center;
|
|
47
|
+
gap: 0.5rem;
|
|
48
|
+
|
|
49
|
+
.button-pagination {
|
|
50
|
+
border: 1px solid red;
|
|
51
|
+
height: 32px;
|
|
52
|
+
border: none;
|
|
53
|
+
color: ${theme.colors.blue};
|
|
54
|
+
background-color: ${theme.colors.white};
|
|
55
|
+
border-radius: 5px;
|
|
56
|
+
font-weight: 500;
|
|
57
|
+
font-size: ${theme.sizes.small};
|
|
58
|
+
padding: 0 15px;
|
|
59
|
+
}
|
|
60
|
+
`}
|
|
61
|
+
`;
|
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import Tabela, { TabelaProps } from './index';
|
|
3
3
|
import { Meta } from '@storybook/react';
|
|
4
|
-
import { TabelaStoryContainer } from './styles';
|
|
4
|
+
import { TabelaAcoes, TabelaStoryContainer } from './styles';
|
|
5
|
+
import IconeBotao from '../../atomos/IconeBotao';
|
|
6
|
+
import Icone from '../../atomos/Icone';
|
|
7
|
+
import { theme } from '../../../styles/theme';
|
|
8
|
+
import editar from '../../../assets/imagens/icons/EditarPerfil.svg';
|
|
9
|
+
import deletar from '../../../assets/imagens/icons/RemoveFIltro.svg';
|
|
5
10
|
|
|
6
11
|
export default {
|
|
7
12
|
title: 'Components/organismos/Tabela',
|
|
@@ -36,15 +41,122 @@ const columns: any = [
|
|
|
36
41
|
},
|
|
37
42
|
];
|
|
38
43
|
|
|
44
|
+
const data: any = [
|
|
45
|
+
{
|
|
46
|
+
nome: 'exemplo',
|
|
47
|
+
email: 'exemplo@gmail.com',
|
|
48
|
+
genero: 'masculino',
|
|
49
|
+
rua: 'Alameda Olga',
|
|
50
|
+
estado: 'SP',
|
|
51
|
+
cidade: 'São Paulo',
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
nome: 'exemplo',
|
|
55
|
+
email: 'exemplo@gmail.com',
|
|
56
|
+
genero: 'masculino',
|
|
57
|
+
rua: 'Alameda Olga',
|
|
58
|
+
estado: 'SP',
|
|
59
|
+
cidade: 'São Paulo',
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
nome: 'exemplo',
|
|
63
|
+
email: 'exemplo@gmail.com',
|
|
64
|
+
genero: 'masculino',
|
|
65
|
+
rua: 'Alameda Olga',
|
|
66
|
+
estado: 'SP',
|
|
67
|
+
cidade: 'São Paulo',
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
nome: 'exemplo',
|
|
71
|
+
email: 'exemplo@gmail.com',
|
|
72
|
+
genero: 'masculino',
|
|
73
|
+
rua: 'Alameda Olga',
|
|
74
|
+
estado: 'SP',
|
|
75
|
+
cidade: 'São Paulo',
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
nome: 'exemplo',
|
|
79
|
+
email: 'exemplo@gmail.com',
|
|
80
|
+
genero: 'masculino',
|
|
81
|
+
rua: 'Alameda Olga',
|
|
82
|
+
estado: 'SP',
|
|
83
|
+
cidade: 'São Paulo',
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
nome: 'exemplo',
|
|
87
|
+
email: 'exemplo@gmail.com',
|
|
88
|
+
genero: 'masculino',
|
|
89
|
+
rua: 'Alameda Olga',
|
|
90
|
+
estado: 'SP',
|
|
91
|
+
cidade: 'São Paulo',
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
nome: 'exemplo',
|
|
95
|
+
email: 'exemplo@gmail.com',
|
|
96
|
+
genero: 'masculino',
|
|
97
|
+
rua: 'Alameda Olga',
|
|
98
|
+
estado: 'SP',
|
|
99
|
+
cidade: 'São Paulo',
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
nome: 'exemplo',
|
|
103
|
+
email: 'exemplo@gmail.com',
|
|
104
|
+
genero: 'masculino',
|
|
105
|
+
rua: 'Alameda Olga',
|
|
106
|
+
estado: 'SP',
|
|
107
|
+
cidade: 'São Paulo',
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
nome: 'exemplo',
|
|
111
|
+
email: 'exemplo@gmail.com',
|
|
112
|
+
genero: 'masculino',
|
|
113
|
+
rua: 'Alameda Olga',
|
|
114
|
+
estado: 'SP',
|
|
115
|
+
cidade: 'São Paulo',
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
nome: 'exemplo',
|
|
119
|
+
email: 'exemplo@gmail.com',
|
|
120
|
+
genero: 'masculino',
|
|
121
|
+
rua: 'Alameda Olga',
|
|
122
|
+
estado: 'SP',
|
|
123
|
+
cidade: 'São Paulo',
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
nome: 'exemplo',
|
|
127
|
+
email: 'exemplo@gmail.com',
|
|
128
|
+
genero: 'masculino',
|
|
129
|
+
rua: 'Alameda Olga',
|
|
130
|
+
estado: 'SP',
|
|
131
|
+
cidade: 'São Paulo',
|
|
132
|
+
},
|
|
133
|
+
];
|
|
134
|
+
|
|
39
135
|
const props: TabelaProps<any> = {
|
|
40
|
-
|
|
136
|
+
data: data,
|
|
137
|
+
isLoading: false,
|
|
41
138
|
columns: columns,
|
|
42
|
-
endpoint: '',
|
|
43
|
-
tituloTabela: 'Usuario',
|
|
44
139
|
enableExpanding: false,
|
|
45
|
-
baseUrl: 'https://randomuser.me/api/',
|
|
46
140
|
enableRowSelection: false,
|
|
47
141
|
enableRowActions: false,
|
|
142
|
+
tamanhoPaginacao: 10,
|
|
143
|
+
handleAdicionar: () => console.log('adicionar'),
|
|
144
|
+
acoes: ({ row }) => (
|
|
145
|
+
<TabelaAcoes>
|
|
146
|
+
<IconeBotao
|
|
147
|
+
tipo="table"
|
|
148
|
+
onClick={() => console.log('edit', row.original)}
|
|
149
|
+
>
|
|
150
|
+
<Icone svg={editar} fill={theme.colors.blue} width={20} height={20} />
|
|
151
|
+
</IconeBotao>
|
|
152
|
+
<IconeBotao
|
|
153
|
+
tipo="table"
|
|
154
|
+
onClick={() => console.log('delete', row.original)}
|
|
155
|
+
>
|
|
156
|
+
<Icone svg={deletar} fill={theme.colors.blue} width={20} height={20} />
|
|
157
|
+
</IconeBotao>
|
|
158
|
+
</TabelaAcoes>
|
|
159
|
+
),
|
|
48
160
|
};
|
|
49
161
|
|
|
50
162
|
const Template: any = (args: TabelaProps<any>) => (
|
|
@@ -2,7 +2,6 @@ import React from 'react';
|
|
|
2
2
|
import Tabela from './index';
|
|
3
3
|
import { render } from '../../../test/render';
|
|
4
4
|
|
|
5
|
-
/* TODO Fazer teste de requisição */
|
|
6
5
|
describe('Tabela', () => {
|
|
7
6
|
const columns: any = [
|
|
8
7
|
{
|
|
@@ -34,13 +33,12 @@ describe('Tabela', () => {
|
|
|
34
33
|
it('Renderiza corretamente', () => {
|
|
35
34
|
const { getByText } = render(
|
|
36
35
|
<Tabela<any>
|
|
37
|
-
|
|
36
|
+
isLoading={false}
|
|
37
|
+
data={[]}
|
|
38
38
|
tituloTabela="Usuário"
|
|
39
|
-
chave="users"
|
|
40
39
|
enableExpanding={false}
|
|
41
40
|
enableRowSelection={false}
|
|
42
41
|
columns={columns}
|
|
43
|
-
endpoint={'/usuarios'}
|
|
44
42
|
/>
|
|
45
43
|
);
|
|
46
44
|
|
|
@@ -52,13 +50,12 @@ describe('Tabela', () => {
|
|
|
52
50
|
|
|
53
51
|
const { getByText } = render(
|
|
54
52
|
<Tabela<any>
|
|
53
|
+
data={[]}
|
|
54
|
+
isLoading={false}
|
|
55
55
|
enableExpanding={false}
|
|
56
|
-
baseUrl="https://randomuser.me/api/"
|
|
57
56
|
enableRowSelection={false}
|
|
58
57
|
tituloTabela="Usuário"
|
|
59
|
-
chave="users"
|
|
60
58
|
columns={columns}
|
|
61
|
-
endpoint={'/usuarios'}
|
|
62
59
|
/>
|
|
63
60
|
);
|
|
64
61
|
const botaoPlanilha = getByText('Baixar Planilha de Dados');
|
|
@@ -8,20 +8,18 @@ import {
|
|
|
8
8
|
MRT_ColumnFiltersState,
|
|
9
9
|
MRT_SortingState,
|
|
10
10
|
MRT_ColumnOrderState,
|
|
11
|
-
MRT_RowSelectionState
|
|
11
|
+
MRT_RowSelectionState,
|
|
12
|
+
MRT_Cell,
|
|
13
|
+
MRT_Row,
|
|
14
|
+
MRT_TableInstance
|
|
12
15
|
} from "mantine-react-table";
|
|
13
16
|
import * as S from "./styles";
|
|
14
17
|
import { useCallback, useMemo, useState } from "react";
|
|
15
18
|
import Paginacao from "../../molecules/Paginacao";
|
|
16
19
|
import TabelaHeader, { SelectDataProps } from "../../molecules/TabelaHeader";
|
|
17
|
-
import { getData } from "../../../hooks/tabelaHook";
|
|
20
|
+
// import { getData } from "../../../hooks/tabelaHook";
|
|
18
21
|
import { utils, writeFileXLSX } from "xlsx";
|
|
19
22
|
import { Table } from "@mantine/core";
|
|
20
|
-
import Icone from "../../atomos/Icone";
|
|
21
|
-
import { theme } from "../../../styles/theme";
|
|
22
|
-
import editar from "../../../assets/imagens/icons/EditarPerfil.svg";
|
|
23
|
-
import deletar from "../../../assets/imagens/icons/RemoveFIltro.svg";
|
|
24
|
-
import IconeBotao from "../../atomos/IconeBotao";
|
|
25
23
|
import SkeletonTable from "./SkeletonTable";
|
|
26
24
|
import HeaderTable from "./HeaderTable";
|
|
27
25
|
import BodyTable from "./BodyTable";
|
|
@@ -29,42 +27,38 @@ import FooterTable from "./FooterTable";
|
|
|
29
27
|
import { MRT_Localization_PT_BR } from "../../../utils/tableLocale";
|
|
30
28
|
|
|
31
29
|
export interface TabelaProps<T extends MRT_RowData> {
|
|
30
|
+
data: Array<T>
|
|
32
31
|
columns: MRT_ColumnDef<T>[];
|
|
32
|
+
isLoading: boolean;
|
|
33
33
|
tituloTabela?: string;
|
|
34
|
-
|
|
35
|
-
baseUrl:string;
|
|
36
|
-
chave: string;
|
|
34
|
+
tamanhoPaginacao?:number;
|
|
37
35
|
enableRowSelection: boolean;
|
|
36
|
+
handleAdicionar?: (() => void) | undefined;
|
|
38
37
|
setRowSelection?: React.Dispatch<React.SetStateAction<MRT_RowSelectionState>>;
|
|
38
|
+
acoes?: ((props: {
|
|
39
|
+
cell: MRT_Cell<T, unknown>;
|
|
40
|
+
renderedRowIndex?: number;
|
|
41
|
+
row: MRT_Row<T>;
|
|
42
|
+
table: MRT_TableInstance<T>;
|
|
43
|
+
}) => React.ReactNode) | undefined
|
|
39
44
|
rowSelection?: MRT_RowSelectionState | undefined;
|
|
40
45
|
enableExpanding: boolean;
|
|
41
46
|
fixedPosition?: Array<string>;
|
|
42
47
|
enableRowActions?: boolean;
|
|
43
48
|
hasTotalFooter?: boolean;
|
|
44
49
|
}
|
|
45
|
-
export interface GetParams {
|
|
46
|
-
columnFilterFns: MRT_ColumnFilterFnsState;
|
|
47
|
-
columnFilters: MRT_ColumnFiltersState;
|
|
48
|
-
globalFilter: string;
|
|
49
|
-
sorting: MRT_SortingState;
|
|
50
|
-
order: string;
|
|
51
|
-
pagination: MRT_PaginationState;
|
|
52
|
-
chave: string;
|
|
53
|
-
endpoint: string;
|
|
54
|
-
baseUrl: string;
|
|
55
|
-
filtrosPor: string;
|
|
56
|
-
columnOrder: MRT_ColumnOrderState;
|
|
57
|
-
}
|
|
58
50
|
|
|
59
51
|
function Tabela<T extends MRT_RowData>({
|
|
52
|
+
data,
|
|
60
53
|
columns,
|
|
54
|
+
isLoading,
|
|
61
55
|
tituloTabela,
|
|
62
|
-
|
|
63
|
-
baseUrl,
|
|
56
|
+
tamanhoPaginacao,
|
|
64
57
|
setRowSelection,
|
|
65
|
-
|
|
58
|
+
handleAdicionar,
|
|
66
59
|
enableRowSelection,
|
|
67
60
|
enableRowActions,
|
|
61
|
+
acoes,
|
|
68
62
|
hasTotalFooter,
|
|
69
63
|
enableExpanding,
|
|
70
64
|
rowSelection = {},
|
|
@@ -93,7 +87,7 @@ function Tabela<T extends MRT_RowData>({
|
|
|
93
87
|
const [sorting, setSorting] = useState<MRT_SortingState>([]);
|
|
94
88
|
|
|
95
89
|
const [pagination, setPagination] = useState<MRT_PaginationState>({
|
|
96
|
-
pageIndex:
|
|
90
|
+
pageIndex: 0,
|
|
97
91
|
pageSize: 10
|
|
98
92
|
});
|
|
99
93
|
const [ordenarPor, setOrdenarPor] = useState<SelectDataProps>({
|
|
@@ -105,20 +99,7 @@ function Tabela<T extends MRT_RowData>({
|
|
|
105
99
|
const [filtrosPor, setFiltrosPor] = useState(filtrosPelaTabela[0] ?? []);
|
|
106
100
|
const [toogleBuscarColuna, setToogleBuscarColuna] = useState(false);
|
|
107
101
|
|
|
108
|
-
|
|
109
|
-
columnFilterFns,
|
|
110
|
-
columnFilters,
|
|
111
|
-
globalFilter,
|
|
112
|
-
sorting,
|
|
113
|
-
order: ordenarPor.value,
|
|
114
|
-
endpoint,
|
|
115
|
-
baseUrl: baseUrl,
|
|
116
|
-
chave,
|
|
117
|
-
filtrosPor: filtrosPor.value,
|
|
118
|
-
columnOrder,
|
|
119
|
-
pagination
|
|
120
|
-
});
|
|
121
|
-
|
|
102
|
+
|
|
122
103
|
const calcStickPosition = useCallback(
|
|
123
104
|
(index: number) => {
|
|
124
105
|
if (enableExpanding) {
|
|
@@ -144,11 +125,10 @@ function Tabela<T extends MRT_RowData>({
|
|
|
144
125
|
[columnFilters]
|
|
145
126
|
);
|
|
146
127
|
|
|
147
|
-
const fetchData = data ?? [];
|
|
148
128
|
|
|
149
|
-
const table = useMantineReactTable({
|
|
150
|
-
|
|
151
|
-
|
|
129
|
+
const table = useMantineReactTable({
|
|
130
|
+
data: data,
|
|
131
|
+
columns: columns,
|
|
152
132
|
enableRowSelection: enableRowSelection,
|
|
153
133
|
onRowSelectionChange: setRowSelection,
|
|
154
134
|
getRowId: (row) => row.id,
|
|
@@ -215,7 +195,7 @@ function Tabela<T extends MRT_RowData>({
|
|
|
215
195
|
fz: "xs"
|
|
216
196
|
},
|
|
217
197
|
|
|
218
|
-
renderRowActions: ({ row }) => (
|
|
198
|
+
renderRowActions: acoes && acoes/* ({ row }) => (
|
|
219
199
|
<S.TabelaAcoes>
|
|
220
200
|
<IconeBotao
|
|
221
201
|
tipo="table"
|
|
@@ -235,11 +215,11 @@ function Tabela<T extends MRT_RowData>({
|
|
|
235
215
|
/>
|
|
236
216
|
</IconeBotao>
|
|
237
217
|
</S.TabelaAcoes>
|
|
238
|
-
)
|
|
218
|
+
) */
|
|
239
219
|
});
|
|
240
220
|
|
|
241
221
|
const exportarXlsx = useCallback(() => {
|
|
242
|
-
const ws = utils.json_to_sheet(
|
|
222
|
+
const ws = utils.json_to_sheet(data);
|
|
243
223
|
const wb = utils.book_new();
|
|
244
224
|
utils.book_append_sheet(wb, ws, "Data");
|
|
245
225
|
writeFileXLSX(wb, "SheetJSReactAoO.xlsx");
|
|
@@ -265,6 +245,7 @@ function Tabela<T extends MRT_RowData>({
|
|
|
265
245
|
{/* Filtros e titulo */}
|
|
266
246
|
<TabelaHeader<T>
|
|
267
247
|
table={table}
|
|
248
|
+
handleAdicionar={handleAdicionar}
|
|
268
249
|
toogleBuscarColuna={toogleBuscarColuna}
|
|
269
250
|
setToogleBuscarColuna={setToogleBuscarColuna}
|
|
270
251
|
setGlobalFilter={setGlobalFilter}
|
|
@@ -317,12 +298,16 @@ function Tabela<T extends MRT_RowData>({
|
|
|
317
298
|
|
|
318
299
|
{/* Paginação */}
|
|
319
300
|
<S.TabelaPaginationWrapper>
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
301
|
+
{data.length > 0 && (
|
|
302
|
+
<Paginacao
|
|
303
|
+
tamanhoPaginacao={tamanhoPaginacao}
|
|
304
|
+
data={data! ?? []}
|
|
305
|
+
handlePaginationChange={(prev) => setPagination(prev)}
|
|
306
|
+
setTabelaPaginacaoProps={setPagination}
|
|
307
|
+
tabelaPaginacao={pagination}
|
|
308
|
+
|
|
309
|
+
/>
|
|
310
|
+
)}
|
|
326
311
|
</S.TabelaPaginationWrapper>
|
|
327
312
|
</S.TabelaWrapper>
|
|
328
313
|
);
|
|
@@ -106,7 +106,7 @@ export const TabelaBody = styled(Table.Tbody)`
|
|
|
106
106
|
}
|
|
107
107
|
|
|
108
108
|
&:hover {
|
|
109
|
-
opacity: 0.
|
|
109
|
+
opacity: 0.6;
|
|
110
110
|
}
|
|
111
111
|
|
|
112
112
|
&[data-active='true'] {
|
|
@@ -121,7 +121,7 @@ export const TabelaBody = styled(Table.Tbody)`
|
|
|
121
121
|
|
|
122
122
|
.mantine-focus-auto {
|
|
123
123
|
&:hover {
|
|
124
|
-
opacity: 0.
|
|
124
|
+
opacity: 0.6;
|
|
125
125
|
}
|
|
126
126
|
}
|
|
127
127
|
.sticky {
|
|
@@ -180,7 +180,8 @@ export const TabelaPaginationWrapper = styled.div`
|
|
|
180
180
|
`;
|
|
181
181
|
|
|
182
182
|
export const TabelaStoryContainer = styled.div`
|
|
183
|
-
${() => css`
|
|
183
|
+
${({ theme }) => css`
|
|
184
|
+
background-color: ${theme.colors.gray['300']};
|
|
184
185
|
.mrt-table-head-sort-button {
|
|
185
186
|
margin-left: 5px;
|
|
186
187
|
width: 15px;
|
|
@@ -5,28 +5,30 @@ export const useUser = ({ ...props }: GetParams) => {
|
|
|
5
5
|
const handleGetUsuarios = async () => {
|
|
6
6
|
try {
|
|
7
7
|
const { data } = await axios.get(`${props.endpoint}`);
|
|
8
|
-
const dataFormatada =
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
8
|
+
const dataFormatada =
|
|
9
|
+
data?.results ??
|
|
10
|
+
[].map((usuario: any, index: number) => {
|
|
11
|
+
return {
|
|
12
|
+
nome: usuario.name.first,
|
|
13
|
+
email: usuario.email,
|
|
14
|
+
genero: usuario.gender,
|
|
15
|
+
rua: usuario.location.street.name,
|
|
16
|
+
estado: usuario.location.state,
|
|
17
|
+
cidade: usuario.location.city,
|
|
18
|
+
idade: index,
|
|
19
|
+
id: index,
|
|
20
|
+
subRows: [
|
|
21
|
+
{
|
|
22
|
+
nome: 'exemplo',
|
|
23
|
+
email: 'exemplo',
|
|
24
|
+
genero: 'exemplo',
|
|
25
|
+
rua: 'exemplo',
|
|
26
|
+
estado: 'exemplo',
|
|
27
|
+
cidade: 'exemplo',
|
|
28
|
+
},
|
|
29
|
+
],
|
|
30
|
+
};
|
|
31
|
+
});
|
|
30
32
|
return dataFormatada;
|
|
31
33
|
} catch (error) {
|
|
32
34
|
console.error(error);
|