wca-designsystem 0.0.21 → 0.0.23
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 +12 -6
- package/src/components/atomos/BadgeModulos/Badge.test.tsx +12 -0
- package/src/components/atomos/BadgeModulos/BadgeModulos.stories.tsx +21 -0
- package/src/components/atomos/BadgeModulos/index.tsx +33 -0
- package/src/components/atomos/BadgeModulos/styles.ts +16 -0
- package/src/components/atomos/Botao/Botao.test.tsx +3 -6
- package/src/components/atomos/Botao/index.tsx +6 -0
- package/src/components/atomos/Botao/styles.ts +12 -12
- package/src/components/atomos/IconeBotao/index.tsx +8 -3
- package/src/components/atomos/IconeBotao/styles.ts +10 -6
- package/src/components/atomos/InputDeData/InputDeData.stories.tsx +16 -0
- package/src/components/atomos/InputDeData/InputDeData.test.tsx +12 -0
- package/src/components/atomos/InputDeData/index.tsx +26 -0
- package/src/components/atomos/InputDeData/styles.ts +16 -0
- package/src/components/atomos/InputDeTexto/InputDeTexto.stories.tsx +2 -0
- package/src/components/atomos/InputDeTexto/index.tsx +7 -4
- package/src/components/atomos/InputDeTexto/styles.ts +15 -8
- package/src/components/atomos/LinkNavbar/index.tsx +4 -2
- package/src/components/atomos/MultiSelect/MultiSelect.stories.tsx +14 -0
- package/src/components/atomos/MultiSelect/MultiSelect.test.tsx +14 -0
- package/src/components/atomos/MultiSelect/index.tsx +33 -0
- package/src/components/atomos/MultiSelect/styles.ts +14 -0
- package/src/components/atomos/NavbarTituloHeader/styles.ts +1 -0
- package/src/components/modules/Cabecalho/index.tsx +7 -2
- package/src/components/modules/Cabecalho/styles.ts +10 -6
- package/src/components/modules/ConchaAplicacao/index.tsx +5 -2
- package/src/components/modules/ConchaAplicacao/styles.ts +8 -4
- package/src/components/modules/Navbar/index.tsx +6 -5
- package/src/components/modules/Navbar/styles.ts +13 -12
- package/src/components/molecules/CardInicial/CardInicial.stories.tsx +1 -0
- package/src/components/molecules/Modal/Modal.stories.tsx +31 -0
- package/src/components/molecules/Modal/Modal.test.tsx +22 -0
- package/src/components/molecules/Modal/index.tsx +46 -0
- package/src/components/molecules/Modal/styles.ts +34 -0
- package/src/components/organismos/Calendario/Calendario.modal.tsx +75 -0
- package/src/components/organismos/Calendario/Calendario.stories.tsx +29 -0
- package/src/components/organismos/Calendario/index.tsx +111 -0
- package/src/components/organismos/Calendario/styles.ts +128 -0
- package/src/components/organismos/Tabela/Tabela.stories.tsx +1 -1
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
import styled, { css } from
|
|
1
|
+
import styled, { css } from 'styled-components';
|
|
2
|
+
|
|
3
|
+
type CabecalhoProps = {
|
|
4
|
+
color?: string;
|
|
5
|
+
};
|
|
2
6
|
|
|
3
7
|
export const CabecalhoContainer = styled.header`
|
|
4
8
|
display: flex;
|
|
@@ -10,8 +14,8 @@ export const CabecalhoContainer = styled.header`
|
|
|
10
14
|
position: relative;
|
|
11
15
|
`;
|
|
12
16
|
|
|
13
|
-
export const CabecalhoInfoWrapper = styled.div
|
|
14
|
-
${({ theme }) => css`
|
|
17
|
+
export const CabecalhoInfoWrapper = styled.div<CabecalhoProps>`
|
|
18
|
+
${({ theme, color }) => css`
|
|
15
19
|
display: block;
|
|
16
20
|
|
|
17
21
|
@media (min-width: ${theme.responsive.md}) {
|
|
@@ -28,7 +32,7 @@ export const CabecalhoInfoWrapper = styled.div`
|
|
|
28
32
|
align-items: center;
|
|
29
33
|
justify-content: center;
|
|
30
34
|
border-radius: 8px;
|
|
31
|
-
background-color: ${
|
|
35
|
+
background-color: ${color};
|
|
32
36
|
}
|
|
33
37
|
|
|
34
38
|
.info-wrapper {
|
|
@@ -36,7 +40,7 @@ export const CabecalhoInfoWrapper = styled.div`
|
|
|
36
40
|
|
|
37
41
|
h1 {
|
|
38
42
|
font-size: ${theme.sizes.large};
|
|
39
|
-
color: ${
|
|
43
|
+
color: ${color};
|
|
40
44
|
margin: 15px 0;
|
|
41
45
|
|
|
42
46
|
@media (min-width: ${theme.responsive.md}) {
|
|
@@ -61,7 +65,7 @@ export const CabecalhoInfoWrapper = styled.div`
|
|
|
61
65
|
display: flex;
|
|
62
66
|
align-items: center;
|
|
63
67
|
justify-content: center;
|
|
64
|
-
background-color: ${theme.colors.gray[
|
|
68
|
+
background-color: ${theme.colors.gray['500']};
|
|
65
69
|
border-radius: 8px;
|
|
66
70
|
}
|
|
67
71
|
`}
|
|
@@ -6,6 +6,7 @@ import Cabecalho from '../Cabecalho';
|
|
|
6
6
|
import { useLocation } from 'react-router-dom';
|
|
7
7
|
import { NotificationsProps } from '../../atomos/UsuarioNotification';
|
|
8
8
|
import { LinksProps } from '../../molecules/GrupoDeLinks';
|
|
9
|
+
import { theme } from '../../../styles/theme';
|
|
9
10
|
|
|
10
11
|
type ConchaAplicacaolType = {
|
|
11
12
|
children: React.ReactNode;
|
|
@@ -17,6 +18,7 @@ type ConchaAplicacaolType = {
|
|
|
17
18
|
temNotificacoes?: boolean;
|
|
18
19
|
sairFunc: () => void;
|
|
19
20
|
activeLink: string;
|
|
21
|
+
color?: string;
|
|
20
22
|
};
|
|
21
23
|
export function ConchaAplicacao({
|
|
22
24
|
children,
|
|
@@ -25,6 +27,7 @@ export function ConchaAplicacao({
|
|
|
25
27
|
isNavHover,
|
|
26
28
|
sairFunc,
|
|
27
29
|
activeLink,
|
|
30
|
+
color = theme.colors.blue,
|
|
28
31
|
notificacoes,
|
|
29
32
|
links,
|
|
30
33
|
navbarRef,
|
|
@@ -43,7 +46,7 @@ export function ConchaAplicacao({
|
|
|
43
46
|
transitionTimingFunction="ease-in"
|
|
44
47
|
transitionDuration={3}
|
|
45
48
|
>
|
|
46
|
-
<S.
|
|
49
|
+
<S.NavbarWrapper color={color} ref={navbarRef} data-active={isNavHover}>
|
|
47
50
|
<Navbar
|
|
48
51
|
sairFunc={sairFunc}
|
|
49
52
|
activeLink={activeLink}
|
|
@@ -51,7 +54,7 @@ export function ConchaAplicacao({
|
|
|
51
54
|
isHover={isNavHover}
|
|
52
55
|
links={links}
|
|
53
56
|
/>
|
|
54
|
-
</S.
|
|
57
|
+
</S.NavbarWrapper>
|
|
55
58
|
<S.ConchaAplicacaoMainWrapper>
|
|
56
59
|
<Container fluid>
|
|
57
60
|
{paginaAtual.length > 0 && (
|
|
@@ -2,6 +2,10 @@ import { AppShell } from '@mantine/core';
|
|
|
2
2
|
import styled, { css } from 'styled-components';
|
|
3
3
|
import fundo from '../../../assets/imagens/novos-icones/STI_iconePreto.svg';
|
|
4
4
|
|
|
5
|
+
type ConchaAplicacaoProps = {
|
|
6
|
+
color?: string;
|
|
7
|
+
};
|
|
8
|
+
|
|
5
9
|
export const ConchaAplicacaoWrapper = styled(AppShell)`
|
|
6
10
|
${() => css`
|
|
7
11
|
background-image: url(${fundo});
|
|
@@ -12,12 +16,12 @@ export const ConchaAplicacaoWrapper = styled(AppShell)`
|
|
|
12
16
|
`}
|
|
13
17
|
`;
|
|
14
18
|
|
|
15
|
-
export const
|
|
16
|
-
${({
|
|
17
|
-
transition: all 0.
|
|
19
|
+
export const NavbarWrapper = styled(AppShell.Navbar)<ConchaAplicacaoProps>`
|
|
20
|
+
${({ color }) => css`
|
|
21
|
+
transition: all 0.5s; /* Transição suave de 0.1 segundos */
|
|
18
22
|
|
|
19
23
|
&[data-active='true'] {
|
|
20
|
-
border-right: 5px solid ${
|
|
24
|
+
border-right: 5px solid ${color};
|
|
21
25
|
}
|
|
22
26
|
`}
|
|
23
27
|
`;
|
|
@@ -11,7 +11,6 @@ import CiclosEncerrados from '../../../assets/imagens/icons/CiclosEncerrados.svg
|
|
|
11
11
|
import Logo from '../../../assets/imagens/novos-icones/STI_nomeCor.svg';
|
|
12
12
|
import LogoInitial from '../../../assets/imagens/novos-icones/STI_iconeBranco.svg';
|
|
13
13
|
import { useMemo } from 'react';
|
|
14
|
-
import { FadingComponent } from '../../atomos/FadeAnimacao';
|
|
15
14
|
import AjudaIcone from '../../atomos/AjudaIcone';
|
|
16
15
|
|
|
17
16
|
export type NavbarType = {
|
|
@@ -20,6 +19,7 @@ export type NavbarType = {
|
|
|
20
19
|
links?: LinksProps[];
|
|
21
20
|
activeLink: string;
|
|
22
21
|
sairFunc: () => void;
|
|
22
|
+
color?: string;
|
|
23
23
|
};
|
|
24
24
|
const Navbar = ({
|
|
25
25
|
isHover,
|
|
@@ -27,6 +27,7 @@ const Navbar = ({
|
|
|
27
27
|
links,
|
|
28
28
|
modulo,
|
|
29
29
|
activeLink,
|
|
30
|
+
color = theme.colors.blue,
|
|
30
31
|
}: NavbarType) => {
|
|
31
32
|
const LogoHeader = useMemo(() => (isHover ? Logo : LogoInitial), [isHover]);
|
|
32
33
|
|
|
@@ -34,7 +35,7 @@ const Navbar = ({
|
|
|
34
35
|
<S.NavbarWrapper
|
|
35
36
|
data-testid="navbar"
|
|
36
37
|
data-active={isHover}
|
|
37
|
-
color={isHover ? theme.colors.white :
|
|
38
|
+
color={isHover ? theme.colors.white : color}
|
|
38
39
|
>
|
|
39
40
|
<S.NavbarHeader className={isHover ? 'nav-hover' : ''}>
|
|
40
41
|
<Icone
|
|
@@ -63,8 +64,8 @@ const Navbar = ({
|
|
|
63
64
|
</IconeBotao>
|
|
64
65
|
</S.NavbarHeader>
|
|
65
66
|
|
|
66
|
-
|
|
67
|
-
<S.NabarBody>
|
|
67
|
+
<>
|
|
68
|
+
<S.NabarBody color={color}>
|
|
68
69
|
<NavbarTituloHeader
|
|
69
70
|
isNavHover={isHover}
|
|
70
71
|
modulo={modulo}
|
|
@@ -76,7 +77,7 @@ const Navbar = ({
|
|
|
76
77
|
isNavHover={isHover}
|
|
77
78
|
/>
|
|
78
79
|
</S.NabarBody>
|
|
79
|
-
|
|
80
|
+
</>
|
|
80
81
|
|
|
81
82
|
<S.NavbarFooter
|
|
82
83
|
data-active={isHover}
|
|
@@ -1,22 +1,24 @@
|
|
|
1
|
-
import styled, { css } from
|
|
1
|
+
import styled, { css } from 'styled-components';
|
|
2
2
|
|
|
3
3
|
type NavbarWrapperProps = {
|
|
4
|
-
color
|
|
4
|
+
color?: string;
|
|
5
5
|
};
|
|
6
6
|
|
|
7
7
|
export const NavbarWrapper = styled.div<NavbarWrapperProps>`
|
|
8
|
-
${({
|
|
8
|
+
${({ color }) => css`
|
|
9
9
|
padding: 0;
|
|
10
10
|
text-align: center;
|
|
11
11
|
background-color: ${color};
|
|
12
12
|
box-shadow: 8px 0px 11px -7px rgba(0, 0, 0, 0.5);
|
|
13
13
|
height: 100vh;
|
|
14
|
+
overflow-y: auto;
|
|
15
|
+
overflow-x: hidden;
|
|
14
16
|
|
|
15
17
|
.logo {
|
|
16
18
|
margin: 30px 0;
|
|
17
19
|
|
|
18
|
-
&[data-active=
|
|
19
|
-
border-right: 5px solid ${
|
|
20
|
+
&[data-active='true'] {
|
|
21
|
+
border-right: 5px solid ${color};
|
|
20
22
|
}
|
|
21
23
|
}
|
|
22
24
|
`}
|
|
@@ -36,10 +38,10 @@ export const NavbarHeader = styled.div`
|
|
|
36
38
|
`}
|
|
37
39
|
`;
|
|
38
40
|
|
|
39
|
-
export const NabarBody = styled.div
|
|
40
|
-
${({ theme }) => css`
|
|
41
|
+
export const NabarBody = styled.div<NavbarWrapperProps>`
|
|
42
|
+
${({ theme, color }) => css`
|
|
41
43
|
.selected {
|
|
42
|
-
background-color: ${
|
|
44
|
+
background-color: ${color};
|
|
43
45
|
|
|
44
46
|
p {
|
|
45
47
|
color: ${theme.colors.white};
|
|
@@ -56,9 +58,8 @@ export const NabarBody = styled.div`
|
|
|
56
58
|
export const NavbarFooter = styled.div`
|
|
57
59
|
${({ theme }) => css`
|
|
58
60
|
text-align: center;
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
color: ${theme.colors.gray["700"]};
|
|
61
|
+
margin: 90% 0 15px 0;
|
|
62
|
+
|
|
63
|
+
color: ${theme.colors.gray['700']};
|
|
63
64
|
`}
|
|
64
65
|
`;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import ModalCustom, { ModalProps } from './index';
|
|
3
|
+
import { Meta } from '@storybook/react';
|
|
4
|
+
import { theme } from '../../../styles/theme';
|
|
5
|
+
|
|
6
|
+
export default {
|
|
7
|
+
title: 'Components/moleculas/ModalCustom',
|
|
8
|
+
component: ModalCustom,
|
|
9
|
+
} as Meta;
|
|
10
|
+
|
|
11
|
+
const props: ModalProps = {
|
|
12
|
+
children: <p>Exemplo</p>,
|
|
13
|
+
close: () => console.log('aqui'),
|
|
14
|
+
modalTitle: 'exemplo',
|
|
15
|
+
open: true,
|
|
16
|
+
color: theme.colors.blue,
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const Template: any = (args: ModalProps) => (
|
|
20
|
+
<>
|
|
21
|
+
<ModalCustom {...args} />
|
|
22
|
+
</>
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
export const ModalInitialProps = Template.bind({
|
|
26
|
+
...props,
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
ModalInitialProps.args = {
|
|
30
|
+
...props,
|
|
31
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import ModalCustom, { ModalProps } from '.';
|
|
3
|
+
import { theme } from '../../../styles/theme';
|
|
4
|
+
import { render } from '../../../test/render';
|
|
5
|
+
|
|
6
|
+
describe('ModalCustom', () => {
|
|
7
|
+
const props: ModalProps = {
|
|
8
|
+
children: <p>Exemplo</p>,
|
|
9
|
+
close: () => console.log('aqui'),
|
|
10
|
+
modalTitle: 'exemplo',
|
|
11
|
+
open: true,
|
|
12
|
+
color: theme.colors.blue,
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
it('Renderiza corretamente', () => {
|
|
16
|
+
const { getByText } = render(<ModalCustom {...props} />);
|
|
17
|
+
|
|
18
|
+
const descricao = getByText('exemplo');
|
|
19
|
+
|
|
20
|
+
expect(descricao).toBeDefined();
|
|
21
|
+
});
|
|
22
|
+
});
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { MantineSize, Modal } from '@mantine/core';
|
|
3
|
+
import * as S from './styles';
|
|
4
|
+
|
|
5
|
+
export type ModalProps = {
|
|
6
|
+
open: boolean;
|
|
7
|
+
close: () => void;
|
|
8
|
+
children: React.ReactNode;
|
|
9
|
+
modalTitle: string;
|
|
10
|
+
color?: string;
|
|
11
|
+
size?: number | MantineSize | (string & {}) | undefined;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
const ModalCustom = ({
|
|
15
|
+
close,
|
|
16
|
+
color,
|
|
17
|
+
open,
|
|
18
|
+
children,
|
|
19
|
+
modalTitle,
|
|
20
|
+
size,
|
|
21
|
+
}: ModalProps) => {
|
|
22
|
+
return (
|
|
23
|
+
<Modal.Root
|
|
24
|
+
opened={open}
|
|
25
|
+
onClose={close}
|
|
26
|
+
size={size}
|
|
27
|
+
centered
|
|
28
|
+
transitionProps={{
|
|
29
|
+
transition: 'fade',
|
|
30
|
+
duration: 300,
|
|
31
|
+
timingFunction: 'linear',
|
|
32
|
+
}}
|
|
33
|
+
>
|
|
34
|
+
<Modal.Overlay />
|
|
35
|
+
<Modal.Content>
|
|
36
|
+
<S.ModalHeader color={color}>
|
|
37
|
+
<S.ModalTitle color={color}>{modalTitle}</S.ModalTitle>
|
|
38
|
+
<S.ModalCloseButton iconSize={30} />
|
|
39
|
+
</S.ModalHeader>
|
|
40
|
+
<Modal.Body>{children}</Modal.Body>
|
|
41
|
+
</Modal.Content>
|
|
42
|
+
</Modal.Root>
|
|
43
|
+
);
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
export default ModalCustom;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { Modal } from '@mantine/core';
|
|
2
|
+
import styled, { css } from 'styled-components';
|
|
3
|
+
import { theme } from '../../../styles/theme';
|
|
4
|
+
|
|
5
|
+
type ModalProps = {
|
|
6
|
+
color?: string;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export const ModalHeader = styled(Modal.Header)<ModalProps>`
|
|
10
|
+
${({ color }) => css`
|
|
11
|
+
background-color: ${color};
|
|
12
|
+
`}
|
|
13
|
+
`;
|
|
14
|
+
export const ModalTitle = styled(Modal.Title)`
|
|
15
|
+
${() => css`
|
|
16
|
+
color: ${theme.colors.white};
|
|
17
|
+
font-weight: bold;
|
|
18
|
+
`}
|
|
19
|
+
`;
|
|
20
|
+
export const ModalCloseButton = styled(Modal.CloseButton)<ModalProps>`
|
|
21
|
+
${({ color }) => css`
|
|
22
|
+
color: ${theme.colors.white};
|
|
23
|
+
font-weight: bold;
|
|
24
|
+
|
|
25
|
+
&:hover {
|
|
26
|
+
background-color: ${color};
|
|
27
|
+
opacity: 0.8;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
svg {
|
|
31
|
+
width: ${theme.sizes.xLarge};
|
|
32
|
+
}
|
|
33
|
+
`}
|
|
34
|
+
`;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import * as S from './styles';
|
|
3
|
+
import SelectCustomizado from '../../atomos/Select';
|
|
4
|
+
import InputDeData from '../../atomos/InputDeData';
|
|
5
|
+
import Botao from '../../atomos/Botao';
|
|
6
|
+
import { useForm } from '@mantine/form';
|
|
7
|
+
import { ComboboxData } from '@mantine/core';
|
|
8
|
+
|
|
9
|
+
type CalendarioModalProps = {
|
|
10
|
+
color?: string;
|
|
11
|
+
confirm: (form: any) => void;
|
|
12
|
+
perfilOptions: ComboboxData | undefined;
|
|
13
|
+
hierarquiaOptions: ComboboxData | undefined;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const CalendarioModal = ({
|
|
17
|
+
color,
|
|
18
|
+
confirm,
|
|
19
|
+
perfilOptions,
|
|
20
|
+
hierarquiaOptions,
|
|
21
|
+
}: CalendarioModalProps) => {
|
|
22
|
+
const form = useForm({
|
|
23
|
+
mode: 'controlled',
|
|
24
|
+
initialValues: {
|
|
25
|
+
hierarquia: '',
|
|
26
|
+
perfil: '',
|
|
27
|
+
dataInicial: new Date(),
|
|
28
|
+
dataFinal: '',
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
return (
|
|
33
|
+
<S.CalendarioModalWrapper color={color}>
|
|
34
|
+
<h2>Adicionar Agenda</h2>
|
|
35
|
+
<p>
|
|
36
|
+
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod
|
|
37
|
+
tempor incididunt ut labore et dolore magna aliqua.
|
|
38
|
+
</p>
|
|
39
|
+
<S.CalendarioModalInputs>
|
|
40
|
+
<SelectCustomizado
|
|
41
|
+
tipo="round"
|
|
42
|
+
placeholder="Selecione uma opção"
|
|
43
|
+
labelAbaixo="Hierarquia"
|
|
44
|
+
data={hierarquiaOptions}
|
|
45
|
+
{...form.getInputProps('hierarquia')}
|
|
46
|
+
/>
|
|
47
|
+
<SelectCustomizado
|
|
48
|
+
tipo="round"
|
|
49
|
+
placeholder="Selecione uma opção"
|
|
50
|
+
labelAbaixo="Perfil"
|
|
51
|
+
data={perfilOptions}
|
|
52
|
+
{...form.getInputProps('perfil')}
|
|
53
|
+
/>
|
|
54
|
+
<InputDeData
|
|
55
|
+
labelAbaixo="data inicial"
|
|
56
|
+
{...form.getInputProps('dataInicial')}
|
|
57
|
+
/>
|
|
58
|
+
<InputDeData
|
|
59
|
+
labelAbaixo="data final"
|
|
60
|
+
{...form.getInputProps('dataFinal')}
|
|
61
|
+
/>
|
|
62
|
+
|
|
63
|
+
<Botao
|
|
64
|
+
tipo="default"
|
|
65
|
+
color={color}
|
|
66
|
+
onClick={() => confirm(form.values)}
|
|
67
|
+
>
|
|
68
|
+
CONFIRMAR
|
|
69
|
+
</Botao>
|
|
70
|
+
</S.CalendarioModalInputs>
|
|
71
|
+
</S.CalendarioModalWrapper>
|
|
72
|
+
);
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
export default CalendarioModal;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Meta } from '@storybook/react';
|
|
3
|
+
import Calendario from './index';
|
|
4
|
+
import { theme } from '../../../styles/theme';
|
|
5
|
+
|
|
6
|
+
export default {
|
|
7
|
+
title: 'Components/organismos/Calendario',
|
|
8
|
+
component: Calendario,
|
|
9
|
+
} as Meta;
|
|
10
|
+
|
|
11
|
+
const events = [
|
|
12
|
+
{ title: 'Meeting', start: new Date(), end: new Date('2024-09-29') },
|
|
13
|
+
];
|
|
14
|
+
|
|
15
|
+
const Template: any = (args: any) => (
|
|
16
|
+
<>
|
|
17
|
+
<Calendario {...args} />
|
|
18
|
+
</>
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
export const CardDestaqueStory = Template.bind({});
|
|
22
|
+
|
|
23
|
+
CardDestaqueStory.args = {
|
|
24
|
+
events: events,
|
|
25
|
+
perfilOptions: [{ label: 'exemplo', value: 'exemplo' }],
|
|
26
|
+
hierarquiaOptions: [{ label: 'exemplo', value: 'exemplo' }],
|
|
27
|
+
color: theme.colors.magentaSec,
|
|
28
|
+
confirm: (form: any) => console.log(form),
|
|
29
|
+
};
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import React, { useCallback, useRef, useState } from 'react';
|
|
2
|
+
import FullCalendar from '@fullcalendar/react';
|
|
3
|
+
import dayGridPlugin from '@fullcalendar/daygrid';
|
|
4
|
+
import timeGridPlugin from '@fullcalendar/timegrid';
|
|
5
|
+
import interactionPlugin from '@fullcalendar/interaction';
|
|
6
|
+
import {
|
|
7
|
+
CalendarApi,
|
|
8
|
+
EventContentArg,
|
|
9
|
+
EventSourceInput,
|
|
10
|
+
} from '@fullcalendar/core';
|
|
11
|
+
import * as S from './styles';
|
|
12
|
+
import ptBrLocale from '@fullcalendar/core/locales/pt-br';
|
|
13
|
+
import SelectCustomizado from '../../atomos/Select';
|
|
14
|
+
import Botao from '../../atomos/Botao';
|
|
15
|
+
import CalendarioModal from './Calendario.modal';
|
|
16
|
+
import { ComboboxData } from '@mantine/core';
|
|
17
|
+
|
|
18
|
+
interface CalendarioProps extends FullCalendar {
|
|
19
|
+
events: EventSourceInput | undefined;
|
|
20
|
+
confirm: (form: any) => void;
|
|
21
|
+
liberar: () => void;
|
|
22
|
+
perfilOptions: ComboboxData | undefined;
|
|
23
|
+
hierarquiaOptions: ComboboxData | undefined;
|
|
24
|
+
color?: string;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/* const events = [
|
|
28
|
+
{ title: 'Meeting', start: new Date(), end: new Date('2024-09-29') },
|
|
29
|
+
]; */
|
|
30
|
+
// a custom render function
|
|
31
|
+
function renderEventContent(eventInfo: EventContentArg) {
|
|
32
|
+
return (
|
|
33
|
+
<S.EventosWrapper>
|
|
34
|
+
<p>
|
|
35
|
+
{eventInfo.timeText} | {eventInfo.event.title}
|
|
36
|
+
</p>
|
|
37
|
+
</S.EventosWrapper>
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
const Calendario = ({
|
|
41
|
+
events,
|
|
42
|
+
confirm,
|
|
43
|
+
color,
|
|
44
|
+
liberar,
|
|
45
|
+
hierarquiaOptions,
|
|
46
|
+
perfilOptions,
|
|
47
|
+
...props
|
|
48
|
+
}: CalendarioProps) => {
|
|
49
|
+
const calendarRef = useRef<CalendarApi | null>(null);
|
|
50
|
+
const [adicionar, setAdicionar] = useState(false);
|
|
51
|
+
|
|
52
|
+
const handleViewChange = useCallback((view: string) => {
|
|
53
|
+
if (calendarRef.current) {
|
|
54
|
+
calendarRef.current.changeView(view);
|
|
55
|
+
}
|
|
56
|
+
}, []);
|
|
57
|
+
|
|
58
|
+
return (
|
|
59
|
+
<S.CalendarioWrapper color={color}>
|
|
60
|
+
<S.CalendarioHeaderButtons>
|
|
61
|
+
<Botao
|
|
62
|
+
onClick={() => setAdicionar(!adicionar)}
|
|
63
|
+
tipo="default"
|
|
64
|
+
color={color}
|
|
65
|
+
>
|
|
66
|
+
ADICIONAR
|
|
67
|
+
</Botao>
|
|
68
|
+
<Botao color={color} tipo="default" onClick={liberar}>
|
|
69
|
+
LIBERAR CRÍTICA
|
|
70
|
+
</Botao>
|
|
71
|
+
</S.CalendarioHeaderButtons>
|
|
72
|
+
{adicionar && (
|
|
73
|
+
<CalendarioModal
|
|
74
|
+
perfilOptions={perfilOptions}
|
|
75
|
+
hierarquiaOptions={hierarquiaOptions}
|
|
76
|
+
confirm={confirm}
|
|
77
|
+
color={color}
|
|
78
|
+
/>
|
|
79
|
+
)}
|
|
80
|
+
<S.CalendarioHeaderControl>
|
|
81
|
+
<SelectCustomizado
|
|
82
|
+
tipo="table"
|
|
83
|
+
placeholder={`Visualizar: por dia`}
|
|
84
|
+
data={[
|
|
85
|
+
{ label: 'Visualizar por mês', value: 'dayGridMonth' },
|
|
86
|
+
{ label: 'Visualizar por semana', value: 'timeGridWeek' },
|
|
87
|
+
{ label: 'Visualizar por dia', value: 'timeGridDay' },
|
|
88
|
+
]}
|
|
89
|
+
onChange={(e) => handleViewChange(e!)}
|
|
90
|
+
/>
|
|
91
|
+
</S.CalendarioHeaderControl>
|
|
92
|
+
<FullCalendar
|
|
93
|
+
ref={(element) => {
|
|
94
|
+
if (element) {
|
|
95
|
+
calendarRef.current = element.getApi(); // Armazena a API do calendário na ref
|
|
96
|
+
}
|
|
97
|
+
}}
|
|
98
|
+
plugins={[dayGridPlugin, timeGridPlugin, interactionPlugin]}
|
|
99
|
+
initialView={'dayGridMonth'}
|
|
100
|
+
locales={[ptBrLocale]}
|
|
101
|
+
locale="pt-br"
|
|
102
|
+
weekends={true}
|
|
103
|
+
events={events}
|
|
104
|
+
eventContent={renderEventContent}
|
|
105
|
+
{...props}
|
|
106
|
+
/>
|
|
107
|
+
</S.CalendarioWrapper>
|
|
108
|
+
);
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
export default Calendario;
|