wca-designsystem 0.0.49 → 0.0.51
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/Select/index.tsx +4 -6
- package/src/components/atomos/Select/styles.ts +4 -4
- package/src/components/molecules/Graficos/Area/Area.stories.tsx +94 -0
- package/src/components/molecules/Graficos/Area/Area.test.tsx +102 -0
- package/src/components/molecules/Graficos/Area/index.tsx +76 -0
- package/src/components/molecules/Graficos/Area/styles.ts +53 -0
- package/src/components/molecules/Graficos/Barras/Barras.stories.tsx +104 -0
- package/src/components/molecules/Graficos/Barras/Barras.test.tsx +99 -0
- package/src/components/molecules/Graficos/Barras/index.tsx +28 -0
- package/src/components/molecules/Graficos/Linhas/Linhas.stories.tsx +63 -0
- package/src/components/molecules/Graficos/Linhas/Linhas.test.tsx +99 -0
- package/src/components/molecules/Graficos/Linhas/index.tsx +29 -0
- package/src/components/molecules/TabelaHeader/index.tsx +48 -5
- package/src/components/molecules/TabelaHeader/styles.ts +47 -0
- package/src/components/organismos/Tabela/Tabela.test.tsx +1 -0
- package/src/components/organismos/Tabela/body.tsx +5 -1
- package/src/components/organismos/Tabela/header.tsx +3 -3
- package/src/components/organismos/Tabela/index.tsx +19 -3
- package/src/components/organismos/Tabela/styles.ts +21 -19
package/package.json
CHANGED
|
@@ -9,11 +9,13 @@ import { theme } from '../../../styles/theme';
|
|
|
9
9
|
export interface SelectCustomizadoProps extends SelectProps {
|
|
10
10
|
tipo: 'table' | 'round';
|
|
11
11
|
labelAbaixo?: string;
|
|
12
|
+
color?: string;
|
|
12
13
|
}
|
|
13
14
|
|
|
14
15
|
const SelectCustomizado = ({
|
|
15
16
|
tipo,
|
|
16
17
|
labelAbaixo,
|
|
18
|
+
color,
|
|
17
19
|
...props
|
|
18
20
|
}: SelectCustomizadoProps) => {
|
|
19
21
|
/* Renderiza conforme o tipo que você escolher */
|
|
@@ -40,16 +42,12 @@ const SelectCustomizado = ({
|
|
|
40
42
|
table: (
|
|
41
43
|
<S.SelectTabela
|
|
42
44
|
{...props}
|
|
45
|
+
color={color}
|
|
43
46
|
data-testid="table"
|
|
44
47
|
height={'25px'}
|
|
45
48
|
mih={'25px'}
|
|
46
49
|
rightSection={
|
|
47
|
-
<Icone
|
|
48
|
-
svg={arrowDown}
|
|
49
|
-
width={20}
|
|
50
|
-
height={20}
|
|
51
|
-
fill={theme.colors.blue}
|
|
52
|
-
/>
|
|
50
|
+
<Icone svg={arrowDown} width={20} height={20} fill={color} />
|
|
53
51
|
}
|
|
54
52
|
/>
|
|
55
53
|
),
|
|
@@ -43,20 +43,20 @@ export const RightSelect = styled.div`
|
|
|
43
43
|
`;
|
|
44
44
|
|
|
45
45
|
export const SelectTabela = styled(Select)`
|
|
46
|
-
${({
|
|
46
|
+
${({ color }) => css`
|
|
47
47
|
border-radius: 5px;
|
|
48
48
|
|
|
49
49
|
input {
|
|
50
50
|
min-height: 25px;
|
|
51
51
|
height: 25px;
|
|
52
|
-
box-shadow: 0px 2px 3px 0px ${
|
|
52
|
+
box-shadow: 0px 2px 3px 0px ${color};
|
|
53
53
|
border: none;
|
|
54
|
-
color: ${
|
|
54
|
+
color: ${color};
|
|
55
55
|
background-color: transparent;
|
|
56
56
|
font-weight: bold;
|
|
57
57
|
|
|
58
58
|
&::placeholder {
|
|
59
|
-
color: ${
|
|
59
|
+
color: ${color};
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
62
|
`}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import AreaChart, { AreaWrapperProps, DataInfoProps } from './index';
|
|
3
|
+
import { Meta } from '@storybook/react/*';
|
|
4
|
+
|
|
5
|
+
import '@mantine/charts/styles.css';
|
|
6
|
+
|
|
7
|
+
export default {
|
|
8
|
+
title: 'Components/moleculas/Graficos/Area',
|
|
9
|
+
component: AreaChart,
|
|
10
|
+
} as Meta;
|
|
11
|
+
|
|
12
|
+
const data = [
|
|
13
|
+
{ date: 1, Apples: 110 },
|
|
14
|
+
{ date: 2, Apples: 600 },
|
|
15
|
+
{ date: 3, Apples: 800 },
|
|
16
|
+
{ date: 4, Apples: 500 },
|
|
17
|
+
{ date: 5, Apples: 1000 },
|
|
18
|
+
{ date: 6, Apples: 400 },
|
|
19
|
+
{ date: 7, Apples: 1200 },
|
|
20
|
+
{ date: 8, Apples: 800 },
|
|
21
|
+
{ date: 9, Apples: 950 },
|
|
22
|
+
{ date: 10, Apples: 700 },
|
|
23
|
+
{ date: 11, Apples: 850 },
|
|
24
|
+
{ date: 12, Apples: 550 },
|
|
25
|
+
{ date: 13, Apples: 900 },
|
|
26
|
+
{ date: 14, Apples: 750 },
|
|
27
|
+
{ date: 15, Apples: 600 },
|
|
28
|
+
{ date: 16, Apples: 1100 },
|
|
29
|
+
{ date: 17, Apples: 500 },
|
|
30
|
+
{ date: 18, Apples: 100 },
|
|
31
|
+
{ date: 19, Apples: 0 },
|
|
32
|
+
{ date: 20, Apples: 850 },
|
|
33
|
+
{ date: 21, Apples: 700 },
|
|
34
|
+
{ date: 22, Apples: 650 },
|
|
35
|
+
{ date: 23, Apples: 0 },
|
|
36
|
+
{ date: 24, Apples: 800 },
|
|
37
|
+
{ date: 25, Apples: 1200 },
|
|
38
|
+
{ date: 26, Apples: 1050 },
|
|
39
|
+
{ date: 27, Apples: 500 },
|
|
40
|
+
{ date: 28, Apples: 950 },
|
|
41
|
+
{ date: 29, Apples: 700 },
|
|
42
|
+
{ date: 30, Apples: 800 },
|
|
43
|
+
];
|
|
44
|
+
|
|
45
|
+
const dataInfo: Array<DataInfoProps> = [
|
|
46
|
+
{
|
|
47
|
+
id: 'info-1',
|
|
48
|
+
dataLabel: 'Total Data (01)',
|
|
49
|
+
dataValores: '89,529',
|
|
50
|
+
color: '#1151b1',
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
id: 'info-2',
|
|
54
|
+
dataLabel: 'Data (02)',
|
|
55
|
+
dataValores: '83,529',
|
|
56
|
+
color: '#1151b1',
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
id: 'info-3',
|
|
60
|
+
dataLabel: 'Data (03)',
|
|
61
|
+
dataValores: '5,000',
|
|
62
|
+
color: '#1151b1',
|
|
63
|
+
},
|
|
64
|
+
];
|
|
65
|
+
|
|
66
|
+
const series = [{ name: 'Apples', color: '#ACC0DE' }];
|
|
67
|
+
|
|
68
|
+
const props: AreaWrapperProps = {
|
|
69
|
+
data: data,
|
|
70
|
+
series: series,
|
|
71
|
+
dataKey: 'date',
|
|
72
|
+
bg: '#EEE',
|
|
73
|
+
w: undefined,
|
|
74
|
+
h: undefined,
|
|
75
|
+
withLegend: false,
|
|
76
|
+
datainfo: dataInfo,
|
|
77
|
+
titulo: 'Título',
|
|
78
|
+
subtitulo: 'Texto explicativo curto',
|
|
79
|
+
containerinfo: true,
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
const Template: any = (args: AreaWrapperProps) => (
|
|
83
|
+
<>
|
|
84
|
+
<AreaChart {...args} />
|
|
85
|
+
</>
|
|
86
|
+
);
|
|
87
|
+
|
|
88
|
+
export const AreaStory = Template.bind({
|
|
89
|
+
...props,
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
AreaStory.args = {
|
|
93
|
+
...props,
|
|
94
|
+
};
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render } from '../../../../test/render';
|
|
3
|
+
import AreaWrapper from './index';
|
|
4
|
+
|
|
5
|
+
const mockData = [
|
|
6
|
+
{ name: 'Janeiro', value: 50 },
|
|
7
|
+
{ name: 'Fevereiro', value: 80 },
|
|
8
|
+
{ name: 'Março', value: 40 },
|
|
9
|
+
];
|
|
10
|
+
|
|
11
|
+
const mockSeries = [{ name: 'Série 1', color: '#ACC0DE' }];
|
|
12
|
+
|
|
13
|
+
describe('Componente AreaChart', () => {
|
|
14
|
+
test('Renderiza com informações de título e subtítulo', () => {
|
|
15
|
+
const { getByText } = render(
|
|
16
|
+
<AreaWrapper
|
|
17
|
+
titulo="Título Teste"
|
|
18
|
+
subtitulo="Subtítulo Teste"
|
|
19
|
+
containerinfo={true}
|
|
20
|
+
data={mockData}
|
|
21
|
+
series={mockSeries}
|
|
22
|
+
dataKey="value"
|
|
23
|
+
/>
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
expect(getByText('Título Teste')).toBeDefined();
|
|
27
|
+
expect(getByText('Subtítulo Teste')).toBeDefined();
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
test('Renderiza os elementos de DataInfo corretamente', () => {
|
|
31
|
+
const mockDataInfo = [
|
|
32
|
+
{ id: '1', dataValores: '10%', dataLabel: 'Janeiro', color: '#FF0000' },
|
|
33
|
+
{ id: '2', dataValores: '20%', dataLabel: 'Fevereiro', color: '#00FF00' },
|
|
34
|
+
];
|
|
35
|
+
|
|
36
|
+
const { getByText, container } = render(
|
|
37
|
+
<AreaWrapper
|
|
38
|
+
datainfo={mockDataInfo}
|
|
39
|
+
containerinfo={true}
|
|
40
|
+
data={mockData}
|
|
41
|
+
series={mockSeries}
|
|
42
|
+
dataKey="value"
|
|
43
|
+
/>
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
mockDataInfo.forEach(({ dataValores, dataLabel, color }) => {
|
|
47
|
+
expect(getByText(dataValores)).toBeDefined();
|
|
48
|
+
expect(getByText(dataLabel)).toBeDefined();
|
|
49
|
+
|
|
50
|
+
const colorBox = container.querySelector(
|
|
51
|
+
`[style="background-color: ${color};"]`
|
|
52
|
+
);
|
|
53
|
+
expect(colorBox).toBeDefined();
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
test('Renderiza o gráfico corretamente com dados fornecidos', () => {
|
|
58
|
+
const { container } = render(
|
|
59
|
+
<AreaWrapper
|
|
60
|
+
data={mockData}
|
|
61
|
+
series={mockSeries}
|
|
62
|
+
dataKey="value"
|
|
63
|
+
containerinfo={false}
|
|
64
|
+
/>
|
|
65
|
+
);
|
|
66
|
+
|
|
67
|
+
// Verifica se o gráfico foi montado na DOM
|
|
68
|
+
const chartElement = container.querySelector('svg');
|
|
69
|
+
expect(chartElement).toBeDefined();
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
test('Lida com ausência de dados', () => {
|
|
73
|
+
const { container } = render(
|
|
74
|
+
<AreaWrapper
|
|
75
|
+
data={[]}
|
|
76
|
+
series={mockSeries}
|
|
77
|
+
dataKey="value"
|
|
78
|
+
containerinfo={false}
|
|
79
|
+
/>
|
|
80
|
+
);
|
|
81
|
+
|
|
82
|
+
// Verifica se o gráfico não exibe informações
|
|
83
|
+
const chartElement = container.querySelector('svg');
|
|
84
|
+
expect(chartElement).toBeDefined(); // Gráfico deve existir
|
|
85
|
+
expect(container.textContent).not.toContain('%'); // Não deve exibir valores
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
test('Renderiza corretamente com containerinfo false', () => {
|
|
89
|
+
const { container, queryByText } = render(
|
|
90
|
+
<AreaWrapper
|
|
91
|
+
containerinfo={false}
|
|
92
|
+
data={mockData}
|
|
93
|
+
series={mockSeries}
|
|
94
|
+
dataKey="value"
|
|
95
|
+
/>
|
|
96
|
+
);
|
|
97
|
+
|
|
98
|
+
// Verifica que informações do container não foram renderizadas
|
|
99
|
+
expect(queryByText('Título Teste')).toBeNull();
|
|
100
|
+
expect(container.querySelector('.data-valores')).toBeNull();
|
|
101
|
+
});
|
|
102
|
+
});
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { AreaChart, AreaChartProps } from '@mantine/charts';
|
|
2
|
+
import {
|
|
3
|
+
Titulo,
|
|
4
|
+
SubTitulo,
|
|
5
|
+
DataInfo,
|
|
6
|
+
ContainerInfo,
|
|
7
|
+
ContainerGrafico,
|
|
8
|
+
} from './styles';
|
|
9
|
+
import React from 'react';
|
|
10
|
+
import { Flex } from '@mantine/core';
|
|
11
|
+
|
|
12
|
+
export interface DataInfoProps {
|
|
13
|
+
id: string;
|
|
14
|
+
dataValores: string;
|
|
15
|
+
dataLabel: string;
|
|
16
|
+
color?: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface AreaWrapperProps extends AreaChartProps {
|
|
20
|
+
titulo?: string;
|
|
21
|
+
corTitulo?: string;
|
|
22
|
+
subtitulo?: string;
|
|
23
|
+
datainfo?: Array<DataInfoProps>;
|
|
24
|
+
containerinfo: boolean;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const AreaWrapper = ({
|
|
28
|
+
data,
|
|
29
|
+
series,
|
|
30
|
+
dataKey,
|
|
31
|
+
h,
|
|
32
|
+
w,
|
|
33
|
+
withLegend,
|
|
34
|
+
bg,
|
|
35
|
+
titulo,
|
|
36
|
+
subtitulo,
|
|
37
|
+
datainfo,
|
|
38
|
+
containerinfo,
|
|
39
|
+
corTitulo,
|
|
40
|
+
}: AreaWrapperProps) => {
|
|
41
|
+
return (
|
|
42
|
+
<ContainerGrafico bg={bg} width={w}>
|
|
43
|
+
{containerinfo && (
|
|
44
|
+
<ContainerInfo>
|
|
45
|
+
<Titulo color={corTitulo ?? '#316FCD'}>{titulo}</Titulo>
|
|
46
|
+
<SubTitulo>{subtitulo}</SubTitulo>
|
|
47
|
+
<Flex>
|
|
48
|
+
{datainfo?.map(({ id, color, dataLabel, dataValores }) => (
|
|
49
|
+
<DataInfo key={id} color={color}>
|
|
50
|
+
<div className="data-valores">{dataValores}</div>
|
|
51
|
+
<p className="data-texto">{dataLabel}</p>
|
|
52
|
+
</DataInfo>
|
|
53
|
+
))}
|
|
54
|
+
</Flex>
|
|
55
|
+
</ContainerInfo>
|
|
56
|
+
)}
|
|
57
|
+
<AreaChart
|
|
58
|
+
fillOpacity={0.9}
|
|
59
|
+
bg={bg}
|
|
60
|
+
w={w}
|
|
61
|
+
h={h ?? 300}
|
|
62
|
+
data={data}
|
|
63
|
+
series={series}
|
|
64
|
+
dataKey={dataKey}
|
|
65
|
+
withLegend={withLegend}
|
|
66
|
+
gridAxis="none"
|
|
67
|
+
curveType="linear"
|
|
68
|
+
withDots={false}
|
|
69
|
+
withGradient={false}
|
|
70
|
+
tooltipAnimationDuration={200}
|
|
71
|
+
/>
|
|
72
|
+
</ContainerGrafico>
|
|
73
|
+
);
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
export default AreaWrapper;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { DefaultMantineColor, StyleProp } from '@mantine/core';
|
|
2
|
+
import styled, { css } from 'styled-components';
|
|
3
|
+
|
|
4
|
+
export const Titulo = styled.h2`
|
|
5
|
+
color: ${({ color }) => color};
|
|
6
|
+
margin-bottom: 5px;
|
|
7
|
+
`;
|
|
8
|
+
|
|
9
|
+
export const SubTitulo = styled.p`
|
|
10
|
+
color: #a8a7aa;
|
|
11
|
+
margin: 0;
|
|
12
|
+
margin-bottom: 20px;
|
|
13
|
+
`;
|
|
14
|
+
|
|
15
|
+
export const DataInfo = styled.div`
|
|
16
|
+
${({ color }) => css`
|
|
17
|
+
display: flex;
|
|
18
|
+
flex-direction: column;
|
|
19
|
+
width: 33.3%;
|
|
20
|
+
margin-bottom: 20px;
|
|
21
|
+
|
|
22
|
+
.data-valores {
|
|
23
|
+
font-weight: bold;
|
|
24
|
+
font-size: 24px;
|
|
25
|
+
color: ${color};
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.data-texto {
|
|
29
|
+
color: #a8a7aa;
|
|
30
|
+
margin: 0;
|
|
31
|
+
}
|
|
32
|
+
`}
|
|
33
|
+
`;
|
|
34
|
+
|
|
35
|
+
interface ContainerInfoProps {
|
|
36
|
+
bg?: StyleProp<DefaultMantineColor>;
|
|
37
|
+
width?: StyleProp<React.CSSProperties['width']>;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export const ContainerInfo = styled.div`
|
|
41
|
+
padding-left: 20px;
|
|
42
|
+
`;
|
|
43
|
+
|
|
44
|
+
export const ContainerGrafico = styled.div<ContainerInfoProps>`
|
|
45
|
+
${({ bg, width }: ContainerInfoProps) => css`
|
|
46
|
+
background-color: ${bg ?? '#FFF'};
|
|
47
|
+
max-width: ${width
|
|
48
|
+
? typeof width === 'string'
|
|
49
|
+
? width
|
|
50
|
+
: `${width}px`
|
|
51
|
+
: '100%'};
|
|
52
|
+
`}
|
|
53
|
+
`;
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import BarChart from './index';
|
|
3
|
+
import { Meta } from '@storybook/react/*';
|
|
4
|
+
import { BarChartProps, ChartReferenceLineProps } from '@mantine/charts';
|
|
5
|
+
|
|
6
|
+
import '@mantine/charts/styles.css';
|
|
7
|
+
|
|
8
|
+
export default {
|
|
9
|
+
title: 'Components/moleculas/Graficos/Barras',
|
|
10
|
+
component: BarChart,
|
|
11
|
+
} as Meta;
|
|
12
|
+
|
|
13
|
+
const data = [
|
|
14
|
+
{
|
|
15
|
+
day: 'Monday',
|
|
16
|
+
Smartphones: 1200,
|
|
17
|
+
Laptops: 900,
|
|
18
|
+
Tablets: 200,
|
|
19
|
+
Cellphone: 700,
|
|
20
|
+
Tv: 280,
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
day: 'Tuesday',
|
|
24
|
+
Smartphones: 1900,
|
|
25
|
+
Laptops: [1000, 1200],
|
|
26
|
+
Tablets: 400,
|
|
27
|
+
Cellphone: 700,
|
|
28
|
+
Tv: 280,
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
day: 'Wednesday',
|
|
32
|
+
Smartphones: 400,
|
|
33
|
+
Laptops: 1000,
|
|
34
|
+
Tablets: 200,
|
|
35
|
+
Cellphone: 500,
|
|
36
|
+
Tv: 580,
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
day: 'Thursday',
|
|
40
|
+
Smartphones: 1000,
|
|
41
|
+
Laptops: 200,
|
|
42
|
+
Tablets: 800,
|
|
43
|
+
Cellphone: 200,
|
|
44
|
+
Tv: 480,
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
day: 'Friday',
|
|
48
|
+
Smartphones: 800,
|
|
49
|
+
Laptops: 1400,
|
|
50
|
+
Tablets: 1200,
|
|
51
|
+
Cellphone: 300,
|
|
52
|
+
Tv: 380,
|
|
53
|
+
},
|
|
54
|
+
];
|
|
55
|
+
|
|
56
|
+
const data_alt = [
|
|
57
|
+
{ cargo: 'Previsão', info: 1250, color: '#007CFA' },
|
|
58
|
+
{ cargo: 'Regional 1', info: [1000, 1420], color: '#ED0E09' },
|
|
59
|
+
{ cargo: 'Regional 2', info: [800, 1100], color: '#FFDE00' },
|
|
60
|
+
{ cargo: 'Regional 3', info: [900, 1200], color: '#35BC00' },
|
|
61
|
+
{ cargo: 'Meta', info: 1250, color: '#7030A0' },
|
|
62
|
+
];
|
|
63
|
+
|
|
64
|
+
const series = [
|
|
65
|
+
{ name: 'Smartphones', color: '#0D47A1' },
|
|
66
|
+
{ name: 'Laptops', color: '#1E88E5' },
|
|
67
|
+
{ name: 'Tablets', color: '#42A5F5' },
|
|
68
|
+
{ name: 'Cellphone', color: '#81D4FA' },
|
|
69
|
+
{ name: 'Tv', color: '#97eaf5' },
|
|
70
|
+
];
|
|
71
|
+
|
|
72
|
+
const series_alt = [{ name: 'info', color: '#000' }];
|
|
73
|
+
|
|
74
|
+
const referenceLines: ChartReferenceLineProps[] = [
|
|
75
|
+
{
|
|
76
|
+
y: 1335,
|
|
77
|
+
color: 'red',
|
|
78
|
+
label: 'Meta',
|
|
79
|
+
labelPosition: 'insideTopRight',
|
|
80
|
+
},
|
|
81
|
+
];
|
|
82
|
+
|
|
83
|
+
const props: BarChartProps = {
|
|
84
|
+
data: data_alt,
|
|
85
|
+
series: series_alt,
|
|
86
|
+
dataKey: 'cargo',
|
|
87
|
+
h: 280,
|
|
88
|
+
referenceLines: referenceLines,
|
|
89
|
+
withLegend: true,
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
const Template: any = (args: BarChartProps) => (
|
|
93
|
+
<>
|
|
94
|
+
<BarChart {...args} />
|
|
95
|
+
</>
|
|
96
|
+
);
|
|
97
|
+
|
|
98
|
+
export const BarraStory = Template.bind({
|
|
99
|
+
...props,
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
BarraStory.args = {
|
|
103
|
+
...props,
|
|
104
|
+
};
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render } from '../../../../test/render';
|
|
3
|
+
import BarWrapper from './index';
|
|
4
|
+
|
|
5
|
+
const mockData = [
|
|
6
|
+
{ name: 'Janeiro', value: 50 },
|
|
7
|
+
{ name: 'Fevereiro', value: 80 },
|
|
8
|
+
{ name: 'Março', value: 40 },
|
|
9
|
+
];
|
|
10
|
+
|
|
11
|
+
const mockSeries = [{ name: 'Série 1', color: '#ACC0DE', dataKey: 'value' }];
|
|
12
|
+
|
|
13
|
+
describe('Componente BarWrapper', () => {
|
|
14
|
+
test('Renderiza com dados e séries fornecidos', () => {
|
|
15
|
+
const { container } = render(
|
|
16
|
+
<BarWrapper
|
|
17
|
+
data={mockData}
|
|
18
|
+
series={mockSeries}
|
|
19
|
+
dataKey="value"
|
|
20
|
+
withLegend={false}
|
|
21
|
+
h={400}
|
|
22
|
+
/>
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
// Verifica se o gráfico foi montado na DOM
|
|
26
|
+
const elementoGrafico = container.querySelector('svg');
|
|
27
|
+
expect(elementoGrafico).toBeDefined();
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
test('Renderiza legenda quando withLegend é true', () => {
|
|
31
|
+
const { container } = render(
|
|
32
|
+
<BarWrapper
|
|
33
|
+
data={mockData}
|
|
34
|
+
series={mockSeries}
|
|
35
|
+
dataKey="value"
|
|
36
|
+
withLegend={true}
|
|
37
|
+
h={400}
|
|
38
|
+
/>
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
const elementoLegenda = container.querySelector('.mantine-legend');
|
|
42
|
+
expect(elementoLegenda).toBeDefined();
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
test('Lida corretamente com dados vazios', () => {
|
|
46
|
+
const { container } = render(
|
|
47
|
+
<BarWrapper
|
|
48
|
+
data={[]}
|
|
49
|
+
series={mockSeries}
|
|
50
|
+
dataKey="value"
|
|
51
|
+
withLegend={false}
|
|
52
|
+
h={400}
|
|
53
|
+
/>
|
|
54
|
+
);
|
|
55
|
+
|
|
56
|
+
// Gráfico deve existir, mas sem barras
|
|
57
|
+
const elementoGrafico = container.querySelector('svg');
|
|
58
|
+
expect(elementoGrafico).toBeDefined();
|
|
59
|
+
expect(container.textContent).not.toContain('%'); // Sem valores renderizados
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
test('Aplica linhas de referência corretamente', () => {
|
|
63
|
+
const mockReferenceLines = [{ y: 60, label: 'Média', color: 'red' }];
|
|
64
|
+
|
|
65
|
+
const { container } = render(
|
|
66
|
+
<BarWrapper
|
|
67
|
+
data={mockData}
|
|
68
|
+
series={mockSeries}
|
|
69
|
+
dataKey="value"
|
|
70
|
+
referenceLines={mockReferenceLines}
|
|
71
|
+
withLegend={false}
|
|
72
|
+
h={400}
|
|
73
|
+
/>
|
|
74
|
+
);
|
|
75
|
+
|
|
76
|
+
const elementoLinhaReferencia = container.querySelector(
|
|
77
|
+
'[style*="stroke: red"]'
|
|
78
|
+
);
|
|
79
|
+
expect(elementoLinhaReferencia).toBeDefined();
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
test('Ajusta altura com base na propriedade h', () => {
|
|
83
|
+
const alturaCustomizada = 500;
|
|
84
|
+
const { container } = render(
|
|
85
|
+
<BarWrapper
|
|
86
|
+
data={mockData}
|
|
87
|
+
series={mockSeries}
|
|
88
|
+
dataKey="value"
|
|
89
|
+
withLegend={false}
|
|
90
|
+
h={alturaCustomizada}
|
|
91
|
+
/>
|
|
92
|
+
);
|
|
93
|
+
|
|
94
|
+
const elementoGrafico = container.querySelector('svg');
|
|
95
|
+
expect(elementoGrafico?.getAttribute('height')).toEqual(
|
|
96
|
+
alturaCustomizada.toString()
|
|
97
|
+
);
|
|
98
|
+
});
|
|
99
|
+
});
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { BarChart, BarChartProps } from '@mantine/charts';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
|
|
4
|
+
const BarWrapper = ({
|
|
5
|
+
data,
|
|
6
|
+
series,
|
|
7
|
+
dataKey,
|
|
8
|
+
referenceLines,
|
|
9
|
+
h,
|
|
10
|
+
withLegend,
|
|
11
|
+
type,
|
|
12
|
+
}: BarChartProps) => {
|
|
13
|
+
return (
|
|
14
|
+
<BarChart
|
|
15
|
+
data={data}
|
|
16
|
+
series={series}
|
|
17
|
+
referenceLines={referenceLines}
|
|
18
|
+
dataKey={dataKey}
|
|
19
|
+
withLegend={withLegend}
|
|
20
|
+
type={type}
|
|
21
|
+
tooltipAnimationDuration={200}
|
|
22
|
+
gridAxis="xy"
|
|
23
|
+
h={h}
|
|
24
|
+
/>
|
|
25
|
+
);
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export default BarWrapper;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import LinesChart from './index';
|
|
3
|
+
import { Meta } from '@storybook/react/*';
|
|
4
|
+
import { LineChartProps } from '@mantine/charts';
|
|
5
|
+
|
|
6
|
+
import '@mantine/charts/styles.css';
|
|
7
|
+
|
|
8
|
+
export default {
|
|
9
|
+
title: 'Components/moleculas/Graficos/Linhas',
|
|
10
|
+
component: LinesChart,
|
|
11
|
+
} as Meta;
|
|
12
|
+
|
|
13
|
+
const data = [
|
|
14
|
+
{
|
|
15
|
+
hour: '12:00',
|
|
16
|
+
Apples: 110,
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
hour: '13:00',
|
|
20
|
+
Apples: 60,
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
hour: '14:00',
|
|
24
|
+
Apples: 80,
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
hour: '15:00',
|
|
28
|
+
Apples: 75,
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
hour: '16:00',
|
|
32
|
+
Apples: 65,
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
hour: '17:00',
|
|
36
|
+
Apples: 40,
|
|
37
|
+
},
|
|
38
|
+
];
|
|
39
|
+
|
|
40
|
+
const series = [{ name: 'Apples', color: 'indigo' }];
|
|
41
|
+
|
|
42
|
+
const props: LineChartProps = {
|
|
43
|
+
data: data,
|
|
44
|
+
series: series,
|
|
45
|
+
dataKey: 'hour',
|
|
46
|
+
h: 280,
|
|
47
|
+
withLegend: true,
|
|
48
|
+
color: 'red',
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
const Template: any = (args: LineChartProps) => (
|
|
52
|
+
<>
|
|
53
|
+
<LinesChart {...args} />
|
|
54
|
+
</>
|
|
55
|
+
);
|
|
56
|
+
|
|
57
|
+
export const LinesStory = Template.bind({
|
|
58
|
+
...props,
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
LinesStory.args = {
|
|
62
|
+
...props,
|
|
63
|
+
};
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render } from '../../../../test/render';
|
|
3
|
+
import LinesWrapper from './index';
|
|
4
|
+
|
|
5
|
+
const mockData = [
|
|
6
|
+
{ name: 'Janeiro', value: 50 },
|
|
7
|
+
{ name: 'Fevereiro', value: 80 },
|
|
8
|
+
{ name: 'Março', value: 40 },
|
|
9
|
+
];
|
|
10
|
+
|
|
11
|
+
const mockSeries = [{ name: 'Série 1', color: '#ACC0DE', dataKey: 'value' }];
|
|
12
|
+
|
|
13
|
+
describe('Componente LinesWrapper', () => {
|
|
14
|
+
test('Renderiza com dados e séries fornecidos', () => {
|
|
15
|
+
const { container } = render(
|
|
16
|
+
<LinesWrapper
|
|
17
|
+
data={mockData}
|
|
18
|
+
series={mockSeries}
|
|
19
|
+
dataKey="value"
|
|
20
|
+
withLegend={false}
|
|
21
|
+
h={400}
|
|
22
|
+
color="#ACC0DE"
|
|
23
|
+
/>
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
const chartElement = container.querySelector('svg');
|
|
27
|
+
expect(chartElement).toBeDefined();
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
test('Renderiza legenda quando withLegend é true', () => {
|
|
31
|
+
const { container } = render(
|
|
32
|
+
<LinesWrapper
|
|
33
|
+
data={mockData}
|
|
34
|
+
series={mockSeries}
|
|
35
|
+
dataKey="value"
|
|
36
|
+
withLegend={true}
|
|
37
|
+
h={400}
|
|
38
|
+
color="#ACC0DE"
|
|
39
|
+
/>
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
const legendElement = container.querySelector('.mantine-legend');
|
|
43
|
+
expect(legendElement).toBeDefined();
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
test('Lida com ausência de dados de forma adequada', () => {
|
|
47
|
+
const { container } = render(
|
|
48
|
+
<LinesWrapper
|
|
49
|
+
data={[]}
|
|
50
|
+
series={mockSeries}
|
|
51
|
+
dataKey="value"
|
|
52
|
+
withLegend={false}
|
|
53
|
+
h={400}
|
|
54
|
+
color="#ACC0DE"
|
|
55
|
+
/>
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
const chartElement = container.querySelector('svg');
|
|
59
|
+
expect(chartElement).toBeDefined();
|
|
60
|
+
expect(container.textContent).not.toContain('%'); // Sem valores renderizados
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
test('Aplica altura personalizada com base na propriedade h', () => {
|
|
64
|
+
const customHeight = 500;
|
|
65
|
+
const { container } = render(
|
|
66
|
+
<LinesWrapper
|
|
67
|
+
data={mockData}
|
|
68
|
+
series={mockSeries}
|
|
69
|
+
dataKey="value"
|
|
70
|
+
withLegend={false}
|
|
71
|
+
h={customHeight}
|
|
72
|
+
color="#ACC0DE"
|
|
73
|
+
/>
|
|
74
|
+
);
|
|
75
|
+
|
|
76
|
+
const chartElement = container.querySelector('svg');
|
|
77
|
+
expect(chartElement?.getAttribute('height')).toEqual(
|
|
78
|
+
customHeight.toString()
|
|
79
|
+
);
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
test('Aplica corretamente as propriedades de cor nos pontos e pontos ativos', () => {
|
|
83
|
+
const customColor = '#FF5733';
|
|
84
|
+
|
|
85
|
+
const { container } = render(
|
|
86
|
+
<LinesWrapper
|
|
87
|
+
data={mockData}
|
|
88
|
+
series={mockSeries}
|
|
89
|
+
dataKey="value"
|
|
90
|
+
withLegend={false}
|
|
91
|
+
h={400}
|
|
92
|
+
color={customColor}
|
|
93
|
+
/>
|
|
94
|
+
);
|
|
95
|
+
|
|
96
|
+
const dots = container.querySelectorAll('[r="2.5"][fill="#FF5733"]');
|
|
97
|
+
expect(dots.length).toBeGreaterThan(0); // Certifica que os pontos possuem a cor customizada
|
|
98
|
+
});
|
|
99
|
+
});
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { LineChart, LineChartProps } from '@mantine/charts';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
|
|
4
|
+
const LinesWrapper = ({
|
|
5
|
+
data,
|
|
6
|
+
series,
|
|
7
|
+
dataKey,
|
|
8
|
+
withLegend,
|
|
9
|
+
h,
|
|
10
|
+
color,
|
|
11
|
+
}: LineChartProps) => {
|
|
12
|
+
return (
|
|
13
|
+
<>
|
|
14
|
+
<LineChart
|
|
15
|
+
h={h ?? 300}
|
|
16
|
+
data={data}
|
|
17
|
+
series={series}
|
|
18
|
+
dataKey={dataKey}
|
|
19
|
+
withLegend={withLegend}
|
|
20
|
+
dotProps={{ r: 2.5, strokeWidth: 0, fill: color }}
|
|
21
|
+
activeDotProps={{ r: 2.5, strokeWidth: 0, fill: color }}
|
|
22
|
+
gridAxis="xy"
|
|
23
|
+
curveType="linear"
|
|
24
|
+
/>
|
|
25
|
+
</>
|
|
26
|
+
);
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export default LinesWrapper;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { useCallback } from 'react';
|
|
2
2
|
import * as S from './styles';
|
|
3
3
|
import InputDeTexto from '../../atomos/InputDeTexto';
|
|
4
4
|
import SelectCustomizado from '../../atomos/Select';
|
|
@@ -7,11 +7,15 @@ import IconeBotao from '../../atomos/IconeBotao';
|
|
|
7
7
|
import Botao from '../../atomos/Botao';
|
|
8
8
|
import pesquisar from '../../../assets/imagens/icons/Busca.svg';
|
|
9
9
|
import ordernar from '../../../assets/imagens/icons/Ordernar.svg';
|
|
10
|
-
import { SelectDataProps } from '../../organismos/Tabela';
|
|
10
|
+
import { Column, SelectDataProps } from '../../organismos/Tabela';
|
|
11
11
|
import filtrar from '../../../assets/imagens/icons/Filtrar.svg';
|
|
12
|
+
import colunas from '../../../assets/imagens/icons/Colunas.svg';
|
|
12
13
|
import plus from '../../../assets/imagens/icons/Mais.svg';
|
|
14
|
+
import { Menu, Switch } from '@mantine/core';
|
|
13
15
|
|
|
14
|
-
export type TabelaHeaderProps
|
|
16
|
+
export type TabelaHeaderProps<
|
|
17
|
+
T extends { id: string | number; children: Array<T> }
|
|
18
|
+
> = {
|
|
15
19
|
globalFilter: string;
|
|
16
20
|
setGlobalFilter: React.Dispatch<React.SetStateAction<string>>;
|
|
17
21
|
setToogleFiltros: React.Dispatch<React.SetStateAction<boolean>>;
|
|
@@ -23,20 +27,33 @@ export type TabelaHeaderProps = {
|
|
|
23
27
|
handleAdicionar?: () => void;
|
|
24
28
|
ordenarPor?: SelectDataProps;
|
|
25
29
|
hasFiltersButtons?: boolean;
|
|
30
|
+
columns: Column<T>[];
|
|
31
|
+
setFormatedColumns: React.Dispatch<React.SetStateAction<Column<T>[]>>;
|
|
26
32
|
};
|
|
27
|
-
const TabelaHeader = ({
|
|
33
|
+
const TabelaHeader = <T extends { id: string | number; children: Array<T> }>({
|
|
28
34
|
globalFilter,
|
|
29
35
|
setGlobalFilter,
|
|
30
36
|
setToogleFiltros,
|
|
31
37
|
toogleFiltros,
|
|
32
38
|
color,
|
|
33
39
|
hasAdd,
|
|
40
|
+
columns,
|
|
34
41
|
hasFiltersButtons,
|
|
35
42
|
handleAdicionar,
|
|
36
43
|
ordenarPor,
|
|
37
44
|
setOrdenarPor,
|
|
45
|
+
setFormatedColumns,
|
|
38
46
|
hasOrder,
|
|
39
|
-
}: TabelaHeaderProps) => {
|
|
47
|
+
}: TabelaHeaderProps<T>) => {
|
|
48
|
+
const onChangeCheckedColumn = useCallback((column: string) => {
|
|
49
|
+
const columnsFormated = columns.map(columnFiltered => {
|
|
50
|
+
if (columnFiltered.key === column) {
|
|
51
|
+
columnFiltered.active = !columnFiltered.active;
|
|
52
|
+
}
|
|
53
|
+
return columnFiltered;
|
|
54
|
+
});
|
|
55
|
+
setFormatedColumns(columnsFormated);
|
|
56
|
+
}, []);
|
|
40
57
|
return (
|
|
41
58
|
<S.HeaderTableContent>
|
|
42
59
|
<InputDeTexto
|
|
@@ -47,6 +64,31 @@ const TabelaHeader = ({
|
|
|
47
64
|
placeholder="Pesquisar na tabela"
|
|
48
65
|
rightSection={<Icone svg={pesquisar} fill={color} />}
|
|
49
66
|
/>
|
|
67
|
+
<S.ToogleMenuColunas
|
|
68
|
+
color={color}
|
|
69
|
+
shadow="md"
|
|
70
|
+
width={150}
|
|
71
|
+
closeOnClickOutside={false}
|
|
72
|
+
>
|
|
73
|
+
<Menu.Target>
|
|
74
|
+
<button type="button" title="Toogle Colunas">
|
|
75
|
+
<Icone svg={colunas} fill={color} />
|
|
76
|
+
</button>
|
|
77
|
+
</Menu.Target>
|
|
78
|
+
<Menu.Dropdown>
|
|
79
|
+
{columns?.map(column => (
|
|
80
|
+
<Menu.Item key={String(column.key)}>
|
|
81
|
+
<S.MenuDropDown>
|
|
82
|
+
<Switch
|
|
83
|
+
checked={column.active}
|
|
84
|
+
onChange={() => onChangeCheckedColumn(String(column.key))}
|
|
85
|
+
/>
|
|
86
|
+
{column.header}
|
|
87
|
+
</S.MenuDropDown>
|
|
88
|
+
</Menu.Item>
|
|
89
|
+
))}
|
|
90
|
+
</Menu.Dropdown>
|
|
91
|
+
</S.ToogleMenuColunas>
|
|
50
92
|
{hasOrder && (
|
|
51
93
|
<SelectCustomizado
|
|
52
94
|
tipo="table"
|
|
@@ -57,6 +99,7 @@ const TabelaHeader = ({
|
|
|
57
99
|
onChange={(_value, option) => setOrdenarPor!(option)}
|
|
58
100
|
value={ordenarPor ? ordenarPor.value : null}
|
|
59
101
|
placeholder={`Ordenar por ${ordenarPor}`}
|
|
102
|
+
color={color}
|
|
60
103
|
maw={200}
|
|
61
104
|
comboboxProps={{
|
|
62
105
|
position: 'bottom',
|
|
@@ -1,5 +1,10 @@
|
|
|
1
|
+
import { Menu } from '@mantine/core';
|
|
1
2
|
import styled, { css } from 'styled-components';
|
|
2
3
|
|
|
4
|
+
type MenuColunaProps = {
|
|
5
|
+
color?: string;
|
|
6
|
+
};
|
|
7
|
+
|
|
3
8
|
export const HeaderTableContent = styled.div`
|
|
4
9
|
${({ theme }) => css`
|
|
5
10
|
display: flex;
|
|
@@ -14,3 +19,45 @@ export const HeaderTableContent = styled.div`
|
|
|
14
19
|
export const ToogleButton = styled.div`
|
|
15
20
|
${() => css``}
|
|
16
21
|
`;
|
|
22
|
+
|
|
23
|
+
export const ToogleMenuColunas = styled(Menu)<MenuColunaProps>`
|
|
24
|
+
${({ theme, color }) => css`
|
|
25
|
+
width: 30px;
|
|
26
|
+
height: 30px;
|
|
27
|
+
display: flex;
|
|
28
|
+
align-items: center;
|
|
29
|
+
justify-content: center;
|
|
30
|
+
border-radius: 4px;
|
|
31
|
+
background-color: ${theme.colors.gray['300']};
|
|
32
|
+
box-shadow: -1px 0px 0px 0px ${color};
|
|
33
|
+
border-right: none;
|
|
34
|
+
border-top: none;
|
|
35
|
+
border-bottom: none;
|
|
36
|
+
cursor: pointer;
|
|
37
|
+
|
|
38
|
+
&:hover {
|
|
39
|
+
background-color: ${theme.colors.white};
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
&:disabled {
|
|
43
|
+
cursor: not-allowed;
|
|
44
|
+
border-left: 2px solid rgba(203, 203, 203, 1);
|
|
45
|
+
box-shadow: none;
|
|
46
|
+
|
|
47
|
+
&:hover {
|
|
48
|
+
background-color: ${theme.colors.gray['300']};
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.checkebox {
|
|
53
|
+
border: 1px solid red;
|
|
54
|
+
}
|
|
55
|
+
`}
|
|
56
|
+
`;
|
|
57
|
+
|
|
58
|
+
export const MenuDropDown = styled.div`
|
|
59
|
+
display: flex;
|
|
60
|
+
align-items: center;
|
|
61
|
+
justify-content: start;
|
|
62
|
+
gap: 5px;
|
|
63
|
+
`;
|
|
@@ -187,7 +187,11 @@ function BodyTable<T extends { id: string | number; children: Array<T> }>(
|
|
|
187
187
|
];
|
|
188
188
|
}
|
|
189
189
|
return (
|
|
190
|
-
<S.TabelaBody
|
|
190
|
+
<S.TabelaBody
|
|
191
|
+
color={color}
|
|
192
|
+
hasselect={hasSelect ? 'true' : 'false'}
|
|
193
|
+
// style={{ left: hasSelect ? '52px' : '17px' }}
|
|
194
|
+
>
|
|
191
195
|
{data.flatMap(item =>
|
|
192
196
|
renderRows(
|
|
193
197
|
item,
|
|
@@ -82,7 +82,7 @@ const HeaderTabela = <T,>({
|
|
|
82
82
|
{hasExpand && <></>}
|
|
83
83
|
{hasSelect && <></>}
|
|
84
84
|
{columns.map((header, index) => {
|
|
85
|
-
if (header.key === 'expand')
|
|
85
|
+
if (header.key === 'expand' || header.key === 'select')
|
|
86
86
|
return <th key={index} className="expand"></th>;
|
|
87
87
|
if (header.key !== 'acoes') {
|
|
88
88
|
return (
|
|
@@ -116,7 +116,7 @@ const HeaderTabela = <T,>({
|
|
|
116
116
|
value: 'ativo',
|
|
117
117
|
});
|
|
118
118
|
setGlobalFilter(String(e.currentTarget.checked));
|
|
119
|
-
setPagination({ pageIndex:
|
|
119
|
+
setPagination({ pageIndex: 1, pageSize: 10 });
|
|
120
120
|
}}
|
|
121
121
|
/>
|
|
122
122
|
) : (
|
|
@@ -128,7 +128,7 @@ const HeaderTabela = <T,>({
|
|
|
128
128
|
tipo="table"
|
|
129
129
|
placeholder={`Pesquisar por: ${header.header}`}
|
|
130
130
|
onChange={e => {
|
|
131
|
-
setPagination({ pageIndex:
|
|
131
|
+
setPagination({ pageIndex: 1, pageSize: 10 });
|
|
132
132
|
setFiltrosPor({
|
|
133
133
|
label: header.header,
|
|
134
134
|
value:
|
|
@@ -14,6 +14,7 @@ export type Column<T> = {
|
|
|
14
14
|
render?: (value: T) => React.ReactNode;
|
|
15
15
|
cell?: (row: T) => React.ReactNode;
|
|
16
16
|
expand?: (item: T) => React.ReactNode;
|
|
17
|
+
active: boolean;
|
|
17
18
|
};
|
|
18
19
|
|
|
19
20
|
export type SelectDataProps = {
|
|
@@ -94,9 +95,24 @@ const Tabela = <T extends { id: string | number; children: Array<T> }>({
|
|
|
94
95
|
}: CustomTableProps<T>) => {
|
|
95
96
|
const [toogleFiltros, setToogleFiltros] = useState(false);
|
|
96
97
|
|
|
98
|
+
const [formatedColumns, setFormatedColumns] = useState(
|
|
99
|
+
columns.map(column => {
|
|
100
|
+
return {
|
|
101
|
+
...column,
|
|
102
|
+
active: true,
|
|
103
|
+
};
|
|
104
|
+
})
|
|
105
|
+
);
|
|
106
|
+
|
|
107
|
+
const columnsToShow = formatedColumns.filter(
|
|
108
|
+
column => column.active === true
|
|
109
|
+
);
|
|
110
|
+
|
|
97
111
|
return (
|
|
98
112
|
<S.TableWrapper>
|
|
99
113
|
<TabelaHeader
|
|
114
|
+
setFormatedColumns={setFormatedColumns}
|
|
115
|
+
columns={formatedColumns}
|
|
100
116
|
handleAdicionar={handleAdicionar}
|
|
101
117
|
globalFilter={globalFilter}
|
|
102
118
|
setGlobalFilter={setGlobalFilter}
|
|
@@ -125,12 +141,12 @@ const Tabela = <T extends { id: string | number; children: Array<T> }>({
|
|
|
125
141
|
setSimples={setSimples}
|
|
126
142
|
color={color}
|
|
127
143
|
hasSelect={hasSelect}
|
|
128
|
-
columns={
|
|
144
|
+
columns={columnsToShow}
|
|
129
145
|
fixedPosition={fixedPosition!}
|
|
130
146
|
/>
|
|
131
147
|
)}
|
|
132
148
|
{isLoading ? (
|
|
133
|
-
<SkeletonTable columns={
|
|
149
|
+
<SkeletonTable columns={columnsToShow} data={data} />
|
|
134
150
|
) : (
|
|
135
151
|
<>
|
|
136
152
|
{data?.length === 0 ? (
|
|
@@ -145,7 +161,7 @@ const Tabela = <T extends { id: string | number; children: Array<T> }>({
|
|
|
145
161
|
setRowSelection={setRowSelection}
|
|
146
162
|
acoesChildren={acoesChildren}
|
|
147
163
|
data={data}
|
|
148
|
-
columns={
|
|
164
|
+
columns={columnsToShow}
|
|
149
165
|
/>
|
|
150
166
|
)}
|
|
151
167
|
</>
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import styled, { css } from 'styled-components'
|
|
2
|
-
import { Pagination } from '@mantine/core'
|
|
1
|
+
import styled, { css } from 'styled-components';
|
|
2
|
+
import { Pagination } from '@mantine/core';
|
|
3
3
|
|
|
4
4
|
type ColorsProp = {
|
|
5
|
-
color?: string
|
|
6
|
-
headerSelection?: Array<String
|
|
7
|
-
hasselect?: string
|
|
8
|
-
tdMinWidth?: string
|
|
9
|
-
}
|
|
5
|
+
color?: string;
|
|
6
|
+
headerSelection?: Array<String>;
|
|
7
|
+
hasselect?: string;
|
|
8
|
+
tdMinWidth?: string;
|
|
9
|
+
};
|
|
10
10
|
|
|
11
11
|
export const TableWrapper = styled.div`
|
|
12
12
|
${() => css`
|
|
13
13
|
max-width: 1500px;
|
|
14
14
|
overflow-x: hidden;
|
|
15
15
|
`}
|
|
16
|
-
|
|
16
|
+
`;
|
|
17
17
|
|
|
18
18
|
export const TableContainer = styled.div`
|
|
19
19
|
overflow-x: auto;
|
|
@@ -21,7 +21,7 @@ export const TableContainer = styled.div`
|
|
|
21
21
|
font-family: 'Open Sans', sans-serif;
|
|
22
22
|
max-width: 1500px;
|
|
23
23
|
width: 100%;
|
|
24
|
-
|
|
24
|
+
`;
|
|
25
25
|
|
|
26
26
|
export const StyledTable = styled.table`
|
|
27
27
|
${({ theme }) => css`
|
|
@@ -52,7 +52,7 @@ export const StyledTable = styled.table`
|
|
|
52
52
|
padding: 0;
|
|
53
53
|
}
|
|
54
54
|
`}
|
|
55
|
-
|
|
55
|
+
`;
|
|
56
56
|
|
|
57
57
|
export const TabelaHeader = styled.thead<ColorsProp>`
|
|
58
58
|
${({ theme, color }) => css`
|
|
@@ -90,7 +90,7 @@ export const TabelaHeader = styled.thead<ColorsProp>`
|
|
|
90
90
|
min-width: 50px;
|
|
91
91
|
}
|
|
92
92
|
`}
|
|
93
|
-
|
|
93
|
+
`;
|
|
94
94
|
|
|
95
95
|
export const TabelaBody = styled.tbody<ColorsProp>`
|
|
96
96
|
${({ theme, color, hasselect }) => css`
|
|
@@ -98,13 +98,15 @@ export const TabelaBody = styled.tbody<ColorsProp>`
|
|
|
98
98
|
width: 100%;
|
|
99
99
|
|
|
100
100
|
.select {
|
|
101
|
-
position: fixed;
|
|
102
101
|
background-color: ${color};
|
|
102
|
+
position: absolute;
|
|
103
|
+
left: 17px;
|
|
103
104
|
}
|
|
104
105
|
|
|
105
106
|
.expand {
|
|
107
|
+
position: absolute;
|
|
106
108
|
width: 50px;
|
|
107
|
-
left: ${hasselect === 'true' ? '
|
|
109
|
+
left: ${hasselect === 'true' ? '53px' : '17px'};
|
|
108
110
|
background-color: ${color};
|
|
109
111
|
display: flex;
|
|
110
112
|
align-items: center;
|
|
@@ -142,12 +144,12 @@ export const TabelaBody = styled.tbody<ColorsProp>`
|
|
|
142
144
|
}
|
|
143
145
|
|
|
144
146
|
.sticky {
|
|
145
|
-
background-color
|
|
147
|
+
background-color: ;
|
|
146
148
|
color: ${theme.colors.white};
|
|
147
149
|
font-weight: bold;
|
|
148
150
|
}
|
|
149
151
|
`}
|
|
150
|
-
|
|
152
|
+
`;
|
|
151
153
|
|
|
152
154
|
export const TabelaSemDados = styled.div<ColorsProp>`
|
|
153
155
|
${({ color, theme }) => css`
|
|
@@ -165,7 +167,7 @@ export const TabelaSemDados = styled.div<ColorsProp>`
|
|
|
165
167
|
color: ${color};
|
|
166
168
|
}
|
|
167
169
|
`}
|
|
168
|
-
|
|
170
|
+
`;
|
|
169
171
|
|
|
170
172
|
export const PaginacaoWrapper = styled.div<ColorsProp>`
|
|
171
173
|
${({ theme, color }) => css`
|
|
@@ -187,7 +189,7 @@ export const PaginacaoWrapper = styled.div<ColorsProp>`
|
|
|
187
189
|
margin-left: 15px;
|
|
188
190
|
}
|
|
189
191
|
`}
|
|
190
|
-
|
|
192
|
+
`;
|
|
191
193
|
|
|
192
194
|
export const PaginationMantine = styled(Pagination)`
|
|
193
195
|
${({ theme }) => css`
|
|
@@ -203,7 +205,7 @@ export const PaginationMantine = styled(Pagination)`
|
|
|
203
205
|
}
|
|
204
206
|
}
|
|
205
207
|
`}
|
|
206
|
-
|
|
208
|
+
`;
|
|
207
209
|
|
|
208
210
|
export const PaginationButtons = styled.div<ColorsProp>`
|
|
209
211
|
${({ theme, color }) => css`
|
|
@@ -223,4 +225,4 @@ export const PaginationButtons = styled.div<ColorsProp>`
|
|
|
223
225
|
padding: 0 15px;
|
|
224
226
|
}
|
|
225
227
|
`}
|
|
226
|
-
|
|
228
|
+
`;
|